Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1837,6 +1837,15 @@ public static class GridCacheDataStore implements CacheDataStore {
*/
private volatile long nextStoreCleanTimeNanos;

/** */
private GridQueryRowCacheCleaner rowCacheCleaner;

/**
* Mutex used to synchronise publication of initialized delegate link and actions that should change
* the delegate's state, so the delegate will not be in obsolete state.
*/
private final Object delegatePublicationMux = new Object();

/** */
private PartitionMetaStorage<SimpleDataRow> partStorage;

Expand Down Expand Up @@ -2130,7 +2139,11 @@ private CacheDataStore init0(boolean checkExists) throws IgniteCheckedException
pageMem.releasePage(grpId, partMetaId, partMetaPage);
}

delegate = delegate0;
synchronized (delegatePublicationMux) {
delegate0.setRowCacheCleaner(rowCacheCleaner);

delegate = delegate0;
}
}
catch (Throwable ex) {
U.error(log, "Unhandled exception during page store initialization. All further operations will " +
Expand Down Expand Up @@ -2532,6 +2545,10 @@ private Metas getOrAllocatePartitionMetas() throws IgniteCheckedException {
/** {@inheritDoc} */
@Override public void setRowCacheCleaner(GridQueryRowCacheCleaner rowCacheCleaner) {
try {
synchronized (delegatePublicationMux) {
this.rowCacheCleaner = rowCacheCleaner;
}

CacheDataStore delegate0 = init0(true);

if (delegate0 != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class RowStore {
private final boolean persistenceEnabled;

/** Row cache cleaner. */
private GridQueryRowCacheCleaner rowCacheCleaner;
private volatile GridQueryRowCacheCleaner rowCacheCleaner;

/** */
protected final CacheGroupContext grp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,42 @@

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

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import javax.cache.Cache;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.cache.QueryEntity;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.SqlQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.query.h2.H2RowCache;
import org.apache.ignite.internal.processors.query.h2.opt.H2CacheRow;
import org.apache.ignite.testframework.GridTestUtils;
import org.jsr166.ConcurrentLinkedHashMap;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

/**
* Tests H2RowCacheRegistry.
*/
@RunWith(Parameterized.class)
@SuppressWarnings({"unchecked", "ConstantConditions"})
public class H2RowCacheSelfTest extends AbstractIndexingCommonTest {
/** Keys count. */
Expand All @@ -51,18 +61,45 @@ public class H2RowCacheSelfTest extends AbstractIndexingCommonTest {
/** Random generator. */
private static final Random RND = new Random(System.currentTimeMillis());

/** */
@Parameterized.Parameters(name = "persistenceEnabled={0}")
public static Collection<Object[]> testParams() {
return Arrays.asList(new Object[]{true}, new Object[]{false});
}

/** */
@Parameterized.Parameter
public boolean persistenceEnabled;

/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
startGrid();
cleanPersistenceDir();

Ignite ignite = startGrid();

if (persistenceEnabled)
ignite.cluster().state(ClusterState.ACTIVE);
}

/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
stopAllGrids();

cleanPersistenceDir();

super.afterTest();
}

/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
return super.getConfiguration(igniteInstanceName)
.setDataStorageConfiguration(
new DataStorageConfiguration().setDefaultDataRegionConfiguration(
new DataRegionConfiguration().setPersistenceEnabled(persistenceEnabled)
)
);
}

/**
* @param name Cache name.
* @param enableOnheapCache Enable on-heal SQL rows cache.
Expand Down