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

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

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

Future.onSuccess介绍

暂无

代码示例

代码示例来源:origin: wxyyxc1992/Backend-Boilerplates

public void run() {
 ask(frontend,
   new TransformationJob("hello-" + counter.incrementAndGet()),
   timeout).onSuccess(new OnSuccess<Object>() {
  public void onSuccess(Object result) {
   System.out.println(result);
  }
 }, ec);
}

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

/**
 * Requests a metric dump from the given actor.
 *
 * @param actor ActorRef to request the dump from
 */
private void queryMetrics(ActorRef actor) {
  Future<Object> metricQueryFuture = new BasicGateway(actor).ask(MetricQueryService.getCreateDump(), timeout);
  metricQueryFuture
    .onSuccess(new OnSuccess<Object>() {
      @Override
      public void onSuccess(Object result) throws Throwable {
        addMetrics(result);
      }
    }, ctx);
  logErrorOnFailure(metricQueryFuture, "Fetching metrics failed.");
}

代码示例来源:origin: dataArtisans/yahoo-streaming-benchmark

public Future<ActorRef> getActorRefFuture(K key) {
  final int partitionNumber = retrievalService.getPartitionID(key);
  synchronized (cacheLock) {
    ActorRef result = cache.get(partitionNumber);
    if(result != null) {
      return Futures.successful(result);
    }
  }
  LOG.debug("Retrieve actor URL from retrieval service.");
  String actorURL = retrievalService.retrieveActorURL(key);
  if (actorURL == null) {
    return Futures.failed(new Exception("Could not retrieve actor."));
  } else {
    ActorSelection selection = getContext().system().actorSelection(actorURL);
    LOG.debug("Resolve actor URL to ActorRef.");
    Future<ActorRef> actorRefFuture = selection.resolveOne(lookupTimeout);
    actorRefFuture.onSuccess(new OnSuccess<ActorRef>() {
      @Override
      public void onSuccess(ActorRef result) throws Throwable {
        synchronized (cacheLock) {
          cache.put(partitionNumber, result);
        }
      }
    }, executor);
    return actorRefFuture;
  }
}

代码示例来源:origin: baekjunlim/AkkaStarting

@Override
public void onReceive(Object message) throws Exception {
  if (message instanceof Integer) {
    Future<Object> future = Patterns.ask(child, message, timeout);
    
    // onSuccess, onComplete, onFailure 등은 blocking 동작이 아니다.
    future.onSuccess(new SaySuccess<Object>(), ec);
    future.onComplete(new SayComplete<Object>(), ec);
    future.onFailure(new SayFailure<Object>(), ec);
  } else if (message instanceof String) {
    log.info("NonblockingActor received a messasge: " + message);
  }
}

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

