public static byte[] serialize(Object obj) throws IOException { return serialize(obj, false); }
@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); } }
@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); } }
} else if (objectType == EXCEPTION) { DataSerializer.writeByteArray(CacheServerHelper.serialize(value), out);
DataSerializer.writeByteArray(CacheServerHelper.serialize(value), out);
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 writeObject(Object value, int index, DataOutput out) throws IOException { byte objectType = this.objectTypeArray[index]; if (logger.isTraceEnabled(LogMarker.VERSIONED_OBJECT_LIST_VERBOSE)) { logger.trace(LogMarker.VERSIONED_OBJECT_LIST_VERBOSE, "writing object {} of type {}: {}", index, objectType, value); } out.writeByte(objectType); if (objectType == OBJECT && value instanceof byte[]) { if (this.serializeValues) { DataSerializer.writeByteArray((byte[]) value, out); } else { 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 { if (this.serializeValues) { DataSerializer.writeObjectAsByteArray(value, out); } else { DataSerializer.writeObject(value, out); } } }
@Override public void toData(DataOutput out) throws IOException { out.writeByte(_operation.getEventCode()); DataSerializer.writeString(_regionName, out); DataSerializer.writeObject(_keyOfInterest, out); if (_value instanceof byte[]) { DataSerializer.writeByteArray((byte[]) _value, out); } else { DataSerializer.writeByteArray(CacheServerHelper.serialize(_value), out); } out.writeByte(_valueIsObject); DataSerializer.writeObject(_membershipId, out); // DataSerializer.writeObject(_eventIdentifier,out); out.writeBoolean(_shouldConflate); out.writeBoolean(_isInterestListPassed); DataSerializer.writeByteArray(this.deltaBytes, out); out.writeBoolean(_hasCqs); // if (_hasCqs) { // DataSerializer.writeHashMap(this._clientCqs, out); // } DataSerializer.writeObject(_callbackArgument, out); DataSerializer.writeHashSet((HashSet) this._clientInterestList, out); DataSerializer.writeHashSet((HashSet) this._clientInterestListInv, out); DataSerializer.writeObject(this.versionTag, out); }
private static void sendRegistrationMessageToClients(DataSerializer dataSerializer) { InternalCache cache = GemFireCacheImpl.getInstance(); if (cache == null) { // A cache has not yet been created. // we can't propagate it to clients return; } byte[][] serializedDataSerializer = new byte[2][]; try { serializedDataSerializer[0] = CacheServerHelper.serialize(dataSerializer.getClass().toString().substring(6)); byte[] idBytes = new byte[4]; Part.encodeInt(dataSerializer.getId(), idBytes); serializedDataSerializer[1] = idBytes; } catch (IOException ignored) { if (logger.isTraceEnabled(LogMarker.SERIALIZER_VERBOSE)) { logger.trace(LogMarker.SERIALIZER_VERBOSE, "InternalDataSerializer encountered an IOException while serializing DataSerializer :{}", dataSerializer); } } ClientDataSerializerMessage clientDataSerializerMessage = new ClientDataSerializerMessage(EnumListenerEvent.AFTER_REGISTER_DATASERIALIZER, serializedDataSerializer, (ClientProxyMembershipID) dataSerializer.getContext(), (EventID) dataSerializer.getEventId(), new Class[][] {dataSerializer.getSupportedClasses()}); // Deliver it to all the clients CacheClientNotifier.routeClientMessage(clientDataSerializerMessage); }
} else { try { value = CacheServerHelper.serialize(entry.value); } catch (IOException e) { logger.warn(
try { for (int j = 0; j < numOfClasses; j++) { classBytes[j] = CacheServerHelper.serialize(this.supportedClasses[i / 2][j].getName());
this._value = serializedValue = CacheServerHelper.serialize(latestValue);
val = ((CachedDeserializable) val).getSerializedValue(); } else { val = CacheServerHelper.serialize(val);
if (l == null) { if (!(this._value instanceof byte[])) { this._value = CacheServerHelper.serialize(this._value);
if (latestValue == null) { if (!(this._value instanceof byte[])) { this._value = CacheServerHelper.serialize(this._value);
if (latestValue == null) { if (!(this._value instanceof byte[])) { this._value = CacheServerHelper.serialize(this._value);