Is there way to set IdleTimeout in ignite XML configuration file? - ignite

I need to set idleTimeout at server level as the connections are not being closed properly by the client.
I found below link, but I am not sure how to set using XML configuration file.
https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/ClientConnectorConfiguration.html#setIdleTimeout-long-
Is there way to set IdleTimeout in ignite/GridGain XML configuration file?

You can configure ClientConnectorConfiguration like this:
<bean class="org.apache.ignite.configuration.IgniteConfiguration" id="ignite.cfg">
<property name="clientConnectorConfiguration">
<bean class="org.apache.ignite.configuration.ClientConnectorConfiguration">
...
</bean>
</property>
</bean>
For more details see docs

Related

Ignite: Configuring persistence to a custom directory

I want to provide a custom directory to persist the data. My persistence configuration is:
<property name="dataStorageConfiguration">
<bean class="org.apache.ignite.configuration.DataStorageConfiguration">
<property name="defaultDataRegionConfiguration">
<bean class="org.apache.ignite.configuration.DataRegionConfiguration">
<property name="persistenceEnabled" value="true"/>
</bean>
</property>
</bean>
</property>
As mentioned in the documentation, by default it persists under ${IGNITE_HOME}/work/db directory on each node. I can change the directory by calling setStoragePath() method. But how do I configure it through xml.
I have searched but couldn't find in the documentation. Please help to find the right xml key for modifying this configuration.
Thanks!!
The correct one would be the property of DataStorageConfiguration:
<property name="storagePath" value="$ENV_VAR/relative/path"/>
Javadoc link: https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/DataStorageConfiguration.html#getStoragePath--

How to configure cache for ignite-spark-dataframe?

I managed to save and load spark dataframe from ignite by the example here: https://apacheignite-fs.readme.io/docs/ignite-data-frame
By following the code example when the cache is created in ignite it automatically has a name like "SQL_PUBLIC_name_of_table_in_spark".
One the other hand if I want to change some cache configuration I need to specify the same cache name in xml or code before creating ignite cache. Because cache configuration can not be changed after cache is created. See following code.
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="cacheConfiguration">
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<!-- Set a cache name. -->
<property name="name" value="SQL_PUBLIC_name_of_table_in_spark"/>
<!-- Set cache mode. -->
<property name="cacheMode" value="PARTITIONED"/>
</bean>
</property>
</bean>
Then one of them will be reject by "cache already exists" The result is I could't change any cache configuration by xml/code.
Is this expected? And how can I change the cache configuration in this case?
The doc page you've link contains a code piece that creates an SQL table:
CREATE TABLE person (
id LONG,
name VARCHAR,
city_id LONG,
PRIMARY KEY (id, city_id)
) WITH "backups=1, affinityKey=city_id”;
This SQL command is what actually creates the cache. You can change this command to change the parameters of the cache that will be created. Refer to the CREATE TABLE doc.
In particular, the parameter that gives the most flexibility is WITH template=mytemplate. It lets you create a cache from a pre-existing template configuration. To register a template you can specify it in your cacheConfiguration with a name ending with asterisk, like
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="cacheConfiguration">
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="mytemplate*"/>
<!-- your parameters. -->
</bean>
</property>
</bean>
You can also specify the WITH parameters for CREATE TABLE in the OPTION_CREATE_TABLE_PARAMETERS setting if the table is being created automatically by Spark.

Apache Ignite Eviction Policy Max Size in Visor shown as <n/a>

