Search in sources :

Example 1 with CommandLineParameters

use of org.apache.airavata.common.utils.StringUtil.CommandLineParameters in project airavata by apache.

the class ServerMain method main.

// private static void addSecondaryShutdownHook(){
// Runtime.getRuntime().addShutdownHook(new Thread(){
// @Override
// public void run() {
// System.out.print("Graceful shutdown attempt is still active. Do you want to exit instead? (y/n)");
// String command=System.console().readLine().trim().toLowerCase();
// if (command.equals("yes") || command.equals("y")){
// System.exit(1);
// }
// }
// });
// }
public static void main(String[] args) throws ParseException, IOException, AiravataException {
    ServerSettings.mergeSettingsCommandLineArgs(args);
    ServerSettings.setServerRoles(ApplicationSettings.getSetting(SERVERS_KEY, "all").split(","));
    if (ServerSettings.isEnabledKafkaLogging()) {
        final ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
        if (iLoggerFactory instanceof LoggerContext) {
            final KafkaAppender kafkaAppender = new KafkaAppender(ServerSettings.getKafkaBrokerList(), ServerSettings.getKafkaTopicPrefix());
            kafkaAppender.setContext((LoggerContext) iLoggerFactory);
            kafkaAppender.setName("kafka-appender");
            kafkaAppender.clearAllFilters();
            kafkaAppender.start();
            // Until AIRAVATA-2073 filter org.apache.kafka logs
            ((LoggerContext) iLoggerFactory).getLogger("org.apache.airavata").addAppender(kafkaAppender);
            ((LoggerContext) iLoggerFactory).getLogger("org.apache.zookeeper").addAppender(kafkaAppender);
            ((LoggerContext) iLoggerFactory).getLogger("org.apache.derby").addAppender(kafkaAppender);
            ((LoggerContext) iLoggerFactory).getLogger("org.apache.commons").addAppender(kafkaAppender);
            ((LoggerContext) iLoggerFactory).getLogger("org.apache.thrift").addAppender(kafkaAppender);
            ((LoggerContext) iLoggerFactory).getLogger("com").addAppender(kafkaAppender);
            ((LoggerContext) iLoggerFactory).getLogger("net").addAppender(kafkaAppender);
        } else {
            logger.warn("Kafka logging is enabled but cannot find logback LoggerContext, found", iLoggerFactory.getClass().toString());
            throw new AiravataException("Kafka logging is enabled but cannot find logback LoggerContext");
        }
    } else {
        logger.info("Kafka logging is disabled in airavata server configurations");
    }
    CommandLineParameters commandLineParameters = StringUtil.getCommandLineParser(args);
    if (commandLineParameters.getArguments().contains(STOP_COMMAND_STR)) {
        performServerStopRequest(commandLineParameters);
    } else {
        AiravataZKUtils.startEmbeddedZK(cnxnFactory);
        performServerStart(args);
    }
}
Also used : CommandLineParameters(org.apache.airavata.common.utils.StringUtil.CommandLineParameters) ILoggerFactory(org.slf4j.ILoggerFactory) KafkaAppender(org.apache.airavata.common.logging.kafka.KafkaAppender) LoggerContext(ch.qos.logback.classic.LoggerContext) AiravataException(org.apache.airavata.common.exception.AiravataException)

Aggregations

LoggerContext (ch.qos.logback.classic.LoggerContext)1 AiravataException (org.apache.airavata.common.exception.AiravataException)1 KafkaAppender (org.apache.airavata.common.logging.kafka.KafkaAppender)1 CommandLineParameters (org.apache.airavata.common.utils.StringUtil.CommandLineParameters)1 ILoggerFactory (org.slf4j.ILoggerFactory)1