Examples of DataByteArrayInputStream


Examples of org.apache.kahadb.util.DataByteArrayInputStream

    }


    public int checkBatchRecord(DataFileAccessor reader, int offset) throws IOException {
        byte controlRecord[] = new byte[BATCH_CONTROL_RECORD_SIZE];
        DataByteArrayInputStream controlIs = new DataByteArrayInputStream(controlRecord);

        reader.readFully(offset, controlRecord);

        // Assert that it's  a batch record.
        for( int i=0; i < BATCH_CONTROL_RECORD_HEADER.length; i++ ) {
            if( controlIs.readByte() != BATCH_CONTROL_RECORD_HEADER[i] ) {
                return -1;
            }
        }

        int size = controlIs.readInt();
        if( size > MAX_BATCH_SIZE ) {
            return -1;
        }

        if( isChecksum() ) {

            long expectedChecksum = controlIs.readLong();
            if( expectedChecksum == 0 ) {
                // Checksuming was not enabled when the record was stored.
                // we can't validate the record :(
                return size;
            }
View Full Code Here

Examples of org.apache.kahadb.util.DataByteArrayInputStream

     * @return
     * @throws IOException
     */
    public JournalCommand<?> load(Location location) throws IOException {
        ByteSequence data = journal.read(location);
        DataByteArrayInputStream is = new DataByteArrayInputStream(data);
        byte readByte = is.readByte();
        KahaEntryType type = KahaEntryType.valueOf(readByte);
        if( type == null ) {
            throw new IOException("Could not load journal record. Invalid location: "+location);
        }
        JournalCommand<?> message = (JournalCommand<?>)type.createMessage();
View Full Code Here

Examples of org.apache.kahadb.util.DataByteArrayInputStream

    }


    public int checkBatchRecord(DataFileAccessor reader, int offset) throws IOException {
        byte controlRecord[] = new byte[BATCH_CONTROL_RECORD_SIZE];
        DataByteArrayInputStream controlIs = new DataByteArrayInputStream(controlRecord);

        reader.readFully(offset, controlRecord);

        // Assert that it's  a batch record.
        for( int i=0; i < BATCH_CONTROL_RECORD_HEADER.length; i++ ) {
            if( controlIs.readByte() != BATCH_CONTROL_RECORD_HEADER[i] ) {
                return -1;
            }
        }

        int size = controlIs.readInt();
        if( size > MAX_BATCH_SIZE ) {
            return -1;
        }

        if( isChecksum() ) {

            long expectedChecksum = controlIs.readLong();
            if( expectedChecksum == 0 ) {
                // Checksuming was not enabled when the record was stored.
                // we can't validate the record :(
                return size;
            }
View Full Code Here

Examples of org.apache.kahadb.util.DataByteArrayInputStream

     * @return
     * @throws IOException
     */
    public JournalCommand load(Location location) throws IOException {
        ByteSequence data = journal.read(location);
        DataByteArrayInputStream is = new DataByteArrayInputStream(data);
        byte readByte = is.readByte();
        KahaEntryType type = KahaEntryType.valueOf(readByte);
        if( type == null ) {
            throw new IOException("Could not load journal record. Invalid location: "+location);
        }
        JournalCommand message = (JournalCommand)type.createMessage();
View Full Code Here

Examples of org.fusesource.hawtbuf.DataByteArrayInputStream

            dataOut.writeByte(NULL_TYPE);
        }
    }

    public Object unmarshal(DataByteArrayInputStream dis) throws IOException {
        DataByteArrayInputStream dataIn = dis;
        if (!sizePrefixDisabled) {
            int size = dis.readInt();
            if (size > maxFrameSize) {
                throw new IOException(
                        "Frame size of " + (size / (1024 * 1024)) +
View Full Code Here

Examples of org.fusesource.hawtbuf.DataByteArrayInputStream

                if (readSize == 0) {
                    break;
                }

                inputBuffer.flip();
                DataByteArrayInputStream dis = new DataByteArrayInputStream(inputBuffer.array());
                codec.parse(dis, readSize);

                // clear the buffer
                inputBuffer.clear();
View Full Code Here

Examples of org.fusesource.hawtbuf.DataByteArrayInputStream

            dataOut.writeByte(NULL_TYPE);
        }
    }

    public Object unmarshal(DataByteArrayInputStream dis) throws IOException {
        DataByteArrayInputStream dataIn = dis;
        if (!sizePrefixDisabled) {
            int size = dis.readInt();
            if (size > maxFrameSize) {
                throw new IOException(
                        "Frame size of " + (size / (1024 * 1024)) +
View Full Code Here

Examples of org.fusesource.hawtbuf.DataByteArrayInputStream

    }

    public static Properties stringToProperties(String str) throws IOException {
        Properties result = new Properties();
        if (str != null && str.length() > 0) {
            DataByteArrayInputStream dataIn = new DataByteArrayInputStream(str.getBytes());
            result.load(dataIn);
            dataIn.close();
        }
        return result;
    }
View Full Code Here

Examples of org.fusesource.hawtbuf.DataByteArrayInputStream

        keyCodec.encode(key, baos);
        return baos.toBuffer();
    }

    public String unmarshallKey(Buffer buffer) throws IOException {
        DataByteArrayInputStream bais = new DataByteArrayInputStream(buffer);
        String key = keyCodec.decode(bais);
        return key;
    }
View Full Code Here

Examples of org.fusesource.hawtbuf.DataByteArrayInputStream

        exchangeCodec.encode(pe, baos);
        return baos.toBuffer();
    }

    public Exchange unmarshallExchange(CamelContext camelContext, Buffer buffer) throws IOException {
        DataByteArrayInputStream bais = new DataByteArrayInputStream(buffer);
        DefaultExchangeHolder pe = exchangeCodec.decode(bais);
        Exchange answer = new DefaultExchange(camelContext);
        DefaultExchangeHolder.unmarshal(answer, pe);
        // restore the from endpoint
        String fromEndpointUri = (String) answer.removeProperty("CamelAggregatedFromEndpoint");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.