Java Code Examples for io.atomix.cluster.Member#id()

The following examples show how to use io.atomix.cluster.Member#id() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultClusterMembershipService.java    From atomix with Apache License 2.0 6 votes vote down vote up
public DefaultClusterMembershipService(
    Member localMember,
    Version version,
    ManagedNodeDiscoveryService discoveryService,
    BootstrapService bootstrapService,
    GroupMembershipProtocol protocol) {
  this.discoveryService = checkNotNull(discoveryService, "discoveryService cannot be null");
  this.bootstrapService = checkNotNull(bootstrapService, "bootstrapService cannot be null");
  this.protocol = checkNotNull(protocol, "protocol cannot be null");
  this.localMember = new StatefulMember(
      localMember.id(),
      localMember.address(),
      localMember.zone(),
      localMember.rack(),
      localMember.host(),
      localMember.properties(),
      version);
}
 
Example 2
Source File: HeartbeatMembershipProtocol.java    From atomix with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Void> join(BootstrapService bootstrap, NodeDiscoveryService discovery, Member member) {
  if (started.compareAndSet(false, true)) {
    this.bootstrapService = bootstrap;
    this.discoveryService = discovery;
    this.localMember = new GossipMember(
        member.id(),
        member.address(),
        member.zone(),
        member.rack(),
        member.host(),
        member.properties(),
        member.version(),
        System.currentTimeMillis());
    discoveryService.addListener(discoveryEventListener);

    LOGGER.info("{} - Member activated: {}", localMember.id(), localMember);
    localMember.setActive(true);
    localMember.setReachable(true);
    members.put(localMember.id(), localMember);
    post(new GroupMembershipEvent(GroupMembershipEvent.Type.MEMBER_ADDED, localMember));

    bootstrapService.getMessagingService().registerHandler(HEARTBEAT_MESSAGE, this::handleHeartbeat, heartbeatScheduler);
    heartbeatFuture = heartbeatScheduler.scheduleAtFixedRate(
        this::sendHeartbeats, 0, config.getHeartbeatInterval().toMillis(), TimeUnit.MILLISECONDS);
    LOGGER.info("Started");
  }
  return CompletableFuture.completedFuture(null);
}
 
Example 3
Source File: SwimMembershipProtocol.java    From atomix with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Void> join(BootstrapService bootstrap, NodeDiscoveryService discovery, Member member) {
  if (started.compareAndSet(false, true)) {
    this.bootstrapService = bootstrap;
    this.discoveryService = discovery;
    this.localMember = new SwimMember(
        member.id(),
        member.address(),
        member.zone(),
        member.rack(),
        member.host(),
        member.properties(),
        member.version(),
        System.currentTimeMillis());
    this.localProperties.putAll(localMember.properties());
    discoveryService.addListener(discoveryEventListener);

    LOGGER.info("{} - Member activated: {}", localMember.id(), localMember);
    localMember.setState(State.ALIVE);
    members.put(localMember.id(), localMember);
    post(new GroupMembershipEvent(GroupMembershipEvent.Type.MEMBER_ADDED, localMember));

    registerHandlers();
    gossipFuture = swimScheduler.scheduleAtFixedRate(
        this::gossip, 0, config.getGossipInterval().toMillis(), TimeUnit.MILLISECONDS);
    probeFuture = swimScheduler.scheduleAtFixedRate(
        this::probe, 0, config.getProbeInterval().toMillis(), TimeUnit.MILLISECONDS);
    swimScheduler.execute(this::sync);
    LOGGER.info("Started");
  }
  return CompletableFuture.completedFuture(null);
}