private final long[] currentOffset;
private final long[] nextOffset;
private final Map<UUID, ChatRoomData>[] chatRoomData;
- private final InfoChannel infoChannel;
+ private final ChannelMediator channelMediator;
private final ShardingPublisherStrategy shardingPublisherStrategy;
private boolean running;
Duration pollingInterval,
int bufferSize,
Clock clock,
- InfoChannel infoChannel,
+ ChannelMediator channelMediator,
ShardingPublisherStrategy shardingPublisherStrategy)
{
log.debug(
IntStream
.range(0, numShards)
.forEach(shard -> this.chatRoomData[shard] = new HashMap<>());
- this.infoChannel = infoChannel;
+ this.channelMediator = channelMediator;
this.shardingPublisherStrategy = shardingPublisherStrategy;
}
currentOffset);
consumer.seek(topicPartition, nextOffset[partition]);
- infoChannel.sendShardAssignedEvent(partition);
+ channelMediator.shardAssigned(partition);
shardingPublisherStrategy
.publishOwnership(partition)
.doOnSuccess(instanceId -> log.info(
"Could not publish instance {} as owner of shard {}: {}",
instanceId,
partition,
- throwable))
+ throwable.toString()))
+ .onErrorComplete()
.block();
});
isShardOwned[partition] = false;
nextOffset[partition] = consumer.position(topicPartition);
log.info("Partition revoked: {} - next={}", partition, nextOffset[partition]);
- infoChannel.sendShardRevokedEvent(partition);
+ channelMediator.shardRevoked(partition);
});
}
return Mono.error(new ShardNotOwnedException(instanceId, shard));
}
- return infoChannel
+ return channelMediator
.getChatRoomInfo(id)
.map(chatRoomInfo ->
chatRoomData[shard].computeIfAbsent(id, this::computeChatRoomData));