/** * 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)); // If the quorum hint is ALL then set the local member to ACTIVE. if (quorumHint == Quorum.ALL.size()) { serverBuilder.withType(Member.Type.ACTIVE); } CopycatServer server = serverBuilder.build(); server.serializer().resolve(new ResourceManagerTypeResolver(registry)); return new ResourceServer(server); }
/** * Sets the client transport, returning the server builder for method chaining. * <p> * The configured transport should be the same transport as all clients. * If no transport is explicitly provided, the instance will default to the {@code NettyTransport} * if available on the classpath. * * @param transport The server transport. * @return The server builder. * @throws NullPointerException if {@code transport} is null */ public Builder withClientTransport(Transport transport) { builder.withClientTransport(transport); return this; }
/** * Sets the client transport, returning the server builder for method chaining. * <p> * The configured transport should be the same transport as all clients. * If no transport is explicitly provided, the instance will default to the {@code NettyTransport} * if available on the classpath. * * @param transport The server transport. * @return The server builder. * @throws NullPointerException if {@code transport} is null */ public Builder withClientTransport(Transport transport) { builder.withClientTransport(transport); return this; }