You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by 罗 辉 <lu...@zetyun.com> on 2017/08/17 04:41:20 UTC

problems in test ignite PersistentStore

hello guys:

      I'm trying to test the new feature PersistentStore, and got below questions:


  1.  streamer.addData() only support Nothing type input, how to make it support Int,String and others? here is my code:

import java.util.List;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.SqlFieldsQuery;
object singlenodepersist {
  def main(args:Array[String]){
    Ignition.setClientMode(true)
    val config = "config/test.xml"
    val ig = Ignition.start(config)
    ig.active(true)
    val cache = createCache$[Int, String]("organization")

    val streamer = ig.dataStreamer("organization")
    streamer.allowOverwrite(true)
    for(i<- 1 to 10000){
      streamer.addData(1, "1")    //I got problem in this line :typemismatch;  found   : Int(1)  required: Nothing
    }
  }
}
I am using scala 2.10.6

2. In the path of  IGNITE_HOME, I did no changes and tried to run
bin/ignite.shexamples/config/persistentstore/example-persistent-store.xml,
I got below exception:
classorg.apache.ignite.IgniteException: Failed to instantiate Spring XML application context (make sure all classes used in Spring configuration are present at CLASSPATH)
Caused by: java.lang.ClassNotFoundException: org.apache.ignite.examples.model.Organization
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
        at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:284)
        ... 40 more
......
Failed to start grid: Failed to instantiate Spring XML application context (make sure all classes used in Spring configuration are present at CLASSPATH) [springUrl=file:/data/disk01/huzongxing/ignite/examples/config/persistentstore/example-persistent-store.xml]
Note! You may use 'USER_LIBS' environment variable to specify your classpath.
It seems that I need to include the class org.apache.ignite.examples.model.Organization into my classpath, in which library it locates?

3.I want to set the persistentstore path to my SSD mount point, which configuration I can apply?

Any ideas are appreciated!

San.Luo

答复: 答复: problems in test ignite PersistentStore

Posted by 罗 辉 <lu...@zetyun.com>.
got it ,thank you Val, I got to have another try.

________________________________
发件人: vkulichenko <va...@gmail.com>
发送时间: 2017年8月19日 1:54:11
收件人: user@ignite.apache.org
主题: Re: 答复: problems in test ignite PersistentStore

You don't see anything in /ssd folder, because you provided it in
PersistenceStoreConfiguration object which is not even set anywhere. This
code has no effect:

val psc = new PersistentStoreConfiguration
psc.setPersistentStorePath("/ssd")

Actually, Ignite configuration can't be changed in runtime anyway, so it
should be done in XML as part of PersistentStoreConfiguration bean:

<property name="persistentStoreConfiguration">
    <bean
class="org.apache.ignite.configuration.PersistentStoreConfiguration">
        <property name="persistentStorePath" value="/ssd"/>
    </bean
</property>

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/problems-in-test-ignite-PersistentStore-tp16244p16297.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: 答复: problems in test ignite PersistentStore

Posted by vkulichenko <va...@gmail.com>.
You don't see anything in /ssd folder, because you provided it in
PersistenceStoreConfiguration object which is not even set anywhere. This
code has no effect:

val psc = new PersistentStoreConfiguration
psc.setPersistentStorePath("/ssd")

Actually, Ignite configuration can't be changed in runtime anyway, so it
should be done in XML as part of PersistentStoreConfiguration bean:

<property name="persistentStoreConfiguration">
    <bean
class="org.apache.ignite.configuration.PersistentStoreConfiguration">
        <property name="persistentStorePath" value="/ssd"/>
    </bean
</property>

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/problems-in-test-ignite-PersistentStore-tp16244p16297.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

答复: problems in test ignite PersistentStore

Posted by 罗 辉 <lu...@zetyun.com>.
thank you dkarachentsev, i realized the type undefined mistake


     I correct my codes like below :

object SingleNodePersist {
  def main(args: Array[String]) {
    Ignition.setClientMode(true)
    val config = "/data/disk01/huzongxing/ignite/config/test.xml"
    val ig = Ignition.start(config)
    ig.active(true)
    val cache = ig.getOrCreateCache[Long, Int]("organization")
    val psc = new PersistentStoreConfiguration
    psc.setPersistentStorePath("/ssd")

    val streamer = ig.dataStreamer[Long, Int]("organization")
    streamer.allowOverwrite(true)
    for (i <- 1 to 10000) {
      streamer.addData(i, i)
      if (i > 0 && i % 10000 == 0)
        println("Done: " + i)
    }

    cache.close()
  }
}


and my test.xml as well:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">
    <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>
        <!-- Setting up caches. -->
        <property name="cacheConfiguration">
            <list>
                <bean class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="name" value="organization"/>
                    <property name="backups" value="1"/>
                    <property name="atomicityMode" value="TRANSACTIONAL"/>
                    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
<!--
                    <property name="indexedTypes">
                        <list>
                            <value>java.lang.Long</value>
                            <value>java.lang.Int</value>
                        </list>
                    </property>
-->
                </bean>
            </list>
        </property>
        <property name="binaryConfiguration">
            <bean class="org.apache.ignite.configuration.BinaryConfiguration">
                <property name="compactFooter" value="false"/>
            </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">
                    <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
                    <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
                    <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:47500..47502</value>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>
</beans>

after I changed my code and xml file,the test program can run normally.
I am expecting something to be written into /ssd directory , however I found nothing.
It seems the cache default behaviour is to store the cache data into memory only , not memory and disk simultaneously.
I will continue to look up the docs which you mentioned .

thanks again.


________________________________
发件人: dkarachentsev <dk...@gridgain.com>
发送时间: 2017年8月18日 0:08:17
收件人: user@ignite.apache.org
主题: Re: problems in test ignite PersistentStore

Hi,

1. You need to set types for datastreamer just like for cache you did:
var streamer = ig.dataStreamer[Int, String]("organization")

2. Check that classes from ignite/examples are in classpath. It's a maven
module which has scala examples that you may play with.

3. [1, 2, 3]

[1]
https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/PersistentStoreConfiguration.html#setPersistentStorePath(java.lang.String)
[2]
https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/PersistentStoreConfiguration.html#setWalStorePath(java.lang.String)
[3]
https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/PersistentStoreConfiguration.html#setWalArchivePath(java.lang.String)

Thanks!
-Dmitry.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/problems-in-test-ignite-PersistentStore-tp16244p16256.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: problems in test ignite PersistentStore

Posted by dkarachentsev <dk...@gridgain.com>.
Hi,

1. You need to set types for datastreamer just like for cache you did:
var streamer = ig.dataStreamer[Int, String]("organization")

2. Check that classes from ignite/examples are in classpath. It's a maven
module which has scala examples that you may play with.

3. [1, 2, 3]

[1]
https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/PersistentStoreConfiguration.html#setPersistentStorePath(java.lang.String)
[2]
https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/PersistentStoreConfiguration.html#setWalStorePath(java.lang.String)
[3]
https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/PersistentStoreConfiguration.html#setWalArchivePath(java.lang.String)

Thanks!
-Dmitry.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/problems-in-test-ignite-PersistentStore-tp16244p16256.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.