Skip to content

Commit

Permalink
IGNITE-24419 Move checkpoint dir to NodeFileTree
Browse files Browse the repository at this point in the history
  • Loading branch information
nizhikov committed Feb 5, 2025
1 parent a2d8bc1 commit 66c1e11
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.spi.checkpoint.sharedfs.SharedFsCheckpointSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.openjdk.jol.info.GraphLayout;
Expand Down Expand Up @@ -70,7 +71,7 @@ private void cleanPersistenceDir() throws Exception {

SharedFileTree sft = new SharedFileTree(U.defaultWorkDirectory());

U.delete(new File(sft.root(), "cp"));
U.delete(new File(sft.root(), SharedFsCheckpointSpi.DFLT_ROOT));
U.delete(sft.marshaller().getParentFile());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.ignite.internal.util.typedef.internal.U;

import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR;
import static org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree.CHECKPOINT_DIR;
import static org.apache.ignite.internal.processors.cache.persistence.filename.SharedFileTree.BINARY_METADATA_DIR;
import static org.apache.ignite.internal.processors.cache.persistence.filename.SharedFileTree.MARSHALLER_DIR;

Expand All @@ -35,7 +34,7 @@
public abstract class IgnitePersistenceCompatibilityAbstractTest extends IgniteCompatibilityAbstractTest {
/** Persistence directories. */
private static final List<String> PERSISTENCE_DIRS
= Arrays.asList(DFLT_STORE_DIR, BINARY_METADATA_DIR, CHECKPOINT_DIR, MARSHALLER_DIR);
= Arrays.asList(DFLT_STORE_DIR, BINARY_METADATA_DIR, "cp", MARSHALLER_DIR);

/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ private void doTestStartupWithOldVersion(String ver) throws Exception {

NodeFileTree ft = ignite.context().pdsFolderResolver().fileTree();

File nodeArchiveDir = ft.walArchive();

File[] compressedSegments = nodeArchiveDir.listFiles(new FilenameFilter() {
File[] compressedSegments = ft.walArchive().listFiles(new FilenameFilter() {
@Override public boolean accept(File dir, String name) {
return name.endsWith(".wal.zip");
}
Expand All @@ -139,9 +137,7 @@ private void doTestStartupWithOldVersion(String ver) throws Exception {

stopAllGrids();

File cpMarkersDir = ft.checkpoint();

File[] cpMarkers = cpMarkersDir.listFiles();
File[] cpMarkers = ft.checkpoint().listFiles();

assertNotNull(cpMarkers);
assertTrue(cpMarkers.length > 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public boolean walArchiveEnabled() {
* @param cfg Configured directory path.
* @return Initialized directory.
*/
private File resolveDirectory(String cfg) {
public File resolveDirectory(String cfg) {
File sharedDir = new File(cfg);

return sharedDir.isAbsolute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,19 @@
@IgniteSpiMultipleInstancesSupport(true)
@IgniteSpiConsistencyChecked(optional = false)
public class SharedFsCheckpointSpi extends IgniteSpiAdapter implements CheckpointSpi {
/**
* Default root checkpoint directory.
*/
public static final String DFLT_ROOT = "cp";

/**
* Default checkpoint directory. Note that this path is relative to {@code IGNITE_HOME/work} folder
* if {@code IGNITE_HOME} system or environment variable specified, otherwise it is relative to
* {@code work} folder under system {@code java.io.tmpdir} folder.
*
* @see org.apache.ignite.configuration.IgniteConfiguration#getWorkDirectory()
*/
public static final String DFLT_DIR_PATH = "cp/sharedfs";
public static final String DFLT_DIR_PATH = DFLT_ROOT + "/sharedfs";

/** */
private static final String CODES = "0123456789QWERTYUIOPASDFGHJKLZXCVBNM";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,8 @@ public static void doSnapshotCancellationTest(
assertTrue(CU.isPersistenceEnabled(srv.configuration()));
assertTrue(CU.isPersistentCache(ccfg, srv.configuration().getDataStorageConfiguration()));

File snpDir = new SharedFileTree(srv.configuration()).snapshotsRoot();

List<BlockingExecutor> execs = setBlockingSnapshotExecutor(srvs);

IgniteFuture<Void> fut = snp(startCli).createSnapshot(SNAPSHOT_NAME, null, null, false,
Expand All @@ -819,8 +821,6 @@ public static void doSnapshotCancellationTest(
IgniteFutureCancelledException.class,
"Execution of snapshot tasks has been cancelled by external process");

File snpDir = new SharedFileTree(srv.configuration()).snapshotsRoot();

assertEquals("Snapshot directory must be empty due to snapshot cancelled", 0, snpDir.list().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
import org.apache.ignite.mxbean.MXBeanDescription;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.resources.LoggerResource;
import org.apache.ignite.spi.checkpoint.sharedfs.SharedFsCheckpointSpi;
import org.apache.ignite.testframework.GridTestNode;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.GridAbstractTest;
Expand Down Expand Up @@ -1971,7 +1972,7 @@ protected void cleanPersistenceDir() throws Exception {
protected void cleanPersistenceDir(boolean saveSnp) throws Exception {
assertTrue("Grids are not stopped", F.isEmpty(G.allGrids()));

U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), "cp", false));
U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), SharedFsCheckpointSpi.DFLT_ROOT, false));
U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), DFLT_STORE_DIR, false));

SharedFileTree sft = sharedFileTree();
Expand Down

0 comments on commit 66c1e11

Please sign in to comment.