Skip to content

Commit

Permalink
IGNITE-10522 Fix checkpoint tmp files doesn't not removed on start no…
Browse files Browse the repository at this point in the history
…de - Fixes #5571.

Signed-off-by: Dmitriy Govorukhin <dmitriy.govorukhin@gmail.com>
  • Loading branch information
akalash authored and dgovorukhin committed Dec 7, 2018
1 parent 57ccf9b commit 472889d
Show file tree
Hide file tree
Showing 5 changed files with 532 additions and 611 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
import static org.apache.ignite.failure.FailureType.CRITICAL_ERROR;
import static org.apache.ignite.failure.FailureType.SYSTEM_WORKER_TERMINATION;
import static org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.CHECKPOINT_RECORD;
import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.TMP_FILE_MATCHER;
import static org.apache.ignite.internal.util.IgniteUtils.checkpointBufferSize;

/**
Expand Down Expand Up @@ -537,10 +538,7 @@ private DataRegionConfiguration createMetastoreDataRegionConfig(DataStorageConfi
*/
@Override public void cleanupTempCheckpointDirectory() throws IgniteCheckedException {
try {
try (DirectoryStream<Path> files = Files.newDirectoryStream(
cpDir.toPath(),
path -> path.endsWith(FilePageStoreManager.TMP_SUFFIX))
) {
try (DirectoryStream<Path> files = Files.newDirectoryStream(cpDir.toPath(), TMP_FILE_MATCHER::matches)) {
for (Path path : files)
Files.delete(path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.StandardCopyOption;
import java.util.AbstractList;
import java.util.Arrays;
Expand Down Expand Up @@ -118,6 +120,10 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen
/** */
public static final String META_STORAGE_NAME = "metastorage";

/** Matcher for searching of *.tmp files. */
public static final PathMatcher TMP_FILE_MATCHER =
FileSystems.getDefault().getPathMatcher("glob:**" + TMP_SUFFIX);

/** Marshaller. */
private static final Marshaller marshaller = new JdkMarshaller();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3585,7 +3585,7 @@ public static boolean delete(Path path) {
}
}

if (path.endsWith("jar")) {
if (path.toFile().getName().endsWith("jar")) {
try {
// Why do we do this?
new JarFile(path.toString(), false).close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.ignite.testframework.junits;

import javax.cache.configuration.Factory;
import javax.cache.configuration.FactoryBuilder;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.lang.annotation.Annotation;
Expand All @@ -41,8 +43,6 @@
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import javax.cache.configuration.Factory;
import javax.cache.configuration.FactoryBuilder;
import junit.framework.TestCase;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
Expand Down

0 comments on commit 472889d

Please sign in to comment.