Search in sources :

Example 1 with InternalPartitionService

use of com.hazelcast.internal.partition.InternalPartitionService in project hazelcast by hazelcast.

the class InvalidationMetadataDistortionTest method distortRandomPartitionSequence.

private void distortRandomPartitionSequence(String mapName, HazelcastInstance member) {
    NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(member);
    CacheService service = nodeEngineImpl.getService(CacheService.SERVICE_NAME);
    CacheEventHandler cacheEventHandler = service.getCacheEventHandler();
    MetaDataGenerator metaDataGenerator = cacheEventHandler.getMetaDataGenerator();
    InternalPartitionService partitionService = nodeEngineImpl.getPartitionService();
    int partitionCount = partitionService.getPartitionCount();
    int randomPartition = getInt(partitionCount);
    int randomSequence = getInt(MAX_VALUE);
    metaDataGenerator.setCurrentSequence(mapName, randomPartition, randomSequence);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) CacheEventHandler(com.hazelcast.cache.impl.CacheEventHandler) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) CacheService(com.hazelcast.cache.impl.CacheService)

Example 2 with InternalPartitionService

use of com.hazelcast.internal.partition.InternalPartitionService in project hazelcast by hazelcast.

the class GetPartitionsMessageTask method call.

protected Object call() {
    InternalPartitionService service = getService(InternalPartitionService.SERVICE_NAME);
    service.firstArrangement();
    Map<Address, List<Integer>> partitionsMap = new HashMap<Address, List<Integer>>();
    for (IPartition partition : service.getPartitions()) {
        Address owner = partition.getOwnerOrNull();
        if (owner == null) {
            partitionsMap.clear();
            return ClientGetPartitionsCodec.encodeResponse(partitionsMap.entrySet());
        }
        List<Integer> indexes = partitionsMap.get(owner);
        if (indexes == null) {
            indexes = new LinkedList<Integer>();
            partitionsMap.put(owner, indexes);
        }
        indexes.add(partition.getPartitionId());
    }
    return ClientGetPartitionsCodec.encodeResponse(partitionsMap.entrySet());
}
Also used : Address(com.hazelcast.nio.Address) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) HashMap(java.util.HashMap) List(java.util.List) LinkedList(java.util.LinkedList) IPartition(com.hazelcast.spi.partition.IPartition)

Example 3 with InternalPartitionService

use of com.hazelcast.internal.partition.InternalPartitionService in project hazelcast by hazelcast.

the class XAClearRemoteTransactionMessageTask method call.

@Override
protected Object call() throws Exception {
    InternalOperationService operationService = nodeEngine.getOperationService();
    InternalPartitionService partitionService = nodeEngine.getPartitionService();
    ClientEndpoint endpoint = getEndpoint();
    Data xidData = serializationService.toData(parameters.xid);
    Operation op = new ClearRemoteTransactionOperation(xidData);
    op.setCallerUuid(endpoint.getUuid());
    int partitionId = partitionService.getPartitionId(xidData);
    InvocationBuilder builder = operationService.createInvocationBuilder(getServiceName(), op, partitionId);
    builder.setTryCount(TRY_COUNT).setResultDeserialized(false);
    builder.invoke();
    return XATransactionClearRemoteCodec.encodeResponse();
}
Also used : ClearRemoteTransactionOperation(com.hazelcast.transaction.impl.xa.operations.ClearRemoteTransactionOperation) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) Data(com.hazelcast.nio.serialization.Data) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) ClearRemoteTransactionOperation(com.hazelcast.transaction.impl.xa.operations.ClearRemoteTransactionOperation) Operation(com.hazelcast.spi.Operation) InvocationBuilder(com.hazelcast.spi.InvocationBuilder) ClientEndpoint(com.hazelcast.client.ClientEndpoint) ClientEndpoint(com.hazelcast.client.ClientEndpoint)

Example 4 with InternalPartitionService

use of com.hazelcast.internal.partition.InternalPartitionService 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 5 with InternalPartitionService

use of com.hazelcast.internal.partition.InternalPartitionService in project hazelcast by hazelcast.

the class TimedMemberStateFactoryHelper method registerJMXBeans.

