Java 类akka.actor.InvalidActorNameException 实例源码

项目:hashsdn-controller    文件:AbstractRaftActorIntegrationTest.java   
protected TestActorRef<TestRaftActor> newTestRaftActor(String id, TestRaftActor.Builder builder) {
    builder.collectorActor(factory.createActor(
            MessageCollectorActor.props(), factory.generateActorId(id + "-collector"))).id(id);

    InvalidActorNameException lastEx = null;
    for (int i = 0; i < 10; i++) {
        try {
            return factory.createTestActor(builder.props().withDispatcher(Dispatchers.DefaultDispatcherId())
                    .withMailbox(Mailboxes.DefaultMailboxId()), id);
        } catch (InvalidActorNameException e) {
            lastEx = e;
            Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
        }
    }

    assertNotNull(lastEx);
    throw lastEx;
}
项目:hashsdn-controller    文件:TestActorFactory.java   
/**
 * Create a test actor with the passed in name.
 *
 * @param props the actor Props
 * @param actorId name of actor
 * @param <T> the actor type
 * @return the ActorRef
 */
@SuppressWarnings("unchecked")
public <T extends Actor> TestActorRef<T> createTestActor(Props props, String actorId) {
    InvalidActorNameException lastError = null;
    for (int i = 0; i < 10; i++) {
        try {
            TestActorRef<T> actorRef = TestActorRef.create(system, props, actorId);
            return (TestActorRef<T>) addActor(actorRef, true);
        } catch (InvalidActorNameException e) {
            lastError = e;
            Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
        }
    }

    throw lastError;
}
项目:iotplatform    文件:SessionManagerActor.java   
private void forwardToSessionActor(SessionAwareMsg msg) {
  if (msg instanceof ToDeviceSessionActorMsg || msg instanceof SessionCloseMsg) {
    String sessionIdStr = msg.getSessionId().toUidStr();
    ActorRef sessionActor = sessionActors.get(sessionIdStr);
    if (sessionActor != null) {
      sessionActor.tell(msg, ActorRef.noSender());
    } else {
      log.debug("[{}] Session actor was already removed.", sessionIdStr);
    }
  } else {
    try {
      getOrCreateSessionActor(msg.getSessionId()).tell(msg, self());
    } catch (InvalidActorNameException e) {
      log.info("Invalid msg : {}", msg);
    }
  }
}