From 493909e1aed77133a3747ed0d2d5d7a297650f22 Mon Sep 17 00:00:00 2001 From: Nikolay Izhikov Date: Sat, 7 Mar 2026 18:10:21 +0300 Subject: [PATCH 1/8] WIP --- docs/_docs/code-snippets/java/pom.xml | 5 - modules/bom/pom.xml | 5 - .../apache/ignite/IgniteSystemProperties.java | 12 - .../apache/ignite/internal/IgnitionEx.java | 25 - modules/spring/pom.xml | 6 - .../p2p/GridP2PUserVersionChangeSelfTest.java | 377 ----- .../testsuites/IgniteSpringTestSuite.java | 2 - modules/urideploy/README.txt | 33 - modules/urideploy/licenses/apache-2.0.txt | 202 --- modules/urideploy/pom.xml | 164 -- .../uri/GridUriDeploymentClassLoader.java | 185 --- .../GridUriDeploymentClassLoaderFactory.java | 95 -- .../uri/GridUriDeploymentDiscovery.java | 121 -- .../uri/GridUriDeploymentFileProcessor.java | 458 ------ .../GridUriDeploymentFileProcessorResult.java | 113 -- .../GridUriDeploymentFileResourceLoader.java | 86 - .../uri/GridUriDeploymentJarVerifier.java | 399 ----- .../uri/GridUriDeploymentSpringDocument.java | 100 -- .../uri/GridUriDeploymentSpringParser.java | 79 - .../uri/GridUriDeploymentUnitDescriptor.java | 279 ---- .../uri/GridUriDeploymentUriParser.java | 180 --- .../spi/deployment/uri/UriDeploymentSpi.java | 1408 ----------------- .../deployment/uri/UriDeploymentSpiMBean.java | 52 - .../spi/deployment/uri/package-info.java | 23 - .../scanners/GridDeploymentFileHandler.java | 32 - .../GridDeploymentFolderScannerHelper.java | 55 - .../GridUriDeploymentScannerListener.java | 54 - .../uri/scanners/UriDeploymentScanner.java | 47 - .../scanners/UriDeploymentScannerContext.java | 92 -- .../scanners/UriDeploymentScannerManager.java | 226 --- .../file/UriDeploymentFileScanner.java | 337 ---- .../uri/scanners/file/package-info.java | 23 - .../http/UriDeploymentHttpScanner.java | 507 ------ .../uri/scanners/http/package-info.java | 23 - .../deployment/uri/scanners/package-info.java | 23 - ...GridTaskUriDeploymentDeadlockSelfTest.java | 105 -- ...UriDeploymentAbsentProcessorClassTest.java | 117 -- .../ignite/p2p/GridP2PDisabledSelfTest.java | 218 --- .../GridUriDeploymentAbstractSelfTest.java | 106 -- ...ymentClassLoaderMultiThreadedSelfTest.java | 75 - .../GridUriDeploymentClassLoaderSelfTest.java | 79 - ...DeploymentClassloaderRegisterSelfTest.java | 159 -- .../uri/GridUriDeploymentConfigSelfTest.java | 76 - ...ridUriDeploymentFileProcessorSelfTest.java | 167 -- .../GridUriDeploymentMd5CheckSelfTest.java | 209 --- ...ymentMultiScannersErrorThrottlingTest.java | 54 - ...ridUriDeploymentMultiScannersSelfTest.java | 57 - .../uri/GridUriDeploymentSimpleSelfTest.java | 197 --- .../deployment/uri/META-INF/ignite.brokenxml | 18 - .../spi/deployment/uri/META-INF/ignite.empty | 0 .../deployment/uri/META-INF/ignite.incorrefs | 18 - .../spi/deployment/uri/META-INF/ignite.xml | 38 - .../spi/deployment/uri/package-info.java | 23 - .../file/GridFileDeploymentSelfTest.java | 206 --- .../GridFileDeploymentUndeploySelfTest.java | 113 -- .../uri/scanners/file/package-info.java | 23 - .../http/GridHttpDeploymentSelfTest.java | 239 --- .../uri/scanners/http/package-info.java | 23 - .../testsuites/IgniteToolsSelfTestSuite.java | 32 - .../IgniteUriDeploymentTestSuite.java | 71 - .../ignite/tools/GridToolsSelfTest.java | 395 ----- .../ignite/tools/gartask/META-INF/ignite.xml | 38 - .../org/apache/ignite/tools/package-info.java | 23 - pom.xml | 1 - 64 files changed, 8708 deletions(-) delete mode 100644 modules/spring/src/test/java/org/apache/ignite/p2p/GridP2PUserVersionChangeSelfTest.java delete mode 100644 modules/urideploy/README.txt delete mode 100644 modules/urideploy/licenses/apache-2.0.txt delete mode 100644 modules/urideploy/pom.xml delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoader.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderFactory.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentDiscovery.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessor.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessorResult.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileResourceLoader.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentJarVerifier.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSpringDocument.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSpringParser.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentUnitDescriptor.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentUriParser.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpiMBean.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/package-info.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/GridDeploymentFileHandler.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/GridDeploymentFolderScannerHelper.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/GridUriDeploymentScannerListener.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/UriDeploymentScanner.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/UriDeploymentScannerContext.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/UriDeploymentScannerManager.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/file/UriDeploymentFileScanner.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/file/package-info.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/UriDeploymentHttpScanner.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/package-info.java delete mode 100644 modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/package-info.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/internal/GridTaskUriDeploymentDeadlockSelfTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/internal/UriDeploymentAbsentProcessorClassTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/p2p/GridP2PDisabledSelfTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentAbstractSelfTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderMultiThreadedSelfTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderSelfTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassloaderRegisterSelfTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentConfigSelfTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessorSelfTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMd5CheckSelfTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersErrorThrottlingTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersSelfTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSimpleSelfTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.brokenxml delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.empty delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.incorrefs delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.xml delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/package-info.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentSelfTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentUndeploySelfTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/package-info.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/package-info.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteToolsSelfTestSuite.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteUriDeploymentTestSuite.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/tools/GridToolsSelfTest.java delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/tools/gartask/META-INF/ignite.xml delete mode 100644 modules/urideploy/src/test/java/org/apache/ignite/tools/package-info.java diff --git a/docs/_docs/code-snippets/java/pom.xml b/docs/_docs/code-snippets/java/pom.xml index 66b95b0878140..77a2e41d3c062 100644 --- a/docs/_docs/code-snippets/java/pom.xml +++ b/docs/_docs/code-snippets/java/pom.xml @@ -57,11 +57,6 @@ ignite-spring ${ignite.version} - - ${project.groupId} - ignite-urideploy - ${ignite.version} - ${project.groupId} ignite-zookeeper diff --git a/modules/bom/pom.xml b/modules/bom/pom.xml index 25f8124d03fc0..08b2ad73a9235 100644 --- a/modules/bom/pom.xml +++ b/modules/bom/pom.xml @@ -146,11 +146,6 @@ ignite-tools ${revision} - - ${project.groupId} - ignite-urideploy - ${revision} - ${project.groupId} ignite-yardstick diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java index bbb9d38537073..ed01c9662bd4b 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java @@ -29,7 +29,6 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.CheckpointWriteOrder; import org.apache.ignite.configuration.DataStorageConfiguration; -import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.configuration.DiskPageCompression; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.cache.query.index.sorted.inline.InlineRecommender; @@ -369,17 +368,6 @@ public final class IgniteSystemProperties extends IgniteCommonsSystemProperties "overrides the settings set via IgniteConfiguration", type = String.class) public static final String IGNITE_LOCAL_HOST = "IGNITE_LOCAL_HOST"; - /** - * System property to override deployment mode configuration parameter. - * Valid values for property are: PRIVATE, ISOLATED, SHARED or CONTINUOUS. - * - * @see org.apache.ignite.configuration.DeploymentMode - * @see org.apache.ignite.configuration.IgniteConfiguration#getDeploymentMode() - */ - @SystemProperty(value = "Sets deployment mode configuration parameter. Valid " + - "values for property are: PRIVATE, ISOLATED, SHARED or CONTINUOUS", type = DeploymentMode.class) - public static final String IGNITE_DEP_MODE_OVERRIDE = "IGNITE_DEPLOYMENT_MODE_OVERRIDE"; - /** * Property controlling size of buffer holding completed transaction versions. Such buffer * is used to detect duplicate transaction and has a default value of {@code 102400}. In diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java index 7f4529a6a1951..b77187f2d7611 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java @@ -62,7 +62,6 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; -import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.configuration.ExecutorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; @@ -128,7 +127,6 @@ import static org.apache.ignite.IgniteState.STOPPED_ON_SEGMENTATION; import static org.apache.ignite.IgniteSystemProperties.IGNITE_CACHE_CLIENT; import static org.apache.ignite.IgniteSystemProperties.IGNITE_CONFIG_URL; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_DEP_MODE_OVERRIDE; import static org.apache.ignite.IgniteSystemProperties.IGNITE_LOCAL_HOST; import static org.apache.ignite.IgniteSystemProperties.IGNITE_NO_SHUTDOWN_HOOK; import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_CONSISTENT_ID; @@ -1879,29 +1877,6 @@ private IgniteConfiguration initializeConfiguration(IgniteConfiguration cfg) myCfg.setClientMode(threadClient); } - // Check for deployment mode override. - String depModeName = IgniteSystemProperties.getString(IGNITE_DEP_MODE_OVERRIDE); - - if (!F.isEmpty(depModeName)) { - if (!F.isEmpty(myCfg.getCacheConfiguration())) { - U.quietAndInfo(log, "Skipping deployment mode override for caches (custom closure " + - "execution may not work for console Visor)"); - } - else { - try { - DeploymentMode depMode = DeploymentMode.valueOf(depModeName); - - if (myCfg.getDeploymentMode() != depMode) - myCfg.setDeploymentMode(depMode); - } - catch (IllegalArgumentException e) { - throw new IgniteCheckedException("Failed to override deployment mode using system property " + - "(are there any misspellings?)" + - "[name=" + IGNITE_DEP_MODE_OVERRIDE + ", value=" + depModeName + ']', e); - } - } - } - if (myCfg.getUserAttributes() == null) myCfg.setUserAttributes(Collections.emptyMap()); diff --git a/modules/spring/pom.xml b/modules/spring/pom.xml index a8c11444928ec..f1c164d1e5c86 100644 --- a/modules/spring/pom.xml +++ b/modules/spring/pom.xml @@ -52,12 +52,6 @@ 1.1.1 - - ${project.groupId} - ignite-urideploy - test - - ${project.groupId} ignite-log4j2 diff --git a/modules/spring/src/test/java/org/apache/ignite/p2p/GridP2PUserVersionChangeSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/p2p/GridP2PUserVersionChangeSelfTest.java deleted file mode 100644 index 2b09ee17e4288..0000000000000 --- a/modules/spring/src/test/java/org/apache/ignite/p2p/GridP2PUserVersionChangeSelfTest.java +++ /dev/null @@ -1,377 +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.p2p; - -import java.net.URL; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import java.util.concurrent.CountDownLatch; -import javax.cache.Cache; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.DeploymentMode; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.events.DeploymentEvent; -import org.apache.ignite.events.Event; -import org.apache.ignite.events.EventType; -import org.apache.ignite.internal.util.typedef.PAX; -import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.testframework.GridTestExternalClassLoader; -import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.config.GridTestProperties; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Ignore; -import org.junit.Test; - -import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static org.apache.ignite.events.EventType.EVT_NODE_FAILED; -import static org.apache.ignite.events.EventType.EVT_NODE_LEFT; -import static org.apache.ignite.events.EventType.EVT_TASK_UNDEPLOYED; - -/** - * The test does the following: - * - * 1. The test should execute a task in SHARED_DEPLOY mode, restart a node with new version and make sure that a - * new class loader is created on remote node. - * 2. The test should execute a task in SHARED_DEPLOY mode, restart a node with same version and make sure - * that the same class loader is created on remote node. - * 3. The test should execute a task in SHARED_UNDEPLOY mode, restart a node with same version and - * make sure that a new class loader is created on remote node. - */ -@SuppressWarnings({"ProhibitedExceptionDeclared", "unchecked"}) -public class GridP2PUserVersionChangeSelfTest extends GridCommonAbstractTest { - /** Current deployment mode. */ - private DeploymentMode depMode; - - /** Test task class name. */ - private static final String TEST_TASK_NAME = "org.apache.ignite.tests.p2p.P2PTestTaskExternalPath1"; - - /** Test resource class name. */ - private static final String TEST_RCRS_NAME = "org.apache.ignite.tests.p2p.TestUserResource"; - - /** */ - public GridP2PUserVersionChangeSelfTest() { - super(/*start grid*/false); - } - - /** {@inheritDoc} */ - @Override protected long getTestTimeout() { - return 30 * 1000; - } - - /** - * @return Timeout for condition waits. - */ - private long getConditionTimeout() { - return getTestTimeout() > 10000 ? getTestTimeout() - 10000 : getTestTimeout(); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - cfg.setDeploymentMode(depMode); - cfg.setNetworkTimeout(10000); - - if (igniteInstanceName.contains("testCacheRedeployVersionChangeContinuousMode")) { - CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - - cacheCfg.setCacheMode(CacheMode.REPLICATED); - - cfg.setCacheConfiguration(cacheCfg); - } - else - cfg.setCacheConfiguration(); - - cfg.setIncludeEventTypes(EventType.EVTS_ALL); - - return cfg; - } - - /** - * @throws Exception If test failed. - */ - @Test - public void testRedeployVersionChangeContinuousMode() throws Exception { - depMode = DeploymentMode.CONTINUOUS; - - checkRedeployVersionChange(); - } - - /** - * @throws Exception If test failed. - */ - @Test - public void testRedeployVersionChangeSharedMode() throws Exception { - depMode = DeploymentMode.SHARED; - - checkRedeployVersionChange(); - } - - /** - * @throws Exception If failed. - */ - private void checkRedeployVersionChange() throws Exception { - try { - Ignite ignite1 = startGrid(1); - Ignite ignite2 = startGrid(2); - - GridTestExternalClassLoader ldr = new GridTestExternalClassLoader( - new URL[] { new URL(GridTestProperties.getProperty("p2p.uri.cls")) }, - Collections.singletonMap("META-INF/ignite.xml", makeUserVersion("1").getBytes())); - - Class task1 = ldr.loadClass(TEST_TASK_NAME); - - final CountDownLatch undeployed = new CountDownLatch(1); - - ignite2.events().localListen(new IgnitePredicate() { - @Override public boolean apply(Event evt) { - if (evt.type() == EVT_TASK_UNDEPLOYED && - ((DeploymentEvent)evt).alias().equals(TEST_TASK_NAME)) - undeployed.countDown(); - - return true; - } - }, EVT_TASK_UNDEPLOYED); - - Integer res1 = (Integer)ignite1.compute().execute(task1, ignite2.cluster().localNode().id()); - - stopGrid(1); - - ldr.setResourceMap(Collections.singletonMap("META-INF/ignite.xml", makeUserVersion("2").getBytes())); - - ignite1 = startGrid(1); - - Integer res2 = (Integer)ignite1.compute().execute(task1, ignite2.cluster().localNode().id()); - - assert !res1.equals(res2); - - // Allow P2P timeout to expire. - assert undeployed.await(30000, MILLISECONDS); - } - finally { - stopGrid(1); - stopGrid(2); - } - } - - /** - * @throws Exception If failed. - */ - @Test - public void testRedeployOnNodeRestartContinuousMode() throws Exception { - depMode = DeploymentMode.CONTINUOUS; - - try { - Ignite ignite1 = startGrid(1); - Ignite ignite2 = startGrid(2); - - GridTestExternalClassLoader ldr = new GridTestExternalClassLoader( - new URL[] { new URL(GridTestProperties.getProperty("p2p.uri.cls")) }); - - Class task1 = ldr.loadClass(TEST_TASK_NAME); - - final CountDownLatch undeployed = new CountDownLatch(1); - - ignite2.events().localListen(new IgnitePredicate() { - @Override public boolean apply(Event evt) { - if (evt.type() == EVT_TASK_UNDEPLOYED && - ((DeploymentEvent)evt).alias().equals(TEST_TASK_NAME)) - undeployed.countDown(); - - return true; - } - }, EVT_TASK_UNDEPLOYED); - - Integer res1 = (Integer)ignite1.compute().execute(task1, ignite2.cluster().localNode().id()); - - stopGrid(1); - - ignite1 = startGrid(1); - - Integer res2 = (Integer)ignite1.compute().execute(task1, ignite2.cluster().localNode().id()); - - assert !undeployed.await(3000, MILLISECONDS); - - assert res1.equals(res2); - } - finally { - stopGrid(1); - stopGrid(2); - } - } - - /** - * @throws Exception If failed. - */ - @Test - public void testRedeployOnNodeRestartSharedMode() throws Exception { - depMode = DeploymentMode.SHARED; - - try { - Ignite ignite1 = startGrid(1); - Ignite ignite2 = startGrid(2); - - GridTestExternalClassLoader ldr = new GridTestExternalClassLoader( - new URL[] { new URL(GridTestProperties.getProperty("p2p.uri.cls")) }); - - Class task1 = ldr.loadClass(TEST_TASK_NAME); - - final CountDownLatch undeployed = new CountDownLatch(1); - - ignite2.events().localListen(new IgnitePredicate() { - @Override public boolean apply(Event evt) { - if (evt.type() == EVT_TASK_UNDEPLOYED && - ((DeploymentEvent)evt).alias().equals(TEST_TASK_NAME)) - undeployed.countDown(); - - return true; - } - }, EVT_TASK_UNDEPLOYED); - - final CountDownLatch discoLatch = new CountDownLatch(1); - - ignite2.events().localListen(new IgnitePredicate() { - @Override public boolean apply(Event evt) { - if (evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED) - discoLatch.countDown(); - - return true; - } - }, EVT_NODE_LEFT, EVT_NODE_FAILED); - - Integer res1 = (Integer)ignite1.compute().execute(task1, ignite2.cluster().localNode().id()); - - stopGrid(1); - - assert discoLatch.await(1000, MILLISECONDS); - - assert undeployed.await(1000, MILLISECONDS); - - ignite1 = startGrid(1); - - Integer res2 = (Integer)ignite1.compute().execute(task1, ignite2.cluster().localNode().id()); - - assert !res1.equals(res2); - } - finally { - stopGrid(1); - stopGrid(2); - } - } - - /** - * @throws Exception If failed. - */ - @Ignore("https://issues.apache.org/jira/browse/IGNITE-604") - @Test - public void testCacheRedeployVersionChangeContinuousMode() throws Exception { - depMode = DeploymentMode.CONTINUOUS; - - try { - Ignite ignite1 = startGrid("testCacheRedeployVersionChangeContinuousMode1"); - Ignite ignite2 = startGrid("testCacheRedeployVersionChangeContinuousMode2"); - - GridTestExternalClassLoader ldr = new GridTestExternalClassLoader( - new URL[] { new URL(GridTestProperties.getProperty("p2p.uri.cls")) }, - Collections.singletonMap("META-INF/ignite.xml", makeUserVersion("1").getBytes())); - - Class rcrsCls = ldr.loadClass(TEST_RCRS_NAME); - - IgniteCache cache1 = ignite1.cache(DEFAULT_CACHE_NAME); - - assertNotNull(cache1); - - cache1.put(1L, rcrsCls.newInstance()); - - final IgniteCache cache2 = ignite2.cache(DEFAULT_CACHE_NAME); - - assertNotNull(cache2); - - // The entry should propagate to grid2, because the - // cache is REPLICATED. This happens asynchronously, we - // need to use condition wait. - assert GridTestUtils.waitForCondition(new PAX() { - @Override public boolean applyx() { - return cache2.get(1L) != null; - } - }, getConditionTimeout()); - - stopGrid("testCacheRedeployVersionChangeContinuousMode1"); - - // Increase the user version of the test class. - ldr.setResourceMap(Collections.singletonMap("META-INF/ignite.xml", makeUserVersion("2").getBytes())); - - ignite1 = startGrid("testCacheRedeployVersionChangeContinuousMode1"); - - cache1 = ignite1.cache(DEFAULT_CACHE_NAME); - - assertNotNull(cache1); - - // Put an entry with a new user version. - cache1.put(2L, rcrsCls.newInstance()); - - // At this point, old version of test resource should be undeployed - // and removed from cache asynchronously. - assert GridTestUtils.waitForCondition(new PAX() { - @Override public boolean applyx() { - return cache2.get(1L) == null; - } - }, getConditionTimeout()) : "2nd condition failed [entries1=" + toSet(cache1.iterator()) + - ", entries2=" + toSet(cache2.iterator()) + ']'; - } - finally { - stopAllGrids(); - } - } - - /** - * - */ - private Set> toSet(Iterator> iter) { - Set> set = new HashSet<>(); - - while (iter.hasNext()) - set.add(iter.next()); - - return set; - } - - /** - * Creates content of META-INF/ignite.xml for specified user version. - * - * @param userVer Version to create. - * @return content of META-INF/ignite.xml. - */ - private String makeUserVersion(String userVer) { - return " " + - " " + - " " + - ""; - } -} diff --git a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java index c012cc43542ea..050cdde2d5bc9 100644 --- a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java +++ b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java @@ -35,7 +35,6 @@ import org.apache.ignite.internal.metric.RegexpMetricFilterTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtMultiBackupTest; import org.apache.ignite.internal.processors.resource.GridTransformSpringInjectionSelfTest; -import org.apache.ignite.p2p.GridP2PUserVersionChangeSelfTest; import org.apache.ignite.spring.IgniteExcludeInConfigurationTest; import org.apache.ignite.spring.IgniteStartFromStreamConfigurationTest; import org.apache.ignite.spring.injection.GridServiceInjectionSpringResourceTest; @@ -59,7 +58,6 @@ IgniteExcludeInConfigurationTest.class, // Tests moved to this suite since they require Spring functionality. - GridP2PUserVersionChangeSelfTest.class, IgniteDynamicCacheConfigTest.class, diff --git a/modules/urideploy/README.txt b/modules/urideploy/README.txt deleted file mode 100644 index dc3defdf7fbdc..0000000000000 --- a/modules/urideploy/README.txt +++ /dev/null @@ -1,33 +0,0 @@ -Apache Ignite URI Deploy Module -------------------------------- - -Apache Ignite URI Deploy module provides capabilities to deploy tasks from different sources like -File System, HTTP, or even Email. - -To enable URI Deploy module when starting a standalone node, move 'optional/ignite-urideploy' folder to -'libs' folder before running 'ignite.{sh|bat}' script. The content of the module folder will -be added to classpath in this case. - -Importing URI Deploy Module In Maven Project --------------------------------------------- - -If you are using Maven to manage dependencies of your project, you can add URI Deploy module -dependency like this (replace '${ignite.version}' with actual Ignite version you are -interested in): - - - ... - - ... - - org.apache.ignite - ignite-urideploy - ${ignite.version} - - ... - - ... - diff --git a/modules/urideploy/licenses/apache-2.0.txt b/modules/urideploy/licenses/apache-2.0.txt deleted file mode 100644 index d645695673349..0000000000000 --- a/modules/urideploy/licenses/apache-2.0.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. diff --git a/modules/urideploy/pom.xml b/modules/urideploy/pom.xml deleted file mode 100644 index 8927c9d5b4b1a..0000000000000 --- a/modules/urideploy/pom.xml +++ /dev/null @@ -1,164 +0,0 @@ - - - - - - - 4.0.0 - - - org.apache.ignite - ignite-parent-internal - ${revision} - ../../parent-internal/pom.xml - - - ignite-urideploy - - http://ignite.apache.org - - - - ${project.groupId} - ignite-core - - - - org.springframework - spring-aop - ${spring.version} - - - - org.springframework - spring-beans - ${spring.version} - - - - org.springframework - spring-context - ${spring.version} - - - - org.springframework - spring-core - ${spring.version} - - - - org.springframework - spring-expression - ${spring.version} - - - - org.springframework - spring-tx - ${spring.version} - - - - com.github.jtidy - jtidy - ${jtidy.version} - - - - commons-codec - commons-codec - ${commons.codec.version} - - - - org.apache.tomcat - tomcat-servlet-api - ${tomcat.version} - test - - - - ${project.groupId} - ignite-core - test-jar - test - - - - ${project.groupId} - ignite-tools - test - - - - org.eclipse.jetty - jetty-io - ${jetty.version} - test - - - - org.eclipse.jetty - jetty-http - ${jetty.version} - test - - - - org.eclipse.jetty - jetty-server - ${jetty.version} - test - - - - org.eclipse.jetty - jetty-util - ${jetty.version} - test - - - - com.google.guava - guava - test - - - - org.apache.logging.log4j - log4j-core - test - - - - - - - org.apache.maven.plugins - maven-deploy-plugin - 2.8.2 - - false - - - - - diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoader.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoader.java deleted file mode 100644 index 075f1d64dec10..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoader.java +++ /dev/null @@ -1,185 +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.spi.deployment.uri; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.Arrays; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.jetbrains.annotations.Nullable; - -/** - * Loads classes and resources from "unpacked" deployment archives. - *

- * Class loader scans package directory first and then if - * class/resource was not found scans all JAR files. - */ -class GridUriDeploymentClassLoader extends URLClassLoader { - /** - * Creates new instance of class loader. - * - * @param urls The URLs from which to load classes and resources. - * @param parent The parent class loader for delegation. - */ - GridUriDeploymentClassLoader(URL[] urls, ClassLoader parent) { - super(urls, parent); - } - - /** {@inheritDoc} */ - @Override protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { - // First, check if the class has already been loaded. - Class cls = findLoadedClass(name); - - if (cls == null) { - try { - try { - // Search classes in a deployment unit. - // NOTE: findClass(String) is not overridden since it is always called after - // findLoadedClass(String) in exclusive synchronization block. - cls = findClass(name); - } - catch (ClassNotFoundException ignored) { - // If still not found, then invoke parent class loader in order - // to find the class. - cls = super.loadClass(name, resolve); - } - } - catch (ClassNotFoundException e) { - throw e; - } - // Catch Throwable to secure against any errors resulted from - // corrupted class definitions or other user errors. - catch (Exception e) { - throw new ClassNotFoundException("Failed to load class due to unexpected error: " + name, e); - } - } - - return cls; - } - - /** - * Load class from a deployment unit. - * - * @param name Class name. - * @return Loaded class. - * @throws ClassNotFoundException If no class found. - */ - public synchronized Class loadClassIsolated(String name) throws ClassNotFoundException { - // First, check if the class has already been loaded. - Class cls = findLoadedClass(name); - - if (cls == null) { - try { - // Search classes in deployment unit. - // NOTE: findClass(String) is not overridden since it is always called after - // findLoadedClass(String) in exclusive synchronization block. - cls = findClass(name); - } - catch (ClassNotFoundException e) { - throw e; - } - // Catch Throwable to secure against any errors resulted from - // corrupted class definitions or other user errors. - catch (Exception e) { - throw new ClassNotFoundException("Failed to load class due to unexpected error: " + name, e); - } - } - - return cls; - } - - /** - * Load class from GAR file. - * - * @param name Class name. - * @return Loaded class. - * @throws ClassNotFoundException If no class found. - * @deprecated Use {@link GridUriDeploymentClassLoader#loadClassIsolated(String)} instead. - */ - @Deprecated - public synchronized Class loadClassGarOnly(String name) throws ClassNotFoundException { - return loadClassIsolated(name); - } - - /** {@inheritDoc} */ - @Override public URL getResource(String name) { - URL url = findResource(name); - - if (url == null) - url = ClassLoader.getSystemResource(name); - - if (url == null) - url = super.getResource(name); - - return url; - } - - /** {@inheritDoc} */ - @Override public InputStream getResourceAsStream(String name) { - // Find resource in a deployment unit first. - InputStream in = getResourceAsStreamIsolated(name); - - // Find resource in parent class loader. - if (in == null) - in = ClassLoader.getSystemResourceAsStream(name); - - if (in == null) - in = super.getResourceAsStream(name); - - return in; - } - - /** - * Returns an input stream for reading the specified resource from a deployment unit only. - * - * @param name Resource name. - * @return An input stream for reading the resource, or {@code null} - * if the resource could not be found. - */ - @Nullable public InputStream getResourceAsStreamIsolated(String name) { - URL url = findResource(name); - - try { - return url != null ? url.openStream() : null; - } - catch (IOException ignored) { - return null; - } - } - - /** - * Returns an input stream for reading the specified resource from GAR file only. - * - * @param name Resource name. - * @return An input stream for reading the resource, or {@code null} - * if the resource could not be found. - * - * @deprecated Use {@link GridUriDeploymentClassLoader#getResourceAsStreamIsolated(String)} instead. - */ - @Deprecated - @Nullable public InputStream getResourceAsStreamGarOnly(String name) { - return getResourceAsStreamIsolated(name); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridUriDeploymentClassLoader.class, this, "urls", Arrays.toString(getURLs())); - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderFactory.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderFactory.java deleted file mode 100644 index 2cb21441c1ce2..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderFactory.java +++ /dev/null @@ -1,95 +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.spi.deployment.uri; - -import java.io.File; -import java.io.FilenameFilter; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import org.apache.ignite.IgniteLogger; -import org.apache.ignite.spi.IgniteSpiException; - -/** - * Factory class to create class loader that loads classes and resources from - * the deployment archive or "unpacked" deployment archive (package directory). - *

- * Class loader scans deployment archive or directory first and than if - * class/resource was not found scans all JAR files. - * It is assumed that all libraries are in the {@link #DFLT_LIBS_DIR_PATH} - * directory. - */ -class GridUriDeploymentClassLoaderFactory { - /** Libraries directory default value (value is {@code lib}). */ - public static final String DFLT_LIBS_DIR_PATH = "lib"; - - /** - * @param parent Parent class loader. - * @param file Deployment archive or directory with an unpacked deployment archive. - * @param log Logger. - * @return Class Loader. - * @throws org.apache.ignite.spi.IgniteSpiException In case of any error. - */ - public static ClassLoader create(ClassLoader parent, File file, IgniteLogger log) throws IgniteSpiException { - assert parent != null; - assert file != null; - assert log != null; - - assert file.isDirectory(); - - List urls = new ArrayList<>(); - - try { - String url = file.toURI().toURL().toString(); - - URL mainUrl = url.length() > 0 && url.charAt(url.length() - 1) == '/' ? - file.toURI().toURL() : new URL(url + '/'); - - urls.add(mainUrl); - - File libDir = new File(file, DFLT_LIBS_DIR_PATH); - - if (libDir.exists()) { - File[] files = libDir.listFiles(new FilenameFilter() { - @Override public boolean accept(File dir, String name) { - return name.endsWith(".jar"); - } - }); - - if (files.length > 0) { - for (File jarFile : files) { - urls.add(jarFile.toURI().toURL()); - } - } - } - - return new GridUriDeploymentClassLoader(urls.toArray(new URL[urls.size()]), parent); - } - catch (MalformedURLException e) { - throw new IgniteSpiException("Failed to create class loader for a package: " + file, e); - } - } - - /** - * Ensure singleton. - */ - private GridUriDeploymentClassLoaderFactory() { - // No-op. - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentDiscovery.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentDiscovery.java deleted file mode 100644 index d47ec68563883..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentDiscovery.java +++ /dev/null @@ -1,121 +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.spi.deployment.uri; - -import java.io.File; -import java.io.IOException; -import java.util.HashSet; -import java.util.Set; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import org.apache.ignite.compute.ComputeTask; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.IgniteSpiException; - -/** - * Helper that loads classes either from directory or from JAR file. - *

- * If loading from directory is used, helper scans given directory - * and all subdirectories recursively and loads all files - * with ".class" extension by given class loader. If class could not - * be loaded it will be ignored. - *

- * If JAR file loading is used helper scans JAR file and tries to - * load all {@link JarEntry} assuming it's a file name. - * If at least one of them could not be loaded helper fails. - */ -final class GridUriDeploymentDiscovery { - /** - * Enforces singleton. - */ - private GridUriDeploymentDiscovery() { - // No-op. - } - - /** - * Load classes from given file. File could be either directory or JAR file. - * - * @param clsLdr Class loader to load files. - * @param file Either directory or JAR file which contains classes or - * references to them. - * @return Set of found and loaded classes or empty set if file does not - * exist. - * @throws org.apache.ignite.spi.IgniteSpiException Thrown if given JAR file references to none - * existed class or IOException occurred during processing. - */ - static Set>> getClasses(ClassLoader clsLdr, File file) - throws IgniteSpiException { - Set>> rsrcs = new HashSet<>(); - - if (!file.exists()) - return rsrcs; - - GridUriDeploymentFileResourceLoader fileRsrcLdr = new GridUriDeploymentFileResourceLoader(clsLdr, file); - - if (file.isDirectory()) - findResourcesInDirectory(fileRsrcLdr, file, rsrcs); - else { - try { - for (JarEntry entry : U.asIterable(new JarFile(file.getAbsolutePath()).entries())) { - Class> rsrc = fileRsrcLdr.createResource(entry.getName(), false); - - if (rsrc != null) - rsrcs.add(rsrc); - } - } - catch (IOException e) { - throw new IgniteSpiException("Failed to discover classes in file: " + file.getAbsolutePath(), e); - } - } - - return rsrcs; - } - - /** - * Recursively scans given directory and load all found files by loader. - * - * @param clsLdr Loader that could load class from given file. - * @param dir Directory which should be scanned. - * @param rsrcs Set which will be filled in. - */ - private static void findResourcesInDirectory(GridUriDeploymentFileResourceLoader clsLdr, File dir, - Set>> rsrcs) { - assert dir.isDirectory(); - - for (File file : dir.listFiles()) { - if (file.isDirectory()) { - // Recurse down into directories. - findResourcesInDirectory(clsLdr, file, rsrcs); - } - else { - Class> rsrc = null; - - try { - rsrc = clsLdr.createResource(file.getAbsolutePath(), true); - } - catch (IgniteSpiException e) { - // Must never happen because we use 'ignoreUnknownRsrc=true'. - assert false; - } - - if (rsrc != null) - rsrcs.add(rsrc); - } - } - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessor.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessor.java deleted file mode 100644 index a564503e62309..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessor.java +++ /dev/null @@ -1,458 +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.spi.deployment.uri; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Modifier; -import java.net.URL; -import java.net.URLClassLoader; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import org.apache.commons.codec.binary.Hex; -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.ignite.IgniteException; -import org.apache.ignite.IgniteLogger; -import org.apache.ignite.compute.ComputeTask; -import org.apache.ignite.internal.util.IgniteUtils; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.IgniteSpiException; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.spi.deployment.uri.UriDeploymentSpi.XML_DESCRIPTOR_PATH; - -/** - * Utility class. - *

- * Provides useful and common functions for URI deployment. - */ -final class GridUriDeploymentFileProcessor { - /** - * Enforces singleton. - */ - private GridUriDeploymentFileProcessor() { - // No-op. - } - - /** - * Method processes given package and extracts all tasks from it which are - * either mentioned in a task descriptor or implement interface {@link org.apache.ignite.compute.ComputeTask} - * if there is no descriptor in file. - * - * @param file Package file with tasks. - * @param uri URI of the package. - * @param deployDir deployment directory with downloaded files. - * @param log Logger. - * @throws org.apache.ignite.spi.IgniteSpiException Thrown if file could not be read. - * @return List of tasks from given file. - */ - @Nullable static GridUriDeploymentFileProcessorResult processFile(File file, String uri, File deployDir, - IgniteLogger log) throws IgniteSpiException { - File pkg = file; - - if (!checkIntegrity(file, log)) { - U.error(log, "Failed to load tasks from a package (invalid file signature) [uri=" + - U.hidePassword(uri) + ']'); - - return null; - } - - if (!file.isDirectory()) { - pkg = new File(deployDir, "dirzip_" + file.getName()); - - pkg.mkdirs(); - - try { - U.unzip(file, pkg, log); - } - catch (IOException e) { - throw new IgniteSpiException("IO error when unzipping a package: " - + file.getAbsolutePath(), e); - } - } - - GridUriDeploymentFileProcessorResult res = null; - - if (pkg.isDirectory()) { - try { - File xml = new File(pkg, XML_DESCRIPTOR_PATH); - - if (!xml.exists() || xml.isDirectory()) { - U.warn(log, - "Processing deployment without descriptor file (it will cause full classpath scan) [path=" - + XML_DESCRIPTOR_PATH + ", package=" + pkg.getAbsolutePath() + ']'); - - res = processNoDescriptorFile(pkg, uri, log); - } - else { - InputStream in = null; - - try { - in = new BufferedInputStream(new FileInputStream(xml)); - - // Parse XML task definitions and add them to cache. - GridUriDeploymentSpringDocument doc = GridUriDeploymentSpringParser.parseTasksDocument(in, log); - - assert doc != null; - - res = processWithDescriptorFile(doc, pkg, uri, log); - } - finally { - U.close(in, log); - } - } - } - catch (IOException e) { - throw new IgniteSpiException("IO error when parsing a package: " - + pkg.getAbsolutePath(), e); - } - } - - if (res != null) - res.setMd5(md5(pkg, log)); - - return res; - } - - /** - * Calculates md5 checksum for the given file o directory. - * For directories tries to walk all nested files accumulating the result. - * - * @param file file to calculate sum or root directory for accumulating calculation. - * @param log logger to log all failures. - * @return string representation of the calculated checksum or {@code null} if calculation failed. - */ - @Nullable public static String md5(@Nullable File file, @Nullable IgniteLogger log) { - if (file != null) - return file.isFile() ? fileMd5(file, log) : directoryMd5(file, log); - - return null; - } - - /** - * Calculates md5 checksum for the given file - * - * @param file file to calculate md5. - * @param log logger to log all failures. - * @return string representation of the calculated checksum or {@code null} if calculation failed. - */ - @Nullable public static String fileMd5(@Nullable File file, @Nullable IgniteLogger log) { - String md5 = null; - - if (file != null) { - if (!file.isFile()) { - U.warn(log, "Failed to find file for md5 calculation: " + file); - - return null; - } - - InputStream in = null; - - try { - in = new BufferedInputStream(new FileInputStream(file)); - - md5 = DigestUtils.md5Hex(in); - } - catch (IOException e) { - U.warn(log, "Failed to open input stream for md5 calculation: " + e.getMessage()); - } - finally { - U.closeQuiet(in); - } - } - - return md5; - } - - /** - * For directories tries to walk all nested files accumulating them into single md5 checksum. - * - * @param dir directory to calculate md5. - * @param log logger to log all failures. - * @return string representation of the calculated checksum or {@code null} if calculation failed. - */ - @Nullable public static String directoryMd5(@Nullable File dir, @Nullable IgniteLogger log) { - if (dir != null) { - if (!dir.isDirectory()) { - U.warn(log, "Failed to find directory for md5 calculation: " + dir); - - return null; - } - - try { - MessageDigest digest = MessageDigest.getInstance("MD5"); - - return addDirectoryDigest(dir, digest, log) ? Hex.encodeHexString(digest.digest()) : null; - } - catch (NoSuchAlgorithmException e) { - throw new IgniteException("MD5 digest algorithm not found.", e); - } - } - - return null; - } - - /** - * Repulsively adds all files in the given directory to the given Digest object. - * - * @param file directory to start calculation from. - * @param digest digest object where all available files should be applied. - * @param log logger to report errors. - * @return {@code true} if digest was added successfully, {@code false} otherwise. - */ - private static boolean addDirectoryDigest(File file, MessageDigest digest, @Nullable IgniteLogger log) { - assert file.isDirectory(); - - File[] files = file.listFiles(); - - if (files == null) - return true; - - Arrays.sort(files); - - for (File visited : files) { - if (visited.isFile()) { - if (!addFileDigest(visited, digest, log)) - return false; - } - else if (visited.isDirectory()) { - if (!addDirectoryDigest(visited, digest, log)) - return false; - } - } - - return true; - } - - /** - * Adds given file to the given Digest object. - * - * @param file file for digest calculations. - * @param digest digest object to add file. - * @param log logger to report errors. - * @return {@code true} if digest was added successfully, {@code false} otherwise. - */ - private static boolean addFileDigest(File file, MessageDigest digest, @Nullable IgniteLogger log) { - if (!file.isFile()) { - U.error(log, "Failed to add file to directory digest (will not check MD5 hash): " + file); - - return false; - } - - InputStream in = null; - - try { - in = new BufferedInputStream(new FileInputStream(file)); - - byte[] buf = new byte[1024]; - - int read = in.read(buf, 0, 1024); - - while (read > -1) { - digest.update(buf, 0, read); - - read = in.read(buf, 0, 1024); - } - } - catch (IOException e) { - U.error(log, "Failed to add file to directory digest (will not check MD5 hash): " + file, e); - - return false; - } - finally { - U.closeQuiet(in); - } - - return true; - } - - /** - * Cleanup class loaders resource. - * - * @param clsLdr Released class loader. - * @param log Logger. - */ - static void cleanupUnit(ClassLoader clsLdr, IgniteLogger log) { - assert clsLdr != null; - assert log != null; - assert clsLdr instanceof URLClassLoader; - - URLClassLoader clsLdr0 = (URLClassLoader)clsLdr; - - U.close(clsLdr0, log); - - try { - URL url = IgniteUtils.classLoaderUrls(clsLdr)[0]; - - File dir = new File(url.toURI()); - - U.delete(dir); - - if (dir.getName().startsWith("dirzip_")) { - File jarFile = new File(dir.getParentFile(), dir.getName().substring(7)); - - U.delete(jarFile); - } - } - catch (Exception e) { - U.error(log, "Failed to cleanup unit [clsLdr=" + clsLdr + ']', e); - } - } - - /** - * Processes given package and returns back all tasks which are in its descriptor. - * - * @param doc Package descriptor. - * @param file Package file. - * @param uri URI of the package file. - * @param log Logger. - * @throws org.apache.ignite.spi.IgniteSpiException Thrown if it's impossible to open file. - * @return List of tasks from descriptor. - */ - private static GridUriDeploymentFileProcessorResult processWithDescriptorFile(GridUriDeploymentSpringDocument doc, - File file, String uri, IgniteLogger log) throws IgniteSpiException { - ClassLoader clsLdr = GridUriDeploymentClassLoaderFactory.create(U.gridClassLoader(), file, log); - - List>> tasks = doc.getTasks(clsLdr); - - List>> validTasks = null; - - if (!F.isEmpty(tasks)) { - validTasks = new ArrayList<>(); - - for (Class> task : tasks) { - if (!isAllowedTaskClass(task)) { - U.warn(log, "Failed to load task. Task should be public none-abstract class " + - "(might be inner static one) that implements ComputeTask interface [taskCls=" + task + ']'); - } - else { - if (log.isDebugEnabled()) - log.debug("Found grid deployment task: " + task.getName()); - - validTasks.add(task); - } - } - } - - GridUriDeploymentFileProcessorResult res = new GridUriDeploymentFileProcessorResult(); - - res.setFile(file); - res.setClassLoader(clsLdr); - - if (!F.isEmpty(validTasks)) - res.setTaskClasses(validTasks); - else if (log.isDebugEnabled()) - log.debug("No tasks loaded from file [file=" + file.getAbsolutePath() + - ", uri=" + U.hidePassword(uri) + ']'); - - return res; - } - - /** - * Processes packages which have no descriptor. It scans every class and - * checks if it is a valid task or not. All valid tasks are returned back. - * - * @param file Package file or directory. - * @param uri URI of the package file. - * @param log Logger. - * @throws org.apache.ignite.spi.IgniteSpiException Thrown if file reading error happened. - * @return List of tasks from given file. - */ - private static GridUriDeploymentFileProcessorResult processNoDescriptorFile(File file, String uri, IgniteLogger log) - throws IgniteSpiException { - ClassLoader clsLdr = GridUriDeploymentClassLoaderFactory.create(U.gridClassLoader(), file, log); - - Set>> clss = GridUriDeploymentDiscovery.getClasses(clsLdr, file); - - GridUriDeploymentFileProcessorResult res = new GridUriDeploymentFileProcessorResult(); - - res.setFile(file); - res.setClassLoader(clsLdr); - - if (clss != null) { - List>> validTasks = - new ArrayList<>(clss.size()); - - for (Class> cls : clss) { - if (isAllowedTaskClass(cls)) { - if (log.isDebugEnabled()) - log.debug("Found grid deployment task: " + cls.getName()); - - validTasks.add(cls); - } - } - - if (!validTasks.isEmpty()) - res.setTaskClasses(validTasks); - else if (log.isDebugEnabled()) - log.debug("No tasks loaded from file [file=" + file.getAbsolutePath() + - ", uri=" + U.hidePassword(uri) + ']'); - } - - return res; - } - - /** - * Check that class may be instantiated as {@link org.apache.ignite.compute.ComputeTask} and used - * in deployment. - * - * Loaded task class must implement interface {@link org.apache.ignite.compute.ComputeTask}. - * Only non-abstract, non-interfaces and public classes allowed. - * Inner static classes also allowed for loading. - * - * @param cls Class to check - * @return {@code true} if class allowed for deployment. - */ - private static boolean isAllowedTaskClass(Class cls) { - if (!ComputeTask.class.isAssignableFrom(cls)) - return false; - - int modifiers = cls.getModifiers(); - - return !Modifier.isAbstract(modifiers) && !Modifier.isInterface(modifiers) && - (!cls.isMemberClass() || Modifier.isStatic(modifiers)) && Modifier.isPublic(modifiers); - } - - /** - * Make integrity check for a package. - * Method returns {@code false} if the package has incorrect signature. - * - * @param file package which should be verified. - * @param log Logger. - * @return {@code true} if given file is a directory of verification - * completed successfully otherwise returns {@code false}. - */ - private static boolean checkIntegrity(File file, IgniteLogger log) { - try { - return file.isDirectory() || GridUriDeploymentJarVerifier.verify(file.getAbsolutePath(), false, log); - } - catch (IOException e) { - U.error(log, "Error while making integrity file check.", e); - } - - return false; - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessorResult.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessorResult.java deleted file mode 100644 index 65ba349802205..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessorResult.java +++ /dev/null @@ -1,113 +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.spi.deployment.uri; - -import java.io.File; -import java.util.List; -import org.apache.ignite.compute.ComputeTask; -import org.apache.ignite.internal.util.typedef.internal.S; - -/** - * Deployment file processing result. - */ -class GridUriDeploymentFileProcessorResult { - /** Class loader. */ - private ClassLoader clsLdr; - - /** Task class. */ - private List>> taskClss; - - /** Deploument unit file. */ - private File file; - - /** Hash of deployment unit. */ - private String md5; - - /** - * Getter for property 'clsLdr'. - * - * @return Value for property 'clsLdr'. - */ - public ClassLoader getClassLoader() { - return clsLdr; - } - - /** - * Setter for property 'clsLdr'. - * - * @param clsLdr Value to set for property 'clsLdr'. - */ - public void setClassLoader(ClassLoader clsLdr) { - this.clsLdr = clsLdr; - } - - /** - * Getter for property 'taskClss'. - * - * @return Value for property 'taskClss'. - */ - public List>> getTaskClasses() { - return taskClss; - } - - /** - * Setter for property 'taskClss'. - * - * @param taskClss Value to set for property 'taskClss'. - */ - public void setTaskClasses(List>> taskClss) { - this.taskClss = taskClss; - } - - /** - * Gets package file. - * - * @return Package file. - */ - public File getFile() { - return file; - } - - /** - * Sets package file. - * - * @param file Package file. - */ - public void setFile(File file) { - this.file = file; - } - - /** - * @return md5 hash of this deployment result. - */ - public String getMd5() { - return md5; - } - - /** - * @param md5 md5 hash of this deployment result. - */ - public void setMd5(String md5) { - this.md5 = md5; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridUriDeploymentFileProcessorResult.class, this); - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileResourceLoader.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileResourceLoader.java deleted file mode 100644 index 72ad91f1b757c..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileResourceLoader.java +++ /dev/null @@ -1,86 +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.spi.deployment.uri; - -import java.io.File; -import org.apache.ignite.compute.ComputeTask; -import org.apache.ignite.spi.IgniteSpiException; - -/** - * Class loader helper that could load class from the file using certain - * class loader. - */ -class GridUriDeploymentFileResourceLoader { - /** Class loader class should be loaded by. */ - private final ClassLoader clsLdr; - - /** Initial directory. */ - private final File scanPathDir; - - /** - * Creates new instance of loader helper. - * - * @param clsLdr Class loader class should be loaded by. - * @param scanPathDir Initial directory. - */ - GridUriDeploymentFileResourceLoader(ClassLoader clsLdr, File scanPathDir) { - this.clsLdr = clsLdr; - this.scanPathDir = scanPathDir; - } - - /** - * Creates new class from file with given file name. - * - * @param fileName Name of the class to be loaded. It might be either - * fully-qualified or just a class name. - * @param ignoreUnknownRsrc Whether unresolved classes should be - * ignored or not. - * @return Loaded class. - * @throws org.apache.ignite.spi.IgniteSpiException If class could not be loaded and - * {@code ignoreUnknownRsrc} parameter is {@code true}. - */ - @SuppressWarnings("unchecked") - Class> createResource(String fileName, boolean ignoreUnknownRsrc) throws IgniteSpiException { - if (scanPathDir.isDirectory()) - fileName = fileName.substring(scanPathDir.getAbsolutePath().length() + 1); - - if (fileName.endsWith(".class")) { - String str = fileName; - - // Replace separators. - str = str.replaceAll("\\/|\\\\", "."); - - // Strip off '.class' extension. - str = str.substring(0, str.indexOf(".class")); - - try { - return (Class>)clsLdr.loadClass(str); - } - catch (ClassNotFoundException e) { - if (ignoreUnknownRsrc) { - // No-op. - } - else - throw new IgniteSpiException("Failed to load class: " + str, e); - } - } - - // Not a class resource. - return null; - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentJarVerifier.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentJarVerifier.java deleted file mode 100644 index 2006f38e2a1ea..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentJarVerifier.java +++ /dev/null @@ -1,399 +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.spi.deployment.uri; - -import java.io.IOException; -import java.io.InputStream; -import java.security.CodeSigner; -import java.security.PublicKey; -import java.security.cert.Certificate; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.jar.JarInputStream; -import java.util.jar.Manifest; -import org.apache.ignite.IgniteLogger; -import org.apache.ignite.internal.util.typedef.internal.U; - -/** - * Helper class that verifies either JAR file or JAR file input stream - * if it is consistent or not. Consistency means that file was not changed - * since build and all files mentioned in manifest are signed. - */ -final class GridUriDeploymentJarVerifier { - /** - * Enforces singleton. - */ - private GridUriDeploymentJarVerifier() { - // No-op. - } - - /** Default buffer size = 4K. */ - private static final int BUF_SIZE = 4096; - - /** - * Verify JAR-file that it was not changed since creation. - * If parameter {@code allSigned} equals {@code true} and file is not - * listed in manifest than method return {@code false}. If file listed - * in manifest but doesn't exist in JAR-file than method return - * {@code false}. - * - * @param jarName JAR file name. - * @param allSigned If {@code true} then all files must be signed. - * @param log Logger. - * @return {@code true} if JAR file was not changed. - * @throws IOException Thrown if JAR file or its entries could not be read. - */ - static boolean verify(String jarName, boolean allSigned, IgniteLogger log) throws IOException { - assert jarName != null; - - return verify0(jarName, null, allSigned, log); - } - - /** - * Verify JAR-file that all files declared in manifest are signed. - * If manifest is {@code null} than method returns {@code true} if - * public key is {@code null}. - * If parameter {@code allSigned} equals {@code true} and file not - * listed in manifest than method return {@code false}. If file - * listed in manifest but doesn't exist in JAR-file than method - * return {@code false}. - * - * @param jarName JAR file name. - * @param pubKey Public key. - * @param allSigned If {@code true} then all files must be signed. - * @param log Logger. - * @return {@code true} if JAR file is signed with given public key. - * @throws IOException Thrown if JAR file or its entries could not be read. - */ - static boolean verify(String jarName, PublicKey pubKey, boolean allSigned, IgniteLogger log) - throws IOException { - assert jarName != null; - assert pubKey != null; - - return verify0(jarName, pubKey, allSigned, log); - } - - /** - * Tests whether given JAR file input stream was not changed since creation. - * - * @param in JAR file input stream. - * @param allSigned Hint which means that all files of all entries must be - * signed. - * @param log Logger. - * @return {@code true} if JAR file input stream was not changed. - * @throws IOException Thrown if JAR file stream or its entries could not - * be read. - */ - static boolean verify(InputStream in, boolean allSigned, IgniteLogger log) throws IOException { - assert in != null; - - return verify0(in, null, allSigned, log); - } - - /** - * Tests whether given JAR file input stream is signed with public key. - * If manifest is {@code null} than method returns {@code true} if - * public key is {@code null}. - * If parameter {@code allSigned} equals {@code true} and file not - * listed in manifest than method return {@code false}. If file - * listed in manifest but doesn't exist in JAR-file than method - * return {@code false}. - * - * @param in JAR file input stream. - * @param pubKey Public key to be tested with. - * @param allSigned Hint which means that all files in entry must be signed. - * @param log Logger. - * @return {@code true} if JAR file is signed with given public key. - * @throws IOException Thrown if JAR file or its entries could not be read. - */ - static boolean verify(InputStream in, PublicKey pubKey, boolean allSigned, IgniteLogger log) - throws IOException { - assert in != null; - assert pubKey != null; - - return verify0(in, pubKey, allSigned, log); - } - - /** - * Tests whether all files in given JAR file input stream are signed - * with public key. If manifest is {@code null} than method returns - * {@code true} if public key is null. - * - * @param in JAR file input stream. - * @param pubKey Public key to be tested with. - * @param allSigned Hint which means that all files in entry must be signed. - * @param log Logger. - * @return {@code true} if JAR file is signed with given public key. - * @throws IOException Thrown if JAR file or its entries could not be read. - */ - private static boolean verify0(InputStream in, PublicKey pubKey, boolean allSigned, IgniteLogger log) - throws IOException { - assert in != null; - - JarInputStream jin = null; - - try { - jin = new JarInputStream(in, true); - - Manifest manifest = jin.getManifest(); - - // Manifest must be included into a signed package. - if (manifest == null) - return pubKey == null; - - Set manifestFiles = getSignedFiles(manifest); - - JarEntry jarEntry; - - while ((jarEntry = jin.getNextJarEntry()) != null) { - if (jarEntry.isDirectory()) - continue; - - // Verify by reading the file if altered. - // Will return quietly if no problem. - verifyDigestsImplicitly(jin); - - if (!verifyEntry(jarEntry, manifest, pubKey, allSigned, true)) - return false; - - manifestFiles.remove(jarEntry.getName()); - } - - return manifestFiles.size() <= 0; - } - catch (SecurityException e) { - if (log.isDebugEnabled()) - log.debug("Got security error (ignoring): " + e.getMessage()); - } - finally { - U.close(jin, log); - } - - return false; - } - - /** - * Tests whether all files in given JAR file are signed - * with public key. If manifest is {@code null} than method returns - * {@code true} if public key is null. - *

- * DO NOT REFACTOR THIS METHOD. THERE IS A SUN DEFECT ABOUT PROCESSING JAR AS - * FILE AND AS STREAM. THE PROCESSING IS DIFFERENT. - * - * @param jarName JAR file name. - * @param pubKey Public key to be tested with. - * @param allSigned Hint which means that all files in entry must be signed. - * @param log Logger. - * @return {@code true} if JAR file is signed with given public key. - * @throws IOException Thrown if JAR file or its entries could not be read. - */ - private static boolean verify0(String jarName, PublicKey pubKey, boolean allSigned, IgniteLogger log) - throws IOException { - JarFile jarFile = null; - - try { - jarFile = new JarFile(jarName, true); - - Manifest manifest = jarFile.getManifest(); - - // Manifest must be included into a signed package. - if (manifest == null) - return pubKey == null; - - Set manifestFiles = getSignedFiles(manifest); - - Enumeration entries = jarFile.entries(); - - while (entries.hasMoreElements()) { - JarEntry jarEntry = entries.nextElement(); - - if (jarEntry.isDirectory()) - continue; - - // Verify by reading the file if altered. - // Will return quietly if no problem. - verifyDigestsImplicitly(jarFile.getInputStream(jarEntry)); - - if (!verifyEntry(jarEntry, manifest, pubKey, allSigned, false)) - return false; - - manifestFiles.remove(jarEntry.getName()); - } - - return manifestFiles.size() <= 0; - } - catch (SecurityException e) { - if (log.isDebugEnabled()) - log.debug("Got security error (ignoring): " + e.getMessage()); - } - finally { - U.close(jarFile, log); - } - - return false; - } - - /** - * Tests whether given JAR entry from manifest contains at least one - * certificate with given public key. - *

- * Files which starts with "META-INF/" are always verified successfully. - * - * @param jarEntry Tested JAR entry. - * @param manifest Manifest this entry belongs to. - * @param pubKey Public key we are testing. If it is {@code null} returns - * {@code true}. - * @param allSigned Hint which means that all files in entry must be signed. - * @param makeCerts If {@code true} JAR entry certificates are scanned. - * Otherwise all JAR entry signers certificates are scanned. - * @return {@code true} if JAR entry is verified {@code false} otherwise. - */ - private static boolean verifyEntry(JarEntry jarEntry, Manifest manifest, PublicKey pubKey, boolean allSigned, - boolean makeCerts) { - assert jarEntry != null; - assert manifest != null; - - boolean inManifest = false; - - String entryName = jarEntry.getName(); - - // Check that entry name contains in manifest file. - if (manifest.getAttributes(entryName) != null || manifest.getAttributes("./" + entryName) != null || - manifest.getAttributes('/' + entryName) != null) - inManifest = true; - - // Don't ignore files not listed in manifest and META-INF directory. - if (allSigned && !inManifest && !entryName.toUpperCase().startsWith("META-INF/")) - return false; - - // Looking at entries in manifest file. - if (inManifest) { - Certificate[] certs = !makeCerts ? jarEntry.getCertificates() : getCertificates(jarEntry); - - boolean isSigned = certs != null && certs.length > 0; - - if (!isSigned || pubKey != null && !findKeyInCertificates(pubKey, certs)) - return false; - } - - return true; - } - - /** - * This checks that everything is valid and unchanged from the digest - * listed in the manifest next to the name. - * - * @param in JAR file or JAR entry input stream. - * @throws IOException Thrown if read fails. - */ - private static void verifyDigestsImplicitly(InputStream in) throws IOException { - byte[] buf = new byte[BUF_SIZE]; - - while (in.read(buf, 0, buf.length) != -1) { - // Just read the entry. Will throw a SecurityException if signature - // or digest check fails. Since we instantiated JarFile with parameter - // true, that tells it to verify that the files match the digests - // and haven't been changed. - } - } - - /** - * Tests whether given certificate contains public key or not. - * - * @param key Public key which we are looking for. - * @param certs Certificate which should be tested. - * @return {@code true} if certificate contains given key and - * {@code false} if not. - */ - private static boolean findKeyInCertificates(PublicKey key, Certificate[] certs) { - if (key == null || certs == null) - return false; - - for (Certificate cert : certs) { - if (cert.getPublicKey().equals(key)) - return true; - } - - return false; - } - - /** - * Gets all signed files from the manifest. - *

- * It scans all manifest entries and their attributes. If there is an attribute - * name which ends with "-DIGEST" we are assuming that manifest entry name is a - * signed file name. - * - * @param manifest JAR file manifest. - * @return Either empty set if none found or set of signed file names. - */ - private static Set getSignedFiles(Manifest manifest) { - Set fileNames = new HashSet<>(); - - Map entries = manifest.getEntries(); - - if (entries != null && entries.size() > 0) { - for (Map.Entry entry : entries.entrySet()) { - Attributes attrs = entry.getValue(); - - for (Map.Entry attrEntry : attrs.entrySet()) { - if (attrEntry.getKey().toString().toUpperCase().endsWith("-DIGEST")) { - fileNames.add(entry.getKey()); - - break; - } - } - } - } - - return fileNames; - } - - /** - * Gets all JAR file entry certificates. - * Method scans entry for signers and than collects all their certificates. - * - * @param entry JAR file entry. - * @return Array of certificates which corresponds to the entry. - */ - private static Certificate[] getCertificates(JarEntry entry) { - Certificate[] certs = null; - - CodeSigner[] signers = entry.getCodeSigners(); - - // Extract the certificates in each code signer's cert chain. - if (signers != null) { - List certChains = new ArrayList<>(); - - for (CodeSigner signer : signers) - certChains.addAll(signer.getSignerCertPath().getCertificates()); - - // Convert into a Certificate[] - return certChains.toArray(new Certificate[certChains.size()]); - } - - return certs; - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSpringDocument.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSpringDocument.java deleted file mode 100644 index 0143537c52258..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSpringDocument.java +++ /dev/null @@ -1,100 +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.spi.deployment.uri; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import org.apache.ignite.compute.ComputeTask; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.IgniteSpiException; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.xml.XmlBeanFactory; - -/** - * Helper class which helps to read deployer and tasks information from - * {@code Spring} configuration file. - */ -class GridUriDeploymentSpringDocument { - /** Initialized springs beans factory. */ - private final XmlBeanFactory factory; - - /** List of tasks from package description. */ - private List>> tasks; - - /** - * Creates new instance of configuration helper with given configuration. - * - * @param factory Configuration factory. - */ - GridUriDeploymentSpringDocument(XmlBeanFactory factory) { - assert factory != null; - - this.factory = factory; - } - - /** - * Loads tasks declared in configuration by given class loader. - * - * @param clsLdr Class loader. - * @return Declared tasks. - * @throws org.apache.ignite.spi.IgniteSpiException Thrown if there are no tasks in - * configuration or configuration could not be read. - */ - @SuppressWarnings({"unchecked"}) - List>> getTasks(ClassLoader clsLdr) throws IgniteSpiException { - assert clsLdr != null; - - try { - if (tasks == null) { - tasks = new ArrayList<>(); - - Map beans = factory.getBeansOfType(List.class); - - if (!beans.isEmpty()) { - for (List list : beans.values()) { - for (String clsName : list) { - Class taskCls; - - try { - taskCls = clsLdr.loadClass(clsName); - } - catch (ClassNotFoundException e) { - throw new IgniteSpiException("Failed to load task class [className=" + clsName + ']', e); - } - - assert taskCls != null; - - tasks.add(taskCls); - } - } - } - } - } - catch (BeansException e) { - throw new IgniteSpiException("Failed to get tasks declared in XML file.", e); - } - - return tasks; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridUriDeploymentSpringDocument.class, this); - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSpringParser.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSpringParser.java deleted file mode 100644 index 842a8cf9be07c..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSpringParser.java +++ /dev/null @@ -1,79 +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.spi.deployment.uri; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import org.apache.ignite.IgniteLogger; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.IgniteSpiException; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.xml.XmlBeanFactory; -import org.springframework.core.io.ByteArrayResource; -import org.springframework.core.io.InputStreamResource; - -/** - * Workaround for {@link InputStreamResource}. Converts input stream with XML - * to {@code GridUriDeploymentSpringDocument} with {@link ByteArrayResource} - * instead of {@link InputStreamResource}. - */ -final class GridUriDeploymentSpringParser { - /** - * Enforces singleton. - */ - private GridUriDeploymentSpringParser() { - // No-op. - } - - /** - * Converts given input stream expecting XML inside to - * {@link GridUriDeploymentSpringDocument}. - *

- * This is a workaround for the {@link InputStreamResource} which does - * not work properly. - * - * @param in Input stream with XML. - * @param log Logger - * @return Grid wrapper for the input stream. - * @throws org.apache.ignite.spi.IgniteSpiException Thrown if incoming input stream could not be - * read or parsed by {@code Spring} {@link XmlBeanFactory}. - * @see XmlBeanFactory - */ - static GridUriDeploymentSpringDocument parseTasksDocument(InputStream in, IgniteLogger log) throws - IgniteSpiException { - assert in != null; - - // Note: use ByteArrayResource instead of InputStreamResource because InputStreamResource doesn't work. - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - try { - U.copy(in, out); - - XmlBeanFactory factory = new XmlBeanFactory(new ByteArrayResource(out.toByteArray())); - - return new GridUriDeploymentSpringDocument(factory); - } - catch (BeansException | IOException e) { - throw new IgniteSpiException("Failed to parse spring XML file.", e); - } - finally { - U.close(out, log); - } - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentUnitDescriptor.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentUnitDescriptor.java deleted file mode 100644 index 22965c4b427b5..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentUnitDescriptor.java +++ /dev/null @@ -1,279 +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.spi.deployment.uri; - -import java.io.File; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import org.apache.ignite.internal.util.tostring.GridToStringExclude; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.P1; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.lang.IgniteBiTuple; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.spi.deployment.uri.GridUriDeploymentUnitDescriptor.Type.CLASS; -import static org.apache.ignite.spi.deployment.uri.GridUriDeploymentUnitDescriptor.Type.FILE; - -/** - * Container for information about tasks and file where classes placed. It also contains tasks instances. - */ -class GridUriDeploymentUnitDescriptor { - /** - * Container type. - */ - @SuppressWarnings({"PackageVisibleInnerClass"}) enum Type { - /** - * Container has reference to the file with tasks. - */ - FILE, - - /** - * Container keeps tasks deployed directly. - */ - CLASS - } - - /** - * Container type. - */ - private final Type type; - - /** - * If type is {@link Type#FILE} contains URI of {@link #file} otherwise must be null. - */ - @GridToStringExclude - private final String uri; - - /** - * If type is {@link Type#FILE} contains file with tasks otherwise must be null. - */ - private final File file; - - /** - * Tasks deployment timestamp. - */ - private final long tstamp; - - /** */ - private final ClassLoader clsLdr; - - /** Set of all resources. */ - private final Set> rsrcs = new HashSet<>(); - - /** Map of resources by alias. */ - private final Map> rsrcsByAlias = new HashMap<>(); - - /** - * If type is {@link Type#FILE} and digest was computed successfully contains MD5 digest of the source file. - */ - private final String md5; - - /** - * Constructs descriptor for a deployment unit. - * - * @param uri URI of the deployment unit. - * @param file File itself. - * @param tstamp Tasks deployment timestamp. - * @param clsLdr Class loader. - * @param md5 Hash of unit file of directory. - */ - GridUriDeploymentUnitDescriptor(String uri, File file, long tstamp, ClassLoader clsLdr, String md5) { - assert uri != null; - assert file != null; - assert tstamp > 0; - - this.uri = uri; - this.file = file; - this.tstamp = tstamp; - this.clsLdr = clsLdr; - this.md5 = md5; - - type = FILE; - } - - /** - * Constructs a deployment unit descriptor based on timestamp and {@link org.apache.ignite.compute.ComputeTask} - * instances. - * - * @param tstamp Tasks deployment timestamp. - * @param clsLdr Class loader. - */ - GridUriDeploymentUnitDescriptor(long tstamp, ClassLoader clsLdr) { - assert clsLdr != null; - assert tstamp > 0; - - this.tstamp = tstamp; - this.clsLdr = clsLdr; - - uri = null; - file = null; - md5 = null; - type = CLASS; - } - - /** - * Gets descriptor type. - * - * @return Descriptor type. - */ - public Type getType() { - return type; - } - - /** - * Gets file URL. - * - * @return {@code null} if tasks were deployed directly and reference to the package file URI if tasks - * were deployed from the file. - */ - public String getUri() { - return uri; - } - - /** - * Tasks' package file. - * - * @return {@code null} if tasks were deployed directly and package file if tasks were deployed from it. - */ - public File getFile() { - return file; - } - - /** - * Gets tasks deployment timestamp. - * - * @return Tasks deployment timestamp. - */ - public long getTimestamp() { - return tstamp; - } - - /** - * Source file MD5 digest. - * - * @return MD5 digest of the source file if it is available, otherwise {@code null}. - */ - public String getMd5() { - return md5; - } - - /** - * Deployed task. - * - * @return Deployed task. - */ - public ClassLoader getClassLoader() { - return clsLdr; - } - - /** - * Adds resource to this descriptor. - * - * @param cls Resource class. - */ - public void addResource(Class cls) { - rsrcs.add(cls); - } - - /** - * Adds resource by alias to this descriptor. - * - * @param alias Resource alias. - * @param cls Resource class. - */ - public void addResource(String alias, Class cls) { - rsrcsByAlias.put(alias, cls); - - rsrcs.add(cls); - } - - /** - * Gets resource by alias. - * - * @param alias Resource alias. - * @return Resource class or {@code null}, if there is no resource - * for this alias. - */ - @Nullable public Class getResourceByAlias(String alias) { - return rsrcsByAlias.get(alias); - } - - /** - * Gets resource by alias map. - * - * @return Unmodifiable resource by alias map. - */ - public Map> getResourcesByAlias() { - return Collections.unmodifiableMap(rsrcsByAlias); - } - - /** - * Gets a full resource set. - * - * @return Unmodifiable resource set. - */ - public Set> getResources() { - return Collections.unmodifiableSet(rsrcs); - } - - /** - * Looks up for resource by name (either full class name or alias). - * - * @param rsrcName Resource name (either full class name or alias). - * @return Tuple of resource class and alias or {@code null}, if - * resource is not found. The second tuple member is - * {@code null} if the resource has no alias. - */ - @Nullable public IgniteBiTuple, String> findResource(final String rsrcName) { - // Find by alias. - Class cls = rsrcsByAlias.get(rsrcName); - - if (cls != null) - return F., String>t(cls, rsrcName); - - // Find by class name. - cls = F.find(rsrcs, null, new P1>() { - @Override public boolean apply(Class cls0) { - return cls0.getName().equals(rsrcName); - } - }); - - return cls != null ? F., String>t(cls, null) : null; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return clsLdr.hashCode(); - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object obj) { - return obj instanceof GridUriDeploymentUnitDescriptor && - clsLdr.equals(((GridUriDeploymentUnitDescriptor)obj).clsLdr); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridUriDeploymentUnitDescriptor.class, this, "uri", U.hidePassword(uri)); - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentUriParser.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentUriParser.java deleted file mode 100644 index b5f77e911cad8..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentUriParser.java +++ /dev/null @@ -1,180 +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.spi.deployment.uri; - -import org.apache.ignite.internal.util.tostring.GridToStringExclude; -import org.apache.ignite.internal.util.typedef.internal.S; - -/** - * Helper class which encodes given string. - * It replaces all occurrences of space with '%20', percent sign - * with '%25' and semicolon with '%3B' if given string corresponds to - * expected format. - *

- * Expected format is (schema):(//)URL(?|#)(parameters) - */ -class GridUriDeploymentUriParser { - /** Input string which should be parsed and encoded. */ - private final String input; - - /** Encoded string. */ - @GridToStringExclude private String encoded; - - /** - * Creates new instance of parser for the given input string. - * - * @param input Input string which will be parsed. - */ - GridUriDeploymentUriParser(String input) { - assert input != null; - - this.input = input; - - encoded = input; - } - - /** - * Parses {@link #input} by extracting URL without schema and parameters - * and than encodes this URL. - *

- * Expected {@link #input} format is (schema):(//)URL(?|#)(parameters) - * - * @return Either encoded string or unchanged if it does not match format. - */ - String parse() { - int n = input.length(); - - // Scheme. - int p = scan(0, n, "/?#", ":"); - - if (p > 0 && at(p, n, ':')) { - p++; // Skip ':' - - if (at(p, n, '/')) { - if (at(p, n, '/') && at(p + 1, n, '/')) { - p += 2; - - // Seek authority. - int q = scan(p, n, "", "/?#"); - - if (q > p) - p = q; - } - - int q = scan(p, n, "", "?#"); - - StringBuilder buf = new StringBuilder(input.substring(0, p)); - - buf.append(encodePath(input.substring(p, q))); - buf.append(input.substring(q, n)); - - encoded = buf.toString(); - } - } - - return encoded; - } - - /** - * Scan forward from the given start position. Stop at the first char - * in the err string (in which case -1 is returned), or the first char - * in the stop string (in which case the index of the preceding char is - * returned), or the end of the input string (in which case the length - * of the input string is returned). May return the start position if - * none matches. - * - * @param start Start scan position. - * @param end End scan position. - * @param err Error characters. - * @param stop Stoppers. - * @return {@code -1} if character from the error characters list was found; - * index of first character occurrence is on stop character list; end - * position if {@link #input} does not contain any characters - * from {@code error} or {@code stop}; start if start > end. - */ - private int scan(int start, int end, String err, String stop) { - int p = start; - - while (p < end) { - char c = input.charAt(p); - - if (err.indexOf(c) >= 0) - return -1; - - if (stop.indexOf(c) >= 0) - break; - - p++; - } - - return p; - } - - /** - * Tests whether {@link #input} contains {@code c} at position {@code start} - * and {@code start} less than {@code end}. - * - * @param start Start position. - * @param end End position. - * @param c Character {@link #input} is tested against - * @return {@code true} only if {@link #input} contains {@code c} at position - * {@code start} and {@code start} less than {@code end}. - */ - private boolean at(int start, int end, char c) { - return start < end && input.charAt(start) == c; - } - - /** - * Encodes given path by replacing all occurrences of space with '%20', - * percent sign with '%25' and semicolon with '%3B'. - * - * @param path Path to be encoded. - * @return Encoded path. - */ - private String encodePath(String path) { - StringBuilder buf = new StringBuilder(path.length()); - - for (int i = 0; i < path.length(); i++) { - char c = path.charAt(i); - - switch (c) { - case ' ': { - buf.append("%20"); break; - } - - case '%': { - buf.append("%25"); break; - } - case ';': { - buf.append("%3B"); break; - } - - default: { - buf.append(c); - } - } - } - - return buf.toString(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridUriDeploymentUriParser.class, this); - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java deleted file mode 100644 index 2639cc62c1a43..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java +++ /dev/null @@ -1,1408 +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.spi.deployment.uri; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.InputStream; -import java.io.Serializable; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.IgniteLogger; -import org.apache.ignite.compute.ComputeTask; -import org.apache.ignite.compute.ComputeTaskName; -import org.apache.ignite.internal.IgniteInterruptedCheckedException; -import org.apache.ignite.internal.util.tostring.GridToStringExclude; -import org.apache.ignite.internal.util.tostring.GridToStringInclude; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.internal.A; -import org.apache.ignite.internal.util.typedef.internal.LT; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.resources.LoggerResource; -import org.apache.ignite.spi.IgniteSpiAdapter; -import org.apache.ignite.spi.IgniteSpiConfiguration; -import org.apache.ignite.spi.IgniteSpiConsistencyChecked; -import org.apache.ignite.spi.IgniteSpiException; -import org.apache.ignite.spi.IgniteSpiMBeanAdapter; -import org.apache.ignite.spi.IgniteSpiMultipleInstancesSupport; -import org.apache.ignite.spi.deployment.DeploymentListener; -import org.apache.ignite.spi.deployment.DeploymentResource; -import org.apache.ignite.spi.deployment.DeploymentResourceAdapter; -import org.apache.ignite.spi.deployment.DeploymentSpi; -import org.apache.ignite.spi.deployment.uri.scanners.GridUriDeploymentScannerListener; -import org.apache.ignite.spi.deployment.uri.scanners.UriDeploymentScanner; -import org.apache.ignite.spi.deployment.uri.scanners.UriDeploymentScannerManager; -import org.apache.ignite.spi.deployment.uri.scanners.file.UriDeploymentFileScanner; -import org.apache.ignite.spi.deployment.uri.scanners.http.UriDeploymentHttpScanner; -import org.jetbrains.annotations.Nullable; - -/** - * Implementation of {@link org.apache.ignite.spi.deployment.DeploymentSpi} which can deploy tasks from - * different sources like file system folders, email and HTTP. - * There are different ways to deploy tasks in grid and every deploy method - * depends on selected source protocol. This SPI is configured to work - * with a list of URI's. Every URI contains all data about protocol/transport - * plus configuration parameters like credentials, scan frequency, and others. - *

- * When SPI establishes a connection with an URI, it downloads deployable units - * to the temporary directory in order to prevent it from any changes while - * scanning. Use method {@link #setTemporaryDirectoryPath(String) setTemporaryDirectoryPath(String)}) - * to set custom temporary folder for downloaded deployment units. SPI will - * create folder under the path with name identical to local node ID. - *

- * SPI tracks all changes of every given URI. This means that if any file is - * changed or deleted, SPI will re-deploy or delete corresponding tasks. - * Note that the very first apply to {@link #findResource(String)} - * is blocked until SPI finishes scanning all URI's at least once. - *

- * There are several deployable unit types supported: - *

    - *
  • JAR file.
  • - *
  • GAR file.
  • - *
  • Local disk folder with structure of an unpacked deployment archive.
  • - *
  • Local disk folder containing only compiled Java classes.
  • - *
- *

Deployment package

- * Deployment package can be represented as a regular JAR file with a specific structure similar to WAR format. - * Package files can have {@code '.jar'} or {@code '.gar'} extension. - *

- * Package structure: - *

- *      META-INF/
- *              |
- *               - ignite.xml
- *               - ...
- *      lib/
- *         |
- *          -some-lib.jar
- *          - ...
- *      xyz.class
- *      ...
- *
    - *
  • - * {@code META-INF/} entry may contain {@code ignite.xml} file which is a - * task descriptor file. The purpose of task descriptor XML file is to specify - * all tasks to be deployed. This file is a regular - * Spring XML - * definition file. {@code META-INF/} entry may also contain any other file - * specified by JAR format. - *
  • - *
  • - * {@code lib/} entry contains all library dependencies. - *
  • - *
  • Compiled Java classes must be placed in the root of a package file.
  • - *
- * A package may be deployed without a descriptor file. If there is no descriptor file, SPI - * will scan all classes in archive and instantiate those that implement - * {@link org.apache.ignite.compute.ComputeTask} interface. In that case, all grid task classes must have a - * public no-argument constructor. Use {@link org.apache.ignite.compute.ComputeTaskAdapter} adapter for - * convenience when creating grid tasks. - *

- * By default, all downloaded packages that have digital signature in {@code META-INF} - * folder will be verified and deployed only if signature is valid. - *

- *

URI

- * This SPI uses a hierarchical URI definition. For more information about standard URI - * syntax refer to {@link URI java.net.URI} documentation. - *
- * [scheme:][//authority][path][?query] - * [#fragment]
- *

- * Every URI defines its own deployment repository which will be scanned for any changes. - * URI itself has all information about protocol, connectivity, scan intervals and other - * parameters. - *

- * URI's may contain special characters, like spaces. If {@code encodeUri} - * flag is set to {@code true} (see {@link #setEncodeUri(boolean)}), then - * URI 'path' field will be automatically encoded. By default this flag is - * set to {@code true}. - *

- *

Code Example

- * The following example demonstrates how the deployment SPI can be used. It expects that you have a package file - * in 'home/username/ignite/work/my_deployment/file' folder which contains 'myproject.HelloWorldTask' class. - *
- * IgniteConfiguration cfg = new IgniteConfiguration();
- *
- * DeploymentSpi deploymentSpi = new UriDeploymentSpi();
- *
- * deploymentSpi.setUriList(Arrays.asList("file:///home/username/ignite/work/my_deployment/file"));
- *
- * cfg.setDeploymentSpi(deploymentSpi);
- *
- * try (Ignite ignite = Ignition.start(cfg)) {
- *     ignite.compute().execute("myproject.HelloWorldTask", "my args");
- * }
- * 
- *

Configuration

- * {@code UriDeploymentSpi} has the following optional configuration - * parameters (there are no mandatory parameters): - *
    - *
  • - * Array of {@link UriDeploymentScanner}-s which will be used to deploy resources - * (see {@link #setScanners(UriDeploymentScanner...)}). If not specified, preconfigured {@link UriDeploymentFileScanner} - * and {@link UriDeploymentHttpScanner} are used. You can implement your own scanner - * by implementing {@link UriDeploymentScanner} interface. - *
  • - *
  • - * Temporary directory path where scanned packages are - * copied to (see {@link #setTemporaryDirectoryPath(String) setTemporaryDirectoryPath(String)}). - *
  • - *
  • - * List of URIs to scan (see {@link #setUriList(List)}). If not - * specified, then URI specified by {@link #DFLT_DEPLOY_DIR DFLT_DEPLOY_DIR} is used. - *
  • - *
  • - * Flag to control encoding of the {@code 'path'} portion of URI - * (see {@link #setEncodeUri(boolean) setEncodeUri(boolean)}). - *
  • - *
- *

Protocols

- * Following protocols are supported by this SPI out of the box: - * - * Custom Protocols. - *

- * You can add support for additional protocols if needed. To do this implement UriDeploymentScanner interface and - * plug your implementation into the SPI via {@link #setScanners(UriDeploymentScanner...)} method. - *

- * In addition to SPI configuration parameters, all necessary configuration - * parameters for selected URI should be defined in URI. Different protocols - * have different configuration parameters described below. Parameters are - * separated by '{@code ;}' character. - *

- *

File

- * For this protocol SPI will scan folder specified by URI on file system and - * download any deplloyment files or directories that end with .jar or .gar from source - * directory defined in URI. For file system URI must have scheme equal to {@code file}. - *

- * Following parameters are supported: - * - * - * - * - * - * - * - * - * - * - * - * - * - *
ParameterDescriptionOptionalDefault
freqScanning frequency in milliseconds.Yes{@code 5000} ms specified in {@link UriDeploymentFileScanner#DFLT_SCAN_FREQ}.
- *

File URI Example

- * The following example will scan {@code 'c:/Program files/ignite/deployment'} - * folder on local box every {@code '1000'} milliseconds. Note that since path - * has spaces, {@link #setEncodeUri(boolean) setEncodeUri(boolean)} parameter must - * be set to {@code true} (which is default behavior). - *
- * {@code file://freq=2000@localhost/c:/Program files/ignite/deployment} - *
- * - *

HTTP/HTTPS

- * URI deployment scanner tries to read DOM of the html it points to and parses out href attributes of all <a> tags - * - this becomes the collection of URLs to deployment package files that should be deployed. It's important that - * HTTP scanner uses {@code URLConnection.getLastModified()} method to check if there were any changes since last - * iteration for each deployment file before redeploying. - *

- * Following parameters are supported: - * - * - * - * - * - * - * - * - * - * - * - * - * - *
ParameterDescriptionOptionalDefault
freqScanning frequency in milliseconds.Yes{@code 300000} ms specified in {@link UriDeploymentHttpScanner#DFLT_SCAN_FREQ}.
- *

HTTP URI Example

- * The following example will download the page `www.mysite.com/ignite/deployment`, parse it and download and deploy - * all deployment packages specified by href attributes of <a> elements on the page using authentication - * {@code 'username:password'} every '10000' milliseconds (only new/updated packages). - *
- * {@code http://username:password;freq=10000@www.mysite.com:110/ignite/deployment} - *
- *

Java Example

- * UriDeploymentSpi needs to be explicitly configured to override default local deployment SPI. - *
- * UriDeploymentSpi deploySpi = new UriDeploymentSpi();
- *
- * IgniteConfiguration cfg = new IgniteConfiguration();
- *
- * // Set URIs.
- * deploySpi.setUriList(Arrays.asList("http://www.site.com/tasks",
- *     "file://freq=20000@localhost/c:/Program files/gg-deployment"));
- *
- * // Override temporary directory path.
- * deploySpi.setTemporaryDirectoryPath("c:/tmp/grid");
- *
- * //  Override default deployment SPI.
- * cfg.setDeploymentSpi(deploySpi);
- *
- * //  Start grid.
- * Ignition.start(cfg);
- * 
- *

- *

Spring Example

- * UriDeploymentSpi can be configured from Spring XML configuration file: - *
- * <bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true">
- *         ...
- *         <property name="deploymentSpi">
- *             <bean class="org.apache.ignite.grid.spi.deployment.uri.UriDeploymentSpi">
- *                 <property name="temporaryDirectoryPath" value="c:/tmp/grid"/>
- *                 <property name="uriList">
- *                     <list>
- *                         <value>http://www.site.com/tasks</value>
- *                         <value>file://freq=20000@localhost/c:/Program files/gg-deployment</value>
- *                     </list>
- *                 </property>
- *             </bean>
- *         </property>
- *         ...
- * </bean>
- * 
- *

- * - *
- * For information about Spring framework visit www.springframework.org - * @see org.apache.ignite.spi.deployment.DeploymentSpi - */ -@IgniteSpiMultipleInstancesSupport(true) -@IgniteSpiConsistencyChecked(optional = false) -@SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"}) -public class UriDeploymentSpi extends IgniteSpiAdapter implements DeploymentSpi { - /** - * Default deployment directory where SPI will pick up packages. Note that this path is relative to - * {@code IGNITE_HOME/work} folder if {@code IGNITE_HOME} system or environment variable specified, - * otherwise it is relative to {@code work} folder under system {@code java.io.tmpdir} folder. - * - * @see org.apache.ignite.configuration.IgniteConfiguration#getWorkDirectory() - */ - public static final String DFLT_DEPLOY_DIR = "deployment/file"; - - /** Default task description file path and name (value is {@code META-INF/ignite.xml}). */ - public static final String XML_DESCRIPTOR_PATH = "META-INF/ignite.xml"; - - /** - * Default temporary directory name relative to file path - * {@link #setTemporaryDirectoryPath(String)}} (value is {@code gg.uri.deployment.tmp}). - */ - public static final String DEPLOY_TMP_ROOT_NAME = "gg.uri.deployment.tmp"; - - /** Temporary directory name. */ - private String tmpDirPath; - - /** Sub-folder of 'tmpDirPath'. */ - private String deployTmpDirPath; - - /** List of URIs to be scanned. */ - @GridToStringInclude - private List uriList = new ArrayList<>(); - - /** List of encoded URIs. */ - private Collection uriEncodedList = new ArrayList<>(); - - /** Indicates whether md5 digest should be checked by this SPI before file deployment. */ - private boolean checkMd5; - - /** */ - private final LinkedList unitLoaders = new LinkedList<>(); - - /** */ - @SuppressWarnings({"TypeMayBeWeakened"}) - @GridToStringExclude - private final LastTimeUnitDescriptorComparator unitComp = new LastTimeUnitDescriptorComparator(); - - /** List of scanner managers. Every URI has it's own manager. */ - private final Collection mgrs = new ArrayList<>(); - - /** Whether URIs should be encoded or not. */ - private boolean encodeUri = true; - - /** Whether first scan cycle is completed or not. */ - private int firstScanCntr; - - /** Deployment listener which processes all notifications from scanners. */ - private volatile DeploymentListener lsnr; - - /** */ - private final Object mux = new Object(); - - /** */ - @LoggerResource - private IgniteLogger log; - - /** NOTE: flag for test purposes only. */ - private boolean delayOnNewOrUpdatedFile; - - /** Configured scanners. */ - private UriDeploymentScanner[] scanners; - - /** - * Sets absolute path to temporary directory which will be used by - * deployment SPI to keep all deployed classes in. - *

- * If not provided, default value is {@code java.io.tmpdir} system property value. - * - * @param tmpDirPath Temporary directory path. - * @return {@code this} for chaining. - */ - @IgniteSpiConfiguration(optional = true) - public UriDeploymentSpi setTemporaryDirectoryPath(String tmpDirPath) { - this.tmpDirPath = tmpDirPath; - - return this; - } - - /** - * Sets list of URI which point to a directory with packages and which should be - * scanned by SPI for the new tasks. - *

- * If not provided, default value is list with - * {@code file://${IGNITE_HOME}/work/deployment/file} element. - * Note that system property {@code IGNITE_HOME} must be set. - * For unknown {@code IGNITE_HOME} list of URI must be provided explicitly. - * - * @param uriList Package file URIs. - * @return {@code this} for chaining. - */ - @IgniteSpiConfiguration(optional = true) - public UriDeploymentSpi setUriList(List uriList) { - this.uriList = uriList; - - return this; - } - - /** - * If set to {@code true} then SPI should exclude files with same md5s from deployment. - * Otherwise it should try to load new unit regardless to possible file duplication. - * - * @param checkMd5 new value for the property - * @return {@code this} for chaining. - */ - @IgniteSpiConfiguration(optional = true) - public UriDeploymentSpi setCheckMd5(boolean checkMd5) { - this.checkMd5 = checkMd5; - - return this; - } - - /** - * Gets {@code checkMd5} property. - * - * @return value of the {@code checkMd5} property. - */ - public boolean isCheckMd5() { - return checkMd5; - } - - /** - * Indicates that URI must be encoded before usage. Encoding means replacing - * all occurrences of space with '%20', percent sign with '%25' - * and semicolon with '%3B'. - *

- * If not provided, default value is {@code true}. - * - * @param encodeUri {@code true} if every URI should be encoded and - * {@code false} otherwise. - * @return {@code this} for chaining. - */ - @IgniteSpiConfiguration(optional = true) - public UriDeploymentSpi setEncodeUri(boolean encodeUri) { - this.encodeUri = encodeUri; - - return this; - } - - /** - * Gets temporary directory path. - * - * @return Temporary directory path. - */ - public String getTemporaryDirectoryPath() { - return tmpDirPath; - } - - /** - * Gets list of URIs that are processed by SPI. - * - * @return List of URIs. - */ - public List getUriList() { - return Collections.unmodifiableList(uriList); - } - - /** {@inheritDoc} */ - @Override public void setListener(@Nullable DeploymentListener lsnr) { - this.lsnr = lsnr; - } - - /** - * Gets scanners. - * - * @return Scanners. - */ - public UriDeploymentScanner[] getScanners() { - return scanners; - } - - /** - * Sets scanners. - * - * @param scanners Scanners. - * @return {@code this} for chaining. - */ - @IgniteSpiConfiguration(optional = true) - public UriDeploymentSpi setScanners(UriDeploymentScanner... scanners) { - this.scanners = scanners; - - return this; - } - - /** {@inheritDoc} */ - @Override public void spiStop() throws IgniteSpiException { - for (UriDeploymentScannerManager mgr : mgrs) - mgr.cancel(); - - for (UriDeploymentScannerManager mgr : mgrs) - mgr.join(); - - // Clear inner collections. - uriEncodedList.clear(); - mgrs.clear(); - - List tmpClsLdrs; - - // Release all class loaders. - synchronized (mux) { - tmpClsLdrs = new ArrayList<>(unitLoaders.size()); - - for (GridUriDeploymentUnitDescriptor desc : unitLoaders) - tmpClsLdrs.add(desc.getClassLoader()); - } - - for (ClassLoader ldr : tmpClsLdrs) - onUnitReleased(ldr); - - // Delete temp directory. - if (deployTmpDirPath != null) - U.delete(new File(deployTmpDirPath)); - - unregisterMBean(); - - // Ack ok stop. - if (log.isDebugEnabled()) - log.debug(stopInfo()); - } - - /** {@inheritDoc} */ - @Override public void spiStart(String igniteInstanceName) throws IgniteSpiException { - // Start SPI start stopwatch. - startStopwatch(); - - assertParameter(uriList != null, "uriList != null"); - - initializeUriList(); - - if (uriEncodedList.isEmpty()) - addDefaultUri(); - - initializeTemporaryDirectoryPath(); - - registerMBean(igniteInstanceName, new UriDeploymentSpiMBeanImpl(this), UriDeploymentSpiMBean.class); - - FilenameFilter filter = new FilenameFilter() { - @Override public boolean accept(File dir, String name) { - assert name != null; - - String nameLowerCase = name.toLowerCase(); - - return nameLowerCase.endsWith(".gar") || nameLowerCase.endsWith(".jar"); - } - }; - - firstScanCntr = 0; - - GridUriDeploymentScannerListener lsnr = new GridUriDeploymentScannerListener() { - @Override public void onNewOrUpdatedFile(File file, String uri, long tstamp) { - if (log.isInfoEnabled()) - log.info("Found new or updated deployment unit [uri=" + U.hidePassword(uri) + - ", file=" + file.getAbsolutePath() + ", tstamp=" + tstamp + ']'); - - if (delayOnNewOrUpdatedFile) { - U.warn(log, "Delaying onNewOrUpdatedFile() by 10000 ms since 'delayOnNewOrUpdatedFile' " + - "is set to true (is this intentional?)."); - - try { - U.sleep(10000); - } - catch (IgniteInterruptedCheckedException ignored) { - // No-op - } - - U.warn(log, "Delay finished."); - } - - try { - GridUriDeploymentFileProcessorResult fileRes = GridUriDeploymentFileProcessor.processFile(file, uri, - new File(deployTmpDirPath), log); - - if (fileRes != null) - newUnitReceived(uri, fileRes.getFile(), tstamp, fileRes.getClassLoader(), - fileRes.getTaskClasses(), fileRes.getMd5()); - } - catch (IgniteSpiException e) { - U.error(log, "Error when processing file: " + file.getAbsolutePath(), e); - } - } - - /** {@inheritDoc} */ - @Override public void onDeletedFiles(List uris) { - if (log.isInfoEnabled()) { - List uriList = null; - - if (uris != null) { - uriList = new ArrayList<>(); - - for (String uri : uris) - uriList.add(U.hidePassword(uri)); - } - - if (log.isInfoEnabled()) - log.info("Found deleted deployment units [uris=" + uriList + ']'); - } - - processDeletedFiles(uris); - } - - /** {@inheritDoc} */ - @Override public void onFirstScanFinished() { - synchronized (mux) { - firstScanCntr++; - - if (isFirstScanFinished(firstScanCntr)) - mux.notifyAll(); - } - } - }; - - // Set default scanners if none are configured. - if (scanners == null) { - scanners = new UriDeploymentScanner[2]; - - scanners[0] = new UriDeploymentFileScanner(); - scanners[1] = new UriDeploymentHttpScanner(); - } - - for (URI uri : uriEncodedList) { - File file = new File(deployTmpDirPath); - - long freq = -1; - - try { - freq = getFrequencyFromUri(uri); - } - catch (NumberFormatException e) { - U.error(log, "Error parsing parameter value for frequency.", e); - } - - UriDeploymentScannerManager mgr = null; - - for (UriDeploymentScanner scanner : scanners) { - if (scanner.acceptsURI(uri)) { - mgr = new UriDeploymentScannerManager(igniteInstanceName, uri, file, freq > 0 ? freq : - scanner.getDefaultScanFrequency(), filter, lsnr, log, scanner); - - break; - } - } - - if (mgr == null) - throw new IgniteSpiException("Unsupported URI (please configure appropriate scanner): " + uri); - - mgrs.add(mgr); - - mgr.start(); - } - - // Ack parameters. - if (log.isDebugEnabled()) { - log.debug(configInfo("tmpDirPath", tmpDirPath)); - log.debug(configInfo("uriList", uriList)); - log.debug(configInfo("encodeUri", encodeUri)); - log.debug(configInfo("scanners", mgrs)); - } - - // Ack ok start. - if (log.isDebugEnabled()) - log.debug(startInfo()); - } - - /** - * Gets URI refresh frequency. - * URI is parsed and {@code freq} parameter value returned. - * - * @param uri URI to be parsed. - * @return {@code -1} if there if no {@code freq} parameter otherwise - * returns frequency. - * @throws NumberFormatException Thrown if {@code freq} parameter value - * is not a number. - */ - private long getFrequencyFromUri(URI uri) throws NumberFormatException { - assert uri != null; - - String userInfo = uri.getUserInfo(); - - if (userInfo != null) { - String[] arr = userInfo.split(";"); - - if (arr.length > 0) - for (String el : arr) - if (el.startsWith("freq=")) - return Long.parseLong(el.substring(5)); - } - - return -1; - } - - /** {@inheritDoc} */ - @Nullable @Override public DeploymentResource findResource(String rsrcName) { - assert rsrcName != null; - - // Wait until all scanner managers finish their first scanning. - try { - synchronized (mux) { - while (!isFirstScanFinished(firstScanCntr)) - mux.wait(5000); - } - } - catch (InterruptedException e) { - U.error(log, "Failed to wait while all scanner managers finish their first scanning.", e); - - Thread.currentThread().interrupt(); - - return null; - } - - synchronized (mux) { - // Last updated class loader has highest priority in search. - for (GridUriDeploymentUnitDescriptor unitDesc : unitLoaders) { - // Try to find resource for current class loader. - String clsName = rsrcName; - Class clsByAlias = unitDesc.getResourcesByAlias().get(rsrcName); - - if (clsByAlias != null) - clsName = clsByAlias.getName(); - - try { - ClassLoader ldr = unitDesc.getClassLoader(); - - Class cls = ldr instanceof GridUriDeploymentClassLoader ? - ((GridUriDeploymentClassLoader)ldr).loadClassIsolated(clsName) : - ldr.loadClass(clsName); - - assert cls != null; - - IgniteBiTuple, String> rsrc = unitDesc.findResource(rsrcName); - - if (rsrc != null) { - // Recalculate resource name in case if access is performed by - // class name and not the resource name. - String alias = rsrc.get2(); - - return new DeploymentResourceAdapter( - alias != null ? alias : rsrcName, - cls, - unitDesc.getClassLoader()); - } - // Ignore invalid tasks. - else if (!ComputeTask.class.isAssignableFrom(cls)) { - unitDesc.addResource(cls); - - return new DeploymentResourceAdapter(rsrcName, cls, unitDesc.getClassLoader()); - } - } - catch (ClassNotFoundException ignored) { - // No-op. - } - } - - return null; - } - } - - /** {@inheritDoc} */ - @Override public boolean register(ClassLoader ldr, Class rsrc) throws IgniteSpiException { - A.notNull(ldr, "ldr"); - A.notNull(rsrc, "rsrc"); - - long tstamp = U.currentTimeMillis(); - - Collection rmvClsLdrs = new ArrayList<>(); - - Map newRsrcs; - - synchronized (mux) { - GridUriDeploymentUnitDescriptor desc = null; - - // Find existing class loader. - for (GridUriDeploymentUnitDescriptor unitDesc : unitLoaders) - if (unitDesc.getClassLoader().equals(ldr)) { - desc = unitDesc; - - break; - } - - if (desc == null) { - desc = new GridUriDeploymentUnitDescriptor(tstamp, ldr); - - // New unit has largest timestamp. - assert unitLoaders.size() <= 0 || unitComp.compare(desc, unitLoaders.getFirst()) <= 0; - - unitLoaders.addFirst(desc); - } - - newRsrcs = addResources(ldr, desc, new Class[]{rsrc}); - - if (!F.isEmpty(newRsrcs)) - removeResources(ldr, newRsrcs, rmvClsLdrs); - } - - for (ClassLoader cldLdr : rmvClsLdrs) - onUnitReleased(cldLdr); - - return !F.isEmpty(newRsrcs); - } - - /** {@inheritDoc} */ - @Override public boolean unregister(String rsrcName) { - assert rsrcName != null; - - Collection rmvClsLdrs = new ArrayList<>(); - - boolean rmv; - - synchronized (mux) { - Map rsrcs = U.newHashMap(1); - - rsrcs.put(rsrcName, rsrcName); - - rmv = removeResources(null, rsrcs, rmvClsLdrs); - } - - for (ClassLoader cldLdr : rmvClsLdrs) - onUnitReleased(cldLdr); - - return rmv; - } - - /** - * Add new classes in class loader resource map. - * Note that resource map may contain two entries for one added class: - * task name -> class name and class name -> class name. - * - * @param ldr Registered class loader. - * @param desc Deployment descriptor. - * @param clss Registered classes array. - * @return Map of new resources added for registered class loader. - * @throws org.apache.ignite.spi.IgniteSpiException If resource already registered. Exception thrown - * if registered resources conflicts with rule when all task classes must be - * annotated with different task names. - */ - @Nullable private Map addResources(ClassLoader ldr, GridUriDeploymentUnitDescriptor desc, Class[] clss) - throws IgniteSpiException { - assert ldr != null; - assert desc != null; - assert clss != null; - - // Maps resources to classes. - // Map may contain 2 entries for one class. - Map> alias2Cls = new HashMap<>(clss.length * 2, 1.0f); - - // Check alias collision between added classes. - for (Class cls : clss) { - String alias = null; - - if (ComputeTask.class.isAssignableFrom(cls)) { - ComputeTaskName nameAnn = U.getAnnotation(cls, ComputeTaskName.class); - - if (nameAnn != null) - alias = nameAnn.value(); - } - - // If added classes maps to one alias. - if (alias != null && alias2Cls.containsKey(alias) && !alias2Cls.get(alias).equals(cls)) - throw new IgniteSpiException("Failed to register resources with given task name " + - "(found another class with same task name) [taskName=" + alias + - ", cls1=" + cls.getName() + ", cls2=" + alias2Cls.get(alias).getName() + ", ldr=" + ldr + ']'); - - if (alias != null) { - alias2Cls.put(alias, cls); - - desc.addResource(alias, cls); - } - else - desc.addResource(cls); - } - - Map newRsrcs = null; - - // Check collisions between added and exist classes. - for (Entry> entry : alias2Cls.entrySet()) { - String newAlias = entry.getKey(); - String newName = entry.getValue().getName(); - Class cls = desc.getResourceByAlias(newAlias); - - if (cls != null) { - // Different classes for the same resource name. - if (!cls.getName().equals(newName)) - throw new IgniteSpiException("Failed to register resources with given task name " + - "(found another class with same task name in the same class loader) [taskName=" + newAlias + - ", existingCls=" + cls.getName() + ", newCls=" + newName + ", ldr=" + ldr + ']'); - } - // Add resources that should be removed for another class loaders. - else { - if (newRsrcs == null) - newRsrcs = U.newHashMap(alias2Cls.size() + clss.length); - - newRsrcs.put(newAlias, newName); - newRsrcs.put(newName, newName); - } - } - - return newRsrcs; - } - - /** - * Remove resources for all class loaders except {@code ignoreClsLdr}. - * - * @param ignoreClsLdr Ignored class loader or {@code null} to remove for all class loaders. - * @param rsrcs Resources that should be used in search for class loader to remove. - * @param rmvClsLdrs Class loaders to remove. - * @return {@code True} if resource was removed. - */ - private boolean removeResources(@Nullable ClassLoader ignoreClsLdr, Map rsrcs, - Collection rmvClsLdrs) { - assert Thread.holdsLock(mux); - assert rsrcs != null; - - boolean res = false; - - for (Iterator iter = unitLoaders.iterator(); iter.hasNext();) { - GridUriDeploymentUnitDescriptor desc = iter.next(); - ClassLoader ldr = desc.getClassLoader(); - - if (ignoreClsLdr == null || !ldr.equals(ignoreClsLdr)) { - boolean isRmv = false; - - // Check class loader's registered resources. - for (String rsrcName : rsrcs.keySet()) { - IgniteBiTuple, String> rsrc = desc.findResource(rsrcName); - - // Remove class loader if resource found. - if (rsrc != null) { - iter.remove(); - - // Add class loaders in collection to notify listener outside synchronization block. - rmvClsLdrs.add(ldr); - - isRmv = true; - res = true; - - break; - } - } - - if (isRmv) - continue; - - // Check is possible to load resources with classloader. - for (Entry entry : rsrcs.entrySet()) { - // Check classes with class loader only when classes points to classes to avoid redundant check. - // Resources map contains two entries for class with task name(alias). - if (entry.getKey().equals(entry.getValue()) && isResourceExist(ldr, entry.getKey())) { - iter.remove(); - - // Add class loaders in collection to notify listener outside synchronization block. - rmvClsLdrs.add(ldr); - - res = true; - - break; - } - } - } - } - - return res; - } - - /** - * Check is class can be reached. - * - * @param ldr Class loader. - * @param clsName Class name. - * @return {@code true} if class can be loaded. - */ - private boolean isResourceExist(ClassLoader ldr, String clsName) { - String rsrc = clsName.replaceAll("\\.", "/") + ".class"; - - InputStream in = null; - - try { - in = ldr instanceof GridUriDeploymentClassLoader ? - ((GridUriDeploymentClassLoader)ldr).getResourceAsStreamIsolated(rsrc) : - ldr.getResourceAsStream(rsrc); - - return in != null; - } - finally { - U.close(in, log); - } - } - - /** - * Tests whether first scan is finished or not. - * - * @param cntr Number of already scanned URIs. - * @return {@code true} if all URIs have been scanned at least once and - * {@code false} otherwise. - */ - private boolean isFirstScanFinished(int cntr) { - assert uriEncodedList != null; - - return cntr >= uriEncodedList.size(); - } - - /** - * Fills in list of URIs with all available URIs and encodes them if - * encoding is enabled. - * - * @throws org.apache.ignite.spi.IgniteSpiException Thrown if at least one URI has incorrect syntax. - */ - private void initializeUriList() throws IgniteSpiException { - for (String uri : uriList) { - assertParameter(uri != null, "uriList.get(X) != null"); - - String encUri = encodeUri(uri.replaceAll("\\\\", "/")); - - URI uriObj; - - try { - uriObj = new URI(encUri); - } - catch (URISyntaxException e) { - throw new IgniteSpiException("Failed to parse URI [uri=" + U.hidePassword(uri) + - ", encodedUri=" + U.hidePassword(encUri) + ']', e); - } - - if (uriObj.getScheme() == null || uriObj.getScheme().trim().isEmpty()) - throw new IgniteSpiException("Failed to get 'scheme' from URI [uri=" + - U.hidePassword(uri) + - ", encodedUri=" + U.hidePassword(encUri) + ']'); - - uriEncodedList.add(uriObj); - } - } - - /** - * Add configuration for file scanner. - * - * @throws org.apache.ignite.spi.IgniteSpiException Thrown if default URI syntax is incorrect. - */ - private void addDefaultUri() throws IgniteSpiException { - assert uriEncodedList != null; - - URI uri; - - try { - uri = U.resolveWorkDirectory(ignite.configuration().getWorkDirectory(), DFLT_DEPLOY_DIR, false).toURI(); - } - catch (IgniteCheckedException e) { - throw new IgniteSpiException("Failed to initialize default file scanner", e); - } - - uriEncodedList.add(uri); - } - - /** - * Encode URI path if encoding is enabled. Set of encoded characters - * in path is (' ', ';', '%'). - * - * @param path URI which should be encoded. - * @return Either encoded URI if encoding is enabled or given one - * if encoding is disabled. - */ - private String encodeUri(String path) { - return encodeUri ? new GridUriDeploymentUriParser(path).parse() : path; - } - - /** - * Initializes temporary directory path. Path consists of base path - * (either {@link #tmpDirPath} value or {@code java.io.tmpdir} - * system property value if first is {@code null}) and path relative - * to base one - {@link #DEPLOY_TMP_ROOT_NAME}/{@code local node ID}. - * - * @throws org.apache.ignite.spi.IgniteSpiException Thrown if temporary directory could not be created. - */ - private void initializeTemporaryDirectoryPath() throws IgniteSpiException { - String tmpDirPath = this.tmpDirPath == null ? System.getProperty("java.io.tmpdir") : this.tmpDirPath; - - if (tmpDirPath == null) - throw new IgniteSpiException("Error initializing temporary deployment directory."); - - File dir = new File(tmpDirPath + File.separator + DEPLOY_TMP_ROOT_NAME + File.separator + - ignite.configuration().getNodeId()); - - if (!U.mkdirs(dir)) - throw new IgniteSpiException("Error initializing temporary deployment directory: " + dir); - - if (!dir.isDirectory()) - throw new IgniteSpiException("Temporary deployment directory path is not a valid directory: " + dir); - - if (!dir.canRead() || !dir.canWrite()) - throw new IgniteSpiException("Can not write to or read from temporary deployment directory: " + dir); - - this.tmpDirPath = tmpDirPath; - - deployTmpDirPath = dir.getPath(); - } - - /** - * Deploys all tasks that correspond to given descriptor. - * First method checks tasks versions and stops processing tasks that - * have both versioned and unversioned instances. - *

- * Than it deletes tasks with lower version and deploys newest tasks. - * - * @param newDesc Tasks deployment descriptor. - * @param clss Registered classes. - */ - private void newUnitReceived(GridUriDeploymentUnitDescriptor newDesc, Collection> clss) { - assert newDesc != null; - assert newDesc.getType() == GridUriDeploymentUnitDescriptor.Type.FILE; - - if (clss != null && !clss.isEmpty()) { - try { - addResources(newDesc.getClassLoader(), newDesc, clss.toArray(new Class[clss.size()])); - } - catch (IgniteSpiException e) { - U.warn(log, "Failed to register a class loader for a package [newDesc=" + newDesc + - ", msg=" + e.getMessage() + ']'); - } - } - - Collection rmvClsLdrs = new ArrayList<>(); - - synchronized (mux) { - if (checkMd5 && unitDeployed(newDesc.getMd5())) { - if (log.isInfoEnabled()) - LT.info(log, "Skipping new deployment unit because of md5 match " + - "[uri='" + U.hidePassword(newDesc.getUri()) + - "', file=" + (newDesc.getFile() == null ? "N/A" : newDesc.getFile()) + ']'); - - return; - } - - boolean isAdded = false; - boolean ignoreNewUnit = false; - - for (ListIterator iter = unitLoaders.listIterator(); - iter.hasNext();) { - GridUriDeploymentUnitDescriptor desc = iter.next(); - - assert !newDesc.getClassLoader().equals(desc.getClassLoader()) : - "URI scanners always create new class loader for every package: " + newDesc; - - // Only for deployment archives. Undeploy all for overwritten packages. - if (desc.getType() == GridUriDeploymentUnitDescriptor.Type.FILE && - newDesc.getUri().equals(desc.getUri()) && !newDesc.getFile().equals(desc.getFile())) { - // Remove descriptor. - iter.remove(); - - // Add class loaders in collection to notify listener outside synchronization block. - rmvClsLdrs.add(desc.getClassLoader()); - - // Last descriptor. - if (!iter.hasNext()) - // New descriptor will be added after loop. - break; - - continue; - } - - if (!isAdded) { - // Unit with largest timestamp win. - // Insert it before current element. - if (unitComp.compare(newDesc, desc) <= 0) { - // Remove current class loader if found collisions. - if (checkUnitCollision(desc, newDesc)) { - iter.remove(); - iter.add(newDesc); - - // Add class loaders in collection to notify listener outside synchronization block. - rmvClsLdrs.add(desc.getClassLoader()); - } - // Or add new class loader before current class loader. - else { - iter.set(newDesc); - iter.add(desc); - } - - isAdded = true; - } - else if (checkUnitCollision(newDesc, desc)) { - // Don't add new unit if found collisions with latest class loader. - ignoreNewUnit = true; - break; - } - } - // New descriptor already added and we need to check other class loaders for collisions. - else if (checkUnitCollision(newDesc, desc)) { - iter.remove(); - - // Add class loaders in collection to notify listener outside synchronization block. - rmvClsLdrs.add(desc.getClassLoader()); - } - } - - if (!ignoreNewUnit) { - if (!isAdded) - unitLoaders.add(newDesc); - - if (log.isDebugEnabled()) - LT.info(log, "Class loader (re)registered [clsLdr=" + newDesc.getClassLoader() + - ", tstamp=" + newDesc.getTimestamp() + - ", uri='" + U.hidePassword(newDesc.getUri()) + - "', file=" + (newDesc.getFile() == null ? "N/A" : newDesc.getFile()) + ']'); - } - } - - for (ClassLoader cldLdr : rmvClsLdrs) - onUnitReleased(cldLdr); - } - - /** - * Check task resource collisions in added descriptor {@code newDesc} with another - * descriptor {@code existDesc}. - * - * @param newDesc New added descriptor. - * @param existDesc Exist descriptor. - * @return {@code True} if collisions found. - */ - private boolean checkUnitCollision(GridUriDeploymentUnitDescriptor newDesc, - GridUriDeploymentUnitDescriptor existDesc) { - assert newDesc != null; - assert existDesc != null; - - Map> rsrcsByAlias = newDesc.getResourcesByAlias(); - - for (Entry> entry : existDesc.getResourcesByAlias().entrySet()) { - String rsrcName = entry.getKey(); - - if (rsrcsByAlias.containsKey(rsrcName)) { - U.warn(log, "Found collision with task name in a different package. " + - "Class loader will be removed [taskName=" + rsrcName + ", cls1=" + rsrcsByAlias.get(rsrcName) + - ", cls2=" + entry.getValue() + ", newDesc=" + newDesc + ", existDesc=" + existDesc + ']'); - - return true; - } - } - - for (Class rsrcCls : existDesc.getResources()) { - if (!ComputeTask.class.isAssignableFrom(rsrcCls) && - isResourceExist(newDesc.getClassLoader(), rsrcCls.getName())) { - U.warn(log, "Found collision with task class in different deployment packages. " + - "Class loader will be removed [taskCls=" + rsrcCls + - ", removedDesc=" + newDesc + ", existDesc=" + existDesc + ']'); - - return true; - } - } - - return false; - } - - /** - * Deploys or redeploys given tasks. - * - * @param uri Package file URI. - * @param file Package file. - * @param tstamp File modification date. - * @param ldr Class loader. - * @param clss List of tasks which were found in the package. - * @param md5 md5 of the new unit. - */ - private void newUnitReceived(String uri, File file, long tstamp, ClassLoader ldr, - Collection>> clss, @Nullable String md5) { - assert uri != null; - assert file != null; - assert tstamp > 0; - - // To avoid units with incorrect timestamp. - tstamp = Math.min(tstamp, U.currentTimeMillis()); - - // Create descriptor. - GridUriDeploymentUnitDescriptor desc = new GridUriDeploymentUnitDescriptor(uri, file, tstamp, ldr, md5); - - newUnitReceived(desc, clss != null && !clss.isEmpty() ? new ArrayList>(clss) : null); - } - - /** - * Removes all tasks that belong to package files which are on list - * of removed files. - * - * @param uris List of removed files. - */ - @SuppressWarnings({"TypeMayBeWeakened"}) - private void processDeletedFiles(List uris) { - assert uris != null; - - if (uris.isEmpty()) - return; - - synchronized (mux) { - Set uriSet = new HashSet<>(uris); - - for (Iterator iter = unitLoaders.iterator(); iter.hasNext();) { - GridUriDeploymentUnitDescriptor desc = iter.next(); - - if (desc.getType() == GridUriDeploymentUnitDescriptor.Type.FILE && uriSet.contains(desc.getUri())) { - // Remove descriptor. - iter.remove(); - - onUnitReleased(desc.getClassLoader()); - } - } - } - } - - /** - * Notifies listener about released class loader. - * - * @param clsLdr Released class loader. - */ - private void onUnitReleased(ClassLoader clsLdr) { - // Make sure we don't remove system class loader. - if (!clsLdr.equals(getClass().getClassLoader())) - GridUriDeploymentFileProcessor.cleanupUnit(clsLdr, log); - - DeploymentListener tmp = lsnr; - - if (tmp != null) - tmp.onUnregistered(clsLdr); - } - - /** - * Checks if a nut with the same md5 ai already deployed with this SPI. - * - * @param md5 md5 of a new unit. - * @return {@code true} if this unit deployed, {@code false} otherwise. - */ - private boolean unitDeployed(String md5) { - assert Thread.holdsLock(mux); - - if (md5 != null) { - for (GridUriDeploymentUnitDescriptor d: unitLoaders) - if (md5.equals(d.getMd5())) - return true; - } - - return false; - } - - /** - * Task deployment descriptor comparator. - * The greater descriptor is those one that has less timestamp. - */ - private static class LastTimeUnitDescriptorComparator implements Comparator, - Serializable { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override public int compare(GridUriDeploymentUnitDescriptor o1, GridUriDeploymentUnitDescriptor o2) { - if (o1.getTimestamp() < o2.getTimestamp()) - return 1; - - return o1.getTimestamp() == o2.getTimestamp() ? 0 : -1; - } - } - - /** {@inheritDoc} */ - @Override public IgniteSpiAdapter setName(String name) { - super.setName(name); - - return this; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(UriDeploymentSpi.class, this); - } - - /** - * MBean implementation for UriDeploymentSpi. - */ - private class UriDeploymentSpiMBeanImpl extends IgniteSpiMBeanAdapter implements UriDeploymentSpiMBean { - /** {@inheritDoc} */ - UriDeploymentSpiMBeanImpl(IgniteSpiAdapter spiAdapter) { - super(spiAdapter); - } - - /** {@inheritDoc} */ - @Override public String getTemporaryDirectoryPath() { - return UriDeploymentSpi.this.getTemporaryDirectoryPath(); - } - - /** {@inheritDoc} */ - @Override public List getUriList() { - return UriDeploymentSpi.this.getUriList(); - } - - /** {@inheritDoc} */ - @Override public boolean isCheckMd5() { - return UriDeploymentSpi.this.isCheckMd5(); - } - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpiMBean.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpiMBean.java deleted file mode 100644 index d1e599f1ee730..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpiMBean.java +++ /dev/null @@ -1,52 +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.spi.deployment.uri; - -import java.util.List; -import org.apache.ignite.mxbean.MXBeanDescription; -import org.apache.ignite.spi.IgniteSpiManagementMBean; - -/** - * Management bean for {@link UriDeploymentSpi}. - */ -@MXBeanDescription("MBean that provides access to URI deployment SPI configuration.") -public interface UriDeploymentSpiMBean extends IgniteSpiManagementMBean { - /** - * Gets temporary directory path. - * - * @return Temporary directory path. - */ - @MXBeanDescription("Temporary directory path.") - public String getTemporaryDirectoryPath(); - - /** - * Gets list of URIs that are processed by SPI. - * - * @return List of URIs. - */ - @MXBeanDescription("List of URIs.") - public List getUriList(); - - /** - * Indicates if this SPI should check new deployment units md5 for redundancy. - * - * @return if files are ckecked for redundancy. - */ - @MXBeanDescription("Indicates if MD5 check is enabled.") - public boolean isCheckMd5(); -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/package-info.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/package-info.java deleted file mode 100644 index 67330563b4c16..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/package-info.java +++ /dev/null @@ -1,23 +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. - */ - -/** - * - * Contains URI-based deployment SPI implementation. - */ - -package org.apache.ignite.spi.deployment.uri; diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/GridDeploymentFileHandler.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/GridDeploymentFileHandler.java deleted file mode 100644 index 7ee6dc97f9264..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/GridDeploymentFileHandler.java +++ /dev/null @@ -1,32 +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.spi.deployment.uri.scanners; - -import java.io.File; - -/** - * File handler interface. It somehow handles given file. - */ -public interface GridDeploymentFileHandler { - /** - * Processes given file. - * - * @param file File to be handled. - */ - public void handle(File file); -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/GridDeploymentFolderScannerHelper.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/GridDeploymentFolderScannerHelper.java deleted file mode 100644 index 3dabc75299677..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/GridDeploymentFolderScannerHelper.java +++ /dev/null @@ -1,55 +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.spi.deployment.uri.scanners; - -import java.io.File; -import java.io.FileFilter; - -/** - * Helper class that recursively goes through the list of - * files/directories and handles them by calling given handler. - */ -public final class GridDeploymentFolderScannerHelper { - /** - * Enforces singleton. - */ - private GridDeploymentFolderScannerHelper() { - // No-op. - } - - /** - * Applies given file to the handler if it is not filtered out by given - * filter. If given file is not accepted by filter and it is a directory - * than recursively scans directory and apply the same method for every - * found file. - * - * @param file File that should be handled. - * @param filter File filter. - * @param handler Handler which should handle files. - */ - public static void scanFolder(File file, FileFilter filter, GridDeploymentFileHandler handler) { - assert file != null; - - if (filter.accept(file)) - handler.handle(file); - else if (file.isDirectory()) { - for (File child : file.listFiles()) - scanFolder(child, filter, handler); - } - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/GridUriDeploymentScannerListener.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/GridUriDeploymentScannerListener.java deleted file mode 100644 index f815929b8abe9..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/GridUriDeploymentScannerListener.java +++ /dev/null @@ -1,54 +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.spi.deployment.uri.scanners; - -import java.io.File; -import java.util.EventListener; -import java.util.List; - -/** - * Scanner listener interface. Whatever deployment scanner is used - * (http, file and so on) following events happens: - *

    - *
  • {@code onNewOrUpdatedFile} - happens when new file has been found or updated.
  • - *
  • {@code onDeletedFiles} - happens when file(s) has been removed.
  • - *
  • {@code onFirstScanFinished} - happens when scanner completed its first scan.
  • - *
- */ -public interface GridUriDeploymentScannerListener extends EventListener { - /** - * Notifies about new file or those one that was updated. - * - * @param file New or updated file. - * @param uri File URI. - * @param tstamp File modification date. - */ - public void onNewOrUpdatedFile(File file, String uri, long tstamp); - - /** - * Notifies about removed files. - * - * @param uris List of removed files. - */ - public void onDeletedFiles(List uris); - - /** - * Notifies about first scan completion. - */ - public void onFirstScanFinished(); -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/UriDeploymentScanner.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/UriDeploymentScanner.java deleted file mode 100644 index 3e1e608484ba3..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/UriDeploymentScanner.java +++ /dev/null @@ -1,47 +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.spi.deployment.uri.scanners; - -import java.net.URI; - -/** - * URI deployment scanner. - */ -public interface UriDeploymentScanner { - /** - * Check whether scanner is able to process the given URI. - * - * @param uri URI. - * @return {@code true} if scanner is able to process the URI. - */ - boolean acceptsURI(URI uri); - - /** - * Scan the given URI. - * - * @param scanCtx Scan context. - */ - void scan(UriDeploymentScannerContext scanCtx); - - /** - * Gets default scan frequency in milliseconds. - * - * @return Default scan frequency. - */ - long getDefaultScanFrequency(); -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/UriDeploymentScannerContext.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/UriDeploymentScannerContext.java deleted file mode 100644 index cd1870cbb928e..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/UriDeploymentScannerContext.java +++ /dev/null @@ -1,92 +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.spi.deployment.uri.scanners; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.net.URI; -import org.apache.ignite.IgniteLogger; - -/** - * Deployment scanner context. - */ -public interface UriDeploymentScannerContext { - /** - * Creates temp file in temp directory. - * - * @param fileName File name. - * @param tmpDir dir to creating file. - * @return created file. - * @throws IOException if error occur. - */ - File createTempFile(String fileName, File tmpDir) throws IOException; - - /** - * Gets temporary deployment directory. - * - * @return Temporary deployment directory. - */ - File getDeployDirectory(); - - /** - * Gets filter for found files. Before listener is notified about - * changes with certain file last should be accepted by filter. - * - * @return New, updated or deleted file filter. - */ - FilenameFilter getFilter(); - - /** - * Gets deployment listener. - * - * @return Listener which should be notified about all deployment events - * by scanner. - */ - GridUriDeploymentScannerListener getListener(); - - /** - * Gets scanner logger. - * - * @return Logger. - */ - IgniteLogger getLogger(); - - /** - * Gets deployment URI. - * - * @return Deployment URI. - */ - URI getUri(); - - /** - * Tests whether scanner was cancelled before or not. - * - * @return {@code true} if scanner was cancelled and {@code false} - * otherwise. - */ - boolean isCancelled(); - - /** - * Tests whether first scan completed or not. - * - * @return {@code true} if first scan has been already completed and - * {@code false} otherwise. - */ - boolean isFirstScan(); -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/UriDeploymentScannerManager.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/UriDeploymentScannerManager.java deleted file mode 100644 index d4155f1e4ba15..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/UriDeploymentScannerManager.java +++ /dev/null @@ -1,226 +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.spi.deployment.uri.scanners; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.net.URI; -import org.apache.ignite.IgniteLogger; -import org.apache.ignite.internal.util.tostring.GridToStringExclude; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.IgniteSpiThread; - -/** - * URI deployment scanner manager. - */ -public class UriDeploymentScannerManager implements UriDeploymentScannerContext { - /** Ignite instance name. */ - private final String igniteInstanceName; - - /** URI that scanner should looks after. */ - @GridToStringExclude - private final URI uri; - - /** Temporary deployment directory. */ - private final File deployDir; - - /** Scan frequency. */ - private final long freq; - - /** Found files filter. */ - private final FilenameFilter filter; - - /** Scanner listener which should be notified about changes. */ - private final GridUriDeploymentScannerListener lsnr; - - /** Logger. */ - private final IgniteLogger log; - - /** Underlying scanner. */ - private final UriDeploymentScanner scanner; - - /** Scanner implementation. */ - private IgniteSpiThread scannerThread; - - /** Whether first scan completed or not. */ - private boolean firstScan = true; - - /** - * Creates new scanner. - * - * @param igniteInstanceName Ignite instance name. - * @param uri URI which scanner should looks after. - * @param deployDir Temporary deployment directory. - * @param freq Scan frequency. - * @param filter Found files filter. - * @param lsnr Scanner listener which should be notifier about changes. - * @param log Logger. - * @param scanner Scanner. - */ - public UriDeploymentScannerManager( - String igniteInstanceName, - URI uri, - File deployDir, - long freq, - FilenameFilter filter, - GridUriDeploymentScannerListener lsnr, - IgniteLogger log, - UriDeploymentScanner scanner) { - assert uri != null; - assert freq > 0; - assert deployDir != null; - assert filter != null; - assert log != null; - assert lsnr != null; - assert scanner != null; - - this.igniteInstanceName = igniteInstanceName; - this.uri = uri; - this.deployDir = deployDir; - this.freq = freq; - this.filter = filter; - this.log = log.getLogger(getClass()); - this.lsnr = lsnr; - this.scanner = scanner; - } - - /** - * Starts scanner. - */ - public void start() { - scannerThread = new IgniteSpiThread(igniteInstanceName, "grid-uri-scanner", log) { - /** {@inheritDoc} */ - @SuppressWarnings({"BusyWait"}) - @Override protected void body() throws InterruptedException { - try { - while (!isInterrupted()) { - try { - scanner.scan(UriDeploymentScannerManager.this); - } - catch (Exception e) { - log.error("Uncaught error in URI deployment scanner", e); - } - finally { - // Do it in finally to avoid any hanging. - if (firstScan) { - firstScan = false; - - lsnr.onFirstScanFinished(); - } - } - - Thread.sleep(freq); - } - } - finally { - // Double check. If we were cancelled before anything has been scanned. - if (firstScan) { - firstScan = false; - - lsnr.onFirstScanFinished(); - } - } - } - }; - - scannerThread.start(); - - if (log.isDebugEnabled()) - log.debug("Grid URI deployment scanner started: " + this); - } - - /** - * Cancels scanner execution. - */ - public void cancel() { - U.interrupt(scannerThread); - } - - /** - * Joins scanner thread. - */ - public void join() { - U.join(scannerThread, log); - - if (log.isDebugEnabled()) - log.debug("Grid URI deployment scanner stopped: " + this); - } - - /** {@inheritDoc} */ - @Override public boolean isCancelled() { - assert scannerThread != null; - - return scannerThread.isInterrupted(); - } - - /** {@inheritDoc} */ - @Override public File createTempFile(String fileName, File tmpDir) throws IOException { - assert fileName != null; - - int idx = fileName.lastIndexOf('.'); - - if (idx == -1) - idx = fileName.length(); - - String prefix = fileName.substring(0, idx); - if (idx < 3) { // Prefix must be at least 3 characters long. See File.createTempFile(...). - prefix += "___"; - } - - String suffix = fileName.substring(idx); - - return File.createTempFile(prefix, suffix, tmpDir); - } - - /** {@inheritDoc} */ - @Override public boolean isFirstScan() { - return firstScan; - } - - /** {@inheritDoc} */ - @Override public URI getUri() { - return uri; - } - - /** {@inheritDoc} */ - @Override public File getDeployDirectory() { - return deployDir; - } - - /** {@inheritDoc} */ - @Override public FilenameFilter getFilter() { - return filter; - } - - /** {@inheritDoc} */ - @Override public GridUriDeploymentScannerListener getListener() { - return lsnr; - } - - /** {@inheritDoc} */ - @Override public IgniteLogger getLogger() { - return log; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(UriDeploymentScannerManager.class, this, "uri", U.hidePassword(uri.toString())); - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/file/UriDeploymentFileScanner.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/file/UriDeploymentFileScanner.java deleted file mode 100644 index a908761aa3a85..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/file/UriDeploymentFileScanner.java +++ /dev/null @@ -1,337 +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.spi.deployment.uri.scanners.file; - -import java.io.File; -import java.io.FileFilter; -import java.io.IOException; -import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import org.apache.ignite.internal.util.lang.GridTuple; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.IgniteSpiException; -import org.apache.ignite.spi.deployment.uri.scanners.GridDeploymentFileHandler; -import org.apache.ignite.spi.deployment.uri.scanners.GridDeploymentFolderScannerHelper; -import org.apache.ignite.spi.deployment.uri.scanners.UriDeploymentScanner; -import org.apache.ignite.spi.deployment.uri.scanners.UriDeploymentScannerContext; - -/** - * URI deployment file scanner. - */ -public class UriDeploymentFileScanner implements UriDeploymentScanner { - /** Default scan frequency. */ - public static final int DFLT_SCAN_FREQ = 5000; - - /** Per-URI contexts. */ - private final ConcurrentHashMap uriCtxs = new ConcurrentHashMap<>(); - - /** {@inheritDoc} */ - @Override public boolean acceptsURI(URI uri) { - String proto = uri.getScheme().toLowerCase(); - - return "file".equals(proto); - } - - /** {@inheritDoc} */ - @Override public void scan(UriDeploymentScannerContext scanCtx) { - URI uri = scanCtx.getUri(); - - URIContext uriCtx = uriCtxs.get(uri); - - if (uriCtx == null) { - uriCtx = createUriContext(uri, scanCtx); - - URIContext oldUriCtx = uriCtxs.putIfAbsent(uri, uriCtx); - - if (oldUriCtx != null) - uriCtx = oldUriCtx; - } - - uriCtx.scan(scanCtx); - } - - /** {@inheritDoc} */ - @Override public long getDefaultScanFrequency() { - return DFLT_SCAN_FREQ; - } - - /** - * Create context for the given URI. - * - * @param uri URI. - * @param scanCtx Scanner context. - * @return URI context. - */ - private URIContext createUriContext(URI uri, final UriDeploymentScannerContext scanCtx) { - String scanDirPath = uri.getPath(); - - File scanDir = null; - - if (scanDirPath != null) - scanDir = new File(scanDirPath); - - if (scanDir == null || !scanDir.isDirectory()) - throw new IgniteSpiException("URI is either not provided or is not a directory: " + - U.hidePassword(uri.toString())); - - FileFilter pkgFilter = new FileFilter() { - /** {@inheritDoc} */ - @Override public boolean accept(File pathname) { - return scanCtx.getFilter().accept(null, pathname.getName()); - } - }; - - FileFilter pkgDirFilesFilter = new FileFilter() { - /** {@inheritDoc} */ - @Override public boolean accept(File pathname) { - // Allow all files in package. - return pathname.isFile(); - } - }; - - return new URIContext(scanDir, pkgFilter, pkgDirFilesFilter); - } - - /** - * Converts given file name to the URI with "file" scheme. - * - * @param name File name to be converted. - * @return File name with "file://" prefix. - */ - private static String getFileUri(String name) { - assert name != null; - - name = name.replace("\\", "/"); - - return "file://" + (name.charAt(0) == '/' ? "" : '/') + name; - } - - /** - * Context for the given URI. - */ - private static class URIContext { - /** Scanning directory or file. */ - private final File scanDir; - - /** Package filter. */ - private final FileFilter pkgFilter; - - /** Package directory files filter. */ - private final FileFilter pkgDirFilesFilter; - - /** Cache of found package files or directories to check if any of it has been updated. */ - private final Map tstampCache = new HashMap<>(); - - /** Cache of found files in a package to check if any of it has been updated. */ - private final Map> pkgDirFilesTstampCache = new HashMap<>(); - - /** - * Constructor. - * - * @param scanDir Scan directory. - * @param pkgFilter Package file filter. - * @param pkgDirFilesFilter Package directory files filter. - */ - private URIContext(File scanDir, FileFilter pkgFilter, FileFilter pkgDirFilesFilter) { - this.scanDir = scanDir; - this.pkgFilter = pkgFilter; - this.pkgDirFilesFilter = pkgDirFilesFilter; - } - - /** - * Perform scan. - * - * @param scanCtx Scan context. - */ - private void scan(final UriDeploymentScannerContext scanCtx) { - final Set foundFiles = scanCtx.isFirstScan() ? - new HashSet() : U.newHashSet(tstampCache.size()); - - GridDeploymentFileHandler hnd = new GridDeploymentFileHandler() { - /** {@inheritDoc} */ - @Override public void handle(File file) { - foundFiles.add(file); - - handleFile(file, scanCtx); - } - }; - - // Scan directory for deploy units. - GridDeploymentFolderScannerHelper.scanFolder(scanDir, pkgFilter, hnd); - - // Print warning if no packages found first time. - if (scanCtx.isFirstScan() && foundFiles.isEmpty()) - U.warn(scanCtx.getLogger(), "No packages found in: " + U.hidePassword(scanCtx.getUri().toString())); - - if (!scanCtx.isFirstScan()) { - Collection deletedFiles = new HashSet<>(tstampCache.keySet()); - - deletedFiles.removeAll(foundFiles); - - if (!deletedFiles.isEmpty()) { - List uris = new ArrayList<>(); - - for (File file : deletedFiles) { - uris.add(getFileUri(file.getAbsolutePath())); - } - - // Clear cache. - tstampCache.keySet().removeAll(deletedFiles); - - pkgDirFilesTstampCache.keySet().removeAll(deletedFiles); - - scanCtx.getListener().onDeletedFiles(uris); - } - } - } - - /** - * Tests whether given directory or file was changed since last check and if so - * copies all directory sub-folders and files or file itself to the deployment - * directory and than notifies listener about new or updated files. - * - * @param file Scanning directory or file. - * @param ctx Scanner context. - */ - private void handleFile(File file, UriDeploymentScannerContext ctx) { - boolean changed; - - Long lastMod; - - if (file.isDirectory()) { - GridTuple dirLastModified = F.t(file.lastModified()); - - changed = checkPackageDirectoryChanged(file, dirLastModified); - - lastMod = dirLastModified.get(); - } - else { - lastMod = tstampCache.get(file); - - changed = lastMod == null || lastMod != file.lastModified(); - - lastMod = file.lastModified(); - } - - // If file is new or has been modified. - if (changed) { - tstampCache.put(file, lastMod); - - if (ctx.getLogger().isDebugEnabled()) - ctx.getLogger().debug("Discovered deployment file or directory: " + file); - - String fileName = file.getName(); - - try { - File cpFile = ctx.createTempFile(fileName, ctx.getDeployDirectory()); - - // Delete file when JVM stopped. - cpFile.deleteOnExit(); - - if (file.isDirectory()) { - cpFile = new File(cpFile.getParent(), "dir_" + cpFile.getName()); - - // Delete directory when JVM stopped. - cpFile.deleteOnExit(); - } - - // Copy file to deploy directory. - U.copy(file, cpFile, true); - - String fileUri = getFileUri(file.getAbsolutePath()); - - assert lastMod != null; - - ctx.getListener().onNewOrUpdatedFile(cpFile, fileUri, lastMod); - } - catch (IOException e) { - U.error(ctx.getLogger(), "Error saving file: " + fileName, e); - } - } - } - - /** - * Tests whether certain directory was changed since given modification date. - * It scans all directory files one by one and compares their modification - * dates with those ones that was collected before. - *

- * If at least one file was changed (has modification date after given one) - * whole directory is considered as modified. - * - * @param dir Scanning directory. - * @param lastModified Last calculated Directory modification date. - * @return {@code true} if directory was changed since last check and - * {@code false} otherwise. - */ - @SuppressWarnings("ConstantConditions") - private boolean checkPackageDirectoryChanged(File dir, final GridTuple lastModified) { - final Map clssTstampCache; - - boolean firstScan = false; - - if (!pkgDirFilesTstampCache.containsKey(dir)) { - firstScan = true; - - pkgDirFilesTstampCache.put(dir, clssTstampCache = new HashMap<>()); - } - else - clssTstampCache = pkgDirFilesTstampCache.get(dir); - - assert clssTstampCache != null; - - final GridTuple changed = F.t(false); - - final Set foundFiles = firstScan ? new HashSet() : U.newHashSet(clssTstampCache.size()); - - GridDeploymentFileHandler hnd = new GridDeploymentFileHandler() { - @Override public void handle(File file) { - foundFiles.add(file); - - Long fileLastModified = clssTstampCache.get(file); - - if (fileLastModified == null || fileLastModified != file.lastModified()) { - clssTstampCache.put(file, fileLastModified = file.lastModified()); - - changed.set(true); - } - - // Calculate last modified file in folder. - if (fileLastModified > lastModified.get()) - lastModified.set(fileLastModified); - } - }; - - // Scan package for changes. - GridDeploymentFolderScannerHelper.scanFolder(dir, pkgDirFilesFilter, hnd); - - // Clear cache for deleted files. - if (!firstScan && clssTstampCache.keySet().retainAll(foundFiles)) - changed.set(true); - - return changed.get(); - } - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/file/package-info.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/file/package-info.java deleted file mode 100644 index 3096e41f69691..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/file/package-info.java +++ /dev/null @@ -1,23 +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. - */ - -/** - * - * Contains directory scanner for URI deployer SPI. - */ - -package org.apache.ignite.spi.deployment.uri.scanners.file; diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/UriDeploymentHttpScanner.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/UriDeploymentHttpScanner.java deleted file mode 100644 index bfb7a41994dd4..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/UriDeploymentHttpScanner.java +++ /dev/null @@ -1,507 +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.spi.deployment.uri.scanners.http; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.ConnectException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; -import java.net.URLConnection; -import java.net.UnknownHostException; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.internal.util.typedef.internal.LT; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.IgniteSpiException; -import org.apache.ignite.spi.deployment.uri.scanners.UriDeploymentScanner; -import org.apache.ignite.spi.deployment.uri.scanners.UriDeploymentScannerContext; -import org.jetbrains.annotations.Nullable; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.w3c.tidy.Tidy; - -/** - * HTTP-based URI deployment scanner. - *

- * This scanner reads DOM of the HTML available via {@link UriDeploymentScannerContext#getUri()} - * and parses out href attributes of all {@code <a>} tags - - * they become the collection of URLs to GAR files that should be deployed. - */ -public class UriDeploymentHttpScanner implements UriDeploymentScanner { - /** Default scan frequency. */ - public static final int DFLT_SCAN_FREQ = 300000; - - /** Secure socket protocol to use. */ - private static final String PROTOCOL = "TLS"; - - /** Per-URI contexts. */ - private final ConcurrentHashMap uriCtxs = new ConcurrentHashMap<>(); - - /** {@inheritDoc} */ - @Override public boolean acceptsURI(URI uri) { - String proto = uri.getScheme().toLowerCase(); - - return "http".equals(proto) || "https".equals(proto); - } - - /** {@inheritDoc} */ - @Override public void scan(UriDeploymentScannerContext scanCtx) { - URI uri = scanCtx.getUri(); - - URIContext uriCtx = uriCtxs.get(uri); - - if (uriCtx == null) { - uriCtx = createUriContext(uri, scanCtx); - - URIContext oldUriCtx = uriCtxs.putIfAbsent(uri, uriCtx); - - if (oldUriCtx != null) - uriCtx = oldUriCtx; - } - - uriCtx.scan(scanCtx); - } - - /** - * Create context for the given URI. - * - * @param uri URI. - * @param scanCtx Scanner context. - * @return URI context. - */ - private URIContext createUriContext(URI uri, final UriDeploymentScannerContext scanCtx) { - assert "http".equals(uri.getScheme()) || "https".equals(uri.getScheme()); - - URL scanDir; - - try { - scanDir = new URL(uri.getScheme(), uri.getHost(), uri.getPort(), uri.getPath()); - } - catch (MalformedURLException e) { - throw new IgniteSpiException("Wrong value for scanned HTTP directory with URI: " + uri, e); - } - - SSLSocketFactory sockFactory = null; - - try { - if ("https".equals(uri.getScheme())) { - // Set up socket factory to do authentication. - SSLContext ctx = SSLContext.getInstance(PROTOCOL); - - ctx.init(null, getTrustManagers(scanCtx), null); - - sockFactory = ctx.getSocketFactory(); - } - } - catch (NoSuchAlgorithmException e) { - throw new IgniteSpiException("Failed to initialize SSL context. URI: " + uri, e); - } - catch (KeyManagementException e) { - throw new IgniteSpiException("Failed to initialize SSL context. URI:" + uri, e); - } - - return new URIContext(scanDir, sockFactory); - } - - /** {@inheritDoc} */ - @Override public long getDefaultScanFrequency() { - return DFLT_SCAN_FREQ; - } - - /** - * Construct array with one trust manager which don't reject input certificates. - * - * @param scanCtx context. - * @return Array with one X509TrustManager implementation of trust manager. - */ - private static TrustManager[] getTrustManagers(final UriDeploymentScannerContext scanCtx) { - return new TrustManager[]{ - new X509TrustManager() { - /** {@inheritDoc} */ - @Nullable @Override public X509Certificate[] getAcceptedIssuers() { - return null; - } - - /** {@inheritDoc} */ - @Override public void checkClientTrusted(X509Certificate[] certs, String authType) { - StringBuilder buf = new StringBuilder(); - - buf.append("Trust manager handle client certificates [authType="); - buf.append(authType); - buf.append(", certificates="); - - for (X509Certificate cert : certs) { - buf.append("{type="); - buf.append(cert.getType()); - buf.append(", principalName="); - buf.append(cert.getSubjectX500Principal().getName()); - buf.append('}'); - } - - buf.append(']'); - - if (scanCtx.getLogger().isDebugEnabled()) - scanCtx.getLogger().debug(buf.toString()); - } - - /** {@inheritDoc} */ - @Override public void checkServerTrusted(X509Certificate[] certs, String authType) { - StringBuilder buf = new StringBuilder(); - - buf.append("Trust manager handle server certificates [authType="); - buf.append(authType); - buf.append(", certificates="); - - for (X509Certificate cert : certs) { - buf.append("{type="); - buf.append(cert.getType()); - buf.append(", principalName="); - buf.append(cert.getSubjectX500Principal().getName()); - buf.append('}'); - } - - buf.append(']'); - - if (scanCtx.getLogger().isDebugEnabled()) - scanCtx.getLogger().debug(buf.toString()); - } - } - }; - } - - /** - * URI context. - */ - private class URIContext { - /** */ - private final URL scanDir; - - /** Outgoing data SSL socket factory. */ - private final SSLSocketFactory sockFactory; - - /** */ - private final Tidy tidy; - - /** Cache of found files to check if any of it has been updated. */ - private final Map tstampCache = new HashMap<>(); - - /** - * Constructor. - * - * @param scanDir Scan directory. - * @param sockFactory Socket factory. - */ - public URIContext(URL scanDir, SSLSocketFactory sockFactory) { - this.scanDir = scanDir; - this.sockFactory = sockFactory; - - tidy = new Tidy(); - - tidy.setQuiet(true); - tidy.setOnlyErrors(true); - tidy.setShowWarnings(false); - tidy.setInputEncoding("UTF8"); - tidy.setOutputEncoding("UTF8"); - } - - /** - * Perform scan. - * - * @param scanCtx Scan context. - */ - private void scan(UriDeploymentScannerContext scanCtx) { - Collection foundFiles = U.newHashSet(tstampCache.size()); - - long start = U.currentTimeMillis(); - - processHttp(foundFiles, scanCtx); - - if (scanCtx.getLogger().isDebugEnabled()) - scanCtx.getLogger().debug("HTTP scanner time in ms: " + (U.currentTimeMillis() - start)); - - if (!scanCtx.isFirstScan()) { - Collection deletedFiles = new HashSet<>(tstampCache.keySet()); - - deletedFiles.removeAll(foundFiles); - - if (!deletedFiles.isEmpty()) { - List uris = new ArrayList<>(); - - for (String file : deletedFiles) - uris.add(getFileUri(fileName(file), scanCtx)); - - tstampCache.keySet().removeAll(deletedFiles); - - scanCtx.getListener().onDeletedFiles(uris); - } - } - } - - /** - * @param files Files to process. - * @param scanCtx Scan context. - */ - private void processHttp(Collection files, UriDeploymentScannerContext scanCtx) { - Set urls = getUrls(scanDir, scanCtx); - - for (String url : urls) { - String fileName = fileName(url); - - if (scanCtx.getFilter().accept(null, fileName)) { - files.add(url); - - Long lastModified = tstampCache.get(url); - - InputStream in = null; - OutputStream out = null; - - File file = null; - - try { - URLConnection conn = new URL(url).openConnection(); - - if (conn instanceof HttpsURLConnection) { - HttpsURLConnection httpsConn = (HttpsURLConnection)conn; - - httpsConn.setHostnameVerifier(new DeploymentHostnameVerifier()); - - assert sockFactory != null; - - // Initialize socket factory. - httpsConn.setSSLSocketFactory(sockFactory); - } - - if (lastModified != null) - conn.setIfModifiedSince(lastModified); - - in = conn.getInputStream(); - - long rcvLastModified = conn.getLastModified(); - - if (in == null || lastModified != null && (lastModified == rcvLastModified || - conn instanceof HttpURLConnection && - ((HttpURLConnection)conn).getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED)) - continue; - - tstampCache.put(url, rcvLastModified); - - lastModified = rcvLastModified; - - if (scanCtx.getLogger().isDebugEnabled()) { - scanCtx.getLogger().debug("Discovered deployment file or directory: " + - U.hidePassword(url)); - } - - file = scanCtx.createTempFile(fileName, scanCtx.getDeployDirectory()); - - // Delete file when JVM stopped. - file.deleteOnExit(); - - out = new FileOutputStream(file); - - U.copy(in, out); - } - catch (IOException e) { - if (!scanCtx.isCancelled()) { - if (X.hasCause(e, ConnectException.class)) { - LT.error(scanCtx.getLogger(), e, "Failed to connect to HTTP server " + - "(connection refused): " + U.hidePassword(url)); - } - else if (X.hasCause(e, UnknownHostException.class)) { - LT.error(scanCtx.getLogger(), e, "Failed to connect to HTTP server " + - "(host is unknown): " + U.hidePassword(url)); - } - else - U.error(scanCtx.getLogger(), "Failed to save file: " + fileName, e); - } - } - finally { - U.closeQuiet(in); - U.closeQuiet(out); - } - - if (file != null && file.exists() && file.length() > 0) - scanCtx.getListener().onNewOrUpdatedFile(file, getFileUri(fileName, scanCtx), lastModified); - } - } - } - - /** - * @param url Base URL. - * @param scanCtx Scan context. - * @return Set of referenced URLs in string format. - */ - private Set getUrls(URL url, UriDeploymentScannerContext scanCtx) { - assert url != null; - - InputStream in = null; - - Set urls = new HashSet<>(); - - Document dom = null; - - try { - URLConnection conn = url.openConnection(); - - if (conn instanceof HttpsURLConnection) { - HttpsURLConnection httpsConn = (HttpsURLConnection)conn; - - httpsConn.setHostnameVerifier(new DeploymentHostnameVerifier()); - - assert sockFactory != null; - - // Initialize socket factory. - httpsConn.setSSLSocketFactory(sockFactory); - } - - in = conn.getInputStream(); - - if (in == null) - throw new IOException("Failed to open connection: " + U.hidePassword(url.toString())); - - dom = tidy.parseDOM(in, null); - } - catch (IOException e) { - if (!scanCtx.isCancelled()) { - if (X.hasCause(e, ConnectException.class)) { - LT.error(scanCtx.getLogger(), e, "Failed to connect to HTTP server (connection refused): " + - U.hidePassword(url.toString())); - } - else if (X.hasCause(e, UnknownHostException.class)) { - LT.error(scanCtx.getLogger(), e, "Failed to connect to HTTP server (host is unknown): " + - U.hidePassword(url.toString())); - } - else - U.error(scanCtx.getLogger(), "Failed to get HTML page: " + U.hidePassword(url.toString()), e); - } - } - finally { - U.closeQuiet(in); - } - - if (dom != null) - findReferences(dom, urls, url, scanCtx); - - return urls; - } - - /** - * @param node XML element node. - * @param res Set of URLs in string format to populate. - * @param baseUrl Base URL. - * @param scanCtx Scan context. - */ - @SuppressWarnings( {"UnnecessaryFullyQualifiedName"}) - private void findReferences(org.w3c.dom.Node node, Set res, URL baseUrl, - UriDeploymentScannerContext scanCtx) { - if (node instanceof Element && "a".equals(node.getNodeName().toLowerCase())) { - Element element = (Element)node; - - String href = element.getAttribute("href"); - - if (href != null && !href.isEmpty()) { - URL url = null; - - try { - url = new URL(href); - } - catch (MalformedURLException e) { - try { - url = new URL(baseUrl.getProtocol(), baseUrl.getHost(), baseUrl.getPort(), - href.charAt(0) == '/' ? href : baseUrl.getFile() + '/' + href); - } - catch (MalformedURLException e1) { - U.error(scanCtx.getLogger(), "Skipping bad URL: " + href, e1); - } - } - - if (url != null) - res.add(url.toString()); - } - } - - NodeList childNodes = node.getChildNodes(); - - for (int i = 0; i < childNodes.getLength(); i++) - findReferences(childNodes.item(i), res, baseUrl, scanCtx); - } - - /** - * @param url Base URL string format. - * @return File name extracted from {@code url} string format. - */ - private String fileName(String url) { - assert url != null; - - return url.substring(url.lastIndexOf('/') + 1); - } - - /** - * Gets file URI for the given file name. It extends any given name with {@code URI}. - * - * @param name File name. - * @param scanCtx Scan context. - * @return URI for the given file name. - */ - private String getFileUri(String name, UriDeploymentScannerContext scanCtx) { - assert name != null; - - String fileUri = scanCtx.getUri().toString(); - - fileUri = fileUri.length() > 0 && fileUri.charAt(fileUri.length() - 1) == '/' ? fileUri + name : - fileUri + '/' + name; - - return fileUri; - } - } - - /** - * Verifier always return successful result for any host. - */ - private static class DeploymentHostnameVerifier implements HostnameVerifier { - /** {@inheritDoc} */ - @Override public boolean verify(String hostname, SSLSession ses) { - // Remote host trusted by default. - return true; - } - } -} diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/package-info.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/package-info.java deleted file mode 100644 index 041c1d440d02d..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/package-info.java +++ /dev/null @@ -1,23 +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. - */ - -/** - * - * Contains HTTP scanner for URI deployer SPI. - */ - -package org.apache.ignite.spi.deployment.uri.scanners.http; diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/package-info.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/package-info.java deleted file mode 100644 index bd7843ac73632..0000000000000 --- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/package-info.java +++ /dev/null @@ -1,23 +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. - */ - -/** - * - * Contains common classes for URI deployment scanners. - */ - -package org.apache.ignite.spi.deployment.uri.scanners; diff --git a/modules/urideploy/src/test/java/org/apache/ignite/internal/GridTaskUriDeploymentDeadlockSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/internal/GridTaskUriDeploymentDeadlockSelfTest.java deleted file mode 100644 index c672a56394655..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/internal/GridTaskUriDeploymentDeadlockSelfTest.java +++ /dev/null @@ -1,105 +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.internal; - -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; -import org.apache.ignite.Ignite; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.events.Event; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.deployment.uri.UriDeploymentSpi; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; - -import static java.util.concurrent.TimeUnit.SECONDS; -import static org.apache.ignite.events.EventType.EVT_NODE_JOINED; - -/** - * Test to reproduce gg-2852. - */ -public class GridTaskUriDeploymentDeadlockSelfTest extends GridCommonAbstractTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - - UriDeploymentSpi deploymentSpi = new UriDeploymentSpi(); - - deploymentSpi.setUriList( - Arrays.asList(U.resolveIgniteUrl("modules/extdata/uri/target/resources/").toURI().toString())); - - if (igniteInstanceName.endsWith("2")) { - // Delay deployment for 2nd grid only. - Field f = deploymentSpi.getClass().getDeclaredField("delayOnNewOrUpdatedFile"); - - f.setAccessible(true); - - f.set(deploymentSpi, true); - } - - c.setDeploymentSpi(deploymentSpi); - - return c; - } - - /** - * @throws Exception If failed. - */ - @Test - public void testDeadlock() throws Exception { - try { - Ignite g = startGrid(1); - - final CountDownLatch latch = new CountDownLatch(1); - - g.events().localListen(new IgnitePredicate() { - @Override public boolean apply(Event evt) { - assert evt.type() == EVT_NODE_JOINED; - - latch.countDown(); - - return true; - } - }, EVT_NODE_JOINED); - - IgniteInternalFuture f = multithreadedAsync(new Callable() { - @Override public Object call() throws Exception { - startGrid(2); - - return null; - } - }, 1); - - assert latch.await(5, SECONDS); - - info(">>> Starting task."); - - assert "2".equals(executeAsync(compute(g.cluster().forPredicate(n -> n.equals(F.first(g.cluster().forRemotes().nodes())))), - "GarHelloWorldTask", "HELLOWORLD.MSG").get(60000)); - - f.get(); - } - finally { - stopAllGrids(); - } - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/internal/UriDeploymentAbsentProcessorClassTest.java b/modules/urideploy/src/test/java/org/apache/ignite/internal/UriDeploymentAbsentProcessorClassTest.java deleted file mode 100644 index a63946ae57aa9..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/internal/UriDeploymentAbsentProcessorClassTest.java +++ /dev/null @@ -1,117 +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.internal; - -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Collections; -import javax.cache.processor.EntryProcessor; -import org.apache.ignite.Ignite; -import org.apache.ignite.configuration.DeploymentMode; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.marshaller.optimized.OptimizedMarshallerInaccessibleClassException; -import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.spi.deployment.uri.UriDeploymentSpi; -import org.apache.ignite.testframework.GridTestExternalClassLoader; -import org.apache.ignite.testframework.config.GridTestProperties; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.Test; - -/** */ -public class UriDeploymentAbsentProcessorClassTest extends GridCommonAbstractTest { - /** */ - private static final String RUN_CLS = "org.apache.ignite.tests.p2p.compute.ExternalEntryProcessor"; - - /** */ - private Path file; - - /** */ - private Object retVal; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - UriDeploymentSpi spi = new UriDeploymentSpi(); - - file = Files.createTempDirectory(getClass().getName()); - - spi.setUriList(Collections.singletonList(file.toUri().toString())); - - return super.getConfiguration(igniteInstanceName) - .setPeerClassLoadingEnabled(false) - .setDeploymentSpi(spi) - .setDeploymentMode(DeploymentMode.SHARED); - } - - /** - * Starts server node with URI deployment of empty directory. - * Starts client node. - * In a separate thread, load entry processor from p2p class loader. - * Try to invoke it on server node, catch expected exception. - * Check that server node is operational after. - * - * @throws Exception if failed. - */ - @Test - public void test() throws Exception { - try { - startGrid(1); - - final Ignite ignite2 = startClientGrid(2); - - Thread thread = new Thread(() -> { - try { - ClassLoader cl = new GridTestExternalClassLoader(new URL[] { - new URL(GridTestProperties.getProperty("p2p.uri.cls")) }); - - Thread.currentThread().setContextClassLoader(cl); - - Class cls = cl.loadClass(RUN_CLS); - - EntryProcessor proc = (EntryProcessor)cls.newInstance(); - - retVal = ignite2.getOrCreateCache(DEFAULT_CACHE_NAME).invoke(0, proc); - } - catch (Exception ex) { - if (X.hasCause(ex, "Failed to find class with given class loader for unmarshalling", - OptimizedMarshallerInaccessibleClassException.class)) { - ignite2.log().warning("Caught expected exception", ex); - - retVal = 0; - } - else - throw new RuntimeException(ex); - } - }); - - thread.start(); - - thread.join(); - - assertEquals(0, retVal); - - assertEquals(0, grid(1).cache(DEFAULT_CACHE_NAME).size()); - } - finally { - stopAllGrids(); - - if (file != null) - file.toFile().delete(); - } - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/p2p/GridP2PDisabledSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/p2p/GridP2PDisabledSelfTest.java deleted file mode 100644 index 08a2b92811401..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/p2p/GridP2PDisabledSelfTest.java +++ /dev/null @@ -1,218 +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.p2p; - -import java.io.File; -import java.io.IOException; -import java.util.Collections; -import java.util.UUID; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteException; -import org.apache.ignite.configuration.DeploymentMode; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.deployment.uri.UriDeploymentSpi; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.apache.ignite.testframework.junits.common.GridCommonTest; -import org.junit.Test; - -/** - * Test what happens if peer class loading is disabled. - *

- * In order for this test to run, make sure that your - * {@code p2p.uri.cls} folder ends with {@code .gar} extension. - */ -@SuppressWarnings({"ProhibitedExceptionDeclared"}) -@GridCommonTest(group = "P2P") -public class GridP2PDisabledSelfTest extends GridCommonAbstractTest { - /** Task name. */ - private static final String TASK_NAME = "org.apache.ignite.tests.p2p.P2PTestTaskExternalPath1"; - - /** External class loader. */ - private static ClassLoader extLdr; - - /** Current deployment mode. Used in {@link #getConfiguration(String)}. */ - private DeploymentMode depMode; - - /** */ - private boolean initGar; - - /** Path to GAR file. */ - private String garFile; - - /** - * - */ - public GridP2PDisabledSelfTest() { - super(/*start grid*/false); - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - extLdr = getExternalClassLoader(); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - cfg.setPeerClassLoadingEnabled(false); - - cfg.setDeploymentMode(depMode); - - if (initGar) { - UriDeploymentSpi depSpi = new UriDeploymentSpi(); - - depSpi.setUriList(Collections.singletonList(garFile)); - - cfg.setDeploymentSpi(depSpi); - } - - cfg.setMetricsUpdateFrequency(500); - - return cfg; - } - - /** - * Test what happens if peer class loading is disabled. - * - * @throws Exception if error occur. - */ - @SuppressWarnings("unchecked") - private void checkClassNotFound() throws Exception { - initGar = false; - - try { - Ignite ignite1 = startGrid(1); - Ignite ignite2 = startGrid(2); - - Class task = extLdr.loadClass(TASK_NAME); - - try { - ignite1.compute().execute(task, ignite2.cluster().localNode().id()); - - assert false; - } - catch (IgniteException e) { - info("Received expected exception: " + e); - } - } - finally { - stopGrid(1); - stopGrid(2); - } - } - - /** - * @throws Exception if error occur. - */ - private void checkGar() throws Exception { - initGar = true; - - String garDir = "modules/extdata/p2p/target/deploy"; - String garFileName = "p2p.gar"; - - File origGarPath = U.resolveIgnitePath(garDir + '/' + garFileName); - - File tmpPath = new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); - - if (!tmpPath.mkdir()) - throw new IOException("Can not create temp directory"); - - try { - File newGarFile = new File(tmpPath, garFileName); - - U.copy(origGarPath, newGarFile, false); - - assert newGarFile.exists(); - - try { - garFile = "file:///" + tmpPath.getAbsolutePath(); - - try { - Ignite ignite1 = startGrid(1); - Ignite ignite2 = startGrid(2); - - Integer res = ignite1.compute().execute(TASK_NAME, ignite2.cluster().localNode().id()); - - assert res != null; - } - finally { - stopGrid(1); - stopGrid(2); - } - } - finally { - if (newGarFile != null && !newGarFile.delete()) - error("Can not delete temp gar file"); - } - } - finally { - if (!tmpPath.delete()) - error("Can not delete temp directory"); - } - } - - /** - * Test GridDeploymentMode.ISOLATED mode. - * - * @throws Exception if error occur. - */ - @Test - public void testGarPrivateMode() throws Exception { - depMode = DeploymentMode.PRIVATE; - - checkGar(); - } - - /** - * Test GridDeploymentMode.ISOLATED mode. - * - * @throws Exception if error occur. - */ - @Test - public void testGarIsolatedMode() throws Exception { - depMode = DeploymentMode.ISOLATED; - - checkGar(); - } - - /** - * Test GridDeploymentMode.CONTINUOUS mode. - * - * @throws Exception if error occur. - */ - @Test - public void testGarContinuousMode() throws Exception { - depMode = DeploymentMode.CONTINUOUS; - - checkGar(); - } - - /** - * Test GridDeploymentMode.SHARED mode. - * - * @throws Exception if error occur. - */ - @Test - public void testGarSharedMode() throws Exception { - depMode = DeploymentMode.SHARED; - - checkGar(); - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentAbstractSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentAbstractSelfTest.java deleted file mode 100644 index 603297785a950..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentAbstractSelfTest.java +++ /dev/null @@ -1,106 +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.spi.deployment.uri; - -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.util.lang.GridAbsPredicateX; -import org.apache.ignite.spi.deployment.DeploymentListener; -import org.apache.ignite.spi.deployment.DeploymentResource; -import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.config.GridTestProperties; -import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; -import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; - -/** - * - */ -public abstract class GridUriDeploymentAbstractSelfTest extends GridSpiAbstractTest { - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - getSpi().setListener(null); - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - getSpi().setListener(new DeploymentListener() { - @Override public void onUnregistered(ClassLoader ldr) { - // No-op. - } - }); - } - - /** - * @return Temporary directory to be used in test. - */ - @GridSpiTestConfig - public String getTemporaryDirectoryPath() { - String path = GridTestProperties.getProperty("deploy.uri.tmpdir"); - - assert path != null; - - return path; - } - - /** - * @param taskName Name of available task. - * @throws Exception if failed. - */ - protected void checkTask(String taskName) throws Exception { - assert taskName != null; - - DeploymentResource task = getSpi().findResource(taskName); - - assert task != null; - - info("Deployed task [task=" + task + ']'); - } - - /** - * @param taskName name of unavailable task. - * @throws Exception if failed. - */ - protected void checkNoTask(String taskName) throws Exception { - assert taskName != null; - - DeploymentResource task = getSpi().findResource(taskName); - - assert task == null; - - info("Not deployed task [task=" + task + ']'); - } - - /** - * @param taskName name of task to wait on. - * @param expectDeployed if {@code true}, wait for availability, else wait for unavailability. - * @param timeout in ms. - * @throws Exception if failed. - */ - protected void waitForTask(String taskName, boolean expectDeployed, long timeout) throws IgniteCheckedException { - assertTrue("Failed to wait for (un)deployment of " + taskName, - GridTestUtils.waitForCondition(new GridAbsPredicateX() { - @Override public boolean applyx() throws IgniteCheckedException { - if (expectDeployed) - return getSpi().findResource(taskName) != null; - else - return getSpi().findResource(taskName) == null; - } - }, timeout)); - - info((expectDeployed ? "Deployed" : "Not deployed") + " task [task=" + taskName + ']'); - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderMultiThreadedSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderMultiThreadedSelfTest.java deleted file mode 100644 index 4ea79908b176a..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderMultiThreadedSelfTest.java +++ /dev/null @@ -1,75 +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.spi.deployment.uri; - -import java.net.URL; -import java.util.concurrent.Callable; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.testframework.config.GridTestProperties; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.jetbrains.annotations.Nullable; -import org.junit.Test; - -/** - * Grid URI deployment class loader self test. - */ -public class GridUriDeploymentClassLoaderMultiThreadedSelfTest extends GridCommonAbstractTest { - /** - * @throws Exception If failed. - */ - @Test - public void testMultiThreadedClassLoading() throws Exception { - for (int i = 0; i < 50; i++) - doTest(); - } - - /** - * @throws Exception If failed. - */ - private void doTest() throws Exception { - final GridUriDeploymentClassLoader ldr = new GridUriDeploymentClassLoader( - new URL[] { U.resolveIgniteUrl(GridTestProperties.getProperty("ant.urideployment.gar.file")) }, - getClass().getClassLoader()); - - multithreaded( - new Callable() { - @Nullable @Override public Object call() throws Exception { - ldr.loadClass("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask0"); - - return null; - } - }, - 500 - ); - - final GridUriDeploymentClassLoader ldr0 = new GridUriDeploymentClassLoader( - new URL[] { U.resolveIgniteUrl(GridTestProperties.getProperty("ant.urideployment.gar.file")) }, - getClass().getClassLoader()); - - multithreaded( - new Callable() { - @Nullable @Override public Object call() throws Exception { - ldr0.loadClassIsolated("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask0"); - - return null; - } - }, - 500 - ); - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderSelfTest.java deleted file mode 100644 index 522bc60c716bb..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderSelfTest.java +++ /dev/null @@ -1,79 +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.spi.deployment.uri; - -import java.net.URL; -import java.util.Collections; -import java.util.List; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.deployment.DeploymentResource; -import org.apache.ignite.testframework.config.GridTestProperties; -import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; -import org.junit.Test; - -/** - * Grid URI deployment class loader test. - */ -@GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") -public class GridUriDeploymentClassLoaderSelfTest extends GridUriDeploymentAbstractSelfTest { - /** - * @throws Exception If failed. - */ - @Test - public void testNestedJarClassloading() throws Exception { - ClassLoader ldr = getGarClassLoader(); - - // Load class from nested JAR file - assert ldr.loadClass("javax.mail.Service") != null; - } - - /** - * @throws Exception If failed. - */ - @Test - public void testClasspathResourceLoading() throws Exception { - ClassLoader ldr = getGarClassLoader(); - - // Get resource from GAR file - URL rsrcUrl = ldr.getResource("org/apache/ignite/test/test.properties"); - - assert rsrcUrl != null; - } - - /** - * @return Test GAR's class loader - * @throws Exception if test GAR wasn't deployed - */ - private ClassLoader getGarClassLoader() throws Exception { - DeploymentResource task = getSpi().findResource("GridUriDeploymentTestWithNameTask7"); - - assert task != null; - - return task.getClassLoader(); - } - - /** - * @return List of URIs to use in this test. - */ - @GridSpiTestConfig - public List getUriList() { - return Collections.singletonList(GridTestProperties.getProperty("ant.urideployment.gar.uri"). - replace("EXTDATA", U.resolveIgnitePath("modules/extdata").getAbsolutePath())); - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassloaderRegisterSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassloaderRegisterSelfTest.java deleted file mode 100644 index bc79242b10528..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassloaderRegisterSelfTest.java +++ /dev/null @@ -1,159 +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.spi.deployment.uri; - -import java.io.Serializable; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.apache.ignite.compute.ComputeJob; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.compute.ComputeTask; -import org.apache.ignite.compute.ComputeTaskSplitAdapter; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.deployment.DeploymentListener; -import org.apache.ignite.spi.deployment.DeploymentResource; -import org.apache.ignite.testframework.config.GridTestProperties; -import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; -import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; -import org.junit.Test; - -/** - * Test for classloader registering. - */ -@GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") -public class GridUriDeploymentClassloaderRegisterSelfTest extends GridSpiAbstractTest { - /** */ - private static Map>>> tasks = - Collections.synchronizedMap(new HashMap>>>()); - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - getSpi().setListener(null); - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - getSpi().setListener(new DeploymentListener() { - @Override public void onUnregistered(ClassLoader ldr) { - tasks.remove(ldr); - } - }); - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - tasks.clear(); - } - - /** - * @param taskCls Class to be deployed. - * @throws Exception if deployment failed. - */ - private void deploy(Class> taskCls) throws Exception { - getSpi().register(taskCls.getClassLoader(), taskCls); - - Set>> clss = new HashSet<>(1); - - clss.add(taskCls); - - tasks.put(taskCls.getClassLoader(), clss); - } - - /** - * @param taskCls Unavailable task class. - */ - private void checkUndeployed(Class> taskCls) { - assert !tasks.containsKey(taskCls.getClassLoader()); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testDeploy() throws Exception { - Class> task = GridFileDeploymentTestTask.class; - - deploy(task); - - DeploymentResource t1 = getSpi().findResource(task.getName()); - - assert t1 != null; - - DeploymentResource t2 = getSpi().findResource(task.getName()); - - assert t1.equals(t2); - assert t1.getResourceClass() == t2.getResourceClass(); - - getSpi().unregister(task.getName()); - - checkUndeployed(task); - - assert getSpi().findResource(task.getName()) == null; - } - - /** - * @throws Exception If failed. - */ - @Test - public void testRedeploy() throws Exception { - // Test non-versioned redeploy. - Class> t1 = GridFileDeploymentTestTask.class; - - deploy(t1); - - Class> t2 = GridFileDeploymentTestTask.class; - - deploy(t2); - - getSpi().unregister(t1.getName()); - - checkUndeployed(t1); - checkUndeployed(t2); - } - - /** - * @return List of URIs to use in this test. - */ - @GridSpiTestConfig - public List getUriList() { - // No real gar file is required. Add one just to avoid failure because of missed to default directory. - return Collections.singletonList(GridTestProperties.getProperty("ant.urideployment.gar.uri"). - replace("EXTDATA", U.resolveIgnitePath("modules/extdata").getAbsolutePath())); - } - - /** - * Do nothing task for test. - */ - private static class GridFileDeploymentTestTask extends ComputeTaskSplitAdapter { - /** {@inheritDoc} */ - @Override protected Collection split(int gridSize, Object arg) { - return null; - } - - /** {@inheritDoc} */ - @Override public Serializable reduce(List results) { - return null; - } - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentConfigSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentConfigSelfTest.java deleted file mode 100644 index f2a5d4c53fad3..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentConfigSelfTest.java +++ /dev/null @@ -1,76 +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.spi.deployment.uri; - -import java.io.File; -import java.util.Collections; - -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.testframework.config.GridTestProperties; -import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; -import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.junit.Test; - -/** - * - */ -@GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") -public class GridUriDeploymentConfigSelfTest extends GridSpiAbstractConfigTest { - /** - * @throws Exception If failed. - */ - @Test - public void testNegativeConfig() throws Exception { - checkNegativeSpiProperty(new UriDeploymentSpi(), "uriList", null); - checkNegativeSpiProperty(new UriDeploymentSpi(), "uriList", Collections.singletonList("qwertyuiop"), false); - checkNegativeSpiProperty(new UriDeploymentSpi(), "uriList", Collections.singletonList(null), false); - } - - /** - * Verifies that mixing LocalDeploymentSpi and UriDeploymentSpi doesn't violate configuration consistency rules. - * - * @throws Exception If failed. - */ - @Test - public void testClientSpiConsistencyChecked() throws Exception { - String srvName = "server"; - String clientName = "client"; - - IgniteConfiguration srvCfg = getConfiguration(); - - UriDeploymentSpi deploymentSpi = new UriDeploymentSpi(); - String tmpDir = GridTestProperties.getProperty("deploy.uri.tmpdir"); - File tmp = new File(tmpDir); - - if (!tmp.exists()) - tmp.mkdir(); - - deploymentSpi.setUriList(Collections.singletonList("file://" + tmpDir)); - srvCfg.setDeploymentSpi(deploymentSpi); - - try { - startGrid(srvName, srvCfg); - - IgniteConfiguration clientCfg = getConfiguration(); - startClientGrid(clientName, clientCfg); - } - finally { - stopAllGrids(); - } - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessorSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessorSelfTest.java deleted file mode 100644 index e36d81a0f2e24..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessorSelfTest.java +++ /dev/null @@ -1,167 +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.spi.deployment.uri; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.testframework.config.GridTestProperties; -import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; -import org.apache.ignite.util.antgar.IgniteDeploymentGarAntTask; -import org.apache.tools.ant.Project; -import org.junit.Test; - -/** - * - */ -@GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") -public class GridUriDeploymentFileProcessorSelfTest extends GridUriDeploymentAbstractSelfTest { - /** - * @throws Exception If failed. - */ - @Test - public void testTaskCorrect() throws Exception { - proceedTest("correct.gar", "ignite.xml", - "org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask0", true); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testTaskWithBrokenXML() throws Exception { - proceedTest("broken.gar", "ignite.brokenxml", "brokenxml-task", false); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testTaskWithEmptyXML() throws Exception { - proceedTest("empty.gar", "ignite.empty", "emptyxml-task", false); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testTaskWithIncorrectRefsXML() throws Exception { - proceedTest("incorrefs.gar", "ignite.incorrefs", "incorrectref-task", false); - } - - /** - * @param garFileName Name of .gar file. - * @param garDescFileName Name of Ignite descriptor file. - * @param taskId Task id. - * @param deployed If {@code true} then givent task should be deployed after test, - * if {@code false} then it should be undeployed. - * @throws Exception If failed. - */ - private void proceedTest(String garFileName, String garDescFileName, final String taskId, final boolean deployed) - throws Exception { - info("This test checks broken tasks. All exceptions that might happen are the part of the test."); - - String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); - String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); - String baseDirName = tmpDirName + File.separator + System.currentTimeMillis(); - String metaDirName = baseDirName + File.separator + "META-INF"; - String garDescDirName = - U.resolveIgnitePath(GridTestProperties.getProperty("deploy.gar.descriptor.dir")) + - File.separator + garDescFileName; - - // Make base, META-INF and deployment dirs. - File destDir = new File(GridTestProperties.getProperty("deploy.uri.file2.path")); - - if (!destDir.exists()) { - boolean mkdir = destDir.mkdirs(); - - assert mkdir; - } - - boolean mkdir = new File(baseDirName).mkdirs(); - - assert mkdir; - - mkdir = new File(metaDirName).mkdirs(); - - assert mkdir; - - // Make Gar file - U.copy( new File(garDescDirName), new File(metaDirName + File.separator + "ignite.xml"), true); - - // Copy files to basedir - U.copy(new File(srcDirName), new File(baseDirName), true); - - File garFile = new File(baseDirName + File.separator + garFileName); - - IgniteDeploymentGarAntTask garTask = new IgniteDeploymentGarAntTask(); - - Project garProject = new Project(); - - garProject.setName("Gar test project"); - - garTask.setDestFile(garFile); - garTask.setBasedir(new File(baseDirName)); - garTask.setProject(garProject); - - garTask.execute(); - - assert garFile.exists(); - - // Copy to deployment directory. - U.copy(garFile, destDir, true); - - try { - // Wait for SPI - waitForTask(taskId, deployed, 5000); - - if (deployed) - assert getSpi().findResource(taskId) != null; - else - assert getSpi().findResource(taskId) == null; - } - finally { - U.delete(destDir); - - // Wait for SPI refresh - Thread.sleep(1000); - } - } - - /** - * @return List of URI to be used as deployment source. - */ - @GridSpiTestConfig - public List getUriList() { - File destDir = new File(GridTestProperties.getProperty("deploy.uri.file2.path")); - - if (!destDir.exists()) { - boolean mkdir = destDir.mkdirs(); - - assert mkdir; - } - - List uriList = new ArrayList<>(); - - uriList.add(GridTestProperties.getProperty("deploy.uri.file2")); - - return uriList; - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMd5CheckSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMd5CheckSelfTest.java deleted file mode 100644 index 5a658e47de8f2..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMd5CheckSelfTest.java +++ /dev/null @@ -1,209 +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.spi.deployment.uri; - -import java.io.File; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.deployment.DeploymentListener; -import org.apache.ignite.spi.deployment.DeploymentResource; -import org.apache.ignite.testframework.config.GridTestProperties; -import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; -import org.junit.Test; - -/** - * Redundancy for URI deployment test - */ -@GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") -public class GridUriDeploymentMd5CheckSelfTest extends GridUriDeploymentAbstractSelfTest { - /** - * Used to count number of unit undeployments. - */ - private AtomicInteger undeployCntr = new AtomicInteger(); - - /** - * Test skipping fresh deployment of duplicated .gar files. - * - * @throws Exception if failed. - */ - @Test - public void testMd5FileCheck() throws Exception { - undeployCntr.set(0); - - String taskName = "GridUriDeploymentTestWithNameTask7"; - - DeploymentResource task = getSpi().findResource(taskName); - - assert task == null; - - atomicCopy(getGarFile(), getDeployDir(), "uri1.gar"); - - waitForTask(taskName, true, 10000); - - assert undeployCntr.get() == 0; - - atomicCopy(getGarFile(), getDeployDir(), "uri2.gar"); - - waitForTask(taskName, true, 10000); - - assert undeployCntr.get() == 0; - } - - /** - * Test skipping fresh deployment of .gar directories with equal content. - * - * @throws Exception if failed. - */ - @Test - public void testMd5DirectoryCheck() throws Exception { - undeployCntr.set(0); - - String taskName = "GridUriDeploymentTestWithNameTask6"; - - DeploymentResource task = getSpi().findResource(taskName); - - assert task == null; - - atomicCopy(getGarDir(), getDeployDir(), "uri1.gar"); - - waitForTask(taskName, true, 10000); - - assert undeployCntr.get() == 0; - - atomicCopy(getGarDir(), getDeployDir(), "uri2.gar"); - - waitForTask(taskName, true, 10000); - - assert undeployCntr.get() == 0; - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - U.delete(getGarDir()); - U.delete(new File(getDeployDir(), "uri1.gar")); - U.delete(new File(getDeployDir(), "uri2.gar")); - - Thread.sleep(500); - } - - /** - * First copies to parent directory, when moves atomically to destination directory. - */ - private static void atomicCopy(File src, File destDir, String fileName) throws IOException { - File destParent = new File(destDir.getParent(), fileName); - - U.copy(src, destParent, true); - - destParent.renameTo(new File(destDir, fileName)); - } - - /** - * Prepares and returns a directory for test deployments. - * - * @return directory used as deployment source in this test. - */ - private File getDeployDir() { - File tmpDir = new File(GridTestProperties.getProperty("deploy.uri.file2.path")); - - if (!tmpDir.exists()) - tmpDir.mkdirs(); - - assert tmpDir.isDirectory(); - - return tmpDir; - } - - /** - * Returns original .gar file to use in this test. - * - * @return a valid .gar file path. - */ - private File getGarFile() { - File gar = U.resolveIgnitePath(GridTestProperties.getProperty("ant.urideployment.gar.file")); - - assert gar.isFile(); - - return gar; - } - - /** - * Prepares and returns .gar directory to use in this test. - * - * @return a valid .gar directory. - * @throws IOException if such directory can't be created. - */ - private File getGarDir() throws IOException { - File file = getGarFile(); - File parent = file.getParentFile(); - - assert parent.isDirectory(); - - File garDir = new File(parent, "extracted_" + file.getName()); - - // If content wasn't extracted before - if (!garDir.isDirectory()) { - garDir.mkdirs(); - U.unzip(file, garDir, null); - } - - return garDir; - } - - /** - * @return List of URI to use as deployment source. - */ - @GridSpiTestConfig - public List getUriList() { - getDeployDir(); // Force creation. - return Collections.singletonList(GridTestProperties.getProperty("deploy.uri.file2")); - } - - /** - * @return {@code true} - */ - @GridSpiTestConfig - public boolean getCheckMd5() { - return true; - } - - /** - * Sets listener to increment {@code undeployCounter} - * - * @throws Exception if failed. - */ - @Override protected void beforeTestsStarted() throws Exception { - getSpi().setListener(new DeploymentListener() { - @Override public void onUnregistered(ClassLoader ldr) { - undeployCntr.incrementAndGet(); - } - }); - } - - /** - * Cleans temporary deployment directory. - * - * @throws Exception if cleanup failed. - */ - @Override protected void afterTestsStopped() throws Exception { - U.delete(getDeployDir()); - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersErrorThrottlingTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersErrorThrottlingTest.java deleted file mode 100644 index 5e4a4c108b52c..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersErrorThrottlingTest.java +++ /dev/null @@ -1,54 +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.spi.deployment.uri; - -import java.util.ArrayList; -import java.util.List; -import org.apache.ignite.internal.util.typedef.internal.LT; -import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; -import org.junit.Test; - -/** - * Tests error and warn messages throttling. - */ -@GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") -public class GridUriDeploymentMultiScannersErrorThrottlingTest extends GridUriDeploymentAbstractSelfTest { - /** - * @throws Exception If failed. - */ - @Test - public void testThrottling() throws Exception { - LT.throttleTimeout(11000); - - Thread.sleep(15 * 1000); - } - - /** - * @return URI list. - */ - @GridSpiTestConfig - public List getUriList() { - List uriList = new ArrayList<>(); - - uriList.add("http://freq=5000@localhost/tasks"); - uriList.add("http://freq=5000@unknownhost.host/tasks"); - - return uriList; - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersSelfTest.java deleted file mode 100644 index f4f9b35ab003e..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersSelfTest.java +++ /dev/null @@ -1,57 +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.spi.deployment.uri; - -import java.util.ArrayList; -import java.util.List; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.testframework.config.GridTestProperties; -import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; -import org.junit.Test; - -/** - * Test URI deployment with multiple scanners. - */ -@GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") -public class GridUriDeploymentMultiScannersSelfTest extends GridUriDeploymentAbstractSelfTest { - /** - * @throws Exception If failed. - */ - @Test - public void testDeployment() throws Exception { - checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask0"); - } - - /** - * @return List of deployment sources. - */ - @GridSpiTestConfig - public List getUriList() { - List uriList = new ArrayList<>(); - - // Fake URI. - uriList.add(GridTestProperties.getProperty("deploy.uri.http")); - - // One real URI. - uriList.add(GridTestProperties.getProperty("ant.urideployment.gar.uri"). - replace("EXTDATA", U.resolveIgnitePath("modules/extdata").getAbsolutePath())); - - return uriList; - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSimpleSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSimpleSelfTest.java deleted file mode 100644 index 6dcbf5abc1aec..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSimpleSelfTest.java +++ /dev/null @@ -1,197 +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.spi.deployment.uri; - -import java.io.Serializable; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.compute.ComputeJob; -import org.apache.ignite.compute.ComputeJobAdapter; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.compute.ComputeTaskAdapter; -import org.apache.ignite.compute.ComputeTaskName; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.deployment.DeploymentResource; -import org.apache.ignite.testframework.config.GridTestProperties; -import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; -import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; -import org.jetbrains.annotations.NotNull; -import org.junit.Test; - -/** - * - */ -@GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") -public class GridUriDeploymentSimpleSelfTest extends GridSpiAbstractTest { - /** - * @return List of URI to use as deployment source. - */ - @GridSpiTestConfig - public List getUriList() { - // No real gar file is required. Add one just to avoid failure because of missed default directory. - return Collections.singletonList(GridTestProperties.getProperty("ant.urideployment.gar.uri"). - replace("EXTDATA", U.resolveIgnitePath("modules/extdata").getAbsolutePath())); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testSimpleDeploy() throws Exception { - UriDeploymentSpi spi = getSpi(); - - spi.register(TestTask.class.getClassLoader(), TestTask.class); - - DeploymentResource task = spi.findResource(TestTask.class.getName()); - - assert task != null; - assert task.getResourceClass() == TestTask.class; - assert spi.findResource("TestTaskWithName") == null; - - spi.unregister(TestTask.class.getName()); - - assert spi.findResource(TestTask.class.getName()) == null; - } - - /** - * @throws Exception If failed. - */ - @Test - public void testSimpleRedeploy() throws Exception { - for (int i = 0; i < 100; i++) - testSimpleDeploy(); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testSimpleDeployWithName() throws Exception { - UriDeploymentSpi spi = getSpi(); - - spi.register(TestTaskWithName.class.getClassLoader(), TestTaskWithName.class); - - DeploymentResource task = spi.findResource("TestTaskWithName"); - - assert task != null; - assert task.getResourceClass() == TestTaskWithName.class; - assert spi.findResource(TestTaskWithName.class.getName()) != null; - - spi.unregister("TestTaskWithName"); - - assert spi.findResource("TestTaskWithName") == null; - } - - /** - * @throws Exception If failed. - */ - @Test - public void testSimpleRedeployWithName() throws Exception { - for (int i = 0; i < 100; i++) - testSimpleDeployWithName(); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testSimpleDeployTwoTasks() throws Exception { - UriDeploymentSpi spi = getSpi(); - - spi.register(TestTask.class.getClassLoader(), TestTask.class); - spi.register(TestTaskWithName.class.getClassLoader(), TestTaskWithName.class); - - DeploymentResource task1 = spi.findResource("TestTaskWithName"); - DeploymentResource task2 = spi.findResource(TestTask.class.getName()); - - assert task1 != null; - assert task1.getResourceClass() == TestTaskWithName.class; - assert spi.findResource(TestTaskWithName.class.getName()) != null; - - assert task2 != null; - assert task2.getResourceClass() == TestTask.class; - assert spi.findResource("TestTask") == null; - - spi.unregister("TestTaskWithName"); - - assert spi.findResource("TestTaskWithName") == null; - - spi.unregister(TestTask.class.getName()); - - assert spi.findResource(TestTask.class.getName()) == null; - } - - /** - * @throws Exception If failed. - */ - @Test - public void testSimpleRedeployTwoTasks() throws Exception { - for (int i = 0; i < 100; i++) - testSimpleDeployTwoTasks(); - } - - /** - * Test task. - */ - private static class TestTask extends ComputeTaskAdapter { - /** {@inheritDoc} */ - @NotNull @Override public Map map(List subgrid, Object arg) { - assert subgrid.size() == 1; - - return Collections.singletonMap(new ComputeJobAdapter() { - @Override public Serializable execute() { - return "result"; - } - }, subgrid.get(0)); - } - - /** {@inheritDoc} */ - @Override public Object reduce(List results) { - assert results.size() == 1; - - return results.get(0).getData(); - } - } - - /** - * Named test task. - */ - @ComputeTaskName("TestTaskWithName") - private static class TestTaskWithName extends ComputeTaskAdapter { - /** {@inheritDoc} */ - @NotNull @Override public Map map(List subgrid, Object arg) { - assert subgrid.size() == 1; - - return Collections.singletonMap(new ComputeJobAdapter() { - @Override public Serializable execute() { - return "result"; - } - }, subgrid.get(0)); - } - - /** {@inheritDoc} */ - @Override public Object reduce(List results) { - assert results.size() == 1; - - return results.get(0).getData(); - } - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.brokenxml b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.brokenxml deleted file mode 100644 index 79b72e9e352fe..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.brokenxml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - Ignite Spring configuration file in gar-file for ant GAR task. - - - zx - - - - \ No newline at end of file diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.empty b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.empty deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.incorrefs b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.incorrefs deleted file mode 100644 index 880e03b8d9eb8..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.incorrefs +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - Ignite Spring configuration file in gar-file for ant GAR task. - - - - - - - \ No newline at end of file diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.xml b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.xml deleted file mode 100644 index d9ff2bc570931..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - Ignite Spring configuration file in gar-file. - - - - org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask0 - org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestWithNameTask0 - - diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/package-info.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/package-info.java deleted file mode 100644 index 24a3c37e27dc0..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/package-info.java +++ /dev/null @@ -1,23 +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. - */ - -/** - * - * Contains internal tests or test related classes and interfaces. - */ - -package org.apache.ignite.spi.deployment.uri; diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentSelfTest.java deleted file mode 100644 index 19ec733c514a4..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentSelfTest.java +++ /dev/null @@ -1,206 +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.spi.deployment.uri.scanners.file; - -import java.util.Collections; -import java.util.List; -import org.apache.ignite.spi.deployment.uri.GridUriDeploymentAbstractSelfTest; -import org.apache.ignite.spi.deployment.uri.UriDeploymentSpi; -import org.apache.ignite.testframework.config.GridTestProperties; -import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; -import org.junit.Test; - -/** - * Test file protocol scanner. - */ -@GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") -public class GridFileDeploymentSelfTest extends GridUriDeploymentAbstractSelfTest { - /** - * @return List of URI to use as deployment source. - */ - @GridSpiTestConfig - public List getUriList() { - return Collections.singletonList(GridTestProperties.getProperty("deploy.uri.file")); - } - - /** - * Tests task from folder 'deploydir.gar'. - * - * @throws Exception If failed. - */ - @Test - public void testDeploymentFromFolder() throws Exception { - checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask0"); - checkTask("GridUriDeploymentTestWithNameTask0"); - } - - /** - * Tests task from file 'deployfile.jar'. - * - * @throws Exception If failed. - */ - @Test - public void testDeploymentFromJar() throws Exception { - checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask8"); - checkTask("GridUriDeploymentTestWithNameTask8"); - } - - /** - * Tests task from file 'deployfile.gar'. - * - * @throws Exception If failed. - */ - @Test - public void testDeploymentFromGar() throws Exception { - checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3"); - checkTask("GridUriDeploymentTestWithNameTask3"); - } - - /** - * Tests task from file 'deployfile-nodescr.gar'. - * - * Looks for task {@code GridUriDeploymentTestTask4} without descriptor file from GAR-file. - * That task loads resource {@code spring.xml}. - * - * To check {@code GridDeploymentUriClassLoader} class loader you need to delete all classes - * and resources from Junit classpath. Note that class loader searches classes in a GAR file and - * not in the parent class loader for junits. - * - * @throws Exception If failed. - */ - @Test - public void testNoDescriptorDeployment() throws Exception { - checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask4"); - checkTask("GridUriDeploymentTestWithNameTask4"); - } - - /** - * Tests task from file 'deployfile-bad.gar'. - * - * Looks for tasks {@code GridUriDeploymentAbstractTestTask} - * {@code GridInnerTestTask} - * {@code GridUriDeploymentInterfaceTestTask} - * {@code GridUriDeploymentNonePublicTestTask} from GAR-file. Tasks should not be deployed. - * - * @throws Exception If failed. - */ - @Test - public void testBadDeployment() throws Exception { - checkNoTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentAbstractTestTask"); - - checkNoTask("org.apache.ignite.spi.deployment.uri.tasks.GridInnerTestTask"); - checkNoTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentInnerTestTask$GridInnerTestTask"); - checkNoTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentInnerTestTask.GridInnerTestTask"); - - checkNoTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentInterfaceTestTask"); - checkNoTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentNonePublicTestTask"); - } - - /** - * Tests task from file 'deployfile.jar'. - * - * Looks for task {@code GridUriDeploymentTestTask9}. - * That task loads resource {@code spring9.xml} and imports external class from the same JAR - * External class loads resource {@code test9.properties} from the same JAR it is loaded from. - * - * To check {@code GridDeploymentUriClassLoader} class loader need to delete all classes - * and resources from Junit classpath. Note that class loader searches for classes in a JAR - * file and not in the parent class loader for junits. - * - * @throws Exception If failed. - */ - @Test - public void testDependenceJarDeployment() throws Exception { - checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask9"); - getSpi().findResource("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask9") - .getResourceClass().newInstance(); - } - - /** - * Tests task from file 'deployfile-depend.gar'. - * - * Looks for task {@code GridUriDeploymentTestTask1} with descriptor file from GAR-file. - * That task loads resource {@code spring1.xml} and imports external class from /lib/*.jar - * External class loads resource {@code test1.properties}from the same JAR it is loaded from. - * - * To check {@code GridDeploymentUriClassLoader} class loader need to delete all classes - * and resources from Junit classpath. Note that class loader searches for classes in a GAR - * file and not in the parent class loader for junits. - * - * @throws Exception If failed. - */ - @Test - public void testDependenceGarDeployment() throws Exception { - checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask1"); - getSpi().findResource("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask1") - .getResourceClass().newInstance(); - } - - /** - * Tests task from file 'deploydir-nodescr-depend.gar'. - * - * Looks for task {@code GridUriDeploymentTestTask2} without descriptor file from GAR-file. - * That task loads resource {@code spring2.xml} and imports external class from /lib/*.jar - * External class loads resource {@code test2.properties}from the same JAR it is loaded from. - * - * To check {@code GridDeploymentUriClassLoader} class loader need to delete all classes - * and resources from Junit classpath. Note that class loader searches for classes in a GAR - * file and not in the parent class loader for junits. - * - * @throws Exception If failed. - */ - @Test - public void testNoDescriptorDependenceDeployment() throws Exception { - checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask2"); - getSpi().findResource("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask2") - .getResourceClass().newInstance(); - } - - /** - * Tests task from files 'well-signed-deployfile.gar', 'bad-signed-deployfile.gar', - * 'well-signed-deployfile.jar' and 'bad-signed-deployfile.jar'. - * Files 'bad-signed-deployfile.gar', 'bad-signed-deployfile.jar' contain non-signed modifications. - * - * Sign JAR with command: - * $ jarsigner -keystore $IGNITE_HOME/modules/tests/config/signeddeploy/keystore -storepass "abc123" - * -keypass "abc123" -signedjar signed-deployfile.jar deployfile.jar business - * - * Verify signed JAR-file: - * $ jarsigner -verify -keystore $IGNITE_HOME/modules/tests/config/signeddeploy/keystore -storepass "abc123" - * -keypass "abc123" signed-deployfile.jar - * - * @throws Exception If failed. - */ - @Test - public void testSignedDeployment() throws Exception { - checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask5"); - checkTask("GridUriDeploymentTestWithNameTask5"); - checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask10"); - checkTask("GridUriDeploymentTestWithNameTask10"); - - assert getSpi().findResource("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask6") == null : - "Task from GAR with invalid signature should not be deployed."; - assert getSpi().findResource("tasks.GridUriDeploymentTestWithNameTask6") - == null : "Task from GAR with invalid signature should not be deployed."; - assert getSpi().findResource("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask11") == null : - "Task from JAR with invalid signature should not be deployed."; - assert getSpi().findResource("GridUriDeploymentTestWithNameTask11") - == null : "Task from JAR with invalid signature should not be deployed."; - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentUndeploySelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentUndeploySelfTest.java deleted file mode 100644 index e4f19e1edca50..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentUndeploySelfTest.java +++ /dev/null @@ -1,113 +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.spi.deployment.uri.scanners.file; - -import java.io.File; -import java.util.Collections; -import java.util.List; -import java.util.UUID; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.deployment.uri.UriDeploymentSpi; -import org.apache.ignite.testframework.config.GridTestProperties; -import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; -import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; -import org.junit.Test; - -/** - * Tests correct task undeployment after source file removing. - */ -@GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") -public class GridFileDeploymentUndeploySelfTest extends GridSpiAbstractTest { - /** */ - private static String tmpDirPath = System.getProperty("java.io.tmpdir") + '/' + UUID.randomUUID(); - - /** */ - private static final String GAR_FILE_NAME = "deployfile.gar"; - - /** {@inheritDoc} */ - @Override protected void beforeSpiStarted() throws Exception { - File deployDir = new File(tmpDirPath); - - assert !deployDir.exists() : "Directory exists " + deployDir.getCanonicalPath(); - - boolean mkdir = deployDir.mkdir(); - - assert mkdir : "Unable to create directory: " + deployDir.getCanonicalPath(); - - info("URI list for test [uriList=" + getUriList() + ']'); - - super.beforeSpiStarted(); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testUndeployGarFile() throws Exception { - String garFilePath = - U.resolveIgnitePath(GridTestProperties.getProperty("ant.urideployment.gar.file")).getPath(); - - File garFile = new File(garFilePath); - - assert garFile.exists() : "Test gar file not found [path=" + garFilePath + ']'; - - File newGarFile = new File(tmpDirPath + '/' + GAR_FILE_NAME); - - assert !newGarFile.exists(); - - U.copy(garFile, newGarFile, false); - - assert newGarFile.exists(); - - Thread.sleep(UriDeploymentFileScanner.DFLT_SCAN_FREQ + 3000); - - assert getSpi().findResource("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3") != null : - "Failed to find resource for added GAR file."; - assert getSpi().findResource("GridUriDeploymentTestWithNameTask3") != null; - - boolean del = newGarFile.delete(); - - assert del : "Filed to delete file [path=" + newGarFile.getAbsolutePath() + ']'; - - assert !newGarFile.exists(); - - Thread.sleep(UriDeploymentFileScanner.DFLT_SCAN_FREQ + 3000); - - assert getSpi().findResource("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3") == null; - assert getSpi().findResource("GridUriDeploymentTestWithNameTask3") == null; - } - - /** - * @throws Exception If failed. - */ - @Override protected void afterTestsStopped() throws Exception { - File deployDir = new File(tmpDirPath); - - if (deployDir.exists()) - deployDir.delete(); - } - - /** - * @return List of URI to use as deployment source. - */ - @GridSpiTestConfig - public List getUriList() { - return Collections.singletonList("file:///" + tmpDirPath); - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/package-info.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/package-info.java deleted file mode 100644 index 13665557c1fc7..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/package-info.java +++ /dev/null @@ -1,23 +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. - */ - -/** - * - * Contains internal tests or test related classes and interfaces. - */ - -package org.apache.ignite.spi.deployment.uri.scanners.file; diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java deleted file mode 100644 index b366d4fe2fa93..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java +++ /dev/null @@ -1,239 +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.spi.deployment.uri.scanners.http; - -import java.io.File; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.deployment.uri.GridUriDeploymentAbstractSelfTest; -import org.apache.ignite.spi.deployment.uri.UriDeploymentSpi; -import org.apache.ignite.testframework.config.GridTestProperties; -import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.ServerConnector; -import org.eclipse.jetty.server.handler.ResourceHandler; -import org.junit.Test; - -/** - * Test http scanner. - */ -@GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") -public class GridHttpDeploymentSelfTest extends GridUriDeploymentAbstractSelfTest { - /** Frequency */ - private static final int FREQ = 5000; - - /** */ - public static final String LIBS_GAR = "libs-file.gar"; - - /** */ - public static final String CLASSES_GAR = "classes-file.gar"; - - /** */ - public static final String ALL_GAR = "file.gar"; - - /** */ - public static final String ALL_JAR = "file.jar"; - - /** Gar-file which contains libs. */ - public static final String LIBS_GAR_FILE_PATH = U.resolveIgnitePath( - GridTestProperties.getProperty("ant.urideployment.gar.libs-file")).getPath(); - - /** Gar-file which contains classes (cannot be used without libs). */ - public static final String CLASSES_GAR_FILE_PATH = U.resolveIgnitePath( - GridTestProperties.getProperty("ant.urideployment.gar.classes-file")).getPath(); - - /** Gar-file which caontains both libs and classes. */ - public static final String ALL_GAR_FILE_PATH = U.resolveIgnitePath( - GridTestProperties.getProperty("ant.urideployment.gar.file")).getPath(); - - /** JAR file with tasks and dependencies. */ - public static final String JAR_FILE_PATH = U.resolveIgnitePath( - GridTestProperties.getProperty("urideployment.jar.uri")).getPath(); - - /** Jetty. */ - private static Server srv; - - /** Resource base. */ - private static String rsrcBase; - - /** {@inheritDoc} */ - @Override protected void beforeSpiStarted() throws Exception { - srv = new Server(); - - ServerConnector conn = new ServerConnector(srv); - - conn.setPort(8080); - - srv.addConnector(conn); - - ResourceHandler hnd = new ResourceHandler(); - - hnd.setDirectoriesListed(true); - - String garPathTmp = GridTestProperties.getProperty("urideployment.path.tmp"); - - File resourseBaseDir = U.resolveIgnitePath(garPathTmp); - - if (resourseBaseDir == null) { - resourseBaseDir = new File(U.getIgniteHome(), garPathTmp); - - assertTrue(resourseBaseDir.mkdirs()); - } - - rsrcBase = resourseBaseDir.getPath(); - - hnd.setResourceBase(rsrcBase); - - srv.setHandler(hnd); - - srv.start(); - - assert srv.isStarted(); - } - - /** - * @throws Exception If failed. - */ - @Override protected void afterTestsStopped() throws Exception { - assert srv.isStarted(); - - srv.stop(); - - assert srv.isStopped(); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testDeployUndeploy2GarFiles() throws Exception { - String taskName = "org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3"; - - checkNoTask(taskName); - - try { - copyToResourceBase(LIBS_GAR_FILE_PATH, LIBS_GAR); - - copyToResourceBase(CLASSES_GAR_FILE_PATH, CLASSES_GAR); - - waitForTask(taskName, true, FREQ + 3000); - } - catch (Exception e) { - e.printStackTrace(); - } - finally { - deleteFromResourceBase(LIBS_GAR); - deleteFromResourceBase(CLASSES_GAR); - - waitForTask(taskName, false, FREQ + 3000); - } - } - - /** - * @throws Exception If failed. - */ - @Test - public void testDeployUndeployJar() throws Exception { - String taskName = "org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask8"; - - checkNoTask(taskName); - - try { - copyToResourceBase(JAR_FILE_PATH, ALL_JAR); - - waitForTask(taskName, true, FREQ + 3000); - } - catch (Exception e) { - e.printStackTrace(); - } - finally { - deleteFromResourceBase(ALL_JAR); - - waitForTask(taskName, false, FREQ + 3000); - } - } - - /** - * @throws Exception If failed. - */ - @Test - public void testSameContantFiles() throws Exception { - String taskName = "org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3"; - - checkNoTask(taskName); - - try { - copyToResourceBase(ALL_GAR_FILE_PATH, ALL_GAR); - - waitForTask(taskName, true, FREQ + 3000); - - copyToResourceBase(ALL_GAR_FILE_PATH, "file-copy.gar"); - - waitForTask(taskName, true, FREQ + 3000); - } - catch (Throwable e) { - e.printStackTrace(); - } - finally { - deleteFromResourceBase(ALL_GAR); - deleteFromResourceBase("file-copy.gar"); - - waitForTask(taskName, false, FREQ + 3000); - } - } - - /** - * @return Test server URl as deployment source URI. - */ - @GridSpiTestConfig - public List getUriList() { - return Collections.singletonList("http://freq=" + FREQ + "@localhost:8080/"); - } - - /** - * @param fileName File name. - */ - private void deleteFromResourceBase(String fileName) { - File file = new File(rsrcBase + '/' + fileName); - - if (!file.delete()) - U.warn(log, "Could not delete file: " + file); - } - - /** - * @param path Path to the file which should be copied. - * @param newFileName New file name. - * @throws IOException If exception. - */ - private void copyToResourceBase(String path, String newFileName) throws IOException { - File file = new File(path); - - assert file.exists() : "Test file not found [path=" + path + ']'; - - File newFile = new File(rsrcBase + '/' + newFileName); - - assert !newFile.exists(); - - U.copy(file, newFile, false); - - assert newFile.exists(); - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/package-info.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/package-info.java deleted file mode 100644 index e6a79379f5da1..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/package-info.java +++ /dev/null @@ -1,23 +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. - */ - -/** - * - * Contains internal tests or test related classes and interfaces. - */ - -package org.apache.ignite.spi.deployment.uri.scanners.http; diff --git a/modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteToolsSelfTestSuite.java b/modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteToolsSelfTestSuite.java deleted file mode 100644 index 6c8d923a94f4a..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteToolsSelfTestSuite.java +++ /dev/null @@ -1,32 +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.testsuites; - -import org.apache.ignite.tools.GridToolsSelfTest; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * Tools self-test suite. - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - GridToolsSelfTest.class -}) -public class IgniteToolsSelfTestSuite { -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteUriDeploymentTestSuite.java b/modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteUriDeploymentTestSuite.java deleted file mode 100644 index a5b49fa85b410..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteUriDeploymentTestSuite.java +++ /dev/null @@ -1,71 +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.testsuites; - -import org.apache.ignite.internal.GridTaskUriDeploymentDeadlockSelfTest; -import org.apache.ignite.internal.UriDeploymentAbsentProcessorClassTest; -import org.apache.ignite.p2p.ClassLoadingProblemExceptionTest; -import org.apache.ignite.p2p.ClassLoadingProblemExtendedLoggingTest; -import org.apache.ignite.p2p.GridP2PDisabledSelfTest; -import org.apache.ignite.spi.deployment.uri.GridUriDeploymentClassLoaderMultiThreadedSelfTest; -import org.apache.ignite.spi.deployment.uri.GridUriDeploymentClassLoaderSelfTest; -import org.apache.ignite.spi.deployment.uri.GridUriDeploymentClassloaderRegisterSelfTest; -import org.apache.ignite.spi.deployment.uri.GridUriDeploymentConfigSelfTest; -import org.apache.ignite.spi.deployment.uri.GridUriDeploymentFileProcessorSelfTest; -import org.apache.ignite.spi.deployment.uri.GridUriDeploymentMd5CheckSelfTest; -import org.apache.ignite.spi.deployment.uri.GridUriDeploymentMultiScannersErrorThrottlingTest; -import org.apache.ignite.spi.deployment.uri.GridUriDeploymentMultiScannersSelfTest; -import org.apache.ignite.spi.deployment.uri.GridUriDeploymentSimpleSelfTest; -import org.apache.ignite.spi.deployment.uri.scanners.file.GridFileDeploymentSelfTest; -import org.apache.ignite.spi.deployment.uri.scanners.file.GridFileDeploymentUndeploySelfTest; -import org.apache.ignite.spi.deployment.uri.scanners.http.GridHttpDeploymentSelfTest; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * Tests against {@link org.apache.ignite.spi.deployment.uri.UriDeploymentSpi}. - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - GridUriDeploymentConfigSelfTest.class, - GridUriDeploymentSimpleSelfTest.class, - GridUriDeploymentClassloaderRegisterSelfTest.class, - GridUriDeploymentFileProcessorSelfTest.class, - GridUriDeploymentClassLoaderSelfTest.class, - GridUriDeploymentClassLoaderMultiThreadedSelfTest.class, - GridUriDeploymentMultiScannersSelfTest.class, - GridUriDeploymentConfigSelfTest.class, - - GridFileDeploymentUndeploySelfTest.class, - GridHttpDeploymentSelfTest.class, - - GridFileDeploymentSelfTest.class, - GridUriDeploymentMultiScannersErrorThrottlingTest.class, - GridUriDeploymentMd5CheckSelfTest.class, - - // GAR Ant task tests. - IgniteToolsSelfTestSuite.class, - - GridTaskUriDeploymentDeadlockSelfTest.class, - GridP2PDisabledSelfTest.class, - ClassLoadingProblemExceptionTest.class, - ClassLoadingProblemExtendedLoggingTest.class, - UriDeploymentAbsentProcessorClassTest.class -}) -public class IgniteUriDeploymentTestSuite { -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/tools/GridToolsSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/tools/GridToolsSelfTest.java deleted file mode 100644 index 976b27acb6873..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/tools/GridToolsSelfTest.java +++ /dev/null @@ -1,395 +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.tools; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.testframework.config.GridTestProperties; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.apache.ignite.testframework.junits.common.GridCommonTest; -import org.apache.ignite.util.antgar.IgniteDeploymentGarAntTask; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.junit.Test; - -/** - * Tests for Ant task generating GAR file. - */ -@GridCommonTest(group = "Tools") -public class GridToolsSelfTest extends GridCommonAbstractTest { - /** - * @throws Exception If failed. - */ - @Test - public void testCorrectAntGarTask() throws Exception { - String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); - String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); - String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_0"; - String metaDirName = baseDirName + File.separator + "META-INF"; - String garFileName = baseDirName + ".gar"; - String garDescDirName = - U.resolveIgnitePath(GridTestProperties.getProperty("ant.gar.descriptor.dir")).getAbsolutePath() - + File.separator + "ignite.xml"; - - // Make base and META-INF dir. - boolean mkdir = new File(baseDirName).mkdirs(); - - assert mkdir; - - mkdir = new File(metaDirName).mkdirs(); - - assert mkdir; - - // Make Gar file - U.copy(new File(garDescDirName), new File(metaDirName + File.separator + "ignite.xml"), true); - - // Copy files to basedir - U.copy(new File(srcDirName), new File(baseDirName), true); - - IgniteDeploymentGarAntTask garTask = new IgniteDeploymentGarAntTask(); - - Project garProject = new Project(); - - garProject.setName("Gar test project"); - - garTask.setDestFile(new File(garFileName)); - garTask.setBasedir(new File(baseDirName)); - garTask.setProject(garProject); - - garTask.execute(); - - File garFile = new File(garFileName); - - assert garFile.exists(); - - boolean res = checkStructure(garFile, true); - - assert res; - } - - /** - * @param garFile GAR file. - * @param hasDescr Whether GAR file has descriptor. - * @throws IOException If GAR file is not found. - * @return Whether GAR file structure is correct. - */ - private boolean checkStructure(File garFile, boolean hasDescr) throws IOException { - ZipFile zip = new ZipFile(garFile); - - String descr = "META-INF/ignite.xml"; - - ZipEntry entry = zip.getEntry(descr); - - if (entry == null && !hasDescr) { - if (log().isInfoEnabled()) { - log().info("Process deployment without descriptor file [path=" + - descr + ", file=" + garFile.getAbsolutePath() + ']'); - } - - return true; - } - else if (entry != null && hasDescr) { - InputStream in = null; - - try { - in = new BufferedInputStream(zip.getInputStream(entry)); - - return true; - } - finally { - U.close(in, log()); - } - } - else - return false; - } - - /** - * @throws Exception If failed. - */ - @Test - public void testAntGarTaskWithExternalP2PDescriptor() throws Exception { - String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); - String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); - String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_1"; - String metaDirName = baseDirName + File.separator + "META-INF"; - String garFileName = baseDirName + ".gar"; - String garDescrDirName = - U.resolveIgnitePath(GridTestProperties.getProperty("ant.gar.descriptor.dir")).getAbsolutePath(); - - // Make base and META-INF dir. - boolean mkdir = new File(baseDirName).mkdirs(); - - assert mkdir; - - mkdir = new File(metaDirName).mkdirs(); - - assert mkdir; - - // Copy files to basedir - U.copy(new File(srcDirName), new File(baseDirName), true); - - IgniteDeploymentGarAntTask garTask = new IgniteDeploymentGarAntTask(); - - Project garProject = new Project(); - - garProject.setName("Gar test project"); - - garTask.setDestFile(new File(garFileName)); - garTask.setDescrdir(new File(garDescrDirName)); - garTask.setBasedir(new File(baseDirName)); - garTask.setProject(garProject); - - garTask.execute(); - - File garFile = new File(garFileName); - - assert garFile.exists(); - - boolean res = checkStructure(garFile, true); - - assert res; - } - - /** - * @throws Exception If failed. - */ - @Test - public void testAntGarTaskWithDoubleP2PDescriptor() throws Exception { - String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); - String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); - String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_2"; - String metaDirName = baseDirName + File.separator + "META-INF"; - String garFileName = baseDirName + ".gar"; - String garDescrDirName = - U.resolveIgnitePath(GridTestProperties.getProperty("ant.gar.descriptor.dir")).getAbsolutePath() - + File.separator + "ignite.xml"; - - // Make base and META-INF dir. - boolean mkdir = new File(baseDirName).mkdirs(); - - assert mkdir; - - mkdir = new File(metaDirName).mkdirs(); - - assert mkdir; - - // Make Gar file - U.copy(new File(garDescrDirName), new File(metaDirName + File.separator + "ignite.xml"), true); - - // Copy files to basedir - U.copy(new File(srcDirName), new File(baseDirName), true); - - IgniteDeploymentGarAntTask garTask = new IgniteDeploymentGarAntTask(); - - Project garProject = new Project(); - - garProject.setName("Gar test project"); - - garTask.setDestFile(new File(garFileName)); - garTask.setDescrdir(new File(garDescrDirName)); - garTask.setBasedir(new File(baseDirName)); - garTask.setProject(garProject); - - try { - garTask.execute(); - - assert false; - } - catch (BuildException e) { - if (log().isInfoEnabled()) - log().info(e.getMessage()); - } - } - - /** - * @throws Exception If failed. - */ - @Test - public void testAntGarTaskWithDirDescriptor() throws Exception { - String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); - String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); - String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_3"; - String metaDirName = baseDirName + File.separator + "META-INF"; - String garFileName = baseDirName + ".gar"; - - // Make base and META-INF dir. - boolean mkdir = new File(baseDirName).mkdirs(); - - assert mkdir; - - mkdir = new File(metaDirName).mkdirs(); - - assert mkdir; - - // Copy files to basedir - U.copy(new File(srcDirName), new File(baseDirName), true); - - IgniteDeploymentGarAntTask garTask = new IgniteDeploymentGarAntTask(); - - Project garProject = new Project(); - - garProject.setName("Gar test project"); - - garTask.setDestFile(new File(garFileName)); - garTask.setBasedir(new File(baseDirName)); - garTask.setProject(garProject); - garTask.setDescrdir(new File(garFileName)); - - try { - garTask.execute(); - - assert false; - } - catch (BuildException e) { - if (log().isInfoEnabled()) - log().info(e.getMessage()); - } - } - - /** - * @throws Exception If failed. - */ - @Test - public void testAntGarTaskWithNullDescriptor() throws Exception { - String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); - String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); - String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_4"; - String metaDirName = baseDirName + File.separator + "META-INF"; - String garFileName = baseDirName + ".gar"; - - // Make base and META-INF dir. - boolean mkdir = new File(baseDirName).mkdirs(); - - assert mkdir; - - mkdir = new File(metaDirName).mkdirs(); - - assert mkdir; - - // Copy files to basedir - U.copy(new File(srcDirName), new File(baseDirName), true); - - IgniteDeploymentGarAntTask garTask = new IgniteDeploymentGarAntTask(); - - Project garProject = new Project(); - - garProject.setName("Gar test project"); - - garTask.setDestFile(new File(garFileName)); - garTask.setBasedir(new File(baseDirName)); - garTask.setProject(garProject); - - try { - garTask.execute(); - } - catch (BuildException e) { - if (log().isInfoEnabled()) - log().info(e.getMessage()); - - assert false; - } - } - - /** - * @throws Exception If failed. - */ - @Test - public void testAntGarTaskWithFileBaseDir() throws Exception { - String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); - String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); - String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_5"; - String metaDirName = baseDirName + File.separator + "META-INF"; - String garFileName = baseDirName + ".gar"; - - // Make base and META-INF dir. - boolean mkdir = new File(baseDirName).mkdirs(); - - assert mkdir; - - mkdir = new File(metaDirName).mkdirs(); - - assert mkdir; - - // Copy files to basedir - U.copy(new File(srcDirName), new File(baseDirName), true); - - IgniteDeploymentGarAntTask garTask = new IgniteDeploymentGarAntTask(); - - Project garProject = new Project(); - - garProject.setName("Gar test project"); - - garTask.setDestFile(new File(garFileName)); - garTask.setBasedir(new File(garFileName)); - garTask.setProject(garProject); - garTask.setDescrdir(new File(garFileName)); - - try { - garTask.execute(); - - assert false; - } - catch (BuildException e) { - if (log().isInfoEnabled()) - log().info(e.getMessage()); - } - } - - /** - * @throws Exception If failed. - */ - @Test - public void testAntGarTaskToString() throws Exception { - String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); - String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); - String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_6"; - String metaDirName = baseDirName + File.separator + "META-INF"; - String garFileName = baseDirName + ".gar"; - - // Make base and META-INF dir. - boolean mkdir = new File(baseDirName).mkdirs(); - - assert mkdir; - - mkdir = new File(metaDirName).mkdirs(); - - assert mkdir; - - // Copy files to basedir - U.copy(new File(srcDirName), new File(baseDirName), true); - - IgniteDeploymentGarAntTask garTask = new IgniteDeploymentGarAntTask(); - - Project garProject = new Project(); - - garProject.setName("Gar test project"); - - garTask.setDestFile(new File(garFileName)); - garTask.setBasedir(new File(garFileName)); - garTask.setProject(garProject); - garTask.setDescrdir(new File(garFileName)); - - garTask.toString(); - } -} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/tools/gartask/META-INF/ignite.xml b/modules/urideploy/src/test/java/org/apache/ignite/tools/gartask/META-INF/ignite.xml deleted file mode 100644 index a85e33e33089d..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/tools/gartask/META-INF/ignite.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - Ignite Spring configuration file in gar-file. - - - - org.apache.ignite.grid.tests.p2p.GridP2PTestTask - org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestWithNameTask0 - - diff --git a/modules/urideploy/src/test/java/org/apache/ignite/tools/package-info.java b/modules/urideploy/src/test/java/org/apache/ignite/tools/package-info.java deleted file mode 100644 index 5ad78a880d150..0000000000000 --- a/modules/urideploy/src/test/java/org/apache/ignite/tools/package-info.java +++ /dev/null @@ -1,23 +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. - */ - -/** - * - * Contains internal tests or test related classes and interfaces. - */ - -package org.apache.ignite.tools; diff --git a/pom.xml b/pom.xml index b7babc3d8033f..ab17fb30a861b 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,6 @@ modules/clients modules/spring modules/web - modules/urideploy modules/indexing modules/json modules/rest-http From 2de14bc39b34bbb3b79c2b9fabfb115beb92cf31 Mon Sep 17 00:00:00 2001 From: Nikolay Izhikov Date: Sat, 7 Mar 2026 18:22:19 +0300 Subject: [PATCH 2/8] WIP --- ...IgniteCacheSharedExecutionContextTest.java | 35 ------------------- .../GridCacheNodeFailureAbstractTest.java | 11 ------ ...GridCachePreloadLifecycleAbstractTest.java | 2 -- .../GridCacheReplicatedPreloadSelfTest.java | 3 -- .../p2p/ClassLoadingProblemExceptionTest.java | 1 - ...lassLoadingProblemExtendedLoggingTest.java | 2 -- .../ignite/p2p/SharedDeploymentTest.java | 4 +-- .../testsuites/IgniteCacheTestSuite.java | 2 -- .../cache/GridCacheOffHeapSelfTest.java | 3 -- .../GridCacheOffheapIndexGetSelfTest.java | 3 -- 10 files changed, 1 insertion(+), 65 deletions(-) delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheSharedExecutionContextTest.java diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheSharedExecutionContextTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheSharedExecutionContextTest.java deleted file mode 100644 index ba70be49eaf7d..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheSharedExecutionContextTest.java +++ /dev/null @@ -1,35 +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.internal.processors.cache.context; - -import org.apache.ignite.configuration.DeploymentMode; -import org.apache.ignite.configuration.IgniteConfiguration; - -/** - * - */ -public class IgniteCacheSharedExecutionContextTest extends IgniteCacheAtomicExecutionContextTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - cfg.setDeploymentMode(DeploymentMode.SHARED); - - return cfg; - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java index a4a973ff56273..9b43451d2ca9c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java @@ -26,8 +26,6 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteState; import org.apache.ignite.Ignition; -import org.apache.ignite.configuration.DeploymentMode; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.events.Event; import org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException; import org.apache.ignite.internal.util.typedef.G; @@ -75,15 +73,6 @@ protected GridCacheNodeFailureAbstractTest() { super(false /*start grid. */); } - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - - c.setDeploymentMode(DeploymentMode.SHARED); - - return c; - } - /** * @throws Exception If failed. */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePreloadLifecycleAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePreloadLifecycleAbstractTest.java index 3b6ee2808eea2..01b32ae83bbd0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePreloadLifecycleAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePreloadLifecycleAbstractTest.java @@ -19,7 +19,6 @@ import java.io.Serializable; import org.apache.ignite.cache.CacheRebalanceMode; -import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lifecycle.LifecycleBean; @@ -66,7 +65,6 @@ public abstract class GridCachePreloadLifecycleAbstractTest extends GridCommonAb c.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED); c.setIncludeProperties(); - c.setDeploymentMode(DeploymentMode.SHARED); c.setNetworkTimeout(10000); c.setConnectorConfiguration(null); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java index 947539d0a2978..e013047b8ee8b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java @@ -57,7 +57,6 @@ import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; -import static org.apache.ignite.configuration.DeploymentMode.CONTINUOUS; import static org.apache.ignite.events.EventType.EVTS_ALL; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_STARTED; @@ -102,8 +101,6 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cacheConfiguration(igniteInstanceName)); - cfg.setDeploymentMode(CONTINUOUS); - cfg.setUserAttributes(F.asMap("EVEN", !igniteInstanceName.endsWith("0") && !igniteInstanceName.endsWith("2"))); MemoryEventStorageSpi spi = new MemoryEventStorageSpi(); diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExceptionTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExceptionTest.java index 44a39859e05b7..890787e029a02 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExceptionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExceptionTest.java @@ -95,7 +95,6 @@ public class ClassLoadingProblemExceptionTest extends GridCommonAbstractTest imp cfg .setClientMode(igniteInstanceName.startsWith(CLIENT_PREFIX)) .setPeerClassLoadingEnabled(true) - .setDeploymentMode(SHARED) .setCommunicationSpi(new TestCommunicationSpi()); return cfg; diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExtendedLoggingTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExtendedLoggingTest.java index fd0f825c3bc50..17c272ae86661 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExtendedLoggingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/ClassLoadingProblemExtendedLoggingTest.java @@ -33,7 +33,6 @@ import org.junit.runners.Parameterized; import static com.google.common.primitives.Ints.asList; -import static org.apache.ignite.configuration.DeploymentMode.SHARED; import static org.apache.ignite.internal.TestRecordingCommunicationSpi.spi; import static org.apache.ignite.testframework.GridTestUtils.setFieldValue; @@ -65,7 +64,6 @@ public static List allowSuccessfulClassRequestsCntList() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { return super.getConfiguration(igniteInstanceName) .setPeerClassLoadingEnabled(true) - .setDeploymentMode(SHARED) .setCommunicationSpi(new TestRecordingCommunicationSpi()) .setGridLogger(listeningLog) .setNetworkTimeout(1000); diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/SharedDeploymentTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/SharedDeploymentTest.java index 51966fa93a97f..adab96325bb4a 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/SharedDeploymentTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/SharedDeploymentTest.java @@ -22,7 +22,6 @@ import java.net.URL; import java.util.Collection; import org.apache.ignite.Ignite; -import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.testframework.GridTestExternalClassLoader; @@ -48,8 +47,7 @@ public class SharedDeploymentTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { return super.getConfiguration(igniteInstanceName) - .setPeerClassLoadingEnabled(true) - .setDeploymentMode(DeploymentMode.SHARED); + .setPeerClassLoadingEnabled(true); } /** diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java index fff7dd11c1a69..666719c08ff6b 100755 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java @@ -79,7 +79,6 @@ import org.apache.ignite.internal.processors.cache.context.IgniteCacheP2PDisableExecutionContextTest; import org.apache.ignite.internal.processors.cache.context.IgniteCachePrivateExecutionContextTest; import org.apache.ignite.internal.processors.cache.context.IgniteCacheReplicatedExecutionContextTest; -import org.apache.ignite.internal.processors.cache.context.IgniteCacheSharedExecutionContextTest; import org.apache.ignite.internal.processors.cache.context.IgniteCacheTxExecutionContextTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteCrossCacheTxStoreSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheGetStoreErrorSelfTest; @@ -150,7 +149,6 @@ public static List> suite(Collection ignoredTests) { GridTestUtils.addTestIfNeeded(suite, IgniteCacheIsolatedExecutionContextTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, IgniteCacheP2PDisableExecutionContextTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, IgniteCachePrivateExecutionContextTest.class, ignoredTests); - GridTestUtils.addTestIfNeeded(suite, IgniteCacheSharedExecutionContextTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, StoreArrayKeyTest.class, ignoredTests); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java index d7721472b576c..7a0c444bebbd2 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java @@ -31,7 +31,6 @@ import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; -import static org.apache.ignite.configuration.DeploymentMode.SHARED; /** * Test for cache swap. @@ -54,8 +53,6 @@ public class GridCacheOffHeapSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cacheCfg); - cfg.setDeploymentMode(SHARED); - return cfg; } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java index e8a0800fe0f70..a9f6e9cbb2719 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java @@ -38,7 +38,6 @@ import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; -import static org.apache.ignite.configuration.DeploymentMode.SHARED; /** * Tests off heap storage when both offheaped and swapped entries exists. @@ -50,8 +49,6 @@ public class GridCacheOffheapIndexGetSelfTest extends GridCommonAbstractTest { cfg.setNetworkTimeout(2000); - cfg.setDeploymentMode(SHARED); - return cfg; } From 3c07531ffa813cab1225ba4354e992940f09fe0b Mon Sep 17 00:00:00 2001 From: Nikolay Izhikov Date: Sat, 7 Mar 2026 18:27:46 +0300 Subject: [PATCH 3/8] WIP --- ...teCacheContinuousExecutionContextTest.java | 35 ------------------- ...niteCacheIsolatedExecutionContextTest.java | 35 ------------------- ...gniteCachePrivateExecutionContextTest.java | 35 ------------------- .../testsuites/IgniteCacheTestSuite.java | 6 ---- 4 files changed, 111 deletions(-) delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheContinuousExecutionContextTest.java delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheIsolatedExecutionContextTest.java delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCachePrivateExecutionContextTest.java diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheContinuousExecutionContextTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheContinuousExecutionContextTest.java deleted file mode 100644 index 44ddb782e98bc..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheContinuousExecutionContextTest.java +++ /dev/null @@ -1,35 +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.internal.processors.cache.context; - -import org.apache.ignite.configuration.DeploymentMode; -import org.apache.ignite.configuration.IgniteConfiguration; - -/** - * - */ -public class IgniteCacheContinuousExecutionContextTest extends IgniteCacheAtomicExecutionContextTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - cfg.setDeploymentMode(DeploymentMode.CONTINUOUS); - - return cfg; - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheIsolatedExecutionContextTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheIsolatedExecutionContextTest.java deleted file mode 100644 index fa1d9624740f5..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheIsolatedExecutionContextTest.java +++ /dev/null @@ -1,35 +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.internal.processors.cache.context; - -import org.apache.ignite.configuration.DeploymentMode; -import org.apache.ignite.configuration.IgniteConfiguration; - -/** - * - */ -public class IgniteCacheIsolatedExecutionContextTest extends IgniteCacheP2PDisableExecutionContextTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - cfg.setDeploymentMode(DeploymentMode.ISOLATED); - - return cfg; - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCachePrivateExecutionContextTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCachePrivateExecutionContextTest.java deleted file mode 100644 index 57d2a8ee8a018..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCachePrivateExecutionContextTest.java +++ /dev/null @@ -1,35 +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.internal.processors.cache.context; - -import org.apache.ignite.configuration.DeploymentMode; -import org.apache.ignite.configuration.IgniteConfiguration; - -/** - * - */ -public class IgniteCachePrivateExecutionContextTest extends IgniteCacheP2PDisableExecutionContextTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - cfg.setDeploymentMode(DeploymentMode.PRIVATE); - - return cfg; - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java index 666719c08ff6b..679b105e2ecf6 100755 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java @@ -74,10 +74,7 @@ import org.apache.ignite.internal.processors.cache.IgnitePutAllLargeBatchSelfTest; import org.apache.ignite.internal.processors.cache.IgnitePutAllUpdateNonPreloadedPartitionSelfTest; import org.apache.ignite.internal.processors.cache.context.IgniteCacheAtomicExecutionContextTest; -import org.apache.ignite.internal.processors.cache.context.IgniteCacheContinuousExecutionContextTest; -import org.apache.ignite.internal.processors.cache.context.IgniteCacheIsolatedExecutionContextTest; import org.apache.ignite.internal.processors.cache.context.IgniteCacheP2PDisableExecutionContextTest; -import org.apache.ignite.internal.processors.cache.context.IgniteCachePrivateExecutionContextTest; import org.apache.ignite.internal.processors.cache.context.IgniteCacheReplicatedExecutionContextTest; import org.apache.ignite.internal.processors.cache.context.IgniteCacheTxExecutionContextTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteCrossCacheTxStoreSelfTest; @@ -145,10 +142,7 @@ public static List> suite(Collection ignoredTests) { GridTestUtils.addTestIfNeeded(suite, IgniteCacheAtomicExecutionContextTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, IgniteCacheReplicatedExecutionContextTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, IgniteCacheTxExecutionContextTest.class, ignoredTests); - GridTestUtils.addTestIfNeeded(suite, IgniteCacheContinuousExecutionContextTest.class, ignoredTests); - GridTestUtils.addTestIfNeeded(suite, IgniteCacheIsolatedExecutionContextTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, IgniteCacheP2PDisableExecutionContextTest.class, ignoredTests); - GridTestUtils.addTestIfNeeded(suite, IgniteCachePrivateExecutionContextTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, StoreArrayKeyTest.class, ignoredTests); From 993f71d4c9cd559c18f5d89d08b1b5f3bcf39021 Mon Sep 17 00:00:00 2001 From: Nikolay Izhikov Date: Tue, 10 Mar 2026 12:25:04 +0300 Subject: [PATCH 4/8] WIP --- .../processors/cache/GridCachePutAllFailoverSelfTest.java | 3 --- .../replicated/GridCacheSyncReplicatedPreloadSelfTest.java | 2 -- 2 files changed, 5 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java index 819a062d862ef..a68706fa33c22 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java @@ -42,7 +42,6 @@ import org.apache.ignite.compute.ComputeJobContext; import org.apache.ignite.compute.ComputeTaskFuture; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.IgniteKernal; @@ -659,8 +658,6 @@ protected CacheAtomicityMode atomicityMode() { cfg.setPeerClassLoadingEnabled(false); - cfg.setDeploymentMode(DeploymentMode.CONTINUOUS); - TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); discoverySpi.setAckTimeout(60000); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheSyncReplicatedPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheSyncReplicatedPreloadSelfTest.java index 39124b2aab58d..6c009a70a122d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheSyncReplicatedPreloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheSyncReplicatedPreloadSelfTest.java @@ -30,7 +30,6 @@ import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; -import static org.apache.ignite.configuration.DeploymentMode.CONTINUOUS; /** * Multithreaded tests for replicated cache preloader. @@ -59,7 +58,6 @@ public GridCacheSyncReplicatedPreloadSelfTest() { cacheCfg.setRebalanceBatchSize(10000); cfg.setCacheConfiguration(cacheCfg); - cfg.setDeploymentMode(CONTINUOUS); return cfg; } From baecc444b84e50e908ab4761eb4b2702760aed03 Mon Sep 17 00:00:00 2001 From: Nikolay Izhikov Date: Tue, 10 Mar 2026 12:32:29 +0300 Subject: [PATCH 5/8] WIP --- .../distributed/dht/GridCacheDhtPreloadBigDataSelfTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadBigDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadBigDataSelfTest.java index 5b3892821f368..4e3d5303c070d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadBigDataSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadBigDataSelfTest.java @@ -34,7 +34,6 @@ import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; -import static org.apache.ignite.configuration.DeploymentMode.CONTINUOUS; import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_REBALANCE_BATCH_SIZE; /** @@ -92,7 +91,6 @@ public GridCacheDhtPreloadBigDataSelfTest() { c.setLifecycleBeans(lbean); c.setCacheConfiguration(cc); - c.setDeploymentMode(CONTINUOUS); c.setNetworkTimeout(1000); return c; From b4b1300e5d45fd5a265e5875677803fa3691800a Mon Sep 17 00:00:00 2001 From: Nikolay Izhikov Date: Tue, 10 Mar 2026 12:33:56 +0300 Subject: [PATCH 6/8] WIP --- .../distributed/GridCachePreloadRestartAbstractSelfTest.java | 3 --- .../distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java | 2 -- 2 files changed, 5 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePreloadRestartAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePreloadRestartAbstractSelfTest.java index 7cbe02cd66930..c000455688cb0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePreloadRestartAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePreloadRestartAbstractSelfTest.java @@ -32,7 +32,6 @@ import static org.apache.ignite.cache.CacheRebalanceMode.NONE; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; -import static org.apache.ignite.configuration.DeploymentMode.CONTINUOUS; import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_REBALANCE_BATCH_SIZE; import static org.apache.ignite.internal.util.lang.ClusterNodeFunc.nodeIds; @@ -95,8 +94,6 @@ public abstract class GridCachePreloadRestartAbstractSelfTest extends GridCommon @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - c.setDeploymentMode(CONTINUOUS); - // Cache. CacheConfiguration cc = defaultCacheConfiguration(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java index 42060fab26162..86e79299a2e3b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java @@ -43,7 +43,6 @@ import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.NONE; -import static org.apache.ignite.configuration.DeploymentMode.CONTINUOUS; import static org.apache.ignite.events.EventType.EVTS_CACHE_REBALANCE; import static org.apache.ignite.internal.util.lang.ClusterNodeFunc.nodeIds; @@ -91,7 +90,6 @@ public GridCacheDhtPreloadDisabledSelfTest() { //cacheCfg.setRebalanceThreadPoolSize(1); cfg.setCacheConfiguration(cacheCfg); - cfg.setDeploymentMode(CONTINUOUS); return cfg; } From b2e2d1f08f35aac801e1f047b656db2a7020b99a Mon Sep 17 00:00:00 2001 From: Nikolay Izhikov Date: Tue, 10 Mar 2026 13:23:51 +0300 Subject: [PATCH 7/8] WIP --- ...CacheConfigurationConsistencySelfTest.java | 42 ------------------- .../dht/GridCacheDhtPreloadSelfTest.java | 2 - .../GridCacheDhtPreloadStartStopSelfTest.java | 2 - .../GridCacheDhtPreloadUnloadSelfTest.java | 2 - 4 files changed, 48 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java index 4e6964e48933c..190d5ea04fa4a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java @@ -35,7 +35,6 @@ import org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicyFactory; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.util.typedef.C1; @@ -56,8 +55,6 @@ import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_ASYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.configuration.CacheConfiguration.DFLT_CACHE_MODE; -import static org.apache.ignite.configuration.DeploymentMode.CONTINUOUS; -import static org.apache.ignite.configuration.DeploymentMode.SHARED; /** * @@ -73,9 +70,6 @@ public class GridCacheConfigurationConsistencySelfTest extends GridCommonAbstrac /** */ private CacheMode cacheMode = REPLICATED; - /** */ - private DeploymentMode depMode = SHARED; - /** */ private C1 initCache; @@ -105,8 +99,6 @@ public class GridCacheConfigurationConsistencySelfTest extends GridCommonAbstrac cfg.setGridLogger(strLog); } - cfg.setDeploymentMode(depMode); - if (cacheEnabled) { CacheConfiguration cacheCfg = defaultCacheConfiguration(); @@ -185,7 +177,6 @@ public void testNullCacheMode() throws Exception { cacheEnabled = true; cacheName = "myCache"; cacheMode = null; - depMode = SHARED; assert startGrid(1).cache("myCache").getConfiguration(CacheConfiguration.class).getCacheMode() == DFLT_CACHE_MODE; } @@ -197,7 +188,6 @@ public void testNullCacheMode() throws Exception { public void testWithCacheAndWithoutCache() throws Exception { // 1st grid without cache. cacheEnabled = false; - depMode = SHARED; startGrid(2); @@ -205,7 +195,6 @@ public void testWithCacheAndWithoutCache() throws Exception { cacheEnabled = true; cacheName = "myCache"; cacheMode = REPLICATED; - depMode = SHARED; startGrid(1); } @@ -219,7 +208,6 @@ public void testSameCacheDifferentModes() throws Exception { cacheEnabled = true; cacheName = "myCache"; cacheMode = REPLICATED; - depMode = SHARED; startGrid(1); @@ -227,7 +215,6 @@ public void testSameCacheDifferentModes() throws Exception { cacheEnabled = true; cacheName = "myCache"; cacheMode = PARTITIONED; - depMode = SHARED; try { startGrid(2); @@ -248,7 +235,6 @@ public void testDifferentCacheDifferentModes() throws Exception { cacheEnabled = true; cacheName = "replicated"; cacheMode = REPLICATED; - depMode = SHARED; startGrid(2); @@ -256,7 +242,6 @@ public void testDifferentCacheDifferentModes() throws Exception { cacheEnabled = true; cacheName = "partitioned"; cacheMode = PARTITIONED; - depMode = SHARED; startGrid(3); @@ -264,37 +249,10 @@ public void testDifferentCacheDifferentModes() throws Exception { cacheEnabled = true; cacheName = "partitioned"; cacheMode = null; - depMode = SHARED; startGrid(4); } - /** - * @throws Exception If failed. - */ - @Test - public void testDifferentDeploymentModes() throws Exception { - // 1st grid with SHARED mode. - cacheEnabled = true; - cacheName = "partitioned"; - cacheMode = PARTITIONED; - depMode = SHARED; - - startGrid(1); - - // 2nd grid with CONTINUOUS mode. - cacheEnabled = true; - cacheName = "partitioned"; - cacheMode = PARTITIONED; - depMode = CONTINUOUS; - - GridTestUtils.assertThrows(log, new Callable() { - @Override public Object call() throws Exception { - return startGrid(2); - } - }, IgniteCheckedException.class, null); - } - /** * @throws Exception If failed. */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java index 649dbd24a9979..82d697ee4d950 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java @@ -50,7 +50,6 @@ import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; -import static org.apache.ignite.configuration.DeploymentMode.CONTINUOUS; import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_REBALANCE_BATCH_SIZE; import static org.apache.ignite.events.EventType.EVTS_CACHE_REBALANCE; import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.MOVING; @@ -101,7 +100,6 @@ public GridCacheDhtPreloadSelfTest() { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setCacheConfiguration(cacheConfiguration(igniteInstanceName)); - cfg.setDeploymentMode(CONTINUOUS); return cfg; } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java index 47362d65149ed..d1c042aa25755 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java @@ -41,7 +41,6 @@ import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; -import static org.apache.ignite.configuration.DeploymentMode.CONTINUOUS; import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_REBALANCE_BATCH_SIZE; import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING; @@ -109,7 +108,6 @@ public GridCacheDhtPreloadStartStopSelfTest() { } cfg.setCacheConfiguration(cacheCfgs); - cfg.setDeploymentMode(CONTINUOUS); return cfg; } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadUnloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadUnloadSelfTest.java index a2728aa9a3874..f887fc2c67d72 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadUnloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadUnloadSelfTest.java @@ -35,7 +35,6 @@ import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; -import static org.apache.ignite.configuration.DeploymentMode.CONTINUOUS; import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_REBALANCE_BATCH_SIZE; /** @@ -95,7 +94,6 @@ public GridCacheDhtPreloadUnloadSelfTest() { c.setLifecycleBeans(lbean); c.setCacheConfiguration(cc); - c.setDeploymentMode(CONTINUOUS); c.setNetworkTimeout(netTimeout); return c; From a7b9b5060f77d72287f114358736f5bfa373b2d7 Mon Sep 17 00:00:00 2001 From: Nikolay Izhikov Date: Tue, 10 Mar 2026 13:34:48 +0300 Subject: [PATCH 8/8] WIP --- ...ridDiscoveryManagerAttributesSelfTest.java | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java index a89a8dfb11f88..c6907fa33f89e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java @@ -19,7 +19,6 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.marshaller.Marshallers; @@ -30,8 +29,6 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2; import static org.apache.ignite.IgniteSystemProperties.IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID; import static org.apache.ignite.IgniteSystemProperties.IGNITE_SECURITY_COMPATIBILITY_MODE; -import static org.apache.ignite.configuration.DeploymentMode.CONTINUOUS; -import static org.apache.ignite.configuration.DeploymentMode.SHARED; /** * Tests for node attributes consistency checks. @@ -40,9 +37,6 @@ public class GridDiscoveryManagerAttributesSelfTest extends GridCommonAbstractTe /** */ private static final String PREFER_IPV4 = "java.net.preferIPv4Stack"; - /** */ - private static DeploymentMode mode; - /** */ private static boolean p2pEnabled; @@ -54,7 +48,6 @@ public class GridDiscoveryManagerAttributesSelfTest extends GridCommonAbstractTe IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setIncludeProperties(PREFER_IPV4); - cfg.setDeploymentMode(mode); cfg.setPeerClassLoadingEnabled(p2pEnabled); if (secEnabled) @@ -65,8 +58,6 @@ public class GridDiscoveryManagerAttributesSelfTest extends GridCommonAbstractTe /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { - mode = SHARED; - p2pEnabled = false; } @@ -315,28 +306,6 @@ private void doTestCompatibilityEnabled(String prop, Object first, Object second } } - /** - * @throws Exception If failed. - */ - @Test - public void testDifferentDeploymentModes() throws Exception { - IgniteEx g = startGrid(0); - - checkIsClientFlag(g); - - mode = CONTINUOUS; - - try { - startClientGrid(1); - - fail(); - } - catch (IgniteCheckedException e) { - if (!e.getCause().getMessage().startsWith("Remote node has deployment mode different from")) - throw e; - } - } - /** * @throws Exception If failed. */