use of com.palantir.atlasdb.util.MetricsManager in project atlasdb by palantir.
the class TargetedSweepMetricsTest method canReportMetricsSeparatelyToDifferentManagers.
@Test
public void canReportMetricsSeparatelyToDifferentManagers() {
metrics.updateEnqueuedWrites(CONS_ZERO, 10);
metrics.updateEntriesRead(CONS_ZERO, 21);
metrics.updateNumberOfTombstones(CONS_ZERO, 1);
metrics.updateAbortedWritesDeleted(CONS_ZERO, 2);
metrics.updateSweepTimestamp(CONS_ZERO, 7);
metrics.registerEntriesReadInBatch(CONS_ZERO, 20);
MetricsManager anotherMetricsManager = MetricsManagers.createForTests();
TargetedSweepMetrics secondMetrics = TargetedSweepMetrics.createWithClock(anotherMetricsManager, kvs, () -> clockTime, METRICS_CONFIGURATION, 8);
secondMetrics.updateEnqueuedWrites(CONS_ZERO, 5);
secondMetrics.updateEntriesRead(CONS_ZERO, 5);
secondMetrics.updateNumberOfTombstones(CONS_ZERO, 5);
secondMetrics.updateAbortedWritesDeleted(CONS_ZERO, 5);
secondMetrics.updateSweepTimestamp(CONS_ZERO, 5);
secondMetrics.registerEntriesReadInBatch(CONS_ZERO, 15);
assertThat(metricsManager).hasEnqueuedWritesConservativeEqualTo(10);
assertThat(metricsManager).hasEntriesReadConservativeEqualTo(21);
assertThat(metricsManager).hasTombstonesPutConservativeEqualTo(1);
assertThat(metricsManager).hasAbortedWritesDeletedConservativeEquals(2);
assertThat(metricsManager).hasSweepTimestampConservativeEqualTo(7L);
assertThat(metricsManager).containsEntriesReadInBatchConservative(20L);
assertThat(anotherMetricsManager).hasEnqueuedWritesConservativeEqualTo(5);
assertThat(anotherMetricsManager).hasEntriesReadConservativeEqualTo(5);
assertThat(anotherMetricsManager).hasTombstonesPutConservativeEqualTo(5);
assertThat(anotherMetricsManager).hasAbortedWritesDeletedConservativeEquals(5);
assertThat(anotherMetricsManager).hasSweepTimestampConservativeEqualTo(5L);
assertThat(anotherMetricsManager).containsEntriesReadInBatchConservative(15L);
}
use of com.palantir.atlasdb.util.MetricsManager in project atlasdb by palantir.
the class AbstractTargetedSweepTest method setup.
@Before
@Override
public void setup() {
super.setup();
MetricsManager metricsManager = MetricsManagers.createForTests();
sweepQueue = TargetedSweeper.createUninitializedForTest(metricsManager, () -> ImmutableTargetedSweepRuntimeConfig.builder().shards(1).maximumPartitionsToBatchInSingleRead(8).build());
sweepQueue.initializeWithoutRunning(timestampsSupplier, mock(TimelockService.class), kvs, txService, mock(TargetedSweepFollower.class));
}
use of com.palantir.atlasdb.util.MetricsManager in project atlasdb by palantir.
the class SweepTestUtils method setupTxManager.
public static TransactionManager setupTxManager(KeyValueService kvs, TimelockService legacyTimelockService, TimestampManagementService tsmService, SweepStrategyManager ssm, TransactionService txService) {
MetricsManager metricsManager = MetricsManagers.createForTests();
LockService lockService = LockServiceImpl.create(LockServerOptions.builder().isStandaloneServer(false).build());
Supplier<AtlasDbConstraintCheckingMode> constraints = () -> AtlasDbConstraintCheckingMode.NO_CONSTRAINT_CHECKING;
ConflictDetectionManager cdm = ConflictDetectionManagers.createWithoutWarmingCache(kvs);
Cleaner cleaner = new NoOpCleaner();
MultiTableSweepQueueWriter writer = TargetedSweeper.createUninitializedForTest(() -> 1);
TransactionManager txManager = SerializableTransactionManager.createForTest(metricsManager, kvs, legacyTimelockService, tsmService, lockService, NoOpLockWatchManager.create(), txService, constraints, cdm, ssm, cleaner, AbstractTransactionTest.GET_RANGES_THREAD_POOL_SIZE, AbstractTransactionTest.DEFAULT_GET_RANGES_CONCURRENCY, writer);
setupTables(kvs);
writer.initialize(txManager);
return txManager;
}
use of com.palantir.atlasdb.util.MetricsManager in project atlasdb by palantir.
the class TimeLockAgent method createAndRegisterResources.
private void createAndRegisterResources() {
registerTimeLockCorruptionJerseyFilter();
registerTimeLockCorruptionNotifiers();
registerPaxosResource();
registerExceptionMappers();
registerClientFeedbackService();
namespaces = new TimelockNamespaces(metricsManager, this::createInvalidatingTimeLockServices, Suppliers.compose(TimeLockRuntimeConfiguration::maxNumberOfClients, runtime::get), DisabledNamespaces.create(sqliteDataSource));
registerManagementResource();
// Finally, register the health check, and endpoints associated with the clients.
TimeLockResource resource = TimeLockResource.create(namespaces);
healthCheck = paxosResources.leadershipComponents().healthCheck(namespaces::getActiveClients);
registrar.accept(resource);
Function<String, LockService> lockServiceGetter = namespace -> namespaces.get(namespace).getLockService();
Function<String, AsyncTimelockService> asyncTimelockServiceGetter = namespace -> namespaces.get(namespace).getTimelockService();
Function<String, BackupTimeLockServiceView> backupTimeLockServiceViewGetter = namespace -> namespaces.getForRestore(namespace);
AuthHeaderValidator authHeaderValidator = getAuthHeaderValidator();
RedirectRetryTargeter redirectRetryTargeter = redirectRetryTargeter();
if (undertowRegistrar.isPresent()) {
Consumer<UndertowService> presentUndertowRegistrar = undertowRegistrar.get();
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, ConjureTimelockResource.undertow(redirectRetryTargeter, asyncTimelockServiceGetter));
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, ConjureLockWatchingResource.undertow(redirectRetryTargeter, asyncTimelockServiceGetter));
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, ConjureLockV1Resource.undertow(redirectRetryTargeter, lockServiceGetter));
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, TimeLockPaxosHistoryProviderResource.undertow(corruptionComponents.localHistoryLoader()));
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, MultiClientConjureTimelockResource.undertow(redirectRetryTargeter, asyncTimelockServiceGetter));
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, AtlasBackupResource.undertow(authHeaderValidator, redirectRetryTargeter, asyncTimelockServiceGetter));
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, AtlasRestoreResource.undertow(authHeaderValidator, redirectRetryTargeter, backupTimeLockServiceViewGetter));
registerCorruptionHandlerWrappedService(presentUndertowRegistrar, DisabledNamespacesUpdaterResource.undertow(authHeaderValidator, redirectRetryTargeter, namespaces));
} else {
registrar.accept(ConjureTimelockResource.jersey(redirectRetryTargeter, asyncTimelockServiceGetter));
registrar.accept(ConjureLockWatchingResource.jersey(redirectRetryTargeter, asyncTimelockServiceGetter));
registrar.accept(ConjureLockV1Resource.jersey(redirectRetryTargeter, lockServiceGetter));
registrar.accept(TimeLockPaxosHistoryProviderResource.jersey(corruptionComponents.localHistoryLoader()));
registrar.accept(MultiClientConjureTimelockResource.jersey(redirectRetryTargeter, asyncTimelockServiceGetter));
registrar.accept(AtlasBackupResource.jersey(authHeaderValidator, redirectRetryTargeter, asyncTimelockServiceGetter));
registrar.accept(AtlasRestoreResource.jersey(authHeaderValidator, redirectRetryTargeter, backupTimeLockServiceViewGetter));
registrar.accept(DisabledNamespacesUpdaterResource.jersey(authHeaderValidator, redirectRetryTargeter, namespaces));
}
}
use of com.palantir.atlasdb.util.MetricsManager in project atlasdb by palantir.
the class TimeLockServerLauncher method run.
@Override
public void run(CombinedTimeLockServerConfiguration configuration, Environment environment) throws JsonProcessingException {
environment.getObjectMapper().registerModule(new Jdk8Module()).registerModule(new JavaTimeModule());
environment.jersey().register(ConjureJerseyFeature.INSTANCE);
environment.jersey().register(new EmptyOptionalTo204ExceptionMapper());
MetricsManager metricsManager = MetricsManagers.of(environment.metrics(), taggedMetricRegistry);
Consumer<Object> registrar = component -> environment.jersey().register(component);
log.info("Paxos configuration\n{}", UnsafeArg.of("paxosConfig", environment.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(configuration.install().paxos())));
TimeLockRuntimeConfiguration runtime = configuration.runtime();
TimeLockAgent timeLockAgent = TimeLockAgent.create(metricsManager, configuration.install(), // this won't actually live reload
Refreshable.only(runtime), runtime.clusterSnapshot(), USER_AGENT, CombinedTimeLockServerConfiguration.threadPoolSize(), CombinedTimeLockServerConfiguration.blockingTimeoutMs(), registrar, Optional.empty(), OrderableSlsVersion.valueOf("0.0.0"), environment.getObjectMapper(), () -> System.exit(0));
environment.lifecycle().manage(new Managed() {
@Override
public void start() {
}
@Override
public void stop() {
}
});
environment.lifecycle().addLifeCycleListener(new LifeCycle.Listener() {
@Override
public void lifeCycleStarting(LifeCycle event) {
}
@Override
public void lifeCycleStarted(LifeCycle event) {
}
@Override
public void lifeCycleFailure(LifeCycle event, Throwable cause) {
shutdownFuture.setException(cause);
}
@Override
public void lifeCycleStopping(LifeCycle event) {
}
@Override
public void lifeCycleStopped(LifeCycle event) {
timeLockAgent.shutdown();
shutdownFuture.set(null);
}
});
}
Aggregations