├── .gitattributes
├── .gitignore
├── LICENSE.txt
├── README.md
├── SECURITY.md
├── THIRD_PARTY_LICENSE.txt
├── build.gradle
├── clients
├── okafka.pom
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── org
│ │ └── oracle
│ │ └── okafka
│ │ ├── clients
│ │ ├── ClusterConnectionStates.java
│ │ ├── CommonClientConfigs.java
│ │ ├── KafkaClient.java
│ │ ├── Metadata.java
│ │ ├── NetworkClient.java
│ │ ├── TopicTeqParameters.java
│ │ ├── admin
│ │ │ ├── Admin.java
│ │ │ ├── AdminClient.java
│ │ │ ├── AdminClientConfig.java
│ │ │ ├── CreateTopicsResult.java
│ │ │ ├── DeleteTopicsOptions.java
│ │ │ ├── DeleteTopicsResult.java
│ │ │ ├── DescribeTopicsResult.java
│ │ │ ├── KafkaAdminClient.java
│ │ │ ├── TopicDescription.java
│ │ │ └── internals
│ │ │ │ └── AQKafkaAdmin.java
│ │ ├── consumer
│ │ │ ├── ConsumerConfig.java
│ │ │ ├── KafkaConsumer.java
│ │ │ ├── TxEQAssignor.java
│ │ │ └── internals
│ │ │ │ ├── AQKafkaConsumer.java
│ │ │ │ ├── ConsumerNetworkClient.java
│ │ │ │ ├── FetchMetricsRegistry.java
│ │ │ │ ├── NoOpConsumerRebalanceListener.java
│ │ │ │ ├── OkafkaConsumerMetrics.java
│ │ │ │ ├── SubscriptionState.java
│ │ │ │ └── TopicMetadataFetcher.java
│ │ └── producer
│ │ │ ├── KafkaProducer.java
│ │ │ ├── ProducerConfig.java
│ │ │ └── internals
│ │ │ ├── AQKafkaProducer.java
│ │ │ ├── FutureRecordMetadata.java
│ │ │ ├── IncompleteBatches.java
│ │ │ ├── OkafkaProducerMetrics.java
│ │ │ ├── OracleTransactionManager.java
│ │ │ ├── ProduceRequestResult.java
│ │ │ ├── ProducerBatch.java
│ │ │ ├── ProducerIdAndEpoch.java
│ │ │ ├── RecordAccumulator.java
│ │ │ ├── SenderMetricsRegistry.java
│ │ │ └── SenderThread.java
│ │ └── common
│ │ ├── AQException.java
│ │ ├── Node.java
│ │ ├── config
│ │ └── SslConfigs.java
│ │ ├── errors
│ │ ├── ConnectionException.java
│ │ ├── FeatureNotSupportedException.java
│ │ ├── InvalidLoginCredentialsException.java
│ │ ├── InvalidMessageIdException.java
│ │ └── RecordNotFoundSQLException.java
│ │ ├── internals
│ │ ├── PartitionData.java
│ │ ├── QPATInfo.java
│ │ ├── QPATInfoList.java
│ │ ├── QPIMInfo.java
│ │ ├── QPIMInfoList.java
│ │ └── SessionData.java
│ │ ├── network
│ │ ├── AQClient.java
│ │ └── SelectorMetrics.java
│ │ ├── protocol
│ │ └── ApiKeys.java
│ │ ├── record
│ │ ├── BaseRecords.java
│ │ └── BufferSupplier.java
│ │ ├── requests
│ │ ├── AbstractRequest.java
│ │ ├── AbstractResponse.java
│ │ ├── CommitRequest.java
│ │ ├── CommitResponse.java
│ │ ├── ConnectMeRequest.java
│ │ ├── ConnectMeResponse.java
│ │ ├── CreateTopicsRequest.java
│ │ ├── CreateTopicsResponse.java
│ │ ├── DeleteGroupsRequest.java
│ │ ├── DeleteGroupsResponse.java
│ │ ├── DeleteTopicsRequest.java
│ │ ├── DeleteTopicsResponse.java
│ │ ├── FetchRequest.java
│ │ ├── FetchResponse.java
│ │ ├── IsolationLevel.java
│ │ ├── JoinGroupRequest.java
│ │ ├── JoinGroupResponse.java
│ │ ├── ListGroupsRequest.java
│ │ ├── ListGroupsResponse.java
│ │ ├── ListOffsetsRequest.java
│ │ ├── ListOffsetsResponse.java
│ │ ├── MetadataRequest.java
│ │ ├── MetadataResponse.java
│ │ ├── OffsetFetchRequest.java
│ │ ├── OffsetFetchResponse.java
│ │ ├── OffsetResetRequest.java
│ │ ├── OffsetResetResponse.java
│ │ ├── ProduceRequest.java
│ │ ├── ProduceResponse.java
│ │ ├── RequestHeader.java
│ │ ├── ResponseHeader.java
│ │ ├── SubscribeRequest.java
│ │ ├── SubscribeResponse.java
│ │ ├── SyncGroupRequest.java
│ │ ├── SyncGroupResponse.java
│ │ ├── UnsubscribeRequest.java
│ │ └── UnsubscribeResponse.java
│ │ └── utils
│ │ ├── ConnectionUtils.java
│ │ ├── CreateTopics.java
│ │ ├── FetchOffsets.java
│ │ ├── MessageIdConverter.java
│ │ ├── ReflectionUtil.java
│ │ └── TNSParser.java
│ └── test
│ └── java
│ ├── ojdbc.properties
│ ├── org
│ └── oracle
│ │ └── okafka
│ │ └── tests
│ │ ├── ConsumerMetricsTest.java
│ │ ├── DeleteConsumerGroups.java
│ │ ├── ListConsumerGroupOffsets.java
│ │ ├── ListConsumerGroups.java
│ │ ├── OkafkaAutoOffsetReset.java
│ │ ├── OkafkaDeleteTopic.java
│ │ ├── OkafkaDeleteTopicById.java
│ │ ├── OkafkaDescribeTopics.java
│ │ ├── OkafkaDescribeTopicsById.java
│ │ ├── OkafkaFetchCommittedOffset.java
│ │ ├── OkafkaListOffsets.java
│ │ ├── OkafkaListTopics.java
│ │ ├── OkafkaSeekToBeginning.java
│ │ ├── OkafkaSeekToEnd.java
│ │ ├── OkafkaSetup.java
│ │ ├── OkafkaUnsubscribe.java
│ │ ├── ProducerMetricsTest.java
│ │ ├── SimpleOkafkaAdmin.java
│ │ ├── SimpleOkafkaConsumer.java
│ │ ├── SimpleOkafkaProducer.java
│ │ └── TestRunner.java
│ └── test.config
├── connectors
├── .gitignore
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── SECURITY.md
├── THIRD_PARTY_LICENSE.txt
├── pom.xml
├── samples
│ └── ConsumerOfJmsSchema.java
└── src
│ └── main
│ ├── java
│ └── oracle
│ │ └── jdbc
│ │ └── txeventq
│ │ └── kafka
│ │ └── connect
│ │ ├── common
│ │ └── utils
│ │ │ ├── AppInfoParser.java
│ │ │ ├── Constants.java
│ │ │ ├── JmsUtils.java
│ │ │ └── Node.java
│ │ ├── schema
│ │ ├── JmsDestination.java
│ │ ├── JmsMessage.java
│ │ ├── Key.java
│ │ └── PropertyValue.java
│ │ ├── sink
│ │ ├── TxEventQSinkConnector.java
│ │ ├── task
│ │ │ └── TxEventQSinkTask.java
│ │ └── utils
│ │ │ ├── TxEventQProducer.java
│ │ │ └── TxEventQSinkConfig.java
│ │ └── source
│ │ ├── TxEventQSourceConnector.java
│ │ ├── task
│ │ └── TxEventQSourceTask.java
│ │ └── utils
│ │ ├── TxEventQConnectorConfig.java
│ │ ├── TxEventQConsumer.java
│ │ └── TxEventQSourceRecord.java
│ └── resources
│ ├── connect-txeventq-sink.properties
│ ├── connect-txeventq-source.properties
│ ├── kafka-connect-oracle-version.properties
│ └── logback.xml
├── examples
├── consumer
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── org
│ │ │ └── oracle
│ │ │ └── okafka
│ │ │ └── examples
│ │ │ └── ConsumerOKafka.java
│ │ └── resources
│ │ └── config.properties
├── ojdbc.properties
└── producer
│ └── src
│ └── main
│ ├── java
│ └── org
│ │ └── oracle
│ │ └── okafka
│ │ └── examples
│ │ └── ProducerOKafka.java
│ └── resources
│ └── config.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── sbom_generation.yaml
└── settings.gradle
/.gitattributes:
--------------------------------------------------------------------------------
1 | #
2 | # https://help.github.com/articles/dealing-with-line-endings/
3 | #
4 | # These are explicitly windows files and should use crlf
5 | *.bat text eol=crlf
6 |
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | .vscode
3 | .gradle
4 |
5 | # Maven assets
6 | .mvn
7 | mvnw
8 | mvnw.cmd
9 |
10 | .java-version
11 |
12 | target/
13 | build/
14 | bin/
15 |
16 | .dccache
17 | .DS_Store
18 |
19 | doc/
20 | /.metadata/
21 |
22 | .classpath
23 | .project
24 | .settings/
25 | clients/.classpath
26 | clients/.project
27 | clients/.settings/
28 | examples/.project
29 | examples/.settings/
30 | examples/ojdbc.properties
31 | examples/consumer/.classpath
32 | examples/consumer/.project
33 | examples/consumer/.settings/
34 | examples/producer/.classpath
35 | examples/producer/.project
36 | examples/producer/.settings/
37 | okafka-github/
38 | clients/config.properties
39 | clients/ojdbc.properties
40 | clientsafterConsumingOkafka.csv
41 | clientsafterProducingOkafka.csv
42 | examples/.externalToolBuilders/
43 | /.gitignore/
44 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Reporting security vulnerabilities
2 |
3 | Oracle values the independent security research community and believes that
4 | responsible disclosure of security vulnerabilities helps us ensure the security
5 | and privacy of all our users.
6 |
7 | Please do NOT raise a GitHub Issue to report a security vulnerability. If you
8 | believe you have found a security vulnerability, please submit a report to
9 | [secalert_us@oracle.com][1] preferably with a proof of concept. Please review
10 | some additional information on [how to report security vulnerabilities to Oracle][2].
11 | We encourage people who contact Oracle Security to use email encryption using
12 | [our encryption key][3].
13 |
14 | We ask that you do not use other channels or contact the project maintainers
15 | directly.
16 |
17 | Non-vulnerability related security issues including ideas for new or improved
18 | security features are welcome on GitHub Issues.
19 |
20 | ## Security updates, alerts and bulletins
21 |
22 | Security updates will be released on a regular cadence. Many of our projects
23 | will typically release security fixes in conjunction with the
24 | Oracle Critical Patch Update program. Additional
25 | information, including past advisories, is available on our [security alerts][4]
26 | page.
27 |
28 | ## Security-related information
29 |
30 | We will provide security related information such as a threat model, considerations
31 | for secure use, or any known security issues in our documentation. Please note
32 | that labs and sample code are intended to demonstrate a concept and may not be
33 | sufficiently hardened for production use.
34 |
35 | [1]: mailto:secalert_us@oracle.com
36 | [2]: https://www.oracle.com/corporate/security-practices/assurance/vulnerability/reporting.html
37 | [3]: https://www.oracle.com/security-alerts/encryptionkey.html
38 | [4]: https://www.oracle.com/security-alerts/
39 |
--------------------------------------------------------------------------------
/clients/okafka.pom:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.oracle.database.messaging
5 | okafka
6 | 23.4.0.0
7 |
8 |
9 | okafka
10 | Oracle's implementation of Kafka Java Client for Oracle Transactional Event Queues
11 | https://docs.oracle.com/en/database/oracle/oracle-database/23/okjdc/index.html
12 |
13 |
14 |
15 |
16 | Oracle Free Use Terms and Conditions (FUTC)
17 |
18 | https://www.oracle.com/downloads/licenses/oracle-free-license.html
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | Oracle America, Inc.
28 | http://www.oracle.com
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | UTF-8
37 | UTF-8
38 | 11
39 | ${java.version}
40 | ${java.version}
41 | 23.4.0.24.05
42 | 23.3.0.0
43 | 2.0.1
44 | 1.3
45 |
46 |
47 |
48 |
49 | com.oracle.database.jdbc
50 | ojdbc11
51 | ${oracle-jdbc.version}
52 |
53 |
54 | com.oracle.database.jdbc
55 | ucp
56 | ${oracle-jdbc.version}
57 |
58 |
59 | com.oracle.database.security
60 | oraclepki
61 | ${oracle-jdbc.version}
62 |
63 |
64 | javax.jms
65 | javax.jms-api
66 | ${jms.version}
67 |
68 |
69 | javax.transaction
70 | javax.transaction-api
71 | ${javax-transaction.version}
72 |
73 |
74 | javax.transaction
75 | jta
76 | 1.1
77 |
78 |
79 | com.oracle.database.messaging
80 | aqapi
81 | ${oracle-db-messaging.version}
82 |
83 |
84 |
85 | org.apache.kafka
86 | kafka-clients
87 | 3.7.1
88 |
89 |
90 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/clients/TopicTeqParameters.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.clients;
9 |
10 |
11 | import java.util.HashMap;
12 |
13 | import org.oracle.okafka.clients.admin.TopicDescription;
14 |
15 | public class TopicTeqParameters {
16 |
17 | int keyBased;
18 | int stickyDeq;
19 | int shardNum;
20 | int dbMajorVersion;
21 | int dbMinorVersion;
22 | int msgVersion;
23 |
24 |
25 | public void setKeyBased(int keyBased)
26 | {
27 | this.keyBased = keyBased;
28 | }
29 |
30 | public void setStickyDeq(int stickyDeq)
31 | {
32 | this.stickyDeq = stickyDeq;
33 | }
34 |
35 | public void setShardNum(int shardNum)
36 | {
37 | this.shardNum = shardNum;
38 | }
39 |
40 | private void setMsgVersion(int msgVersion)
41 | {
42 | this.msgVersion = msgVersion;
43 | }
44 |
45 | public int getKeyBased()
46 | {
47 | return this.keyBased;
48 | }
49 |
50 | public int getStickyDeq()
51 | {
52 | return this.stickyDeq;
53 | }
54 |
55 | public int getShardNum()
56 | {
57 | return this.shardNum;
58 | }
59 |
60 | public int getMsgVersion()
61 | {
62 | if(getStickyDeq()!=2) {
63 | this.msgVersion = 1;
64 | }
65 | else {
66 | this.msgVersion = 2;
67 | }
68 | return this.msgVersion;
69 | }
70 |
71 | @Override
72 | public boolean equals(final Object o) {
73 | if (this == o) return true;
74 | if (o == null || getClass() != o.getClass()) return false;
75 | final TopicTeqParameters that = (TopicTeqParameters) o;
76 | return this.keyBased == that.keyBased &&
77 | this.stickyDeq == that.stickyDeq &&
78 | this.shardNum == that.shardNum &&
79 | this.dbMajorVersion == that.dbMajorVersion &&
80 | this.dbMinorVersion == that.dbMinorVersion &&
81 | this.msgVersion == that.msgVersion;
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/clients/admin/AdminClient.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | package org.oracle.okafka.clients.admin;
26 |
27 | import java.util.Map;
28 | import java.util.Properties;
29 |
30 | import org.apache.kafka.common.annotation.InterfaceStability;
31 |
32 | /**
33 | * The administrative client for Transactional Event Queues(TXEQ), which supports managing and inspecting topics.
34 | * For this release only creation of topic(s) and deletion of topic(s) is supported.
35 | * A topic can be created by invoking {@code #createTopics(Collection)} and deleted by invoking {@code #deleteTopics(Collection)} method.
36 | *
37 | * Topic can be created with following configuration.
38 | *
39 | * retention.ms: Amount of time in milliseconds for which records stay in topic and are available for consumption. Internally, retention.ms value is rounded to the second. Default value for this parameter is 7 days.
40 | *
41 | */
42 | @InterfaceStability.Evolving
43 | public abstract class AdminClient implements Admin {
44 |
45 | /**
46 | * Create a new AdminClient with the given configuration.
47 | *
48 | * @param props The configuration.
49 | * @return The new KafkaAdminClient.
50 | */
51 | final static String DUMMY_BOOTSTRAP ="localhost:1521";
52 | public static AdminClient create(Properties props) {
53 | String bootStrap = (String)props.get(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG);
54 | if(bootStrap== null)
55 | {
56 | String secProtocol = props.getProperty(AdminClientConfig.SECURITY_PROTOCOL_CONFIG);
57 | if(secProtocol != null && secProtocol.equalsIgnoreCase("SSL")) {
58 | // Connect using Oracle Wallet and tnsnames.ora.
59 | // User does not need to know the database host ip and port.
60 | props.setProperty(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, DUMMY_BOOTSTRAP);
61 | }
62 | }
63 | return KafkaAdminClient.createInternal(new org.oracle.okafka.clients.admin.AdminClientConfig(props), new KafkaAdminClient.TimeoutProcessorFactory());
64 | }
65 |
66 | /**
67 | * Create a new AdminClient with the given configuration.
68 | *
69 | * @param conf The configuration.
70 | * @return The new KafkaAdminClient.
71 | */
72 | public static AdminClient create(Map conf) {
73 |
74 | String bootStrap = (String)conf.get(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG);
75 | if(bootStrap == null)
76 | {
77 | String setSecProtocol = (String)conf.get(AdminClientConfig.SECURITY_PROTOCOL_CONFIG);
78 | if(setSecProtocol != null && setSecProtocol.equalsIgnoreCase("SSL"))
79 | {
80 | // Connect using Wallet and TNSNAMES.ora.
81 | // User does not need to know the database host ip and port.
82 | conf.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, DUMMY_BOOTSTRAP);
83 | }
84 | }
85 | return KafkaAdminClient.createInternal(new AdminClientConfig(conf), null);
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/clients/admin/CreateTopicsResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 | package org.oracle.okafka.clients.admin;
25 |
26 | import org.apache.kafka.common.KafkaFuture;
27 | import org.apache.kafka.common.annotation.InterfaceStability;
28 | import java.util.Collection;
29 | import java.util.Map;
30 |
31 | /**
32 | * The result of {@link Admin#createTopics(Collection)}.
33 | *
34 | * The API of this class is evolving, see {@link Admin} for details.
35 | */
36 | @InterfaceStability.Evolving
37 | public class CreateTopicsResult extends org.apache.kafka.clients.admin.CreateTopicsResult {
38 |
39 | public CreateTopicsResult(Map> futures)
40 | {
41 | super(futures);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/clients/admin/DeleteTopicsOptions.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | package org.oracle.okafka.clients.admin;
26 |
27 | import org.apache.kafka.common.annotation.InterfaceStability;
28 |
29 | import java.util.Collection;
30 |
31 | /**
32 | * Options for {@link Admin#deleteTopics(Collection)}.
33 | *
34 | * The API of this class is evolving, see {@link Admin} for details.
35 | */
36 | @InterfaceStability.Evolving
37 | public class DeleteTopicsOptions extends org.apache.kafka.clients.admin.DeleteTopicsOptions {
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/clients/admin/DeleteTopicsResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | package org.oracle.okafka.clients.admin;
26 |
27 | import org.apache.kafka.common.KafkaFuture;
28 | import org.apache.kafka.common.Uuid;
29 | import org.apache.kafka.common.annotation.InterfaceStability;
30 |
31 | import java.util.Collection;
32 | import java.util.Map;
33 |
34 | /**
35 | * The result of the {@link Admin#deleteTopics(Collection)} call.
36 | *
37 | * The API of this class is evolving, see {@link Admin} for details.
38 | */
39 | @InterfaceStability.Evolving
40 | public class DeleteTopicsResult extends org.apache.kafka.clients.admin.DeleteTopicsResult {
41 |
42 | DeleteTopicsResult(Map> topicIdFutures, Map> nameFutures) {
43 | super(topicIdFutures, nameFutures);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/clients/admin/DescribeTopicsResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | package org.oracle.okafka.clients.admin;
26 |
27 | import java.util.Map;
28 |
29 | import org.apache.kafka.clients.admin.TopicDescription;
30 | import org.apache.kafka.common.KafkaFuture;
31 | import org.apache.kafka.common.Uuid;
32 |
33 | /**
34 | * The result of the {@link Admin#describeTopics(Collection)} call.
35 | *
36 | * The API of this class is evolving, see {@link Admin} for details.
37 | */
38 | public class DescribeTopicsResult extends org.apache.kafka.clients.admin.DescribeTopicsResult {
39 |
40 | protected DescribeTopicsResult(Map> topicIdFutures, Map> nameFutures) {
41 | super(topicIdFutures, nameFutures);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/clients/admin/TopicDescription.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | package org.oracle.okafka.clients.admin;
26 |
27 | import java.util.Collections;
28 | import java.util.List;
29 | import java.util.Map;
30 | import java.util.Objects;
31 |
32 | import org.apache.kafka.common.PartitionInfo;
33 | import org.apache.kafka.common.TopicPartitionInfo;
34 | import org.apache.kafka.common.Uuid;
35 | import org.oracle.okafka.clients.TopicTeqParameters;
36 |
37 | /**
38 | * A detailed description of a single topic in the cluster.
39 | */
40 | public class TopicDescription extends org.apache.kafka.clients.admin.TopicDescription{
41 |
42 | private final TopicTeqParameters topicParameters;
43 |
44 | public TopicDescription(String name, boolean internal, List partitions, TopicTeqParameters topicTeqParameters, Uuid topicId) {
45 | super(name, internal, partitions,Collections.emptySet(),topicId);
46 | this.topicParameters=topicTeqParameters;
47 |
48 | }
49 |
50 | @Override
51 | public boolean equals(final Object o) {
52 | Boolean superEqual = super.equals(o);
53 | if (superEqual) {
54 | final TopicDescription that = (TopicDescription) o;
55 | return this.topicParameters.equals(that.topicParameters);
56 | }
57 | return false;
58 | }
59 |
60 | @Override
61 | public int hashCode() {
62 | return Objects.hash(this.name(), this.isInternal(), this.partitions(), topicParameters);
63 | }
64 |
65 | private TopicTeqParameters topicTeqParameters() {
66 | return this.topicParameters;
67 | }
68 |
69 |
70 |
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/clients/consumer/internals/NoOpConsumerRebalanceListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.clients.consumer.internals;
9 |
10 | import org.apache.kafka.clients.consumer.ConsumerRebalanceListener;
11 | import org.apache.kafka.common.TopicPartition;
12 | import java.util.Collection;
13 |
14 | public class NoOpConsumerRebalanceListener implements ConsumerRebalanceListener{
15 |
16 | @Override
17 | public void onPartitionsAssigned(Collection partitions) {}
18 |
19 | @Override
20 | public void onPartitionsRevoked(Collection partitions) {}
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/clients/consumer/internals/OkafkaConsumerMetrics.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.clients.consumer.internals;
9 |
10 | import org.apache.kafka.common.MetricName;
11 | import org.apache.kafka.common.metrics.Measurable;
12 | import org.apache.kafka.common.metrics.Metrics;
13 | import org.apache.kafka.common.metrics.Sensor;
14 | import org.apache.kafka.common.metrics.stats.Avg;
15 | import org.apache.kafka.common.metrics.stats.CumulativeSum;
16 | import org.apache.kafka.common.metrics.stats.Max;
17 |
18 | import java.util.concurrent.TimeUnit;
19 |
20 | public class OkafkaConsumerMetrics implements AutoCloseable {
21 | private final MetricName lastPollMetricName;
22 | private final Sensor timeBetweenPollSensor;
23 | private final Sensor pollIdleSensor;
24 | private final Sensor commitSyncSensor;
25 | private final Metrics metrics;
26 | private long lastPollMs;
27 | private long pollStartMs;
28 | private long timeSinceLastPollMs;
29 |
30 | public OkafkaConsumerMetrics(Metrics metrics, String metricGrpPrefix) {
31 | this.metrics = metrics;
32 | String metricGroupName = metricGrpPrefix + "-metrics";
33 | Measurable lastPoll = (mConfig, now) -> {
34 | if (lastPollMs == 0L)
35 | return -1d;
36 | else
37 | return TimeUnit.SECONDS.convert(now - lastPollMs, TimeUnit.MILLISECONDS);
38 | };
39 | this.lastPollMetricName = metrics.metricName("last-poll-seconds-ago",
40 | metricGroupName, "The number of seconds since the last poll() invocation.");
41 | metrics.addMetric(lastPollMetricName, lastPoll);
42 |
43 | this.timeBetweenPollSensor = metrics.sensor("time-between-poll");
44 | this.timeBetweenPollSensor.add(metrics.metricName("time-between-poll-avg",
45 | metricGroupName,
46 | "The average delay between invocations of poll() in milliseconds."),
47 | new Avg());
48 | this.timeBetweenPollSensor.add(metrics.metricName("time-between-poll-max",
49 | metricGroupName,
50 | "The max delay between invocations of poll() in milliseconds."),
51 | new Max());
52 |
53 | this.pollIdleSensor = metrics.sensor("poll-idle-ratio-avg");
54 | this.pollIdleSensor.add(metrics.metricName("poll-idle-ratio-avg",
55 | metricGroupName,
56 | "The average fraction of time the consumer's poll() is idle as opposed to waiting for the user code to process records."),
57 | new Avg());
58 |
59 | this.commitSyncSensor = metrics.sensor("commit-sync-time-ns-total");
60 | this.commitSyncSensor.add(
61 | metrics.metricName(
62 | "commit-sync-time-ns-total",
63 | metricGroupName,
64 | "The total time the consumer has spent in commitSync in nanoseconds"
65 | ),
66 | new CumulativeSum()
67 | );
68 |
69 | }
70 |
71 | public void recordPollStart(long pollStartMs) {
72 | this.pollStartMs = pollStartMs;
73 | this.timeSinceLastPollMs = lastPollMs != 0L ? pollStartMs - lastPollMs : 0;
74 | this.timeBetweenPollSensor.record(timeSinceLastPollMs);
75 | this.lastPollMs = pollStartMs;
76 | }
77 |
78 | public void recordPollEnd(long pollEndMs) {
79 | long pollTimeMs = pollEndMs - pollStartMs;
80 | double pollIdleRatio = pollTimeMs * 1.0 / (pollTimeMs + timeSinceLastPollMs);
81 | this.pollIdleSensor.record(pollIdleRatio);
82 | }
83 |
84 | public void recordCommitSync(long duration) {
85 | this.commitSyncSensor.record(duration);
86 | }
87 |
88 |
89 | @Override
90 | public void close() {
91 | metrics.removeMetric(lastPollMetricName);
92 | metrics.removeSensor(timeBetweenPollSensor.name());
93 | metrics.removeSensor(pollIdleSensor.name());
94 | metrics.removeSensor(commitSyncSensor.name());
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/clients/consumer/internals/TopicMetadataFetcher.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.clients.consumer.internals;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Arrays;
5 | import java.util.HashMap;
6 | import java.util.List;
7 | import java.util.Map;
8 |
9 | import org.apache.kafka.clients.ClientResponse;
10 | import org.apache.kafka.common.KafkaException;
11 | import org.apache.kafka.common.PartitionInfo;
12 | import org.apache.kafka.common.errors.TimeoutException;
13 | import org.apache.kafka.common.utils.LogContext;
14 | import org.apache.kafka.common.utils.Timer;
15 | import org.oracle.okafka.common.requests.MetadataRequest;
16 | import org.oracle.okafka.common.requests.MetadataResponse;
17 | import org.slf4j.Logger;
18 |
19 | public class TopicMetadataFetcher {
20 | private final Logger log;
21 | private final ConsumerNetworkClient client;
22 |
23 | public TopicMetadataFetcher(LogContext logContext, ConsumerNetworkClient client) {
24 | this.log = logContext.logger(getClass());
25 | this.client = client;
26 |
27 | }
28 |
29 | public Map> getAllTopicMetadata(Timer timer) {
30 | MetadataRequest.Builder request = MetadataRequest.Builder.listAllTopics(true);
31 | return getTopicMetadata(request, timer);
32 | }
33 |
34 | private Map> getTopicMetadata(MetadataRequest.Builder builder, Timer timer) {
35 | boolean retry = false;
36 |
37 | do {
38 | retry = false;
39 | ClientResponse response = client.sendMetadataRequest(builder);
40 | MetadataResponse metadataResponse = (MetadataResponse) response.responseBody();
41 |
42 | if (metadataResponse.getException() == null && !response.wasDisconnected()) {
43 | Map> listTopicsMap = new HashMap<>();
44 | List partitionInfoList = metadataResponse.partitions();
45 | for (int i = 0; i < partitionInfoList.size(); i++) {
46 | String topic = partitionInfoList.get(i).topic();
47 | if (listTopicsMap.containsKey(topic)) {
48 | listTopicsMap.get(topic).add(partitionInfoList.get(i));
49 | } else {
50 | listTopicsMap.put(topic, new ArrayList<>(Arrays.asList(partitionInfoList.get(i))));
51 | }
52 | }
53 | return listTopicsMap;
54 | } else if (response.wasDisconnected())
55 | retry = true;
56 | else {
57 | log.error("Exception Caught: ", metadataResponse.getException());
58 | throw new KafkaException("Unexpected error listing topics", metadataResponse.getException());
59 | }
60 | } while (retry && timer.notExpired());
61 |
62 | throw new TimeoutException("Timeout expired while fetching topic metadata");
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/clients/producer/internals/IncompleteBatches.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 | package org.oracle.okafka.clients.producer.internals;
25 |
26 | import java.util.ArrayList;
27 | import java.util.HashSet;
28 | import java.util.Set;
29 |
30 | /*
31 | * A thread-safe helper class to hold batches that haven't been acknowledged yet (including those
32 | * which have and have not been sent).
33 | */
34 | class IncompleteBatches {
35 | private final Set incomplete;
36 |
37 | public IncompleteBatches() {
38 | this.incomplete = new HashSet<>();
39 | }
40 |
41 | public void add(ProducerBatch batch) {
42 | synchronized (incomplete) {
43 | this.incomplete.add(batch);
44 | }
45 | }
46 |
47 | public void remove(ProducerBatch batch) {
48 | synchronized (incomplete) {
49 | boolean removed = this.incomplete.remove(batch);
50 | if (!removed)
51 | throw new IllegalStateException("Remove from the incomplete set failed. This should be impossible.");
52 | }
53 | }
54 |
55 | public Iterable copyAll() {
56 | synchronized (incomplete) {
57 | return new ArrayList<>(this.incomplete);
58 | }
59 | }
60 |
61 | public boolean isEmpty() {
62 | synchronized (incomplete) {
63 | return incomplete.isEmpty();
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/clients/producer/internals/ProduceRequestResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | /*
26 | * 04/20/2020: This file is modified to support Kafka Java Client compatability to Oracle Transactional Event Queues.
27 | *
28 | */
29 |
30 | package org.oracle.okafka.clients.producer.internals;
31 |
32 | import java.util.List;
33 | import java.util.function.Function;
34 |
35 | import org.apache.kafka.clients.producer.RecordMetadata;
36 | import org.apache.kafka.common.TopicPartition;
37 | import org.oracle.okafka.common.utils.MessageIdConverter.OKafkaOffset;
38 |
39 | /**
40 | * A class that models the future completion of a produce request for a single
41 | * partition. There is one of these per partition in a produce request and it is
42 | * shared by all the {@link RecordMetadata} instances that are batched together
43 | * for the same partition in the request.
44 | */
45 | public class ProduceRequestResult extends org.apache.kafka.clients.producer.internals.ProduceRequestResult {
46 |
47 | private volatile List msgIds = null;
48 |
49 | /**
50 | * Create an instance of this class.
51 | *
52 | * @param topicPartition The topic and partition to which this record set was
53 | * sent was sent
54 | */
55 | public ProduceRequestResult(TopicPartition topicPartition) {
56 | super(topicPartition);
57 | }
58 |
59 | /**
60 | * Set the result of the produce request.
61 | *
62 | * @param baseOffset The base offset assigned to the record
63 | * @param logAppendTime The log append time or -1 if CreateTime is being used
64 | * @param error The error that occurred if there was one, or null
65 | */
66 | public void set(long baseOffset, long logAppendTime, List msgIds,
67 | Function errorsByIndex) {
68 | set(baseOffset, logAppendTime, errorsByIndex);
69 | this.msgIds = msgIds;
70 | }
71 |
72 | public void set(long baseOffset, long logAppendTime, List msgIds, RuntimeException errorsByIndex) {
73 | set(baseOffset, logAppendTime, batchIndex -> errorsByIndex);
74 | this.msgIds = msgIds;
75 | }
76 |
77 | /**
78 | * The base offset for the request (the first offset in the record set)
79 | */
80 | public List msgIds() {
81 | return msgIds;
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/clients/producer/internals/ProducerIdAndEpoch.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 | package org.oracle.okafka.clients.producer.internals;
25 |
26 | import static org.apache.kafka.common.record.RecordBatch.NO_PRODUCER_EPOCH;
27 | import static org.apache.kafka.common.record.RecordBatch.NO_PRODUCER_ID;
28 |
29 | class ProducerIdAndEpoch {
30 | static final ProducerIdAndEpoch NONE = new ProducerIdAndEpoch(NO_PRODUCER_ID, NO_PRODUCER_EPOCH);
31 |
32 | public final long producerId;
33 | public final short epoch;
34 |
35 | ProducerIdAndEpoch(long producerId, short epoch) {
36 | this.producerId = producerId;
37 | this.epoch = epoch;
38 | }
39 |
40 | public boolean isValid() {
41 | return NO_PRODUCER_ID < producerId;
42 | }
43 |
44 | @Override
45 | public String toString() {
46 | return "(producerId=" + producerId + ", epoch=" + epoch + ")";
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/AQException.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.common;
9 |
10 | /**
11 | * Base class of all other TEQ exceptions.
12 | *
13 | * @author srkarre
14 | *
15 | */
16 | public class AQException extends RuntimeException {
17 | private final static long serialVersionUID = 1L;
18 |
19 | public AQException(String message, Throwable cause) {
20 | super(message, cause);
21 | }
22 |
23 | public AQException(String message) {
24 | super(message);
25 | }
26 |
27 | public AQException(Throwable cause) {
28 | super(cause);
29 | }
30 |
31 | public AQException() {
32 | super();
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/config/SslConfigs.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | /*
26 | * 04/20/2020: This file is modified to support Kafka Java Client compatability to Oracle Transactional Event Queues.
27 | *
28 | */
29 |
30 | package org.oracle.okafka.common.config;
31 |
32 | import org.apache.kafka.common.config.ConfigDef;
33 | import org.apache.kafka.common.config.ConfigDef.Importance;
34 |
35 | public class SslConfigs extends org.apache.kafka.common.config.SslConfigs {
36 | /*
37 | * NOTE: DO NOT CHANGE EITHER CONFIG NAMES AS THESE ARE PART OF THE PUBLIC API AND CHANGE WILL BREAK USER CODE.
38 | */
39 |
40 | public static final String TNS_ALIAS = "tns.alias";
41 | public static final String TNS_ALIAS_DOC = "alias of connection string in tnsnames.ora. This connection is used for connecting to database instance";
42 |
43 | public static void addClientSslSupport(ConfigDef config) {
44 | org.apache.kafka.common.config.SslConfigs.addClientSslSupport(config);
45 | config.define(SslConfigs.TNS_ALIAS, ConfigDef.Type.STRING, null, Importance.MEDIUM, SslConfigs.TNS_ALIAS_DOC);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/errors/ConnectionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.common.errors;
9 |
10 | import org.apache.kafka.common.KafkaException;
11 |
12 | /**
13 | * Thrown when OKafka application fails to connect with the Oracle Database.
14 | */
15 | public class ConnectionException extends KafkaException {
16 | private static final long serialVersionUID = 1L;
17 |
18 | public ConnectionException(Throwable cause) {
19 | super(cause);
20 | }
21 | public ConnectionException(String msg) {
22 | super(msg);
23 | }
24 |
25 | public ConnectionException(String msg, Throwable cause) {
26 | super(msg, cause);
27 | }
28 |
29 | public ConnectionException() {
30 | super();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/errors/FeatureNotSupportedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.common.errors;
9 |
10 | import org.oracle.okafka.common.AQException;
11 |
12 | /**
13 | * If a method/api is not supported then this exception is thrown.
14 | *
15 | * @author srkarre
16 | *
17 | */
18 | public class FeatureNotSupportedException extends AQException {
19 | private static final long serialVersionUID = 1L;
20 |
21 | public FeatureNotSupportedException(String message, Throwable cause) {
22 | super(message, cause);
23 | }
24 |
25 | public FeatureNotSupportedException(String message) {
26 | super(message);
27 | }
28 |
29 | public FeatureNotSupportedException(Throwable cause) {
30 | super(cause);
31 | }
32 |
33 | public FeatureNotSupportedException() {
34 | super();
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/errors/InvalidLoginCredentialsException.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 |
9 | package org.oracle.okafka.common.errors;
10 |
11 | import org.oracle.okafka.common.AQException;
12 |
13 | /**
14 | * This exception indicates that user provided invalid login details.
15 | *
16 | * @author srkarre
17 | *
18 | */
19 | public class InvalidLoginCredentialsException extends AQException {
20 | private final static long serialVersionUID = 1L;
21 |
22 | public InvalidLoginCredentialsException(String message, Throwable cause) {
23 | super(message, cause);
24 | }
25 |
26 | public InvalidLoginCredentialsException(String message) {
27 | super(message);
28 | }
29 |
30 | public InvalidLoginCredentialsException(Throwable cause) {
31 | super(cause);
32 | }
33 |
34 | public InvalidLoginCredentialsException() {
35 | super();
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/errors/InvalidMessageIdException.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.common.errors;
9 |
10 | import org.oracle.okafka.common.AQException;
11 |
12 | /**
13 | * This exception indicates that client has received invalid message id from server.
14 | *
15 | * @author srkarre
16 | *
17 | */
18 | public class InvalidMessageIdException extends AQException {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | public InvalidMessageIdException(String message, Throwable cause) {
23 | super(message, cause);
24 | }
25 |
26 | public InvalidMessageIdException(String message) {
27 | super(message);
28 | }
29 |
30 | public InvalidMessageIdException(Throwable cause) {
31 | super(cause);
32 | }
33 |
34 | public InvalidMessageIdException() {
35 | super();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/errors/RecordNotFoundSQLException.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.errors;
2 |
3 | import java.sql.SQLException;
4 |
5 | /**
6 | * Exception indicates that either specified topic name/id in describeTopics()/deleteTopic() call is not found.
7 | */
8 | public class RecordNotFoundSQLException extends SQLException {
9 | public RecordNotFoundSQLException(String message) {
10 | super(message);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/internals/PartitionData.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.internals;
2 |
3 | import org.apache.kafka.common.TopicPartition;
4 |
5 | public class PartitionData {
6 | private TopicPartition topicPartition;
7 | private int queueId;
8 | private String subscriberName;
9 | private int subscriberId;
10 | private int ownerInstanceId;
11 | private boolean local;
12 |
13 | public PartitionData(String queueName, int queueId, int partitionId,
14 | String subName, int subId, int ownerInstanceId, boolean local) {
15 | this.topicPartition = new TopicPartition(queueName, partitionId);
16 | this.queueId = queueId;
17 | this.subscriberName = subName;
18 | this.subscriberId = subId;
19 | this.ownerInstanceId = ownerInstanceId;
20 | this.local = local;
21 | }
22 | public String toString()
23 | {
24 | if(topicPartition == null)
25 | return "NULL";
26 |
27 | return "{Topic:"+topicPartition.topic()+",ConsumerGroupID:"+subscriberName+
28 | ",Partition:"+topicPartition.partition()+",OwnerInstance:"+ownerInstanceId+",}";
29 | }
30 |
31 | public TopicPartition getTopicPartition() {
32 | return this.topicPartition;
33 | }
34 | public int getOwnerInstanceId() {
35 | return this.ownerInstanceId;
36 | }
37 |
38 | public void setOwnerInstanceId(int instId)
39 | {
40 | this.ownerInstanceId = instId;
41 | }
42 |
43 | public int getQueueId() {
44 | return this.queueId;
45 | }
46 |
47 | public String getSubName() {
48 | return this.subscriberName;
49 | }
50 |
51 | public int getSubId() {
52 | return this.subscriberId;
53 | }
54 |
55 | public void setLocal(boolean _local)
56 | {
57 | local = _local;
58 | }
59 | public boolean getLocal()
60 | {
61 | return local;
62 | }
63 |
64 | public boolean equals(Object obj)
65 | {
66 | if(!(obj instanceof PartitionData))
67 | return false;
68 |
69 | PartitionData tPart = (PartitionData)obj;
70 | return this.topicPartition.equals(tPart.topicPartition);
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/internals/QPATInfoList.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.internals;
2 | import java.sql.Connection;
3 | import java.sql.SQLException;
4 | import org.oracle.okafka.common.internals.QPATInfo;
5 | import oracle.jdbc.OracleArray;
6 | import oracle.jdbc.OracleData;
7 | import oracle.jdbc.OracleDataFactory;
8 | import oracle.jdbc.internal.OracleTypes;
9 | import oracle.jpub.runtime.OracleDataMutableArray;
10 | public class QPATInfoList implements OracleData, OracleDataFactory {
11 | public static final String _SQL_NAME = "SYS.AQ$_QPAT_INFO_LIST";
12 | public static final int _SQL_TYPECODE = OracleTypes.ARRAY;
13 | OracleDataMutableArray _array;
14 | private static final QPATInfoList _QPATInfoList_Factory = new QPATInfoList();
15 |
16 | public static OracleDataFactory getOracleDataFactory() {
17 | return _QPATInfoList_Factory;
18 | }
19 | public QPATInfoList()
20 | {
21 | this((QPATInfo[])null);
22 | }
23 | public QPATInfoList(QPATInfo[] a)
24 | {
25 | _array = new OracleDataMutableArray(2002, a, QPATInfo.getFactory());
26 | }
27 | @Override
28 | public OracleData create(Object d, int sqlType) throws SQLException {
29 | if (d == null) return null;
30 | QPATInfoList a = new QPATInfoList();
31 | a._array = new OracleDataMutableArray(2002, (OracleArray) d, QPATInfo.getFactory());
32 | return a;
33 | }
34 | @Override
35 | public Object toJDBCObject(Connection con) throws SQLException {
36 | return _array.toJDBCObject(con, _SQL_NAME);
37 | }
38 |
39 | public int length() throws SQLException {
40 | return _array.length();
41 | }
42 | public int getBaseType() throws SQLException{
43 | return _array.getBaseType();
44 | }
45 | public String getBaseTypeName() throws SQLException
46 | {
47 | return _array.getBaseTypeName();
48 | }
49 | public QPATInfo[] getArray() throws SQLException
50 | {
51 | return (QPATInfo[]) _array.getObjectArray(
52 | new QPATInfo[_array.length()]);
53 | }
54 | public void setArray(QPATInfo[] a) throws SQLException
55 | {
56 | _array.setObjectArray(a);
57 | }
58 | public QPATInfo[] getArray(long index, int count) throws SQLException
59 | {
60 | return (QPATInfo[]) _array.getObjectArray(index,
61 | new QPATInfo[_array.sliceLength(index, count)]);
62 | }
63 | public void setArray(QPATInfo[] a, long index) throws SQLException
64 | {
65 | _array.setObjectArray(a, index);
66 | }
67 | public QPATInfo getElement(long index) throws SQLException
68 | {
69 | return (QPATInfo) _array.getObjectElement(index);
70 | }
71 | public void setElement(QPATInfo a, long index) throws SQLException
72 | {
73 | _array.setObjectElement(a, index);
74 | }
75 | }
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/internals/QPIMInfo.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.internals;
2 | import java.math.BigDecimal;
3 | import java.sql.Connection;
4 | import java.sql.SQLException;
5 | import oracle.jdbc.OracleConnection;
6 | import oracle.jdbc.OracleData;
7 | import oracle.jdbc.OracleDataFactory;
8 | import oracle.jdbc.OracleStruct;
9 | import oracle.jdbc.internal.ObjectData;
10 | import oracle.jdbc.internal.OracleTypes;
11 | import oracle.jpub.runtime.OracleDataMutableStruct;
12 | public class QPIMInfo implements OracleData, OracleDataFactory, ObjectData {
13 | public static final String _SQL_NAME = "SYS.AQ$_QPIM_INFO";
14 | public static final int _SQL_TYPECODE = OracleTypes.STRUCT;
15 | static int[] _sqlType =
16 | {
17 | 12, 12, 4, 4
18 | };
19 | static OracleDataFactory[] _factory = new OracleDataFactory[4];
20 | public static QPIMInfo _QPIMInfo_Factory = new QPIMInfo();
21 |
22 | OracleDataMutableStruct _struct;
23 |
24 | private OracleConnection con = null;
25 | public static OracleDataFactory getFactory() {
26 | return _QPIMInfo_Factory;
27 | }
28 |
29 | public QPIMInfo() {
30 | _struct = new OracleDataMutableStruct(new Object[4], _sqlType, _factory);
31 | }
32 | @Override
33 | public OracleData create(Object d, int sqlType) throws SQLException {
34 | if (d == null) return null;
35 | QPIMInfo o = new QPIMInfo();
36 | if( d instanceof QPIMInfo){
37 | o.shallowCopy((QPIMInfo)d);
38 | }else{
39 | o._struct = new OracleDataMutableStruct((OracleStruct) d, _sqlType, _factory);
40 | }
41 | return o;
42 | }
43 | @Override
44 | public Object toJDBCObject(Connection con) throws SQLException {
45 |
46 | Object[] attrbs = new Object[13];
47 | attrbs[0] = getOwner();
48 | attrbs[1] = getQueueName();
49 | attrbs[2] = getPartitionId();
50 | attrbs[3] = getOwnerInstId();
51 | return con.createStruct(_SQL_NAME, attrbs);
52 | }
53 |
54 | public String toString()
55 | {
56 | if(_struct == null)
57 | return null;
58 | try
59 | {
60 | String str = "{OwnerInstance:"+getOwner()+",TopicName:"+getQueueName()+",Partition:"+getPartitionId()+",OwnerInstanceID:"+getOwnerInstId()+"}";
61 | return str;
62 | }catch(Exception e)
63 | {
64 | return "Null " +e.getMessage();
65 | }
66 | }
67 |
68 | void shallowCopy(QPIMInfo d) throws SQLException {
69 | _struct = d._struct;
70 | }
71 | public void setOwner(String owner) throws SQLException{
72 | _struct.setAttribute(0, owner);
73 | }
74 |
75 | public String getOwner() throws SQLException{
76 | return (String)_struct.getAttribute(0);
77 | }
78 |
79 | public void setQueueName(String name) throws SQLException{
80 | _struct.setAttribute(1, name);
81 | }
82 |
83 | public String getQueueName() throws SQLException{
84 | return (String)_struct.getAttribute(1);
85 | }
86 | public void setPartitionId(int partition) throws SQLException{
87 | _struct.setAttribute(2, new BigDecimal(partition));
88 | }
89 |
90 | public Integer getPartitionId() throws SQLException{
91 | return (Integer)((BigDecimal)_struct.getAttribute(2)).intValue();
92 | }
93 |
94 | public void setOwnerInstId(int inst) throws SQLException{
95 | _struct.setAttribute(3, new BigDecimal(inst));
96 | }
97 |
98 | public Integer getOwnerInstId() throws SQLException{
99 | return (Integer)((BigDecimal)_struct.getAttribute(3)).intValue();
100 | }
101 | }
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/internals/QPIMInfoList.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.internals;
2 | import java.sql.Connection;
3 | import java.sql.SQLException;
4 | import org.oracle.okafka.common.internals.QPIMInfo;
5 | import oracle.jdbc.OracleArray;
6 | import oracle.jdbc.OracleData;
7 | import oracle.jdbc.OracleDataFactory;
8 | import oracle.jdbc.internal.OracleTypes;
9 | import oracle.jpub.runtime.OracleDataMutableArray;
10 | public class QPIMInfoList implements OracleData, OracleDataFactory {
11 | public static final String _SQL_NAME = "SYS.AQ$_QPIM_INFO_LIST";
12 | public static final int _SQL_TYPECODE = OracleTypes.ARRAY;
13 | OracleDataMutableArray _array;
14 | private static final QPIMInfoList _QPIMInfoList_Factory = new QPIMInfoList();
15 |
16 | public static OracleDataFactory getOracleDataFactory() {
17 | return _QPIMInfoList_Factory;
18 | }
19 | public QPIMInfoList()
20 | {
21 | this((QPIMInfo[])null);
22 | }
23 | public QPIMInfoList(QPIMInfo[] a)
24 | {
25 | _array = new OracleDataMutableArray(2002, a, QPIMInfo.getFactory());
26 | }
27 | @Override
28 | public OracleData create(Object d, int sqlType) throws SQLException {
29 | if (d == null) return null;
30 | QPIMInfoList a = new QPIMInfoList();
31 | a._array = new OracleDataMutableArray(2002, (OracleArray) d, QPIMInfo.getFactory());
32 | return a;
33 | }
34 | @Override
35 | public Object toJDBCObject(Connection con) throws SQLException {
36 | return _array.toJDBCObject(con, _SQL_NAME);
37 | }
38 |
39 | public int length() throws SQLException {
40 | return _array.length();
41 | }
42 | public int getBaseType() throws SQLException{
43 | return _array.getBaseType();
44 | }
45 | public String getBaseTypeName() throws SQLException
46 | {
47 | return _array.getBaseTypeName();
48 | }
49 | public QPIMInfo[] getArray() throws SQLException
50 | {
51 | return (QPIMInfo[]) _array.getObjectArray(
52 | new QPIMInfo[_array.length()]);
53 | }
54 | public void setArray(QPIMInfo[] a) throws SQLException
55 | {
56 | _array.setObjectArray(a);
57 | }
58 | public QPIMInfo[] getArray(long index, int count) throws SQLException
59 | {
60 | return (QPIMInfo[]) _array.getObjectArray(index,
61 | new QPIMInfo[_array.sliceLength(index, count)]);
62 | }
63 | public void setArray(QPIMInfo[] a, long index) throws SQLException
64 | {
65 | _array.setObjectArray(a, index);
66 | }
67 | public QPIMInfo getElement(long index) throws SQLException
68 | {
69 | return (QPIMInfo) _array.getObjectElement(index);
70 | }
71 | public void setElement(QPIMInfo a, long index) throws SQLException
72 | {
73 | _array.setObjectElement(a, index);
74 | }
75 |
76 | }
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/record/BaseRecords.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | package org.oracle.okafka.common.record;
26 |
27 | /**
28 | * Base interface for accessing records which could be contained in the log, or an in-memory materialization of log records.
29 | */
30 | public interface BaseRecords {
31 | /**
32 | * The size of these records in bytes.
33 | * @return The size in bytes of the records
34 | */
35 | int sizeInBytes();
36 |
37 | /**
38 | * Encapsulate this {@link BaseRecords} object into {@link RecordsSend}
39 | * @return Initialized {@link RecordsSend} object
40 | */
41 | //void toSend(String destination);
42 | }
43 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/AbstractRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | /*
26 | * 04/20/2020: This file is modified to support Kafka Java Client compatability to Oracle Transactional Event Queues.
27 | *
28 | */
29 |
30 | package org.oracle.okafka.common.requests;
31 |
32 | import org.oracle.okafka.common.protocol.ApiKeys;
33 |
34 | public abstract class AbstractRequest extends org.apache.kafka.common.requests.AbstractRequest{
35 |
36 | public AbstractRequest(ApiKeys apiKey, short version)
37 | {
38 | super(ApiKeys.convertToApacheKafkaKey(apiKey), version);
39 | }
40 |
41 | public static abstract class Builder extends org.apache.kafka.common.requests.AbstractRequest.Builder
42 | {
43 | private final ApiKeys apiKey;
44 |
45 |
46 | public Builder(ApiKeys apiKey) {
47 | super(ApiKeys.convertToApacheKafkaKey(apiKey), (short)1);
48 | this.apiKey = apiKey;
49 | }
50 |
51 | public ApiKeys apiKeyOKafka() {
52 | return apiKey;
53 | }
54 |
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/AbstractResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | /*
26 | * 04/20/2020: This file is modified to support Kafka Java Client compatability to Oracle Transactional Event Queues.
27 | *
28 | */
29 |
30 | package org.oracle.okafka.common.requests;
31 |
32 | import org.oracle.okafka.common.protocol.ApiKeys;
33 |
34 | public abstract class AbstractResponse extends org.apache.kafka.common.requests.AbstractResponse {
35 | ApiKeys apiKey;
36 |
37 | protected AbstractResponse(ApiKeys apiKey) {
38 | super(ApiKeys.convertToApacheKafkaKey(apiKey));
39 | this.apiKey = apiKey;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/CommitRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.common.requests;
9 |
10 | import java.util.List;
11 | import java.util.Map;
12 |
13 | import org.apache.kafka.clients.consumer.OffsetAndMetadata;
14 | import org.oracle.okafka.common.Node;
15 | import org.apache.kafka.common.TopicPartition;
16 | import org.apache.kafka.common.protocol.ApiMessage;
17 | import org.apache.kafka.common.requests.AbstractResponse;
18 | import org.oracle.okafka.common.protocol.ApiKeys;
19 |
20 | public class CommitRequest extends AbstractRequest {
21 | public static class Builder extends AbstractRequest.Builder {
22 |
23 | private final Map> nodeTPMap;
24 | private final Map offsetAndMetadata;
25 |
26 | public Builder(Map> _nodeTPMap, Map offsetAndMetadata) {
27 | super(ApiKeys.COMMIT);
28 | this.nodeTPMap = _nodeTPMap;
29 | this.offsetAndMetadata = offsetAndMetadata;
30 | }
31 |
32 | @Override
33 | public CommitRequest build() {
34 | return new CommitRequest(nodeTPMap, offsetAndMetadata);
35 | }
36 |
37 | @Override
38 | public String toString() {
39 | StringBuilder bld = new StringBuilder();
40 | bld.append("(type=commitRequest").
41 | append(")");
42 | return bld.toString();
43 | }
44 |
45 | @Override
46 | public CommitRequest build(short version) {
47 | return new CommitRequest(nodeTPMap, offsetAndMetadata);
48 | }
49 | }
50 |
51 | private final Map> nodeTPMap;
52 | private final Map offsetAndMetadata;
53 | private CommitRequest(Map> _nodeTPMap, Map offsetAndMetadata) {
54 | super(ApiKeys.COMMIT,(short)1);
55 | this.nodeTPMap = _nodeTPMap;
56 | this.offsetAndMetadata = offsetAndMetadata;
57 | }
58 |
59 | public Map> nodes() {
60 | return this.nodeTPMap;
61 | }
62 |
63 | public Map offsets() {
64 | return this.offsetAndMetadata;
65 | }
66 |
67 | @Override
68 | public ApiMessage data() {
69 | // TODO Auto-generated method stub
70 | return null;
71 | }
72 |
73 | @Override
74 | public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
75 | // TODO Auto-generated method stub
76 | return null;
77 | }
78 |
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/CommitResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.common.requests;
9 |
10 | import java.util.List;
11 | import java.util.Map;
12 |
13 | import org.apache.kafka.clients.consumer.OffsetAndMetadata;
14 | import org.oracle.okafka.common.Node;
15 | import org.oracle.okafka.common.errors.FeatureNotSupportedException;
16 | import org.oracle.okafka.common.protocol.ApiKeys;
17 | import org.apache.kafka.common.TopicPartition;
18 | import org.apache.kafka.common.protocol.ApiMessage;
19 | import org.apache.kafka.common.protocol.Errors;
20 |
21 | public class CommitResponse extends AbstractResponse {
22 |
23 | private final boolean error;
24 | private final Map result;
25 | private final Map> nodes;
26 | private final Map offsets;
27 |
28 | public CommitResponse(Map result, Map> nodes,
29 | Map offsets, boolean error) {
30 | super(ApiKeys.COMMIT);
31 | this.result = result;
32 | this.nodes = nodes;
33 | this.offsets = offsets;
34 | this.error = error;
35 |
36 | }
37 |
38 | public Map getResult() {
39 | return result;
40 | }
41 |
42 | public Map> getNodes() {
43 | return nodes;
44 | }
45 |
46 | public Map offsets() {
47 | return offsets;
48 | }
49 |
50 | public boolean error() {
51 | return error;
52 | }
53 |
54 | @Override
55 | public ApiMessage data() {
56 | // TODO Auto-generated method stub
57 | return null;
58 | }
59 |
60 | @Override
61 | public Map errorCounts() {
62 | // TODO Auto-generated method stub
63 | return null;
64 | }
65 |
66 | @Override
67 | public int throttleTimeMs() {
68 | // TODO Auto-generated method stub
69 | return 0;
70 | }
71 |
72 | @Override
73 | public void maybeSetThrottleTimeMs(int arg0) {
74 | throw new FeatureNotSupportedException("This feature is not suported for this release.");
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/ConnectMeRequest.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.requests;
2 |
3 | import org.apache.kafka.common.protocol.ApiMessage;
4 | import org.apache.kafka.common.requests.AbstractResponse;
5 | import org.oracle.okafka.common.protocol.ApiKeys;
6 |
7 | public class ConnectMeRequest extends AbstractRequest {
8 |
9 | private String schemaName;
10 | private String topicName;
11 | private String groupId;
12 |
13 | public static class Builder extends AbstractRequest.Builder
14 | {
15 | private String schemaName;
16 | private String topicName;
17 | private String groupId;
18 |
19 | public Builder(String _schemaName , String _topicName, String _groupId)
20 | {
21 | super(ApiKeys.CONNECT_ME);
22 | this.schemaName = _schemaName;
23 | this.topicName = _topicName;
24 | this.groupId = _groupId;
25 | }
26 |
27 | public ConnectMeRequest build()
28 | {
29 | return new ConnectMeRequest(this.schemaName,this.topicName,this.groupId);
30 | }
31 |
32 | @Override
33 | public ConnectMeRequest build(short version) {
34 | return new ConnectMeRequest(this.schemaName,this.topicName,this.groupId);
35 | }
36 | }
37 |
38 | public ConnectMeRequest(String _schemaName , String _topicName, String _groupId)
39 | {
40 | super(ApiKeys.CONNECT_ME,(short)1);
41 | this.schemaName = _schemaName;
42 | this.topicName = _topicName;
43 | this.groupId = _groupId;
44 | }
45 |
46 | public String getSchemaName()
47 | {
48 | return schemaName;
49 | }
50 | public String getToipcName()
51 | {
52 | return topicName;
53 | }
54 | public String getGroupId()
55 | {
56 | return groupId;
57 | }
58 |
59 | @Override
60 | public ApiMessage data() {
61 | // TODO Auto-generated method stub
62 | return null;
63 | }
64 |
65 | @Override
66 | public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
67 | // TODO Auto-generated method stub
68 | return null;
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/CreateTopicsResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | /*
26 | * 04/20/2020: This file is modified to support Kafka Java Client compatability to Oracle Transactional Event Queues.
27 | *
28 | */
29 |
30 | package org.oracle.okafka.common.requests;
31 |
32 | import java.util.Map;
33 |
34 | import org.apache.kafka.common.Uuid;
35 | import org.apache.kafka.common.protocol.ApiMessage;
36 | import org.apache.kafka.common.protocol.Errors;
37 | import org.oracle.okafka.common.errors.FeatureNotSupportedException;
38 | import org.oracle.okafka.common.protocol.ApiKeys;
39 |
40 | public class CreateTopicsResponse extends AbstractResponse {
41 | final Map errors;
42 | final Map topicIdMap;
43 | private Exception requestResult;
44 |
45 | public CreateTopicsResponse(Map errors, Map topicIdMap) {
46 | super(ApiKeys.CREATE_TOPICS);
47 | this.errors = errors;
48 | this.topicIdMap=topicIdMap;
49 | this.requestResult = null;
50 | }
51 |
52 | public Map errors() {
53 | return errors;
54 | }
55 |
56 | public void setResult(Exception ex) {
57 | if(requestResult != null) {
58 | requestResult = ex;
59 | }
60 | }
61 |
62 | public Exception getResult() {
63 | return requestResult;
64 | }
65 |
66 | public Map topicIdMap(){
67 | return topicIdMap;
68 | }
69 |
70 | @Override
71 | public ApiMessage data() {
72 | // TODO Auto-generated method stub
73 | return null;
74 | }
75 |
76 | @Override
77 | public Map errorCounts() {
78 | // TODO Auto-generated method stub
79 | return null;
80 | }
81 |
82 | @Override
83 | public int throttleTimeMs() {
84 | // TODO Auto-generated method stub
85 | return 0;
86 | }
87 |
88 | @Override
89 | public void maybeSetThrottleTimeMs(int arg0) {
90 | throw new FeatureNotSupportedException("This feature is not suported for this release.");
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/DeleteGroupsRequest.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.requests;
2 |
3 | import java.util.List;
4 |
5 | import org.apache.kafka.common.protocol.ApiMessage;
6 | import org.oracle.okafka.common.protocol.ApiKeys;
7 |
8 | public class DeleteGroupsRequest extends AbstractRequest {
9 | private final List groups;
10 |
11 | public static class Builder extends AbstractRequest.Builder {
12 | private final List groups;
13 |
14 | public Builder(List groups) {
15 | super(ApiKeys.DELETE_GROUPS);
16 | this.groups = groups;
17 | }
18 |
19 | @Override
20 | public DeleteGroupsRequest build(short version) {
21 | return new DeleteGroupsRequest(groups);
22 | }
23 |
24 | @Override
25 | public String toString() {
26 | return groups.toString();
27 | }
28 | }
29 |
30 | public DeleteGroupsRequest(List groups) {
31 | super(ApiKeys.DELETE_GROUPS, (short)1);
32 | this.groups = groups;
33 | }
34 |
35 | public List groups() {
36 | return this.groups;
37 | }
38 |
39 | @Override
40 | public ApiMessage data() {
41 | // TODO Auto-generated method stub
42 | return null;
43 | }
44 |
45 | @Override
46 | public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
47 | // TODO Auto-generated method stub
48 | return null;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/DeleteGroupsResponse.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.requests;
2 |
3 | import java.util.Map;
4 |
5 | import org.apache.kafka.common.protocol.ApiMessage;
6 | import org.apache.kafka.common.protocol.Errors;
7 | import org.oracle.okafka.common.protocol.ApiKeys;
8 |
9 | public class DeleteGroupsResponse extends AbstractResponse {
10 |
11 | private final Map errorMap;
12 | private Exception exception;
13 |
14 | public DeleteGroupsResponse(Map errors) {
15 | super(ApiKeys.DELETE_GROUPS);
16 | this.errorMap = errors;
17 | }
18 |
19 | public Map errors(){
20 | return errorMap;
21 | }
22 |
23 | public void setException(Exception exception) {
24 | this.exception = exception;
25 | }
26 |
27 | public Exception getException() {
28 | return exception;
29 | }
30 |
31 | @Override
32 | public ApiMessage data() {
33 | // TODO Auto-generated method stub
34 | return null;
35 | }
36 |
37 | @Override
38 | public Map errorCounts() {
39 | // TODO Auto-generated method stub
40 | return null;
41 | }
42 |
43 | @Override
44 | public int throttleTimeMs() {
45 | // TODO Auto-generated method stub
46 | return 0;
47 | }
48 |
49 | @Override
50 | public void maybeSetThrottleTimeMs(int throttleTimeMs) {
51 | // TODO Auto-generated method stub
52 |
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/DeleteTopicsRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | /*
26 | * 04/20/2020: This file is modified to support Kafka Java Client compatability to Oracle Transactional Event Queues.
27 | *
28 | */
29 |
30 | package org.oracle.okafka.common.requests;
31 |
32 | import java.util.Set;
33 |
34 | import org.oracle.okafka.common.protocol.ApiKeys;
35 | import org.apache.kafka.common.Uuid;
36 | import org.apache.kafka.common.protocol.ApiMessage;
37 | import org.apache.kafka.common.requests.AbstractResponse;
38 | import org.apache.kafka.common.utils.Utils;
39 |
40 | public class DeleteTopicsRequest extends AbstractRequest {
41 |
42 | private final Set topics;
43 | private final Set topicIds;
44 | private final Integer timeout;
45 |
46 | public static class Builder extends AbstractRequest.Builder {
47 | private final Set topics;
48 | private final Set topicIds;
49 | private final Integer timeout;
50 |
51 | public Builder(Set topics, Set topicIds, Integer timeout) {
52 | super(ApiKeys.DELETE_TOPICS);
53 | this.topics = topics;
54 | this.topicIds=topicIds;
55 | this.timeout = timeout;
56 | }
57 |
58 | @Override
59 | public DeleteTopicsRequest build() {
60 | return new DeleteTopicsRequest(topics, topicIds, timeout);
61 | }
62 |
63 | @Override
64 | public DeleteTopicsRequest build(short version) {
65 | return new DeleteTopicsRequest(topics,topicIds , timeout);
66 | }
67 |
68 | @Override
69 | public String toString() {
70 | StringBuilder bld = new StringBuilder();
71 | bld.append("(type=DeleteTopicsRequest").
72 | append(topics!=null ? ", topics=(" : ", topic Ids=(").
73 | append(topics!=null ? Utils.join(topics, ", ") : Utils.join(topicIds, ", ")).append(")").
74 | append(", timeout=").append(timeout).
75 | append(")");
76 | return bld.toString();
77 | }
78 |
79 |
80 | }
81 |
82 | private DeleteTopicsRequest(Set topics, Set topicIds, Integer timeout) {
83 | super(ApiKeys.DELETE_TOPICS, (short)1);
84 | this.topics = topics;
85 | this.topicIds=topicIds;
86 | this.timeout = timeout;
87 | }
88 |
89 | public Set topics() {
90 | return topics;
91 | }
92 |
93 | public Integer timeout() {
94 | return this.timeout;
95 | }
96 |
97 | public Set topicIds(){
98 | return topicIds;
99 | }
100 |
101 | @Override
102 | public ApiMessage data() {
103 | // TODO Auto-generated method stub
104 | return null;
105 | }
106 |
107 | @Override
108 | public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
109 | // TODO Auto-generated method stub
110 | return null;
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/DeleteTopicsResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | /*
26 | * 04/20/2020: This file is modified to support Kafka Java Client compatability to Oracle Transactional Event Queues.
27 | *
28 | */
29 |
30 | package org.oracle.okafka.common.requests;
31 |
32 | import java.sql.SQLException;
33 | import java.util.Map;
34 |
35 | import org.apache.kafka.common.Uuid;
36 | import org.apache.kafka.common.protocol.ApiMessage;
37 | import org.apache.kafka.common.protocol.Errors;
38 | import org.oracle.okafka.common.errors.FeatureNotSupportedException;
39 | import org.oracle.okafka.common.protocol.ApiKeys;
40 |
41 |
42 | public class DeleteTopicsResponse extends AbstractResponse {
43 | private final Map topicNameErrorMap;
44 | private final Map topicIdErrorMap;
45 | private Exception requestResult;
46 |
47 | public DeleteTopicsResponse(Map topicNameErrorMap, Map topicIdErrorMap) {
48 | super(ApiKeys.DELETE_TOPICS);
49 | this.topicNameErrorMap = topicNameErrorMap;
50 | this.topicIdErrorMap=topicIdErrorMap;
51 | this.requestResult = null;
52 | }
53 |
54 | public Map topicErrormap(){
55 | return this.topicNameErrorMap;
56 | }
57 |
58 | public Map topicIdErrorMap(){
59 | return this.topicIdErrorMap;
60 | }
61 |
62 | public void setResult(Exception ex) {
63 | if(requestResult != null) {
64 | requestResult = ex;
65 | }
66 | }
67 |
68 | public Exception getResult() {
69 | return requestResult;
70 | }
71 |
72 | @Override
73 | public ApiMessage data() {
74 | // TODO Auto-generated method stub
75 | return null;
76 | }
77 |
78 | @Override
79 | public Map errorCounts() {
80 | // TODO Auto-generated method stub
81 | return null;
82 | }
83 |
84 | @Override
85 | public int throttleTimeMs() {
86 | // TODO Auto-generated method stub
87 | return 0;
88 | }
89 |
90 | @Override
91 | public void maybeSetThrottleTimeMs(int arg0) {
92 | throw new FeatureNotSupportedException("This feature is not suported for this release.");
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/FetchRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | /*
26 | * 04/20/2020: This file is modified to support Kafka Java Client compatability to Oracle Transactional Event Queues.
27 | *
28 | */
29 |
30 | package org.oracle.okafka.common.requests;
31 |
32 | import org.apache.kafka.common.protocol.ApiMessage;
33 | import org.apache.kafka.common.requests.AbstractResponse;
34 | import org.oracle.okafka.common.protocol.ApiKeys;
35 |
36 | public class FetchRequest extends AbstractRequest {
37 |
38 | public static class Builder extends AbstractRequest.Builder {
39 |
40 | private final String topic;
41 | private final long pollTimeoutMs;
42 |
43 | public Builder(String topic, long pollTimeoutMs) {
44 | super(ApiKeys.FETCH);
45 | this.topic = topic;
46 | this.pollTimeoutMs = pollTimeoutMs;
47 | }
48 |
49 | @Override
50 | public FetchRequest build() {
51 | return new FetchRequest(topic, pollTimeoutMs);
52 | }
53 |
54 | @Override
55 | public String toString() {
56 | StringBuilder bld = new StringBuilder();
57 | bld.append("(type=fetchRequest").
58 | append(", topics=").append(topic).
59 | append(")");
60 | return bld.toString();
61 | }
62 |
63 | @Override
64 | public FetchRequest build(short version) {
65 | return build();
66 | }
67 | }
68 |
69 | private final String topic;
70 | private final long pollTimeoutMs;
71 | private FetchRequest(String topic, long pollTimeoutMs) {
72 | super(ApiKeys.FETCH, (short)1);
73 | this.topic = topic;
74 | this.pollTimeoutMs = pollTimeoutMs;
75 | }
76 |
77 | public String topic() {
78 | return this.topic;
79 | }
80 |
81 | public long pollTimeout() {
82 | return this.pollTimeoutMs;
83 | }
84 |
85 | @Override
86 | public ApiMessage data() {
87 | // TODO Auto-generated method stub
88 | return null;
89 | }
90 |
91 | @Override
92 | public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
93 | // TODO Auto-generated method stub
94 | return null;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/FetchResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | /*
26 | * 04/20/2020: This file is modified to support Kafka Java Client compatability to Oracle Transactional Event Queues.
27 | *
28 | */
29 |
30 | package org.oracle.okafka.common.requests;
31 |
32 | import oracle.jms.AQjmsBytesMessage;
33 |
34 | import java.util.List;
35 | import java.util.Map;
36 |
37 | import org.apache.kafka.common.protocol.ApiMessage;
38 | import org.apache.kafka.common.protocol.Errors;
39 | import org.oracle.okafka.common.errors.FeatureNotSupportedException;
40 | import org.oracle.okafka.common.protocol.ApiKeys;
41 |
42 | public class FetchResponse extends AbstractResponse {
43 | private final String topic;
44 | private final List messages;
45 | private final Exception exception;
46 |
47 | public FetchResponse(String topic, List messages, Exception exception) {
48 | super(ApiKeys.FETCH);
49 | this.topic = topic;
50 | this.messages = messages;
51 | this.exception = exception;
52 | }
53 |
54 | public String topic() {
55 | return topic;
56 | }
57 |
58 | public List getMessages() {
59 | return this.messages;
60 | }
61 |
62 | public Exception getException() {
63 | return this.exception;
64 | }
65 |
66 | @Override
67 | public ApiMessage data() {
68 | // TODO Auto-generated method stub
69 | return null;
70 | }
71 |
72 | @Override
73 | public Map errorCounts() {
74 | // TODO Auto-generated method stub
75 | return null;
76 | }
77 |
78 | @Override
79 | public int throttleTimeMs() {
80 | // TODO Auto-generated method stub
81 | return 0;
82 | }
83 |
84 | @Override
85 | public void maybeSetThrottleTimeMs(int arg0) {
86 | throw new FeatureNotSupportedException("This feature is not suported for this release.");
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/IsolationLevel.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 | package org.oracle.okafka.common.requests;
25 |
26 | public enum IsolationLevel {
27 | READ_UNCOMMITTED((byte) 0), READ_COMMITTED((byte) 1);
28 |
29 | private final byte id;
30 |
31 | IsolationLevel(byte id) {
32 | this.id = id;
33 | }
34 |
35 | public byte id() {
36 | return id;
37 | }
38 |
39 | public static IsolationLevel forId(byte id) {
40 | switch (id) {
41 | case 0:
42 | return READ_UNCOMMITTED;
43 | case 1:
44 | return READ_COMMITTED;
45 | default:
46 | throw new IllegalArgumentException("Unknown isolation level " + id);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/JoinGroupRequest.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.requests;
2 |
3 | import org.apache.kafka.common.protocol.ApiMessage;
4 | import org.apache.kafka.common.requests.AbstractResponse;
5 | import org.oracle.okafka.common.internals.SessionData;
6 | import org.oracle.okafka.common.protocol.ApiKeys;
7 |
8 | public class JoinGroupRequest extends AbstractRequest {
9 |
10 | public static class Builder extends AbstractRequest.Builder {
11 | private SessionData sessionData;
12 |
13 | public Builder(SessionData sessionData) {
14 | super(ApiKeys.JOIN_GROUP);
15 | this.sessionData = sessionData;
16 | }
17 |
18 | @Override
19 | public JoinGroupRequest build() {
20 | return new JoinGroupRequest(sessionData);
21 | }
22 |
23 | @Override
24 | public String toString() {
25 | StringBuilder bld = new StringBuilder();
26 | bld.append("(type=joinGroupRequest")
27 | .append(")");
28 | return bld.toString();
29 | }
30 |
31 | @Override
32 | public JoinGroupRequest build(short version) {
33 | return build();
34 | }
35 |
36 | }
37 |
38 | private SessionData sessionData;
39 | public JoinGroupRequest(SessionData sessionData ) {
40 | super(ApiKeys.JOIN_GROUP, (short)1);
41 | this.sessionData = sessionData;
42 |
43 | }
44 |
45 | public SessionData getSessionData() {
46 | return this.sessionData;
47 | }
48 |
49 | @Override
50 | public ApiMessage data() {
51 | // TODO Auto-generated method stub
52 | return null;
53 | }
54 |
55 | @Override
56 | public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
57 | // TODO Auto-generated method stub
58 | return null;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/JoinGroupResponse.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.requests;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | import org.oracle.okafka.common.errors.FeatureNotSupportedException;
7 | import org.oracle.okafka.common.internals.PartitionData;
8 | import org.oracle.okafka.common.internals.SessionData;
9 | import org.oracle.okafka.common.protocol.ApiKeys;
10 | import org.apache.kafka.common.protocol.ApiMessage;
11 | import org.apache.kafka.common.protocol.Errors;
12 | import org.apache.kafka.common.utils.LogContext;
13 | import org.slf4j.Logger;
14 |
15 | public class JoinGroupResponse extends AbstractResponse {
16 | private Map sessionData;
17 | private List partitions;
18 | private int leader;
19 | private int version;
20 | private Exception exception;
21 | protected final Logger log ;
22 |
23 | public JoinGroupResponse(Map sessionData, List partitions, int leader, int version, Exception exception) {
24 | super(ApiKeys.JOIN_GROUP);
25 | this.sessionData= sessionData;
26 | this.partitions = partitions;
27 | this.leader = leader;
28 | this.version = version;
29 | this.exception = exception;
30 | LogContext logContext = new LogContext("[AQ$_JOIN_GROUP:]");
31 | this.log = logContext.logger(JoinGroupResponse.class) ;
32 |
33 | log.debug("QPAT:");
34 |
35 | for(String mapSessionDataKeyNow : sessionData.keySet() )
36 | {
37 | log.debug("MapSessionDataKey " + mapSessionDataKeyNow );
38 | SessionData sessionDataNow = sessionData.get(mapSessionDataKeyNow);
39 | log.debug("Session Data Now: " + sessionDataNow.toString());
40 | }
41 |
42 | if(partitions != null)
43 | {
44 | log.debug("QPIM:");
45 | for(PartitionData pData: partitions)
46 | {
47 | log.debug("PData: " + pData);
48 | }
49 | }else
50 | {
51 | log.debug("QPIM: NULL");
52 | }
53 | log.debug("Leader = " +leader +", Verssion: " + version );
54 | }
55 |
56 | public Map getSessionData() {
57 | return this.sessionData;
58 | }
59 |
60 | public List partitions() {
61 | return this.partitions;
62 | }
63 |
64 | public int leader() {
65 | return this.leader;
66 | }
67 |
68 | public int version() {
69 | return this.version;
70 | }
71 |
72 | public Exception getException() {
73 | return this.exception;
74 | }
75 |
76 | @Override
77 | public ApiMessage data() {
78 | // TODO Auto-generated method stub
79 | return null;
80 | }
81 |
82 | @Override
83 | public Map errorCounts() {
84 | // TODO Auto-generated method stub
85 | return null;
86 | }
87 |
88 | @Override
89 | public int throttleTimeMs() {
90 | // TODO Auto-generated method stub
91 | return 0;
92 | }
93 |
94 | @Override
95 | public void maybeSetThrottleTimeMs(int arg0) {
96 | throw new FeatureNotSupportedException("This feature is not suported for this release.");
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/ListGroupsRequest.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.requests;
2 |
3 | import org.oracle.okafka.common.protocol.ApiKeys;
4 | import org.apache.kafka.common.protocol.ApiMessage;
5 | import org.apache.kafka.common.requests.AbstractResponse;
6 |
7 | public class ListGroupsRequest extends AbstractRequest {
8 |
9 | public static class Builder extends AbstractRequest.Builder {
10 | public Builder() {
11 | super(ApiKeys.LIST_GROUPS);
12 | }
13 |
14 | @Override
15 | public ListGroupsRequest build(short version) {
16 | return new ListGroupsRequest(version);
17 | }
18 |
19 | @Override
20 | public String toString() {
21 | return "(type = ListGroupsRequest)";
22 | }
23 | }
24 |
25 | public ListGroupsRequest(short version) {
26 | super(ApiKeys.LIST_GROUPS, version);
27 | }
28 |
29 | @Override
30 | public ApiMessage data() {
31 | // TODO Auto-generated method stub
32 | return null;
33 | }
34 |
35 | @Override
36 | public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
37 | // TODO Auto-generated method stub
38 | return null;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/ListGroupsResponse.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.requests;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | import org.oracle.okafka.common.protocol.ApiKeys;
7 | import org.apache.kafka.common.protocol.ApiMessage;
8 | import org.apache.kafka.common.protocol.Errors;
9 |
10 | public class ListGroupsResponse extends AbstractResponse{
11 |
12 | private final List groupNames;
13 | private Exception exception;
14 |
15 | public ListGroupsResponse(List groups ) {
16 | super(ApiKeys.LIST_GROUPS);
17 | this.groupNames = groups;
18 | }
19 |
20 | public List groups(){
21 | return groupNames;
22 | }
23 |
24 | public void setException(Exception ex) {
25 | this.exception = ex;
26 | }
27 |
28 | public Exception getException() {
29 | return exception;
30 | }
31 |
32 | @Override
33 | public ApiMessage data() {
34 | // TODO Auto-generated method stub
35 | return null;
36 | }
37 | @Override
38 | public Map errorCounts() {
39 | // TODO Auto-generated method stub
40 | return null;
41 | }
42 | @Override
43 | public int throttleTimeMs() {
44 | // TODO Auto-generated method stub
45 | return 0;
46 | }
47 | @Override
48 | public void maybeSetThrottleTimeMs(int throttleTimeMs) {
49 | // TODO Auto-generated method stub
50 |
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/ListOffsetsRequest.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.requests;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | import org.apache.kafka.common.protocol.ApiMessage;
7 | import org.apache.kafka.common.requests.AbstractResponse;
8 | import org.oracle.okafka.common.protocol.ApiKeys;
9 |
10 | public class ListOffsetsRequest extends AbstractRequest {
11 |
12 | public static final long EARLIEST_TIMESTAMP = -2L;
13 | public static final long LATEST_TIMESTAMP = -1L;
14 | public static final long MAX_TIMESTAMP = -3L;
15 |
16 | private final Map> topicoffsetPartitionMap;
17 |
18 | public static class Builder extends AbstractRequest.Builder {
19 | private final Map> topicoffsetPartitionMap;
20 |
21 | public Builder(Map> topicoffsetPartitionMap) {
22 | super(ApiKeys.LIST_OFFSETS);
23 | this.topicoffsetPartitionMap = topicoffsetPartitionMap;
24 | }
25 |
26 | @Override
27 | public ListOffsetsRequest build(short version) {
28 | return new ListOffsetsRequest(topicoffsetPartitionMap, version);
29 | }
30 |
31 | @Override
32 | public String toString() {
33 | return "(type=ListOffsetsRequest, " + topicoffsetPartitionMap.toString();
34 | }
35 | }
36 |
37 | private ListOffsetsRequest(Map> topicoffsetPartitionMap, short version) {
38 | super(ApiKeys.LIST_OFFSETS, version);
39 | this.topicoffsetPartitionMap = topicoffsetPartitionMap;
40 | }
41 |
42 | public Map> getOffsetPartitionMap() {
43 | return topicoffsetPartitionMap;
44 | }
45 |
46 | @Override
47 | public ApiMessage data() {
48 | // TODO Auto-generated method stub
49 | return null;
50 | }
51 |
52 | @Override
53 | public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
54 | // TODO Auto-generated method stub
55 | return null;
56 | }
57 |
58 | public static class ListOffsetsPartition {
59 | int partitionIndex;
60 | long timestamp;
61 |
62 | public ListOffsetsPartition() {
63 | this.partitionIndex = 0;
64 | this.timestamp = 0L;
65 | }
66 |
67 | @Override
68 | public boolean equals(Object obj) {
69 | if (!(obj instanceof ListOffsetsPartition))
70 | return false;
71 | ListOffsetsPartition other = (ListOffsetsPartition) obj;
72 | if (partitionIndex != other.partitionIndex)
73 | return false;
74 | if (timestamp != other.timestamp)
75 | return false;
76 | return true;
77 | }
78 |
79 | @Override
80 | public int hashCode() {
81 | int hashCode = 0;
82 | hashCode = 31 * hashCode + partitionIndex;
83 | hashCode = 31 * hashCode + ((int) (timestamp >> 32) ^ (int) timestamp);
84 | return hashCode;
85 | }
86 |
87 | @Override
88 | public String toString() {
89 | return "ListOffsetsPartition(" + "partitionIndex=" + partitionIndex + ", timestamp=" + timestamp + ")";
90 | }
91 |
92 | public int partitionIndex() {
93 | return this.partitionIndex;
94 | }
95 |
96 | public long timestamp() {
97 | return this.timestamp;
98 | }
99 |
100 | public ListOffsetsPartition setPartitionIndex(int v) {
101 | this.partitionIndex = v;
102 | return this;
103 | }
104 |
105 | public ListOffsetsPartition setTimestamp(long v) {
106 | this.timestamp = v;
107 | return this;
108 | }
109 |
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/ListOffsetsResponse.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.requests;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | import org.apache.kafka.common.protocol.ApiMessage;
7 | import org.apache.kafka.common.protocol.Errors;
8 | import org.oracle.okafka.common.errors.FeatureNotSupportedException;
9 | import org.oracle.okafka.common.protocol.ApiKeys;
10 |
11 | public class ListOffsetsResponse extends AbstractResponse {
12 | final Map> offsetPartitionResponseMap;
13 | private Exception exception;
14 |
15 | public ListOffsetsResponse(Map> offsetPartitionResponseMap) {
16 | super(ApiKeys.LIST_OFFSETS);
17 | this.offsetPartitionResponseMap = offsetPartitionResponseMap;
18 | exception = null;
19 | }
20 |
21 | public Map> getOffsetPartitionResponseMap() {
22 | return offsetPartitionResponseMap;
23 | }
24 |
25 | public void setException(Exception ex) {
26 | if (exception != null) {
27 | exception = ex;
28 | }
29 | }
30 |
31 | public Exception getException() {
32 | return exception;
33 | }
34 |
35 | public static class ListOffsetsPartitionResponse {
36 | int partitionIndex;
37 | Exception error;
38 | long timestamp;
39 | long offset;
40 |
41 | public ListOffsetsPartitionResponse() {
42 | this.partitionIndex = 0;
43 | this.error = null;
44 | this.timestamp = -1L;
45 | this.offset = -1L;
46 | }
47 |
48 | @Override
49 | public boolean equals(Object obj) {
50 | if (!(obj instanceof ListOffsetsPartitionResponse))
51 | return false;
52 | ListOffsetsPartitionResponse other = (ListOffsetsPartitionResponse) obj;
53 | if (partitionIndex != other.partitionIndex)
54 | return false;
55 | if (error != other.error)
56 | return false;
57 | if (timestamp != other.timestamp)
58 | return false;
59 | if (offset != other.offset)
60 | return false;
61 | return true;
62 | }
63 |
64 | @Override
65 | public int hashCode() {
66 | int hashCode = 0;
67 | hashCode = 31 * hashCode + partitionIndex;
68 | hashCode = 31 * hashCode + ((int) (timestamp >> 32) ^ (int) timestamp);
69 | hashCode = 31 * hashCode + ((int) (offset >> 32) ^ (int) offset);
70 | return hashCode;
71 | }
72 |
73 | @Override
74 | public String toString() {
75 | return "ListOffsetsPartitionResponse(" + "partitionIndex=" + partitionIndex + ", error=" + error
76 | + ", timestamp=" + timestamp + ", offset=" + offset + ")";
77 | }
78 |
79 | public int partitionIndex() {
80 | return this.partitionIndex;
81 | }
82 |
83 | public Exception getError() {
84 | return this.error;
85 | }
86 |
87 | public long timestamp() {
88 | return this.timestamp;
89 | }
90 |
91 | public long offset() {
92 | return this.offset;
93 | }
94 |
95 | public ListOffsetsPartitionResponse setPartitionIndex(int v) {
96 | this.partitionIndex = v;
97 | return this;
98 | }
99 |
100 | public ListOffsetsPartitionResponse setError(Exception v) {
101 | this.error = v;
102 | return this;
103 | }
104 |
105 | public ListOffsetsPartitionResponse setTimestamp(long v) {
106 | this.timestamp = v;
107 | return this;
108 | }
109 |
110 | public ListOffsetsPartitionResponse setOffset(long v) {
111 | this.offset = v;
112 | return this;
113 | }
114 | }
115 |
116 | @Override
117 | public ApiMessage data() {
118 | // TODO Auto-generated method stub
119 | return null;
120 | }
121 |
122 | @Override
123 | public Map errorCounts() {
124 | // TODO Auto-generated method stub
125 | return null;
126 | }
127 |
128 | @Override
129 | public int throttleTimeMs() {
130 | // TODO Auto-generated method stub
131 | return 0;
132 | }
133 |
134 | @Override
135 | public void maybeSetThrottleTimeMs(int throttleTimeMs) {
136 | throw new FeatureNotSupportedException("This feature is not suported for this release.");
137 | }
138 |
139 | }
140 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/OffsetFetchRequest.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.requests;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | import org.apache.kafka.common.TopicPartition;
7 | import org.apache.kafka.common.protocol.ApiMessage;
8 | import org.apache.kafka.common.requests.AbstractResponse;
9 | import org.oracle.okafka.common.protocol.ApiKeys;
10 |
11 | public class OffsetFetchRequest extends AbstractRequest{
12 |
13 | public static final List ALL_TOPIC_PARTITIONS = null;
14 | private final Map> perGroupTopicPartitions;
15 |
16 | public static class Builder extends AbstractRequest.Builder {
17 | private final Map> perGroupTopicPartitions;
18 |
19 | public Builder(Map> perGroupTopicPartitions) {
20 | super(ApiKeys.OFFSET_FETCH);
21 | this.perGroupTopicPartitions = perGroupTopicPartitions;
22 | }
23 |
24 | @Override
25 | public OffsetFetchRequest build(short version) {
26 | return new OffsetFetchRequest(perGroupTopicPartitions, version);
27 | }
28 |
29 | @Override
30 | public String toString() {
31 | return "(type=ListOffsetsRequest, " + ", " + "GroupIdTopicPartitions:" + perGroupTopicPartitions.toString();
32 | }
33 | }
34 |
35 | private OffsetFetchRequest(Map> perGroupTopicPartitions, short version) {
36 | super(ApiKeys.OFFSET_FETCH, version);
37 | this.perGroupTopicPartitions = perGroupTopicPartitions;
38 | }
39 |
40 | public Map> perGroupTopicpartitions(){
41 | return perGroupTopicPartitions;
42 | }
43 |
44 | @Override
45 | public ApiMessage data() {
46 | // TODO Auto-generated method stub
47 | return null;
48 | }
49 |
50 | @Override
51 | public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
52 | // TODO Auto-generated method stub
53 | return null;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/OffsetFetchResponse.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.requests;
2 |
3 | import java.util.Map;
4 | import java.util.Objects;
5 |
6 | import org.apache.kafka.common.TopicPartition;
7 | import org.apache.kafka.common.protocol.ApiMessage;
8 | import org.apache.kafka.common.protocol.Errors;
9 | import org.oracle.okafka.common.protocol.ApiKeys;
10 |
11 | public class OffsetFetchResponse extends AbstractResponse {
12 |
13 | private final Map> offsetFetchResponseMap;
14 | private Exception exception;
15 |
16 | public static final class PartitionOffsetData {
17 | public final long offset;
18 | public final Exception error;
19 |
20 | public PartitionOffsetData(long offset, Exception error) {
21 | this.offset = offset;
22 | this.error = error;
23 | }
24 |
25 | @Override
26 | public boolean equals(Object other) {
27 | if (!(other instanceof PartitionOffsetData))
28 | return false;
29 | PartitionOffsetData otherPartition = (PartitionOffsetData) other;
30 | return Objects.equals(this.offset, otherPartition.offset)
31 | && Objects.equals(this.error, otherPartition.error);
32 | }
33 |
34 | @Override
35 | public String toString() {
36 | return "PartitionData(" + "offset=" + offset + ", error='" + error != null ? error.toString() : null + ")";
37 | }
38 |
39 | @Override
40 | public int hashCode() {
41 | return Objects.hash(offset, error);
42 | }
43 | }
44 |
45 | public OffsetFetchResponse(Map> offsetFetchResponseMap) {
46 | super(ApiKeys.OFFSET_FETCH);
47 | this.offsetFetchResponseMap = offsetFetchResponseMap;
48 | exception = null;
49 | }
50 |
51 | public void setException(Exception ex) {
52 | this.exception=ex;
53 | }
54 |
55 | public Map> getOffsetFetchResponseMap(){
56 | return offsetFetchResponseMap;
57 | }
58 |
59 | public Exception getException() {
60 | return exception;
61 | }
62 |
63 | @Override
64 | public ApiMessage data() {
65 | // TODO Auto-generated method stub
66 | return null;
67 | }
68 |
69 | @Override
70 | public Map errorCounts() {
71 | // TODO Auto-generated method stub
72 | return null;
73 | }
74 |
75 | @Override
76 | public int throttleTimeMs() {
77 | // TODO Auto-generated method stub
78 | return 0;
79 | }
80 |
81 | @Override
82 | public void maybeSetThrottleTimeMs(int throttleTimeMs) {
83 | // TODO Auto-generated method stub
84 |
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/OffsetResetRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.common.requests;
9 |
10 | import java.util.Map;
11 |
12 | import org.apache.kafka.common.TopicPartition;
13 | import org.apache.kafka.common.protocol.ApiMessage;
14 | import org.apache.kafka.common.requests.AbstractResponse;
15 | import org.oracle.okafka.common.protocol.ApiKeys;
16 |
17 | public class OffsetResetRequest extends AbstractRequest {
18 |
19 | public static class Builder extends AbstractRequest.Builder {
20 |
21 | private final Map offsetResetTimestamps;
22 | private final long pollTimeoutMs;
23 |
24 | public Builder(Map offsetResetTimestamps, long pollTimeoutMs) {
25 | super(ApiKeys.OFFSETRESET);
26 | this.offsetResetTimestamps = offsetResetTimestamps;
27 | this.pollTimeoutMs = pollTimeoutMs;
28 | }
29 |
30 | @Override
31 | public OffsetResetRequest build() {
32 | return new OffsetResetRequest(offsetResetTimestamps, pollTimeoutMs);
33 | }
34 |
35 | @Override
36 | public String toString() {
37 | StringBuilder bld = new StringBuilder();
38 | bld.append("(type=OffsetResetRequest").
39 | append(", offsetResetTimestampss=").append(offsetResetTimestamps).
40 | append(")");
41 | return bld.toString();
42 | }
43 |
44 | @Override
45 | public OffsetResetRequest build(short version) {
46 | return build();
47 | }
48 | }
49 |
50 | private final Map offsetResetTimestamps;
51 | private final long pollTimeoutMs;
52 | private OffsetResetRequest(Map offsetResetTimestamps, long pollTimeoutMs) {
53 | super(ApiKeys.OFFSETRESET, (short)0);
54 | this.offsetResetTimestamps = offsetResetTimestamps;
55 | this.pollTimeoutMs = pollTimeoutMs;
56 | }
57 |
58 | public Map offsetResetTimestamps() {
59 | return this.offsetResetTimestamps;
60 | }
61 |
62 | public long pollTimeout() {
63 | return this.pollTimeoutMs;
64 | }
65 |
66 | @Override
67 | public ApiMessage data() {
68 | // TODO Auto-generated method stub
69 | return null;
70 | }
71 |
72 | @Override
73 | public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
74 | // TODO Auto-generated method stub
75 | return null;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/OffsetResetResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.common.requests;
9 |
10 | import java.util.Map;
11 | import org.apache.kafka.common.TopicPartition;
12 | import org.apache.kafka.common.protocol.ApiMessage;
13 | import org.apache.kafka.common.protocol.Errors;
14 | import org.oracle.okafka.common.errors.FeatureNotSupportedException;
15 | import org.oracle.okafka.common.protocol.ApiKeys;
16 |
17 | public class OffsetResetResponse extends AbstractResponse {
18 | private final Map offsetResetResponse;
19 | private final Exception exception ;
20 | public OffsetResetResponse(Map offsetResetResponse, Exception exception) {
21 | super(ApiKeys.OFFSETRESET);
22 | this.offsetResetResponse = offsetResetResponse;
23 | this.exception = exception;
24 | }
25 |
26 | public Map offsetResetResponse() {
27 | return offsetResetResponse;
28 | }
29 |
30 | public Exception getException() {
31 | return exception;
32 | }
33 |
34 | @Override
35 | public ApiMessage data() {
36 | // TODO Auto-generated method stub
37 | return null;
38 | }
39 |
40 | @Override
41 | public Map errorCounts() {
42 | // TODO Auto-generated method stub
43 | return null;
44 | }
45 |
46 | @Override
47 | public int throttleTimeMs() {
48 | // TODO Auto-generated method stub
49 | return 0;
50 | }
51 |
52 | @Override
53 | public void maybeSetThrottleTimeMs(int arg0) {
54 | throw new FeatureNotSupportedException("This feature is not suported for this release.");
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/RequestHeader.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | /*
26 | * 04/20/2020: This file is modified to support Kafka Java Client compatability to Oracle Transactional Event Queues.
27 | *
28 | */
29 |
30 | package org.oracle.okafka.common.requests;
31 |
32 | import static java.util.Objects.requireNonNull;
33 |
34 | import org.apache.kafka.common.message.RequestHeaderData;
35 | import org.oracle.okafka.common.protocol.ApiKeys;
36 |
37 | /**
38 | * The header for a request in the Kafka protocol
39 | */
40 | public class RequestHeader {// extends org.apache.kafka.common.requests.RequestHeader{
41 |
42 | private final RequestHeaderData data;
43 | private final ApiKeys apiKey;
44 | private final String clientId;
45 | private final int correlationId;
46 |
47 | public RequestHeader(ApiKeys apiKey, String clientId, int correlation) {
48 | data = new RequestHeaderData().setClientId(clientId).setCorrelationId(correlation).setRequestApiKey(apiKey.id);
49 | this.apiKey = requireNonNull(apiKey);
50 | this.clientId = clientId;
51 | this.correlationId = correlation;
52 | }
53 |
54 | public ApiKeys apiKey() {
55 | return apiKey;
56 | }
57 |
58 | public String clientId() {
59 | return clientId;
60 | }
61 |
62 | public int correlationId() {
63 | return correlationId;
64 | }
65 |
66 | public ResponseHeader toResponseHeader() {
67 | return new ResponseHeader(correlationId);
68 | }
69 |
70 | @Override
71 | public String toString() {
72 | return "RequestHeader(apiKey=" + apiKey +
73 | ", clientId=" + clientId +
74 | ", correlationId=" + correlationId +
75 | ")";
76 | }
77 |
78 | @Override
79 | public boolean equals(Object o) {
80 | if (this == o) return true;
81 | if (o == null || getClass() != o.getClass()) return false;
82 |
83 | RequestHeader that = (RequestHeader) o;
84 | return apiKey == that.apiKey &&
85 | correlationId == that.correlationId &&
86 | (clientId == null ? that.clientId == null : clientId.equals(that.clientId));
87 | }
88 |
89 | @Override
90 | public int hashCode() {
91 | int result = apiKey.hashCode();
92 | result = 31 * result + (clientId != null ? clientId.hashCode() : 0);
93 | result = 31 * result + correlationId;
94 | return result;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/ResponseHeader.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | /*
9 | * Licensed to the Apache Software Foundation (ASF) under one or more
10 | * contributor license agreements. See the NOTICE file distributed with
11 | * this work for additional information regarding copyright ownership.
12 | * The ASF licenses this file to You under the Apache License, Version 2.0
13 | * (the "License"); you may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | /*
26 | * 04/20/2020: This file is modified to support Kafka Java Client compatability to Oracle Transactional Event Queues.
27 | *
28 | */
29 |
30 | package org.oracle.okafka.common.requests;
31 |
32 | /**
33 | * A response header in the kafka protocol.
34 | */
35 | public class ResponseHeader {
36 | private final int correlationId;
37 |
38 | public ResponseHeader(int correlationId) {
39 | this.correlationId = correlationId;
40 | }
41 |
42 | public int correlationId() {
43 | return correlationId;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/SubscribeRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.common.requests;
9 |
10 | import org.apache.kafka.common.protocol.ApiMessage;
11 | import org.apache.kafka.common.requests.AbstractResponse;
12 | import org.oracle.okafka.common.protocol.ApiKeys;
13 |
14 | public class SubscribeRequest extends AbstractRequest {
15 | public static class Builder extends AbstractRequest.Builder {
16 | private final String topic;
17 | public Builder(String topic) {
18 | super(ApiKeys.SUBSCRIBE);
19 | this.topic = topic;
20 | }
21 |
22 | @Override
23 | public SubscribeRequest build() {
24 | return new SubscribeRequest(topic);
25 | }
26 |
27 | @Override
28 | public String toString() {
29 | StringBuilder bld = new StringBuilder();
30 | bld.append("(type=subscribeRequest").
31 | append(", topics=").append(topic).
32 | append(")");
33 | return bld.toString();
34 | }
35 |
36 | @Override
37 | public SubscribeRequest build(short version) {
38 | return build();
39 | }
40 | }
41 | private final String topic;
42 | public SubscribeRequest(String topic) {
43 | super(ApiKeys.SUBSCRIBE,(short)1);
44 | this.topic = topic;
45 | }
46 |
47 | public String getTopic() {
48 | return this.topic;
49 | }
50 |
51 | @Override
52 | public ApiMessage data() {
53 | // TODO Auto-generated method stub
54 | return null;
55 | }
56 |
57 | @Override
58 | public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
59 | // TODO Auto-generated method stub
60 | return null;
61 | }
62 |
63 | }
64 |
65 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/SubscribeResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.common.requests;
9 |
10 | import java.util.Map;
11 |
12 | import javax.jms.JMSException;
13 |
14 | import org.apache.kafka.common.protocol.ApiMessage;
15 | import org.apache.kafka.common.protocol.Errors;
16 | import org.oracle.okafka.common.errors.FeatureNotSupportedException;
17 | import org.oracle.okafka.common.protocol.ApiKeys;
18 |
19 | public class SubscribeResponse extends AbstractResponse {
20 | private final JMSException exception;
21 | private final String topic;
22 |
23 | public SubscribeResponse(String topic, JMSException exception) {
24 | super(ApiKeys.SUBSCRIBE);
25 | this.topic = topic;
26 | this.exception = exception;
27 | }
28 |
29 | public String getTopic() {
30 | return this.topic;
31 |
32 | }
33 |
34 | public JMSException getException() {
35 | return this.exception;
36 | }
37 |
38 | @Override
39 | public ApiMessage data() {
40 | // TODO Auto-generated method stub
41 | return null;
42 | }
43 |
44 | @Override
45 | public Map errorCounts() {
46 | // TODO Auto-generated method stub
47 | return null;
48 | }
49 |
50 | @Override
51 | public int throttleTimeMs() {
52 | // TODO Auto-generated method stub
53 | return 0;
54 | }
55 |
56 | @Override
57 | public void maybeSetThrottleTimeMs(int arg0) {
58 | throw new FeatureNotSupportedException("This feature is not suported for this release.");
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/SyncGroupRequest.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.requests;
2 |
3 | import java.util.List;
4 |
5 | import org.apache.kafka.common.protocol.ApiMessage;
6 | import org.apache.kafka.common.requests.AbstractResponse;
7 | import org.oracle.okafka.common.internals.SessionData;
8 | import org.oracle.okafka.common.protocol.ApiKeys;
9 |
10 | public class SyncGroupRequest extends AbstractRequest {
11 | public static class Builder extends AbstractRequest.Builder {
12 | private List sessionData;
13 | private final int version;
14 |
15 | public Builder(List sessionData, int version) {
16 | super(ApiKeys.SYNC_GROUP);
17 | this.sessionData = sessionData;
18 | this.version = version;
19 | }
20 |
21 | @Override
22 | public SyncGroupRequest build() {
23 | return new SyncGroupRequest(sessionData, version);
24 | }
25 |
26 | @Override
27 | public String toString() {
28 | StringBuilder bld = new StringBuilder();
29 | bld.append("(type=SyncGroupRequest")
30 | .append(")");
31 | return bld.toString();
32 | }
33 |
34 | @Override
35 | public SyncGroupRequest build(short version) {
36 | return build();
37 | }
38 |
39 | }
40 |
41 | private List sessionData;
42 | private int version;
43 | public SyncGroupRequest(List sessionData, int version) {
44 | super(ApiKeys.SYNC_GROUP,(short)1);
45 | this.sessionData = sessionData;
46 | this.version = version;
47 | }
48 |
49 | public List getSessionData() {
50 | return this.sessionData;
51 | }
52 |
53 | public int getVersion() {
54 | return this.version;
55 | }
56 |
57 | @Override
58 | public ApiMessage data() {
59 | // TODO Auto-generated method stub
60 | return null;
61 | }
62 |
63 | @Override
64 | public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
65 | // TODO Auto-generated method stub
66 | return null;
67 | }
68 |
69 | }
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/SyncGroupResponse.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.requests;
2 |
3 | import java.util.Map;
4 |
5 | import org.apache.kafka.common.protocol.ApiMessage;
6 | import org.apache.kafka.common.protocol.Errors;
7 | import org.oracle.okafka.common.internals.SessionData;
8 | import org.oracle.okafka.common.protocol.ApiKeys;
9 |
10 | public class SyncGroupResponse extends AbstractResponse {
11 | private SessionData sessionData;
12 | private int version;
13 | private Exception exception;
14 |
15 | public SyncGroupResponse(SessionData sessionData, int version, Exception exception) {
16 | super(ApiKeys.SYNC_GROUP);
17 | this.sessionData = sessionData;
18 | this.version = version;
19 | this.exception = exception;
20 | }
21 |
22 | public SessionData getSessionData() {
23 | return this.sessionData;
24 | }
25 |
26 | public int getVersion() {
27 | return this.version;
28 | }
29 |
30 | public Exception getException() {
31 | return this.exception;
32 | }
33 |
34 | @Override
35 | public ApiMessage data() {
36 | // TODO Auto-generated method stub
37 | return null;
38 | }
39 |
40 | @Override
41 | public Map errorCounts() {
42 | // TODO Auto-generated method stub
43 | return null;
44 | }
45 |
46 | @Override
47 | public int throttleTimeMs() {
48 | // TODO Auto-generated method stub
49 | return 0;
50 | }
51 |
52 | @Override
53 | public void maybeSetThrottleTimeMs(int arg0) {
54 | // TODO Auto-generated method stub
55 |
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/UnsubscribeRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.common.requests;
9 |
10 | import org.apache.kafka.common.protocol.ApiMessage;
11 | import org.apache.kafka.common.requests.AbstractResponse;
12 | import org.oracle.okafka.common.protocol.ApiKeys;
13 |
14 | public class UnsubscribeRequest extends AbstractRequest {
15 | public static class Builder extends AbstractRequest.Builder {
16 |
17 | public Builder() {
18 | super(ApiKeys.UNSUBSCRIBE);
19 | }
20 |
21 | @Override
22 | public UnsubscribeRequest build() {
23 | return new UnsubscribeRequest();
24 | }
25 |
26 | @Override
27 | public String toString() {
28 | StringBuilder bld = new StringBuilder();
29 | bld.append("(type=unsubscribeRequest").
30 | append(")");
31 | return bld.toString();
32 | }
33 |
34 | @Override
35 | public UnsubscribeRequest build(short version) {
36 | return build();
37 | }
38 | }
39 | public UnsubscribeRequest() {
40 | super(ApiKeys.UNSUBSCRIBE,(short)1);
41 | }
42 | @Override
43 | public ApiMessage data() {
44 | // TODO Auto-generated method stub
45 | return null;
46 | }
47 | @Override
48 | public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
49 | // TODO Auto-generated method stub
50 | return null;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/requests/UnsubscribeResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.common.requests;
9 |
10 | import java.util.Map;
11 |
12 | import org.apache.kafka.common.protocol.ApiMessage;
13 | import org.apache.kafka.common.protocol.Errors;
14 | import org.oracle.okafka.common.errors.FeatureNotSupportedException;
15 | import org.oracle.okafka.common.protocol.ApiKeys;
16 |
17 | public class UnsubscribeResponse extends AbstractResponse {
18 | private final Map response;
19 |
20 | public UnsubscribeResponse(Map response) {
21 | super(ApiKeys.UNSUBSCRIBE);
22 | this.response = response;
23 | }
24 |
25 | public Map response() {
26 | return this.response;
27 |
28 | }
29 |
30 | @Override
31 | public ApiMessage data() {
32 | // TODO Auto-generated method stub
33 | return null;
34 | }
35 |
36 | @Override
37 | public Map errorCounts() {
38 | // TODO Auto-generated method stub
39 | return null;
40 | }
41 |
42 | @Override
43 | public int throttleTimeMs() {
44 | // TODO Auto-generated method stub
45 | return 0;
46 | }
47 |
48 | @Override
49 | public void maybeSetThrottleTimeMs(int arg0) {
50 | throw new FeatureNotSupportedException("This feature is not suported for this release.");
51 | }
52 |
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/utils/ReflectionUtil.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.common.utils;
2 |
3 | import java.lang.reflect.Constructor;
4 | import java.lang.reflect.InvocationTargetException;
5 |
6 | public class ReflectionUtil {
7 | public static T createInstance(Class clazz, Class>[] paramTypes, Object... args) {
8 | T instance = null;
9 | try {
10 | Constructor constructor = clazz.getDeclaredConstructor(paramTypes);
11 | constructor.setAccessible(true);
12 | instance = constructor.newInstance(args);
13 | } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
14 | | IllegalArgumentException | InvocationTargetException e) {
15 | throw new RuntimeException("Failed to create instance via reflection", e);
16 | }
17 | return instance;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/clients/src/main/java/org/oracle/okafka/common/utils/TNSParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** OKafka Java Client version 23.4.
3 | **
4 | ** Copyright (c) 2019, 2024 Oracle and/or its affiliates.
5 | ** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
6 | */
7 |
8 | package org.oracle.okafka.common.utils;
9 |
10 | import org.oracle.okafka.clients.CommonClientConfigs;
11 | import org.apache.kafka.common.config.AbstractConfig;
12 |
13 | import java.io.File;
14 | import java.io.FileNotFoundException;
15 | import java.io.FileReader;
16 | import java.io.IOException;
17 | import java.util.Stack;
18 | import java.util.StringTokenizer;
19 | public class TNSParser {
20 | private final AbstractConfig configs;
21 | private String fileStr ;
22 | private final String hashChar = "#";
23 | private final String eol = "\r\n";
24 |
25 | public TNSParser( AbstractConfig configs) {
26 | this.configs = configs;
27 | }
28 |
29 | public static String getProperty(String connStr, String property) {
30 | int index = connStr.indexOf(property);
31 | if(index == -1)
32 | return null;
33 | int index1 = connStr.indexOf("=", index);
34 | if(index1 == -1)
35 | return null;
36 | int index2 = connStr.indexOf(")", index1);
37 | if(index2 == -1)
38 | return null;
39 | return connStr.substring(index1 + 1, index2).trim();
40 | }
41 | public String getConnectionString(String alias) {
42 | String aliasTmp = alias.trim().toUpperCase();
43 | Stack stack = new Stack<>();
44 | int index = -1;
45 | boolean found = false;
46 | while((index = fileStr.indexOf(aliasTmp, index + 1)) != -1 ) {
47 | if( fileStr.indexOf("=(DESCRIPTION", index) == index + aliasTmp.length()) {
48 | found = true;
49 | break;
50 | }
51 | }
52 | if ( found ) {
53 | for(int ind = index; ind < fileStr.length() ; ind++) {
54 | if(fileStr.charAt(ind) == '(')
55 | {stack.push("("); }
56 | else if(fileStr.charAt(ind) == ')'){
57 | if(stack.empty())
58 | return null;
59 | stack.pop();
60 | if(stack.empty())
61 | return fileStr.substring(index, ind + 1);
62 | //if( ind + 1 < fileStr.length() && (fileStr.charAt(ind + 1) != '(' || fileStr.charAt(ind + 1) != ')'))
63 | //return null;
64 | }
65 |
66 | }
67 | }
68 | return null;
69 | }
70 | private String removeUnwanted(String fileStr) {
71 |
72 | StringBuilder sb = new StringBuilder();
73 | for(int ind = 0 ; ind < fileStr.length(); ind++) {
74 | if( fileStr.charAt(ind) != ' ' )
75 | sb.append(fileStr.charAt(ind));
76 | }
77 | String strtmp = new String (sb.toString());
78 | String filestr = "";
79 | String tokenstr = new String ();
80 | StringTokenizer st = new StringTokenizer(strtmp, eol);
81 | while(st.hasMoreTokens()) {
82 | tokenstr = st.nextToken().trim();
83 | if (!tokenstr.contains(hashChar))
84 | filestr = filestr + tokenstr + eol;
85 | else {
86 | if(tokenstr.indexOf(hashChar) != 0)
87 | filestr = filestr + tokenstr.substring(0, tokenstr.indexOf(hashChar)) + eol;
88 | }
89 | }
90 | return filestr;
91 |
92 | }
93 | public void readFile() throws FileNotFoundException, IOException {
94 | char[] buf = null;
95 | FileReader fr = null;
96 | try {
97 | File f = new File(configs.getString(CommonClientConfigs.ORACLE_NET_TNS_ADMIN) + "/tnsnames.ora");
98 | fr = new FileReader(f);
99 | int length = (int)f.length();
100 | buf = new char[length];
101 | fr.read(buf, 0, length);
102 |
103 |
104 | String fileStr = new String(buf);
105 | fileStr = fileStr.toUpperCase();
106 | this.fileStr = removeUnwanted(fileStr);
107 | } finally {
108 | if(fr != null)
109 | fr.close();
110 | }
111 |
112 |
113 |
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/clients/src/test/java/ojdbc.properties:
--------------------------------------------------------------------------------
1 | user=OKafka
2 | password=Welcome_123#
--------------------------------------------------------------------------------
/clients/src/test/java/org/oracle/okafka/tests/DeleteConsumerGroups.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.tests;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Arrays;
5 | import java.util.concurrent.ExecutionException;
6 |
7 | import org.apache.kafka.clients.admin.Admin;
8 | import org.apache.kafka.clients.admin.DeleteConsumerGroupsResult;
9 | import org.apache.kafka.common.KafkaFuture;
10 | import org.junit.Test;
11 | import org.oracle.okafka.clients.admin.AdminClient;
12 |
13 | public class DeleteConsumerGroups {
14 |
15 | @Test
16 | public void DeleteGroupsTest() {
17 |
18 | try (Admin admin = AdminClient.create(OkafkaSetup.setup())) {
19 |
20 | DeleteConsumerGroupsResult delResult = admin.deleteConsumerGroups(new ArrayList<>(Arrays.asList("S1")));
21 | try {
22 | KafkaFuture groupFutures = delResult.all();
23 | groupFutures.get();
24 | System.out.println("Main Thread Out of wait now");
25 | } catch (InterruptedException | ExecutionException e) {
26 |
27 | throw new IllegalStateException(e);
28 | }
29 | System.out.println("Auto Closing admin now");
30 | } catch (Exception e) {
31 | System.out.println("Exception while deleting groups " + e);
32 | e.printStackTrace();
33 | }
34 | System.out.println("Test: DeleteConsumerGroups completed");
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/clients/src/test/java/org/oracle/okafka/tests/ListConsumerGroupOffsets.java:
--------------------------------------------------------------------------------
1 | package org.oracle.okafka.tests;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Collections;
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | import org.apache.kafka.clients.admin.Admin;
9 | import org.apache.kafka.clients.admin.ListConsumerGroupOffsetsResult;
10 | import org.apache.kafka.clients.admin.ListConsumerGroupOffsetsSpec;
11 | import org.apache.kafka.clients.consumer.OffsetAndMetadata;
12 | import org.apache.kafka.common.KafkaFuture;
13 | import org.apache.kafka.common.TopicPartition;
14 | import org.junit.Test;
15 | import org.oracle.okafka.clients.admin.AdminClient;
16 |
17 | public class ListConsumerGroupOffsets {
18 |
19 | @Test
20 | public void ListConsumerGroupOffsetsTest() {
21 |
22 | try (Admin admin = AdminClient.create(OkafkaSetup.setup())) {
23 | String groupId = "S1";
24 | List topicPartitions = new ArrayList<>();
25 | topicPartitions.add(new TopicPartition("TEQ", 0));
26 | topicPartitions.add(new TopicPartition("TEQ", 1));
27 | topicPartitions.add(new TopicPartition("TEQ", 2));
28 | topicPartitions.add(new TopicPartition("TEQ", 3));
29 | topicPartitions.add(new TopicPartition("TEQ", 4));
30 |
31 | ListConsumerGroupOffsetsSpec spec = new ListConsumerGroupOffsetsSpec().topicPartitions(topicPartitions);
32 | ListConsumerGroupOffsetsResult result = admin
33 | .listConsumerGroupOffsets(Collections.singletonMap(groupId, spec));
34 | try {
35 | KafkaFuture