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

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

本文整理了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

  1. @Override
  2. public MemberVersion getVersion() {
  3. return node.getVersion();
  4. }

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

  1. @Override
  2. public MemberVersion getVersion() {
  3. return node.getVersion();
  4. }

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

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

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

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

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

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

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

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

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

  1. protected void createNodeState(MemberStateImpl memberState) {
  2. Node node = instance.node;
  3. ClusterService cluster = instance.node.clusterService;
  4. NodeStateImpl nodeState = new NodeStateImpl(cluster.getClusterState(), node.getState(),
  5. cluster.getClusterVersion(), node.getVersion());
  6. memberState.setNodeState(nodeState);
  7. }

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

  1. protected void createNodeState(MemberStateImpl memberState) {
  2. Node node = instance.node;
  3. ClusterService cluster = instance.node.clusterService;
  4. NodeStateImpl nodeState = new NodeStateImpl(cluster.getClusterState(), node.getState(),
  5. cluster.getClusterVersion(), node.getVersion());
  6. memberState.setNodeState(nodeState);
  7. }

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

  1. @Override
  2. public void onClusterVersionChange(Version newVersion) {
  3. if (!node.getVersion().asVersion().isEqualTo(newVersion)) {
  4. systemLogger.info("Cluster version set to " + newVersion);
  5. }
  6. ServiceManager serviceManager = node.getNodeEngine().getServiceManager();
  7. List<ClusterVersionListener> listeners = serviceManager.getServices(ClusterVersionListener.class);
  8. for (ClusterVersionListener listener : listeners) {
  9. listener.onClusterVersionChange(newVersion);
  10. }
  11. // also trigger cluster version change on explicitly registered listeners
  12. for (ClusterVersionListener listener : clusterVersionListeners) {
  13. listener.onClusterVersionChange(newVersion);
  14. }
  15. }

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

  1. @Override
  2. public void onClusterVersionChange(Version newVersion) {
  3. if (!node.getVersion().asVersion().isEqualTo(newVersion)) {
  4. systemLogger.info("Cluster version set to " + newVersion);
  5. }
  6. ServiceManager serviceManager = node.getNodeEngine().getServiceManager();
  7. List<ClusterVersionListener> listeners = serviceManager.getServices(ClusterVersionListener.class);
  8. for (ClusterVersionListener listener : listeners) {
  9. listener.onClusterVersionChange(newVersion);
  10. }
  11. // also trigger cluster version change on explicitly registered listeners
  12. for (ClusterVersionListener listener : clusterVersionListeners) {
  13. listener.onClusterVersionChange(newVersion);
  14. }
  15. }

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

  1. private Version getClusterOrNodeVersion() {
  2. if (node.getClusterService() != null && !node.getClusterService().getClusterVersion().isUnknown()) {
  3. return node.getClusterService().getClusterVersion();
  4. } else {
  5. String overriddenClusterVersion = node.getProperties().getString(GroupProperty.INIT_CLUSTER_VERSION);
  6. return (overriddenClusterVersion != null) ? MemberVersion.of(overriddenClusterVersion).asVersion()
  7. : node.getVersion().asVersion();
  8. }
  9. }

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

  1. private Version getClusterOrNodeVersion() {
  2. if (node.getClusterService() != null && !node.getClusterService().getClusterVersion().isUnknown()) {
  3. return node.getClusterService().getClusterVersion();
  4. } else {
  5. String overriddenClusterVersion = node.getProperties().getString(GroupProperty.INIT_CLUSTER_VERSION);
  6. return (overriddenClusterVersion != null) ? MemberVersion.of(overriddenClusterVersion).asVersion()
  7. : node.getVersion().asVersion();
  8. }
  9. }

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

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

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

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

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

  1. public boolean setThisMemberAsMaster() {
  2. clusterServiceLock.lock();
  3. try {
  4. if (clusterService.isJoined()) {
  5. logger.warning("Cannot set as master because node is already joined!");
  6. return false;
  7. }
  8. logger.finest("This node is being set as the master");
  9. Address thisAddress = node.getThisAddress();
  10. MemberVersion version = node.getVersion();
  11. clusterService.setMasterAddress(thisAddress);
  12. if (clusterService.getClusterVersion().isUnknown()) {
  13. clusterService.getClusterStateManager().setClusterVersion(version.asVersion());
  14. }
  15. clusterService.getClusterClock().setClusterStartTime(Clock.currentTimeMillis());
  16. clusterService.setClusterId(UuidUtil.createClusterUuid());
  17. clusterService.getMembershipManager().setLocalMemberListJoinVersion(SINGLETON_MEMBER_LIST_VERSION);
  18. clusterService.setJoined(true);
  19. return true;
  20. } finally {
  21. clusterServiceLock.unlock();
  22. }
  23. }

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

  1. public boolean setThisMemberAsMaster() {
  2. clusterServiceLock.lock();
  3. try {
  4. if (clusterService.isJoined()) {
  5. logger.warning("Cannot set as master because node is already joined!");
  6. return false;
  7. }
  8. logger.finest("This node is being set as the master");
  9. Address thisAddress = node.getThisAddress();
  10. MemberVersion version = node.getVersion();
  11. clusterService.setMasterAddress(thisAddress);
  12. if (clusterService.getClusterVersion().isUnknown()) {
  13. clusterService.getClusterStateManager().setClusterVersion(version.asVersion());
  14. }
  15. clusterService.getClusterClock().setClusterStartTime(Clock.currentTimeMillis());
  16. clusterService.setClusterId(UuidUtil.createClusterUuid());
  17. clusterService.getMembershipManager().setLocalMemberListJoinVersion(SINGLETON_MEMBER_LIST_VERSION);
  18. clusterService.setJoined(true);
  19. return true;
  20. } finally {
  21. clusterServiceLock.unlock();
  22. }
  23. }

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

  1. private void handleActiveAndJoined(JoinMessage joinMessage) {
  2. if (!(joinMessage instanceof JoinRequest)) {
  3. logDroppedMessage(joinMessage);
  4. return;
  5. }
  6. ClusterServiceImpl clusterService = node.getClusterService();
  7. Address masterAddress = clusterService.getMasterAddress();
  8. if (clusterService.isMaster()) {
  9. JoinMessage response = new JoinMessage(Packet.VERSION, node.getBuildInfo().getBuildNumber(), node.getVersion(),
  10. node.getThisAddress(), node.getThisUuid(), node.isLiteMember(), node.createConfigCheck());
  11. node.multicastService.send(response);
  12. } else if (joinMessage.getAddress().equals(masterAddress)) {
  13. MemberImpl master = node.getClusterService().getMember(masterAddress);
  14. if (master != null && !master.getUuid().equals(joinMessage.getUuid())) {
  15. String message = "New join request has been received from current master. Suspecting " + masterAddress;
  16. logger.warning(message);
  17. // I just make a local suspicion. Probably other nodes will eventually suspect as well.
  18. clusterService.suspectMember(master, message, false);
  19. }
  20. }
  21. }

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

  1. private void handleActiveAndJoined(JoinMessage joinMessage) {
  2. if (!(joinMessage instanceof JoinRequest)) {
  3. logDroppedMessage(joinMessage);
  4. return;
  5. }
  6. ClusterServiceImpl clusterService = node.getClusterService();
  7. Address masterAddress = clusterService.getMasterAddress();
  8. if (clusterService.isMaster()) {
  9. JoinMessage response = new JoinMessage(Packet.VERSION, node.getBuildInfo().getBuildNumber(), node.getVersion(),
  10. node.getThisAddress(), node.getThisUuid(), node.isLiteMember(), node.createConfigCheck());
  11. node.multicastService.send(response);
  12. } else if (joinMessage.getAddress().equals(masterAddress)) {
  13. MemberImpl master = node.getClusterService().getMember(masterAddress);
  14. if (master != null && !master.getUuid().equals(joinMessage.getUuid())) {
  15. String message = "New join request has been received from current master. Suspecting " + masterAddress;
  16. logger.warning(message);
  17. // I just make a local suspicion. Probably other nodes will eventually suspect as well.
  18. clusterService.suspectMember(master, message, false);
  19. }
  20. }
  21. }

相关文章