ch.ethz.systems.cloudy2.server.components.router.dht.DHTRouter
是主要负责路由的,可以从这儿来改。
修改路线
client end:
add swich command in cli.java:
cloudy2>: switch mode=[0,1,2,3,4]
which will be sent by javaclient.java.
server端:
in
ch.ethz.systems.cloudy2.server.external.java.CloudyRequestWorker.consume(ServerDataEvent)
read from the request message, the emun EJavaOperations indicates which it is types request(ROUTING_TABLE, GET, PUT, DELETE; )
ch.ethz.systems.cloudy2.server.components.protocol.quorum.QuorumProtocol
ch.ethz.systems.cloudy2.server.components.protocol.quorum.QuorumProtocol.put(DPI, int, int)
GET inside:
ch.ethz.systems.cloudy2.server.components.protocol.quorum.QuorumProtocol
just to do:
Map<DPI, List<Endpoint>> m = CloudyFactory.getRouter().getPreferenceList(dpi, replicationFactor);
really invokes:
ch.ethz.systems.cloudy2.server.components.router.dht.DHTRouter.getPreferenceList(DPI, int)
for a DPI with a single key
String partitioning = partitioningStrategy.getPartitioning(dpi);
find the responsible node:
private Entry<Token,Endpoint> ch.ethz.systems.cloudy2.server.components.router.dht.DHTRouter.binarySearchResponsibleToken(Token);
Entry<Token,Endpoint> responsibleToken = tokenToEndpointMap.ceilingEntry(token);//ifin ps mode, it should check tokenToEndpointMapPS;
while (list.size() < numberOfReplicas) {
Entry<Token,Endpoint> nextEntry = tokenToEndpointMap.higherEntry(lastToken);
}
So, finally, it refers to tokenToEndpointMap.
We decide to modify tokenToEndpointMap.
tokenToEndpointMap was only used at following places:
ch.ethz.systems.cloudy2.server.components.router.dht.DHTRouter // many times
ch.ethz.systems.cloudy2.server.components.router.dht.DHTRouterStatic.getBootstrapInformation(Endpoint)
ch.ethz.systems.cloudy2.server.components.router.dht.DHTRouterStatic.claimSeed()
endpointToTokensMap just store avialable nodes, see DHTRouter.java isReady();
ch.ethz.systems.cloudy2.server.components.router.dht.DHTRouter.onChange(Endpoint, EndpointState)seems to be a key interface.
if (CloudyFactory.getGossiper().isAlive(endpoint))
{
}
else
{
}
Invoking of DHTRouter.java
1) DefaultBootstrapper.java
ch.ethz.systems.cloudy2.server.components.bootstrapper.def.DefaultBootstrapper.bootstrap()
{...
CloudyFactory.getRouter().setBootstrapInformation(bootInfoMsg.getBootstrapInfo());
if (isSeed == true) {
CloudyFactory.getRouter().claimSeed();
}
}
2) QuorumProtocol.javach.ethz.systems.cloudy2.server.components.protocol.quorum.QuorumProtocol.onChange(Endpoint, EndpointState)
{
Set<DPI> dpis = CloudyFactory.getRouter().getDpisManagedBy(endpointState);
ReplicationLevelAssurer task = new ReplicationLevelAssurer(endpoint, dpis);
}
subclass:
ch.ethz.systems.cloudy2.server.components.protocol.quorum.QuorumProtocol.ReplicationLevelAssurer.run(){
if (CloudyFactory.getGossiper().isAlive(deadEndpoint)) { // Endpoint is alive again
// Check if the Endpoint still has the same tokens
// anycom: after 1 minute.
Set<DPI> managedDPIs = CloudyFactory.getRouter().getDpisManagedBy(deadEndpoint);
...
}
}
When one node has been declared dead, and the replication-factor is more than 1, its replicated data will be copy to other nodes.
QuorumProtocol will wait 60 seconds to copy. Onchange(..)
ch.ethz.systems.cloudy2.server.components.protocol.quorum.QuorumProtocol.ReplicationLevelAssurer
streamrang()
ch.ethz.systems.cloudy2.server.components.router.dht.DHTRouter.getPreferenceList(DPI, int)
In addition, the Balancer also move the data.