Exemplo n.º 1
0
 private Builder(Address clientAddress, Address serverAddress, Collection<Address> members) {
   this.members = Assert.notNull(members, "members");
   Serializer serializer = new Serializer();
   this.clientAddress = Assert.notNull(clientAddress, "clientAddress");
   this.clientBuilder = CopycatClient.builder(members).withSerializer(serializer.clone());
   this.serverBuilder =
       CopycatServer.builder(clientAddress, serverAddress, members)
           .withSerializer(serializer.clone());
 }
Exemplo n.º 2
0
    /** Builds a client for the replica. */
    private ResourceClient buildClient() {
      buildTransport();

      // Resolve resources.
      resourceResolver.resolve(registry);

      // Configure the client and server with a transport that routes all local client communication
      // directly through the local server, ensuring we don't incur unnecessary network traffic by
      // sending operations to a remote server when a local server is already available in the same
      // JVM.=
      clientBuilder
          .withTransport(
              new CombinedClientTransport(
                  clientAddress,
                  new LocalTransport(localRegistry),
                  clientTransport != null ? clientTransport : serverTransport))
          .withServerSelectionStrategy(new CombinedSelectionStrategy(clientAddress));

      CopycatClient client = clientBuilder.build();
      client.serializer().resolve(new ResourceManagerTypeResolver(registry));
      return new ResourceClient(new CombinedCopycatClient(client, serverTransport), registry);
    }
Exemplo n.º 3
0
 @Override
 public boolean isOpen() {
   return client.isOpen();
 }
Exemplo n.º 4
0
 @Override
 public CompletableFuture<Void> close() {
   return client.close();
 }
Exemplo n.º 5
0
 @Override
 public CompletableFuture<CopycatClient> recover() {
   return client.recover();
 }
Exemplo n.º 6
0
 @Override
 public CompletableFuture<CopycatClient> open() {
   return client.open();
 }
Exemplo n.º 7
0
 @Override
 public <T> Listener<T> onEvent(String event, Consumer<T> callback) {
   return client.onEvent(event, callback);
 }
Exemplo n.º 8
0
 @Override
 public Listener<Void> onEvent(String event, Runnable callback) {
   return client.onEvent(event, callback);
 }
Exemplo n.º 9
0
 @Override
 public <T> CompletableFuture<T> submit(Command<T> command) {
   return client.submit(command);
 }
Exemplo n.º 10
0
 @Override
 public Session session() {
   return client.session();
 }
Exemplo n.º 11
0
 @Override
 public Serializer serializer() {
   return client.serializer();
 }
Exemplo n.º 12
0
 @Override
 public ThreadContext context() {
   return client.context();
 }
Exemplo n.º 13
0
 @Override
 public Listener<State> onStateChange(Consumer<State> consumer) {
   return client.onStateChange(consumer);
 }
Exemplo n.º 14
0
 @Override
 public State state() {
   return client.state();
 }
Exemplo n.º 15
0
 @Override
 public boolean isClosed() {
   return client.isClosed();
 }
Exemplo n.º 16
0
 @Override
 public String toString() {
   return client.toString();
 }
Exemplo n.º 17
0
 @Override
 public <T> CompletableFuture<T> submit(Query<T> query) {
   return client.submit(query);
 }