Examples of ByteBufferInput


Examples of com.esotericsoftware.kryo.io.ByteBufferInput

    long bufAddress = UnsafeUtil.unsafe().allocateMemory(4096);
    try {
      ByteBufferOutput outputBuffer = new ByteBufferOutput(bufAddress, 4096);
      outputBuffer.writeInt(10);

      ByteBufferInput inputBuffer = new ByteBufferInput(outputBuffer.getByteBuffer());
      inputBuffer.readInt();
      inputBuffer.release();

      outputBuffer.release();
      outputBuffer = new UnsafeMemoryOutput(bufAddress, 4096);
      outputBuffer.writeInt(10);

      inputBuffer = new UnsafeMemoryInput(outputBuffer.getByteBuffer());
      inputBuffer.readInt();
      inputBuffer.release();
      outputBuffer.release();
    } catch (Throwable t) {
      System.err.println("Streams with preallocated direct memory are not supported on this JVM");
      t.printStackTrace();
    } finally {
View Full Code Here

Examples of com.esotericsoftware.kryo.io.ByteBufferInput

      public Output createOutput(int size, int limit) {
        return new ByteBufferOutput(size, limit);
      }

      public Input createInput(InputStream os, int size) {
        return new ByteBufferInput(os, size);
      }

      public Input createInput(byte[] buffer) {
        return new ByteBufferInput(buffer);
      }
    });

    roundTripWithStreamFactory(unsafeLength, object1, new StreamFactory() {
      public Output createOutput(OutputStream os) {
View Full Code Here

Examples of com.esotericsoftware.kryo.io.ByteBufferInput

      public Output createOutput(int size, int limit) {
        return new ByteBufferOutput(size, limit);
      }

      public Input createInput(InputStream os, int size) {
        return new ByteBufferInput(os, size);
      }

      public Input createInput(byte[] buffer) {
        return new ByteBufferInput(buffer);
      }
    });

    roundTripWithStreamFactory(unsafeLength, object1, new StreamFactory() {
      public Output createOutput(OutputStream os) {
View Full Code Here

Examples of com.esotericsoftware.kryo.io.ByteBufferInput

  public <T extends Entry> void testSerializeAndDeserializeEntry(Class<T> entryType, T entry)
    throws Exception {
    Kryo kryo = new Kryo();
    ByteBuffer buffer = ByteBuffer.allocate(4096);
    Output output = new ByteBufferOutput(buffer);
    Input input = new ByteBufferInput(buffer);
    Class<? extends Serializer> serializer = entryType.getAnnotation(EntryType.class).serializer();
    kryo.register(entryType, serializer.newInstance(), entryType.getAnnotation(EntryType.class) .id());
    kryo.writeClassAndObject(output, entry);
    T result = (T) kryo.readClassAndObject(input);
    Assert.assertEquals(entry, result);
View Full Code Here

Examples of com.esotericsoftware.kryo.io.ByteBufferInput

    kryo.register(RegisterUDP.class);
    kryo.register(KeepAlive.class);
    kryo.register(DiscoverHost.class);
    kryo.register(Ping.class);

    input = new ByteBufferInput();
    output = new ByteBufferOutput();
  }
View Full Code Here

Examples of org.jboss.marshalling.ByteBufferInput

    private Object deserialize(final String info) throws IOException, ClassNotFoundException {

        byte[] data = Base64.decode(info.trim());
        Unmarshaller unmarshaller = factory.createUnmarshaller(configuration);
        unmarshaller.start(new ByteBufferInput(ByteBuffer.wrap(data)));
        try {
            return unmarshaller.readObject();
        } finally {
            unmarshaller.close();
        }
View Full Code Here

Examples of org.jboss.marshalling.ByteBufferInput

                    Map<String, PersistentSession> ret = new HashMap<String, PersistentSession>();
                    for (Map.Entry<String, SessionEntry> sessionEntry : data.entrySet()) {
                        if (sessionEntry.getValue().expiry.getTime() > time) {
                            Map<String, Object> session = new HashMap<String, Object>();
                            for (Map.Entry<String, byte[]> sessionAttribute : sessionEntry.getValue().data.entrySet()) {
                                unmarshaller.start(new ByteBufferInput(ByteBuffer.wrap(sessionAttribute.getValue())));
                                session.put(sessionAttribute.getKey(), unmarshaller.readObject());
                                unmarshaller.finish();
                            }
                            ret.put(sessionEntry.getKey(), new PersistentSession(sessionEntry.getValue().expiry, session));
                        }
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.