You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by David Li <da...@gmail.com> on 2017/03/30 09:19:42 UTC

ScanQuery With BinaryObject

Hello,

I am having a little issue with the ScanQuery for BinaryObject.

Some code snippets

IgniteCache<Long, Organization> cache = ignite.cache(CacheConfig.CACHE_NAME);
IgniteCache<Long, BinaryObject> binaryCache = cache.withKeepBinary();

// scan query
IgniteBiPredicate<Long, BinaryObject> filter = new
IgniteBiPredicate<Long, BinaryObject>() {
    @Override
    public boolean apply(Long key, BinaryObject value) {
        return false;
    }
};
ScanQuery<Long, BinaryObject> scanQuery = new ScanQuery<>(filter);

List<Cache.Entry<Long, BinaryObject>> result =
binaryCache.query(scanQuery).getAll();


I expect it will return an empty result, somehow it always returns
everything in the cache.

Not sure what is wrong?


BRs,

David

Re: ScanQuery With BinaryObject

Posted by Andrey Mashenkov <an...@gmail.com>.
Hi David,

Thanks for reproducer. I've create a ticket [1] for this bug.

[1] https://issues.apache.org/jira/browse/IGNITE-4918

On Wed, Apr 5, 2017 at 5:03 PM, Andrey Mashenkov <andrey.mashenkov@gmail.com
> wrote:

> I've creted a ticket [1].
>
> [1] https://issues.apache.org/jira/browse/IGNITE-4918
>
> On Wed, Apr 5, 2017 at 4:42 PM, Valentin Kulichenko <
> valentin.kulichenko@gmail.com> wrote:
>
>> Looks like a bug. Can you create a ticket?
>>
>> -Val
>>
>> On Wed, Apr 5, 2017 at 2:01 AM, Andrey Mashenkov <
>> andrey.mashenkov@gmail.com
>> > wrote:
>>
>> > To reproduce
>> > - start standalone server
>> > - run test, it should work fine.
>> > - run test with changed filter code, it will return same results.
>> >
>> >
>> > On Wed, Apr 5, 2017 at 11:40 AM, Valentin Kulichenko <
>> > valentin.kulichenko@gmail.com> wrote:
>> >
>> >> Can you provide the test?
>> >>
>> >> -Val
>> >>
>> >> On Wed, Apr 5, 2017 at 1:37 AM, Andrey Mashenkov <
>> >> andrey.mashenkov@gmail.com
>> >> > wrote:
>> >>
>> >> > Hi Val,
>> >> >
>> >> > I run test with no filter class in server classpath. I've got an
>> error
>> >> > wiith peerClassLoading disabled, which is ok as server can't
>> unmarshal
>> >> > filter object.
>> >> > But with peerClassLoading enabled, query works fine but looks like
>> >> filter
>> >> > class won't be updated on server.
>> >> >
>> >> > On Wed, Apr 5, 2017 at 11:14 AM, Valentin Kulichenko <
>> >> > valentin.kulichenko@gmail.com> wrote:
>> >> >
>> >> > > Andrey,
>> >> > >
>> >> > > Marshaller cache does not store classes, only class names. So I'm
>> not
>> >> > sure
>> >> > > what you mean by this.
>> >> > >
>> >> > > I looked at the code and it seems I was wrong - peer class loading
>> >> does
>> >> > > work for scan query filter, which is good. But as I mentioned
>> before,
>> >> if
>> >> > > the class is available on local classpath, it will never be
>> >> dynamically
>> >> > > loaded, even if peer class loading is enabled. Therefore server
>> will
>> >> not
>> >> > > know about any changes happening to the class definition on the
>> >> client.
>> >> > > This is correct behavior.
>> >> > >
>> >> > > -Val
>> >> > >
>> >> > > On Wed, Apr 5, 2017 at 12:01 AM, Andrey Mashenkov <
>> >> > > andrey.mashenkov@gmail.com> wrote:
>> >> > >
>> >> > > > Hi Val,
>> >> > > >
>> >> > > > Filter object serialized and send inside GridCacheQueryRequest,
>> and
>> >> > then
>> >> > > it
>> >> > > > is deserialized on server side and loaded by cache class loader.
>> >> > > > Looks like filter class is cached in marshaller cache.
>> >> > > >
>> >> > > >
>> >> > > > On Tue, Apr 4, 2017 at 4:43 PM, Valentin Kulichenko <
>> >> > > > valentin.kulichenko@gmail.com> wrote:
>> >> > > >
>> >> > > > > Andrey,
>> >> > > > >
>> >> > > > > To my knowledge, peer class loading is not supported for scan
>> >> query
>> >> > > > > filters, but I'm not sure though. Can you please check?
>> >> > > > >
>> >> > > > > Note that this actually doesn't matter if the class is
>> available
>> >> on
>> >> > > > > server's local classpath. In this case it will be always used
>> >> > > regardless
>> >> > > > of
>> >> > > > > any changes done on a client (i.e. will never be dynamically
>> >> loaded).
>> >> > > > This
>> >> > > > > is true for any functionality, including Compute Grid.
>> >> > > > >
>> >> > > > > -Val
>> >> > > > >
>> >> > > > > On Mon, Apr 3, 2017 at 10:19 AM, Andrey Mashenkov <
>> >> > > > > andrey.mashenkov@gmail.com> wrote:
>> >> > > > >
>> >> > > > > > Crossposted to dev:
>> >> > > > > >
>> >> > > > > > Guys,
>> >> > > > > >
>> >> > > > > > ScanQuery filter code (see IgniteBiPredicate implementation
>> >> below)
>> >> > > can
>> >> > > > be
>> >> > > > > > cached on server side
>> >> > > > > > that can cause unexpected results.
>> >> > > > > > The main point here is server node never restarts while
>> client
>> >> does
>> >> > > it
>> >> > > > > with
>> >> > > > > > filter code changed.
>> >> > > > > >
>> >> > > > > > Is it ok?
>> >> > > > > >
>> >> > > > > > I try to add *serialVersionUID* and it was useless. The only
>> >> class
>> >> > > > > renaming
>> >> > > > > > was helpful.
>> >> > > > > >
>> >> > > > > >
>> >> > > > > > ---------- Forwarded message ----------
>> >> > > > > > From: David Li <da...@gmail.com>
>> >> > > > > > Date: Mon, Apr 3, 2017 at 9:24 AM
>> >> > > > > > Subject: Re: ScanQuery With BinaryObject
>> >> > > > > > To: user@ignite.apache.org
>> >> > > > > >
>> >> > > > > >
>> >> > > > > > Sorry, please ignore the previous email, it was sent by
>> mistake.
>> >> > > > > >
>> >> > > > > > 1. I download apache-ignite-fabric-1.9.0-bin.zip, and unzip
>> it.
>> >> > > > > > 2. In terminal, I start an ignite instance by *bin/ignite.sh
>> >> > > > > > examples/config/example-ignite.xml*
>> >> > > > > > 3. I create a Java application, source code as below:
>> >> > > > > >
>> >> > > > > > public static void main(String[] args) {
>> >> > > > > >     String ORG_CACHE = "org_cache_remote";
>> >> > > > > >    * Ignition.setClientMode(true);*
>> >> > > > > >     Ignite ignite = Ignition.start("example-ignite.xml");
>> >> > > > > >     CacheConfiguration<Long, Organization> orgCacheCfg = new
>> >> > > > > > CacheConfiguration<>(ORG_CACHE);
>> >> > > > > >     orgCacheCfg.setIndexedTypes(Long.class,
>> >> Organization.class);
>> >> > > > > >     ignite.destroyCache(ORG_CACHE);
>> >> > > > > >     IgniteCache<Long, Organization> cache =
>> ignite.createCache(
>> >> > > > > > orgCacheCfg);
>> >> > > > > >     cache.put(1L, new Organization(1L, "org1", true, "jurong
>> >> east",
>> >> > > > > > "1111"));
>> >> > > > > >     cache.put(2L, new Organization(2L, "org2", false,
>> "orchard",
>> >> > > > > "2222"));
>> >> > > > > >     cache.put(3L, new Organization(3L, "org3", true, "jurong
>> >> west",
>> >> > > > > > "3333"));
>> >> > > > > >     cache.put(4L, new Organization(4L, "org4", false,
>> >> "woodlands",
>> >> > > > > > "4444"));
>> >> > > > > >     cache.put(5L, new Organization(5L, "org5", false,
>> "changi",
>> >> > > > "5555"));
>> >> > > > > >     // cache.put(6L, new Organization(6L, "org6", true,
>> "jurong
>> >> > > > island",
>> >> > > > > > "6666"));
>> >> > > > > >
>> >> > > > > >     IgniteCache<Long, BinaryObject> binaryCache =
>> >> > > > cache.withKeepBinary();
>> >> > > > > >
>> >> > > > > >     List<Cache.Entry<Long, BinaryObject>> result;
>> >> > > > > >
>> >> > > > > >     System.out.println("Scan by address");
>> >> > > > > >     ScanQuery<Long, BinaryObject> scanAddress = new
>> ScanQuery<>(
>> >> > > > > >         new IgniteBiPredicate<Long, BinaryObject>() {
>> >> > > > > >             @Override
>> >> > > > > >             public boolean apply(Long aLong, BinaryObject
>> >> > > > binaryObject) {
>> >> > > > > >                 *// first time filter by jurong, got two
>> >> entries,
>> >> > > org1
>> >> > > > > and
>> >> > > > > > org3*
>> >> > > > > > *                // second time filter by changi, got two
>> >> entries,
>> >> > > org1
>> >> > > > > and
>> >> > > > > > org3*
>> >> > > > > > *                // third time filter by changi as well,
>> >> uncomment
>> >> > > > org6,
>> >> > > > > > got three entries, org1, org3 and org6*
>> >> > > > > > *                return
>> >> > > > > > binaryObject.<String>field("address").startsWith("jurong");*
>> >> > > > > >             }
>> >> > > > > >         }
>> >> > > > > >     );
>> >> > > > > >     result = binaryCache.query(scanAddress).getAll();
>> >> > > > > >     System.out.println("result: " + result.size());
>> >> > > > > >     for (Cache.Entry<Long, BinaryObject> entry : result) {
>> >> > > > > >         System.out.println(entry.getValue().deserialize().
>> >> > > toString());
>> >> > > > > >     }
>> >> > > > > >
>> >> > > > > >     ignite.close();
>> >> > > > > > }
>> >> > > > > >
>> >> > > > > > Here what I want to do is start a client node, connect to the
>> >> > server
>> >> > > > node
>> >> > > > > > started in step 2. Then I create a cache, put some data
>> inside,
>> >> > > > > > then try to run a scan query to find entries by its address.
>> >> > > > > > The problem is when I run this program first time, it will
>> >> return
>> >> > two
>> >> > > > > > entries, their addresses are started with "jurong", which is
>> >> > correct.
>> >> > > > > > When I run the program again, with changed value, eg.
>> "changi",
>> >> it
>> >> > > > should
>> >> > > > > > return one entry, somehow, it still return two entries with
>> >> address
>> >> > > > > started
>> >> > > > > > with "jurong", rather than "changi".
>> >> > > > > > When I uncomment the line of "org6", and run the program
>> again,
>> >> it
>> >> > > will
>> >> > > > > > return three entries, all of their addresses are started with
>> >> > > "jurong".
>> >> > > > > >
>> >> > > > > > I have no idea what is going on.
>> >> > > > > >
>> >> > > > > >
>> >> > > > > >
>> >> > > > > >
>> >> > > > > >
>> >> > > > > > --
>> >> > > > > > Best regards,
>> >> > > > > > Andrey V. Mashenkov
>> >> > > > > >
>> >> > > > >
>> >> > > >
>> >> > > >
>> >> > > >
>> >> > > > --
>> >> > > > Best regards,
>> >> > > > Andrey V. Mashenkov
>> >> > > >
>> >> > >
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Best regards,
>> >> > Andrey V. Mashenkov
>> >> >
>> >>
>> >
>> >
>> >
>> > --
>> > Best regards,
>> > Andrey V. Mashenkov
>> >
>>
>
>
>
> --
> Best regards,
> Andrey V. Mashenkov
>



