GridGain Developers Hub

Codebase Migration

The GridGain 9 code follows patterns that are significantly different from those in GridGain 8. As a temporary measure, you can run your code via the code adapter.

Simple client code can be used to work with the GridGain 9 cluster by adding the migration adapter to your clients, both thick and thin. The adapter will run as an intermediary between your code and GridGain 9. You can keep using GridGain 8 APIs, and the adapter will convert the requests to the cluster dynamically.

However, this approach is limited to simpler code bases and causes a performance loss on higher load environments. More complex code needs to be migrated to GridGain 9 to be properly supported.

To start using the migration adapter:

  • Add the migration adapter dependency to your project:

    <dependency>
      <groupId>org.gridgain.ignite</groupId>
      <artifactId>migration-tools-adapter</artifactId>
      <version>1.0</version>
    </dependency>
  • Create the GridGain 9 client instance:

    // In a separate scope or using the full qualified name.
    // Create a client instance configured to connect your GridGain 9 cluster.
    var ignite3Client = org.apache.ignite3.client.IgniteClient.builder()
        .addresses("127.0.0.1:10800")
        .build();
    
    //Create your desired Ignite 2 interface.
    
    // Thick client
    try (IgniteAdapter adapter = IgniteAdapter.builder(ignite3Client)
        .allowExtraFields(true)
        .build()) {
        //...
    }
    
    // Thin client
    try (IgniteClient adapter = IgniteClientAdapter.builder(ignite3Client)
        .allowExtraFields(true)
        .build()) {
        //...
    }

In the above code:

  • Setting allowExtraFields to true (default) allows extra fields in the Java client adapter. If you migrate a cache in the PACK_EXTRA mode, you can access additional fields in that cache - those that were not converted directly to columns.

  • Setting allowNonDefaultConstructors to true (false by default) enables mapping Java classes that do not define a default constructor. This is not supported natively in GridGain 9. Therefore, we encourage you to implement default constructors in your data classes instead of allowing non-default constructors. The latter relies on unsafe mechanisms and introduces a modest performance penalty.

  • tableTypeRegistry provides mappings between tables and the corresponding Java classes. In GridGain 8, this information is persisted to a system view, which can be overridden locally by individual records. Currently, the default implementation is stored in a persistent table.

Now you can use the thinClient or thickClient the same way as you would use an instance of the GridGain 8 client.