Mercurial > stress-tester
changeset 765:70b55498fb7e
NcDataBlockReader.allocator
author | Devel 2 |
---|---|
date | Mon, 18 Dec 2017 08:43:58 +0100 |
parents | dc80677e532f |
children | 3931dbbb20f4 c01815e24aff |
files | stress-tester/src/main/java/com/passus/st/reader/nc/NcDataBlockReader.java |
diffstat | 1 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataBlockReader.java Fri Dec 15 13:29:14 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataBlockReader.java Mon Dec 18 08:43:58 2017 +0100 @@ -1,7 +1,9 @@ package com.passus.st.reader.nc; import com.passus.commons.Assert; +import com.passus.data.Allocator; import com.passus.data.ByteBuff; +import com.passus.data.DefaultAllocator; import com.passus.data.HeapByteBuff; import com.passus.net.IpAddress; import com.passus.net.session.SessionBean; @@ -55,6 +57,8 @@ private boolean eof = false; + private Allocator allocator = new DefaultAllocator(); + private final Map<Integer, SessionInfo> sessionIdMap = new HashMap<>(); private NcSegmentBlock currentSegmentBlock; @@ -72,6 +76,15 @@ this.path = path; } + public Allocator getAllocator() { + return allocator; + } + + public void setAllocator(Allocator allocator) { + Assert.notNull(allocator, "allocator"); + this.allocator = allocator; + } + public NcHeader getHeader() { return header; } @@ -328,7 +341,7 @@ if (!skipData) { if (payloadBlock.dataSize() <= Integer.MAX_VALUE) { int dataSize = (int) payloadBlock.dataSize(); - ByteBuff data = new HeapByteBuff(dataSize); + ByteBuff data = allocator.allocate(dataSize); //TODO - Mozna zoptymalizowac. Mozna kopiowac bufor bezposrednio do data readSessionPayloadBlockContent(data, dataSize);