Package com.pinterest.secor.common

Examples of com.pinterest.secor.common.SecorConfig


                    + " num_topics num_partitions num_records message_size");
            System.exit(1);
        }
        Random rnd = new Random();
        int num_topics = Integer.parseInt(args[0]);
        SecorConfig config = SecorConfig.load();
        String zkConfig = config.getZookeeperQuorum()
                + config.getKafkaZookeeperPath();
        // create topics list
        String perfTopicPrefix = config.getPerfTestTopicPrefix();
        List<String> topics = Lists.newLinkedList();
        for (int i = 0; i < num_topics; i++) {
            topics.add(perfTopicPrefix + rnd.nextInt(9999));
        }

        int num_partitions = Integer.parseInt(args[1]);

        // createTopics
        createTopics(topics, num_partitions, zkConfig);

        int numRecords = Integer.parseInt(args[2]);
        Properties props = new Properties();
        props.put("metadata.broker.list", "localhost:9092");
        props.put("serializer.class", "kafka.serializer.StringEncoder");
        props.put("request.required.acks", "1");
        props.put("producer.type", "async");

        ProducerConfig producerConfig = new ProducerConfig(props);

        Producer<String, String> producer = new Producer<String, String>(
                producerConfig);
        long size = 0;
        int message_size = Integer.parseInt(args[3]);

        // produce messages
        for (String topic : topics) {
            for (long nEvents = 0; nEvents < numRecords; nEvents++) {
                String ip = String.valueOf(nEvents % num_partitions);
                byte[] payload = new byte[message_size];
                Arrays.fill(payload, (byte) 1);
                String msg = new String(payload, "UTF-8");
                size += msg.length();
                KeyedMessage<String, String> data = new KeyedMessage<String, String>(
                        topic, ip, msg);
                producer.send(data);
            }
        }
        producer.close();

        RateLimitUtil.configure(config);
        Map<TopicPartition, Long> lastOffsets = getTopicMetadata(topics,
                num_partitions, config);
        OstrichAdminService ostrichService = new OstrichAdminService(
                config.getOstrichPort());
        ostrichService.start();
        FileUtil.configure(config);

        LogFileDeleter logFileDeleter = new LogFileDeleter(config);
        logFileDeleter.deleteOldLogs();
        Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() {
            public void uncaughtException(Thread thread, Throwable exception) {
                exception.printStackTrace();
                System.out.println("Thread " + thread + " failed:"
                        + exception.getMessage());
                System.exit(1);
            }
        };
        System.out.println("starting " + config.getConsumerThreads()
                + " consumer threads");
        System.out.println("Rate limit:" + config.getMessagesPerSecond());
        LinkedList<Consumer> consumers = new LinkedList<Consumer>();
        long startMillis = System.currentTimeMillis();
        for (int i = 0; i < config.getConsumerThreads(); ++i) {
            Consumer consumer = new Consumer(config);
            consumer.setUncaughtExceptionHandler(handler);
            consumers.add(consumer);
            consumer.start();
        }
View Full Code Here


    private void setupSequenceFileReaderConfig() {
        PropertiesConfiguration properties = new PropertiesConfiguration();
        properties.addProperty("secor.file.reader.writer",
                "com.pinterest.secor.io.impl.SequenceFileReaderWriter");
        mConfig = new SecorConfig(properties);
    }
View Full Code Here

    private void setupGzipFileReaderConfig() {
        PropertiesConfiguration properties = new PropertiesConfiguration();
        properties.addProperty("secor.file.reader.writer",
                "com.pinterest.secor.io.impl.DelimitedTextFileReaderWriter");
        mConfig = new SecorConfig(properties);
    }
View Full Code Here

public class ProgressMonitorMain {
    private static final Logger LOG = LoggerFactory.getLogger(ProgressMonitorMain.class);

    public static void main(String[] args) {
        try {
            SecorConfig config = SecorConfig.load();
            ProgressMonitor progressMonitor = new ProgressMonitor(config);
            progressMonitor.exportStats();
        } catch (Throwable t) {
            LOG.error("Progress monitor failed", t);
            System.exit(1);
View Full Code Here

            String command = commandLine.getOptionValue("command");
            if (!command.equals("delete_committed_offsets")) {
                throw new IllegalArgumentException(
                    "command has to be one of \"delete_committed_offsets\"");
            }
            SecorConfig config = SecorConfig.load();
            ZookeeperConnector zookeeperConnector = new ZookeeperConnector(config);
            String topic = commandLine.getOptionValue("topic");
            if (commandLine.hasOption("partition")) {
                int partition =
                    ((Number) commandLine.getParsedOptionValue("partition")).intValue();
View Full Code Here

    }

    public static void main(String[] args) {
        try {
            CommandLine commandLine = parseArgs(args);
            SecorConfig config = SecorConfig.load();
            FileUtil.configure(config);
            LogFileVerifier verifier = new LogFileVerifier(config,
                commandLine.getOptionValue("topic"));
            long startOffset = -2;
            long endOffset = Long.MAX_VALUE;
View Full Code Here

            System.err.println("Usage: java -Dconfig=<secor_properties> " +
                               "-Dlog4j.configuration=<log4j_properties> ConsumerMain");
            return;
        }
        try {
            SecorConfig config = SecorConfig.load();
            OstrichAdminService ostrichService = new OstrichAdminService(config.getOstrichPort());
            ostrichService.start();
            FileUtil.configure(config);

            LogFileDeleter logFileDeleter = new LogFileDeleter(config);
            logFileDeleter.deleteOldLogs();

            RateLimitUtil.configure(config);
            Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() {
                public void uncaughtException(Thread thread, Throwable exception) {
                    LOG.error("Thread " + thread + " failed", exception);
                    System.exit(1);
                }
            };
            LOG.info("starting " + config.getConsumerThreads() + " consumer threads");
            LinkedList<Consumer> consumers = new LinkedList<Consumer>();
            for (int i = 0; i < config.getConsumerThreads(); ++i) {
                Consumer consumer = new Consumer(config);
                consumer.setUncaughtExceptionHandler(handler);
                consumers.add(consumer);
                consumer.start();
            }
View Full Code Here

public class PartitionFinalizerMain {
    private static final Logger LOG = LoggerFactory.getLogger(LogFilePrinterMain.class);

    public static void main(String[] args) {
        try {
            SecorConfig config = SecorConfig.load();
            FileUtil.configure(config);
            PartitionFinalizer partitionFinalizer = new PartitionFinalizer(config);
            partitionFinalizer.finalizePartitions();
        } catch (Throwable t) {
            LOG.error("Partition finalizer failed", t);
View Full Code Here

    }

    public static void main(String[] args) {
        try {
            CommandLine commandLine = parseArgs(args);
            SecorConfig config = SecorConfig.load();
            FileUtil.configure(config);
            LogFilePrinter printer = new LogFilePrinter(
                    commandLine.hasOption("print_offsets_only"));
            printer.printFile(commandLine.getOptionValue("file"));
        } catch (Throwable t) {
View Full Code Here

TOP

Related Classes of com.pinterest.secor.common.SecorConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.