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