use of com.github.ambry.config.VerifiableProperties in project ambry by linkedin.
the class NonBlockingRouterTest method getNonBlockingRouterProperties.
/**
* Constructs and returns a VerifiableProperties instance with the defaults required for instantiating
* the {@link NonBlockingRouter}.
* @return the created VerifiableProperties instance.
*/
private Properties getNonBlockingRouterProperties(String routerDataCenter) {
Properties properties = new Properties();
properties.setProperty("router.hostname", "localhost");
properties.setProperty("router.datacenter.name", routerDataCenter);
properties.setProperty("router.put.request.parallelism", Integer.toString(PUT_REQUEST_PARALLELISM));
properties.setProperty("router.put.success.target", Integer.toString(PUT_SUCCESS_TARGET));
properties.setProperty("router.max.put.chunk.size.bytes", Integer.toString(maxPutChunkSize));
properties.setProperty("router.get.request.parallelism", Integer.toString(GET_REQUEST_PARALLELISM));
properties.setProperty("router.get.success.target", Integer.toString(GET_SUCCESS_TARGET));
properties.setProperty("router.delete.request.parallelism", Integer.toString(DELETE_REQUEST_PARALLELISM));
properties.setProperty("router.delete.success.target", Integer.toString(DELETE_SUCCESS_TARGET));
properties.setProperty("router.connection.checkout.timeout.ms", Integer.toString(CHECKOUT_TIMEOUT_MS));
properties.setProperty("router.request.timeout.ms", Integer.toString(REQUEST_TIMEOUT_MS));
properties.setProperty("clustermap.cluster.name", "test");
properties.setProperty("clustermap.datacenter.name", "dc1");
properties.setProperty("clustermap.host.name", "localhost");
properties.setProperty("kms.default.container.key", TestUtils.getRandomKey(128));
return properties;
}
use of com.github.ambry.config.VerifiableProperties in project ambry by linkedin.
the class MockReadableStreamChannel method testFailureOnKMS.
/**
* Tests a failure scenario where connects to server nodes throw exceptions.
*/
@Test
public void testFailureOnKMS() throws Exception {
if (testEncryption) {
setupEncryptionCast(new VerifiableProperties(new Properties()));
instantiateEncryptionCast = false;
kms.exceptionToThrow.set(GSE);
// simple blob
requestAndResultsList.clear();
requestAndResultsList.add(new RequestAndResult(random.nextInt(chunkSize) + 1));
Exception expectedException = new RouterException("", GSE, RouterErrorCode.UnexpectedInternalError);
submitPutsAndAssertFailure(expectedException, false, true, true);
// this should not close the router.
Assert.assertTrue("Router should not be closed", router.isOpen());
assertCloseCleanup();
setupEncryptionCast(new VerifiableProperties(new Properties()));
instantiateEncryptionCast = false;
kms.exceptionToThrow.set(GSE);
// composite blob
requestAndResultsList.clear();
requestAndResultsList.add(new RequestAndResult(chunkSize * random.nextInt(10)));
submitPutsAndAssertFailure(expectedException, false, true, true);
// this should not close the router.
Assert.assertTrue("Router should not be closed", router.isOpen());
assertCloseCleanup();
}
}
use of com.github.ambry.config.VerifiableProperties in project ambry by linkedin.
the class RouterFactoryTest method testRouterFactory.
/**
* Tests the instantiation of a {@link Router} implementation through its {@link RouterFactory} implementation
* @throws IOException
*/
@Test
public void testRouterFactory() throws Exception {
VerifiableProperties verifiableProperties = getVerifiableProperties();
List<FactoryAndRouter> factoryAndRouters = new ArrayList<FactoryAndRouter>();
factoryAndRouters.add(new FactoryAndRouter("com.github.ambry.router.NonBlockingRouterFactory", "com.github.ambry.router.NonBlockingRouter"));
for (FactoryAndRouter factoryAndRouter : factoryAndRouters) {
RouterFactory routerFactory = Utils.getObj(factoryAndRouter.factoryStr, verifiableProperties, new MockClusterMap(), new LoggingNotificationSystem(), null);
Router router = routerFactory.getRouter();
Assert.assertEquals("Did not receive expected Router instance", factoryAndRouter.routerStr, router.getClass().getCanonicalName());
router.close();
}
}
use of com.github.ambry.config.VerifiableProperties in project ambry by linkedin.
the class RouterFactoryTest method getVerifiableProperties.
/**
* Constructs and returns a VerifiableProperties instance with the defaults required for instantiating
* any router.
* @return the created VerifiableProperties instance.
*/
private VerifiableProperties getVerifiableProperties() {
Properties properties = new Properties();
properties.setProperty("router.hostname", "localhost");
properties.setProperty("router.datacenter.name", "DC1");
properties.setProperty("clustermap.cluster.name", "test");
properties.setProperty("clustermap.datacenter.name", "DC1");
properties.setProperty("clustermap.host.name", "localhost");
properties.setProperty("kms.default.container.key", TestUtils.getRandomKey(32));
return new VerifiableProperties(properties);
}
use of com.github.ambry.config.VerifiableProperties in project ambry by linkedin.
the class StaticClusterManagerTest method clusterMapInterface.
@Test
public void clusterMapInterface() throws Exception {
// Exercise entire clusterMap interface
TestUtils.TestHardwareLayout testHardwareLayout = new TestUtils.TestHardwareLayout("Alpha");
TestUtils.TestPartitionLayout testPartitionLayout = new TestUtils.TestPartitionLayout(testHardwareLayout);
// add 3 partitions with read_only state.
testPartitionLayout.partitionState = PartitionState.READ_ONLY;
testPartitionLayout.addNewPartitions(3);
testPartitionLayout.partitionState = PartitionState.READ_WRITE;
Datacenter localDatacenter = testHardwareLayout.getRandomDatacenter();
Properties props = new Properties();
props.setProperty("clustermap.host.name", "localhost");
props.setProperty("clustermap.cluster.name", "cluster");
props.setProperty("clustermap.datacenter.name", localDatacenter.getName());
ClusterMapConfig clusterMapConfig = new ClusterMapConfig(new VerifiableProperties(props));
ClusterMap clusterMapManager = (new StaticClusterAgentsFactory(clusterMapConfig, testPartitionLayout.getPartitionLayout())).getClusterMap();
for (String metricName : clusterMapManager.getMetricRegistry().getNames()) {
System.out.println(metricName);
}
assertEquals("Incorrect local datacenter ID", localDatacenter.getId(), clusterMapManager.getLocalDatacenterId());
List<? extends PartitionId> writablePartitionIds = clusterMapManager.getWritablePartitionIds();
List<? extends PartitionId> partitionIds = clusterMapManager.getAllPartitionIds();
assertEquals(writablePartitionIds.size(), testPartitionLayout.getPartitionCount() - 3);
assertEquals(partitionIds.size(), testPartitionLayout.getPartitionCount());
for (PartitionId partitionId : partitionIds) {
if (partitionId.getPartitionState().equals(PartitionState.READ_WRITE)) {
assertTrue("Partition not found in writable set ", writablePartitionIds.contains(partitionId));
} else {
assertFalse("READ_ONLY Partition found in writable set ", writablePartitionIds.contains(partitionId));
}
}
for (int i = 0; i < partitionIds.size(); i++) {
PartitionId partitionId = partitionIds.get(i);
assertEquals(partitionId.getReplicaIds().size(), testPartitionLayout.getTotalReplicaCount());
DataInputStream partitionStream = new DataInputStream(new ByteBufferInputStream(ByteBuffer.wrap(partitionId.getBytes())));
try {
PartitionId fetchedPartitionId = clusterMapManager.getPartitionIdFromStream(partitionStream);
assertEquals(partitionId, fetchedPartitionId);
} catch (IOException e) {
assertEquals(true, false);
}
}
for (Datacenter datacenter : testHardwareLayout.getHardwareLayout().getDatacenters()) {
for (DataNode dataNode : datacenter.getDataNodes()) {
DataNodeId dataNodeId = clusterMapManager.getDataNodeId(dataNode.getHostname(), dataNode.getPort());
assertEquals(dataNodeId, dataNode);
for (ReplicaId replicaId : clusterMapManager.getReplicaIds(dataNodeId)) {
assertEquals(dataNodeId, replicaId.getDataNodeId());
}
}
}
}
Aggregations