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 68D8D1880E for ; Thu, 3 Dec 2015 06:51:46 +0000 (UTC) Received: (qmail 93882 invoked by uid 500); 3 Dec 2015 06:51:46 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 93845 invoked by uid 500); 3 Dec 2015 06:51:46 -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 93833 invoked by uid 99); 3 Dec 2015 06:51:46 -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, 03 Dec 2015 06:51:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E9E17E0A1F; Thu, 3 Dec 2015 06:51:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Message-Id: <46b14b6e84f24e0e812ed05eb2c3405b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ignite git commit: ignite-2008 Added test reproducing issue. Date: Thu, 3 Dec 2015 06:51:45 +0000 (UTC) Repository: ignite Updated Branches: refs/heads/ignite-1.5 bd99d1ea7 -> e7298adca ignite-2008 Added test reproducing issue. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e7298adc Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e7298adc Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e7298adc Branch: refs/heads/ignite-1.5 Commit: e7298adca37176956ffd93f1f01e32bef6626c12 Parents: bd99d1e Author: sboikov Authored: Thu Dec 3 09:51:37 2015 +0300 Committer: sboikov Committed: Thu Dec 3 09:51:37 2015 +0300 ---------------------------------------------------------------------- .../CacheLockReleaseNodeLeaveTest.java | 110 +++++++++++++++++++ 1 file changed, 110 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/e7298adc/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLockReleaseNodeLeaveTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLockReleaseNodeLeaveTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLockReleaseNodeLeaveTest.java new file mode 100644 index 0000000..956aaef --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLockReleaseNodeLeaveTest.java @@ -0,0 +1,110 @@ +/* + * 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.internal.processors.cache.distributed; + +import java.util.concurrent.Callable; +import java.util.concurrent.locks.Lock; +import org.apache.ignite.Ignite; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; + +/** + * + */ +public class CacheLockReleaseNodeLeaveTest extends GridCommonAbstractTest { + /** */ + private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); + + CacheConfiguration ccfg = new CacheConfiguration(); + + ccfg.setAtomicityMode(TRANSACTIONAL); + + cfg.setCacheConfiguration(ccfg); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + super.afterTest(); + } + + /** + * @throws Exception If failed. + */ + public void testLockRelease() throws Exception { + startGrids(2); + + final Ignite ignite0 = ignite(0); + final Ignite ignite1 = ignite(1); + + final Integer key = primaryKey(ignite1.cache(null)); + + IgniteInternalFuture fut1 = GridTestUtils.runAsync(new Callable() { + @Override public Void call() throws Exception { + Lock lock = ignite0.cache(null).lock(key); + + lock.lock(); + + return null; + } + }, "lock-thread1"); + + fut1.get(); + + IgniteInternalFuture fut2 = GridTestUtils.runAsync(new Callable() { + @Override public Void call() throws Exception { + Lock lock = ignite1.cache(null).lock(key); + + log.info("Start lock."); + + lock.lock(); + + log.info("Locked."); + + return null; + } + }, "lock-thread2"); + + U.sleep(1000); + + log.info("Stop node."); + + ignite0.close(); + + fut2.get(5, SECONDS); + } +}