Search in sources :

Example 11 with TopologyChangedException

use of com.hazelcast.jet.core.TopologyChangedException in project hazelcast-jet by hazelcast.

the class JobExecutionService method onMemberLeave.

/**
 * Cancels executions that contain the left address as the coordinator or a
 * job participant
 */
void onMemberLeave(Address address) {
    executionContexts.values().stream().filter(exeCtx -> exeCtx.coordinator().equals(address) || exeCtx.hasParticipant(address)).forEach(exeCtx -> {
        String message = String.format("Completing %s locally. Reason: Coordinator %s left the cluster", jobAndExecutionId(exeCtx.jobId(), exeCtx.executionId()), address);
        cancelAndComplete(exeCtx, message, new TopologyChangedException("Topology has been changed."));
    });
}
Also used : HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) DistributedFunctions.entryValue(com.hazelcast.jet.function.DistributedFunctions.entryValue) MembershipManager(com.hazelcast.internal.cluster.impl.MembershipManager) Address(com.hazelcast.nio.Address) SenderTasklet(com.hazelcast.jet.impl.execution.SenderTasklet) Util.jobAndExecutionId(com.hazelcast.jet.impl.util.Util.jobAndExecutionId) Supplier(java.util.function.Supplier) ConcurrentMap(java.util.concurrent.ConcurrentMap) Util.idToString(com.hazelcast.jet.impl.util.Util.idToString) Collections.newSetFromMap(java.util.Collections.newSetFromMap) Collectors.toMap(java.util.stream.Collectors.toMap) ILogger(com.hazelcast.logging.ILogger) ExceptionUtil.withTryCatch(com.hazelcast.jet.impl.util.ExceptionUtil.withTryCatch) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) Map(java.util.Map) TaskletExecutionService(com.hazelcast.jet.impl.execution.TaskletExecutionService) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) Collectors.toSet(java.util.stream.Collectors.toSet) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ExecutionContext(com.hazelcast.jet.impl.execution.ExecutionContext) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) Operation(com.hazelcast.spi.Operation) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) PrivilegedAction(java.security.PrivilegedAction) DistributedFunctions.entryKey(com.hazelcast.jet.function.DistributedFunctions.entryKey) TriggerMemberListPublishOp(com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOp) ExecutionPlan(com.hazelcast.jet.impl.execution.init.ExecutionPlan) JetClassLoader(com.hazelcast.jet.impl.deployment.JetClassLoader) TopologyChangedException(com.hazelcast.jet.core.TopologyChangedException) AccessController(java.security.AccessController) Util.idToString(com.hazelcast.jet.impl.util.Util.idToString) TopologyChangedException(com.hazelcast.jet.core.TopologyChangedException)

Example 12 with TopologyChangedException

use of com.hazelcast.jet.core.TopologyChangedException in project hazelcast-jet by hazelcast.

the class ExecutionPlanBuilder method initPartitionOwnersAndMembers.

private static void initPartitionOwnersAndMembers(NodeEngine nodeEngine, MembersView membersView, Collection<MemberInfo> members, Address[] partitionOwners) {
    IPartitionService partitionService = nodeEngine.getPartitionService();
    for (int partitionId = 0; partitionId < partitionOwners.length; partitionId++) {
        Address address = partitionService.getPartitionOwnerOrWait(partitionId);
        MemberInfo member;
        if ((member = membersView.getMember(address)) == null) {
            // it has just left the cluster.
            throw new TopologyChangedException("Topology changed, " + address + " is not in original member list");
        }
        // add member to known members
        members.add(member);
        partitionOwners[partitionId] = address;
    }
}
Also used : Address(com.hazelcast.nio.Address) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) IPartitionService(com.hazelcast.spi.partition.IPartitionService) TopologyChangedException(com.hazelcast.jet.core.TopologyChangedException)

Aggregations

TopologyChangedException (com.hazelcast.jet.core.TopologyChangedException)12 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)7 Address (com.hazelcast.nio.Address)6 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)5 ILogger (com.hazelcast.logging.ILogger)5 Map (java.util.Map)5 Set (java.util.Set)5 Address (com.hazelcast.cluster.Address)4 ExecutionPlan (com.hazelcast.jet.impl.execution.init.ExecutionPlan)4 ExceptionUtil.withTryCatch (com.hazelcast.jet.impl.util.ExceptionUtil.withTryCatch)4 Util.idToString (com.hazelcast.jet.impl.util.Util.idToString)4 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)4 MembersView (com.hazelcast.internal.cluster.impl.MembersView)3 JobConfig (com.hazelcast.jet.config.JobConfig)3 ProcessingGuarantee (com.hazelcast.jet.config.ProcessingGuarantee)3 DAG (com.hazelcast.jet.core.DAG)3 Edge (com.hazelcast.jet.core.Edge)3 Edge.between (com.hazelcast.jet.core.Edge.between)3 JobStatus (com.hazelcast.jet.core.JobStatus)3 COMPLETED (com.hazelcast.jet.core.JobStatus.COMPLETED)3