diff --git a/.travis.yml b/.travis.yml index fcae8668..c441369b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,4 @@ -language: java -jdk: - - openjdk11 +language: generic # Sudo required for doing docker build sudo: required @@ -9,18 +7,41 @@ services: # Build the app and a docker image script: -- mvn clean install -- docker build -t ${TRAVIS_COMMIT} ./killrvideo-services +- travis_fold start docker_build +- docker run -v ${PWD}:/opt/killrvideo-java -w /opt/killrvideo-java maven mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B +- docker build -t ${TRAVIS_COMMIT} -t killrvideo-java-local . +- travis_fold end docker_build +- travis_fold start docker_dependencies_up +- docker-compose -f docker-compose.ci.yml up -d dse dse-config +- sleep 180 +- docker-compose -f docker-compose.ci.yml up -d backend +- sleep 180 +- docker-compose -f docker-compose.ci.yml exec backend echo 'Still alive!' || { echo "Backend is down"; docker-compose -f docker-compose.ci.yml logs dse-config backend; exit 1; } +- travis_fold end docker_dependencies_up +- docker run --network killrvideo-java_default killrvideo/killrvideo-integration-tests # If successful, see if we need to publish also after_success: -- test -z $TRAVIS_TAG && travis_terminate 0 +- "[ \"$TRAVIS_EVENT_TYPE\" = \"cron\" ] && { echo \"Ignore nightly builds\"; travis_terminate 0; }" +- test -z $TRAVIS_TAG && { echo "Ignore non-tagged builds"; travis_terminate 0; } - docker tag ${TRAVIS_COMMIT} killrvideo/killrvideo-java:${TRAVIS_TAG} - echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin - docker push killrvideo/killrvideo-java:${TRAVIS_TAG} +- "[ \"$(git tag --sort=-v:refname | grep -P \"^\\d+.\\d+.\\d+$\" | head -n1)\" == \"$TRAVIS_TAG\" ] && { docker tag ${TRAVIS_COMMIT} killrvideo/killrvideo-java:latest; docker push killrvideo/killrvideo-java:latest; }" + +after_failure: +- travis_fold start docker_logs +- docker-compose -f docker-compose.ci.yml logs dse-config backend +- travis_fold end docker_logs env: global: # DOCKER_USER & PASS - secure: hL9GzKnAuHP130bLzB1nK9e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biS7+ijvIPD9SlRbyUlf7Z3wD8Hf91/fUgkaUoIVkBUFvW8i0fArfcWSIQErvixIGhj41yNOwIAheUFM4Y39NsuilJZZmqZ2Zh0/9AHUiY4fA7C6CajFC06CpjUCpDhb3m0uy1vJcUiG7Y3J6iTrRzaW8eqPnGBQcVTS7/dXPj3WtEP/xOF93sYeZMKE7hk489WAUJNLV9kmasSaVTzbu80kfM5Ml9m675dN3ztUAhaAPT0IqHnycngMBKe2Y7+EDalsDBsffOpO0k= + +notifications: + slack: + rooms: + secure: N6FrJ0l0gw2t1wnty/xPDKvLBZlzOAmkIbHjd4ZrtaC4vLU8iZP+YCRvQd7Vwzc97yDhHIZ41eGtjHjBIIeMX/3rfuS+6GA4VJgyNFGsP0f81YYHxiMOEUlVa2O6LBwbF3LokaFi3l7Iau1c5Op9c3LinhTdE0W6KG+2gxEqSKJkBcVJfK9SZGXg3+6qlq065BWx7xWlzoWgMFyipJJLW1BAqEzP5cc6hHozJ5H/8ucMaJbWQF+nOaIYUJdaop4ChSpe6EFyg0XNp+mIjJ2BxZ6hfYrAs69vwBapBepe4zEoR5xdN1dGUAIDqNY9rr4Npp8InFmBmnlL1xG6FeG73C2qfSr3Y2WziOtwececzmuQWI2Do9ioB5k0KtC4UAV42tpADUODrrwxE8S32tqgr0Pojg8FvgsM6O3twvF1UH3LLEyW7zDzuDpYdtvIROWZGerxyWqQIFI7MzragyL+ZiKKUOG1uKsA8DoeECcMHuUsDEsR/mHalmQGGl2ZNGpphAHg/1HtjB32VDCIuZpFHsqFG7BfMY2dg8Mm+ea4j9imOxM+2TFxbPhoIjIJq1o+/YvolrYviWgmQOpeFw0c1xXWSL5aXmBv2nUnlBaXxfzC9FTl0xmovJmKeYhqJ81TMa33gimsMeccZIDmzcMDsW82idsvtHeNDSX1wil5DXA= + diff --git a/killrvideo-service-comments/Dockerfile b/Dockerfile similarity index 88% rename from killrvideo-service-comments/Dockerfile rename to Dockerfile index 10fa5abb..757f9d64 100644 --- a/killrvideo-service-comments/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM openjdk:11 MAINTAINER Cedrick Lunven -MAINTAINER Davig Gilardi +MAINTAINER David Gilardi ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/killrvideo-java.jar"] EXPOSE 50101 diff --git a/killrvideo-commons/src/main/java/com/killrvideo/conf/DseDriverConfiguration.java b/killrvideo-commons/src/main/java/com/killrvideo/conf/DseDriverConfiguration.java deleted file mode 100644 index 70ed08c4..00000000 --- a/killrvideo-commons/src/main/java/com/killrvideo/conf/DseDriverConfiguration.java +++ /dev/null @@ -1,302 +0,0 @@ -package com.killrvideo.conf; - -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; - -/** - * The DSE (DataStax Enterprise) Driver configuration. - * - *

