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 server for the replica. */
    private ResourceServer buildServer() {
      // Construct the underlying CopycatServer. The server should have been configured with a
      // CombinedTransport
      // that facilitates the local client connecting directly to the server.
      if (clientTransport != null) {
        serverBuilder
            .withClientTransport(
                new CombinedServerTransport(new LocalTransport(localRegistry), clientTransport))
            .withServerTransport(serverTransport);
      } else {
        serverBuilder.withTransport(
            new CombinedServerTransport(new LocalTransport(localRegistry), serverTransport));
      }

      // Set the server resource state machine.
      serverBuilder.withStateMachine(() -> new ResourceManagerState(registry));

      CopycatServer server = serverBuilder.build();
      server.serializer().resolve(new ResourceManagerTypeResolver(registry));
      return new ResourceServer(server);
    }