.onSuccess(new OnSuccess<Object>() {
  @Override
  public void onSuccess(Object result) throws Throwable {
.onSuccess(new OnSuccess<Object>() {
  @Override
  public void onSuccess(Object result) throws Throwable {

代码示例来源:origin: ks-no/eventstore2

final ActorRef sender = sender();
final ActorRef self = self();
((Future<Object>) result).onSuccess(new OnSuccess<Object>(){
  @Override
  public void onSuccess(Object result) throws Throwable {

代码示例来源:origin: ks-no/eventstore2

final ActorRef sender = sender();
final ActorRef self = self();
((Future<Object>) result).onSuccess(new OnSuccess<Object>(){
  @Override
  public void onSuccess(Object result) throws Throwable {

代码示例来源:origin: kodokojo/kodokojo

Future<Object> future = Patterns.ask(target, msg, eventBusOriginMessage.timeout());
Patterns.pipe(future, getContext().dispatcher()).to(sender);
future.onSuccess(new OnSuccess<Object>() {
  @Override
  public void onSuccess(Object result) throws Throwable {

代码示例来源:origin: keeps/roda

private static void startupSharedJournal(final ActorSystem system, boolean startStore, final ActorPath path) {
 // Start the shared journal on one node (don't crash this SPOF)
 // This will not be needed with a distributed journal
 if (startStore) {
  system.actorOf(Props.create(SharedLeveldbStore.class), "store");
 }
 // register the shared journal
 Timeout timeout = new Timeout(15, TimeUnit.SECONDS);
 ActorSelection actorSelection = system.actorSelection(path);
 Future<Object> f = Patterns.ask(actorSelection, new Identify(null), timeout);
 f.onSuccess(new OnSuccess<Object>() {
  @Override
  public void onSuccess(Object arg0) throws Throwable {
   if (arg0 instanceof ActorIdentity && ((ActorIdentity) arg0).getRef() != null) {
    SharedLeveldbJournal.setStore(((ActorIdentity) arg0).getRef(), system);
   } else {
    system.log().error("Lookup of shared journal at {} timed out", path);
    System.exit(-1);
   }
  }
 }, system.dispatcher());
 f.onFailure(new OnFailure() {
  @Override
  public void onFailure(Throwable ex) throws Throwable {
   system.log().error(ex, "Lookup of shared journal at {} timed out", path);
  }
 }, system.dispatcher());
}

代码示例来源:origin: ks-no/eventstore2

private void readAggregateEvents(Messages.RetreiveCorrelationIdEventsAsync retreiveAggregateEvents) {
  final ActorRef sender = sender();
  final ActorRef self = self();
  final Future<Messages.EventWrapperBatch> future = storage.loadEventWrappersForCorrelationIdAsync(retreiveAggregateEvents.getAggregateType(), retreiveAggregateEvents.getCorrelationId(), retreiveAggregateEvents.getFromJournalId());
  future.onSuccess(new OnSuccess<Messages.EventWrapperBatch>() {
    @Override
    public void onSuccess(Messages.EventWrapperBatch result) throws Throwable {
      sender.tell(result, self);
    }
  }, getContext().dispatcher());
  future.onFailure(new OnFailure() {
             @Override
             public void onFailure(Throwable failure) throws Throwable {
               log.error("failed to read events from journalstorage {} ", retreiveAggregateEvents, failure);
             }
           }, getContext().dispatcher()
  );
}

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

.onSuccess(new OnSuccess<ActorRef>() {
  @Override
  public void onSuccess(ActorRef result) throws Throwable {

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

.onSuccess(new OnSuccess<ActorRef>() {
  @Override
  public void onSuccess(ActorRef result) throws Throwable {

代码示例来源:origin: ks-no/eventstore2

private void readAggregateEvents(RetrieveAggregateEventsAsync retreiveAggregateEvents) {
  final ActorRef sender = sender();
  final ActorRef self = self();
  final Future<EventBatch> future = storage.loadEventsForAggregateIdAsync(retreiveAggregateEvents.getAggregateType(), retreiveAggregateEvents.getAggregateId(), retreiveAggregateEvents.getFromJournalId());
  future.onSuccess(new OnSuccess<EventBatch>() {
    @Override
    public void onSuccess(EventBatch result) throws Throwable {
      sender.tell(result, self);
    }
  }, getContext().dispatcher());
  future.onFailure(new OnFailure() {
             @Override
             public void onFailure(Throwable failure) throws Throwable {
               log.error("failed to read events from journalstorage {} ", retreiveAggregateEvents, failure);
             }
           }, getContext().dispatcher()
  );
}

代码示例来源:origin: ks-no/eventstore2

private void readAggregateEvents(Messages.RetreiveAggregateEventsAsync retreiveAggregateEvents) {
  final ActorRef sender = sender();
  final ActorRef self = self();
  final Future<Messages.EventWrapperBatch> future = storage.loadEventWrappersForAggregateIdAsync(retreiveAggregateEvents.getAggregateType(), retreiveAggregateEvents.getAggregateRootId(), retreiveAggregateEvents.getFromJournalId());
  future.onSuccess(new OnSuccess<Messages.EventWrapperBatch>() {
    @Override
    public void onSuccess(Messages.EventWrapperBatch result) throws Throwable {
      sender.tell(result, self);
    }
  }, getContext().dispatcher());
  future.onFailure(new OnFailure() {
             @Override
             public void onFailure(Throwable failure) throws Throwable {
               log.error("failed to read events from journalstorage {} ", retreiveAggregateEvents, failure);
             }
           }, getContext().dispatcher()
  );
}

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

.onSuccess(new OnSuccess<ActorRef>() {
  @Override
  public void onSuccess(ActorRef result) throws Throwable {

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

.onSuccess(new OnSuccess<ActorRef>() {
  @Override
  public void onSuccess(ActorRef result) throws Throwable {

相关文章