use of com.codahale.metrics.MetricRegistry in project cruise-control by linkedin.
the class SessionManagerTest method testSkipStep.
@Test(expected = IllegalArgumentException.class)
public void testSkipStep() {
TestContext context = prepareRequests(false, 1);
SessionManager sessionManager = new SessionManager(1, 1000, context.time(), new MetricRegistry());
HttpServletRequest request = context.request(0);
sessionManager.getAndCreateSessionIfNotExist(request, () -> null, 1);
}
use of com.codahale.metrics.MetricRegistry in project cruise-control by linkedin.
the class SessionManagerTest method testCreateSessionReachingCapacity.
@Test
public void testCreateSessionReachingCapacity() {
TestContext context = prepareRequests(false, 2);
SessionManager sessionManager = new SessionManager(1, 1000, context.time(), new MetricRegistry());
sessionManager.getAndCreateSessionIfNotExist(context.request(0), () -> new OperationFuture<>("testCreateSession"), 0);
assertEquals(1, sessionManager.numSessions());
assertNull(sessionManager.getFuture(context.request(1)));
// Adding same request again should have no impact
sessionManager.getAndCreateSessionIfNotExist(context.request(0), () -> new OperationFuture<>("testCreateSession"), 1);
assertEquals(1, sessionManager.numSessions());
try {
sessionManager.getAndCreateSessionIfNotExist(context.request(1), () -> new OperationFuture<>("testCreateSession"), 0);
fail("Should have thrown exception due to session capacity reached.");
} catch (RuntimeException e) {
// let it go.
}
}
use of com.codahale.metrics.MetricRegistry in project cruise-control by linkedin.
the class ExecutionTaskManagerTest method testStateChangeSequences.
@Test
public void testStateChangeSequences() {
TopicPartition tp = new TopicPartition("topic", 0);
ExecutionTaskManager taskManager = new ExecutionTaskManager(1, 1, new MetricRegistry());
List<List<ExecutionTask.State>> testSequences = new ArrayList<>();
// Completed successfully.
testSequences.add(Arrays.asList(IN_PROGRESS, COMPLETED));
// Rollback succeeded.
testSequences.add(Arrays.asList(IN_PROGRESS, ABORTING, ABORTED));
// Rollback failed.
testSequences.add(Arrays.asList(IN_PROGRESS, ABORTING, DEAD));
// Cannot rollback.
testSequences.add(Arrays.asList(IN_PROGRESS, DEAD));
for (List<ExecutionTask.State> sequence : testSequences) {
taskManager.clear();
// Make sure the proposal does not involve leader movement.
ExecutionProposal proposal = new ExecutionProposal(tp, 0, 2, Arrays.asList(0, 2), Arrays.asList(2, 1));
taskManager.addExecutionProposals(Collections.singletonList(proposal), Collections.emptySet(), generateExpectedCluster(proposal, tp));
List<ExecutionTask> tasks = taskManager.getReplicaMovementTasks();
assertEquals(1, tasks.size());
ExecutionTask task = tasks.get(0);
verifyStateChangeSequence(sequence, task, taskManager);
}
}
use of com.codahale.metrics.MetricRegistry in project Singularity by HubSpot.
the class GuicePropertyFilteringMessageBodyWriter method getMetricRegistry.
private MetricRegistry getMetricRegistry() {
MetricRegistry registry = environment.metrics();
if (registry == null) {
LOG.warn("No environment metrics found!");
registry = SharedMetricRegistries.getOrCreate("com.hubspot");
}
return registry;
}
use of com.codahale.metrics.MetricRegistry in project Singularity by HubSpot.
the class SingularityRunnerBaseModule method configure.
@Override
protected void configure() {
bind(ObjectMapper.class).toInstance(JavaUtils.newObjectMapper());
bind(MetricRegistry.class).toInstance(new MetricRegistry());
SingularityRunnerBaseLogging.quietEagerLogging();
bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator());
bind(SingularityRunnerExceptionNotifier.class).in(Scopes.SINGLETON);
final Optional<String> consolidatedConfigFilename = Optional.fromNullable(Strings.emptyToNull(System.getProperty(CONFIG_PROPERTY)));
final ConfigurationBinder configurationBinder = ConfigurationBinder.newBinder(binder());
configurationBinder.bindPrimaryConfiguration(primaryConfigurationClass, consolidatedConfigFilename);
for (Class<? extends BaseRunnerConfiguration> additionalConfigurationClass : additionalConfigurationClasses) {
configurationBinder.bindConfiguration(additionalConfigurationClass, consolidatedConfigFilename);
}
if (!additionalConfigurationClasses.contains(SingularityRunnerBaseConfiguration.class)) {
configurationBinder.bindConfiguration(SingularityRunnerBaseConfiguration.class, consolidatedConfigFilename);
}
bind(SingularityRunnerBaseLogging.class).asEagerSingleton();
bind(new TypeLiteral<Optional<String>>() {
}).annotatedWith(Names.named(CONSOLIDATED_CONFIG_FILENAME)).toInstance(consolidatedConfigFilename);
}
Aggregations