http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java ---------------------------------------------------------------------- diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java deleted file mode 100644 index 8c85a3e..0000000 --- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.examples.java8.misc.schedule; - -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteException; -import org.apache.ignite.Ignition; -import org.apache.ignite.examples.ExampleNodeStartup; -import org.apache.ignite.scheduler.SchedulerFuture; - -/** - * Demonstrates a cron-based {@link Runnable} execution scheduling. - * Test runnable object broadcasts a phrase to all cluster nodes every minute - * three times with initial scheduling delay equal to five seconds. - * <p> - * Remote nodes should always be started with special configuration file which - * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}. - * <p> - * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node - * with {@code examples/config/example-ignite.xml} configuration. - */ -public class ComputeScheduleExample { - /** - * Executes example. - * - * @param args Command line arguments, none required. - * @throws IgniteException If example execution failed. - */ - public static void main(String[] args) throws IgniteException { - try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) { - System.out.println(); - System.out.println("Compute schedule example started."); - - // Schedule output message every minute. - SchedulerFuture<?> fut = ignite.scheduler().scheduleLocal(() -> - ignite.compute().broadcast(() -> { - System.out.println(); - System.out.println("Howdy! :)"); - - return "Howdy! :)"; - }), - "{5, 3} * * * * *" // Cron expression. - ); - - while (!fut.isDone()) - System.out.println(">>> Invocation result: " + fut.get()); - - System.out.println(); - System.out.println(">>> Schedule future is done and has been unscheduled."); - System.out.println(">>> Check all nodes for hello message output."); - } - } -} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java ---------------------------------------------------------------------- diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java deleted file mode 100644 index 42132f1..0000000 --- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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 description. --> - * Demonstrates usage of cron-based scheduler. - */ -package org.apache.ignite.examples.java8.misc.schedule; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java ---------------------------------------------------------------------- diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java deleted file mode 100644 index 538c4eb..0000000 --- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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.examples.java8.streaming; - -import java.util.List; -import java.util.Random; -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.SqlFieldsQuery; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.examples.ExampleNodeStartup; -import org.apache.ignite.examples.ExamplesUtils; -import org.apache.ignite.stream.StreamTransformer; - -/** - * Stream random numbers into the streaming cache. - * To start the example, you should: - * <ul> - * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li> - * <li>Start streaming using {@link StreamTransformerExample}.</li> - * </ul> - * <p> - * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM. - */ -public class StreamTransformerExample { - /** Random number generator. */ - private static final Random RAND = new Random(); - - /** Range within which to generate numbers. */ - private static final int RANGE = 1000; - - public static void main(String[] args) throws Exception { - // Mark this cluster member as client. - Ignition.setClientMode(true); - - try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) { - if (!ExamplesUtils.hasServerNodes(ignite)) - return; - - CacheConfiguration<Integer, Long> cfg = new CacheConfiguration<>("randomNumbers"); - - // Index key and value. - cfg.setIndexedTypes(Integer.class, Long.class); - - // Auto-close cache at the end of the example. - try (IgniteCache<Integer, Long> stmCache = ignite.getOrCreateCache(cfg)) { - try (IgniteDataStreamer<Integer, Long> stmr = ignite.dataStreamer(stmCache.getName())) { - // Allow data updates. - stmr.allowOverwrite(true); - - // Configure data transformation to count random numbers added to the stream. - stmr.receiver(StreamTransformer.from((e, arg) -> { - // Get current count. - Long val = e.getValue(); - - // Increment count by 1. - e.setValue(val == null ? 1L : val + 1); - - return null; - })); - - // Stream 10 million of random numbers into the streamer cache. - for (int i = 1; i <= 10_000_000; i++) { - stmr.addData(RAND.nextInt(RANGE), 1L); - - if (i % 500_000 == 0) - System.out.println("Number of tuples streamed into Ignite: " + i); - } - } - - // Query top 10 most popular numbers every. - SqlFieldsQuery top10Qry = new SqlFieldsQuery("select _key, _val from Long order by _val desc limit 10"); - - // Execute queries. - List<List<?>> top10 = stmCache.query(top10Qry).getAll(); - - System.out.println("Top 10 most popular numbers:"); - - // Print top 10 words. - ExamplesUtils.printQueryResults(top10); - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java ---------------------------------------------------------------------- diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java deleted file mode 100644 index cef9f2f..0000000 --- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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.examples.java8.streaming; - -import java.io.Serializable; -import java.util.List; -import java.util.Random; -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.SqlFieldsQuery; -import org.apache.ignite.cache.query.annotations.QuerySqlField; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.examples.ExampleNodeStartup; -import org.apache.ignite.examples.ExamplesUtils; -import org.apache.ignite.stream.StreamVisitor; - -/** - * Stream random numbers into the streaming cache. - * To start the example, you should: - * <ul> - * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li> - * <li>Start streaming using {@link StreamVisitorExample}.</li> - * </ul> - * <p> - * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM. - */ -public class StreamVisitorExample { - /** Random number generator. */ - private static final Random RAND = new Random(); - - /** The list of instruments. */ - private static final String[] INSTRUMENTS = {"IBM", "GOOG", "MSFT", "GE", "EBAY", "YHOO", "ORCL", "CSCO", "AMZN", "RHT"}; - - /** The list of initial instrument prices. */ - private static final double[] INITIAL_PRICES = {194.9, 893.49, 34.21, 23.24, 57.93, 45.03, 44.41, 28.44, 378.49, 69.50}; - - public static void main(String[] args) throws Exception { - // Mark this cluster member as client. - Ignition.setClientMode(true); - - try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) { - if (!ExamplesUtils.hasServerNodes(ignite)) - return; - - // Market data cache with default configuration. - CacheConfiguration<String, Double> mktDataCfg = new CacheConfiguration<>("marketTicks"); - - // Financial instrument cache configuration. - CacheConfiguration<String, Instrument> instCfg = new CacheConfiguration<>("instCache"); - - // Index key and value for querying financial instruments. - // Note that Instrument class has @QuerySqlField annotation for secondary field indexing. - instCfg.setIndexedTypes(String.class, Instrument.class); - - // Auto-close caches at the end of the example. - try ( - IgniteCache<String, Double> mktCache = ignite.getOrCreateCache(mktDataCfg); - IgniteCache<String, Instrument> instCache = ignite.getOrCreateCache(instCfg) - ) { - try (IgniteDataStreamer<String, Double> mktStmr = ignite.dataStreamer(mktCache.getName())) { - // Note that we receive market data, but do not populate 'mktCache' (it remains empty). - // Instead we update the instruments in the 'instCache'. - // Since both, 'instCache' and 'mktCache' use the same key, updates are collocated. - mktStmr.receiver(StreamVisitor.from((cache, e) -> { - String symbol = e.getKey(); - Double tick = e.getValue(); - - Instrument inst = instCache.get(symbol); - - if (inst == null) - inst = new Instrument(symbol); - - // Don't populate market cache, as we don't use it for querying. - // Update cached instrument based on the latest market tick. - inst.update(tick); - - instCache.put(symbol, inst); - })); - - // Stream 10 million market data ticks into the system. - for (int i = 1; i <= 10_000_000; i++) { - int idx = RAND.nextInt(INSTRUMENTS.length); - - // Use gaussian distribution to ensure that - // numbers closer to 0 have higher probability. - double price = round2(INITIAL_PRICES[idx] + RAND.nextGaussian()); - - mktStmr.addData(INSTRUMENTS[idx], price); - - if (i % 500_000 == 0) - System.out.println("Number of tuples streamed into Ignite: " + i); - } - } - - // Select top 3 best performing instruments. - SqlFieldsQuery top3qry = new SqlFieldsQuery( - "select symbol, (latest - open) from Instrument order by (latest - open) desc limit 3"); - - // Execute queries. - List<List<?>> top3 = instCache.query(top3qry).getAll(); - - System.out.println("Top performing financial instruments: "); - - // Print top 10 words. - ExamplesUtils.printQueryResults(top3); - } - } - } - - /** - * Rounds double value to two significant signs. - * - * @param val value to be rounded. - * @return rounded double value. - */ - private static double round2(double val) { - return Math.floor(100 * val + 0.5) / 100; - } - - /** - * Financial instrument. - */ - public static class Instrument implements Serializable { - /** Instrument symbol. */ - @QuerySqlField(index = true) - private final String symbol; - - /** Open price. */ - @QuerySqlField(index = true) - private double open; - - /** Close price. */ - @QuerySqlField(index = true) - private double latest; - - /** - * @param symbol Symbol. - */ - public Instrument(String symbol) { - this.symbol = symbol; - } - - /** - * Updates this instrument based on the latest market tick price. - * - * @param price Latest price. - */ - public void update(double price) { - if (open == 0) - open = price; - - this.latest = price; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java ---------------------------------------------------------------------- diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java deleted file mode 100644 index d215d2f..0000000 --- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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 description. --> - * Demonstrates usage of data streamer. - */ -package org.apache.ignite.examples.java8.streaming; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples/config/hibernate/README.txt ---------------------------------------------------------------------- diff --git a/examples/config/hibernate/README.txt b/examples/config/hibernate/README.txt deleted file mode 100644 index 5b7ab29..0000000 --- a/examples/config/hibernate/README.txt +++ /dev/null @@ -1,8 +0,0 @@ -Hibernate L2 Cache Configuration Example ----------------------------------------- - -This folder contains example-hibernate-L2-cache.xml file that demonstrates -how to configure Hibernate to use Apache Ignite cache as an L2 cache provider. - -This file is also used in Hibernate example located in org.apache.ignite.examples.datagrid.hibernate -package. http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples/config/hibernate/example-hibernate-L2-cache.xml ---------------------------------------------------------------------- diff --git a/examples/config/hibernate/example-hibernate-L2-cache.xml b/examples/config/hibernate/example-hibernate-L2-cache.xml deleted file mode 100644 index 3248946..0000000 --- a/examples/config/hibernate/example-hibernate-L2-cache.xml +++ /dev/null @@ -1,64 +0,0 @@ -<?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. ---> - - -<!DOCTYPE hibernate-configuration PUBLIC - "-//Hibernate/Hibernate Configuration DTD 3.0//EN" - "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> - -<!-- - Configuration file for HibernateL2CacheExample. ---> - -<hibernate-configuration> - <session-factory> - <!-- Database connection settings --> - <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property> - - <!-- Drop and re-create the database schema on startup. --> - <property name="hbm2ddl.auto">create</property> - - <!-- Enable L2 cache. --> - <property name="cache.use_second_level_cache">true</property> - - <!-- Enable query cache. --> - <property name="cache.use_query_cache">true</property> - - <!-- Generate L2 cache statistics. --> - <property name="generate_statistics">true</property> - - <!-- Specify Ignite as L2 cache provider. --> - <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property> - - <!-- Specify connection release mode. --> - <property name="connection.release_mode">on_close</property> - - <!-- Set default L2 cache access type. --> - <property name="org.apache.ignite.hibernate.default_access_type">READ_ONLY</property> - - <!-- Specify the entity classes for mapping. --> - <mapping class="org.apache.ignite.examples.datagrid.hibernate.User"/> - <mapping class="org.apache.ignite.examples.datagrid.hibernate.Post"/> - - <!-- Per-class L2 cache settings. --> - <class-cache class="org.apache.ignite.examples.datagrid.hibernate.User" usage="read-only"/> - <class-cache class="org.apache.ignite.examples.datagrid.hibernate.Post" usage="read-only"/> - <collection-cache collection="org.apache.ignite.examples.datagrid.hibernate.User.posts" usage="read-only"/> - </session-factory> -</hibernate-configuration> http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 7b8763f..6eeb006 100644 --- a/pom.xml +++ b/pom.xml @@ -147,6 +147,72 @@ </profile> <profile> + <id>lgpl</id> + <modules> + <module>modules/hibernate</module> + <module>modules/geospatial</module> + <module>modules/schedule</module> + </modules> + + <build> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <dependencies> + <dependency> + <groupId>org.apache.apache.resources</groupId> + <artifactId>apache-source-release-assembly-descriptor</artifactId> + <version>1.0.4</version> + </dependency> + </dependencies> + <executions> + <execution> + <id>release-lgpl</id> + <phase>prepare-package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <descriptors> + <descriptor>assembly/release-${ignite.edition}-lgpl.xml</descriptor> + </descriptors> + <finalName>release-package</finalName> + <appendAssemblyId>false</appendAssemblyId> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.7</version> + <inherited>false</inherited> + <executions> + <execution> + <id>release-postprocessing-lgpl</id> + <goals> + <goal>run</goal> + </goals> + <phase>package</phase> + <configuration> + <target> + <replaceregexp file="${basedir}/target/release-package/examples-lgpl/pom.xml" + byline="true"> + <regexp pattern="to_be_replaced_by_ignite_version"/> + <substitution expression="${project.version}"/> + </replaceregexp> + </target> + </configuration> + </execution> + </executions> + </plugin> + + </plugins> + </build> + </profile> + + <profile> <id>release</id> <activation> <activeByDefault>true</activeByDefault> @@ -459,72 +525,6 @@ </profile> <profile> - <id>lgpl</id> - <modules> - <module>modules/hibernate</module> - <module>modules/geospatial</module> - <module>modules/schedule</module> - </modules> - - <build> - <plugins> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <dependencies> - <dependency> - <groupId>org.apache.apache.resources</groupId> - <artifactId>apache-source-release-assembly-descriptor</artifactId> - <version>1.0.4</version> - </dependency> - </dependencies> - <executions> - <execution> - <id>release-lgpl</id> - <phase>prepare-package</phase> - <goals> - <goal>single</goal> - </goals> - <configuration> - <descriptors> - <descriptor>assembly/release-${ignite.edition}-lgpl.xml</descriptor> - </descriptors> - <finalName>release-package</finalName> - <appendAssemblyId>false</appendAssemblyId> - </configuration> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-antrun-plugin</artifactId> - <version>1.7</version> - <inherited>false</inherited> - <executions> - <execution> - <id>release-postprocessing-lgpl</id> - <goals> - <goal>run</goal> - </goals> - <phase>package</phase> - <configuration> - <target> - <replaceregexp file="${basedir}/target/release-package/examples-lgpl/pom.xml" - byline="true"> - <regexp pattern="to_be_replaced_by_ignite_version"/> - <substitution expression="${project.version}"/> - </replaceregexp> - </target> - </configuration> - </execution> - </executions> - </plugin> - - </plugins> - </build> - </profile> - - <profile> <id>examples</id> <modules> <module>examples</module>