public ClientListenerServiceImpl(
     HazelcastClientInstanceImpl client, int eventThreadCount, int eventQueueCapacity) {
   this.client = client;
   this.executionService = (ClientExecutionServiceImpl) client.getClientExecutionService();
   this.invocationService = client.getInvocationService();
   this.serializationService = client.getSerializationService();
   client.getClientClusterService().addMembershipListener(this);
   this.eventExecutor =
       new StripedExecutor(
           logger,
           client.getName() + ".event",
           client.getThreadGroup(),
           eventThreadCount,
           eventQueueCapacity);
 }
Esempio n. 2
0
  public Address findNextAddressToSendCreateRequest() {
    int clusterSize = client.getClientClusterService().getSize();
    Member liteMember = null;

    final LoadBalancer loadBalancer = client.getLoadBalancer();
    for (int i = 0; i < clusterSize; i++) {
      Member member = loadBalancer.next();
      if (member != null && !member.isLiteMember()) {
        return member.getAddress();
      } else if (liteMember == null) {
        liteMember = member;
      }
    }

    return liteMember != null ? liteMember.getAddress() : null;
  }
Esempio n. 3
0
  private Connection getTargetOrOwnerConnection(final Address target) throws IOException {
    if (target == null) {
      throw new IOException("Not able to setup owner connection!");
    }

    final ClientConnectionManager connectionManager = client.getConnectionManager();
    Connection connection = connectionManager.getConnection(target);
    if (connection == null) {
      final Address ownerConnectionAddress =
          client.getClientClusterService().getOwnerConnectionAddress();
      if (ownerConnectionAddress == null) {
        throw new IOException("Not able to setup owner connection!");
      }

      connection = connectionManager.getConnection(ownerConnectionAddress);
      if (connection == null) {
        throw new IOException("Client is not connected to member " + target);
      }
    }

    return connection;
  }
 public ClientSmartListenerService(
     HazelcastClientInstanceImpl client, int eventThreadCount, int eventQueueCapacity) {
   super(client, eventThreadCount, eventQueueCapacity);
   client.getClientClusterService().addMembershipListener(this);
 }
 public ClientMembershipListener(HazelcastClientInstanceImpl client) {
   this.client = client;
   connectionManager = (ClientConnectionManagerImpl) client.getConnectionManager();
   partitionService = (ClientPartitionServiceImpl) client.getClientPartitionService();
   clusterService = (ClientClusterServiceImpl) client.getClientClusterService();
 }