Photon Server API Documentation
v5.0RC1
Represents a collection of server instances which can be accessed randomly based on their current lod level. More...
Public Member Functions | |
| LoadBalancer () | |
| Initializes a new instance of the LoadBalancer<TServer> class. Use default weights for each load level. More... | |
| LoadBalancer (string configFilePath) | |
| Initializes a new instance of the LoadBalancer<TServer> class. More... | |
| LoadBalancer (int[] loadLevelWeights) | |
| Initializes a new instance of the LoadBalancer<TServer> class. More... | |
| LoadBalancer (int[] loadLevelWeights, int seed, FeedbackLevel priorityUpThreshold=FeedbackLevel.Highest, FeedbackLevel priorityDownThreshold=FeedbackLevel.Highest) | |
| Initializes a new instance of the LoadBalancer<TServer> class. More... | |
| bool | TryAddServer (TServer server, FeedbackLevel loadLevel, byte priority=0) |
| Attempts to add a server instance. More... | |
| bool | TryGetServer (out TServer server) |
| Tries to get a free server instance. More... | |
| bool | TryGetServer (out TServer server, Func< TServer, bool > filter) |
| Tries to get a free server instance. More... | |
| bool | TryRemoveServer (TServer server, byte priority=0) |
| Tries to remove a server instance. More... | |
| bool | TryUpdateServer (TServer server, FeedbackLevel newLoadLevel, byte priority=0, ServerState state=ServerState.Normal) |
| Tries to update a server instance. More... | |
| IList< ServerStateData< TServer > > | GetServerStates () |
| Get states of all stored servers regardless of their status (online/offline/oor) More... | |
| void | DumpState () |
Properties | |
| FeedbackLevel | AverageWorkload [get] |
| Gets the average workload of all server instances. More... | |
| FeedbackLevel | AverageWorkloadForAvailableServers [get] |
| we use this property only for tests More... | |
| int | AverageWorkloadPercentage [get] |
| bool | HasAvailableServers [get] |
| int | TotalWorkload [get] |
| int | ServersInUseWeight [get] |
| int[] | LoadLevelWeights [get] |
| FeedbackLevel | PriorityDownThreshold [get, set] |
| FeedbackLevel | PriorityUpThreshold [get, set] |
| float | ReserveRatio [get, set] |
Events | |
| EventHandler | ServerListUpdated |
Represents a collection of server instances which can be accessed randomly based on their current lod level.
| TServer | The type of the server instances. |
Each server instance gets a weight assigned based on the current load level of that server. The TryGetServer method gets a random server based on this weight. A server with a higher weight will be returned more often than a server with a lower weight. The default values for this weights are the following:
LoadLevel.Lowest = 40 LoadLevel.Low = 30 LoadLevel.Normal = 20 LoadLevel.High = 10 LoadLevel.Highest = 0
If there is for example one server for eac load level, the server with load level lowest will be returned 50% of the times, the one with load level low 30% and so on.
| TServer | : | IComparable<TServer> |
|
inline |
Initializes a new instance of the LoadBalancer<TServer> class. Use default weights for each load level.
|
inline |
Initializes a new instance of the LoadBalancer<TServer> class.
| configFilePath | The full path (absolute or relative) to a config file that specifies a Weight for each LoadLevel. The possible load levels and their values are defined int the FeedbackLevel enumeration. See the LoadBalancing.config for an example. |
|
inline |
Initializes a new instance of the LoadBalancer<TServer> class.
| loadLevelWeights | A list of weights which should be used for each available load level. This list must contain a value for each available load level and must be ordered by the load levels value. The possible load levels and their values are defined int the FeedbackLevel enumeration. |
|
inline |
Initializes a new instance of the LoadBalancer<TServer> class.
This overload is used for unit testing to provide a fixed seed for the random number generator.
|
inline |
|
inline |
Get states of all stored servers regardless of their status (online/offline/oor)
|
inline |
Attempts to add a server instance.
| server | The server instance to add. |
| loadLevel | The current workload of the server instance. |
| priority | Priority of server |
|
inline |
Tries to get a free server instance.
| server | When this method returns, contains an available server instance or null if no available server instances exists. |
|
inline |
Tries to get a free server instance.
| server | When this method returns, contains the server instance with the fewest workload or null if no server instances exists. |
| loadLevel | When this method returns, contains an available server instance or null if no available server instances exists. |
|
inline |
Tries to remove a server instance.
| server | The server instance to remove. |
| priority | Server priority |
|
inline |
Tries to update a server instance.
| server | The server to update. |
| newLoadLevel | The current workload of the server instance. |
| priority | Server priority |
|
get |
Gets the average workload of all server instances.
|
get |
we use this property only for tests
|
get |
|
get |
|
get |
|
getset |
|
getset |
|
getset |
|
get |
|
get |
| EventHandler Photon.Common.LoadBalancer.LoadBalancer< TServer >.ServerListUpdated |