@Override public <T extends DistributedObject> T getDistributedObject(String serviceName, String name) { return delegatedInstance.getDistributedObject(serviceName, name); }
@Override @SuppressWarnings("deprecation") public <T extends DistributedObject> T getDistributedObject(String serviceName, Object id) { return delegate.getDistributedObject(serviceName, id); }
@Override public <T extends DistributedObject> T getDistributedObject(String serviceName, String name) { return delegatedInstance.getDistributedObject(serviceName, name); }
@Setup public void setUp() { map = targetInstance.getDistributedObject(SyntheticMapService.SERVICE_NAME, "map-" + name); }
@Setup public void setUp() { map = targetInstance.getDistributedObject(SyntheticMapService.SERVICE_NAME, "map-" + name); }
@Override public <T extends DistributedObject> T getDistributedObject(String serviceName, String name) { return getHazelcastInstance().getDistributedObject(serviceName, name); }
@Setup public void setUp() { map = targetInstance.getDistributedObject(SyntheticMapService.SERVICE_NAME, "map-" + name); }
@Setup public void setUp() { map = targetInstance.getDistributedObject(SyntheticMapService.SERVICE_NAME, "map-" + name); }
@Setup public void setUp() { map = targetInstance.getDistributedObject(SyntheticMapService.SERVICE_NAME, "map-" + name); }
public static void main(String[] args) throws Exception { HazelcastInstance[] instances = new HazelcastInstance[2]; for (int i = 0; i < instances.length; i++) { HazelcastInstance instance = Hazelcast.newHazelcastInstance(); instances[i] = instance; } Counter counter = instances[0].getDistributedObject(CounterService.NAME, "counter"); counter.inc(1); System.out.println("Finished"); Hazelcast.shutdownAll(); } }
public static void main(String[] args) throws Exception { final HazelcastInstance[] instances = new HazelcastInstance[2]; for (int i = 0; i < instances.length; i++) { HazelcastInstance instance = Hazelcast.newHazelcastInstance(); instances[i] = instance; } System.out.println("Increase the Counter"); Counter counter = instances[0].getDistributedObject(CounterService.NAME, "myCounter"); counter.inc(10); counter = instances[1].getDistributedObject(CounterService.NAME, "myCounter"); counter.await(10); System.out.println("Finished"); Hazelcast.shutdownAll(); } }
public static void main(String[] args) { HazelcastInstance[] instances = new HazelcastInstance[2]; for (int i = 0; i < instances.length; i++) { instances[i] = Hazelcast.newHazelcastInstance(); } Counter[] counters = new Counter[4]; for (int i = 0; i < counters.length; i++) { counters[i] = instances[0].getDistributedObject(CounterService.NAME, i + "counter"); } for (Counter counter : counters) { System.out.println(counter.inc(1)); } System.out.println("Finished"); Hazelcast.shutdownAll(); } }
public <K, V> ICache<K, V> getCacheByFullName(String fullName) { checkNotNull(fullName, "Retrieving a cache instance with a null name is not allowed!"); try { return instance.getDistributedObject(ICacheService.SERVICE_NAME, fullName); } catch (ClientServiceNotFoundException e) { // Cache support is not available at client side throw new IllegalStateException("At client, " + ICacheService.CACHE_SUPPORT_NOT_AVAILABLE_ERROR_MESSAGE); } catch (HazelcastException e) { if (e.getCause() instanceof ServiceNotFoundException) { // Cache support is not available at server side throw new IllegalStateException("At server, " + ICacheService.CACHE_SUPPORT_NOT_AVAILABLE_ERROR_MESSAGE); } else { throw e; } } } }
public <K, V> ICache<K, V> getCacheByFullName(String fullName) { checkNotNull(fullName, "Retrieving a cache instance with a null name is not allowed!"); try { return instance.getDistributedObject(ICacheService.SERVICE_NAME, fullName); } catch (ClientServiceNotFoundException e) { // Cache support is not available at client side throw new IllegalStateException("At client, " + ICacheService.CACHE_SUPPORT_NOT_AVAILABLE_ERROR_MESSAGE); } catch (HazelcastException e) { if (e.getCause() instanceof ServiceNotFoundException) { // Cache support is not available at server side throw new IllegalStateException("At server, " + ICacheService.CACHE_SUPPORT_NOT_AVAILABLE_ERROR_MESSAGE); } else { throw e; } } } }
public static void main(String[] args) { HazelcastInstance[] instances = new HazelcastInstance[2]; for (int i = 0; i < instances.length; i++) { instances[i] = Hazelcast.newHazelcastInstance(); } Counter[] counters = new Counter[4]; for (int i = 0; i < counters.length; i++) { counters[i] = instances[0].getDistributedObject(CounterService.NAME, i + "counter"); } System.out.println("Round 1"); for (Counter counter : counters) { System.out.println(counter.inc(1)); } System.out.println("Round 2"); for (Counter counter : counters) { System.out.println(counter.inc(1)); } System.out.println("Finished"); Hazelcast.shutdownAll(); } }
counters[i] = instances[0].getDistributedObject(CounterService.NAME, i + "counter");
private MapContainer getMapContainer(@Nonnull String name) { if (mapServiceContext == null) { MapProxyImpl<String, CacheSettings> proxy = hazelcast.getDistributedObject(MapService.SERVICE_NAME, SETTINGS_MAP_NAME); mapServiceContext = proxy.getService().getMapServiceContext(); } return mapServiceContext.getMapContainer(name); }
= this.hazelcastInstance.getDistributedObject(MyPriorityQueue.SERVICE_NAME, "strawberry"); MyPriorityQueue<Order> strawberry = (MyPriorityQueue<Order>) distributedObject;
// works for 3.6 using internal classes, most probably will not work for other versions public static void main(String[] args) { // start a hazelcast instance HazelcastInstance hz = Hazelcast.newHazelcastInstance(); // create a CacheManager and Cache on this instance CachingProvider hazelcastCachingProvider = Caching.getCachingProvider("com.hazelcast.cache.HazelcastCachingProvider", HazelcastCachingProvider.class.getClassLoader()); CacheManager cacheManager = hazelcastCachingProvider.getCacheManager(); cacheManager.createCache("test1", new CacheConfig<Object, Object>()); // hacky: obtain a reference to internal cache service CacheDistributedObject cacheDistributedObject = hz.getDistributedObject("hz:impl:cacheService", "setupRef"); ICacheService cacheService = cacheDistributedObject.getService(); // obtain all CacheConfig's in the cluster Collection<CacheConfig> cacheConfigs = cacheService.getCacheConfigs(); for (CacheConfig cacheConfig : cacheConfigs) { System.out.println("Cache name: " + cacheConfig.getName() + ", fully qualified name: " + cacheConfig.getNameWithPrefix()); } hz.shutdown(); }
/** * Read data from the queues. */ @SuppressWarnings("unchecked") @CliCommand(value = "read", help = "Read orders from IQueue and MyPriorityQueue") public void read() throws Exception { // Normal IQueue IQueue<Order> vanilla = this.hazelcastInstance.getQueue("vanilla"); log.info("Queue '{}' has size {}", vanilla.getName(), vanilla.size()); for (int i = 0; !vanilla.isEmpty(); i++) { log.info("Item {} => {}", i, vanilla.poll()); } // MyPriorityQueue DistributedObject distributedObject = this.hazelcastInstance.getDistributedObject(MyPriorityQueue.SERVICE_NAME, "strawberry"); MyPriorityQueue<Order> strawberry = (MyPriorityQueue<Order>) distributedObject; log.info("Queue '{}' has size {}", strawberry.getName(), strawberry.size()); int max = strawberry.size(); for (int i = 0; i < max; i++) { log.info("Item {} => {}", i, strawberry.poll()); } }