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);
}
Set<SerializableXID> xids = new HashSet<SerializableXID>(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) {
currentThread().interrupt();
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[0]);
}
use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class ScheduledExecutorServiceProxy method accumulateTaskHandlersAsScheduledFutures.
@SuppressWarnings("unchecked")
private <V> void accumulateTaskHandlersAsScheduledFutures(Map<Member, List<IScheduledFuture<V>>> accumulator, Map<?, ?> taskHandlersMap) {
ClusterService clusterService = getNodeEngine().getClusterService();
IPartitionService partitionService = getNodeEngine().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();
List<IScheduledFuture<V>> futures = new ArrayList<>();
for (ScheduledTaskHandler handler : handlers) {
IScheduledFuture future = new ScheduledFutureProxy(handler, this);
futures.add(initializeManagedContext(future));
}
if (accumulator.containsKey(owner)) {
List<IScheduledFuture<V>> memberFutures = accumulator.get(owner);
memberFutures.addAll(futures);
} else {
accumulator.put(owner, futures);
}
}
}
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 RaftService method publishGroupAvailabilityEvents.
private void publishGroupAvailabilityEvents(MemberImpl removedMember) {
ClusterService clusterService = nodeEngine.getClusterService();
if (clusterService.getClusterVersion().isUnknownOrLessThan(Versions.V4_1)) {
return;
}
// they will be the ones that keep track of unreachable CP members.
for (CPGroupId groupId : metadataGroupManager.getActiveGroupIds()) {
CPGroupSummary group = metadataGroupManager.getGroup(groupId);
Collection<CPMember> missing = new ArrayList<>();
boolean availabilityDecreased = false;
for (CPMember member : group.members()) {
if (member.getAddress().equals(removedMember.getAddress())) {
// Group's availability decreased because of this removed member
availabilityDecreased = true;
missing.add(member);
} else if (clusterService.getMember(member.getAddress()) == null) {
missing.add(member);
}
}
if (availabilityDecreased) {
CPGroupAvailabilityEvent e = new CPGroupAvailabilityEventImpl(group.id(), group.members(), missing);
nodeEngine.getEventService().publishEvent(SERVICE_NAME, EVENT_TOPIC_AVAILABILITY, e, EVENT_TOPIC_AVAILABILITY.hashCode());
}
}
}
use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.
the class HttpGetCommandProcessor method handleGetClusterVersion.
private void handleGetClusterVersion(HttpGetCommand command) {
Node node = textCommandService.getNode();
ClusterService clusterService = node.getClusterService();
JsonObject response = new JsonObject().add("status", "success").add("version", clusterService.getClusterVersion().toString());
prepareResponse(command, response);
}
Aggregations