Index: oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/AbstractFileStore.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/AbstractFileStore.java (date 1487952321000) +++ oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/AbstractFileStore.java (date 1487949811000) @@ -20,15 +20,11 @@ import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.Maps.newHashMap; -import static com.google.common.collect.Sets.newHashSet; -import static java.lang.String.format; -import static java.util.Collections.singletonMap; import java.io.Closeable; import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; -import java.util.Arrays; import java.util.Map; import java.util.UUID; import java.util.regex.Matcher; @@ -80,7 +76,7 @@ static final int CURRENT_STORE_VERSION = 1; private static final Pattern FILE_NAME_PATTERN = - Pattern.compile("(data|bulk)((0|[1-9][0-9]*)[0-9]{4})([a-z])?.tar"); + Pattern.compile("(data)((0|[1-9][0-9]*)[0-9]{4})([a-z])?.tar"); static final String FILE_NAME_FORMAT = "data%05d%s.tar"; @@ -193,69 +189,21 @@ static Map> collectFiles(File directory) { Map> dataFiles = newHashMap(); - Map bulkFiles = newHashMap(); for (File file : listFiles(directory)) { Matcher matcher = FILE_NAME_PATTERN.matcher(file.getName()); if (matcher.matches()) { Integer index = Integer.parseInt(matcher.group(2)); - if ("data".equals(matcher.group(1))) { - Map files = dataFiles.get(index); - if (files == null) { - files = newHashMap(); - dataFiles.put(index, files); - } - Character generation = 'a'; - if (matcher.group(4) != null) { - generation = matcher.group(4).charAt(0); - } - checkState(files.put(generation, file) == null); - } else { - checkState(bulkFiles.put(index, file) == null); - } - } - } - - if (!bulkFiles.isEmpty()) { - log.info("Upgrading TarMK file names in {}", directory); - - if (!dataFiles.isEmpty()) { - // first put all the data segments at the end of the list - Integer[] indices = - dataFiles.keySet().toArray(new Integer[dataFiles.size()]); - Arrays.sort(indices); - int position = Math.max( - indices[indices.length - 1] + 1, - bulkFiles.size()); - for (Integer index : indices) { - Map files = dataFiles.remove(index); - Integer newIndex = position++; - for (Character generation : newHashSet(files.keySet())) { - File file = files.get(generation); - File newFile = new File( - directory, - format(FILE_NAME_FORMAT, newIndex, generation)); - log.info("Renaming {} to {}", file, newFile); - file.renameTo(newFile); - files.put(generation, newFile); - } - dataFiles.put(newIndex, files); - } - } - - // then add all the bulk segments at the beginning of the list - Integer[] indices = - bulkFiles.keySet().toArray(new Integer[bulkFiles.size()]); - Arrays.sort(indices); - int position = 0; - for (Integer index : indices) { - File file = bulkFiles.remove(index); - Integer newIndex = position++; - File newFile = new File( - directory, format(FILE_NAME_FORMAT, newIndex, "a")); - log.info("Renaming {} to {}", file, newFile); - file.renameTo(newFile); - dataFiles.put(newIndex, singletonMap('a', newFile)); + Map files = dataFiles.get(index); + if (files == null) { + files = newHashMap(); + dataFiles.put(index, files); + } + Character generation = 'a'; + if (matcher.group(4) != null) { + generation = matcher.group(4).charAt(0); + } + checkState(files.put(generation, file) == null); } } Index: oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/FileStoreIT.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/FileStoreIT.java (date 1487952321000) +++ oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/FileStoreIT.java (date 1487949811000) @@ -18,21 +18,15 @@ */ package org.apache.jackrabbit.oak.segment.file; -import static com.google.common.collect.Lists.newArrayList; -import static com.google.common.collect.Sets.newTreeSet; import static org.apache.jackrabbit.oak.segment.file.FileStoreBuilder.fileStoreBuilder; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; import java.io.RandomAccessFile; import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.Random; import com.google.common.base.Strings; @@ -135,31 +129,6 @@ store.close(); } - @Test - public void testRearrangeOldData() throws IOException { - new FileOutputStream(new File(getFileStoreFolder(), "data00000.tar")).close(); - new FileOutputStream(new File(getFileStoreFolder(), "data00010a.tar")).close(); - new FileOutputStream(new File(getFileStoreFolder(), "data00030.tar")).close(); - new FileOutputStream(new File(getFileStoreFolder(), "bulk00002.tar")).close(); - new FileOutputStream(new File(getFileStoreFolder(), "bulk00005a.tar")).close(); - - Map files = FileStore.collectFiles(getFileStoreFolder()); - assertEquals( - newArrayList(0, 1, 31, 32, 33), - newArrayList(newTreeSet(files.keySet()))); - - assertTrue(new File(getFileStoreFolder(), "data00000a.tar").isFile()); - assertTrue(new File(getFileStoreFolder(), "data00001a.tar").isFile()); - assertTrue(new File(getFileStoreFolder(), "data00031a.tar").isFile()); - assertTrue(new File(getFileStoreFolder(), "data00032a.tar").isFile()); - assertTrue(new File(getFileStoreFolder(), "data00033a.tar").isFile()); - - files = FileStore.collectFiles(getFileStoreFolder()); - assertEquals( - newArrayList(0, 1, 31, 32, 33), - newArrayList(newTreeSet(files.keySet()))); - } - @Test // See OAK-2049 public void segmentOverflow() throws Exception { for (int n = 1; n < 255; n++) { // 255 = ListRecord.LEVEL_SIZE