本文整理汇总了Java中se.sics.kompics.Component类的典型用法代码示例。如果您正苦于以下问题:Java Component类的具体用法?Java Component怎么用?Java Component使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Component类属于se.sics.kompics包,在下文中一共展示了Component类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:jimdowling,项目名称:gvod,代码行数:22,代码来源:GradientSimulator.java
示例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);
}
开发者ID:jimdowling,项目名称:gvod,代码行数:26,代码来源:GradientSimulator.java
示例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));
}
开发者ID:jimdowling,项目名称:gvod,代码行数:27,代码来源:GradientSimulationMain.java
示例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);
}
开发者ID:jimdowling,项目名称:gvod,代码行数:22,代码来源:LsSimulator.java
示例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);
}
开发者ID:jimdowling,项目名称:gvod,代码行数:23,代码来源:LsSimulator.java
示例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);
}
开发者ID:jimdowling,项目名称:gvod,代码行数:17,代码来源:VideoSimulator.java
示例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. ");
}
}
}
开发者ID:jimdowling,项目名称:gvod,代码行数:23,代码来源:SwingMain.java
示例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;
}
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:21,代码来源:SimulatorComponent.java
示例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());
}
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:20,代码来源:SimulatorComponent.java
示例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));
}
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:20,代码来源:SimulatorMain.java
示例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);
}
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:22,代码来源:SimulatorComponent.java
示例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));
}
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:19,代码来源:SimulatorMain.java
示例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());
}
开发者ID:kompics,项目名称:kompics,代码行数:19,代码来源:NetworkTest.java
示例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);
}
开发者ID:kompics,项目名称:kompics,代码行数:22,代码来源:NetworkTest.java
示例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);
}
开发者ID:kompics,项目名称:kompics,代码行数:21,代码来源:NetworkTest.java
示例16: schedule
import se.sics.kompics.Component; //导入依赖的package包/类
public final void schedule(Component component, int wid) {
ComponentCore core = (ComponentCore) component;
// check if any worker need waking up
int swc = sleepingWorkerCount.get();
Worker toAwake = null;
if (swc > 0) {
swc = sleepingWorkerCount.getAndDecrement();
if (swc > 0) {
toAwake = sleepingWorkers.poll();
}
}
if (toAwake == null) {
// add new work to the queue of the worker who generated it
workers[wid].addWork(core);
} else {
// add new work to the queue of the worker to be awaken
workers[toAwake.getWid()].addWork(core);
// wake up sleeping worker
synchronized (toAwake) {
toAwake.notify();
}
}
}
开发者ID:kompics,项目名称:kompics,代码行数:27,代码来源:WorkStealingScheduler.java
示例17: ClientParent
import se.sics.kompics.Component; //导入依赖的package包/类
public ClientParent(Init init) {
Component node = create(Client.class, new Client.Init(init.self, init.member));
Component input = create(InputGen.class, se.sics.kompics.Init.NONE);
if (init.deploy) {
connect(node.getNegative(Network.class), create(NettyNetwork.class, new NettyInit(init.self)).getPositive(Network.class), Channel.TWO_WAY);
connect(node.getNegative(Timer.class), create(JavaTimer.class, Init.NONE).getPositive(Timer.class), Channel.TWO_WAY);
} else {
connect(node.getNegative(Network.class), requires(Network.class), Channel.TWO_WAY);
connect(node.getNegative(Timer.class), requires(Timer.class), Channel.TWO_WAY);
}
connect(input.getNegative(InputGenPort.class), node.getPositive(InputGenPort.class), Channel.TWO_WAY);
}
开发者ID:tobiajo,项目名称:jbstore,代码行数:16,代码来源:ClientParent.java
示例18: NodeParent
import se.sics.kompics.Component; //导入依赖的package包/类
public NodeParent(Init init) {
Component node = create(Node.class, new Node.Init(init.self, init.member, init.id, init.n));
if (init.deploy) {
connect(node.getNegative(Network.class), create(NettyNetwork.class, new NettyInit(init.self)).getPositive(Network.class), Channel.TWO_WAY);
} else {
connect(node.getNegative(Network.class), requires(Network.class), Channel.TWO_WAY); // Node <-> Network
}
Component viewSync = create(ViewSync.class, se.sics.kompics.Init.NONE);
connect(viewSync.getNegative(ViewSyncPort.class), node.getPositive(ViewSyncPort.class), Channel.ONE_WAY_NEG); // Node --> ViewSync
connect(viewSync.getNegative(NodePort.class), node.getPositive(NodePort.class), Channel.ONE_WAY_POS); // Node <-- ViewSync
Component epfd = create(EPFD.class, se.sics.kompics.Init.NONE);
if (init.deploy) {
connect(epfd.getNegative(Timer.class), create(JavaTimer.class, Init.NONE).getPositive(Timer.class), Channel.TWO_WAY);
} else {
connect(epfd.getNegative(Timer.class), requires(Timer.class), Channel.TWO_WAY); // EPDF <-> Timer
}
connect(epfd.getNegative(EPFDPort.class), node.getPositive(EPFDPort.class), Channel.ONE_WAY_NEG); // EPDF <-- Node
connect(epfd.getNegative(NodePort.class), node.getPositive(NodePort.class), Channel.ONE_WAY_POS); // EPDF --> Node
connect(epfd.getNegative(EPFDPort.class), viewSync.getPositive(EPFDPort.class), Channel.TWO_WAY); // EPDF <-> ViewSync
Component kvStore = create(KVStore.class, se.sics.kompics.Init.NONE);
connect(kvStore.getNegative(KVStorePort.class), node.getPositive(KVStorePort.class), Channel.ONE_WAY_NEG); // KVStore <-- Node
connect(kvStore.getNegative(NodePort.class), node.getPositive(NodePort.class), Channel.ONE_WAY_POS); // KVStore --> Node
connect(kvStore.getNegative(KVStorePort.class), viewSync.getPositive(KVStorePort.class), Channel.ONE_WAY_NEG); // KVStore <-- ViewSync
}
开发者ID:tobiajo,项目名称:jbstore,代码行数:29,代码来源:NodeParent.java
示例19: PingerParent
import se.sics.kompics.Component; //导入依赖的package包/类
public PingerParent(Init init) {
Component timer = create(JavaTimer.class, Init.NONE);
Component network = create(NettyNetwork.class, new NettyInit(init.self));
Component pinger = create(Pinger.class, new Pinger.Init(init.self, init.ponger));
connect(pinger.getNegative(Timer.class), timer.getPositive(Timer.class), Channel.TWO_WAY);
connect(pinger.getNegative(Network.class), network.getPositive(Network.class), Channel.TWO_WAY);
}
开发者ID:tobiajo,项目名称:jbstore,代码行数:10,代码来源:PingerParent.java
示例20: ComponentBodyAdapter
import se.sics.kompics.Component; //导入依赖的package包/类
ComponentBodyAdapter(ResolutionContext context, JDefinedClass clazz) {
super(context, clazz);
initBlock = clazz.instanceInit();
handlerType = (JClass) context.unit._ref(Handler.class);
posPortType = (JClass) context.unit._ref(Positive.class);
negPortType = (JClass) context.unit._ref(Negative.class);
componentType = (JClass) context.unit._ref(Component.class);
initType = (JClass) context.unit._ref(Init.class);
}
开发者ID:kompics,项目名称:kola,代码行数:10,代码来源:ComponentBodyAdapter.java
注:本文中的se.sics.kompics.Component类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论