use of com.github.ambry.clustermap.VcrClusterAgentsFactory in project ambry by linkedin.
the class StaticVcrClusterParticipantTest method staticVcrClusterFactoryTest.
@Test
public void staticVcrClusterFactoryTest() throws Exception {
Properties props = new Properties();
String hostName = "localhostTest";
int port = 12345;
List<String> assignedPartitions = Arrays.asList("0", "1");
props.setProperty("clustermap.cluster.name", "test");
props.setProperty("clustermap.datacenter.name", "DC1");
props.setProperty("clustermap.host.name", hostName);
props.setProperty("clustermap.port", Integer.toString(port));
props.setProperty("clustermap.default.partition.class", MockClusterMap.DEFAULT_PARTITION_CLASS);
props.setProperty("clustermap.resolve.hostnames", "false");
props.setProperty("vcr.assigned.partitions", String.join(",", assignedPartitions));
VerifiableProperties vProps = new VerifiableProperties(props);
CloudConfig cloudConfig = new CloudConfig(vProps);
ClusterMapConfig clusterMapConfig = new ClusterMapConfig(vProps);
VcrClusterAgentsFactory factory = new StaticVcrClusterAgentsFactory(cloudConfig, clusterMapConfig, mockClusterMap, null, null, null, new MetricRegistry());
VcrClusterParticipant vcrClusterParticipant = factory.getVcrClusterParticipant();
assertEquals("CloudDataNode host name doesn't match", hostName, vcrClusterParticipant.getCurrentDataNodeId().getHostname());
assertEquals("CloudDataNode port doesn't match", port, vcrClusterParticipant.getCurrentDataNodeId().getPort());
assertTrue("Partition assignment incorrect", assignedPartitions.equals(vcrClusterParticipant.getAssignedPartitionIds().stream().map(partitionId -> partitionId.toPathString()).collect(Collectors.toList())));
assertEquals("Number of CloudDataNode should be 1", 1, vcrClusterParticipant.getAllDataNodeIds().size());
assertEquals("CloudDataNode mismatch", vcrClusterParticipant.getCurrentDataNodeId(), vcrClusterParticipant.getAllDataNodeIds().get(0));
}
use of com.github.ambry.clustermap.VcrClusterAgentsFactory in project ambry by linkedin.
the class AmbryMain method main.
public static void main(String[] args) {
final AmbryServer ambryServer;
int exitCode = 0;
try {
InvocationOptions options = new InvocationOptions(args);
Properties properties = Utils.loadProps(options.serverPropsFilePath);
VerifiableProperties verifiableProperties = new VerifiableProperties(properties);
ClusterMapConfig clusterMapConfig = new ClusterMapConfig(verifiableProperties);
CloudConfig cloudConfig = new CloudConfig(verifiableProperties);
ClusterAgentsFactory clusterAgentsFactory = Utils.getObj(clusterMapConfig.clusterMapClusterAgentsFactory, clusterMapConfig, options.hardwareLayoutFilePath, options.partitionLayoutFilePath);
logger.info("Bootstrapping AmbryServer");
VcrClusterAgentsFactory vcrClusterAgentsFactory = Utils.getObj(cloudConfig.vcrClusterAgentsFactoryClass);
ambryServer = new AmbryServer(verifiableProperties, clusterAgentsFactory, vcrClusterAgentsFactory, SystemTime.getInstance());
// attach shutdown handler to catch control-c
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
logger.info("Received shutdown signal. Shutting down AmbryServer");
ambryServer.shutdown();
}
});
ambryServer.startup();
ambryServer.awaitShutdown();
} catch (Exception e) {
logger.error("Exception during bootstrap of AmbryServer", e);
exitCode = 1;
}
logger.info("Exiting AmbryMain");
System.exit(exitCode);
}
Aggregations