Ejemplo 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());
 }
Ejemplo 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);
    }
Ejemplo n.º 3
0
 @Override
 public boolean isOpen() {
   return client.isOpen();
 }
Ejemplo n.º 4
0
 @Override
 public CompletableFuture<Void> close() {
   return client.close();
 }
Ejemplo n.º 5
0
 @Override
 public CompletableFuture<CopycatClient> recover() {
   return client.recover();
 }
Ejemplo n.º 6
0
 @Override
 public CompletableFuture<CopycatClient> open() {
   return client.open();
 }
Ejemplo n.º 7
0
 @Override
 public <T> Listener<T> onEvent(String event, Consumer<T> callback) {
   return client.onEvent(event, callback);
 }
Ejemplo n.º 8
0
 @Override
 public Listener<Void> onEvent(String event, Runnable callback) {
   return client.onEvent(event, callback);
 }
Ejemplo n.º 9
0
 @Override
 public <T> CompletableFuture<T> submit(Command<T> command) {
   return client.submit(command);
 }
Ejemplo n.º 10
0
 @Override
 public Session session() {
   return client.session();
 }
Ejemplo n.º 11
0
 @Override
 public Serializer serializer() {
   return client.serializer();
 }
Ejemplo n.º 12
0
 @Override
 public ThreadContext context() {
   return client.context();
 }
Ejemplo n.º 13
0
 @Override
 public Listener<State> onStateChange(Consumer<State> consumer) {
   return client.onStateChange(consumer);
 }
Ejemplo n.º 14
0
 @Override
 public State state() {
   return client.state();
 }
Ejemplo n.º 15
0
 @Override
 public boolean isClosed() {
   return client.isClosed();
 }
Ejemplo n.º 16
0
 @Override
 public String toString() {
   return client.toString();
 }
Ejemplo n.º 17
0
 @Override
 public <T> CompletableFuture<T> submit(Query<T> query) {
   return client.submit(query);
 }