• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Member类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中akka.cluster.Member的典型用法代码示例。如果您正苦于以下问题:Java Member类的具体用法?Java Member怎么用?Java Member使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Member类属于akka.cluster包,在下文中一共展示了Member类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: waitForMembersUp

import akka.cluster.Member; //导入依赖的package包/类
public void waitForMembersUp(final String... otherMembers) {
    Set<String> otherMembersSet = Sets.newHashSet(otherMembers);
    Stopwatch sw = Stopwatch.createStarted();
    while (sw.elapsed(TimeUnit.SECONDS) <= 10) {
        CurrentClusterState state = Cluster.get(getSystem()).state();
        for (Member m: state.getMembers()) {
            if (m.status() == MemberStatus.up() && otherMembersSet.remove(m.getRoles().iterator().next())
                    && otherMembersSet.isEmpty()) {
                return;
            }
        }

        Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
    }

    fail("Member(s) " + otherMembersSet + " are not Up");
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:IntegrationTestKit.java


示例2: waitForMembersUp

import akka.cluster.Member; //导入依赖的package包/类
static void waitForMembersUp(final ActorSystem node, final UniqueAddress... addresses) {
    Set<UniqueAddress> otherMembersSet = Sets.newHashSet(addresses);
    Stopwatch sw = Stopwatch.createStarted();
    while (sw.elapsed(TimeUnit.SECONDS) <= 10) {
        CurrentClusterState state = Cluster.get(node).state();
        for (Member m : state.getMembers()) {
            if (m.status() == MemberStatus.up() && otherMembersSet.remove(m.uniqueAddress())
                    && otherMembersSet.isEmpty()) {
                return;
            }
        }

        Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
    }

    fail("Member(s) " + otherMembersSet + " are not Up");
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:RpcRegistryTest.java


示例3: register

import akka.cluster.Member; //导入依赖的package包/类
void register(Member member) {
    if (member.hasRole(Constants.CLUSTER_BACKEND)) {
        logger.info("Remote port:{} , nodes register.", member.address().port().get());
        getContext().watch(sender());

        String portStr = member.address().port().get().toString();
        clusterNodeRouters.put(Integer.valueOf(portStr.substring(portStr.length() - 2)), sender());
    }
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:10,代码来源:AbstractClusterFrontendActor.java


示例4: remove

import akka.cluster.Member; //导入依赖的package包/类
void remove(Member member) {
    if (member.hasRole(Constants.CLUSTER_BACKEND)) {
        logger.info("Remote port:{} , nodes remove.", member.address().port().get());
        getContext().unwatch(sender());
        clusterNodeRouters.inverse().remove(getSender());
    }
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:8,代码来源:AbstractClusterFrontendActor.java


示例5: createReceive

import akka.cluster.Member; //导入依赖的package包/类
@Override
    public Receive createReceive() {
        return receiveBuilder()
                .match(ApiRequest.class, this::onRequest)
                .match(ApiRequestForward.class, this::onForward)
                .match(MemberOfflineEvent.class, this::onOffline)
                .match(MemberOnlineEvent.class, this::onOnline)
                .match(BackendFindEvent.class, e -> getSender().tell(findFrontendSocket, getSelf()))

                .match(ClusterEvent.CurrentClusterState.class, state -> {
                    for (Member member : state.getMembers()) {
                        if (member.status().equals(MemberStatus.up())) {
                            register(member);
                        } else if (member.status().equals(MemberStatus.removed())) {
                            remove(member);
                        }
                    }
                })
                .match(ClusterEvent.MemberUp.class, mUp -> register(mUp.member()))
                .match(ClusterEvent.MemberRemoved.class, mRem -> remove(mRem.member()))
                .match(Terminated.class, t -> {
                    logger.info("Frontend {} left.", getSender());
//                    getContext().unwatch(getSender());
//                    ClusterChildNodeSystem.INSTANCE.removeRouterFronted();
                })
                .build();
    }
 
开发者ID:freedompy,项目名称:commelina,代码行数:28,代码来源:AbstractBackendActor.java


示例6: register

import akka.cluster.Member; //导入依赖的package包/类
void register(Member member) {
    if (member.hasRole(Constants.CLUSTER_FRONTEND)) {
        logger.info("Frontend port:{} , nodes register.", member.address().port().get());
        String frontendPath = member.address() + Constants.CLUSTER_FRONTEND_PATH;
        findFrontendSocket = BackendFindFrontend.newBuilder().setFrontendAddress(frontendPath).build();
    }
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:8,代码来源:AbstractBackendActor.java


示例7: receiveMemberRemoveOrUnreachable

import akka.cluster.Member; //导入依赖的package包/类
/**
 * Remove member from local copy of member list. If member down is self, then stop the actor
 *
 * @param member who went down
 */
private void receiveMemberRemoveOrUnreachable(final Member member) {
    LOG.debug("Received memberDown or Unreachable: {}", member);

    //if its self, then stop itself
    if (selfAddress.equals(member.address())) {
        getContext().stop(getSelf());
        return;
    }

    removePeer(member.address());
    LOG.debug("Removed member [{}], Active member list [{}]", member.address(), clusterMembers);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:Gossiper.java


示例8: receiveMemberUpOrReachable

import akka.cluster.Member; //导入依赖的package包/类
/**
 * Add member to the local copy of member list if it doesn't already.
 *
 * @param member the member to add
 */
private void receiveMemberUpOrReachable(final Member member) {
    LOG.debug("Received memberUp or reachable: {}", member);

    //ignore up notification for self
    if (selfAddress.equals(member.address())) {
        return;
    }

    addPeer(member.address());
    LOG.debug("Added member [{}], Active member list [{}]", member.address(), clusterMembers);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:Gossiper.java


示例9: onReceive

import akka.cluster.Member; //导入依赖的package包/类
@Override
public void onReceive(Object message) throws Throwable
{
  if (message instanceof ClusterEvent.MemberUp) {
    ClusterEvent.MemberUp event = (ClusterEvent.MemberUp) message;
    this.up(event.member());
  } else if (message instanceof ClusterEvent.CurrentClusterState) {
    ClusterEvent.CurrentClusterState state = (ClusterEvent.CurrentClusterState) message;
    Iterable<Member> members = state.getMembers();
    for (Member o : members) {
      if (o.status().equals(MemberStatus.up())) {
        this.up(o);
      }
    }
  } else if (message instanceof ClusterEvent.UnreachableMember) {
    ClusterEvent.UnreachableMember mUnreachable = (ClusterEvent.UnreachableMember) message;
    log.info("有个节点不可达: {}", mUnreachable.member());
  } else if (message instanceof ClusterEvent.MemberRemoved) {
    ClusterEvent.MemberRemoved mRemoved = (ClusterEvent.MemberRemoved) message;
    log.info("有节点被删掉: {}", mRemoved.member());
  } else if (message instanceof ClusterEvent.MemberEvent) {
    log.info("节点事件: {}", message);
  } else if (message instanceof Registration) {
    Registration r = (Registration) message;
    if (match(this.slaves, r.getService())) {
      getContext().watch(getSender());
      this.addService(getSender(), r.getService());
      log.info("register success! sender =" + getSender());
      log.info("register success! self =" + this.self());
    } else {
        log.info("register failed! r.service = " + r.getService());
        log.info("register failed! this.service=" + this.service);
    }
  } else if (message instanceof Terminated) {
    Terminated terminated = (Terminated) message;
    this.removeService(terminated.actor());
  } else {
    this.onMessage(message);
  }
}
 
开发者ID:beykery,项目名称:bakka,代码行数:41,代码来源:BaseActor.java


示例10: up

import akka.cluster.Member; //导入依赖的package包/类
/**
 * 向新加入节点注册自己
 *
 * @param member
 */
private void up(Member member)
{
  ActorSelection as = getContext().actorSelection(member.address() + "/user/*");
  if (as != null) {
    as.tell(new Registration(service), self());
  }
}
 
开发者ID:beykery,项目名称:bakka,代码行数:13,代码来源:BaseActor.java


示例11: remove

import akka.cluster.Member; //导入依赖的package包/类
void remove(Member member) {
    if (member.hasRole(Constants.CLUSTER_FRONTEND)) {
        logger.info("Frontend port:{} , nodes remove.", member.address().port().get());
        findFrontendSocket = BackendFindFrontend.getDefaultInstance();
    }
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:7,代码来源:AbstractBackendActor.java


示例12: memberToName

import akka.cluster.Member; //导入依赖的package包/类
@VisibleForTesting
static MemberName memberToName(final Member member) {
    return MemberName.forName(member.roles().iterator().next());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:5,代码来源:ShardManager.java


示例13: memberToName

import akka.cluster.Member; //导入依赖的package包/类
private static MemberName memberToName(final Member member) {
    return MemberName.forName(member.roles().iterator().next());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:4,代码来源:ShardedDataTreeActor.java


示例14: createMemberRemoved

import akka.cluster.Member; //导入依赖的package包/类
public static MemberRemoved createMemberRemoved(final String memberName, final String address) {
    UniqueAddress uniqueAddress = new UniqueAddress(AddressFromURIString.parse(address), 55L);
    Member member = new Member(uniqueAddress, 1, MemberStatus.removed(), setOf(memberName));

    return new MemberRemoved(member, MemberStatus.up());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:7,代码来源:MockClusterWrapper.java


示例15: createMemberUp

import akka.cluster.Member; //导入依赖的package包/类
public static MemberUp createMemberUp(final String memberName, final String address) {
    UniqueAddress uniqueAddress = new UniqueAddress(AddressFromURIString.parse(address), 55L);
    Member member = new Member(uniqueAddress, 1, MemberStatus.up(), setOf(memberName));

    return new MemberUp(member);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:7,代码来源:MockClusterWrapper.java


示例16: createUnreachableMember

import akka.cluster.Member; //导入依赖的package包/类
public static UnreachableMember createUnreachableMember(final String memberName, final String address) {
    UniqueAddress uniqueAddress = new UniqueAddress(AddressFromURIString.parse(address), 55L);
    Member member = new Member(uniqueAddress, 1, MemberStatus.up(), setOf(memberName));

    return new UnreachableMember(member);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:7,代码来源:MockClusterWrapper.java


示例17: createReachableMember

import akka.cluster.Member; //导入依赖的package包/类
public static ReachableMember createReachableMember(final String memberName, final String address) {
    UniqueAddress uniqueAddress = new UniqueAddress(AddressFromURIString.parse(address), 55L);
    Member member = new Member(uniqueAddress, 1, MemberStatus.up(), setOf(memberName));

    return new ReachableMember(member);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:7,代码来源:MockClusterWrapper.java


示例18: countDownIfOther

import akka.cluster.Member; //导入依赖的package包/类
private void countDownIfOther(final Member member, final CountDownLatch latch) {
    if (!getCluster().getCurrentMemberName().equals(memberToName(member))) {
        latch.countDown();
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:6,代码来源:ShardManagerTest.java


示例19: processAsClusterEvent

import akka.cluster.Member; //导入依赖的package包/类
/**
 * Process messages about nodes up, down, reachable and unreachable.
 */
private void processAsClusterEvent(Object message) {

    if (message instanceof ClusterEvent.CurrentClusterState) {
        ClusterEvent.CurrentClusterState state = (ClusterEvent.CurrentClusterState) message;
        nodes.clear();
        for (Member member : state.getMembers()) {
            if (member.hasRole("io") && member.status().equals( MemberStatus.up())) {
                nodes.add(member.address());
                logger.debug("RequestActor {} received cluster-state member-up for {}", name, member.address());
            }
        }

    } else if (message instanceof ClusterEvent.MemberUp) {
        ClusterEvent.MemberUp mUp = (ClusterEvent.MemberUp) message;
        if (mUp.member().hasRole("io")) {
            nodes.add( mUp.member().address() );
        }
        logger.debug("{} received member-up for {}", name, mUp.member().address());

    } else if (message instanceof ClusterEvent.MemberEvent) {
        ClusterEvent.MemberEvent other = (ClusterEvent.MemberEvent) message;
        nodes.remove(other.member().address());

    } else if (message instanceof ClusterEvent.UnreachableMember) {
        ClusterEvent.UnreachableMember unreachable = (ClusterEvent.UnreachableMember) message;
        nodes.remove(unreachable.member().address());
        logger.debug("{} received un-reachable for {}", name, unreachable.member().address());

    } else if (message instanceof ClusterEvent.ReachableMember) {
        ClusterEvent.ReachableMember reachable = (ClusterEvent.ReachableMember) message;
        if (reachable.member().hasRole("io")) {
            nodes.add( reachable.member().address() );
        }
        logger.debug("{} received reachable for {}", name, reachable.member().address());

    } else {
        logger.error("{}: unhandled message: {}", name, message.toString());
        unhandled(message);
    }
}
 
开发者ID:apache,项目名称:usergrid,代码行数:44,代码来源:ClientActor.java



注:本文中的akka.cluster.Member类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DOMForest类代码示例发布时间:2022-05-23
下一篇:
Java MediaIntentReceiver类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap