use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.
the class AbstractRingBufferOperation method getRingbufferWaitNotifyKey.
/**
* Returns {@link WaitNotifyKey} of the ringbuffer.
*
* If the RingbufferContainer exists it reuses it's {@link RingbufferContainer#getRingEmptyWaitNotifyKey()}.
* If the RingbufferContainer doesn't exist it creates new RingbufferWaitNotifyKey and doesn't recreate
* the ringbuffer container.
*
* @return WaitNotifyKey of the ringbuffer
*/
WaitNotifyKey getRingbufferWaitNotifyKey() {
final RingbufferService service = getService();
final ObjectNamespace ns = RingbufferService.getRingbufferNamespace(name);
RingbufferContainer ringbuffer = service.getContainerOrNull(getPartitionId(), ns);
if (ringbuffer != null) {
return ringbuffer.getRingEmptyWaitNotifyKey();
} else {
return new RingbufferWaitNotifyKey(ns, getPartitionId());
}
}
use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.
the class ProxyManager method destroyProxyLocally.
/**
* Locally destroys the proxy identified by the given service and object ID.
* <p>
* Upon successful completion the proxy is unregistered in this proxy
* manager and all local resources associated with the proxy are released.
*
* @param service the service associated with the proxy.
* @param id the ID of the object to destroy the proxy of.
*/
public void destroyProxyLocally(String service, String id) {
ObjectNamespace objectNamespace = new DistributedObjectNamespace(service, id);
ClientProxyFuture clientProxyFuture = proxies.remove(objectNamespace);
if (clientProxyFuture != null) {
ClientProxy clientProxy = clientProxyFuture.get();
clientProxy.destroyLocally();
}
}
use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.
the class Invocation_BlockingTest method sync_whenOperationTimeout.
// ====================================================================
//
// ====================================================================
@Test
public void sync_whenOperationTimeout() {
int callTimeout = 5000;
Config config = new Config().setProperty(OPERATION_CALL_TIMEOUT_MILLIS.getName(), "" + callTimeout);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance local = factory.newHazelcastInstance(config);
HazelcastInstance remote = factory.newHazelcastInstance(config);
warmUpPartitions(factory.getAllHazelcastInstances());
NodeEngineImpl nodeEngine = getNodeEngineImpl(local);
String key = generateKeyOwnedBy(remote);
ObjectNamespace namespace = new DistributedObjectNamespace(SERVICE_NAME, key);
int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
// first we lock the lock by another thread
OperationServiceImpl opService = nodeEngine.getOperationService();
int otherThreadId = 2;
opService.invokeOnPartition(new LockOperation(namespace, nodeEngine.toData(key), otherThreadId, -1, -1).setPartitionId(partitionId)).join();
// then we execute a lock operation that won't be executed because lock is already acquired
// we are going to do some waiting (3x call timeout)
int threadId = 1;
Operation op = new LockOperation(namespace, nodeEngine.toData(key), threadId, -1, 3 * callTimeout).setPartitionId(partitionId);
final InternalCompletableFuture<Object> future = opService.invokeOnPartition(op);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertTrue(future.isDone());
}
});
assertEquals(Boolean.FALSE, future.join());
}
use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.
the class ReliableTopicCreateTest method testConstruction.
@Test
public void testConstruction() {
HazelcastInstance hz = createHazelcastInstance();
RingbufferService ringbufferService = getNodeEngineImpl(hz).getService(RingbufferService.SERVICE_NAME);
ReliableTopicProxy<String> topic = (ReliableTopicProxy<String>) hz.<String>getReliableTopic("foo");
final String name = RingbufferService.TOPIC_RB_PREFIX + "foo";
Ringbuffer ringbuffer = hz.getRingbuffer(name);
assertSame(ringbuffer, topic.ringbuffer);
// make sure the ringbuffer and topic are hooked up correctly
topic.publish("item1");
topic.publish("item2");
assertEquals(0, ringbuffer.headSequence());
assertEquals(1, ringbuffer.tailSequence());
final Map<ObjectNamespace, RingbufferContainer> containers = ringbufferService.getContainers().get(ringbufferService.getRingbufferPartitionId(name));
final ObjectNamespace ns = RingbufferService.getRingbufferNamespace(ringbuffer.getName());
assertEquals(1, containers.size());
assertTrue(containers.containsKey(ns));
}
use of com.hazelcast.internal.services.ObjectNamespace in project hazelcast by hazelcast.
the class ReliableTopicCreateTest method testRingbufferConfiguration.
@Test
public void testRingbufferConfiguration() {
Config config = new Config();
RingbufferConfig rbConfig = new RingbufferConfig("foo").setCapacity(21);
config.addRingBufferConfig(rbConfig);
HazelcastInstance hz = createHazelcastInstance(config);
RingbufferService ringbufferService = getNodeEngineImpl(hz).getService(RingbufferService.SERVICE_NAME);
ReliableTopicProxy topic = (ReliableTopicProxy) hz.getReliableTopic("foo");
Ringbuffer ringbuffer = hz.getRingbuffer(RingbufferService.TOPIC_RB_PREFIX + "foo");
assertSame(ringbuffer, topic.ringbuffer);
assertEquals(21, ringbuffer.capacity());
// triggers the creation
ringbuffer.size();
final Map<ObjectNamespace, RingbufferContainer> containers = ringbufferService.getContainers().get(ringbufferService.getRingbufferPartitionId(ringbuffer.getName()));
final ObjectNamespace ns = RingbufferService.getRingbufferNamespace(ringbuffer.getName());
assertEquals(1, containers.size());
assertTrue(containers.containsKey(ns));
RingbufferContainer container = containers.get(ns);
assertEquals(rbConfig.getCapacity(), container.getConfig().getCapacity());
}
Aggregations