Java 类akka.actor.ActorRefProvider 实例源码

项目:hashsdn-controller    文件:Gossiper.java   
@Override
public void preStart() {
    ActorRefProvider provider = getContext().provider();
    selfAddress = provider.getDefaultAddress();

    bucketStore = new BucketStoreAccess(getContext(), config.getAskDuration());

    if (provider instanceof ClusterActorRefProvider) {
        cluster = Cluster.get(getContext().system());
        cluster.subscribe(getSelf(),
                ClusterEvent.initialStateAsEvents(),
                ClusterEvent.MemberEvent.class,
                ClusterEvent.ReachableMember.class,
                ClusterEvent.UnreachableMember.class);
    }

    if (autoStartGossipTicks) {
        gossipTask = getContext().system().scheduler().schedule(
                new FiniteDuration(1, TimeUnit.SECONDS),        //initial delay
                config.getGossipTickInterval(),                 //interval
                getSelf(),                                      //target
                GOSSIP_TICK,                                    //message
                getContext().dispatcher(),                      //execution context
                getSelf()                                       //sender
        );
    }
}
项目:hashsdn-controller    文件:BucketStoreActor.java   
@Override
public void preStart() {
    ActorRefProvider provider = getContext().provider();
    selfAddress = provider.getDefaultAddress();

    if (provider instanceof ClusterActorRefProvider) {
        getContext().actorOf(Gossiper.props(config).withMailbox(config.getMailBoxName()), "gossiper");
    }
}