improve trace logging

- Add filename for trace logs for read/write operations.
This commit is contained in:
2019-08-18 09:25:49 +02:00
parent 16bf0933e7
commit 3252fcf42d
15 changed files with 102 additions and 39 deletions

View File

@@ -43,8 +43,8 @@ public class BSFileTest {
long blockOffset = -1;
long start = System.nanoTime();
//
try (final DiskStorage ds = new DiskStorage(file)) {
try (final DiskStorage ds = new DiskStorage(file, dataDirectory)) {
try (final BSFile bsFile = BSFile.newFile(ds, NullCustomizer.INSTANCE)) {
@@ -64,7 +64,7 @@ public class BSFileTest {
System.out.println("duration write: " + (System.nanoTime() - start) / 1_000_000.0 + "ms");
start = System.nanoTime();
try (final DiskStorage ds = new DiskStorage(file)) {
try (final DiskStorage ds = new DiskStorage(file, dataDirectory)) {
final BSFile bsFile = BSFile.existingFile(blockOffset, ds, NullCustomizer.INSTANCE);
final LongList actualLongs = bsFile.asLongList();
final LongList expectedLongs = LongList.rangeClosed(0, numLongs - 1);
@@ -83,7 +83,7 @@ public class BSFileTest {
final Map<Long, LongList> expected = new HashMap<>();
final List<Future<Void>> futures = new ArrayList<>();
final long start = System.nanoTime();
try (final DiskStorage ds = new DiskStorage(file)) {
try (final DiskStorage ds = new DiskStorage(file, dataDirectory)) {
for (int i = 0; i < threads; i++) {
final Future<Void> future = pool.submit(() -> {
@@ -117,7 +117,7 @@ public class BSFileTest {
System.out.println("duration write: " + (System.nanoTime() - start) / 1_000_000.0 + "ms");
// verification
try (final DiskStorage ds = new DiskStorage(file)) {
try (final DiskStorage ds = new DiskStorage(file, dataDirectory)) {
for (final Entry<Long, LongList> entry : expected.entrySet()) {
final long rootBlockNumber = entry.getKey();
final LongList expectedValues = entry.getValue();

View File

@@ -37,7 +37,7 @@ public class TimeSeriesFileTest {
long start = System.nanoTime();
long lastEpochMilli = 0;
//
try (final DiskStorage ds = new DiskStorage(file)) {
try (final DiskStorage ds = new DiskStorage(file, dataDirectory)) {
try (final TimeSeriesFile bsFile = TimeSeriesFile.newFile(ds)) {
@@ -72,7 +72,7 @@ public class TimeSeriesFileTest {
System.out.println("duration write: " + (System.nanoTime() - start) / 1_000_000.0 + "ms");
start = System.nanoTime();
try (final DiskStorage ds = new DiskStorage(file)) {
try (final DiskStorage ds = new DiskStorage(file, dataDirectory)) {
final TimeSeriesFile bsFile = TimeSeriesFile.existingFile(blockNumber, ds);
final LongList actualLongs = bsFile.asTimeValueLongList();

View File

@@ -43,7 +43,7 @@ public class DiskStorageTest {
final Path databaseFile = dataDirectory.resolve("db.ds");
Files.deleteIfExists(databaseFile);
try (DiskStorage ds = new DiskStorage(databaseFile)) {
try (DiskStorage ds = new DiskStorage(databaseFile, dataDirectory)) {
final int numBlocks = 10;
allocateBlocks(ds, numBlocks, BLOCK_SIZE);
@@ -81,7 +81,7 @@ public class DiskStorageTest {
//
// But it does see the changes. Most likely, because both channels
// use the same buffers from the operating system.
try (DiskStorage ds2 = new DiskStorage(databaseFile)) {
try (DiskStorage ds2 = new DiskStorage(databaseFile, dataDirectory)) {
for (int i = 0; i < numBlocks; i++) {
final DiskBlock diskBlock = ds2.getDiskBlock(i, BLOCK_SIZE);
assertAllValuesAreEqual(diskBlock, (byte) i);
@@ -98,7 +98,7 @@ public class DiskStorageTest {
final ExecutorService pool = Executors.newCachedThreadPool();
try (DiskStorage ds = new DiskStorage(databaseFile)) {
try (DiskStorage ds = new DiskStorage(databaseFile, dataDirectory)) {
final int numBlocks = 10;
final long[] blockOffsets = allocateBlocks(ds, numBlocks, BLOCK_SIZE);
@@ -140,7 +140,7 @@ public class DiskStorageTest {
public void testAllocationSmallerThanMinimalBlockSize() throws Exception {
final Path databaseFile = dataDirectory.resolve("db.ds");
try (DiskStorage ds = new DiskStorage(databaseFile)) {
try (DiskStorage ds = new DiskStorage(databaseFile, dataDirectory)) {
final int blockSize = 31; // minimal block size is 32
ds.allocateBlock(blockSize);
@@ -151,7 +151,7 @@ public class DiskStorageTest {
public void testAllocateAndFreeSingleBlockInFreeList() throws Exception {
final Path databaseFile = dataDirectory.resolve("db.ds");
try (DiskStorage ds = new DiskStorage(databaseFile)) {
try (DiskStorage ds = new DiskStorage(databaseFile, dataDirectory)) {
final int blockSize = 32;
final long block_8_39 = ds.allocateBlock(blockSize);
@@ -175,7 +175,7 @@ public class DiskStorageTest {
public void testAllocateAndFreeMultipleBlocksInFreeList() throws Exception {
final Path databaseFile = dataDirectory.resolve("db.ds");
try (DiskStorage ds = new DiskStorage(databaseFile)) {
try (DiskStorage ds = new DiskStorage(databaseFile, dataDirectory)) {
final int blockSize = 32;
ds.allocateBlock(blockSize);
@@ -212,7 +212,7 @@ public class DiskStorageTest {
public void testAllocateAndFreeInsertFreeNodeInTheMiddleOfTheFreeList() throws Exception {
final Path databaseFile = dataDirectory.resolve("db.ds");
try (DiskStorage ds = new DiskStorage(databaseFile)) {
try (DiskStorage ds = new DiskStorage(databaseFile, dataDirectory)) {
final int blockSize = 32;
ds.allocateBlock(blockSize);
@@ -242,7 +242,7 @@ public class DiskStorageTest {
public void testAllocateAndFreeMultipleBlocksWithDifferentSizes() throws Exception {
final Path databaseFile = dataDirectory.resolve("db.ds");
try (DiskStorage ds = new DiskStorage(databaseFile)) {
try (DiskStorage ds = new DiskStorage(databaseFile, dataDirectory)) {
final int blockSizeSmall = 32;
final int blockSizeBig = 64;

View File

@@ -41,7 +41,7 @@ public class PersistentMapTest {
final String value = "value1";
final String key = "key1";
try (final PersistentMap<String, String> map = new PersistentMap<>(file, PersistentMap.STRING_CODER,
try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory, PersistentMap.STRING_CODER,
PersistentMap.STRING_CODER)) {
Assert.assertNull(map.getValue(key));
@@ -50,7 +50,7 @@ public class PersistentMapTest {
Assert.assertEquals(map.getValue(key), value);
}
try (final PersistentMap<String, String> map = new PersistentMap<>(file, PersistentMap.STRING_CODER,
try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,PersistentMap.STRING_CODER,
PersistentMap.STRING_CODER)) {
Assert.assertEquals(map.getValue(key), value);
@@ -64,7 +64,7 @@ public class PersistentMapTest {
final Random rnd = new Random(1);
try (final PersistentMap<String, String> map = new PersistentMap<>(file, PersistentMap.STRING_CODER,
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER,
PersistentMap.STRING_CODER)) {
map.setMaxEntriesInNode(2);
@@ -98,7 +98,7 @@ public class PersistentMapTest {
}
}
try (final PersistentMap<String, String> map = new PersistentMap<>(file, PersistentMap.STRING_CODER,
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER,
PersistentMap.STRING_CODER)) {
// map.print(PersistentMap.STRING_DECODER, PersistentMap.STRING_DECODER);
final AtomicInteger maxDepth = new AtomicInteger();
@@ -127,7 +127,7 @@ public class PersistentMapTest {
final SecureRandom rnd = new SecureRandom();
rnd.setSeed(1);
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file, PersistentMap.LONG_CODER,
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file,dataDirectory, PersistentMap.LONG_CODER,
PersistentMap.LONG_CODER)) {
for (int i = 0; i < 1000; i++) {
@@ -159,7 +159,7 @@ public class PersistentMapTest {
}
}
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file, PersistentMap.LONG_CODER,
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file,dataDirectory, PersistentMap.LONG_CODER,
PersistentMap.LONG_CODER)) {
// map.print(PersistentMap.LONG_DECODER, PersistentMap.LONG_DECODER);
final AtomicInteger counter = new AtomicInteger();
@@ -187,7 +187,7 @@ public class PersistentMapTest {
final SecureRandom rnd = new SecureRandom();
rnd.setSeed(1);
try (final PersistentMap<Long, Empty> map = new PersistentMap<>(file, PersistentMap.LONG_CODER,
try (final PersistentMap<Long, Empty> map = new PersistentMap<>(file,dataDirectory, PersistentMap.LONG_CODER,
PersistentMap.EMPTY_ENCODER)) {
for (int i = 0; i < 1500; i++) {
@@ -219,7 +219,7 @@ public class PersistentMapTest {
}
}
try (final PersistentMap<Long, Empty> map = new PersistentMap<>(file, PersistentMap.LONG_CODER,
try (final PersistentMap<Long, Empty> map = new PersistentMap<>(file,dataDirectory, PersistentMap.LONG_CODER,
PersistentMap.EMPTY_ENCODER)) {
map.print();
final AtomicInteger counter = new AtomicInteger();
@@ -247,7 +247,7 @@ public class PersistentMapTest {
final Queue<Integer> numbers = new LinkedList<>(Arrays.asList(1, 15, 11, 4, 16, 3, 13));
try (final PersistentMap<String, String> map = new PersistentMap<>(file, PersistentMap.STRING_CODER,
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER,
PersistentMap.STRING_CODER)) {
final int numbersSize = numbers.size();
@@ -275,7 +275,7 @@ public class PersistentMapTest {
}
}
try (final PersistentMap<String, String> map = new PersistentMap<>(file, PersistentMap.STRING_CODER,
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER,
PersistentMap.STRING_CODER)) {
// map.print(PersistentMap.STRING_DECODER, PersistentMap.STRING_DECODER);
@@ -309,13 +309,13 @@ public class PersistentMapTest {
input.put(UUID.randomUUID().toString(), UUID.randomUUID().toString());
}
try (final PersistentMap<String, String> map = new PersistentMap<>(file, PersistentMap.STRING_CODER,
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER,
PersistentMap.STRING_CODER)) {
map.putAllValues(input);
}
try (final PersistentMap<String, String> map = new PersistentMap<>(file, PersistentMap.STRING_CODER,
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER,
PersistentMap.STRING_CODER)) {
{
@@ -336,7 +336,7 @@ public class PersistentMapTest {
final SecureRandom rnd = new SecureRandom();
rnd.setSeed(1);
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file, PersistentMap.LONG_CODER,
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file,dataDirectory, PersistentMap.LONG_CODER,
PersistentMap.LONG_CODER)) {
for (int i = 0; i < 1_000; i++) {
@@ -368,7 +368,7 @@ public class PersistentMapTest {
}
}
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file, PersistentMap.LONG_CODER,
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file,dataDirectory, PersistentMap.LONG_CODER,
PersistentMap.LONG_CODER)) {
final AtomicInteger counter = new AtomicInteger();
final AtomicInteger maxDepth = new AtomicInteger();