public static Object deserialize(byte[] blob) throws IOException, ClassNotFoundException { return deserialize(blob, false); }
public static byte[] serialize(Object obj) throws IOException { return serialize(obj, false); }
public static Object deserialize(byte[] blob, Version version, boolean unzipObject) throws IOException, ClassNotFoundException { return unzipObject ? unzip(blob) : BlobHelper.deserializeBlob(blob, version, null); }
CacheServerHelper.setIsDefaultServer(server);
public static byte[] serialize(Object obj, boolean zipObject) throws IOException { return zipObject ? zip(obj) : BlobHelper.serializeToBlob(obj); }
public String getString() { if (this.part == null) { return null; } if (!isBytes()) { Assert.assertTrue(false, "expected String part to be of type BYTE, part =" + this.toString()); } return CacheServerHelper.fromUTF((byte[]) this.part); }
CacheServerHelper.setIsDefaultServer(cacheServer);
@Override public void importNewObject(Object nv, boolean isSerialized) { if (!isSerialized) { throw new IllegalStateException("Expected importNewBytes to be called."); } try { this._value = CacheServerHelper.serialize(nv); } catch (IOException e) { throw new GemFireIOException("Exception serializing entry value", e); } }
public Object getObject(boolean unzip) throws IOException, ClassNotFoundException { if (isBytes()) { return this.part; } else { if (this.version != null) { return CacheServerHelper.deserialize((byte[]) this.part, this.version, unzip); } else { return CacheServerHelper.deserialize((byte[]) this.part, unzip); } } }
public static Object deserialize(byte[] blob, boolean unzipObject) throws IOException, ClassNotFoundException { return unzipObject ? unzip(blob) : BlobHelper.deserializeBlob(blob); }
@Override public void toData(DataOutput out) throws IOException { out.writeBoolean(this.hasKeys); if (this.objectTypeArray != null) { int numObjects = this.objects.size(); out.writeInt(numObjects); for (int index = 0; index < numObjects; ++index) { Object value = this.objects.get(index); byte objectType = this.objectTypeArray[index]; if (this.hasKeys) { DataSerializer.writeObject(this.keys.get(index), out); } out.writeBoolean(objectType == EXCEPTION); if (objectType == OBJECT && value instanceof byte[]) { out.write((byte[]) value); } else if (objectType == EXCEPTION) { // write exception as byte array so native clients can skip it DataSerializer.writeByteArray(CacheServerHelper.serialize(value), out); // write the exception string for native clients DataSerializer.writeString(value.toString(), out); } else { DataSerializer.writeObject(value, out); } } } else { out.writeInt(0); } }
public Object getValue() { if (isDeserialized || value == null) { return value; } try { value = CacheServerHelper.deserialize((byte[]) value); } catch (IOException ioe) { throw new RuntimeException( "IOException deserializing value", ioe); } catch (ClassNotFoundException cnfe) { throw new RuntimeException( "ClassNotFoundException deserializing value", cnfe); } isDeserialized = true; return value; }
} else if (objectType == EXCEPTION) { DataSerializer.writeByteArray(CacheServerHelper.serialize(value), out);
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { this.hasKeys = in.readBoolean(); if (this.hasKeys) { this.keys = new ArrayList(); } int numObjects = in.readInt(); if (numObjects > 0) { for (int index = 0; index < numObjects; ++index) { if (this.hasKeys) { Object key = DataSerializer.readObject(in); this.keys.add(key); } boolean isException = in.readBoolean(); Object value; if (isException) { byte[] exBytes = DataSerializer.readByteArray(in); value = CacheServerHelper.deserialize(exBytes); // ignore the exception string meant for native clients DataSerializer.readString(in); } else { value = DataSerializer.readObject(in); } this.objects.add(value); } } }
DataSerializer.writeByteArray(CacheServerHelper.serialize(value), out);
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { boolean keysPresent = in.readBoolean(); if (keysPresent) { this.keys = new ArrayList(); } this.hasKeys = keysPresent; int numObjects = in.readInt(); this.objectTypeArray = new byte[numObjects]; if (numObjects > 0) { for (int index = 0; index < numObjects; ++index) { if (keysPresent) { Object key = DataSerializer.readObject(in); this.keys.add(key); } byte objectType = in.readByte(); this.objectTypeArray[index] = objectType; Object value; if (objectType == EXCEPTION) { byte[] exBytes = DataSerializer.readByteArray(in); value = CacheServerHelper.deserialize(exBytes); // ignore the exception string meant for native clients DataSerializer.readString(in); } else { value = DataSerializer.readByteArray(in); } this.objects.add(value); } } }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { boolean keysPresent = in.readBoolean(); if (keysPresent) { this.keys = new ArrayList(); } this.hasKeys = keysPresent; int numObjects = in.readInt(); this.objectTypeArray = new byte[numObjects]; if (numObjects > 0) { for (int index = 0; index < numObjects; ++index) { if (keysPresent) { Object key = DataSerializer.readObject(in); this.keys.add(key); } byte objectType = in.readByte(); this.objectTypeArray[index] = objectType; Object value; if (objectType == EXCEPTION) { byte[] exBytes = DataSerializer.readByteArray(in); value = CacheServerHelper.deserialize(exBytes); // ignore the exception string meant for native clients DataSerializer.readString(in); } else { value = DataSerializer.readObject(in); } this.objects.add(value); } } }
public byte[] getSerializedValue() { if (this.newValueBytes == null) { final Object val; val = basicGetNewValue(); if (val instanceof byte[]) { return (byte[]) val; } else if (val instanceof CachedDeserializable) { return ((CachedDeserializable) val).getSerializedValue(); } try { return CacheServerHelper.serialize(val); } catch (IOException ioe) { throw new GemFireIOException("unexpected exception", ioe); } } else { return this.newValueBytes; } }
private void readObject(int index, DataInput in) throws IOException, ClassNotFoundException { Object value; this.objectTypeArray[index] = in.readByte(); if (logger.isTraceEnabled(LogMarker.VERSIONED_OBJECT_LIST_VERBOSE)) { logger.trace(LogMarker.VERSIONED_OBJECT_LIST_VERBOSE, "reading object {} of type {}", index, objectTypeArray[index]); } boolean isException = this.objectTypeArray[index] == EXCEPTION; if (isException) { byte[] exBytes = DataSerializer.readByteArray(in); value = CacheServerHelper.deserialize(exBytes); // ignore the exception string meant for native clients DataSerializer.readString(in); } else if (this.serializeValues) { value = DataSerializer.readByteArray(in); } else { value = DataSerializer.readObject(in); } this.objects.add(value); }