Exemplo n.º 1
0
 private HazelcastClient(ClientConfig config) {
   this.config = config;
   final GroupConfig groupConfig = config.getGroupConfig();
   instanceName = "hz.client_" + id + (groupConfig != null ? "_" + groupConfig.getName() : "");
   threadGroup = new ThreadGroup(instanceName);
   lifecycleService = new LifecycleServiceImpl(this);
   clientProperties = new ClientProperties(config);
   serializationService = initSerializationService(config);
   proxyManager = new ProxyManager(this);
   executionService =
       new ClientExecutionServiceImpl(
           instanceName,
           threadGroup,
           Thread.currentThread().getContextClassLoader(),
           config.getExecutorPoolSize());
   transactionManager = new ClientTransactionManager(this);
   LoadBalancer lb = config.getLoadBalancer();
   if (lb == null) {
     lb = new RoundRobinLB();
   }
   loadBalancer = lb;
   connectionManager = createClientConnectionManager();
   clusterService = new ClientClusterServiceImpl(this);
   invocationService = new ClientInvocationServiceImpl(this);
   userContext = new ConcurrentHashMap<String, Object>();
   proxyManager.init(config);
   partitionService = new ClientPartitionServiceImpl(this);
 }
Exemplo n.º 2
0
 @Override
 @Deprecated
 public <T extends DistributedObject> T getDistributedObject(String serviceName, Object id) {
   if (id instanceof String) {
     return (T) proxyManager.getProxy(serviceName, (String) id);
   }
   throw new IllegalArgumentException("'id' must be type of String!");
 }
Exemplo n.º 3
0
 void doShutdown() {
   CLIENTS.remove(id);
   executionService.shutdown();
   partitionService.stop();
   clusterService.stop();
   transactionManager.shutdown();
   connectionManager.shutdown();
   proxyManager.destroy();
   serializationService.destroy();
 }
Exemplo n.º 4
0
 @Override
 public Collection<DistributedObject> getDistributedObjects() {
   try {
     GetDistributedObjectsRequest request = new GetDistributedObjectsRequest();
     final Future<SerializableCollection> future = invocationService.invokeOnRandomTarget(request);
     final SerializableCollection serializableCollection =
         serializationService.toObject(future.get());
     for (Data data : serializableCollection) {
       final DistributedObjectInfo o = serializationService.toObject(data);
       getDistributedObject(o.getServiceName(), o.getName());
     }
     return (Collection<DistributedObject>) proxyManager.getDistributedObjects();
   } catch (Exception e) {
     throw ExceptionUtil.rethrow(e);
   }
 }
Exemplo n.º 5
0
 @Override
 public <T extends DistributedObject> T getDistributedObject(String serviceName, String name) {
   return (T) proxyManager.getProxy(serviceName, name);
 }
Exemplo n.º 6
0
 @Override
 public boolean removeDistributedObjectListener(String registrationId) {
   return proxyManager.removeDistributedObjectListener(registrationId);
 }
Exemplo n.º 7
0
 @Override
 public String addDistributedObjectListener(DistributedObjectListener distributedObjectListener) {
   return proxyManager.addDistributedObjectListener(distributedObjectListener);
 }