Search in sources :

Example 1 with ClusterService

use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.

the class KeyValueJob method invoke.

@Override
protected <T> JobCompletableFuture<T> invoke(Collator collator) {
    ClusterService clusterService = nodeEngine.getClusterService();
    if (clusterService.getSize(MemberSelectors.DATA_MEMBER_SELECTOR) == 0) {
        throw new IllegalStateException("Could not register map reduce job since there are no nodes owning a partition");
    }
    String jobId = UuidUtil.newUnsecureUuidString();
    AbstractJobTracker jobTracker = (AbstractJobTracker) this.jobTracker;
    TrackableJobFuture<T> jobFuture = new TrackableJobFuture<T>(name, jobId, jobTracker, nodeEngine, collator);
    if (jobTracker.registerTrackableJob(jobFuture)) {
        return startSupervisionTask(jobFuture, jobId);
    }
    throw new IllegalStateException("Could not register map reduce job");
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) AbstractJobTracker(com.hazelcast.mapreduce.impl.AbstractJobTracker)

Example 2 with ClusterService

use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.

the class MapDestroyCacheMessageTask method call.

@Override
protected Object call() throws Exception {
    ClusterService clusterService = clientEngine.getClusterService();
    Collection<MemberImpl> members = clusterService.getMemberImpls();
    List<Future<Boolean>> futures = new ArrayList<Future<Boolean>>(members.size());
    createInvocations(members, futures);
    Collection<Boolean> results = FutureUtil.returnWithDeadline(futures, 1, TimeUnit.MINUTES);
    return reduce(results);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) MemberImpl(com.hazelcast.instance.MemberImpl) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future)

Example 3 with ClusterService

use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.

the class AbstractMapReduceTask method processMessage.

@Override
protected void processMessage() {
    MapReduceService mapReduceService = getService(MapReduceService.SERVICE_NAME);
    NodeEngine nodeEngine = mapReduceService.getNodeEngine();
    ClusterService clusterService = nodeEngine.getClusterService();
    if (clusterService.getSize(MemberSelectors.DATA_MEMBER_SELECTOR) == 0) {
        throw new IllegalStateException("Could not register map reduce job since there are no nodes owning a partition");
    }
    final String objectName = getDistributedObjectName();
    AbstractJobTracker jobTracker = (AbstractJobTracker) mapReduceService.createDistributedObject(objectName);
    TrackableJobFuture jobFuture = new TrackableJobFuture(objectName, getJobId(), jobTracker, nodeEngine, null);
    if (jobTracker.registerTrackableJob(jobFuture)) {
        startSupervisionTask(jobTracker);
        jobFuture.andThen(this);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) TrackableJobFuture(com.hazelcast.mapreduce.impl.task.TrackableJobFuture) ClusterService(com.hazelcast.internal.cluster.ClusterService) MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) AbstractJobTracker(com.hazelcast.mapreduce.impl.AbstractJobTracker)

Example 4 with ClusterService

use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.

the class ScheduledExecutorGetAllScheduledMessageTask method accumulateTaskHandlersAsUrnValues.

@SuppressWarnings("unchecked")
private void accumulateTaskHandlersAsUrnValues(Map<Member, List<ScheduledTaskHandler>> accumulator, Map<?, ?> taskHandlersMap) {
    ClusterService clusterService = nodeEngine.getClusterService();
    IPartitionService partitionService = nodeEngine.getPartitionService();
    for (Map.Entry<?, ?> entry : taskHandlersMap.entrySet()) {
        Member owner;
        Object key = entry.getKey();
        if (key instanceof Number) {
            owner = clusterService.getMember(partitionService.getPartitionOwner((Integer) key));
        } else {
            owner = (Member) key;
        }
        List<ScheduledTaskHandler> handlers = (List<ScheduledTaskHandler>) entry.getValue();
        if (accumulator.containsKey(owner)) {
            List<ScheduledTaskHandler> memberUrns = accumulator.get(owner);
            memberUrns.addAll(handlers);
        } else {
            accumulator.put(owner, handlers);
        }
    }
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) ScheduledTaskHandler(com.hazelcast.scheduledexecutor.ScheduledTaskHandler) IPartitionService(com.hazelcast.spi.partition.IPartitionService) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Member(com.hazelcast.core.Member)

Example 5 with ClusterService

use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.

the class ClusterServiceMemberListTest method verifyMembersFromLiteMember.

private void verifyMembersFromLiteMember(final HazelcastInstance instance) {
    final Member localMember = getLocalMember(instance);
    final ClusterService clusterService = getClusterService(instance);
    final Collection<Member> liteMembers = clusterService.getMembers(LITE_MEMBER_SELECTOR);
    final Collection<Member> dataMembers = clusterService.getMembers(DATA_MEMBER_SELECTOR);
    assertContains(liteMembers, localMember);
    assertNotContains(dataMembers, localMember);
    final Collection<Member> liteMembersWithoutThis = clusterService.getMembers(MemberSelectors.and(LITE_MEMBER_SELECTOR, NON_LOCAL_MEMBER_SELECTOR));
    assertNotContains(liteMembersWithoutThis, localMember);
    final Collection<Member> dataMembersWithThis = clusterService.getMembers(MemberSelectors.or(DATA_MEMBER_SELECTOR, LOCAL_MEMBER_SELECTOR));
    assertContains(dataMembersWithThis, localMember);
}
Also used : Accessors.getClusterService(com.hazelcast.test.Accessors.getClusterService) ClusterService(com.hazelcast.internal.cluster.ClusterService)

Aggregations

ClusterService (com.hazelcast.internal.cluster.ClusterService)53 Address (com.hazelcast.cluster.Address)11 Member (com.hazelcast.cluster.Member)10 ArrayList (java.util.ArrayList)10 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)8 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)8 Future (java.util.concurrent.Future)8 UUID (java.util.UUID)6 CPMember (com.hazelcast.cp.CPMember)5 ILogger (com.hazelcast.logging.ILogger)5 Accessors.getClusterService (com.hazelcast.test.Accessors.getClusterService)5 ClusterState (com.hazelcast.cluster.ClusterState)4 Node (com.hazelcast.instance.impl.Node)4 JsonObject (com.hazelcast.internal.json.JsonObject)4 AbstractJobTracker (com.hazelcast.mapreduce.impl.AbstractJobTracker)4 NodeEngine (com.hazelcast.spi.impl.NodeEngine)4 Operation (com.hazelcast.spi.impl.operationservice.Operation)4 Member (com.hazelcast.core.Member)3 CPGroupId (com.hazelcast.cp.CPGroupId)3 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)3