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();
}
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);
}
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;
}
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);
}
}
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);
}
}
Aggregations