-- 
Best regards,
Andrey V. Mashenkov

Re: ScanQuery With BinaryObject

Posted by Andrey Mashenkov <an...@gmail.com>.
I've creted a ticket [1].

[1] https://issues.apache.org/jira/browse/IGNITE-4918

On Wed, Apr 5, 2017 at 4:42 PM, Valentin Kulichenko <
valentin.kulichenko@gmail.com> wrote:

> Looks like a bug. Can you create a ticket?
>
> -Val
>
> On Wed, Apr 5, 2017 at 2:01 AM, Andrey Mashenkov <
> andrey.mashenkov@gmail.com
> > wrote:
>
> > To reproduce
> > - start standalone server
> > - run test, it should work fine.
> > - run test with changed filter code, it will return same results.
> >
> >
> > On Wed, Apr 5, 2017 at 11:40 AM, Valentin Kulichenko <
> > valentin.kulichenko@gmail.com> wrote:
> >
> >> Can you provide the test?
> >>
> >> -Val
> >>
> >> On Wed, Apr 5, 2017 at 1:37 AM, Andrey Mashenkov <
> >> andrey.mashenkov@gmail.com
> >> > wrote:
> >>
> >> > Hi Val,
> >> >
> >> > I run test with no filter class in server classpath. I've got an error
> >> > wiith peerClassLoading disabled, which is ok as server can't unmarshal
> >> > filter object.
> >> > But with peerClassLoading enabled, query works fine but looks like
> >> filter
> >> > class won't be updated on server.
> >> >
> >> > On Wed, Apr 5, 2017 at 11:14 AM, Valentin Kulichenko <
> >> > valentin.kulichenko@gmail.com> wrote:
> >> >
> >> > > Andrey,
> >> > >
> >> > > Marshaller cache does not store classes, only class names. So I'm
> not
> >> > sure
> >> > > what you mean by this.
> >> > >
> >> > > I looked at the code and it seems I was wrong - peer class loading
> >> does
> >> > > work for scan query filter, which is good. But as I mentioned
> before,
> >> if
> >> > > the class is available on local classpath, it will never be
> >> dynamically
> >> > > loaded, even if peer class loading is enabled. Therefore server will
> >> not
> >> > > know about any changes happening to the class definition on the
> >> client.
> >> > > This is correct behavior.
> >> > >
> >> > > -Val
> >> > >
> >> > > On Wed, Apr 5, 2017 at 12:01 AM, Andrey Mashenkov <
> >> > > andrey.mashenkov@gmail.com> wrote:
> >> > >
> >> > > > Hi Val,
> >> > > >
> >> > > > Filter object serialized and send inside GridCacheQueryRequest,
> and
> >> > then
> >> > > it
> >> > > > is deserialized on server side and loaded by cache class loader.
> >> > > > Looks like filter class is cached in marshaller cache.
> >> > > >
> >> > > >
> >> > > > On Tue, Apr 4, 2017 at 4:43 PM, Valentin Kulichenko <
> >> > > > valentin.kulichenko@gmail.com> wrote:
> >> > > >
> >> > > > > Andrey,
> >> > > > >
> >> > > > > To my knowledge, peer class loading is not supported for scan
> >> query
> >> > > > > filters, but I'm not sure though. Can you please check?
> >> > > > >
> >> > > > > Note that this actually doesn't matter if the class is available
> >> on
> >> > > > > server's local classpath. In this case it will be always used
> >> > > regardless
> >> > > > of
> >> > > > > any changes done on a client (i.e. will never be dynamically
> >> loaded).
> >> > > > This
> >> > > > > is true for any functionality, including Compute Grid.
> >> > > > >
> >> > > > > -Val
> >> > > > >
> >> > > > > On Mon, Apr 3, 2017 at 10:19 AM, Andrey Mashenkov <
> >> > > > > andrey.mashenkov@gmail.com> wrote:
> >> > > > >
> >> > > > > > Crossposted to dev:
> >> > > > > >
> >> > > > > > Guys,
> >> > > > > >
> >> > > > > > ScanQuery filter code (see IgniteBiPredicate implementation
> >> below)
> >> > > can
> >> > > > be
> >> > > > > > cached on server side
> >> > > > > > that can cause unexpected results.
> >> > > > > > The main point here is server node never restarts while client
> >> does
> >> > > it
> >> > > > > with
> >> > > > > > filter code changed.
> >> > > > > >
> >> > > > > > Is it ok?
> >> > > > > >
> >> > > > > > I try to add *serialVersionUID* and it was useless. The only
> >> class
> >> > > > > renaming
> >> > > > > > was helpful.
> >> > > > > >
> >> > > > > >
> >> > > > > > ---------- Forwarded message ----------
> >> > > > > > From: David Li <da...@gmail.com>
> >> > > > > > Date: Mon, Apr 3, 2017 at 9:24 AM
> >> > > > > > Subject: Re: ScanQuery With BinaryObject
> >> > > > > > To: user@ignite.apache.org
> >> > > > > >
> >> > > > > >
> >> > > > > > Sorry, please ignore the previous email, it was sent by
> mistake.
> >> > > > > >
> >> > > > > > 1. I download apache-ignite-fabric-1.9.0-bin.zip, and unzip
> it.
> >> > > > > > 2. In terminal, I start an ignite instance by *bin/ignite.sh
> >> > > > > > examples/config/example-ignite.xml*
> >> > > > > > 3. I create a Java application, source code as below:
> >> > > > > >
> >> > > > > > public static void main(String[] args) {
> >> > > > > >     String ORG_CACHE = "org_cache_remote";
> >> > > > > >    * Ignition.setClientMode(true);*
> >> > > > > >     Ignite ignite = Ignition.start("example-ignite.xml");
> >> > > > > >     CacheConfiguration<Long, Organization> orgCacheCfg = new
> >> > > > > > CacheConfiguration<>(ORG_CACHE);
> >> > > > > >     orgCacheCfg.setIndexedTypes(Long.class,
> >> Organization.class);
> >> > > > > >     ignite.destroyCache(ORG_CACHE);
> >> > > > > >     IgniteCache<Long, Organization> cache =
> ignite.createCache(
> >> > > > > > orgCacheCfg);
> >> > > > > >     cache.put(1L, new Organization(1L, "org1", true, "jurong
> >> east",
> >> > > > > > "1111"));
> >> > > > > >     cache.put(2L, new Organization(2L, "org2", false,
> "orchard",
> >> > > > > "2222"));
> >> > > > > >     cache.put(3L, new Organization(3L, "org3", true, "jurong
> >> west",
> >> > > > > > "3333"));
> >> > > > > >     cache.put(4L, new Organization(4L, "org4", false,
> >> "woodlands",
> >> > > > > > "4444"));
> >> > > > > >     cache.put(5L, new Organization(5L, "org5", false,
> "changi",
> >> > > > "5555"));
> >> > > > > >     // cache.put(6L, new Organization(6L, "org6", true,
> "jurong
> >> > > > island",
> >> > > > > > "6666"));
> >> > > > > >
> >> > > > > >     IgniteCache<Long, BinaryObject> binaryCache =
> >> > > > cache.withKeepBinary();
> >> > > > > >
> >> > > > > >     List<Cache.Entry<Long, BinaryObject>> result;
> >> > > > > >
> >> > > > > >     System.out.println("Scan by address");
> >> > > > > >     ScanQuery<Long, BinaryObject> scanAddress = new
> ScanQuery<>(
> >> > > > > >         new IgniteBiPredicate<Long, BinaryObject>() {
> >> > > > > >             @Override
> >> > > > > >             public boolean apply(Long aLong, BinaryObject
> >> > > > binaryObject) {
> >> > > > > >                 *// first time filter by jurong, got two
> >> entries,
> >> > > org1
> >> > > > > and
> >> > > > > > org3*
> >> > > > > > *                // second time filter by changi, got two
> >> entries,
> >> > > org1
> >> > > > > and
> >> > > > > > org3*
> >> > > > > > *                // third time filter by changi as well,
> >> uncomment
> >> > > > org6,
> >> > > > > > got three entries, org1, org3 and org6*
> >> > > > > > *                return
> >> > > > > > binaryObject.<String>field("address").startsWith("jurong");*
> >> > > > > >             }
> >> > > > > >         }
> >> > > > > >     );
> >> > > > > >     result = binaryCache.query(scanAddress).getAll();
> >> > > > > >     System.out.println("result: " + result.size());
> >> > > > > >     for (Cache.Entry<Long, BinaryObject> entry : result) {
> >> > > > > >         System.out.println(entry.getValue().deserialize().
> >> > > toString());
> >> > > > > >     }
> >> > > > > >
> >> > > > > >     ignite.close();
> >> > > > > > }
> >> > > > > >
> >> > > > > > Here what I want to do is start a client node, connect to the
> >> > server
> >> > > > node
> >> > > > > > started in step 2. Then I create a cache, put some data
> inside,
> >> > > > > > then try to run a scan query to find entries by its address.
> >> > > > > > The problem is when I run this program first time, it will
> >> return
> >> > two
> >> > > > > > entries, their addresses are started with "jurong", which is
> >> > correct.
> >> > > > > > When I run the program again, with changed value, eg.
> "changi",
> >> it
> >> > > > should
> >> > > > > > return one entry, somehow, it still return two entries with
> >> address
> >> > > > > started
> >> > > > > > with "jurong", rather than "changi".
> >> > > > > > When I uncomment the line of "org6", and run the program
> again,
> >> it
> >> > > will
> >> > > > > > return three entries, all of their addresses are started with
> >> > > "jurong".
> >> > > > > >
> >> > > > > > I have no idea what is going on.
> >> > > > > >
> >> > > > > >
> >> > > > > >
> >> > > > > >
> >> > > > > >
> >> > > > > > --
> >> > > > > > Best regards,
> >> > > > > > Andrey V. Mashenkov
> >> > > > > >
> >> > > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > > --
> >> > > > Best regards,
> >> > > > Andrey V. Mashenkov
> >> > > >
> >> > >
> >> >
> >> >
> >> >
> >> > --
> >> > Best regards,
> >> > Andrey V. Mashenkov
> >> >
> >>
> >
> >
> >
> > --
> > Best regards,
> > Andrey V. Mashenkov
> >
>



-- 
Best regards,
Andrey V. Mashenkov

Re: ScanQuery With BinaryObject

Posted by Valentin Kulichenko <va...@gmail.com>.
Looks like a bug. Can you create a ticket?

-Val

On Wed, Apr 5, 2017 at 2:01 AM, Andrey Mashenkov <andrey.mashenkov@gmail.com
> wrote:

