scala.concurrent.Future.isCompleted()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中scala.concurrent.Future.isCompleted()方法的一些代码示例,展示了Future.isCompleted()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Future.isCompleted()方法的具体详情如下:
包路径:scala.concurrent.Future
类名称:Future
方法名:isCompleted

Future.isCompleted介绍

暂无

代码示例

代码示例来源:origin: org.apache.flink/flink-runtime_2.10

@Override
public boolean isDone() {
  return scalaFuture.isCompleted();
}

代码示例来源:origin: org.apache.servicecomb.saga/saga-core-akka

@Override
public boolean isTerminated() {
 return actorSystem.whenTerminated().isCompleted();
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.11

@Override
public void run() {
  try {
    while (running && (monitored == null || !monitored.whenTerminated().isCompleted())) {
      logger.info(getMemoryUsageStatsAsString(memoryBean));
      logger.info(getDirectMemoryStatsAsString(directBufferBean));
      logger.info(getMemoryPoolStatsAsString(poolBeans));
      logger.info(getGarbageCollectorStatsAsString(gcBeans));
      
      try {
        Thread.sleep(interval);
      }
      catch (InterruptedException e) {
        if (running) {
          throw e;
        }
      }
    }
  }
  catch (Throwable t) {
    logger.error("Memory logger terminated with exception", t);
  }
}

代码示例来源:origin: org.apache.flink/flink-runtime

@Override
public void run() {
  try {
    while (running && (monitored == null || !monitored.whenTerminated().isCompleted())) {
      logger.info(getMemoryUsageStatsAsString(memoryBean));
      logger.info(getDirectMemoryStatsAsString(directBufferBean));
      logger.info(getMemoryPoolStatsAsString(poolBeans));
      logger.info(getGarbageCollectorStatsAsString(gcBeans));
      
      try {
        Thread.sleep(interval);
      }
      catch (InterruptedException e) {
        if (running) {
          throw e;
        }
      }
    }
  }
  catch (Throwable t) {
    logger.error("Memory logger terminated with exception", t);
  }
}

代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore

@Override
public ListenableFuture<Void> abort() {
  dataTree.startAbort(this);
  state = State.ABORTED;
  final Optional<Future<Iterable<Object>>> maybeAborts = userCohorts.abort();
  if (!maybeAborts.isPresent()) {
    return VOID_FUTURE;
  }
  final Future<Iterable<Object>> aborts = maybeAborts.get();
  if (aborts.isCompleted()) {
    return VOID_FUTURE;
  }
  final SettableFuture<Void> ret = SettableFuture.create();
  aborts.onComplete(new OnComplete<Iterable<Object>>() {
    @Override
    public void onComplete(final Throwable failure, final Iterable<Object> objs) {
      if (failure != null) {
        ret.setException(failure);
      } else {
        ret.set(null);
      }
    }
  }, ExecutionContexts.global());
  return ret;
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.10

if (cachedFuture.isCompleted() &&
  cachedFuture.value().get().isFailure()) {

代码示例来源:origin: org.apache.flink/flink-runtime-web_2.10

/**
 * Returns the currently known leading job manager gateway and its web monitor port.
 */
public Option<Tuple2<ActorGateway, Integer>> getJobManagerGatewayAndWebPort() throws Exception {
  if (leaderGatewayPortFuture != null) {
    Future<Tuple2<ActorGateway, Integer>> gatewayPortFuture = leaderGatewayPortFuture;
    if (gatewayPortFuture.isCompleted()) {
      Tuple2<ActorGateway, Integer> gatewayPort = Await.result(gatewayPortFuture, timeout);
      return Option.apply(gatewayPort);
    } else {
      return Option.empty();
    }
  } else {
    return Option.empty();
  }
}

代码示例来源:origin: opendaylight/controller

@Test(expected = SchemaSourceException.class)
public void testGetNonExistentYangTextSchemaSource() throws Exception {
  Mockito.when(mockedLocalRepository.getSchemaSource(ID, YangTextSchemaSource.class)).thenReturn(
      Futures.immediateFailedCheckedFuture(
          new SchemaSourceException("Source is not provided")));
  Future<YangTextSchemaSourceSerializationProxy> retrievedSourceFuture =
      remoteRepository.getYangTextSchemaSource(ID);
  assertTrue(retrievedSourceFuture.isCompleted());
  Await.result(retrievedSourceFuture, FiniteDuration.Zero());
}

代码示例来源:origin: org.apache.flink/flink-runtime-web_2.10

@Override
public void channelRead0(ChannelHandlerContext ctx, Routed routed) throws Exception {
  if (localJobManagerAddressFuture.isCompleted()) {
    if (localJobManagerAddress == null) {
      localJobManagerAddress = Await.result(localJobManagerAddressFuture, timeout);

代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore

final TransactionContextWrapper newTransactionContextWrapper(final TransactionProxy parent, final String shardName) {
  final TransactionContextWrapper transactionContextWrapper =
      new TransactionContextWrapper(parent.getIdentifier(), actorContext);
  Future<PrimaryShardInfo> findPrimaryFuture = findPrimaryShard(shardName, parent.getIdentifier());
  if(findPrimaryFuture.isCompleted()) {
    Try<PrimaryShardInfo> maybe = findPrimaryFuture.value().get();
    if(maybe.isSuccess()) {
      onFindPrimaryShardSuccess(maybe.get(), parent, shardName, transactionContextWrapper);
    } else {
      onFindPrimaryShardFailure(maybe.failed().get(), parent, shardName, transactionContextWrapper);
    }
  } else {
    findPrimaryFuture.onComplete(new OnComplete<PrimaryShardInfo>() {
      @Override
      public void onComplete(final Throwable failure, final PrimaryShardInfo primaryShardInfo) {
        if (failure == null) {
          onFindPrimaryShardSuccess(primaryShardInfo, parent, shardName, transactionContextWrapper);
        } else {
          onFindPrimaryShardFailure(failure, parent, shardName, transactionContextWrapper);
        }
      }
    }, actorContext.getClientDispatcher());
  }
  return transactionContextWrapper;
}

代码示例来源:origin: opendaylight/controller

@Test
public void testGetExistingYangTextSchemaSource() throws Exception {
  String source = "Test source.";
  YangTextSchemaSource schemaSource = YangTextSchemaSource.delegateForByteSource(
      ID, ByteSource.wrap(source.getBytes()));
  Mockito.when(mockedLocalRepository.getSchemaSource(ID, YangTextSchemaSource.class)).thenReturn(
      Futures.immediateCheckedFuture(schemaSource));
  Future<YangTextSchemaSourceSerializationProxy> retrievedSourceFuture =
      remoteRepository.getYangTextSchemaSource(ID);
  assertTrue(retrievedSourceFuture.isCompleted());
  YangTextSchemaSource resultSchemaSource = Await.result(retrievedSourceFuture,
      FiniteDuration.Zero()).getRepresentation();
  assertEquals(resultSchemaSource.getIdentifier(), schemaSource.getIdentifier());
  assertArrayEquals(resultSchemaSource.read(), schemaSource.read());
}

代码示例来源:origin: org.apache.flink/flink-runtime-web_2.10

@Override
protected void channelRead0(ChannelHandlerContext ctx, Routed routed) throws Exception {
  if (localJobManagerAddressFuture.isCompleted()) {
    if (localJobManagerAddress == null) {
      localJobManagerAddress = Await.result(localJobManagerAddressFuture, timeout);
    }
    Option<Tuple2<ActorGateway, Integer>> jobManager = retriever.getJobManagerGatewayAndWebPort();
    if (jobManager.isDefined()) {
      Tuple2<ActorGateway, Integer> gatewayPort = jobManager.get();
      String redirectAddress = HandlerRedirectUtils.getRedirectAddress(
        localJobManagerAddress, gatewayPort);
      if (redirectAddress != null) {
        HttpResponse redirect = HandlerRedirectUtils.getRedirectResponse(redirectAddress, routed.path(),
          httpsEnabled);
        KeepAliveWrite.flush(ctx, routed.request(), redirect);
      }
      else {
        respondAsLeader(ctx, routed, gatewayPort._1());
      }
    } else {
      KeepAliveWrite.flush(ctx, routed.request(), HandlerRedirectUtils.getUnavailableResponse());
    }
  } else {
    KeepAliveWrite.flush(ctx, routed.request(), HandlerRedirectUtils.getUnavailableResponse());
  }
}

代码示例来源:origin: org.apache.flink/flink-runtime

while (!jobSubmissionFuture.isCompleted()) {
  try {
    Await.ready(jobSubmissionFuture, askTimeout);
      if (!jobSubmissionFuture.isCompleted()) {
        throw new JobExecutionException(
          jobID,

代码示例来源:origin: org.apache.flink/flink-runtime_2.11

while (!jobSubmissionFuture.isCompleted()) {
  try {
    Await.ready(jobSubmissionFuture, askTimeout);
      if (!jobSubmissionFuture.isCompleted()) {
        throw new JobExecutionException(
          jobID,

代码示例来源:origin: com.alibaba.blink/flink-runtime

while (!jobSubmissionFuture.isCompleted()) {
  try {
    Await.ready(jobSubmissionFuture, askTimeout);
      if (!jobSubmissionFuture.isCompleted()) {
        throw new JobExecutionException(
          jobID,

代码示例来源:origin: org.apache.flink/flink-runtime_2.10

while (!jobSubmissionFuture.isCompleted()) {
  try {
    Await.ready(jobSubmissionFuture, askTimeout);
      if (!jobSubmissionFuture.isCompleted()) {
        throw new JobExecutionException(
          jobID,

相关文章