Skip to content

Commit 5ba41d3

Browse files
committed
Moving to merged drivers
1 parent e3feb74 commit 5ba41d3

File tree

41 files changed

+760
-707
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+760
-707
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ services:
6767
# Sample Data Generator, imitates behaviour of users on the killrVideo website.
6868
# Adds comments and rates videos, upload new videos and so on.
6969
generator:
70-
image: killrvideo/killrvideo-generator:3.0.1
70+
image: killrvideo/killrvideo-generator:3.0.2
7171
depends_on:
7272
- backend # Needs Backend to be running
7373
environment:

killrvideo-commons/.factorypath

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<factorypath>
2-
<factorypathentry kind="VARJAR" id="M2_REPO/com/datastax/dse/dse-java-driver-mapper-processor/2.3.0/dse-java-driver-mapper-processor-2.3.0.jar" enabled="true" runInBatchMode="false"/>
3-
<factorypathentry kind="VARJAR" id="M2_REPO/com/datastax/dse/dse-java-driver-core/2.3.0/dse-java-driver-core-2.3.0.jar" enabled="true" runInBatchMode="false"/>
4-
<factorypathentry kind="VARJAR" id="M2_REPO/com/datastax/oss/java-driver-core/4.3.0/java-driver-core-4.3.0.jar" enabled="true" runInBatchMode="false"/>
5-
<factorypathentry kind="VARJAR" id="M2_REPO/com/datastax/oss/native-protocol/1.4.7/native-protocol-1.4.7.jar" enabled="true" runInBatchMode="false"/>
6-
<factorypathentry kind="VARJAR" id="M2_REPO/io/netty/netty-handler/4.1.39.Final/netty-handler-4.1.39.Final.jar" enabled="true" runInBatchMode="false"/>
7-
<factorypathentry kind="VARJAR" id="M2_REPO/io/netty/netty-common/4.1.39.Final/netty-common-4.1.39.Final.jar" enabled="true" runInBatchMode="false"/>
8-
<factorypathentry kind="VARJAR" id="M2_REPO/io/netty/netty-buffer/4.1.39.Final/netty-buffer-4.1.39.Final.jar" enabled="true" runInBatchMode="false"/>
9-
<factorypathentry kind="VARJAR" id="M2_REPO/io/netty/netty-transport/4.1.39.Final/netty-transport-4.1.39.Final.jar" enabled="true" runInBatchMode="false"/>
10-
<factorypathentry kind="VARJAR" id="M2_REPO/io/netty/netty-resolver/4.1.39.Final/netty-resolver-4.1.39.Final.jar" enabled="true" runInBatchMode="false"/>
11-
<factorypathentry kind="VARJAR" id="M2_REPO/io/netty/netty-codec/4.1.39.Final/netty-codec-4.1.39.Final.jar" enabled="true" runInBatchMode="false"/>
2+
<factorypathentry kind="VARJAR" id="M2_REPO/com/datastax/oss/java-driver-mapper-processor/4.5.1/java-driver-mapper-processor-4.5.1.jar" enabled="true" runInBatchMode="false"/>
3+
<factorypathentry kind="VARJAR" id="M2_REPO/com/datastax/oss/java-driver-mapper-runtime/4.5.1/java-driver-mapper-runtime-4.5.1.jar" enabled="true" runInBatchMode="false"/>
4+
<factorypathentry kind="VARJAR" id="M2_REPO/com/datastax/oss/java-driver-core/4.5.1/java-driver-core-4.5.1.jar" enabled="true" runInBatchMode="false"/>
5+
<factorypathentry kind="VARJAR" id="M2_REPO/com/datastax/oss/native-protocol/1.4.9/native-protocol-1.4.9.jar" enabled="true" runInBatchMode="false"/>
6+
<factorypathentry kind="VARJAR" id="M2_REPO/io/netty/netty-handler/4.1.45.Final/netty-handler-4.1.45.Final.jar" enabled="true" runInBatchMode="false"/>
7+
<factorypathentry kind="VARJAR" id="M2_REPO/io/netty/netty-common/4.1.45.Final/netty-common-4.1.45.Final.jar" enabled="true" runInBatchMode="false"/>
8+
<factorypathentry kind="VARJAR" id="M2_REPO/io/netty/netty-buffer/4.1.45.Final/netty-buffer-4.1.45.Final.jar" enabled="true" runInBatchMode="false"/>
9+
<factorypathentry kind="VARJAR" id="M2_REPO/io/netty/netty-transport/4.1.45.Final/netty-transport-4.1.45.Final.jar" enabled="true" runInBatchMode="false"/>
10+
<factorypathentry kind="VARJAR" id="M2_REPO/io/netty/netty-resolver/4.1.45.Final/netty-resolver-4.1.45.Final.jar" enabled="true" runInBatchMode="false"/>
11+
<factorypathentry kind="VARJAR" id="M2_REPO/io/netty/netty-codec/4.1.45.Final/netty-codec-4.1.45.Final.jar" enabled="true" runInBatchMode="false"/>
1212
<factorypathentry kind="VARJAR" id="M2_REPO/com/typesafe/config/1.3.4/config-1.3.4.jar" enabled="true" runInBatchMode="false"/>
1313
<factorypathentry kind="VARJAR" id="M2_REPO/com/github/jnr/jnr-ffi/2.1.10/jnr-ffi-2.1.10.jar" enabled="true" runInBatchMode="false"/>
1414
<factorypathentry kind="VARJAR" id="M2_REPO/com/github/jnr/jffi/1.2.19/jffi-1.2.19.jar" enabled="true" runInBatchMode="false"/>
@@ -22,37 +22,37 @@
2222
<factorypathentry kind="VARJAR" id="M2_REPO/com/github/jnr/jnr-x86asm/1.0.2/jnr-x86asm-1.0.2.jar" enabled="true" runInBatchMode="false"/>
2323
<factorypathentry kind="VARJAR" id="M2_REPO/com/github/jnr/jnr-posix/3.0.50/jnr-posix-3.0.50.jar" enabled="true" runInBatchMode="false"/>
2424
<factorypathentry kind="VARJAR" id="M2_REPO/com/github/jnr/jnr-constants/0.9.12/jnr-constants-0.9.12.jar" enabled="true" runInBatchMode="false"/>
25+
<factorypathentry kind="VARJAR" id="M2_REPO/org/javatuples/javatuples/1.2/javatuples-1.2.jar" enabled="true" runInBatchMode="false"/>
26+
<factorypathentry kind="VARJAR" id="M2_REPO/org/slf4j/slf4j-api/1.7.26/slf4j-api-1.7.26.jar" enabled="true" runInBatchMode="false"/>
2527
<factorypathentry kind="VARJAR" id="M2_REPO/io/dropwizard/metrics/metrics-core/4.0.5/metrics-core-4.0.5.jar" enabled="true" runInBatchMode="false"/>
2628
<factorypathentry kind="VARJAR" id="M2_REPO/org/hdrhistogram/HdrHistogram/2.1.11/HdrHistogram-2.1.11.jar" enabled="true" runInBatchMode="false"/>
27-
<factorypathentry kind="VARJAR" id="M2_REPO/com/datastax/dse/dse-native-protocol/1.2.3/dse-native-protocol-1.2.3.jar" enabled="true" runInBatchMode="false"/>
28-
<factorypathentry kind="VARJAR" id="M2_REPO/org/slf4j/slf4j-api/1.7.26/slf4j-api-1.7.26.jar" enabled="true" runInBatchMode="false"/>
2929
<factorypathentry kind="VARJAR" id="M2_REPO/com/esri/geometry/esri-geometry-api/1.2.1/esri-geometry-api-1.2.1.jar" enabled="true" runInBatchMode="false"/>
3030
<factorypathentry kind="VARJAR" id="M2_REPO/org/json/json/20090211/json-20090211.jar" enabled="true" runInBatchMode="false"/>
3131
<factorypathentry kind="VARJAR" id="M2_REPO/org/codehaus/jackson/jackson-core-asl/1.9.12/jackson-core-asl-1.9.12.jar" enabled="true" runInBatchMode="false"/>
32-
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/tinkerpop/gremlin-core/3.3.3/gremlin-core-3.3.3.jar" enabled="true" runInBatchMode="false"/>
33-
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/tinkerpop/gremlin-shaded/3.3.3/gremlin-shaded-3.3.3.jar" enabled="true" runInBatchMode="false"/>
32+
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/tinkerpop/gremlin-core/3.4.5/gremlin-core-3.4.5.jar" enabled="true" runInBatchMode="false"/>
33+
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/tinkerpop/gremlin-shaded/3.4.5/gremlin-shaded-3.4.5.jar" enabled="true" runInBatchMode="false"/>
3434
<factorypathentry kind="VARJAR" id="M2_REPO/commons-configuration/commons-configuration/1.10/commons-configuration-1.10.jar" enabled="true" runInBatchMode="false"/>
3535
<factorypathentry kind="VARJAR" id="M2_REPO/commons-lang/commons-lang/2.6/commons-lang-2.6.jar" enabled="true" runInBatchMode="false"/>
3636
<factorypathentry kind="VARJAR" id="M2_REPO/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar" enabled="true" runInBatchMode="false"/>
37+
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.jar" enabled="true" runInBatchMode="false"/>
3738
<factorypathentry kind="VARJAR" id="M2_REPO/org/yaml/snakeyaml/1.15/snakeyaml-1.15.jar" enabled="true" runInBatchMode="false"/>
38-
<factorypathentry kind="VARJAR" id="M2_REPO/org/javatuples/javatuples/1.2/javatuples-1.2.jar" enabled="true" runInBatchMode="false"/>
3939
<factorypathentry kind="VARJAR" id="M2_REPO/com/carrotsearch/hppc/0.7.1/hppc-0.7.1.jar" enabled="true" runInBatchMode="false"/>
4040
<factorypathentry kind="VARJAR" id="M2_REPO/com/jcabi/jcabi-manifests/1.1/jcabi-manifests-1.1.jar" enabled="true" runInBatchMode="false"/>
4141
<factorypathentry kind="VARJAR" id="M2_REPO/com/jcabi/jcabi-log/0.14/jcabi-log-0.14.jar" enabled="true" runInBatchMode="false"/>
4242
<factorypathentry kind="VARJAR" id="M2_REPO/net/objecthunter/exp4j/0.4.8/exp4j-0.4.8.jar" enabled="true" runInBatchMode="false"/>
43-
<factorypathentry kind="VARJAR" id="M2_REPO/org/slf4j/jcl-over-slf4j/1.7.21/jcl-over-slf4j-1.7.21.jar" enabled="true" runInBatchMode="false"/>
44-
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/tinkerpop/tinkergraph-gremlin/3.3.3/tinkergraph-gremlin-3.3.3.jar" enabled="true" runInBatchMode="false"/>
45-
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/commons/commons-lang3/3.3.1/commons-lang3-3.3.1.jar" enabled="true" runInBatchMode="false"/>
43+
<factorypathentry kind="VARJAR" id="M2_REPO/org/slf4j/jcl-over-slf4j/1.7.25/jcl-over-slf4j-1.7.25.jar" enabled="true" runInBatchMode="false"/>
44+
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/tinkerpop/tinkergraph-gremlin/3.4.5/tinkergraph-gremlin-3.4.5.jar" enabled="true" runInBatchMode="false"/>
45+
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/tinkerpop/gremlin-driver/3.4.5/gremlin-driver-3.4.5.jar" enabled="true" runInBatchMode="false"/>
46+
<factorypathentry kind="VARJAR" id="M2_REPO/org/codehaus/groovy/groovy/2.5.7/groovy-2.5.7-indy.jar" enabled="true" runInBatchMode="false"/>
47+
<factorypathentry kind="VARJAR" id="M2_REPO/org/codehaus/groovy/groovy-json/2.5.7/groovy-json-2.5.7-indy.jar" enabled="true" runInBatchMode="false"/>
4648
<factorypathentry kind="VARJAR" id="M2_REPO/com/fasterxml/jackson/core/jackson-core/2.10.0/jackson-core-2.10.0.jar" enabled="true" runInBatchMode="false"/>
4749
<factorypathentry kind="VARJAR" id="M2_REPO/com/fasterxml/jackson/core/jackson-databind/2.10.0/jackson-databind-2.10.0.jar" enabled="true" runInBatchMode="false"/>
4850
<factorypathentry kind="VARJAR" id="M2_REPO/com/fasterxml/jackson/core/jackson-annotations/2.10.0/jackson-annotations-2.10.0.jar" enabled="true" runInBatchMode="false"/>
4951
<factorypathentry kind="VARJAR" id="M2_REPO/org/reactivestreams/reactive-streams/1.0.2/reactive-streams-1.0.2.jar" enabled="true" runInBatchMode="false"/>
50-
<factorypathentry kind="VARJAR" id="M2_REPO/com/datastax/dse/dse-java-driver-mapper-runtime/2.3.0/dse-java-driver-mapper-runtime-2.3.0.jar" enabled="true" runInBatchMode="false"/>
51-
<factorypathentry kind="VARJAR" id="M2_REPO/com/datastax/oss/java-driver-mapper-runtime/4.3.0/java-driver-mapper-runtime-4.3.0.jar" enabled="true" runInBatchMode="false"/>
52-
<factorypathentry kind="VARJAR" id="M2_REPO/com/datastax/oss/java-driver-query-builder/4.3.0/java-driver-query-builder-4.3.0.jar" enabled="true" runInBatchMode="false"/>
52+
<factorypathentry kind="VARJAR" id="M2_REPO/com/datastax/oss/java-driver-query-builder/4.5.1/java-driver-query-builder-4.5.1.jar" enabled="true" runInBatchMode="false"/>
5353
<factorypathentry kind="VARJAR" id="M2_REPO/com/datastax/oss/java-driver-shaded-guava/25.1-jre/java-driver-shaded-guava-25.1-jre.jar" enabled="true" runInBatchMode="false"/>
5454
<factorypathentry kind="VARJAR" id="M2_REPO/com/squareup/javapoet/1.11.1/javapoet-1.11.1.jar" enabled="true" runInBatchMode="false"/>
5555
<factorypathentry kind="VARJAR" id="M2_REPO/com/github/stephenc/jcip/jcip-annotations/1.0-1/jcip-annotations-1.0-1.jar" enabled="true" runInBatchMode="false"/>
56-
<factorypathentry kind="VARJAR" id="M2_REPO/com/github/spotbugs/spotbugs-annotations/3.1.3/spotbugs-annotations-3.1.3.jar" enabled="true" runInBatchMode="false"/>
56+
<factorypathentry kind="VARJAR" id="M2_REPO/com/github/spotbugs/spotbugs-annotations/3.1.12/spotbugs-annotations-3.1.12.jar" enabled="true" runInBatchMode="false"/>
5757
<factorypathentry kind="VARJAR" id="M2_REPO/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar" enabled="true" runInBatchMode="false"/>
5858
</factorypath>

