From de91e82fe8e95b8d26cd7cd4645ede18fec29093 Mon Sep 17 00:00:00 2001 From: nikolay_tikhonov Date: Thu, 12 Feb 2015 17:18:04 +0300 Subject: [PATCH] #IGNITE-50 Fixed review notes. --- .../configuration/IgniteConfiguration.java | 2 +- .../cache/GridCacheDeploymentManager.java | 17 +++++------- ...niteCacheAbstractExecutionContextTest.java | 22 ++++++++++++---- .../tests/p2p/CacheDeploymentTestValue.java | 2 +- .../ignite/tests/p2p/CacheTestValue.java | 26 ------------------- 5 files changed, 25 insertions(+), 44 deletions(-) delete mode 100644 modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheTestValue.java diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java index 33c044884cb1a..95e0a0fe6cd0d 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java @@ -464,6 +464,7 @@ public IgniteConfiguration(IgniteConfiguration cfg) { cacheCfg = cfg.getCacheConfiguration(); cacheSanityCheckEnabled = cfg.isCacheSanityCheckEnabled(); connectorCfg = cfg.getConnectorConfiguration(); + classLdr = cfg.getClassLoader(); clockSyncFreq = cfg.getClockSyncFrequency(); clockSyncSamples = cfg.getClockSyncSamples(); deployMode = cfg.getDeploymentMode(); @@ -520,7 +521,6 @@ public IgniteConfiguration(IgniteConfiguration cfg) { userAttrs = cfg.getUserAttributes(); waitForSegOnStart = cfg.isWaitForSegmentOnStart(); warmupClos = cfg.getWarmupClosure(); - classLdr = cfg.getClassLoader(); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java index 982832898af5e..12cd679cd2220 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java @@ -82,7 +82,7 @@ public class GridCacheDeploymentManager extends GridCacheSharedManagerAdap /** {@inheritDoc} */ @Override public void start0() throws IgniteCheckedException { - globalLdr = getCacheClassLoader(); + globalLdr = new CacheClassLoader(cctx.gridConfig().getClassLoader()); nodeFilter = new P1() { @Override public boolean apply(ClusterNode node) { @@ -124,14 +124,6 @@ public class GridCacheDeploymentManager extends GridCacheSharedManagerAdap } } - /** - * @return If user's class loader is null then will be used default class loader. - */ - private CacheClassLoader getCacheClassLoader() { - return cctx.gridConfig().getClassLoader() == null ? new CacheClassLoader() - : new CacheClassLoader(cctx.gridConfig().getClassLoader()); - } - /** {@inheritDoc} */ @Override protected void stop0(boolean cancel) { if (discoLsnr != null) @@ -773,10 +765,13 @@ private CacheClassLoader() { } /** - * Sets context class loader as user's class loader. + * Sets context class loader. + * If user's class loader is null then will be used default class loader. + * + * @param classLdr User's class loader. */ private CacheClassLoader(ClassLoader classLdr) { - super(classLdr); + super(classLdr != null ? classLdr : U.detectClassLoader(GridCacheDeploymentManager.class)); p2pExclude = cctx.gridConfig().getPeerClassLoadingLocalClassPathExclude(); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java index 141dd50fa4e11..7575c7a6de441 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java @@ -30,7 +30,10 @@ */ public abstract class IgniteCacheAbstractExecutionContextTest extends IgniteCacheAbstractTest { /** */ - public static final String TEST_VALUE = "org.apache.ignite.tests.p2p.CacheTestValue"; + public static final String TEST_VALUE = "org.apache.ignite.tests.p2p.CacheDeploymentTestValue"; + + /** */ + public static final int ITER_CNT = 1000; /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { @@ -41,9 +44,18 @@ public abstract class IgniteCacheAbstractExecutionContextTest extends IgniteCach return cfg; } + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { + CacheConfiguration cacheConfiguration = super.cacheConfiguration(gridName); + + cacheConfiguration.setBackups(1); + + return cacheConfiguration; + } + /** {@inheritDoc} */ @Override protected int gridCount() { - return 3; + return 2; } /** @@ -56,11 +68,11 @@ public void testUsersClassLoader() throws Exception { IgniteCache jcache = grid(0).jcache(null); - for (int i = 0; i < 1000; i++) + for (int i = 0; i < ITER_CNT; i++) jcache.put(i, val); - for (int i = 0; i < 1000; i++) { - int idx = i % 3; + for (int i = 0; i < ITER_CNT; i++) { + int idx = i % gridCount(); if (idx == 0) assertEquals(jcache.get(i).getClass().getClassLoader(), testClassLdr); diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestValue.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestValue.java index 8cffa8953bc0c..e020525319b3c 100644 --- a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestValue.java +++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestValue.java @@ -20,7 +20,7 @@ import java.io.*; /** - * Value object for {@code GridCacheDeploymentSelfTest}. + * Value object for {@code GridCacheDeploymentSelfTest}, {@code IgniteCacheAbstractExecutionContextTest}. */ public class CacheDeploymentTestValue implements Serializable { // No-op. diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheTestValue.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheTestValue.java deleted file mode 100644 index 827cccd8e040c..0000000000000 --- a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheTestValue.java +++ /dev/null @@ -1,26 +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.tests.p2p; - -import java.io.Serializable; - -/** - * Value object for {@code IgniteCacheAbstractExecutionContextTest}. - */ -public class CacheTestValue implements Serializable { -}