> To reproduce
> - start standalone server
> - run test, it should work fine.
> - run test with changed filter code, it will return same results.
>
>
> On Wed, Apr 5, 2017 at 11:40 AM, Valentin Kulichenko <
> valentin.kulichenko@gmail.com> wrote:
>
>> Can you provide the test?
>>
>> -Val
>>
>> On Wed, Apr 5, 2017 at 1:37 AM, Andrey Mashenkov <
>> andrey.mashenkov@gmail.com
>> > wrote:
>>
>> > Hi Val,
>> >
>> > I run test with no filter class in server classpath. I've got an error
>> > wiith peerClassLoading disabled, which is ok as server can't unmarshal
>> > filter object.
>> > But with peerClassLoading enabled, query works fine but looks like
>> filter
>> > class won't be updated on server.
>> >
>> > On Wed, Apr 5, 2017 at 11:14 AM, Valentin Kulichenko <
>> > valentin.kulichenko@gmail.com> wrote:
>> >
>> > > Andrey,
>> > >
>> > > Marshaller cache does not store classes, only class names. So I'm not
>> > sure
>> > > what you mean by this.
>> > >
>> > > I looked at the code and it seems I was wrong - peer class loading
>> does
>> > > work for scan query filter, which is good. But as I mentioned before,
>> if
>> > > the class is available on local classpath, it will never be
>> dynamically
>> > > loaded, even if peer class loading is enabled. Therefore server will
>> not
>> > > know about any changes happening to the class definition on the
>> client.
>> > > This is correct behavior.
>> > >
>> > > -Val
>> > >
>> > > On Wed, Apr 5, 2017 at 12:01 AM, Andrey Mashenkov <
>> > > andrey.mashenkov@gmail.com> wrote:
>> > >
>> > > > Hi Val,
>> > > >
>> > > > Filter object serialized and send inside GridCacheQueryRequest, and
>> > then
>> > > it
>> > > > is deserialized on server side and loaded by cache class loader.
>> > > > Looks like filter class is cached in marshaller cache.
>> > > >
>> > > >
>> > > > On Tue, Apr 4, 2017 at 4:43 PM, Valentin Kulichenko <
>> > > > valentin.kulichenko@gmail.com> wrote:
>> > > >
>> > > > > Andrey,
>> > > > >
>> > > > > To my knowledge, peer class loading is not supported for scan
>> query
>> > > > > filters, but I'm not sure though. Can you please check?
>> > > > >
>> > > > > Note that this actually doesn't matter if the class is available
>> on
>> > > > > server's local classpath. In this case it will be always used
>> > > regardless
>> > > > of
>> > > > > any changes done on a client (i.e. will never be dynamically
>> loaded).
>> > > > This
>> > > > > is true for any functionality, including Compute Grid.
>> > > > >
>> > > > > -Val
>> > > > >
>> > > > > On Mon, Apr 3, 2017 at 10:19 AM, Andrey Mashenkov <
>> > > > > andrey.mashenkov@gmail.com> wrote:
>> > > > >
>> > > > > > Crossposted to dev:
>> > > > > >
>> > > > > > Guys,
>> > > > > >
>> > > > > > ScanQuery filter code (see IgniteBiPredicate implementation
>> below)
>> > > can
>> > > > be
>> > > > > > cached on server side
>> > > > > > that can cause unexpected results.
>> > > > > > The main point here is server node never restarts while client
>> does
>> > > it
>> > > > > with
>> > > > > > filter code changed.
>> > > > > >
>> > > > > > Is it ok?
>> > > > > >
>> > > > > > I try to add *serialVersionUID* and it was useless. The only
>> class
>> > > > > renaming
>> > > > > > was helpful.
>> > > > > >
>> > > > > >
>> > > > > > ---------- Forwarded message ----------
>> > > > > > From: David Li <da...@gmail.com>
>> > > > > > Date: Mon, Apr 3, 2017 at 9:24 AM
>> > > > > > Subject: Re: ScanQuery With BinaryObject
>> > > > > > To: user@ignite.apache.org
>> > > > > >
>> > > > > >
>> > > > > > Sorry, please ignore the previous email, it was sent by mistake.
>> > > > > >
>> > > > > > 1. I download apache-ignite-fabric-1.9.0-bin.zip, and unzip it.
>> > > > > > 2. In terminal, I start an ignite instance by *bin/ignite.sh
>> > > > > > examples/config/example-ignite.xml*
>> > > > > > 3. I create a Java application, source code as below:
>> > > > > >
>> > > > > > public static void main(String[] args) {
>> > > > > >     String ORG_CACHE = "org_cache_remote";
>> > > > > >    * Ignition.setClientMode(true);*
>> > > > > >     Ignite ignite = Ignition.start("example-ignite.xml");
>> > > > > >     CacheConfiguration<Long, Organization> orgCacheCfg = new
>> > > > > > CacheConfiguration<>(ORG_CACHE);
>> > > > > >     orgCacheCfg.setIndexedTypes(Long.class,
>> Organization.class);
>> > > > > >     ignite.destroyCache(ORG_CACHE);
>> > > > > >     IgniteCache<Long, Organization> cache = ignite.createCache(
>> > > > > > orgCacheCfg);
>> > > > > >     cache.put(1L, new Organization(1L, "org1", true, "jurong
>> east",
>> > > > > > "1111"));
>> > > > > >     cache.put(2L, new Organization(2L, "org2", false, "orchard",
>> > > > > "2222"));
>> > > > > >     cache.put(3L, new Organization(3L, "org3", true, "jurong
>> west",
>> > > > > > "3333"));
>> > > > > >     cache.put(4L, new Organization(4L, "org4", false,
>> "woodlands",
>> > > > > > "4444"));
>> > > > > >     cache.put(5L, new Organization(5L, "org5", false, "changi",
>> > > > "5555"));
>> > > > > >     // cache.put(6L, new Organization(6L, "org6", true, "jurong
>> > > > island",
>> > > > > > "6666"));
>> > > > > >
>> > > > > >     IgniteCache<Long, BinaryObject> binaryCache =
>> > > > cache.withKeepBinary();
>> > > > > >
>> > > > > >     List<Cache.Entry<Long, BinaryObject>> result;
>> > > > > >
>> > > > > >     System.out.println("Scan by address");
>> > > > > >     ScanQuery<Long, BinaryObject> scanAddress = new ScanQuery<>(
>> > > > > >         new IgniteBiPredicate<Long, BinaryObject>() {
>> > > > > >             @Override
>> > > > > >             public boolean apply(Long aLong, BinaryObject
>> > > > binaryObject) {
>> > > > > >                 *// first time filter by jurong, got two
>> entries,
>> > > org1
>> > > > > and
>> > > > > > org3*
>> > > > > > *                // second time filter by changi, got two
>> entries,
>> > > org1
>> > > > > and
>> > > > > > org3*
>> > > > > > *                // third time filter by changi as well,
>> uncomment
>> > > > org6,
>> > > > > > got three entries, org1, org3 and org6*
>> > > > > > *                return
>> > > > > > binaryObject.<String>field("address").startsWith("jurong");*
>> > > > > >             }
>> > > > > >         }
>> > > > > >     );
>> > > > > >     result = binaryCache.query(scanAddress).getAll();
>> > > > > >     System.out.println("result: " + result.size());
>> > > > > >     for (Cache.Entry<Long, BinaryObject> entry : result) {
>> > > > > >         System.out.println(entry.getValue().deserialize().
>> > > toString());
>> > > > > >     }
>> > > > > >
>> > > > > >     ignite.close();
>> > > > > > }
>> > > > > >
>> > > > > > Here what I want to do is start a client node, connect to the
>> > server
>> > > > node
>> > > > > > started in step 2. Then I create a cache, put some data inside,
>> > > > > > then try to run a scan query to find entries by its address.
>> > > > > > The problem is when I run this program first time, it will
>> return
>> > two
>> > > > > > entries, their addresses are started with "jurong", which is
>> > correct.
>> > > > > > When I run the program again, with changed value, eg. "changi",
>> it
>> > > > should
>> > > > > > return one entry, somehow, it still return two entries with
>> address
>> > > > > started
>> > > > > > with "jurong", rather than "changi".
>> > > > > > When I uncomment the line of "org6", and run the program again,
>> it
>> > > will
>> > > > > > return three entries, all of their addresses are started with
>> > > "jurong".
>> > > > > >
>> > > > > > I have no idea what is going on.
>> > > > > >
>> > > > > >
>> > > > > >
>> > > > > >
>> > > > > >
>> > > > > > --
>> > > > > > Best regards,
>> > > > > > Andrey V. Mashenkov
>> > > > > >
>> > > > >
>> > > >
>> > > >
>> > > >
>> > > > --
>> > > > Best regards,
>> > > > Andrey V. Mashenkov
>> > > >
>> > >
>> >
>> >
>> >
>> > --
>> > Best regards,
>> > Andrey V. Mashenkov
>> >
>>
>
>
>
> --
> Best regards,
> Andrey V. Mashenkov
>

Re: ScanQuery With BinaryObject

Posted by Andrey Mashenkov <an...@gmail.com>.
To reproduce
- start standalone server
- run test, it should work fine.
- run test with changed filter code, it will return same results.


On Wed, Apr 5, 2017 at 11:40 AM, Valentin Kulichenko <
valentin.kulichenko@gmail.com> wrote:

