Search in sources :

Example 11 with Address

use of com.hazelcast.nio.Address in project hazelcast by hazelcast.

the class MergeClustersOperation method run.

@Override
public void run() {
    final Address caller = getCallerAddress();
    final NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    final Node node = nodeEngine.getNode();
    final Address masterAddress = node.getMasterAddress();
    final ILogger logger = node.loggingService.getLogger(this.getClass().getName());
    boolean local = caller == null;
    if (!local && !caller.equals(masterAddress)) {
        logger.warning("Ignoring merge instruction sent from non-master endpoint: " + caller);
        return;
    }
    logger.warning(node.getThisAddress() + " is merging to " + newTargetAddress + ", because: instructed by master " + masterAddress);
    nodeEngine.getExecutionService().execute(ExecutionService.SYSTEM_EXECUTOR, new Runnable() {

        @Override
        public void run() {
            node.getClusterService().merge(newTargetAddress);
        }
    });
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Address(com.hazelcast.nio.Address) Node(com.hazelcast.instance.Node) ILogger(com.hazelcast.logging.ILogger)

Example 12 with Address

use of com.hazelcast.nio.Address in project hazelcast by hazelcast.

the class LockClusterStateOperation method readInternal.

@Override
protected void readInternal(ObjectDataInput in) throws IOException {
    super.readInternal(in);
    stateChange = in.readObject();
    initiator = new Address();
    initiator.readData(in);
    txnId = in.readUTF();
    leaseTime = in.readLong();
    partitionStateVersion = in.readInt();
}
Also used : Address(com.hazelcast.nio.Address)

Example 13 with Address

use of com.hazelcast.nio.Address in project hazelcast by hazelcast.

the class MasterConfirmationOperation method run.

@Override
public void run() {
    final Address endpoint = getCallerAddress();
    if (endpoint == null) {
        return;
    }
    final ClusterServiceImpl clusterService = getService();
    final ILogger logger = getLogger();
    final MemberImpl member = clusterService.getMember(endpoint);
    if (member == null) {
        logger.warning("MasterConfirmation has been received from " + endpoint + ", but it is not a member of this cluster!");
        OperationService operationService = getNodeEngine().getOperationService();
        operationService.send(new MemberRemoveOperation(clusterService.getThisAddress()), endpoint);
    } else {
        if (clusterService.isMaster()) {
            clusterService.getClusterHeartbeatManager().acceptMasterConfirmation(member, timestamp);
        } else {
            logger.warning(endpoint + " has sent MasterConfirmation, but this node is not master!");
        }
    }
}
Also used : Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ILogger(com.hazelcast.logging.ILogger) OperationService(com.hazelcast.spi.OperationService)

Example 14 with Address

use of com.hazelcast.nio.Address in project hazelcast by hazelcast.

the class MemberInfoUpdateOperation method run.

@Override
public void run() throws Exception {
    checkLocalMemberUuid();
    ClusterServiceImpl clusterService = getService();
    Address callerAddress = getConnectionEndpointOrThisAddress();
    if (clusterService.updateMembers(memberInfos, callerAddress)) {
        processPartitionState();
    }
}
Also used : Address(com.hazelcast.nio.Address) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl)

Example 15 with Address

use of com.hazelcast.nio.Address in project hazelcast by hazelcast.

the class TimedMemberStateFactory method createMemberState.

private void createMemberState(TimedMemberState timedMemberState, MemberStateImpl memberState, Collection<StatisticsAwareService> services) {
    Node node = instance.node;
    HashSet<ClientEndPointDTO> serializableClientEndPoints = new HashSet<ClientEndPointDTO>();
    for (Client client : instance.node.clientEngine.getClients()) {
        serializableClientEndPoints.add(new ClientEndPointDTO(client));
    }
    memberState.setClients(serializableClientEndPoints);
    Address thisAddress = node.getThisAddress();
    memberState.setAddress(thisAddress.getHost() + ":" + thisAddress.getPort());
    TimedMemberStateFactoryHelper.registerJMXBeans(instance, memberState);
    MemberPartitionStateImpl memberPartitionState = (MemberPartitionStateImpl) memberState.getMemberPartitionState();
    InternalPartitionService partitionService = node.getPartitionService();
    IPartition[] partitions = partitionService.getPartitions();
    List<Integer> partitionList = memberPartitionState.getPartitions();
    for (IPartition partition : partitions) {
        if (partition.isLocal()) {
            partitionList.add(partition.getPartitionId());
        }
    }
    memberPartitionState.setMigrationQueueSize(partitionService.getMigrationQueueSize());
    memberPartitionState.setMemberStateSafe(memberStateSafe);
    memberState.setLocalMemoryStats(getMemoryStats());
    memberState.setOperationStats(getOperationStats());
    TimedMemberStateFactoryHelper.createRuntimeProps(memberState);
    createMemState(timedMemberState, memberState, services);
    createNodeState(memberState);
    createHotRestartState(memberState);
    createClusterHotRestartStatus(memberState);
    createWanSyncState(memberState);
}
Also used : Address(com.hazelcast.nio.Address) ClientEndPointDTO(com.hazelcast.internal.management.dto.ClientEndPointDTO) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) Node(com.hazelcast.instance.Node) MemberPartitionStateImpl(com.hazelcast.monitor.impl.MemberPartitionStateImpl) Client(com.hazelcast.core.Client) IPartition(com.hazelcast.spi.partition.IPartition) HashSet(java.util.HashSet)

Aggregations

Address (com.hazelcast.nio.Address)274 Test (org.junit.Test)44 QuickTest (com.hazelcast.test.annotation.QuickTest)36 HashMap (java.util.HashMap)33 ParallelTest (com.hazelcast.test.annotation.ParallelTest)29 Member (com.hazelcast.core.Member)27 ArrayList (java.util.ArrayList)27 Map (java.util.Map)26 ILogger (com.hazelcast.logging.ILogger)25 InetAddress (java.net.InetAddress)25 MemberImpl (com.hazelcast.instance.MemberImpl)21 List (java.util.List)20 HashSet (java.util.HashSet)18 Connection (com.hazelcast.nio.Connection)17 NodeEngine (com.hazelcast.spi.NodeEngine)16 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)16 IOException (java.io.IOException)16 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)14 HazelcastInstance (com.hazelcast.core.HazelcastInstance)13 IPartitionService (com.hazelcast.spi.partition.IPartitionService)13