deps: Refactor dependencies (#3224)

* remove spring dep
move junit, logging, mockito under dep mgmt

* upgrade anti-corruption-layer deps

* async method invocation

* balking, bloc

* bridge to bytecode

* caching

* callback - cqrs

* component - health check

* hexagonal - metadata mapping

* rest of the patterns

* remove checkstyle, take spotless into use
This commit is contained in:
Ilkka Seppälä
2025-03-29 19:34:27 +02:00
committed by GitHub
parent 371439aeaa
commit 0ca162a55c
1863 changed files with 14403 additions and 17632 deletions
@@ -85,5 +85,4 @@ public class App {
shard2.clearData();
shard3.clearData();
}
}
@@ -27,9 +27,7 @@ package com.iluwatar.sharding;
import lombok.Getter;
import lombok.Setter;
/**
* Basic data structure for each tuple stored in data shards.
*/
/** Basic data structure for each tuple stored in data shards. */
@Getter
@Setter
public class Data {
@@ -42,6 +40,7 @@ public class Data {
/**
* Constructor of Data class.
*
* @param key data key
* @param value data value
* @param type data type
@@ -53,14 +52,13 @@ public class Data {
}
enum DataType {
TYPE_1, TYPE_2, TYPE_3
TYPE_1,
TYPE_2,
TYPE_3
}
@Override
public String toString() {
return "Data {" + "key="
+ key + ", value='" + value
+ '\'' + ", type=" + type + '}';
return "Data {" + "key=" + key + ", value='" + value + '\'' + ", type=" + type + '}';
}
}
@@ -27,10 +27,9 @@ package com.iluwatar.sharding;
import lombok.extern.slf4j.Slf4j;
/**
* ShardManager with hash strategy. The purpose of this strategy is to reduce the
* chance of hot-spots in the data. It aims to distribute the data across the shards
* in a way that achieves a balance between the size of each shard and the average
* load that each shard will encounter.
* ShardManager with hash strategy. The purpose of this strategy is to reduce the chance of
* hot-spots in the data. It aims to distribute the data across the shards in a way that achieves a
* balance between the size of each shard and the average load that each shard will encounter.
*/
@Slf4j
public class HashShardManager extends ShardManager {
@@ -50,5 +49,4 @@ public class HashShardManager extends ShardManager {
var hash = data.getKey() % shardCount;
return hash == 0 ? hash + shardCount : hash;
}
}
@@ -30,9 +30,8 @@ import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
* ShardManager with lookup strategy. In this strategy the sharding logic implements
* a map that routes a request for data to the shard that contains that data by using
* the shard key.
* ShardManager with lookup strategy. In this strategy the sharding logic implements a map that
* routes a request for data to the shard that contains that data by using the shard key.
*/
@Slf4j
public class LookupShardManager extends ShardManager {
@@ -59,5 +58,4 @@ public class LookupShardManager extends ShardManager {
return new SecureRandom().nextInt(shardCount - 1) + 1;
}
}
}
@@ -51,5 +51,4 @@ public class RangeShardManager extends ShardManager {
case TYPE_3 -> 3;
};
}
}
@@ -28,13 +28,10 @@ import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
/**
* The Shard class stored data in a HashMap.
*/
/** The Shard class stored data in a HashMap. */
public class Shard {
@Getter
private final int id;
@Getter private final int id;
private final Map<Integer, Data> dataStore;
@@ -28,9 +28,7 @@ import java.util.HashMap;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
* Abstract class for ShardManager.
*/
/** Abstract class for ShardManager. */
@Slf4j
public abstract class ShardManager {
@@ -44,8 +42,8 @@ public abstract class ShardManager {
* Add a provided shard instance to shardMap.
*
* @param shard new shard instance.
* @return {@code true} if succeed to add the new instance.
* {@code false} if the shardId is already existed.
* @return {@code true} if succeed to add the new instance. {@code false} if the shardId is
* already existed.
*/
public boolean addNewShard(final Shard shard) {
var shardId = shard.getId();
@@ -97,5 +95,4 @@ public abstract class ShardManager {
* @return id of shard that the data should be stored
*/
protected abstract int allocateShard(final Data data);
}
@@ -28,14 +28,11 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import org.junit.jupiter.api.Test;
/**
* Unit tests for App class.
*/
/** Unit tests for App class. */
class AppTest {
@Test
void shouldExecuteWithoutException() {
assertDoesNotThrow(() -> App.main(new String[]{}));
assertDoesNotThrow(() -> App.main(new String[] {}));
}
}
@@ -29,16 +29,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Unit tests for HashShardManager class.
*/
/** Unit tests for HashShardManager class. */
class HashShardManagerTest {
private HashShardManager hashShardManager;
/**
* Initialize hashShardManager instance.
*/
/** Initialize hashShardManager instance. */
@BeforeEach
void setup() {
hashShardManager = new HashShardManager();
@@ -56,5 +52,4 @@ class HashShardManagerTest {
hashShardManager.storeData(data);
assertEquals(data, hashShardManager.getShardById(1).getDataById(1));
}
}
@@ -31,16 +31,12 @@ import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Unit tests for LookupShardManager class.
*/
/** Unit tests for LookupShardManager class. */
class LookupShardManagerTest {
private LookupShardManager lookupShardManager;
/**
* Initialize lookupShardManager instance.
*/
/** Initialize lookupShardManager instance. */
@BeforeEach
void setup() {
lookupShardManager = new LookupShardManager();
@@ -29,16 +29,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Unit tests for RangeShardManager class.
*/
/** Unit tests for RangeShardManager class. */
class RangeShardManagerTest {
private RangeShardManager rangeShardManager;
/**
* Initialize rangeShardManager instance.
*/
/** Initialize rangeShardManager instance. */
@BeforeEach
void setup() {
rangeShardManager = new RangeShardManager();
@@ -56,5 +52,4 @@ class RangeShardManagerTest {
rangeShardManager.storeData(data);
assertEquals(data, rangeShardManager.getShardById(1).getDataById(1));
}
}
@@ -32,16 +32,12 @@ import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Unit tests for ShardManager class.
*/
/** Unit tests for ShardManager class. */
class ShardManagerTest {
private ShardManager shardManager;
/**
* Initialize shardManager instance.
*/
/** Initialize shardManager instance. */
@BeforeEach
void setup() {
shardManager = new TestShardManager();
@@ -32,10 +32,7 @@ import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Unit tests for Shard class.
*/
/** Unit tests for Shard class. */
class ShardTest {
private Data data;
@@ -60,7 +57,6 @@ class ShardTest {
} catch (NoSuchFieldException | IllegalAccessException e) {
fail("Fail to modify field access.");
}
}
@Test