My question is really simple.
I am using the example XML config for setting up the following Eviction Policy from https://apacheignite.readme.io/docs/evictions#section-first-in-first-out-fifo- .
<bean class="org.apache.ignite.cache.CacheConfiguration">
<property name="name" value="myCache"/>
<!-- Enabling on-heap caching for this distributed cache. -->
<property name="onheapCacheEnabled" value="true"/>
<property name="evictionPolicy">
<!-- FIFO eviction policy. -->
<bean class="org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy">
<!-- Set the maximum cache size to 1 million (default is 100,000). -->
<property name="maxSize" value="1000000"/>
</bean>
</property>
...
</bean>
How can I verify that my eviction policy has been setup successfully before start seeding data into my cache? I have been using visor and then the config command, I can see that Eviction Policy Enabled is set to on, Eviction Policy set to o.a.i.cache.eviction.fifo.FifoEvictionPolicy but Eviction Policy Max Size is set to <n/a> although it has been configured in the XML. That leads me to think that the Eviction policy max size is not setup correctly. Can someone share some light into this question?
Apache Ignite has management beans, so you can verify your Cache configuration using MBeans. Just run a jconsole from JDK and check Cache configuration. Please see sample screenshot:
Thanks, Alexey

Apache Ignite JDBC Thin Client Does not work with Existing Cache

I have created an Ignite cache "contact" and added "Person" object to it.
When I use Ignite JDBC Client mode I am able to query this cache. But when I implement JDBC Thin Client, it says that the table Person does not exist.
I tried the query this way:
Select * from Person
Select * from contact.Person
Both did not work with Thin Client. I am using Ignite 2.1.
I appreciate your help as how to query an existing cache using Thin Client.
Thank you.
Cache Configuration in default-config.xml
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<!-- Enabling Apache Ignite Persistent Store. -->
<property name="persistentStoreConfiguration">
<bean class="org.apache.ignite.configuration.PersistentStoreConfiguration"/>
</property>
<property name="binaryConfiguration">
<bean class="org.apache.ignite.configuration.BinaryConfiguration">
<property name="compactFooter" value="false"/>
</bean>
</property>
<property name="memoryConfiguration">
<bean class="org.apache.ignite.configuration.MemoryConfiguration">
<!-- Setting the page size to 4 KB -->
<property name="pageSize" value="#{4 * 1024}"/>
</bean>
</property>
<!-- Explicitly configure TCP discovery SPI to provide a list of initial nodes. -->
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
<property name="addresses">
<list>
<!-- In distributed environment, replace with actual host IP address. -->
<value>127.0.0.1:55500..55502</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</beans>
Cache Configuration in the Server Side of the Code
CacheConfiguration<Long, Person> cc = new CacheConfiguration<>(cacheName);
cc.setCacheMode(CacheMode.REPLICATED);
cc.setRebalanceMode(CacheRebalanceMode.ASYNC);
cc.setIndexedTypes(Long.class, Person.class);
cache = ignite.getOrCreateCache(cc);
Thin Client JDBC URL
Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
// Open the JDBC connection.
Connection conn = DriverManager.getConnection("jdbc:ignite:thin://192.168.1.111:10800");
Statement st = conn.createStatement();
If you want to query data from an existing cache using SQL, you should specify an SQL schema in the cache configuration. Add the following code before the cache creation:
cc.setSqlSchema("PUBLIC");
Note that you have persistence configured, so when you do ignite.getOrCreateCache(cc); the new configuration won't be applied, if a cache with this name is already persisted. You should, for example, remove persistence data or use createCache(...) method instead.

How to consume message from the endpoint in Apache Camel?

I had created a message with a topic name and set some information with key/value pair and sent the message to the MessageBus (i.e, produced the message to an endPoint - in my case endpoint is a messageBus).
How can consume the message from that endPoint? I know the uri, endpoint. what configurations needs to be done for my consumer ( any camel XML changes to done ?).
Please help.
see the camel-jms page for details, but you basically need to do some basic Spring XML to configure the ActiveMQ connection and then establish your route...
from("activemq:queue:inboundQueue").bean(MyConsumerBean.class);
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="vm://localhost?broker.persistent=false&broker.useJmx=false"/>
</bean>
</property>
</bean>
see these unit test for more information...
https://svn.apache.org/repos/asf/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteTest.java
https://svn.apache.org/repos/asf/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpring.xml