You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ar...@apache.org on 2019/01/29 09:56:49 UTC
[beam] branch master updated: [BEAM-6520] Deprecate MongoDb
`withKeepAlive`
This is an automated email from the ASF dual-hosted git repository.
aromanenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new f1fe880 [BEAM-6520] Deprecate MongoDb `withKeepAlive`
new a37615a Merge pull request #7648: [BEAM-6520] Deprecate MongoDb `withKeepAlive`
f1fe880 is described below
commit f1fe880c749810eb1dc2ae4c9c71e33dd23aa793
Author: Ismaël Mejía <ie...@gmail.com>
AuthorDate: Mon Jan 28 11:50:30 2019 +0100
[BEAM-6520] Deprecate MongoDb `withKeepAlive`
This is done because it is also deprecated in the Mongo driver.
---
.../org/apache/beam/sdk/io/mongodb/MongoDbIO.java | 57 ++++++++++++++++------
1 file changed, 41 insertions(+), 16 deletions(-)
diff --git a/sdks/java/io/mongodb/src/main/java/org/apache/beam/sdk/io/mongodb/MongoDbIO.java b/sdks/java/io/mongodb/src/main/java/org/apache/beam/sdk/io/mongodb/MongoDbIO.java
index 4f9d33f..e9694f8 100644
--- a/sdks/java/io/mongodb/src/main/java/org/apache/beam/sdk/io/mongodb/MongoDbIO.java
+++ b/sdks/java/io/mongodb/src/main/java/org/apache/beam/sdk/io/mongodb/MongoDbIO.java
@@ -133,6 +133,10 @@ public class MongoDbIO {
@Nullable
abstract String uri();
+ /**
+ * @deprecated This is deprecated in the MongoDB API and will be removed in a future version.
+ */
+ @Deprecated
abstract boolean keepAlive();
abstract int maxConnectionIdleTime();
@@ -162,7 +166,10 @@ public class MongoDbIO {
@AutoValue.Builder
abstract static class Builder {
abstract Builder setUri(String uri);
-
+ /**
+ * @deprecated This is deprecated in the MongoDB API and will be removed in a future version.
+ */
+ @Deprecated
abstract Builder setKeepAlive(boolean keepAlive);
abstract Builder setMaxConnectionIdleTime(int maxConnectionIdleTime);
@@ -226,7 +233,13 @@ public class MongoDbIO {
return builder().setUri(uri).build();
}
- /** Sets whether socket keep alive is enabled. */
+ /**
+ * Sets whether socket keep alive is enabled.
+ *
+ * @deprecated configuring keep-alive has been deprecated in the MongoDB Java API. It now
+ * defaults to true and disabling it is not recommended.
+ */
+ @Deprecated
public Read withKeepAlive(boolean keepAlive) {
return builder().setKeepAlive(keepAlive).build();
}
@@ -246,7 +259,7 @@ public class MongoDbIO {
return builder().setSslInvalidHostNameAllowed(invalidHostNameAllowed).build();
}
- /** Enable ignoreSSLCertificate for ssl for connection (allow for self signed ceritificates). */
+ /** Enable ignoreSSLCertificate for ssl for connection (allow for self signed certificates). */
public Read withIgnoreSSLCertificate(boolean ignoreSSLCertificate) {
return builder().setIgnoreSSLCertificate(ignoreSSLCertificate).build();
}
@@ -329,7 +342,7 @@ public class MongoDbIO {
/** A MongoDB {@link BoundedSource} reading {@link Document} from a given instance. */
@VisibleForTesting
static class BoundedMongoDbSource extends BoundedSource<Document> {
- private Read spec;
+ private final Read spec;
private BoundedMongoDbSource(Read spec) {
this.spec = spec;
@@ -403,7 +416,7 @@ public class MongoDbIO {
// the desired batch size is small, using default chunk size of 1MB
if (desiredBundleSizeBytes < 1024L * 1024L) {
- desiredBundleSizeBytes = 1L * 1024L * 1024L;
+ desiredBundleSizeBytes = 1024L * 1024L;
}
// now we have the batch size (provided by user or provided by the runner)
@@ -522,7 +535,7 @@ public class MongoDbIO {
private MongoCursor<Document> cursor;
private Document current;
- public BoundedMongoDbReader(BoundedMongoDbSource source) {
+ BoundedMongoDbReader(BoundedMongoDbSource source) {
this.source = source;
}
@@ -604,7 +617,10 @@ public class MongoDbIO {
@Nullable
abstract String uri();
-
+ /**
+ * @deprecated This is deprecated in the MongoDB API and will be removed in a future version.
+ */
+ @Deprecated
abstract boolean keepAlive();
abstract int maxConnectionIdleTime();
@@ -630,7 +646,10 @@ public class MongoDbIO {
@AutoValue.Builder
abstract static class Builder {
abstract Builder setUri(String uri);
-
+ /**
+ * @deprecated This is deprecated in the MongoDB API and will be removed in a future version.
+ */
+ @Deprecated
abstract Builder setKeepAlive(boolean keepAlive);
abstract Builder setMaxConnectionIdleTime(int maxConnectionIdleTime);
@@ -692,7 +711,13 @@ public class MongoDbIO {
return builder().setUri(uri).build();
}
- /** Sets whether socket keep alive is enabled. */
+ /**
+ * Sets whether socket keep alive is enabled.
+ *
+ * @deprecated configuring keep-alive has been deprecated in the MongoDB Java API. It now
+ * defaults to true and disabling it is not recommended.
+ */
+ @Deprecated
public Write withKeepAlive(boolean keepAlive) {
return builder().setKeepAlive(keepAlive).build();
}
@@ -723,7 +748,7 @@ public class MongoDbIO {
return builder().setOrdered(ordered).build();
}
- /** Enable ignoreSSLCertificate for ssl for connection (allow for self signed ceritificates). */
+ /** Enable ignoreSSLCertificate for ssl for connection (allow for self signed certificates). */
public Write withIgnoreSSLCertificate(boolean ignoreSSLCertificate) {
return builder().setIgnoreSSLCertificate(ignoreSSLCertificate).build();
}
@@ -775,12 +800,12 @@ public class MongoDbIO {
private transient MongoClient client;
private List<Document> batch;
- public WriteFn(Write spec) {
+ WriteFn(Write spec) {
this.spec = spec;
}
@Setup
- public void createMongoClient() throws Exception {
+ public void createMongoClient() {
client =
new MongoClient(
new MongoClientURI(
@@ -793,12 +818,12 @@ public class MongoDbIO {
}
@StartBundle
- public void startBundle() throws Exception {
+ public void startBundle() {
batch = new ArrayList<>();
}
@ProcessElement
- public void processElement(ProcessContext ctx) throws Exception {
+ public void processElement(ProcessContext ctx) {
// Need to copy the document because mongoCollection.insertMany() will mutate it
// before inserting (will assign an id).
batch.add(new Document(ctx.element()));
@@ -808,7 +833,7 @@ public class MongoDbIO {
}
@FinishBundle
- public void finishBundle() throws Exception {
+ public void finishBundle() {
flush();
}
@@ -830,7 +855,7 @@ public class MongoDbIO {
}
@Teardown
- public void closeMongoClient() throws Exception {
+ public void closeMongoClient() {
client.close();
client = null;
}