Examples of TopicPartition


Examples of org.apache.kafka.common.TopicPartition

                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

Examples of org.apache.kafka.common.TopicPartition

    }
   
    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

Examples of org.apache.kafka.common.TopicPartition

                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

Examples of org.apache.kafka.common.TopicPartition

        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

Examples of org.apache.kafka.common.TopicPartition

                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

Examples of org.apache.kafka.common.TopicPartition

            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

Examples of org.apache.kafka.common.TopicPartition

            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

Examples of org.apache.kafka.common.TopicPartition

        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

Examples of org.apache.kafka.common.TopicPartition

        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

Examples of org.apache.kafka.common.TopicPartition

    private AbstractRequestResponse createJoinGroupRequest() {
        return new JoinGroupRequest("group1", 30000, Arrays.asList("topic1"), "consumer1", "strategy1");
    }

    private AbstractRequestResponse createJoinGroupResponse() {
        return new JoinGroupResponse((short)0, 1, "consumer1", Arrays.asList(new TopicPartition("test11", 1), new TopicPartition("test2", 1)));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.