本文整理汇总了Java中akka.actor.Status类的典型用法代码示例。如果您正苦于以下问题:Java Status类的具体用法?Java Status怎么用?Java Status使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Status类属于akka.actor包,在下文中一共展示了Status类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onProducerRemoved
import akka.actor.Status; //导入依赖的package包/类
private void onProducerRemoved(final ProducerRemoved message) {
LOG.debug("Received ProducerRemoved: {}", message);
final List<CompletableFuture<Object>> futures = new ArrayList<>();
for (final String address : resolver.getShardingServicePeerActorAddresses()) {
final ActorSelection selection = actorSystem.actorSelection(address);
futures.add(FutureConverters.toJava(
actorContext.executeOperationAsync(selection, new NotifyProducerRemoved(message.getSubtrees())))
.toCompletableFuture());
}
final CompletableFuture<Void> combinedFuture = CompletableFuture.allOf(
futures.toArray(new CompletableFuture[futures.size()]));
final ActorRef respondTo = getSender();
combinedFuture
.thenRun(() -> respondTo.tell(new Status.Success(null), self()))
.exceptionally(e -> {
respondTo.tell(new Status.Failure(null), self());
return null;
});
}
示例2: testAddShardReplicaWithFindPrimaryTimeout
import akka.actor.Status; //导入依赖的package包/类
@Test
public void testAddShardReplicaWithFindPrimaryTimeout() throws Exception {
LOG.info("testAddShardReplicaWithFindPrimaryTimeout starting");
datastoreContextBuilder.shardInitializationTimeout(100, TimeUnit.MILLISECONDS);
new JavaTestKit(getSystem()) {
{
MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.<String, List<String>>builder()
.put("astronauts", Arrays.asList("member-2")).build());
final ActorRef newReplicaShardManager = actorFactory
.createActor(newTestShardMgrBuilder(mockConfig).shardActor(mockShardActor).props()
.withDispatcher(Dispatchers.DefaultDispatcherId()), shardMgrID);
newReplicaShardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
MockClusterWrapper.sendMemberUp(newReplicaShardManager, "member-2",
AddressFromURIString.parse("akka://[email protected]:5").toString());
newReplicaShardManager.tell(new AddShardReplica("astronauts"), getRef());
Status.Failure resp = expectMsgClass(duration("5 seconds"), Status.Failure.class);
assertEquals("Failure obtained", true, resp.cause() instanceof RuntimeException);
}
};
LOG.info("testAddShardReplicaWithFindPrimaryTimeout ending");
}
示例3: assignUsers
import akka.actor.Status; //导入依赖的package包/类
private void assignUsers(final StateObjectChangeMessage.Request request,
final SubjectState subjectState) {
try {
if (request.getStateObjectChangeDTO().getUserAssignments() == null
|| request.getStateObjectChangeDTO().getUserAssignments().isEmpty()) {
LOG.debug("All user assignements are done at the moment for P_ID [{}]", request.getPiId());
} else {
PatternsCS
.ask(getContext().parent(),
new AssignUsersMessage.Request(request.getPiId(),
request.getStateObjectChangeDTO().getUserAssignments()),
Global.TIMEOUT)
.toCompletableFuture().get();
}
triggerSendInternal(subjectState, request);
triggerSendExternal(subjectState, request);
triggerSendProcess(subjectState, request);
} catch (final Exception e) {
LOG.error(e.getMessage());
sender.tell(new Status.Failure(new IllegalStateException("Error: " + e.getMessage())),
getSelf());
}
}
示例4: triggerSendExternal
import akka.actor.Status; //导入依赖的package包/类
private void triggerSendExternal(final SubjectState subjectState,
final StateObjectChangeMessage.Request request) {
final List<MessageFlow> messageFlows = subjectState.getCurrentState().getMessageFlow().stream()
.filter(mf -> SubjectModelType.EXTERNAL.equals(mf.getReceiver().getSubjectModelType()))
.collect(Collectors.toList());
messageFlows.stream()
.map(mf -> getExternalOutputMessage(request.getPiId(), mf, subjectState.getSubject()))
.forEachOrdered(output -> {
LOG.debug("Send message to external-communicator [{}]", output);
externalCommunicatorClient.sendExternalOutputMessage(output);
subjectState.setToNotifiedEC();
});
if (messageFlows.size() >= 1) {
if (waitForECResponse(subjectState)) {
changeToNextState(subjectState, request);
} else {
sender.tell(new Status.Failure(new IllegalStateException(
"Could not send message to all external users in PI_ID [" + request.getPiId() + "]")),
getSelf());
}
}
}
示例5: testRequestLeadershipTransferToFollower2WithFollower2Lagging
import akka.actor.Status; //导入依赖的package包/类
@Test
public void testRequestLeadershipTransferToFollower2WithFollower2Lagging() {
testLog.info("testRequestLeadershipTransferToFollower2WithFollower2Lagging starting");
createRaftActors();
createRequestLeadershipResultCollectorActor();
sendPayloadWithFollower2Lagging();
sendFollower2RequestLeadershipTransferToLeader();
verifyRaftState(follower1Actor, RaftState.Follower);
verifyRaftState(follower2Actor, RaftState.Follower);
verifyRaftState(follower3Actor, RaftState.Follower);
Status.Failure failure = expectFirstMatching(requestLeadershipResultCollectorActor, Status.Failure.class);
assertTrue(failure.cause() instanceof LeadershipTransferFailedException);
testLog.info("testRequestLeadershipTransferToFollower2WithFollower2Lagging ending");
}
示例6: onMakeLeaderLocal
import akka.actor.Status; //导入依赖的package包/类
private void onMakeLeaderLocal() {
LOG.debug("{}: onMakeLeaderLocal received", persistenceId());
if (isLeader()) {
getSender().tell(new Status.Success(null), getSelf());
return;
}
final ActorSelection leader = getLeader();
if (leader == null) {
// Leader is not present. The cluster is most likely trying to
// elect a leader and we should let that run its normal course
// TODO we can wait for the election to complete and retry the
// request. We can also let the caller retry by sending a flag
// in the response indicating the request is "reTryable".
getSender().tell(new Failure(
new LeadershipTransferFailedException("We cannot initiate leadership transfer to local node. "
+ "Currently there is no leader for " + persistenceId())),
getSelf());
return;
}
leader.tell(new RequestLeadership(getId(), getSender()), getSelf());
}
示例7: registerCohort
import akka.actor.Status; //导入依赖的package包/类
@SuppressWarnings("checkstyle:IllegalCatch")
void registerCohort(final ActorRef sender, final RegisterCohort cohort) {
takeLock();
try {
final ActorRef cohortRef = cohort.getCohort();
final RegistrationTreeNode<ActorRef> node =
findNodeFor(cohort.getPath().getRootIdentifier().getPathArguments());
addRegistration(node, cohort.getCohort());
cohortToNode.put(cohortRef, node);
} catch (final Exception e) {
sender.tell(new Status.Failure(e), ActorRef.noSender());
return;
} finally {
releaseLock();
}
sender.tell(new Status.Success(null), ActorRef.noSender());
}
示例8: onGetShardRole
import akka.actor.Status; //导入依赖的package包/类
private void onGetShardRole(final GetShardRole message) {
LOG.debug("{}: onGetShardRole for shard: {}", persistenceId(), message.getName());
final String name = message.getName();
final ShardInformation shardInformation = localShards.get(name);
if (shardInformation == null) {
LOG.info("{}: no shard information for {} found", persistenceId(), name);
getSender().tell(new Status.Failure(
new IllegalArgumentException("Shard with name " + name + " not present.")), ActorRef.noSender());
return;
}
getSender().tell(new GetShardRoleReply(shardInformation.getRole()), ActorRef.noSender());
}
示例9: onRemoveServerReply
import akka.actor.Status; //导入依赖的package包/类
private void onRemoveServerReply(final ActorRef originalSender, final ShardIdentifier shardId,
final RemoveServerReply replyMsg, final String leaderPath) {
shardReplicaOperationsInProgress.remove(shardId.getShardName());
LOG.debug("{}: Received {} for shard {}", persistenceId(), replyMsg, shardId.getShardName());
if (replyMsg.getStatus() == ServerChangeStatus.OK) {
LOG.debug("{}: Leader shard successfully removed the replica shard {}", persistenceId(),
shardId.getShardName());
originalSender.tell(new Status.Success(null), getSelf());
} else {
LOG.warn("{}: Leader failed to remove shard replica {} with status {}",
persistenceId(), shardId, replyMsg.getStatus());
Exception failure = getServerChangeException(RemoveServer.class, replyMsg.getStatus(), leaderPath, shardId);
originalSender.tell(new Status.Failure(failure), getSelf());
}
}
示例10: onCreateShard
import akka.actor.Status; //导入依赖的package包/类
@SuppressWarnings("checkstyle:IllegalCatch")
private void onCreateShard(final CreateShard createShard) {
LOG.debug("{}: onCreateShard: {}", persistenceId(), createShard);
Object reply;
try {
String shardName = createShard.getModuleShardConfig().getShardName();
if (localShards.containsKey(shardName)) {
LOG.debug("{}: Shard {} already exists", persistenceId(), shardName);
reply = new Status.Success(String.format("Shard with name %s already exists", shardName));
} else {
doCreateShard(createShard);
reply = new Status.Success(null);
}
} catch (Exception e) {
LOG.error("{}: onCreateShard failed", persistenceId(), e);
reply = new Status.Failure(e);
}
if (getSender() != null && !getContext().system().deadLetters().equals(getSender())) {
getSender().tell(reply, getSelf());
}
}
示例11: onNotifyProducerRemoved
import akka.actor.Status; //导入依赖的package包/类
private void onNotifyProducerRemoved(final NotifyProducerRemoved message) {
LOG.debug("Received NotifyProducerRemoved: {}", message);
final ActorProducerRegistration registration = idToProducer.remove(message.getSubtrees().iterator().next());
if (registration == null) {
LOG.warn("The notification contained a path on which no producer is registered, throwing away");
getSender().tell(new Status.Success(null), noSender());
return;
}
try {
registration.close();
getSender().tell(new Status.Success(null), noSender());
} catch (final DOMDataTreeProducerException e) {
LOG.error("Unable to close producer", e);
getSender().tell(new Status.Failure(e), noSender());
}
}
示例12: run
import akka.actor.Status; //导入依赖的package包/类
@Override
public void run() {
final Future<Object> ask = Patterns.ask(shard, FindLeader.INSTANCE, context.getOperationTimeout());
ask.onComplete(new OnComplete<Object>() {
@Override
public void onComplete(final Throwable throwable, final Object findLeaderReply) throws Throwable {
if (throwable != null) {
tryReschedule(throwable);
} else {
final FindLeaderReply findLeader = (FindLeaderReply) findLeaderReply;
final java.util.Optional<String> leaderActor = findLeader.getLeaderActor();
if (leaderActor.isPresent()) {
// leader is found, backend seems ready, check if the frontend is ready
LOG.debug("{} - Leader for config shard is ready. Ending lookup.",
clusterWrapper.getCurrentMemberName());
replyTo.tell(new Status.Success(null), noSender());
} else {
tryReschedule(null);
}
}
}
}, system.dispatcher());
}
示例13: onReceive
import akka.actor.Status; //导入依赖的package包/类
@Override
public void onReceive(Object message) throws InterpreterException {
if (message instanceof InterpreterInterface.SubmoduleOutPortHasSignal) {
moduleOutPortHasSignal(((InterpreterInterface.SubmoduleOutPortHasSignal) message).getOutPortId());
} else if (message instanceof InstanceProvider) {
setInstanceProvider((InstanceProvider) message);
} else if (message instanceof RuntimeContext) {
setRuntimeContext((RuntimeContext) message);
} else if (message == TopLevelInterpreterActorInterface.Start.INSTANCE) {
startRunning();
} else if (message instanceof Props) {
start((Props) message);
} else if (message instanceof Terminated) {
childActorTerminated(((Terminated) message).actor());
} else if (message instanceof Status.Failure) {
failure(((Status.Failure) message).cause());
} else {
super.onReceive(message);
}
}
示例14: cancel
import akka.actor.Status; //导入依赖的package包/类
void cancel(long executionId, Throwable throwable) {
ActorRef child = getContext().getChild(String.valueOf(executionId));
if (child != null) {
if (!scheduledTerminations.containsKey(child)) {
getContext().watch(child);
child.tell(new Status.Failure(throwable), getSelf());
// Give the top-level interpreter some time to finish. Otherwise, we will terminate it after a timeout.
Cancellable scheduledTermination = getContext().system().scheduler().scheduleOnce(
Duration.create(1, TimeUnit.MINUTES),
child,
PoisonPill.getInstance(),
getContext().dispatcher(),
getSelf()
);
scheduledTerminations.put(child, scheduledTermination);
}
} else {
log.warning("Request to cancel unknown execution {} because of: {}", executionId, throwable);
}
}
示例15: handleMessage
import akka.actor.Status; //导入依赖的package包/类
@Override
public void handleMessage(Object message) throws Exception {
if (message instanceof LookupKvStateLocation) {
// Add to received lookups queue
receivedLookups.add((LookupKvStateLocation) message);
Object msg = lookupResponses.poll();
if (msg != null) {
if (msg instanceof Throwable) {
sender().tell(new Status.Failure((Throwable) msg), self());
} else {
sender().tell(new Status.Success(msg), self());
}
}
} else if (message instanceof UUID) {
this.leaderSessionId = (UUID) message;
} else {
LOG.debug("Received unhandled message: {}", message);
}
}