@Override protected void readInternal(ObjectDataInput in) throws IOException { super.readInternal(in); int confSize = in.readInt(); for (int i = 0; i < confSize; i++) { final CacheConfig config = in.readObject(); configs.add(config); } int count = in.readInt(); for (int i = 0; i < count; i++) { int subCount = in.readInt(); String name = in.readUTF(); Map<Data, CacheRecord> m = new HashMap<Data, CacheRecord>(subCount); data.put(name, m); // subCount + 1 because of the DefaultData written as the last entry // which adds another Data entry at the end of the stream! for (int j = 0; j < subCount + 1; j++) { Data key = in.readData(); // Empty data received so reading can be stopped here since // since the real object subCount might be different from // the number on the stream due to found expired entries if (key.dataSize() == 0) { break; } CacheRecord record = in.readObject(); m.put(key, record); } } }
@Override protected void writeInternal(ObjectDataOutput out) throws IOException { super.writeInternal(out); out.writeBoolean(retain); out.writeInt(valueSet.size()); for (Data value : valueSet) { value.writeData(out); } }
public void writePortable(PortableWriter writer) throws IOException { writer.writeInt("s", entrySet.size()); final ObjectDataOutput out = writer.getRawDataOutput(); for (Map.Entry<Data, Data> entry : entrySet) { Data key = entry.getKey(); Data value = entry.getValue(); key.writeData(out); value.writeData(out); } }
@Override public void write(PortableWriter writer) throws IOException { writer.writeUTF("n", name); writer.writeInt("size", keys.size()); ObjectDataOutput output = writer.getRawDataOutput(); for (Data key : keys) { key.writeData(output); } output.writeObject(processor); }
public void write(PortableWriter writer) throws IOException { writer.writeUTF("n", name); writer.writeInt("size", keys.size()); if (!keys.isEmpty()) { ObjectDataOutput output = writer.getRawDataOutput(); for (Data key : keys) { key.writeData(output); } } }
@Override protected void writeInternal(ObjectDataOutput out) throws IOException { super.writeInternal(out); final List<Data> keyValueSequence = this.keyValueSequence; final int size = keyValueSequence.size(); out.writeInt(size); for (Data data : keyValueSequence) { data.writeData(out); } }
public void writeData(ObjectDataOutput out) throws IOException { out.writeInt(map.size()); for (Map.Entry<Data, Collection<Data>> entry : map.entrySet()) { entry.getKey().writeData(out); Collection<Data> coll = entry.getValue(); out.writeInt(coll.size()); for (Data data : coll) { data.writeData(out); } } }
public void read(PortableReader reader) throws IOException { name = reader.readUTF("n"); int size = reader.readInt("size"); if (size > 0) { ObjectDataInput input = reader.getRawDataInput(); for (int i = 0; i < size; i++) { Data key = new Data(); key.readData(input); keys.add(key); } } }
public void readPortable(PortableReader reader) throws IOException { int size = reader.readInt("s"); final ObjectDataInput in = reader.getRawDataInput(); entrySet = new HashSet<Map.Entry>(size); for (int i = 0; i < size; i++) { Data key = new Data(); Data value = new Data(); key.readData(in); value.readData(in); entrySet.add(new AbstractMap.SimpleEntry(key, value)); } }
@Override protected void readInternal(ObjectDataInput in) throws IOException { super.readInternal(in); retain = in.readBoolean(); final int size = in.readInt(); valueSet = new HashSet<Data>(size); for (int i = 0; i < size; i++) { final Data value = new Data(); value.readData(in); valueSet.add(value); } }
@Override public void read(PortableReader reader) throws IOException { name = reader.readUTF("n"); int size = reader.readInt("size"); keys = new HashSet<Data>(); ObjectDataInput input = reader.getRawDataInput(); for (int i = 0; i < size; i++) { Data key = new Data(); key.readData(input); keys.add(key); } processor = input.readObject(); }
protected void writeInternal(ObjectDataOutput out) throws IOException { out.writeUTF(name); dataKey.writeData(out); out.writeLong(threadId); IOUtil.writeNullableData(out, dataValue); out.writeLong(ttl); }
@Override public void read(PortableReader reader) throws IOException { name = reader.readUTF("n"); final ObjectDataInput in = reader.getRawDataInput(); key = new Data(); key.readData(in); }
@Override protected void readInternal(ObjectDataInput in) throws IOException { super.readInternal(in); final int size = in.readInt(); if (size < 1) { keyValueSequence = Collections.emptyList(); } else { final List<Data> tmpKeyValueSequence = new ArrayList<Data>(size); for (int i = 0; i < size; i++) { final Data data = new Data(); data.readData(in); tmpKeyValueSequence.add(data); } keyValueSequence = tmpKeyValueSequence; } }
@Override public void writeData(ObjectDataOutput out) throws IOException { super.writeData(out); dataKey.writeData(out); IOUtil.writeNullableData(out, dataNewValue); IOUtil.writeNullableData(out, dataOldValue); }
protected void readInternal(ObjectDataInput in) throws IOException { name = in.readUTF(); dataKey = new Data(); dataKey.readData(in); threadId = in.readLong(); dataValue = IOUtil.readNullableData(in); ttl = in.readLong(); }
@Override public BufferObjectDataInput takeInputBuffer(Data data) { BufferObjectDataInput in = inputQueue.poll(); if (in == null) { in = serializationService.createObjectDataInput((byte[]) null); } in.init(data.toByteArray(), HeapData.DATA_OFFSET); return in; }
@Override public AttributeType getAttributeType(String attributeName) { if (KEY_ATTRIBUTE_NAME.equals(attributeName)) { return ReflectionHelper.getAttributeType(getKey().getClass()); } else if (THIS_ATTRIBUTE_NAME.equals(attributeName)) { return ReflectionHelper.getAttributeType(getValue().getClass()); } boolean isKey = isKey(attributeName); attributeName = getAttributeName(isKey, attributeName); Data data = getOptionalTargetData(isKey); if (data != null && data.isPortable()) { PortableContext portableContext = serializationService.getPortableContext(); return PortableExtractor.getAttributeType(portableContext, data, attributeName); } return ReflectionHelper.getAttributeType(isKey ? getKey() : getValue(), attributeName); }
@Override public Comparable getAttribute(String attributeName) throws QueryException { if (KEY_ATTRIBUTE_NAME.equals(attributeName)) { return (Comparable) getKey(); } else if (THIS_ATTRIBUTE_NAME.equals(attributeName)) { return (Comparable) getValue(); } boolean isKey = isKey(attributeName); attributeName = getAttributeName(isKey, attributeName); Data targetData = getOptionalTargetData(isKey); // if the content is available in 'Data' format and it is portable, we can directly // extract the content from the targetData, without needing to deserialize if (targetData != null && targetData.isPortable()) { return extractViaPortable(attributeName, targetData); } return extractViaReflection(attributeName, isKey); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } QueryEntry that = (QueryEntry) o; if (!indexKey.equals(that.indexKey)) { return false; } return true; }
public void fireEntryListenerEvent( Data key, Data oldValue, Data value, EntryEventType eventType, String name, Address caller) { Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, name); if (registrations.isEmpty()) { return; } EntryEventData eventData = new EntryEventData(name, name, caller, key, value, oldValue, eventType.getType()); for (EventRegistration registration : registrations) { if (!shouldPublish(key, oldValue, value, eventType, registration.getFilter())) { continue; } eventService.publishEvent(SERVICE_NAME, registration, eventData, key.hashCode()); } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } EntryEventFilter that = (EntryEventFilter) o; if (includeValue != that.includeValue) { return false; } if (key != null ? !key.equals(that.key) : that.key != null) { return false; } return true; }
@Override public void write(PortableWriter writer) throws IOException { writer.writeUTF("n", name); final ObjectDataOutput out = writer.getRawDataOutput(); key.writeData(out); }
protected void writeInternal(ObjectDataOutput out) throws IOException { super.writeInternal(out); out.writeLong(recordId); out.writeInt(index); value.writeData(out); }
@Override public int hashCode() { int result = (includeValue ? 1 : 0); result = 31 * result + (key != null ? key.hashCode() : 0); return result; }
@Override public boolean eval(Object arg) { return key == null || key.equals(arg); }
@Override public void writeData(ObjectDataOutput out) throws IOException { super.writeData(out); value.writeData(out); }
private Data mockPortableData() { Data keyData = mock(Data.class); when(keyData.isPortable()).thenReturn(true); return keyData; }
public void write(PortableWriter writer) throws IOException { writer.writeUTF("n", name); writer.writeLong("threadId", threadId); final ObjectDataOutput out = writer.getRawDataOutput(); key.writeData(out); }
@Override public void readData(ObjectDataInput in) throws IOException { super.readData(in); value = new Data(); value.readData(in); }