本文整理了Java中scala.concurrent.Future.onFailure()
方法的一些代码示例,展示了Future.onFailure()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Future.onFailure()
方法的具体详情如下:
包路径:scala.concurrent.Future
类名称:Future
方法名:onFailure
暂无
代码示例来源:origin: org.apache.flink/flink-runtime-web_2.10
private void logErrorOnFailure(Future<Object> future, final String message) {
future.onFailure(new OnFailure() {
@Override
public void onFailure(Throwable failure) throws Throwable {
LOG.debug(message, failure);
}
}, ctx);
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.11
@Override
public void notifyPartitionConsumable(JobID jobId, final ResultPartitionID partitionId, final TaskActions taskActions) {
final JobManagerMessages.ScheduleOrUpdateConsumers msg = new JobManagerMessages.ScheduleOrUpdateConsumers(jobId, partitionId);
Future<Object> futureResponse = jobManager.ask(msg, jobManagerMessageTimeout);
futureResponse.onFailure(new OnFailure() {
@Override
public void onFailure(Throwable failure) {
LOG.error("Could not schedule or update consumers at the JobManager.", failure);
taskActions.failExternally(new RuntimeException("Could not notify JobManager to schedule or update consumers", failure));
}
}, executionContext);
}
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.10
@Override
public void notifyPartitionConsumable(JobID jobId, final ResultPartitionID partitionId, final TaskActions taskActions) {
final JobManagerMessages.ScheduleOrUpdateConsumers msg = new JobManagerMessages.ScheduleOrUpdateConsumers(jobId, partitionId);
Future<Object> futureResponse = jobManager.ask(msg, jobManagerMessageTimeout);
futureResponse.onFailure(new OnFailure() {
@Override
public void onFailure(Throwable failure) {
LOG.error("Could not schedule or update consumers at the JobManager.", failure);
taskActions.failExternally(new RuntimeException("Could not notify JobManager to schedule or update consumers", failure));
}
}, executionContext);
}
}
代码示例来源:origin: org.apache.flink/flink-runtime
@Override
public void notifyPartitionConsumable(JobID jobId, final ResultPartitionID partitionId, final TaskActions taskActions) {
final JobManagerMessages.ScheduleOrUpdateConsumers msg = new JobManagerMessages.ScheduleOrUpdateConsumers(jobId, partitionId);
Future<Object> futureResponse = jobManager.ask(msg, jobManagerMessageTimeout);
futureResponse.onFailure(new OnFailure() {
@Override
public void onFailure(Throwable failure) {
LOG.error("Could not schedule or update consumers at the JobManager.", failure);
taskActions.failExternally(new RuntimeException("Could not notify JobManager to schedule or update consumers", failure));
}
}, executionContext);
}
}
代码示例来源:origin: com.alibaba.blink/flink-runtime
@Override
public void notifyPartitionConsumable(JobID jobId, final ResultPartitionID partitionId, final TaskActions taskActions) {
final JobManagerMessages.ScheduleOrUpdateConsumers msg = new JobManagerMessages.ScheduleOrUpdateConsumers(jobId, partitionId);
Future<Object> futureResponse = jobManager.ask(msg, jobManagerMessageTimeout);
futureResponse.onFailure(new OnFailure() {
@Override
public void onFailure(Throwable failure) {
LOG.error("Could not schedule or update consumers at the JobManager.", failure);
taskActions.failExternally(new RuntimeException("Could not notify JobManager to schedule or update consumers", failure));
}
}, executionContext);
}
}
代码示例来源: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: ks-no/eventstore2
((Future<Object>) result).onFailure(new OnFailure(){
代码示例来源:origin: ks-no/eventstore2
((Future<Object>) result).onFailure(new OnFailure(){
代码示例来源:origin: ks-no/eventstore2
private void tryToFillSubscription(final ActorRef sender, final Subscription subscription) {
final ActorRef self = self();
if (subscription instanceof AsyncSubscription) {
Future<Boolean> f = future(() -> {
log.info("Got async subscription on {} from {}, filling subscriptions", subscription, sender);
boolean finished = loadEvents(sender, subscription);
if (!finished) {
log.info("Async IncompleteSubscriptionPleaseSendNew");
sender.tell(new IncompleteSubscriptionPleaseSendNew(subscription.getAggregateType()), self);
} else {
log.info("Async CompleteAsyncSubscriptionPleaseSendSyncSubscription");
sender.tell(new CompleteAsyncSubscriptionPleaseSendSyncSubscription(subscription.getAggregateType()), self);
}
return finished;
}, getContext().system().dispatcher());
f.onFailure(new OnFailure() {
public void onFailure(Throwable failure) {
log.error("Error in AsyncSubscribe, restarting subscriber", failure);
sender.tell(new NewEventstoreStarting(), self);
}
}, getContext().system().dispatcher());
} else {
log.info("Sending subscription to singelton {} from {}", eventstoresingeltonProxy.path(), sender().path());
eventstoresingeltonProxy.tell(subscription, sender());
}
}
代码示例来源:origin: ks-no/eventstore2
private void tryToFillSubscription(final ActorRef sender, final Messages.AsyncSubscription subscription) {
final ActorRef self = self();
Future<Boolean> f = future(() -> {
log.info("Got async subscription on {} from {}, filling subscriptions", subscription, sender);
boolean finished = loadEvents(sender, subscription);
if (!finished) {
log.info("Async IncompleteSubscriptionPleaseSendNew");
sender.tell(Messages.IncompleteSubscriptionPleaseSendNew.newBuilder().setAggregateType(subscription.getAggregateType()).build(), self);
} else {
log.info("Async CompleteAsyncSubscriptionPleaseSendSyncSubscription");
sender.tell(Messages.CompleteAsyncSubscriptionPleaseSendSyncSubscription.newBuilder().setAggregateType(subscription.getAggregateType()).build(), self);
}
return finished;
}, getContext().system().dispatcher());
f.onFailure(new OnFailure() {
public void onFailure(Throwable failure) {
log.error("Error in AsyncSubscribe, restarting subscriber", failure);
sender.tell(new NewEventstoreStarting(), self);
}
}, getContext().system().dispatcher());
}
代码示例来源: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: 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()
);
}
内容来源于网络,如有侵权,请联系作者删除!