use of com.github.ambry.config.RouterConfig in project ambry by linkedin.
the class ServerTestUtil method getSSLFactoryIfRequired.
/**
* Create an {@link SSLFactory} if there are SSL enabled datacenters in the properties
* @param verifiableProperties the {@link VerifiableProperties} to use.
* @return an {@link SSLFactory}, or {@code null}, if no {@link SSLFactory} is required.
* @throws Exception
*/
static SSLFactory getSSLFactoryIfRequired(VerifiableProperties verifiableProperties) throws Exception {
if (new RouterConfig(verifiableProperties).routerEnableHttp2NetworkClient) {
return new NettySslHttp2Factory(new SSLConfig(verifiableProperties));
}
ClusterMapConfig clusterMapConfig = new ClusterMapConfig(verifiableProperties);
boolean requiresSSL = clusterMapConfig.clusterMapSslEnabledDatacenters.length() > 0;
return requiresSSL ? SSLFactory.getNewInstance(new SSLConfig(verifiableProperties)) : null;
}
use of com.github.ambry.config.RouterConfig in project ambry by linkedin.
the class UndeleteOperationTrackerTest method getOperationTracker.
/**
* Returns {@link UndeleteOperationTracker}.
* @param parallelism the number of parallel requests that can be in flight.
* @return {@link UndeleteOperationTracker}.
*/
private UndeleteOperationTracker getOperationTracker(int parallelism) {
Properties props = new Properties();
props.setProperty(RouterConfig.ROUTER_HOSTNAME, "localhost");
props.setProperty(RouterConfig.ROUTER_DATACENTER_NAME, localDcName);
props.setProperty(RouterConfig.ROUTER_OPERATION_TRACKER_TERMINATE_ON_NOT_FOUND_ENABLED, "true");
props.setProperty(RouterConfig.ROUTER_GET_ELIGIBLE_REPLICAS_BY_STATE_ENABLED, Boolean.toString(replicasStateEnabled));
props.setProperty(RouterConfig.ROUTER_UNDELETE_REQUEST_PARALLELISM, Integer.toString(parallelism));
RouterConfig routerConfig = new RouterConfig(new VerifiableProperties(props));
NonBlockingRouterMetrics routerMetrics = new NonBlockingRouterMetrics(mockClusterMap, routerConfig);
return new UndeleteOperationTracker(routerConfig, mockPartition, originatingDcName, routerMetrics);
}
use of com.github.ambry.config.RouterConfig in project ambry by linkedin.
the class CommonTestUtils method getCurrentBlobIdVersion.
/**
* Get the current active blob id version via {@link RouterConfig}
* @return the current active blob id version.
*/
public static short getCurrentBlobIdVersion() {
Properties props = new Properties();
props.setProperty("router.hostname", "localhost");
props.setProperty("router.datacenter.name", "localDC");
return new RouterConfig(new VerifiableProperties(props)).routerBlobidCurrentVersion;
}
use of com.github.ambry.config.RouterConfig in project ambry by linkedin.
the class AdaptiveOperationTrackerTest method createRouterConfig.
/**
* Generate an instance of {@link RouterConfig} based on input parameters.
* @param crossColoEnabled {@code true} if cross colo needs to be enabled. {@code false} otherwise.
* @param successTarget the number of successful responses required for the operation to succeed.
* @param parallelism the number of parallel requests that can be in flight.
* @param maxInflightNum the maximum number of inflight requests for adaptive tracker.
* @param customPercentiles the custom percentiles to be reported. Percentiles are specified in a comma-separated
* string, i.e "0.94,0.96,0.97".
* @param excludeTimeout whether to exclude timed out requests in Histogram.
* @return an instance of {@link RouterConfig}
*/
private RouterConfig createRouterConfig(boolean crossColoEnabled, int successTarget, int parallelism, int maxInflightNum, String customPercentiles, boolean excludeTimeout) {
Properties props = new Properties();
props.setProperty("router.hostname", "localhost");
props.setProperty("router.datacenter.name", localDcName);
props.setProperty("router.get.cross.dc.enabled", Boolean.toString(crossColoEnabled));
props.setProperty("router.get.success.target", Integer.toString(successTarget));
props.setProperty("router.get.request.parallelism", Integer.toString(parallelism));
props.setProperty("router.get.include.non.originating.dc.replicas", "true");
props.setProperty("router.get.replicas.required", Integer.toString(Integer.MAX_VALUE));
props.setProperty("router.put.request.parallelism", Integer.toString(parallelism));
props.setProperty("router.put.success.target", Integer.toString(successTarget));
props.setProperty("router.latency.tolerance.quantile", Double.toString(QUANTILE));
props.setProperty("router.operation.tracker.metric.scope", trackerScope.toString());
props.setProperty("router.operation.tracker.max.inflight.requests", Integer.toString(maxInflightNum));
props.setProperty("router.operation.tracker.exclude.timeout.enabled", Boolean.toString(excludeTimeout));
props.setProperty(RouterConfig.ROUTER_ADAPTIVE_OPERATION_TRACKER_WAITING_FOR_RESPONSE, "true");
if (customPercentiles != null) {
props.setProperty("router.operation.tracker.custom.percentiles", customPercentiles);
}
return new RouterConfig(new VerifiableProperties(props));
}
use of com.github.ambry.config.RouterConfig in project ambry by linkedin.
the class AdaptiveOperationTrackerTest method customPercentilesMetricsRegistryTest.
/**
* Test that {@link NonBlockingRouterMetrics} can correctly register custom percentiles. An example of metric name is:
* "com.github.ambry.router.GetOperation.LocalColoLatencyMs.91.0.thPercentile"
*/
@Test
public void customPercentilesMetricsRegistryTest() {
// test that if custom percentile is not set, no corresponding metrics would be generated.
MetricRegistry metricRegistry = routerMetrics.getMetricRegistry();
MetricFilter filter = new MetricFilter() {
@Override
public boolean matches(String name, Metric metric) {
return name.endsWith("thPercentile");
}
};
SortedMap<String, Gauge> gauges = metricRegistry.getGauges(filter);
assertTrue("No gauges should be created because custom percentile is not set", gauges.isEmpty());
// test that dedicated gauges are correctly created for custom percentiles.
String customPercentiles = "0.91,0.97";
RouterConfig routerConfig = createRouterConfig(false, 1, 1, 6, customPercentiles, true);
String[] percentileArray = customPercentiles.split(",");
Arrays.sort(percentileArray);
List<String> sortedPercentiles = Arrays.stream(percentileArray).map(p -> String.valueOf(Double.parseDouble(p) * 100)).collect(Collectors.toList());
routerMetrics = new NonBlockingRouterMetrics(mockClusterMap, routerConfig);
gauges = routerMetrics.getMetricRegistry().getGauges(filter);
// Note that each percentile creates 4 metrics (GetBlobInfo/GetBlob joins LocalColo/CrossColo). So, the total number of
// metrics should equal to 4 * (# of given custom percentiles)
assertEquals("The number of custom percentile gauge doesn't match", sortedPercentiles.size() * 4, gauges.size());
Iterator mapItor = gauges.keySet().iterator();
Iterator<String> listItor = sortedPercentiles.iterator();
while (listItor.hasNext()) {
String gaugeName = (String) mapItor.next();
String percentileStr = listItor.next();
assertTrue("The gauge name doesn't match", gaugeName.endsWith(percentileStr + ".thPercentile"));
}
// reset router metrics to clean up registered custom percentile metrics
routerMetrics = new NonBlockingRouterMetrics(mockClusterMap, defaultRouterConfig);
}
Aggregations