Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ranger Discovery Bundle and Lib Version upgrades #29

Merged
merged 2 commits into from
Dec 6, 2023
Merged
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
17 changes: 9 additions & 8 deletions .github/workflows/build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: '1.8'
cache: maven
- name: Build with Maven
run: mvn -B clean package --file pom.xml
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
cache: maven
distribution: 'temurin'
- name: Build with Maven
run: mvn -B clean package --file pom.xml
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Changelog
All notable changes to this project will be documented in this file.

## [1.0-RC15]
- Moved discovery bundle from https://github.com/appform-io/dropwizard-service-discovery.
- Updated to dropwizard version 2.1.10 : BOM update.
- Upgraded to java version 17 with release in 11
- Removed com.fasterxml and introduced dropwizard-jackson for the jackson bindings.
- Upgraded to junit 5 and fixed the necessary tests including wiremock versions and tests.
- Upgraded the curator framework version
- Done sonar fixes after the java version upgrade

## [1.0-RC14]
- When the Collection of Services is empty the monitor should gracefully return [PR](https://github.com/appform-io/ranger/pull/27)

Expand Down
82 changes: 59 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>io.appform.ranger</groupId>
<artifactId>ranger</artifactId>
<packaging>pom</packaging>
<version>1.0-RC14</version>
<version>1.0-RC15</version>
<name>Ranger</name>
<url>https://github.com/appform-io/ranger</url>
<description>Service Discovery for Java</description>
Expand All @@ -27,6 +27,7 @@
<module>ranger-http-model</module>
<module>ranger-http-server-bundle</module>
<module>ranger-zk-server-bundle</module>
<module>ranger-discovery-bundle</module>
</modules>

<distributionManagement>
Expand Down Expand Up @@ -82,26 +83,45 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<guava.version>31.0.1-jre</guava.version>
<curator.version>5.1.0</curator.version>
<jackson.version>2.13.1</jackson.version>
<curator.version>5.5.0</curator.version>
<slf4j.version>1.7.32</slf4j.version>

<maven.compiler.version>3.8.0</maven.compiler.version>
<java.version>1.8</java.version>
<java.version>17</java.version>
<java.release.version>11</java.release.version>
<lombok.version>1.18.22</lombok.version>
<annotations.version>3.0.1u2</annotations.version>

<junit.version>4.13.2</junit.version>
<junit.jupiter.version>5.8.2</junit.jupiter.version>
<awaitility.version>4.1.1</awaitility.version>
<guava-retrying.version>2.0.0</guava-retrying.version>

<http.client.version>4.9.3</http.client.version>
<wiremock.version>2.27.2</wiremock.version>
<wiremock.version>3.3.1</wiremock.version>
<mockito.version>4.2.0</mockito.version>

<logback.version>1.2.10</logback.version>
<dropwizard.version>2.1.10</dropwizard.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit.jupiter.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-bom</artifactId>
<type>pom</type>
<scope>import</scope>
<version>${dropwizard.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
Expand All @@ -124,32 +144,25 @@
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-jackson</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.github.rholder</groupId>
<artifactId>guava-retrying</artifactId>
<version>${guava-retrying.version}</version>
</dependency>

<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
Expand All @@ -167,12 +180,18 @@
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<release>${java.release.version}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<version>0.8.8</version>
<executions>
<execution>
<goals>
Expand Down Expand Up @@ -206,7 +225,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.0</version>
<version>3.6.3</version>
<configuration>
<doclint>all,-missing</doclint>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down Expand Up @@ -265,6 +287,20 @@
</plugins>
</build>
</profile>
<!-- The following are required for dns cache manipulator.
Ref: https://github.com/alibaba/java-dns-cache-manipulator#jvm-settings-for-java-16 -->
<profile>
<id>add-java-open-options-for-jdk16+</id>
<activation>
<jdk>[16,)</jdk>
</activation>
<properties>
<argLine>
--add-opens java.base/java.net=ALL-UNNAMED
--add-opens java.base/sun.net=ALL-UNNAMED
</argLine>
</properties>
</profile>
</profiles>

</project>
7 changes: 1 addition & 6 deletions ranger-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ranger</artifactId>
<groupId>io.appform.ranger</groupId>
<version>1.0-RC14</version>
<version>1.0-RC15</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -23,11 +23,6 @@
<version>${project.version}</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,41 @@
import io.appform.ranger.core.utils.RangerTestUtils;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import lombok.var;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

@Slf4j
public class AbstractRangerHubClientTest {
class AbstractRangerHubClientTest {

private static final Service service = RangerTestUtils.getService("test-ns", "test-s");

@Test
public void testAbstractHubClient() {
void testAbstractHubClient() {
val testAbstractHub = RangerHubTestUtils.getTestHub();
testAbstractHub.start();
var node = testAbstractHub.getNode(service).orElse(null);
Assert.assertNotNull(node);
Assert.assertTrue(node.getHost().equalsIgnoreCase("localhost"));
Assert.assertEquals(9200, node.getPort());
Assert.assertEquals(1, node.getNodeData().getShardId());
Assert.assertFalse(testAbstractHub.getNode(RangerTestUtils.getService("test", "test")).isPresent());
Assert.assertFalse(testAbstractHub.getNode(service, nodeData -> nodeData.getShardId() == 2).isPresent());
Assert.assertFalse(testAbstractHub.getNode(RangerTestUtils.getService("test", "test"), nodeData -> nodeData.getShardId() == 1).isPresent());
Assertions.assertNotNull(node);
Assertions.assertTrue(node.getHost().equalsIgnoreCase("localhost"));
Assertions.assertEquals(9200, node.getPort());
Assertions.assertEquals(1, node.getNodeData().getShardId());
Assertions.assertFalse(testAbstractHub.getNode(RangerTestUtils.getService("test", "test")).isPresent());
Assertions.assertFalse(testAbstractHub.getNode(service, nodeData -> nodeData.getShardId() == 2).isPresent());
Assertions.assertFalse(testAbstractHub.getNode(RangerTestUtils.getService("test", "test"), nodeData -> nodeData.getShardId() == 1).isPresent());
testAbstractHub.stop();
}

@Test
public void testAbstractHubClientWithDataSource() {
void testAbstractHubClientWithDataSource() {
val testAbstractHub = RangerHubTestUtils.getTestHubWithDataSource();
testAbstractHub.start();
var node = testAbstractHub.getNode(service).orElse(null);
Assert.assertNotNull(node);
Assert.assertTrue(node.getHost().equalsIgnoreCase("localhost"));
Assert.assertEquals(9200, node.getPort());
Assert.assertEquals(1, node.getNodeData().getShardId());
Assert.assertFalse(testAbstractHub.getNode(RangerTestUtils.getService("test", "test")).isPresent());
Assert.assertFalse(testAbstractHub.getNode(service, nodeData -> nodeData.getShardId() == 2).isPresent());
Assert.assertFalse(testAbstractHub.getNode(RangerTestUtils.getService("test", "test"), nodeData -> nodeData.getShardId() == 1).isPresent());
val node = testAbstractHub.getNode(service).orElse(null);
Assertions.assertNotNull(node);
Assertions.assertTrue(node.getHost().equalsIgnoreCase("localhost"));
Assertions.assertEquals(9200, node.getPort());
Assertions.assertEquals(1, node.getNodeData().getShardId());
Assertions.assertFalse(testAbstractHub.getNode(RangerTestUtils.getService("test", "test")).isPresent());
Assertions.assertFalse(testAbstractHub.getNode(service, nodeData -> nodeData.getShardId() == 2).isPresent());
Assertions.assertFalse(testAbstractHub.getNode(RangerTestUtils.getService("test", "test"), nodeData -> nodeData.getShardId() == 1).isPresent());
testAbstractHub.stop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,26 @@
import io.appform.ranger.client.utils.CriteriaUtils;
import io.appform.ranger.core.units.TestNodeData;
import lombok.val;
import lombok.var;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.function.Predicate;

public class CriteriaUtilsTest {
class CriteriaUtilsTest {

private Predicate<TestNodeData> getCriteria(int shardId){
return testNodeData -> testNodeData.getShardId() == shardId;
}

@Test
public void testGetCriteria(){
void testGetCriteria(){
val initialCriteria = getCriteria(1);
val argCriteria = getCriteria(2);
var mergedCriteria = CriteriaUtils.getCriteria(true, initialCriteria, argCriteria);
Assert.assertFalse(mergedCriteria.test(TestNodeData.builder().shardId(1).build()));
Assert.assertFalse(mergedCriteria.test(TestNodeData.builder().shardId(2).build()));
Assertions.assertFalse(mergedCriteria.test(TestNodeData.builder().shardId(1).build()));
Assertions.assertFalse(mergedCriteria.test(TestNodeData.builder().shardId(2).build()));
mergedCriteria = CriteriaUtils.getCriteria(false, initialCriteria, argCriteria);
Assert.assertFalse(mergedCriteria.test(TestNodeData.builder().shardId(1).build()));
Assert.assertTrue(mergedCriteria.test(TestNodeData.builder().shardId(2).build()));
Assertions.assertFalse(mergedCriteria.test(TestNodeData.builder().shardId(1).build()));
Assertions.assertTrue(mergedCriteria.test(TestNodeData.builder().shardId(2).build()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public ServiceFinder<TestNodeData, ListBasedServiceRegistry<TestNodeData>> build
val finder = new TestSimpleUnshardedServiceFinder<TestNodeData>()
.withNamespace(service.getNamespace())
.withServiceName(service.getServiceName())
.withDeserializer(new Deserializer<TestNodeData>() {})
.withDeserializer(new Deserializer<>() {
})
.build();
finder.start();
return finder;
Expand Down
2 changes: 1 addition & 1 deletion ranger-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ranger</artifactId>
<groupId>io.appform.ranger</groupId>
<version>1.0-RC14</version>
<version>1.0-RC15</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package io.appform.ranger.core.finder.serviceregistry;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ListMultimap;
import io.appform.ranger.core.model.Service;
Expand Down Expand Up @@ -46,7 +45,7 @@ public ListMultimap<T, ServiceNode<T>> nodes() {
@Override
public List<ServiceNode<T>> nodeList() {
val nodeList = nodes.get();
return null == nodeList ? ImmutableList.of() : new ArrayList<>(nodeList.values());
return null == nodeList ? List.of() : new ArrayList<>(nodeList.values());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import io.appform.ranger.core.util.Exceptions;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import lombok.var;

import java.util.List;
import java.util.concurrent.ExecutorService;
Expand Down Expand Up @@ -67,7 +66,7 @@ public void start() {
log.info("Started updater for [{}]. Triggering initial update.", serviceName);
checkForUpdate(null);
log.info("Waiting for initial update to complete for: {}", serviceName);
var stopwatch = Stopwatch.createStarted();
val stopwatch = Stopwatch.createStarted();
try {
RetryerBuilder.<Boolean>newBuilder()
.retryIfResult(r -> null == r || !r)
Expand Down
Loading