use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.
the class MultiMapService method prepareReplicationOperation.
@Override
public Operation prepareReplicationOperation(PartitionReplicationEvent event, Collection<ServiceNamespace> namespaces) {
if (namespaces.isEmpty()) {
return null;
}
MultiMapPartitionContainer partitionContainer = partitionContainers[event.getPartitionId()];
int replicaIndex = event.getReplicaIndex();
Map<String, Map<Data, MultiMapValue>> map = createHashMap(namespaces.size());
for (ServiceNamespace namespace : namespaces) {
assert isKnownServiceNamespace(namespace) : namespace + " is not a MultiMapService namespace!";
ObjectNamespace ns = (ObjectNamespace) namespace;
MultiMapContainer container = partitionContainer.containerMap.get(ns.getObjectName());
if (container == null) {
continue;
}
if (container.getConfig().getTotalBackupCount() < replicaIndex) {
continue;
}
map.put(ns.getObjectName(), container.getMultiMapValues());
}
return map.isEmpty() ? null : new MultiMapReplicationOperation(map).setServiceName(MultiMapService.SERVICE_NAME).setNodeEngine(nodeEngine);
}
use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.
the class AbstractRingBufferOperation method getRingBufferContainer.
/**
* Returns an {@link RingbufferContainer} or creates a new one if necessary by calling
* {@link RingbufferService#getOrCreateContainer(int, ObjectNamespace, RingbufferConfig)}.
* Also calls the {@link RingbufferContainer#cleanup()} before returning
* the container. This will currently remove any expired items.
*
* @return the ringbuffer container
*/
RingbufferContainer getRingBufferContainer() {
final RingbufferService service = getService();
final ObjectNamespace ns = RingbufferService.getRingbufferNamespace(name);
RingbufferContainer ringbuffer = service.getContainerOrNull(getPartitionId(), ns);
if (ringbuffer == null) {
ringbuffer = service.getOrCreateContainer(getPartitionId(), ns, service.getRingbufferConfig(name));
}
ringbuffer.cleanup();
return ringbuffer;
}
use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.
the class ReplicationOperation method writeInternal.
@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
out.writeInt(migrationData.size());
for (Entry<ObjectNamespace, RingbufferContainer> entry : migrationData.entrySet()) {
final ObjectNamespace ns = entry.getKey();
out.writeObject(ns);
RingbufferContainer container = entry.getValue();
container.writeData(out);
}
}
Aggregations