mServer = CopycatServer.builder(getLocalAddress(mConf)) .withStorage(storage) .withElectionTimeout(Duration.ofMillis(mConf.getElectionTimeoutMs())) .withHeartbeatInterval(Duration.ofMillis(mConf.getHeartbeatIntervalMs())) .withSnapshotAllowed(mSnapshotAllowed)
/** * Sets the server election timeout, returning the server builder for method chaining. * <p> * The election timeout is the duration since last contact with the cluster leader after which * the server should start a new election. The election timeout should always be significantly * larger than {@link #withHeartbeatInterval(Duration)} in order to prevent unnecessary elections. * * @param electionTimeout The server election timeout in milliseconds. * @return The server builder. * @throws NullPointerException if {@code electionTimeout} is null */ public Builder withElectionTimeout(Duration electionTimeout) { builder.withElectionTimeout(electionTimeout); return this; }
/** * Sets the replica election timeout, returning the replica builder for method chaining. * <p> * The election timeout is the duration since last contact with the cluster leader after which * the replica should start a new election. The election timeout should always be significantly * larger than {@link #withHeartbeatInterval(Duration)} in order to prevent unnecessary elections. * * @param electionTimeout The replica election timeout in milliseconds. * @return The replica builder. * @throws NullPointerException if {@code electionTimeout} is null */ public Builder withElectionTimeout(Duration electionTimeout) { serverBuilder.withElectionTimeout(electionTimeout); return this; }
/** * Sets the server election timeout, returning the server builder for method chaining. * <p> * The election timeout is the duration since last contact with the cluster leader after which * the server should start a new election. The election timeout should always be significantly * larger than {@link #withHeartbeatInterval(Duration)} in order to prevent unnecessary elections. * * @param electionTimeout The server election timeout in milliseconds. * @return The server builder. * @throws NullPointerException if {@code electionTimeout} is null */ public Builder withElectionTimeout(Duration electionTimeout) { builder.withElectionTimeout(electionTimeout); return this; }