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