Package org.activeio

Examples of org.activeio.Packet.remaining()


   
    long start = System.currentTimeMillis();
    Packet answer = next.read(location);   
    long end = System.currentTimeMillis();
   
    readBytesCounter.add(answer.remaining());
    readLatency.addTime(end-start);
    return answer;
  }

  /**
 
View Full Code Here


    }   
   
    public boolean readFromPacket(Packet packet) throws IOException {
        Packet dup = packet.duplicate();

        if( dup.remaining() < RECORD_HEADER_SIZE )
            return false;
        DataInputStream is = new DataInputStream(new PacketInputStream(dup));
        readHeader( is );
        if( dup.remaining() < payloadLength+RECORD_FOOTER_SIZE ) {
            return false;
View Full Code Here

        if( dup.remaining() < RECORD_HEADER_SIZE )
            return false;
        DataInputStream is = new DataInputStream(new PacketInputStream(dup));
        readHeader( is );
        if( dup.remaining() < payloadLength+RECORD_FOOTER_SIZE ) {
            return false;
        }
       
        // Set limit to create a slice of the payload.
        dup.limit(dup.position()+payloadLength);
View Full Code Here

       
    }

    private void storeState() throws IOException {
        Packet controlData = controlFile.getControlData();
        if( controlData.remaining() == 0 )
            return;
       
        DataOutput data = new DataOutputStream(new PacketOutputStream(controlData));

        data.writeInt(lastLogFileId);
View Full Code Here

    }

    private void loadState() throws IOException {
        if( controlFile.load() ) {
            Packet controlData = controlFile.getControlData();
            if( controlData.remaining() == 0 )
                return;
           
            DataInput data = new DataInputStream(new PacketInputStream(controlData));
   
            lastLogFileId =data.readInt();
View Full Code Here

                            }
                            if( p == EOSPacket.EOS_PACKET ) {
                                System.out.println("Peer disconnected.");
                                dispose();
                            }
                            c += p.remaining();
                        }
                        done.release();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
View Full Code Here

    public void testInit() {
        Packet packet = createTestPacket(100);
        assertEquals( 100, packet.capacity() );       
        assertEquals( 0, packet.position());       
        assertEquals( 100, packet.limit() );       
        assertEquals( 100, packet.remaining() );       
        assertTrue( packet.hasRemaining() );       
    }
   
    public void testPosition() {
        Packet packet = createTestPacket(100);
View Full Code Here

    public void testRemaining() {
        Packet packet = createTestPacket(100);
        packet.position(5);
        packet.limit(95);
        assertEquals(90, packet.remaining());
        assertTrue(packet.hasRemaining());

        packet.position(5);
        packet.limit(5);
        assertEquals(0, packet.remaining());
View Full Code Here

        assertEquals(90, packet.remaining());
        assertTrue(packet.hasRemaining());

        packet.position(5);
        packet.limit(5);
        assertEquals(0, packet.remaining());
        assertFalse(packet.hasRemaining());
    }
   
    public void testFlip() {
        Packet packet = createTestPacket(100);
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.