> Can you provide the test?
>
> -Val
>
> On Wed, Apr 5, 2017 at 1:37 AM, Andrey Mashenkov <
> andrey.mashenkov@gmail.com
> > wrote:
>
> > Hi Val,
> >
> > I run test with no filter class in server classpath. I've got an error
> > wiith peerClassLoading disabled, which is ok as server can't unmarshal
> > filter object.
> > But with peerClassLoading enabled, query works fine but looks like filter
> > class won't be updated on server.
> >
> > On Wed, Apr 5, 2017 at 11:14 AM, Valentin Kulichenko <
> > valentin.kulichenko@gmail.com> wrote:
> >
> > > Andrey,
> > >
> > > Marshaller cache does not store classes, only class names. So I'm not
> > sure
> > > what you mean by this.
> > >
> > > I looked at the code and it seems I was wrong - peer class loading does
> > > work for scan query filter, which is good. But as I mentioned before,
> if
> > > the class is available on local classpath, it will never be dynamically
> > > loaded, even if peer class loading is enabled. Therefore server will
> not
> > > know about any changes happening to the class definition on the client.
> > > This is correct behavior.
> > >
> > > -Val
> > >
> > > On Wed, Apr 5, 2017 at 12:01 AM, Andrey Mashenkov <
> > > andrey.mashenkov@gmail.com> wrote:
> > >
> > > > Hi Val,
> > > >
> > > > Filter object serialized and send inside GridCacheQueryRequest, and
> > then
> > > it
> > > > is deserialized on server side and loaded by cache class loader.
> > > > Looks like filter class is cached in marshaller cache.
> > > >
> > > >
> > > > On Tue, Apr 4, 2017 at 4:43 PM, Valentin Kulichenko <
> > > > valentin.kulichenko@gmail.com> wrote:
> > > >
> > > > > Andrey,
> > > > >
> > > > > To my knowledge, peer class loading is not supported for scan query
> > > > > filters, but I'm not sure though. Can you please check?
> > > > >
> > > > > Note that this actually doesn't matter if the class is available on
> > > > > server's local classpath. In this case it will be always used
> > > regardless
> > > > of
> > > > > any changes done on a client (i.e. will never be dynamically
> loaded).
> > > > This
> > > > > is true for any functionality, including Compute Grid.
> > > > >
> > > > > -Val
> > > > >
> > > > > On Mon, Apr 3, 2017 at 10:19 AM, Andrey Mashenkov <
> > > > > andrey.mashenkov@gmail.com> wrote:
> > > > >
> > > > > > Crossposted to dev:
> > > > > >
> > > > > > Guys,
> > > > > >
> > > > > > ScanQuery filter code (see IgniteBiPredicate implementation
> below)
> > > can
> > > > be
> > > > > > cached on server side
> > > > > > that can cause unexpected results.
> > > > > > The main point here is server node never restarts while client
> does
> > > it
> > > > > with
> > > > > > filter code changed.
> > > > > >
> > > > > > Is it ok?
> > > > > >
> > > > > > I try to add *serialVersionUID* and it was useless. The only
> class
> > > > > renaming
> > > > > > was helpful.
> > > > > >
> > > > > >
> > > > > > ---------- Forwarded message ----------
> > > > > > From: David Li <da...@gmail.com>
> > > > > > Date: Mon, Apr 3, 2017 at 9:24 AM
> > > > > > Subject: Re: ScanQuery With BinaryObject
> > > > > > To: user@ignite.apache.org
> > > > > >
> > > > > >
> > > > > > Sorry, please ignore the previous email, it was sent by mistake.
> > > > > >
> > > > > > 1. I download apache-ignite-fabric-1.9.0-bin.zip, and unzip it.
> > > > > > 2. In terminal, I start an ignite instance by *bin/ignite.sh
> > > > > > examples/config/example-ignite.xml*
> > > > > > 3. I create a Java application, source code as below:
> > > > > >
> > > > > > public static void main(String[] args) {
> > > > > >     String ORG_CACHE = "org_cache_remote";
> > > > > >    * Ignition.setClientMode(true);*
> > > > > >     Ignite ignite = Ignition.start("example-ignite.xml");
> > > > > >     CacheConfiguration<Long, Organization> orgCacheCfg = new
> > > > > > CacheConfiguration<>(ORG_CACHE);
> > > > > >     orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
> > > > > >     ignite.destroyCache(ORG_CACHE);
> > > > > >     IgniteCache<Long, Organization> cache = ignite.createCache(
> > > > > > orgCacheCfg);
> > > > > >     cache.put(1L, new Organization(1L, "org1", true, "jurong
> east",
> > > > > > "1111"));
> > > > > >     cache.put(2L, new Organization(2L, "org2", false, "orchard",
> > > > > "2222"));
> > > > > >     cache.put(3L, new Organization(3L, "org3", true, "jurong
> west",
> > > > > > "3333"));
> > > > > >     cache.put(4L, new Organization(4L, "org4", false,
> "woodlands",
> > > > > > "4444"));
> > > > > >     cache.put(5L, new Organization(5L, "org5", false, "changi",
> > > > "5555"));
> > > > > >     // cache.put(6L, new Organization(6L, "org6", true, "jurong
> > > > island",
> > > > > > "6666"));
> > > > > >
> > > > > >     IgniteCache<Long, BinaryObject> binaryCache =
> > > > cache.withKeepBinary();
> > > > > >
> > > > > >     List<Cache.Entry<Long, BinaryObject>> result;
> > > > > >
> > > > > >     System.out.println("Scan by address");
> > > > > >     ScanQuery<Long, BinaryObject> scanAddress = new ScanQuery<>(
> > > > > >         new IgniteBiPredicate<Long, BinaryObject>() {
> > > > > >             @Override
> > > > > >             public boolean apply(Long aLong, BinaryObject
> > > > binaryObject) {
> > > > > >                 *// first time filter by jurong, got two entries,
> > > org1
> > > > > and
> > > > > > org3*
> > > > > > *                // second time filter by changi, got two
> entries,
> > > org1
> > > > > and
> > > > > > org3*
> > > > > > *                // third time filter by changi as well,
> uncomment
> > > > org6,
> > > > > > got three entries, org1, org3 and org6*
> > > > > > *                return
> > > > > > binaryObject.<String>field("address").startsWith("jurong");*
> > > > > >             }
> > > > > >         }
> > > > > >     );
> > > > > >     result = binaryCache.query(scanAddress).getAll();
> > > > > >     System.out.println("result: " + result.size());
> > > > > >     for (Cache.Entry<Long, BinaryObject> entry : result) {
> > > > > >         System.out.println(entry.getValue().deserialize().
> > > toString());
> > > > > >     }
> > > > > >
> > > > > >     ignite.close();
> > > > > > }
> > > > > >
> > > > > > Here what I want to do is start a client node, connect to the
> > server
> > > > node
> > > > > > started in step 2. Then I create a cache, put some data inside,
> > > > > > then try to run a scan query to find entries by its address.
> > > > > > The problem is when I run this program first time, it will return
> > two
> > > > > > entries, their addresses are started with "jurong", which is
> > correct.
> > > > > > When I run the program again, with changed value, eg. "changi",
> it
> > > > should
> > > > > > return one entry, somehow, it still return two entries with
> address
> > > > > started
> > > > > > with "jurong", rather than "changi".
> > > > > > When I uncomment the line of "org6", and run the program again,
> it
> > > will
> > > > > > return three entries, all of their addresses are started with
> > > "jurong".
> > > > > >
> > > > > > I have no idea what is going on.
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Best regards,
> > > > > > Andrey V. Mashenkov
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Best regards,
> > > > Andrey V. Mashenkov
> > > >
> > >
> >
> >
> >
> > --
> > Best regards,
> > Andrey V. Mashenkov
> >
>



-- 
Best regards,
Andrey V. Mashenkov

Re: ScanQuery With BinaryObject

Posted by Valentin Kulichenko <va...@gmail.com>.
Can you provide the test?

-Val

On Wed, Apr 5, 2017 at 1:37 AM, Andrey Mashenkov <andrey.mashenkov@gmail.com
> wrote:

> Hi Val,
>
> I run test with no filter class in server classpath. I've got an error
> wiith peerClassLoading disabled, which is ok as server can't unmarshal
> filter object.
> But with peerClassLoading enabled, query works fine but looks like filter
> class won't be updated on server.
>
> On Wed, Apr 5, 2017 at 11:14 AM, Valentin Kulichenko <
> valentin.kulichenko@gmail.com> wrote:
>
> > Andrey,
> >
> > Marshaller cache does not store classes, only class names. So I'm not
> sure
> > what you mean by this.
> >
> > I looked at the code and it seems I was wrong - peer class loading does
> > work for scan query filter, which is good. But as I mentioned before, if
> > the class is available on local classpath, it will never be dynamically
> > loaded, even if peer class loading is enabled. Therefore server will not
> > know about any changes happening to the class definition on the client.
> > This is correct behavior.
> >
> > -Val
> >
> > On Wed, Apr 5, 2017 at 12:01 AM, Andrey Mashenkov <
> > andrey.mashenkov@gmail.com> wrote:
> >
> > > Hi Val,
> > >
> > > Filter object serialized and send inside GridCacheQueryRequest, and
> then
> > it
> > > is deserialized on server side and loaded by cache class loader.
> > > Looks like filter class is cached in marshaller cache.
> > >
> > >
> > > On Tue, Apr 4, 2017 at 4:43 PM, Valentin Kulichenko <
> > > valentin.kulichenko@gmail.com> wrote:
> > >
> > > > Andrey,
> > > >
> > > > To my knowledge, peer class loading is not supported for scan query
> > > > filters, but I'm not sure though. Can you please check?
> > > >
> > > > Note that this actually doesn't matter if the class is available on
> > > > server's local classpath. In this case it will be always used
> > regardless
> > > of
> > > > any changes done on a client (i.e. will never be dynamically loaded).
> > > This
> > > > is true for any functionality, including Compute Grid.
> > > >
> > > > -Val
> > > >
> > > > On Mon, Apr 3, 2017 at 10:19 AM, Andrey Mashenkov <
> > > > andrey.mashenkov@gmail.com> wrote:
> > > >
> > > > > Crossposted to dev:
> > > > >
> > > > > Guys,
> > > > >
> > > > > ScanQuery filter code (see IgniteBiPredicate implementation below)
> > can
> > > be
> > > > > cached on server side
> > > > > that can cause unexpected results.
> > > > > The main point here is server node never restarts while client does
> > it
> > > > with
> > > > > filter code changed.
> > > > >
> > > > > Is it ok?
> > > > >
> > > > > I try to add *serialVersionUID* and it was useless. The only class
> > > > renaming
> > > > > was helpful.
> > > > >
> > > > >
> > > > > ---------- Forwarded message ----------
> > > > > From: David Li <da...@gmail.com>
> > > > > Date: Mon, Apr 3, 2017 at 9:24 AM
> > > > > Subject: Re: ScanQuery With BinaryObject
> > > > > To: user@ignite.apache.org
> > > > >
> > > > >
> > > > > Sorry, please ignore the previous email, it was sent by mistake.
> > > > >
> > > > > 1. I download apache-ignite-fabric-1.9.0-bin.zip, and unzip it.
> > > > > 2. In terminal, I start an ignite instance by *bin/ignite.sh
> > > > > examples/config/example-ignite.xml*
> > > > > 3. I create a Java application, source code as below:
> > > > >
> > > > > public static void main(String[] args) {
> > > > >     String ORG_CACHE = "org_cache_remote";
> > > > >    * Ignition.setClientMode(true);*
> > > > >     Ignite ignite = Ignition.start("example-ignite.xml");
> > > > >     CacheConfiguration<Long, Organization> orgCacheCfg = new
> > > > > CacheConfiguration<>(ORG_CACHE);
> > > > >     orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
> > > > >     ignite.destroyCache(ORG_CACHE);
> > > > >     IgniteCache<Long, Organization> cache = ignite.createCache(
> > > > > orgCacheCfg);
> > > > >     cache.put(1L, new Organization(1L, "org1", true, "jurong east",
> > > > > "1111"));
> > > > >     cache.put(2L, new Organization(2L, "org2", false, "orchard",
> > > > "2222"));
> > > > >     cache.put(3L, new Organization(3L, "org3", true, "jurong west",
> > > > > "3333"));
> > > > >     cache.put(4L, new Organization(4L, "org4", false, "woodlands",
> > > > > "4444"));
> > > > >     cache.put(5L, new Organization(5L, "org5", false, "changi",
> > > "5555"));
> > > > >     // cache.put(6L, new Organization(6L, "org6", true, "jurong
> > > island",
> > > > > "6666"));
> > > > >
> > > > >     IgniteCache<Long, BinaryObject> binaryCache =
> > > cache.withKeepBinary();
> > > > >
> > > > >     List<Cache.Entry<Long, BinaryObject>> result;
> > > > >
> > > > >     System.out.println("Scan by address");
> > > > >     ScanQuery<Long, BinaryObject> scanAddress = new ScanQuery<>(
> > > > >         new IgniteBiPredicate<Long, BinaryObject>() {
> > > > >             @Override
> > > > >             public boolean apply(Long aLong, BinaryObject
> > > binaryObject) {
> > > > >                 *// first time filter by jurong, got two entries,
> > org1
> > > > and
> > > > > org3*
> > > > > *                // second time filter by changi, got two entries,
> > org1
> > > > and
> > > > > org3*
> > > > > *                // third time filter by changi as well, uncomment
> > > org6,
> > > > > got three entries, org1, org3 and org6*
> > > > > *                return
> > > > > binaryObject.<String>field("address").startsWith("jurong");*
> > > > >             }
> > > > >         }
> > > > >     );
> > > > >     result = binaryCache.query(scanAddress).getAll();
> > > > >     System.out.println("result: " + result.size());
> > > > >     for (Cache.Entry<Long, BinaryObject> entry : result) {
> > > > >         System.out.println(entry.getValue().deserialize().
> > toString());
> > > > >     }
> > > > >
> > > > >     ignite.close();
> > > > > }
> > > > >
> > > > > Here what I want to do is start a client node, connect to the
> server
> > > node
> > > > > started in step 2. Then I create a cache, put some data inside,
> > > > > then try to run a scan query to find entries by its address.
> > > > > The problem is when I run this program first time, it will return
> two
> > > > > entries, their addresses are started with "jurong", which is
> correct.
> > > > > When I run the program again, with changed value, eg. "changi", it
> > > should
> > > > > return one entry, somehow, it still return two entries with address
> > > > started
> > > > > with "jurong", rather than "changi".
> > > > > When I uncomment the line of "org6", and run the program again, it
> > will
> > > > > return three entries, all of their addresses are started with
> > "jurong".
> > > > >
> > > > > I have no idea what is going on.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Best regards,
> > > > > Andrey V. Mashenkov
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Best regards,
> > > Andrey V. Mashenkov
> > >
> >
>
>
>
> --
> Best regards,
> Andrey V. Mashenkov
>

