use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class DefaultDriverContext method buildRequestTracker.
protected RequestTracker buildRequestTracker(RequestTracker requestTrackerFromBuilder) {
List<RequestTracker> trackers = new ArrayList<>();
if (requestTrackerFromBuilder != null) {
trackers.add(requestTrackerFromBuilder);
}
for (LoadBalancingPolicy lbp : this.getLoadBalancingPolicies().values()) {
lbp.getRequestTracker().ifPresent(trackers::add);
}
DefaultDriverOption newOption = DefaultDriverOption.REQUEST_TRACKER_CLASSES;
@SuppressWarnings("deprecation") DefaultDriverOption legacyOption = DefaultDriverOption.REQUEST_TRACKER_CLASS;
DriverExecutionProfile profile = config.getDefaultProfile();
if (profile.isDefined(newOption)) {
trackers.addAll(Reflection.buildFromConfigList(this, newOption, RequestTracker.class, "com.datastax.oss.driver.internal.core.tracker"));
}
if (profile.isDefined(legacyOption)) {
LOG.warn("Option {} has been deprecated and will be removed in a future release; please use option {} instead.", legacyOption, newOption);
Reflection.buildFromConfig(this, legacyOption, RequestTracker.class, "com.datastax.oss.driver.internal.core.tracker").ifPresent(trackers::add);
}
if (trackers.isEmpty()) {
return new NoopRequestTracker(this);
} else if (trackers.size() == 1) {
return trackers.get(0);
} else {
return new MultiplexingRequestTracker(trackers);
}
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class Conversions method resolveIdempotence.
public static boolean resolveIdempotence(Request request, InternalDriverContext context) {
Boolean requestIsIdempotent = request.isIdempotent();
DriverExecutionProfile executionProfile = resolveExecutionProfile(request, context);
return (requestIsIdempotent == null) ? executionProfile.getBoolean(DefaultDriverOption.REQUEST_DEFAULT_IDEMPOTENCE) : requestIsIdempotent;
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class MonotonicTimestampGenerator method buildClock.
private static Clock buildClock(DriverContext context) {
DriverExecutionProfile config = context.getConfig().getDefaultProfile();
boolean forceJavaClock = config.getBoolean(DefaultDriverOption.TIMESTAMP_GENERATOR_FORCE_JAVA_CLOCK, false);
return Clock.getInstance(forceJavaClock);
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class DefaultSchemaQueriesFactoryTest method buildFactory.
private DefaultSchemaQueriesFactory buildFactory() {
final DriverExecutionProfile mockProfile = mock(DriverExecutionProfile.class);
final DriverConfig mockConfig = mock(DriverConfig.class);
when(mockConfig.getDefaultProfile()).thenReturn(mockProfile);
final InternalDriverContext mockInternalCtx = mock(InternalDriverContext.class);
when(mockInternalCtx.getConfig()).thenReturn(mockConfig);
return new DefaultSchemaQueriesFactory(mockInternalCtx);
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class DropwizardNodeMetricUpdaterTest method should_log_warning_when_provided_eviction_time_setting_is_too_low.
@Test
public void should_log_warning_when_provided_eviction_time_setting_is_too_low() {
// given
LoggerTest.LoggerSetup logger = LoggerTest.setupTestLogger(AbstractMetricUpdater.class, Level.WARN);
Node node = mock(Node.class);
InternalDriverContext context = mock(InternalDriverContext.class);
DriverExecutionProfile profile = mock(DriverExecutionProfile.class);
DriverConfig config = mock(DriverConfig.class);
Set<NodeMetric> enabledMetrics = Collections.singleton(DefaultNodeMetric.CQL_MESSAGES);
Duration expireAfter = AbstractMetricUpdater.MIN_EXPIRE_AFTER.minusMinutes(1);
// when
when(context.getSessionName()).thenReturn("prefix");
when(context.getConfig()).thenReturn(config);
when(config.getDefaultProfile()).thenReturn(profile);
when(profile.getDuration(DefaultDriverOption.METRICS_NODE_EXPIRE_AFTER)).thenReturn(expireAfter);
DropwizardNodeMetricUpdater updater = new DropwizardNodeMetricUpdater(node, context, enabledMetrics, new MetricRegistry()) {
@Override
protected void initializeGauge(NodeMetric metric, DriverExecutionProfile profile, Supplier<Number> supplier) {
// do nothing
}
@Override
protected void initializeCounter(NodeMetric metric, DriverExecutionProfile profile) {
// do nothing
}
@Override
protected void initializeHdrTimer(NodeMetric metric, DriverExecutionProfile profile, DriverOption highestLatency, DriverOption significantDigits, DriverOption interval) {
// do nothing
}
};
// then
assertThat(updater.getExpireAfter()).isEqualTo(AbstractMetricUpdater.MIN_EXPIRE_AFTER);
verify(logger.appender, timeout(500).times(1)).doAppend(logger.loggingEventCaptor.capture());
assertThat(logger.loggingEventCaptor.getValue().getMessage()).isNotNull();
assertThat(logger.loggingEventCaptor.getValue().getFormattedMessage()).contains(String.format("[prefix] Value too low for %s: %s. Forcing to %s instead.", DefaultDriverOption.METRICS_NODE_EXPIRE_AFTER.getPath(), expireAfter, AbstractMetricUpdater.MIN_EXPIRE_AFTER));
}
Aggregations