use of com.github.ambry.config.ClusterMapConfig in project ambry by linkedin.
the class TestUtils method getDummyConfig.
/**
* For use when the the actual values in {@link ClusterMapConfig} are unimportant.
* @return a {@link ClusterMapConfig} with some default values.
*/
static ClusterMapConfig getDummyConfig() {
Properties props = new Properties();
props.setProperty("clustermap.host.name", "localhost");
props.setProperty("clustermap.cluster.name", "cluster");
props.setProperty("clustermap.datacenter.name", "");
props.setProperty("clustermap.resolve.hostnames", "false");
return new ClusterMapConfig(new VerifiableProperties(props));
}
use of com.github.ambry.config.ClusterMapConfig in project ambry by linkedin.
the class StaticClusterManagerTest method clusterMapInterface.
@Test
public void clusterMapInterface() {
// Exercise entire clusterMap interface
TestHardwareLayout testHardwareLayout = new TestHardwareLayout("Alpha");
TestPartitionLayout testPartitionLayout = new TestPartitionLayout(testHardwareLayout, null);
// add 3 partitions with read_only state.
testPartitionLayout.partitionState = PartitionState.READ_ONLY;
testPartitionLayout.addNewPartitions(3, DEFAULT_PARTITION_CLASS, testPartitionLayout.partitionState, null);
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(null);
List<? extends PartitionId> partitionIds = clusterMapManager.getAllPartitionIds(null);
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());
}
}
}
}
use of com.github.ambry.config.ClusterMapConfig in project ambry by linkedin.
the class HelixHealthReportAggregationTaskTest method makeClusterMapConfig.
private ClusterMapConfig makeClusterMapConfig() {
Properties props = new Properties();
props.setProperty("clustermap.host.name", INSTANCE_NAME);
props.setProperty("clustermap.cluster.name", CLUSTER_NAME);
props.setProperty("clustermap.datacenter.name", "DC1");
return new ClusterMapConfig(new VerifiableProperties(props));
}
use of com.github.ambry.config.ClusterMapConfig in project ambry by linkedin.
the class AccountStatsMySqlStoreIntegrationTest method createAccountStatsMySqlStore.
private AccountStatsMySqlStore createAccountStatsMySqlStore(String clusterName, String hostname, int port) throws Exception {
Path localBackupFilePath = createTemporaryFile();
Properties configProps = Utils.loadPropsFromResource("accountstats_mysql.properties");
configProps.setProperty(ClusterMapConfig.CLUSTERMAP_CLUSTER_NAME, clusterName);
configProps.setProperty(ClusterMapConfig.CLUSTERMAP_HOST_NAME, hostname);
configProps.setProperty(ClusterMapConfig.CLUSTERMAP_DATACENTER_NAME, "dc1");
configProps.setProperty(ClusterMapConfig.CLUSTERMAP_PORT, String.valueOf(port));
configProps.setProperty(AccountStatsMySqlConfig.DOMAIN_NAMES_TO_REMOVE, ".github.com");
configProps.setProperty(AccountStatsMySqlConfig.UPDATE_BATCH_SIZE, String.valueOf(batchSize));
configProps.setProperty(AccountStatsMySqlConfig.POOL_SIZE, String.valueOf(5));
configProps.setProperty(AccountStatsMySqlConfig.LOCAL_BACKUP_FILE_PATH, localBackupFilePath.toString());
VerifiableProperties verifiableProperties = new VerifiableProperties(configProps);
return (AccountStatsMySqlStore) new AccountStatsMySqlStoreFactory(verifiableProperties, new ClusterMapConfig(verifiableProperties), new MetricRegistry()).getAccountStatsStore();
}
use of com.github.ambry.config.ClusterMapConfig in project ambry by linkedin.
the class PartitionClassReportsDaoTest method createAccountStatsMySqlStore.
private static AccountStatsMySqlStore createAccountStatsMySqlStore(String clusterName, String hostname, int port, int batchSize) throws Exception {
Path tempDir = Files.createTempDirectory("PartitionClassReportsDaoTest");
Properties configProps = Utils.loadPropsFromResource("accountstats_mysql.properties");
configProps.setProperty(ClusterMapConfig.CLUSTERMAP_CLUSTER_NAME, clusterName);
configProps.setProperty(ClusterMapConfig.CLUSTERMAP_HOST_NAME, hostname);
configProps.setProperty(ClusterMapConfig.CLUSTERMAP_DATACENTER_NAME, "dc1");
configProps.setProperty(ClusterMapConfig.CLUSTERMAP_PORT, String.valueOf(port));
configProps.setProperty(AccountStatsMySqlConfig.DOMAIN_NAMES_TO_REMOVE, ".github.com");
configProps.setProperty(AccountStatsMySqlConfig.UPDATE_BATCH_SIZE, String.valueOf(batchSize));
configProps.setProperty(AccountStatsMySqlConfig.LOCAL_BACKUP_FILE_PATH, tempDir.toString());
VerifiableProperties verifiableProperties = new VerifiableProperties(configProps);
return (AccountStatsMySqlStore) new AccountStatsMySqlStoreFactory(verifiableProperties, new ClusterMapConfig(verifiableProperties), new MetricRegistry()).getAccountStatsStore();
}
Aggregations