Search in sources :

Example 1 with VcrClusterAgentsFactory

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));
}
Also used : VcrClusterAgentsFactory(com.github.ambry.clustermap.VcrClusterAgentsFactory) Arrays(java.util.Arrays) MetricRegistry(com.codahale.metrics.MetricRegistry) Properties(java.util.Properties) VcrClusterAgentsFactory(com.github.ambry.clustermap.VcrClusterAgentsFactory) VerifiableProperties(com.github.ambry.config.VerifiableProperties) Test(org.junit.Test) Collectors(java.util.stream.Collectors) CloudConfig(com.github.ambry.config.CloudConfig) List(java.util.List) VcrClusterParticipant(com.github.ambry.clustermap.VcrClusterParticipant) ClusterMapConfig(com.github.ambry.config.ClusterMapConfig) MockClusterAgentsFactory(com.github.ambry.clustermap.MockClusterAgentsFactory) Assert(org.junit.Assert) MockClusterMap(com.github.ambry.clustermap.MockClusterMap) Before(org.junit.Before) VcrClusterParticipant(com.github.ambry.clustermap.VcrClusterParticipant) VerifiableProperties(com.github.ambry.config.VerifiableProperties) MetricRegistry(com.codahale.metrics.MetricRegistry) CloudConfig(com.github.ambry.config.CloudConfig) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) ClusterMapConfig(com.github.ambry.config.ClusterMapConfig) Test(org.junit.Test)

Example 2 with VcrClusterAgentsFactory

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);
}
Also used : VcrClusterAgentsFactory(com.github.ambry.clustermap.VcrClusterAgentsFactory) VerifiableProperties(com.github.ambry.config.VerifiableProperties) CloudConfig(com.github.ambry.config.CloudConfig) ClusterAgentsFactory(com.github.ambry.clustermap.ClusterAgentsFactory) VcrClusterAgentsFactory(com.github.ambry.clustermap.VcrClusterAgentsFactory) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) InvocationOptions(com.github.ambry.utils.InvocationOptions) ClusterMapConfig(com.github.ambry.config.ClusterMapConfig)

Aggregations

VcrClusterAgentsFactory (com.github.ambry.clustermap.VcrClusterAgentsFactory)2 CloudConfig (com.github.ambry.config.CloudConfig)2 ClusterMapConfig (com.github.ambry.config.ClusterMapConfig)2 VerifiableProperties (com.github.ambry.config.VerifiableProperties)2 Properties (java.util.Properties)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 ClusterAgentsFactory (com.github.ambry.clustermap.ClusterAgentsFactory)1 MockClusterAgentsFactory (com.github.ambry.clustermap.MockClusterAgentsFactory)1 MockClusterMap (com.github.ambry.clustermap.MockClusterMap)1 VcrClusterParticipant (com.github.ambry.clustermap.VcrClusterParticipant)1 InvocationOptions (com.github.ambry.utils.InvocationOptions)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Assert (org.junit.Assert)1 Before (org.junit.Before)1 Test (org.junit.Test)1