当前位置: 首页>>代码示例>>Java>>正文


Java ExecutionException类代码示例

本文整理汇总了Java中java.util.concurrent.ExecutionException的典型用法代码示例。如果您正苦于以下问题:Java ExecutionException类的具体用法?Java ExecutionException怎么用?Java ExecutionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExecutionException类属于java.util.concurrent包,在下文中一共展示了ExecutionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import java.util.concurrent.ExecutionException; //导入依赖的package包/类
private static Future<AdProviderReader> validate(final Future<AdProviderReader> a, final Future<AdProviderReader> b) {
	try {
		if (b.get() == null) {
			return a;
		}
		if (a.get() == null) {
			return b;
		}

		if (FloatComparator.greaterThanWithPrecision(a.get().getPriceEur(), b.get().getPriceEur())) {
			return a;
		}
	} catch (final InterruptedException | ExecutionException e) {
		log.error(e.getMessage());
	}

	return b;
}
 
开发者ID:ad-tech-group,项目名称:openssp,代码行数:19,代码来源:ExchangeServer.java

示例2: testRead

import java.util.concurrent.ExecutionException; //导入依赖的package包/类
/**
 * Test of read method, of class BaseConsole.
 *
 * @throws java.lang.InterruptedException
 * @throws java.util.concurrent.ExecutionException
 * @throws java.util.concurrent.TimeoutException
 */
@Test
public void testRead() throws InterruptedException, ExecutionException, TimeoutException {
    assert !Platform.isFxApplicationThread();
    new JFXPanel();

    FutureTask<Void> futureTask = new FutureTask<>(() -> {
        console.write('a');
        char output = console.read();
        assertEquals("BaseConsole does not work properly.", 'a', output);

        console.write('\n');
        output = console.read();
        assertEquals("BaseConsole does not work properly.", '\n', output);
        return null;
    });
    Platform.runLater(futureTask);
    futureTask.get(5, TimeUnit.SECONDS);
}
 
开发者ID:kasirgalabs,项目名称:ETUmulator,代码行数:26,代码来源:BaseConsoleTest.java

示例3: shouldThrowIfNotOK

import java.util.concurrent.ExecutionException; //导入依赖的package包/类
@Test
public void shouldThrowIfNotOK() throws Exception {
  when(client.send(any(Request.class)))
      .thenReturn(CompletableFuture.completedFuture(Response.forStatus(Status.BAD_REQUEST)));
  try {
    RktCommandHelper.sendRequest(client,
                                 "http://localhost:8080/rkt/gc",
                                 GcOptions
                                     .builder()
                                     .markOnly(true)
                                     .build(),
                                 GcOutput.class)
        .toCompletableFuture().get();
    fail();
  } catch (ExecutionException e) {
    assertSame(RktLauncherRemoteHttpException.class, e.getCause().getClass());
    assertEquals(400, ((RktLauncherRemoteHttpException) e.getCause()).getCode());
  }
}
 
开发者ID:honnix,项目名称:rkt-launcher,代码行数:20,代码来源:RktCommandHelperTest.java

示例4: testBulkLoadUncheckedException

