Search in sources :

Example 11 with RetryableHazelcastException

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);
}
Also used : HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) AuthenticationException(com.hazelcast.client.AuthenticationException) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) MemberLeftException(com.hazelcast.core.MemberLeftException) AuthenticationException(com.hazelcast.client.AuthenticationException) AccessControlException(java.security.AccessControlException)

Example 12 with RetryableHazelcastException

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);
    });
}
Also used : JobStatus(com.hazelcast.jet.core.JobStatus) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) Util.idToString(com.hazelcast.jet.Util.idToString)

Example 13 with RetryableHazelcastException

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));
    }
}
Also used : Address(com.hazelcast.cluster.Address) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) MembershipManager(com.hazelcast.internal.cluster.impl.MembershipManager) TriggerMemberListPublishOp(com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOp) TopologyChangedException(com.hazelcast.jet.core.TopologyChangedException)

Example 14 with RetryableHazelcastException

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);
}
Also used : Address(com.hazelcast.cluster.Address) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) TopologyChangedException(com.hazelcast.jet.core.TopologyChangedException)

Example 15 with RetryableHazelcastException

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");
    }
}
Also used : RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Aggregations

RetryableHazelcastException (com.hazelcast.spi.exception.RetryableHazelcastException)22 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)6 Address (com.hazelcast.cluster.Address)5 TopologyChangedException (com.hazelcast.jet.core.TopologyChangedException)4 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)3 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)3 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)3 MembershipManager (com.hazelcast.internal.cluster.impl.MembershipManager)3 TriggerMemberListPublishOp (com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOp)3 ILogger (com.hazelcast.logging.ILogger)3 Address (com.hazelcast.nio.Address)3 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)2 MemberLeftException (com.hazelcast.core.MemberLeftException)2 MigrationInfo (com.hazelcast.internal.partition.MigrationInfo)2 Predicate (com.hazelcast.query.Predicate)2 NodeEngine (com.hazelcast.spi.impl.NodeEngine)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2