public static ClusterConfiguration getClusterConfiguration(TimeLockInstallConfiguration install) { return install.cluster(); }
private TimestampCreator getTimestampCreator(MetricRegistry metrics) { TsBoundPersisterConfiguration timestampBoundPersistence = install.timestampBoundPersistence(); if (timestampBoundPersistence instanceof PaxosTsBoundPersisterConfiguration) { return getPaxosTimestampCreator(metrics); } else if (timestampBoundPersistence instanceof DatabaseTsBoundPersisterConfiguration) { return new DbBoundTimestampCreator( ((DatabaseTsBoundPersisterConfiguration) timestampBoundPersistence) .keyValueServiceConfig()); } throw new RuntimeException(String.format("Unknown TsBoundPersisterConfiguration found %s", timestampBoundPersistence.getClass())); }
private LeaderConfig getLeaderConfig() { // TODO (jkong): Live Reload Paxos Ping Rates PaxosRuntimeConfiguration paxosRuntimeConfiguration = runtime.get(); return ImmutableLeaderConfig.builder() .sslConfiguration(PaxosRemotingUtils.getSslConfigurationOptional(install)) .leaders(PaxosRemotingUtils.addProtocols(install, PaxosRemotingUtils.getClusterAddresses(install))) .localServer(PaxosRemotingUtils.addProtocol(install, PaxosRemotingUtils.getClusterConfiguration(install).localServer())) .acceptorLogDir(Paths.get(install.paxos().dataDirectory().toString(), PaxosTimeLockConstants.LEADER_PAXOS_NAMESPACE, PaxosTimeLockConstants.ACCEPTOR_SUBDIRECTORY_PATH).toFile()) .learnerLogDir(Paths.get(install.paxos().dataDirectory().toString(), PaxosTimeLockConstants.LEADER_PAXOS_NAMESPACE, PaxosTimeLockConstants.LEARNER_SUBDIRECTORY_PATH).toFile()) .pingRateMs(paxosRuntimeConfiguration.pingRateMs()) .quorumSize(PaxosRemotingUtils.getQuorumSize(PaxosRemotingUtils.getClusterAddresses(install))) .leaderPingResponseWaitMs(paxosRuntimeConfiguration.pingRateMs()) .randomWaitBeforeProposingLeadershipMs(paxosRuntimeConfiguration.pingRateMs()) .build(); }
private TimeLockAgent(MetricsManager metricsManager, TimeLockInstallConfiguration install, Supplier<TimeLockRuntimeConfiguration> runtime, TimeLockDeprecatedConfiguration deprecated, Consumer<Object> registrar) { this.metricsManager = metricsManager; this.install = install; this.runtime = runtime; this.registrar = registrar; this.paxosResource = PaxosResource.create(metricsManager.getRegistry(), install.paxos().dataDirectory().toString()); this.leadershipCreator = new PaxosLeadershipCreator(this.metricsManager, install, runtime, registrar); this.lockCreator = new LockCreator(runtime, deprecated); this.timestampCreator = getTimestampCreator(metricsManager.getRegistry()); LockLog lockLog = new LockLog(metricsManager.getRegistry(), Suppliers.compose(TimeLockRuntimeConfiguration::slowLockLogTriggerMillis, runtime::get)); this.timelockCreator = new AsyncTimeLockServicesCreator(metricsManager, lockLog, leadershipCreator); }
public static Set<String> getRemoteServerAddresses(TimeLockInstallConfiguration install) { return Sets.difference(getClusterAddresses(install), ImmutableSet.of(install.cluster().localServer())); }
/** * Creates timestamp and lock services for the given client. It is expected that for each client there should * only be (up to) one active timestamp service, and one active lock service at any time. * @param client Client namespace to create the services for * @return Invalidating timestamp and lock services */ private TimeLockServices createInvalidatingTimeLockServices(String client) { List<String> uris = install.cluster().clusterMembers(); ImmutableLeaderConfig leaderConfig = ImmutableLeaderConfig.builder() .addLeaders(uris.toArray(new String[uris.size()])) .localServer(install.cluster().localServer()) .sslConfiguration(PaxosRemotingUtils.getSslConfigurationOptional(install)) .quorumSize(PaxosRemotingUtils.getQuorumSize(uris)) .build(); Supplier<ManagedTimestampService> rawTimestampServiceSupplier = timestampCreator .createTimestampService(client, leaderConfig); Supplier<LockService> rawLockServiceSupplier = lockCreator::createThreadPoolingLockService; return timelockCreator.createTimeLockServices(client, rawTimestampServiceSupplier, rawLockServiceSupplier); } }