Package org.activeio

Examples of org.activeio.Packet


        if( isDisabled() ) {
            log.info("test disabled: "+getName());
            return;
        }
        log.info("Start of testManySmallSendReceives");
        Packet outboundPacket = new ByteArrayPacket("Hello World".getBytes());
        long start = System.currentTimeMillis();
        for( int i=0; i < getTestIterations(); i++ ) {
            doSendReceive(outboundPacket.duplicate());
        }
        long end = System.currentTimeMillis();       
        log.info("done. Duration: "+duration(start,end)+", duration per send: "+unitDuration(start, end, getTestIterations()));
    }
View Full Code Here


                }
            }
        });
       
        while( inboundPacket.hasRemaining() ) {
          Packet packet = serverChannel.read(1000*5);
          assertNotNull(packet);
          packet.read(inboundPacket);
        }       
        outboundPacket.clear();
        inboundPacket.clear();
        assertEquals(outboundPacket.sliceAsBytes(), inboundPacket.sliceAsBytes());
               
View Full Code Here

   */
  public Packet read(RecordLocation location)
      throws InvalidRecordLocationException, IOException {
   
    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 void write(Packet packet) throws IOException {
            packet = packet.slice();
            while(packet.hasRemaining()) {
                int size = Math.max(maxPacketSize, packet.remaining());
                packet.position(size);
                Packet remaining = packet.slice();
                packet.flip();
                Packet data = packet.slice();
                super.write(data);
                packet = remaining;
                try {
                    Thread.sleep(packetDelay);
                } catch (InterruptedException e) {
View Full Code Here

        cs = new FilterAsynchChannelServer(cs) {
            public void onAccept(Channel channel) {
                SynchChannel synchChannel = AsynchToSynchChannelAdapter.adapt(channel);               
                super.onAccept(new FilterSynchChannel(synchChannel) {
                    public org.activeio.Packet read(long timeout) throws IOException {
                        Packet packet = super.read(timeout);
                        if( packet!=null && packet.hasRemaining() )
                            serverPacketCounter.increment();
                        return packet;
                    }
                });
            }
View Full Code Here

          assertNull(mark);
    }
   
    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);
     
      // 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

        this.putback = packet;
    }
   
    public Packet read(long timeout) throws IOException {
        if(putback!=null ) {
            Packet p = putback;
            putback=null;
            return p;
        }
        return super.read(timeout);
    }
View Full Code Here

    public Packet read(long timeout) throws IOException {
        long start = System.currentTimeMillis();
        if( assembledPackets.isEmpty() ) {
            while( true ) {
               
              Packet packet = getNext().read(timeout);
              if( packet==null ) {
                    return null;
              }
             
              aggregator.addRawPacket(packet);
View Full Code Here

        IAsyncFuture future = (IAsyncFuture)abstractFuture;
        try {
           
            if( inputByteBuffer.position()>0 ) {
              ByteBuffer remaining = inputByteBuffer.slice();           
              Packet data = new ByteBufferPacket(((ByteBuffer)inputByteBuffer.flip()).slice());
             
              channelListener.onPacket(data);             
              // Keep the remaining buffer around to fill with data.
              inputByteBuffer = remaining;
              requestNextRead();
View Full Code Here

    /**
     * @see org.activeio.FilterAsynchChannel#write(org.activeio.channel.Packet)
     */
    public void write(Packet packet) throws IOException {
        Packet passThrough = AppendedPacket.join(PASSTHROUGH_PACKET.duplicate(), packet);
        synchronized(writeMutex) {
            super.write(passThrough);
        }
    }
View Full Code Here

TOP

Related Classes of org.activeio.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.