use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.
the class CollectionEvent method readData.
@Override
public void readData(ObjectDataInput in) throws IOException {
name = in.readString();
eventType = ItemEventType.getByType(in.readInt());
caller = new Address();
caller.readData(in);
data = IOUtil.readData(in);
}
use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.
the class AbstractMember method getSocketAddress.
@Override
public InetSocketAddress getSocketAddress(EndpointQualifier qualifier) {
Address addr = addressMap.get(qualifier);
if (addr == null && !qualifier.getType().equals(ProtocolType.MEMBER)) {
addr = addressMap.get(MEMBER);
}
checkNotNull(addr);
try {
return addr.getInetSocketAddress();
} catch (UnknownHostException e) {
if (getLogger() != null) {
getLogger().warning(e);
}
return null;
}
}
use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.
the class ExecutorServiceProxy method submitToMember.
private <T> void submitToMember(@Nonnull Data taskData, @Nonnull Member member, @Nullable ExecutionCallback<T> callback) {
checkNotNull(member, "member must not be null");
checkNotShutdown();
NodeEngine nodeEngine = getNodeEngine();
UUID uuid = newUnsecureUUID();
MemberCallableTaskOperation op = new MemberCallableTaskOperation(name, uuid, taskData);
OperationService operationService = nodeEngine.getOperationService();
Address address = member.getAddress();
InvocationFuture<T> future = operationService.createInvocationBuilder(DistributedExecutorService.SERVICE_NAME, op, address).invoke();
if (callback != null) {
future.whenCompleteAsync(new ExecutionCallbackAdapter<>(callback)).whenCompleteAsync((v, t) -> {
if (t instanceof RejectedExecutionException) {
callback.onFailure(t);
}
});
}
}
use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.
the class ClusterJoinManager method checkIfUsingAnExistingMemberUuid.
private boolean checkIfUsingAnExistingMemberUuid(JoinMessage joinMessage) {
Member member = clusterService.getMember(joinMessage.getUuid());
Address target = joinMessage.getAddress();
if (member != null && !member.getAddress().equals(joinMessage.getAddress())) {
if (clusterService.isMaster() && !isMastershipClaimInProgress()) {
String message = "There's already an existing member " + member + " with the same UUID. " + target + " is not allowed to join.";
logger.warning(message);
} else {
sendMasterAnswer(target);
}
return true;
}
return false;
}
use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.
the class ClusterJoinManager method handleMasterResponse.
/**
* Set master address, if required.
*
* @param masterAddress address of cluster's master, as provided in {@link MasterResponseOp}
* @param callerAddress address of node that sent the {@link MasterResponseOp}
* @see MasterResponseOp
*/
public void handleMasterResponse(Address masterAddress, Address callerAddress) {
clusterServiceLock.lock();
try {
if (logger.isFineEnabled()) {
logger.fine(format("Handling master response %s from %s", masterAddress, callerAddress));
}
if (clusterService.isJoined()) {
if (logger.isFineEnabled()) {
logger.fine(format("Ignoring master response %s from %s, this node is already joined", masterAddress, callerAddress));
}
return;
}
if (node.getThisAddress().equals(masterAddress)) {
logger.warning("Received my address as master address from " + callerAddress);
return;
}
Address currentMaster = clusterService.getMasterAddress();
if (currentMaster == null || currentMaster.equals(masterAddress)) {
setMasterAndJoin(masterAddress);
return;
}
if (currentMaster.equals(callerAddress)) {
logger.warning(format("Setting master to %s since %s says it is not master anymore", masterAddress, currentMaster));
setMasterAndJoin(masterAddress);
return;
}
Connection conn = node.getServer().getConnectionManager(MEMBER).get(currentMaster);
if (conn != null && conn.isAlive()) {
logger.info(format("Ignoring master response %s from %s since this node has an active master %s", masterAddress, callerAddress, currentMaster));
sendJoinRequest(currentMaster);
} else {
logger.warning(format("Ambiguous master response! Received master response %s from %s. " + "This node has a master %s, but does not have an active connection to it. " + "Master field will be unset now.", masterAddress, callerAddress, currentMaster));
clusterService.setMasterAddress(null);
}
} finally {
clusterServiceLock.unlock();
}
}
Aggregations