use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class PlanCacheChecker method check.
public void check() {
if (planCache.size() == 0) {
return;
}
// Collect object IDs
SqlCatalog catalog = new SqlCatalog(tableResolvers);
Set<PlanObjectKey> objectKeys = new HashSet<>();
for (Map<String, Table> tableMap : catalog.getSchemas().values()) {
for (Table table : tableMap.values()) {
PlanObjectKey objectKey = table.getObjectKey();
if (objectKey != null) {
objectKeys.add(objectKey);
}
}
}
// Prepare partition distribution
Map<UUID, PartitionIdSet> partitions = QueryUtils.createPartitionMap(nodeEngine, null, false);
// Do check
planCache.check(new PlanCheckContext(objectKeys, partitions));
}
use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class MapIndexScanP method splitOnMigration.
/**
* Perform splitting of a {@link Split} after receiving {@link MissingPartitionException}
* or various cluster state exceptions like {@link MemberLeftException}.
* <p>
* Method gets current partition table and proceeds with following procedure:
* <p>
* It splits the partitions assigned to the split according to the new
* partition owner into disjoint sets, one for each owner.
*
* @param split the split to split
* @return collection of new split units
*/
private List<Split> splitOnMigration(Split split) {
IndexIterationPointer[] lastPointers = split.pointers;
InternalPartitionService partitionService = getNodeEngine(hazelcastInstance).getPartitionService();
Map<Address, Split> newSplits = new HashMap<>();
PrimitiveIterator.OfInt partitionIterator = split.partitions.intIterator();
while (partitionIterator.hasNext()) {
int partitionId = partitionIterator.nextInt();
// If at least one partition owner is not assigned -- assign current member.
// Later, a WrongTargetException will be thrown
// and it causes this method to be called again.
// Occasionally prediction with current member would be correct.
Address potentialOwner = partitionService.getPartition(partitionId).getOwnerOrNull();
Address owner = potentialOwner == null ? split.owner : partitionService.getPartition(partitionId).getOwnerOrNull();
newSplits.computeIfAbsent(owner, x -> new Split(new PartitionIdSet(partitionService.getPartitionCount()), owner, lastPointers)).partitions.add(partitionId);
}
return new ArrayList<>(newSplits.values());
}
use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class MapExecuteOnKeysMessageTask method getPartitions.
@Override
public PartitionIdSet getPartitions() {
IPartitionService partitionService = nodeEngine.getPartitionService();
int partitions = partitionService.getPartitionCount();
PartitionIdSet partitionIds = new PartitionIdSet(partitions);
Iterator<Data> iterator = parameters.keys.iterator();
int addedPartitions = 0;
while (iterator.hasNext() && addedPartitions < partitions) {
Data key = iterator.next();
if (partitionIds.add(partitionService.getPartitionId(key))) {
addedPartitions++;
}
}
return partitionIds;
}
use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class AbstractMapQueryMessageTask method createInvocationsForMissingPartitions.
private void createInvocationsForMissingPartitions(PartitionIdSet missingPartitionsList, List<Future> futures, Predicate predicate) {
final OperationServiceImpl operationService = nodeEngine.getOperationService();
MapService mapService = nodeEngine.getService(getServiceName());
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
Query query = buildQuery(predicate);
PrimitiveIterator.OfInt missingPartitionIterator = missingPartitionsList.intIterator();
missingPartitionIterator.forEachRemaining((IntConsumer) partitionId -> {
MapOperation queryPartitionOperation = createQueryPartitionOperation(query, mapServiceContext);
queryPartitionOperation.setPartitionId(partitionId);
try {
Future future = operationService.invokeOnPartition(SERVICE_NAME, queryPartitionOperation, partitionId);
futures.add(future);
} catch (Throwable t) {
throw rethrow(t);
}
});
}
use of com.hazelcast.internal.util.collection.PartitionIdSet in project hazelcast by hazelcast.
the class SetUtil method singletonPartitionIdSet.
public static PartitionIdSet singletonPartitionIdSet(int partitionCount, int partitionId) {
PartitionIdSet set = new PartitionIdSet(partitionCount);
set.add(partitionId);
return set;
}
Aggregations