Package kafka.javaapi.producer

Examples of kafka.javaapi.producer.Producer


        Validate.notNull(topicSelector, "topicSelector can not be null");
        Map configMap = (Map) stormConf.get(KAFKA_BROKER_PROPERTIES);
        Properties properties = new Properties();
        properties.putAll(configMap);
        ProducerConfig config = new ProducerConfig(properties);
        producer = new Producer(config);
    }
View Full Code Here


    public void testKafkaService() throws Exception {

        KafkaService kafkaService = new KafkaService();
        KafkaService kafkaServiceSpy = spy(kafkaService);
        //Create a mock producer object and add it to the producer list
        Producer mockProducer = mock(Producer.class);
        ArrayList<Producer> producerList = kafkaServiceSpy.getProducerListUnsafe();
        producerList.clear();
        producerList.add(mockProducer);

        //Start KafkaProduction and test whether listener object was added
View Full Code Here

                        .withCorePoolSize(numberOfProducers)
                        .withMaxPoolSize(numberOfProducers)
                        .withUnboundedQueue()
                        .build();
                for(int i=0;i<numberOfProducers;i++) {
                    Producer producer = new Producer(new ProducerConfig(config.getKafkaProperties()));
                    producerList.add(producer);
                }
                ready = true;
            }
        } catch (Exception e) {
View Full Code Here

      String clientId = kafkaProducerProperties_08.getProperty("client.id");
      // start producer threads
      for (int i = 0; i < numProducers; i++) {
        kafkaProducerProperties_08.put("client.id", clientId + "-" + i);
        ProducerConfig producerConfig_08 = new ProducerConfig(kafkaProducerProperties_08);
        Producer producer = new Producer(producerConfig_08);
        ProducerThread producerThread = new ProducerThread(producerDataChannel, producer, i);
        producerThread.start();
        producerThreads.add(producerThread);
      }
    }
View Full Code Here

        producerProps.put("metadata.broker.list", formatAddress(_uri.getHost(), _uri.getPort()));
        producerProps.put("send.buffer.bytes", String.valueOf(TCP_BUFFER_SIZE));
        producerProps.put("connect.timeout.ms", String.valueOf(CONNECT_TIMEOUT));
        producerProps.put("reconnect.interval", String.valueOf(RECONNECT_INTERVAL));
       
    _producer = new Producer(new ProducerConfig(producerProps));
     
  }
View Full Code Here

    props.put("metadata.broker.list", brokerList);
    props.put("producer.type", "async");
    props.put("request.required.acks", "1");
    props.put("request.timeout.ms", "30000");
    log.debug("Broker list: " + brokerList);
    Producer producer = new Producer(new ProducerConfig(props));
    try {
      for (byte[] message : monitorSet) {
        KeyedMessage keyedMessage = new KeyedMessage(
            "TrackingMonitoringEvent", message);
        producer.send(keyedMessage);
      }
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println(topic + " issue sending tracking to "
                    + brokerList.toString());
    } finally {
      if (producer != null) {
        producer.close();
      }
    }

  }
View Full Code Here

        this.inputTransform = inputTransform;
    }

    public void start() {
        if (producer == null) {
            producer = new Producer(producerConfig);
        }
    }
View Full Code Here

        }
    }

    public void processMeter(MetricName name, Metered meter, Context context) {
        final String header = "# time,count,1 min rate,mean rate,5 min rate,15 min rate";
        final Producer producer = context.getProducer();
        final String topic = "%s-metrics-meter".format(prefix);
        final String message = valueOf(meter.count()) + ',' + meter.oneMinuteRate() + ',' + meter.meanRate() + ','
                + meter.fiveMinuteRate() + ',' + meter.fifteenMinuteRate();
        send(producer, header, topic, message);
    }
View Full Code Here

        send(producer, header, topic, message);
    }

    public void processCounter(MetricName name, Counter counter, Context context) {
        final String header = "# time,count";
        final Producer producer = context.getProducer();
        final String topic = "%s-metrics-counter".format(prefix);
        final String message = valueOf(counter.count());
        send(producer, header, topic, message);
    }
View Full Code Here

        send(producer, header, topic, message);
    }

    public void processHistogram(MetricName name, Histogram histogram, Context context) {
        final String header = "# time,min,max,mean,median,stddev,95%,99%,99.9%";
        final Producer producer = context.getProducer();
        final Snapshot snapshot = histogram.getSnapshot();
        final String topic="%s-metrics-histogram".format(prefix);
        final String message = valueOf(histogram.min()) + ',' + histogram.max() + ',' + histogram.mean() + ','
                + snapshot.getMedian() + ',' + histogram.stdDev() + ',' + snapshot.get95thPercentile() + ',' + snapshot.get99thPercentile() + ','
                + snapshot.get999thPercentile();
View Full Code Here

TOP

Related Classes of kafka.javaapi.producer.Producer

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.