Package org.apache.activeio.packet

Examples of org.apache.activeio.packet.Packet


        LOG.info("Journal Recovery Started from: " + journal);
        ConnectionContext context = new ConnectionContext();

        // While we have records in the journal.
        while ((pos = journal.getNextRecordLocation(pos)) != null) {
            Packet data = journal.read(pos);
            DataStructure c = (DataStructure)wireFormat.unmarshal(toByteSequence(data));

            if (c instanceof Message) {
                Message message = (Message)c;
                JournalMessageStore store = (JournalMessageStore)createMessageStore(message.getDestination());
View Full Code Here


     * @return
     * @throws IOException
     */
    public DataStructure readCommand(RecordLocation location) throws IOException {
        try {
            Packet packet = journal.read(location);
            return (DataStructure)wireFormat.unmarshal(toByteSequence(packet));
        } catch (InvalidRecordLocationException e) {
            throw createReadException(location, e);
        } catch (IOException e) {
            throw createReadException(location, e);
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public void testAppendAndRead() throws InvalidRecordLocationException, InterruptedException, IOException {

        Packet data1 = createPacket("Hello World 1");
        RecordLocation location1 = journal.write(data1, false);
        Packet data2 = createPacket("Hello World 2");
        RecordLocation location2 = journal.write(data2, false);
        Packet data3 = createPacket("Hello World 3");
        RecordLocation location3 = journal.write(data3, false);

        // Thread.sleep(1000);

        // Now see if we can read that data.
        Packet data;
        data = journal.read(location2);
        assertEquals(data2, data);
        data = journal.read(location1);
        assertEquals(data1, data);
        data = journal.read(location3);
View Full Code Here

        log.info(journal);
    }

    public void testCanReadFromArchivedLogFile() throws InvalidRecordLocationException, InterruptedException, IOException {

        Packet data1 = createPacket("Hello World 1");
        RecordLocationFacade location1 = (RecordLocationFacade)journal.write(data1, false);

        RecordLocationFacade pos;
        int counter = 0;
        do {

            Packet p = createPacket("<<<data>>>");
            pos = (RecordLocationFacade)journal.write(p, false);
            if (counter++ % 1000 == 0) {
                journal.setMark(pos, false);
            }

        } while (pos.getLocation().getDataFileId() < 5);

        // Now see if we can read that first packet.
        Packet data;
        data = journal.read(location1);
        assertEquals(data1, data);

    }
View Full Code Here

     * @return
     * @throws IOException
     */
    public DataStructure readCommand(RecordLocation location) throws IOException {
        try {
            Packet packet = journal.read(location);
            return (DataStructure)wireFormat.unmarshal(toByteSequence(packet));
        } catch (InvalidRecordLocationException e) {
            throw createReadException(location, e);
        } catch (IOException e) {
            throw createReadException(location, e);
View Full Code Here

        LOG.info("Journal Recovery Started from: " + journal);
        ConnectionContext context = new ConnectionContext(new NonCachedMessageEvaluationContext());

        // While we have records in the journal.
        while ((pos = journal.getNextRecordLocation(pos)) != null) {
            Packet data = journal.read(pos);
            DataStructure c = (DataStructure)wireFormat.unmarshal(toByteSequence(data));

            if (c instanceof Message) {
                Message message = (Message)c;
                JournalMessageStore store = (JournalMessageStore)createMessageStore(message.getDestination());
View Full Code Here

     * @return
     * @throws IOException
     */
    public DataStructure readCommand(RecordLocation location) throws IOException {
        try {
            Packet packet = journal.read(location);
            return (DataStructure)wireFormat.unmarshal(toByteSequence(packet));
        } catch (InvalidRecordLocationException e) {
            throw createReadException(location, e);
        } catch (IOException e) {
            throw createReadException(location, e);
View Full Code Here

        LOG.info("Journal Recovery Started from: " + journal);
        ConnectionContext context = new ConnectionContext(new NonCachedMessageEvaluationContext());

        // While we have records in the journal.
        while ((pos = journal.getNextRecordLocation(pos)) != null) {
            Packet data = journal.read(pos);
            DataStructure c = (DataStructure)wireFormat.unmarshal(toByteSequence(data));

            if (c instanceof Message) {
                Message message = (Message)c;
                JournalMessageStore store = (JournalMessageStore)createMessageStore(message.getDestination());
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public void testAppendAndRead() throws InvalidRecordLocationException, InterruptedException, IOException {

        Packet data1 = createPacket("Hello World 1");
        RecordLocation location1 = journal.write(data1, false);
        Packet data2 = createPacket("Hello World 2");
        RecordLocation location2 = journal.write(data2, false);
        Packet data3 = createPacket("Hello World 3");
        RecordLocation location3 = journal.write(data3, false);

        // Thread.sleep(1000);

        // Now see if we can read that data.
        Packet data;
        data = journal.read(location2);
        assertEquals(data2, data);
        data = journal.read(location1);
        assertEquals(data1, data);
        data = journal.read(location3);
View Full Code Here

        log.info(journal.toString());
    }

    public void testReadOnlyRead() throws InvalidRecordLocationException, InterruptedException, IOException {
     
      Packet data1 = createPacket("Hello World 1");
        RecordLocation location1 = journal.write(data1, false);
        Packet data2 = createPacket("Hello World 2");
        RecordLocation location2 = journal.write(data2, false);
        Packet data3 = createPacket("Hello World 3");
        RecordLocation location3 = journal.write(data3, false);
       
        Packet packet;
        packet = journal.read(location2);
        assertEquals(data2, packet);
        packet = journal.read(location1);
        assertEquals(data1, packet);
        packet = journal.read(location3);
View Full Code Here

TOP

Related Classes of org.apache.activeio.packet.Packet

Copyright © 2018 www.massapicom. 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.