Skip to content

Commit

Permalink
Introducing stundb-api to hold very essential models that can be used…
Browse files Browse the repository at this point in the history
… internally and transitively exposed through stundb-net-client. (#45)

* Applied Google/AOSP code style. (#35)

Refactored the way seeds are contacted, so we can retry again after some backoff time up to a maximum number of attempts.
Turned some classes into record classes.
Moved from Kryo to Apache Fury.
Fixed issue Entry::equals that would lead to unwanted data duplication as ConcurrentSet::addAll wouldn't recognize duplicated entries.

* Bump org.mapstruct.version from 1.5.3.Final to 1.5.5.Final (#30)

Bumps `org.mapstruct.version` from 1.5.3.Final to 1.5.5.Final.

Updates `org.mapstruct:mapstruct` from 1.5.3.Final to 1.5.5.Final
- [Release notes](https://github.com/mapstruct/mapstruct/releases)
- [Commits](mapstruct/mapstruct@1.5.3.Final...1.5.5.Final)

Updates `org.mapstruct:mapstruct-processor` from 1.5.3.Final to 1.5.5.Final
- [Release notes](https://github.com/mapstruct/mapstruct/releases)
- [Commits](mapstruct/mapstruct@1.5.3.Final...1.5.5.Final)

---
updated-dependencies:
- dependency-name: org.mapstruct:mapstruct
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.mapstruct:mapstruct-processor
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rafael Silvério <[email protected]>

* Bump org.junit:junit-bom from 5.10.1 to 5.10.2 (#31)

Bumps [org.junit:junit-bom](https://github.com/junit-team/junit5) from 5.10.1 to 5.10.2.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](junit-team/junit5@r5.10.1...r5.10.2)

---
updated-dependencies:
- dependency-name: org.junit:junit-bom
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump org.slf4j:slf4j-api from 2.0.7 to 2.0.12 (#33)

Bumps org.slf4j:slf4j-api from 2.0.7 to 2.0.12.

---
updated-dependencies:
- dependency-name: org.slf4j:slf4j-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump org.apache.maven.plugins:maven-surefire-plugin from 3.1.2 to 3.2.5 (#34)

Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.1.2 to 3.2.5.
- [Release notes](https://github.com/apache/maven-surefire/releases)
- [Commits](apache/maven-surefire@surefire-3.1.2...surefire-3.2.5)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-surefire-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Using maven properties for junit and surefire deps.

* Isolated net-client dependencies

Isolated net-client by adding the needed bindings to ClientModule, so external clients can rely solely on the net-client and net-core modules.

* Introducing stundb-api to hold very essential models that can be used internally and transitively exposed through stundb-net-client. (#44)

* Bump com.google.guava:guava from 32.1.1-jre to 33.0.0-jre (#39)

Bumps [com.google.guava:guava](https://github.com/google/guava) from 32.1.1-jre to 33.0.0-jre.
- [Release notes](https://github.com/google/guava/releases)
- [Commits](https://github.com/google/guava/commits)

---
updated-dependencies:
- dependency-name: com.google.guava:guava
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
rafaelsilverioit and dependabot[bot] authored Feb 27, 2024
1 parent 05cd58b commit 10b5cba
Show file tree
Hide file tree
Showing 53 changed files with 274 additions and 225 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Move from Kryo to Apache Fury

### Doing
- Create a Spring Boot app to observe nodes and expose actions through a REST API
- TESTS (unit & acceptance)!

### TODO
Expand All @@ -24,5 +25,4 @@
- Authentication
- Support multiple cache eviction policies
- Change how synchronization works today
- Create a Spring Boot app to observe nodes and expose data through a REST API
- Create a node gateway app to receive requests from clients, and load balance requests between nodes
9 changes: 5 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.stundb</groupId>
<artifactId>stundb</artifactId>
<version>1.0.0</version>
<name>stundb</name>
<name>StunDB</name>
<description>StunDB - A stunning distributed key-value database</description>
<packaging>pom</packaging>
<properties>
Expand All @@ -16,7 +16,8 @@
<junit.version>5.10.2</junit.version>
<surefire.version>3.2.5</surefire.version>
<lombok.version>1.18.30</lombok.version>
<jacoco.version>0.8.10</jacoco.version>
<jacoco.version>0.8.11</jacoco.version>
<maven.compiler.plugin.version>3.12.1</maven.compiler.plugin.version>
<skipTests>false</skipTests>
</properties>
<modules>
Expand Down Expand Up @@ -93,7 +94,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.4.0</version>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -131,7 +132,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>17</source> <!-- depending on your project -->
<target>17</target> <!-- depending on your project -->
Expand Down
12 changes: 6 additions & 6 deletions stundb/acceptance-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>acceptance-tests</artifactId>
<artifactId>stundb-acceptance-tests</artifactId>
<version>1.0.0</version>
<name>stundb - parent - acceptance tests</name>
<name>StunDB - Acceptance tests</name>
<description>StunDB - Acceptance tests</description>
<packaging>jar</packaging>
<dependencyManagement>
Expand All @@ -24,7 +24,7 @@
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-bom</artifactId>
<version>7.13.0</version>
<version>7.15.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -33,13 +33,13 @@
<dependencies>
<dependency>
<groupId>com.stundb</groupId>
<artifactId>core</artifactId>
<artifactId>stundb-core</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.stundb</groupId>
<artifactId>net-client</artifactId>
<artifactId>stundb-net-client</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -85,7 +85,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<encoding>UTF-8</encoding>
<source>${java.version}</source>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
package com.stundb.modules;

import com.google.inject.AbstractModule;
import com.stundb.core.configuration.ConfigurationLoader;
import com.stundb.core.mappers.ApplicationConfigMapper;
import com.stundb.core.models.ApplicationConfig;
import com.stundb.core.modules.providers.ApplicationConfigProvider;
import com.stundb.api.configuration.ConfigurationLoader;
import com.stundb.api.mappers.ApplicationConfigMapper;
import com.stundb.api.models.ApplicationConfig;
import com.stundb.api.providers.ApplicationConfigProvider;
import com.stundb.modules.providers.PropertiesProvider;
import com.stundb.net.client.modules.ClientModule;
import com.stundb.net.core.codecs.Codec;
import com.stundb.net.core.modules.providers.CodecProvider;

import java.util.Properties;

public class Module extends AbstractModule {

@Override
protected void configure() {
bind(Codec.class).toProvider(CodecProvider.class).asEagerSingleton();

bind(Properties.class).toProvider(PropertiesProvider.class);
bind(ConfigurationLoader.class).toInstance(new ConfigurationLoader());
bind(ApplicationConfig.class).toProvider(ApplicationConfigProvider.class);
Expand Down
15 changes: 15 additions & 0 deletions stundb/api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.stundb</groupId>
<artifactId>stundb-parent</artifactId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>stundb-api</artifactId>
<version>1.0.0</version>
<name>StunDB - API</name>
<description>StunDB - API</description>
<packaging>jar</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.stundb.core.configuration;
package com.stundb.api.configuration;

import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.stundb.core.configuration;
package com.stundb.api.configuration;

import com.stundb.core.mappers.ApplicationConfigMapper;
import com.stundb.core.models.ApplicationConfig;
import com.stundb.api.mappers.ApplicationConfigMapper;
import com.stundb.api.models.ApplicationConfig;

import jakarta.inject.Inject;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.stundb.core.crdt;
package com.stundb.api.crdt;

import java.time.Instant;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.stundb.core.mappers;
package com.stundb.api.mappers;

import com.stundb.core.configuration.ApplicationProperties;
import com.stundb.core.models.*;
import com.stundb.api.configuration.ApplicationProperties;
import com.stundb.api.models.ApplicationConfig;
import com.stundb.api.models.Capacity;
import com.stundb.api.models.Timeouts;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.stundb.core.mappers;
package com.stundb.api.mappers;

import com.stundb.core.models.Executor;
import com.stundb.core.models.Executors;
import com.stundb.api.models.Executor;
import com.stundb.api.models.Executors;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.stundb.core.models;
package com.stundb.api.models;

import lombok.Data;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.stundb.core.models;
package com.stundb.api.models;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package com.stundb.core.models;
package com.stundb.api.models;

public record Executor(Integer threads) {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.stundb.core.models;
package com.stundb.api.models;

public record Executors(
Executor tcpClient,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.stundb.core.models;
package com.stundb.api.models;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.stundb.core.modules.providers;
package com.stundb.api.providers;

import com.stundb.core.configuration.ConfigurationLoader;
import com.stundb.core.models.ApplicationConfig;
import com.stundb.api.configuration.ConfigurationLoader;
import com.stundb.api.models.ApplicationConfig;

import jakarta.inject.Inject;
import jakarta.inject.Provider;

public class ApplicationConfigProvider implements Provider<ApplicationConfig> {

@Inject
private ConfigurationLoader loader;
@Inject private ConfigurationLoader loader;

@Override
public ApplicationConfig get() {
Expand Down
12 changes: 6 additions & 6 deletions stundb/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>application</artifactId>
<artifactId>stundb-application</artifactId>
<version>1.0.0</version>
<name>stundb - parent - application</name>
<description>StunDB - Main application code</description>
<name>StunDB - Application</name>
<description>StunDB - Application</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.stundb</groupId>
<artifactId>core</artifactId>
<artifactId>stundb-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.stundb</groupId>
<artifactId>net-client</artifactId>
<artifactId>stundb-net-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.stundb</groupId>
<artifactId>net-server</artifactId>
<artifactId>stundb-net-server</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
Expand Down
10 changes: 5 additions & 5 deletions stundb/application/src/main/java/com/stundb/modules/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
import com.google.inject.TypeLiteral;
import com.google.inject.matcher.Matchers;
import com.google.inject.name.Names;
import com.stundb.api.configuration.ConfigurationLoader;
import com.stundb.api.mappers.ApplicationConfigMapper;
import com.stundb.api.models.ApplicationConfig;
import com.stundb.api.providers.ApplicationConfigProvider;
import com.stundb.core.cache.Cache;
import com.stundb.core.configuration.ConfigurationLoader;
import com.stundb.core.logging.Loggable;
import com.stundb.core.logging.RequestLogger;
import com.stundb.core.mappers.ApplicationConfigMapper;
import com.stundb.core.models.ApplicationConfig;
import com.stundb.core.models.Node;
import com.stundb.core.models.UniqueId;
import com.stundb.core.modules.providers.ApplicationConfigProvider;
import com.stundb.modules.providers.CacheProvider;
import com.stundb.modules.providers.CommandHandlerProvider;
import com.stundb.modules.providers.MessageDigestProvider;
import com.stundb.modules.providers.UniqueIdProvider;
import com.stundb.net.client.modules.ClientModule;
import com.stundb.net.core.codecs.Codec;
import com.stundb.net.core.models.Node;
import com.stundb.net.core.modules.providers.CodecProvider;
import com.stundb.net.server.handlers.CommandHandler;
import com.stundb.service.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.stundb.modules.providers;

import com.stundb.api.models.ApplicationConfig;
import com.stundb.core.cache.Cache;
import com.stundb.core.cache.FIFOCache;
import com.stundb.core.models.ApplicationConfig;

import jakarta.inject.Inject;
import jakarta.inject.Provider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.stundb.modules.providers;

import com.stundb.core.models.ApplicationConfig;
import com.stundb.api.models.ApplicationConfig;

import jakarta.inject.Inject;
import jakarta.inject.Provider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.stundb.modules.providers;

import com.stundb.core.models.ApplicationConfig;
import com.stundb.api.models.ApplicationConfig;
import com.stundb.core.models.UniqueId;
import com.stundb.utils.NodeUtils;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.stundb.service;

import com.stundb.core.models.Node;
import com.stundb.net.core.models.Node;
import com.stundb.net.core.models.requests.CRDTRequest;
import com.stundb.net.core.models.requests.DeregisterRequest;
import com.stundb.net.core.models.requests.ElectedRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.stundb.service.impl;

import static com.stundb.core.models.Status.State.FAILING;
import static com.stundb.core.models.Status.State.RUNNING;
import static com.stundb.net.core.models.NodeStatus.State.FAILING;
import static com.stundb.net.core.models.NodeStatus.State.RUNNING;

import com.stundb.api.models.ApplicationConfig;
import com.stundb.core.cache.Cache;
import com.stundb.core.logging.Loggable;
import com.stundb.core.models.ApplicationConfig;
import com.stundb.core.models.Node;
import com.stundb.core.models.Status;
import com.stundb.core.models.UniqueId;
import com.stundb.net.client.StunDBClient;
import com.stundb.net.core.models.Command;
import com.stundb.net.core.models.Node;
import com.stundb.net.core.models.NodeStatus;
import com.stundb.net.core.models.requests.ElectedRequest;
import com.stundb.net.core.models.requests.Request;
import com.stundb.service.ElectionService;
Expand Down Expand Up @@ -92,7 +92,7 @@ private void becomeLeader(Collection<Node> nodes) {
config.getPort(),
uniqueId.number(),
true,
Status.create(RUNNING)));
NodeStatus.create(RUNNING)));

// notifying other nodes that I became the cluster's leader
utils.filterNodesByState(nodes, uniqueId.number(), List.of(RUNNING))
Expand Down
Loading

0 comments on commit 10b5cba

Please sign in to comment.