Search in sources :

Example 1 with InvocationOptions

use of com.github.ambry.utils.InvocationOptions in project ambry by linkedin.

the class RestServerMain method main.

public static void main(String[] args) {
    final RestServer restServer;
    int exitCode = 0;
    ClusterMap clusterMap = null;
    try {
        InvocationOptions options = new InvocationOptions(args);
        Properties properties = Utils.loadProps(options.serverPropsFilePath);
        VerifiableProperties verifiableProperties = new VerifiableProperties(properties);
        ClusterMapConfig clusterMapConfig = new ClusterMapConfig(verifiableProperties);
        ClusterAgentsFactory clusterAgentsFactory = Utils.getObj(clusterMapConfig.clusterMapClusterAgentsFactory, clusterMapConfig, options.hardwareLayoutFilePath, options.partitionLayoutFilePath);
        clusterMap = clusterAgentsFactory.getClusterMap();
        SSLFactory sslFactory = getSSLFactoryIfRequired(verifiableProperties);
        logger.info("Bootstrapping RestServer");
        restServer = new RestServer(verifiableProperties, clusterMap, new LoggingNotificationSystem(), sslFactory);
        // attach shutdown handler to catch control-c
        Runtime.getRuntime().addShutdownHook(new Thread() {

            public void run() {
                logger.info("Received shutdown signal. Shutting down RestServer");
                restServer.shutdown();
            }
        });
        restServer.start();
        restServer.awaitShutdown();
    } catch (Exception e) {
        logger.error("Exception during bootstrap of RestServer", e);
        exitCode = 1;
    } finally {
        if (clusterMap != null) {
            clusterMap.close();
        }
    }
    logger.info("Exiting RestServerMain");
    System.exit(exitCode);
}
Also used : ClusterMap(com.github.ambry.clustermap.ClusterMap) SSLFactory(com.github.ambry.commons.SSLFactory) VerifiableProperties(com.github.ambry.config.VerifiableProperties) LoggingNotificationSystem(com.github.ambry.commons.LoggingNotificationSystem) ClusterAgentsFactory(com.github.ambry.clustermap.ClusterAgentsFactory) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) InvocationOptions(com.github.ambry.utils.InvocationOptions) ClusterMapConfig(com.github.ambry.config.ClusterMapConfig) IOException(java.io.IOException) GeneralSecurityException(java.security.GeneralSecurityException)

Example 2 with InvocationOptions

use of com.github.ambry.utils.InvocationOptions 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);
        ClusterAgentsFactory clusterAgentsFactory = Utils.getObj(clusterMapConfig.clusterMapClusterAgentsFactory, clusterMapConfig, options.hardwareLayoutFilePath, options.partitionLayoutFilePath);
        logger.info("Bootstrapping AmbryServer");
        ambryServer = new AmbryServer(verifiableProperties, clusterAgentsFactory, 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 : VerifiableProperties(com.github.ambry.config.VerifiableProperties) ClusterAgentsFactory(com.github.ambry.clustermap.ClusterAgentsFactory) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) InvocationOptions(com.github.ambry.utils.InvocationOptions) ClusterMapConfig(com.github.ambry.config.ClusterMapConfig)

Aggregations

ClusterAgentsFactory (com.github.ambry.clustermap.ClusterAgentsFactory)2 ClusterMapConfig (com.github.ambry.config.ClusterMapConfig)2 VerifiableProperties (com.github.ambry.config.VerifiableProperties)2 InvocationOptions (com.github.ambry.utils.InvocationOptions)2 Properties (java.util.Properties)2 ClusterMap (com.github.ambry.clustermap.ClusterMap)1 LoggingNotificationSystem (com.github.ambry.commons.LoggingNotificationSystem)1 SSLFactory (com.github.ambry.commons.SSLFactory)1 IOException (java.io.IOException)1 GeneralSecurityException (java.security.GeneralSecurityException)1