Skip to content

Commit 7c21098

Browse files
ibessonovagoncharuk
authored andcommitted
IGNITE-11390 Fixed distributed metastorage start for an in-memory cluster - Fixes apache#6170.
Signed-off-by: Alexey Goncharuk <[email protected]>
1 parent fb898be commit 7c21098

File tree

7 files changed

+80
-33
lines changed

7 files changed

+80
-33
lines changed

modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/baseline/autoadjust/ChangeTopologyWatcher.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public ChangeTopologyWatcher(GridKernalContext ctx) {
9797
if (isLocalNodeCoordinator(discoveryMgr)) {
9898
exchangeManager.affinityReadyFuture(new AffinityTopologyVersion(discoEvt.topologyVersion()))
9999
.listen((IgniteInClosure<IgniteInternalFuture<AffinityTopologyVersion>>)future -> {
100+
if (future.error() != null)
101+
return;
100102

101103
if (exchangeManager.lastFinishedFuture().hasLostPartitions()) {
102104
log.warning("Baseline won't be changed cause the lost partitions were detected");

modules/core/src/main/java/org/apache/ignite/internal/processors/metastorage/persistence/DistributedMetaStorageImpl.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ public DistributedMetaStorageImpl(GridKernalContext ctx) {
185185
ver = DistributedMetaStorageVersion.INITIAL_VERSION;
186186

187187
bridge = new EmptyDistributedMetaStorageBridge();
188-
189-
for (DistributedMetastorageLifecycleListener subscriber : subscrProcessor.getDistributedMetastorageSubscribers())
190-
subscriber.onReadyForRead(this);
191188
}
192189

193190
GridDiscoveryManager discovery = ctx.discovery();
@@ -205,6 +202,14 @@ public DistributedMetaStorageImpl(GridKernalContext ctx) {
205202

206203
/** {@inheritDoc} */
207204
@Override public void onKernalStart(boolean active) throws IgniteCheckedException {
205+
if (ctx.clientNode() || ctx.isDaemon())
206+
return;
207+
208+
if (!isPersistenceEnabled(ctx.config())) {
209+
for (DistributedMetastorageLifecycleListener subscriber : subscrProcessor.getDistributedMetastorageSubscribers())
210+
subscriber.onReadyForRead(this);
211+
}
212+
208213
if (active)
209214
onActivate(ctx);
210215
}
Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
2424
import org.junit.Test;
2525

26+
import static org.junit.Assume.assumeTrue;
27+
2628
/**
2729
*
2830
*/
29-
public class DistributedConfigurationTest extends GridCommonAbstractTest {
31+
public abstract class DistributedConfigurationAbstractTest extends GridCommonAbstractTest {
3032
/** */
3133
private static final String TEST_PROP = "someLong";
3234

@@ -57,48 +59,24 @@ public class DistributedConfigurationTest extends GridCommonAbstractTest {
5759
DataStorageConfiguration storageCfg = new DataStorageConfiguration();
5860

5961
storageCfg.getDefaultDataRegionConfiguration()
60-
.setPersistenceEnabled(true)
62+
.setPersistenceEnabled(isPersistent())
6163
.setMaxSize(500L * 1024 * 1024);
6264

6365
cfg.setDataStorageConfiguration(storageCfg);
6466

6567
return cfg;
6668
}
6769

68-
// /**
69-
// * @throws Exception If failed.
70-
// */
71-
// @Test
72-
// public void test() throws Exception {
73-
// IgniteEx ignite0 = startGrid(0);
74-
// IgniteEx ignite1 = startGrid(1);
75-
//
76-
// ignite0.cluster().active(true);
77-
//
78-
// Assert.assertEquals(0, ignite0.cluster().baselineConfiguration().getBaselineAutoAdjustTimeout());
79-
// Assert.assertEquals(0, ignite1.cluster().baselineConfiguration().getBaselineAutoAdjustTimeout());
80-
//
81-
// ignite0.cluster().baselineConfiguration().setBaselineAutoAdjustTimeout(2);
82-
//
83-
// Assert.assertEquals(2, ignite0.cluster().baselineConfiguration().getBaselineAutoAdjustTimeout());
84-
// Assert.assertEquals(2, ignite1.cluster().baselineConfiguration().getBaselineAutoAdjustTimeout());
85-
//
86-
// stopAllGrids();
87-
//
88-
// ignite0 = startGrid(0);
89-
// ignite1 = startGrid(1);
90-
//
91-
// ignite0.cluster().active(true);
92-
//
93-
// Assert.assertEquals(2, ignite0.cluster().baselineConfiguration().getBaselineAutoAdjustTimeout());
94-
// Assert.assertEquals(2, ignite1.cluster().baselineConfiguration().getBaselineAutoAdjustTimeout());
95-
// }
70+
/** */
71+
protected abstract boolean isPersistent();
9672

9773
/**
9874
* @throws Exception If failed.
9975
*/
10076
@Test
10177
public void testSuccessClusterWideUpdate() throws Exception {
78+
assumeTrue(isPersistent());
79+
10280
IgniteEx ignite0 = startGrid(0);
10381
IgniteEx ignite1 = startGrid(1);
10482

@@ -135,6 +113,8 @@ public void testSuccessClusterWideUpdate() throws Exception {
135113
*/
136114
@Test
137115
public void testReadLocalValueOnInactiveGrid() throws Exception {
116+
assumeTrue(isPersistent());
117+
138118
IgniteEx ignite0 = startGrid(0);
139119
startGrid(1);
140120

@@ -193,6 +173,8 @@ public void testNotAttachedProperty() throws Exception {
193173
*/
194174
@Test(expected = NotWritablePropertyException.class)
195175
public void testPropagateValueOnInactiveGridShouldThrowException() throws Exception {
176+
assumeTrue(isPersistent());
177+
196178
IgniteEx ignite0 = (IgniteEx)startGrids(2);
197179

198180
DistributedLongProperty long0 = ignite0.context().distributedConfiguration().registerLong(TEST_PROP, 0L);
@@ -205,6 +187,8 @@ public void testPropagateValueOnInactiveGridShouldThrowException() throws Except
205187
*/
206188
@Test
207189
public void testReadInitValueBeforeOnReadyForReady() throws Exception {
190+
assumeTrue(isPersistent());
191+
208192
IgniteEx ignite0 = startGrid(0);
209193
IgniteEx ignite1 = startGrid(1);
210194

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.ignite.internal.processors.configuration.distributed;
19+
20+
/** */
21+
public class DistributedConfigurationInMemoryTest extends DistributedConfigurationAbstractTest {
22+
/** {@inheritDoc} */
23+
@Override protected boolean isPersistent() {
24+
return false;
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.ignite.internal.processors.configuration.distributed;
19+
20+
/** */
21+
public class DistributedConfigurationPersistentTest extends DistributedConfigurationAbstractTest {
22+
/** {@inheritDoc} */
23+
@Override protected boolean isPersistent() {
24+
return true;
25+
}
26+
}

modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import org.apache.ignite.internal.processors.closure.GridClosureProcessorRemoteTest;
6666
import org.apache.ignite.internal.processors.closure.GridClosureProcessorSelfTest;
6767
import org.apache.ignite.internal.processors.closure.GridClosureSerializationTest;
68+
import org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationInMemoryTest;
6869
import org.apache.ignite.internal.processors.continuous.GridEventConsumeSelfTest;
6970
import org.apache.ignite.internal.processors.continuous.GridMessageListenSelfTest;
7071
import org.apache.ignite.internal.processors.database.BPlusTreeFakeReuseSelfTest;
@@ -214,6 +215,7 @@
214215

215216
// In-memory Distributed MetaStorage.
216217
DistributedMetaStorageTest.class,
218+
DistributedConfigurationInMemoryTest.class,
217219

218220
ConsistentIdImplicitlyExplicitlyTest.class,
219221

modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.apache.ignite.internal.processors.cache.persistence.wal.SegmentedRingByteBufferTest;
5151
import org.apache.ignite.internal.processors.cache.persistence.wal.SysPropWalDeltaConsistencyTest;
5252
import org.apache.ignite.internal.processors.cache.persistence.wal.aware.SegmentAwareTest;
53+
import org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationPersistentTest;
5354
import org.apache.ignite.internal.processors.database.IgniteDbDynamicCacheSelfTest;
5455
import org.apache.ignite.internal.processors.database.IgniteDbMultiNodePutGetTest;
5556
import org.apache.ignite.internal.processors.database.IgniteDbPutGetWithCacheStoreTest;
@@ -173,5 +174,6 @@ public static void addRealPageStoreTests(List<Class<?>> suite, Collection<Class>
173174
//MetaStorage
174175
GridTestUtils.addTestIfNeeded(suite, IgniteMetaStorageBasicTest.class, ignoredTests);
175176
GridTestUtils.addTestIfNeeded(suite, DistributedMetaStoragePersistentTest.class, ignoredTests);
177+
GridTestUtils.addTestIfNeeded(suite, DistributedConfigurationPersistentTest.class, ignoredTests);
176178
}
177179
}

0 commit comments

Comments
 (0)