Skip to content

Commit

Permalink
Add option to use SSL
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavlo committed Jan 4, 2023
1 parent 35240c3 commit c91c1d6
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
.vscode
.metals
target
*.iml
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

<groupId>com.dremio.plugin</groupId>
<!--[Dremio version]-[plugin version]-->
<version>20.0.0-0.0.1</version>
<version>23.1.0-0.0.1</version>
<artifactId>dremio-singlestore-plugin</artifactId>
<name>Dremio SingleStore ARP Connector</name>

<properties>
<version.dremio>20.0.0-202201050826310141-8cc7162b</version.dremio>
<version.dremio>23.1.0-202211250121140756-a79618c7</version.dremio>
</properties>

<dependencies>
Expand Down
45 changes: 35 additions & 10 deletions src/main/java/com/dremio/exec/store/jdbc/conf/SingleStoreConf.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package com.dremio.exec.store.jdbc.conf;

import static com.google.common.base.Preconditions.checkNotNull;
import com.dremio.exec.catalog.conf.Property;

import com.dremio.options.OptionManager;
import com.dremio.security.CredentialsService;
Expand All @@ -32,6 +32,7 @@

import io.protostuff.Tag;

import java.util.List;
import javax.validation.constraints.NotBlank;

/**
Expand All @@ -48,12 +49,11 @@ public class SingleStoreConf extends AbstractArpConf<SingleStoreConf> {
@NotBlank
@Tag(1)
@DisplayMetadata(label = "Host")
public String host = "localhost";
public String host;

@NotBlank
@Tag(2)
@DisplayMetadata(label = "Port")
public String port = "3306";
public int port = 3306;

@NotBlank
@Tag(3)
Expand All @@ -63,7 +63,7 @@ public class SingleStoreConf extends AbstractArpConf<SingleStoreConf> {
@NotBlank
@Tag(4)
@DisplayMetadata(label = "Username")
public String user = "root";
public String user;

@NotBlank
@Tag(5)
Expand All @@ -72,30 +72,55 @@ public class SingleStoreConf extends AbstractArpConf<SingleStoreConf> {
public String password;

@Tag(6)
@DisplayMetadata(label = "Use SSL")
public boolean useSsl;

@Tag(7)
@DisplayMetadata(label = "Server Certificate")
public String serverSslCert;

@Tag(8)
@DisplayMetadata(label = "Record fetch size")
@NotMetadataImpacting
public int fetchSize = 200;

@Tag(7)
@Tag(9)
@DisplayMetadata(label = "Maximum idle connections")
@NotMetadataImpacting
public int maxIdleConns = 8;

@Tag(8)
@Tag(10)
@DisplayMetadata(label = "Connection idle time (s)")
@NotMetadataImpacting
public int idleTimeSec = 60;

@Tag(11)
public List<Property> propertyList;

@VisibleForTesting
public String toJdbcConnectionString() {
checkNotNull(user, "Missing username!");
String url = String.format("jdbc:singlestore://%s:%s", host, port);
boolean userProvided = false;
if (database != null && !database.equals("")) {
url += String.format("/%s", database);
}
url += String.format("?user=%s", user);
if (user != null && !user.equals("")) {
url += String.format("?user=%s", user);
userProvided = true;
}
if (password != null && !password.equals("")) {
url += String.format("&password=%s", password);
url += String.format("%spassword=%s", userProvided ? "&" : "?", password);
}
if (useSsl) {
url += "&useSsl=true";
}
if (serverSslCert != null && !serverSslCert.equals("")) {
url += String.format("&serverSslCert=%s", serverSslCert);
}
if (this.propertyList != null) {
for (Property p : this.propertyList) {
url += String.format("&%s=%s", p.name, p.value);
}
}

return url;
Expand Down
71 changes: 70 additions & 1 deletion src/main/resources/singlestore-layout.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,76 @@
"isGeneral": true,
"sections": [
{
"name": "SingleStore Source"
"name": "Connection",
"elements": [
{
"propName": "config.host"
},
{
"propName": "config.port",
"size": "half"
},
{
"propName": "config.database",
"size": "half"
}
]
},
{
"name": "Authentication",
"elements": [
{
"propName": "config.user",
"size": "half"
},
{
"propName": "config.password"
}
]
}
]
},
{
"name": "Advanced Options",
"sections": [
{
"name": "Dremio Connection Properties",
"elements": [
{
"propName": "config.fetchSize",
"size": "half",
"tooltip": "Number of records to fetch at once.",
"help": {
"position": "bottom",
"text": "Set to 0 to have Dremio automatically decide."
}
},
{
"propName": "config.maxIdleConns",
"size": "half",
"tooltip": "Maximum number of idle connections to keep."
},
{
"propName": "config.idleTimeSec",
"size": "half",
"tooltip": "Idle time, in seconds, before a connection is considered for closure."
}
]
},
{
"name": "Additional JDBC Parameters",
"elements": [
{
"emptyLabel": "No properties added",
"addLabel": "Add property",
"propName": "config.propertyList",
"tooltip": "Add a new property that will be used to establish a connection.",
"help": {
"position": "bottom",
"text": "All available parameters can be found at\n https://docs.singlestore.com/managed-service/en/developer-resources/connect-with-application-development-tools/connect-with-java-jdbc/the-singlestore-jdbc-driver.html"
}
}
]
}
]
}
Expand Down

0 comments on commit c91c1d6

Please sign in to comment.