static void registerJMXBeans(HazelcastInstanceImpl instance, MemberStateImpl memberState) {
    final EventService es = instance.node.nodeEngine.getEventService();
    final InternalOperationService os = instance.node.nodeEngine.getOperationService();
    final ConnectionManager cm = instance.node.connectionManager;
    final InternalPartitionService ps = instance.node.partitionService;
    final ProxyService proxyService = instance.node.nodeEngine.getProxyService();
    final ExecutionService executionService = instance.node.nodeEngine.getExecutionService();
    final MXBeansDTO beans = new MXBeansDTO();
    final EventServiceDTO esBean = new EventServiceDTO(es);
    beans.setEventServiceBean(esBean);
    final OperationServiceDTO osBean = new OperationServiceDTO(os);
    beans.setOperationServiceBean(osBean);
    final ConnectionManagerDTO cmBean = new ConnectionManagerDTO(cm);
    beans.setConnectionManagerBean(cmBean);
    final PartitionServiceBeanDTO psBean = new PartitionServiceBeanDTO(ps, instance);
    beans.setPartitionServiceBean(psBean);
    final ProxyServiceDTO proxyServiceBean = new ProxyServiceDTO(proxyService);
    beans.setProxyServiceBean(proxyServiceBean);
    final ManagedExecutorService systemExecutor = executionService.getExecutor(ExecutionService.SYSTEM_EXECUTOR);
    final ManagedExecutorService asyncExecutor = executionService.getExecutor(ExecutionService.ASYNC_EXECUTOR);
    final ManagedExecutorService scheduledExecutor = executionService.getExecutor(ExecutionService.SCHEDULED_EXECUTOR);
    final ManagedExecutorService clientExecutor = executionService.getExecutor(ExecutionService.CLIENT_EXECUTOR);
    final ManagedExecutorService queryExecutor = executionService.getExecutor(ExecutionService.QUERY_EXECUTOR);
    final ManagedExecutorService ioExecutor = executionService.getExecutor(ExecutionService.IO_EXECUTOR);
    final ManagedExecutorDTO systemExecutorDTO = new ManagedExecutorDTO(systemExecutor);
    final ManagedExecutorDTO asyncExecutorDTO = new ManagedExecutorDTO(asyncExecutor);
    final ManagedExecutorDTO scheduledExecutorDTO = new ManagedExecutorDTO(scheduledExecutor);
    final ManagedExecutorDTO clientExecutorDTO = new ManagedExecutorDTO(clientExecutor);
    final ManagedExecutorDTO queryExecutorDTO = new ManagedExecutorDTO(queryExecutor);
    final ManagedExecutorDTO ioExecutorDTO = new ManagedExecutorDTO(ioExecutor);
    beans.putManagedExecutor(ExecutionService.SYSTEM_EXECUTOR, systemExecutorDTO);
    beans.putManagedExecutor(ExecutionService.ASYNC_EXECUTOR, asyncExecutorDTO);
    beans.putManagedExecutor(ExecutionService.SCHEDULED_EXECUTOR, scheduledExecutorDTO);
    beans.putManagedExecutor(ExecutionService.CLIENT_EXECUTOR, clientExecutorDTO);
    beans.putManagedExecutor(ExecutionService.QUERY_EXECUTOR, queryExecutorDTO);
    beans.putManagedExecutor(ExecutionService.IO_EXECUTOR, ioExecutorDTO);
    memberState.setBeans(beans);
}
Also used : InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) EventService(com.hazelcast.spi.EventService) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) ExecutionService(com.hazelcast.spi.ExecutionService) EventServiceDTO(com.hazelcast.internal.management.dto.EventServiceDTO) MXBeansDTO(com.hazelcast.internal.management.dto.MXBeansDTO) ManagedExecutorDTO(com.hazelcast.internal.management.dto.ManagedExecutorDTO) ConnectionManagerDTO(com.hazelcast.internal.management.dto.ConnectionManagerDTO) ManagedExecutorService(com.hazelcast.util.executor.ManagedExecutorService) ConnectionManager(com.hazelcast.nio.ConnectionManager) ProxyService(com.hazelcast.spi.ProxyService) PartitionServiceBeanDTO(com.hazelcast.internal.management.dto.PartitionServiceBeanDTO) OperationServiceDTO(com.hazelcast.internal.management.dto.OperationServiceDTO) ProxyServiceDTO(com.hazelcast.internal.management.dto.ProxyServiceDTO)

Aggregations

InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)45 Address (com.hazelcast.nio.Address)11 HazelcastInstance (com.hazelcast.core.HazelcastInstance)10 Test (org.junit.Test)10 Node (com.hazelcast.instance.Node)9 ParallelTest (com.hazelcast.test.annotation.ParallelTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 ArrayList (java.util.ArrayList)8 Config (com.hazelcast.config.Config)6 Data (com.hazelcast.nio.serialization.Data)6 IPartition (com.hazelcast.spi.partition.IPartition)6 HashMap (java.util.HashMap)6 InternalPartition (com.hazelcast.internal.partition.InternalPartition)5 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)5 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)5 List (java.util.List)5 Map (java.util.Map)5 ICacheService (com.hazelcast.cache.impl.ICacheService)4 ICacheRecordStore (com.hazelcast.cache.impl.ICacheRecordStore)3 CacheConfig (com.hazelcast.config.CacheConfig)3