Invoking instance of Ignite service which is deployed together with a cache data

2018-09-13 Thread Maxim Malygin
Hi Guys,

I have a service (Ignite Service Grid) which deploys on each node in
cluster (one instance per node). The service has a method which reads data
from a partitioned cache by a key which is passed as parameter of the
method. I'd like to invoke an instance of the service which is deployed on
the same node the key points to. In other words I need to invoke service
which is deployed on the same node where a cache data is stored. Is it
possible?

Thanks,
Maxim


Constant affinity key for some set of caches

2018-07-26 Thread Maxim Malygin
Hi,

I'd like to keep some set of caches together. In other words, I need that
all elements of, for example, cache1 and cache2 were collocated to one node.
I can do it by adding some additional field to their keys and initialize it
with the same constant value for all caches. But I don't want keep this
additional field as part of key because it will eat additional memory and
will do my code more complex.

Is it possible to do it without an additional field in keys?
I know there is AffinityKeyMapper which can be configured in
CacheConfiguration but it's marked as deprecated in 2.6.0.

Thanks,
Maxim


Re: Java API for SQL queries

2018-07-24 Thread Maxim Malygin
Really? How about DML statements?

Regards,
Maxim

вт, 24 июл. 2018 г. в 15:06, Evgenii Zhuravlev :

> I'm not sure that this case is valid at all right now, since as for now,
> Ignite doesn't support transactions for SQL.
>
> Evgenii
>
> 2018-07-24 13:36 GMT+03:00 Maxim Malygin :
>
>> Hi Evgenii,
>>
>> Thanks for the answer.
>> Unfortunately it seems it does matter. If I do a query inside a
>> transaction and use an instance of a cache that differs of a cache inside
>> the query, I will get the following exception (note I do it on client node):
>>
>> Exception in thread "main" javax.cache.CacheException: Cannot start/stop
>> cache within lock or transaction.
>> at
>> org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl.query(IgniteCacheProxyImpl.java:676)
>> at
>> org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl.query(IgniteCacheProxyImpl.java:615)
>> at
>> org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.query(GatewayProtectedCacheProxy.java:356)
>> at simax.test.Startup.main(Startup.java:39)
>> Caused by: class org.apache.ignite.IgniteException: Cannot start/stop
>> cache within lock or transaction.
>> at
>> org.apache.ignite.internal.processors.cache.GridCacheProcessor.checkEmptyTransactions(GridCacheProcessor.java:4251)
>> at
>> org.apache.ignite.internal.processors.cache.GridCacheProcessor.dynamicStartCache(GridCacheProcessor.java:2942)
>> at
>> org.apache.ignite.internal.processors.cache.GridCacheProcessor.dynamicStartCache(GridCacheProcessor.java:2884)
>> at
>> org.apache.ignite.internal.processors.cache.GridCacheProcessor.createMissingQueryCaches(GridCacheProcessor.java:4114)
>> at
>> org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.prepareStatementAndCaches(IgniteH2Indexing.java:2017)
>> at
>> org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.parseAndSplit(IgniteH2Indexing.java:1796)
>> at
>> org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.querySqlFields(IgniteH2Indexing.java:1652)
>> at
>> org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:2035)
>> at
>> org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:2030)
>> at
>> org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36)
>> at
>> org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:2578)
>> at
>> org.apache.ignite.internal.processors.query.GridQueryProcessor.querySqlFields(GridQueryProcessor.java:2044)
>> at
>> org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl.query(IgniteCacheProxyImpl.java:664)
>>
>> It seems the issue is in starting cache used in the query. If I get
>> IgniteCache instance for that cache, it will be started before the
>> transaction. But if it's never used in Ignite.cache(..) or
>> ignite.getOrCreateCache(..), the cache will be started inside query(..)
>> method which is executed in the transaction and I will get the above listed
>> exception. As workaround, I need to pre-initialize all caches used in
>> queries using either Ignite.cache(..) or ignite.getOrCreateCache(..). Note
>> that all caches are configured in XML configuration on server nodes only
>> but the queries is executed on a client node.
>>
>> The code is very simple:
>>
>> public class Startup {
>> private static final Logger log = LogManager.getLogger(Startup.class);
>>
>> public static void main(String[] args) {
>>boolean client = args.length >= 1 &&
>> "client".equalsIgnoreCase(args[0]);
>>Ignite ignite;
>> if (client) {
>> log.info("Starting client node...");
>> ignite = Ignition.start("client.xml");
>> } else {
>> log.info("Starting server node...");
>> ignite = Ignition.start("server.xml");
>> }
>> log.info("Cache names: " + ignite.cacheNames());
>> IgniteCache cache1 = ignite.cache("Cache1");
>>
>> try (Transaction tx = ignite.transactions().txStart()) {
>> // query from cache1 using instance of cache1
>> List> r1 = cache1.query(new SqlFieldsQuery("SELECT *
>> FROM Cache1")).getAll(); // No exception here because Cache1 

Java API for SQL queries

2018-07-23 Thread Maxim Malygin
Hi,

I have the question regarding Java API for SQL queries.
As I understand from the documentation, API for SQL queries is placed in
IgniteCache interface ("query" method). This means that I need to get or
create a cache to do a SQL query. What cache name I should use to get
instance of IgniteCache? Some dummy cache?

Thanks,
Maxim


Re: Cache configuration in case of Client mode

2018-07-05 Thread Maxim Malygin
Please show stack trace of your NPE.

Regards,
Maxim

чт, 5 июл. 2018 г. в 14:48, Prasad Bhalerao :

> Don't want to use that method.  I know that cache is already present on
> server node as it is loaded by loaders and this ignite.cache method is
> present in my common framework.
>
> Thanks,
> Prasad
>
> On Thu, Jul 5, 2018, 5:14 PM Sambhaji Sawant 
> wrote:
>
>> try using
>> ignite.getOrCreateCache("cacheName");
>>
>> On Thu, Jul 5, 2018 at 3:49 PM, Prasad Bhalerao <
>> prasadbhalerao1...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I have provided the cache configurations on ignite node which is started
>>> in server mode,but other ignite node which started in client mode does not
>>> have any cache configurations.
>>>
>>> Now case is cache is present on ignite server node. But when I access
>>> the same cache from client node I get NullPointerException when I execute
>>> following code on client node.
>>>
>>> ignite.cache(getCacheName())
>>>
>>> Is it necessary to provide all cache configuration on client node as
>>> well?
>>> If yes why?
>>>
>>> Thanks,
>>> Prasad
>>>
>>
>>


Does Ignite support something like "database" from mysql?

2018-07-04 Thread Maxim Malygin
Hi Guys,

I 'd like to have isolated caches/tables for multiple tenants. In mysql I
can do it by creating databases per tenant. Is it possible to do something
like this in Ignite?
I can create unique tables per tenant (for example
-) but it's very uncomfortable in use.

Also I'm trying to understand how Ignite caches maps to Ignite SQL tables.
For example I create simple cache with the following configuration






Is it possible to query this cache via SQL? What table name should be in
query?

Thanks,
Maxim