use of com.hazelcast.spi.exception.RetryableHazelcastException in project hazelcast by hazelcast.
the class AbstractMessageTask method handleAuthenticationFailure.
private void handleAuthenticationFailure() {
Exception exception;
if (nodeEngine.isRunning()) {
String message = "Client " + endpoint + " must authenticate before any operation.";
logger.severe(message);
exception = new RetryableHazelcastException(new AuthenticationException(message));
} else {
exception = new HazelcastInstanceNotActiveException();
}
sendClientMessage(exception);
connection.close("Authentication failed. " + exception.getMessage(), null);
}
use of com.hazelcast.spi.exception.RetryableHazelcastException in project hazelcast by hazelcast.
the class JobCoordinationService method terminateJob.
public CompletableFuture<Void> terminateJob(long jobId, TerminationMode terminationMode) {
return runWithJob(jobId, masterContext -> {
// User can cancel in any state, other terminations are allowed only when running.
// This is not technically required (we can request termination in any state),
// but this method is only called by the user. It would be weird for the client to
// request a restart if the job didn't start yet etc.
// Also, it would be weird to restart the job during STARTING: as soon as it will start,
// it will restart.
// In any case, it doesn't make sense to restart a suspended job.
JobStatus jobStatus = masterContext.jobStatus();
if (jobStatus != RUNNING && terminationMode != CANCEL_FORCEFUL) {
throw new IllegalStateException("Cannot " + terminationMode + ", job status is " + jobStatus + ", should be " + RUNNING);
}
String terminationResult = masterContext.jobContext().requestTermination(terminationMode, false).f1();
if (terminationResult != null) {
throw new IllegalStateException("Cannot " + terminationMode + ": " + terminationResult);
}
}, jobResult -> {
if (terminationMode != CANCEL_FORCEFUL) {
throw new IllegalStateException("Cannot " + terminationMode + " job " + idToString(jobId) + " because it already has a result: " + jobResult);
}
logger.fine("Ignoring cancellation of a completed job " + idToString(jobId));
}, jobRecord -> {
// we'll eventually learn of the job through scanning of records or from a join operation
throw new RetryableHazelcastException("No MasterContext found for job " + idToString(jobId) + " for " + terminationMode);
});
}
use of com.hazelcast.spi.exception.RetryableHazelcastException in project hazelcast by hazelcast.
the class JobExecutionService method verifyClusterInformation.
private void verifyClusterInformation(long jobId, long executionId, Address coordinator, int coordinatorMemberListVersion, Set<MemberInfo> participants) {
Address masterAddress = nodeEngine.getMasterAddress();
ClusterServiceImpl clusterService = (ClusterServiceImpl) nodeEngine.getClusterService();
MembershipManager membershipManager = clusterService.getMembershipManager();
int localMemberListVersion = membershipManager.getMemberListVersion();
Address thisAddress = nodeEngine.getThisAddress();
if (coordinatorMemberListVersion > localMemberListVersion) {
if (masterAddress == null) {
// elected or split brain merge will happen).
throw new RetryableHazelcastException(String.format("Cannot initialize %s for coordinator %s, local member list version %s," + " coordinator member list version %s. And also, since the master address" + " is not known to this member, cannot request a new member list from master.", jobIdAndExecutionId(jobId, executionId), coordinator, localMemberListVersion, coordinatorMemberListVersion));
}
assert !masterAddress.equals(thisAddress) : String.format("Local node: %s is master but InitOperation has coordinator member list version: %s larger than " + " local member list version: %s", thisAddress, coordinatorMemberListVersion, localMemberListVersion);
nodeEngine.getOperationService().send(new TriggerMemberListPublishOp(), masterAddress);
throw new RetryableHazelcastException(String.format("Cannot initialize %s for coordinator %s, local member list version %s," + " coordinator member list version %s", jobIdAndExecutionId(jobId, executionId), coordinator, localMemberListVersion, coordinatorMemberListVersion));
}
// If the participant members can receive the new member list before the
// coordinator, and we can also get into the
// "coordinatorMemberListVersion < localMemberListVersion" case. If this
// situation occurs when a job participant leaves, then the job start will
// fail. Since the unknown participating member situation couldn't
// be resolved with retrying the InitExecutionOperation for this
// case, we do nothing here and let it fail below if some participant
// isn't found.
// The job start won't fail if this situation occurs when a new member
// is added to the cluster, because all job participants are known to the
// other participating members. The only disadvantage of this is that a
// newly added member will not be a job participant and partition mapping
// may not be completely proper in this case.
boolean isLocalMemberParticipant = false;
for (MemberInfo participant : participants) {
if (participant.getAddress().equals(thisAddress)) {
isLocalMemberParticipant = true;
}
if (membershipManager.getMember(participant.getAddress(), participant.getUuid()) == null) {
throw new TopologyChangedException(String.format("Cannot initialize %s for coordinator %s: participant %s not found in local member list." + " Local member list version: %s, coordinator member list version: %s", jobIdAndExecutionId(jobId, executionId), coordinator, participant, localMemberListVersion, coordinatorMemberListVersion));
}
}
if (!isLocalMemberParticipant) {
throw new IllegalArgumentException(String.format("Cannot initialize %s since member %s is not in participants: %s", jobIdAndExecutionId(jobId, executionId), thisAddress, participants));
}
}
use of com.hazelcast.spi.exception.RetryableHazelcastException in project hazelcast by hazelcast.
the class AbstractJetMessageTask method getInvocationBuilder.
@Override
protected InvocationBuilder getInvocationBuilder(Operation operation) {
Address address;
if (getLightJobCoordinator() != null) {
MemberImpl member = nodeEngine.getClusterService().getMember(getLightJobCoordinator());
if (member == null) {
throw new TopologyChangedException("Light job coordinator left the cluster");
}
address = member.getAddress();
} else {
address = nodeEngine.getMasterAddress();
if (address == null) {
throw new RetryableHazelcastException("master not yet known");
}
}
return nodeEngine.getOperationService().createInvocationBuilder(JetServiceBackend.SERVICE_NAME, operation, address);
}
use of com.hazelcast.spi.exception.RetryableHazelcastException in project orientdb by orientechnologies.
the class OHazelcastPlugin method entryAdded.
@Override
public void entryAdded(final EntryEvent<String, Object> iEvent) {
if (hazelcastInstance == null || !hazelcastInstance.getLifecycleService().isRunning())
return;
try {
if (iEvent.getMember() == null)
// IGNORE IT
return;
final String eventNodeName = getNodeName(iEvent.getMember());
if ("?".equals(eventNodeName))
// MOM ALWAYS SAYS: DON'T ACCEPT CHANGES FROM STRANGERS NODES
return;
final String key = iEvent.getKey();
if (key.startsWith(CONFIG_NODE_PREFIX)) {
if (!iEvent.getMember().equals(hazelcastInstance.getCluster().getLocalMember())) {
final ODocument cfg = (ODocument) iEvent.getValue();
final String joinedNodeName = (String) cfg.field("name");
if (this.nodeName.equals(joinedNodeName)) {
ODistributedServerLog.error(this, joinedNodeName, eventNodeName, DIRECTION.IN, "Found a new node (%s) with the same name as current: '" + joinedNodeName + "'. The node has been excluded. Change the name in its config/orientdb-dserver-config.xml file", iEvent.getMember());
throw new ODistributedException("Found a new node (" + iEvent.getMember().toString() + ") with the same name as current: '" + joinedNodeName + "'. The node has been excluded. Change the name in its config/orientdb-dserver-config.xml file");
}
registerNode(iEvent.getMember(), joinedNodeName);
}
} else if (key.startsWith(CONFIG_DBSTATUS_PREFIX)) {
ODistributedServerLog.info(this, nodeName, eventNodeName, DIRECTION.IN, "Received new status %s=%s", key.substring(CONFIG_DBSTATUS_PREFIX.length()), iEvent.getValue());
// REASSIGN HIS CLUSTER
final String dbNode = key.substring(CONFIG_DBSTATUS_PREFIX.length());
final String nodeName = dbNode.substring(0, dbNode.indexOf("."));
final String databaseName = dbNode.substring(dbNode.indexOf(".") + 1);
onDatabaseEvent(nodeName, databaseName, (DB_STATUS) iEvent.getValue());
invokeOnDatabaseStatusChange(nodeName, databaseName, (DB_STATUS) iEvent.getValue());
if (!iEvent.getMember().equals(hazelcastInstance.getCluster().getLocalMember()) && DB_STATUS.ONLINE.equals(iEvent.getValue())) {
final DB_STATUS s = getDatabaseStatus(getLocalNodeName(), databaseName);
if (s == DB_STATUS.NOT_AVAILABLE) {
// INSTALL THE DATABASE
installDatabase(false, databaseName, false, OGlobalConfiguration.DISTRIBUTED_BACKUP_TRY_INCREMENTAL_FIRST.getValueAsBoolean());
}
}
}
} catch (HazelcastInstanceNotActiveException e) {
OLogManager.instance().error(this, "Hazelcast is not running");
} catch (RetryableHazelcastException e) {
OLogManager.instance().error(this, "Hazelcast is not running");
}
}
Aggregations