Hi Ilya, hey Denis,

thank you both of you for taking a look into this problem.

How would you like get the reproducing stand-alone runnable?

I attached a single file which reproduces the problem.

Do you like to have it in any other way?


Some comments:
In this issue, it does not matter if the Transformer Class is a static member 
class or a separate class it self. Both produce the exception.

The Transformer (IgniteClosure) class works fine in a broadcast.

  // simple IgniteClosure broadcast
  ignite.compute().broadcast(new Transformer<>(), 
"broadcast").forEach(System.out::println);

and for a scanquery with transform from within remote job (like this broadcast)

  // broadcast which return the result the scanquery transform
  ignite.compute().broadcast(() -> {
    return cache.query(new ScanQuery<>(), new Transformer<>()).getAll();
  }).stream().flatMap(List::stream).forEach(System.out::println);

but does not work on the client side directly

  // does throw a ClassNotFound Exception about the Transformer Class.
  cache.query(new ScanQuery<>(), new 
Transformer<>()).getAll().forEach(System.out::println);


Thank you.

Let me know if I can do more to help you to find the problem.

Best,
Rafael




On 7/2/20 5:39 PM, Ilya Kasnacheev wrote:
> Hello!
> 
> I would like to start with a reproducer. Rafael, can you please throw
> together a runnable stand-alone reproducer of this issue?
> 
> Thanks,
> 

-- 
Rafael Troilo
HeiGIT gGmbH
Heidelberg Institute for Geoinformation Technology at Heidelberg University

https://heigit.org | rafael.tro...@heigit.org | phone +49-6221-533 484

Postal address: Schloss-Wolfsbrunnenweg 33 | 69118 Heidelberg | Germany
Offices: Berliner Str. 45 | 69120 Heidelberg | Germany

Amtsgericht Mannheim | HRB 733765
Managing Directors: Prof. Dr. Alexander Zipf | Dr. Gesa Schönberger
import java.util.Collections;
import java.util.List;
import javax.cache.Cache.Entry;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.ScanQuery;
import org.apache.ignite.lang.IgniteClosure;

public class ScanQueryWithTransform {
  private static final String cacheName = "ScanQueryTransformerIssue";

  public static void main(String[] args) {
    if(args.length == 0) {
      System.out.println("missing config file argument!");
      System.exit(1);
    }
    
    String cfg = args[0];
   
    Ignition.setClientMode(true);
    try(Ignite ignite = Ignition.start(cfg)){
      IgniteCache<Integer, String> cache = ignite.createCache(cacheName);
      for(int i=0; i < 5; i++) {
        // fill cache with some data
        cache.put(i,Integer.toBinaryString(i));
      }

// simple IgniteClosure broadcast
ignite.compute().broadcast(new Transformer<>(), "broadcast").forEach(System.out::println);
// broadcast which return the result the scanquery transform
ignite.compute().broadcast(() -> {
  return cache.query(new ScanQuery<>(), new Transformer<>()).getAll();
}).stream().flatMap(List::stream).forEach(System.out::println);
      
            
cache.query(new ScanQuery<>(), new Transformer<>()).getAll().forEach(System.out::println);

//      System.out.println("Scan Query!");
//      ScanQuery<Integer,String> qry = new ScanQuery<>();
//      try(QueryCursor<Entry<Integer, String>> cursor = cache.query(new ScanQuery<>(), new Transformer<>())){
//        // throws exception about ClassNotFound Transformer
//        cursor.getAll();
//      }catch(Exception e) {
//        e.printStackTrace();
//      }
      
      

      //clean up!
      ignite.destroyCache(cacheName);
    }
  }
  
  private static class Transformer<T> implements IgniteClosure<T,T> {
    private static final long serialVersionUID = 1L;

    @Override
    public T apply(T e) {
      return e;
    }
  }
}

Reply via email to