Package org.infinispan.marshall

Examples of org.infinispan.marshall.StreamingMarshaller


      commandExt.writeCommandHeader(output, command);

      String cacheName = command.getCacheName();
      output.writeUTF(cacheName);
      ComponentRegistry registry = gcr.getNamedComponentRegistry(cacheName);
      StreamingMarshaller marshaller = registry.getComponent(
            StreamingMarshaller.class, KnownComponentNames.CACHE_MARSHALLER);
      // Take the cache marshaller and generate the payload for the rest of
      // the command using that cache marshaller and the write the bytes in
      // the original payload.
      ExposedByteArrayOutputStream os = marshallParameters(command, marshaller);
View Full Code Here


      byte type = input.readByte();
      byte methodId = (byte) input.readShort();

      String cacheName = input.readUTF();
      ComponentRegistry registry = gcr.getNamedComponentRegistry(cacheName);
      StreamingMarshaller marshaller;
      if (registry == null) {
         // Even though the command is directed at a cache, it could happen
         // that the cache is not yet started, so fallback on global marshaller.
         marshaller = gcr.getComponent(
               StreamingMarshaller.class, KnownComponentNames.GLOBAL_MARSHALLER);
      } else {
         marshaller = registry.getComponent(
               StreamingMarshaller.class, KnownComponentNames.CACHE_MARSHALLER);
      }

      byte[] paramsRaw = new byte[UnsignedNumeric.readUnsignedInt(input)];
      // This is not ideal cos it forces the code to read all parameters into
      // memory and then splitting them, potentially leading to excessive
      // buffering. An alternative solution is shown in SharedStreamMultiMarshallerTest
      // but it requires some special treatment - iow, hacking :)
      input.readFully(paramsRaw);
      ByteArrayInputStream is = new ByteArrayInputStream(paramsRaw, 0, paramsRaw.length);
      ObjectInput paramsInput = marshaller.startObjectInput(is, true);
      // Not ideal, but the alternative (without changing API), would have been
      // using thread locals which are expensive to retrieve.
      // Remember that the aim with externalizers is for them to be stateless.
      if (paramsInput instanceof ExtendedRiverUnmarshaller)
         ((ExtendedRiverUnmarshaller) paramsInput).setInfinispanMarshaller(marshaller);

      try {
         Object[] args = commandExt.readParameters(paramsInput);
         return commandExt.cmdFactory.fromStream(methodId, args, type, cacheName);
      } catch (IOException e) {
         throw e;
      } finally {
         marshaller.finishObjectInput(paramsInput);
      }
   }
View Full Code Here

      return (ComponentRegistry) extractField(ci, "componentRegistry");
   }

   public static AbstractDelegatingMarshaller extractCacheMarshaller(Cache cache) {
      ComponentRegistry cr = (ComponentRegistry) extractField(cache, "componentRegistry");
      StreamingMarshaller marshaller = cr.getComponent(StreamingMarshaller.class, KnownComponentNames.CACHE_MARSHALLER);
      return (AbstractDelegatingMarshaller) marshaller;
   }
View Full Code Here

      commandExt.writeCommandHeader(output, command);

      String cacheName = command.getCacheName();
      output.writeUTF(cacheName);
      ComponentRegistry registry = gcr.getNamedComponentRegistry(cacheName);
      StreamingMarshaller marshaller;
      if (registry == null) {
         // TODO This is a hack to support global commands CacheViewControlCommand
         // but they should not be CacheRpcCommands at all
         marshaller = gcr.getComponent(
               StreamingMarshaller.class, KnownComponentNames.GLOBAL_MARSHALLER);
View Full Code Here

      byte type = input.readByte();
      byte methodId = (byte) input.readShort();

      String cacheName = input.readUTF();
      ComponentRegistry registry = gcr.getNamedComponentRegistry(cacheName);
      StreamingMarshaller marshaller;
      if (registry == null) {
         // Even though the command is directed at a cache, it could happen
         // that the cache is not yet started, so fallback on global marshaller.
         marshaller = gcr.getComponent(
               StreamingMarshaller.class, KnownComponentNames.GLOBAL_MARSHALLER);
      } else {
         marshaller = registry.getComponent(
               StreamingMarshaller.class, KnownComponentNames.CACHE_MARSHALLER);
      }

      byte[] paramsRaw = new byte[UnsignedNumeric.readUnsignedInt(input)];
      // This is not ideal cos it forces the code to read all parameters into
      // memory and then splitting them, potentially leading to excessive
      // buffering. An alternative solution is shown in SharedStreamMultiMarshallerTest
      // but it requires some special treatment - iow, hacking :)
      input.readFully(paramsRaw);
      ByteArrayInputStream is = new ByteArrayInputStream(paramsRaw, 0, paramsRaw.length);
      ObjectInput paramsInput = marshaller.startObjectInput(is, true);
      // Not ideal, but the alternative (without changing API), would have been
      // using thread locals which are expensive to retrieve.
      // Remember that the aim with externalizers is for them to be stateless.
      if (paramsInput instanceof ExtendedRiverUnmarshaller)
         ((ExtendedRiverUnmarshaller) paramsInput).setInfinispanMarshaller(marshaller);

      try {
         Object[] args = commandExt.readParameters(paramsInput);
         return commandExt.cmdFactory.fromStream(methodId, args, type, cacheName);
      } catch (IOException e) {
         throw e;
      } finally {
         marshaller.finishObjectInput(paramsInput);
      }
   }
