/** * Creates a ConnectionManagerAwareDbKvs. * * @param config Configuration file. * @param runtimeConfig unused. * @param leaderConfig unused. * @param namespace unused. * @param unusedLongSupplier unused. * @param initializeAsync unused. Async initialization has not been implemented and is not propagated. * @return The requested KeyValueService instance */ @Override public KeyValueService createRawKeyValueService( MetricsManager metricsManager, KeyValueServiceConfig config, Supplier<Optional<KeyValueServiceRuntimeConfig>> runtimeConfig, Optional<LeaderConfig> leaderConfig, Optional<String> namespace, LongSupplier unusedLongSupplier, boolean initializeAsync) { if (initializeAsync) { log.warn("Asynchronous initialization not implemented, will initialize synchronousy."); } Preconditions.checkArgument(config instanceof DbKeyValueServiceConfig, "DbAtlasDbFactory expects a configuration of type DbKeyValueServiceConfiguration, found %s", config.getClass()); return ConnectionManagerAwareDbKvs.create((DbKeyValueServiceConfig) config); }
private InDbTimestampBoundStore createTimestampBoundStore(Optional<TableReference> timestampTable, ConnectionManagerAwareDbKvs dbkvs) { return timestampTable .map(tableReference -> InDbTimestampBoundStore.create( dbkvs.getConnectionManager(), tableReference /* Not using the table prefix here, as the tableRef should contain any necessary prefix.*/ )) .orElseGet(() -> InDbTimestampBoundStore.create( dbkvs.getConnectionManager(), AtlasDbConstants.TIMESTAMP_TABLE, dbkvs.getTablePrefix())); } }
public static ConnectionManagerAwareDbKvs create(DbKeyValueServiceConfig config) { HikariCPConnectionManager connManager = new HikariCPConnectionManager(config.connection()); ReentrantManagedConnectionSupplier connSupplier = new ReentrantManagedConnectionSupplier(connManager); SqlConnectionSupplier sqlConnSupplier = getSimpleTimedSqlConnectionSupplier(connSupplier); return new ConnectionManagerAwareDbKvs(DbKvs.create(config, sqlConnSupplier), connManager, sqlConnSupplier); }
private static Callable<Boolean> canCreateKeyValueService() { return () -> { ConnectionManagerAwareDbKvs kvs = null; try { kvs = createKvs(); return kvs.getConnectionManager().getConnection().isValid(5); } catch (Exception ex) { if (ex.getMessage().contains("The connection attempt failed.") || ex.getMessage().contains("the database system is starting up")) { return false; } else { throw ex; } } finally { if (kvs != null) { kvs.close(); } } }; }
@Override protected TimestampBoundStore createTimestampBoundStore() { kvs = DbkvsPostgresTestSuite.createKvs(); return InDbTimestampBoundStore.create( kvs.getConnectionManager(), AtlasDbConstants.TIMESTAMP_TABLE, DbkvsPostgresTestSuite.getKvsConfig().ddl().tablePrefix()); } }
static void setMaxRangeOfTimestampsBatchSize(long value, ConnectionManagerAwareDbKvs kvs) { ((DbKvs) kvs.delegate()).setMaxRangeOfTimestampsBatchSize(value); }
@After public void tearDown() throws Exception { kvs.close(); }
private InDbTimestampBoundStore createTimestampBoundStore(Optional<TableReference> timestampTable, ConnectionManagerAwareDbKvs dbkvs) { return timestampTable .map(tableReference -> InDbTimestampBoundStore.create( dbkvs.getConnectionManager(), tableReference /* Not using the table prefix here, as the tableRef should contain any necessary prefix.*/ )) .orElseGet(() -> InDbTimestampBoundStore.create( dbkvs.getConnectionManager(), AtlasDbConstants.TIMESTAMP_TABLE, dbkvs.getTablePrefix())); } }
public static ConnectionManagerAwareDbKvs create(DbKeyValueServiceConfig config) { HikariCPConnectionManager connManager = new HikariCPConnectionManager(config.connection()); ReentrantManagedConnectionSupplier connSupplier = new ReentrantManagedConnectionSupplier(connManager); SqlConnectionSupplier sqlConnSupplier = getSimpleTimedSqlConnectionSupplier(connSupplier); return new ConnectionManagerAwareDbKvs(DbKvs.create(config, sqlConnSupplier), connManager, sqlConnSupplier); }
public static ConnectionManagerAwareDbKvs createKvs() { return ConnectionManagerAwareDbKvs.create(getKvsConfig()); } }
/** * Creates a ConnectionManagerAwareDbKvs. * * @param config Configuration file. * @param runtimeConfig unused. * @param leaderConfig unused. * @param namespace unused. * @param unusedLongSupplier unused. * @param initializeAsync unused. Async initialization has not been implemented and is not propagated. * @return The requested KeyValueService instance */ @Override public KeyValueService createRawKeyValueService( MetricsManager metricsManager, KeyValueServiceConfig config, Supplier<Optional<KeyValueServiceRuntimeConfig>> runtimeConfig, Optional<LeaderConfig> leaderConfig, Optional<String> namespace, LongSupplier unusedLongSupplier, boolean initializeAsync) { if (initializeAsync) { log.warn("Asynchronous initialization not implemented, will initialize synchronousy."); } Preconditions.checkArgument(config instanceof DbKeyValueServiceConfig, "DbAtlasDbFactory expects a configuration of type DbKeyValueServiceConfiguration, found %s", config.getClass()); return ConnectionManagerAwareDbKvs.create((DbKeyValueServiceConfig) config); }