/** * */ public PdxOutputStream() { this.hdos = new HeapDataOutputStream(Version.CURRENT); }
/** * @param allocSize */ public PdxOutputStream(int allocSize) { this.hdos = new HeapDataOutputStream(allocSize, Version.CURRENT); }
public void testWriteByteBuffer() { HeapDataOutputStream out = new HeapDataOutputStream(32, Version.CURRENT); byte[] bytes = "1234567890qwertyuiopasdfghjklzxcvbnm,./;'".getBytes(); out.write(ByteBuffer.wrap(bytes, 0, 2)); out.write(ByteBuffer.wrap(bytes, 2, bytes.length - 2)); byte[] actual = out.toByteArray(); assertEquals(new String(bytes) , new String(actual)); }
public byte[] toBytes() throws IOException { HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT); sendTo(hdos); return hdos.toByteArray(); } public int compareTo(Object o) {
public void writeCredentials(DataOutputStream dos, DataInputStream dis, Properties p_credentials, boolean isNotification, DistributedMember member) throws IOException, GemFireSecurityException { HeapDataOutputStream hdos = new HeapDataOutputStream(32, Version.CURRENT_GFE); try { writeCredentials(dos, dis, p_credentials, isNotification, member, hdos); } finally { hdos.close(); } }
public byte[] toBytes() throws IOException { HeapDataOutputStream hdos = new HeapDataOutputStream(16, Version.CURRENT); sendTo(hdos); return hdos.toByteArray(); }
private byte[] serializeVersionTag(int entryVersion, long regionVersion, VersionSource versionMember, long timestamp, int dsId) throws IOException { HeapDataOutputStream out = new HeapDataOutputStream(4 + 8 + 4 + 8 + 4, Version.CURRENT); serializeVersionTag(entryVersion, regionVersion, versionMember, timestamp, dsId, out); byte[] versionsBytes = out.toByteArray(); return versionsBytes; }
private void defineAType() throws IOException { SimpleClass sc = new SimpleClass(1, (byte) 2); HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT); DataSerializer.writeObject(sc, out); } private void defineATypeNoEnum() throws IOException {
public void testCheckPortablity() throws Exception { setupSerializer(true, "com.gemstone.gemfire.pdx.AutoSerializableJUnitTest.BigHolder"); BigInteger bi = new BigInteger("12345678901234567890"); BigDecimal bd = new BigDecimal("1234567890.1234567890"); BigHolder bih = new BigHolder(bi, bd); HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT); try { DataSerializer.writeObject(bih, out); fail("expected NonPortableClassException"); } catch (NonPortableClassException expected) { } }
public static int calculateBytesForTSandDSID(int dsid) { HeapDataOutputStream out = new HeapDataOutputStream(4 + 8, Version.CURRENT); long now = System.currentTimeMillis(); try { writeUnsignedVL(now, out); writeUnsignedVL(InternalDataSerializer.encodeZigZag64(dsid), out); } catch (IOException e) { return 0; } return out.size(); }
public Object call() throws Exception { //Make sure the cache exists getCache(); DataSerializer.writeObject(new SimpleClass(value, (byte) value), new HeapDataOutputStream(Version.CURRENT)); return null; } };
public void testMonth() throws Exception { setupSerializer(false, false, "com.gemstone.gemfire.pdx.AutoSerializableJUnitTest.MyMonth"); MyMonth m = new MyMonth(1); HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT); DataSerializer.writeObject(m, out); Object dObj = DataSerializer.readObject(new DataInputStream( new ByteArrayInputStream(out.toByteArray()))); assertEquals(m, dObj); }
public void testExternalizable() throws Exception { setupSerializer("com.gemstone.gemfire.pdx.AutoSerializableJUnitTest.MyExternalizable"); MyExternalizable o = new MyExternalizable(79); HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT); DataSerializer.writeObject(o, out); Object dObj = DataSerializer.readObject(new DataInputStream( new ByteArrayInputStream(out.toByteArray()))); assertEquals(o, dObj); }
/** * A serializable with a writeReplace method should use standard serialization. */ public void testComparator() throws Exception { setupSerializer("com.gemstone.gemfire.pdx.AutoSerializableJUnitTest.MyComparator"); TreeSet o = new TreeSet(new MyComparator()); HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT); DataSerializer.writeObject(o, out); Object dObj = DataSerializer.readObject(new DataInputStream( new ByteArrayInputStream(out.toByteArray()))); assertEquals(o, dObj); }
private byte[] pmidToBytes(PersistentMemberID id) { try { HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT); InternalDataSerializer.invokeToData(id, hdos); return hdos.toByteArray(); } catch (IOException ex) { throw new DiskAccessException(LocalizedStrings.DiskInitFile_FAILED_INIT_FILE_WRITE_BECAUSE_0.toLocalizedString(ex), this.parent); } }
private byte[] pmidToBytes(PersistentMemberID id) { try { HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT); InternalDataSerializer.invokeToData(id, hdos); return hdos.toByteArray(); } catch (IOException ex) { throw new DiskAccessException(LocalizedStrings.DiskInitFile_FAILED_INIT_FILE_WRITE_BECAUSE_0.toLocalizedString(ex), this.parent); } }
public void testIsFieldIncluded() throws IOException, ClassNotFoundException { setupSerializer(new ExplicitIncludedAutoSerializer(false, "com.gemstone.gemfire.pdx.DomainObjectPdxAuto"), true); DomainObject objOut = new DomainObjectPdxAuto(4); HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT); DataSerializer.writeObject(objOut, out); PdxInstance pi = (PdxInstance)DataSerializer.readObject(new DataInputStream( new ByteArrayInputStream(out.toByteArray()))); assertEquals(true, pi.hasField("long_0")); assertEquals(false, pi.hasField("string_0")); } public static class ExplicitFieldNameAutoSerializer extends ReflectionBasedAutoSerializer {
public Object call() throws Exception { HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT); DataSerializer.writeObject(new SimpleClass(57, (byte) 3), out); byte[] bytes = out.toByteArray(); Region r = getRootRegion("testSimplePdx"); r.put(1, bytes); return null; } });
protected static void writeServerMember(DistributedMember member, DataOutputStream dos) throws IOException { Version v = Version.CURRENT_GFE; if (dos instanceof VersionedDataStream) { v = ((VersionedDataStream) dos).getVersion(); } HeapDataOutputStream hdos = new HeapDataOutputStream(v); DataSerializer.writeObject(member, hdos); DataSerializer.writeByteArray(hdos.toByteArray(), dos); hdos.close(); }
protected static void writeServerMember(DistributedMember member, DataOutputStream dos) throws IOException { Version v = Version.CURRENT; if (dos instanceof VersionedDataStream) { v = ((VersionedDataStream) dos).getVersion(); } HeapDataOutputStream hdos = new HeapDataOutputStream(v); DataSerializer.writeObject(member, hdos); DataSerializer.writeByteArray(hdos.toByteArray(), dos); hdos.close(); }