Search in sources :

Example 1 with RouterConfig

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;
}
Also used : SSLConfig(com.github.ambry.config.SSLConfig) NettySslHttp2Factory(com.github.ambry.commons.NettySslHttp2Factory) RouterConfig(com.github.ambry.config.RouterConfig) ClusterMapConfig(com.github.ambry.config.ClusterMapConfig)

Example 2 with RouterConfig

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);
}
Also used : VerifiableProperties(com.github.ambry.config.VerifiableProperties) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) RouterConfig(com.github.ambry.config.RouterConfig)

Example 3 with RouterConfig

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;
}
Also used : VerifiableProperties(com.github.ambry.config.VerifiableProperties) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) RouterConfig(com.github.ambry.config.RouterConfig)

Example 4 with RouterConfig

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));
}
Also used : VerifiableProperties(com.github.ambry.config.VerifiableProperties) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) RouterConfig(com.github.ambry.config.RouterConfig)

Example 5 with RouterConfig

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);
}
Also used : Histogram(com.codahale.metrics.Histogram) Arrays(java.util.Arrays) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) MockReplicaId(com.github.ambry.clustermap.MockReplicaId) PortType(com.github.ambry.network.PortType) TestUtils(com.github.ambry.utils.TestUtils) Map(java.util.Map) Counter(com.codahale.metrics.Counter) MetricFilter(com.codahale.metrics.MetricFilter) LinkedList(java.util.LinkedList) Time(com.github.ambry.utils.Time) MockDataNodeId(com.github.ambry.clustermap.MockDataNodeId) Resource(com.github.ambry.clustermap.Resource) MetricRegistry(com.codahale.metrics.MetricRegistry) Properties(java.util.Properties) Pair(com.github.ambry.utils.Pair) Iterator(java.util.Iterator) VerifiableProperties(com.github.ambry.config.VerifiableProperties) Metric(com.codahale.metrics.Metric) Set(java.util.Set) Utils(com.github.ambry.utils.Utils) Test(org.junit.Test) MockPartitionId(com.github.ambry.clustermap.MockPartitionId) Collectors(java.util.stream.Collectors) RouterConfig(com.github.ambry.config.RouterConfig) List(java.util.List) MockTime(com.github.ambry.utils.MockTime) ReplicaId(com.github.ambry.clustermap.ReplicaId) Gauge(com.codahale.metrics.Gauge) Port(com.github.ambry.network.Port) Assert(org.junit.Assert) CachedHistogram(com.github.ambry.utils.CachedHistogram) Collections(java.util.Collections) MockClusterMap(com.github.ambry.clustermap.MockClusterMap) PartitionId(com.github.ambry.clustermap.PartitionId) SortedMap(java.util.SortedMap) MetricRegistry(com.codahale.metrics.MetricRegistry) RouterConfig(com.github.ambry.config.RouterConfig) Gauge(com.codahale.metrics.Gauge) MetricFilter(com.codahale.metrics.MetricFilter) Iterator(java.util.Iterator) Metric(com.codahale.metrics.Metric) Test(org.junit.Test)

Aggregations

RouterConfig (com.github.ambry.config.RouterConfig)43 VerifiableProperties (com.github.ambry.config.VerifiableProperties)39 Properties (java.util.Properties)29 Test (org.junit.Test)28 BlobProperties (com.github.ambry.messageformat.BlobProperties)21 LoggingNotificationSystem (com.github.ambry.commons.LoggingNotificationSystem)18 MockClusterMap (com.github.ambry.clustermap.MockClusterMap)15 MockTime (com.github.ambry.utils.MockTime)12 ArrayList (java.util.ArrayList)12 InMemAccountService (com.github.ambry.account.InMemAccountService)10 PutManagerTest (com.github.ambry.router.PutManagerTest)10 ServerErrorCode (com.github.ambry.server.ServerErrorCode)9 HashMap (java.util.HashMap)8 Map (java.util.Map)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 MockDataNodeId (com.github.ambry.clustermap.MockDataNodeId)7 BlobId (com.github.ambry.commons.BlobId)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 ReplicaId (com.github.ambry.clustermap.ReplicaId)5 ResponseHandler (com.github.ambry.commons.ResponseHandler)5