use of com.palantir.atlasdb.cassandra.CassandraServersConfigs.CassandraServersConfig 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.cassandra.CassandraServersConfigs.CassandraServersConfig 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.cassandra.CassandraServersConfigs.CassandraServersConfig in project atlasdb by palantir.
the class TokenRangeFetcher method getTokenRange.
public Map<InetSocketAddress, RangeSet<LightweightOppToken>> getTokenRange(String tableName) {
KeyspaceMetadata keyspaceMetadata = cqlMetadata.getKeyspaceMetadata(namespace);
if (keyspaceMetadata == null) {
log.error("Could not find metadata for a keyspace that is supposed to exist", SafeArg.of("keyspace", namespace));
return ImmutableMap.of();
}
TableMetadata tableMetadata = keyspaceMetadata.getTable(tableName);
if (tableMetadata == null) {
log.error("Could not find metadata for table that is supposed to exist", SafeArg.of("keyspace", namespace), SafeArg.of("tableName", tableName));
return ImmutableMap.of();
}
Set<LightweightOppToken> partitionTokens = getPartitionTokens(tableMetadata);
Map<InetSocketAddress, RangeSet<LightweightOppToken>> tokenRangesByNode = ClusterMetadataUtils.getTokenMapping(CassandraServersConfigs.getCqlHosts(cassandraServersConfig), cqlMetadata, namespace, partitionTokens);
if (!partitionTokens.isEmpty() && log.isDebugEnabled()) {
int numTokenRanges = tokenRangesByNode.values().stream().mapToInt(ranges -> ranges.asRanges().size()).sum();
log.debug("Identified token ranges requiring repair", SafeArg.of("keyspace", namespace), SafeArg.of("table", tableName), SafeArg.of("numPartitionKeys", partitionTokens.size()), SafeArg.of("numTokenRanges", numTokenRanges));
}
return tokenRangesByNode;
}
use of com.palantir.atlasdb.cassandra.CassandraServersConfigs.CassandraServersConfig 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