Search in sources :

Example 21 with ObjectNamespace

use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.

the class ObservableRingbufferContainerLeakTest method testLeakingRingbufferContainerWhenUsingObservableIterator.

/**
 * Regression test for #19580
 */
@Test
@Repeat(100)
public void testLeakingRingbufferContainerWhenUsingObservableIterator() {
    Config config = smallInstanceConfig();
    config.setProperty("hazelcast.partition.count", "1");
    config.getJetConfig().setEnabled(true);
    HazelcastInstance hz = createHazelcastInstance(config);
    JetService jet = hz.getJet();
    Ringbuffer<Object> ringbuffer = hz.getRingbuffer("__jet.observables.my-observable");
    Observable<Object> obs = jet.getObservable("my-observable");
    ringbuffer.add(42);
    ringbuffer.addAsync(DoneItem.DONE_ITEM, OverflowPolicy.OVERWRITE);
    Iterator<Object> it = obs.iterator();
    it.hasNext();
    it.next();
    it.hasNext();
    obs.destroy();
    RingbufferService ringbufferService = Accessors.getService(hz, RingbufferService.SERVICE_NAME);
    Map<ObjectNamespace, RingbufferContainer> containers = ringbufferService.getContainers().values().iterator().next();
    assertThat(containers).hasSize(0);
}
Also used : RingbufferContainer(com.hazelcast.ringbuffer.impl.RingbufferContainer) HazelcastInstance(com.hazelcast.core.HazelcastInstance) JetService(com.hazelcast.jet.JetService) Config(com.hazelcast.config.Config) RingbufferService(com.hazelcast.ringbuffer.impl.RingbufferService) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test) Repeat(com.hazelcast.test.annotation.Repeat)

Example 22 with ObjectNamespace

use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.

the class AbstractEventJournalBasicTest method assertEventJournalSize.

/**
 * Asserts that the number of event journal entries for the partition
 * {@code partitionId} is equal to the given {@code size}.
 *
 * @param partitionId the partition ID for the event journal entries
 * @param adapter     the adapter for a specific data structure
 * @param size        the expected count for the partition event journal events
 */
private void assertEventJournalSize(int partitionId, EventJournalDataStructureAdapter<?, ?, EJ_TYPE> adapter, int size) {
    final ObjectNamespace namespace = adapter.getNamespace();
    HazelcastInstance partitionOwner = null;
    for (HazelcastInstance instance : instances) {
        if (getNode(instance).partitionService.getPartition(partitionId).isLocal()) {
            partitionOwner = instance;
            break;
        }
    }
    final Node node = getNode(partitionOwner);
    final NodeEngineImpl nodeEngine = node.nodeEngine;
    final RingbufferService rbService = nodeEngine.getService(RingbufferService.SERVICE_NAME);
    final ConcurrentMap<Integer, Map<ObjectNamespace, RingbufferContainer>> containers = rbService.getContainers();
    final Map<ObjectNamespace, RingbufferContainer> partitionContainers = containers.get(partitionId);
    if (size == 0 && partitionContainers == null) {
        return;
    }
    assertNotNull(partitionContainers);
    final RingbufferContainer container = partitionContainers.get(namespace);
    if (size == 0 && container == null) {
        return;
    }
    assertNotNull(container);
    assertEquals(size, container.size());
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) RingbufferContainer(com.hazelcast.ringbuffer.impl.RingbufferContainer) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Accessors.getNode(com.hazelcast.test.Accessors.getNode) Node(com.hazelcast.instance.impl.Node) RingbufferService(com.hazelcast.ringbuffer.impl.RingbufferService) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace) HashMap(java.util.HashMap) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map)

Example 23 with ObjectNamespace

use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.

the class ReliableTopicCreateTest method testWildcardConfig.

@Test
public void testWildcardConfig() {
    Config config = new Config();
    config.addRingBufferConfig(new RingbufferConfig("foo*").setCapacity(10));
    config.addReliableTopicConfig(new ReliableTopicConfig("foo*").setTopicOverloadPolicy(DISCARD_NEWEST));
    HazelcastInstance hz = createHazelcastInstance(config);
    RingbufferService ringbufferService = getNodeEngineImpl(hz).getService(RingbufferService.SERVICE_NAME);
    ReliableTopicProxy<String> topic = (ReliableTopicProxy<String>) hz.<String>getReliableTopic("foo");
    Ringbuffer ringbuffer = topic.ringbuffer;
    topic.publish("foo");
    ReliableTopicProxy proxy = assertInstanceOf(ReliableTopicProxy.class, topic);
    assertEquals(proxy.overloadPolicy, TopicOverloadPolicy.DISCARD_NEWEST);
    final ConcurrentMap<Integer, Map<ObjectNamespace, RingbufferContainer>> containers = ringbufferService.getContainers();
    assertEquals(1, containers.size());
    final Map<ObjectNamespace, RingbufferContainer> partitionContainers = containers.get(ringbufferService.getRingbufferPartitionId(ringbuffer.getName()));
    final ObjectNamespace ns = RingbufferService.getRingbufferNamespace(ringbuffer.getName());
    assertTrue(partitionContainers.containsKey(ns));
    assertEquals(0, ringbuffer.headSequence());
    assertEquals(0, ringbuffer.tailSequence());
    assertEquals(10, ringbuffer.capacity());
}
Also used : RingbufferContainer(com.hazelcast.ringbuffer.impl.RingbufferContainer) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) ListenerConfig(com.hazelcast.config.ListenerConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Config(com.hazelcast.config.Config) Ringbuffer(com.hazelcast.ringbuffer.Ringbuffer) HazelcastInstance(com.hazelcast.core.HazelcastInstance) RingbufferConfig(com.hazelcast.config.RingbufferConfig) RingbufferService(com.hazelcast.ringbuffer.impl.RingbufferService) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 24 with ObjectNamespace

use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.

the class DistributedObjectNamespaceConstructorTest method testConstructor.

@Test
public void testConstructor() {
    ObjectNamespace objectNamespace = getRingbufferNamespace("myRingbuffer");
    DistributedObjectNamespaceConstructor constructor = new DistributedObjectNamespaceConstructor(DistributedObjectNamespace.class);
    ObjectNamespace clonedObjectNamespace = (ObjectNamespace) constructor.createNew(objectNamespace);
    assertEquals(objectNamespace.getServiceName(), clonedObjectNamespace.getServiceName());
    assertEquals(objectNamespace.getObjectName(), clonedObjectNamespace.getObjectName());
}
Also used : DistributedObjectNamespaceConstructor(com.hazelcast.test.starter.constructor.DistributedObjectNamespaceConstructor) ObjectNamespace(com.hazelcast.internal.services.ObjectNamespace) DistributedObjectNamespace(com.hazelcast.internal.services.DistributedObjectNamespace) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 25 with ObjectNamespace

use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.

the class DefaultRecordStore method clearLockStore.

private void clearLockStore() {
    NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    LockSupportService lockService = nodeEngine.getServiceOrNull(LockSupportService.SERVICE_NAME);
    if (lockService != null) {
        ObjectNamespace namespace = MapService.getObjectNamespace(name);
        lockService.clearLockStore(partitionId, namespace);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) LockSupportService(com.hazelcast.internal.locksupport.LockSupportService) 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