Re: ScanQuery With BinaryObject

Posted by Andrey Mashenkov <an...@gmail.com>.
Hi Val,

I run test with no filter class in server classpath. I've got an error
wiith peerClassLoading disabled, which is ok as server can't unmarshal
filter object.
But with peerClassLoading enabled, query works fine but looks like filter
class won't be updated on server.

On Wed, Apr 5, 2017 at 11:14 AM, Valentin Kulichenko <
valentin.kulichenko@gmail.com> wrote:

> Andrey,
>
> Marshaller cache does not store classes, only class names. So I'm not sure
> what you mean by this.
>
> I looked at the code and it seems I was wrong - peer class loading does
> work for scan query filter, which is good. But as I mentioned before, if
> the class is available on local classpath, it will never be dynamically
> loaded, even if peer class loading is enabled. Therefore server will not
> know about any changes happening to the class definition on the client.
> This is correct behavior.
>
> -Val
>
> On Wed, Apr 5, 2017 at 12:01 AM, Andrey Mashenkov <
> andrey.mashenkov@gmail.com> wrote:
>
> > Hi Val,
> >
> > Filter object serialized and send inside GridCacheQueryRequest, and then
> it
> > is deserialized on server side and loaded by cache class loader.
> > Looks like filter class is cached in marshaller cache.
> >
> >
> > On Tue, Apr 4, 2017 at 4:43 PM, Valentin Kulichenko <
> > valentin.kulichenko@gmail.com> wrote:
> >
> > > Andrey,
> > >
> > > To my knowledge, peer class loading is not supported for scan query
> > > filters, but I'm not sure though. Can you please check?
> > >
> > > Note that this actually doesn't matter if the class is available on
> > > server's local classpath. In this case it will be always used
> regardless
> > of
> > > any changes done on a client (i.e. will never be dynamically loaded).
> > This
> > > is true for any functionality, including Compute Grid.
> > >
> > > -Val
> > >
> > > On Mon, Apr 3, 2017 at 10:19 AM, Andrey Mashenkov <
> > > andrey.mashenkov@gmail.com> wrote:
> > >
> > > > Crossposted to dev:
> > > >
> > > > Guys,
> > > >
> > > > ScanQuery filter code (see IgniteBiPredicate implementation below)
> can
> > be
> > > > cached on server side
> > > > that can cause unexpected results.
> > > > The main point here is server node never restarts while client does
> it
> > > with
> > > > filter code changed.
> > > >
> > > > Is it ok?
> > > >
> > > > I try to add *serialVersionUID* and it was useless. The only class
> > > renaming
> > > > was helpful.
> > > >
> > > >
> > > > ---------- Forwarded message ----------
> > > > From: David Li <da...@gmail.com>
> > > > Date: Mon, Apr 3, 2017 at 9:24 AM
> > > > Subject: Re: ScanQuery With BinaryObject
> > > > To: user@ignite.apache.org
> > > >
> > > >
> > > > Sorry, please ignore the previous email, it was sent by mistake.
> > > >
> > > > 1. I download apache-ignite-fabric-1.9.0-bin.zip, and unzip it.
> > > > 2. In terminal, I start an ignite instance by *bin/ignite.sh
> > > > examples/config/example-ignite.xml*
> > > > 3. I create a Java application, source code as below:
> > > >
> > > > public static void main(String[] args) {
> > > >     String ORG_CACHE = "org_cache_remote";
> > > >    * Ignition.setClientMode(true);*
> > > >     Ignite ignite = Ignition.start("example-ignite.xml");
> > > >     CacheConfiguration<Long, Organization> orgCacheCfg = new
> > > > CacheConfiguration<>(ORG_CACHE);
> > > >     orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
> > > >     ignite.destroyCache(ORG_CACHE);
> > > >     IgniteCache<Long, Organization> cache = ignite.createCache(
> > > > orgCacheCfg);
> > > >     cache.put(1L, new Organization(1L, "org1", true, "jurong east",
> > > > "1111"));
> > > >     cache.put(2L, new Organization(2L, "org2", false, "orchard",
> > > "2222"));
> > > >     cache.put(3L, new Organization(3L, "org3", true, "jurong west",
> > > > "3333"));
> > > >     cache.put(4L, new Organization(4L, "org4", false, "woodlands",
> > > > "4444"));
> > > >     cache.put(5L, new Organization(5L, "org5", false, "changi",
> > "5555"));
> > > >     // cache.put(6L, new Organization(6L, "org6", true, "jurong
> > island",
> > > > "6666"));
> > > >
> > > >     IgniteCache<Long, BinaryObject> binaryCache =
> > cache.withKeepBinary();
> > > >
> > > >     List<Cache.Entry<Long, BinaryObject>> result;
> > > >
> > > >     System.out.println("Scan by address");
> > > >     ScanQuery<Long, BinaryObject> scanAddress = new ScanQuery<>(
> > > >         new IgniteBiPredicate<Long, BinaryObject>() {
> > > >             @Override
> > > >             public boolean apply(Long aLong, BinaryObject
> > binaryObject) {
> > > >                 *// first time filter by jurong, got two entries,
> org1
> > > and
> > > > org3*
> > > > *                // second time filter by changi, got two entries,
> org1
> > > and
> > > > org3*
> > > > *                // third time filter by changi as well, uncomment
> > org6,
> > > > got three entries, org1, org3 and org6*
> > > > *                return
> > > > binaryObject.<String>field("address").startsWith("jurong");*
> > > >             }
> > > >         }
> > > >     );
> > > >     result = binaryCache.query(scanAddress).getAll();
> > > >     System.out.println("result: " + result.size());
> > > >     for (Cache.Entry<Long, BinaryObject> entry : result) {
> > > >         System.out.println(entry.getValue().deserialize().
> toString());
> > > >     }
> > > >
> > > >     ignite.close();
> > > > }
> > > >
> > > > Here what I want to do is start a client node, connect to the server
> > node
> > > > started in step 2. Then I create a cache, put some data inside,
> > > > then try to run a scan query to find entries by its address.
> > > > The problem is when I run this program first time, it will return two
> > > > entries, their addresses are started with "jurong", which is correct.
> > > > When I run the program again, with changed value, eg. "changi", it
> > should
> > > > return one entry, somehow, it still return two entries with address
> > > started
> > > > with "jurong", rather than "changi".
> > > > When I uncomment the line of "org6", and run the program again, it
> will
> > > > return three entries, all of their addresses are started with
> "jurong".
> > > >
> > > > I have no idea what is going on.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Best regards,
> > > > Andrey V. Mashenkov
> > > >
> > >
> >
> >
> >
> > --
> > Best regards,
> > Andrey V. Mashenkov
> >
>



-- 
Best regards,
Andrey V. Mashenkov

Re: ScanQuery With BinaryObject

Posted by Valentin Kulichenko <va...@gmail.com>.
Andrey,

Marshaller cache does not store classes, only class names. So I'm not sure
what you mean by this.

I looked at the code and it seems I was wrong - peer class loading does
work for scan query filter, which is good. But as I mentioned before, if
the class is available on local classpath, it will never be dynamically
loaded, even if peer class loading is enabled. Therefore server will not
know about any changes happening to the class definition on the client.
This is correct behavior.

-Val

On Wed, Apr 5, 2017 at 12:01 AM, Andrey Mashenkov <
andrey.mashenkov@gmail.com> wrote:

> Hi Val,
>
> Filter object serialized and send inside GridCacheQueryRequest, and then it
> is deserialized on server side and loaded by cache class loader.
> Looks like filter class is cached in marshaller cache.
>
>
> On Tue, Apr 4, 2017 at 4:43 PM, Valentin Kulichenko <
> valentin.kulichenko@gmail.com> wrote:
>
> > Andrey,
> >
> > To my knowledge, peer class loading is not supported for scan query
> > filters, but I'm not sure though. Can you please check?
> >
> > Note that this actually doesn't matter if the class is available on
> > server's local classpath. In this case it will be always used regardless
> of
> > any changes done on a client (i.e. will never be dynamically loaded).
> This
> > is true for any functionality, including Compute Grid.
> >
> > -Val
> >
> > On Mon, Apr 3, 2017 at 10:19 AM, Andrey Mashenkov <
> > andrey.mashenkov@gmail.com> wrote:
> >
> > > Crossposted to dev:
> > >
> > > Guys,
> > >
> > > ScanQuery filter code (see IgniteBiPredicate implementation below) can
> be
> > > cached on server side
> > > that can cause unexpected results.
> > > The main point here is server node never restarts while client does it
> > with
> > > filter code changed.
> > >
> > > Is it ok?
> > >
> > > I try to add *serialVersionUID* and it was useless. The only class
> > renaming
> > > was helpful.
> > >
> > >
> > > ---------- Forwarded message ----------
> > > From: David Li <da...@gmail.com>
> > > Date: Mon, Apr 3, 2017 at 9:24 AM
> > > Subject: Re: ScanQuery With BinaryObject
> > > To: user@ignite.apache.org
> > >
> > >
> > > Sorry, please ignore the previous email, it was sent by mistake.
> > >
> > > 1. I download apache-ignite-fabric-1.9.0-bin.zip, and unzip it.
> > > 2. In terminal, I start an ignite instance by *bin/ignite.sh
> > > examples/config/example-ignite.xml*
> > > 3. I create a Java application, source code as below:
> > >
> > > public static void main(String[] args) {
> > >     String ORG_CACHE = "org_cache_remote";
> > >    * Ignition.setClientMode(true);*
> > >     Ignite ignite = Ignition.start("example-ignite.xml");
> > >     CacheConfiguration<Long, Organization> orgCacheCfg = new
> > > CacheConfiguration<>(ORG_CACHE);
> > >     orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
> > >     ignite.destroyCache(ORG_CACHE);
> > >     IgniteCache<Long, Organization> cache = ignite.createCache(
> > > orgCacheCfg);
> > >     cache.put(1L, new Organization(1L, "org1", true, "jurong east",
> > > "1111"));
> > >     cache.put(2L, new Organization(2L, "org2", false, "orchard",
> > "2222"));
> > >     cache.put(3L, new Organization(3L, "org3", true, "jurong west",
> > > "3333"));
> > >     cache.put(4L, new Organization(4L, "org4", false, "woodlands",
> > > "4444"));
> > >     cache.put(5L, new Organization(5L, "org5", false, "changi",
> "5555"));
> > >     // cache.put(6L, new Organization(6L, "org6", true, "jurong
> island",
> > > "6666"));
> > >
> > >     IgniteCache<Long, BinaryObject> binaryCache =
> cache.withKeepBinary();
> > >
> > >     List<Cache.Entry<Long, BinaryObject>> result;
> > >
> > >     System.out.println("Scan by address");
> > >     ScanQuery<Long, BinaryObject> scanAddress = new ScanQuery<>(
> > >         new IgniteBiPredicate<Long, BinaryObject>() {
> > >             @Override
> > >             public boolean apply(Long aLong, BinaryObject
> binaryObject) {
> > >                 *// first time filter by jurong, got two entries, org1
> > and
> > > org3*
> > > *                // second time filter by changi, got two entries, org1
> > and
> > > org3*
> > > *                // third time filter by changi as well, uncomment
> org6,
> > > got three entries, org1, org3 and org6*
> > > *                return
> > > binaryObject.<String>field("address").startsWith("jurong");*
> > >             }
> > >         }
> > >     );
> > >     result = binaryCache.query(scanAddress).getAll();
> > >     System.out.println("result: " + result.size());
> > >     for (Cache.Entry<Long, BinaryObject> entry : result) {
> > >         System.out.println(entry.getValue().deserialize().toString());
> > >     }
> > >
> > >     ignite.close();
> > > }
> > >
> > > Here what I want to do is start a client node, connect to the server
> node
> > > started in step 2. Then I create a cache, put some data inside,
> > > then try to run a scan query to find entries by its address.
> > > The problem is when I run this program first time, it will return two
> > > entries, their addresses are started with "jurong", which is correct.
> > > When I run the program again, with changed value, eg. "changi", it
> should
> > > return one entry, somehow, it still return two entries with address
> > started
> > > with "jurong", rather than "changi".
> > > When I uncomment the line of "org6", and run the program again, it will
> > > return three entries, all of their addresses are started with "jurong".
> > >
> > > I have no idea what is going on.
> > >
> > >
> > >
> > >
> > >
> > > --
> > > Best regards,
> > > Andrey V. Mashenkov
> > >
> >
>
>
>
> --
> Best regards,
> Andrey V. Mashenkov
>

