Examples of ExposedByteArrayOutputStream


Examples of org.infinispan.io.ExposedByteArrayOutputStream

      PutKeyValueCommand cmd = new PutKeyValueCommand(
            "k", "v", false, null, 0, 0, Collections.<Flag>emptySet());
      try {
         // Write
         StreamingMarshaller globalMarshal = extractGlobalMarshaller(cm);
         ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(1024);
         ObjectOutput globalOO = globalMarshal.startObjectOutput(baos, false, 1024);
         try {
            globalOO.writeObject(address);
         } finally {
            globalMarshal.finishObjectOutput(globalOO);
         }

         byte[] bytes = new byte[baos.size()];
         System.arraycopy(baos.getRawBuffer(), 0, bytes, 0, bytes.length);

         // Read
         ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
         ObjectInput globalOI = globalMarshal.startObjectInput(bais, false);
         try {
View Full Code Here

Examples of org.jboss.cache.io.ExposedByteArrayOutputStream

   }

   @Override
   public ByteBuffer objectToBuffer(Object obj) throws Exception
   {
      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(128);
      ObjectOutputStream out = new ObjectOutputStream(baos);

      out.writeShort(versionInt);
      if (trace) log.trace("Wrote version " + versionInt);

      //now marshall the contents of the object
      defaultMarshaller.objectToObjectStream(obj, out);
      out.close();

      // and return bytes.
      return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
   }
View Full Code Here

Examples of org.jboss.cache.io.ExposedByteArrayOutputStream

      MarshalledValueOutputStream out = null;
      byte[] result = null;
      try
      {
         ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(16 * 1024);
         out = new MarshalledValueOutputStream(baos);
         try
         {
            stateTransferManager.getState(out, fqn, timeout, force, false);
         }
         catch (RegionEmptyException ree)
         {
            return null;
         }
         result = baos.getRawBuffer();
      }
      finally
      {
         Util.close(out);
      }
View Full Code Here

Examples of org.jboss.cache.io.ExposedByteArrayOutputStream

   public byte[] getState()
   {
      MarshalledValueOutputStream out = null;
      byte[] result;
      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(16 * 1024);
      try
      {
         out = new MarshalledValueOutputStream(baos);

         stateTransferManager.getState(out, Fqn.ROOT, configuration.getStateRetrievalTimeout(), true, true);
      }
      catch (Throwable t)
      {
         stateProducingFailed(t);
      }
      finally
      {
         result = baos.getRawBuffer();
         Util.close(out);
      }
      return result;
   }
View Full Code Here

Examples of org.jboss.cache.io.ExposedByteArrayOutputStream

      if (hasDifferentSourceAndIntegrationRoots)
      {
         sourceRoot = state_id.split(DefaultStateTransferManager.PARTIAL_STATE_DELIMITER)[0];
      }

      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(16 * 1024);
      try
      {
         out = new MarshalledValueOutputStream(baos);

         stateTransferManager.getState(out, Fqn.fromString(sourceRoot),
               configuration.getStateRetrievalTimeout(), true, true);
      }
      catch (Throwable t)
      {
         stateProducingFailed(t);
      }
      finally
      {
         result = baos.getRawBuffer();
         Util.close(out);
      }
      return result;
   }
View Full Code Here

Examples of org.jboss.cache.io.ExposedByteArrayOutputStream

      MarshalledValueOutputStream out = null;
      byte[] result = null;
      try
      {
         ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(16 * 1024);
         out = new MarshalledValueOutputStream(baos);
         try
         {
            stateTransferManager.getState(out, fqn, timeout, force, false);
         }
         catch (RegionEmptyException ree)
         {
            return null;
         }
         result = baos.getRawBuffer();
      }
      finally
      {
         Util.close(out);
      }
View Full Code Here

Examples of org.jboss.cache.io.ExposedByteArrayOutputStream

   public byte[] getState()
   {
      MarshalledValueOutputStream out = null;
      byte[] result;
      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(16 * 1024);
      try
      {
         out = new MarshalledValueOutputStream(baos);

         stateTransferManager.getState(out, Fqn.ROOT, configuration.getStateRetrievalTimeout(), true, true);
      }
      catch (Throwable t)
      {
         stateProducingFailed(t);
      }
      finally
      {
         result = baos.getRawBuffer();
         Util.close(out);
      }
      return result;
   }
