├── README.md └── src ├── main ├── java │ ├── org │ │ └── apache │ │ │ └── kafka │ │ │ ├── clients │ │ │ ├── admin │ │ │ │ ├── extend │ │ │ │ │ ├── FindCoordinatorOptions.java │ │ │ │ │ ├── ListGroupOffsetsOptions.java │ │ │ │ │ ├── DescribeConsumerGroupOptions.java │ │ │ │ │ ├── FindCoordinatorResult.java │ │ │ │ │ ├── DescribeConsumerGroupResult.java │ │ │ │ │ └── ListGroupOffsetsResult.java │ │ │ │ ├── model │ │ │ │ │ ├── ConsumerSummary.java │ │ │ │ │ ├── ConsumerGroupSummary.java │ │ │ │ │ └── PartitionAssignmentState.java │ │ │ │ ├── AlterReplicaLogDirsOptions.java │ │ │ │ ├── DescribeClusterOptions.java │ │ │ │ ├── CreateAclsOptions.java │ │ │ │ ├── DeleteTopicsOptions.java │ │ │ │ ├── DeleteAclsOptions.java │ │ │ │ ├── DescribeTopicsOptions.java │ │ │ │ ├── DescribeConfigsOptions.java │ │ │ │ ├── DescribeLogDirsOptions.java │ │ │ │ ├── DescribeAclsOptions.java │ │ │ │ └── DescribeReplicaLogDirsOptions.java │ │ │ ├── consumer │ │ │ │ ├── internals │ │ │ │ │ ├── RequestFutureListener.java │ │ │ │ │ ├── StaleMetadataException.java │ │ │ │ │ ├── NoAvailableBrokersException.java │ │ │ │ │ ├── RequestFutureAdapter.java │ │ │ │ │ └── NoOpConsumerRebalanceListener.java │ │ │ │ ├── OffsetResetStrategy.java │ │ │ │ └── InvalidOffsetException.java │ │ │ ├── RequestCompletionHandler.java │ │ │ ├── producer │ │ │ │ ├── BufferExhaustedException.java │ │ │ │ └── internals │ │ │ │ │ └── ProducerIdAndEpoch.java │ │ │ └── ConnectionState.java │ │ │ ├── common │ │ │ ├── header │ │ │ │ └── Header.java │ │ │ ├── network │ │ │ │ ├── Mode.java │ │ │ │ ├── InvalidReceiveException.java │ │ │ │ ├── TransportLayers.java │ │ │ │ └── NetworkSend.java │ │ │ ├── errors │ │ │ │ ├── InvalidTxnStateException.java │ │ │ │ ├── InvalidPidMappingException.java │ │ │ │ ├── DuplicateSequenceException.java │ │ │ │ ├── TransactionalIdAuthorizationException.java │ │ │ │ ├── InvalidRequiredAcksException.java │ │ │ │ ├── ConcurrentTransactionsException.java │ │ │ │ ├── AuthorizationException.java │ │ │ │ ├── InvalidGroupIdException.java │ │ │ │ ├── TopicExistsException.java │ │ │ │ ├── ControllerMovedException.java │ │ │ │ ├── NotControllerException.java │ │ │ │ ├── InvalidFetchSizeException.java │ │ │ │ ├── InvalidPartitionsException.java │ │ │ │ ├── BrokerNotAvailableException.java │ │ │ │ ├── InvalidSessionTimeoutException.java │ │ │ │ ├── GroupAuthorizationException.java │ │ │ │ ├── InvalidCommitOffsetSizeException.java │ │ │ │ ├── InvalidConfigurationException.java │ │ │ │ ├── ClusterAuthorizationException.java │ │ │ │ ├── InconsistentGroupProtocolException.java │ │ │ │ ├── InvalidReplicaAssignmentException.java │ │ │ │ ├── InvalidReplicationFactorException.java │ │ │ │ ├── TransactionCoordinatorFencedException.java │ │ │ │ ├── OperationNotAttemptedException.java │ │ │ │ ├── PolicyViolationException.java │ │ │ │ ├── ReassignmentInProgressException.java │ │ │ │ ├── InvalidTimestampException.java │ │ │ │ ├── SecurityDisabledException.java │ │ │ │ ├── ReplicaNotAvailableException.java │ │ │ │ ├── WakeupException.java │ │ │ │ ├── NotEnoughReplicasAfterAppendException.java │ │ │ │ ├── UnknownMemberIdException.java │ │ │ │ ├── UnsupportedSaslMechanismException.java │ │ │ │ ├── IllegalGenerationException.java │ │ │ │ ├── InvalidOffsetException.java │ │ │ │ ├── RebalanceInProgressException.java │ │ │ │ ├── InvalidTxnTimeoutException.java │ │ │ │ ├── LogDirNotFoundException.java │ │ │ │ ├── LeaderNotAvailableException.java │ │ │ │ ├── TimeoutException.java │ │ │ │ ├── OffsetOutOfRangeException.java │ │ │ │ ├── InvalidRequestException.java │ │ │ │ ├── RetriableException.java │ │ │ │ ├── IllegalSaslStateException.java │ │ │ │ ├── ProducerFencedException.java │ │ │ │ ├── UnsupportedForMessageFormatException.java │ │ │ │ ├── UnknownProducerIdException.java │ │ │ │ ├── InvalidMetadataException.java │ │ │ │ ├── NotEnoughReplicasException.java │ │ │ │ ├── OffsetMetadataTooLarge.java │ │ │ │ ├── RecordBatchTooLargeException.java │ │ │ │ ├── NotLeaderForPartitionException.java │ │ │ │ ├── TopicAuthorizationException.java │ │ │ │ ├── UnknownServerException.java │ │ │ │ ├── DisconnectException.java │ │ │ │ ├── OutOfOrderSequenceException.java │ │ │ │ ├── NetworkException.java │ │ │ │ ├── NotCoordinatorException.java │ │ │ │ └── InterruptException.java │ │ │ ├── security │ │ │ │ ├── kerberos │ │ │ │ │ ├── NoMatchingRule.java │ │ │ │ │ └── BadFormatString.java │ │ │ │ ├── authenticator │ │ │ │ │ └── DefaultLogin.java │ │ │ │ ├── scram │ │ │ │ │ ├── ScramCredentialCallback.java │ │ │ │ │ ├── ScramCredential.java │ │ │ │ │ └── ScramSaslClientProvider.java │ │ │ │ ├── auth │ │ │ │ │ ├── AuthenticationContext.java │ │ │ │ │ ├── PlaintextAuthenticationContext.java │ │ │ │ │ └── SslAuthenticationContext.java │ │ │ │ └── plain │ │ │ │ │ └── PlainSaslServerProvider.java │ │ │ ├── requests │ │ │ │ ├── RequestAndSize.java │ │ │ │ ├── TransactionResult.java │ │ │ │ ├── AbstractRequestResponse.java │ │ │ │ ├── IsolationLevel.java │ │ │ │ └── ResourceType.java │ │ │ ├── config │ │ │ │ ├── Config.java │ │ │ │ └── ConfigException.java │ │ │ ├── Configurable.java │ │ │ ├── utils │ │ │ │ ├── OperatingSystem.java │ │ │ │ ├── CloseableIterator.java │ │ │ │ ├── SecurityUtils.java │ │ │ │ └── ByteBufferInputStream.java │ │ │ ├── protocol │ │ │ │ └── types │ │ │ │ │ ├── SchemaException.java │ │ │ │ │ └── BoundField.java │ │ │ ├── metrics │ │ │ │ ├── MetricValueProvider.java │ │ │ │ ├── Gauge.java │ │ │ │ ├── MeasurableStat.java │ │ │ │ ├── Stat.java │ │ │ │ ├── Measurable.java │ │ │ │ └── stats │ │ │ │ │ ├── Value.java │ │ │ │ │ ├── Percentile.java │ │ │ │ │ ├── Sum.java │ │ │ │ │ ├── Count.java │ │ │ │ │ ├── Total.java │ │ │ │ │ ├── Min.java │ │ │ │ │ ├── SimpleRate.java │ │ │ │ │ └── Max.java │ │ │ ├── record │ │ │ │ ├── InvalidRecordException.java │ │ │ │ ├── AbstractRecordBatch.java │ │ │ │ ├── ConvertedRecords.java │ │ │ │ ├── RecordBatchIterator.java │ │ │ │ └── TimestampType.java │ │ │ ├── serialization │ │ │ │ ├── ByteArraySerializer.java │ │ │ │ ├── ByteArrayDeserializer.java │ │ │ │ ├── BytesSerializer.java │ │ │ │ ├── BytesDeserializer.java │ │ │ │ ├── ByteBufferDeserializer.java │ │ │ │ ├── ShortSerializer.java │ │ │ │ ├── IntegerSerializer.java │ │ │ │ ├── FloatSerializer.java │ │ │ │ └── LongSerializer.java │ │ │ ├── KafkaException.java │ │ │ └── Metric.java │ │ │ └── server │ │ │ └── policy │ │ │ └── PolicyDemo.java │ └── com │ │ └── hidden │ │ └── custom │ │ └── kafka │ │ └── admin │ │ ├── model │ │ ├── ConsumerGroupSummary.java │ │ ├── ConsumerSummary.java │ │ └── PartitionAssignmentState.java │ │ └── ConsumerGroupMainTest.java └── resources │ └── log4j.properties └── test └── java └── com └── hidden └── custom └── kafka └── admin └── ConsumerGroupUtilsTest.java /README.md: -------------------------------------------------------------------------------- 1 | 本项目主要针对Kafka做一些功能增强的实现,包括kafka-client, kafka-core等,也会包含一些生态产品,如监控类产品等。 2 | 3 | 更多内容欢迎关注:朱小厮的博客。 4 | 5 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/extend/FindCoordinatorOptions.java: -------------------------------------------------------------------------------- 1 | package org.apache.kafka.clients.admin.extend; 2 | 3 | import org.apache.kafka.clients.admin.AbstractOptions; 4 | import org.apache.kafka.common.annotation.InterfaceStability; 5 | 6 | /** 7 | * Created by hidden.zhu on 2018/4/13. 8 | */ 9 | @InterfaceStability.Evolving 10 | public class FindCoordinatorOptions extends AbstractOptions { 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/extend/ListGroupOffsetsOptions.java: -------------------------------------------------------------------------------- 1 | package org.apache.kafka.clients.admin.extend; 2 | 3 | import org.apache.kafka.clients.admin.AbstractOptions; 4 | import org.apache.kafka.common.annotation.InterfaceStability; 5 | 6 | /** 7 | * Created by hidden.zhu on 2018/4/13. 8 | */ 9 | @InterfaceStability.Evolving 10 | public class ListGroupOffsetsOptions extends AbstractOptions { 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/extend/DescribeConsumerGroupOptions.java: -------------------------------------------------------------------------------- 1 | package org.apache.kafka.clients.admin.extend; 2 | 3 | import org.apache.kafka.clients.admin.AbstractOptions; 4 | import org.apache.kafka.common.annotation.InterfaceStability; 5 | 6 | /** 7 | * Created by hidden.zhu on 2018/4/12. 8 | */ 9 | @InterfaceStability.Evolving 10 | public class DescribeConsumerGroupOptions extends AbstractOptions{ 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/hidden/custom/kafka/admin/model/ConsumerGroupSummary.java: -------------------------------------------------------------------------------- 1 | package com.hidden.custom.kafka.admin.model; 2 | 3 | import lombok.Data; 4 | import org.apache.kafka.common.Node; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by hidden.zhu on 2018/4/10. 10 | */ 11 | @Data 12 | public class ConsumerGroupSummary { 13 | private String state; 14 | private String assignmentStrategy; 15 | private List consumers; 16 | private Node coordinator; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hidden/custom/kafka/admin/model/ConsumerSummary.java: -------------------------------------------------------------------------------- 1 | package com.hidden.custom.kafka.admin.model; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | import org.apache.kafka.common.TopicPartition; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by hidden.zhu on 2018/4/10. 11 | */ 12 | @Data 13 | @Builder 14 | public class ConsumerSummary { 15 | private String consumerId; 16 | private String clientId; 17 | private String host; 18 | private List assignment; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/model/ConsumerSummary.java: -------------------------------------------------------------------------------- 1 | package org.apache.kafka.clients.admin.model; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | import org.apache.kafka.common.TopicPartition; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by hidden.zhu on 2018/4/10. 11 | */ 12 | @Data 13 | @Builder 14 | public class ConsumerSummary { 15 | private String consumerId; 16 | private String clientId; 17 | private String host; 18 | private List assignment; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/model/ConsumerGroupSummary.java: -------------------------------------------------------------------------------- 1 | package org.apache.kafka.clients.admin.model; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | import org.apache.kafka.common.Node; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by hidden.zhu on 2018/4/10. 11 | */ 12 | @Data 13 | @Builder 14 | public class ConsumerGroupSummary { 15 | private String state; 16 | private String assignmentStrategy; 17 | private List consumers; 18 | private Node coordinator; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # Global logging configuration 2 | log4j.rootLogger=WARN, stdout 3 | 4 | # Console output... 5 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 6 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 7 | log4j.appender.stdout.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} -[%p] - [%m] - [%C:%L]%n 8 | 9 | # logfile 10 | log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender 11 | log4j.appender.FILE.File=kafkatest 12 | log4j.appender.FILE.DatePattern='_'yyyy-MM-dd'.log' 13 | log4j.appender.FILE.layout=org.apache.log4j.PatternLayout 14 | log4j.appender.FILE.layout.ConversionPattern=%m%n -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/extend/FindCoordinatorResult.java: -------------------------------------------------------------------------------- 1 | package org.apache.kafka.clients.admin.extend; 2 | 3 | import org.apache.kafka.common.KafkaFuture; 4 | import org.apache.kafka.common.Node; 5 | import org.apache.kafka.common.annotation.InterfaceStability; 6 | 7 | /** 8 | * Created by hidden.zhu on 2018/4/13. 9 | */ 10 | @InterfaceStability.Evolving 11 | public class FindCoordinatorResult { 12 | private final KafkaFuture future; 13 | 14 | public FindCoordinatorResult(KafkaFuture future) { 15 | this.future = future; 16 | } 17 | 18 | public KafkaFuture values(){ 19 | return future; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/model/PartitionAssignmentState.java: -------------------------------------------------------------------------------- 1 | package org.apache.kafka.clients.admin.model; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | import org.apache.kafka.common.Node; 6 | 7 | /** 8 | * Created by hidden.zhu on 2018/4/10. 9 | */ 10 | @Data 11 | @Builder 12 | public class PartitionAssignmentState { 13 | private String group; 14 | private Node coordinator; 15 | private String topic; 16 | private int partition; 17 | private long offset; 18 | private long lag; 19 | private String consumerId; 20 | private String host; 21 | private String clientId; 22 | private long logEndOffset; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/extend/DescribeConsumerGroupResult.java: -------------------------------------------------------------------------------- 1 | package org.apache.kafka.clients.admin.extend; 2 | 3 | import org.apache.kafka.clients.admin.model.ConsumerGroupSummary; 4 | import org.apache.kafka.common.KafkaFuture; 5 | import org.apache.kafka.common.annotation.InterfaceStability; 6 | 7 | /** 8 | * Created by hidden.zhu on 2018/4/12. 9 | */ 10 | @InterfaceStability.Evolving 11 | public class DescribeConsumerGroupResult { 12 | private final KafkaFuture future; 13 | 14 | public DescribeConsumerGroupResult(KafkaFuture future) { 15 | this.future = future; 16 | } 17 | 18 | public KafkaFuture values(){ 19 | return future; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/extend/ListGroupOffsetsResult.java: -------------------------------------------------------------------------------- 1 | package org.apache.kafka.clients.admin.extend; 2 | 3 | import org.apache.kafka.common.TopicPartition; 4 | import org.apache.kafka.common.annotation.InterfaceStability; 5 | import org.apache.kafka.common.internals.KafkaFutureImpl; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | * Created by hidden.zhu on 2018/4/13. 11 | */ 12 | @InterfaceStability.Evolving 13 | public class ListGroupOffsetsResult { 14 | private final KafkaFutureImpl> future; 15 | 16 | public ListGroupOffsetsResult(KafkaFutureImpl> future) { 17 | this.future = future; 18 | } 19 | 20 | public KafkaFutureImpl> values(){ 21 | return this.future; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/hidden/custom/kafka/admin/model/PartitionAssignmentState.java: -------------------------------------------------------------------------------- 1 | package com.hidden.custom.kafka.admin.model; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | /** 7 | * Created by hidden.zhu on 2018/4/10. 8 | */ 9 | @Data 10 | @Builder 11 | public class PartitionAssignmentState { 12 | private String group; 13 | private Node coordinator; 14 | private String topic; 15 | private int partition; 16 | private long offset; 17 | private long lag; 18 | private String consumerId; 19 | private String host; 20 | private String clientId; 21 | private long logEndOffset; 22 | 23 | @Data 24 | public static class Node{ 25 | public int id; 26 | public String idString; 27 | public String host; 28 | public int port; 29 | public String rack; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/header/Header.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.header; 18 | 19 | public interface Header { 20 | 21 | String key(); 22 | 23 | byte[] value(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/network/Mode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.network; 18 | 19 | /** 20 | * Connection mode for SSL and SASL connections. 21 | */ 22 | public enum Mode { CLIENT, SERVER } 23 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/server/policy/PolicyDemo.java: -------------------------------------------------------------------------------- 1 | package org.apache.kafka.server.policy; 2 | 3 | import java.util.Map; 4 | 5 | import org.apache.kafka.common.errors.PolicyViolationException; 6 | 7 | public class PolicyDemo implements CreateTopicPolicy{ 8 | public void configure(Map configs) { 9 | System.out.println(configs); 10 | } 11 | 12 | public void close() throws Exception {} 13 | 14 | public void validate(RequestMetadata requestMetadata) 15 | throws PolicyViolationException { 16 | System.out.println(requestMetadata); 17 | if(requestMetadata.numPartitions()!=null || requestMetadata.replicationFactor()!=null){ 18 | if(requestMetadata.numPartitions()< 5){ 19 | throw new PolicyViolationException("Topic should have at least 5 partitions, received: " 20 | + requestMetadata.numPartitions()); 21 | } 22 | if(requestMetadata.replicationFactor()<= 1){ 23 | throw new PolicyViolationException("Topic should have at least 2 replication factor, recevied: " 24 | + requestMetadata.replicationFactor()); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidTxnStateException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class InvalidTxnStateException extends ApiException { 20 | public InvalidTxnStateException(String message) { 21 | super(message); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidPidMappingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class InvalidPidMappingException extends ApiException { 20 | public InvalidPidMappingException(String message) { 21 | super(message); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/DuplicateSequenceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class DuplicateSequenceException extends ApiException { 20 | 21 | public DuplicateSequenceException(String message) { 22 | super(message); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/security/kerberos/NoMatchingRule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.security.kerberos; 18 | 19 | import java.io.IOException; 20 | 21 | public class NoMatchingRule extends IOException { 22 | NoMatchingRule(String msg) { 23 | super(msg); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/TransactionalIdAuthorizationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class TransactionalIdAuthorizationException extends AuthorizationException { 20 | public TransactionalIdAuthorizationException(final String message) { 21 | super(message); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/hidden/custom/kafka/admin/ConsumerGroupUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.hidden.custom.kafka.admin; 2 | 3 | import org.apache.kafka.clients.consumer.KafkaConsumer; 4 | import org.apache.kafka.common.TopicPartition; 5 | import org.junit.Test; 6 | 7 | import java.util.ArrayList; 8 | import java.util.Collection; 9 | 10 | 11 | /** 12 | * Created by hidden.zhu on 2018/4/19. 13 | */ 14 | public class ConsumerGroupUtilsTest { 15 | @Test 16 | public void createNewConsumer() throws Exception { 17 | String brokerUrl = "localhost:9092"; 18 | String groupId = "ITSNOTMATTER"; 19 | String topic = "topic-test1"; 20 | KafkaConsumer consumer = ConsumerGroupUtils.createNewConsumer(brokerUrl, groupId); 21 | Collection collection = new ArrayList<>(); 22 | collection.add(new TopicPartition(topic, 0)); 23 | collection.add(new TopicPartition(topic, 1)); 24 | collection.add(new TopicPartition(topic, 2)); 25 | collection.add(new TopicPartition(topic, 3)); 26 | System.out.println(consumer.endOffsets(collection)); 27 | } 28 | 29 | @Test 30 | public void printPasList() throws Exception { 31 | 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidRequiredAcksException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class InvalidRequiredAcksException extends ApiException { 20 | private static final long serialVersionUID = 1L; 21 | 22 | public InvalidRequiredAcksException(String message) { 23 | super(message); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/consumer/internals/RequestFutureListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.clients.consumer.internals; 18 | 19 | /** 20 | * Listener interface to hook into RequestFuture completion. 21 | */ 22 | public interface RequestFutureListener { 23 | 24 | void onSuccess(T value); 25 | 26 | void onFailure(RuntimeException e); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/ConcurrentTransactionsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class ConcurrentTransactionsException extends ApiException { 20 | private static final long serialVersionUID = 1L; 21 | 22 | public ConcurrentTransactionsException(final String message) { 23 | super(message); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/security/authenticator/DefaultLogin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.security.authenticator; 18 | 19 | public class DefaultLogin extends AbstractLogin { 20 | 21 | @Override 22 | public String serviceName() { 23 | return "kafka"; 24 | } 25 | 26 | @Override 27 | public void close() { 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/requests/RequestAndSize.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.requests; 18 | 19 | public class RequestAndSize { 20 | public final AbstractRequest request; 21 | public final int size; 22 | 23 | public RequestAndSize(AbstractRequest request, int size) { 24 | this.request = request; 25 | this.size = size; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/security/kerberos/BadFormatString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.security.kerberos; 18 | 19 | import java.io.IOException; 20 | 21 | public class BadFormatString extends IOException { 22 | BadFormatString(String msg) { 23 | super(msg); 24 | } 25 | BadFormatString(String msg, Throwable err) { 26 | super(msg, err); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/AuthorizationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class AuthorizationException extends ApiException { 20 | 21 | public AuthorizationException(String message) { 22 | super(message); 23 | } 24 | 25 | public AuthorizationException(String message, Throwable cause) { 26 | super(message, cause); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/consumer/internals/StaleMetadataException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.clients.consumer.internals; 18 | 19 | import org.apache.kafka.common.errors.InvalidMetadataException; 20 | 21 | /** 22 | * Thrown when metadata is old and needs to be refreshed. 23 | */ 24 | public class StaleMetadataException extends InvalidMetadataException { 25 | private static final long serialVersionUID = 1L; 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/consumer/internals/NoAvailableBrokersException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.clients.consumer.internals; 18 | 19 | import org.apache.kafka.common.errors.InvalidMetadataException; 20 | 21 | /** 22 | * No brokers were available to complete a request. 23 | */ 24 | public class NoAvailableBrokersException extends InvalidMetadataException { 25 | private static final long serialVersionUID = 1L; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/config/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.config; 18 | 19 | import java.util.List; 20 | 21 | public class Config { 22 | private final List configValues; 23 | 24 | public Config(List configValues) { 25 | this.configValues = configValues; 26 | } 27 | 28 | public List configValues() { 29 | return configValues; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/Configurable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common; 18 | 19 | import java.util.Map; 20 | 21 | /** 22 | * A Mix-in style interface for classes that are instantiated by reflection and need to take configuration parameters 23 | */ 24 | public interface Configurable { 25 | 26 | /** 27 | * Configure this class with the given key-value pairs 28 | */ 29 | void configure(Map configs); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidGroupIdException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class InvalidGroupIdException extends ApiException { 20 | private static final long serialVersionUID = 1L; 21 | 22 | public InvalidGroupIdException(String message, Throwable cause) { 23 | super(message, cause); 24 | } 25 | 26 | public InvalidGroupIdException(String message) { 27 | super(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/TopicExistsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class TopicExistsException extends ApiException { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public TopicExistsException(String message) { 24 | super(message); 25 | } 26 | 27 | public TopicExistsException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/AlterReplicaLogDirsOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.kafka.clients.admin; 19 | 20 | import org.apache.kafka.common.annotation.InterfaceStability; 21 | import java.util.Map; 22 | 23 | /** 24 | * Options for {@link AdminClient#alterReplicaLogDirs(Map, AlterReplicaLogDirsOptions)}. 25 | */ 26 | @InterfaceStability.Evolving 27 | public class AlterReplicaLogDirsOptions extends AbstractOptions { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/network/InvalidReceiveException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.network; 18 | 19 | import org.apache.kafka.common.KafkaException; 20 | 21 | public class InvalidReceiveException extends KafkaException { 22 | 23 | public InvalidReceiveException(String message) { 24 | super(message); 25 | } 26 | 27 | public InvalidReceiveException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/RequestCompletionHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.clients; 18 | 19 | /** 20 | * A callback interface for attaching an action to be executed when a request is complete and the corresponding response 21 | * has been received. This handler will also be invoked if there is a disconnection while handling the request. 22 | */ 23 | public interface RequestCompletionHandler { 24 | 25 | public void onComplete(ClientResponse response); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/ControllerMovedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class ControllerMovedException extends ApiException { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public ControllerMovedException(String message) { 24 | super(message); 25 | } 26 | 27 | public ControllerMovedException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/NotControllerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class NotControllerException extends RetriableException { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public NotControllerException(String message) { 24 | super(message); 25 | } 26 | 27 | public NotControllerException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/DescribeClusterOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.kafka.clients.admin; 19 | 20 | import org.apache.kafka.common.annotation.InterfaceStability; 21 | 22 | /** 23 | * Options for {@link AdminClient#describeCluster()}. 24 | * 25 | * The API of this class is evolving, see {@link AdminClient} for details. 26 | */ 27 | @InterfaceStability.Evolving 28 | public class DescribeClusterOptions extends AbstractOptions { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidFetchSizeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class InvalidFetchSizeException extends ApiException { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public InvalidFetchSizeException(String message) { 24 | super(message); 25 | } 26 | 27 | public InvalidFetchSizeException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidPartitionsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class InvalidPartitionsException extends ApiException { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public InvalidPartitionsException(String message) { 24 | super(message); 25 | } 26 | 27 | public InvalidPartitionsException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/BrokerNotAvailableException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class BrokerNotAvailableException extends ApiException { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public BrokerNotAvailableException(String message) { 24 | super(message); 25 | } 26 | 27 | public BrokerNotAvailableException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidSessionTimeoutException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class InvalidSessionTimeoutException extends ApiException { 20 | private static final long serialVersionUID = 1L; 21 | 22 | public InvalidSessionTimeoutException(String message, Throwable cause) { 23 | super(message, cause); 24 | } 25 | 26 | public InvalidSessionTimeoutException(String message) { 27 | super(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/GroupAuthorizationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class GroupAuthorizationException extends AuthorizationException { 20 | private final String groupId; 21 | 22 | public GroupAuthorizationException(String groupId) { 23 | super("Not authorized to access group: " + groupId); 24 | this.groupId = groupId; 25 | } 26 | 27 | public String groupId() { 28 | return groupId; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidCommitOffsetSizeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class InvalidCommitOffsetSizeException extends ApiException { 20 | private static final long serialVersionUID = 1L; 21 | 22 | public InvalidCommitOffsetSizeException(String message, Throwable cause) { 23 | super(message, cause); 24 | } 25 | 26 | public InvalidCommitOffsetSizeException(String message) { 27 | super(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidConfigurationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class InvalidConfigurationException extends ApiException { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public InvalidConfigurationException(String message) { 24 | super(message); 25 | } 26 | 27 | public InvalidConfigurationException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/ClusterAuthorizationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class ClusterAuthorizationException extends AuthorizationException { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public ClusterAuthorizationException(String message) { 24 | super(message); 25 | } 26 | 27 | public ClusterAuthorizationException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/utils/OperatingSystem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.utils; 18 | 19 | import java.util.Locale; 20 | 21 | public final class OperatingSystem { 22 | 23 | private OperatingSystem() { 24 | } 25 | 26 | public static final String NAME; 27 | 28 | public static final boolean IS_WINDOWS; 29 | 30 | static { 31 | NAME = System.getProperty("os.name").toLowerCase(Locale.ROOT); 32 | IS_WINDOWS = NAME.startsWith("windows"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InconsistentGroupProtocolException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class InconsistentGroupProtocolException extends ApiException { 20 | private static final long serialVersionUID = 1L; 21 | 22 | public InconsistentGroupProtocolException(String message, Throwable cause) { 23 | super(message, cause); 24 | } 25 | 26 | public InconsistentGroupProtocolException(String message) { 27 | super(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/protocol/types/SchemaException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.protocol.types; 18 | 19 | import org.apache.kafka.common.KafkaException; 20 | 21 | /** 22 | * Thrown if the protocol schema validation fails while parsing request or response. 23 | */ 24 | public class SchemaException extends KafkaException { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | public SchemaException(String message) { 29 | super(message); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/CreateAclsOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.kafka.clients.admin; 19 | 20 | import org.apache.kafka.common.annotation.InterfaceStability; 21 | 22 | import java.util.Collection; 23 | 24 | /** 25 | * Options for {@link AdminClient#createAcls(Collection)}. 26 | * 27 | * The API of this class is evolving, see {@link AdminClient} for details. 28 | */ 29 | @InterfaceStability.Evolving 30 | public class CreateAclsOptions extends AbstractOptions { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidReplicaAssignmentException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class InvalidReplicaAssignmentException extends ApiException { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public InvalidReplicaAssignmentException(String message) { 24 | super(message); 25 | } 26 | 27 | public InvalidReplicaAssignmentException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidReplicationFactorException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class InvalidReplicationFactorException extends ApiException { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public InvalidReplicationFactorException(String message) { 24 | super(message); 25 | } 26 | 27 | public InvalidReplicationFactorException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/DeleteTopicsOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.kafka.clients.admin; 19 | 20 | import org.apache.kafka.common.annotation.InterfaceStability; 21 | 22 | import java.util.Collection; 23 | 24 | /** 25 | * Options for {@link AdminClient#deleteTopics(Collection)}. 26 | * 27 | * The API of this class is evolving, see {@link AdminClient} for details. 28 | */ 29 | @InterfaceStability.Evolving 30 | public class DeleteTopicsOptions extends AbstractOptions { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/requests/TransactionResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.requests; 18 | 19 | public enum TransactionResult { 20 | ABORT(false), COMMIT(true); 21 | 22 | public final boolean id; 23 | 24 | TransactionResult(boolean id) { 25 | this.id = id; 26 | } 27 | 28 | public static TransactionResult forId(boolean id) { 29 | if (id) { 30 | return TransactionResult.COMMIT; 31 | } 32 | return TransactionResult.ABORT; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/DeleteAclsOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.kafka.clients.admin; 19 | 20 | import org.apache.kafka.common.annotation.InterfaceStability; 21 | 22 | import java.util.Collection; 23 | 24 | /** 25 | * Options for the {@link AdminClient#deleteAcls(Collection)} call. 26 | * 27 | * The API of this class is evolving, see {@link AdminClient} for details. 28 | */ 29 | @InterfaceStability.Evolving 30 | public class DeleteAclsOptions extends AbstractOptions { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/TransactionCoordinatorFencedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class TransactionCoordinatorFencedException extends ApiException { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public TransactionCoordinatorFencedException(String message) { 24 | super(message); 25 | } 26 | 27 | public TransactionCoordinatorFencedException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/DescribeTopicsOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.kafka.clients.admin; 19 | 20 | import org.apache.kafka.common.annotation.InterfaceStability; 21 | 22 | import java.util.Collection; 23 | 24 | /** 25 | * Options for {@link AdminClient#describeTopics(Collection)}. 26 | * 27 | * The API of this class is evolving, see {@link AdminClient} for details. 28 | */ 29 | @InterfaceStability.Evolving 30 | public class DescribeTopicsOptions extends AbstractOptions { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/DescribeConfigsOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.kafka.clients.admin; 19 | 20 | import org.apache.kafka.common.annotation.InterfaceStability; 21 | 22 | import java.util.Collection; 23 | 24 | /** 25 | * Options for {@link AdminClient#describeConfigs(Collection)}. 26 | * 27 | * The API of this class is evolving, see {@link AdminClient} for details. 28 | */ 29 | @InterfaceStability.Evolving 30 | public class DescribeConfigsOptions extends AbstractOptions { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/OperationNotAttemptedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * Indicates that the broker did not attempt to execute this operation. This may happen for batched RPCs where some 21 | * operations in the batch failed, causing the broker to respond without trying the rest. 22 | */ 23 | public class OperationNotAttemptedException extends ApiException { 24 | public OperationNotAttemptedException(final String message) { 25 | super(message); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/PolicyViolationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * Exception thrown if a create topics request does not satisfy the configured policy for a topic. 21 | */ 22 | public class PolicyViolationException extends ApiException { 23 | 24 | public PolicyViolationException(String message) { 25 | super(message); 26 | } 27 | 28 | public PolicyViolationException(String message, Throwable cause) { 29 | super(message, cause); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/DescribeLogDirsOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.kafka.clients.admin; 19 | 20 | import org.apache.kafka.common.annotation.InterfaceStability; 21 | 22 | import java.util.Collection; 23 | 24 | 25 | /** 26 | * Options for {@link AdminClient#describeLogDirs(Collection)} 27 | * 28 | * The API of this class is evolving, see {@link AdminClient} for details. 29 | */ 30 | @InterfaceStability.Evolving 31 | public class DescribeLogDirsOptions extends AbstractOptions { 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/metrics/MetricValueProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.metrics; 18 | 19 | /** 20 | * Super-interface for {@link Measurable} or {@link Gauge} that provides 21 | * metric values. 22 | *

23 | * In the future for Java8 and above, {@link Gauge#value(MetricConfig, long)} will be 24 | * moved to this interface with a default implementation in {@link Measurable} that returns 25 | * {@link Measurable#measure(MetricConfig, long)}. 26 | *

27 | */ 28 | public interface MetricValueProvider { } 29 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/security/scram/ScramCredentialCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.security.scram; 18 | 19 | import javax.security.auth.callback.Callback; 20 | 21 | public class ScramCredentialCallback implements Callback { 22 | private ScramCredential scramCredential; 23 | 24 | public ScramCredential scramCredential() { 25 | return scramCredential; 26 | } 27 | 28 | public void scramCredential(ScramCredential scramCredential) { 29 | this.scramCredential = scramCredential; 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/DescribeAclsOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.kafka.clients.admin; 19 | 20 | import org.apache.kafka.common.acl.AclBindingFilter; 21 | import org.apache.kafka.common.annotation.InterfaceStability; 22 | 23 | /** 24 | * Options for {@link AdminClient#describeAcls(AclBindingFilter)}. 25 | * 26 | * The API of this class is evolving, see {@link AdminClient} for details. 27 | */ 28 | @InterfaceStability.Evolving 29 | public class DescribeAclsOptions extends AbstractOptions { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/ReassignmentInProgressException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.kafka.common.errors; 19 | 20 | /** 21 | * Thrown if a request cannot be completed because a partition reassignment is in progress. 22 | */ 23 | public class ReassignmentInProgressException extends ApiException { 24 | 25 | public ReassignmentInProgressException(String msg) { 26 | super(msg); 27 | } 28 | 29 | public ReassignmentInProgressException(String msg, Throwable cause) { 30 | super(msg, cause); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/record/InvalidRecordException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.record; 18 | 19 | import org.apache.kafka.common.errors.CorruptRecordException; 20 | 21 | public class InvalidRecordException extends CorruptRecordException { 22 | 23 | private static final long serialVersionUID = 1; 24 | 25 | public InvalidRecordException(String s) { 26 | super(s); 27 | } 28 | 29 | public InvalidRecordException(String message, Throwable cause) { 30 | super(message, cause); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidTimestampException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * Indicate the timestamp of a record is invalid. 21 | */ 22 | public class InvalidTimestampException extends ApiException { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | public InvalidTimestampException(String message) { 27 | super(message); 28 | } 29 | 30 | public InvalidTimestampException(String message, Throwable cause) { 31 | super(message, cause); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/metrics/Gauge.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.metrics; 18 | 19 | /** 20 | * A gauge metric is an instantaneous reading of a particular value. 21 | */ 22 | public interface Gauge extends MetricValueProvider { 23 | 24 | /** 25 | * Returns the current value associated with this gauge. 26 | * @param config The configuration for this metric 27 | * @param now The POSIX time in milliseconds the measurement is being taken 28 | */ 29 | T value(MetricConfig config, long now); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/admin/DescribeReplicaLogDirsOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.kafka.clients.admin; 19 | 20 | import org.apache.kafka.common.annotation.InterfaceStability; 21 | import java.util.Collection; 22 | 23 | /** 24 | * Options for {@link AdminClient#describeReplicaLogDirs(Collection)}. 25 | * 26 | * The API of this class is evolving, see {@link AdminClient} for details. 27 | */ 28 | @InterfaceStability.Evolving 29 | public class DescribeReplicaLogDirsOptions extends AbstractOptions { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/consumer/internals/RequestFutureAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.clients.consumer.internals; 18 | 19 | /** 20 | * Adapt from a request future of one type to another. 21 | * 22 | * @param Type to adapt from 23 | * @param Type to adapt to 24 | */ 25 | public abstract class RequestFutureAdapter { 26 | 27 | public abstract void onSuccess(F value, RequestFuture future); 28 | 29 | public void onFailure(RuntimeException e, RequestFuture future) { 30 | future.raise(e); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/SecurityDisabledException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * An error indicating that security is disabled on the broker. 21 | */ 22 | public class SecurityDisabledException extends ApiException { 23 | private static final long serialVersionUID = 1L; 24 | 25 | public SecurityDisabledException(String message) { 26 | super(message); 27 | } 28 | 29 | public SecurityDisabledException(String message, Throwable cause) { 30 | super(message, cause); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/metrics/MeasurableStat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.metrics; 18 | 19 | /** 20 | * A MeasurableStat is a {@link Stat} that is also {@link Measurable} (i.e. can produce a single floating point value). 21 | * This is the interface used for most of the simple statistics such as {@link org.apache.kafka.common.metrics.stats.Avg}, 22 | * {@link org.apache.kafka.common.metrics.stats.Max}, {@link org.apache.kafka.common.metrics.stats.Count}, etc. 23 | */ 24 | public interface MeasurableStat extends Stat, Measurable { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/record/AbstractRecordBatch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.record; 18 | 19 | abstract class AbstractRecordBatch implements RecordBatch { 20 | 21 | @Override 22 | public boolean hasProducerId() { 23 | return RecordBatch.NO_PRODUCER_ID < producerId(); 24 | } 25 | 26 | @Override 27 | public long nextOffset() { 28 | return lastOffset() + 1; 29 | } 30 | 31 | @Override 32 | public boolean isCompressed() { 33 | return compressionType() != CompressionType.NONE; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/serialization/ByteArraySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.serialization; 18 | 19 | import java.util.Map; 20 | 21 | public class ByteArraySerializer implements Serializer { 22 | 23 | @Override 24 | public void configure(Map configs, boolean isKey) { 25 | // nothing to do 26 | } 27 | 28 | @Override 29 | public byte[] serialize(String topic, byte[] data) { 30 | return data; 31 | } 32 | 33 | @Override 34 | public void close() { 35 | // nothing to do 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/utils/CloseableIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.utils; 18 | 19 | import java.io.Closeable; 20 | import java.util.Iterator; 21 | 22 | /** 23 | * Iterators that need to be closed in order to release resources should implement this interface. 24 | * 25 | * Warning: before implementing this interface, consider if there are better options. The chance of misuse is 26 | * a bit high since people are used to iterating without closing. 27 | */ 28 | public interface CloseableIterator extends Iterator, Closeable { 29 | void close(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/metrics/Stat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.metrics; 18 | 19 | /** 20 | * A Stat is a quantity such as average, max, etc that is computed off the stream of updates to a sensor 21 | */ 22 | public interface Stat { 23 | 24 | /** 25 | * Record the given value 26 | * @param config The configuration to use for this metric 27 | * @param value The value to record 28 | * @param timeMs The POSIX time in milliseconds this value occurred 29 | */ 30 | public void record(MetricConfig config, double value, long timeMs); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/serialization/ByteArrayDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.serialization; 18 | 19 | import java.util.Map; 20 | 21 | public class ByteArrayDeserializer implements Deserializer { 22 | 23 | @Override 24 | public void configure(Map configs, boolean isKey) { 25 | // nothing to do 26 | } 27 | 28 | @Override 29 | public byte[] deserialize(String topic, byte[] data) { 30 | return data; 31 | } 32 | 33 | @Override 34 | public void close() { 35 | // nothing to do 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/metrics/Measurable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.metrics; 18 | 19 | /** 20 | * A measurable quantity that can be registered as a metric 21 | */ 22 | public interface Measurable extends MetricValueProvider { 23 | 24 | /** 25 | * Measure this quantity and return the result as a double 26 | * @param config The configuration for this metric 27 | * @param now The POSIX time in milliseconds the measurement is being taken 28 | * @return The measured value 29 | */ 30 | double measure(MetricConfig config, long now); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/ReplicaNotAvailableException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class ReplicaNotAvailableException extends ApiException { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public ReplicaNotAvailableException(String message) { 24 | super(message); 25 | } 26 | 27 | public ReplicaNotAvailableException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | 31 | public ReplicaNotAvailableException(Throwable cause) { 32 | super(cause); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/protocol/types/BoundField.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.protocol.types; 18 | 19 | /** 20 | * A field definition bound to a particular schema. 21 | */ 22 | public class BoundField { 23 | public final Field def; 24 | final int index; 25 | final Schema schema; 26 | 27 | public BoundField(Field def, Schema schema, int index) { 28 | this.def = def; 29 | this.schema = schema; 30 | this.index = index; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return def.name + ":" + def.type; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/consumer/internals/NoOpConsumerRebalanceListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.clients.consumer.internals; 18 | 19 | import org.apache.kafka.clients.consumer.ConsumerRebalanceListener; 20 | import org.apache.kafka.common.TopicPartition; 21 | 22 | import java.util.Collection; 23 | 24 | public class NoOpConsumerRebalanceListener implements ConsumerRebalanceListener { 25 | 26 | @Override 27 | public void onPartitionsAssigned(Collection partitions) {} 28 | 29 | @Override 30 | public void onPartitionsRevoked(Collection partitions) {} 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/metrics/stats/Value.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.metrics.stats; 18 | 19 | import org.apache.kafka.common.metrics.MeasurableStat; 20 | import org.apache.kafka.common.metrics.MetricConfig; 21 | 22 | /** 23 | * An instantaneous value. 24 | */ 25 | public class Value implements MeasurableStat { 26 | private double value = 0; 27 | 28 | @Override 29 | public double measure(MetricConfig config, long now) { 30 | return value; 31 | } 32 | 33 | @Override 34 | public void record(MetricConfig config, double value, long timeMs) { 35 | this.value = value; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/metrics/stats/Percentile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.metrics.stats; 18 | 19 | import org.apache.kafka.common.MetricName; 20 | 21 | public class Percentile { 22 | 23 | private final MetricName name; 24 | private final double percentile; 25 | 26 | public Percentile(MetricName name, double percentile) { 27 | super(); 28 | this.name = name; 29 | this.percentile = percentile; 30 | } 31 | 32 | public MetricName name() { 33 | return this.name; 34 | } 35 | 36 | public double percentile() { 37 | return this.percentile; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/producer/BufferExhaustedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.clients.producer; 18 | 19 | import org.apache.kafka.common.KafkaException; 20 | 21 | /** 22 | * This exception is thrown if the producer is in non-blocking mode and the rate of data production exceeds the rate at 23 | * which data can be sent for long enough for the allocated buffer to be exhausted. 24 | */ 25 | public class BufferExhaustedException extends KafkaException { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | public BufferExhaustedException(String message) { 30 | super(message); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/WakeupException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | import org.apache.kafka.common.KafkaException; 20 | 21 | /** 22 | * Exception used to indicate preemption of a blocking operation by an external thread. 23 | * For example, {@link org.apache.kafka.clients.consumer.KafkaConsumer#wakeup} 24 | * can be used to break out of an active {@link org.apache.kafka.clients.consumer.KafkaConsumer#poll(long)}, 25 | * which would raise an instance of this exception. 26 | */ 27 | public class WakeupException extends KafkaException { 28 | private static final long serialVersionUID = 1L; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/serialization/BytesSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.serialization; 18 | 19 | import org.apache.kafka.common.utils.Bytes; 20 | 21 | import java.util.Map; 22 | 23 | public class BytesSerializer implements Serializer { 24 | 25 | public void configure(Map configs, boolean isKey) { 26 | // nothing to do 27 | } 28 | 29 | public byte[] serialize(String topic, Bytes data) { 30 | if (data == null) 31 | return null; 32 | 33 | return data.get(); 34 | } 35 | 36 | public void close() { 37 | // nothing to do 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/NotEnoughReplicasAfterAppendException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * Number of insync replicas for the partition is lower than min.insync.replicas This exception is raised when the low 21 | * ISR size is discovered *after* the message was already appended to the log. Producer retries will cause duplicates. 22 | */ 23 | public class NotEnoughReplicasAfterAppendException extends RetriableException { 24 | private static final long serialVersionUID = 1L; 25 | 26 | public NotEnoughReplicasAfterAppendException(String message) { 27 | super(message); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/UnknownMemberIdException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class UnknownMemberIdException extends ApiException { 20 | private static final long serialVersionUID = 1L; 21 | 22 | public UnknownMemberIdException() { 23 | super(); 24 | } 25 | 26 | public UnknownMemberIdException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | 30 | public UnknownMemberIdException(String message) { 31 | super(message); 32 | } 33 | 34 | public UnknownMemberIdException(Throwable cause) { 35 | super(cause); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/serialization/BytesDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.serialization; 18 | 19 | import org.apache.kafka.common.utils.Bytes; 20 | 21 | import java.util.Map; 22 | 23 | public class BytesDeserializer implements Deserializer { 24 | 25 | public void configure(Map configs, boolean isKey) { 26 | // nothing to do 27 | } 28 | 29 | public Bytes deserialize(String topic, byte[] data) { 30 | if (data == null) 31 | return null; 32 | 33 | return new Bytes(data); 34 | } 35 | 36 | public void close() { 37 | // nothing to do 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/security/auth/AuthenticationContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.security.auth; 18 | 19 | import java.net.InetAddress; 20 | 21 | /** 22 | * An object representing contextual information from the authentication session. See 23 | * {@link SaslAuthenticationContext} and {@link SslAuthenticationContext}. 24 | */ 25 | public interface AuthenticationContext { 26 | /** 27 | * Underlying security protocol of the authentication session. 28 | */ 29 | SecurityProtocol securityProtocol(); 30 | 31 | /** 32 | * Address of the authenticated client 33 | */ 34 | InetAddress clientAddress(); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/serialization/ByteBufferDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.serialization; 18 | 19 | import java.nio.ByteBuffer; 20 | import java.util.Map; 21 | 22 | public class ByteBufferDeserializer implements Deserializer { 23 | 24 | public void configure(Map configs, boolean isKey) { 25 | // nothing to do 26 | } 27 | 28 | public ByteBuffer deserialize(String topic, byte[] data) { 29 | if (data == null) 30 | return null; 31 | 32 | return ByteBuffer.wrap(data); 33 | } 34 | 35 | public void close() { 36 | // nothing to do 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/UnsupportedSaslMechanismException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * This exception indicates that the SASL mechanism requested by the client 21 | * is not enabled on the broker. 22 | */ 23 | public class UnsupportedSaslMechanismException extends AuthenticationException { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | public UnsupportedSaslMechanismException(String message) { 28 | super(message); 29 | } 30 | 31 | public UnsupportedSaslMechanismException(String message, Throwable cause) { 32 | super(message, cause); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/KafkaException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common; 18 | 19 | /** 20 | * The base class of all other Kafka exceptions 21 | */ 22 | public class KafkaException extends RuntimeException { 23 | 24 | private final static long serialVersionUID = 1L; 25 | 26 | public KafkaException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | 30 | public KafkaException(String message) { 31 | super(message); 32 | } 33 | 34 | public KafkaException(Throwable cause) { 35 | super(cause); 36 | } 37 | 38 | public KafkaException() { 39 | super(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/IllegalGenerationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class IllegalGenerationException extends ApiException { 20 | private static final long serialVersionUID = 1L; 21 | 22 | public IllegalGenerationException() { 23 | super(); 24 | } 25 | 26 | public IllegalGenerationException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | 30 | public IllegalGenerationException(String message) { 31 | super(message); 32 | } 33 | 34 | public IllegalGenerationException(Throwable cause) { 35 | super(cause); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/requests/AbstractRequestResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.requests; 18 | 19 | import org.apache.kafka.common.protocol.types.Struct; 20 | 21 | import java.nio.ByteBuffer; 22 | 23 | public abstract class AbstractRequestResponse { 24 | /** 25 | * Visible for testing. 26 | */ 27 | public static ByteBuffer serialize(Struct headerStruct, Struct bodyStruct) { 28 | ByteBuffer buffer = ByteBuffer.allocate(headerStruct.sizeOf() + bodyStruct.sizeOf()); 29 | headerStruct.writeTo(buffer); 30 | bodyStruct.writeTo(buffer); 31 | buffer.rewind(); 32 | return buffer; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/serialization/ShortSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.serialization; 18 | 19 | import java.util.Map; 20 | 21 | public class ShortSerializer implements Serializer { 22 | 23 | public void configure(Map configs, boolean isKey) { 24 | // nothing to do 25 | } 26 | 27 | public byte[] serialize(String topic, Short data) { 28 | if (data == null) 29 | return null; 30 | 31 | return new byte[] { 32 | (byte) (data >>> 8), 33 | data.byteValue() 34 | }; 35 | } 36 | 37 | public void close() { 38 | // nothing to do 39 | } 40 | } -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/consumer/OffsetResetStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.clients.consumer; 18 | 19 | public enum OffsetResetStrategy { 20 | LATEST, EARLIEST, NONE 21 | } 22 | /** 23 | * What to do when there is no initial offset in Kafka or if the current offset does not 24 | * exist any more on the server (e.g. because that data has been deleted): 25 | - earliest: automatically reset the offset to the earliest offset 26 | - latest: automatically reset the offset to the latest offset 27 | - none: throw exception to the consumer if no previous offset is found for the consumer's group 28 | - anything else: throw exception to the consumer. 29 | */ 30 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidOffsetException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * Thrown when the offset for a set of partitions is invalid (either undefined or out of range), 21 | * and no reset policy has been configured. 22 | * @see OffsetOutOfRangeException 23 | */ 24 | public class InvalidOffsetException extends ApiException { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | public InvalidOffsetException(String message) { 29 | super(message); 30 | } 31 | 32 | public InvalidOffsetException(String message, Throwable cause) { 33 | super(message, cause); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/RebalanceInProgressException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | public class RebalanceInProgressException extends ApiException { 20 | private static final long serialVersionUID = 1L; 21 | 22 | public RebalanceInProgressException() { 23 | super(); 24 | } 25 | 26 | public RebalanceInProgressException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | 30 | public RebalanceInProgressException(String message) { 31 | super(message); 32 | } 33 | 34 | public RebalanceInProgressException(Throwable cause) { 35 | super(cause); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidTxnTimeoutException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * The transaction coordinator returns this error code if the timeout received via the InitProducerIdRequest is larger than 21 | * the `max.transaction.timeout.ms` config value. 22 | */ 23 | public class InvalidTxnTimeoutException extends ApiException { 24 | private static final long serialVersionUID = 1L; 25 | 26 | public InvalidTxnTimeoutException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | 30 | public InvalidTxnTimeoutException(String message) { 31 | super(message); 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/LogDirNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * Thrown when a request is made for a log directory that is not present on the broker 21 | */ 22 | public class LogDirNotFoundException extends ApiException { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | public LogDirNotFoundException(String message) { 27 | super(message); 28 | } 29 | 30 | public LogDirNotFoundException(String message, Throwable cause) { 31 | super(message, cause); 32 | } 33 | 34 | public LogDirNotFoundException(Throwable cause) { 35 | super(cause); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/record/ConvertedRecords.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.record; 18 | 19 | public class ConvertedRecords { 20 | 21 | private final T records; 22 | private final RecordsProcessingStats recordsProcessingStats; 23 | 24 | public ConvertedRecords(T records, RecordsProcessingStats recordsProcessingStats) { 25 | this.records = records; 26 | this.recordsProcessingStats = recordsProcessingStats; 27 | } 28 | 29 | public T records() { 30 | return records; 31 | } 32 | 33 | public RecordsProcessingStats recordsProcessingStats() { 34 | return recordsProcessingStats; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/LeaderNotAvailableException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * There is no currently available leader for the given partition (either because a leadership election is in progress 21 | * or because all replicas are down). 22 | */ 23 | public class LeaderNotAvailableException extends InvalidMetadataException { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | public LeaderNotAvailableException(String message) { 28 | super(message); 29 | } 30 | 31 | public LeaderNotAvailableException(String message, Throwable cause) { 32 | super(message, cause); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/TimeoutException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * Indicates that a request timed out. 21 | */ 22 | public class TimeoutException extends RetriableException { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | public TimeoutException() { 27 | super(); 28 | } 29 | 30 | public TimeoutException(String message, Throwable cause) { 31 | super(message, cause); 32 | } 33 | 34 | public TimeoutException(String message) { 35 | super(message); 36 | } 37 | 38 | public TimeoutException(Throwable cause) { 39 | super(cause); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/OffsetOutOfRangeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * No reset policy has been defined, and the offsets for these partitions are either larger or smaller 21 | * than the range of offsets the server has for the given partition. 22 | */ 23 | public class OffsetOutOfRangeException extends InvalidOffsetException { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | public OffsetOutOfRangeException(String message) { 28 | super(message); 29 | } 30 | 31 | public OffsetOutOfRangeException(String message, Throwable cause) { 32 | super(message, cause); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidRequestException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * Thrown when a request breaks basic wire protocol rules. 21 | * This most likely occurs because of a request being malformed by the client library or 22 | * the message was sent to an incompatible broker. 23 | */ 24 | public class InvalidRequestException extends ApiException { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | public InvalidRequestException(String message) { 29 | super(message); 30 | } 31 | 32 | public InvalidRequestException(String message, Throwable cause) { 33 | super(message, cause); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/security/auth/PlaintextAuthenticationContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.security.auth; 18 | 19 | import java.net.InetAddress; 20 | 21 | public class PlaintextAuthenticationContext implements AuthenticationContext { 22 | private final InetAddress clientAddress; 23 | 24 | public PlaintextAuthenticationContext(InetAddress clientAddress) { 25 | this.clientAddress = clientAddress; 26 | } 27 | 28 | @Override 29 | public SecurityProtocol securityProtocol() { 30 | return SecurityProtocol.PLAINTEXT; 31 | } 32 | 33 | @Override 34 | public InetAddress clientAddress() { 35 | return clientAddress; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/RetriableException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * A retryable exception is a transient exception that if retried may succeed. 21 | */ 22 | public abstract class RetriableException extends ApiException { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | public RetriableException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | 30 | public RetriableException(String message) { 31 | super(message); 32 | } 33 | 34 | public RetriableException(Throwable cause) { 35 | super(cause); 36 | } 37 | 38 | public RetriableException() { 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/hidden/custom/kafka/admin/ConsumerGroupMainTest.java: -------------------------------------------------------------------------------- 1 | package com.hidden.custom.kafka.admin; 2 | 3 | import org.apache.kafka.clients.admin.app.KafkaConsumerGroupService; 4 | import org.apache.kafka.clients.admin.model.PartitionAssignmentState; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by hidden.zhu on 2018/4/14. 10 | */ 11 | public class ConsumerGroupMainTest { 12 | public static void main(String[] args) { 13 | String brokerUrl = "localhost:9092"; 14 | String group = "CONSUMER_GROUP_ID"; 15 | testKafkaConsumerGroupCustomService(brokerUrl,group); 16 | System.out.println("----------------------------------------------"); 17 | testKafkaConsumerGroupService(brokerUrl,group); 18 | } 19 | 20 | 21 | public static void testKafkaConsumerGroupService(String brokerUrl, String group){ 22 | KafkaConsumerGroupService service = new KafkaConsumerGroupService(brokerUrl); 23 | service.init(); 24 | List pasList = service.collectGroupAssignment(group); 25 | ConsumerGroupUtils.printPasList(pasList); 26 | service.close(); 27 | } 28 | 29 | public static void testKafkaConsumerGroupCustomService(String brokerUrl, String group){ 30 | KafkaConsumerGroupCustomService service = new KafkaConsumerGroupCustomService(brokerUrl); 31 | service.init(); 32 | List pasList = service.collectGroupAssignment(group); 33 | ConsumerGroupUtils.printPasList(pasList); 34 | service.close(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/IllegalSaslStateException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * This exception indicates unexpected requests prior to SASL authentication. 21 | * This could be due to misconfigured security, e.g. if PLAINTEXT protocol 22 | * is used to connect to a SASL endpoint. 23 | */ 24 | public class IllegalSaslStateException extends AuthenticationException { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | public IllegalSaslStateException(String message) { 29 | super(message); 30 | } 31 | 32 | public IllegalSaslStateException(String message, Throwable cause) { 33 | super(message, cause); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/ProducerFencedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * This fatal exception indicates that another producer with the same transactional.id has been 21 | * started. It is only possible to have one producer instance with a transactional.id at any 22 | * given time, and the latest one to be started "fences" the previous instances so that they can no longer 23 | * make transactional requests. When you encounter this exception, you must close the producer instance. 24 | */ 25 | public class ProducerFencedException extends ApiException { 26 | 27 | public ProducerFencedException(String msg) { 28 | super(msg); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/Metric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common; 18 | 19 | /** 20 | * A metric tracked for monitoring purposes. 21 | */ 22 | public interface Metric { 23 | 24 | /** 25 | * A name for this metric 26 | */ 27 | MetricName metricName(); 28 | 29 | /** 30 | * The value of the metric as double if the metric is measurable and `0.0` otherwise. 31 | * 32 | * @deprecated As of 1.0.0, use {@link #metricValue()} instead. This will be removed in a future major release. 33 | */ 34 | @Deprecated 35 | double value(); 36 | 37 | /** 38 | * The value of the metric, which may be measurable or a non-measurable gauge 39 | */ 40 | Object metricValue(); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/serialization/IntegerSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.serialization; 18 | 19 | import java.util.Map; 20 | 21 | public class IntegerSerializer implements Serializer { 22 | 23 | public void configure(Map configs, boolean isKey) { 24 | // nothing to do 25 | } 26 | 27 | public byte[] serialize(String topic, Integer data) { 28 | if (data == null) 29 | return null; 30 | 31 | return new byte[] { 32 | (byte) (data >>> 24), 33 | (byte) (data >>> 16), 34 | (byte) (data >>> 8), 35 | data.byteValue() 36 | }; 37 | } 38 | 39 | public void close() { 40 | // nothing to do 41 | } 42 | } -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/consumer/InvalidOffsetException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.clients.consumer; 18 | 19 | import org.apache.kafka.common.KafkaException; 20 | import org.apache.kafka.common.TopicPartition; 21 | 22 | import java.util.Set; 23 | 24 | /** 25 | * Thrown when the offset for a set of partitions is invalid (either undefined or out of range), 26 | * and no reset policy has been configured. 27 | * @see NoOffsetForPartitionException 28 | * @see OffsetOutOfRangeException 29 | */ 30 | public abstract class InvalidOffsetException extends KafkaException { 31 | 32 | public InvalidOffsetException(String message) { 33 | super(message); 34 | } 35 | 36 | public abstract Set partitions(); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/UnsupportedForMessageFormatException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * The message format version does not support the requested function. For example, if idempotence is 21 | * requested and the topic is using a message format older than 0.11.0.0, then this error will be returned. 22 | */ 23 | public class UnsupportedForMessageFormatException extends ApiException { 24 | private static final long serialVersionUID = 1L; 25 | 26 | public UnsupportedForMessageFormatException(String message) { 27 | super(message); 28 | } 29 | 30 | public UnsupportedForMessageFormatException(String message, Throwable cause) { 31 | super(message, cause); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/requests/IsolationLevel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.requests; 18 | 19 | public enum IsolationLevel { 20 | READ_UNCOMMITTED((byte) 0), READ_COMMITTED((byte) 1); 21 | 22 | private final byte id; 23 | 24 | IsolationLevel(byte id) { 25 | this.id = id; 26 | } 27 | 28 | public byte id() { 29 | return id; 30 | } 31 | 32 | public static IsolationLevel forId(byte id) { 33 | switch (id) { 34 | case 0: 35 | return READ_UNCOMMITTED; 36 | case 1: 37 | return READ_COMMITTED; 38 | default: 39 | throw new IllegalArgumentException("Unknown isolation level " + id); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/network/TransportLayers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.network; 18 | 19 | import java.nio.channels.GatheringByteChannel; 20 | 21 | public final class TransportLayers { 22 | 23 | private TransportLayers() {} 24 | 25 | // This is temporary workaround as Send and Receive interfaces are used by BlockingChannel. 26 | // Once BlockingChannel is removed we can make Send and Receive work with TransportLayer rather than 27 | // GatheringByteChannel or ScatteringByteChannel. 28 | public static boolean hasPendingWrites(GatheringByteChannel channel) { 29 | if (channel instanceof TransportLayer) 30 | return ((TransportLayer) channel).hasPendingWrites(); 31 | return false; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/UnknownProducerIdException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.kafka.common.errors; 19 | 20 | /** 21 | * This exception is raised by the broker if it could not locate the producer metadata associated with the producerId 22 | * in question. This could happen if, for instance, the producer's records were deleted because their retention time 23 | * had elapsed. Once the last records of the producerId are removed, the producer's metadata is removed from the broker, 24 | * and future appends by the producer will return this exception. 25 | */ 26 | public class UnknownProducerIdException extends OutOfOrderSequenceException { 27 | 28 | public UnknownProducerIdException(String message) { 29 | super(message); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/requests/ResourceType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.kafka.common.requests; 19 | 20 | public enum ResourceType { 21 | UNKNOWN((byte) 0), ANY((byte) 1), TOPIC((byte) 2), GROUP((byte) 3), BROKER((byte) 4); 22 | 23 | private static final ResourceType[] VALUES = values(); 24 | 25 | private final byte id; 26 | 27 | ResourceType(byte id) { 28 | this.id = id; 29 | } 30 | 31 | public byte id() { 32 | return id; 33 | } 34 | 35 | public static ResourceType forId(byte id) { 36 | if (id < 0) 37 | throw new IllegalArgumentException("id should be positive, id: " + id); 38 | if (id >= VALUES.length) 39 | return UNKNOWN; 40 | return VALUES[id]; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InvalidMetadataException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * An exception that may indicate the client's metadata is out of date 21 | */ 22 | public abstract class InvalidMetadataException extends RetriableException { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | public InvalidMetadataException() { 27 | super(); 28 | } 29 | 30 | public InvalidMetadataException(String message) { 31 | super(message); 32 | } 33 | 34 | public InvalidMetadataException(String message, Throwable cause) { 35 | super(message, cause); 36 | } 37 | 38 | public InvalidMetadataException(Throwable cause) { 39 | super(cause); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/NotEnoughReplicasException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * Number of insync replicas for the partition is lower than min.insync.replicas 21 | */ 22 | public class NotEnoughReplicasException extends RetriableException { 23 | private static final long serialVersionUID = 1L; 24 | 25 | public NotEnoughReplicasException() { 26 | super(); 27 | } 28 | 29 | public NotEnoughReplicasException(String message, Throwable cause) { 30 | super(message, cause); 31 | } 32 | 33 | public NotEnoughReplicasException(String message) { 34 | super(message); 35 | } 36 | 37 | public NotEnoughReplicasException(Throwable cause) { 38 | super(cause); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/OffsetMetadataTooLarge.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * The client has tried to save its offset with associated metadata larger than the maximum size allowed by the server. 21 | */ 22 | public class OffsetMetadataTooLarge extends ApiException { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | public OffsetMetadataTooLarge() { 27 | } 28 | 29 | public OffsetMetadataTooLarge(String message) { 30 | super(message); 31 | } 32 | 33 | public OffsetMetadataTooLarge(Throwable cause) { 34 | super(cause); 35 | } 36 | 37 | public OffsetMetadataTooLarge(String message, Throwable cause) { 38 | super(message, cause); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/RecordBatchTooLargeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * This record batch is larger than the maximum allowable size 21 | */ 22 | public class RecordBatchTooLargeException extends ApiException { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | public RecordBatchTooLargeException() { 27 | super(); 28 | } 29 | 30 | public RecordBatchTooLargeException(String message, Throwable cause) { 31 | super(message, cause); 32 | } 33 | 34 | public RecordBatchTooLargeException(String message) { 35 | super(message); 36 | } 37 | 38 | public RecordBatchTooLargeException(Throwable cause) { 39 | super(cause); 40 | } 41 | 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/config/ConfigException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.config; 18 | 19 | import org.apache.kafka.common.KafkaException; 20 | 21 | /** 22 | * Thrown if the user supplies an invalid configuration 23 | */ 24 | public class ConfigException extends KafkaException { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | public ConfigException(String message) { 29 | super(message); 30 | } 31 | 32 | public ConfigException(String name, Object value) { 33 | this(name, value, null); 34 | } 35 | 36 | public ConfigException(String name, Object value, String message) { 37 | super("Invalid value " + value + " for configuration " + name + (message == null ? "" : ": " + message)); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/NotLeaderForPartitionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * This server is not the leader for the given partition 21 | */ 22 | public class NotLeaderForPartitionException extends InvalidMetadataException { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | public NotLeaderForPartitionException() { 27 | super(); 28 | } 29 | 30 | public NotLeaderForPartitionException(String message) { 31 | super(message); 32 | } 33 | 34 | public NotLeaderForPartitionException(Throwable cause) { 35 | super(cause); 36 | } 37 | 38 | public NotLeaderForPartitionException(String message, Throwable cause) { 39 | super(message, cause); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/utils/SecurityUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.utils; 18 | 19 | import org.apache.kafka.common.security.auth.KafkaPrincipal; 20 | 21 | public class SecurityUtils { 22 | 23 | public static KafkaPrincipal parseKafkaPrincipal(String str) { 24 | if (str == null || str.isEmpty()) { 25 | throw new IllegalArgumentException("expected a string in format principalType:principalName but got " + str); 26 | } 27 | 28 | String[] split = str.split(":", 2); 29 | 30 | if (split.length != 2) { 31 | throw new IllegalArgumentException("expected a string in format principalType:principalName but got " + str); 32 | } 33 | 34 | return new KafkaPrincipal(split[0], split[1]); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/TopicAuthorizationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | import java.util.Collections; 20 | import java.util.Set; 21 | 22 | public class TopicAuthorizationException extends AuthorizationException { 23 | private final Set unauthorizedTopics; 24 | 25 | public TopicAuthorizationException(Set unauthorizedTopics) { 26 | super("Not authorized to access topics: " + unauthorizedTopics); 27 | this.unauthorizedTopics = unauthorizedTopics; 28 | } 29 | 30 | public TopicAuthorizationException(String unauthorizedTopic) { 31 | this(Collections.singleton(unauthorizedTopic)); 32 | } 33 | 34 | public Set unauthorizedTopics() { 35 | return unauthorizedTopics; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/UnknownServerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * An error occurred on the server for which the client doesn't have a corresponding error code. This is generally an 21 | * unexpected error. 22 | * 23 | */ 24 | public class UnknownServerException extends ApiException { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | public UnknownServerException() { 29 | } 30 | 31 | public UnknownServerException(String message) { 32 | super(message); 33 | } 34 | 35 | public UnknownServerException(Throwable cause) { 36 | super(cause); 37 | } 38 | 39 | public UnknownServerException(String message, Throwable cause) { 40 | super(message, cause); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/DisconnectException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | 20 | /** 21 | * Server disconnected before a request could be completed. 22 | */ 23 | public class DisconnectException extends RetriableException { 24 | public static final DisconnectException INSTANCE = new DisconnectException(); 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | public DisconnectException() { 29 | super(); 30 | } 31 | 32 | public DisconnectException(String message, Throwable cause) { 33 | super(message, cause); 34 | } 35 | 36 | public DisconnectException(String message) { 37 | super(message); 38 | } 39 | 40 | public DisconnectException(Throwable cause) { 41 | super(cause); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/ConnectionState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.clients; 18 | 19 | /** 20 | * The states of a node connection 21 | * 22 | * DISCONNECTED: connection has not been successfully established yet 23 | * CONNECTING: connection is under progress 24 | * CHECKING_API_VERSIONS: connection has been established and api versions check is in progress. Failure of this check will cause connection to close 25 | * READY: connection is ready to send requests 26 | * AUTHENTICATION_FAILED: connection failed due to an authentication error 27 | */ 28 | public enum ConnectionState { 29 | DISCONNECTED, CONNECTING, CHECKING_API_VERSIONS, READY, AUTHENTICATION_FAILED; 30 | 31 | public boolean isDisconnected() { 32 | return this == AUTHENTICATION_FAILED || this == DISCONNECTED; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/metrics/stats/Sum.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.metrics.stats; 18 | 19 | import java.util.List; 20 | 21 | import org.apache.kafka.common.metrics.MetricConfig; 22 | 23 | /** 24 | * A {@link SampledStat} that maintains the sum of what it has seen. 25 | */ 26 | public class Sum extends SampledStat { 27 | 28 | public Sum() { 29 | super(0); 30 | } 31 | 32 | @Override 33 | protected void update(Sample sample, MetricConfig config, double value, long now) { 34 | sample.value += value; 35 | } 36 | 37 | @Override 38 | public double combine(List samples, MetricConfig config, long now) { 39 | double total = 0.0; 40 | for (Sample sample : samples) 41 | total += sample.value; 42 | return total; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/OutOfOrderSequenceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * This exception indicates that the broker received an unexpected sequence number from the producer, 21 | * which means that data may have been lost. If the producer is configured for idempotence only (i.e. 22 | * if enable.idempotence is set and no transactional.id is configured), it 23 | * is possible to continue sending with the same producer instance, but doing so risks reordering 24 | * of sent records. For transactional producers, this is a fatal error and you should close the 25 | * producer. 26 | */ 27 | public class OutOfOrderSequenceException extends ApiException { 28 | 29 | public OutOfOrderSequenceException(String msg) { 30 | super(msg); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/NetworkException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * A misc. network-related IOException occurred when making a request. This could be because the client's metadata is 21 | * out of date and it is making a request to a node that is now dead. 22 | */ 23 | public class NetworkException extends InvalidMetadataException { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | public NetworkException() { 28 | super(); 29 | } 30 | 31 | public NetworkException(String message, Throwable cause) { 32 | super(message, cause); 33 | } 34 | 35 | public NetworkException(String message) { 36 | super(message); 37 | } 38 | 39 | public NetworkException(Throwable cause) { 40 | super(cause); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/metrics/stats/Count.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.metrics.stats; 18 | 19 | import java.util.List; 20 | 21 | import org.apache.kafka.common.metrics.MetricConfig; 22 | 23 | /** 24 | * A {@link SampledStat} that maintains a simple count of what it has seen. 25 | */ 26 | public class Count extends SampledStat { 27 | 28 | public Count() { 29 | super(0); 30 | } 31 | 32 | @Override 33 | protected void update(Sample sample, MetricConfig config, double value, long now) { 34 | sample.value += 1.0; 35 | } 36 | 37 | @Override 38 | public double combine(List samples, MetricConfig config, long now) { 39 | double total = 0.0; 40 | for (Sample sample : samples) 41 | total += sample.value; 42 | return total; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/metrics/stats/Total.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.metrics.stats; 18 | 19 | import org.apache.kafka.common.metrics.MeasurableStat; 20 | import org.apache.kafka.common.metrics.MetricConfig; 21 | 22 | /** 23 | * An un-windowed cumulative total maintained over all time. 24 | */ 25 | public class Total implements MeasurableStat { 26 | 27 | private double total; 28 | 29 | public Total() { 30 | this.total = 0.0; 31 | } 32 | 33 | public Total(double value) { 34 | this.total = value; 35 | } 36 | 37 | @Override 38 | public void record(MetricConfig config, double value, long now) { 39 | this.total += value; 40 | } 41 | 42 | @Override 43 | public double measure(MetricConfig config, long now) { 44 | return this.total; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/NotCoordinatorException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | /** 20 | * In the context of the group coordinator, the broker returns this error code if it receives an offset fetch 21 | * or commit request for a group it's not the coordinator of. 22 | * 23 | * In the context of the transactional coordinator, it returns this error when it receives a transactional 24 | * request with a transactionalId the coordinator doesn't own. 25 | */ 26 | public class NotCoordinatorException extends RetriableException { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | public NotCoordinatorException(String message) { 31 | super(message); 32 | } 33 | 34 | public NotCoordinatorException(String message, Throwable cause) { 35 | super(message, cause); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/network/NetworkSend.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.network; 18 | 19 | import java.nio.ByteBuffer; 20 | 21 | /** 22 | * A size delimited Send that consists of a 4 byte network-ordered size N followed by N bytes of content 23 | */ 24 | public class NetworkSend extends ByteBufferSend { 25 | 26 | public NetworkSend(String destination, ByteBuffer buffer) { 27 | super(destination, sizeDelimit(buffer)); 28 | } 29 | 30 | private static ByteBuffer[] sizeDelimit(ByteBuffer buffer) { 31 | return new ByteBuffer[] {sizeBuffer(buffer.remaining()), buffer}; 32 | } 33 | 34 | private static ByteBuffer sizeBuffer(int size) { 35 | ByteBuffer sizeBuffer = ByteBuffer.allocate(4); 36 | sizeBuffer.putInt(size); 37 | sizeBuffer.rewind(); 38 | return sizeBuffer; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/security/plain/PlainSaslServerProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.security.plain; 18 | 19 | import java.security.Provider; 20 | import java.security.Security; 21 | 22 | import org.apache.kafka.common.security.plain.PlainSaslServer.PlainSaslServerFactory; 23 | 24 | public class PlainSaslServerProvider extends Provider { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | @SuppressWarnings("deprecation") 29 | protected PlainSaslServerProvider() { 30 | super("Simple SASL/PLAIN Server Provider", 1.0, "Simple SASL/PLAIN Server Provider for Kafka"); 31 | put("SaslServerFactory." + PlainSaslServer.PLAIN_MECHANISM, PlainSaslServerFactory.class.getName()); 32 | } 33 | 34 | public static void initialize() { 35 | Security.addProvider(new PlainSaslServerProvider()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/serialization/FloatSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.serialization; 18 | 19 | import java.util.Map; 20 | 21 | public class FloatSerializer implements Serializer { 22 | 23 | @Override 24 | public void configure(final Map configs, final boolean isKey) { 25 | // nothing to do 26 | } 27 | 28 | @Override 29 | public byte[] serialize(final String topic, final Float data) { 30 | if (data == null) 31 | return null; 32 | 33 | long bits = Float.floatToRawIntBits(data); 34 | return new byte[] { 35 | (byte) (bits >>> 24), 36 | (byte) (bits >>> 16), 37 | (byte) (bits >>> 8), 38 | (byte) bits 39 | }; 40 | } 41 | 42 | @Override 43 | public void close() { 44 | // nothing to do 45 | } 46 | } -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/errors/InterruptException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.errors; 18 | 19 | import org.apache.kafka.common.KafkaException; 20 | 21 | /** 22 | * An unchecked wrapper for InterruptedException 23 | */ 24 | public class InterruptException extends KafkaException { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | public InterruptException(InterruptedException cause) { 29 | super(cause); 30 | Thread.currentThread().interrupt(); 31 | } 32 | 33 | public InterruptException(String message, InterruptedException cause) { 34 | super(message, cause); 35 | Thread.currentThread().interrupt(); 36 | } 37 | 38 | public InterruptException(String message) { 39 | super(message, new InterruptedException()); 40 | Thread.currentThread().interrupt(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/metrics/stats/Min.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.metrics.stats; 18 | 19 | import java.util.List; 20 | 21 | import org.apache.kafka.common.metrics.MetricConfig; 22 | 23 | /** 24 | * A {@link SampledStat} that gives the min over its samples. 25 | */ 26 | public class Min extends SampledStat { 27 | 28 | public Min() { 29 | super(Double.MAX_VALUE); 30 | } 31 | 32 | @Override 33 | protected void update(Sample sample, MetricConfig config, double value, long now) { 34 | sample.value = Math.min(sample.value, value); 35 | } 36 | 37 | @Override 38 | public double combine(List samples, MetricConfig config, long now) { 39 | double min = Double.MAX_VALUE; 40 | for (Sample sample : samples) 41 | min = Math.min(min, sample.value); 42 | return min; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/metrics/stats/SimpleRate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.metrics.stats; 18 | 19 | import org.apache.kafka.common.metrics.MetricConfig; 20 | 21 | /** 22 | * A simple rate the rate is incrementally calculated 23 | * based on the elapsed time between the earliest reading 24 | * and now. 25 | * 26 | * An exception is made for the first window, which is 27 | * considered of fixed size. This avoids the issue of 28 | * an artificially high rate when the gap between readings 29 | * is close to 0. 30 | */ 31 | public class SimpleRate extends Rate { 32 | 33 | @Override 34 | public long windowSize(MetricConfig config, long now) { 35 | stat.purgeObsoleteSamples(config, now); 36 | long elapsed = now - stat.oldest(now).lastWindowMs; 37 | return elapsed < config.timeWindowMs() ? config.timeWindowMs() : elapsed; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/record/RecordBatchIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.record; 18 | 19 | import org.apache.kafka.common.KafkaException; 20 | import org.apache.kafka.common.utils.AbstractIterator; 21 | 22 | import java.io.IOException; 23 | 24 | class RecordBatchIterator extends AbstractIterator { 25 | 26 | private final LogInputStream logInputStream; 27 | 28 | RecordBatchIterator(LogInputStream logInputStream) { 29 | this.logInputStream = logInputStream; 30 | } 31 | 32 | @Override 33 | protected T makeNext() { 34 | try { 35 | T batch = logInputStream.nextBatch(); 36 | if (batch == null) 37 | return allDone(); 38 | return batch; 39 | } catch (IOException e) { 40 | throw new KafkaException(e); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/security/auth/SslAuthenticationContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.security.auth; 18 | 19 | import javax.net.ssl.SSLSession; 20 | import java.net.InetAddress; 21 | 22 | public class SslAuthenticationContext implements AuthenticationContext { 23 | private final SSLSession session; 24 | private final InetAddress clientAddress; 25 | 26 | public SslAuthenticationContext(SSLSession session, InetAddress clientAddress) { 27 | this.session = session; 28 | this.clientAddress = clientAddress; 29 | } 30 | 31 | public SSLSession session() { 32 | return session; 33 | } 34 | 35 | @Override 36 | public SecurityProtocol securityProtocol() { 37 | return SecurityProtocol.SSL; 38 | } 39 | 40 | @Override 41 | public InetAddress clientAddress() { 42 | return clientAddress; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/serialization/LongSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.serialization; 18 | 19 | import java.util.Map; 20 | 21 | public class LongSerializer implements Serializer { 22 | 23 | public void configure(Map configs, boolean isKey) { 24 | // nothing to do 25 | } 26 | 27 | public byte[] serialize(String topic, Long data) { 28 | if (data == null) 29 | return null; 30 | 31 | return new byte[] { 32 | (byte) (data >>> 56), 33 | (byte) (data >>> 48), 34 | (byte) (data >>> 40), 35 | (byte) (data >>> 32), 36 | (byte) (data >>> 24), 37 | (byte) (data >>> 16), 38 | (byte) (data >>> 8), 39 | data.byteValue() 40 | }; 41 | } 42 | 43 | public void close() { 44 | // nothing to do 45 | } 46 | } -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/metrics/stats/Max.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.metrics.stats; 18 | 19 | import java.util.List; 20 | 21 | import org.apache.kafka.common.metrics.MetricConfig; 22 | 23 | /** 24 | * A {@link SampledStat} that gives the max over its samples. 25 | */ 26 | public final class Max extends SampledStat { 27 | 28 | public Max() { 29 | super(Double.NEGATIVE_INFINITY); 30 | } 31 | 32 | @Override 33 | protected void update(Sample sample, MetricConfig config, double value, long now) { 34 | sample.value = Math.max(sample.value, value); 35 | } 36 | 37 | @Override 38 | public double combine(List samples, MetricConfig config, long now) { 39 | double max = Double.NEGATIVE_INFINITY; 40 | for (Sample sample : samples) 41 | max = Math.max(max, sample.value); 42 | return max; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/security/scram/ScramCredential.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.security.scram; 18 | 19 | public class ScramCredential { 20 | 21 | private final byte[] salt; 22 | private final byte[] serverKey; 23 | private final byte[] storedKey; 24 | private final int iterations; 25 | 26 | public ScramCredential(byte[] salt, byte[] storedKey, byte[] serverKey, int iterations) { 27 | this.salt = salt; 28 | this.serverKey = serverKey; 29 | this.storedKey = storedKey; 30 | this.iterations = iterations; 31 | } 32 | 33 | public byte[] salt() { 34 | return salt; 35 | } 36 | 37 | public byte[] serverKey() { 38 | return serverKey; 39 | } 40 | 41 | public byte[] storedKey() { 42 | return storedKey; 43 | } 44 | 45 | public int iterations() { 46 | return iterations; 47 | } 48 | } -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/clients/producer/internals/ProducerIdAndEpoch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.clients.producer.internals; 18 | 19 | import static org.apache.kafka.common.record.RecordBatch.NO_PRODUCER_EPOCH; 20 | import static org.apache.kafka.common.record.RecordBatch.NO_PRODUCER_ID; 21 | 22 | class ProducerIdAndEpoch { 23 | static final ProducerIdAndEpoch NONE = new ProducerIdAndEpoch(NO_PRODUCER_ID, NO_PRODUCER_EPOCH); 24 | 25 | public final long producerId; 26 | public final short epoch; 27 | 28 | ProducerIdAndEpoch(long producerId, short epoch) { 29 | this.producerId = producerId; 30 | this.epoch = epoch; 31 | } 32 | 33 | public boolean isValid() { 34 | return NO_PRODUCER_ID < producerId; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return "(producerId=" + producerId + ", epoch=" + epoch + ")"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/utils/ByteBufferInputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.utils; 18 | 19 | import java.io.InputStream; 20 | import java.nio.ByteBuffer; 21 | 22 | /** 23 | * A byte buffer backed input inputStream 24 | */ 25 | public final class ByteBufferInputStream extends InputStream { 26 | private final ByteBuffer buffer; 27 | 28 | public ByteBufferInputStream(ByteBuffer buffer) { 29 | this.buffer = buffer; 30 | } 31 | 32 | public int read() { 33 | if (!buffer.hasRemaining()) { 34 | return -1; 35 | } 36 | return buffer.get() & 0xFF; 37 | } 38 | 39 | public int read(byte[] bytes, int off, int len) { 40 | if (!buffer.hasRemaining()) { 41 | return -1; 42 | } 43 | 44 | len = Math.min(len, buffer.remaining()); 45 | buffer.get(bytes, off, len); 46 | return len; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/record/TimestampType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.record; 18 | 19 | import java.util.NoSuchElementException; 20 | 21 | /** 22 | * The timestamp type of the records. 23 | */ 24 | public enum TimestampType { 25 | NO_TIMESTAMP_TYPE(-1, "NoTimestampType"), CREATE_TIME(0, "CreateTime"), LOG_APPEND_TIME(1, "LogAppendTime"); 26 | 27 | public final int id; 28 | public final String name; 29 | 30 | TimestampType(int id, String name) { 31 | this.id = id; 32 | this.name = name; 33 | } 34 | 35 | public static TimestampType forName(String name) { 36 | for (TimestampType t : values()) 37 | if (t.name.equals(name)) 38 | return t; 39 | throw new NoSuchElementException("Invalid timestamp type " + name); 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return name; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/apache/kafka/common/security/scram/ScramSaslClientProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.kafka.common.security.scram; 18 | 19 | import java.security.Provider; 20 | import java.security.Security; 21 | 22 | import org.apache.kafka.common.security.scram.ScramSaslClient.ScramSaslClientFactory; 23 | 24 | public class ScramSaslClientProvider extends Provider { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | @SuppressWarnings("deprecation") 29 | protected ScramSaslClientProvider() { 30 | super("SASL/SCRAM Client Provider", 1.0, "SASL/SCRAM Client Provider for Kafka"); 31 | for (ScramMechanism mechanism : ScramMechanism.values()) 32 | put("SaslClientFactory." + mechanism.mechanismName(), ScramSaslClientFactory.class.getName()); 33 | } 34 | 35 | public static void initialize() { 36 | Security.addProvider(new ScramSaslClientProvider()); 37 | } 38 | } 39 | --------------------------------------------------------------------------------