Re: Cache configuration in case of Client mode

2018-07-05 Thread Вячеслав Коптилин
Oh, I see now that we are talking about Factory
:)
Yes, it looks like a usability issue or even a bug. The implementation
should inject dependencies into that factory in the same way it does for
CacheStoreFactory.
As a workaround, you can try the following:

private CacheConfiguration ipContainerIPV4CacheCfg() {
CacheConfiguration ipContainerIpV4CacheCfg = new
CacheConfiguration<>(CacheName.IP_CONTAINER_IPV4_CACHE.name());
Factory storeFactory =
FactoryBuilder.factoryOf(IpContainerIpV4CacheLoader.class);
ipContainerIpV4CacheCfg.setCacheStoreFactory(storeFactory);
ipContainerIpV4CacheCfg.setCacheStoreSessionListenerFactories(new
Factory() {
@Override public CacheStoreSessionListener create() {
return new TestCacheStoreSessionListener();
}
});

...
}

public class TestCacheStoreSessionListener extends
CacheJdbcStoreSessionListener {
@SpringApplicationContextResource
public void setupDataSourceFromSpringContext(Object appCtx) {
ApplicationContext appContext = (ApplicationContext) appCtx;
setDataSource((DataSource) appContext.getBean("dataSource"));
}
}

Best regards,
Slava.

чт, 5 июл. 2018 г. в 18:44, Prasad Bhalerao :

>
> I tried to debug the ignite code, GridResourceProcessor.inject is not
>> being executed for injecting resources into CacheStoreSessionListener. It
>> is being called for Cachestores.
>>
>> Can you please advise?
>>
>> Thanks,
>> Prasad
>>
>> On Thu, Jul 5, 2018 at 8:14 PM Prasad Bhalerao <
>> prasadbhalerao1...@gmail.com> wrote:
>>
>>> I had used SpringApplicationContextResource  annotation. But it did not
>>> inject the application context in it. So I decided to use spring managed
>>> bean and it worked but now it is creating the problem which is described in
>>> this mail chain.
>>>
>>> On Thu, Jul 5, 2018 at 8:11 PM Prasad Bhalerao <
>>> prasadbhalerao1...@gmail.com> wrote:
>>>
 I had used SpringApplicationContextResource  annotation. But it did not
 inject the application context in it. So I decided to use spring managed
 bean and it worked.

 Thanks,
 Prasad

 On Thu, Jul 5, 2018 at 7:49 PM Вячеслав Коптилин <
 slava.kopti...@gmail.com> wrote:

