Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8852117C71 for ; Thu, 29 Oct 2015 11:52:56 +0000 (UTC) Received: (qmail 12118 invoked by uid 500); 29 Oct 2015 11:52:56 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 12042 invoked by uid 500); 29 Oct 2015 11:52:56 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 11260 invoked by uid 99); 29 Oct 2015 11:52:55 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Oct 2015 11:52:55 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8707CE3923; Thu, 29 Oct 2015 11:52:55 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.apache.org Date: Thu, 29 Oct 2015 11:53:05 -0000 Message-Id: <9a624a230d1f445383b41082d17a8e1f@git.apache.org> In-Reply-To: <9b91b6c127674318a13d534091545425@git.apache.org> References: <9b91b6c127674318a13d534091545425@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [11/50] ignite git commit: IGNITE-1653 http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/User.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/User.java b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/User.java new file mode 100644 index 0000000..d0486f5 --- /dev/null +++ b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/User.java @@ -0,0 +1,154 @@ +/* + * 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 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 getPosts() { + return posts; + } + + /** + * @param posts New posts. + */ + public void setPosts(Set 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/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/package-info.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/package-info.java b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/package-info.java new file mode 100644 index 0000000..7bddaaf --- /dev/null +++ b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + */ + +/** + * + * Hibernate example. + */ +package org.apache.ignite.examples.datagrid.hibernate; http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java new file mode 100644 index 0000000..d040b88 --- /dev/null +++ b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java @@ -0,0 +1,122 @@ +/* + * 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 { + /** 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 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 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/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java new file mode 100644 index 0000000..f993d81 --- /dev/null +++ b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java @@ -0,0 +1,151 @@ +/* + * 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. + *

+ * This example uses {@link CacheHibernatePersonStore} as a persistent store. + *

+ * 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 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() { + @Override public CacheStoreSessionListener create() { + CacheHibernateStoreSessionListener lsnr = new CacheHibernateStoreSessionListener(); + + lsnr.setHibernateConfigurationPath(HIBERNATE_CFG); + + return lsnr; + } + }); + + cacheCfg.setReadThrough(true); + cacheCfg.setWriteThrough(true); + + try (IgniteCache 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 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 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)); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml ---------------------------------------------------------------------- diff --git a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml new file mode 100644 index 0000000..035ab98 --- /dev/null +++ b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml ---------------------------------------------------------------------- diff --git a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml new file mode 100644 index 0000000..80a43e7 --- /dev/null +++ b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + jdbc:h2:mem:example;DB_CLOSE_DELAY=-1 + + + update + + + false + + + + + http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java new file mode 100644 index 0000000..7210b49 --- /dev/null +++ b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + */ + +/** + * + * Contains Hibernate-based cache store implementation. + */ +package org.apache.ignite.examples.datagrid.store.hibernate; http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples/src/main/java-lgpl/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java-lgpl/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java b/examples/src/main/java-lgpl/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java new file mode 100644 index 0000000..f8d0660 --- /dev/null +++ b/examples/src/main/java-lgpl/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java @@ -0,0 +1,82 @@ +/* + * 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.misc.schedule; + +import java.util.concurrent.Callable; +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.lang.IgniteRunnable; +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. + *

+ * Remote nodes should always be started with special configuration file which + * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}. + *

+ * 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( + new Callable() { + private int invocations; + + @Override public Integer call() { + invocations++; + + ignite.compute().broadcast( + new IgniteRunnable() { + @Override public void run() { + System.out.println(); + System.out.println("Howdy! :)"); + } + } + ); + + return invocations; + } + }, + "{5, 3} * * * * *" // Cron expression. + ); + + while (!fut.isDone()) + System.out.println(">>> Invocation #: " + 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/bd2cd923/examples/src/main/java-lgpl/org/apache/ignite/examples/misc/schedule/package-info.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java-lgpl/org/apache/ignite/examples/misc/schedule/package-info.java b/examples/src/main/java-lgpl/org/apache/ignite/examples/misc/schedule/package-info.java new file mode 100644 index 0000000..6602a6e --- /dev/null +++ b/examples/src/main/java-lgpl/org/apache/ignite/examples/misc/schedule/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + */ + +/** + * + * Demonstrates usage of cron-based scheduler. + */ +package org.apache.ignite.examples.misc.schedule; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples/src/test/java-lgpl/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java ---------------------------------------------------------------------- diff --git a/examples/src/test/java-lgpl/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java b/examples/src/test/java-lgpl/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java new file mode 100644 index 0000000..8a40d4a --- /dev/null +++ b/examples/src/test/java-lgpl/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples; + +import org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample; + +/** + * Multi-node test for {@link HibernateL2CacheExample}. + */ +public class HibernateL2CacheExampleMultiNodeSelfTest extends HibernateL2CacheExampleSelfTest { + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + for (int i = 0; i < RMT_NODES_CNT; i++) + startGrid("node-" + i, "examples/config/example-ignite.xml"); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples/src/test/java-lgpl/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java ---------------------------------------------------------------------- diff --git a/examples/src/test/java-lgpl/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java b/examples/src/test/java-lgpl/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java new file mode 100644 index 0000000..68767d7 --- /dev/null +++ b/examples/src/test/java-lgpl/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java @@ -0,0 +1,33 @@ +/* + * 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; + +import org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample; +import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; + +/** + * Tests the {@link HibernateL2CacheExample}. + */ +public class HibernateL2CacheExampleSelfTest extends GridAbstractExamplesTest { + /** + * @throws Exception If failed. + */ + public void testHibernateL2CacheExample() throws Exception { + HibernateL2CacheExample.main(EMPTY_ARGS); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/examples/src/test/java-lgpl/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java ---------------------------------------------------------------------- diff --git a/examples/src/test/java-lgpl/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java b/examples/src/test/java-lgpl/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java new file mode 100644 index 0000000..7c99712 --- /dev/null +++ b/examples/src/test/java-lgpl/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java @@ -0,0 +1,48 @@ +/* + * 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.testsuites; + +import junit.framework.TestSuite; +import org.apache.ignite.examples.HibernateL2CacheExampleMultiNodeSelfTest; +import org.apache.ignite.examples.HibernateL2CacheExampleSelfTest; +import org.apache.ignite.testframework.GridTestUtils; + +import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP; + +/** + * Examples test suite.

Contains only Spring ignite examples tests. + */ +public class IgniteLgplExamplesSelfTestSuite extends TestSuite { + /** + * @return Suite. + * @throws Exception If failed. + */ + public static TestSuite suite() throws Exception { + System.setProperty(IGNITE_OVERRIDE_MCAST_GRP, + GridTestUtils.getNextMulticastGroup(IgniteLgplExamplesSelfTestSuite.class)); + + TestSuite suite = new TestSuite("Ignite Examples Test Suite"); + + suite.addTest(new TestSuite(HibernateL2CacheExampleSelfTest.class)); + + // Multi-node. + suite.addTest(new TestSuite(HibernateL2CacheExampleMultiNodeSelfTest.class)); + + return suite; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2cd923/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 6eeb006..5f06555 100644 --- a/pom.xml +++ b/pom.xml @@ -153,63 +153,6 @@ modules/geospatial modules/schedule - - - - - maven-assembly-plugin - - - org.apache.apache.resources - apache-source-release-assembly-descriptor - 1.0.4 - - - - - release-lgpl - prepare-package - - single - - - - assembly/release-${ignite.edition}-lgpl.xml - - release-package - false - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.7 - false - - - release-postprocessing-lgpl - - run - - package - - - - - - - - - - - - - - @@ -533,13 +476,6 @@ - examples-lgpl - - examples-lgpl - - - - apache-release