Package org.activeio.packet

Examples of org.activeio.packet.ByteArrayPacket


        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


     * @throws IOException
     * @throws URISyntaxException
     * @throws InterruptedException
     */
    private void doSendReceive(final Packet outboundPacket) throws IOException, URISyntaxException, InterruptedException {
        ByteArrayPacket inboundPacket = new ByteArrayPacket(new byte[outboundPacket.remaining()]);

        // Do the send async.
        sendExecutor.execute( new Runnable() {
            public void run() {
                try {
                    clientChannel.write(outboundPacket);
                    clientChannel.flush();
                } catch (IOException e) {
                }
            }
        });
       
        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

       
        if( syncFrequency>=0 && (i%syncFrequency)==0 ) {
          sync=true;
        }       
        try {
          journal.write(new ByteArrayPacket(data), sync);
          Thread.sleep(workerThinkTime);
        } catch (Exception e) {
          e.printStackTrace();
          return;
        }
View Full Code Here

    }

    protected void hitIIOPServer() throws Exception {
        SynchChannel channel = channelFactory.openSynchChannel(server.getConnectURI());
        ((SocketMetadata)channel.narrow(SocketMetadata.class)).setTcpNoDelay(true);
        channel.write(new ByteArrayPacket("GIOPcrapcrap".getBytes("UTF-8")));
        channel.flush();
        channel.dispose();
    }
View Full Code Here

    public void testUnknownAccept() throws IOException, URISyntaxException, InterruptedException {
        SynchChannel channel = channelFactory.openSynchChannel(server.getConnectURI());
        ((SocketMetadata)channel.narrow(SocketMetadata.class)).setTcpNoDelay(true);
        channel
                .write(new ByteArrayPacket("Licensed under the Apache License, Version 2.0 (the \"License\")"
                        .getBytes("UTF-8")));
        channel.flush();
        String type = (String) resultSlot.poll(1000 * 5);
        assertNull(type);
        channel.dispose();
View Full Code Here

                    byte data[] = ("HTTP/1.1 200 OK\r\n" + "Content-Type: text/html; charset=UTF-8\r\n" + "\r\n"
                            + "Hello World").getBytes("UTF-8");

                    ((SocketMetadata)channel.narrow(SocketMetadata.class)).setTcpNoDelay(true);
                    ((AsynchChannel) channel).write(new ByteArrayPacket(data));

                    channel.dispose();
                } catch (Throwable e) {
                    e.printStackTrace();
                }
View Full Code Here

    /**
     * @param string
     * @return
     */
    private Packet createPacket(String string) {
        return new ByteArrayPacket(string.getBytes());
    }
View Full Code Here

    private static final int DEFAULT_BUFFER_SIZE = 1024*64;
    private final Packet buffer;
    private final boolean enableDirectWrites;
   
    public WriteBufferedSynchChannel(SynchChannel channel) {
        this(channel, new ByteArrayPacket(new byte[DEFAULT_BUFFER_SIZE]));
    }
View Full Code Here

     * @throws IOException
     * @throws InterruptedException
     */
    private void appendHelloRecord(int i) throws IOException, InterruptedException {
        byte data[] = ("Hello World: " + i).getBytes();
        Record batchedRecord = new Record(LogFileManager.DATA_RECORD_TYPE, new ByteArrayPacket(data), null);
        batchedRecord.setLocation(logFile.getNextAppendLocation());
       
        BatchedWrite write = new BatchedWrite(new ByteBufferPacket(ByteBuffer.allocate(1024)));
        write.append(batchedRecord,null, true);
        write.flip();
View Full Code Here

            requestMap.remove(requestId);
        }       
    }

    private Packet createHeaderPacket(byte type, short requestId) throws IOException {
        ByteArrayPacket header = new ByteArrayPacket(new byte[]{3});
        PacketData data = new PacketData(header);
        data.writeByte(type);
        data.writeShort(requestId);
        header.flip();
        return header;
    }
View Full Code Here

TOP

Related Classes of org.activeio.packet.ByteArrayPacket

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.