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 TopicService method dispatchEvent.
@Override
public void dispatchEvent(Object event, Object listener) {
TopicEvent topicEvent = (TopicEvent) event;
ClusterService clusterService = nodeEngine.getClusterService();
MemberImpl member = clusterService.getMember(topicEvent.publisherAddress);
if (member == null) {
member = new MemberImpl(topicEvent.publisherAddress, nodeEngine.getVersion(), false);
}
Message message = new DataAwareMessage(topicEvent.name, topicEvent.data, topicEvent.publishTime, member, nodeEngine.getSerializationService());
incrementReceivedMessages(topicEvent.name);
MessageListener messageListener = (MessageListener) listener;
messageListener.onMessage(message);
}
use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class TransactionImpl method rollbackBackupLogs.
private void rollbackBackupLogs() {
if (!backupLogsCreated) {
return;
}
OperationService operationService = nodeEngine.getOperationService();
ClusterService clusterService = nodeEngine.getClusterService();
List<Future> futures = new ArrayList<Future>(backupAddresses.length);
for (Address backupAddress : backupAddresses) {
if (clusterService.getMember(backupAddress) != null) {
Future f = operationService.invokeOnTarget(SERVICE_NAME, createRollbackTxBackupLogOperation(), backupAddress);
futures.add(f);
}
}
waitWithDeadline(futures, timeoutMillis, MILLISECONDS, rollbackTxExceptionHandler);
}
use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class TransactionImpl method replicateTxnLog.
private void replicateTxnLog() throws InterruptedException, ExecutionException, java.util.concurrent.TimeoutException {
if (skipBackupLogReplication()) {
return;
}
OperationService operationService = nodeEngine.getOperationService();
ClusterService clusterService = nodeEngine.getClusterService();
List<Future> futures = new ArrayList<Future>(backupAddresses.length);
for (Address backupAddress : backupAddresses) {
if (clusterService.getMember(backupAddress) != null) {
Operation op = createReplicateTxBackupLogOperation();
Future f = operationService.invokeOnTarget(SERVICE_NAME, op, backupAddress);
futures.add(f);
}
}
waitWithDeadline(futures, timeoutMillis, MILLISECONDS, replicationTxExceptionHandler);
}
use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class TransactionManagerServiceImpl method pickBackupLogAddresses.
Address[] pickBackupLogAddresses(int durability) {
if (durability == 0) {
return EMPTY_ADDRESSES;
}
// This should be cleaned up because this is quite a complex approach since it depends on
// the number of members in the cluster and creates litter.
ClusterService clusterService = nodeEngine.getClusterService();
List<MemberImpl> members = new ArrayList<MemberImpl>(clusterService.getMemberImpls());
members.remove(nodeEngine.getLocalMember());
int c = Math.min(members.size(), durability);
shuffle(members);
Address[] addresses = new Address[c];
for (int i = 0; i < c; i++) {
addresses[i] = members.get(i).getAddress();
}
return addresses;
}
Aggregations