Search code examples
javaignite

How to use ignite data streamer with binary objects, data not loaded to cluster


I have a server cache based on Java Pojo.

IgniteCache<Long, Asset> assets

with config

 CacheConfiguration<Long, Asset> CACHE = new CacheConfiguration()
    .setName(Asset.NAME)
        .setCacheMode(CacheMode.PARTITIONED)
        .setBackups(0)
        .setStoreKeepBinary(true)
        .setIndexedTypes(Long.class, Asset.class);
  }

I would like to load data using a client-side streamer using BinaryObjects so I don't have a dependency on the Pojo -> Asset

There are no exceptions on the client-side but I don't see any data created on the cluster

    final IgniteDataStreamer<Long, BinaryObject> streamer = ignite.dataStreamer("Asset");
    streamer.perNodeBufferSize(10);
    streamer.allowOverwrite(false);
    streamer.keepBinary();

      long id = faker.random().nextLong(1000);
      BinaryObjectBuilder builder = binary.builder("Asset");

      builder.setField("id", id, Long.TYPE);
      builder.setField("name", "John Doe", String.class);
      builder.setField("timezone", TimeZone.getDefault(), TimeZone.class);
      final BinaryObject build = builder.build();
      streamer.addData(id, build);

No data is loaded to the cache.

is there a mismatch between the pojo and the binary object?

what am I doing wrong?

Note: Streaming with the real Asset object works fine.


Solution

  • You need to flush() the streamer. This would force it to send the queued data to the server. Worked in my reproducer.

    Alternatively, put more entries into the stream than the buffer size

    You can also set the auto flush frequency, forcing the streamer to flush on a set interval.