IGNITE-1653
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bd2cd923 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bd2cd923 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bd2cd923 Branch: refs/heads/ignite-1607 Commit: bd2cd92349cf369f6a2f8b634591e180d8acfb58 Parents: 15cc1bd Author: Anton Vinogradov <[email protected]> Authored: Mon Oct 26 17:24:35 2015 +0300 Committer: Anton Vinogradov <[email protected]> Committed: Mon Oct 26 17:24:35 2015 +0300 ---------------------------------------------------------------------- DEVNOTES.txt | 2 +- assembly/dependencies-fabric-lgpl.xml | 169 +++++++++++++ assembly/dependencies-fabric.xml | 3 + assembly/release-fabric-base.xml | 107 ++++++++ assembly/release-fabric-lgpl.xml | 41 ++-- assembly/release-fabric.xml | 85 +------ assembly/release-hadoop-lgpl.xml | 39 --- config/fabric-lgpl/default-config.xml | 29 +++ examples-lgpl/README.txt | 27 -- examples-lgpl/config/example-cache.xml | 73 ------ examples-lgpl/config/example-ignite.xml | 83 ------- examples-lgpl/config/hibernate/README.txt | 8 - .../hibernate/example-hibernate-L2-cache.xml | 64 ----- examples-lgpl/pom-standalone.xml | 186 -------------- examples-lgpl/pom.xml | 128 ---------- .../hibernate/HibernateL2CacheExample.java | 245 ------------------- .../examples/datagrid/hibernate/Post.java | 130 ---------- .../examples/datagrid/hibernate/User.java | 154 ------------ .../datagrid/hibernate/package-info.java | 22 -- .../hibernate/CacheHibernatePersonStore.java | 122 --------- .../hibernate/CacheHibernateStoreExample.java | 151 ------------ .../datagrid/store/hibernate/Person.hbm.xml | 34 --- .../datagrid/store/hibernate/hibernate.cfg.xml | 41 ---- .../datagrid/store/hibernate/package-info.java | 22 -- .../misc/schedule/ComputeScheduleExample.java | 82 ------- .../examples/misc/schedule/package-info.java | 22 -- .../misc/schedule/ComputeScheduleExample.java | 68 ----- .../java8/misc/schedule/package-info.java | 22 -- .../ignite/examples/java8/package-info.java | 23 -- .../scalar/examples/ScalarScheduleExample.scala | 66 ----- ...ibernateL2CacheExampleMultiNodeSelfTest.java | 31 --- .../HibernateL2CacheExampleSelfTest.java | 33 --- .../IgniteLgplExamplesSelfTestSuite.java | 48 ---- ...ibernateL2CacheExampleMultiNodeSelfTest.java | 29 --- .../HibernateL2CacheExampleSelfTest.java | 37 --- .../IgniteLgplExamplesJ8SelfTestSuite.java | 46 ---- .../ScalarLgplExamplesMultiNodeSelfTest.scala | 33 --- .../examples/ScalarLgplExamplesSelfTest.scala | 36 --- .../ScalarLgplExamplesSelfTestSuite.scala | 37 --- examples/README-LGPL.txt | 33 +++ examples/README.txt | 21 +- examples/config/hibernate/README.txt | 8 + .../hibernate/example-hibernate-L2-cache.xml | 64 +++++ examples/pom-standalone-lgpl.xml | 217 ++++++++++++++++ examples/pom-standalone.xml | 156 ++++++------ examples/pom.xml | 157 ++++++------ .../hibernate/HibernateL2CacheExample.java | 245 +++++++++++++++++++ .../examples/datagrid/hibernate/Post.java | 130 ++++++++++ .../examples/datagrid/hibernate/User.java | 154 ++++++++++++ .../datagrid/hibernate/package-info.java | 22 ++ .../hibernate/CacheHibernatePersonStore.java | 122 +++++++++ .../hibernate/CacheHibernateStoreExample.java | 151 ++++++++++++ .../datagrid/store/hibernate/Person.hbm.xml | 34 +++ .../datagrid/store/hibernate/hibernate.cfg.xml | 41 ++++ .../datagrid/store/hibernate/package-info.java | 22 ++ .../misc/schedule/ComputeScheduleExample.java | 82 +++++++ .../examples/misc/schedule/package-info.java | 22 ++ ...ibernateL2CacheExampleMultiNodeSelfTest.java | 31 +++ .../HibernateL2CacheExampleSelfTest.java | 33 +++ .../IgniteLgplExamplesSelfTestSuite.java | 48 ++++ pom.xml | 64 ----- 61 files changed, 1977 insertions(+), 2458 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/DEVNOTES.txt ---------------------------------------------------------------------- diff --git a/DEVNOTES.txt b/DEVNOTES.txt index a6c45f0..e8e3741 100644 --- a/DEVNOTES.txt +++ b/DEVNOTES.txt @@ -7,7 +7,7 @@ Without LGPL dependencies and Scala 2.10: mvn clean package -DskipTests -Dscala-2.10 With LGPL dependencies: - mvn clean package -DskipTests -Prelease,lgpl + mvn clean package -DskipTests -Prelease,lgpl -Dignite.edition=fabric-lgpl With LGPL dependencies and Scala 2.10: mvn clean package -DskipTests -Prelease,lgpl -Dscala-2.10 http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/assembly/dependencies-fabric-lgpl.xml ---------------------------------------------------------------------- diff --git a/assembly/dependencies-fabric-lgpl.xml b/assembly/dependencies-fabric-lgpl.xml new file mode 100644 index 0000000..f50847e --- /dev/null +++ b/assembly/dependencies-fabric-lgpl.xml @@ -0,0 +1,169 @@ +<?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. +--> + +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 + http://maven.apache.org/xsd/assembly-1.1.2.xsd"> + <id>dependencies</id> + + <formats> + <format>dir</format> + </formats> + + <includeBaseDirectory>false</includeBaseDirectory> + + <moduleSets> + <moduleSet> + <includes> + <include>org.apache.ignite:ignite-spring</include> + <include>org.apache.ignite:ignite-indexing</include> + </includes> + <sources> + <includeModuleDirectory>true</includeModuleDirectory> + <fileSets> + <fileSet> + <directory>${basedir}</directory> + <outputDirectory>/</outputDirectory> + <includes> + <include>README.txt</include> + <include>licenses/**</include> + </includes> + </fileSet> + <fileSet> + <directory>${basedir}/target/licenses</directory> + <outputDirectory>/licenses</outputDirectory> + </fileSet> + <fileSet> + <directory>target/libs</directory> + <outputDirectory>/</outputDirectory> + </fileSet> + <fileSet> + <directory>target</directory> + <outputDirectory>/</outputDirectory> + <includes> + <include>*.jar</include> + </includes> + <excludes> + <exclude>*-tests.jar</exclude> + <exclude>*-javadoc.jar</exclude> + <exclude>*-sources.jar</exclude> + </excludes> + </fileSet> + </fileSets> + </sources> + </moduleSet> + + <moduleSet> + <includes> + <include>org.apache.ignite:ignite-core</include> + </includes> + <sources> + <includeModuleDirectory>false</includeModuleDirectory> + <fileSets> + <fileSet> + <directory>${basedir}</directory> + <outputDirectory>/</outputDirectory> + <includes> + <include>README.txt</include> + <include>licenses/**</include> + </includes> + </fileSet> + <fileSet> + <directory>${basedir}/target/licenses</directory> + <outputDirectory>/licenses</outputDirectory> + </fileSet> + <fileSet> + <directory>target/libs</directory> + <outputDirectory>/</outputDirectory> + </fileSet> + <fileSet> + <directory>target</directory> + <outputDirectory>/</outputDirectory> + <includes> + <include>*.jar</include> + </includes> + <excludes> + <exclude>*-tests.jar</exclude> + <exclude>*-javadoc.jar</exclude> + <exclude>*-sources.jar</exclude> + </excludes> + </fileSet> + </fileSets> + </sources> + </moduleSet> + + <moduleSet> + <includeSubModules>true</includeSubModules> + <excludes> + <exclude>org.apache.ignite:ignite-core</exclude> + <exclude>org.apache.ignite:ignite-clients</exclude> + <exclude>org.apache.ignite:ignite-spring</exclude> + <exclude>org.apache.ignite:ignite-tools</exclude> + <exclude>org.apache.ignite:ignite-extdata-p2p</exclude> + <exclude>org.apache.ignite:ignite-extdata-uri</exclude> + <exclude>org.apache.ignite:ignite-extdata-uri-dep</exclude> + <exclude>org.apache.ignite:ignite-examples</exclude> + <exclude>org.apache.ignite:ignite-schema-import-demo</exclude> + <exclude>org.apache.ignite:ignite-indexing</exclude> + <exclude>org.apache.ignite:ignite-visor-console</exclude> + <exclude>org.apache.ignite:ignite-visor-console_2.10</exclude> + <exclude>org.apache.ignite:ignite-visor-plugins</exclude> + <exclude>org.apache.ignite:ignite-hadoop</exclude> + <exclude>org.apache.ignite:ignite-schema-import</exclude> + <exclude>org.apache.ignite:ignite-codegen</exclude> + <exclude>org.apache.ignite:ignite-apache-license-gen</exclude> + </excludes> + <sources> + <includeModuleDirectory>true</includeModuleDirectory> + <outputDirectoryMapping>optional/${module.artifactId}</outputDirectoryMapping> + <fileSets> + <fileSet> + <directory>${basedir}</directory> + <outputDirectory>/</outputDirectory> + <includes> + <include>README.txt</include> + <include>licenses/**</include> + </includes> + </fileSet> + <fileSet> + <directory>${basedir}/target/licenses</directory> + <outputDirectory>/licenses</outputDirectory> + </fileSet> + <fileSet> + <directory>target/libs</directory> + <outputDirectory>/</outputDirectory> + </fileSet> + <fileSet> + <directory>target</directory> + <outputDirectory>/</outputDirectory> + <includes> + <include>*.jar</include> + </includes> + <excludes> + <exclude>*-tests.jar</exclude> + <exclude>*-javadoc.jar</exclude> + <exclude>*-sources.jar</exclude> + </excludes> + </fileSet> + </fileSets> + </sources> + </moduleSet> + </moduleSets> +</assembly> http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/assembly/dependencies-fabric.xml ---------------------------------------------------------------------- diff --git a/assembly/dependencies-fabric.xml b/assembly/dependencies-fabric.xml index f50847e..5fb7cb1 100644 --- a/assembly/dependencies-fabric.xml +++ b/assembly/dependencies-fabric.xml @@ -129,6 +129,9 @@ <exclude>org.apache.ignite:ignite-schema-import</exclude> <exclude>org.apache.ignite:ignite-codegen</exclude> <exclude>org.apache.ignite:ignite-apache-license-gen</exclude> + <exclude>org.apache.ignite:ignite-hibernate</exclude> + <exclude>org.apache.ignite:ignite-schedule</exclude> + <exclude>org.apache.ignite:ignite-geospatial</exclude> </excludes> <sources> <includeModuleDirectory>true</includeModuleDirectory> http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/assembly/release-fabric-base.xml ---------------------------------------------------------------------- diff --git a/assembly/release-fabric-base.xml b/assembly/release-fabric-base.xml new file mode 100644 index 0000000..944e8ce --- /dev/null +++ b/assembly/release-fabric-base.xml @@ -0,0 +1,107 @@ +<?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. + --> + +<component xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.2" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.2 + http://maven.apache.org/xsd/component-1.1.2.xsd"> + <files> + <file> + <source>assembly/LICENSE_FABRIC</source> + <destName>LICENSE</destName> + <outputDirectory>/</outputDirectory> + </file> + + <file> + <source>assembly/NOTICE_FABRIC</source> + <destName>NOTICE</destName> + <outputDirectory>/</outputDirectory> + </file> + + <file> + <source>examples/schema-import/pom-standalone.xml</source> + <outputDirectory>/examples/schema-import</outputDirectory> + <destName>pom.xml</destName> + </file> + </files> + + <fileSets> + <fileSet> + <directory>bin</directory> + <outputDirectory>/bin</outputDirectory> + <includes> + <include>igniterouter.bat</include> + </includes> + </fileSet> + + <fileSet> + <directory>bin</directory> + <outputDirectory>/bin</outputDirectory> + <fileMode>0755</fileMode> + <includes> + <include>igniterouter.sh</include> + </includes> + </fileSet> + + <fileSet> + <directory>config/router</directory> + <outputDirectory>/config/router</outputDirectory> + </fileSet> + + <fileSet> + <directory>examples</directory> + <outputDirectory>/examples</outputDirectory> + <includes> + <include>rest/**</include> + <include>memcached/**</include> + <include>schema-import/src/**</include> + <include>schema-import/bin/**</include> + <include>schema-import/README.txt</include> + </includes> + </fileSet> + + <fileSet> + <directory>target/javadoc/core</directory> + <outputDirectory>/docs/javadoc</outputDirectory> + </fileSet> + + <fileSet> + <directory>modules/scalar/target/site/scaladocs</directory> + <outputDirectory>/docs/scaladoc/scalar</outputDirectory> + </fileSet> + + <fileSet> + <directory>examples</directory> + <outputDirectory>/examples</outputDirectory> + <includes> + <include>config/**</include> + <include>src/**</include> + </includes> + <excludes> + <exclude>**/package.html</exclude> + <exclude>src/test/**</exclude> + </excludes> + </fileSet> + + <fileSet> + <directory>assembly/libs</directory> + <outputDirectory>/libs</outputDirectory> + </fileSet> + </fileSets> +</component> http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/assembly/release-fabric-lgpl.xml ---------------------------------------------------------------------- diff --git a/assembly/release-fabric-lgpl.xml b/assembly/release-fabric-lgpl.xml index b8757db..1766558 100644 --- a/assembly/release-fabric-lgpl.xml +++ b/assembly/release-fabric-lgpl.xml @@ -21,7 +21,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> - <id>fabric</id> + <id>fabric-lgpl</id> <includeBaseDirectory>false</includeBaseDirectory> @@ -29,35 +29,22 @@ <format>dir</format> </formats> + <componentDescriptors> + <componentDescriptor>release-base.xml</componentDescriptor> + <componentDescriptor>release-fabric-base.xml</componentDescriptor> + </componentDescriptors> + <files> <file> - <source>examples-lgpl/pom-standalone.xml</source> - <outputDirectory>/examples-lgpl</outputDirectory> + <source>examples/pom-standalone-lgpl.xml</source> + <outputDirectory>/examples</outputDirectory> <destName>pom.xml</destName> </file> - </files> - <fileSets> - <fileSet> - <directory>examples-lgpl</directory> - <outputDirectory>/examples-lgpl</outputDirectory> - <includes> - <include>README.txt</include> - </includes> - </fileSet> - - <fileSet> - <directory>examples-lgpl</directory> - <outputDirectory>/examples-lgpl</outputDirectory> - <includes> - <include>config/**</include> - <include>src/**</include> - </includes> - <excludes> - <exclude>**/package.html</exclude> - <exclude>pom-standalone.xml</exclude> - <exclude>src/test/**</exclude> - </excludes> - </fileSet> - </fileSets> + <file> + <source>examples/README-LGPL.txt</source> + <outputDirectory>/examples</outputDirectory> + <destName>README.txt</destName> + </file> + </files> </assembly> http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/assembly/release-fabric.xml ---------------------------------------------------------------------- diff --git a/assembly/release-fabric.xml b/assembly/release-fabric.xml index 9f9fbb2..ffde8ec 100644 --- a/assembly/release-fabric.xml +++ b/assembly/release-fabric.xml @@ -31,97 +31,20 @@ <componentDescriptors> <componentDescriptor>release-base.xml</componentDescriptor> + <componentDescriptor>release-fabric-base.xml</componentDescriptor> </componentDescriptors> <files> <file> - <source>assembly/LICENSE_FABRIC</source> - <destName>LICENSE</destName> - <outputDirectory>/</outputDirectory> - </file> - - <file> - <source>assembly/NOTICE_FABRIC</source> - <destName>NOTICE</destName> - <outputDirectory>/</outputDirectory> - </file> - - <file> <source>examples/pom-standalone.xml</source> <outputDirectory>/examples</outputDirectory> <destName>pom.xml</destName> </file> <file> - <source>examples/schema-import/pom-standalone.xml</source> - <outputDirectory>/examples/schema-import</outputDirectory> - <destName>pom.xml</destName> + <source>examples/README.txt</source> + <outputDirectory>/examples</outputDirectory> + <destName>README.txt</destName> </file> </files> - - <fileSets> - <fileSet> - <directory>bin</directory> - <outputDirectory>/bin</outputDirectory> - <includes> - <include>igniterouter.bat</include> - </includes> - </fileSet> - - <fileSet> - <directory>bin</directory> - <outputDirectory>/bin</outputDirectory> - <fileMode>0755</fileMode> - <includes> - <include>igniterouter.sh</include> - </includes> - </fileSet> - - <fileSet> - <directory>config/router</directory> - <outputDirectory>/config/router</outputDirectory> - </fileSet> - - <fileSet> - <directory>examples</directory> - <outputDirectory>/examples</outputDirectory> - <includes> - <include>rest/**</include> - <include>memcached/**</include> - <include>schema-import/src/**</include> - <include>schema-import/bin/**</include> - <include>schema-import/README.txt</include> - <include>README.txt</include> - </includes> - </fileSet> - - <fileSet> - <directory>target/javadoc/core</directory> - <outputDirectory>/docs/javadoc</outputDirectory> - </fileSet> - - <fileSet> - <directory>modules/scalar/target/site/scaladocs</directory> - <outputDirectory>/docs/scaladoc/scalar</outputDirectory> - </fileSet> - - <fileSet> - <directory>examples</directory> - <outputDirectory>/examples</outputDirectory> - <includes> - <include>config/**</include> - <include>src/**</include> - </includes> - <excludes> - <exclude>**/package.html</exclude> - <exclude>pom-standalone.xml</exclude> - <exclude>src/test/**</exclude> - </excludes> - </fileSet> - - <fileSet> - <directory>assembly/libs</directory> - <outputDirectory>/libs</outputDirectory> - </fileSet> - </fileSets> </assembly> http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/assembly/release-hadoop-lgpl.xml ---------------------------------------------------------------------- diff --git a/assembly/release-hadoop-lgpl.xml b/assembly/release-hadoop-lgpl.xml deleted file mode 100644 index ac2fc31..0000000 --- a/assembly/release-hadoop-lgpl.xml +++ /dev/null @@ -1,39 +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. ---> - -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 - http://maven.apache.org/xsd/assembly-1.1.2.xsd"> - <id>fabric</id> - - <includeBaseDirectory>false</includeBaseDirectory> - - <formats> - <format>dir</format> - </formats> - - <files> - <file> - <source>assembly/LICENSE_HADOOP</source><!--assembly should contain at least one file. copied from release-hadoop.xml --> - <destName>LICENSE</destName> - <outputDirectory>/</outputDirectory> - </file> - </files> -</assembly> http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/config/fabric-lgpl/default-config.xml ---------------------------------------------------------------------- diff --git a/config/fabric-lgpl/default-config.xml b/config/fabric-lgpl/default-config.xml new file mode 100644 index 0000000..5da95ba --- /dev/null +++ b/config/fabric-lgpl/default-config.xml @@ -0,0 +1,29 @@ +<?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. +--> + +<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"> + <!-- + Alter configuration below as needed. + --> + <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"/> +</beans> http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples-lgpl/README.txt ---------------------------------------------------------------------- diff --git a/examples-lgpl/README.txt b/examples-lgpl/README.txt deleted file mode 100644 index 8c8982e..0000000 --- a/examples-lgpl/README.txt +++ /dev/null @@ -1,27 +0,0 @@ -Apache Ignite LGPL Examples -====================== - -This folder contains code examples for various Apache Ignite functionality. - -Examples are shipped as a separate Maven project, so to start running you simply need -to import provided `pom.xml` file into your favourite IDE. - -The examples folder contains he following subfolders: - -- `config` - contains Ignite configuration files needed for examples. -- `src/main/java` - contains Java examples for different Ignite modules and features. -- `src/main/java8` - contains additional set of Java examples utilizing Java 8 lambdas. These examples - are excluded by default, enable `java8-examples` Maven profile to include them (JDK8 is required). - - -Starting Remote Nodes -===================== - -Remote nodes for examples should always be started with special configuration file which enables P2P -class loading: `examples/config/example-ignite.xml`. To run a remote node in IDE use `ExampleNodeStartup` class. - - -Java7 vs Java8 -=============== -Some examples (not all) which can benefit from Java8 Lambda support were re-written with Java8 lambdas. -For full set of examples, look at both Java7 and Java8 packages. http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples-lgpl/config/example-cache.xml ---------------------------------------------------------------------- diff --git a/examples-lgpl/config/example-cache.xml b/examples-lgpl/config/example-cache.xml deleted file mode 100644 index dcb8e75..0000000 --- a/examples-lgpl/config/example-cache.xml +++ /dev/null @@ -1,73 +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. - --> - -<!-- - 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="cacheConfiguration"> - <list> - <!-- Partitioned cache example configuration (Atomic mode). --> - <bean class="org.apache.ignite.configuration.CacheConfiguration"> - <property name="atomicityMode" value="ATOMIC"/> - <property name="backups" value="1"/> - </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/ignite/blob/bd2cd923/examples-lgpl/config/example-ignite.xml ---------------------------------------------------------------------- diff --git a/examples-lgpl/config/example-ignite.xml b/examples-lgpl/config/example-ignite.xml deleted file mode 100644 index e870106..0000000 --- a/examples-lgpl/config/example-ignite.xml +++ /dev/null @@ -1,83 +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. - --> - -<!-- - Ignite configuration with all defaults and enabled p2p deployment and enabled events. ---> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:util="http://www.springframework.org/schema/util" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/util - http://www.springframework.org/schema/util/spring-util.xsd"> - <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> - <!-- Set to true to enable distributed class loading for examples, default is false. --> - <property name="peerClassLoadingEnabled" value="true"/> - - <property name="marshaller"> - <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller"> - <!-- Set to false to allow non-serializable objects in examples, default is true. --> - <property name="requireSerializable" value="false"/> - </bean> - </property> - - <!-- Enable task execution events for examples. --> - <property name="includeEventTypes"> - <list> - <!--Task execution events--> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/> - - <!--Cache events--> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED"/> - </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/ignite/blob/bd2cd923/examples-lgpl/config/hibernate/README.txt ---------------------------------------------------------------------- diff --git a/examples-lgpl/config/hibernate/README.txt b/examples-lgpl/config/hibernate/README.txt deleted file mode 100644 index 5b7ab29..0000000 --- a/examples-lgpl/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/bd2cd923/examples-lgpl/config/hibernate/example-hibernate-L2-cache.xml ---------------------------------------------------------------------- diff --git a/examples-lgpl/config/hibernate/example-hibernate-L2-cache.xml b/examples-lgpl/config/hibernate/example-hibernate-L2-cache.xml deleted file mode 100644 index a2f7e89..0000000 --- a/examples-lgpl/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/bd2cd923/examples-lgpl/pom-standalone.xml ---------------------------------------------------------------------- diff --git a/examples-lgpl/pom-standalone.xml b/examples-lgpl/pom-standalone.xml deleted file mode 100644 index 2e3bf8f..0000000 --- a/examples-lgpl/pom-standalone.xml +++ /dev/null @@ -1,186 +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. ---> - -<!-- - POM file. ---> -<project - xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <groupId>org.apache.ignite</groupId> - <artifactId>ignite-examples-lgpl</artifactId> - <version>to_be_replaced_by_ignite_version</version> - <packaging>pom</packaging> - - <dependencies> - <dependency> - <groupId>org.apache.ignite</groupId> - <artifactId>ignite-examples</artifactId> - <version>to_be_replaced_by_ignite_version</version> - </dependency> - - <dependency> - <groupId>org.apache.ignite</groupId> - <artifactId>ignite-hibernate</artifactId> - <version>to_be_replaced_by_ignite_version</version> - </dependency> - - <dependency> - <groupId>org.apache.ignite</groupId> - <artifactId>ignite-schedule</artifactId> - <version>to_be_replaced_by_ignite_version</version> - </dependency> - </dependencies> - - <modules> - <module>../examples</module> - </modules> - - <build> - <resources> - <resource> - <directory>src/main/java</directory> - <excludes> - <exclude>**/*.java</exclude> - </excludes> - </resource> - <resource> - <directory>config</directory> - </resource> - </resources> - - <plugins> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.1</version> - <configuration> - <source>1.7</source> - <target>1.7</target> - </configuration> - </plugin> - </plugins> - </build> - - <profiles> - <profile> - <id>java8-examples</id> - - <activation> - <jdk>[1.8,)</jdk> - </activation> - - <build> - <plugins> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.1</version> - <configuration> - <source>1.8</source> - <target>1.8</target> - </configuration> - </plugin> - - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <version>1.9.1</version> - <executions> - <execution> - <id>add-sources</id> - <phase>generate-sources</phase> - <goals> - <goal>add-source</goal> - </goals> - <configuration> - <sources> - <source>src/main/java8</source> - </sources> - </configuration> - </execution> - <execution> - <id>add-tests</id> - <phase>generate-test-sources</phase> - <goals> - <goal>add-test-source</goal> - </goals> - <configuration> - <sources> - <source>src/test/java8</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - - <profile> - <id>scala</id> - - <dependencies> - <dependency> - <groupId>org.apache.ignite</groupId> - <artifactId>ignite-scalar</artifactId> - <version>to_be_replaced_by_ignite_version</version> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>net.alchim31.maven</groupId> - <artifactId>scala-maven-plugin</artifactId> - <version>3.2.0</version> - <configuration> - <jvmArgs> - <jvmArg>-Xms512m</jvmArg> - <jvmArg>-Xmx1024m</jvmArg> - </jvmArgs> - </configuration> - <executions> - <execution> - <id>scala-compile-first</id> - <phase>process-resources</phase> - <goals> - <goal>add-source</goal> - <goal>compile</goal> - </goals> - </execution> - <execution> - <id>scala-test-compile</id> - <phase>process-test-resources</phase> - <goals> - <goal>testCompile</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> -</project> http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples-lgpl/pom.xml ---------------------------------------------------------------------- diff --git a/examples-lgpl/pom.xml b/examples-lgpl/pom.xml deleted file mode 100644 index 019dc23..0000000 --- a/examples-lgpl/pom.xml +++ /dev/null @@ -1,128 +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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.ignite</groupId> - <artifactId>ignite-parent</artifactId> - <version>1</version> - <relativePath>../parent</relativePath> - </parent> - - <artifactId>ignite-examples-lgpl</artifactId> - <version>1.5.0-SNAPSHOT</version> - - <dependencies> - <dependency> - <groupId>org.apache.ignite</groupId> - <artifactId>ignite-hibernate</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.ignite</groupId> - <artifactId>ignite-schedule</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.ignite</groupId> - <artifactId>ignite-examples</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.ignite</groupId> - <artifactId>ignite-core</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <resources> - <resource> - <directory>src/main/java</directory> - <excludes> - <exclude>**/*.java</exclude> - </excludes> - </resource> - <resource> - <directory>config</directory> - </resource> - </resources> - </build> - - <profiles> - <profile> - <id>java8-examples</id> - - <activation> - <jdk>[1.8,)</jdk> - </activation> - - <build> - <plugins> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <source>1.8</source> - <target>1.8</target> - </configuration> - </plugin> - - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <version>1.9.1</version> - <executions> - <execution> - <id>add-sources</id> - <phase>generate-sources</phase> - <goals> - <goal>add-source</goal> - </goals> - <configuration> - <sources> - <source>src/main/java8</source> - </sources> - </configuration> - </execution> - <execution> - <id>add-tests</id> - <phase>generate-test-sources</phase> - <goals> - <goal>add-test-source</goal> - </goals> - <configuration> - <sources> - <source>src/test/java8</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> -</project> http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java ---------------------------------------------------------------------- diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java deleted file mode 100644 index 2f271c8..0000000 --- a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java +++ /dev/null @@ -1,245 +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.datagrid.hibernate; - -import java.net.URL; -import java.util.Arrays; -import java.util.List; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteException; -import org.apache.ignite.Ignition; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.examples.ExampleNodeStartup; -import org.apache.ignite.examples.ExamplesUtils; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.cache.spi.access.AccessType; -import org.hibernate.cfg.Configuration; -import org.hibernate.service.ServiceRegistryBuilder; -import org.hibernate.stat.SecondLevelCacheStatistics; - -import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; - -/** - * This example demonstrates the use of Ignite In-Memory Data Ignite cluster as a Hibernate - * Second-Level cache provider. - * <p> - * The Hibernate Second-Level cache (or "L2 cache" shortly) lets you significantly - * reduce the number of requests to the underlying SQL database. Because database - * access is known to be an expansive operation, using L2 cache may improve - * performance dramatically. - * <p> - * This example defines 2 entity classes: {@link User} and {@link Post}, with - * 1 <-> N relation, and marks them with appropriate annotations for Hibernate - * object-relational mapping to SQL tables of an underlying H2 in-memory database. - * The example launches node in the same JVM and registers it in - * Hibernate configuration as an L2 cache implementation. It then stores and - * queries instances of the entity classes to and from the database, having - * Hibernate SQL output, L2 cache statistics output, and Ignite cache metrics - * output enabled. - * <p> - * When running example, it's easy to notice that when an object is first - * put into a database, the L2 cache is not used and it's contents is empty. - * However, when an object is first read from the database, it is immediately - * stored in L2 cache (which is Ignite In-Memory Data Ignite cluster in fact), which can - * be seen in stats output. Further requests of the same object only read the data - * from L2 cache and do not hit the database. - * <p> - * In this example, the Hibernate query cache is also enabled. Query cache lets you - * avoid hitting the database in case of repetitive queries with the same parameter - * values. You may notice that when the example runs the same query repeatedly in - * loop, only the first query hits the database and the successive requests take the - * data from L2 cache. - * <p> - * Note: this example uses {@link AccessType#READ_ONLY} L2 cache access type, but you - * can experiment with other access types by modifying the Hibernate configuration file - * {@code IGNITE_HOME/examples/config/hibernate/example-hibernate-L2-cache.xml}, used by the example. - * <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 HibernateL2CacheExample { - /** JDBC URL for backing database (an H2 in-memory database is used). */ - private static final String JDBC_URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1"; - - /** Path to hibernate configuration file (will be resolved from application {@code CLASSPATH}). */ - private static final String HIBERNATE_CFG = "hibernate/example-hibernate-L2-cache.xml"; - - /** Entity names for stats output. */ - private static final List<String> ENTITY_NAMES = - Arrays.asList(User.class.getName(), Post.class.getName(), User.class.getName() + ".posts"); - - /** - * Executes example. - * - * @param args Command line arguments, none required. - * @throws IgniteException If example execution failed. - */ - public static void main(String[] args) throws IgniteException { - // Start the node, run the example, and stop the node when finished. - try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) { - // We use a single session factory, but create a dedicated session - // for each transaction or query. This way we ensure that L1 cache - // is not used (L1 cache has per-session scope only). - System.out.println(); - System.out.println(">>> Hibernate L2 cache example started."); - - try ( - // Create all required caches. - IgniteCache c1 = createCache("org.hibernate.cache.spi.UpdateTimestampsCache", ATOMIC); - IgniteCache c2 = createCache("org.hibernate.cache.internal.StandardQueryCache", ATOMIC); - IgniteCache c3 = createCache("org.apache.ignite.examples.datagrid.hibernate.User", TRANSACTIONAL); - IgniteCache c4 = createCache("org.apache.ignite.examples.datagrid.hibernate.User.posts", TRANSACTIONAL); - IgniteCache c5 = createCache("org.apache.ignite.examples.datagrid.hibernate.Post", TRANSACTIONAL) - ) { - URL hibernateCfg = ExamplesUtils.url(HIBERNATE_CFG); - - SessionFactory sesFactory = createHibernateSessionFactory(hibernateCfg); - - System.out.println(); - System.out.println(">>> Creating objects."); - - final long userId; - - Session ses = sesFactory.openSession(); - - try { - Transaction tx = ses.beginTransaction(); - - User user = new User("jedi", "Luke", "Skywalker"); - - user.getPosts().add(new Post(user, "Let the Force be with you.")); - - ses.save(user); - - tx.commit(); - - // Create a user object, store it in DB, and save the database-generated - // object ID. You may try adding more objects in a similar way. - userId = user.getId(); - } - finally { - ses.close(); - } - - // Output L2 cache and Ignite cache stats. You may notice that - // at this point the object is not yet stored in L2 cache, because - // the read was not yet performed. - printStats(sesFactory); - - System.out.println(); - System.out.println(">>> Querying object by ID."); - - // Query user by ID several times. First time we get an L2 cache - // miss, and the data is queried from DB, but it is then stored - // in cache and successive queries hit the cache and return - // immediately, no SQL query is made. - for (int i = 0; i < 3; i++) { - ses = sesFactory.openSession(); - - try { - Transaction tx = ses.beginTransaction(); - - User user = (User)ses.get(User.class, userId); - - System.out.println("User: " + user); - - for (Post post : user.getPosts()) - System.out.println("\tPost: " + post); - - tx.commit(); - } - finally { - ses.close(); - } - } - - // Output the stats. We should see 1 miss and 2 hits for - // User and Collection object (stored separately in L2 cache). - // The Post is loaded with the collection, so it won't imply - // a miss. - printStats(sesFactory); - } - } - } - - /** - * Creates cache. - * - * @param name Cache name. - * @param atomicityMode Atomicity mode. - * @return Cache configuration. - */ - private static IgniteCache createCache(String name, CacheAtomicityMode atomicityMode) { - CacheConfiguration ccfg = new CacheConfiguration(name); - - ccfg.setAtomicityMode(atomicityMode); - ccfg.setWriteSynchronizationMode(FULL_SYNC); - - return Ignition.ignite().getOrCreateCache(ccfg); - } - - /** - * Creates a new Hibernate {@link SessionFactory} using a programmatic - * configuration. - * - * @param hibernateCfg Hibernate configuration file. - * @return New Hibernate {@link SessionFactory}. - */ - private static SessionFactory createHibernateSessionFactory(URL hibernateCfg) { - ServiceRegistryBuilder builder = new ServiceRegistryBuilder(); - - builder.applySetting("hibernate.connection.url", JDBC_URL); - builder.applySetting("hibernate.show_sql", true); - - return new Configuration() - .configure(hibernateCfg) - .buildSessionFactory(builder.buildServiceRegistry()); - } - - /** - * Prints Hibernate L2 cache statistics to standard output. - * - * @param sesFactory Hibernate {@link SessionFactory}, for which to print - * statistics. - */ - private static void printStats(SessionFactory sesFactory) { - System.out.println("=== Hibernate L2 cache statistics ==="); - - for (String entityName : ENTITY_NAMES) { - System.out.println("\tEntity: " + entityName); - - SecondLevelCacheStatistics stats = - sesFactory.getStatistics().getSecondLevelCacheStatistics(entityName); - - System.out.println("\t\tL2 cache entries: " + stats.getEntries()); - System.out.println("\t\tHits: " + stats.getHitCount()); - System.out.println("\t\tMisses: " + stats.getMissCount()); - } - - System.out.println("====================================="); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java ---------------------------------------------------------------------- diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java deleted file mode 100644 index 8e98835..0000000 --- a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java +++ /dev/null @@ -1,130 +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.datagrid.hibernate; - -import java.util.Date; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.ManyToOne; - -/** - * An entity class representing a post, that a - * {@link User} has made on some public service. - */ -@Entity -class Post { - /** ID. */ - @Id - @GeneratedValue(strategy=GenerationType.AUTO) - private long id; - - /** Author. */ - @ManyToOne - private User author; - - /** Text. */ - private String text; - - /** Created timestamp. */ - private Date created; - - /** - * Default constructor (required by Hibernate). - */ - Post() { - // No-op. - } - - /** - * Constructor. - * - * @param author Author. - * @param text Text. - */ - Post(User author, String text) { - this.author = author; - this.text = text; - created = new Date(); - } - - /** - * @return ID. - */ - public long getId() { - return id; - } - - /** - * @param id New ID. - */ - public void setId(long id) { - this.id = id; - } - - /** - * @return Author. - */ - public User getAuthor() { - return author; - } - - /** - * @param author New author. - */ - public void setAuthor(User author) { - this.author = author; - } - - /** - * @return Text. - */ - public String getText() { - return text; - } - - /** - * @param text New text. - */ - public void setText(String text) { - this.text = text; - } - - /** - * @return Created timestamp. - */ - public Date getCreated() { - return (Date)created.clone(); - } - - /** - * @param created New created timestamp. - */ - public void setCreated(Date created) { - this.created = (Date)created.clone(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return "Post [id=" + id + - ", text=" + text + - ", created=" + created + - ']'; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java ---------------------------------------------------------------------- diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java deleted file mode 100644 index d0486f5..0000000 --- a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java +++ /dev/null @@ -1,154 +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.datagrid.hibernate; - -import java.util.HashSet; -import java.util.Set; -import javax.persistence.CascadeType; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import org.hibernate.annotations.NaturalId; - -/** - * A user entity class. Represents a user of some public service, - * having a number of personal information fields as well as a - * number of posts written. - */ -@Entity -class User { - /** ID. */ - @Id - @GeneratedValue(strategy=GenerationType.AUTO) - private long id; - - /** Login. */ - @NaturalId - private String login; - - /** First name. */ - private String firstName; - - /** Last name. */ - private String lastName; - - /** Posts. */ - @OneToMany(mappedBy = "author", cascade = CascadeType.ALL) - private Set<Post> posts = new HashSet<>(); - - /** - * Default constructor (required by Hibernate). - */ - User() { - // No-op. - } - - /** - * Constructor. - * - * @param login Login. - * @param firstName First name. - * @param lastName Last name. - */ - User(String login, String firstName, String lastName) { - this.login = login; - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * @return ID. - */ - public long getId() { - return id; - } - - /** - * @param id New ID. - */ - public void setId(long id) { - this.id = id; - } - - /** - * @return Login. - */ - public String getLogin() { - return login; - } - - /** - * @param login New login. - */ - public void setLogin(String login) { - this.login = login; - } - - /** - * @return First name. - */ - public String getFirstName() { - return firstName; - } - - /** - * @param firstName New first name. - */ - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - /** - * @return Last name. - */ - public String getLastName() { - return lastName; - } - - /** - * @param lastName New last name. - */ - public void setLastName(String lastName) { - this.lastName = lastName; - } - - /** - * @return Posts. - */ - public Set<Post> getPosts() { - return posts; - } - - /** - * @param posts New posts. - */ - public void setPosts(Set<Post> posts) { - this.posts = posts; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return "User [id=" + id + - ", login=" + login + - ", firstName=" + firstName + - ", lastName=" + lastName + - ']'; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java ---------------------------------------------------------------------- diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java deleted file mode 100644 index 7bddaaf..0000000 --- a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/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. --> - * Hibernate example. - */ -package org.apache.ignite.examples.datagrid.hibernate; http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java ---------------------------------------------------------------------- diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java deleted file mode 100644 index d040b88..0000000 --- a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java +++ /dev/null @@ -1,122 +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.datagrid.store.hibernate; - -import java.util.List; -import java.util.UUID; -import javax.cache.integration.CacheLoaderException; -import javax.cache.integration.CacheWriterException; -import org.apache.ignite.cache.store.CacheStore; -import org.apache.ignite.cache.store.CacheStoreAdapter; -import org.apache.ignite.cache.store.CacheStoreSession; -import org.apache.ignite.examples.datagrid.store.Person; -import org.apache.ignite.lang.IgniteBiInClosure; -import org.apache.ignite.resources.CacheStoreSessionResource; -import org.hibernate.HibernateException; -import org.hibernate.Session; - -/** - * Example of {@link CacheStore} implementation that uses Hibernate - * and deals with maps {@link UUID} to {@link Person}. - */ -public class CacheHibernatePersonStore extends CacheStoreAdapter<Long, Person> { - /** Auto-injected store session. */ - @CacheStoreSessionResource - private CacheStoreSession ses; - - /** {@inheritDoc} */ - @Override public Person load(Long key) { - System.out.println(">>> Store load [key=" + key + ']'); - - Session hibSes = ses.attachment(); - - try { - return (Person)hibSes.get(Person.class, key); - } - catch (HibernateException e) { - throw new CacheLoaderException("Failed to load value from cache store [key=" + key + ']', e); - } - } - - /** {@inheritDoc} */ - @Override public void write(javax.cache.Cache.Entry<? extends Long, ? extends Person> entry) { - Long key = entry.getKey(); - Person val = entry.getValue(); - - System.out.println(">>> Store write [key=" + key + ", val=" + val + ']'); - - Session hibSes = ses.attachment(); - - try { - hibSes.saveOrUpdate(val); - } - catch (HibernateException e) { - throw new CacheWriterException("Failed to put value to cache store [key=" + key + ", val" + val + "]", e); - } - } - - /** {@inheritDoc} */ - @SuppressWarnings({"JpaQueryApiInspection"}) - @Override public void delete(Object key) { - System.out.println(">>> Store delete [key=" + key + ']'); - - Session hibSes = ses.attachment(); - - try { - hibSes.createQuery("delete " + Person.class.getSimpleName() + " where key = :key"). - setParameter("key", key). - executeUpdate(); - } - catch (HibernateException e) { - throw new CacheWriterException("Failed to remove value from cache store [key=" + key + ']', e); - } - } - - /** {@inheritDoc} */ - @Override public void loadCache(IgniteBiInClosure<Long, Person> clo, Object... args) { - if (args == null || args.length == 0 || args[0] == null) - throw new CacheLoaderException("Expected entry count parameter is not provided."); - - final int entryCnt = (Integer)args[0]; - - Session hibSes = ses.attachment(); - - try { - int cnt = 0; - - List list = hibSes.createCriteria(Person.class). - setMaxResults(entryCnt). - list(); - - if (list != null) { - for (Object obj : list) { - Person person = (Person)obj; - - clo.apply(person.getId(), person); - - cnt++; - } - } - - System.out.println(">>> Loaded " + cnt + " values into cache."); - } - catch (HibernateException e) { - throw new CacheLoaderException("Failed to load values from cache store.", e); - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java ---------------------------------------------------------------------- diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java deleted file mode 100644 index f993d81..0000000 --- a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java +++ /dev/null @@ -1,151 +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.datagrid.store.hibernate; - -import java.util.UUID; -import javax.cache.configuration.Factory; -import javax.cache.configuration.FactoryBuilder; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteException; -import org.apache.ignite.Ignition; -import org.apache.ignite.cache.store.CacheStoreSessionListener; -import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreSessionListener; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.examples.ExampleNodeStartup; -import org.apache.ignite.examples.ExamplesUtils; -import org.apache.ignite.examples.datagrid.store.Person; -import org.apache.ignite.transactions.Transaction; - -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; - -/** - * Demonstrates usage of cache with underlying persistent store configured. - * <p> - * This example uses {@link CacheHibernatePersonStore} as a persistent store. - * <p> - * Remote nodes can be started with {@link ExampleNodeStartup} in another JVM which will - * start node with {@code examples/config/example-ignite.xml} configuration. - */ -public class CacheHibernateStoreExample { - /** Hibernate configuration resource path. */ - private static final String HIBERNATE_CFG = - "/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml"; - - /** Cache name. */ - private static final String CACHE_NAME = CacheHibernateStoreExample.class.getSimpleName(); - - /** Heap size required to run this example. */ - public static final int MIN_MEMORY = 1024 * 1024 * 1024; - - /** Number of entries to load. */ - private static final int ENTRY_COUNT = 100_000; - - /** Global person ID to use across entire example. */ - private static final Long id = Math.abs(UUID.randomUUID().getLeastSignificantBits()); - - /** - * Executes example. - * - * @param args Command line arguments, none required. - * @throws IgniteException If example execution failed. - */ - public static void main(String[] args) throws IgniteException { - ExamplesUtils.checkMinMemory(MIN_MEMORY); - - // To start ignite with desired configuration uncomment the appropriate line. - try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) { - System.out.println(); - System.out.println(">>> Cache store example started."); - - CacheConfiguration<Long, Person> cacheCfg = new CacheConfiguration<>(CACHE_NAME); - - // Set atomicity as transaction, since we are showing transactions in example. - cacheCfg.setAtomicityMode(TRANSACTIONAL); - - // Configure Hibernate store. - cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(CacheHibernatePersonStore.class)); - - // Configure Hibernate session listener. - cacheCfg.setCacheStoreSessionListenerFactories(new Factory<CacheStoreSessionListener>() { - @Override public CacheStoreSessionListener create() { - CacheHibernateStoreSessionListener lsnr = new CacheHibernateStoreSessionListener(); - - lsnr.setHibernateConfigurationPath(HIBERNATE_CFG); - - return lsnr; - } - }); - - cacheCfg.setReadThrough(true); - cacheCfg.setWriteThrough(true); - - try (IgniteCache<Long, Person> cache = ignite.getOrCreateCache(cacheCfg)) { - // Make initial cache loading from persistent store. This is a - // distributed operation and will call CacheStore.loadCache(...) - // method on all nodes in topology. - loadCache(cache); - - // Start transaction and execute several cache operations with - // read/write-through to persistent store. - executeTransaction(cache); - } - } - } - - /** - * Makes initial cache loading. - * - * @param cache Cache to load. - */ - private static void loadCache(IgniteCache<Long, Person> cache) { - long start = System.currentTimeMillis(); - - // Start loading cache from persistent store on all caching nodes. - cache.loadCache(null, ENTRY_COUNT); - - long end = System.currentTimeMillis(); - - System.out.println(">>> Loaded " + cache.size() + " keys with backups in " + (end - start) + "ms."); - } - - /** - * Executes transaction with read/write-through to persistent store. - * - * @param cache Cache to execute transaction on. - */ - private static void executeTransaction(IgniteCache<Long, Person> cache) { - try (Transaction tx = Ignition.ignite().transactions().txStart()) { - Person val = cache.get(id); - - System.out.println("Read value: " + val); - - val = cache.getAndPut(id, new Person(id, "Isaac", "Newton")); - - System.out.println("Overwrote old value: " + val); - - val = cache.get(id); - - System.out.println("Read value: " + val); - - tx.commit(); - } - - System.out.println("Read value after commit: " + cache.get(id)); - } -}
