本文整理汇总了Java中org.jetlang.core.RunnableExecutorImpl类的典型用法代码示例。如果您正苦于以下问题:Java RunnableExecutorImpl类的具体用法?Java RunnableExecutorImpl怎么用?Java RunnableExecutorImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RunnableExecutorImpl类属于org.jetlang.core包,在下文中一共展示了RunnableExecutorImpl类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeTestInstance
import org.jetlang.core.RunnableExecutorImpl; //导入依赖的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);
}
示例2: whenTheReplicatorIsInState
import org.jetlang.core.RunnableExecutorImpl; //导入依赖的package包/类
private void whenTheReplicatorIsInState(Replicator.State state) throws Exception {
final Fiber replicatorFiber = new ThreadFiber(new RunnableExecutorImpl(batchExecutor),
"replicatorFiber-Thread", true);
replicatorInstance = new ReplicatorInstance(replicatorFiber,
MY_ID,
QUORUM_ID,
log,
clock,
persistence,
sendRpcChannel,
eventChannel,
commitNotices,
state);
sendRpcChannel.subscribe(rpcFiber, (request) -> {
if (request.getRequest().to == MY_ID) {
handleLoopBack(request);
}
});
replicatorInstance.start();
}
示例3: waitForReply
import org.jetlang.core.RunnableExecutorImpl; //导入依赖的package包/类
public static <S, R> ChannelListener<S> waitForReply(RequestChannel<S, R> channel) {
List<Throwable> throwables = new ArrayList<>();
BatchExecutor exceptionHandlingBatchExecutor = new ExceptionHandlingBatchExecutor(throwables::add);
RunnableExecutor runnableExecutor = new RunnableExecutorImpl(exceptionHandlingBatchExecutor);
Fiber channelSubscriberFiber = new ThreadFiber(runnableExecutor, null, true);
ArrayBlockingQueue<S> messages = new ArrayBlockingQueue<>(1);
channel.subscribe(channelSubscriberFiber, m -> {
try {
messages.put(m.getRequest());
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
channelSubscriberFiber.start();
return new ChannelListener<>(channelSubscriberFiber, messages, throwables);
}
示例4: listenTo
import org.jetlang.core.RunnableExecutorImpl; //导入依赖的package包/类
public static <T> ChannelListener<T> listenTo(Subscriber<T> channel) {
List<Throwable> throwables = new ArrayList<>();
BatchExecutor exceptionHandlingBatchExecutor = new ExceptionHandlingBatchExecutor(throwables::add);
RunnableExecutor runnableExecutor = new RunnableExecutorImpl(exceptionHandlingBatchExecutor);
Fiber channelSubscriberFiber = new ThreadFiber(runnableExecutor, null, true);
ArrayBlockingQueue<T> messages = new ArrayBlockingQueue<>(1);
channel.subscribe(channelSubscriberFiber, m -> {
try {
messages.put(m);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
channelSubscriberFiber.start();
return new ChannelListener<>(channelSubscriberFiber, messages, throwables);
}
示例5: makeFiberSupplier
import org.jetlang.core.RunnableExecutorImpl; //导入依赖的package包/类
private FiberSupplier makeFiberSupplier() {
return (throwableHandler) -> {
BatchExecutor batchExecutor = new ExceptionHandlingBatchExecutor(throwableHandler);
RunnableExecutor runnableExecutor = new RunnableExecutorImpl(batchExecutor);
return new ThreadFiber(runnableExecutor, "o-log-reader-test-thread", false);
};
}
示例6: createLeaderAndSetupFibersAndChannels
import org.jetlang.core.RunnableExecutorImpl; //导入依赖的package包/类
@Before
public final void createLeaderAndSetupFibersAndChannels() throws Exception {
sendRpcChannel.subscribe(rpcFiber, (request) -> System.out.println(request.getRequest()));
sendRpcChannel.subscribe(rpcFiber, this::routeOutboundRequests);
sendRpcChannel.subscribe(rpcFiber, requestLog::publish);
Fiber replicatorFiber = new ThreadFiber(new RunnableExecutorImpl(batchExecutor), "replicatorFiber-Thread", true);
InRamSim.StoppableClock clock = new InRamSim.StoppableClock(0, 1000);
clock.startTimeout();
log.logEntries(
Lists.newArrayList(
new LogEntry(CURRENT_TERM, 1, new ArrayList<>(), QuorumConfiguration.of(PEER_ID_LIST).toProtostuff())));
lastIndex = 1;
ReplicatorInfoPersistence persister = new InRamSim.Persister();
persister.writeCurrentTermAndVotedFor(QUORUM_ID, CURRENT_TERM, LEADER_ID);
replicatorInstance = new ReplicatorInstance(replicatorFiber,
LEADER_ID,
QUORUM_ID,
log,
clock,
new InRamSim.Persister(),
sendRpcChannel,
new MemoryChannel<>(),
commitNotices,
State.LEADER);
replicatorInstance.start();
rpcFiber.start();
}
示例7: beforeClass
import org.jetlang.core.RunnableExecutorImpl; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
if (dirty) {
System.setProperty(C5ServerConstants.C5_CFG_PATH, ClusterOrPseudoCluster.testFolder.getRoot().getAbsolutePath());
System.setProperty("clusterName", C5ServerConstants.LOCALHOST);
server = Main.startC5Server(new String[]{});
metaOnNode = server.getNodeId();
TabletModule tabletServer = (TabletModule) server.getModule(ModuleType.Tablet).get();
RegionServerModule regionServer = (RegionServerModule) server.getModule(ModuleType.RegionServer).get();
stateChanges = tabletServer.getTabletStateChanges();
Fiber receiver = new ThreadFiber(new RunnableExecutorImpl(), "cluster-receiver-static-fiber", false);
receiver.start();
// create java.util.concurrent.CountDownLatch to notify when message arrives
final CountDownLatch latch = new CountDownLatch(1);
Fiber fiber = new ThreadFiber(new RunnableExecutorImpl(), "cluster-tablet-state-change-fiber", false);
fiber.start();
tabletServer.getTabletStateChanges().subscribe(fiber, tabletStateChange -> {
if (tabletStateChange.state.equals(Tablet.State.Leader)) {
if (tabletStateChange.tablet.getRegionInfo().getRegionNameAsString().startsWith("hbase:meta")) {
metaOnPort = regionServer.port();
metaOnNode = server.getNodeId();
latch.countDown();
fiber.dispose();
}
}
});
latch.await();
receiver.dispose();
}
dirty = false;
}
示例8: before
import org.jetlang.core.RunnableExecutorImpl; //导入依赖的package包/类
@Before
public void before() throws InterruptedException, ExecutionException, TimeoutException {
Fiber receiver = new ThreadFiber(new RunnableExecutorImpl(), "cluster-receiver-fiber", false);
receiver.start();
final CountDownLatch latch = new CountDownLatch(1);
Callback<TabletStateChange> onMsg = message -> {
if (message.state.equals(Tablet.State.Leader)) {
latch.countDown();
}
};
stateChanges.subscribe(receiver, onMsg);
TableName clientTableName = TabletNameHelpers.getClientTableName("c5", name.getMethodName());
org.apache.hadoop.hbase.TableName tableName = TabletNameHelpers.getHBaseTableName(clientTableName);
Channel<CommandRpcRequest<?>> commandChannel = server.getCommandChannel();
ModuleSubCommand createTableSubCommand = new ModuleSubCommand(ModuleType.Tablet,
TestHelpers.getCreateTabletSubCommand(tableName, splitkeys, Arrays.asList(server)));
CommandRpcRequest<ModuleSubCommand> createTableCommand = new CommandRpcRequest<>(server.getNodeId(),
createTableSubCommand);
commandChannel.publish(createTableCommand);
latch.await();
table = new FakeHTable(C5TestServerConstants.LOCALHOST, getRegionServerPort(),
TabletNameHelpers.toByteString(clientTableName));
row = Bytes.toBytes(name.getMethodName());
receiver.dispose();
}
示例9: before
import org.jetlang.core.RunnableExecutorImpl; //导入依赖的package包/类
@Before
public void before() {
Random portRandomizer = new Random();
modulePortUnderTest = 3000 + portRandomizer.nextInt(3000);
context.checking(new Expectations() {{
allowing(server).getCommandRequests();
will(returnValue(serverRequests));
allowing(server).getModule(with(equal(ModuleType.Discovery)));
will(returnFutureWithValue(discoveryModule));
allowing(server).getNodeId();
will(returnValue(LOCAL_NODE_ID));
}});
ourFiber.start();
serverRequests.subscribe(ourFiber, this::handleServerRequests);
controlService = new ControlService(
server,
new ThreadFiber(new RunnableExecutorImpl(), "control-service-fiber", false),
acceptConnectionGroup,
ioWorkerGroup,
modulePortUnderTest
);
controlClient = new SimpleControlClient(ioWorkerGroup);
controlService.startAndWait();
}
示例10: WsEventListener
import org.jetlang.core.RunnableExecutorImpl; //导入依赖的package包/类
public WsEventListener() {
this(new ThreadFiber(new RunnableExecutorImpl(), "ws-events", true));
}