You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2016/08/26 09:16:06 UTC
[02/50] ignite git commit: ignite-1018 No need to guard nodeLocalMap
ignite-1018 No need to guard nodeLocalMap
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fc4c68b0
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fc4c68b0
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fc4c68b0
Branch: refs/heads/ignite-3443
Commit: fc4c68b01ad26421bd964852c92dc769c6d2def4
Parents: 4199ff4
Author: sboikov <sb...@gridgain.com>
Authored: Wed Aug 17 16:06:25 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Aug 17 16:06:25 2016 +0300
----------------------------------------------------------------------
.../internal/cluster/IgniteClusterImpl.java | 9 +--
.../IgniteLocalNodeMapBeforeStartTest.java | 82 ++++++++++++++++++++
.../ignite/testsuites/IgniteBasicTestSuite.java | 3 +-
3 files changed, 85 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fc4c68b0/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java
index 98d8c5e..aa5e63f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java
@@ -132,14 +132,7 @@ public class IgniteClusterImpl extends ClusterGroupAdapter implements IgniteClus
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public <K, V> ConcurrentMap<K, V> nodeLocalMap() {
- guard();
-
- try {
- return nodeLoc;
- }
- finally {
- unguard();
- }
+ return nodeLoc;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/fc4c68b0/modules/core/src/test/java/org/apache/ignite/internal/IgniteLocalNodeMapBeforeStartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteLocalNodeMapBeforeStartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteLocalNodeMapBeforeStartTest.java
new file mode 100644
index 0000000..5f22399
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteLocalNodeMapBeforeStartTest.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ConcurrentMap;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.lifecycle.LifecycleBean;
+import org.apache.ignite.lifecycle.LifecycleEventType;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.lifecycle.LifecycleEventType.AFTER_NODE_START;
+import static org.apache.ignite.lifecycle.LifecycleEventType.AFTER_NODE_STOP;
+import static org.apache.ignite.lifecycle.LifecycleEventType.BEFORE_NODE_START;
+import static org.apache.ignite.lifecycle.LifecycleEventType.BEFORE_NODE_STOP;
+
+/**
+ *
+ */
+public class IgniteLocalNodeMapBeforeStartTest extends GridCommonAbstractTest {
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNodeLocalMapFromLifecycleBean() throws Exception {
+ IgniteConfiguration cfg = getConfiguration(getTestGridName(0));
+
+ LifecycleBeanTest lifecycleBean = new LifecycleBeanTest();
+
+ // Provide lifecycle bean to configuration.
+ cfg.setLifecycleBeans(lifecycleBean);
+
+ try (Ignite ignite = Ignition.start(cfg)) {
+ // No-op.
+ }
+
+ assertTrue(lifecycleBean.evtQueue.size() == 4);
+ assertTrue(lifecycleBean.evtQueue.poll() == BEFORE_NODE_START);
+ assertTrue(lifecycleBean.evtQueue.poll() == AFTER_NODE_START);
+ assertTrue(lifecycleBean.evtQueue.poll() == BEFORE_NODE_STOP);
+ assertTrue(lifecycleBean.evtQueue.poll() == AFTER_NODE_STOP);
+ }
+
+ /**
+ * Simple {@link LifecycleBean} implementation.
+ */
+ private static class LifecycleBeanTest implements LifecycleBean {
+ /** Auto-inject ignite instance. */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** Event queue. */
+ ConcurrentLinkedQueue<LifecycleEventType> evtQueue = new ConcurrentLinkedQueue<>();
+
+ /** {@inheritDoc} */
+ @Override public void onLifecycleEvent(LifecycleEventType evt) {
+ evtQueue.add(evt);
+
+ // check nodeLocalMap is not locked
+ ConcurrentMap map = ignite.cluster().nodeLocalMap();
+
+ assertNotNull(map);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/fc4c68b0/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index 6611500..52b6bfd 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -32,6 +32,7 @@ import org.apache.ignite.internal.GridReleaseTypeSelfTest;
import org.apache.ignite.internal.GridSelfTest;
import org.apache.ignite.internal.GridStartStopSelfTest;
import org.apache.ignite.internal.GridStopWithCancelSelfTest;
+import org.apache.ignite.internal.IgniteLocalNodeMapBeforeStartTest;
import org.apache.ignite.internal.IgniteSlowClientDetectionSelfTest;
import org.apache.ignite.internal.processors.affinity.GridAffinityProcessorRendezvousSelfTest;
import org.apache.ignite.internal.processors.cache.GridProjectionForCachesOnDaemonNodeSelfTest;
@@ -125,7 +126,7 @@ public class IgniteBasicTestSuite extends TestSuite {
suite.addTestSuite(GridNodeMetricsLogSelfTest.class);
suite.addTestSuite(IgniteExceptionInNioWorkerSelfTest.class);
-
+ suite.addTestSuite(IgniteLocalNodeMapBeforeStartTest.class);
suite.addTestSuite(OdbcProcessorValidationSelfTest.class);
GridTestUtils.addTestIfNeeded(suite, DynamicProxySerializationMultiJvmSelfTest.class, ignoredTests);