#ignite-961: start query-example.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/d2f41c93 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/d2f41c93 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/d2f41c93 Branch: refs/heads/ignite-1121 Commit: d2f41c93a4afcfd5d876f68f7ef25429984d98b2 Parents: a2ab189 Author: ivasilinets <ivasilin...@gridgain.com> Authored: Fri Jul 17 18:46:39 2015 +0300 Committer: ivasilinets <ivasilin...@gridgain.com> Committed: Fri Jul 17 18:46:39 2015 +0300 ---------------------------------------------------------------------- examples/config/js/example-query.xml | 91 ++++++++++++++++++++ examples/pom.xml | 6 ++ .../ignite/examples/ExampleNodeStartup.java | 2 +- examples/src/main/js/cache-query-example.js | 20 ++--- 4 files changed, 108 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d2f41c93/examples/config/js/example-query.xml ---------------------------------------------------------------------- diff --git a/examples/config/js/example-query.xml b/examples/config/js/example-query.xml new file mode 100644 index 0000000..27136a0 --- /dev/null +++ b/examples/config/js/example-query.xml @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + 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. +--> + +<!-- + Ignite Spring configuration file to startup Ignite cache. + + This file demonstrates how to configure cache using Spring. Provided cache + will be created on node startup. + + Use this configuration file when running HTTP REST examples (see 'examples/rest' folder). + + When starting a standalone node, you need to execute the following command: + {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/example-cache.xml + + When starting Ignite from Java IDE, pass path to this file to Ignition: + Ignition.start("examples/config/example-cache.xml"); +--> +<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"> + <property name="localHost" value="127.0.0.1" /> + + <property name="cacheConfiguration"> + <list> + <!-- Partitioned cache example configuration (Atomic mode). --> + <bean class="org.apache.ignite.configuration.CacheConfiguration"> + <property name="name" value="CacheQueryExample"/> + <property name="typeMetadata"> + <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <property name="valueType" value="javax.json.JsonObject"/> + <property name="queryFields"> + <map> + <entry key="salary" value="java.lang.Integer"/> + <entry key="address" value="javax.json.JsonObject"/> + </map> + </property> + <property name="ascendingFields"> + <map> + <entry key="name" value="java.lang.String"/> + <entry key="id" value="java.lang.Integer"/> + </map> + </property> + </bean> + </property> + </bean> + </list> + </property> + + <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. --> + <property name="discoverySpi"> + <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> + <property name="ipFinder"> + <!-- + Ignite provides several options for automatic discovery that can be used + instead os static IP based discovery. For information on all options refer + to our documentation: http://apacheignite.readme.io/docs/cluster-config + --> + <!-- 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..47509</value> + </list> + </property> + </bean> + </property> + </bean> + </property> + </bean> +</beans> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d2f41c93/examples/pom.xml ---------------------------------------------------------------------- diff --git a/examples/pom.xml b/examples/pom.xml index 901851d..8204a36 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -39,6 +39,12 @@ <dependency> <groupId>org.apache.ignite</groupId> + <artifactId>ignite-json</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> <artifactId>ignite-core</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d2f41c93/examples/src/main/java/org/apache/ignite/examples/ExampleNodeStartup.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/ExampleNodeStartup.java b/examples/src/main/java/org/apache/ignite/examples/ExampleNodeStartup.java index f972b53..1239856 100644 --- a/examples/src/main/java/org/apache/ignite/examples/ExampleNodeStartup.java +++ b/examples/src/main/java/org/apache/ignite/examples/ExampleNodeStartup.java @@ -30,6 +30,6 @@ public class ExampleNodeStartup { * @throws IgniteException If failed. */ public static void main(String[] args) throws IgniteException { - Ignition.start("examples/config/example-ignite.xml"); + Ignition.start("examples/config/js/example-query.xml"); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d2f41c93/examples/src/main/js/cache-query-example.js ---------------------------------------------------------------------- diff --git a/examples/src/main/js/cache-query-example.js b/examples/src/main/js/cache-query-example.js index 8b455b5..752175f 100644 --- a/examples/src/main/js/cache-query-example.js +++ b/examples/src/main/js/cache-query-example.js @@ -103,16 +103,16 @@ main = function() { // Initialize cache for people. function initializeEntries() { - var key1 = "1"; - var value1 = {"firstName" : "John", "lastName" : "Doe", "salary" : 2000}; - var key2 = "2"; - var value2 = {"firstName" : "Jane", "lastName" : "Doe", "salary" : 1000}; - var key3 = "3"; - var value3 = {"firstName" : "John", "lastName" : "Smith", "salary" : 1000}; - var key4 = "4"; - var value4 = {"firstName" : "Jane", "lastName" : "Smith", "salary" : 2000}; - var key5 = "5"; - var value5 = {"firstName" : "Ann", "lastName" : "Smith", "salary" : 3000}; + var key1 = 1; + var value1 = {"name" : "John", "id" : 1, "salary" : 2000, "address" : {"street" : "1st Avenue"}}; + var key2 = 2; + var value2 = {"name" : "Jane", "id" : 2, "salary" : 1000, "address" : {"street" : "1st Avenue"}}; + var key3 = 3; + var value3 = {"name" : "John", "id" : 3, "salary" : 1000, "address" : {"street" : "1st Avenue"}}; + var key4 = 4; + var value4 = {"name" : "Jane", "id" : 4, "salary" : 2000, "address" : {"street" : "1st Avenue"}}; + var key5 = 5; + var value5 = {"name" : "Ann", "id" : 5, "salary" : 3000, "address" : {"street" : "1st Avenue"}}; return [new CacheEntry(key1, value1), new CacheEntry(key2, value2), new CacheEntry(key3, value3), new CacheEntry(key4, value4)];