- * Driver options should be specified in the usual way, that is, through an - * application.conf file accessible on the application classpath. See the - * driver configuration - * section in the online docs for more information. - * - *

- * To illustrate how to integrate the driver configuration with Spring, a few driver options should be configured through Spring's - * own configuration mechanism: - * - *

    - *
  1. killrvideo.dse.contactPoints: this property will override the driver's {@code - * datastax-java-driver.basic.contact-points} option; it will default to 127.0.0.1 - * if unspecified; - *
  2. killrvideo.dse.port: this property will be combined with the previous one to create initial contact points; it will - * default to 9042 if unspecified; - *
  3. driver.localdc: this property will override the driver's {@code - * datastax-java-driver.basic.load-balancing-policy.local-datacenter} option; it has no default value and must be specified; - *
  4. driver.keyspace: this property will override the driver's {@code - * datastax-java-driver.basic.session-keyspace} option; it has no default value and must be specified; - *
  5. driver.consistency: this property will override the driver's {@code - * datastax-java-driver.basic.request.consistency}; it will default to LOCAL_QUORUM - * if unspecified; - *
  6. driver.pageSize: this property will override the driver's {@code - * datastax-java-driver.basic.request.page-size}; it will default to 10 if unspecified; - *
  7. driver.username: this property will override the driver's {@code - * datastax-java-driver.advanced.auth-provider.username} option; if unspecified, it will be assumed that no authentication - * is required; - *
  8. driver.password: this property will override the driver's {@code - * datastax-java-driver.advanced.auth-provider.password} option; if unspecified, it will be assumed that no authentication - * is required; - *
