Skip to content

Commit

Permalink
Merge pull request #269 from panghy/address-268
Browse files Browse the repository at this point in the history
  • Loading branch information
panghy committed Aug 13, 2022
2 parents 02554e7 + b935329 commit 0c9c408
Show file tree
Hide file tree
Showing 25 changed files with 104 additions and 500 deletions.
34 changes: 17 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,32 @@ allprojects {
ext {
set('springCloudVersion', "2021.0.3")
set('wavefrontVersion', "2.2.2")
set('grpcVersion', "1.46.0")
set('grpcVersion', "1.48.0")
}
}

subprojects {
tasks.withType(Test).configureEach {
useJUnitPlatform()
}
}

subprojects {
configurations.all {
resolutionStrategy.eachDependency { details ->
if ("io.grpc".equalsIgnoreCase(details.requested.group)) {
details.useVersion "${grpcVersion}"
}
if ("com.google.guava".equalsIgnoreCase(details.requested.group) &&
"guava".equalsIgnoreCase(details.requested.name)) {
details.useVersion "31.1-jre"
}
if ("org.foundationdb".equalsIgnoreCase(details.requested.group) &&
"fdb-java".equalsIgnoreCase(details.requested.name)) {
details.useVersion "6.3.24"
}
if ("com.google.protobuf".equalsIgnoreCase(details.requested.group)) {
details.useVersion "3.20.1"
resolutionStrategy {
// fail eagerly on version conflict (includes transitive dependencies)
// e.g. multiple different versions of the same dependency (group and name are equal)
failOnVersionConflict()
eachDependency { details ->
if ("io.grpc".equalsIgnoreCase(details.requested.group)) {
details.useVersion "${grpcVersion}"
}
if ("com.google.guava".equalsIgnoreCase(details.requested.group) &&
"guava".equalsIgnoreCase(details.requested.name)) {
details.useVersion "31.1-jre"
}
if ("com.google.errorprone".equalsIgnoreCase(details.requested.group) &&
"error_prone_annotations".equalsIgnoreCase(details.requested.name)) {
details.useVersion "2.14.0"
}
}
}
}
Expand Down
17 changes: 13 additions & 4 deletions lionrock-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,21 @@ generateNativeImageConfig {
}

dependencies {
implementation 'io.grpc:grpc-stub'
implementation 'io.grpc:grpc-okhttp'
implementation('io.grpc:grpc-stub:1.48.0') {
exclude group: 'com.google.guava', module: 'guava'
exclude group: 'com.google.errorprone', module: 'error_prone_annotations'
}
implementation('io.grpc:grpc-okhttp:1.48.0') {
exclude group: 'com.google.guava', module: 'guava'
exclude group: 'com.google.errorprone', module: 'error_prone_annotations'
}

implementation project(':lionrock-foundationdb-client')
implementation project(':lionrock-proto-java')
implementation 'org.foundationdb:fdb-java'
implementation('com.google.guava:guava:31.1-jre') {
exclude group: 'com.google.errorprone'
}
implementation 'org.foundationdb:fdb-java:6.3.24'
implementation 'info.picocli:picocli-shell-jline3:4.6.3'
implementation 'org.jline:jline-terminal-jansi:3.21.0'
implementation 'org.fusesource.jansi:jansi:2.4.0'
Expand Down Expand Up @@ -121,7 +130,7 @@ publishing {
}

javadoc {
if(JavaVersion.current().isJava9Compatible()) {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
Expand Down
13 changes: 7 additions & 6 deletions lionrock-fdb-record-layer-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ bootJar {
}

dependencies {
implementation 'org.foundationdb:fdb-record-layer-core-pb3:3.1.256.0'
implementation project(':lionrock-foundationdb-client')
implementation project(':lionrock-proto-java')
implementation 'io.grpc:grpc-stub'
implementation 'org.foundationdb:fdb-record-layer-core-pb3:3.1.256.0'
implementation 'com.google.protobuf:protobuf-java:3.21.1'
implementation 'org.foundationdb:fdb-java:6.3.24'
implementation 'io.grpc:grpc-stub:1.48.0'

testImplementation project(path: ':lionrock-foundationdb-server', configuration: 'plain')
testImplementation project(path: ':lionrock-foundationdb-server', configuration: 'tests')
testImplementation(testFixtures(project(":lionrock-grpc-tests")))

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.springframework.cloud:spring-cloud-starter-sleuth'
testRuntimeOnly('io.github.lognet:grpc-spring-boot-starter:4.8.0')

testImplementation 'org.junit.jupiter:junit-jupiter-api'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
Expand Down Expand Up @@ -81,7 +82,7 @@ publishing {
repositories {
maven {
name = "OSSRH"
if(project.version.endsWith('-SNAPSHOT')) {
if (project.version.endsWith('-SNAPSHOT')) {
url "https://s01.oss.sonatype.org/content/repositories/snapshots/"
} else {
url "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
Expand All @@ -95,7 +96,7 @@ publishing {
}

javadoc {
if(JavaVersion.current().isJava9Compatible()) {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
Expand All @@ -107,6 +108,6 @@ signing {

protobuf {
protoc {
artifact = 'com.google.protobuf:protoc'
artifact = 'com.google.protobuf:protoc:3.21.1'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public void testSumOfTheQuantityOfAllItemsOrdered() {
@BeforeEach
public void setupConnection() {
logger.info("setupConnection()");
RemoteFDBDatabaseFactory factory = new RemoteFDBDatabaseFactory(channel, "RemoteRecordLayerTests");
RemoteFDBDatabaseFactory factory = new RemoteFDBDatabaseFactory(stub, "RemoteRecordLayerTests");
this.fdb = factory.getDatabase();
this.fdb.setAsyncToSyncExceptionMapper((ex, event) -> {
if (ex instanceof ExecutionException || ex instanceof CompletionException) {
Expand Down
16 changes: 8 additions & 8 deletions lionrock-foundationdb-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

plugins {
id 'java'
id 'java-library'
id 'maven-publish'
id 'jacoco'
id 'signing'
Expand All @@ -30,9 +30,11 @@ repositories {

dependencies {
implementation project(':lionrock-proto-java')
implementation 'org.foundationdb:fdb-java'
implementation 'io.grpc:grpc-stub'
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: "3.21.4"
implementation 'org.foundationdb:fdb-java:6.3.24'
implementation('io.grpc:grpc-stub:1.48.0')
implementation('io.grpc:grpc-api:1.48.0')
implementation 'com.google.protobuf:protobuf-java:3.21.1'
implementation 'com.google.guava:guava:31.1-jre'

testImplementation group: 'org.mockito', name: 'mockito-core', version: '4.6.1'
testImplementation 'net.bytebuddy:byte-buddy:1.12.13'
Expand All @@ -42,10 +44,8 @@ dependencies {
testImplementation project(path: ':lionrock-foundationdb-server', configuration: 'plain')
testImplementation project(path: ':lionrock-foundationdb-server', configuration: 'tests')

// replace after refactoring.
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.springframework.cloud:spring-cloud-starter-sleuth'
testRuntimeOnly('io.github.lognet:grpc-spring-boot-starter:4.8.0')

testImplementation 'org.junit.jupiter:junit-jupiter-api'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
Expand Down Expand Up @@ -95,7 +95,7 @@ publishing {
repositories {
maven {
name = "OSSRH"
if(project.version.endsWith('-SNAPSHOT')) {
if (project.version.endsWith('-SNAPSHOT')) {
url "https://s01.oss.sonatype.org/content/repositories/snapshots/"
} else {
url "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
Expand All @@ -109,7 +109,7 @@ publishing {
}

javadoc {
if(JavaVersion.current().isJava9Compatible()) {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,22 @@
import com.apple.foundationdb.KeySelector;
import com.apple.foundationdb.KeyValue;
import com.apple.foundationdb.Transaction;
import io.github.panghy.lionrock.FoundationDbGrpcFacade;
import io.github.panghy.lionrock.client.foundationdb.RemoteFoundationDBDatabaseFactory;
import io.github.panghy.lionrock.tests.AbstractGrpcTest;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.springframework.boot.test.context.SpringBootTest;

import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.concurrent.CompletableFuture;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;

@SpringBootTest(webEnvironment = NONE, properties = {"grpc.port=0", "grpc.shutdownGrace=0",
"logging.level.io.github.panghy.lionrock=DEBUG"}, classes = FoundationDbGrpcFacade.class)
public class AbstractFoundationDBClientTests extends AbstractGrpcTest {

static final byte[] HELLO_B = "hello".getBytes(StandardCharsets.UTF_8);
static final byte[] WORLD_B = "world".getBytes(StandardCharsets.UTF_8);
static final CompletableFuture<?> DONE = CompletableFuture.completedFuture(null);

static ManagedChannel channel;
static Database db;

String getValue(Database stub, byte[] key) {
Expand Down Expand Up @@ -64,14 +54,6 @@ long setKeyAndCommit(Database db, byte[] key, byte[] value) {

@BeforeEach
public void setupChannel() {
channel = ManagedChannelBuilder.forAddress("localhost", getPort()).
usePlaintext().
build();
db = RemoteFoundationDBDatabaseFactory.open("fdb", "integration test", channel);
}

@AfterEach
public void shutdownChannel() {
channel.shutdownNow();
db = RemoteFoundationDBDatabaseFactory.open("fdb", "integration test", stub);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void testSetAndRead_multiple() {

@Test
void testStartTransaction_withInvalidDatabaseName() {
Database database = RemoteFoundationDBDatabaseFactory.open("INVALID", "integration test", channel);
Database database = RemoteFoundationDBDatabaseFactory.open("INVALID", "integration test", stub);
try {
database.runAsync(ReadTransaction::getReadVersion).join();
fail();
Expand Down
18 changes: 12 additions & 6 deletions lionrock-foundationdb-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,25 @@ bootJar {
}

dependencies {
implementation project(':lionrock-proto-java')
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'io.zipkin.brave:brave-instrumentation-grpc'
implementation 'org.foundationdb:fdb-java:6.3.24'

implementation 'com.wavefront:wavefront-spring-boot-starter'
implementation 'com.google.protobuf:protobuf-java:3.21.1'
implementation 'com.google.code.findbugs:jsr305:3.0.2'

implementation('io.github.lognet:grpc-spring-boot-starter:4.8.0')
implementation 'com.wavefront:wavefront-spring-boot-starter'

implementation project(':lionrock-proto-java')
implementation 'org.foundationdb:fdb-java'
implementation 'net.devh:grpc-spring-boot-starter:2.13.1.RELEASE'
implementation 'io.grpc:grpc-netty-shaded:1.48.0'

testImplementation project(':lionrock-foundationdb-client')
testImplementation(testFixtures(project(":lionrock-grpc-tests")))
testImplementation 'io.grpc:grpc-testing'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testImplementation 'org.junit.platform:junit-platform-suite'
Expand Down Expand Up @@ -101,7 +107,7 @@ publishing {
repositories {
maven {
name = "OSSRH"
if(project.version.endsWith('-SNAPSHOT')) {
if (project.version.endsWith('-SNAPSHOT')) {
url "https://s01.oss.sonatype.org/content/repositories/snapshots/"
} else {
url "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
Expand All @@ -115,7 +121,7 @@ publishing {
}

javadoc {
if(JavaVersion.current().isJava9Compatible()) {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import io.grpc.stub.StreamObserver;
import org.lognet.springboot.grpc.GRpcService;
import net.devh.boot.grpc.server.service.GrpcService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -45,19 +45,19 @@
import static java.util.concurrent.CompletableFuture.completedFuture;

@SpringBootApplication
@GRpcService
@GrpcService
@Component
public class FoundationDbGrpcFacade extends TransactionalKeyValueStoreGrpc.TransactionalKeyValueStoreImplBase {

Logger logger = LoggerFactory.getLogger(FoundationDbGrpcFacade.class);

@Autowired
Configuration config;
LionrockConfiguration config;
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@Autowired
Tracer tracer;

Map<String, Configuration.Cluster> clusterMap = new HashMap<>();
Map<String, LionrockConfiguration.Cluster> clusterMap = new HashMap<>();
Map<String, Database> databaseMap = new HashMap<>();

@PostConstruct
Expand All @@ -66,7 +66,7 @@ public void init() {
"(FDB API Version: " + config.getFdbVersion() + ")");
FDB.selectAPIVersion(config.getFdbVersion());
List<CompletableFuture<?>> readVersionCFs = new ArrayList<>(config.getClusters().size());
for (Configuration.Cluster cluster : config.getClusters()) {
for (LionrockConfiguration.Cluster cluster : config.getClusters()) {
clusterMap.put(cluster.getName(), cluster);
Database fdb = FDB.instance().open(cluster.getClusterFile());
if (cluster.isCheckOnStartup()) {
Expand Down Expand Up @@ -119,7 +119,7 @@ public void init() {
}

private CompletableFuture<Long> getReadVersionOrLog(
Configuration.Cluster cluster, Database fdb, AtomicLong start) {
LionrockConfiguration.Cluster cluster, Database fdb, AtomicLong start) {
return getReadVersionWithTimeout(fdb).exceptionally(ex -> {
logger.warn("Cluster: " + cluster.getName() + " with file: " + cluster.getClusterFile() +
" failed to get read version after" + (System.currentTimeMillis() - start.get()) + "ms", ex);
Expand Down Expand Up @@ -1291,7 +1291,7 @@ private void mutateValue(MutateValueRequest req) {

/**
* Use asList() with range gets (only enabled via
* {@link Configuration.InternalOptions#isUseAsListForRangeGets()}.
* {@link LionrockConfiguration.InternalOptions#isUseAsListForRangeGets()}.
* <p>
* Normally, calls are routed to
* {@link #handleRangeGetWithAsyncIterator(StreamingDatabaseRequest, GetRangeRequest, Span, KeySelector, KeySelector, AsyncIterable)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package io.github.panghy.lionrock;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@Component
@Configuration
@ConfigurationProperties(prefix = "lionrock.foundationdb")
public class Configuration {
public class LionrockConfiguration {

/**
* The FDB version to use when initializing FDB.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ management:
wavefront:
application:
name: lionrock
service: fdb-facade
service: fdb-facade

grpc:
server:
port: 6565
reflection-service-enabled: true

0 comments on commit 0c9c408

Please sign in to comment.