import java.util.concurrent.ExecutionException; //导入依赖的package包/类
public void testBulkLoadUncheckedException() throws ExecutionException {
  Exception e = new RuntimeException();
  CacheLoader<Object, Object> loader = exceptionLoader(e);
  LoadingCache<Object, Object> cache = CacheBuilder.newBuilder()
      .recordStats()
      .build(bulkLoader(loader));
  CacheStats stats = cache.stats();
  assertEquals(0, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(0, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());

  try {
    cache.getAll(asList(new Object()));
    fail();
  } catch (UncheckedExecutionException expected) {
    assertSame(e, expected.getCause());
  }
  stats = cache.stats();
  assertEquals(1, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(1, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:25,代码来源:CacheLoadingTest.java

示例5: callAsync

import java.util.concurrent.ExecutionException; //导入依赖的package包/类
/**
 * This method is used to formulate an asynchronous api call on the base of the
 * given parameters and return a {@link HttpResponse}
 *
 * @param httpRequest,
 *            a prepared {@link HttpRequest} used for api call
 * @param consumerOnSuccess,
 *            the consumer used to handle success response
 * @param consumerOnError,
 *            the consumer used to handle error response
 * @param attempts,
 *            the number of attempts to test if an error occurs during the api
 *            call
 * @throws ExecutionException
 *             if a problem occurred during the retrieving of REST client
 */
public static void callAsync(HttpRequest httpRequest, Consumer<HttpResponse> consumerOnSuccess,
		Consumer<Throwable> consumerOnError, int attempts) throws ExecutionException {
	// prepare the call
	Call<ResponseBody> call = prepareCall(httpRequest);
	if (call == null) {
		LOGGER.error("Call cannot be null");
		return;
	}
	if (consumerOnSuccess == null) {
		LOGGER.error("Async consumer on success cannot be null");
		return;
	}
	Date startTime = new Date();
	// make asynchronous http request and get http response
	enqueueCall(call, consumerOnSuccess, consumerOnError, attempts, startTime);
}
 
开发者ID:lucapompei,项目名称:ReactiveRest,代码行数:33,代码来源:RestService.java

示例6: testProducerFencedException

import java.util.concurrent.ExecutionException; //导入依赖的package包/类
@Test(expected = ExecutionException.class)
public void testProducerFencedException() throws InterruptedException, ExecutionException {
    final long pid = 13131L;
    final short epoch = 1;

    doInitTransactions(pid, epoch);

    transactionManager.beginTransaction();
    transactionManager.maybeAddPartitionToTransaction(tp0);

    Future<RecordMetadata> responseFuture = accumulator.append(tp0, time.milliseconds(), "key".getBytes(),
            "value".getBytes(), Record.EMPTY_HEADERS, null, MAX_BLOCK_TIMEOUT).future;

    assertFalse(responseFuture.isDone());
    prepareAddPartitionsToTxnResponse(Errors.NONE, tp0, epoch, pid);
    prepareProduceResponse(Errors.INVALID_PRODUCER_EPOCH, pid, epoch);
    sender.run(time.milliseconds()); // Add partitions.

    sender.run(time.milliseconds());  // send produce.

    assertTrue(responseFuture.isDone());
    assertTrue(transactionManager.hasError());
    responseFuture.get();
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:25,代码来源:TransactionManagerTest.java

示例7: testCoordinationLifecycle

import java.util.concurrent.ExecutionException; //导入依赖的package包/类
@Test
public void testCoordinationLifecycle() throws InterruptedException, ExecutionException {
    CarService carService = getCarService("em");
    assertNoCars(carService);
    Runnable carLifeCycle = getService(Runnable.class, "(type=carCoordinated)");
    carLifeCycle.run();
    ExecutorService exec = Executors.newFixedThreadPool(20);
    List<Future<?>> futures = new ArrayList<Future<?>>();
    for (int c=0; c<100; c++) {
        futures.add(exec.submit(carLifeCycle));
    }
    exec.shutdown();
    exec.awaitTermination(30, TimeUnit.SECONDS);
    for (Future<?> future : futures) {
        future.get();
    }
    assertNoCars(carService);
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:19,代码来源:BlueprintTest.java

示例8: testSeparateWrites

import java.util.concurrent.ExecutionException; //导入依赖的package包/类
@Test
public void testSeparateWrites() throws InterruptedException, TimeoutException, ExecutionException {

    DataBroker dataBroker = testContext.getDataBroker();

    final SettableFuture<AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject>> eventFuture =
            SettableFuture.create();
    dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, DEEP_WILDCARDED_PATH,
        dataChangeEvent -> eventFuture.set(dataChangeEvent), DataChangeScope.SUBTREE);

    final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
    transaction.put(LogicalDatastoreType.OPERATIONAL, NODE_0_CWU_PATH, CWU, true);
    transaction.put(LogicalDatastoreType.OPERATIONAL, NODE_0_LVU_PATH, LVU, true);
    transaction.put(LogicalDatastoreType.OPERATIONAL, NODE_1_LVU_PATH, LVU, true);
    transaction.submit().get(5, TimeUnit.SECONDS);

    AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = eventFuture.get(1000, TimeUnit.MILLISECONDS);

    validateEvent(event);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:WildcardedDataChangeListenerTest.java

示例9: main

import java.util.concurrent.ExecutionException; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException, IOException, ExecutionException {

        setGlobalUncaughtExceptionHandler();

        String conf = System.getProperty("canal-es.properties", "classpath:canal-es.properties");

        Properties properties = getProperties(conf);

        TotoroBootStrap canalScheduler = new TotoroBootStrap(properties);
        canalScheduler.start();

        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            try {
                logger.info("## stop the totoro server");
                canalScheduler.stop();
            } catch (Throwable e) {
                logger.warn("##something goes wrong when stopping totoro Server:", e);
            } finally {
                logger.info("## totoro server is down.");
            }
        }));

    }
 
开发者ID:zhongchengxcr,项目名称:canal-elasticsearch,代码行数:24,代码来源:TotoroLauncher.java

示例10: loadProjectList_callback_registers_exception_on_ack_future

import java.util.concurrent.ExecutionException; //导入依赖的package包/类
@Test
public void loadProjectList_callback_registers_exception_on_ack_future( ) throws Exception {
    // Setup
    when( _mockRequestController.sendRequest( getApiVersion( ), "projects", ProjectList.class ) )
            .thenReturn( Futures.immediateFailedFuture( new RuntimeException( "Unexpected test exception" ) ) );
    // Exercise
    final ListenableFuture<Void> ackFuture = _apiController.loadProjectList( );
    // Verify
    try {
        ackFuture.get( );
    } catch ( ExecutionException e ) {
        if ( e.getCause( ).getClass( ) == RuntimeException.class && e.getCause( ).getMessage( ).equals( "Unexpected test exception" ) )
            return;
    }
    TestCase.fail( );
}
 
开发者ID:u2032,项目名称:wall-t,代码行数:17,代码来源:ApiControllerTest.java

示例11: testGetAllJobStatusChangesObservableEmitsExpectedEventsWhenAborted

import java.util.concurrent.ExecutionException; //导入依赖的package包/类
@Test
public void testGetAllJobStatusChangesObservableEmitsExpectedEventsWhenAborted() throws InterruptedException, ExecutionException, TimeoutException {
    final JobExecutionResult executorResult = new JobExecutionResult(ABORTED);
    final JobExecutor executor = MockJobExecutor.thatResolvesWith(executorResult);
    final JobManager jobManager = createManagerWith(executor);

    final List<JobStatus> statusesEmitted = new ArrayList<>();
    jobManager.allJobStatusChanges()
            .map(JobEvent::getNewStatus)
            .subscribe(statusesEmitted::add);

    final Pair<JobId, CancelablePromise<FinalizedJob>> ret =
            jobManager.submit(STANDARD_VALID_REQUEST);

    ret.getRight().get(DEFAULT_TIMEOUT, MILLISECONDS);

    assertThat(statusesEmitted).isEqualTo(asList(SUBMITTED, RUNNING, ABORTED));
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:19,代码来源:JobManagerTest.java

示例12: compute

import java.util.concurrent.ExecutionException; //导入依赖的package包/类
@Override protected Double compute() {
  if (endPos <= startPos) {
    return 0.0;
  }
  if (endPos - startPos == 1) {
    if (splits[startPos] != null) {
      return splits[startPos].squaredNorm();
    } else {
      return 0.0;
    }
  } else {
    int middle = (startPos + endPos) / 2;
    SquaredNormOp opLeft = new SquaredNormOp(splits, startPos, middle);
    SquaredNormOp opRight = new SquaredNormOp(splits, middle, endPos);
    invokeAll(opLeft, opRight);

    try {
      return opLeft.get() + opRight.get();
    } catch (InterruptedException | ExecutionException e) {
      LOG.error("NNZCounterOp failed " + e.getMessage());
      return 0.0;
    }
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:25,代码来源:CompDoubleVector.java

示例13: testBulkLoadNull

import java.util.concurrent.ExecutionException; //导入依赖的package包/类
public void testBulkLoadNull() throws ExecutionException {
  LoadingCache<Object, Object> cache = CacheBuilder.newBuilder()
      .recordStats()
      .build(bulkLoader(constantLoader(null)));
  CacheStats stats = cache.stats();
  assertEquals(0, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(0, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());

  try {
    cache.getAll(asList(new Object()));
    fail();
  } catch (InvalidCacheLoadException expected) {}
  stats = cache.stats();
  assertEquals(1, stats.missCount());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(1, stats.loadExceptionCount());
  assertEquals(0, stats.hitCount());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:21,代码来源:CacheLoadingTest.java

示例14: submitTransaction

import java.util.concurrent.ExecutionException; //导入依赖的package包/类
@Override
public Future<Transaction> submitTransaction(Transaction transaction) {

    TransactionTask transactionTask = new TransactionTask(transaction, channelManager);

    final Future<List<Transaction>> listFuture =
            TransactionExecutor.instance.submitTransaction(transactionTask);

    pendingState.addPendingTransaction(transaction);

    return new FutureAdapter<Transaction, List<Transaction>>(listFuture) {
        @Override
        protected Transaction adapt(List<Transaction> adapteeResult) throws ExecutionException {
            return adapteeResult.get(0);
        }
    };
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:18,代码来源:EthereumImpl.java

示例15: testMintingLarge2

import java.util.concurrent.ExecutionException; //导入依赖的package包/类
@Test
public void testMintingLarge2() throws ExecutionException, InterruptedException {
    dataBtc(1).dataBtc(2);
    rateBtc(101, 1_050_001);
    rateBtc(102, 7);

    int current = 0;
    current = minting.mint(current, 100, 0, 1 * 100_000_000, 0, "w1");
    Assert.assertEquals(0, current);
    current = minting.mint(current, 102, 0, 1 * 100_000_000, 0, "w2");

    Assert.assertEquals(14, current);

    Iterator<Token> it = tokenRepository.findAllByOrderByWalletAddress().iterator();
    Assert.assertEquals(14,  it.next().getAmount().intValue());
}
 
开发者ID:modum-io,项目名称:tokenapp-backend,代码行数:17,代码来源:TestMinting.java


注:本文中的java.util.concurrent.ExecutionException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。