use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class MapCombineTask method requestAssignment.
private static void requestAssignment(Set<Object> keys, JobSupervisor supervisor) {
try {
MapReduceService mapReduceService = supervisor.getMapReduceService();
String name = supervisor.getConfiguration().getName();
String jobId = supervisor.getConfiguration().getJobId();
KeysAssignmentResult assignmentResult = mapReduceService.processRequest(supervisor.getJobOwner(), new KeysAssignmentOperation(name, jobId, keys));
if (assignmentResult.getResultState() == SUCCESSFUL) {
Map<Object, Address> assignment = assignmentResult.getAssignment();
for (Map.Entry<Object, Address> entry : assignment.entrySet()) {
// Cache the keys for later mappings
if (!supervisor.assignKeyReducerAddress(entry.getKey(), entry.getValue())) {
throw new IllegalStateException("Key reducer assignment in illegal state");
}
}
}
} catch (Exception e) {
// Just announce it to higher levels
throw new RuntimeException(e);
}
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class TrackableJobFuture method shouldCancel.
@Override
protected boolean shouldCancel(boolean mayInterruptIfRunning) {
Address jobOwner = mapReduceService.getLocalAddress();
if (!mapReduceService.registerJobSupervisorCancellation(name, jobId, jobOwner)) {
return false;
}
JobSupervisor supervisor = mapReduceService.getJobSupervisor(name, jobId);
if (supervisor == null || !supervisor.isOwnerNode()) {
return false;
}
Exception exception = new CancellationException("Operation was cancelled by the user");
return supervisor.cancelAndNotify(exception);
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class TcpIpConnectionManager method onClose.
/**
* Deals with cleaning up a closed connection. This method should only be called once by the
* {@link TcpIpConnection#close(String, Throwable)} method where it is protected against multiple closes.
*/
void onClose(Connection connection) {
closedCount.inc();
if (activeConnections.remove(connection)) {
// this should not be needed; but some tests are using DroppingConnection which is not a TcpIpConnection.
if (connection instanceof TcpIpConnection) {
ioThreadingModel.onConnectionRemoved((TcpIpConnection) connection);
}
metricsRegistry.discardMetrics(connection);
}
Address endPoint = connection.getEndPoint();
if (endPoint != null) {
connectionsInProgress.remove(endPoint);
connectionsMap.remove(endPoint, connection);
fireConnectionRemovedEvent(connection, endPoint);
}
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class HostAwareMemberGroupFactory method createInternalMemberGroups.
@Override
protected Set<MemberGroup> createInternalMemberGroups(Collection<? extends Member> allMembers) {
Map<String, MemberGroup> groups = new HashMap<String, MemberGroup>();
for (Member member : allMembers) {
Address address = ((MemberImpl) member).getAddress();
MemberGroup group = groups.get(address.getHost());
if (group == null) {
group = new DefaultMemberGroup();
groups.put(address.getHost(), group);
}
group.addMember(member);
}
return new HashSet<MemberGroup>(groups.values());
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class ReplicatedMapService method triggerAntiEntropy.
/** Send an operation to all replicas to check their replica versions for all partitions for which this node is the owner */
public void triggerAntiEntropy() {
if (clusterService.getSize(DATA_MEMBER_SELECTOR) == 1) {
return;
}
Collection<Address> addresses = new ArrayList<Address>(getMemberAddresses(DATA_MEMBER_SELECTOR));
addresses.remove(nodeEngine.getThisAddress());
for (int i = 0; i < partitionContainers.length; i++) {
Address thisAddress = nodeEngine.getThisAddress();
InternalPartition partition = partitionService.getPartition(i, false);
Address ownerAddress = partition.getOwnerOrNull();
if (!thisAddress.equals(ownerAddress)) {
continue;
}
PartitionContainer partitionContainer = partitionContainers[i];
if (partitionContainer.isEmpty()) {
continue;
}
for (Address address : addresses) {
CheckReplicaVersionOperation checkReplicaVersionOperation = new CheckReplicaVersionOperation(partitionContainer);
checkReplicaVersionOperation.setPartitionId(i);
checkReplicaVersionOperation.setValidateTarget(false);
operationService.createInvocationBuilder(SERVICE_NAME, checkReplicaVersionOperation, address).setTryCount(INVOCATION_TRY_COUNT).invoke();
}
}
}
Aggregations