com.hazelcast.instance.Node.getVersion()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中com.hazelcast.instance.Node.getVersion()方法的一些代码示例,展示了Node.getVersion()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getVersion()方法的具体详情如下:
包路径:com.hazelcast.instance.Node
类名称:Node
方法名:getVersion

Node.getVersion介绍

[英]Returns the codebase version of the node.
[中]返回节点的代码基版本。

代码示例

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public MemberVersion getVersion() {
  return node.getVersion();
}

代码示例来源:origin: com.hazelcast/hazelcast-all

@Override
public MemberVersion getVersion() {
  return node.getVersion();
}

代码示例来源:origin: hazelcast/hazelcast-jet

private void validateNodeCompatibleWith(Version clusterVersion) {
  if (!node.getNodeExtension().isNodeVersionCompatibleWith(clusterVersion)) {
    throw new VersionMismatchException("Node's codebase version " + node.getVersion() + " is incompatible with "
        + "the requested cluster version " + clusterVersion);
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public boolean isNodeVersionCompatibleWith(Version clusterVersion) {
  Preconditions.checkNotNull(clusterVersion);
  return node.getVersion().asVersion().equals(clusterVersion);
}

代码示例来源:origin: com.hazelcast/hazelcast-all

private void validateNodeCompatibleWith(Version clusterVersion) {
  if (!node.getNodeExtension().isNodeVersionCompatibleWith(clusterVersion)) {
    throw new VersionMismatchException("Node's codebase version " + node.getVersion() + " is incompatible with "
        + "the requested cluster version " + clusterVersion);
  }
}

代码示例来源:origin: com.hazelcast/hazelcast-all

@Override
public boolean isNodeVersionCompatibleWith(Version clusterVersion) {
  Preconditions.checkNotNull(clusterVersion);
  return node.getVersion().asVersion().equals(clusterVersion);
}

代码示例来源:origin: hazelcast/hazelcast-jet

protected void createNodeState(MemberStateImpl memberState) {
  Node node = instance.node;
  ClusterService cluster = instance.node.clusterService;
  NodeStateImpl nodeState = new NodeStateImpl(cluster.getClusterState(), node.getState(),
      cluster.getClusterVersion(), node.getVersion());
  memberState.setNodeState(nodeState);
}

代码示例来源:origin: com.hazelcast/hazelcast-all

protected void createNodeState(MemberStateImpl memberState) {
  Node node = instance.node;
  ClusterService cluster = instance.node.clusterService;
  NodeStateImpl nodeState = new NodeStateImpl(cluster.getClusterState(), node.getState(),
      cluster.getClusterVersion(), node.getVersion());
  memberState.setNodeState(nodeState);
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public void onClusterVersionChange(Version newVersion) {
  if (!node.getVersion().asVersion().isEqualTo(newVersion)) {
    systemLogger.info("Cluster version set to " + newVersion);
  }
  ServiceManager serviceManager = node.getNodeEngine().getServiceManager();
  List<ClusterVersionListener> listeners = serviceManager.getServices(ClusterVersionListener.class);
  for (ClusterVersionListener listener : listeners) {
    listener.onClusterVersionChange(newVersion);
  }
  // also trigger cluster version change on explicitly registered listeners
  for (ClusterVersionListener listener : clusterVersionListeners) {
    listener.onClusterVersionChange(newVersion);
  }
}

代码示例来源:origin: com.hazelcast/hazelcast-all

@Override
public void onClusterVersionChange(Version newVersion) {
  if (!node.getVersion().asVersion().isEqualTo(newVersion)) {
    systemLogger.info("Cluster version set to " + newVersion);
  }
  ServiceManager serviceManager = node.getNodeEngine().getServiceManager();
  List<ClusterVersionListener> listeners = serviceManager.getServices(ClusterVersionListener.class);
  for (ClusterVersionListener listener : listeners) {
    listener.onClusterVersionChange(newVersion);
  }
  // also trigger cluster version change on explicitly registered listeners
  for (ClusterVersionListener listener : clusterVersionListeners) {
    listener.onClusterVersionChange(newVersion);
  }
}

代码示例来源:origin: com.hazelcast/hazelcast-all

private Version getClusterOrNodeVersion() {
  if (node.getClusterService() != null && !node.getClusterService().getClusterVersion().isUnknown()) {
    return node.getClusterService().getClusterVersion();
  } else {
    String overriddenClusterVersion = node.getProperties().getString(GroupProperty.INIT_CLUSTER_VERSION);
    return (overriddenClusterVersion != null) ? MemberVersion.of(overriddenClusterVersion).asVersion()
        : node.getVersion().asVersion();
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet

private Version getClusterOrNodeVersion() {
  if (node.getClusterService() != null && !node.getClusterService().getClusterVersion().isUnknown()) {
    return node.getClusterService().getClusterVersion();
  } else {
    String overriddenClusterVersion = node.getProperties().getString(GroupProperty.INIT_CLUSTER_VERSION);
    return (overriddenClusterVersion != null) ? MemberVersion.of(overriddenClusterVersion).asVersion()
        : node.getVersion().asVersion();
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet

/**
 * Send a {@link WhoisMasterOp} to designated address.
 *
 * @param toAddress the address to which the operation will be sent.
 * @return {@code true} if the operation was sent, otherwise {@code false}.
 */
public boolean sendMasterQuestion(Address toAddress) {
  checkNotNull(toAddress, "No endpoint is specified!");
  BuildInfo buildInfo = node.getBuildInfo();
  final Address thisAddress = node.getThisAddress();
  JoinMessage joinMessage = new JoinMessage(Packet.VERSION, buildInfo.getBuildNumber(), node.getVersion(),
      thisAddress, clusterService.getThisUuid(), node.isLiteMember(), node.createConfigCheck());
  return nodeEngine.getOperationService().send(new WhoisMasterOp(joinMessage), toAddress);
}

代码示例来源:origin: com.hazelcast/hazelcast-all

/**
 * Send a {@link WhoisMasterOp} to designated address.
 *
 * @param toAddress the address to which the operation will be sent.
 * @return {@code true} if the operation was sent, otherwise {@code false}.
 */
public boolean sendMasterQuestion(Address toAddress) {
  checkNotNull(toAddress, "No endpoint is specified!");
  BuildInfo buildInfo = node.getBuildInfo();
  final Address thisAddress = node.getThisAddress();
  JoinMessage joinMessage = new JoinMessage(Packet.VERSION, buildInfo.getBuildNumber(), node.getVersion(),
      thisAddress, clusterService.getThisUuid(), node.isLiteMember(), node.createConfigCheck());
  return nodeEngine.getOperationService().send(new WhoisMasterOp(joinMessage), toAddress);
}

代码示例来源:origin: hazelcast/hazelcast-jet

public boolean setThisMemberAsMaster() {
  clusterServiceLock.lock();
  try {
    if (clusterService.isJoined()) {
      logger.warning("Cannot set as master because node is already joined!");
      return false;
    }
    logger.finest("This node is being set as the master");
    Address thisAddress = node.getThisAddress();
    MemberVersion version = node.getVersion();
    clusterService.setMasterAddress(thisAddress);
    if (clusterService.getClusterVersion().isUnknown()) {
      clusterService.getClusterStateManager().setClusterVersion(version.asVersion());
    }
    clusterService.getClusterClock().setClusterStartTime(Clock.currentTimeMillis());
    clusterService.setClusterId(UuidUtil.createClusterUuid());
    clusterService.getMembershipManager().setLocalMemberListJoinVersion(SINGLETON_MEMBER_LIST_VERSION);
    clusterService.setJoined(true);
    return true;
  } finally {
    clusterServiceLock.unlock();
  }
}

代码示例来源:origin: com.hazelcast/hazelcast-all

public boolean setThisMemberAsMaster() {
  clusterServiceLock.lock();
  try {
    if (clusterService.isJoined()) {
      logger.warning("Cannot set as master because node is already joined!");
      return false;
    }
    logger.finest("This node is being set as the master");
    Address thisAddress = node.getThisAddress();
    MemberVersion version = node.getVersion();
    clusterService.setMasterAddress(thisAddress);
    if (clusterService.getClusterVersion().isUnknown()) {
      clusterService.getClusterStateManager().setClusterVersion(version.asVersion());
    }
    clusterService.getClusterClock().setClusterStartTime(Clock.currentTimeMillis());
    clusterService.setClusterId(UuidUtil.createClusterUuid());
    clusterService.getMembershipManager().setLocalMemberListJoinVersion(SINGLETON_MEMBER_LIST_VERSION);
    clusterService.setJoined(true);
    return true;
  } finally {
    clusterServiceLock.unlock();
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet

private void handleActiveAndJoined(JoinMessage joinMessage) {
  if (!(joinMessage instanceof JoinRequest)) {
    logDroppedMessage(joinMessage);
    return;
  }
  ClusterServiceImpl clusterService = node.getClusterService();
  Address masterAddress = clusterService.getMasterAddress();
  if (clusterService.isMaster()) {
    JoinMessage response = new JoinMessage(Packet.VERSION, node.getBuildInfo().getBuildNumber(), node.getVersion(),
        node.getThisAddress(), node.getThisUuid(), node.isLiteMember(), node.createConfigCheck());
    node.multicastService.send(response);
  } else if (joinMessage.getAddress().equals(masterAddress)) {
    MemberImpl master = node.getClusterService().getMember(masterAddress);
    if (master != null && !master.getUuid().equals(joinMessage.getUuid())) {
      String message = "New join request has been received from current master. Suspecting " + masterAddress;
      logger.warning(message);
      // I just make a local suspicion. Probably other nodes will eventually suspect as well.
      clusterService.suspectMember(master, message, false);
    }
  }
}

代码示例来源:origin: com.hazelcast/hazelcast-all

private void handleActiveAndJoined(JoinMessage joinMessage) {
  if (!(joinMessage instanceof JoinRequest)) {
    logDroppedMessage(joinMessage);
    return;
  }
  ClusterServiceImpl clusterService = node.getClusterService();
  Address masterAddress = clusterService.getMasterAddress();
  if (clusterService.isMaster()) {
    JoinMessage response = new JoinMessage(Packet.VERSION, node.getBuildInfo().getBuildNumber(), node.getVersion(),
        node.getThisAddress(), node.getThisUuid(), node.isLiteMember(), node.createConfigCheck());
    node.multicastService.send(response);
  } else if (joinMessage.getAddress().equals(masterAddress)) {
    MemberImpl master = node.getClusterService().getMember(masterAddress);
    if (master != null && !master.getUuid().equals(joinMessage.getUuid())) {
      String message = "New join request has been received from current master. Suspecting " + masterAddress;
      logger.warning(message);
      // I just make a local suspicion. Probably other nodes will eventually suspect as well.
      clusterService.suspectMember(master, message, false);
    }
  }
}

相关文章

微信公众号

最新文章

更多