Package org.apache.kafka.common

Examples of org.apache.kafka.common.TopicPartition


        int partition = 0;
        if (this.cluster.partitionsForTopic(record.topic()) != null)
            partition = partitioner.partition(record, this.cluster);
        ProduceRequestResult result = new ProduceRequestResult();
        FutureRecordMetadata future = new FutureRecordMetadata(result, 0);
        TopicPartition topicPartition = new TopicPartition(record.topic(), partition);
        long offset = nextOffset(topicPartition);
        Completion completion = new Completion(topicPartition, offset, new RecordMetadata(topicPartition, 0, offset), result, callback);
        this.sent.add(record);
        if (autoComplete)
            completion.complete(null);
View Full Code Here


                Object[] offsets = partitionResponse.getArray(OFFSETS_KEY_NAME);
                List<Long> offsetsList = new ArrayList<Long>();
                for (Object offset: offsets)
                    offsetsList.add((Long) offset);
                PartitionData partitionData = new PartitionData(errorCode, offsetsList);
                responseData.put(new TopicPartition(topic, partition), partitionData);
            }
        }
    }
View Full Code Here

    }
   
    private ConsumerRecord(String topic, int partitionId, byte[] key, byte[] value, long offset, Exception error) {
        if (topic == null)
            throw new IllegalArgumentException("Topic cannot be null");
        this.partition = new TopicPartition(topic, partitionId);
        this.key = key;
        this.value = value;
        this.offset = offset; 
        this.error = error;
    }
View Full Code Here

                int partition = partitionResponse.getInt(PARTITION_KEY_NAME);
                short errorCode = partitionResponse.getShort(ERROR_CODE_KEY_NAME);
                long highWatermark = partitionResponse.getLong(HIGH_WATERMARK_KEY_NAME);
                ByteBuffer recordSet = partitionResponse.getBytes(RECORD_SET_KEY_NAME);
                PartitionData partitionData = new PartitionData(errorCode, highWatermark, recordSet);
                responseData.put(new TopicPartition(topic, partition), partitionData);
            }
        }
    }
View Full Code Here

        assignedPartitions = new ArrayList<TopicPartition>();
        for (Object topicDataObj : struct.getArray(ASSIGNED_PARTITIONS_KEY_NAME)) {
            Struct topicData = (Struct) topicDataObj;
            String topic = topicData.getString(TOPIC_KEY_NAME);
            for (Object partitionObj : topicData.getArray(PARTITIONS_KEY_NAME))
                assignedPartitions.add(new TopicPartition(topic, (Integer) partitionObj));
        }
        errorCode = struct.getShort(ERROR_CODE_KEY_NAME);
        generationId = struct.getInt(GENERATION_ID_KEY_NAME);
        consumerId = struct.getString(CONSUMER_ID_KEY_NAME);
    }
View Full Code Here

                int partition = partitionResponse.getInt(PARTITION_KEY_NAME);
                long offset = partitionResponse.getLong(COMMIT_OFFSET_KEY_NAME);
                long timestamp = partitionResponse.getLong(TIMESTAMP_KEY_NAME);
                String metadata = partitionResponse.getString(METADATA_KEY_NAME);
                PartitionData partitionData = new PartitionData(offset, timestamp, metadata);
                offsetData.put(new TopicPartition(topic, partition), partitionData);
            }
        }
        groupId = struct.getString(GROUP_ID_KEY_NAME);
        // This field only exists in v1.
        if (struct.hasField(GENERATION_ID_KEY_NAME))
View Full Code Here

            String topic = topicData.getString(TOPIC_KEY_NAME);
            for (Object partitionResponseObj : topicData.getArray(PARTITION_DATA_KEY_NAME)) {
                Struct partitionResponse = (Struct) partitionResponseObj;
                int partition = partitionResponse.getInt(PARTITION_KEY_NAME);
                ByteBuffer records = partitionResponse.getBytes(RECORD_SET_KEY_NAME);
                partitionRecords.put(new TopicPartition(topic, partition), records);
            }
        }
        acks = struct.getShort(ACKS_KEY_NAME);
        timeout = struct.getInt(TIMEOUT_KEY_NAME);
    }
View Full Code Here

            String topic = topicResponse.getString(TOPIC_KEY_NAME);
            for (Object partitionResponseObj : topicResponse.getArray(PARTITIONS_KEY_NAME)) {
                Struct partitionResponse = (Struct) partitionResponseObj;
                int partition = partitionResponse.getInt(PARTITION_KEY_NAME);
                short errorCode = partitionResponse.getShort(ERROR_CODE_KEY_NAME);
                responseData.put(new TopicPartition(topic, partition), errorCode);
            }
        }
    }
View Full Code Here

        return new ConsumerMetadataResponse((short)1, new Node(10, "host1", 2014));
    }

    private AbstractRequestResponse createFetchRequest() {
        Map<TopicPartition, FetchRequest.PartitionData> fetchData = new HashMap<TopicPartition, FetchRequest.PartitionData>();
        fetchData.put(new TopicPartition("test1", 0), new FetchRequest.PartitionData(100, 1000000));
        fetchData.put(new TopicPartition("test2", 0), new FetchRequest.PartitionData(200, 1000000));
        return new FetchRequest(-1, 100, 100000, fetchData);
    }
View Full Code Here

        return new FetchRequest(-1, 100, 100000, fetchData);
    }

    private AbstractRequestResponse createFetchResponse() {
        Map<TopicPartition, FetchResponse.PartitionData> responseData = new HashMap<TopicPartition, FetchResponse.PartitionData>();
        responseData.put(new TopicPartition("test", 0), new FetchResponse.PartitionData((short)0, 1000000, ByteBuffer.allocate(10)));
        return new FetchResponse(responseData);
    }
View Full Code Here

TOP

Related Classes of org.apache.kafka.common.TopicPartition

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.