Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
262 changes: 262 additions & 0 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.queryService</groupId>
<artifactId>Salesforce-CDP-jdbc</artifactId>
<version>1.16.0</version>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<relocations>
<relocation>
<pattern>org.apache</pattern>
<shadedPattern>${shadeBase}.apache</shadedPattern>
</relocation>
<relocation>
<pattern>io.netty</pattern>
<shadedPattern>${shadeBase}.io.netty</shadedPattern>
</relocation>
</relocations>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/LICENSE*</exclude>
<exclude>META-INF/NOTICE*</exclude>
<exclude>META-INF/DEPENDENCIES</exclude>
<exclude>META-INF/maven/**</exclude>
<exclude>META-INF/services/com.fasterxml.*</exclude>
<exclude>META-INF/*.xml</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>.netbeans_automatic_build</exclude>
<exclude>git.properties</exclude>
<exclude>google-http-client.properties</exclude>
<exclude>storage.v1.json</exclude>
<exclude>pipes-fork-server-default-log4j2.xml</exclude>
<exclude>dependencies.properties</exclude>
<exclude>pipes-fork-server-default-log4j2.xml</exclude>
</excludes>
</filter>
<filter>
<artifact>org.apache.arrow:arrow-vector</artifact>
<excludes>
<exclude>codegen/**</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer />
<transformer />
</transformers>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${junit.platform.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.7.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>powermock-module-junit4-common</artifactId>
<groupId>org.powermock</groupId>
</exclusion>
<exclusion>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.0.0-M4</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>junit-platform-engine</artifactId>
<groupId>org.junit.platform</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.0.0-M4</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>junit-jupiter-api</artifactId>
<groupId>org.junit.jupiter</groupId>
</exclusion>
<exclusion>
<artifactId>junit-platform-engine</artifactId>
<groupId>org.junit.platform</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>4.12.0-M4</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>junit-platform-engine</artifactId>
<groupId>org.junit.platform</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>9.0.17</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>tomcat-servlet-api</artifactId>
<groupId>org.apache.tomcat</groupId>
</exclusion>
<exclusion>
<artifactId>tomcat-jsp-api</artifactId>
<groupId>org.apache.tomcat</groupId>
</exclusion>
<exclusion>
<artifactId>tomcat-juli</artifactId>
<groupId>org.apache.tomcat</groupId>
</exclusion>
<exclusion>
<artifactId>tomcat-annotations-api</artifactId>
<groupId>org.apache.tomcat</groupId>
</exclusion>
<exclusion>
<artifactId>tomcat-api</artifactId>
<groupId>org.apache.tomcat</groupId>
</exclusion>
<exclusion>
<artifactId>tomcat-jni</artifactId>
<groupId>org.apache.tomcat</groupId>
</exclusion>
<exclusion>
<artifactId>tomcat-coyote</artifactId>
<groupId>org.apache.tomcat</groupId>
</exclusion>
<exclusion>
<artifactId>tomcat-util</artifactId>
<groupId>org.apache.tomcat</groupId>
</exclusion>
<exclusion>
<artifactId>tomcat-util-scan</artifactId>
<groupId>org.apache.tomcat</groupId>
</exclusion>
<exclusion>
<artifactId>tomcat-jaspic-api</artifactId>
<groupId>org.apache.tomcat</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.7.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>powermock-api-mockito-common</artifactId>
<groupId>org.powermock</groupId>
</exclusion>
<exclusion>
<artifactId>mockito-core</artifactId>
<groupId>org.mockito</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.20.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<lombok.version>1.18.22</lombok.version>
<slf4j.version>1.7.32</slf4j.version>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<powermock.version>1.7.1</powermock.version>
<shadeBase>com.salesforce.cdp.queryservice.internal</shadeBase>
<junit.jupiter.version>5.0.0-M4</junit.jupiter.version>
<junit.vintage.version>4.12.0-M4</junit.vintage.version>
<junit.platform.version>1.0.0-M4</junit.platform.version>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.salesforce.cdp.queryservice.model.Token;
import com.salesforce.cdp.queryservice.util.Constants;
import com.salesforce.cdp.queryservice.util.TokenHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

Expand Down Expand Up @@ -58,7 +59,14 @@ public QueryServiceConnection(String url, Properties properties) throws SQLExcep
this.isSocksProxyDisabled = Boolean.parseBoolean(this.properties.getProperty(Constants.DISABLE_SOCKS_PROXY));

// default `enableStreamFlow` is false
enableStreamFlow = Boolean.parseBoolean(this.properties.getProperty(Constants.ENABLE_STREAM_FLOW, Constants.FALSE_STR));
if(this.properties.containsKey(Constants.ENABLE_STREAM_FLOW)) {
enableStreamFlow = Boolean.parseBoolean(this.properties.getProperty(Constants.ENABLE_STREAM_FLOW, Constants.FALSE_STR));
}
String streamFlow = System.getenv("enablestreamflow");
if(Boolean.parseBoolean(streamFlow) == true) {
enableStreamFlow = true;
}


// use isValid to test connection
this.isValid(20);
Expand Down Expand Up @@ -351,8 +359,16 @@ public boolean isValid(int timeout) throws SQLException {
}

try {
PreparedStatement statement = this.prepareStatement(TEST_CONNECT_QUERY);
return statement.execute();
if(properties.containsKey(Constants.CORETOKEN) && TokenHelper.tokenExistsInCache(this.properties.getProperty(Constants.CORETOKEN))) {
log.info("Reusing connection");
return true;
}
else {

PreparedStatement statement = this.prepareStatement(TEST_CONNECT_QUERY);
return statement.execute();
}

} catch (Exception e) {
log.error("Exception while connecting to server", e);
if(isEnableStreamFlow()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ public void start(final Listener<RespT> responseListener, final Metadata headers
Key.of("Authorization", Metadata.ASCII_STRING_MARSHALLER), authHeaders.get(Constants.ACCESS_TOKEN));

if (properties.containsKey(Constants.USER_AGENT)) {
headers.put(Key.of(Constants.USER_AGENT_GRPC, Metadata.ASCII_STRING_MARSHALLER), properties.get(Constants.USER_AGENT).toString());
String enableV2InGRPCStream = System.getenv("enableV2InGRPCStream");
if(Boolean.parseBoolean(enableV2InGRPCStream) == true) {
headers.put(Key.of(Constants.USER_AGENT_GRPC, Metadata.ASCII_STRING_MARSHALLER), properties.get(Constants.USER_AGENT).toString() + "-JDBCV2STREAM");
}
else {
headers.put(Key.of(Constants.USER_AGENT_GRPC, Metadata.ASCII_STRING_MARSHALLER), properties.get(Constants.USER_AGENT).toString());
}

} else {
headers.put(Key.of(Constants.USER_AGENT_GRPC, Metadata.ASCII_STRING_MARSHALLER), Constants.USER_AGENT_VALUE);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.salesforce.cdp.queryservice.interceptors;

import lombok.extern.slf4j.Slf4j;
import okhttp3.*;

import java.net.InetSocketAddress;
import java.net.Proxy;
import java.time.LocalDateTime;

@Slf4j
public class HttpEventListener extends EventListener {

@Override
public void connectStart(Call call, InetSocketAddress inetSocketAddress, Proxy proxy) {
log.info("connectStart");
}

@Override
public void connectEnd(Call call, InetSocketAddress inetSocketAddress, Proxy proxy, Protocol protocol) {
log.info("connectEnd");
}



@Override
public void callStart(Call call) {
log.info("callStart");
}

// @Override
// public void requestHeadersEnd(Call call, Request request) {
// log.info("requestHeadersEnd");
// }
//
// @Override
// public void responseHeadersEnd(Call call, Response response) {
// log.info("responseHeadersEnd");
// }

@Override
public void callEnd(Call call) {
log.info("callEnd");
}

@Override
public void requestBodyEnd(Call call, long byteCount){
log.info("requestBodyEnd {}", byteCount);
}

@Override
public void requestBodyStart(Call call) {
log.info("requestBodyStart");
}

@Override
public void responseBodyStart(Call call) {
log.info("responseBodyStart");
}

@Override
public void responseBodyEnd(Call call, long byteCount) {
log.info("responseBodyEnd");
}
}
Loading