+ int shard = shardingStrategy.selectShard(id);
+ if (ownedShards.contains(shard))
+ {
+ return Mono.justOrEmpty(chatrooms[shard].get(id));
+ }
+ else
+ {
+ int[] ownedShards = new int[this.ownedShards.size()];
+ Iterator<Integer> iterator = this.ownedShards.iterator();
+ for (int i = 0; iterator.hasNext(); i++)
+ {
+ ownedShards[i] = iterator.next();
+ }
+ return Mono.error(new UnknownChatroomException(
+ id,
+ shard,
+ ownedShards));
+ }