use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class ClusterServiceMemberListTest method verifyMembersFromDataMember.
private void verifyMembersFromDataMember(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(dataMembers, localMember);
assertNotContains(liteMembers, localMember);
final Collection<Member> dataMembersWithoutThis = clusterService.getMembers(MemberSelectors.and(DATA_MEMBER_SELECTOR, NON_LOCAL_MEMBER_SELECTOR));
assertNotContains(dataMembersWithoutThis, localMember);
final Collection<Member> liteMembersWithThis = clusterService.getMembers(MemberSelectors.or(LITE_MEMBER_SELECTOR, LOCAL_MEMBER_SELECTOR));
assertContains(liteMembersWithThis, localMember);
}
use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class ClusterServiceMemberListTest method verifySizeFromDataMember.
private void verifySizeFromDataMember(final HazelcastInstance instance) {
final ClusterService clusterService = getClusterService(instance);
assertEquals(1, clusterService.getSize(MemberSelectors.LITE_MEMBER_SELECTOR));
assertEquals(2, clusterService.getSize(MemberSelectors.DATA_MEMBER_SELECTOR));
assertEquals(1, clusterService.getSize(MemberSelectors.and(DATA_MEMBER_SELECTOR, NON_LOCAL_MEMBER_SELECTOR)));
assertEquals(2, clusterService.getSize(MemberSelectors.or(LITE_MEMBER_SELECTOR, LOCAL_MEMBER_SELECTOR)));
}
use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class XAResourceImpl method recover.
@Override
public Xid[] recover(int flag) throws XAException {
NodeEngine nodeEngine = getNodeEngine();
XAService xaService = getService();
OperationService operationService = nodeEngine.getOperationService();
ClusterService clusterService = nodeEngine.getClusterService();
Collection<Member> memberList = clusterService.getMembers();
List<Future<SerializableList>> futureList = new ArrayList<Future<SerializableList>>();
for (Member member : memberList) {
if (member.localMember()) {
continue;
}
CollectRemoteTransactionsOperation op = new CollectRemoteTransactionsOperation();
Address address = member.getAddress();
InternalCompletableFuture<SerializableList> future = operationService.invokeOnTarget(SERVICE_NAME, op, address);
futureList.add(future);
}
HashSet<SerializableXID> xids = new HashSet<SerializableXID>();
xids.addAll(xaService.getPreparedXids());
for (Future<SerializableList> future : futureList) {
try {
SerializableList xidSet = future.get();
for (Data xidData : xidSet) {
SerializableXID xid = nodeEngine.toObject(xidData);
xids.add(xid);
}
} catch (InterruptedException e) {
throw new XAException(XAException.XAER_RMERR);
} catch (MemberLeftException e) {
logger.warning("Member left while recovering", e);
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof HazelcastInstanceNotActiveException || cause instanceof TargetNotMemberException) {
logger.warning("Member left while recovering", e);
} else {
throw new XAException(XAException.XAER_RMERR);
}
}
}
return xids.toArray(new SerializableXID[xids.size()]);
}
use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class TransactionImpl method purgeBackupLogs.
private void purgeBackupLogs() {
if (!backupLogsCreated) {
return;
}
OperationService operationService = nodeEngine.getOperationService();
ClusterService clusterService = nodeEngine.getClusterService();
for (Address backupAddress : backupAddresses) {
if (clusterService.getMember(backupAddress) != null) {
try {
operationService.invokeOnTarget(SERVICE_NAME, createPurgeTxBackupLogOperation(), backupAddress);
} catch (Throwable e) {
logger.warning("Error during purging backups!", e);
}
}
}
}
use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class AbstractMapReduceTask method startSupervisionTask.
private void startSupervisionTask(JobTracker jobTracker) {
final MapReduceService mapReduceService = getService(MapReduceService.SERVICE_NAME);
final JobTrackerConfig config = ((AbstractJobTracker) jobTracker).getJobTrackerConfig();
final boolean communicateStats = config.isCommunicateStats();
final int chunkSize = getChunkSizeOrConfigChunkSize(config);
final TopologyChangedStrategy topologyChangedStrategy = getTopologyChangedStrategyOrConfigTopologyChangedStrategy(config);
final String name = getDistributedObjectName();
final String jobId = getJobId();
final KeyValueSource keyValueSource = getKeyValueSource();
final Mapper mapper = getMapper();
final CombinerFactory combinerFactory = getCombinerFactory();
final ReducerFactory reducerFactory = getReducerFactory();
final Collection keys = getKeys();
final Collection<Object> keyObjects = getKeyObjects(keys);
final KeyPredicate predicate = getPredicate();
final ClusterService clusterService = nodeEngine.getClusterService();
for (Member member : clusterService.getMembers(KeyValueJobOperation.MEMBER_SELECTOR)) {
Operation operation = new KeyValueJobOperation(name, jobId, chunkSize, keyValueSource, mapper, combinerFactory, reducerFactory, communicateStats, topologyChangedStrategy);
executeOperation(operation, member.getAddress(), mapReduceService, nodeEngine);
}
// After we prepared all the remote systems we can now start the processing
for (Member member : clusterService.getMembers(DATA_MEMBER_SELECTOR)) {
Operation operation = new StartProcessingJobOperation(name, jobId, keyObjects, predicate);
executeOperation(operation, member.getAddress(), mapReduceService, nodeEngine);
}
}
Aggregations