Re: ScanQuery With BinaryObject

Posted by Andrey Mashenkov <an...@gmail.com>.
Hi Val,

Filter object serialized and send inside GridCacheQueryRequest, and then it
is deserialized on server side and loaded by cache class loader.
Looks like filter class is cached in marshaller cache.


On Tue, Apr 4, 2017 at 4:43 PM, Valentin Kulichenko <
valentin.kulichenko@gmail.com> wrote:

> Andrey,
>
> To my knowledge, peer class loading is not supported for scan query
> filters, but I'm not sure though. Can you please check?
>
> Note that this actually doesn't matter if the class is available on
> server's local classpath. In this case it will be always used regardless of
> any changes done on a client (i.e. will never be dynamically loaded). This
> is true for any functionality, including Compute Grid.
>
> -Val
>
> On Mon, Apr 3, 2017 at 10:19 AM, Andrey Mashenkov <
> andrey.mashenkov@gmail.com> wrote:
>
> > Crossposted to dev:
> >
> > Guys,
> >
> > ScanQuery filter code (see IgniteBiPredicate implementation below) can be
> > cached on server side
> > that can cause unexpected results.
> > The main point here is server node never restarts while client does it
> with
> > filter code changed.
> >
> > Is it ok?
> >
> > I try to add *serialVersionUID* and it was useless. The only class
> renaming
> > was helpful.
> >
> >
> > ---------- Forwarded message ----------
> > From: David Li <da...@gmail.com>
> > Date: Mon, Apr 3, 2017 at 9:24 AM
> > Subject: Re: ScanQuery With BinaryObject
> > To: user@ignite.apache.org
> >
> >
> > Sorry, please ignore the previous email, it was sent by mistake.
> >
> > 1. I download apache-ignite-fabric-1.9.0-bin.zip, and unzip it.
> > 2. In terminal, I start an ignite instance by *bin/ignite.sh
> > examples/config/example-ignite.xml*
> > 3. I create a Java application, source code as below:
> >
> > public static void main(String[] args) {
> >     String ORG_CACHE = "org_cache_remote";
> >    * Ignition.setClientMode(true);*
> >     Ignite ignite = Ignition.start("example-ignite.xml");
> >     CacheConfiguration<Long, Organization> orgCacheCfg = new
> > CacheConfiguration<>(ORG_CACHE);
> >     orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
> >     ignite.destroyCache(ORG_CACHE);
> >     IgniteCache<Long, Organization> cache = ignite.createCache(
> > orgCacheCfg);
> >     cache.put(1L, new Organization(1L, "org1", true, "jurong east",
> > "1111"));
> >     cache.put(2L, new Organization(2L, "org2", false, "orchard",
> "2222"));
> >     cache.put(3L, new Organization(3L, "org3", true, "jurong west",
> > "3333"));
> >     cache.put(4L, new Organization(4L, "org4", false, "woodlands",
> > "4444"));
> >     cache.put(5L, new Organization(5L, "org5", false, "changi", "5555"));
> >     // cache.put(6L, new Organization(6L, "org6", true, "jurong island",
> > "6666"));
> >
> >     IgniteCache<Long, BinaryObject> binaryCache = cache.withKeepBinary();
> >
> >     List<Cache.Entry<Long, BinaryObject>> result;
> >
> >     System.out.println("Scan by address");
> >     ScanQuery<Long, BinaryObject> scanAddress = new ScanQuery<>(
> >         new IgniteBiPredicate<Long, BinaryObject>() {
> >             @Override
> >             public boolean apply(Long aLong, BinaryObject binaryObject) {
> >                 *// first time filter by jurong, got two entries, org1
> and
> > org3*
> > *                // second time filter by changi, got two entries, org1
> and
> > org3*
> > *                // third time filter by changi as well, uncomment org6,
> > got three entries, org1, org3 and org6*
> > *                return
> > binaryObject.<String>field("address").startsWith("jurong");*
> >             }
> >         }
> >     );
> >     result = binaryCache.query(scanAddress).getAll();
> >     System.out.println("result: " + result.size());
> >     for (Cache.Entry<Long, BinaryObject> entry : result) {
> >         System.out.println(entry.getValue().deserialize().toString());
> >     }
> >
> >     ignite.close();
> > }
> >
> > Here what I want to do is start a client node, connect to the server node
> > started in step 2. Then I create a cache, put some data inside,
> > then try to run a scan query to find entries by its address.
> > The problem is when I run this program first time, it will return two
> > entries, their addresses are started with "jurong", which is correct.
> > When I run the program again, with changed value, eg. "changi", it should
> > return one entry, somehow, it still return two entries with address
> started
> > with "jurong", rather than "changi".
> > When I uncomment the line of "org6", and run the program again, it will
> > return three entries, all of their addresses are started with "jurong".
> >
> > I have no idea what is going on.
> >
> >
> >
> >
> >
> > --
> > Best regards,
> > Andrey V. Mashenkov
> >
>



-- 
Best regards,
Andrey V. Mashenkov

Re: ScanQuery With BinaryObject

Posted by Valentin Kulichenko <va...@gmail.com>.
Andrey,

To my knowledge, peer class loading is not supported for scan query
filters, but I'm not sure though. Can you please check?

Note that this actually doesn't matter if the class is available on
server's local classpath. In this case it will be always used regardless of
any changes done on a client (i.e. will never be dynamically loaded). This
is true for any functionality, including Compute Grid.

-Val

On Mon, Apr 3, 2017 at 10:19 AM, Andrey Mashenkov <
andrey.mashenkov@gmail.com> wrote:

> Crossposted to dev:
>
> Guys,
>
> ScanQuery filter code (see IgniteBiPredicate implementation below) can be
> cached on server side
> that can cause unexpected results.
> The main point here is server node never restarts while client does it with
> filter code changed.
>
> Is it ok?
>
> I try to add *serialVersionUID* and it was useless. The only class renaming
> was helpful.
>
>
> ---------- Forwarded message ----------
> From: David Li <da...@gmail.com>
> Date: Mon, Apr 3, 2017 at 9:24 AM
> Subject: Re: ScanQuery With BinaryObject
> To: user@ignite.apache.org
>
>
> Sorry, please ignore the previous email, it was sent by mistake.
>
> 1. I download apache-ignite-fabric-1.9.0-bin.zip, and unzip it.
> 2. In terminal, I start an ignite instance by *bin/ignite.sh
> examples/config/example-ignite.xml*
> 3. I create a Java application, source code as below:
>
> public static void main(String[] args) {
>     String ORG_CACHE = "org_cache_remote";
>    * Ignition.setClientMode(true);*
>     Ignite ignite = Ignition.start("example-ignite.xml");
>     CacheConfiguration<Long, Organization> orgCacheCfg = new
> CacheConfiguration<>(ORG_CACHE);
>     orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
>     ignite.destroyCache(ORG_CACHE);
>     IgniteCache<Long, Organization> cache = ignite.createCache(
> orgCacheCfg);
>     cache.put(1L, new Organization(1L, "org1", true, "jurong east",
> "1111"));
>     cache.put(2L, new Organization(2L, "org2", false, "orchard", "2222"));
>     cache.put(3L, new Organization(3L, "org3", true, "jurong west",
> "3333"));
>     cache.put(4L, new Organization(4L, "org4", false, "woodlands",
> "4444"));
>     cache.put(5L, new Organization(5L, "org5", false, "changi", "5555"));
>     // cache.put(6L, new Organization(6L, "org6", true, "jurong island",
> "6666"));
>
>     IgniteCache<Long, BinaryObject> binaryCache = cache.withKeepBinary();
>
>     List<Cache.Entry<Long, BinaryObject>> result;
>
>     System.out.println("Scan by address");
>     ScanQuery<Long, BinaryObject> scanAddress = new ScanQuery<>(
>         new IgniteBiPredicate<Long, BinaryObject>() {
>             @Override
>             public boolean apply(Long aLong, BinaryObject binaryObject) {
>                 *// first time filter by jurong, got two entries, org1 and
> org3*
> *                // second time filter by changi, got two entries, org1 and
> org3*
> *                // third time filter by changi as well, uncomment org6,
> got three entries, org1, org3 and org6*
> *                return
> binaryObject.<String>field("address").startsWith("jurong");*
>             }
>         }
>     );
>     result = binaryCache.query(scanAddress).getAll();
>     System.out.println("result: " + result.size());
>     for (Cache.Entry<Long, BinaryObject> entry : result) {
>         System.out.println(entry.getValue().deserialize().toString());
>     }
>
>     ignite.close();
> }
>
> Here what I want to do is start a client node, connect to the server node
> started in step 2. Then I create a cache, put some data inside,
> then try to run a scan query to find entries by its address.
> The problem is when I run this program first time, it will return two
> entries, their addresses are started with "jurong", which is correct.
> When I run the program again, with changed value, eg. "changi", it should
> return one entry, somehow, it still return two entries with address started
> with "jurong", rather than "changi".
> When I uncomment the line of "org6", and run the program again, it will
> return three entries, all of their addresses are started with "jurong".
>
> I have no idea what is going on.
>
>
>
>
>
> --
> Best regards,
> Andrey V. Mashenkov
>

Fwd: ScanQuery With BinaryObject

Posted by Andrey Mashenkov <an...@gmail.com>.
Crossposted to dev:

Guys,

ScanQuery filter code (see IgniteBiPredicate implementation below) can be
cached on server side
that can cause unexpected results.
The main point here is server node never restarts while client does it with
filter code changed.

Is it ok?

I try to add *serialVersionUID* and it was useless. The only class renaming
was helpful.


---------- Forwarded message ----------
From: David Li <da...@gmail.com>
Date: Mon, Apr 3, 2017 at 9:24 AM
Subject: Re: ScanQuery With BinaryObject
To: user@ignite.apache.org


Sorry, please ignore the previous email, it was sent by mistake.