killrvideo-commons/pom.xml

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,21 @@
2020
<groupId>ch.qos.logback</groupId>
2121
<artifactId>logback-classic</artifactId>
2222
</dependency>
23-
24-
<!--
25-
<dependency>
26-
<groupId>org.slf4j</groupId>
27-
<artifactId>slf4j-jdk14</artifactId>
28-
<version>1.8.0-beta4</version>
29-
</dependency>
30-
<dependency>
31-
<groupId>org.slf4j</groupId>
32-
<artifactId>slf4j-simple</artifactId>
33-
<version>1.8.0-beta4</version>
34-
</dependency>
35-
<dependency>
36-
<groupId>org.slf4j</groupId>
37-
<artifactId>slf4j-nop</artifactId>
38-
<version>1.8.0-beta4</version>
39-
</dependency>
40-
-->
4123

24+
<!-- Cassandra Driver -->
4225
<dependency>
43-
<groupId>com.datastax.dse</groupId>
44-
<artifactId>dse-java-driver-core</artifactId>
26+
<groupId>com.datastax.oss</groupId>
27+
<artifactId>java-driver-core</artifactId>
4528
</dependency>
4629
<dependency>
47-
<groupId>com.datastax.dse</groupId>
48-
<artifactId>dse-java-driver-query-builder</artifactId>
30+
<groupId>com.datastax.oss</groupId>
31+
<artifactId>java-driver-query-builder</artifactId>
4932
</dependency>
5033
<dependency>
51-
<groupId>com.datastax.dse</groupId>
52-
<artifactId>dse-java-driver-mapper-runtime</artifactId>
34+
<groupId>com.datastax.oss</groupId>
35+
<artifactId>java-driver-mapper-runtime</artifactId>
5336
</dependency>
37+
5438
<dependency>
5539
<groupId>com.evanlennick</groupId>
5640
<artifactId>retry4j</artifactId>
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
package com.killrvideo.conf;
2+
3+
import java.io.File;
4+
import java.time.temporal.ChronoUnit;
5+
import java.util.Optional;
6+
import java.util.concurrent.Callable;
7+
import java.util.concurrent.atomic.AtomicInteger;
8+
9+
import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
10+
import org.slf4j.Logger;
11+
import org.slf4j.LoggerFactory;
12+
import org.springframework.beans.factory.annotation.Value;
13+
import org.springframework.context.annotation.Bean;
14+
import org.springframework.context.annotation.Configuration;
15+
import org.springframework.context.annotation.Profile;
16+
17+
import com.datastax.oss.driver.api.core.CqlIdentifier;
18+
import com.datastax.oss.driver.api.core.CqlSession;
19+
import com.datastax.oss.driver.api.core.CqlSessionBuilder;
20+
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
21+
import com.datastax.oss.driver.api.core.config.DriverConfigLoader;
22+
import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
23+
import com.evanlennick.retry4j.CallExecutor;
24+
import com.evanlennick.retry4j.config.RetryConfig;
25+
import com.evanlennick.retry4j.config.RetryConfigBuilder;
26+
import com.killrvideo.dse.graph.KillrVideoTraversalSource;
27+
28+
/**
29+
* The DSE (DataStax Enterprise) Driver configuration.
30+
*
31+
* The above properties should be typically declared in an {@code application.conf} file.
32+
*
33+
* @author DataStax Developer Advocates team.
34+
*/
35+
@Configuration
36+
@Profile("!unit-test & !integration-test")
37+
public class DriverConfigurationFile {
38+
39+
/** Initialize dedicated connection to ETCD system. */
40+
private static final Logger LOGGER = LoggerFactory.getLogger(DriverConfigurationFile.class);
41+
42+
/** Execution Profile. */
43+
public static final String EXECUTION_PROFILE_SEARCH = "search";
44+
45+
// --- Retries ---
46+
47+
@Value("${killrvideo.dse.maxNumberOfTries:50}")
48+
protected int maxNumberOfTries;
49+
50+
@Value("${killrvideo.dse.delayBetweenTries:5}")
51+
protected int delayBetweenTries;
52+
53+
@Value("#{environment.KILLRVIDEO_DSE_CONFIGURATION_FILE}")
54+
protected Optional<String> driverConfigurationFileEnvVar;
55+
56+
@Value("${killrvideo.dse.configFile:application.conf}")
57+
protected String driverConfigurationFile;
58+
59+
@Bean
60+
public DriverConfigLoader loadConfigurationFile() {
61+
// If the env variable is set we override default value
62+
if (!driverConfigurationFileEnvVar.isEmpty()) {
63+
driverConfigurationFile = driverConfigurationFileEnvVar.get();
64+
}
65+
LOGGER.info("Loading configuration from File '{}'", driverConfigurationFile);
66+
File configFile = new File(DriverConfigurationFile.class.getResource("/" + driverConfigurationFile).getFile());
67+
DriverConfigLoader loader = DriverConfigLoader.fromFile(configFile);
68+
DriverExecutionProfile basic = loader.getInitialConfig().getDefaultProfile();
69+
LOGGER.info("Configuration file has been parsed:");
70+
LOGGER.info("+ keyspace '{}'", basic.getString(DefaultDriverOption.SESSION_KEYSPACE));
71+
LOGGER.info("+ ContactPoints '{}'", basic.getStringList(DefaultDriverOption.CONTACT_POINTS));
72+
return loader;
73+
}
74+
75+
/**
76+
* Returns the keyspace to connect to. The keyspace specified here must exist.
77+
*
78+
* @return The {@linkplain CqlIdentifier keyspace} bean.
79+
*/
80+
@Bean("killrvideo.keyspace")
81+
public CqlIdentifier keyspace(CqlSession cqlSession) {
82+
return cqlSession.getKeyspace().orElseThrow();
83+
}
84+
85+
@Bean
86+
public CqlSession connect(DriverConfigLoader loader) {
87+
LOGGER.info("Initializing connection...");
88+
CqlSessionBuilder cqlSessionBuilder = CqlSession.builder().withConfigLoader(loader);
89+
90+
// Connection Lambda
91+
final AtomicInteger atomicCount = new AtomicInteger(1);
92+
Callable<CqlSession> connect = () -> {
93+
return cqlSessionBuilder.build();
94+
};
95+
96+
// Retry mechanism policy
97+
RetryConfig config = new RetryConfigBuilder()
98+
.retryOnAnyException()
99+
.withMaxNumberOfTries(maxNumberOfTries)
100+
.withDelayBetweenTries(delayBetweenTries, ChronoUnit.SECONDS)
101+
.withFixedBackoff()
102+
.build();
103+
104+
long top = System.currentTimeMillis();
105+
106+
// Let's go
107+
return new CallExecutor<CqlSession>(config)
108+
.afterFailedTry(s -> {
109+
LOGGER.info("Attempt #{}/{} [KO] -> waiting {} seconds for Cluster to start", atomicCount.getAndIncrement(),
110+
maxNumberOfTries, delayBetweenTries); })
111+
.onFailure(s -> {
112+
LOGGER.error("Cannot connection to Cluster after {} attempts, exiting", maxNumberOfTries);
113+
System.err.println("Can not conenction to Cluster after " + maxNumberOfTries + " attempts, exiting");
114+
System.exit(500);
115+
})
116+
.onSuccess(s -> {
117+
long timeElapsed = System.currentTimeMillis() - top;
118+
LOGGER.info("[OK] Connection etablished to Cluster in {} millis.", timeElapsed);})
119+
.execute(connect).getResult();
120+
}
121+
122+
/**
123+
* Graph Traversal for suggested videos.
124+
*
125+
* @param session
126+
* current dse session.
127+
* @return
128+
* traversal
129+
*/
130+
@Bean
131+
public KillrVideoTraversalSource initializeGraphTraversalSource(CqlSession dseSession) {
132+
//System.out.println(dseSession.getMetadata().getNodes().values().iterator().next().getExtras().get("DSE_WORKLOADS"));
133+
//return new KillrVideoTraversalSource(DseGraph.g.getGraph());
134+
return EmptyGraph.instance().traversal(KillrVideoTraversalSource.class);
135+
}
136+
137+
}

0 commit comments

Comments
 (0)