GOSSIP-21 WIP

This commit is contained in:
Edward Capriolo
2016-08-12 20:07:48 -04:00
parent 4e13c899f0
commit f7ee815d91
9 changed files with 392 additions and 154 deletions

View File

@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -40,7 +41,7 @@ import org.apache.gossip.LocalGossipMember;
import org.apache.gossip.event.GossipListener;
import org.apache.gossip.event.GossipState;
import org.apache.gossip.manager.impl.OnlyProcessReceivedPassiveGossipThread;
import org.apache.gossip.manager.random.RandomActiveGossipThread;
import org.apache.gossip.model.GossipDataMessage;
public abstract class GossipManager extends Thread implements NotificationListener {
@ -187,8 +188,8 @@ public abstract class GossipManager extends Thread implements NotificationListen
}
passiveGossipThread = new OnlyProcessReceivedPassiveGossipThread(this, gossipCore);
gossipThreadExecutor.execute(passiveGossipThread);
activeGossipThread = new RandomActiveGossipThread(this, this.gossipCore);
gossipThreadExecutor.execute(activeGossipThread);
activeGossipThread = new ActiveGossipThread(this, this.gossipCore);
activeGossipThread.init();
GossipService.LOGGER.debug("The GossipService is started.");
while (gossipServiceRunning.get()) {
try {
@ -222,4 +223,20 @@ public abstract class GossipManager extends Thread implements NotificationListen
LOGGER.error(e);
}
}
public void gossipData(GossipDataMessage message){
message.setNodeId(me.getId());
gossipCore.addPerNodeData(message);
System.out.println(this.getMyself() + " " + gossipCore.getPerNodeData());
}
public GossipDataMessage findGossipData(String nodeId, String key){
ConcurrentHashMap<String, GossipDataMessage> j = gossipCore.getPerNodeData().get(nodeId);
if (j == null){
return null;
} else {
return j.get(key);
}
}
}