use of com.palantir.atlasdb.keyvalue.cassandra.async.client.creation.ClusterFactory.CassandraClusterConfig in project atlasdb by palantir.
the class CassandraRepairHelper method getCqlClusterUncached.
private ReloadingCloseableContainer<CqlCluster> getCqlClusterUncached(AtlasService atlasService) {
CassandraClusterConfig cassandraClusterConfig = cassandraClusterConfigFactory.apply(atlasService);
Refreshable<CassandraServersConfig> cassandraServersConfigRefreshable = refreshableCassandraServersConfigFactory.apply(atlasService);
return ReloadingCloseableContainerImpl.of(cassandraServersConfigRefreshable, cassandraServersConfig -> CqlCluster.create(cassandraClusterConfig, cassandraServersConfig, atlasService.getNamespace()));
}
use of com.palantir.atlasdb.keyvalue.cassandra.async.client.creation.ClusterFactory.CassandraClusterConfig in project atlasdb by palantir.
the class CassandraRepairEteTest method setUp.
@Before
public void setUp() {
int replicationFactor = 2;
config = ThreeNodeCassandraCluster.getKvsConfig();
runtimeConfig = ThreeNodeCassandraCluster.getRuntimeConfig(replicationFactor);
kvs = CassandraKeyValueServiceImpl.createForTesting(config, runtimeConfig);
TransactionTables.createTables(kvs);
kvs.createTable(TABLE_REF, AtlasDbConstants.GENERIC_TABLE_METADATA);
kvs.putUnlessExists(TABLE_REF, ImmutableMap.of(NONEMPTY_CELL, CONTENTS));
KvsRunner kvsRunner = KvsRunner.create(_unused -> kvs);
Function<AtlasService, CassandraKeyValueServiceConfig> configFactory = _unused -> config;
Function<AtlasService, Refreshable<CassandraKeyValueServiceRuntimeConfig>> runtimeConfigFactory = _unused -> runtimeConfig;
Function<AtlasService, CassandraClusterConfig> cassandraClusterConfigFunction = atlasService -> CassandraClusterConfig.of(configFactory.apply(atlasService), runtimeConfigFactory.apply(atlasService).get());
Function<AtlasService, Refreshable<CassandraServersConfig>> cassandraServersConfigFactory = runtimeConfigFactory.andThen(runtimeConfig -> runtimeConfig.map(CassandraKeyValueServiceRuntimeConfig::servers));
cassandraRepairHelper = new CassandraRepairHelper(kvsRunner, cassandraClusterConfigFunction, cassandraServersConfigFactory);
cluster = new ClusterFactory(Cluster::builder).constructCluster(cassandraClusterConfigFunction.apply(ATLAS_SERVICE), cassandraServersConfigFactory.apply(ATLAS_SERVICE).get());
cqlCluster = new CqlCluster(cluster, cassandraServersConfigFactory.apply(ATLAS_SERVICE).get(), NAMESPACE);
}
use of com.palantir.atlasdb.keyvalue.cassandra.async.client.creation.ClusterFactory.CassandraClusterConfig in project atlasdb by palantir.
the class CassandraKeyValueServiceImpl method createWithCqlClient.
private static CassandraKeyValueService createWithCqlClient(MetricsManager metricsManager, CassandraKeyValueServiceConfig config, Refreshable<CassandraKeyValueServiceRuntimeConfig> runtimeConfig, CassandraClientPool clientPool, CassandraMutationTimestampProvider mutationTimestampProvider, Logger log, boolean initializeAsync) {
try {
CassandraClusterConfig clusterConfig = CassandraClusterConfig.of(config, runtimeConfig.get());
AsyncKeyValueService asyncKeyValueService = config.asyncKeyValueServiceFactory().constructAsyncKeyValueService(metricsManager, config.getKeyspaceOrThrow(), clusterConfig, runtimeConfig.map(CassandraKeyValueServiceRuntimeConfig::servers), initializeAsync);
return createAndInitialize(metricsManager, config, runtimeConfig, clientPool, asyncKeyValueService, mutationTimestampProvider, log, initializeAsync);
} catch (Exception e) {
log.warn("Exception during async KVS creation.", e);
throw Throwables.unwrapAndThrowAtlasDbDependencyException(e);
}
}
use of com.palantir.atlasdb.keyvalue.cassandra.async.client.creation.ClusterFactory.CassandraClusterConfig in project atlasdb by palantir.
the class AtlasDbEteServer method createAndRegisterBackupAndRestoreResource.
private void createAndRegisterBackupAndRestoreResource(AtlasDbEteConfiguration config, Environment environment, TransactionManager txManager, TaggedMetricRegistry taggedMetrics) throws IOException {
AuthHeader authHeader = AuthHeader.of(BearerToken.valueOf("test-auth"));
URL localServer = new URL("https://localhost:1234");
Path backupFolder = Paths.get("/var/data/backup");
Files.createDirectories(backupFolder);
Function<AtlasService, Path> backupFolderFactory = _unused -> backupFolder;
ExternalBackupPersister externalBackupPersister = new ExternalBackupPersister(backupFolderFactory);
Function<String, BackupTimeLockServiceView> timelockServices = _unused -> createBackupTimeLockServiceView(txManager);
AuthHeaderValidator authHeaderValidator = new AuthHeaderValidator(() -> Optional.of(authHeader.getBearerToken()));
RedirectRetryTargeter redirectRetryTargeter = RedirectRetryTargeter.create(localServer, ImmutableList.of(localServer));
AtlasBackupClient atlasBackupClient = AtlasBackupResource.jersey(authHeaderValidator, redirectRetryTargeter, timelockServices);
AtlasRestoreClient atlasRestoreClient = AtlasRestoreResource.jersey(authHeaderValidator, redirectRetryTargeter, timelockServices);
Refreshable<ServerListConfig> serverListConfig = getServerListConfigForTimeLock(config);
TimeLockManagementService timeLockManagementService = getRemoteTimeLockManagementService(serverListConfig, taggedMetrics);
AtlasBackupService atlasBackupService = AtlasBackupService.createForTests(authHeader, atlasBackupClient, txManager, backupFolderFactory);
Function<AtlasService, CassandraKeyValueServiceConfig> keyValueServiceConfigFactory = _unused -> (CassandraKeyValueServiceConfig) config.getAtlasDbConfig().keyValueService();
Function<AtlasService, CassandraKeyValueServiceRuntimeConfig> runtimeConfigFactory = _unused -> (CassandraKeyValueServiceRuntimeConfig) config.getAtlasDbRuntimeConfig().flatMap(AtlasDbRuntimeConfig::keyValueService).orElseThrow();
Function<AtlasService, CassandraClusterConfig> cassandraClusterConfigFactory = atlasService -> CassandraClusterConfig.of(keyValueServiceConfigFactory.apply(atlasService), runtimeConfigFactory.apply(atlasService));
Function<AtlasService, Refreshable<CassandraServersConfig>> refreshableCassandraServersConfigFactory = runtimeConfigFactory.andThen(runtimeConfig -> Refreshable.only(runtimeConfig.servers()));
AtlasRestoreService atlasRestoreService = AtlasRestoreService.createForTests(authHeader, atlasRestoreClient, timeLockManagementService, externalBackupPersister, txManager, cassandraClusterConfigFactory, refreshableCassandraServersConfigFactory);
environment.jersey().register(new SimpleBackupAndRestoreResource(atlasBackupService, atlasRestoreService, externalBackupPersister));
}
Aggregations