All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.panhongan.util.kafka.export.KafkaExporterService Maven / Gradle / Ivy

There is a newer version: 0.1.8
Show newest version
package com.github.panhongan.util.kafka.export;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class KafkaExporterService {
	
	private static final String CLASS_NAME = KafkaExporterService.class.getSimpleName();
	
	private static final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
	
	public static void usage() {
		System.out.println(CLASS_NAME + " ");
	}

	
	public static void main(String [] args) {
		if (args.length != 1) {
			usage();
			return;
		}
		
		// config
		String conf_file = args[0];
		KafkaExporterConfig config = KafkaExporterConfig.getInstance();
		if (!config.parse(conf_file)) {
			logger.warn("parse conf file failed : {}", conf_file);
			return;
		}
		
		logger.info(config.toString());
		
		if (!config.isValid()) {
			logger.warn("config is invalid");
			return;
		}

		// kafka exporter
		KafkaExporter exporter = new KafkaExporter();
		if (exporter.init()) {
			logger.info("{} init ok", CLASS_NAME);
			Runtime.getRuntime().addShutdownHook(new KafkaExporterShutdownHook(exporter));
		} else {
			logger.warn("{} init failed", CLASS_NAME);
			exporter.uninit();
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy