changeset 683:4440624b0c6d

NC file in progress
author Devel 2
date Thu, 23 Nov 2017 13:54:46 +0100
parents e420a96bed43
children 2f43e5c1f20d
files stress-tester/src/main/java/com/passus/st/reader/nc/NcDataBlockReader.java stress-tester/src/main/java/com/passus/st/reader/nc/NcDataBlockWriter.java stress-tester/src/main/java/com/passus/st/reader/nc/block/NcSegmentBlock.java stress-tester/src/test/java/com/passus/st/reader/nc/NcDataBlockReaderTest.java
diffstat 4 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataBlockReader.java	Thu Nov 23 13:21:01 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataBlockReader.java	Thu Nov 23 13:54:46 2017 +0100
@@ -88,7 +88,6 @@
 
         try {
             ch = FileChannel.open(path, StandardOpenOption.READ);
-            System.out.println("size: " + ch.size());
             buffer = new HeapByteBuff(bufferSize);
             nioBuffer = ByteBuffer.allocate(bufferSize);
             nioBuffers = new ByteBuffer[1];
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataBlockWriter.java	Thu Nov 23 13:21:01 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataBlockWriter.java	Thu Nov 23 13:54:46 2017 +0100
@@ -152,6 +152,8 @@
     public void close() throws IOException {
         if (ch != null) {
             closeSegmentBlock();
+            openSegmentBlock();
+            closeSegmentBlock();
             flush();
 
             try {
@@ -398,7 +400,7 @@
         int dataSize = dataBuffer.remaining();
         writeSessionPayloadHeader(timestamp, session, proto, dataSize);
         ch.write(dataBuffer);
-        
+
         updateSegmentInfo(dataSize);
         closeBlock(NcSessionPayloadBlock.TYPE);
     }
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/block/NcSegmentBlock.java	Thu Nov 23 13:21:01 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/reader/nc/block/NcSegmentBlock.java	Thu Nov 23 13:54:46 2017 +0100
@@ -21,6 +21,7 @@
 
     public NcSegmentBlock(long totalSize, long prevTotalSize, int blocksNum) {
         this.totalSize = totalSize;
+        this.prevTotalSize = prevTotalSize;
         this.blocksNum = blocksNum;
     }
 
--- a/stress-tester/src/test/java/com/passus/st/reader/nc/NcDataBlockReaderTest.java	Thu Nov 23 13:21:01 2017 +0100
+++ b/stress-tester/src/test/java/com/passus/st/reader/nc/NcDataBlockReaderTest.java	Thu Nov 23 13:54:46 2017 +0100
@@ -78,13 +78,13 @@
                 assertTrue(payloadBlock.data() instanceof ByteBuff);
                 ByteBuff payload = (ByteBuff) payloadBlock.data();
                 assertEquals(data, payload.toArray());
-                
-                /*block = reader.read();
+
+                block = reader.read();
                 assertEquals(NcSegmentBlock.TYPE, block.type());
                 NcSegmentBlock lastSegmentBlock = (NcSegmentBlock) block;
                 assertEquals(0, lastSegmentBlock.blocksNum());
                 assertEquals(0, lastSegmentBlock.totalSize());
-                assertEquals(firstSegmentBlock.totalSize(), lastSegmentBlock.prevTotalSize());*/
+                assertEquals(firstSegmentBlock.totalSize(), lastSegmentBlock.prevTotalSize());
             }
         } finally {
             if (file != null) {