ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [50/51] incubator-ignite git commit: # ignite-537
Date Fri, 10 Apr 2015 12:11:25 GMT
# ignite-537


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

Branch: refs/heads/ignite-537
Commit: eb85f0661d582affa47461358a829ca89394815b
Parents: b887030
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Apr 10 15:09:11 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Apr 10 15:09:11 2015 +0300

----------------------------------------------------------------------
 .../p2p/startcache/CacheAllNodesFilter.java     |  31 +++++
 .../startcache/CacheConfigP2PStartClient.java   | 116 +++++++++++++++++++
 2 files changed, 147 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eb85f066/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheAllNodesFilter.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheAllNodesFilter.java
b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheAllNodesFilter.java
new file mode 100644
index 0000000..f057fb8
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheAllNodesFilter.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.tests.p2p.startcache;
+
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.lang.*;
+
+/**
+ *
+ */
+public class CacheAllNodesFilter implements IgnitePredicate<ClusterNode> {
+    /** {@inheritDoc} */
+    @Override public boolean apply(ClusterNode clusterNode) {
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eb85f066/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigP2PStartClient.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigP2PStartClient.java
b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigP2PStartClient.java
new file mode 100644
index 0000000..b5e0989
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/startcache/CacheConfigP2PStartClient.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.tests.p2p.startcache;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.query.annotations.*;
+import org.apache.ignite.configuration.*;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ *
+ */
+public class CacheConfigP2PStartClient {
+    /**
+     * @param args Arguments.
+     * @throws Exception If failed.
+     */
+    public static void main(String[] args) throws Exception {
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        Ignite ignite = Ignition.start(cfg);
+
+        int nodes = ignite.cluster().nodes().size();
+
+        if (nodes != 3)
+            throw new Exception("Unexpected nodes number: " + nodes);
+
+        CacheConfiguration<Integer, Organization1> ccfg1 = new CacheConfiguration<>();
+
+        ccfg1.setNodeFilter(new CacheAllNodesFilter());
+
+        ccfg1.setIndexedTypes(Integer.class, Organization1.class);
+
+        IgniteCache<Integer, Organization1> cache1 = ignite.createCache(ccfg1);
+
+        for (int i = 0; i < 500; i++)
+            cache1.put(i, new Organization1("org-" + i));
+
+        Thread.sleep(5000);
+    }
+
+    /**
+     * Organization class.
+     */
+    private static class Organization1 implements Serializable {
+        /** Organization ID (indexed). */
+        @QuerySqlField(index = true)
+        private UUID id;
+
+        /** Organization name (indexed). */
+        @QuerySqlField(index = true)
+        private String name;
+
+        /**
+         * Create organization.
+         *
+         * @param name Organization name.
+         */
+        Organization1(String name) {
+            id = UUID.randomUUID();
+
+            this.name = name;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return "Organization [id=" + id + ", name=" + name + ']';
+        }
+    }
+
+    /**
+     * Organization class.
+     */
+    private static class Organization2 implements Serializable {
+        /** Organization ID (indexed). */
+        @QuerySqlField(index = true)
+        private UUID id;
+
+        /** Organization name (indexed). */
+        @QuerySqlField(index = true)
+        private String name;
+
+        /**
+         * Create organization.
+         *
+         * @param name Organization name.
+         */
+        Organization2(String name) {
+            id = UUID.randomUUID();
+
+            this.name = name;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return "Organization [id=" + id + ", name=" + name + ']';
+        }
+    }
+}


Mime
View raw message