use of java.util.concurrent.Executor in project java-chassis by ServiceComb.
the class ExecutorManager method findExecutor.
// 只会在初始化时执行,一点点重复的查找,没必要做缓存
public static Executor findExecutor(OperationMeta operationMeta) {
Executor executor = findByKey("cse.executors.Provider." + operationMeta.getSchemaQualifiedName());
if (executor != null) {
return executor;
}
// 尝试schema级别
executor = findByKey("cse.executors.Provider." + operationMeta.getSchemaMeta().getName());
if (executor != null) {
return executor;
}
executor = findByKey("cse.executors.default");
if (executor != null) {
return executor;
}
return BeanUtils.getBean("cse.executor.default");
}
use of java.util.concurrent.Executor in project java-chassis by ServiceComb.
the class MockUtil method mockAbstactRestServer.
public void mockAbstactRestServer() {
new MockUp<AbstractRestServer<HttpServletResponse>>() {
@Mock
protected RestOperationMeta findRestOperation(RestServerRequestInternal restRequest) {
RestOperationMeta restOperationMeta = Mockito.mock(RestOperationMeta.class);
OperationMeta operationMeta = Mockito.mock(OperationMeta.class);
Executor executor = Mockito.mock(Executor.class);
operationMeta.setExecutor(executor);
return restOperationMeta;
}
};
}
use of java.util.concurrent.Executor in project core-java by SpineEventEngine.
the class EventBusBuilderShould method use_passed_executor.
@Test
public void use_passed_executor() {
final CountDownLatch executorUsageLatch = new CountDownLatch(1);
final Executor simpleExecutor = new Executor() {
@Override
public void execute(Runnable command) {
// Decrease the counter to ensure this method has been called.
executorUsageLatch.countDown();
}
};
final EventBus.Builder builder = EventBus.newBuilder().setStorageFactory(storageFactory).setEventStoreStreamExecutor(simpleExecutor);
final EventBus build = builder.build();
final Executor streamExecutor = build.getEventStore().getStreamExecutor();
streamExecutor.execute(mock(Runnable.class));
try {
/**
* The executor configured to operate synchronously,
* so the latch should already be {@code zero} at this point.
**/
executorUsageLatch.await(0, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail("The specified executor was not used.");
}
}
use of java.util.concurrent.Executor in project fast-cast by RuedigerMoeller.
the class TestEchoServer method echoServer.
public static void echoServer(FastCast fc) throws InterruptedException {
final FCPublisher echoresp = fc.onTransport("default").publish(fc.getPublisherConf("echoresp"));
final Executor responseExec = Executors.newSingleThreadExecutor();
final long startUpTime = (int) System.currentTimeMillis();
startTestTopic(fc, startUpTime);
startEchoTopic(fc, echoresp, responseExec);
startUnreliableTopic(fc);
while (true) {
Thread.sleep(1000);
}
}
use of java.util.concurrent.Executor in project core-java by SpineEventEngine.
the class StandShould method use_provided_executor_upon_update_of_watched_type.
@Test
public void use_provided_executor_upon_update_of_watched_type() {
final Executor executor = mock(Executor.class);
final BoundedContext boundedContext = BoundedContext.newBuilder().setStand(Stand.newBuilder().setCallbackExecutor(executor)).build();
final Stand stand = boundedContext.getStand();
final StandTestProjectionRepository standTestProjectionRepo = new StandTestProjectionRepository(boundedContext);
stand.registerTypeSupplier(standTestProjectionRepo);
final Topic projectProjections = requestFactory.topic().allOf(Project.class);
final MemoizingObserver<Subscription> observer = memoizingObserver();
stand.subscribe(projectProjections, observer);
final Subscription subscription = observer.firstResponse();
final StreamObserver<Response> noopObserver = noOpObserver();
stand.activate(subscription, emptyUpdateCallback(), noopObserver);
assertNotNull(subscription);
verify(executor, never()).execute(any(Runnable.class));
final ProjectId someId = ProjectId.getDefaultInstance();
final Version stateVersion = Tests.newVersionWithNumber(1);
stand.update(asEnvelope(someId, Project.getDefaultInstance(), stateVersion));
verify(executor, times(1)).execute(any(Runnable.class));
}
Aggregations