use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class CacheClearOperation method afterRun.
@Override
public void afterRun() throws Exception {
super.afterRun();
IPartitionService partitionService = getNodeEngine().getPartitionService();
if (partitionService.getPartitionId(name) == getPartitionId()) {
CacheService cacheService = getService();
cacheService.sendInvalidationEvent(name, null, SOURCE_NOT_AVAILABLE);
}
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class AddPartitionLostListenerMessageTask method call.
@Override
protected Object call() throws Exception {
final IPartitionService partitionService = getService(getServiceName());
final PartitionLostListener listener = new PartitionLostListener() {
@Override
public void partitionLost(PartitionLostEvent event) {
if (endpoint.isAlive()) {
ClientMessage eventMessage = ClientAddPartitionLostListenerCodec.encodePartitionLostEvent(event.getPartitionId(), event.getLostBackupCount(), event.getEventSource());
sendClientMessage(null, eventMessage);
}
}
};
String registrationId;
if (parameters.localOnly) {
registrationId = partitionService.addLocalPartitionLostListener(listener);
} else {
registrationId = partitionService.addPartitionLostListener(listener);
}
endpoint.addListenerDestroyAction(getServiceName(), PARTITION_LOST_EVENT_TOPIC, registrationId);
return registrationId;
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class ScheduledExecutorGetAllScheduledMessageTask method accumulateTaskHandlersAsUrnValues.
@SuppressWarnings("unchecked")
private void accumulateTaskHandlersAsUrnValues(Map<Member, List<ScheduledTaskHandler>> accumulator, Map<?, ?> taskHandlersMap) {
ClusterService clusterService = nodeEngine.getClusterService();
IPartitionService partitionService = nodeEngine.getPartitionService();
for (Map.Entry<?, ?> entry : taskHandlersMap.entrySet()) {
Member owner;
Object key = entry.getKey();
if (key instanceof Number) {
owner = clusterService.getMember(partitionService.getPartitionOwner((Integer) key));
} else {
owner = (Member) key;
}
List<ScheduledTaskHandler> handlers = (List<ScheduledTaskHandler>) entry.getValue();
if (accumulator.containsKey(owner)) {
List<ScheduledTaskHandler> memberUrns = accumulator.get(owner);
memberUrns.addAll(handlers);
} else {
accumulator.put(owner, handlers);
}
}
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class CollectionService method rollbackTransaction.
@Override
public void rollbackTransaction(String transactionId) {
final Set<String> collectionNames = getContainerMap().keySet();
IPartitionService partitionService = nodeEngine.getPartitionService();
OperationService operationService = nodeEngine.getOperationService();
for (String name : collectionNames) {
int partitionId = partitionService.getPartitionId(StringPartitioningStrategy.getPartitionKey(name));
Operation operation = new CollectionTransactionRollbackOperation(name, transactionId).setPartitionId(partitionId).setService(this).setNodeEngine(nodeEngine);
operationService.execute(operation);
}
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class CollectionService method getMigrationData.
protected Map<String, CollectionContainer> getMigrationData(PartitionReplicationEvent event) {
Map<String, CollectionContainer> migrationData = new HashMap<String, CollectionContainer>();
IPartitionService partitionService = nodeEngine.getPartitionService();
for (Map.Entry<String, ? extends CollectionContainer> entry : getContainerMap().entrySet()) {
String name = entry.getKey();
int partitionId = partitionService.getPartitionId(StringPartitioningStrategy.getPartitionKey(name));
CollectionContainer container = entry.getValue();
if (partitionId == event.getPartitionId() && container.getConfig().getTotalBackupCount() >= event.getReplicaIndex()) {
migrationData.put(name, container);
}
}
return migrationData;
}
Aggregations