private void ensureAvailable(ByteSequence bs, RandomAccessFile reader, int required) throws IOException { if (bs.remaining() < required) { bs.reset(); int read = reader.read(bs.data, bs.length, bs.data.length - bs.length); if (read < 0) { if (bs.remaining() == 0) { throw new EOFException("request for " + required + " bytes reached EOF"); } } bs.setLength(bs.length + read); } }
private int findNextBatchRecord(ByteSequence bs, RandomAccessFile reader) throws IOException { final ByteSequence header = new ByteSequence(BATCH_CONTROL_RECORD_HEADER); int pos = 0; while (true) { pos = bs.indexOf(header, 0); if (pos >= 0) { bs.setOffset(bs.offset + pos); return pos; } else { // need to load the next data chunck in.. if (bs.length != bs.data.length) { // If we had a short read then we were at EOF return -1; } bs.setOffset(bs.length - BATCH_CONTROL_RECORD_HEADER.length); bs.reset(); bs.setLength(bs.length + reader.read(bs.data, bs.length, bs.data.length - BATCH_CONTROL_RECORD_HEADER.length)); } } }
private Page readPage(Page page) throws IOException { // Read the page data pageFile.readPage(page.getPageId(), chunk.getData()); chunk.setOffset(0); chunk.setLength(pageFile.getPageSize()); DataByteArrayInputStream in = new DataByteArrayInputStream(chunk); page.read(in); chunk.setOffset(Page.PAGE_HEADER_SIZE); if (page.getType() == Page.PAGE_END_TYPE) { chunk.setLength((int)(page.getNext())); } if (page.getType() == Page.PAGE_FREE_TYPE) { throw new EOFException("Chunk stream does not exist, page: " + page.getPageId() + " is marked free"); } return page; }
checksum.update(bs.getData(), bs.getOffset(), bs.remaining()); bs.setLength(reader.read(bs.data)); bs.setOffset(0);
private void ensureAvailable(ByteSequence bs, RandomAccessFile reader, int required) throws IOException { if (bs.remaining() < required) { bs.reset(); int read = reader.read(bs.data, bs.length, bs.data.length - bs.length); if (read < 0) { if (bs.remaining() == 0) { throw new EOFException("request for " + required + " bytes reached EOF"); } } bs.setLength(bs.length + read); } }
private void ensureAvailable(ByteSequence bs, RandomAccessFile reader, int required) throws IOException { if (bs.remaining() < required) { bs.reset(); int read = reader.read(bs.data, bs.length, bs.data.length - bs.length); if (read < 0) { if (bs.remaining() == 0) { throw new EOFException("request for " + required + " bytes reached EOF"); } } bs.setLength(bs.length + read); } }
private void ensureAvailable(ByteSequence bs, RandomAccessFile reader, int required) throws IOException { if (bs.remaining() < required) { bs.reset(); int read = reader.read(bs.data, bs.length, bs.data.length - bs.length); if (read < 0) { if (bs.remaining() == 0) { throw new EOFException("request for " + required + " bytes reached EOF"); } } bs.setLength(bs.length + read); } }
private ByteSequence readHeaderLine(DataInput in, int maxLength, String errorMessage) throws IOException { byte b; ByteArrayOutputStream baos = new ByteArrayOutputStream(maxLength); while ((b = in.readByte()) != '\n') { if (baos.size() > maxLength) { baos.close(); throw new ProtocolException(errorMessage, true); } baos.write(b); } baos.close(); ByteSequence line = baos.toByteSequence(); if (stompVersion.equals(Stomp.V1_0) || stompVersion.equals(Stomp.V1_2)) { int lineLength = line.getLength(); if (lineLength > 0 && line.data[lineLength-1] == '\r') { line.setLength(lineLength-1); } } return line; }
private int findNextBatchRecord(ByteSequence bs, RandomAccessFile reader) throws IOException { final ByteSequence header = new ByteSequence(BATCH_CONTROL_RECORD_HEADER); int pos = 0; while (true) { pos = bs.indexOf(header, 0); if (pos >= 0) { bs.setOffset(bs.offset + pos); return pos; } else { // need to load the next data chunck in.. if (bs.length != bs.data.length) { // If we had a short read then we were at EOF return -1; } bs.setOffset(bs.length - BATCH_CONTROL_RECORD_HEADER.length); bs.reset(); bs.setLength(bs.length + reader.read(bs.data, bs.length, bs.data.length - BATCH_CONTROL_RECORD_HEADER.length)); } } }
private int findNextBatchRecord(ByteSequence bs, RandomAccessFile reader) throws IOException { final ByteSequence header = new ByteSequence(BATCH_CONTROL_RECORD_HEADER); int pos = 0; while (true) { pos = bs.indexOf(header, 0); if (pos >= 0) { bs.setOffset(bs.offset + pos); return pos; } else { // need to load the next data chunck in.. if (bs.length != bs.data.length) { // If we had a short read then we were at EOF return -1; } bs.setOffset(bs.length - BATCH_CONTROL_RECORD_HEADER.length); bs.reset(); bs.setLength(bs.length + reader.read(bs.data, bs.length, bs.data.length - BATCH_CONTROL_RECORD_HEADER.length)); } } }
private int findNextBatchRecord(ByteSequence bs, RandomAccessFile reader) throws IOException { final ByteSequence header = new ByteSequence(BATCH_CONTROL_RECORD_HEADER); int pos = 0; while (true) { pos = bs.indexOf(header, 0); if (pos >= 0) { bs.setOffset(bs.offset + pos); return pos; } else { // need to load the next data chunck in.. if (bs.length != bs.data.length) { // If we had a short read then we were at EOF return -1; } bs.setOffset(bs.length - BATCH_CONTROL_RECORD_HEADER.length); bs.reset(); bs.setLength(bs.length + reader.read(bs.data, bs.length, bs.data.length - BATCH_CONTROL_RECORD_HEADER.length)); } } }
private ByteSequence readHeaderLine(DataInput in, int maxLength, String errorMessage) throws IOException { byte b; ByteArrayOutputStream baos = new ByteArrayOutputStream(maxLength); while ((b = in.readByte()) != '\n') { if (baos.size() > maxLength) { baos.close(); throw new ProtocolException(errorMessage, true); } baos.write(b); } baos.close(); ByteSequence line = baos.toByteSequence(); if (stompVersion.equals(Stomp.V1_0) || stompVersion.equals(Stomp.V1_2)) { int lineLength = line.getLength(); if (lineLength > 0 && line.data[lineLength-1] == '\r') { line.setLength(lineLength-1); } } return line; }
private ByteSequence readHeaderLine(DataInput in, int maxLength, String errorMessage) throws IOException { byte b; ByteArrayOutputStream baos = new ByteArrayOutputStream(maxLength); while ((b = in.readByte()) != '\n') { if (baos.size() > maxLength) { baos.close(); throw new ProtocolException(errorMessage, true); } baos.write(b); } baos.close(); ByteSequence line = baos.toByteSequence(); if (stompVersion.equals(Stomp.V1_0) || stompVersion.equals(Stomp.V1_2)) { int lineLength = line.getLength(); if (lineLength > 0 && line.data[lineLength-1] == '\r') { line.setLength(lineLength-1); } } return line; }
private ByteSequence readHeaderLine(DataInput in, int maxLength, String errorMessage) throws IOException { byte b; ByteArrayOutputStream baos = new ByteArrayOutputStream(maxLength); while ((b = in.readByte()) != '\n') { if (baos.size() > maxLength) { baos.close(); throw new ProtocolException(errorMessage, true); } baos.write(b); } baos.close(); ByteSequence line = baos.toByteSequence(); if (stompVersion.equals(Stomp.V1_0) || stompVersion.equals(Stomp.V1_2)) { int lineLength = line.getLength(); if (lineLength > 0 && line.data[lineLength - 1] == '\r') { line.setLength(lineLength - 1); } } return line; }
private ByteSequence readHeaderLine(DataInput in, int maxLength, String errorMessage) throws IOException { byte b; ByteArrayOutputStream baos = new ByteArrayOutputStream(maxLength); while ((b = in.readByte()) != '\n') { if (baos.size() > maxLength) { baos.close(); throw new ProtocolException(errorMessage, true); } baos.write(b); } baos.close(); ByteSequence line = baos.toByteSequence(); if (stompVersion.equals(Stomp.V1_0) || stompVersion.equals(Stomp.V1_2)) { int lineLength = line.getLength(); if (lineLength > 0 && line.data[lineLength - 1] == '\r') { line.setLength(lineLength - 1); } } return line; }
private Page readPage(Page page) throws IOException { // Read the page data pageFile.readPage(page.getPageId(), chunk.getData()); chunk.setOffset(0); chunk.setLength(pageFile.getPageSize()); DataByteArrayInputStream in = new DataByteArrayInputStream(chunk); page.read(in); chunk.setOffset(Page.PAGE_HEADER_SIZE); if (page.getType() == Page.PAGE_END_TYPE) { chunk.setLength((int)(page.getNext())); } if (page.getType() == Page.PAGE_FREE_TYPE) { throw new EOFException("Chunk stream does not exist, page: " + page.getPageId() + " is marked free"); } return page; }
private Page readPage(Page page) throws IOException { // Read the page data pageFile.readPage(page.getPageId(), chunk.getData()); chunk.setOffset(0); chunk.setLength(pageFile.getPageSize()); DataByteArrayInputStream in = new DataByteArrayInputStream(chunk); page.read(in); chunk.setOffset(Page.PAGE_HEADER_SIZE); if (page.getType() == Page.PAGE_END_TYPE) { chunk.setLength((int)(page.getNext())); } if (page.getType() == Page.PAGE_FREE_TYPE) { throw new EOFException("Chunk stream does not exist, page: " + page.getPageId() + " is marked free"); } return page; }
private Page readPage(Page page) throws IOException { // Read the page data pageFile.readPage(page.getPageId(), chunk.getData()); chunk.setOffset(0); chunk.setLength(pageFile.getPageSize()); DataByteArrayInputStream in = new DataByteArrayInputStream(chunk); page.read(in); chunk.setOffset(Page.PAGE_HEADER_SIZE); if (page.getType() == Page.PAGE_END_TYPE) { chunk.setLength((int)(page.getNext())); } if (page.getType() == Page.PAGE_FREE_TYPE) { throw new EOFException("Chunk stream does not exist, page: " + page.getPageId() + " is marked free"); } return page; }
checksum.update(bs.getData(), bs.getOffset(), bs.remaining()); bs.setLength(reader.read(bs.data)); bs.setOffset(0);
checksum.update(bs.getData(), bs.getOffset(), bs.remaining()); bs.setLength(reader.read(bs.data)); bs.setOffset(0);