1. I download apache-ignite-fabric-1.9.0-bin.zip, and unzip it.
2. In terminal, I start an ignite instance by *bin/ignite.sh
examples/config/example-ignite.xml*
3. I create a Java application, source code as below:

public static void main(String[] args) {
    String ORG_CACHE = "org_cache_remote";
   * Ignition.setClientMode(true);*
    Ignite ignite = Ignition.start("example-ignite.xml");
    CacheConfiguration<Long, Organization> orgCacheCfg = new
CacheConfiguration<>(ORG_CACHE);
    orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
    ignite.destroyCache(ORG_CACHE);
    IgniteCache<Long, Organization> cache = ignite.createCache(orgCacheCfg);
    cache.put(1L, new Organization(1L, "org1", true, "jurong east",
"1111"));
    cache.put(2L, new Organization(2L, "org2", false, "orchard", "2222"));
    cache.put(3L, new Organization(3L, "org3", true, "jurong west",
"3333"));
    cache.put(4L, new Organization(4L, "org4", false, "woodlands", "4444"));
    cache.put(5L, new Organization(5L, "org5", false, "changi", "5555"));
    // cache.put(6L, new Organization(6L, "org6", true, "jurong island",
"6666"));

    IgniteCache<Long, BinaryObject> binaryCache = cache.withKeepBinary();

    List<Cache.Entry<Long, BinaryObject>> result;

    System.out.println("Scan by address");
    ScanQuery<Long, BinaryObject> scanAddress = new ScanQuery<>(
        new IgniteBiPredicate<Long, BinaryObject>() {
            @Override
            public boolean apply(Long aLong, BinaryObject binaryObject) {
                *// first time filter by jurong, got two entries, org1 and
org3*
*                // second time filter by changi, got two entries, org1 and
org3*
*                // third time filter by changi as well, uncomment org6,
got three entries, org1, org3 and org6*
*                return
binaryObject.<String>field("address").startsWith("jurong");*
            }
        }
    );
    result = binaryCache.query(scanAddress).getAll();
    System.out.println("result: " + result.size());
    for (Cache.Entry<Long, BinaryObject> entry : result) {
        System.out.println(entry.getValue().deserialize().toString());
    }

    ignite.close();
}

Here what I want to do is start a client node, connect to the server node
started in step 2. Then I create a cache, put some data inside,
then try to run a scan query to find entries by its address.
The problem is when I run this program first time, it will return two
entries, their addresses are started with "jurong", which is correct.
When I run the program again, with changed value, eg. "changi", it should
return one entry, somehow, it still return two entries with address started
with "jurong", rather than "changi".
When I uncomment the line of "org6", and run the program again, it will
return three entries, all of their addresses are started with "jurong".

I have no idea what is going on.





-- 
Best regards,
Andrey V. Mashenkov

Re: ScanQuery With BinaryObject

Posted by David Li <da...@gmail.com>.
Hi Andrey,

Your suggestion fixed my problem. Thank you.

On Tue, Apr 4, 2017 at 1:08 AM, Andrey Mashenkov <andrey.mashenkov@gmail.com
> wrote:

> Hi David,
>
> Scan query results are never cached. It looks like your IgniteBiPredicate
> implementation is cached on server side.
> Try to move this class to upper level or make it inner and make "prefix"
> configurable with class constructor. This should work.
>
> On Mon, Apr 3, 2017 at 9:24 AM, David Li <da...@gmail.com> wrote:
>
>> Sorry, please ignore the previous email, it was sent by mistake.
>>
>> 1. I download apache-ignite-fabric-1.9.0-bin.zip, and unzip it.
>> 2. In terminal, I start an ignite instance by *bin/ignite.sh
>> examples/config/example-ignite.xml*
>> 3. I create a Java application, source code as below:
>>
>> public static void main(String[] args) {
>>     String ORG_CACHE = "org_cache_remote";
>>    * Ignition.setClientMode(true);*
>>     Ignite ignite = Ignition.start("example-ignite.xml");
>>     CacheConfiguration<Long, Organization> orgCacheCfg = new
>> CacheConfiguration<>(ORG_CACHE);
>>     orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
>>     ignite.destroyCache(ORG_CACHE);
>>     IgniteCache<Long, Organization> cache = ignite.createCache(orgCacheCfg
>> );
>>     cache.put(1L, new Organization(1L, "org1", true, "jurong east",
>> "1111"));
>>     cache.put(2L, new Organization(2L, "org2", false, "orchard", "2222"));
>>     cache.put(3L, new Organization(3L, "org3", true, "jurong west",
>> "3333"));
>>     cache.put(4L, new Organization(4L, "org4", false, "woodlands",
>> "4444"));
>>     cache.put(5L, new Organization(5L, "org5", false, "changi", "5555"));
>>     // cache.put(6L, new Organization(6L, "org6", true, "jurong island",
>> "6666"));
>>
>>     IgniteCache<Long, BinaryObject> binaryCache = cache.withKeepBinary();
>>
>>     List<Cache.Entry<Long, BinaryObject>> result;
>>
>>     System.out.println("Scan by address");
>>     ScanQuery<Long, BinaryObject> scanAddress = new ScanQuery<>(
>>         new IgniteBiPredicate<Long, BinaryObject>() {
>>             @Override
>>             public boolean apply(Long aLong, BinaryObject binaryObject) {
>>                 *// first time filter by jurong, got two entries, org1
>> and org3*
>> *                // second time filter by changi, got two entries, org1
>> and org3*
>> *                // third time filter by changi as well, uncomment org6,
>> got three entries, org1, org3 and org6*
>> *                return
>> binaryObject.<String>field("address").startsWith("jurong");*
>>             }
>>         }
>>     );
>>     result = binaryCache.query(scanAddress).getAll();
>>     System.out.println("result: " + result.size());
>>     for (Cache.Entry<Long, BinaryObject> entry : result) {
>>         System.out.println(entry.getValue().deserialize().toString());
>>     }
>>
>>     ignite.close();
>> }
>>
>> Here what I want to do is start a client node, connect to the server node
>> started in step 2. Then I create a cache, put some data inside,
>> then try to run a scan query to find entries by its address.
>> The problem is when I run this program first time, it will return two
>> entries, their addresses are started with "jurong", which is correct.
>> When I run the program again, with changed value, eg. "changi", it should
>> return one entry, somehow, it still return two entries with address started
>> with "jurong", rather than "changi".
>> When I uncomment the line of "org6", and run the program again, it will
>> return three entries, all of their addresses are started with "jurong".
>>
>> I have no idea what is going on.
>>
>>
>>
>
>
> --
> Best regards,
> Andrey V. Mashenkov
>

Re: ScanQuery With BinaryObject

Posted by Andrey Mashenkov <an...@gmail.com>.
Hi David,

Scan query results are never cached. It looks like your
IgniteBiPredicate implementation
is cached on server side.
Try to move this class to upper level or make it inner and make "prefix"
configurable with class constructor. This should work.

On Mon, Apr 3, 2017 at 9:24 AM, David Li <da...@gmail.com> wrote:

> Sorry, please ignore the previous email, it was sent by mistake.
>
> 1. I download apache-ignite-fabric-1.9.0-bin.zip, and unzip it.
> 2. In terminal, I start an ignite instance by *bin/ignite.sh
> examples/config/example-ignite.xml*
> 3. I create a Java application, source code as below:
>
> public static void main(String[] args) {
>     String ORG_CACHE = "org_cache_remote";
>    * Ignition.setClientMode(true);*
>     Ignite ignite = Ignition.start("example-ignite.xml");
>     CacheConfiguration<Long, Organization> orgCacheCfg = new
> CacheConfiguration<>(ORG_CACHE);
>     orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
>     ignite.destroyCache(ORG_CACHE);
>     IgniteCache<Long, Organization> cache = ignite.createCache(
> orgCacheCfg);
>     cache.put(1L, new Organization(1L, "org1", true, "jurong east",
> "1111"));
>     cache.put(2L, new Organization(2L, "org2", false, "orchard", "2222"));
>     cache.put(3L, new Organization(3L, "org3", true, "jurong west",
> "3333"));
>     cache.put(4L, new Organization(4L, "org4", false, "woodlands",
> "4444"));
>     cache.put(5L, new Organization(5L, "org5", false, "changi", "5555"));
>     // cache.put(6L, new Organization(6L, "org6", true, "jurong island",
> "6666"));
>
>     IgniteCache<Long, BinaryObject> binaryCache = cache.withKeepBinary();
>
>     List<Cache.Entry<Long, BinaryObject>> result;
>
>     System.out.println("Scan by address");
>     ScanQuery<Long, BinaryObject> scanAddress = new ScanQuery<>(
>         new IgniteBiPredicate<Long, BinaryObject>() {
>             @Override
>             public boolean apply(Long aLong, BinaryObject binaryObject) {
>                 *// first time filter by jurong, got two entries, org1
> and org3*
> *                // second time filter by changi, got two entries, org1
> and org3*
> *                // third time filter by changi as well, uncomment org6,
> got three entries, org1, org3 and org6*
> *                return
> binaryObject.<String>field("address").startsWith("jurong");*
>             }
>         }
>     );
>     result = binaryCache.query(scanAddress).getAll();
>     System.out.println("result: " + result.size());
>     for (Cache.Entry<Long, BinaryObject> entry : result) {
>         System.out.println(entry.getValue().deserialize().toString());
>     }
>
>     ignite.close();
> }
>
> Here what I want to do is start a client node, connect to the server node
> started in step 2. Then I create a cache, put some data inside,
> then try to run a scan query to find entries by its address.
> The problem is when I run this program first time, it will return two
> entries, their addresses are started with "jurong", which is correct.
> When I run the program again, with changed value, eg. "changi", it should
> return one entry, somehow, it still return two entries with address started
> with "jurong", rather than "changi".
> When I uncomment the line of "org6", and run the program again, it will
> return three entries, all of their addresses are started with "jurong".
>
> I have no idea what is going on.
>
>
>


-- 
Best regards,
Andrey V. Mashenkov

Re: ScanQuery With BinaryObject

Posted by David Li <da...@gmail.com>.
Sorry, please ignore the previous email, it was sent by mistake.

1. I download apache-ignite-fabric-1.9.0-bin.zip, and unzip it.
2. In terminal, I start an ignite instance by *bin/ignite.sh
examples/config/example-ignite.xml*
3. I create a Java application, source code as below:

public static void main(String[] args) {
    String ORG_CACHE = "org_cache_remote";
   * Ignition.setClientMode(true);*
    Ignite ignite = Ignition.start("example-ignite.xml");
    CacheConfiguration<Long, Organization> orgCacheCfg = new
CacheConfiguration<>(ORG_CACHE);
    orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
    ignite.destroyCache(ORG_CACHE);
    IgniteCache<Long, Organization> cache = ignite.createCache(orgCacheCfg);
    cache.put(1L, new Organization(1L, "org1", true, "jurong east",
"1111"));
    cache.put(2L, new Organization(2L, "org2", false, "orchard", "2222"));
    cache.put(3L, new Organization(3L, "org3", true, "jurong west",
"3333"));
    cache.put(4L, new Organization(4L, "org4", false, "woodlands", "4444"));
    cache.put(5L, new Organization(5L, "org5", false, "changi", "5555"));
    // cache.put(6L, new Organization(6L, "org6", true, "jurong island",
"6666"));

    IgniteCache<Long, BinaryObject> binaryCache = cache.withKeepBinary();

    List<Cache.Entry<Long, BinaryObject>> result;

    System.out.println("Scan by address");
    ScanQuery<Long, BinaryObject> scanAddress = new ScanQuery<>(
        new IgniteBiPredicate<Long, BinaryObject>() {
            @Override
            public boolean apply(Long aLong, BinaryObject binaryObject) {
                *// first time filter by jurong, got two entries, org1 and
org3*
*                // second time filter by changi, got two entries, org1 and
org3*
*                // third time filter by changi as well, uncomment org6,
got three entries, org1, org3 and org6*
*                return
binaryObject.<String>field("address").startsWith("jurong");*
            }
        }
    );
    result = binaryCache.query(scanAddress).getAll();
    System.out.println("result: " + result.size());
    for (Cache.Entry<Long, BinaryObject> entry : result) {
        System.out.println(entry.getValue().deserialize().toString());
    }

    ignite.close();
}

