public void changeNodeStateToActive() { final ClusterState clusterState = clusterService.getClusterState(); if (clusterState == ClusterState.PASSIVE) { throw new IllegalStateException("This method can be called only when cluster-state is not " + clusterState); } state = NodeState.ACTIVE; }
public void changeNodeStateToPassive() { final ClusterState clusterState = clusterService.getClusterState(); if (clusterState != ClusterState.PASSIVE) { throw new IllegalStateException("This method can be called only when cluster-state is " + clusterState); } state = NodeState.PASSIVE; }
public void changeNodeStateToActive() { final ClusterState clusterState = clusterService.getClusterState(); if (clusterState == ClusterState.PASSIVE) { throw new IllegalStateException("This method can be called only when cluster-state is not " + clusterState); } state = NodeState.ACTIVE; }
public void changeNodeStateToPassive() { final ClusterState clusterState = clusterService.getClusterState(); if (clusterState != ClusterState.PASSIVE) { throw new IllegalStateException("This method can be called only when cluster-state is " + clusterState); } state = NodeState.PASSIVE; }
/** * Returns whether migrations are allowed by current cluster state. */ private boolean isMigrationAllowedByClusterState() { ClusterState clusterState = node.getClusterService().getClusterState(); return clusterState.isMigrationAllowed(); }
private void ensureLiteMemberPromotionIsAllowed() { if (!clusterService.isMaster()) { throw new IllegalStateException("This node is not master!"); } if (clusterService.getClusterJoinManager().isMastershipClaimInProgress()) { throw new IllegalStateException("Mastership claim is in progress!"); } ClusterState state = clusterService.getClusterState(); if (!state.isMigrationAllowed()) { throw new IllegalStateException("Lite member promotion is not allowed when cluster state is " + state); } }
private void ensureLiteMemberPromotionIsAllowed() { if (!clusterService.isMaster()) { throw new IllegalStateException("This node is not master!"); } if (clusterService.getClusterJoinManager().isMastershipClaimInProgress()) { throw new IllegalStateException("Mastership claim is in progress!"); } ClusterState state = clusterService.getClusterState(); if (!state.isMigrationAllowed()) { throw new IllegalStateException("Lite member promotion is not allowed when cluster state is " + state); } }
private void persistJoinedMemberUuids(Collection<MemberInfo> joinedMembers) { if (clusterService.getClusterState().isJoinAllowed()) { long localTime = Clock.currentTimeMillis(); for (MemberInfo member : joinedMembers) { recentlyJoinedMemberUuids.put(member.getUuid(), localTime); } } }
private void persistJoinedMemberUuids(Collection<MemberInfo> joinedMembers) { if (clusterService.getClusterState().isJoinAllowed()) { long localTime = Clock.currentTimeMillis(); for (MemberInfo member : joinedMembers) { recentlyJoinedMemberUuids.put(member.getUuid(), localTime); } } }
private void handleHealthcheck(HttpHeadCommand command) { Node node = textCommandService.getNode(); NodeState nodeState = node.getState(); ClusterServiceImpl clusterService = node.getClusterService(); ClusterState clusterState = clusterService.getClusterState(); int clusterSize = clusterService.getMembers().size(); InternalPartitionService partitionService = node.getPartitionService(); long migrationQueueSize = partitionService.getMigrationQueueSize(); Map<String, Object> headervals = new LinkedHashMap<String, Object>(); headervals.put("NodeState", nodeState); headervals.put("ClusterState", clusterState); headervals.put("MigrationQueueSize", migrationQueueSize); headervals.put("ClusterSize", clusterSize); command.setResponse(headervals); }
private void handleHealthcheck(HttpHeadCommand command) { Node node = textCommandService.getNode(); NodeState nodeState = node.getState(); ClusterServiceImpl clusterService = node.getClusterService(); ClusterState clusterState = clusterService.getClusterState(); int clusterSize = clusterService.getMembers().size(); InternalPartitionService partitionService = node.getPartitionService(); long migrationQueueSize = partitionService.getMigrationQueueSize(); Map<String, Object> headervals = new LinkedHashMap<String, Object>(); headervals.put("NodeState", nodeState); headervals.put("ClusterState", clusterState); headervals.put("MigrationQueueSize", migrationQueueSize); headervals.put("ClusterSize", clusterSize); command.setResponse(headervals); }
private boolean checkClusterStateAllowsJoinBeforeMerge(SplitBrainJoinMessage joinMessage) { ClusterState clusterState = clusterService.getClusterState(); if (!clusterState.isJoinAllowed()) { if (logger.isFineEnabled()) { logger.fine("Should not merge to " + joinMessage.getAddress() + ", because this cluster is in " + clusterState + " state."); } return false; } return true; }
private boolean checkClusterStateAllowsJoinBeforeMerge(SplitBrainJoinMessage joinMessage) { ClusterState clusterState = clusterService.getClusterState(); if (!clusterState.isJoinAllowed()) { if (logger.isFineEnabled()) { logger.fine("Should not merge to " + joinMessage.getAddress() + ", because this cluster is in " + clusterState + " state."); } return false; } return true; }
void onShutdownRequest(Address address) { if (!partitionStateManager.isInitialized()) { sendShutdownOperation(address); return; } ClusterState clusterState = node.getClusterService().getClusterState(); if (!clusterState.isMigrationAllowed() && clusterState != ClusterState.IN_TRANSITION) { sendShutdownOperation(address); return; } if (shutdownRequestedAddresses.add(address)) { logger.info("Shutdown request of " + address + " is handled"); triggerControlTask(); } }
private void handleMemberRemove(MemberMap newMembers, MemberImpl removedMember) { ClusterState clusterState = clusterService.getClusterState(); if (!clusterState.isJoinAllowed()) { if (logger.isFineEnabled()) { logger.fine(removedMember + " is removed, added to members left while cluster is " + clusterState + " state"); } final InternalHotRestartService hotRestartService = node.getNodeExtension().getInternalHotRestartService(); if (!hotRestartService.isMemberExcluded(removedMember.getAddress(), removedMember.getUuid())) { MemberMap membersRemovedInNotJoinableState = membersRemovedInNotJoinableStateRef.get(); membersRemovedInNotJoinableStateRef .set(MemberMap.cloneAdding(membersRemovedInNotJoinableState, removedMember)); } } onMemberRemove(removedMember); // async events sendMembershipEventNotifications(removedMember, unmodifiableSet(new LinkedHashSet<Member>(newMembers.getMembers())), false); }
public void run() { if (!node.getClusterService().getClusterState().isJoinAllowed()) { // If join is not allowed, partition table cannot be modified and we should have // the most recent partition table already. Because cluster state cannot be changed // when our partition table is stale. logger.fine("No need to fetch the latest partition table. Cluster state does not allow new members to join."); shouldFetchPartitionTables = false; return; } maxVersion = partitionStateManager.getVersion(); logger.info("Fetching most recent partition table! my version: " + maxVersion); Collection<MigrationInfo> allCompletedMigrations = new HashSet<MigrationInfo>(); Collection<MigrationInfo> allActiveMigrations = new HashSet<MigrationInfo>(); collectAndProcessResults(allCompletedMigrations, allActiveMigrations); logger.info("Most recent partition table version: " + maxVersion); processNewState(allCompletedMigrations, allActiveMigrations); syncPartitionRuntimeState(); }
void onShutdownRequest(Member member) { if (!partitionStateManager.isInitialized()) { sendShutdownOperation(member.getAddress()); return; } ClusterState clusterState = node.getClusterService().getClusterState(); if (!clusterState.isMigrationAllowed() && clusterState != ClusterState.IN_TRANSITION) { sendShutdownOperation(member.getAddress()); return; } if (shutdownRequestedMembers.add(member)) { logger.info("Shutdown request of " + member + " is handled"); triggerControlTask(); } }
private void handleMemberRemove(MemberMap newMembers, MemberImpl removedMember) { ClusterState clusterState = clusterService.getClusterState(); if (!clusterState.isJoinAllowed()) { if (logger.isFineEnabled()) { logger.fine(removedMember + " is removed, added to members left while cluster is " + clusterState + " state"); } InternalHotRestartService hotRestartService = node.getNodeExtension().getInternalHotRestartService(); if (!hotRestartService.isMemberExcluded(removedMember.getAddress(), removedMember.getUuid())) { addToMissingMembers(removedMember); } } onMemberRemove(removedMember); // async events sendMembershipEventNotifications(removedMember, unmodifiableSet(new LinkedHashSet<Member>(newMembers.getMembers())), false); }
private boolean shouldRun() { ClusterServiceImpl clusterService = node.getClusterService(); if (!clusterService.isJoined()) { return false; } if (!clusterService.isMaster()) { return false; } if (!node.isRunning()) { return false; } final ClusterJoinManager clusterJoinManager = clusterService.getClusterJoinManager(); if (clusterJoinManager.isJoinInProgress()) { return false; } final ClusterState clusterState = clusterService.getClusterState(); return clusterState.isJoinAllowed(); }
private boolean shouldRun() { ClusterServiceImpl clusterService = node.getClusterService(); if (!clusterService.isJoined()) { return false; } if (!clusterService.isMaster()) { return false; } if (!node.isRunning()) { return false; } final ClusterJoinManager clusterJoinManager = clusterService.getClusterJoinManager(); if (clusterJoinManager.isJoinInProgress()) { return false; } final ClusterState clusterState = clusterService.getClusterState(); return clusterState.isJoinAllowed(); }