Migrate Ignite 2 caches to Ignite 3 KeyValueView tables

MSAL

Ignite 3 replaces caches with tables. A cache obtained with cache(name) or getOrCreateCache(name) becomes tables().table(IgniteNameUtils.quoteIfNeeded(name)).keyValueView(K.class, V.class), which reads the table that the Ignite 3 migration tools create for that cache. The key-value operations of IgniteCache and ClientCache move to KeyValueView, taking the transaction as their first argument: the enclosing Ignite 2 transaction where there is one, and null otherwise, which runs the operation in an implicit transaction of its own. A lambda or anonymous class inside a transaction gets a comment unless it is passed to a java.util method that runs it on the same thread. getAllOutTx becomes getAll outside any transaction. containsKey becomes contains, containsKeys becomes containsAll, and clear becomes removeAll. Operations without an Ignite 3 equivalent, such as size, query and invoke, are left as they are. A lookup with getOrCreateCache gets a comment, since the table has to be created before it can be read.

org.openrewrite.apache.ignite.MigrateCacheToKeyValueView
mod run . --recipe=org.openrewrite.apache.ignite.MigrateCacheToKeyValueView

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.