@Override protected void readInternal(ObjectDataInput in) throws IOException { request = new JoinRequest(); request.readData(in); }
@Override public String toString() { return "JoinRequest{" + "packetVersion=" + packetVersion + ", buildNumber=" + buildNumber + ", memberVersion=" + memberVersion + ", address=" + address + ", uuid='" + uuid + "'" + ", liteMember=" + liteMember + ", credentials=" + credentials + ", memberCount=" + getMemberCount() + ", tryCount=" + tryCount + (excludedMemberUuids.size() > 0 ? ", excludedMemberUuids=" + excludedMemberUuids : "") + '}'; }
void onReceivedJoinRequest(JoinRequest joinRequest) { if (joinRequest.getUuid().compareTo(clusterService.getThisUuid()) < 0) { maxTryCount.incrementAndGet(); } }
@SuppressWarnings("checkstyle:npathcomplexity") private boolean checkJoinRequest(JoinRequest joinRequest, Connection connection) { if (checkIfJoinRequestFromAnExistingMember(joinRequest, connection)) { return true; } final InternalHotRestartService hotRestartService = node.getNodeExtension().getInternalHotRestartService(); Address target = joinRequest.getAddress(); String targetUuid = joinRequest.getUuid(); if (hotRestartService.isMemberExcluded(target, targetUuid)) { logger.fine("cannot join " + target + " because it is excluded in cluster start."); hotRestartService.notifyExcludedMember(target); return true; } if (joinRequest.getExcludedMemberUuids().contains(clusterService.getThisUuid())) { logger.warning("cannot join " + target + " since this node is excluded in its list..."); hotRestartService.handleExcludedMemberUuids(target, joinRequest.getExcludedMemberUuids()); return true; } return checkClusterStateBeforeJoin(target, targetUuid); }
/** * Executed by a master node to process the {@link JoinRequest} sent by a node attempting to join the cluster. * * @param joinRequest the join request from a node attempting to join * @param connection the connection of this node to the joining node */ private void executeJoinRequest(JoinRequest joinRequest, Connection connection) { clusterServiceLock.lock(); try { if (checkJoinRequest(joinRequest, connection)) { return; } if (!authenticate(joinRequest)) { return; } if (!validateJoinRequest(joinRequest, joinRequest.getAddress())) { return; } startJoinRequest(joinRequest.toMemberInfo()); } finally { clusterServiceLock.unlock(); } }
private boolean authenticate(JoinRequest joinRequest) { if (!joiningMembers.containsKey(joinRequest.getAddress())) { try { secureLogin(joinRequest); } catch (Exception e) { ILogger securityLogger = node.loggingService.getLogger("com.hazelcast.security"); nodeEngine.getOperationService().send(new AuthenticationFailureOp(), joinRequest.getAddress()); securityLogger.severe(e); return false; } } return true; }
public IdentifiedDataSerializable createNew(Integer arg) { return new JoinRequest(); } };
@Override protected void writeInternal(ObjectDataOutput out) throws IOException { request.writeData(out); }
private void secureLogin(JoinRequest joinRequest) { if (node.securityContext != null) { Credentials credentials = joinRequest.getCredentials(); if (credentials == null) { throw new SecurityException("Expecting security credentials, but credentials could not be found in join request"); } try { LoginContext loginContext = node.securityContext.createMemberLoginContext(credentials); loginContext.login(); } catch (LoginException e) { throw new SecurityException(format("Authentication has failed for %s@%s, cause: %s", credentials.getPrincipal(), credentials.getEndpoint(), e.getMessage())); } } }
private Address findMasterWithMulticast() { try { if (logger.isFineEnabled()) { logger.fine("Searching for master node. Max tries: " + maxTryCount.get()); } JoinRequest joinRequest = node.createJoinRequest(false); while (node.isRunning() && currentTryCount.incrementAndGet() <= maxTryCount.get()) { joinRequest.setTryCount(currentTryCount.get()); node.multicastService.send(joinRequest); Address masterAddress = clusterService.getMasterAddress(); if (masterAddress == null) { //noinspection BusyWait Thread.sleep(getPublishInterval()); } else { return masterAddress; } } } catch (final Exception e) { if (logger != null) { logger.warning(e); } } finally { currentTryCount.set(0); } return null; }
@SuppressWarnings("checkstyle:npathcomplexity") private boolean checkJoinRequest(JoinRequest joinRequest, Connection connection) { if (checkIfJoinRequestFromAnExistingMember(joinRequest, connection)) { return true; } final InternalHotRestartService hotRestartService = node.getNodeExtension().getInternalHotRestartService(); Address target = joinRequest.getAddress(); String targetUuid = joinRequest.getUuid(); if (hotRestartService.isMemberExcluded(target, targetUuid)) { logger.fine("cannot join " + target + " because it is excluded in cluster start."); hotRestartService.notifyExcludedMember(target); return true; } if (checkClusterStateBeforeJoin(target, targetUuid)) { return true; } if (joinRequest.getExcludedMemberUuids().contains(clusterService.getThisUuid())) { logger.warning("cannot join " + target + " since this node is excluded in its list..."); hotRestartService.handleExcludedMemberUuids(target, joinRequest.getExcludedMemberUuids()); return true; } if (!node.getPartitionService().isMemberAllowedToJoin(target)) { logger.warning(target + " not allowed to join right now, it seems restarted."); return true; } return false; }
/** * Executed by a master node to process the {@link JoinRequest} sent by a node attempting to join the cluster. * * @param joinRequest the join request from a node attempting to join * @param connection the connection of this node to the joining node */ private void executeJoinRequest(JoinRequest joinRequest, Connection connection) { clusterServiceLock.lock(); try { if (checkJoinRequest(joinRequest, connection)) { return; } if (!authenticate(joinRequest)) { return; } if (!validateJoinRequest(joinRequest, joinRequest.getAddress())) { return; } startJoinRequest(joinRequest.toMemberInfo()); } finally { clusterServiceLock.unlock(); } }
private boolean authenticate(JoinRequest joinRequest) { if (!joiningMembers.containsKey(joinRequest.getAddress())) { try { secureLogin(joinRequest); } catch (Exception e) { ILogger securityLogger = node.loggingService.getLogger("com.hazelcast.security"); nodeEngine.getOperationService().send(new AuthenticationFailureOp(), joinRequest.getAddress()); securityLogger.severe(e); return false; } } return true; }
public IdentifiedDataSerializable createNew(Integer arg) { return new JoinRequest(); } };
@Override protected void writeInternal(ObjectDataOutput out) throws IOException { request.writeData(out); }
private void secureLogin(JoinRequest joinRequest) { if (node.securityContext != null) { Credentials credentials = joinRequest.getCredentials(); if (credentials == null) { throw new SecurityException("Expecting security credentials, but credentials could not be found in join request"); } try { LoginContext loginContext = node.securityContext.createMemberLoginContext(credentials); loginContext.login(); } catch (LoginException e) { throw new SecurityException(format("Authentication has failed for %s@%s, cause: %s", credentials.getPrincipal(), credentials.getEndpoint(), e.getMessage())); } } }
private Address findMasterWithMulticast() { try { if (logger.isFineEnabled()) { logger.fine("Searching for master node. Max tries: " + maxTryCount.get()); } JoinRequest joinRequest = node.createJoinRequest(false); while (node.isRunning() && currentTryCount.incrementAndGet() <= maxTryCount.get()) { joinRequest.setTryCount(currentTryCount.get()); node.multicastService.send(joinRequest); Address masterAddress = clusterService.getMasterAddress(); if (masterAddress == null) { //noinspection BusyWait Thread.sleep(getPublishInterval()); } else { return masterAddress; } } } catch (final Exception e) { if (logger != null) { logger.warning(e); } } finally { currentTryCount.set(0); } return null; }
@Override protected void readInternal(ObjectDataInput in) throws IOException { request = new JoinRequest(); request.readData(in); }
@Override public void readData(ObjectDataInput in) throws IOException { super.readData(in); credentials = in.readObject(); if (credentials != null) { credentials.setEndpoint(getAddress().getHost()); } tryCount = in.readInt(); int size = in.readInt(); attributes = createHashMap(size); for (int i = 0; i < size; i++) { String key = in.readUTF(); Object value = in.readObject(); attributes.put(key, value); } size = in.readInt(); Set<String> excludedMemberUuids = createHashSet(size); for (int i = 0; i < size; i++) { excludedMemberUuids.add(in.readUTF()); } this.excludedMemberUuids = unmodifiableSet(excludedMemberUuids); }
public JoinRequest createJoinRequest(boolean withCredentials) { final Credentials credentials = (withCredentials && securityContext != null) ? securityContext.getCredentialsFactory().newCredentials() : null; final Set<String> excludedMemberUuids = nodeExtension.getInternalHotRestartService().getExcludedMemberUuids(); MemberImpl localMember = getLocalMember(); return new JoinRequest(Packet.VERSION, buildInfo.getBuildNumber(), version, address, localMember.getUuid(), localMember.isLiteMember(), createConfigCheck(), credentials, localMember.getAttributes(), excludedMemberUuids); }