projects
/
demos
/
kafka
/
chat
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
WIP:test: Simp...
[demos/kafka/chat]
/
src
/
test
/
java
/
de
/
juplo
/
kafka
/
chat
/
backend
/
persistence
/
inmemory
/
ShardedChatHomeTest.java
diff --git
a/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHomeTest.java
b/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHomeTest.java
index
ff82986
..
9b4bde7
100644
(file)
--- a/
src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHomeTest.java
+++ b/
src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHomeTest.java
@@
-11,7
+11,6
@@
import java.nio.file.Paths;
import java.time.Clock;
import java.util.stream.IntStream;
import java.time.Clock;
import java.util.stream.IntStream;
-
public class ShardedChatHomeTest extends ChatHomeWithShardsTestBase
{
@TestConfiguration
public class ShardedChatHomeTest extends ChatHomeWithShardsTestBase
{
@TestConfiguration
@@
-19,55
+18,44
@@
public class ShardedChatHomeTest extends ChatHomeWithShardsTestBase
{
@Bean
ShardedChatHome chatHome(
{
@Bean
ShardedChatHome chatHome(
- Integer numShards,
- int[] ownedShards,
InMemoryChatHomeService chatHomeService)
{
InMemoryChatHomeService chatHomeService)
{
- SimpleChatHome[] chatHomes = new SimpleChatHome[
numShards
];
+ SimpleChatHome[] chatHomes = new SimpleChatHome[
NUM_SHARDS
];
IntStream
IntStream
- .of(ownedShards)
+ .of(ownedShards
()
)
.forEach(shard -> chatHomes[shard] = new SimpleChatHome(chatHomeService, shard));
.forEach(shard -> chatHomes[shard] = new SimpleChatHome(chatHomeService, shard));
- ShardingStrategy strategy = new KafkaLikeShardingStrategy(
numShards
);
+ ShardingStrategy strategy = new KafkaLikeShardingStrategy(
NUM_SHARDS
);
return new ShardedChatHome(chatHomes, strategy);
}
@Bean
InMemoryChatHomeService chatHomeService(
return new ShardedChatHome(chatHomes, strategy);
}
@Bean
InMemoryChatHomeService chatHomeService(
- Integer numShards,
- int[] ownedShards,
StorageStrategy storageStrategy)
{
return new InMemoryChatHomeService(
StorageStrategy storageStrategy)
{
return new InMemoryChatHomeService(
-
numShards
,
- ownedShards,
+
NUM_SHARDS
,
+ ownedShards
()
,
storageStrategy.read());
}
@Bean
storageStrategy.read());
}
@Bean
- public FilesStorageStrategy storageStrategy(
Integer numShards
)
+ public FilesStorageStrategy storageStrategy()
{
return new FilesStorageStrategy(
Paths.get("target", "test-classes", "data", "files"),
Clock.systemDefaultZone(),
8,
{
return new FilesStorageStrategy(
Paths.get("target", "test-classes", "data", "files"),
Clock.systemDefaultZone(),
8,
- new KafkaLikeShardingStrategy(
numShards
),
+ new KafkaLikeShardingStrategy(
NUM_SHARDS
),
messageFlux -> new InMemoryChatRoomService(messageFlux),
new ObjectMapper());
}
messageFlux -> new InMemoryChatRoomService(messageFlux),
new ObjectMapper());
}
- @Bean
- Integer numShards()
- {
- return 10;
- }
-
- @Bean
int[] ownedShards()
{
int[] ownedShards()
{
- return new int[] {
2
};
+ return new int[] {
OWNED_SHARD
};
}
}
}
}
}
}