本文整理汇总了Java中se.sics.kompics.Component类的典型用法代码示例。如果您正苦于以下问题:Java Component类的具体用法?Java Component怎么用?Java Component使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Component类属于se.sics.kompics包,在下文中一共展示了Component类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GradientSimulator
import se.sics.kompics.Component; //导入依赖的package包/类
public GradientSimulator() {
publicPeers = new HashMap<Integer, Component>();
privatePeers = new HashMap<Integer, Component>();
privateAddress = new HashMap<Integer, VodAddress>();
publicAddress = new HashMap<Integer, VodAddress>();
peerTypes = new HashMap<Integer, VodAddress.NatType>();
view = new ConsistentHashtable<Integer>();
subscribe(handleInit, control);
subscribe(handleGenerateReport, timer);
subscribe(handlePeerJoin, simulator);
subscribe(handlePeerFail, simulator);
subscribe(handlePeerChurn, simulator);
subscribe(handleStartCollectData, simulator);
subscribe(handleStopCollectData, simulator);
subscribe(handleCroupierJoinCompleted, croupierPort);
}
示例2: stopAndDestroyPeer
import se.sics.kompics.Component; //导入依赖的package包/类
private void stopAndDestroyPeer(Integer id) {
Component peer = privatePeers.get(id);
if (peer == null) {
peer = publicPeers.get(id);
}
trigger(new Stop(), peer.getControl());
// disconnect(network, peer.getNegative(VodNetwork.class));
// disconnect(timer, peer.getNegative(Timer.class));
// CroupierSnapshot.removePeer(privateAddress.get(id));
VodAddress addr = (publicAddress.get(id) == null)
? privateAddress.get(id) : publicAddress.get(id);
CroupierStats.removeNode(addr.getId(), addr.getOverlayId());
GradientStats.removeNode(addr.getId(), addr.getOverlayId());
privatePeers.remove(id);
publicPeers.remove(id);
privateAddress.remove(id);
publicAddress.remove(id);
peerTypes.remove(id);
destroy(peer);
}
示例3: GradientSimulationMain
import se.sics.kompics.Component; //导入依赖的package包/类
public GradientSimulationMain() throws IOException {
P2pSimulator.setSimulationPortType(SimulatorPort.class);
VodConfig.init(new String[]{});
// create
Component p2pSimulator = create(P2pSimulator.class);
Component gradientSimulator = create(GradientSimulator.class);
final GradientConfiguration gradientConfiguration =
(GradientConfiguration) GradientConfiguration.load(GradientConfiguration.class);
final CroupierConfiguration croupierConfiguration =
(CroupierConfiguration) CroupierConfiguration.load(CroupierConfiguration.class);
final ParentMakerConfiguration parentMakerConfiguration =
(ParentMakerConfiguration) AbstractConfiguration.load(ParentMakerConfiguration.class);
trigger(new P2pSimulatorInit(simulatorScheduler, scenario,
new KingLatencyMap(croupierConfiguration.getSeed())), p2pSimulator.getControl());
trigger(new GradientSimulatorInit(gradientConfiguration, croupierConfiguration,
parentMakerConfiguration), gradientSimulator.getControl());
connect(gradientSimulator.getNegative(VodNetwork.class), p2pSimulator.getPositive(VodNetwork.class));
connect(gradientSimulator.getNegative(Timer.class), p2pSimulator.getPositive(Timer.class));
connect(gradientSimulator.getNegative(SimulatorPort.class), p2pSimulator.getPositive(SimulatorPort.class));
}
示例4: LsSimulator
import se.sics.kompics.Component; //导入依赖的package包/类
public LsSimulator() {
publicPeers = new HashMap<Integer, Component>();
privatePeers = new HashMap<Integer, Component>();
privateAddress = new HashMap<Integer, VodAddress>();
publicAddress = new HashMap<Integer, VodAddress>();
peerTypes = new HashMap<Integer, VodAddress.NatType>();
view = new ConsistentHashtable<Integer>();
subscribe(handleInit, control);
subscribe(handleGenerateReport, timer);
subscribe(handleCroupierPeerJoin, simulator);
subscribe(handleCroupierPeerFail, simulator);
subscribe(handleCroupierPeerChurn, simulator);
subscribe(handleStartCollectData, simulator);
subscribe(handleStopCollectData, simulator);
subscribe(handleCroupierJoinCompleted, croupierPort);
}
示例5: stopAndDestroyPeer
import se.sics.kompics.Component; //导入依赖的package包/类
private void stopAndDestroyPeer(Integer id) {
Component peer = privatePeers.get(id);
if (peer == null) {
peer = publicPeers.get(id);
}
trigger(new Stop(), peer.getControl());
disconnect(network, peer.getNegative(VodNetwork.class));
disconnect(timer, peer.getNegative(Timer.class));
CroupierStats.removeNode(id, VodConfig.SYSTEM_OVERLAY_ID);
InterAsStats.removeNode(id, InterAs.SYSTEM_INTER_AS_OVERLAY_ID);
privatePeers.remove(id);
publicPeers.remove(id);
privateAddress.remove(id);
publicAddress.remove(id);
peerTypes.remove(id);
destroy(peer);
}
示例6: join
import se.sics.kompics.Component; //导入依赖的package包/类
private void join(Integer id, VodAddress.NatType peerType) {
// join with the next id if this id is taken
Integer successor = view.getNode(id);
while (usedIds.contains(id)
|| (successor != null && successor.equals(id))) {
id = (id == Integer.MAX_VALUE) ? 0 : ++peerIdSequence;
successor = view.getNode(id);
}
usedIds.add(id);
logger.debug("[email protected]{}", id);
Component newPeer = createAndStartNewPeer(id, peerType, false);
view.addNode(id);
peerTypes.put(id, peerType);
}
示例7: stopPeer
import se.sics.kompics.Component; //导入依赖的package包/类
@Override
public void stopPeer(Component peer) {
synchronized (this) {
if (peer != null) {
logger.warn("Stopping peer");
try {
unsubscribe(handleQuitCompleted, peer.getPositive(VodPeerPort.class));
disconnect(timer.getPositive(Timer.class), peer.getNegative(Timer.class));
// Disconnecting from netty fails for some reason
// disconnect(network.getPositive(VodNetwork.class), peer.getNegative(VodNetwork.class));
disconnect(web.getNegative(Web.class), peer.getPositive(Web.class));
destroy(peer);
} catch (RuntimeException e) {
// swallow execeptions...
logger.warn("Problem deleting peer: " + e.getMessage());
}
} else {
logger.warn("Problem deleting peer, null pointer to peer. ");
}
}
}
示例8: bootBootstrapNode
import se.sics.kompics.Component; //导入依赖的package包/类
private void bootBootstrapNode() {
Configuration myConf = Configuration.Factory.modifyWithOtherDB(baseConfig, "bootStrap/")
.setIp(baseConfig.getBootstrapServer().getIp())
.setPort(baseConfig.getBootstrapServer().getPort())
.finalise();
Address netSelf = new Address(myConf.getIp(), myConf.getPort(), null);
Component deadLetterBox = create(VirtualNetworkChannel.DefaultDeadLetterComponent.class, Init.NONE);
VirtualNetworkChannel vnc = VirtualNetworkChannel.connect(net,
deadLetterBox.getNegative(Network.class),
new MessageDestinationSelector(new HostAddress(netSelf)));
Component manager = create(HostManager.class, new HostManagerInit(myConf, netSelf, vnc));
connect(manager.getNegative(Timer.class), timer);
trigger(Start.event, deadLetterBox.control());
trigger(Start.event, manager.control());
target = netSelf;
}
示例9: bootNode
import se.sics.kompics.Component; //导入依赖的package包/类
private void bootNode(int port) {
Configuration myConf = Configuration.Factory.modifyWithOtherDB(baseConfig, String.valueOf(port)+"/")
.setIp(baseConfig.getBootstrapServer().getIp())
.setPort(port)
.finalise();
Address netSelf = new Address(myConf.getIp(), myConf.getPort(), null);
Component deadLetterBox = create(VirtualNetworkChannel.DefaultDeadLetterComponent.class, Init.NONE);
VirtualNetworkChannel vnc = VirtualNetworkChannel.connect(net,
deadLetterBox.getNegative(Network.class),
new MessageDestinationSelector(new HostAddress(netSelf)));
Component manager = create(HostManager.class, new HostManagerInit(myConf, netSelf, vnc));
connect(manager.getNegative(Timer.class), timer);
trigger(Start.event, deadLetterBox.control());
trigger(Start.event, manager.control());
}
示例10: SimulatorMain
import se.sics.kompics.Component; //导入依赖的package包/类
public SimulatorMain() {
VirtualSimulator.setSimulationPortType(Experiment.class);
scenario = Launcher.getScenario();
// create
Component simulator = create(VirtualSimulator.class,
new VirtualSimulatorInit((SimulationScheduler) Launcher.getScheduler(),
scenario, new UniformRandomModel(1, 10)));
Component simulationComponent = create(SimulatorComponent.class,
new SimulatorComponentInit(Launcher.getConfig()));
// connect
connect(simulationComponent.getNegative(Network.class),
simulator.getPositive(Network.class));
connect(simulationComponent.getNegative(Timer.class),
simulator.getPositive(Timer.class));
connect(simulationComponent.getNegative(Experiment.class),
simulator.getPositive(Experiment.class));
}
示例11: handle
import se.sics.kompics.Component; //导入依赖的package包/类
@Override
public void handle(Fail event) {
LOG.info("Handing fail event.");
//LOG.info(null);
Component failC = null;
// always let leader fail, since it's the only intereasting case
int failP = group.firstKey();
// int r = RAND.nextInt(components.size());
// for (Integer port : components.keySet()) {
// if (r == 0) {
// failP = port;
// break;
// }
// r--;
// }
failC = components.remove(failP);
group.remove(failP);
trigger(Stop.event, failC.control());
disconnect(failC.getNegative(Network.class), net);
disconnect(failC.getNegative(Timer.class), timer);
}
示例12: SimulatorMain
import se.sics.kompics.Component; //导入依赖的package包/类
public SimulatorMain() {
VirtualSimulator.setSimulationPortType(PaxosExperiment.class);
scenario = PaxosTest.getScenario();
// create
Component simulator = create(VirtualSimulator.class,
new VirtualSimulatorInit((SimulationScheduler) PaxosTest.getScheduler(),
scenario, new UniformRandomModel(5, 90)));
Component simulationComponent = create(SimulatorComponent.class, Init.NONE);
// connect
connect(simulationComponent.getNegative(Network.class),
simulator.getPositive(Network.class));
connect(simulationComponent.getNegative(Timer.class),
simulator.getPositive(Timer.class));
connect(simulationComponent.getNegative(PaxosExperiment.class),
simulator.getPositive(PaxosExperiment.class));
}
示例13: handle
import se.sics.kompics.Component; //导入依赖的package包/类
@Override
public void handle(Recover event) {
long diff = System.currentTimeMillis() - event.timestamp;
if (diff < 100) {
try {
LOG.debug("Waiting for connections to shutdown...");
Thread.sleep(10);
trigger(event, onSelf);
return;
} catch (InterruptedException ex) {
LOG.error("Error while waiting to recover.", ex);
System.exit(1);
}
}
LOG.info("Recovering...");
Component fr = createFRComponent();
trigger(Start.event, fr.control());
}
示例14: streamTest
import se.sics.kompics.Component; //导入依赖的package包/类
@Test
public void streamTest() {
final Transport[] protos = new Transport[]{Transport.TCP, Transport.UDT};
NetworkGenerator netGen = new NetworkGenerator() {
@Override
public Component generate(ComponentProxy parent, Address self) {
NettyInit init = new NettyInit(self, 0, ImmutableSet.copyOf(protos));
return parent.create(NettyNetwork.class, init);
}
};
//Transport[] protos = new Transport[]{Transport.TCP};
LOG.info("********* 2 Node Network Test ***********");
se.sics.kompics.network.test.NetworkTest.runTests(netGen, 2, protos);
LOG.info("********* 5 Node Network Test ***********");
se.sics.kompics.network.test.NetworkTest.runTests(netGen, 5, protos);
}
示例15: datagramTest
import se.sics.kompics.Component; //导入依赖的package包/类
@Test
public void datagramTest() {
final Transport[] protos = new Transport[]{Transport.UDP};
NetworkGenerator netGen = new NetworkGenerator() {
@Override
public Component generate(ComponentProxy parent, Address self) {
NettyInit init = new NettyInit(self, 0, ImmutableSet.copyOf(protos));
return parent.create(NettyNetwork.class, init);
}
};
LOG.info("********* 2 Node Datagram Network Test ***********");
se.sics.kompics.network.test.NetworkTest.runAtLeastTests(netGen, 2, protos);
LOG.info("********* 5 Node Datagram Network Test ***********");
se.sics.kompics.network.test.NetworkTest.runAtLeastTests(netGen, 5, protos);
}