1. If I use ModeShape with clustering activated (with JGroups-backed listeners in modeshape-clustering), then I get the repo replicated on all the nodes. If the repo grows above the available memory, I have a problem.
Actually, at this time the in-memory connector is not really able to be clustered without a bit of extra work on your part. Changes to the content in one process will not be picked up by the in-memory connectors running in the other processes. Notifications of the changes will be sent to the other processes, but the connector does not currently use those. Thus, the in-memory connector is really limited to a single process use case or a read-only distributed case. Obviously these are limited.
2. If I use ModeShape with the Infinispan connector, then the repository will be partitioned among the nodes, and the memory limit will be times as higher. In case of failure of one of the nodes its piece of cake will be restored from a replica on another node.
Yes, this is exactly the purpose of Infinispan ... to provide a replicated, distributed in-memory store for information. The memory limits are indeed higher (simply because the information is not replicated on every process in the cluster), but the increase will be a function of the number of processes and the Infinispan clustering configuration (there are several modes). Fault tolerance is improved because of the cluster, but there is also the ability to persist information should the entire cluster go down.
But again, the situation of available memory an issue is the least likely case. Won't Infinispan be an overkill for me?
At the highest level, I think that Infinispan is perfect for this use case (not having heard any of the other details of your environment), and putting ModeShape on top of Infinispan will give you performance similar to the in-memory connector but with the clustering, fault tolerance and replication features of Infinispan.
Infinispan is heavier than HashMap, but Infinispan is also much more fault-tolerant and clusterable.
Thank you so much, Randall, it's much more clear now.