Package org.activeio

Examples of org.activeio.Packet


    public void remove(String queue, Object id) throws IOException
    {
        ByteArrayOutputStream baos = new ByteArrayOutputStream(256);
        baos.write(DELETE_BYTE);
        baos.write(((UUID)id).asByteArray());
        Packet packet = new ByteArrayPacket(baos.toByteArray());
        RecordLocation loc = journal.write(packet, false);
        synchronized (markLock) {
            unusedMarks.add(loc);
            loc = (RecordLocation)marks.remove(id);
            if (loc != null) {
View Full Code Here


        logger.info("Journal Recovery Started.");
        try {
            synchronized (markLock) {
                // While we have records in the journal.
                while ((pos = journal.getNextRecordLocation(pos)) != null) {
                    Packet packet = journal.read(pos);
                    byte[] buffer = packet.sliceAsBytes();
                    if (buffer[0] == DELETE_BYTE) {
                        UUID id = new UUID(buffer, 1);
                        results.remove(id);
                        unusedMarks.add(pos);
                        RecordLocation loc = (RecordLocation)marks.remove(id);
View Full Code Here

                            if (m != null && m.size() > 0) {
                                logger.trace("Relocating " + m.size() + " records");
                                int nbRecord = 0;
                                while (m.size() > 0) {
                                    RecordLocation loc = (RecordLocation)m.first();
                                    Packet packet = journal.read(loc);
                                    RecordLocation newLoc = journal.write(packet, false);
                                    ObjectInputStream ois = new ObjectInputStream(
                                            new ByteArrayInputStream(packet.sliceAsBytes()));
                                    ois.readByte();
                                    String queue = ois.readUTF();
                                    byte[] buf = new byte[UUID_LENGTH];
                                    ois.read(buf);
                                    UUID id = new UUID(buf);
View Full Code Here

                  Subject subject = Subject.getSubject(AccessController.getContext());
                  String p = subject.getPrincipals().iterator().next().toString();
                  log.info("Sending request as: "+p);

                    Packet request = new ByteArrayPacket("whoami".getBytes());
                    Packet response = channel.request(request, 1000*5*1000);

                    assertNotNull(response);
                    assertEquals( p, new String(response.sliceAsBytes()) );
                    return null;
              }
          });
        } finally {
            channel.dispose();
View Full Code Here

        ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
        try {

            RequestChannel channel = createRequestChannel(target);
            Packet response;
            try {
                channel.start();
                Packet request = serialize(invocation);
                response = channel.request(request, Service.WAIT_FOREVER_TIMEOUT);
            } finally {
                channel.dispose();
            }
View Full Code Here

        ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
        try {

            RequestChannel channel = createRequestChannel(target);
            Packet response;
            try {
                channel.start();
                Packet request = serialize(invocation);
                response = channel.request(request, Service.WAIT_FOREVER_TIMEOUT);
            } finally {
                channel.dispose();               
            }
           
View Full Code Here

                  Subject subject = Subject.getSubject(AccessController.getContext());
                  String p = subject.getPrincipals().iterator().next().toString();
                  log.info("Sending request as: "+p);

                    Packet request = new ByteArrayPacket("whoami".getBytes());
                    Packet response = channel.request(request, 1000*5*1000);

                    assertNotNull(response);
                    assertEquals( p, new String(response.sliceAsBytes()) );
                    return null;
              }
          });
        } finally {
            channel.dispose();
View Full Code Here

   *
   * @return
   * @throws InterruptedException
   */
  public Packet getPacket() throws InterruptedException {
      Packet answer=null;
    synchronized(this) {
      while(answer==null) {
        if( pool.size()>0) {
          answer = (Packet) pool.remove(pool.size()-1);
        } else if( currentPoolSize < maxPackets ) {
View Full Code Here

    public void testSmallSendReceive() throws IOException, URISyntaxException, InterruptedException {
        if( isDisabled() ) {
            log.info("test disabled: "+getName());
            return;
        }
        Packet outboundPacket = new ByteArrayPacket("Hello World".getBytes());
        doSendReceive(outboundPacket.duplicate());
    }
View Full Code Here

        if( isDisabled() ) {
            log.info("test disabled: "+getName());
            return;
        }
       
        Packet outboundPacket = new ByteArrayPacket("Hello World".getBytes());
        doSendReceive(outboundPacket.duplicate());
        // disconnect the client.
        clientChannel.dispose();
       
        // The server should get an EOS packet.
        Packet packet = serverChannel.read(1000);
        assertEquals(EOSPacket.EOS_PACKET, packet);       
    }
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.