use of com.github.ambry.config.RouterConfig in project ambry by linkedin.
the class MockRouterCallback method testTimeoutRequestUpdateHistogramByDefault.
/**
* Test that timed out requests are allowed to update Histogram by default.
*/
@Test
public void testTimeoutRequestUpdateHistogramByDefault() {
NonBlockingRouter.currentOperationsCount.incrementAndGet();
VerifiableProperties vprops = new VerifiableProperties(getNonBlockingRouterProperties(false));
RouterConfig routerConfig = new RouterConfig(vprops);
GetBlobInfoOperation op = new GetBlobInfoOperation(routerConfig, routerMetrics, mockClusterMap, responseHandler, blobId, options, null, routerCallback, kms, cryptoService, cryptoJobHandler, time, false, quotaChargeCallback);
requestRegistrationCallback.setRequestsToSend(new ArrayList<>());
op.poll(requestRegistrationCallback);
while (!op.isOperationComplete()) {
time.sleep(routerConfig.routerRequestTimeoutMs + 1);
op.poll(requestRegistrationCallback);
}
Assert.assertEquals("Must have attempted sending requests to all replicas", replicasCount, correlationIdToGetOperation.size());
Assert.assertEquals(RouterErrorCode.OperationTimedOut, ((RouterException) op.getOperationException()).getErrorCode());
assumeTrue(operationTrackerType.equals(AdaptiveOperationTracker.class.getSimpleName()));
AdaptiveOperationTracker tracker = (AdaptiveOperationTracker) op.getOperationTrackerInUse();
Assert.assertEquals("Number of data points in local colo latency histogram is not expected", 3, tracker.getLatencyHistogram(localReplica).getCount());
Assert.assertEquals("Number of data points in cross colo latency histogram is not expected", 6, tracker.getLatencyHistogram(remoteReplica).getCount());
}
use of com.github.ambry.config.RouterConfig in project ambry by linkedin.
the class MockRouterCallback method testTimeoutAndBlobNotFoundInOriginDc.
/**
* Test the case where origin replicas return Blob_Not_found and the rest times out.
* @throws Exception
*/
@Test
public void testTimeoutAndBlobNotFoundInOriginDc() throws Exception {
assumeTrue(operationTrackerType.equals(AdaptiveOperationTracker.class.getSimpleName()));
correlationIdToGetOperation.clear();
// Pick a remote DC as the new local DC.
String newLocal = "DC1";
String oldLocal = localDcName;
Properties props = getNonBlockingRouterProperties(true);
props.setProperty("router.datacenter.name", newLocal);
props.setProperty("router.get.request.parallelism", "3");
props.setProperty("router.operation.tracker.max.inflight.requests", "3");
routerConfig = new RouterConfig(new VerifiableProperties(props));
for (MockServer server : mockServerLayout.getMockServers()) {
if (server.getDataCenter().equals(oldLocal)) {
// for origin DC, always return Blob_Not_Found;
server.setServerErrorForAllRequests(ServerErrorCode.Blob_Not_Found);
} else {
// Randomly set something here, it will not be used.
server.setServerErrorForAllRequests(ServerErrorCode.No_Error);
}
}
NonBlockingRouter.currentOperationsCount.incrementAndGet();
GetBlobInfoOperation op = new GetBlobInfoOperation(routerConfig, routerMetrics, mockClusterMap, responseHandler, blobId, options, null, routerCallback, kms, cryptoService, cryptoJobHandler, time, false, quotaChargeCallback);
requestRegistrationCallback.setRequestsToSend(new ArrayList<>());
AdaptiveOperationTracker tracker = (AdaptiveOperationTracker) op.getOperationTrackerInUse();
// First three requests would come from local datacenter and they will all time out.
op.poll(requestRegistrationCallback);
Assert.assertEquals("There should only be as many requests at this point as requestParallelism", 3, correlationIdToGetOperation.size());
time.sleep(routerConfig.routerRequestTimeoutMs + 1);
completeOp(op);
RouterException routerException = (RouterException) op.getOperationException();
// error code should be OperationTimedOut because it precedes BlobDoesNotExist
Assert.assertEquals(RouterErrorCode.BlobDoesNotExist, routerException.getErrorCode());
props = getNonBlockingRouterProperties(true);
props.setProperty("router.datacenter.name", oldLocal);
props.setProperty("router.get.request.parallelism", Integer.toString(requestParallelism));
props.setProperty("router.operation.tracker.max.inflight.requests", "2");
routerConfig = new RouterConfig(new VerifiableProperties(props));
}
use of com.github.ambry.config.RouterConfig in project ambry by linkedin.
the class GetManagerTest method getNonBlockingRouter.
/**
* @return Return a {@link NonBlockingRouter} created with default {@link VerifiableProperties}
*/
private NonBlockingRouter getNonBlockingRouter() throws IOException, GeneralSecurityException, ReflectiveOperationException {
Properties properties = new Properties();
properties.setProperty("router.hostname", "localhost");
properties.setProperty("router.datacenter.name", "DC1");
properties.setProperty("router.max.put.chunk.size.bytes", Integer.toString(CHUNK_SIZE));
properties.setProperty("router.put.request.parallelism", Integer.toString(requestParallelism));
properties.setProperty("router.put.success.target", Integer.toString(successTarget));
properties.setProperty("router.metadata.content.version", String.valueOf(metadataContentVersion));
VerifiableProperties vProps = new VerifiableProperties(properties);
routerConfig = new RouterConfig(vProps);
router = new NonBlockingRouter(routerConfig, new NonBlockingRouterMetrics(mockClusterMap, routerConfig), new MockNetworkClientFactory(vProps, mockSelectorState, MAX_PORTS_PLAIN_TEXT, MAX_PORTS_SSL, CHECKOUT_TIMEOUT_MS, mockServerLayout, mockTime), new LoggingNotificationSystem(), mockClusterMap, kms, cryptoService, cryptoJobHandler, new InMemAccountService(false, true), mockTime, MockClusterMap.DEFAULT_PARTITION_CLASS);
resetEncryptionObjects();
return router;
}
use of com.github.ambry.config.RouterConfig in project ambry by linkedin.
the class NonBlockingRouterTestBase method setRouter.
/**
* Initialize and set the router with the given {@link Properties} and {@link MockServerLayout}
* @param props the {@link Properties}
* @param serverLayout the {@link MockServerLayout}.
* @param notificationSystem the {@link NotificationSystem} to use.
*/
protected void setRouter(Properties props, MockServerLayout serverLayout, NotificationSystem notificationSystem) throws Exception {
VerifiableProperties verifiableProperties = new VerifiableProperties((props));
routerConfig = new RouterConfig(verifiableProperties);
routerMetrics = new NonBlockingRouterMetrics(mockClusterMap, routerConfig);
router = new NonBlockingRouter(routerConfig, routerMetrics, new MockNetworkClientFactory(verifiableProperties, mockSelectorState, MAX_PORTS_PLAIN_TEXT, MAX_PORTS_SSL, CHECKOUT_TIMEOUT_MS, serverLayout, mockTime), notificationSystem, mockClusterMap, kms, cryptoService, cryptoJobHandler, accountService, mockTime, MockClusterMap.DEFAULT_PARTITION_CLASS);
}
use of com.github.ambry.config.RouterConfig in project ambry by linkedin.
the class GetBlobOperationTest method testTimeoutRequestUpdateHistogramByDefault.
/**
* Test that timed out requests are allowed to update Histogram by default.
* @throws Exception
*/
@Test
public void testTimeoutRequestUpdateHistogramByDefault() throws Exception {
doPut();
VerifiableProperties vprops = new VerifiableProperties(getDefaultNonBlockingRouterProperties(false));
RouterConfig routerConfig = new RouterConfig(vprops);
GetBlobOperation op = createOperation(routerConfig, null);
op.poll(requestRegistrationCallback);
while (!op.isOperationComplete()) {
time.sleep(routerConfig.routerRequestTimeoutMs + 1);
op.poll(requestRegistrationCallback);
}
Assert.assertEquals("Must have attempted sending requests to all replicas", replicasCount, correlationIdToGetOperation.size());
Assert.assertEquals(RouterErrorCode.OperationTimedOut, ((RouterException) op.getOperationException()).getErrorCode());
assumeTrue(operationTrackerType.equals(AdaptiveOperationTracker.class.getSimpleName()));
AdaptiveOperationTracker tracker = (AdaptiveOperationTracker) op.getFirstChunkOperationTrackerInUse();
Assert.assertEquals("Number of data points in local colo latency histogram is not expected", 3, tracker.getLatencyHistogram(RouterTestHelpers.getAnyReplica(blobId, true, localDcName)).getCount());
Assert.assertEquals("Number of data points in cross colo latency histogram is not expected", 6, tracker.getLatencyHistogram(RouterTestHelpers.getAnyReplica(blobId, false, localDcName)).getCount());
}
Aggregations