Search in sources :

Example 6 with IPartitionService

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

the class ConsumeAccumulatorOperation method isLocal.

private boolean isLocal() {
    NodeEngine nodeEngine = getNodeEngine();
    IPartitionService partitionService = nodeEngine.getPartitionService();
    IPartition partition = partitionService.getPartition(getPartitionId());
    return partition.isLocal();
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) IPartitionService(com.hazelcast.internal.partition.IPartitionService) IPartition(com.hazelcast.internal.partition.IPartition)

Example 7 with IPartitionService

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

the class MapContainer method hasNotExpired.

/**
 * @return {@code true} if queryableEntry has
 * not expired, otherwise returns {@code false}
 */
private boolean hasNotExpired(QueryableEntry queryableEntry, long now) {
    Data keyData = queryableEntry.getKeyData();
    IPartitionService partitionService = mapServiceContext.getNodeEngine().getPartitionService();
    int partitionId = partitionService.getPartitionId(keyData);
    if (!getIndexes(partitionId).isGlobal()) {
        ThreadUtil.assertRunningOnPartitionThread();
    }
    RecordStore recordStore = mapServiceContext.getExistingRecordStore(partitionId, name);
    return recordStore != null && !recordStore.isExpired(keyData, now, false);
}
Also used : IPartitionService(com.hazelcast.internal.partition.IPartitionService) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) Data(com.hazelcast.internal.serialization.Data)

Example 8 with IPartitionService

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

the class MapServiceContextImpl method getOrInitCachedMemberPartitions.

@Override
public PartitionIdSet getOrInitCachedMemberPartitions() {
    PartitionIdSet ownedPartitionIdSet = ownedPartitions;
    if (ownedPartitionIdSet != null) {
        return ownedPartitionIdSet;
    }
    synchronized (this) {
        ownedPartitionIdSet = ownedPartitions;
        if (ownedPartitionIdSet != null) {
            return ownedPartitionIdSet;
        }
        IPartitionService partitionService = nodeEngine.getPartitionService();
        Collection<Integer> partitions = partitionService.getMemberPartitions(nodeEngine.getThisAddress());
        ownedPartitionIdSet = immutablePartitionIdSet(partitionService.getPartitionCount(), partitions);
        ownedPartitions = ownedPartitionIdSet;
    }
    return ownedPartitionIdSet;
}
Also used : IPartitionService(com.hazelcast.internal.partition.IPartitionService) PartitionIdSet(com.hazelcast.internal.util.collection.PartitionIdSet) SetUtil.immutablePartitionIdSet(com.hazelcast.internal.util.SetUtil.immutablePartitionIdSet)

Example 9 with IPartitionService

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

the class PutAllOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    ReplicatedRecordStore store = service.getReplicatedRecordStore(name, true, getPartitionId());
    int partitionId = getPartitionId();
    IPartitionService partitionService = getNodeEngine().getPartitionService();
    ReplicatedMapEventPublishingService eventPublishingService = service.getEventPublishingService();
    for (int i = 0; i < entries.size(); i++) {
        Data key = entries.getKey(i);
        Data value = entries.getValue(i);
        if (partitionId != partitionService.getPartitionId(key)) {
            continue;
        }
        Object putResult = store.put(key, value);
        Data oldValue = getNodeEngine().toData(putResult);
        eventPublishingService.fireEntryListenerEvent(key, oldValue, value, name, getCallerAddress());
        VersionResponsePair response = new VersionResponsePair(putResult, store.getVersion());
        publishReplicationMessage(key, value, response);
    }
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) IPartitionService(com.hazelcast.internal.partition.IPartitionService) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) Data(com.hazelcast.internal.serialization.Data) ReplicatedMapEventPublishingService(com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService)

Example 10 with IPartitionService

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

the class XAResourceImpl method finalizeTransactionRemotely.

private void finalizeTransactionRemotely(Xid xid, boolean isCommit) throws XAException {
    NodeEngine nodeEngine = getNodeEngine();
    IPartitionService partitionService = nodeEngine.getPartitionService();
    OperationService operationService = nodeEngine.getOperationService();
    SerializableXID serializableXID = new SerializableXID(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier());
    Data xidData = nodeEngine.toData(serializableXID);
    int partitionId = partitionService.getPartitionId(xidData);
    FinalizeRemoteTransactionOperation operation = new FinalizeRemoteTransactionOperation(xidData, isCommit);
    InternalCompletableFuture<Integer> future = operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
    Integer errorCode;
    try {
        errorCode = future.get();
    } catch (Exception e) {
        throw ExceptionUtil.rethrow(e);
    }
    if (errorCode != null) {
        throw new XAException(errorCode);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) XAException(javax.transaction.xa.XAException) IPartitionService(com.hazelcast.internal.partition.IPartitionService) Data(com.hazelcast.internal.serialization.Data) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) FinalizeRemoteTransactionOperation(com.hazelcast.transaction.impl.xa.operations.FinalizeRemoteTransactionOperation) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) MemberLeftException(com.hazelcast.core.MemberLeftException) TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) ExecutionException(java.util.concurrent.ExecutionException) XAException(javax.transaction.xa.XAException)

Aggregations

IPartitionService (com.hazelcast.internal.partition.IPartitionService)36 Data (com.hazelcast.internal.serialization.Data)10 NodeEngine (com.hazelcast.spi.impl.NodeEngine)10 Address (com.hazelcast.cluster.Address)8 List (java.util.List)7 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)6 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)6 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)5 IPartition (com.hazelcast.internal.partition.IPartition)4 PartitionIdSet (com.hazelcast.internal.util.collection.PartitionIdSet)4 MapService (com.hazelcast.map.impl.MapService)4 ClusterService (com.hazelcast.internal.cluster.ClusterService)3 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)3 ICacheService (com.hazelcast.cache.impl.ICacheService)2 Connection (com.hazelcast.internal.nio.Connection)2 JobConfig (com.hazelcast.jet.config.JobConfig)2 ProcessorSupplier (com.hazelcast.jet.core.ProcessorSupplier)2 JetServiceBackend (com.hazelcast.jet.impl.JetServiceBackend)2