- * - * The above properties should be typically declared in an {@code application.yml} file. - * - * @author DataStax Developer Advocates team. - * @param - */ -@Configuration -@Profile("!unit-test & !integration-test") -public class DseDriverConfiguration { - -// /** Initialize dedicated connection to ETCD system. */ -// private static final Logger LOGGER = LoggerFactory.getLogger(DseDriverConfiguration.class); -// -// /** Execution Profile. */ -// public static final String EXECUTION_PROFILE_SEARCH = "search"; -// -// @Value("#{'${killrvideo.dse.contactPoints}'.split(',')}") -// private List contactPoints; -// -// @Value("#{environment.KILLRVIDEO_DSE_CONTACT_POINTS}") -// private Optional contactPointsEnvironmentVar; -// -// @Value("${killrvideo.application.name:killrvideo}") -// private String applicationName; -// -// @Value("${killrvideo.dse.port:9042}") -// private int port; -// -// @Value("${killrvideo.dse.keyspace:killrvideo}") -// private String keyspaceName; -// -// @Value("${killrvideo.dse.localdc:dc1}") -// private String localDc; -// -// @Value("${killrvideo.dse.username}") -// public Optional dseUsername; -// -// @Value("${killrvideo.dse.password}") -// public Optional dsePassword; -// -// // --- Retries --- -// -// @Value("${killrvideo.dse.maxNumberOfTries:50}") -// protected int maxNumberOfTries; -// -// @Value("${killrvideo.dse.delayBetweenTries:5}") -// protected int delayBetweenTries; -// -// // --- Request --- -// -// @Value("${killrvideo.dse.consistency:LOCAL_QUORUM}") -// protected String consistency; -// -// @Value("${killrvideo.dse.timeout:5 seconds}") -// protected String timeout; -// -// // --- Search Request --- -// -// @Value("${killrvideo.dse.search.consistency:LOCAL_ONE}") -// protected String searchConsistency; -// -// @Value("${killrvideo.dse.search.timeout:5 seconds}") -// protected String searchTimeout; -// -// // -- Graph -- -// -// @Value("${killrvideo.dse.graph.timeout:5 seconds}") -// protected String graphTimeout; -// -// @Value("${killrvideo.dse.graph.recommendation.name:5}") -// protected String graphName; -// -// // -- Apollo Specifics -- -// -// @Value("${killrvideo.apollo.override-local-dse:false}") -// private boolean connectApollo = false; -// -// @Value("${killrvideo.apollo.keyspace:killrvideo}") -// private String apolloKeyspace; -// -// @Value("${killrvideo.apollo.username:KVUser}") -// private String apolloUserName; -// -// @Value("${killrvideo.apollo.password:KVPassword}") -// public String apolloPassword; -// -// @Value("${killrvideo.apollo.secure-connect-bundle:/tmp/creds.zip}") -// public String apolloSecureConnectoBundleZipPath; -// -// /** -// * Returns the keyspace to connect to. The keyspace specified here must exist. -// * -// * @return The {@linkplain CqlIdentifier keyspace} bean. -// */ -// @Bean("killrvideo.keyspace") -// public CqlIdentifier keyspace() { -// return CqlIdentifier.fromCql(keyspaceName); -// } -// -// /** -// * Returns a {@link ProgrammaticDriverConfigLoaderBuilder} to load driver options. -// * -// *

-// * Use this loader if you need to programmatically override default values for any driver setting. In this example, we -// * manually set the default consistency level to use, and, if a username and password are present, we define a basic -// * authentication scheme using {@link DsePlainTextAuthProvider}. -// * -// *

-// * Any value explicitly set through this loader will take precedence over values found in the driver's standard -// * application.conf file. -// * -// * @return The {@link ProgrammaticDriverConfigLoaderBuilder} bean. -// */ -// @Bean -// public ProgrammaticDriverConfigLoaderBuilder configLoaderBuilder() { -// LOGGER.info("Initializing connectivity to Apollo or DDAC or DSE or OSS Cassandra"); -// ProgrammaticDriverConfigLoaderBuilder configLoaderBuilder = DseDriverConfigLoader.programmaticBuilder(); -// -// // Set BASICS -// configLoaderBuilder.withString(DefaultDriverOption.REQUEST_TIMEOUT, timeout); -// configLoaderBuilder.withString(DefaultDriverOption.REQUEST_CONSISTENCY, consistency); -// return configLoaderBuilder; -// } -// -// /** -// * Returns a {@link DseSessionBuilder} that will configure sessions using the provided -// * {@link ProgrammaticDriverConfigLoaderBuilder config loader builder}, as well as the contact points and local datacenter -// * name found in application.yml, merged with other options found in application.conf. -// * -// * @param driverConfigLoaderBuilder -// * The {@link ProgrammaticDriverConfigLoaderBuilder} bean to use. -// * @return The {@link DseSessionBuilder} bean. -// */ -// @Bean -// public DseSessionBuilder sessionBuilder(@NonNull ProgrammaticDriverConfigLoaderBuilder driverConfigLoaderBuilder) { -// DseSessionBuilder sessionBuilder; -// // Appollo ? -// if (connectApollo) { -// LOGGER.info("+ Connecting to Apollo using {}", apolloSecureConnectoBundleZipPath); -// LOGGER.info("+ Apollo username {}", apolloUserName); -// LOGGER.info("+ Apollo password {}", new String(apolloPassword).replaceAll(".?", "x")); -// LOGGER.info("+ Apollo Keyspace {}", apolloKeyspace); -// sessionBuilder = DseSession.builder() -// .withConfigLoader(driverConfigLoaderBuilder.build()) -// .withCloudSecureConnectBundle(Paths.get(apolloSecureConnectoBundleZipPath)) -// .withAuthCredentials(apolloUserName, apolloPassword) -// .withKeyspace(apolloKeyspace); -// } else { -// LOGGER.info("+ Connecting to Dse {}", apolloSecureConnectoBundleZipPath); -// -// // Set Search Consistency with a 'Profile' -// driverConfigLoaderBuilder -// .startProfile(EXECUTION_PROFILE_SEARCH) -// .withString(DefaultDriverOption.REQUEST_CONSISTENCY, searchConsistency) -// .withString(DefaultDriverOption.REQUEST_TIMEOUT, searchTimeout) -// .endProfile(); -// -// // Graph -// driverConfigLoaderBuilder.withString(KillrvideoDriverOption.GRAPH_NAME, graphName); -// driverConfigLoaderBuilder.withString(KillrvideoDriverOption.GRAPH_TIMEOUT, graphTimeout); -// -// sessionBuilder = new DseSessionBuilder().withConfigLoader(driverConfigLoaderBuilder.build()); -// if (!contactPointsEnvironmentVar.isEmpty() && !contactPointsEnvironmentVar.get().isBlank()) { -// contactPoints = Arrays.asList(contactPointsEnvironmentVar.get().split(",")); -// LOGGER.info(" + Reading contactPoints from KILLRVIDEO_DSE_CONTACT_POINTS"); -// } -// -// // Authentication -// if (!dseUsername.isEmpty() && !dsePassword.isEmpty()) { -// sessionBuilder.withAuthCredentials(dseUsername.get(), dsePassword.get()); -// } -// -// LOGGER.info("+ Contact Points {}", contactPoints); -// for (String contactPoint : contactPoints) { -// InetSocketAddress address = InetSocketAddress.createUnresolved(contactPoint, port); -// sessionBuilder = sessionBuilder.addContactPoint(address); -// } -// LOGGER.info("+ Port '{}'", port); -// LOGGER.info("+ Local Data Center '{}'", localDc); -// sessionBuilder.withLocalDatacenter(localDc); -// LOGGER.info("+ Application name '{}'", applicationName); -// sessionBuilder.withApplicationName(applicationName); -// LOGGER.info("+ KeySpace name '{}'", keyspaceName); -// sessionBuilder.withKeyspace(keyspaceName); -// } -// return sessionBuilder; -// } -// -// /** -// * Returns the {@link DseSession} to use, configured with the provided {@link DseSessionBuilder session builder}. The returned -// * session will be automatically connected to the given keyspace. -// * -// * @param sessionBuilder -// * The {@link DseSessionBuilder} bean to use. -// * @param keyspace -// * The {@linkplain CqlIdentifier keyspace} bean to use. -// * @return The {@link DseSession} bean. -// */ -// @Bean -// public DseSession session(@NonNull DseSessionBuilder dseSessionBuilder) { -// -// final AtomicInteger atomicCount = new AtomicInteger(1); -// Callable connectionToDse = () -> { -// return dseSessionBuilder.build(); -// }; -// -// RetryConfig config = new RetryConfigBuilder() -// .retryOnAnyException() -// .withMaxNumberOfTries(maxNumberOfTries) -// .withDelayBetweenTries(delayBetweenTries, ChronoUnit.SECONDS) -// .withFixedBackoff() -// .build(); -// long top = System.currentTimeMillis(); -// return new CallExecutor(config) -// .afterFailedTry(s -> { -// LOGGER.info("Attempt #{}/{} [KO] -> waiting {} seconds for Cluster to start", atomicCount.getAndIncrement(), -// maxNumberOfTries, delayBetweenTries); }) -// .onFailure(s -> { -// LOGGER.error("Cannot connection to Cluster after {} attempts, exiting", maxNumberOfTries); -// System.err.println("Can not conenction to Cluster after " + maxNumberOfTries + " attempts, exiting"); -// System.exit(500); -// }) -// .onSuccess(s -> { -// long timeElapsed = System.currentTimeMillis() - top; -// LOGGER.info("[OK] Connection etablished to Cluster in {} millis.", timeElapsed);}) -// .execute(connectionToDse).getResult(); -// } -// -// /** -// * Graph Traversal for suggested videos. -// * -// * @param session -// * current dse session. -// * @return -// * traversal -// */ -// @Bean -// public KillrVideoTraversalSource initializeGraphTraversalSource(DseSession dseSession) { -// //System.out.println(dseSession.getMetadata().getNodes().values().iterator().next().getExtras().get("DSE_WORKLOADS")); -// //return new KillrVideoTraversalSource(DseGraph.g.getGraph()); -// return EmptyGraph.instance().traversal(KillrVideoTraversalSource.class); -// } -// -// /** -// * Active workloads on DSE Nodes. -// * Each node can have different workloads, as such we would need to return a Map -// * FOR KILLRVIDEO we assume all nodes have same Workloads as such we use the first. -// */ -// @Bean -// @SuppressWarnings("unchecked") -// public Set< DseWorkload> dseWorkloads(DseSession dseSession) { -// return ((Set) dseSession.getMetadata().getNodes() // Access Nodes -// .values().iterator().next() // Pick First Node -// .getExtras().get("DSE_WORKLOADS")) // Set -// .stream().map(DseWorkload::valueOf) // Valid and convert to enum -// .collect(Collectors.toSet()); -// } -// -// public static enum DseWorkload { Graph, Search, Cassandra, Analytics, SearchAnalytics }; -// - -} diff --git a/killrvideo-commons/src/main/java/com/killrvideo/conf/KafkaConfiguration.java b/killrvideo-commons/src/main/java/com/killrvideo/conf/KafkaConfiguration.java index 1fe30ed2..1c9bb4f9 100644 --- a/killrvideo-commons/src/main/java/com/killrvideo/conf/KafkaConfiguration.java +++ b/killrvideo-commons/src/main/java/com/killrvideo/conf/KafkaConfiguration.java @@ -56,7 +56,7 @@ public class KafkaConfiguration { private String connectionURL; /** - * Should we init connection with ETCD or direct. + * Should we init connection with Env VAR or values in `application.yaml` * * @return * target kafka adress