Re: How to run Ignite REST API scan query with predicate

2018-12-14 Thread begineer
OK, May be I wasn't clear before. Lets say cache contains entries
1. Trade1-> TradeObject{field1 =2, other fields}
Trade2-> TradeObject{field1 =3, other fields}
Trade3-> TradeObject{field1 =2, other fields}

Now if I run scan query without filter, it will return above 3 entries.
But lets say I want to fetch only record 1 and 3. So I create a Predicate
with below field and values
String tradeObjectField1 = 2, 
Set tradeObjectField2List = {Trade1, Trade3}

Now, with default constructor, how will these values be set



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: How to run Ignite REST API scan query with predicate

2018-12-13 Thread begineer
Ok Even if i add default constructor, how do I pass parameters of this class
to query ?



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: How to run Ignite REST API scan query with predicate

2018-12-12 Thread begineer
Yes, Predicate class is public and implement appy(). But I am trying to
understand how to set the fields of the predicate class. 

It has a constructor which takes two parameters

public TradeObjectPredicate(String tradeObjectField1, Set
tradeObjectField2List){
.
}
How to pass these values from REST API.

This is the error I am getting

{"successStatus":1,"error":"Failed to find constructor for provided
arguments
[clsName=myprojectpackage.TradeObjectPredicate]","sessionToken":null,"response":null}

Does it mean I have add default constructor to this class or add JSON
annotations for serialization. But If I add default constructor, predicate
filters will be null.

Please advise



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


How to run Ignite REST API scan query with predicate

2018-12-12 Thread begineer
Hi Guys,
I have an ignite cache of type distributed over several
nodes. I want to query its data using ignite REST APIS as mentioned

https://apacheignite.readme.io/v2.6/docs/rest-api#sql-scan-query-execute 

I am able to query the cache without predicate and page size 
http://host:port/ignite?cmd=qryscanexe&pageSize=10&cacheName=myCacheName

but I would like to do a bit more and add predicate to query. Something like
this

http://host:port/ignite?cmd=qryscanexe&pageSize=10&cacheName=Person&className=myprojectpackage.TradeObjectPredicate

class TradeObjectPredicate implements IgniteBiPredicate
{
private final String tradeObjectField1;
private final Set tradeObjectField2List;
}

How do i pass this predicate so that I can get matching results.

Thanks in Advance




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Querying Ignite caches in DBeaver

2018-09-23 Thread begineer
Hey Guys...
I am trying to use DBeaver for querying cache data in ignite cluster. I can
run simple queries like 'select * from "persons".Person' and it shows all
the records of it.
I have below queries:
1.  Is there a way to list of all caches of cluster in DBeaver SQL Editor
2. Does DBeaver only allows querying data of caches where SQL Queries are
enabled? If not, then how to see data for non SQL caches ?
I get below error when cache is not enabled for SQL queries

SQL Error: Failed to query Ignite.
  Failed to query Ignite.
  Failed to query Ignite.
class org.apache.ignite.IgniteCheckedException: Error server response:
[req=JdbcQueryExecuteRequest [schemaName=null, pageSize=1024, maxRows=200,
sqlQry=SELECT * FROM "persons".person, args=null], resp=JdbcResponse
[res=null, status=1, err=class
org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to
parse query: SELECT * FROM "persons".person]]
Error server response: [req=JdbcQueryExecuteRequest [schemaName=null,
pageSize=1024, maxRows=200, sqlQry=SELECT * FROM "persons".person,
args=null], resp=JdbcResponse [res=null, status=1, err=class
org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to
parse query: SELECT * FROM "persons".person]]





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


How many threads does ignite.executorService() have.

2018-08-28 Thread begineer
Hi Guys,
I have one simple query about ignite executor service.
I know java executor service accepts the no of threads to be run, but there
is no option to pass no of threads to ignite executor service. 

So how does it manage threads to be started.

many thanks



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: NullPointer Exception in Continuous Query

2018-05-10 Thread begineer
Thanks for reply, but unfortunately, I could understand the details in the
link provided. Could you please brief about it. Whats the root cause.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


NullPointer Exception in Continuous Query

2018-05-09 Thread begineer
Hi,
I am getting this exception in logs but not sure on which cache it is
happening. Logs does not help me identifying the cache either.

Apologies to ask here without much details but just wondering if someone
know what are the chances to get this exception.
I have set of caches and  CacheMode is set to Local to all of them.

[2018-05-10/02:02:29.585/BST][ERROR][grid-timeout-worker-#43%null%][o.a.i.i.p.t.GridTimeoutProcessor]
 
- Error when executing timeout callback: CancelableTask
[id=a2ad, endTime=1525914154576, period=5000,
cancel=false,
task=o.a.i.i.processors.cache.query.continuous.CacheContinuousQueryManager$BackupCleaner@4b4455c9]
java.lang.NullPointerException: null
at
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler$1.acknowledgeBackupOnTimeout(CacheContinuousQueryHandler.java:513)
~[ignite-core-1.9.9.jar:1.9.9]
at
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager$BackupCleaner.run(CacheContinuousQueryManager.java:1195)
~[ignite-core-1.9.9.jar:1.9.9]
at
org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor$CancelableTask.onTimeout(GridTimeoutProcessor.java:256)
~[ignite-core-1.9.9.jar:1.9.9]
at
org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor$TimeoutWorker.body(GridTimeoutProcessor.java:158)
~[ignite-core-1.9.9.jar:1.9.9]
at
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
[ignite-core-1.9.9.jar:1.9.9]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Auto sync caches with database

2018-05-08 Thread begineer
Hi,
We are already using 3rd party datastore feature in our application using
cache Stores. I was reading out Hazlecast hot cache feature and thats how I
got this question. It would be big advantage if something like that possible
in ignite.

https://hazelcast.com/resources/keeping-cache-hot/



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Auto sync caches with database

2018-05-07 Thread begineer
Hi,
I have been working with apache ignite 1.9 for quite sometime now and one
common problem which I faced is adding new records to cache from external
systems. Ignite currently don't provide auto sync capability with database.
So I have to write logic to insert entries to cache whenever new data added
to database tables by other application.

Is there a plan to support such a feature in near future. I know Hazlecast
provides this feature already.

e.g. maintaining trades cache for trades from webserver. So I have trades
table which saves uploads. To process them I keep all of them in cache.
Whenever new upload comes in, it is added to cache using cache.put(). Would
be awesome if this upload is picked up from table automatically.

It will make life much more simple.

Regards,
Surinder



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: get() function in ignite cache

2018-05-02 Thread begineer
Thanks. This is awesome!




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


get() function in ignite cache

2018-05-02 Thread begineer
HI Guys,
I am using cache.get() on ignite cache. Its readThrough cache so it means
cache.get() will load entry from cacheStore if not in cache. But in one
place, I  want to get only from cache, so it should not go to backstore to
load the entry. Is there a get version which accomplish that. Does
cache.containsKey() goes to cacheStore if key is not in cache.

Just like cache.remove() delete entry from cacheStore but cache.clear()
removes entry just from cache.

Thanks in advance




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Ignite cache query

2018-04-22 Thread begineer
e.g. 
public class Student {
@QuerySqlField(index=true)
int id;
@QuerySqlField
String name ;
@QuerySqlField
LocalDateTime dob;
@QuerySqlField
LocalDate dos;
@QuerySqlField
Map> map = new HashMap<>();

}

Now you can do something like this.


Ignite ignite = Ignition.start("examples/config/example-ignite.xml");
CacheConfiguration config = new
CacheConfiguration<>("mycache");
config.setIndexedTypes(Integer.class, Student.class);
IgniteCache cache = ignite.getOrCreateCache(config);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("-MM-dd
H:mm");
LocalDateTime time1= LocalDateTime.now();
String s = time1.format(formatter);
LocalDateTime time = LocalDateTime.parse(s, formatter);
Map> map = new HashMap<>();
map.put("Key1", Arrays.asList(new Serializable[]{"value1", "value2"}));
Student s1 = new Student(time, 1, "joe",time.toLocalDate(),map);
Student s2 = new Student(time, 2, "Lee",time.toLocalDate(),map);
cache.put(s1.getId(), s1);
cache.put(s2.getId(), s2);
SqlQuery query = new SqlQuery<>(Student.class, 
"select *
from student where dos =?");
query.setArgs(time.toLocalDate());
List list =
cache.query(query).getAll().stream().map(Cache.Entry::getValue).collect(Collectors.toList());





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Ignite cache query

2018-04-22 Thread begineer
You need to annotate you POJO fields with @QuerySqlField. This annotation
will make them visible to SQL queries on the cache. Also, you can add
indexes to these fields for better performance.

Both, Java and XML configurations are available
See https://apacheignite.readme.io/docs/cache-queries#sql-queries for
details



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


How Ignite manages primary and secondary nodes

2018-04-22 Thread begineer
Hi,
I am bit confused about how ignite manages which nodes is primary and
secondary. Every distributed grid has some node which has information about
primary and secondary nodes so if primary goes down, one of primary is made
secondary which out any data loss(loss here means if primary node data wan't
completely replicated in secondary before primary went down). How does it
work in ignite.

2. Also, If I send a request to fetch one entry of cache o a grid of 10
nodes say. How does it work? Will the request land in random node, search
key there if not send it to next node and so on. Then if entry is found on
nth node, will the result be sent back to client from nth node or it comes
back to 1st node 

3. Who stores the metadata information, as I understand, there is not master
node in ignite.

Thanks



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Effective Data through DataStream

2018-04-21 Thread begineer
I dont understand why you need to define receiver to update value in the
cache. streamer does is for you. you just need to write something like this

try (IgniteDataStreamer streamer =
ignite.dataStreamer("cacheName")) {

for(Entry entry : maps.entrySet()){ 
stmr.addData(entry.getKey().longValue(),entry.getValue()); 
} 
}

datastreamer will flush the data to cache as soon as try with resources is
completed. you don't even need to flush manually 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Failed to wait for partition map exchange

2018-04-21 Thread begineer
Could you please paste complete log. This log is not enough. 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Ignite Sql Query Execution time is too long

2018-04-05 Thread begineer
Have you tried adding indexes to frequently searched fields ? Indexing can
make searching the cache quite faster



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Data Streamer not flushing data to cache

2018-03-31 Thread begineer
One more query.. Would it never flush the data if nothing more is added to
streamer and current size is less than buffer size ?
What is the default time. I can see only flush frequency 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Data Streamer not flushing data to cache

2018-03-31 Thread begineer
Thanks for reply... Its works after invoking flush(). 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Data Streamer not flushing data to cache

2018-03-31 Thread begineer
Hi, This must be something very simple. I am adding 100 items to data
streamer. But it is not flushing items to cache. Is there a settings much
enables it. Cache size is zero. Am I doing something wrong ?

public class DataStreamerExample {
public static void main(String[] args) throws InterruptedException {
Ignite ignite = Ignition.start("examples/config/example-ignite.xml");
CacheConfiguration config = new
CacheConfiguration<>("mycache");
IgniteCache cache = ignite.getOrCreateCache(config);
IgniteDataStreamer streamer = 
ignite.dataStreamer("mycache");
LongStream.range(1, 100).forEach( l->{
System.out.println("Adding to streamer "+ l);
streamer.addData(l, l);
});
System.out.println(streamer.perNodeBufferSize());
System.out.println("Cache size : "+ cache.size(CachePeekMode.ALL));
cache.query(new ScanQuery<>()).getAll().stream().forEach(entry->{
System.out.println("cache Entry: " + entry.getKey()+" "+
entry.getValue());
});
}
}




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Basic terms in Ignite

2018-03-29 Thread begineer
Thanks Dave for very informative reply. I will come back with some more
questions

Regards,




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Basic terms in Ignite

2018-03-25 Thread begineer
Hi,
I am confused about few terms used often in ignite docs. Could someone
please clarify them.

1. What is difference between a Server, JVM and ignite node. Can one have
multiple instances of other 2, like a jvm has two nodes or a node has 2
jvms. Please explain in detail, I am very confused about them

2. In partitioned mode, can a partition span across multiple nodes. Again
relating to first point. If I have 10 servers of 10GB each so total memory
is 100 GB. Can a partition be created on 2-3 servers of 30 GB size. This is
hypothetical example though.

3. Lets say I have 90 GB data to be loaded on 10 servers of 10GB each. Now
if first ignite node joins the gird and starts loading data. There might be
a chance that it loads so much data that it runs out of memory before new
ones join the grid. How do we handle this scenario. Is there a way to wait
for some condition before kicking of cache loading.

Thanks
Surinder




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Using igniteAtomicLong or igniteAtomicSequence as uniqueId in ignite cache

2017-09-28 Thread begineer
Thanks for reply. Surely this should work.Just one query. Will it work in
distributed environment. We have a grid of nodes and I am trying to do it in
a way that it should be working on cluster of nodes than just one jvm.

Regards



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Continuous Query remote listener misses some events or respond really late

2017-09-28 Thread begineer
Hi..
I know its quite late to reply, But I am seeing this issue intermittently
almost everyday. But can't reproduce it locally on dev machine. As suggested
I have moved logs before null check to see if null event is logged. However,
I didn't see it printed in logs. Also, it was suggested to check if events
(in question) reaches remote listener(log should print), no log is printed
in such scenario so I assume event does not reach remote listener
immediately.

Same event is processed after several hours later. like 4 hours some times
even after one day. 

I tried to add same event manually to cache object, it is processed
immediately 
(only if original event is stuck).

Also, host logs are clean, I couldn't find anything suspicious. 
Please let me know if you want any more information. I will try to fetch it.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Using igniteAtomicLong or igniteAtomicSequence as uniqueId in ignite cache

2017-09-27 Thread begineer
Hi,
My application submits heavy requests from UI which are run in async and
request Id is stored in ignite cache and other request details  as value. I
was looking for a way to generate request id. One way to use AtlomicInteger
but that will not support distributed behavior. So I found igniteAtomicLong
datastructure but not quite sure how would I create its bean in spring.xml
to use it.

If some one can provide some sample example , it would be helpful

Thanks



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Thread Pool Starvation in ignite grid

2017-09-07 Thread begineer
Sure, will check the heap stats.And this is not local node. Its happening in
QA environment which has 12 servers connected to grid.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Thread Pool Starvation in ignite grid

2017-09-07 Thread begineer
Hi,
Any one to the rescue here please.I am finding it hard to understand these
logs. When this starts happening, ignite grid just stops working. Nothing
works unless grid is restarted.

Any helpful would be grateful.

Error log:
[2017-09-07/13:16:47.856/BST][WARN
][grid-timeout-worker-#15%null%][o.a.i.i.u.t.G]  - >>> Possible starvation
in striped pool: sys-stripe-3-#4%null%
[Message closure [msg=GridIoMessage [plc=2, topic=TOPIC_CACHE, topicOrd=8,
ordered=false, timeout=0, skipOnTimeout=false,
msg=GridDhtAtomicUpdateRequest [futVer=GridCacheVersion [topVer=116242068,
time=1504786161899, order=1504763782702, nodeOrder=27],
writeVer=GridCacheVersion [topVer=116242068, time=1504786161899,
order=1504763782701, nodeOrder=27], topVer=AffinityTopologyVersion
[topVer=36, minorTopVer=19], keys=[KeyCacheObjectImpl [val=null,
hasValBytes=true]], vals=[CacheObjectImpl [val=null, hasValBytes=true]],
prevVals=null, ttls=GridLongList [idx=1, arr=[180]],
conflictExpireTimes=null, nearTtls=null, nearExpireTimes=null,
syncMode=FULL_ASYNC, nearKeys=null, nearVals=null,
forceTransformBackups=false, subjId=fbbc8445-c275-4459-9ca6-291918131ee1,
taskNameHash=0, updateCntrs=GridLongList [idx=1, arr=[28]],
keepBinary=false, flags=0, super=GridCacheMessage [msgId=667176,
depInfo=null, err=null, skipPrepare=false, cacheId=99252427,
cacheId=99252427, Message closure [msg=GridIoMessage [plc=2,
topic=TOPIC_CACHE, topicOrd=8, ordered=false, timeout=0,
skipOnTimeout=false, msg=GridDhtAtomicUpdateRequest [futVer=GridCacheVersion
[topVer=116242068, time=1504786161967, order=1504763685550, nodeOrder=34],
writeVer=GridCacheVersion [topVer=116242068, time=1504786161967,
order=1504763685549, nodeOrder=34], topVer=AffinityTopologyVersion
[topVer=36, minorTopVer=19], keys=[KeyCacheObjectImpl [val=null,
hasValBytes=true]], vals=[CacheObjectImpl [val=null, hasValBytes=true]],
prevVals=null, ttls=GridLongList [idx=1, arr=[180]],
conflictExpireTimes=null, nearTtls=null, nearExpireTimes=null,
syncMode=FULL_ASYNC, nearKeys=null, nearVals=null,
forceTransformBackups=false, subjId=fbbc8445-c275-4459-9ca6-291918131ee1,
taskNameHash=0, updateCntrs=GridLongList [idx=1, arr=[33]],
keepBinary=false, flags=0, super=GridCacheMessage [msgId=189850,
depInfo=null, err=null, skipPrepare=false, cacheId=99252427,
cacheId=99252427, Message closure [msg=GridIoMessage [plc=2,
topic=TOPIC_CACHE, topicOrd=8, ordered=false, timeout=0,
skipOnTimeout=false, msg=GridDhtAtomicUpdateRequest [futVer=GridCacheVersion
[topVer=116242068, time=1504786162325, order=1504763687249, nodeOrder=24],
writeVer=GridCacheVersion [topVer=116242068, time=1504786162325,
order=1504763687248, nodeOrder=24], topVer=AffinityTopologyVersion
[topVer=36, minorTopVer=19], keys=[KeyCacheObjectImpl [val=null,
hasValBytes=true]], vals=[CacheObjectImpl [val=null, hasValBytes=true]],
prevVals=null, ttls=GridLongList [idx=1, arr=[180]],
conflictExpireTimes=null, nearTtls=null, nearExpireTimes=null,
syncMode=FULL_ASYNC, nearKeys=null, nearVals=null,
forceTransformBackups=false, subjId=fbbc8445-c275-4459-9ca6-291918131ee1,
taskNameHash=0, updateCntrs=GridLongList [idx=1, arr=[31]],
keepBinary=false, flags=0, super=GridCacheMessage [msgId=182619,
depInfo=null, err=null, skipPrepare=false, cacheId=99252427,
cacheId=99252427, Message closure [msg=GridIoMessage [plc=2,
topic=TOPIC_CACHE, topicOrd=8, ordered=false, timeout=0,
skipOnTimeout=false, msg=GridDhtAtomicUpdateRequest [futVer=GridCacheVersion
[topVer=116242068, time=1504786162376, order=1504763679517, nodeOrder=28],
writeVer=GridCacheVersion [topVer=116242068, time=1504786162376,
order=1504763679516, nodeOrder=28], topVer=AffinityTopologyVersion
[topVer=36, minorTopVer=19], keys=[KeyCacheObjectImpl [val=null,
hasValBytes=true]], vals=[CacheObjectImpl [val=null, hasValBytes=true]],
prevVals=null, ttls=GridLongList [idx=1, arr=[180]],
conflictExpireTimes=null, nearTtls=null, nearExpireTimes=null,
syncMode=FULL_ASYNC, nearKeys=null, nearVals=null,
forceTransformBackups=false, subjId=fbbc8445-c275-4459-9ca6-291918131ee1,
taskNameHash=0, updateCntrs=GridLongList [idx=1, arr=[39]],
keepBinary=false, flags=0, super=GridCacheMessage [msgId=170147,
depInfo=null, err=null, skipPrepare=false, cacheId=99252427,
cacheId=99252427, Message closure [msg=GridIoMessage [plc=2,
topic=TOPIC_CACHE, topicOrd=8, ordered=false, timeout=0,
skipOnTimeout=false, msg=GridDhtAtomicUpdateRequest [futVer=GridCacheVersion
[topVer=116242068, time=1504786162315, order=1504763735961, nodeOrder=20],
writeVer=GridCacheVersion [topVer=116242068, time=1504786162315,
order=1504763735960, nodeOrder=20], topVer=AffinityTopologyVersion
[topVer=36, minorTopVer=19], keys=[KeyCacheObjectImpl [val=null,
hasValBytes=true]], vals=[CacheObjectImpl [val=null, hasValBytes=true]],
prevVals=null, ttls=GridLongList [idx=1, arr=[180]],
conflictExpireTimes=null, nearTtls=null, nearExpireTimes=null,
syncMode=FULL_ASYNC, nearKeys=null, nearVals=null,
forceTransformBackups=false

Re: Serialization exception in Ignite compute job

2017-09-05 Thread begineer
HI,
Thanks. Its clear now. And it solved the issue. Thanks again



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Serialization exception in Ignite compute job

2017-08-31 Thread begineer
Hi,
I am submitting a compute job to ignite compute grid, It worked one time but
now its failing every time.

My compute task is Ignite Runnable so it is serializable but enclosing class
is not. I think outer class does not need to be serializable because inner
class is not anonymous.


/** this class is not serializable**/
public EnclosingFile {

public class CreateConfigItemsRunnable implements IgniteRunnable {

}
}

I found this thread which suggests, inner class should be static. Could you
please explain why will it after marked as static.
http://apache-ignite-users.70518.x6.nabble.com/Re-Serialization-exception-on-Ignite-class-td920.html


Error logs:

org.apache.ignite.IgniteException: Remote job threw user exception (override
or implement ComputeTask.result(..) method if you would like to have
automatic failover for this exception).
at
org.apache.ignite.compute.ComputeTaskAdapter.result(ComputeTaskAdapter.java:101)
~[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.task.GridTaskWorker$5.apply(GridTaskWorker.java:1031)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.task.GridTaskWorker$5.apply(GridTaskWorker.java:1024)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6637)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.task.GridTaskWorker.result(GridTaskWorker.java:1024)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.task.GridTaskWorker.onResponse(GridTaskWorker.java:842)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.task.GridTaskWorker.processDelayedResponses(GridTaskWorker.java:691)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.task.GridTaskWorker.body(GridTaskWorker.java:542)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.task.GridTaskProcessor.startTask(GridTaskProcessor.java:679)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.task.GridTaskProcessor.execute(GridTaskProcessor.java:403)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.closure.GridClosureProcessor.runAsync(GridClosureProcessor.java:233)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.closure.GridClosureProcessor.runAsync(GridClosureProcessor.java:207)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.IgniteComputeImpl.run(IgniteComputeImpl.java:417)
[ignite-core-1.8.2.jar:1.8.2]
at
package{edited}.ignite.WorkflowIgniteComputeImpl.run(WorkflowIgniteComputeImpl.java:22)
[workflow-17.10.34.jar:17.10.34]
at
package{edited}.AdHocDeliveryConfigServiceImpl.create(AdHocDeliveryConfigServiceImpl.java:89)
[app-workflow-17.10.34.jar:17.10.34]
at
package{edited}.AdHocDeliveryConfigFacadeImpl.create(AdHocDeliveryConfigFacadeImpl.java:30)
[app-workflow-17.10.34.jar:17.10.34]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[na:1.8.0_71]
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[na:1.8.0_71]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[na:1.8.0_71]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_71]
at
org.apache.ignite.internal.processors.service.GridServiceProxy$ServiceProxyCallable.call(GridServiceProxy.java:406)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2V2.execute(GridClosureProcessor.java:2056)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:560)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6605)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:554)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:483)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1180)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1894)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1215)
[ignite-core-1.8.2.jar:1.8.2]
at
org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(

Can Ignite SqlFunctions have more than one method

2017-07-04 Thread begineer
Hi,
I need to add two custom sqlfunctions to query ignite cache using
sqlqueries. I followed the example below. My question is can we add more
than one methods(with @QuerySqlFunction annotation) to same class or it has
to be one method per class.
https://github.com/gridgain/gridgain-advanced-examples/blob/master/src/main/java/org/gridgain/examples/datagrid/query/CustomSqlFunctionsExample.java

Regards,
Surinder



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Can-Ignite-SqlFunctions-have-more-than-one-method-tp14306.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Ignite SQL Queries on Lists fields sorting

2017-07-04 Thread begineer
ok thank you



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Ignite-SQL-Queries-on-Lists-fields-sorting-tp14129p14305.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Ignite SQL Queries on Lists fields sorting

2017-06-28 Thread begineer
hey Guys,
I have a question about Ignite Sql Queries. Let say my cache looks like
below sample code. If I add orderBy clause on subjectMarksList, how will it
sort it. Compare values in list by index or how. I coudn't find anything in
docs.


Cache

class Student{
int id;
String name;
List subjectMarksList;

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Student that = (Student) o;
Objects.equals(id, that.id) &&
Objects.equals(name, that.name) &&
Objects.equals(subjectMarksList, that.subjectMarksList);

 hashcode()

}






--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Ignite-SQL-Queries-on-Lists-fields-sorting-tp14129.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Continuous Query remote listener misses some events or respond really late

2017-06-16 Thread begineer
Hi,
Thanks I will move the logging as suggested. And that is correct, we don't
store null in caches.



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Continuous-Query-remote-listener-misses-some-events-or-respond-really-late-tp12338p13873.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Two Continuous Queries listening to same event

2017-06-09 Thread begineer
Hi Guys...
Lets say I have a trade Object as below and I want to set up two ignite
services S1 and S2 which will have Continuous queries(Cq1 and Cq2
respectively) listening to same state of trade(e.g SUCCESS), i.e. if trade
moves to SUCCESS state, these CQs setup in S1 and S2 fires and process them
accordingly.

My question is, will this cause any issues like CQ1 might miss some Trade
event because it is picked up by CQ2.
Please let me know if question is not clear.

public class Trade { 
private int id; 
private TradeStatus status; 
private String tradeType; 
public Trade(int id, TradeStatus status, String tradeType) { 
this.id = id; 
this.status = status; 
this.tradeType = tradeType; 
} 

//setter getter, equals, hashcode methods 
} 
  
public enum TradeStatus { 
NEW, CHANGED, EXPIRED, FAILED, UNCHANGED , SUCCESS 
}



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Two-Continuous-Queries-listening-to-same-event-tp13571.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Continuous Query remote listener misses some events or respond really late

2017-06-07 Thread begineer
Hi.. Sorry its quite late to reply. CQ is setup in execute method of service
not in init(), but we do have initialQuery in CQ to scan existing events to
matching the filter. Below is snapshot of one of the many ignite services
set to process trade on when trade moves to particular status.

As you can see, I have added logs to remote filter predicate. But these logs
don't get printed when trade get stuck at particular status. So I assume,
remote filter does not pick the events it is supposed to track.

public enum TradeStatus { 
NEW, CHANGED, EXPIRED, FAILED, UNCHANGED , SUCCESS 
}


/**
 * Ignite Service which picks up CHANGED trade delivery items
 */
public class ChangedTradeService implements Service{

@IgniteInstanceResource
private transient Ignite ignite;
private transient IgniteCache tradeCache;
private transient QueryCursor> cursor;

@Override
public void init(ServiceContext serviceContext) throws Exception {
tradeCache = ignite.cache("tradeCache");
}

@Override
public void execute(ServiceContext serviceContext) throws Exception {
ContinuousQuery query = new ContinuousQuery<>();
query.setLocalListener((CacheEntryUpdatedListenerAsync)
events -> events
.forEach(event -> process(event.getValue(;
query.setRemoteFilterFactory(factoryOf(checkStatus(status)));
query.setInitialQuery(new 
ScanQuery<>(checkStatusPredicate(status)));
QueryCursor> cursor = 
tradeCache.query(query);
cursor.forEach(entry -> process(entry.getValue()));
}

private void process(Trade item){
 log.info("transition started for trade id :"+item.getPkey());
//move the trade to next state(e.g SUCCESS) and next 
Service(contains CQ,
which is looking for SUCCESS status) will pick this up for processing
further and so on
 log.info("transition finished for trade id :"+item.getPkey()); 
}

@Override
public void cancel(ServiceContext serviceContext) {
cursor.close();
}

static CacheEntryEventFilterAsync checkStatus(TradeStatus
status) {
return event -> event.getValue() != null &&
checkStatusPredicate(status).apply(event.getKey(), event.getValue());
}

static IgniteBiPredicate
checkStatusPredicate(TradeStatus status) {
return (k, v) -> {
LOG.debug("Status checking for: {} Event value: {} 
isStatus: {}", status,
v, v.getStatus() == status);
return v.getStatus() == status;
};
}
}




--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Continuous-Query-remote-listener-misses-some-events-or-respond-really-late-tp12338p13476.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Continuous Query remote listener misses some events or respond really late

2017-05-05 Thread begineer
Thanks, In my application, all nodes are server nodes
And how do we be sure that nodes removed/ reconnect to grid is CQ node, it
can be any. 
Also, Is this issue possible in all below scenarios?
1. if node happens to be CQ node or any node? 
2. node is removed from grid forcefully(manual shutdown)
3. node went down due to some reason and grid dropped it

3rd one looks like safe option since it is dropped by grid so grid should be
ware where to shift the CQ? Please correct me if I am wrong.



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Continuous-Query-remote-listener-misses-some-events-or-respond-really-late-tp12338p12454.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Continuous Query remote listener misses some events or respond really late

2017-05-05 Thread begineer
Umm. actually nothing get logged in such scenario. However, as you indicated
earlier, I could see trades get stuck if a node leaves the grid(not always).
Do you know why that happens? Is that a bug?



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Continuous-Query-remote-listener-misses-some-events-or-respond-really-late-tp12338p12452.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Continuous Query remote listener misses some events or respond really late

2017-05-03 Thread begineer
1) How you use ContinuousQuery: with initialQuery or without? : with initial
query having same predicate
2) Did some nodes disconnect when you loose updates? no
3) Did you log entries in CQ.localListener? Just to be sure that error in CQ
logic, not in your service logic. :  
 No log entries in remote filter, nor in locallistner
4) Can someone update old entries? Maybe they just get into CQ again after
4-5 hours by external update?
   --- I tried adding same events just to trigger event again, some time it
moves ahead(event discovered), some times get stuck at same state.
Also, CQ detects them at its won after long time mentioned, we dont add any
event in this case.
Regards,
Surinder



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Continuous-Query-remote-listener-misses-some-events-or-respond-really-late-tp12338p12387.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Continuous Query remote listener misses some events or respond really late

2017-05-03 Thread begineer
Hi Thanks for looking into this. Its not easily reproduce-able. I only see it
some times. Here is my cache and service configuration

Cache configuration:

readThrough="true"
writeThrough="true"
writeBehindEnabled="true"
writeBehindFlushThreadCount="5"
backups="1"
readFromBackup="true"

service configuartion:

maxPerNodeCount="1" 
totalCount="1"

Cache is distributed over 12 nodes.





--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Continuous-Query-remote-listener-misses-some-events-or-respond-really-late-tp12338p12382.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Continuous Query remote listener misses some events or respond really late

2017-05-02 Thread begineer
Hi,
I am currently facing intermittent issue with continuous query. Cant really
reproduce it but if any one faced this issue, please do let me know
My application is deployed on 12 nodes with 5-6 services are used to detect
respective events using continuous query. 
Lets say I have a cache of type 
Cache where Trade is like this
class Trade{
int pkey,
String type

TradeState state;//enum
}
CQ detects the new entry to cache(with updated state) and checks if trade
has the state which matches its remote filter criteria.
A Trade moves from state1-state5. each CQ listens to one stage and do some
processing and move it to next state where next CQ will detect it and act
accordingly.
Problem is sometimes, trade get stuck in some state and does not move. I
have put logs in remote listener Predicate method(which checks the filter
criteria) but these logs don't get printed on console. Some times CQ detect
events after 4-5 hours.
I am using ignite 1.8.2
Does any one seen this behavior, I will be grateful for help extended



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Continuous-Query-remote-listener-misses-some-events-or-respond-really-late-tp12338.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Detecting terminal condition for group of items in Ignite cache.

2016-12-14 Thread begineer
Thanks for reply first of all. Well I had this in back of my mind but it will
be like duplicating the data which we already have in other cache(trades
cache which I am currently querying).

So other way I can think of is using spring scheduler with 1 minute fix-rate
and check if any item moved to SUCCESS state, if yes, postpone execution by
one minute(something like fix-delay but this works after executing the job,
but my requirement is  it should delay the execution itself.) 

If no more items moved to final state within mentioned time, we execute the
scheduler.

Any suggestions in this approach please or any better one?



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Detecting-terminal-condition-for-group-of-items-in-Ignite-cache-tp9526p9539.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Detecting terminal condition for group of items in Ignite cache.

2016-12-14 Thread begineer
Hi,
My sample application processes trades for different companies stored in
Ignite cache. When all trades for particular company reaches SUCCESS stage,
an automatic notification should be triggered and some other
system/application will react to it. To do this, When ever any trade reaches
SUCCESS stage, I detect it using Continuous query, I am comparing total size
of trades for particular company in cache and the trades for that company
which are in SUCCESS stage. If they are equal, trigger a notification else
wait.
There are two drawbacks with this approach.
1. I have to query through all the trades for that company twice every time
trade reach SUCCESS stage which is really really bad.
2. notification can be triggered multiple times if multiple threads
processing trades in parallel in SUCCESS stage.(i.e lets say last 5 items
reach SUCCESS stage together, so 5 emails will be sent since continuous
query will run local listener 5 times)

Is there a better way to do same task. I am hoping it is. My current
approach cannot work in real time application.

Below is my code.



public class TerminalEventsUsingContQuery {
IgniteCache cache;

public static void main(String[] args) {
new TerminalEventsUsingContQuery().test();
}

private void test() {

Ignite ignite = 
Ignition.start("examples/config/example-ignite.xml");
CacheConfiguration config = new
CacheConfiguration<>("TradesCache");

cache = ignite.getOrCreateCache(config);
ContinuousQuery query = new ContinuousQuery<>();
query.setLocalListener(events -> events.forEach(e ->
process(e.getValue(;

query.setRemoteFilterFactory(factoryOf(e ->
TradeStatus.SUCCESS.equals(e.getValue().getStatus(;
query.setInitialQuery(new ScanQuery((k, v) ->
TradeStatus.SUCCESS.equals(v.getStatus(;
buildData();
QueryCursor> cursor = 
cache.query(query);
cursor.forEach(entry -> process(entry.getValue()));
Trade t9 = new Trade(9, TradeStatus.SUCCESS, "type1", 100);
cache.put(t9.getId(), t9);
}

private void process(Trade trade) {
List> totalperRef = cache
.query(new ScanQuery((k, v) -> 
v.getRef() ==
trade.getRef())).getAll();

List> totalSuccessForRef = 
cache.query(new
ScanQuery(
(k, v) -> v.getRef() == trade.getRef() &&
TradeStatus.SUCCESS.equals(v.getStatus(.getAll();

if (totalperRef.size() == totalSuccessForRef.size()) {
System.out.println("Terminal condition reached. Notify 
the handler for :
" + trade.getRef());
} else {
System.out.println("Terminal condition not reached yet. 
Current
processing Trade : " + trade.getId());
}
}

private void buildData() {
Trade t1 = new Trade(1, TradeStatus.SUCCESS, "type1", 100);
Trade t2 = new Trade(2, TradeStatus.FAILED, "type1", 101);
Trade t3 = new Trade(3, TradeStatus.EXPIRED, "type1", 102);
Trade t4 = new Trade(4, TradeStatus.SUCCESS, "type1", 100);
Trade t5 = new Trade(5, TradeStatus.CHANGED, "type1", 103);
Trade t6 = new Trade(6, TradeStatus.SUCCESS, "type1", 100);
Trade t7 = new Trade(7, TradeStatus.CHANGED, "type1", 103);
Trade t8 = new Trade(8, TradeStatus.SUCCESS, "type1", 101);
cache.put(t1.getId(), t1);
cache.put(t2.getId(), t2);
cache.put(t3.getId(), t3);
cache.put(t4.getId(), t4);
cache.put(t5.getId(), t5);
cache.put(t6.getId(), t6);
cache.put(t7.getId(), t7);
cache.put(t8.getId(), t8);
}
}

public class Trade { 
private int id; 
private TradeStatus status; 
private String tradeType; 
public Trade(int id, TradeStatus status, String tradeType) { 
this.id = id; 
this.status = status; 
this.tradeType = tradeType; 
} 

//setter getter, equals, hashcode methods 
}
 
public enum TradeStatus { 
NEW, CHANGED, EXPIRED, FAILED, UNCHANGED , SUCCESS
}



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Detecting-terminal-condition-for-group-of-items-in-Ignite-cache-tp9526.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Building complex queries to query ignite Cache

2016-12-14 Thread begineer
Thanks for reply. 
This is perfect and much simpler if I have to get counts of various
statuses.
Although using this approach to build 3D kind of mapping(i.e. sample table
shown in reply 2 in this thread) requires a lot of manipulation to data.

Thanks all for help. Will come back again if more help required.




--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Building-complex-queries-to-query-ignite-Cache-tp9392p9524.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Building complex queries to query ignite Cache

2016-12-05 Thread begineer
Hi, Thanks for reply. I need this map to build a dashboard UI page which
looks like below(image attached). So specific part of entries would still be
more than 100,000 items which is minimum as data set for given input
parameters.
So just wondering if some inbuilt query could help me here.
 



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Building-complex-queries-to-query-ignite-Cache-tp9392p9395.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Building complex queries to query ignite Cache

2016-12-05 Thread begineer
Hi, I have below sample bean which I am storing as value in cache. I want to
build a map such that it gives me count of trade status for each trade
type(Pls see sample output, done thru java 8 streams). 
Problem with this approach is I have to pull millions of entries from cache
to some collection and manipulate them.

Is there a way to query cache using SQL/ScanQueries to build same map in
more efficient way. Below is my sample code to explain the problem.

public class TradeCacheExample {
public static void main(String[] args) {
Trade trade1 = new Trade(1, TradeStatus.NEW, "type1");
Trade trade2 = new Trade(2, TradeStatus.FAILED, "type2");
Trade trade3 = new Trade(3, TradeStatus.NEW, "type1");
Trade trade4 = new Trade(4, TradeStatus.NEW, "type3");
Trade trade5 = new Trade(5, TradeStatus.CHANGED, "type2");
Trade trade6 = new Trade(6, TradeStatus.EXPIRED, "type1");

Ignite ignite = 
Ignition.start("examples/config/example-ignite.xml");
CacheConfiguration config = new
CacheConfiguration<>("mycache");
config.setIndexedTypes(Integer.class, Trade.class);
IgniteCache cache = 
ignite.getOrCreateCache(config);
cache.put(trade1.getId(), trade1);
cache.put(trade2.getId(), trade2);
cache.put(trade3.getId(), trade3);
cache.put(trade4.getId(), trade4);
cache.put(trade5.getId(), trade5);
cache.put(trade6.getId(), trade6);
List trades = cache.query(new ScanQuery()).getAll().stream().map(item->item.getValue()).collect(toList());

Map> resultMap =
trades.stream().collect(
groupingBy(item -> item.getTradeType(), 
groupingBy(Trade::getStatus,
counting(;
System.out.println(resultMap);
//{type3={NEW=1}, type2={CHANGED=1, FAILED=1}, 
type1={EXPIRED=1, NEW=2}}
}
}

public class Trade {
private int id;
private TradeStatus status;
private String tradeType;
public Trade(int id, TradeStatus status, String tradeType) {
this.id = id;
this.status = status;
this.tradeType = tradeType;
}

//setter getter, equals, hashcode methods

public enum TradeStatus {
NEW, CHANGED, EXPIRED, FAILED, UNCHANGED
}




--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Building-complex-queries-to-query-ignite-Cache-tp9392.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Getting exception in SQL Query JOINS

2016-08-22 Thread begineer
OK thanks



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Getting-exception-in-SQL-Query-JOINS-tp6674p7228.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Getting exception in SQL Query JOINS

2016-08-22 Thread begineer
I have one more related question to this,
Is there a limit to size of array passed. If we use IN clause, Oracle allows
maximum size of 1000



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Getting-exception-in-SQL-Query-JOINS-tp6674p7203.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Getting exception in SQL Query JOINS

2016-08-08 Thread begineer
Thanks it worked 
I changed my code as below 
query1.setArgs(new Object[] {args1.toArray()});



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Getting-exception-in-SQL-Query-JOINS-tp6674p6867.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: SQLQuery JOIN does not accept multiple parameters in list/array as placeholder.

2016-08-08 Thread begineer
Thanks It worked !



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/SQLQuery-JOIN-does-not-accept-multiple-parameters-in-list-array-as-placeholder-tp6837p6868.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: SQLQuery JOIN does not accept multiple parameters in list/array as placeholder.

2016-08-08 Thread begineer
Can some one please reply to this. Is it a bug or I am doing something wrong.



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/SQLQuery-JOIN-does-not-accept-multiple-parameters-in-list-array-as-placeholder-tp6837p6854.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


SQLQuery JOIN does not accept multiple parameters in list/array as placeholder.

2016-08-07 Thread begineer
Hi,
I am trying to use SqlQuery JOIN clause as mentioned in below link which is
work around to avoid IN clause of Sql Query.
As mentioned in docuents, we can pass array or lits of parameters, but query
does not accept array or list with more than one parameter
http://apacheignite.gridgain.org/docs/sql-queries#performance-and-usability-considerations

I have written small program to verify it.

public class SQLJoinPOC {
public static void main(String[] args) {

Ignite ignite = 
Ignition.start("examples/config/example-ignite.xml");
CacheConfiguration config = new
CacheConfiguration<>("students");
config.setIndexedTypes(Integer.class, Student.class);

IgniteCache students = 
ignite.getOrCreateCache(config);
Student student1 = new Student(1, "John");
Student student2 = new Student(2, "Doe");
Student student3 = new Student(3, "kathy");
Student student4 = new Student(4, "Siera");
students.put(student1.getId(), student1);
students.put(student2.getId(), student2);
students.put(student3.getId(), student3);
students.put(student4.getId(), student4);
List list = Arrays.asList(2,3);
/*StringBuffer queryStrings = new StringBuffer(" ");
for (Object object : list) {
queryStrings.append("?,");
}
queryStrings.deleteCharAt(queryStrings.length() - 1);
String sql = "select * from Student where Id in 
("+queryStrings+")";*/
String sql = "select s.* from STUDENT s join table(id bigint = 
?) i on
s.Id = i.Id";
SqlQuery query1 = new 
SqlQuery<>(Student.class, sql);
query1.setArgs(list.toArray());

List> res1 = 
students.query(query1).getAll();
for (Entry entry : res1) {
System.out.println(entry.getKey() + " " + 
entry.getValue());
}
}
}


public class Student implements Serializable{
@QuerySqlField(index=true)
private int Id;
@QuerySqlField(index=true)
private String name;

public int getId() {
return Id;
}

public void setId(int id) {
Id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Student(int id, String name) {
Id = id;
this.name = name;
}

@Override
public int hashCode() {
return Objects.hash(Id, name);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Student other = (Student) obj;
return Objects.equals(Id, other.getId()) && Objects.equals(name,
other.getName());
}

@Override
public String toString() {
return "Student [Id=" + Id + ", name=" + name + "]";
}

}


Exception:

Exception in thread "main" javax.cache.CacheException: class
org.apache.ignite.IgniteException: Failed to bind parameters: [qry=SELECT
s._key, s._val from STUDENT s join table(id bigint = ?) i on s.Id = i.Id,
params=[2, 3]]
at
org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:700)
at com.test.ignite.sample.SQLJoinPOC.main(SQLJoinPOC.java:44)
Caused by: class org.apache.ignite.IgniteException: Failed to bind
parameters: [qry=SELECT s._key, s._val from STUDENT s join table(id bigint =
?) i on s.Id = i.Id, params=[2, 3]]
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.queryTwoStep(GridQueryProcessor.java:837)
at
org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:682)
... 1 more
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to bind
parameters: [qry=SELECT s._key, s._val from STUDENT s join table(id bigint =
?) i on s.Id = i.Id, params=[2, 3]]
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:1787)
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.queryTwoStep(GridQueryProcessor.java:830)
... 2 more
Caused by: javax.cache.CacheException: Failed to bind parameters:
[qry=SELECT s._key, s._val from STUDENT s join table(id bigint = ?) i on
s.Id = i.Id, params=[2, 3]]
at
org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryTwoStep(IgniteH2Indexing.java:1083)
at
org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.q

Re: Getting exception in SQL Query JOINS

2016-08-04 Thread begineer
Does it work for single parameter only. If I pass list to query.setArgs(), I
get below exception
If I pass single value to setArgs, it works fine.
BUt it does not accept list/array of values.

Failed to execute query...
Caused by: org.h2.jdbc.JdbcSQLException: Data conversion error converting
"'[2, 3, 5]' (ID BIGINT)"; SQL statement:
SELECT
C._KEY __C0,
C._VAL __C1
FROM TABLE(ID BIGINT=?1) I 
 INNER JOIN "companies".COMPANY C
WHERE C.ID = I.ID [22018-175]

I changed list to list.toArray(), below exception is thrown"
Caused by: org.h2.jdbc.JdbcSQLException: Invalid value "2" for parameter
"parameterIndex" [90008-175]




--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Getting-exception-in-SQL-Query-JOINS-tp6674p6735.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Getting exception in SQL Query JOINS

2016-08-04 Thread begineer
So What I mean is I need to get data from cache which has keys in the list I
pass to query.
equavalent SQL will be like, 
List list = Arrays.asList(2,3,6);//dynamic list coming from client
StringBuffer queryStrings = new StringBuffer(" ");
for (Object object : list) {
queryStrings.append("?,");
}
queryStrings.deleteCharAt(queryStrings.length()-1);

String sql = "select * from Company where Id in (?);
SqlQuery query1 =  new 
SqlQuery<>(Company.class, sql);
query1.setArgs(queryStrings.toString());

Here, I can append as many keys to stringbuffer as I want and then pass them
to IN clause. BUt this is not good approach and plus IN will not use
indexing.

How do I achieve same thing using table JOIN approach you suggested.



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Getting-exception-in-SQL-Query-JOINS-tp6674p6732.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Getting exception in SQL Query JOINS

2016-08-03 Thread begineer
Cant we have multiple indexTypes for one cache. I have created my
configuration from below Ignite Documentations:
https://apacheignite.readme.io/docs/sql-queries#configuring-sql-indexes-using-queryentity

  

 


 


 Can't I add one more field to indexes like below :



 




--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Getting-exception-in-SQL-Query-JOINS-tp6674p6702.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Getting exception in SQL Query JOINS

2016-08-03 Thread begineer
Thanks... It did not help. 
I cannot use getAll() because I want to get all records which matches the
Ids passed dynamically.



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Getting-exception-in-SQL-Query-JOINS-tp6674p6697.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Getting exception in SQL Query JOINS

2016-08-02 Thread begineer
I want to get data from ignite cache for list of keys which I can pass in IN
clause of SQL Query. BUt since IN does not take dynamic parameters, I
followed  this

 
link to use JOIN to perform my task, Unfortunately I am getting below
exception. Can some one help please.


public static void test() throws InterruptedException{
Ignite ignite = 
Ignition.start("examples/config/example-ignite.xml");
CacheConfiguration ccfg = new
CacheConfiguration<>("companies");
ccfg.setIndexedTypes(Integer.class, Company.class);
ccfg.setIndexedTypes(LocalDate.class, Company.class);

IgniteCache companies = 
ignite.getOrCreateCache(ccfg);
List persons = new ArrayList<>();
List persons1 = new ArrayList<>();
persons.add(new Person(1, 1, "john", "Doe", "", 2000,
Date.valueOf(LocalDate.of(1989, 1, 9;
persons1.add(new Person(2, 2, "Kathy", "Siera", "", 
2000,
Date.valueOf(LocalDate.of(1979, 1, 9;

Company c1 = new Company(Integer.valueOf(1), 
"Comp1",LocalDate.of(1990,
9, 3), Date.valueOf(LocalDate.of(2016, 03, 03)),
Arrays.asList("bangalore","US"),persons);
Company c2 = new Company(Integer.valueOf(2), 
"comp2",LocalDate.of(1995,
6, 1), Date.valueOf(LocalDate.of(2016, 03, 03)),
Arrays.asList("Mumbai","UK"),persons1);
Company c3 = new Company(Integer.valueOf(3), 
"comp3",LocalDate.of(1997,
8, 5), Date.valueOf(LocalDate.of(2016, 03, 03)),
Arrays.asList("CA","US"),persons);
Company c4 = new Company(Integer.valueOf(4), 
"comp4",LocalDate.of(2005,
3, 21), Date.valueOf(LocalDate.of(2016, 03, 03)),
Arrays.asList("GGN","US"),persons1);
Company c5 = new Company(Integer.valueOf(5), 
"GG",LocalDate.of(2010, 2,
23), Date.valueOf(LocalDate.of(2016, 03, 03)),
Arrays.asList("GM","US"),persons);
Company c6 = new Company(Integer.valueOf(6), 
"APache",LocalDate.of(2013,
9, 13), Date.valueOf(LocalDate.of(2016, 03, 03)),
Arrays.asList("RS","US"),persons1);
companies.put(c1.getId(), c1);
companies.put(c2.getId(), c2);
companies.put(c3.getId(), c3);
companies.put(c4.getId(), c4);
companies.put(c5.getId(), c5);
companies.put(c6.getId(), c6);

String sortby = "id";
String orderBy = "desc";
String startdate = "3Mar16";
List list = Arrays.asList(2,3,6);

String sql ="select * from COMPANY p join table(id 
bigint = ?) i on p.id
= i.id";
SqlQuery query1 =  new 
SqlQuery<>(Company.class, sql);
query1.setArgs(list.toArray());
long start = System.currentTimeMillis();
List> res1=  
companies.query(query1).getAll();
Thread.sleep(1000);
long end = System.currentTimeMillis();
System.out.println("time tken : "+(end-start)/1000);
for (Entry entry : res1) {
System.out.println(entry.getKey()+ " 
"+entry.getValue());
}   
}

public class Company {

@QuerySqlField(index=true)
private int id ;

@QuerySqlField(index=true)
private String name;
@QuerySqlField
private LocalDate startDate;
@QuerySqlField(index=true)
private Date inaguration;
@QuerySqlField
private List offices = new ArrayList<>();
@QuerySqlField
private List employees = new ArrayList<>();
...setters/getters
}

Exception :

Exception in thread "main" javax.cache.CacheException: class
org.apache.ignite.IgniteException: Failed to parse query: SELECT
"companies".Company._key, "companies".Company._val from COMPANY p join
table(id bigint = ?) i on p.id = i.id
at
org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:700)
at com.test.ignite.sample.DataGrid.test(DataGrid.java:78)
at com.test.ignite.sample.DataGrid.main(DataGrid.java:27)
Caused by: class org.apache.ignite.IgniteException: Failed to parse query:
SELECT "companies".Company._key, "companies".Company._val from COMPANY p
join table(id bigint = ?) i on p.id = i.id
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.queryTwoStep(GridQueryProcessor.java:837)
at
org.apache.ignite.internal.processors.cache.IgniteCache

Re: Is there any such thing as SQlBuilder in apache Ignite for SQLQuery

2016-07-28 Thread begineer
basically, that does not help me. There will be multiple requests coming to
query the cache which will need data between limit and Offset. PageSize
helps in how data is fetched from cache(i.e in batches of pageSize). but
not for pagination to UI. For example, top 20  for 25th July, may be next
request is top 20 highest payed employees. Without limit and offset, I will
have to iterate through all records to get required ones.

On Thu, Jul 28, 2016 at 5:11 AM, vkulichenko [via Apache Ignite Users] <
ml-node+s70518n6572...@n6.nabble.com> wrote:

> You can query without OFFSET .. LIMIT and iterate through the QueryCursor,
> it will automatically fetch data in pages. The page size is defined by
> pageSize property on the query object. But this will only allow you to go
> forward, you will not be able to return to previous page or go to any
> random page.
>
> -Val
>
> --
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-ignite-users.70518.x6.nabble.com/Is-there-any-such-thing-as-SQlBuilder-in-apache-Ignite-for-SQLQuery-tp6541p6572.html
> To unsubscribe from Is there any such thing as SQlBuilder in apache Ignite
> for SQLQuery, click here
> 
> .
> NAML
> 
>




--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Is-there-any-such-thing-as-SQlBuilder-in-apache-Ignite-for-SQLQuery-tp6541p6595.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite - Using - complex object with nested attributes and search

2016-07-28 Thread begineer
vkulichenko, I have an example where I store Employee object in cache. 

public class Employee {
@QuerySqlField(index=true)
private String name;
@QuerySqlField(index=true)
private List addresses;
}

public class Address {
private String street;
private String city;
}

H2 console contains these fields in columns as below: I can even search
addresses using LIKE %txt%

_KEY : 1  
_VAL :  com.test.ignite.markit.Employee [idHash=878529620, hash=1730337646,
name=John, addresses=[com.test.ignite.markit.Address [idHash=1265060964,
hash=883380345, city=NY, street=street1], com.test.ignite.markit.Address
[idHash=1274742681, hash=54960993, city=UT, street=street1]]]   
NAME : John 
ADDRESSES : [com.test.ignite.markit.Address [idHash=1777853918,
hash=883380345, city=NY, street=street1], com.test.ignite.markit.Address
[idHash=932592472, hash=54960993, city=UT, street=street1]]




--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Ignite-Using-complex-object-with-nested-attributes-and-search-tp6556p6583.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Is there any such thing as SQlBuilder in apache Ignite for SQLQuery

2016-07-27 Thread begineer
Thanks... Is there a better way to implement pagination which will take
updates into account ? Unfortunately, I could not find any help from
documentation to properly implement pagination



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Is-there-any-such-thing-as-SQlBuilder-in-apache-Ignite-for-SQLQuery-tp6541p6560.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Is there any such thing as SQlBuilder in apache Ignite for SQLQuery

2016-07-26 Thread begineer
I am using sql queries to implement pagination in ignite cache. Below is my
code to build sql to be passed to SQLQuery. It looks very messy as there are
lot of checks and if else. Is there something in ignite like builder which
will do the task?

String sql = " select * from Employee"
private String buildSql(String sql, String sortByField, String sortOrder,
Integer startIndex, Integer endIndex) {
boolean isOrdered = false;
if (DataConstants.START_DATE.equals(sortByField)) {
sql = sql + "order by " + DataConstants.START_DATE;
isOrdered = true;
} else if (DataConstants.ISACTIVE.equals(sortByField)) {
sql=sql +"order by "+DataConstants.ISACTIVE;
isOrdered = true;
}...
  
  .
if (isOrdered && 
DataConstants.DESCENDING_ORDER.equals(sortOrder)) {
sql = sql + " " + DataConstants.DESCENDING_ORDER;
}
if (startIndex != null) {
sql = sql + " limit " + startIndex;
if (endIndex != null) {
sql = sql + " , " + endIndex;
}
}
return sql;
}



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Is-there-any-such-thing-as-SQlBuilder-in-apache-Ignite-for-SQLQuery-tp6541.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: cursor.getAll() throws NoSuchMethodError excepion when SqlQuery is executed

2016-07-23 Thread begineer
With the help of Ignite community member, it is resolved. I was using two
different versions of ignite components in different modules of application.

Thanks !



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/cursor-getAll-throws-NoSuchMethodError-excepion-when-SqlQuery-is-executed-tp6489p6492.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


cursor.getAll() throws NoSuchMethodError excepion when SqlQuery is executed

2016-07-23 Thread begineer

I am getting below exception when i call getAll() on cursor returned from
SqlQuery. My POJO class fields are annotated with @QuerySqlField(index=true)
except the ones which are collections(Set and Lits of other cutom Objet. I
have enabled indexing in cache using below configuration
 

java.lang.Long
pckage.MyPojo



I am not getting which method it is looking for?

java.lang.NoSuchMethodError:
org.apache.ignite.internal.processors.cache.GridCacheAffinityManager.assignment(Lorg/apache/ignite/internal/processors/affinity/AffinityTopologyVersion;)Lorg/apache/ignite/internal/processors/affinity/GridAffinityAssignment;
at
org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.stableDataNodes(GridReduceQueryExecutor.java:392)
at
org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.query(GridReduceQueryExecutor.java:498)
at
org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing$2.iterator(IgniteH2Indexing.java:971)
at
org.apache.ignite.internal.processors.cache.QueryCursorImpl.iterator(QueryCursorImpl.java:61)
at
org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing$3.iterator(IgniteH2Indexing.java:1005)
at
org.apache.ignite.internal.processors.cache.QueryCursorImpl.iterator(QueryCursorImpl.java:61)
at
org.apache.ignite.internal.processors.cache.QueryCursorImpl.getAll(QueryCursorImpl.java:73)
..
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.apache.ignite.internal.processors.service.GridServiceProxy$ServiceProxyCallable.call(GridServiceProxy.java:387)
at
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2V2.execute(GridClosureProcessor.java:2004)
at
org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:509)
at
org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6442)
at
org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:503)
at
org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:456)
at
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
at
org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1167)
at
org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1772)
at
org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1058)
at
org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:836)
at
org.apache.ignite.internal.managers.communication.GridIoManager.access$1700(GridIoManager.java:104)
at
org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:799)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2016-07-23 16:22:04,680 [pub-#2%null%] ERROR  
org.apache.ignite.internal.processors.job.GridJobWorker  -- Failed to
execute job [jobId=41fde571651-bb402db9-402a-4fb1-9ba8-aa0d7c307b32,
ses=GridJobSessionImpl [ses=GridTaskSessionImpl
[taskName=o.a.i.i.processors.service.GridServiceProxy$ServiceProxyCallable,
dep=LocalDeployment [super=GridDeployment [ts=1469270628001, depMode=SHARED,
clsLdr=java.net.URLClassLoader@2f983be1,
clsLdrId=43c1a571651-bb402db9-402a-4fb1-9ba8-aa0d7c307b32, userVer=0,
loc=true, sampleClsName=java.lang.String, pendingUndeploy=false,
undeployed=false, usage=0]],
taskClsName=o.a.i.i.processors.service.GridServiceProxy$ServiceProxyCallable,
sesId=31fde571651-d3d8faee-5240-4cdd-9cae-e1b855a0be4d,
startTime=1469271049483, endTime=9223372036854775807,
taskNodeId=d3d8faee-5240-4cdd-9cae-e1b855a0be4d,
clsLdr=java.net.URLClassLoader@2f983be1, closed=false, cpSpi=null,
failSpi=null, loadSpi=null, usage=1, fullSup=false,
subjId=d3d8faee-5240-4cdd-9cae-e1b855a0be4d, mapFut=IgniteFuture
[orig=GridFutureAdapter [resFlag=0, res=null, startTime=1469271049487,
endTime=0, ignoreInterrupts=false, lsnr=null, state=INIT]]],
jobId=41fde571651-bb402db9-402a-4fb1-9ba8-aa0d7c307b32]]
org.apache.ignite.IgniteException: null
at
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2V2.execute(GridClosureProcessor.java:2007)
~[ignite-core-1.5.22.jar:1.5.22]
at
org.apache.ignite.internal.processors.job.GridJobWorker$2.call(G

Re: Column not found exception while running SqlQuery i Ignite.

2016-07-22 Thread begineer
Hi Thanks, Sorry for typo, It still does not work. 



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Column-not-found-exception-while-running-SqlQuery-i-Ignite-tp6464p6480.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.