> It seems that you need to use @
>
> SpringApplicationContextResource
>
> instead of @Autowired.
> Could you please check that?
>
> Thanks.
>
> чт, 5 июл. 2018 г. в 17:01, Prasad Bhalerao <
> prasadbhalerao1...@gmail.com>:
>
>>
>>
>> import java.io.Serializable;
>> import javax.cache.configuration.Factory;
>> import javax.sql.DataSource;
>> import org.apache.ignite.IgniteException;
>> import org.apache.ignite.cache.store.CacheStoreSessionListener;
>> import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener;
>> import org.springframework.beans.factory.annotation.Autowired;
>> import org.springframework.context.ApplicationContext;
>>
>> public class CacheStoreSessionListenerFactory implements 
>> Factory, Serializable {
>>
>>   private static final long serialVersionUID = 6142932447545510244L;
>>
>>   private String className;
>>
>>   @Autowired
>>   private transient ApplicationContext appCtx;
>>
>>
>>   public 
>> CacheStoreSessionListenerFactory(Class clazz) 
>> {
>> this.className = clazz.getName();
>>   }
>>
>>   @Override
>>   public CacheStoreSessionListener create() {
>>
>> if (appCtx == null) {
>>   throw new IgniteException("Spring application context resource is 
>> not injected.");
>> }
>> CacheJdbcStoreSessionListener lsnr = new 
>> CacheJdbcStoreSessionListener();
>> lsnr.setDataSource((DataSource) appCtx.getBean("dataSource"));
>> return lsnr;
>>
>>   }
>>
>> }
>>
>>
>>
>> On Thu, Jul 5, 2018 at 7:24 PM slava.koptilin <
>> slava.kopti...@gmail.com> wrote:
>>
>>> Well, the exception is thrown by your class:
>>> org.apache.ignite.IgniteException: Spring application context
>>> resource is
>>> not injected.
>>>  at
>>>
>>> *com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory*.create(CacheStoreSessionListenerFactory.java:30)
>>>  at
>>>
>>> com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory.create(CacheStoreSessionListenerFactory.java:12)
>>>
>>> Is it possible to share this class as well?
>>>
>>>
>>>
>>> --
>>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>>
>>


Re: Cache configuration in case of Client mode

2018-07-05 Thread Prasad Bhalerao
> I tried to debug the ignite code, GridResourceProcessor.inject is not
> being executed for injecting resources into CacheStoreSessionListener. It
> is being called for Cachestores.
>
> Can you please advise?
>
> Thanks,
> Prasad
>
> On Thu, Jul 5, 2018 at 8:14 PM Prasad Bhalerao <
> prasadbhalerao1...@gmail.com> wrote:
>
>> I had used SpringApplicationContextResource  annotation. But it did not
>> inject the application context in it. So I decided to use spring managed
>> bean and it worked but now it is creating the problem which is described in
>> this mail chain.
>>
>> On Thu, Jul 5, 2018 at 8:11 PM Prasad Bhalerao <
>> prasadbhalerao1...@gmail.com> wrote:
>>
>>> I had used SpringApplicationContextResource  annotation. But it did not
>>> inject the application context in it. So I decided to use spring managed
>>> bean and it worked.
>>>
>>> Thanks,
>>> Prasad
>>>
>>> On Thu, Jul 5, 2018 at 7:49 PM Вячеслав Коптилин <
>>> slava.kopti...@gmail.com> wrote:
>>>
 It seems that you need to use @

 SpringApplicationContextResource

 instead of @Autowired.
 Could you please check that?

 Thanks.

 чт, 5 июл. 2018 г. в 17:01, Prasad Bhalerao <
 prasadbhalerao1...@gmail.com>:

>
>
> import java.io.Serializable;
> import javax.cache.configuration.Factory;
> import javax.sql.DataSource;
> import org.apache.ignite.IgniteException;
> import org.apache.ignite.cache.store.CacheStoreSessionListener;
> import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener;
> import org.springframework.beans.factory.annotation.Autowired;
> import org.springframework.context.ApplicationContext;
>
> public class CacheStoreSessionListenerFactory implements 
> Factory, Serializable {
>
>   private static final long serialVersionUID = 6142932447545510244L;
>
>   private String className;
>
>   @Autowired
>   private transient ApplicationContext appCtx;
>
>
>   public 
> CacheStoreSessionListenerFactory(Class clazz) {
> this.className = clazz.getName();
>   }
>
>   @Override
>   public CacheStoreSessionListener create() {
>
> if (appCtx == null) {
>   throw new IgniteException("Spring application context resource is 
> not injected.");
> }
> CacheJdbcStoreSessionListener lsnr = new 
> CacheJdbcStoreSessionListener();
> lsnr.setDataSource((DataSource) appCtx.getBean("dataSource"));
> return lsnr;
>
>   }
>
> }
>
>
>
> On Thu, Jul 5, 2018 at 7:24 PM slava.koptilin <
> slava.kopti...@gmail.com> wrote:
>
>> Well, the exception is thrown by your class:
>> org.apache.ignite.IgniteException: Spring application context
>> resource is
>> not injected.
>>  at
>>
>> *com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory*.create(CacheStoreSessionListenerFactory.java:30)
>>  at
>>
>> com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory.create(CacheStoreSessionListenerFactory.java:12)
>>
>> Is it possible to share this class as well?
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>
>


Re: Cache configuration in case of Client mode

2018-07-05 Thread Prasad Bhalerao
I tried to debug the ignite code, GridResourceProcessor.inject is not being
executed for injecting resources into CacheStoreSessionListenerFactories.
It is being called for CachestoreFactories.

Can you please advise?

Thanks,
Prasad

On Thu, Jul 5, 2018 at 8:14 PM Prasad Bhalerao 
wrote:

> I had used SpringApplicationContextResource  annotation. But it did not
> inject the application context in it. So I decided to use spring managed
> bean and it worked but now it is creating the problem which is described in
> this mail chain.
>
> On Thu, Jul 5, 2018 at 8:11 PM Prasad Bhalerao <
> prasadbhalerao1...@gmail.com> wrote:
>
>> I had used SpringApplicationContextResource  annotation. But it did not
>> inject the application context in it. So I decided to use spring managed
>> bean and it worked.
>>
>> Thanks,
>> Prasad
>>
>> On Thu, Jul 5, 2018 at 7:49 PM Вячеслав Коптилин <
>> slava.kopti...@gmail.com> wrote:
>>
>>> It seems that you need to use @
>>>
>>> SpringApplicationContextResource
>>>
>>> instead of @Autowired.
>>> Could you please check that?
>>>
>>> Thanks.
>>>
>>> чт, 5 июл. 2018 г. в 17:01, Prasad Bhalerao <
>>> prasadbhalerao1...@gmail.com>:
>>>


 import java.io.Serializable;
 import javax.cache.configuration.Factory;
 import javax.sql.DataSource;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.cache.store.CacheStoreSessionListener;
 import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;

 public class CacheStoreSessionListenerFactory implements 
 Factory, Serializable {

   private static final long serialVersionUID = 6142932447545510244L;

   private String className;

   @Autowired
   private transient ApplicationContext appCtx;


   public CacheStoreSessionListenerFactory(Class 
 clazz) {
 this.className = clazz.getName();
   }

   @Override
   public CacheStoreSessionListener create() {

 if (appCtx == null) {
   throw new IgniteException("Spring application context resource is 
 not injected.");
 }
 CacheJdbcStoreSessionListener lsnr = new 
 CacheJdbcStoreSessionListener();
 lsnr.setDataSource((DataSource) appCtx.getBean("dataSource"));
 return lsnr;

   }

 }



 On Thu, Jul 5, 2018 at 7:24 PM slava.koptilin 
 wrote:

> Well, the exception is thrown by your class:
> org.apache.ignite.IgniteException: Spring application context resource
> is
> not injected.
>  at
>
> *com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory*.create(CacheStoreSessionListenerFactory.java:30)
>  at
>
> com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory.create(CacheStoreSessionListenerFactory.java:12)
>
> Is it possible to share this class as well?
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>



Re: Cache configuration in case of Client mode

2018-07-05 Thread Prasad Bhalerao
I had used SpringApplicationContextResource  annotation. But it did not
inject the application context in it. So I decided to use spring managed
bean and it worked but now it is creating the problem which is described in
this mail chain.

On Thu, Jul 5, 2018 at 8:11 PM Prasad Bhalerao 
wrote:

> I had used SpringApplicationContextResource  annotation. But it did not
> inject the application context in it. So I decided to use spring managed
> bean and it worked.
>
> Thanks,
> Prasad
>
> On Thu, Jul 5, 2018 at 7:49 PM Вячеслав Коптилин 
> wrote:
>
>> It seems that you need to use @
>>
>> SpringApplicationContextResource
>>
>> instead of @Autowired.
>> Could you please check that?
>>
>> Thanks.
>>
>> чт, 5 июл. 2018 г. в 17:01, Prasad Bhalerao > >:
>>
>>>
>>>
>>> import java.io.Serializable;
>>> import javax.cache.configuration.Factory;
>>> import javax.sql.DataSource;
>>> import org.apache.ignite.IgniteException;
>>> import org.apache.ignite.cache.store.CacheStoreSessionListener;
>>> import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener;
>>> import org.springframework.beans.factory.annotation.Autowired;
>>> import org.springframework.context.ApplicationContext;
>>>
>>> public class CacheStoreSessionListenerFactory implements 
>>> Factory, Serializable {
>>>
>>>   private static final long serialVersionUID = 6142932447545510244L;
>>>
>>>   private String className;
>>>
>>>   @Autowired
>>>   private transient ApplicationContext appCtx;
>>>
>>>
>>>   public CacheStoreSessionListenerFactory(Class 
>>> clazz) {
>>> this.className = clazz.getName();
>>>   }
>>>
>>>   @Override
>>>   public CacheStoreSessionListener create() {
>>>
>>> if (appCtx == null) {
>>>   throw new IgniteException("Spring application context resource is not 
>>> injected.");
>>> }
>>> CacheJdbcStoreSessionListener lsnr = new 
>>> CacheJdbcStoreSessionListener();
>>> lsnr.setDataSource((DataSource) appCtx.getBean("dataSource"));
>>> return lsnr;
>>>
>>>   }
>>>
>>> }
>>>
>>>
>>>
>>> On Thu, Jul 5, 2018 at 7:24 PM slava.koptilin 
>>> wrote:
>>>
 Well, the exception is thrown by your class:
 org.apache.ignite.IgniteException: Spring application context resource
 is
 not injected.
  at

 *com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory*.create(CacheStoreSessionListenerFactory.java:30)
  at

 com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory.create(CacheStoreSessionListenerFactory.java:12)

 Is it possible to share this class as well?



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

>>>


Re: Cache configuration in case of Client mode

2018-07-05 Thread Prasad Bhalerao
I had used SpringApplicationContextResource  annotation. But it did not
inject the application context in it. So I decided to use spring managed
bean and it worked.

Thanks,
Prasad

On Thu, Jul 5, 2018 at 7:49 PM Вячеслав Коптилин 
wrote:

> It seems that you need to use @
>
> SpringApplicationContextResource
>
> instead of @Autowired.
> Could you please check that?
>
> Thanks.
>
> чт, 5 июл. 2018 г. в 17:01, Prasad Bhalerao  >:
>
>>
>>
>> import java.io.Serializable;
>> import javax.cache.configuration.Factory;
>> import javax.sql.DataSource;
>> import org.apache.ignite.IgniteException;
>> import org.apache.ignite.cache.store.CacheStoreSessionListener;
>> import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener;
>> import org.springframework.beans.factory.annotation.Autowired;
>> import org.springframework.context.ApplicationContext;
>>
>> public class CacheStoreSessionListenerFactory implements 
>> Factory, Serializable {
>>
>>   private static final long serialVersionUID = 6142932447545510244L;
>>
>>   private String className;
>>
>>   @Autowired
>>   private transient ApplicationContext appCtx;
>>
>>
>>   public CacheStoreSessionListenerFactory(Class 
>> clazz) {
>> this.className = clazz.getName();
>>   }
>>
>>   @Override
>>   public CacheStoreSessionListener create() {
>>
>> if (appCtx == null) {
>>   throw new IgniteException("Spring application context resource is not 
>> injected.");
>> }
>> CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener();
>> lsnr.setDataSource((DataSource) appCtx.getBean("dataSource"));
>> return lsnr;
>>
>>   }
>>
>> }
>>
>>
>>
>> On Thu, Jul 5, 2018 at 7:24 PM slava.koptilin 
>> wrote:
>>
>>> Well, the exception is thrown by your class:
>>> org.apache.ignite.IgniteException: Spring application context resource is
>>> not injected.
>>>  at
>>>
>>> *com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory*.create(CacheStoreSessionListenerFactory.java:30)
>>>  at
>>>
>>> com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory.create(CacheStoreSessionListenerFactory.java:12)
>>>
>>> Is it possible to share this class as well?
>>>
>>>
>>>
>>> --
>>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>>
>>


Re: Cache configuration in case of Client mode

2018-07-05 Thread Вячеслав Коптилин
It seems that you need to use @

SpringApplicationContextResource

instead of @Autowired.
Could you please check that?

Thanks.

чт, 5 июл. 2018 г. в 17:01, Prasad Bhalerao :

>
>
> import java.io.Serializable;
> import javax.cache.configuration.Factory;
> import javax.sql.DataSource;
> import org.apache.ignite.IgniteException;
> import org.apache.ignite.cache.store.CacheStoreSessionListener;
> import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener;
> import org.springframework.beans.factory.annotation.Autowired;
> import org.springframework.context.ApplicationContext;
>
> public class CacheStoreSessionListenerFactory implements 
> Factory, Serializable {
>
>   private static final long serialVersionUID = 6142932447545510244L;
>
>   private String className;
>
>   @Autowired
>   private transient ApplicationContext appCtx;
>
>
>   public CacheStoreSessionListenerFactory(Class 
> clazz) {
> this.className = clazz.getName();
>   }
>
>   @Override
>   public CacheStoreSessionListener create() {
>
> if (appCtx == null) {
>   throw new IgniteException("Spring application context resource is not 
> injected.");
> }
> CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener();
> lsnr.setDataSource((DataSource) appCtx.getBean("dataSource"));
> return lsnr;
>
>   }
>
> }
>
>
>
> On Thu, Jul 5, 2018 at 7:24 PM slava.koptilin 
> wrote:
>
>> Well, the exception is thrown by your class:
>> org.apache.ignite.IgniteException: Spring application context resource is
>> not injected.
>>  at
>>
>> *com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory*.create(CacheStoreSessionListenerFactory.java:30)
>>  at
>>
>> com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory.create(CacheStoreSessionListenerFactory.java:12)
>>
>> Is it possible to share this class as well?
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>
>


Re: Cache configuration in case of Client mode

2018-07-05 Thread Prasad Bhalerao
import java.io.Serializable;
import javax.cache.configuration.Factory;
import javax.sql.DataSource;
import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.store.CacheStoreSessionListener;
import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

public class CacheStoreSessionListenerFactory implements
Factory, Serializable {

  private static final long serialVersionUID = 6142932447545510244L;

  private String className;

  @Autowired
  private transient ApplicationContext appCtx;


  public CacheStoreSessionListenerFactory(Class
clazz) {
this.className = clazz.getName();
  }

  @Override
  public CacheStoreSessionListener create() {

if (appCtx == null) {
  throw new IgniteException("Spring application context resource
is not injected.");
}
CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener();
lsnr.setDataSource((DataSource) appCtx.getBean("dataSource"));
return lsnr;

  }

}



On Thu, Jul 5, 2018 at 7:24 PM slava.koptilin 
wrote:

> Well, the exception is thrown by your class:
> org.apache.ignite.IgniteException: Spring application context resource is
> not injected.
>  at
>
> *com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory*.create(CacheStoreSessionListenerFactory.java:30)
>  at
>
> com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory.create(CacheStoreSessionListenerFactory.java:12)
>
> Is it possible to share this class as well?
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>


Re: Cache configuration in case of Client mode

2018-07-05 Thread slava.koptilin
Well, the exception is thrown by your class:
org.apache.ignite.IgniteException: Spring application context resource is
not injected.
 at
*com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory*.create(CacheStoreSessionListenerFactory.java:30)
 at
com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory.create(CacheStoreSessionListenerFactory.java:12)

Is it possible to share this class as well?



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


Re: Cache configuration in case of Client mode

2018-07-05 Thread Prasad Bhalerao
Hi,

I am using Ignite 2.4 version. Please find attached the log files. Log file
agms-web is a client node log and agms-core is server node log.

Ignite configuration on client node is as follows. When I try to get the
cache contents on client node after data push operation, my request hangs
on ignite.cache(getCacheName()) code and throws following exception. But if
I fire the same request again, code  ignite.cache(getCacheName())  for
cache "IP_CONTAINER_IPV4_CACHE" returns null.  When I debugged on server
node, this cache is present and data is being pushed to this cache by
ignite runnable task.


Exception on first request :

2018-07-05 18:18:34,127 108076 [exchange-worker-#37%springDataNode%] ERROR
o.a.i.i.p.c.GridCachePartitionExchangeManager - Failed to process custom
exchange task: ClientCacheChangeDummyDiscoveryMessage
[reqId=23767a7f-3437-4d20-9993-36d5d88a8860, cachesToClose=null,
startCaches=[IP_CONTAINER_IPV4_CACHE]]
org.apache.ignite.IgniteException: Spring application context resource is
not injected.
 at
com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory.create(CacheStoreSessionListenerFactory.java:30)
 at
com.qualys.agms.grid.cache.loader.factory.CacheStoreSessionListenerFactory.create(CacheStoreSessionListenerFactory.java:12)
 at
org.apache.ignite.internal.processors.cache.GridCacheUtils.startStoreSessionListeners(GridCacheUtils.java:1403)
 at
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.start0(GridCacheStoreManagerAdapter.java:241)
 at
org.apache.ignite.internal.processors.cache.store.CacheOsStoreManager.start0(CacheOsStoreManager.java:64)


@Configuration
@Profile({"prod", "default"})
public class IgniteAppConfig {

  @Value("${ignite.data_storage_path}")
  private String dataStoragePath;

  @Bean
  public IgniteSpringBean igniteInstance() {
IgniteSpringBean ignite = new IgniteSpringBean();

ignite.setConfiguration(getIgniteConfiguration(ignite));

return ignite;
  }

  private IgniteConfiguration getIgniteConfiguration(IgniteSpringBean ignite) {

String HOST = "127.0.0.1:47500..47509";
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
ipFinder.setAddresses(Collections.singletonList(HOST));

TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(ipFinder);

IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setDiscoverySpi(discoSpi);
cfg.setIgniteInstanceName("springDataNode");
cfg.setPeerClassLoadingEnabled(false);
cfg.setRebalanceThreadPoolSize(4);
//cfg.setLifecycleBeans(new IgniteLifeCycleBean());
cfg.setClientMode(true);

return cfg;
  }

}



@Override
public FieldsQueryCursor>
getFieldResultsByCriteria(Serializable customCriteria) {
  QueryCriteria criteria = (QueryCriteria) customCriteria;
  SqlFieldsQuery sqlFieldsQuery = new
SqlFieldsQuery(criteria.getStatement()).setArgs(criteria.getArgs());
  sqlFieldsQuery.setDistributedJoins(criteria.isDistributeJoins());
  return cache().query(sqlFieldsQuery);
}

protected abstract String getCacheName();

protected IgniteCache cache() {
  return ignite.cache(getCacheName());
}


IP_CONTAINER_IPV4_CACHE

private CacheConfiguration ipContainerIPV4CacheCfg() {

  CacheConfiguration ipContainerIpV4CacheCfg = new
CacheConfiguration<>(CacheName.IP_CONTAINER_IPV4_CACHE.name());
  ipContainerIpV4CacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
  ipContainerIpV4CacheCfg.setWriteThrough(true);
  ipContainerIpV4CacheCfg.setReadThrough(false);
  ipContainerIpV4CacheCfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
  
ipContainerIpV4CacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
  ipContainerIpV4CacheCfg.setBackups(1);
  //SpringCacheStoreFactory springCacheStoreFactory = new
SpringCacheStoreFactory(DefaultCacheLoader.class);
  Factory storeFactory =
FactoryBuilder.factoryOf(IpContainerIpV4CacheLoader.class);
  ipContainerIpV4CacheCfg.setCacheStoreFactory(storeFactory);
  ipContainerIpV4CacheCfg.setIndexedTypes(DefaultDataAffinityKey.class,
IpContainerIpV4Data.class);
  
ipContainerIpV4CacheCfg.setCacheStoreSessionListenerFactories(cacheStoreSessionListenerFactory());

  RendezvousAffinityFunction affinityFunction = new
RendezvousAffinityFunction();
  affinityFunction.setExcludeNeighbors(true);
  ipContainerIpV4CacheCfg.setAffiy(affinityFunction);

  return ipContainerIpV4CacheCfg;
}

@Bean
public CacheStoreSessionListenerFactory cacheStoreSessionListenerFactory() {
  return new CacheStoreSessionListenerFactory(CacheStoreSessionListener.class);
}




Thanks
Prasad

On Thu, Jul 5, 2018 at 5:57 PM slava.koptilin 
wrote:

> Hello Prasad,
>
> I cannot reproduce the behavior that you described.
> Please share the code that the community can use in order to reproduce the
> issue.
> It would be nice to have log files from both nodes (client and server).
>
> One more thing. Could you please share the version of Apache Ignite that
> you
> are using?
>
> Thanks!
>

Re: Cache configuration in case of Client mode

2018-07-05 Thread slava.koptilin
Hello Prasad,

I cannot reproduce the behavior that you described.
Please share the code that the community can use in order to reproduce the
issue.
It would be nice to have log files from both nodes (client and server).

One more thing. Could you please share the version of Apache Ignite that you
are using?

Thanks!



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


Re: Cache configuration in case of Client mode

2018-07-05 Thread akurbanov
Hi, 

Try advice to call ignite.getOrCreateCache("cacheName");, got a feeling that
you will get an empty cache there which would mean that this cache is not
created yet or is failing to start. In this case please attach startup logs
for server/client nodes setup.

Regards.



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


Re: Cache configuration in case of Client mode

2018-07-05 Thread Prasad Bhalerao
Hi Maxim,

My mistake, I did not phrase the problem correctly.

I am getting NullPointerException in my code because
ignite.cache(getCacheName())
is returning null on client node.

As I said I have not provided any cache configurations on client node
because I thought it is unnecessary.

So the question is.

Is it necessary to provide all cache configuration on client node as well?
If yes why?


Thanks,
Prasad

On Thu, Jul 5, 2018 at 5:23 PM Maxim Malygin 
wrote:

> 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

>>>
>>>


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
>>>
>>
>>


Re: Cache configuration in case of Client mode

2018-07-05 Thread 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
>>
>
>


Re: Cache configuration in case of Client mode

2018-07-05 Thread Sambhaji Sawant
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
>


Cache configuration in case of Client mode

2018-07-05 Thread Prasad Bhalerao
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