Skip to content

Commit

Permalink
Issue #7546 - minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii0lomakin authored and tglman committed Jul 28, 2017
1 parent 9123b26 commit 0953e55
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.orientechnologies.common.serialization.types.OIntegerSerializer;
import com.orientechnologies.common.serialization.types.OLongSerializer;
import com.orientechnologies.common.types.OModifiableBoolean;
import com.orientechnologies.common.util.OPair;
import com.orientechnologies.orient.core.command.OCommandOutputListener;
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.exception.OStorageException;
Expand Down Expand Up @@ -1339,6 +1338,8 @@ private void readNameIdMap() throws IOException, InterruptedException {
}
}

final Set<String> fixedFiles = new HashSet<String>();

for (Map.Entry<Integer, Set<String>> entry : filesWithfNegativeIds.entrySet()) {
final Set<String> files = entry.getValue();

Expand All @@ -1347,9 +1348,14 @@ private void readNameIdMap() throws IOException, InterruptedException {
fileCounter++;
final int nextId = -fileCounter;
nameIdMap.put(fileName, nextId);

fixedFiles.add(fileName);
}
}
}

if (!fixedFiles.isEmpty())
OLogManager.instance().warn(this, "Removed files " + fixedFiles + " had duplicated ids. Problem is fixed automatically.");
}

private NameFileIdEntry readNextNameIdEntry() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.orientechnologies.orient.core.storage.OStorage;
import com.orientechnologies.orient.core.storage.cache.OWriteCache;
import com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage;
import com.sun.xml.internal.ws.policy.AssertionSet;
import org.testng.Assert;
import org.testng.annotations.Test;

Expand All @@ -36,21 +35,21 @@ public void testRemovedFileIds() throws Exception {
db.close();
storage.close(true, false);

final RandomAccessFile cacheState = new RandomAccessFile(new File(dbPath, "name_id_map.cm"), "rw");
cacheState.seek(cacheState.length());
final RandomAccessFile fileMap = new RandomAccessFile(new File(dbPath, "name_id_map.cm"), "rw");
fileMap.seek(fileMap.length());

writeNameIdEntry(cacheState, "c1.cpm", -100);
writeNameIdEntry(cacheState, "c1.pcl", -100);
writeNameIdEntry(fileMap, "c1.cpm", -100);
writeNameIdEntry(fileMap, "c1.pcl", -100);

writeNameIdEntry(cacheState, "c2.cpm", -200);
writeNameIdEntry(cacheState, "c2.pcl", -200);
writeNameIdEntry(cacheState, "c2.pcl", -400);
writeNameIdEntry(fileMap, "c2.cpm", -200);
writeNameIdEntry(fileMap, "c2.pcl", -200);
writeNameIdEntry(fileMap, "c2.pcl", -400);

writeNameIdEntry(cacheState, "c3.cpm", -500);
writeNameIdEntry(cacheState, "c3.pcl", -500);
writeNameIdEntry(cacheState, "c4.cpm", -500);
writeNameIdEntry(cacheState, "c4.pcl", -600);
writeNameIdEntry(cacheState, "c4.cpm", -600);
writeNameIdEntry(fileMap, "c3.cpm", -500);
writeNameIdEntry(fileMap, "c3.pcl", -500);
writeNameIdEntry(fileMap, "c4.cpm", -500);
writeNameIdEntry(fileMap, "c4.pcl", -600);
writeNameIdEntry(fileMap, "c4.cpm", -600);

db = new ODatabaseDocumentTx("plocal:" + dbPath);
db.open("admin", "admin");
Expand Down

0 comments on commit 0953e55

Please sign in to comment.