How to exit from Client JVM while using Apache Ignite as Data Grid ?

classic Classic list List threaded Threaded
7 messages Options
vijayendra bhati vijayendra bhati
Reply | Threaded
Open this post in threaded view
|

How to exit from Client JVM while using Apache Ignite as Data Grid ?

Hi,
I am trying to query over a 1 node Apache Ignite Data grid.But my client program is not getting exiting, it keeps on running.
Please let me know what needs to be done.I am running the client program in client mode.

Regards,
Vij
Vladislav Pyatkov Vladislav Pyatkov
Reply | Threaded
Open this post in threaded view
|

Re: How to exit from Client JVM while using Apache Ignite as Data Grid ?

Hi vijayendra,

I think you run one client node (<property name="clientMode" value="true"/>)  wihout at last one server node. In that case client node be waiting for server node until it (server node) will not by added.
When you start another node in server mode (<property name="clientMode" value="false"/>), client will continue to work.

If it not help you, please provide additional information.
Please, show code, which starts our node and configuration xml.

On Tue, Apr 5, 2016 at 8:20 AM, vijayendra bhati <[hidden email]> wrote:
Hi,
I am trying to query over a 1 node Apache Ignite Data grid.But my client program is not getting exiting, it keeps on running.
Please let me know what needs to be done.I am running the client program in client mode.

Regards,
Vij

vijayendra bhati vijayendra bhati
Reply | Threaded
Open this post in threaded view
|

Re: How to exit from Client JVM while using Apache Ignite as Data Grid ?

Thanks Vladislav,

I have 1 node running as server with   <property name="clientMode" value="false" /> and I am connecting from my java application with 
  <property name="clientMode" value="true" />.

I am attaching both the configuration files with this mail.

Code snippet is :

public class MarketDataCacheStore {
public MarketDataCacheStore(){
//Ignition.setClientMode(true);
mktDataCacheCfg.setBackups(1);
mktDataCacheCfg.setCacheMode(CacheMode.PARTITIONED);
mktDataCacheCfg.setIndexedTypes(MarketDataKey.class,MarketData.class);
mktDataCache = Ignition.start("config/risk-analytics-cache-client.xml").getOrCreateCache(mktDataCacheCfg);
}
private static final String PARTITIONED_CACHE_NAME = MarketDataCacheStore.class.getSimpleName() + "Partitioned";
private CacheConfiguration<MarketDataKey, MarketData> mktDataCacheCfg = new CacheConfiguration<>(PARTITIONED_CACHE_NAME);
private IgniteCache<MarketDataKey, MarketData> mktDataCache = null;
//private static MarketDataCacheStore cacheStore = new MarketDataCacheStore();
/*public static MarketDataCacheStore getInstance()
{
return cacheStore;
}*/
public void putMktDataInCache(HashMap<MarketDataKey,MarketData> marketDataMap){
mktDataCache.putAll(marketDataMap);
//Ignition.kill(false);
}
public void putMktDataInCache(MarketDataKey marketDataKey,MarketData marketData){
mktDataCache.put(marketDataKey,marketData);
}
public Double[] getMktData(String symbol,Date startDate,Date endDate)
{
String sql = "symbol = ? and businessDate between ? and ? order by businessDate";
 
System.out.println("MarketData for symbol :"+symbol+" with COB between "+startDate.toString()+ "and "+endDate.toString() +"queried with SQL query): ");
Double [] mktDataForPeriod =  mktDataCache.query(new SqlQuery<MarketDataKey, MarketData>(MarketData.class, sql).
               setArgs(symbol, startDate,endDate)).getAll().stream().map(obj-> {
                MarketData mktData = obj.getValue();
                return mktData.getEodPrice();
               }).toArray(Double[]::new);
 
System.out.println("Size returned "+mktDataForPeriod.length);
return mktDataForPeriod;
 
}

}


Regards,
Vij




On Tuesday, April 5, 2016 12:07 PM, Vladislav Pyatkov <[hidden email]> wrote:


Hi vijayendra,

I think you run one client node (<property name="clientMode" value="true"/>)  wihout at last one server node. In that case client node be waiting for server node until it (server node) will not by added.
When you start another node in server mode (<property name="clientMode" value="false"/>), client will continue to work.

If it not help you, please provide additional information.
Please, show code, which starts our node and configuration xml.

On Tue, Apr 5, 2016 at 8:20 AM, vijayendra bhati <[hidden email]> wrote:
Hi,
I am trying to query over a 1 node Apache Ignite Data grid.But my client program is not getting exiting, it keeps on running.
Please let me know what needs to be done.I am running the client program in client mode.

Regards,
Vij




risk-analytics-cache-client.xml (4K) Download Attachment
risk-analytics-cache-server.xml (4K) Download Attachment
Denis Magda Denis Magda
Reply | Threaded
Open this post in threaded view
|

Re: How to exit from Client JVM while using Apache Ignite as Data Grid ?

Hi,

Please elaborate on what you mean under "But my client program is not getting exiting, it keeps on running."

How do you stop the client and your application? Why do you expect that it should be stopped?

If you start a client node it will start internally pools of non daemon Threads that will prevent your application process to stop until ignite.stop(...) is called. Probably this is the case.

--
Denis
vijayendra bhati vijayendra bhati
Reply | Threaded
Open this post in threaded view
|

Re: How to exit from Client JVM while using Apache Ignite as Data Grid ?

Hi,
Client programme is my java code/app from where I am trying to access the ignite cache.
Its just a java programme which should be finished after doing its work and jvm should got shutdown.
Regards,
Vij


On Tue, 5 Apr, 2016 at 2:10 pm, Denis Magda
Hi,

Please elaborate on what you mean under "But my client program is not

getting exiting, it keeps on running."


How do you stop the client and your application? Why do you expect that it
should be stopped?

If you start a client node it will start internally pools of non daemon
Threads that will prevent your application process to stop until
ignite.stop(...) is called. Probably this is the case.

--
Denis



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/How-to-exit-from-Client-JVM-while-using-Apache-Ignite-as-Data-Grid-tp3919p3932.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: How to exit from Client JVM while using Apache Ignite as Data Grid ?

Hi,

Sounds like you didn't stop the node. Use ignite.close() or Ignition.stop() to achieve this.

Let us know if it helps.

-Val
vijayendra bhati vijayendra bhati
Reply | Threaded
Open this post in threaded view
|

Re: How to exit from Client JVM while using Apache Ignite as Data Grid ?

Thanks Valentin,

Yea its working now.
But description of stop method seems little incorrect or more likely I am interpreting it in wrong way.

It say stop()  - "Stops default grid."
I thought it means it will stop the entire data grid.It would be good if it would have say "Stops the current node".

Regards,
Vijayendra Bhati

On Wednesday, April 6, 2016 10:00 AM, vkulichenko <[hidden email]> wrote:


Hi,

Sounds like you didn't stop the node. Use ignite.close() or Ignition.stop()
to achieve this.

Let us know if it helps.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/How-to-exit-from-Client-JVM-while-using-Apache-Ignite-as-Data-Grid-tp3919p3954.html

Sent from the Apache Ignite Users mailing list archive at Nabble.com.