Skip to content

Commit

Permalink
removed usage of providers
Browse files Browse the repository at this point in the history
  • Loading branch information
apanicker-nflx committed Nov 27, 2020
1 parent 9c20e35 commit e3a8ce2
Show file tree
Hide file tree
Showing 72 changed files with 49 additions and 8,753 deletions.
3 changes: 2 additions & 1 deletion cassandra-persistence/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ dependencies {

implementation "com.datastax.cassandra:cassandra-driver-core:${revCassandra}"
implementation "org.apache.commons:commons-lang3"
implementation "javax.inject:javax.inject:1"

implementation 'org.apache.logging.log4j:log4j-web'

testImplementation("org.cassandraunit:cassandra-unit:${revCassandraUnit}") {
exclude group: "com.datastax.cassandra", module: "cassandra-driver-core"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package com.netflix.conductor.cassandra.config;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Metadata;
import com.datastax.driver.core.Session;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.conductor.cassandra.dao.CassandraEventHandlerDAO;
Expand All @@ -22,6 +23,8 @@
import com.netflix.conductor.dao.EventHandlerDAO;
import com.netflix.conductor.dao.ExecutionDAO;
import com.netflix.conductor.dao.MetadataDAO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -31,14 +34,31 @@
@ConditionalOnProperty(name = "db", havingValue = "cassandra")
public class CassandraConfiguration {

private static final Logger LOGGER = LoggerFactory.getLogger(CassandraConfiguration.class);

@Bean
public Cluster cluster(CassandraProperties properties) {
return new CassandraClusterProvider(properties).get();
String host = properties.getHostAddress();
int port = properties.getPort();

LOGGER.info("Connecting to cassandra cluster with host:{}, port:{}", host, port);

Cluster cluster = Cluster.builder()
.addContactPoint(host)
.withPort(port)
.build();

Metadata metadata = cluster.getMetadata();
LOGGER.info("Connected to cluster: {}", metadata.getClusterName());
metadata.getAllHosts().forEach(h -> LOGGER.info("Datacenter:{}, host:{}, rack: {}", h.getDatacenter(),
h.getEndPoint().resolve().getHostName(), h.getRack()));
return cluster;
}

@Bean
public Session session(Cluster cluster) {
return new CassandraSessionProvider(cluster).get();
LOGGER.info("Initializing cassandra session");
return cluster.connect();
}

@Bean
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies {
implementation "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider"

implementation "org.apache.commons:commons-lang3"
implementation "commons-io:commons-io"
implementation "commons-io:commons-io:${revCommonsIo}"

implementation "org.slf4j:slf4j-api"
}
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {

implementation "com.github.rholder:guava-retrying:${revGuavaRetrying}"

implementation "org.apache.bval:bval-jsr"
implementation "org.apache.bval:bval-jsr:${revBval}"

implementation "com.google.protobuf:protobuf-java:${revProtoBuf}"
implementation "com.github.vmg.protogen:protogen-annotations:${revProtogenAnnotations}"
Expand Down
2 changes: 0 additions & 2 deletions contribs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ dependencies {

implementation "io.reactivex:rxjava:${revRxJava}"

implementation "javax.inject:javax.inject:1"

implementation "com.netflix.spectator:spectator-reg-metrics3:${revSpectator}"

testImplementation "org.eclipse.jetty:jetty-server:${revJettyServer}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@Configuration
@ConditionalOnProperty(prefix = "workflow", name = "status.listener.type", havingValue = "archive")
public class ArchivingWorkflowListenerConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@Configuration
@ConditionalOnProperty(prefix = "workflow", name = "status.listener.type", havingValue = "queue_status_publisher")
public class ConductorQueueStatusPublisherConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
import com.netflix.conductor.core.config.ConductorProperties;
import com.netflix.conductor.core.events.EventQueueProvider;
import com.netflix.conductor.core.events.queue.ObservableQueue;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(prefix = "workflow", name = "amqp.event.queue.enabled", havingValue = "true")
public class AMQPEventQueueConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.springframework.context.annotation.Configuration;
import rx.Scheduler;

@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@Configuration
@ConditionalOnProperty(prefix = "workflow", name = "nats_stream.event.queue.enabled", havingValue = "true")
public class NATSStreamConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@Configuration
@ConditionalOnProperty(prefix = "workflow", name = "external.payload.storage", havingValue = "S3")
public class S3Configuration {
Expand Down
6 changes: 2 additions & 4 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies {
implementation "com.fasterxml.jackson.core:jackson-annotations"
implementation "com.fasterxml.jackson.core:jackson-databind"

implementation "commons-io:commons-io"
implementation "commons-io:commons-io:${revCommonsIo}"

implementation "com.google.protobuf:protobuf-java:${revProtoBuf}"

Expand All @@ -23,7 +23,5 @@ dependencies {
implementation "com.netflix.servo:servo-core:${revServo}"
implementation "com.netflix.spectator:spectator-api:${revSpectator}"

implementation "org.apache.bval:bval-jsr"

implementation "javax.inject:javax.inject:1"
implementation "org.apache.bval:bval-jsr:${revBval}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,25 @@
import com.netflix.conductor.core.config.ConductorProperties;
import com.netflix.conductor.core.sync.Lock;
import com.netflix.conductor.metrics.Monitors;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.inject.Provider;
import java.util.concurrent.TimeUnit;

@Service
public class ExecutionLockService {

private static final Logger LOGGER = LoggerFactory.getLogger(ExecutionLockService.class);
private final ConductorProperties properties;
private final Provider<Lock> lockProvider;
private final Lock lock;
private final long lockLeaseTime;
private final long lockTimeToTry;

@Autowired
public ExecutionLockService(ConductorProperties properties, Provider<Lock> lockProvider) {
public ExecutionLockService(ConductorProperties properties, Lock lock) {
this.properties = properties;
this.lockProvider = lockProvider;
this.lock = lock;
this.lockLeaseTime = properties.getLockLeaseTimeMs();
this.lockTimeToTry = properties.getLockTimeToTryMs();
}
Expand All @@ -59,7 +57,6 @@ public boolean acquireLock(String lockId, long timeToTryMs) {

public boolean acquireLock(String lockId, long timeToTryMs, long leaseTimeMs) {
if (properties.isWorkflowExecutionLockEnabled()) {
Lock lock = lockProvider.get();
if (!lock.acquireLock(lockId, timeToTryMs, leaseTimeMs, TimeUnit.MILLISECONDS)) {
LOGGER.debug("Thread {} failed to acquire lock to lockId {}.", Thread.currentThread().getId(), lockId);
Monitors.recordAcquireLockUnsuccessful();
Expand All @@ -77,23 +74,21 @@ public boolean acquireLock(String lockId, long timeToTryMs, long leaseTimeMs) {
*/
public void waitForLock(String lockId) {
if (properties.isWorkflowExecutionLockEnabled()) {
Lock lock = lockProvider.get();
lock.acquireLock(lockId);
LOGGER.debug("Thread {} acquired lock to lockId {}.", Thread.currentThread().getId(), lockId);
}
}

public void releaseLock(String lockId) {
if (properties.isWorkflowExecutionLockEnabled()) {
Lock lock = lockProvider.get();
lock.releaseLock(lockId);
LOGGER.debug("Thread {} released lock to lockId {}.", Thread.currentThread().getId(), lockId);
}
}

public void deleteLock(String lockId) {
if (properties.isWorkflowExecutionLockEnabled()) {
lockProvider.get().deleteLock(lockId);
lock.deleteLock(lockId);
LOGGER.debug("Thread {} deleted lockId {}.", Thread.currentThread().getId(), lockId);
}
}
Expand Down
2 changes: 2 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ ext {
revAwaitility = '3.1.6'
revAwsSdk = '1.11.86'
revAzureStorageBlobSdk = '12.2.0'
revBval = '2.0.4'
revCassandra = '3.10.2'
revCassandraUnit = '3.11.2.0'
revCommonsIo = '2.7'
revCuratorRecipes = '2.4.0'
revCuratorTest = '2.4.0'
revDockerCompose = '0.13.4'
Expand Down
3 changes: 1 addition & 2 deletions es6-persistence/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
dependencies {
implementation project(':conductor-common')
implementation project(':conductor-core')

implementation 'org.springframework.boot:spring-boot-starter'

implementation "commons-io:commons-io"
implementation "commons-io:commons-io:${revCommonsIo}"
implementation "org.apache.commons:commons-lang3"
// SBMTODO: remove guava dep
implementation "com.google.guava:guava:${revGuava}"
Expand Down
2 changes: 0 additions & 2 deletions mysql-persistence/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ dependencies {
implementation project(':conductor-core')
implementation 'org.springframework.boot:spring-boot-starter'

implementation "javax.inject:javax.inject:1"

// SBMTODO: remove guava dep
implementation "com.google.guava:guava:${revGuava}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class MySQLConfiguration {

@Bean
public DataSource dataSource(MySQLProperties properties) {
return new MySQLDataSourceProvider(properties).get();
return new MySQLDataSourceProvider(properties).getDataSource();
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import java.util.concurrent.ThreadFactory;
import javax.sql.DataSource;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.configuration.FluentConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Provider;
import javax.sql.DataSource;
import java.util.concurrent.ThreadFactory;

public class MySQLDataSourceProvider implements Provider<DataSource> {
public class MySQLDataSourceProvider {

private static final Logger LOGGER = LoggerFactory.getLogger(MySQLDataSourceProvider.class);

Expand All @@ -34,8 +32,7 @@ public MySQLDataSourceProvider(MySQLProperties properties) {
this.properties = properties;
}

@Override
public DataSource get() {
public DataSource getDataSource() {
HikariDataSource dataSource = null;
try {
dataSource = new HikariDataSource(createConfiguration());
Expand Down
2 changes: 0 additions & 2 deletions postgres-persistence/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ dependencies {
implementation project(':conductor-core')
implementation 'org.springframework.boot:spring-boot-starter'

implementation "javax.inject:javax.inject:1"

// SBMTODO: remove guava dep
implementation "com.google.guava:guava:${revGuava}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class PostgresConfiguration {

@Bean
public DataSource dataSource(PostgresProperties config) {
return new PostgresDataSourceProvider(config).get();
return new PostgresDataSourceProvider(config).getDataSource();
}

@Bean
Expand Down
Loading

0 comments on commit e3a8ce2

Please sign in to comment.