public static TimestampBoundStore create(CassandraKeyValueService kvs) { return create(kvs, AtlasDbConstants.DEFAULT_INITIALIZE_ASYNC); }
public static TimestampBoundStore create(CassandraKeyValueService kvs, boolean initializeAsync) { CassandraTimestampBoundStore store = new CassandraTimestampBoundStore(kvs.getClientPool(), kvs); store.wrapper.initialize(initializeAsync); return store.wrapper.isInitialized() ? store : store.wrapper; }
result = client.cas( AtlasDbConstants.TIMESTAMP_TABLE, getRowName(), oldVal == null ? ImmutableList.of() : ImmutableList.of(makeColumn(oldVal)), ImmutableList.of(makeColumn(newVal)), ConsistencyLevel.SERIAL, ConsistencyLevel.EACH_QUORUM); + " service."; MultipleRunningTimestampServiceError err = new MultipleRunningTimestampServiceError( String.format(replaceBracesWithStringFormatSpecifier(msg), oldVal, newVal, currentLimit, getCurrentTimestampValues(result))); log.error(msg, SafeArg.of("oldValue", oldVal), SafeArg.of("newValue", newVal), SafeArg.of("inMemoryLimit", currentLimit), SafeArg.of("dbLimit", getCurrentTimestampValues(result)), err); DebugLogger.logger.error(msg, SafeArg.of("newValue", newVal), SafeArg.of("inMemoryLimit", currentLimit), SafeArg.of("dbLimit", getCurrentTimestampValues(result)), err); DebugLogger.logger.error("Thread dump: {}",
private Column makeColumn(long ts) { Column col = new Column(); col.setName(getColumnName()); col.setValue(PtBytes.toBytes(ts)); col.setTimestamp(CASSANDRA_TIMESTAMP); return col; }
private Column makeColumn(long ts) { Column col = new Column(); col.setName(getColumnName()); col.setValue(PtBytes.toBytes(ts)); col.setTimestamp(CASSANDRA_TIMESTAMP); return col; }
result = client.cas( AtlasDbConstants.TIMESTAMP_TABLE, getRowName(), oldVal == null ? ImmutableList.of() : ImmutableList.of(makeColumn(oldVal)), ImmutableList.of(makeColumn(newVal)), ConsistencyLevel.SERIAL, ConsistencyLevel.EACH_QUORUM); + " service."; MultipleRunningTimestampServiceError err = new MultipleRunningTimestampServiceError( String.format(replaceBracesWithStringFormatSpecifier(msg), oldVal, newVal, currentLimit, getCurrentTimestampValues(result))); log.error(msg, SafeArg.of("oldValue", oldVal), SafeArg.of("newValue", newVal), SafeArg.of("inMemoryLimit", currentLimit), SafeArg.of("dbLimit", getCurrentTimestampValues(result)), err); DebugLogger.logger.error(msg, SafeArg.of("newValue", newVal), SafeArg.of("inMemoryLimit", currentLimit), SafeArg.of("dbLimit", getCurrentTimestampValues(result)), err); DebugLogger.logger.error("Thread dump: {}",
@Override public TimestampService createTimestampService( KeyValueService rawKvs, Optional<TableReference> timestampTable, boolean initializeAsync) { Preconditions.checkArgument(!timestampTable.isPresent() || timestampTable.get().equals(AtlasDbConstants.TIMESTAMP_TABLE), "***ERROR:This can cause severe data corruption.***\nUnexpected timestamp table found: %s" + "\nThis can happen if you configure the timelock server to use Cassandra KVS for timestamp" + " persistence, which is unsupported.\nWe recommend using the default paxos timestamp" + " persistence. However, if you are need to persist the timestamp service state in the" + " database, please specify a valid DbKvs config in the timestampBoundPersister block." + "\nNote that if the service has already been running, you will have to migrate the timestamp" + " table to Postgres/Oracle and rename it to %s.", timestampTable.map(TableReference::getQualifiedName).orElse("unknown table"), AtlasDbConstants.TIMELOCK_TIMESTAMP_TABLE); AtlasDbVersion.ensureVersionReported(); Preconditions.checkArgument(rawKvs instanceof CassandraKeyValueService, "TimestampService must be created from an instance of" + " CassandraKeyValueService, found %s", rawKvs.getClass()); return PersistentTimestampServiceImpl.create( CassandraTimestampBoundStore.create((CassandraKeyValueService) rawKvs, initializeAsync), initializeAsync); }
public static TimestampBoundStore create(CassandraKeyValueService kvs, boolean initializeAsync) { CassandraTimestampBoundStore store = new CassandraTimestampBoundStore(kvs.getClientPool(), kvs); store.wrapper.initialize(initializeAsync); return store.wrapper.isInitialized() ? store : store.wrapper; }
private void assertWeCanReadTimestamp(long expectedTimestamp) { TimestampBoundStore timestampBoundStore = CassandraTimestampBoundStore.create(kv); assertThat(timestampBoundStore.getUpperLimit()).isEqualTo(expectedTimestamp); }
private long getBoundAfterTakingOutOneMillionTimestamps() { TimestampBoundStore timestampBoundStore = CassandraTimestampBoundStore.create(kv); long newLimit = timestampBoundStore.getUpperLimit() + ONE_MILLION; timestampBoundStore.storeUpperLimit(newLimit); return newLimit; } }
@Test public void canBackupAndRestoreTimestampTable() { TimestampBoundStore timestampBoundStore = CassandraTimestampBoundStore.create(kv); long limit = timestampBoundStore.getUpperLimit(); timestampBoundStore.storeUpperLimit(limit + ONE_MILLION); invalidator.backupAndInvalidate(); invalidator.revalidateFromBackup(); assertThat(timestampBoundStore.getUpperLimit()).isEqualTo(limit + ONE_MILLION); }
public static TimestampBoundStore create(CassandraKeyValueService kvs) { return create(kvs, AtlasDbConstants.DEFAULT_INITIALIZE_ASYNC); }
@Test public void resilientToMultipleStoreUpperLimitBeforeGet() { TimestampBoundStore ts = CassandraTimestampBoundStore.create(kv); long limit = ts.getUpperLimit(); ts.storeUpperLimit(limit + 10); ts.storeUpperLimit(limit + 20); Assert.assertEquals(limit + 20, ts.getUpperLimit()); }
@Test public void testBounds() { TimestampBoundStore ts = CassandraTimestampBoundStore.create(kv); long limit = ts.getUpperLimit(); ts.storeUpperLimit(limit + 10); Assert.assertEquals(limit + 10, ts.getUpperLimit()); ts.storeUpperLimit(limit + 20); Assert.assertEquals(limit + 20, ts.getUpperLimit()); ts.storeUpperLimit(limit + 30); Assert.assertEquals(limit + 30, ts.getUpperLimit()); }
@Override public TimestampService createTimestampService( KeyValueService rawKvs, Optional<TableReference> timestampTable, boolean initializeAsync) { Preconditions.checkArgument(!timestampTable.isPresent() || timestampTable.get().equals(AtlasDbConstants.TIMESTAMP_TABLE), "***ERROR:This can cause severe data corruption.***\nUnexpected timestamp table found: %s" + "\nThis can happen if you configure the timelock server to use Cassandra KVS for timestamp" + " persistence, which is unsupported.\nWe recommend using the default paxos timestamp" + " persistence. However, if you are need to persist the timestamp service state in the" + " database, please specify a valid DbKvs config in the timestampBoundPersister block." + "\nNote that if the service has already been running, you will have to migrate the timestamp" + " table to Postgres/Oracle and rename it to %s.", timestampTable.map(TableReference::getQualifiedName).orElse("unknown table"), AtlasDbConstants.TIMELOCK_TIMESTAMP_TABLE); AtlasDbVersion.ensureVersionReported(); Preconditions.checkArgument(rawKvs instanceof CassandraKeyValueService, "TimestampService must be created from an instance of" + " CassandraKeyValueService, found %s", rawKvs.getClass()); return PersistentTimestampServiceImpl.create( CassandraTimestampBoundStore.create((CassandraKeyValueService) rawKvs, initializeAsync), initializeAsync); }