Here what I want to do is start a client node, connect to the server node
started in step 2. Then I create a cache, put some data inside,
then try to run a scan query to find entries by its address.
The problem is when I run this program first time, it will return two
entries, their addresses are started with "jurong", which is correct.
When I run the program again, with changed value, eg. "changi", it should
return one entry, somehow, it still return two entries with address started
with "jurong", rather than "changi".
When I uncomment the line of "org6", and run the program again, it will
return three entries, all of their addresses are started with "jurong".

I have no idea what is going on.

Re: ScanQuery With BinaryObject

Posted by David Li <da...@gmail.com>.
1. I download apache-ignite-fabric-1.9.0-bin.zip, and unzip it.
2. In terminal, I start an ignite instance by bin/ignite.sh
examples/config/example-ignite.xml
3. I create a Java application, source code as below:

public static void main(String[] args) {
    String ORG_CACHE = "org_cache_remote";
    Ignition.setClientMode(true);
    Ignite ignite = Ignition.start("example-ignite.xml");
    CacheConfiguration<Long, Organization> orgCacheCfg = new
CacheConfiguration<>(ORG_CACHE);
    orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
    ignite.destroyCache(ORG_CACHE);
    IgniteCache<Long, Organization> cache = ignite.createCache(orgCacheCfg);
    cache.put(1L, new Organization(1L, "org1", true, "jurong east", "1111"));
    cache.put(2L, new Organization(2L, "org2", false, "orchard", "2222"));
    cache.put(3L, new Organization(3L, "org3", true, "jurong west", "3333"));
    cache.put(4L, new Organization(4L, "org4", false, "woodlands", "4444"));
    cache.put(5L, new Organization(5L, "org5", false, "changi",
"5555"));cache.put(6L, new Organization(6L, "org6", true, "jurong
island", "6666"));


    IgniteCache<Long, BinaryObject> binaryCache = cache.withKeepBinary();

    List<Cache.Entry<Long, BinaryObject>> result;

    System.out.println("Scan by address");
    ScanQuery<Long, BinaryObject> scanAddress = new ScanQuery<>(
        new IgniteBiPredicate<Long, BinaryObject>() {
            @Override
            public boolean apply(Long aLong, BinaryObject binaryObject) {
                return
binaryObject.<String>field("address").startsWith("jurong");
            }
        }
    );
    result = binaryCache.query(scanAddress).getAll();
    System.out.println("result: " + result.size());
    for (Cache.Entry<Long, BinaryObject> entry : result) {
        System.out.println(entry.getValue().deserialize().toString());
    }

    ignite.close();
}

Here what I want to do is start a client node, connect to the server
node started in step 2. Then I create a cache, put some data inside,

then try to run a scan query to find entries by its address.

The problem is when I run this program first time, it will return two
entries, their addresses are started with "jurong", which is correct.

When I run the program again, with changed value, eg. changi, it
should return one entry, somehow, it still return two entries with
address started with "jurong", rather than "changi".

When I




On Fri, Mar 31, 2017 at 7:40 PM, Andrey Mashenkov <
andrey.mashenkov@gmail.com> wrote:

> Hi David,
>
> Would you please share your code.
>
> On Fri, Mar 31, 2017 at 10:42 AM, David Li <da...@gmail.com> wrote:
>
>> It is weird.
>>
>> I run the cache query example, scan query works fine.
>>
>> I create my cache query code with a local started server node, scan query
>> works fine.
>>
>> I start a server node from terminal, start a client node in my code and
>> issue scan query, the first query after the server node is started works
>> fine, all the following queries will just return the exactly same result as
>> the first query. I try adding data into the cache, the newly added data
>> will be returned as per the first query. It looks like the first query has
>> been kept somewhere.
>>
>>
>>
>>
>> On Thu, Mar 30, 2017 at 9:02 PM, Andrey Mashenkov <
>> andrey.mashenkov@gmail.com> wrote:
>>
>>> Hi David,
>>>
>>> I've run your code and it works fine for me on ignite 1.7-1.9 versions
>>> and master branch.
>>>
>>> On Thu, Mar 30, 2017 at 12:19 PM, David Li <da...@gmail.com>
>>> wrote:
>>>
>>>> Hello,
>>>>
>>>> I am having a little issue with the ScanQuery for BinaryObject.
>>>>
>>>> Some code snippets
>>>>
>>>> IgniteCache<Long, Organization> cache = ignite.cache(CacheConfig.CACHE_NAME);
>>>> IgniteCache<Long, BinaryObject> binaryCache = cache.withKeepBinary();
>>>>
>>>> // scan query
>>>> IgniteBiPredicate<Long, BinaryObject> filter = new IgniteBiPredicate<Long, BinaryObject>() {
>>>>     @Override
>>>>     public boolean apply(Long key, BinaryObject value) {
>>>>         return false;
>>>>     }
>>>> };
>>>> ScanQuery<Long, BinaryObject> scanQuery = new ScanQuery<>(filter);
>>>>
>>>> List<Cache.Entry<Long, BinaryObject>> result = binaryCache.query(scanQuery).getAll();
>>>>
>>>>
>>>> I expect it will return an empty result, somehow it always returns everything in the cache.
>>>>
>>>> Not sure what is wrong?
>>>>
>>>>
>>>> BRs,
>>>>
>>>> David
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Best regards,
>>> Andrey V. Mashenkov
>>>
>>
>>
>
>
> --
> Best regards,
> Andrey V. Mashenkov
>

Re: ScanQuery With BinaryObject

Posted by Andrey Mashenkov <an...@gmail.com>.
Hi David,

Would you please share your code.

On Fri, Mar 31, 2017 at 10:42 AM, David Li <da...@gmail.com> wrote:

> It is weird.
>
> I run the cache query example, scan query works fine.
>
> I create my cache query code with a local started server node, scan query
> works fine.
>
> I start a server node from terminal, start a client node in my code and
> issue scan query, the first query after the server node is started works
> fine, all the following queries will just return the exactly same result as
> the first query. I try adding data into the cache, the newly added data
> will be returned as per the first query. It looks like the first query has
> been kept somewhere.
>
>
>
>
> On Thu, Mar 30, 2017 at 9:02 PM, Andrey Mashenkov <
> andrey.mashenkov@gmail.com> wrote:
>
>> Hi David,
>>
>> I've run your code and it works fine for me on ignite 1.7-1.9 versions
>> and master branch.
>>
>> On Thu, Mar 30, 2017 at 12:19 PM, David Li <da...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I am having a little issue with the ScanQuery for BinaryObject.
>>>
>>> Some code snippets
>>>
>>> IgniteCache<Long, Organization> cache = ignite.cache(CacheConfig.CACHE_NAME);
>>> IgniteCache<Long, BinaryObject> binaryCache = cache.withKeepBinary();
>>>
>>> // scan query
>>> IgniteBiPredicate<Long, BinaryObject> filter = new IgniteBiPredicate<Long, BinaryObject>() {
>>>     @Override
>>>     public boolean apply(Long key, BinaryObject value) {
>>>         return false;
>>>     }
>>> };
>>> ScanQuery<Long, BinaryObject> scanQuery = new ScanQuery<>(filter);
>>>
>>> List<Cache.Entry<Long, BinaryObject>> result = binaryCache.query(scanQuery).getAll();
>>>
>>>
>>> I expect it will return an empty result, somehow it always returns everything in the cache.
>>>
>>> Not sure what is wrong?
>>>
>>>
>>> BRs,
>>>
>>> David
>>>
>>>
>>>
>>>
>>
>>
>> --
>> Best regards,
>> Andrey V. Mashenkov
>>
>
>


-- 
Best regards,
Andrey V. Mashenkov

Re: ScanQuery With BinaryObject

Posted by David Li <da...@gmail.com>.
It is weird.

I run the cache query example, scan query works fine.

I create my cache query code with a local started server node, scan query
works fine.

I start a server node from terminal, start a client node in my code and
issue scan query, the first query after the server node is started works
fine, all the following queries will just return the exactly same result as
the first query. I try adding data into the cache, the newly added data
will be returned as per the first query. It looks like the first query has
been kept somewhere.




On Thu, Mar 30, 2017 at 9:02 PM, Andrey Mashenkov <
andrey.mashenkov@gmail.com> wrote:

> Hi David,
>
> I've run your code and it works fine for me on ignite 1.7-1.9 versions and
> master branch.
>
> On Thu, Mar 30, 2017 at 12:19 PM, David Li <da...@gmail.com> wrote:
>
>> Hello,
>>
>> I am having a little issue with the ScanQuery for BinaryObject.
>>
>> Some code snippets
>>
>> IgniteCache<Long, Organization> cache = ignite.cache(CacheConfig.CACHE_NAME);
>> IgniteCache<Long, BinaryObject> binaryCache = cache.withKeepBinary();
>>
>> // scan query
>> IgniteBiPredicate<Long, BinaryObject> filter = new IgniteBiPredicate<Long, BinaryObject>() {
>>     @Override
>>     public boolean apply(Long key, BinaryObject value) {
>>         return false;
>>     }
>> };
>> ScanQuery<Long, BinaryObject> scanQuery = new ScanQuery<>(filter);
>>
>> List<Cache.Entry<Long, BinaryObject>> result = binaryCache.query(scanQuery).getAll();
>>
>>
>> I expect it will return an empty result, somehow it always returns everything in the cache.
>>
>> Not sure what is wrong?
>>
>>
>> BRs,
>>
>> David
>>
>>
>>
>>
>
>
> --
> Best regards,
> Andrey V. Mashenkov
>

Re: ScanQuery With BinaryObject

Posted by Andrey Mashenkov <an...@gmail.com>.
Hi David,

I've run your code and it works fine for me on ignite 1.7-1.9 versions and
master branch.

On Thu, Mar 30, 2017 at 12:19 PM, David Li <da...@gmail.com> wrote:

> Hello,
>
> I am having a little issue with the ScanQuery for BinaryObject.
>
> Some code snippets
>
> IgniteCache<Long, Organization> cache = ignite.cache(CacheConfig.CACHE_NAME);
> IgniteCache<Long, BinaryObject> binaryCache = cache.withKeepBinary();
>
> // scan query
> IgniteBiPredicate<Long, BinaryObject> filter = new IgniteBiPredicate<Long, BinaryObject>() {
>     @Override
>     public boolean apply(Long key, BinaryObject value) {
>         return false;
>     }
> };
> ScanQuery<Long, BinaryObject> scanQuery = new ScanQuery<>(filter);
>
> List<Cache.Entry<Long, BinaryObject>> result = binaryCache.query(scanQuery).getAll();
>
>
> I expect it will return an empty result, somehow it always returns everything in the cache.
>
> Not sure what is wrong?
>
>
> BRs,
>
> David
>
>
>
>


-- 
Best regards,
Andrey V. Mashenkov