java.lang.Object
org.gridgain.ignite.migrationtools.adapter.internal.ClientAdapter

public class ClientAdapter extends Object
Provides a base adaptation for the Ignite 2 Client to communicate to the Ignite 3 cluster.

This class has two operation modes. With allowExtraField enabled, unsupported attributes in the mapped type, like nested pojos, will be mapped to the SqlDdlGenerator.EXTRA_FIELDS_COLUMN_NAME column allowing them to be persisted/retrieved alongside the data. This seems to be the default behaviour in Ignite 2. When this feature is enabled the mapped classes must match the database table completely.

This class requires type-hints to match created tables/caches to their mapped classes. Ignite 2 achieved this by persisting the cache configuration.

  • Constructor Details

    • ClientAdapter

      public ClientAdapter(org.apache.ignite3.client.IgniteClient client, org.apache.ignite.migrationtools.tablemanagement.TableTypeRegistry tableTypeRegistry, MapperUtils mapperUtils)
      Constructor.
      Parameters:
      client - The Ignite Client to be wrapped.
      tableTypeRegistry - The registry for the key/value types of tables.
      mapperUtils - Mapper Utility class.
  • Method Details

    • getClientTable

      @Nullable public @Nullable org.apache.ignite3.internal.client.table.ClientTable getClientTable(org.apache.ignite3.table.QualifiedName tableName)
      Get the ClientTable object for the specified table.
      Parameters:
      tableName - Table name.
      Returns:
      The ClientTable for the provided table.
    • cache

      @Nullable public <K, V> @Nullable CacheAdapter<K,V> cache(String name)
      Creates a cache adapter for the given cache. Prefer cache(CacheConfiguration) whenever possible.
      Type Parameters:
      K - Key type.
      V - Value type.
      Parameters:
      name - Cache name.
      Returns:
      The cache adapter for the given cache.
    • cache

      @Nullable public <K, V> @Nullable CacheAdapter<K,V> cache(org.apache.ignite.configuration.CacheConfiguration<K,V> cacheCfg)
      Creates a cache adapter for the given cache configuration.
      Type Parameters:
      K - Key type.
      V - Value type.
      Parameters:
      cacheCfg - Cache Configuration.
      Returns:
      The cache adapter for the given cache.
    • createCache

      public <K, V> CompletableFuture<CacheAdapter<K,V>> createCache(org.apache.ignite.configuration.CacheConfiguration<K,V> cacheCfg)
      Creates a new cache.
      Type Parameters:
      K - Key Type.
      V - Value Type.
      Parameters:
      cacheCfg - Cache configuration.
      Returns:
      A Cache Adatper for the newly created cache, wrapped in a future.
    • createTableAndTypeHints

      public <K, V> CompletableFuture<Map.Entry<org.apache.ignite3.internal.client.table.ClientTable,org.apache.ignite.migrationtools.sql.SqlDdlGenerator.GenerateTableResult>> createTableAndTypeHints(org.apache.ignite.configuration.CacheConfiguration<K,V> cacheCfg)
      Creates a cache and initializes the type hints if necessary.
      Type Parameters:
      K - Key type.
      V - Value type.
      Parameters:
      cacheCfg - Cache configuration.
      Returns:
      The newly created ClientTable and the GenerateTableResult used to create the table.
    • getOrCreateCache

      public <K, V> CompletableFuture<CacheAdapter<K,V>> getOrCreateCache(org.apache.ignite.configuration.CacheConfiguration<K,V> cacheCfg)
      Gets a CacheAdater for a given cache. This method creates the cache if it doesn't exist.
      Type Parameters:
      K - Key type.
      V - Value type.
      Parameters:
      cacheCfg - Cache configuration.
      Returns:
      The Cache Adapter for the specifed cache, wrapped in a future.
    • cacheNames

      public CompletableFuture<Collection<String>> cacheNames()
      Returns the names of all the caches in the cluster.
      Returns:
      Collection holding all the caches names, wrapped in a future.
    • destroyCache

      public CompletableFuture<Void> destroyCache(String cacheName)
      Destroy the specifed cache.
      Parameters:
      cacheName - Cache name.
      Returns:
      A future signaling the completion of this operation.
    • destroyCache

      public CompletableFuture<Void> destroyCache(org.apache.ignite3.table.QualifiedName table)
      Destroy the specific table.
      Parameters:
      table - Table name.
      Returns:
      A future signaling the completion of this operation.
    • close

      public void close() throws Exception
      Throws:
      Exception
    • getLatestSchemaForTable

      public static CompletableFuture<org.apache.ignite3.internal.client.table.ClientSchema> getLatestSchemaForTable(org.apache.ignite3.internal.client.table.ClientTable clientTable)
      Retrieves the latest schema for the specified ClientTable.
      Parameters:
      clientTable - The client table.
      Returns:
      The latest client schema for the specified table.