You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dm...@apache.org on 2015/10/22 16:47:48 UTC
ignite git commit: ignite-1272: adding test to check entry processor
and deployment mode
Repository: ignite
Updated Branches:
refs/heads/ignite-1272 ddbe92e6c -> 3ee912156
ignite-1272: adding test to check entry processor and deployment mode
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3ee91215
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3ee91215
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3ee91215
Branch: refs/heads/ignite-1272
Commit: 3ee912156eb7e4c6f4430b821ae08b00c51f9e84
Parents: ddbe92e
Author: Denis Magda <dm...@gridgain.com>
Authored: Thu Oct 22 17:47:42 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Thu Oct 22 17:47:42 2015 +0300
----------------------------------------------------------------------
...idCacheEntryProcessorDeploymentSelfTest.java | 124 +++++++++++++++++++
.../p2p/CacheDeploymentEntryProcessor.java | 35 ++++++
2 files changed, 159 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3ee91215/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryProcessorDeploymentSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryProcessorDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryProcessorDeploymentSelfTest.java
new file mode 100644
index 0000000..f171c0b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryProcessorDeploymentSelfTest.java
@@ -0,0 +1,124 @@
+/*
+ * 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;
+
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheEntryProcessor;
+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.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ * Cache EntryProcessor + Deployment.
+ */
+public class GridCacheEntryProcessorDeploymentSelfTest extends GridCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** Entry processor */
+ private static final String TEST_ENT_PROCESSOR = "org.apache.ignite.tests.p2p.CacheDeploymentEntryProcessor";
+
+ /** Test value. */
+ private static final String TEST_VALUE = "org.apache.ignite.tests.p2p.CacheDeploymentTestValue";
+
+ /** */
+ private DeploymentMode depMode;
+
+ /** */
+ private boolean cliendMode;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ if (cliendMode)
+ cfg.setClientMode(cliendMode);
+
+ cfg.setDeploymentMode(depMode);
+
+ cfg.setCacheConfiguration(cacheConfiguration());
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(disco);
+
+ cfg.setConnectorConfiguration(null);
+
+ return cfg;
+ }
+
+ /**
+ * @return Cache configuration.
+ * @throws Exception In case of error.
+ */
+ protected CacheConfiguration cacheConfiguration() throws Exception {
+ CacheConfiguration cfg = defaultCacheConfiguration();
+
+ cfg.setCacheMode(PARTITIONED);
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+ cfg.setRebalanceMode(SYNC);
+ cfg.setAtomicityMode(TRANSACTIONAL);
+ cfg.setNearConfiguration(new NearCacheConfiguration());
+ cfg.setBackups(1);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testInvokeDeployment() throws Exception {
+ depMode = DeploymentMode.CONTINUOUS;
+
+ cliendMode = false;
+ startGrid(0);
+
+ cliendMode = true;
+ startGrid(1);
+
+ ClassLoader ldr = getExternalClassLoader();
+
+ Class procCls = ldr.loadClass(TEST_ENT_PROCESSOR);
+ Class valCls = ldr.loadClass(TEST_VALUE);
+
+ assertTrue(grid(1).configuration().isClientMode());
+
+ IgniteCache cache = grid(1).cache(null);
+
+ cache.put("key", valCls.newInstance());
+
+ Boolean res = (Boolean)cache.invoke("key", (CacheEntryProcessor)procCls.newInstance());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/3ee91215/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentEntryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentEntryProcessor.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentEntryProcessor.java
new file mode 100644
index 0000000..3d66fec
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentEntryProcessor.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.tests.p2p;
+
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.cache.CacheEntryProcessor;
+
+/**
+ * Entry processor for {@code GridCacheEntryProcessorDeploymentSelfTest}.
+ */
+public class CacheDeploymentEntryProcessor implements CacheEntryProcessor<String, CacheDeploymentTestValue, Boolean> {
+ /** {@inheritDoc} */
+ @Override public Boolean process(MutableEntry<String, CacheDeploymentTestValue> entry,
+ Object... arguments) throws EntryProcessorException {
+ CacheDeploymentTestValue val = entry.getValue();
+
+ return true;
+ }
+}