Package kafka.javaapi.message

Examples of kafka.javaapi.message.ByteBufferMessageSet


            String instanceId = (String) meta.get("instanceId");
            if(!_config.forceFromStart || instanceId.equals(_topologyInstanceId)) {
                SimpleConsumer consumer = _connections.getConsumer(partition);
                long offset = (Long) meta.get("offset");
                long nextOffset = (Long) meta.get("nextOffset");
                ByteBufferMessageSet msgs = consumer.fetch(new FetchRequest(_config.topic, partition % partitionsPerHost, offset, _config.fetchSizeBytes));
                for(MessageAndOffset msg: msgs) {
                    if(offset == nextOffset) break;
                    if(offset > nextOffset) {
                        throw new RuntimeException("Error when re-emitting batch. overshot the end offset");
                    }
View Full Code Here


         } else {
             long startTime = -1;
             if(config.forceFromStart) startTime = config.startOffsetTime;
             offset = consumer.getOffsetsBefore(config.topic, partition % hosts.partitionsPerHost, startTime, 1)[0];
         }
         ByteBufferMessageSet msgs;
         try {
            msgs = consumer.fetch(new FetchRequest(config.topic, partition % hosts.partitionsPerHost, offset, config.fetchSizeBytes));
         } catch(Exception e) {
             if(e instanceof ConnectException) {
                 throw new FailedFetchException(e);
View Full Code Here

        boolean gotNext = get(key, value);

        if(_response != null) {
            Iterator<ByteBufferMessageSet> iter = _response.iterator();
            while ( !gotNext && iter.hasNext()) {
                ByteBufferMessageSet msgSet = iter.next();
                if ( hasError(msgSet)) return false;
                _messageIt =  (Iterator<MessageAndOffset>) msgSet.iterator();
                gotNext = get(key, value);
            }
        }
        return gotNext;
    }
View Full Code Here

                                                       KafkaProperties.connectionTimeOut,
                                                       KafkaProperties.kafkaProducerBufferSize);

    System.out.println("Testing single fetch");
    FetchRequest req = new FetchRequest(KafkaProperties.topic2, 0, 0L, 100);
    ByteBufferMessageSet messageSet = simpleConsumer.fetch(req);
    printMessages(messageSet);

    System.out.println("Testing single multi-fetch");
    req = new FetchRequest(KafkaProperties.topic2, 0, 0L, 100);
    List<FetchRequest> list = new ArrayList<FetchRequest>();
View Full Code Here

      Message message = new Message(bytes);
      list.add(message);
    }
    // send events
    System.out.println(" send " + list.size() + " " + _topic + " count events to " + _uri);
    _producer.send(_topic, new ByteBufferMessageSet(kafka.message.NoCompressionCodec$.MODULE$, list));

    // close the producer
    _producer.close();
   
    // generate offset files
View Full Code Here

      for(int i = 0; i < batchSize; i++)
      {
        Message message = new Message(new byte[messageSize]);
        messageList.add(message);
      }
      ByteBufferMessageSet set = new ByteBufferMessageSet(kafka.message.CompressionCodec$.MODULE$.getCompressionCodec(compression), messageList);
      producer.send(topic, random.nextInt(numParts), set);
      bytesSent.getAndAdd(batchSize * messageSize);
      messagesSent.getAndAdd(messageList.size());
    }
  }
View Full Code Here

  }

  protected void sendMsgList()
  {
    if (msgList.size() > 0) {
      ByteBufferMessageSet msgSet = new ByteBufferMessageSet(kafka.message.NoCompressionCodec$.MODULE$, msgList);
      producer.send(topic, msgSet);
      msgList.clear();
      totalSize = 0;
    }
  }
View Full Code Here

//            long startOffset = getOffset(topic, partition, config.startOffsetTime);
//            offset = startOffset;
//          }
          throw new KafkaException("fetch data from kafka topic["+topic+"] partition["+partition+"] error:" + code);
        }else {
          ByteBufferMessageSet msgs =  fetchResponse.messageSet(topic, partition);
          return msgs;
        }
  }
View Full Code Here

        // }
    }

    private void fillMessages() {

        ByteBufferMessageSet msgs;
        try {
            msgs = consumer.fetchMessages(partition.getPartition(), emittingOffset + 1);
            LOG.debug("fetch message from offset " + emittingOffset);
            for (MessageAndOffset msg : msgs) {
                emittingMessages.add(msg);
View Full Code Here

TOP

Related Classes of kafka.javaapi.message.ByteBufferMessageSet

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.