Package org.jboss.util.stream

Examples of org.jboss.util.stream.MarshalledValueOutputStream


        }

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        // write a marker to stream to distinguish from null value stream
        baos.write(SERIALIZABLE_VALUE);
        MarshalledValueOutputStream mvos = new MarshalledValueOutputStream(baos);
        mvos.writeObject(obj);
        mvos.flush();
        return baos.toByteArray();
    }
View Full Code Here


                Object state = provider.getCurrentState();
                try {
                    if (provider instanceof StateTransferStreamProvider) {
                        ((StateTransferStreamProvider) provider).getCurrentState(ostream);
                    } else {
                        MarshalledValueOutputStream mvos = new MarshalledValueOutputStream(ostream);
                        toClose = mvos;
                        mvos.writeObject(state);
                    }
                } catch (Exception ex) {
                    CoreGroupCommunicationService.this.log.error("getState failed for service " + serviceName, ex);
                } finally {
                    if (toClose != null) {
View Full Code Here

            CoreGroupCommunicationService.this.log.debug("getState called for service " + serviceName);

            StateTransferProvider provider = stateProviders.get(serviceName);
            if (provider != null) {
                MarshalledValueOutputStream mvos = null;
                Object state = provider.getCurrentState();
                try {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
                    mvos = new MarshalledValueOutputStream(baos);
                    mvos.writeObject(state);
                    mvos.flush();
                    mvos.close();
                    return baos.toByteArray();
                } catch (Exception ex) {
                    CoreGroupCommunicationService.this.log.error("getState failed for service " + serviceName, ex);
                } finally {
                    if (mvos != null) {
                        try {
                            mvos.close();
                        } catch (IOException ignored) {
                            log.debug("Caught exception closing stream used for marshalling state", ignored);
                        }
                    }
                }
View Full Code Here

    *         (or null), and element 1 is the persistent state (or null).
    */
   private byte[] generateState(Fqn fqn, long timeout, boolean force) throws Throwable
   {

      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)
View Full Code Here

   {
   }

   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)
      {
View Full Code Here

   }

   public byte[] getState(String state_id)
   {
      if (trace) log.trace("Getting state for state id " + state_id);
      MarshalledValueOutputStream out = null;
      String sourceRoot = state_id;
      byte[] result;

      boolean hasDifferentSourceAndIntegrationRoots = state_id.indexOf(DefaultStateTransferManager.PARTIAL_STATE_DELIMITER) > 0;
      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)
View Full Code Here

      return result;
   }

   public void getState(OutputStream ostream)
   {
      MarshalledValueOutputStream out = null;
      try
      {
         out = new MarshalledValueOutputStream(ostream);
         stateTransferManager.getState(out, Fqn.ROOT, configuration.getStateRetrievalTimeout(), true, true);
      }
      catch (Throwable t)
      {
         stateProducingFailed(t);
View Full Code Here

   public void getState(String state_id, OutputStream ostream)
   {
      if (trace) log.trace("Getting state for state id " + state_id);
      String sourceRoot = state_id;
      MarshalledValueOutputStream out = null;
      boolean hasDifferentSourceAndIntegrationRoots = state_id.indexOf(DefaultStateTransferManager.PARTIAL_STATE_DELIMITER) > 0;
      if (hasDifferentSourceAndIntegrationRoots)
      {
         sourceRoot = state_id.split(DefaultStateTransferManager.PARTIAL_STATE_DELIMITER)[0];
      }
      try
      {
         out = new MarshalledValueOutputStream(ostream);
         stateTransferManager.getState(out, Fqn.fromString(sourceRoot), configuration.getStateRetrievalTimeout(), true, true);
      }
      catch (Throwable t)
      {
         stateProducingFailed(t);
View Full Code Here

      CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
      loader.remove(X);
      cache.put(X, "key1", "value1");
      Thread.sleep(1000);
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      cache.getMarshaller().objectToObjectStream(DefaultStateTransferManager.STREAMING_DELIMITER_NODE, os);
      //os.close();
      assertTrue(baos.size() > 0);
      loader.remove(X);
View Full Code Here

      /* One FQN only. */
      doPutTests(FQN);
      doRemoveTests(FQN);

      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      os.close();

      /* Add three FQNs, middle FQN last. */
      Fqn k1 = Fqn.fromString("/key1");
      Fqn k2 = Fqn.fromString("/key2");
      Fqn k3 = Fqn.fromString("/key3");

      doPutTests(k1);
      doPutTests(k3);
      doPutTests(k2);
      assertEquals(4, loader.get(k1).size());
      assertEquals(4, loader.get(k2).size());
      assertEquals(4, loader.get(k3).size());

      /* Remove middle FQN first, then the others. */
      doRemoveTests(k2);
      doRemoveTests(k3);
      doRemoveTests(k1);
      assertEquals(null, loader.get(k1));
      assertEquals(null, loader.get(k2));
      assertEquals(null, loader.get(k3));

      baos = new ByteArrayOutputStream(1024);
      os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      os.close();

      stopLoader();
   }
View Full Code Here

TOP

Related Classes of org.jboss.util.stream.MarshalledValueOutputStream

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.