use of io.transport.cluster.actor.AccpetActor in project transporter by wang4ever.
the class ActorManager method actorCreate.
/**
* 创建一个actor
*
* @param actorName
* actor名称
* @return
*/
public ActorBean actorCreate(String actorName) {
// 1.0 Check info.
if (this._system == null)
throw new AkkaException("Create actor failed('" + actorName + "'), actor system is unnitialized.");
if (StringUtils.equalsIgnoreCase(actorName, ActorPath.DEFAULT_ACTOR_NAME) && this.defaultActorBean != null)
throw new AkkaException("Create actor failed, because the name '" + actorName + "' is the guardian.");
// 1.1 Create accpetActor.
try {
this._system.actorOf(Props.create(AccpetActor.class, actorName), actorName);
} catch (InvalidActorNameException e) {
if (logger.isInfoEnabled())
logger.info("Create an existing actor '{}'", actorName);
} catch (Throwable t) {
logger.error("Creating actor '" + actorName + "' failed.", t);
throw new AkkaException(t.getMessage(), t);
}
// 1.2 Selection actor info.
String path = new ActorPath(conf.getActorSystemName(), conf.getHostname(), conf.getRemote().getPort(), actorName).asString();
ActorSelection actorSel = this._system.actorSelection(path);
ActorBean ab = new ActorBean(actorSel.anchor(), path);
// Default actorBean.
if (StringUtils.equalsIgnoreCase(actorName, ActorPath.DEFAULT_ACTOR_NAME))
this.defaultActorBean = ab;
// 1.3 Save actor info.
this.repository.putActorBean(actorName, ab);
return ab;
}
Aggregations