From cb8d2fc2c6d83a26c4d48ede6011557f24ce2850 Mon Sep 17 00:00:00 2001 From: Mithun Mandal Date: Tue, 6 Feb 2024 16:38:15 +0530 Subject: [PATCH] Update MongoDbInterpreter.java adding doc --- .../zeppelin/mongodb/MongoDbInterpreter.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java b/mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java index 2a2fc5f2e6a..49c565dee84 100644 --- a/mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java +++ b/mongodb/src/main/java/org/apache/zeppelin/mongodb/MongoDbInterpreter.java @@ -73,11 +73,12 @@ public void open() { } commandTimeout = Long.parseLong(getProperty("mongo.shell.command.timeout")); maxConcurrency = Integer.parseInt(getProperty("mongo.interpreter.concurrency.max")); - + + /* adding support for protocal like mongodb+srv for atlas cluster*/ String mongoProtocol = getProperty("mongo.server.protocol", "mongodb"); - if ("mongodb".equalsIgnoreCase(mongoProtocol)){ + if ("mongodb".equalsIgnoreCase(mongoProtocol)){ dbAddress = getProperty("mongo.server.host") + ":" + getProperty("mongo.server.port"); - }else{ + }else{ dbAddress = mongoProtocol +"://"+ getProperty("mongo.server.host"); } @@ -124,12 +125,14 @@ public InterpreterResult interpret(String script, InterpreterContext context) { executor.setWatchdog(new ExecuteWatchdog(commandTimeout)); final CommandLine cmdLine = CommandLine.parse(getProperty("mongo.shell.path")); + /* added support for API versions */ String apiVersion = getProperty("mongo.server.api.version", ""); if (!"".equalsIgnoreCase(apiVersion)){ cmdLine.addArgument("--apiVersion", false); cmdLine.addArgument(apiVersion, false); } - + + /* adding support for SSL for and TLS for documentDB */ String runWithSSL = getProperty("mongo.server.ssl.enabled", "false"); if ("true".equalsIgnoreCase(runWithSSL)) cmdLine.addArgument("--ssl", false); @@ -154,25 +157,29 @@ public InterpreterResult interpret(String script, InterpreterContext context) { cmdLine.addArgument("--tlsAllowInvalidHostnames", false); cmdLine.addArgument("--tlsAllowInvalidCertificates", false); } - + + /* support for AWS AccessKey */ String awsAccessKeyId = getProperty("mongo.server.aws.fle.awsAccessKeyId", ""); if (!"".equalsIgnoreCase(awsAccessKeyId)) { cmdLine.addArgument("--awsAccessKeyId", false); cmdLine.addArgument(awsAccessKeyId, false); } - + + /* support for AWS secret */ String awsSecretAccessKey = getProperty("mongo.server.aws.fle.awsSecretAccessKey", ""); if (!"".equalsIgnoreCase(awsSecretAccessKey)) { cmdLine.addArgument("--awsSecretAccessKey", false); cmdLine.addArgument(awsSecretAccessKey, false); } - + + /* support for AWS session token */ String awsSessionToken = getProperty("mongo.server.aws.fle.awsSessionToken", ""); if (!"".equalsIgnoreCase(awsSessionToken)) { cmdLine.addArgument("--awsSessionToken", false); cmdLine.addArgument(awsSessionToken, false); } - + + /* support for AWS key valult namespace */ String keyVaultNamespace = getProperty("mongo.server.aws.fle.keyVaultNamespace", ""); if (!"".equalsIgnoreCase(keyVaultNamespace)) { cmdLine.addArgument("--keyVaultNamespace", false);