View Full Code Here

   }

   @Override
   public void start() throws CacheLoaderException {
      super.start();
      StreamingMarshaller marshaller = getMarshaller();

      if (marshaller == null) {throw new IllegalStateException("Null marshaller not allowed!");}
      remoteCacheManager = new RemoteCacheManager(marshaller, config.getHotRodClientProperties(), true, config.getClassLoader(), config.getAsyncExecutorFactory());
      if (config.getRemoteCacheName().equals(BasicCacheContainer.DEFAULT_CACHE_NAME))
         remoteCache = remoteCacheManager.getCache();
View Full Code Here

      cmdExt.writeCommandHeader(output, command);

      String cacheName = command.getCacheName();
      output.writeUTF(cacheName);
      ComponentRegistry registry = gcr.getNamedComponentRegistry(cacheName);
      StreamingMarshaller marshaller;
      if (registry == null) {
         // TODO This is a hack to support global commands CacheViewControlCommand
         // but they should not be CacheRpcCommands at all
         marshaller = globalMarshaller;
      } else {
View Full Code Here

      byte type = input.readByte();
      byte methodId = (byte) input.readShort();

      String cacheName = input.readUTF();
      ComponentRegistry registry = gcr.getNamedComponentRegistry(cacheName);
      StreamingMarshaller marshaller;
      if (registry == null) {
         // Even though the command is directed at a cache, it could happen
         // that the cache is not yet started, so fallback on global marshaller.
         marshaller = globalMarshaller;
      } else {
         marshaller = registry.getCacheMarshaller();
      }

      byte[] paramsRaw = new byte[UnsignedNumeric.readUnsignedInt(input)];
      // This is not ideal cos it forces the code to read all parameters into
      // memory and then splitting them, potentially leading to excessive
      // buffering. An alternative solution is shown in SharedStreamMultiMarshallerTest
      // but it requires some special treatment - iow, hacking :)
      input.readFully(paramsRaw);
      ByteArrayInputStream is = new ByteArrayInputStream(paramsRaw, 0, paramsRaw.length);
      ObjectInput paramsInput = marshaller.startObjectInput(is, true);
      // Not ideal, but the alternative (without changing API), would have been
      // using thread locals which are expensive to retrieve.
      // Remember that the aim with externalizers is for them to be stateless.
      if (paramsInput instanceof ExtendedRiverUnmarshaller)
         ((ExtendedRiverUnmarshaller) paramsInput).setInfinispanMarshaller(marshaller);

      try {
         Object[] args = cmdExt.readParameters(paramsInput);
         return cmdExt.fromStream(methodId, args, type, cacheName);
      } catch (IOException e) {
         throw e;
      } finally {
         marshaller.finishObjectInput(paramsInput);
      }
   }
View Full Code Here

   }

   @Override
   public void start() throws CacheLoaderException {
      super.start();
      StreamingMarshaller marshaller = getMarshaller();

      if (marshaller == null) {throw new IllegalStateException("Null marshaller not allowed!");}
      remoteCacheManager = new RemoteCacheManager(marshaller, config.getHotRodClientProperties(), config.getAsyncExecutorFactory());
      if (config.getRemoteCacheName().equals(CacheContainer.DEFAULT_CACHE_NAME))
         remoteCache = remoteCacheManager.getCache();
View Full Code Here

      cmdExt.writeCommandHeader(output, command);

      String cacheName = command.getCacheName();
      output.writeUTF(cacheName);
      ComponentRegistry registry = gcr.getNamedComponentRegistry(cacheName);
      StreamingMarshaller marshaller;
      if (registry == null) {
         // TODO This is a hack to support global commands CacheViewControlCommand
         // but they should not be CacheRpcCommands at all
         marshaller = globalMarshaller;
      } else {
View Full Code Here

TOP

Related Classes of org.infinispan.marshall.StreamingMarshaller

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.