View Full Code Here

Examples of org.jboss.cache.io.ExposedByteArrayOutputStream

      if (hasDifferentSourceAndIntegrationRoots)
      {
         sourceRoot = state_id.split(DefaultStateTransferManager.PARTIAL_STATE_DELIMITER)[0];
      }

      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(16 * 1024);
      try
      {
         out = new MarshalledValueOutputStream(baos);

         stateTransferManager.getState(out, Fqn.fromString(sourceRoot),
               configuration.getStateRetrievalTimeout(), true, true);
      }
      catch (Throwable t)
      {
         stateProducingFailed(t);
      }
      finally
      {
         result = baos.getRawBuffer();
         Util.close(out);
      }
      return result;
   }
View Full Code Here

Examples of org.jboss.cache.io.ExposedByteArrayOutputStream

   }

   @Override
   public ByteBuffer objectToBuffer(Object obj) throws Exception
   {
      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(128);
      ObjectOutputStream out = new ObjectOutputStream(baos);

      out.writeShort(versionInt);
      if (trace) log.trace("Wrote version " + versionInt);

      //now marshall the contents of the object
      defaultMarshaller.objectToObjectStream(obj, out);
      out.close();

      // and return bytes.
      return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
   }
View Full Code Here

Examples of org.jboss.cache.util.ExposedByteArrayOutputStream

      int[] sizes = new int[3];
      byte[] retval = null;
      int lastSize;
      MarshalledValueOutputStream out;

      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(1024);
      try {
         initializeStateTransfer(baos);
         lastSize = baos.size();
      }
      catch (Throwable t)
      {
         log.error("failed initialing state transfer byte[]", t);
         if (!suppressErrors)
            throw t;
        
         return null;
      }

      try {
        
         if(generateTransient) {
            out = new MarshalledValueOutputStream(baos);
            marshallTransientState(rootNode, out);
            out.close();
            sizes[0] = baos.size() - lastSize;
            lastSize = baos.size();
            if (debug) {
               log.debug("generated the in-memory state (" + sizes[0] +
                         " bytes)");
            }
            // Return any state associated with the subtree but not stored in it
            if (cache instanceof PojoCache) {
               out = new MarshalledValueOutputStream(baos);
               marshallAssociatedState(fqn, out);
               out.close();
               sizes[1] = baos.size() - lastSize;
               lastSize = baos.size();
               if (debug) {
                  log.debug("returning the associated state (" + sizes[1] +
                            " bytes)");
               }
            }
         }
      }
      catch(Throwable t) {
         log.error("failed getting the in-memory (transient) state", t);
         if (!suppressErrors)
            throw t;
        
         // Reset the byte array and see if we can continue with persistent state
         // TODO reconsider this -- why are errors suppressed at all?
         sizes[0] = sizes[1] = 0;
         baos.reset();
         try {
            initializeStateTransfer(baos);
         }
         catch (Throwable t1) {
            log.error("failed re-initializing state transfer", t1);
            return null;
         }
      }
     
      if (generatePersistent) {
         try {
            if (debug)
               log.debug("getting the persistent state");
            byte[] persState = null;
            if (fqn.size() == 0)
               persState = cache.getCacheLoader().loadEntireState();
            else
               persState = ((ExtendedCacheLoader)cache.getCacheLoader()).loadState(fqn);
           
            if (persState != null) {
               sizes[2] = persState.length;
               baos.write(persState);
            }
           
            if (debug) {
               log.debug("generated the persistent state (" + sizes[2] +
                         " bytes)");
            }
         }
         catch(Throwable t) {
            log.error("failed getting the persistent state", t);
            if (!suppressErrors)
               throw t;
            sizes[2] = 0;
         }
      }
  
      // Overwrite the placeholders used for the sizes of the state transfer
      // components with the correct values
      try {
         byte[] bytes = baos.getRawBuffer();
         overwriteInt(bytes, 8, sizes[0]);
         overwriteInt(bytes, 12, sizes[1]);
         overwriteInt(bytes, 16, sizes[2]);
         retval = bytes;
        
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.