Skip to content
Permalink
Browse files
IGNITE-16908 Move ignite-hibernate modules to the Ignite Extension (#137
)
  • Loading branch information
Mmuzaf committed May 6, 2022
1 parent a5e1f3f commit 12cc59de9c3848c0fa2b9b88face558f3cf10ca7
Showing 88 changed files with 12,904 additions and 0 deletions.
@@ -0,0 +1,34 @@
# Apache Ignite Examples

This module contains examples of how to run [Apache Ignite](ignite.apache.org) and [Apache Ignite](ignite.apache.org) with 3rd party components.

Instructions on how to start examples can be found in [README.txt](README.txt).

## Running examples on JDK 9/10/11

Ignite uses proprietary SDK APIs that are not available by default. See also [How to run Ignite on JDK 9,10 and 11](https://ignite.apache.org/docs/latest/setup#running-ignite-with-java-11-or-later)

To set up local IDE to easier access to examples, it is possible to add following options as default for all applications

``--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED
--add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED
--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED
--add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED
--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
--illegal-access=permit``

For example, for IntelliJ IDEA it is possible to use Application Templates.

Use 'Run' -> 'Edit Configuration' menu.

<img src="https://docs.google.com/drawings/d/e/2PACX-1vQFgjhrPsLPUmic8CA_s1YpjVwA2vQITxNsLrAKOecZxIQEZSb1Ps2XKh0QEn8z9vtYiUofnGek_cag/pub?w=960&h=720"/>

## Contributing to Examples

*Notice* When updating classpath of examples and in case any modifications required in [pom.xml](pom.xml)
please make sure that corresponding changes were applied to
* [pom-standalone.xml](pom-standalone.xml),
* [pom-standalone-lgpl.xml](pom-standalone-lgpl.xml).

These pom files are finalized during release and placed to the `examples` folder with these examples code.
@@ -0,0 +1,27 @@
Apache Ignite Examples
======================

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.


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.


LGPL
=====
It is required some lgpl-based libs, for example: ignite-hibernate or ignite-schedule.
In case these libs can not be found by this maven project please download Apache Ignite sources
at https://ignite.apache.org/download.cgi#sources.

There is a way to gain required libs from sources:

Run "./mvnw clean install -DskipTests " at Apache Ignite sources.
This case will install lgpl-based libs to local maven repository.

Required libs will also appear at /target/release-package/libs/optional sub-folders.
Found libs should be copied to global or project's classpath.
@@ -0,0 +1,76 @@
<?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 abstract="true" 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"/>

<!-- 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>
@@ -0,0 +1,31 @@
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- Imports default Ignite configuration -->
<import resource="example-default.xml"/>

<bean parent="ignite.cfg"/>
</beans>
@@ -0,0 +1,8 @@
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.
@@ -0,0 +1,64 @@
<?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>
@@ -0,0 +1,25 @@
#
# 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.
#

ScalarCacheAffinityExample1=examples/config/example-ignite.xml
ScalarCacheAffinityExample2=examples/config/example-ignite.xml
ScalarCacheAffinitySimpleExample=examples/config/example-ignite.xml
ScalarCacheExample=examples/config/example-ignite.xml
ScalarCacheQueryExample=examples/config/example-ignite.xml
ScalarCountGraphTrianglesExample=examples/config/example-ignite.xml
ScalarPopularNumbersRealTimeExample=examples/config/example-ignite.xml
DataRegionEexample=examples/config/example-data-regions.xml
@@ -0,0 +1,97 @@
<?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 log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN"
"http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
<!--
Log4j configuration.
-->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<!--
Logs System.out messages to console.
-->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<!-- Log to STDOUT. -->
<param name="Target" value="System.out"/>

<!-- Log from DEBUG and higher. -->
<param name="Threshold" value="DEBUG"/>

<!-- The default pattern: Date Priority [Category] Message\n -->
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"/>
</layout>

<!-- Do not log beyond INFO level. -->
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="levelMin" value="DEBUG"/>
<param name="levelMax" value="INFO"/>
</filter>
</appender>

<!--
Logs all System.err messages to console.
-->
<appender name="CONSOLE_ERR" class="org.apache.log4j.ConsoleAppender">
<!-- Log to STDERR. -->
<param name="Target" value="System.err"/>

<!-- Log from WARN and higher. -->
<param name="Threshold" value="WARN"/>

<!-- The default pattern: Date Priority [Category] Message\n -->
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"/>
</layout>
</appender>

<!--
Logs all output to specified file.
-->
<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
<param name="Threshold" value="DEBUG"/>
<param name="File" value="${IGNITE_HOME}/work/log/ignite.log"/>
<param name="Append" value="true"/>
<param name="MaxFileSize" value="10MB"/>
<param name="MaxBackupIndex" value="10"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"/>
</layout>
</appender>

<!-- Disable all open source debugging. -->
<category name="org">
<level value="INFO"/>
</category>

<category name="org.eclipse.jetty">
<level value="INFO"/>
</category>

<!-- Default settings. -->
<root>
<!-- Print at info by default. -->
<level value="INFO"/>

<!-- Append to file and console. -->
<appender-ref ref="FILE"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="CONSOLE_ERR"/>
</root>
</log4j:configuration>
@@ -0,0 +1,19 @@
#
# 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.
#

# Local address to bind to.
local.ip=127.0.0.1

0 comments on commit 12cc59d

Please sign in to comment.