|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tranche.network.MultiServerRequestStrategy
public class MultiServerRequestStrategy
Say a client has a request for many servers. If pick any server (randomly or using a heuristic), you can create this object to determine:
A simple strategy: if want to see best server to which to send a request, calculate this for all online servers and select the strategy with the smallest depth.
Note that a server receiving a multi-server request will also build a MultiServerRequestStategy object, using its host as the parameter. That way, it will know how to partition the request amongst servers to which it is connected.
| Field Summary | |
|---|---|
static int |
INFINITE_DEPTH
Constant used for infinite depth--i.e., cannot solve. |
| Method Summary | |
|---|---|
static MultiServerRequestStrategy |
create(java.lang.String hostReceivingRequest,
java.util.Collection<java.lang.String> serverHostsToRequest)
Say a client has a request for many servers. |
boolean |
equals(java.lang.Object o)
|
boolean |
equivalent(MultiServerRequestStrategy other)
Test that strategy objects are similar. |
static java.util.Collection<MultiServerRequestStrategy> |
findFastestStrategiesUsingConnectedCoreServers(java.util.Collection<java.lang.String> serverHostsToRequest,
org.tranche.commons.Tertiary readable,
org.tranche.commons.Tertiary writable)
Finds set of strategies that have the smallest depth, which is a strong heuristic for speed. |
int |
getDepth()
If this request is sent to the server host listed, this is the 'depth' of the request across the network for the requested servers when modeled as a tree. |
java.lang.String |
getHostReceivingRequest()
The host name for the server to receive the request, per this strategy object. |
java.util.Map<java.lang.String,java.util.Set<java.lang.String>> |
getPartitionsMap()
This is a map containing the following: |
java.util.Set<java.lang.String> |
getUnfulfillableHosts()
All the hosts that are unfulfillable. |
int |
hashCode()
|
void |
printStrategy(java.io.PrintStream out)
|
boolean |
requestContains(java.lang.String host)
Returns true if request contains a particular host. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int INFINITE_DEPTH
Constant used for infinite depth--i.e., cannot solve. If depth equal to this, then discard strategy.
| Method Detail |
|---|
public static java.util.Collection<MultiServerRequestStrategy> findFastestStrategiesUsingConnectedCoreServers(java.util.Collection<java.lang.String> serverHostsToRequest,
org.tranche.commons.Tertiary readable,
org.tranche.commons.Tertiary writable)
Finds set of strategies that have the smallest depth, which is a strong heuristic for speed.
Uses as primary host only online, core servers to which the client is connected.
Uses in the tree of connections only online, core servers.
If caller would like to select strategy based on heuristics other than depth, can call create method for desired to get desired set of strategies.
serverHostsToRequest -
public static MultiServerRequestStrategy create(java.lang.String hostReceivingRequest,
java.util.Collection<java.lang.String> serverHostsToRequest)
Say a client has a request for many servers. If pick any server (randomly or using a heuristic), you can create this object to determine:
A simple strategy: if want to see best server to which to send a request, calculate this for all online servers and select the strategy with the smallest depth.
Note that a server receiving a multi-server request will also build a MultiServerRequestStategy object, using its host as the parameter. That way, it will know how to partition the request amongst servers to which it is connected.
hostReceivingRequest - Server to which to send a request for a set of serversserverHostsToRequest - Set of all servers included in the request. Note that if hostReceivingRequest is not included in the set, then it can still be used to pass the requests on--but it won't be included in the request!
public java.lang.String getHostReceivingRequest()
The host name for the server to receive the request, per this strategy object.
public java.util.Map<java.lang.String,java.util.Set<java.lang.String>> getPartitionsMap()
This is a map containing the following:
Say we want set of hosts in this request, H = { h1, h2, h3, ..., h12 }, |H| = 12. If sending this request to an arbitrary host, h1, this map shows how this server will partition up these requests amongst its connected servers so that the request is filled as quickly as possible.
Say our key set is this map is {h2, h3, h4}, which are servers connected directly to h1. Then, hypothetically:
All the requests were partitioned! Note that just because h2 -> { h2, h5, h6, h7 } doesn't mean that the server is connected to all four servers. The depth is a separate issue (and is available through this object); this is enough information to know where to send the requests next.
public int getDepth()
If this request is sent to the server host listed, this is the 'depth' of the request across the network for the requested servers when modeled as a tree.
I.e., assume the server being sent the request is the root node. The branches are the servers to which it sends the request. If they satisfy the requests, then they are leaves; otherwise, they'll branche, etc. This number is the depth of this tree.
This is a rough approximation of the efficiency--the lower the depth, the more efficient (likely) to be.
Before sending a request to a particular server, can create a number of these summary objects and select the one with lowest depth. Other heuristics might be helpful as well.
public java.lang.String toString()
toString in class java.lang.Objectpublic void printStrategy(java.io.PrintStream out)
public java.util.Set<java.lang.String> getUnfulfillableHosts()
All the hosts that are unfulfillable. Right now, this means because the server is offline. There might be additional future conditions.
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equivalent(MultiServerRequestStrategy other)
Test that strategy objects are similar. Don't have to be exactly same, but must have the following in common:
other -
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic boolean requestContains(java.lang.String host)
Returns true if request contains a particular host.
host -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||