Search in sources :

Example 11 with Node

use of com.hazelcast.instance.Node in project hazelcast by hazelcast.

the class MemberInfoUpdateOperation method getConnectionEndpointOrThisAddress.

final Address getConnectionEndpointOrThisAddress() {
    ClusterServiceImpl clusterService = getService();
    NodeEngineImpl nodeEngine = clusterService.getNodeEngine();
    Node node = nodeEngine.getNode();
    Connection conn = getConnection();
    return conn != null ? conn.getEndPoint() : node.getThisAddress();
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Node(com.hazelcast.instance.Node) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) Connection(com.hazelcast.nio.Connection)

Example 12 with Node

use of com.hazelcast.instance.Node 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)

Example 13 with Node

use of com.hazelcast.instance.Node in project hazelcast by hazelcast.

the class TriggerPartialStartRequest method writeResponse.

@Override
public void writeResponse(ManagementCenterService mcs, JsonObject out) throws Exception {
    Node node = mcs.getHazelcastInstance().node;
    final InternalHotRestartService hotRestartService = node.getNodeExtension().getInternalHotRestartService();
    final boolean done = hotRestartService.triggerPartialStart();
    String result = done ? SUCCESS_RESULT : FAILED_RESULT;
    out.add("result", result);
}
Also used : Node(com.hazelcast.instance.Node) InternalHotRestartService(com.hazelcast.hotrestart.InternalHotRestartService)

Example 14 with Node

use of com.hazelcast.instance.Node in project hazelcast by hazelcast.

the class BaseMigrationOperation method verifyClusterState.

private void verifyClusterState() {
    final NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    ClusterState clusterState = nodeEngine.getClusterService().getClusterState();
    if (clusterState != ClusterState.ACTIVE) {
        throw new IllegalStateException("Cluster state is not active! " + clusterState);
    }
    final Node node = nodeEngine.getNode();
    if (!node.getNodeExtension().isStartCompleted()) {
        throw new IllegalStateException("Migration operation is received before startup is completed. " + "Caller: " + getCallerAddress());
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ClusterState(com.hazelcast.cluster.ClusterState) Node(com.hazelcast.instance.Node)

Example 15 with Node

use of com.hazelcast.instance.Node in project hazelcast by hazelcast.

the class PartitionCorrectnessTestSupport method assertSizeAndData.

private void assertSizeAndData(boolean allowDirty) throws InterruptedException {
    Collection<HazelcastInstance> instances = factory.getAllHazelcastInstances();
    final int actualBackupCount = Math.min(backupCount, instances.size() - 1);
    final int expectedSize = partitionCount * (actualBackupCount + 1);
    int total = 0;
    for (HazelcastInstance hz : instances) {
        TestMigrationAwareService service = getService(hz);
        total += service.size();
        Node node = getNode(hz);
        InternalPartitionService partitionService = node.getPartitionService();
        InternalPartition[] partitions = partitionService.getInternalPartitions();
        Address thisAddress = node.getThisAddress();
        // find leaks
        assertNoLeakingData(service, partitions, thisAddress);
        // find missing
        assertNoMissingData(service, partitions, thisAddress);
        // check values
        assertPartitionVersionsAndBackupValues(actualBackupCount, service, node, partitions, allowDirty);
        assertMigrationEvents(service, thisAddress);
    }
    assertEquals("Missing data!", expectedSize, total);
}
Also used : TestMigrationAwareService(com.hazelcast.internal.partition.service.TestMigrationAwareService) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.nio.Address) Node(com.hazelcast.instance.Node)

Aggregations

Node (com.hazelcast.instance.Node)131 HazelcastInstance (com.hazelcast.core.HazelcastInstance)60 Test (org.junit.Test)50 QuickTest (com.hazelcast.test.annotation.QuickTest)45 ParallelTest (com.hazelcast.test.annotation.ParallelTest)42 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)21 ClientEventRegistration (com.hazelcast.client.spi.impl.listener.ClientEventRegistration)18 Address (com.hazelcast.nio.Address)17 Config (com.hazelcast.config.Config)14 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)13 ILogger (com.hazelcast.logging.ILogger)10 Data (com.hazelcast.nio.serialization.Data)10 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)10 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)9 StringUtil.bytesToString (com.hazelcast.util.StringUtil.bytesToString)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 ClusterService (com.hazelcast.internal.cluster.ClusterService)7 SerializationService (com.hazelcast.spi.serialization.SerializationService)7 ItemListener (com.hazelcast.core.ItemListener)6 Operation (com.hazelcast.spi.Operation)6