Skip to content

Commit

Permalink
Fix NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
cgtz committed Nov 26, 2019
1 parent 59b21ba commit f93708d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class RouterConfig {

public static final String DEFAULT_KMS_FACTORY = "com.github.ambry.router.SingleKeyManagementServiceFactory";
public static final String DEFAULT_CRYPTO_SERVICE_FACTORY = "com.github.ambry.router.GCMCryptoServiceFactory";
public static final double DEFAULT_LATENCY_TOLERANCE_QUANTILE = 0.9;
public static final long DEFAULT_OPERATION_TRACKER_HISTOGRAM_CACHE_TIMEOUT = 1000L;

// config keys
public static final String ROUTER_SCALING_UNIT_COUNT = "router.scaling.unit.count";
Expand Down Expand Up @@ -483,7 +485,8 @@ public RouterConfig(VerifiableProperties verifiableProperties) {
routerGetOperationTrackerType =
verifiableProperties.getString(ROUTER_GET_OPERATION_TRACKER_TYPE, "SimpleOperationTracker");
routerLatencyToleranceQuantile =
verifiableProperties.getDoubleInRange(ROUTER_LATENCY_TOLERANCE_QUANTILE, 0.9, 0.0, 1.0);
verifiableProperties.getDoubleInRange(ROUTER_LATENCY_TOLERANCE_QUANTILE, DEFAULT_LATENCY_TOLERANCE_QUANTILE,
0.0, 1.0);
routerBlobidCurrentVersion =
verifiableProperties.getShortFromAllowedValues(ROUTER_BLOBID_CURRENT_VERSION, (short) 6,
new Short[]{1, 2, 3, 4, 5, 6});
Expand Down Expand Up @@ -522,7 +525,8 @@ public RouterConfig(VerifiableProperties verifiableProperties) {
routerOperationTrackerHistogramDumpPeriod =
verifiableProperties.getLongInRange(ROUTER_OPERATION_TRACKER_HISTOGRAM_DUMP_PERIOD, 600L, 1L, Long.MAX_VALUE);
routerOperationTrackerHistogramCacheTimeoutMs =
verifiableProperties.getLong(ROUTER_OPERATION_TRACKER_HISTOGRAM_CACHE_TIMEOUT_MS, 1000L);
verifiableProperties.getLong(ROUTER_OPERATION_TRACKER_HISTOGRAM_CACHE_TIMEOUT_MS,
DEFAULT_OPERATION_TRACKER_HISTOGRAM_CACHE_TIMEOUT);
if (routerGetRequestParallelism > routerOperationTrackerMaxInflightRequests) {
throw new IllegalArgumentException(
"Operation tracker parallelism is larger than operation tracker max inflight number");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,24 @@ private void initializeResourceToHistogramMap(ClusterMap clusterMap, RouterConfi
* @return a configured {@link CachedHistogram}.
*/
private static CachedHistogram createHistogram(RouterConfig routerConfig, boolean useDefaultReservoirParams) {
Reservoir reservoir = useDefaultReservoirParams ? new ExponentiallyDecayingReservoir()
: new ExponentiallyDecayingReservoir(routerConfig.routerOperationTrackerReservoirSize,
Reservoir reservoir;
long cacheTimeoutMs;
double quantile;
if (routerConfig != null) {
if (useDefaultReservoirParams) {
reservoir = new ExponentiallyDecayingReservoir();
} else {
reservoir = new ExponentiallyDecayingReservoir(routerConfig.routerOperationTrackerReservoirSize,
routerConfig.routerOperationTrackerReservoirDecayFactor);
return new CachedHistogram(reservoir, routerConfig.routerOperationTrackerHistogramCacheTimeoutMs,
routerConfig.routerLatencyToleranceQuantile);
}
cacheTimeoutMs = routerConfig.routerOperationTrackerHistogramCacheTimeoutMs;
quantile = routerConfig.routerLatencyToleranceQuantile;
} else {
reservoir = new ExponentiallyDecayingReservoir();
cacheTimeoutMs = RouterConfig.DEFAULT_OPERATION_TRACKER_HISTOGRAM_CACHE_TIMEOUT;
quantile = RouterConfig.DEFAULT_LATENCY_TOLERANCE_QUANTILE;
}
return new CachedHistogram(reservoir, cacheTimeoutMs, quantile);
}

/**
Expand Down

0 comments on commit f93708d

Please sign in to comment.