@Value.Default public HumanReadableDuration compactInterval() { return HumanReadableDuration.seconds(0); } }
@VisibleForTesting boolean shouldRunCompaction() { long compactIntervalMillis = config.compactInterval().toMilliseconds(); return compactIntervalMillis <= 0 || getMillisSinceLastCompact() >= compactIntervalMillis; }
@Test public void shouldCompactIfCompactMillisIsSetToZero() throws Exception { postgresDdlTable = new PostgresDdlTable(TEST_TABLE, connectionSupplier, ImmutablePostgresDdlConfig.builder().compactInterval(HumanReadableDuration.valueOf("0 ms")).build()); SqlConnection sqlConnection = setUpSqlConnection(NOW_MILLIS - SMALL_POSITIVE_FACTOR, NOW_MILLIS); assertThatVacuumWasPerformed(sqlConnection, false); verify(sqlConnection, never()).selectResultSetUnregisteredQuery(startsWith("SELECT FLOOR"), any()); }
@Before public void setUp() { postgresDdlTable = new PostgresDdlTable(TEST_TABLE, connectionSupplier, ImmutablePostgresDdlConfig.builder() .compactInterval(HumanReadableDuration.milliseconds(COMPACT_INTERVAL_MILLIS)) .build()); }
public static DbKeyValueServiceConfig getKvsConfig() { DockerPort port = docker.containers() .container("postgres") .port(POSTGRES_PORT_NUMBER); InetSocketAddress postgresAddress = new InetSocketAddress(port.getIp(), port.getExternalPort()); ConnectionConfig connectionConfig = ImmutablePostgresConnectionConfig.builder() .dbName("atlas") .dbLogin("palantir") .dbPassword(ImmutableMaskedValue.of("palantir")) .host(postgresAddress.getHostName()) .port(postgresAddress.getPort()) .build(); return ImmutableDbKeyValueServiceConfig.builder() .connection(connectionConfig) .ddl(ImmutablePostgresDdlConfig.builder() .compactInterval(HumanReadableDuration.days(2)) .build()) .build(); }
@VisibleForTesting boolean shouldRunCompaction() { long compactIntervalMillis = config.compactInterval().toMilliseconds(); return compactIntervalMillis <= 0 || getMillisSinceLastCompact() >= compactIntervalMillis; }
@Value.Default public HumanReadableDuration compactInterval() { return HumanReadableDuration.seconds(0); } }