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 NonBlockingRouterTest method setRouter.
/**
* Initialize and set the router with the given {@link Properties} and {@link MockServerLayout}
* @param props the {@link Properties}
* @param mockServerLayout the {@link MockServerLayout}
*/
private void setRouter(Properties props, MockServerLayout mockServerLayout) throws IOException {
VerifiableProperties verifiableProperties = new VerifiableProperties((props));
routerMetrics = new NonBlockingRouterMetrics(mockClusterMap);
router = new NonBlockingRouter(new RouterConfig(verifiableProperties), routerMetrics, new MockNetworkClientFactory(verifiableProperties, null, MAX_PORTS_PLAIN_TEXT, MAX_PORTS_SSL, CHECKOUT_TIMEOUT_MS, mockServerLayout, mockTime), new LoggingNotificationSystem(), mockClusterMap, kms, cryptoService, cryptoJobHandler, mockTime);
}
use of com.github.ambry.config.RouterConfig in project ambry by linkedin.
the class NonBlockingRouterTest method testCompositeBlobDataChunksDelete.
/**
* Test that if a composite blob is deleted, the data chunks are eventually deleted. Also check the service IDs used
* for delete operations.
*/
@Test
public void testCompositeBlobDataChunksDelete() throws Exception {
// Ensure there are 4 chunks.
maxPutChunkSize = PUT_CONTENT_SIZE / 4;
Properties props = getNonBlockingRouterProperties("DC1");
VerifiableProperties verifiableProperties = new VerifiableProperties((props));
RouterConfig routerConfig = new RouterConfig(verifiableProperties);
MockClusterMap mockClusterMap = new MockClusterMap();
MockTime mockTime = new MockTime();
MockServerLayout mockServerLayout = new MockServerLayout(mockClusterMap);
// metadata blob + data chunks.
final AtomicReference<CountDownLatch> deletesDoneLatch = new AtomicReference<>();
final Map<String, String> blobsThatAreDeleted = new HashMap<>();
LoggingNotificationSystem deleteTrackingNotificationSystem = new LoggingNotificationSystem() {
@Override
public void onBlobDeleted(String blobId, String serviceId) {
blobsThatAreDeleted.put(blobId, serviceId);
deletesDoneLatch.get().countDown();
}
};
router = new NonBlockingRouter(routerConfig, new NonBlockingRouterMetrics(mockClusterMap), new MockNetworkClientFactory(verifiableProperties, mockSelectorState, MAX_PORTS_PLAIN_TEXT, MAX_PORTS_SSL, CHECKOUT_TIMEOUT_MS, mockServerLayout, mockTime), deleteTrackingNotificationSystem, mockClusterMap, kms, cryptoService, cryptoJobHandler, mockTime);
setOperationParams();
String blobId = router.putBlob(putBlobProperties, putUserMetadata, putChannel).get();
String deleteServiceId = "delete-service";
Set<String> blobsToBeDeleted = getBlobsInServers(mockServerLayout);
int getRequestCount = mockServerLayout.getCount(RequestOrResponseType.GetRequest);
// The third iteration is to test the case where the blob has expired.
for (int i = 0; i < 3; i++) {
if (i == 2) {
// Create a clean cluster and put another blob that immediate expires.
setOperationParams();
putBlobProperties = new BlobProperties(-1, "serviceId", "memberId", "contentType", false, 0, Utils.getRandomShort(TestUtils.RANDOM), Utils.getRandomShort(TestUtils.RANDOM), false);
blobId = router.putBlob(putBlobProperties, putUserMetadata, putChannel).get();
Set<String> allBlobsInServer = getBlobsInServers(mockServerLayout);
allBlobsInServer.removeAll(blobsToBeDeleted);
blobsToBeDeleted = allBlobsInServer;
}
blobsThatAreDeleted.clear();
deletesDoneLatch.set(new CountDownLatch(5));
router.deleteBlob(blobId, deleteServiceId, null).get();
Assert.assertTrue("Deletes should not take longer than " + AWAIT_TIMEOUT_MS, deletesDoneLatch.get().await(AWAIT_TIMEOUT_MS, TimeUnit.MILLISECONDS));
Assert.assertTrue("All blobs in server are deleted", blobsThatAreDeleted.keySet().containsAll(blobsToBeDeleted));
Assert.assertTrue("Only blobs in server are deleted", blobsToBeDeleted.containsAll(blobsThatAreDeleted.keySet()));
for (Map.Entry<String, String> blobIdAndServiceId : blobsThatAreDeleted.entrySet()) {
String expectedServiceId = blobIdAndServiceId.getKey().equals(blobId) ? deleteServiceId : BackgroundDeleteRequest.SERVICE_ID_PREFIX + deleteServiceId;
Assert.assertEquals("Unexpected service ID for deleted blob", expectedServiceId, blobIdAndServiceId.getValue());
}
// For 1 chunk deletion attempt, 1 background operation for Get is initiated which results in 2 Get Requests at
// the servers.
getRequestCount += 2;
Assert.assertEquals("Only one attempt of chunk deletion should have been done", getRequestCount, mockServerLayout.getCount(RequestOrResponseType.GetRequest));
}
deletesDoneLatch.set(new CountDownLatch(5));
router.deleteBlob(blobId, null, null).get();
Assert.assertTrue("Deletes should not take longer than " + AWAIT_TIMEOUT_MS, deletesDoneLatch.get().await(AWAIT_TIMEOUT_MS, TimeUnit.MILLISECONDS));
router.close();
assertClosed();
Assert.assertEquals("All operations should have completed", 0, router.getOperationsCount());
}
use of com.github.ambry.config.RouterConfig in project ambry by linkedin.
the class ConnectionTrackerTest method initialize.
@Before
public void initialize() {
Properties props = new Properties();
props.setProperty("router.hostname", "localhost");
props.setProperty("router.datacenter.name", "DC1");
props.setProperty("router.scaling.unit.max.connections.per.port.plain.text", "3");
props.setProperty("router.scaling.unit.max.connections.per.port.ssl", "2");
verifiableProperties = new VerifiableProperties((props));
routerConfig = new RouterConfig(verifiableProperties);
networkConfig = new NetworkConfig(verifiableProperties);
time = new MockTime();
plainTextPort = new Port(100, PortType.PLAINTEXT);
sslPort = new Port(200, PortType.SSL);
}
Aggregations