CountTimestampSamplesWritable implements Writable { public CountTimestampSamplesWritable(long count, long epochMilliseconds, List<Long> samples) { this.countTimestampWritable = new CountTimestampWritable(count, epochMilliseconds); this.samples = samples; } CountTimestampSamplesWritable(long count, long epochMilliseconds, List<Long> samples); @Override void write(DataOutput dataOutput); @Override void readFields(DataInput dataInput); List<Long> getSamples(); void setSamples(List<Long> samples); void setCount(long count); long getEpochMilliseconds(); long getCount(); void setEpochMilliseconds(long epochMilliseconds);  }
@Test public void testCountTimestampSamplesWritable() throws Exception { CountTimestampSamplesWritable orig = new CountTimestampSamplesWritable(7L, 123L, Arrays.asList(18L, 19L, 20L)); assertEquals(orig.getCount(), 7L); assertEquals(orig.getEpochMilliseconds(), 123L); assertEquals(Arrays.asList(18L, 19L, 20L), orig.getSamples()); ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); DataOutputStream dataOut = new DataOutputStream(bytesOut); orig.write(dataOut); CountTimestampSamplesWritable deSerialized = new CountTimestampSamplesWritable(0L, 0L, null); deSerialized.readFields(new DataInputStream(new ByteArrayInputStream(bytesOut.toByteArray()))); assertEquals(orig.getCount(), deSerialized.getCount()); assertEquals(orig.getEpochMilliseconds(), deSerialized.getEpochMilliseconds()); assertEquals(orig.getSamples(), deSerialized.getSamples()); }