Github user priyank5485 commented on a diff in the pull request:
https://github.com/apache/storm/pull/1586#discussion_r72303034
--- Diff:
external/storm-kinesis/src/main/java/org/apache/storm/kinesis/spout/KinesisConnectionInfo.java
---
@@ -0,0 +1,137 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.storm.kinesis.spout;
+
+import com.amazonaws.ClientConfiguration;
+import com.amazonaws.auth.AWSCredentialsProvider;
+import com.amazonaws.regions.Regions;
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.io.Input;
+import com.esotericsoftware.kryo.io.Output;
+import org.objenesis.strategy.StdInstantiatorStrategy;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Serializable;
+import java.util.Arrays;
+
+public class KinesisConnectionInfo implements Serializable {
+ private final byte[] serializedKinesisCredsProvider;
+ private final byte[] serializedkinesisClientConfig;
+ private final Integer recordsLimit;
+ private final Regions region;
+
+ private transient AWSCredentialsProvider credentialsProvider;
+ private transient ClientConfiguration clientConfiguration;
+
+ /**
+ *
+ * @param credentialsProvider implementation to provide credentials to
connect to kinesis
+ * @param clientConfiguration client configuration to pass to kinesis
client
+ * @param region region to connect to
+ * @param recordsLimit max records to be fetched in a getRecords
request to kinesis
+ */
+ public KinesisConnectionInfo (AWSCredentialsProvider
credentialsProvider, ClientConfiguration clientConfiguration, Regions region,
Integer recordsLimit) {
+ if (recordsLimit == null || recordsLimit <= 0) {
+ throw new IllegalArgumentException("recordsLimit has to be a
positive integer");
+ }
+ if (region == null) {
+ throw new IllegalArgumentException("region cannot be null");
+ }
+ serializedKinesisCredsProvider =
getKryoSerializedBytes(credentialsProvider);
+ serializedkinesisClientConfig =
getKryoSerializedBytes(clientConfiguration);
+ this.recordsLimit = recordsLimit;
+ this.region = region;
+
+ this.credentialsProvider = null;
+ this.clientConfiguration = null;
+ }
+
+ public Integer getRecordsLimit() {
+ return recordsLimit;
+ }
+
+ public AWSCredentialsProvider getCredentialsProvider() {
+ if (credentialsProvider == null) {
+ credentialsProvider = (AWSCredentialsProvider)
this.getKryoDeserializedObject(serializedKinesisCredsProvider);
+ }
+ return credentialsProvider;
+ }
+
+ public ClientConfiguration getClientConfiguration() {
+ if (clientConfiguration == null) {
+ clientConfiguration = (ClientConfiguration)
this.getKryoDeserializedObject(serializedkinesisClientConfig);
+ }
+ return clientConfiguration;
+ }
+
+ public Regions getRegion() {
+ return region;
+ }
+
+ private byte[] getKryoSerializedBytes (final Object obj) {
+ final Kryo kryo = new Kryo();
+ final ByteArrayOutputStream os = new ByteArrayOutputStream();
+ final Output output = new Output(os);
+ kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
+ kryo.writeClassAndObject(output, obj);
+ output.flush();
+ return os.toByteArray();
+ }
+
+ private Object getKryoDeserializedObject (final byte[] ser) {
+ final Kryo kryo = new Kryo();
+ final Input input = new Input(new ByteArrayInputStream(ser));
+ kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
+ return kryo.readClassAndObject(input);
+ }
+
+ @Override
+ public boolean equals(Object o) {
--- End diff --
Will change it
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---