我正在研究akka演员(JAVA),最近才知道有3种方式(可能更多)知道演员的存在.
发送识别消息:
ActorSelection sel = actorSystem.actorSelection("akka://test/user/TestActor");
AskableActorSelection asker = new AskableActorSelection(sel);
Future<Object> future = asker.ask(new Identify(1), new Timeout(5,
TimeUnit.SECONDS));
ActorIdentity identity = (ActorIdentity) Await.result(future, timeOut.duration());
ActorRef reference = identity.getRef();
if(reference != null){
// Actor exists
} else {
// Actor does not exits
}
Run Code Online (Sandbox Code Playgroud)resolveOne方法:
ActorSelection sel = actorSystem.actorSelection("akka://test/user/TestActor");
Future<ActorRef> future = sel.resolveOne(new Timeout(5,
TimeUnit.SECONDS));
// Wait for the completion of task to be completed.
future.onComplete(new OnComplete<ActorRef>() {
@Override
public void onComplete(Throwable excp, ActorRef child)
throws Throwable { …Run Code Online (Sandbox Code Playgroud)在Mysql中我们可以查询具有子句" WHERE name LIKE'%someName%' "的表,我们可以在java中使用与HashMap相同的功能,如果是这样的话,我们如何通过不迭代每个元素在更短的时间内更有效地实现这一功能?