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);
}
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());
}
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());
}
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());
}
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);
}
}
Aggregations