You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/08/21 08:40:56 UTC

[47/50] [abbrv] ignite git commit: Fixed PersistentStoreExample not to require model classes on server classpath

Fixed PersistentStoreExample not to require model classes on server classpath


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4bfc6e24
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4bfc6e24
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4bfc6e24

Branch: refs/heads/ignite-5578
Commit: 4bfc6e240e9a2cc92b00762ae89a1b735ca9f7ec
Parents: 1539315
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Fri Aug 18 14:47:06 2017 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Fri Aug 18 14:47:06 2017 -0700

----------------------------------------------------------------------
 .../example-persistent-store.xml                | 23 ----------------
 .../persistentstore/PersistentStoreExample.java | 29 ++++++++++++++------
 2 files changed, 21 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4bfc6e24/examples/config/persistentstore/example-persistent-store.xml
----------------------------------------------------------------------
diff --git a/examples/config/persistentstore/example-persistent-store.xml b/examples/config/persistentstore/example-persistent-store.xml
index 8714b09..79138b0 100644
--- a/examples/config/persistentstore/example-persistent-store.xml
+++ b/examples/config/persistentstore/example-persistent-store.xml
@@ -22,34 +22,11 @@
        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>org.apache.ignite.examples.model.Organization</value>
-                        </list>
-                    </property>
-                </bean>
-            </list>
-        </property>
-
         <property name="binaryConfiguration">
             <bean class="org.apache.ignite.configuration.BinaryConfiguration">
                 <property name="compactFooter" value="false"/>

http://git-wip-us.apache.org/repos/asf/ignite/blob/4bfc6e24/examples/src/main/java/org/apache/ignite/examples/persistentstore/PersistentStoreExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/persistentstore/PersistentStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/persistentstore/PersistentStoreExample.java
index 5cd2f08..eec0866 100644
--- a/examples/src/main/java/org/apache/ignite/examples/persistentstore/PersistentStoreExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/persistentstore/PersistentStoreExample.java
@@ -22,8 +22,12 @@ 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.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.cache.query.QueryCursor;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.datagrid.CacheQueryExample;
 import org.apache.ignite.examples.model.Organization;
 
 /**
@@ -43,8 +47,11 @@ import org.apache.ignite.examples.model.Organization;
  * data that is in the persistence only.
  */
 public class PersistentStoreExample {
+    /** Organizations cache name. */
+    private static final String ORG_CACHE = CacheQueryExample.class.getSimpleName() + "Organizations";
+
     /** */
-    private static final boolean UPDATE = true;
+    private static final boolean UPDATE = false;
 
     /**
      * @param args Program arguments, ignored.
@@ -53,18 +60,24 @@ public class PersistentStoreExample {
     public static void main(String[] args) throws Exception {
         Ignition.setClientMode(true);
 
-        try (Ignite ig = Ignition.start("examples/config/persistentstore/example-persistent-store.xml")) {
-
+        try (Ignite ignite = Ignition.start("examples/config/persistentstore/example-persistent-store.xml")) {
             // Activate the cluster. Required to do if the persistent store is enabled because you might need
             // to wait while all the nodes, that store a subset of data on disk, join the cluster.
-            ig.active(true);
+            ignite.active(true);
+
+            CacheConfiguration<Long, Organization> cacheCfg = new CacheConfiguration<>(ORG_CACHE);
+
+            cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+            cacheCfg.setBackups(1);
+            cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+            cacheCfg.setIndexedTypes(Long.class, Organization.class);
 
-            IgniteCache<Long, Organization> cache = ig.cache("organization");
+            IgniteCache<Long, Organization> cache = ignite.getOrCreateCache(cacheCfg);
 
             if (UPDATE) {
                 System.out.println("Populating the cache...");
 
-                try (IgniteDataStreamer<Long, Organization> streamer = ig.dataStreamer("organization")) {
+                try (IgniteDataStreamer<Long, Organization> streamer = ignite.dataStreamer(ORG_CACHE)) {
                     streamer.allowOverwrite(true);
 
                     for (long i = 0; i < 100_000; i++) {
@@ -78,8 +91,8 @@ public class PersistentStoreExample {
 
             // Run SQL without explicitly calling to loadCache().
             QueryCursor<List<?>> cur = cache.query(
-                    new SqlFieldsQuery("select id, name from Organization where name like ?")
-                            .setArgs("organization-54321"));
+                new SqlFieldsQuery("select id, name from Organization where name like ?")
+                    .setArgs("organization-54321"));
 
             System.out.println("SQL Result: " + cur.getAll());