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");
}
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);
}
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);
}
}
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);
}
}
}
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);
}
Aggregations