Search in sources :

Example 26 with ObjectNamespace

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);
}
Also used : ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) MultiMapReplicationOperation(com.hazelcast.multimap.impl.operations.MultiMapReplicationOperation) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) MapUtil.createConcurrentHashMap(com.hazelcast.internal.util.MapUtil.createConcurrentHashMap) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace) MigrationEndpoint(com.hazelcast.internal.partition.MigrationEndpoint)

Example 27 with ObjectNamespace

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;
}
Also used : RingbufferContainer(com.hazelcast.ringbuffer.impl.RingbufferContainer) RingbufferService(com.hazelcast.ringbuffer.impl.RingbufferService) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace)

Example 28 with ObjectNamespace

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);
    }
}
Also used : RingbufferContainer(com.hazelcast.ringbuffer.impl.RingbufferContainer) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace)

Aggregations

ObjectNamespace (com.hazelcast.internal.services.ObjectNamespace)28 RingbufferContainer (com.hazelcast.ringbuffer.impl.RingbufferContainer)12 RingbufferService (com.hazelcast.ringbuffer.impl.RingbufferService)10 ServiceNamespace (com.hazelcast.internal.services.ServiceNamespace)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 DistributedObjectNamespace (com.hazelcast.internal.services.DistributedObjectNamespace)7 Test (org.junit.Test)7 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Config (com.hazelcast.config.Config)4 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)3 Ringbuffer (com.hazelcast.ringbuffer.Ringbuffer)3 Map (java.util.Map)3 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 ListenerConfig (com.hazelcast.config.ListenerConfig)2 MapConfig (com.hazelcast.config.MapConfig)2 ReliableTopicConfig (com.hazelcast.config.ReliableTopicConfig)2 RingbufferConfig (com.hazelcast.config.RingbufferConfig)2 LockSupportService (com.hazelcast.internal.locksupport.LockSupportService)2 MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)2