Skip to content

Commit

Permalink
IGNITE-16822 Fix GridCacheLifecycleAwareSelfTest.testLifecycleAware (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
nizhikov authored Apr 8, 2022
1 parent ff6116f commit ee80c57
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.apache.ignite.internal.processors.cache;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand All @@ -32,14 +31,11 @@
import org.apache.ignite.cache.affinity.AffinityFunction;
import org.apache.ignite.cache.affinity.AffinityFunctionContext;
import org.apache.ignite.cache.affinity.AffinityKeyMapper;
import org.apache.ignite.cache.eviction.EvictableEntry;
import org.apache.ignite.cache.eviction.EvictionFilter;
import org.apache.ignite.cache.eviction.EvictionPolicy;
import org.apache.ignite.cache.store.CacheStore;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.NearCacheConfiguration;
import org.apache.ignite.configuration.TopologyValidator;
import org.apache.ignite.lang.IgniteBiInClosure;
import org.apache.ignite.lang.IgniteBiTuple;
Expand All @@ -60,9 +56,6 @@ public class GridCacheLifecycleAwareSelfTest extends GridAbstractLifecycleAwareS
/** */
private static final String CACHE_NAME = "cache";

/** */
private boolean near;

/** */
private boolean writeBehind;

Expand Down Expand Up @@ -175,21 +168,6 @@ public List<ClusterNode> nodes(int part, Collection<ClusterNode> nodes) {
}
}

/**
*/
public static class TestEvictionPolicy extends TestLifecycleAware implements EvictionPolicy, Serializable {
/**
*/
public TestEvictionPolicy() {
super(CACHE_NAME);
}

/** {@inheritDoc} */
@Override public void onEntryAccessed(boolean rmv, EvictableEntry entry) {
// No-op.
}
}

/**
*/
private static class TestEvictionFilter extends TestLifecycleAware implements EvictionFilter {
Expand Down Expand Up @@ -318,31 +296,10 @@ public TestTopologyValidator() {

lifecycleAwares.add(affinity);

TestEvictionPolicy evictionPlc = new TestEvictionPolicy();

ccfg.setEvictionPolicy(evictionPlc);
ccfg.setOnheapCacheEnabled(true);

lifecycleAwares.add(evictionPlc);

if (near) {
TestEvictionPolicy nearEvictionPlc = new TestEvictionPolicy();

NearCacheConfiguration nearCfg = new NearCacheConfiguration();

nearCfg.setNearEvictionPolicy(nearEvictionPlc);

ccfg.setNearConfiguration(nearCfg);

lifecycleAwares.add(nearEvictionPlc);
}

TestEvictionFilter evictionFilter = new TestEvictionFilter();

ccfg.setEvictionFilter(evictionFilter);

lifecycleAwares.add(evictionFilter);

TestAffinityKeyMapper mapper = new TestAffinityKeyMapper();

ccfg.setAffinityMapper(mapper);
Expand All @@ -351,8 +308,6 @@ public TestTopologyValidator() {

TestInterceptor interceptor = new TestInterceptor();

lifecycleAwares.add(interceptor);

ccfg.setInterceptor(interceptor);

TestTopologyValidator topValidator = new TestTopologyValidator();
Expand All @@ -370,28 +325,22 @@ public TestTopologyValidator() {
@SuppressWarnings("ErrorNotRethrown")
@Test
@Override public void testLifecycleAware() throws Exception {
for (boolean nearEnabled : new boolean[] {true, false}) {
near = nearEnabled;

writeBehind = false;

try {
super.testLifecycleAware();
}
catch (AssertionError e) {
throw new AssertionError("Failed for [near=" + near + ", writeBehind=" + writeBehind + ']',
e);
}

writeBehind = true;

try {
super.testLifecycleAware();
}
catch (AssertionError e) {
throw new AssertionError("Failed for [near=" + near + ", writeBehind=" + writeBehind + ']',
e);
}
writeBehind = false;

try {
super.testLifecycleAware();
}
catch (AssertionError e) {
throw new AssertionError("Failed for [writeBehind=" + writeBehind + ']', e);
}

writeBehind = true;

try {
super.testLifecycleAware();
}
catch (AssertionError e) {
throw new AssertionError("Failed for [writeBehind=" + writeBehind + ']', e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.ignite.testframework.junits.common;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.atomic.AtomicInteger;
Expand All @@ -35,7 +36,7 @@ public abstract class GridAbstractLifecycleAwareSelfTest extends GridCommonAbstr
/**
*/
@SuppressWarnings("PublicInnerClass")
public static class TestLifecycleAware implements LifecycleAware {
public static class TestLifecycleAware implements LifecycleAware, Serializable {
/** */
private AtomicInteger startCnt = new AtomicInteger();

Expand Down

0 comments on commit ee80c57

Please sign in to comment.