use of com.hazelcast.internal.services.ServiceNamespace in project hazelcast by hazelcast.
the class RingbufferService method prepareReplicationOperation.
@Override
public Operation prepareReplicationOperation(PartitionReplicationEvent event, Collection<ServiceNamespace> namespaces) {
int partitionId = event.getPartitionId();
Map<ObjectNamespace, RingbufferContainer> partitionContainers = containers.get(partitionId);
if (isNullOrEmpty(partitionContainers)) {
return null;
}
Map<ObjectNamespace, RingbufferContainer> migrationData = new HashMap<>();
for (ServiceNamespace namespace : namespaces) {
ObjectNamespace ns = (ObjectNamespace) namespace;
RingbufferContainer container = partitionContainers.get(ns);
if (container != null && container.getConfig().getTotalBackupCount() >= event.getReplicaIndex()) {
migrationData.put(ns, container);
}
}
if (migrationData.isEmpty()) {
return null;
}
return new ReplicationOperation(migrationData, event.getPartitionId(), event.getReplicaIndex());
}
use of com.hazelcast.internal.services.ServiceNamespace in project hazelcast by hazelcast.
the class ReplicaFragmentMigrationState method writeData.
@Override
public void writeData(ObjectDataOutput out) throws IOException {
out.writeInt(namespaces.size());
for (Map.Entry<ServiceNamespace, long[]> e : namespaces.entrySet()) {
out.writeObject(e.getKey());
out.writeLongArray(e.getValue());
}
out.writeInt(migrationOperations.size());
for (Operation operation : migrationOperations) {
out.writeObject(operation);
}
chunkSerDeHelper.writeChunkedOperations(out);
}
use of com.hazelcast.internal.services.ServiceNamespace in project hazelcast by hazelcast.
the class AbstractPartitionPrimaryReplicaAntiEntropyTask method retainAndGetNamespaces.
// works only on primary. backups are retained
// in PartitionBackupReplicaAntiEntropyTask
final Collection<ServiceNamespace> retainAndGetNamespaces() {
PartitionReplicationEvent event = new PartitionReplicationEvent(null, partitionId, 0);
Collection<FragmentedMigrationAwareService> services = nodeEngine.getServices(FragmentedMigrationAwareService.class);
Collection<ServiceNamespace> namespaces = new HashSet<>();
for (FragmentedMigrationAwareService service : services) {
Collection<ServiceNamespace> serviceNamespaces = service.getAllServiceNamespaces(event);
if (serviceNamespaces != null) {
namespaces.addAll(serviceNamespaces);
}
}
namespaces.add(NonFragmentedServiceNamespace.INSTANCE);
PartitionReplicaManager replicaManager = partitionService.getReplicaManager();
replicaManager.retainNamespaces(partitionId, namespaces);
ILogger logger = nodeEngine.getLogger(getClass());
if (logger.isFinestEnabled()) {
logger.finest("Retained namespaces for partitionId=" + partitionId + ". Service namespaces=" + namespaces + ", retained namespaces=" + replicaManager.getNamespaces(partitionId));
}
return replicaManager.getNamespaces(partitionId);
}
use of com.hazelcast.internal.services.ServiceNamespace in project hazelcast by hazelcast.
the class WriteBehindStateHolder method prepare.
void prepare(PartitionContainer container, Collection<ServiceNamespace> namespaces, int replicaIndex) {
int size = namespaces.size();
flushSequences = createHashMap(size);
delayedEntries = createHashMap(size);
reservationsByTxnIdPerMap = createHashMap(size);
for (ServiceNamespace namespace : namespaces) {
ObjectNamespace mapNamespace = (ObjectNamespace) namespace;
String mapName = mapNamespace.getObjectName();
RecordStore recordStore = container.getRecordStore(mapName);
if (recordStore == null) {
continue;
}
MapContainer mapContainer = recordStore.getMapContainer();
MapConfig mapConfig = mapContainer.getMapConfig();
if (mapConfig.getTotalBackupCount() < replicaIndex || !mapContainer.getMapStoreContext().isWriteBehindMapStoreEnabled()) {
continue;
}
WriteBehindStore mapDataStore = (WriteBehindStore) recordStore.getMapDataStore();
reservationsByTxnIdPerMap.put(mapName, mapDataStore.getTxnReservedCapacityCounter().getReservedCapacityCountPerTxnId());
WriteBehindQueue<DelayedEntry> writeBehindQueue = mapDataStore.getWriteBehindQueue();
List<DelayedEntry> entries = writeBehindQueue.asList();
if (entries == null || entries.isEmpty()) {
continue;
}
delayedEntries.put(mapName, entries);
flushSequences.put(mapName, new ArrayDeque<>(mapDataStore.getFlushSequences()));
}
}
use of com.hazelcast.internal.services.ServiceNamespace in project hazelcast by hazelcast.
the class OperationBackupHandler method sendBackups0.
int sendBackups0(BackupAwareOperation backupAwareOp) {
int requestedSyncBackups = requestedSyncBackups(backupAwareOp);
int requestedAsyncBackups = requestedAsyncBackups(backupAwareOp);
int requestedTotalBackups = requestedTotalBackups(backupAwareOp);
if (requestedTotalBackups == 0) {
return 0;
}
Operation op = (Operation) backupAwareOp;
PartitionReplicaVersionManager versionManager = node.getPartitionService().getPartitionReplicaVersionManager();
ServiceNamespace namespace = versionManager.getServiceNamespace(op);
long[] replicaVersions = versionManager.incrementPartitionReplicaVersions(op.getPartitionId(), namespace, requestedTotalBackups);
boolean syncForced = backpressureRegulator.isSyncForced(backupAwareOp);
int syncBackups = syncBackups(requestedSyncBackups, requestedAsyncBackups, syncForced);
int asyncBackups = asyncBackups(requestedSyncBackups, requestedAsyncBackups, syncForced);
// TODO: This could cause a problem with back pressure
if (!op.returnsResponse()) {
asyncBackups += syncBackups;
syncBackups = 0;
}
if (syncBackups + asyncBackups == 0) {
return 0;
}
return makeBackups(backupAwareOp, op.getPartitionId(), replicaVersions, syncBackups, asyncBackups);
}
Aggregations