本文整理汇总了Java中org.jetlang.channels.MemoryRequestChannel类的典型用法代码示例。如果您正苦于以下问题:Java MemoryRequestChannel类的具体用法?Java MemoryRequestChannel怎么用?Java MemoryRequestChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemoryRequestChannel类属于org.jetlang.channels包,在下文中一共展示了MemoryRequestChannel类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JetlangPonger
import org.jetlang.channels.MemoryRequestChannel; //导入依赖的package包/类
/** Creates a JetlangPonger. */
public JetlangPonger(final Fiber _fiber) {
fiber = _fiber;
channel = new MemoryRequestChannel();
final Callback<Request> onReq = new Callback<Request>() {
@Override
public void onMessage(final Request message) {
final Object request = message.getRequest();
if (request instanceof PingRequest) {
final PingRequest ping = (PingRequest) request;
message.reply(ping.processRequest(JetlangPonger.this));
} else {
throw new IllegalStateException(
"Expected PingRequest but got "
+ request.getClass());
}
}
};
fiber.start();
channel.subscribe(fiber, onReq);
}
示例2: makeTestInstance
import org.jetlang.channels.MemoryRequestChannel; //导入依赖的package包/类
private ReplicatorInstance makeTestInstance() throws Exception {
long thisReplicatorId = 1;
ReplicatorClock info = new InRamSim.StoppableClock(0, Integer.MAX_VALUE / 2L);
ReplicatorLog proxyLog = getReplicatorLogWhichInvokesMock();
return new ReplicatorInstance(new ThreadFiber(new RunnableExecutorImpl(batchExecutor), null, true),
thisReplicatorId,
QUORUM_ID,
proxyLog,
info,
persistence,
new MemoryRequestChannel<>(),
eventChannel,
commitNotices,
State.FOLLOWER);
}
示例3: JetlangPinger
import org.jetlang.channels.MemoryRequestChannel; //导入依赖的package包/类
/** Creates a JetlangPinger. */
@SuppressWarnings({ "rawtypes", "unchecked" })
public JetlangPinger(final Fiber _fiber) {
fiber = _fiber;
channel = new MemoryRequestChannel();
final Callback<Request> onReq = new Callback<Request>() {
@Override
public void onMessage(final Request message) {
final Object request = message.getRequest();
if (request instanceof HammerRequest) {
final HammerRequest req = (HammerRequest) request;
try {
req.processRequest(JetlangPinger.this);
ping(message);
} catch (final Exception e) {
e.printStackTrace();
message.reply(-1);
}
} else {
throw new IllegalStateException(
"Expected HammerRequest but got "
+ request.getClass());
}
}
};
fiber.start();
channel.subscribe(fiber, onReq);
}