private byte[] getBytes(Object o) { if (o instanceof byte[]) { return (byte[]) o; } if (o instanceof CachedDeserializable) { return ((CachedDeserializable) o).getSerializedValue(); } else { return EntryEventImpl.serialize(o); } }
private void checkQueueGet(String key, KeyValue expected, String... entries) throws Exception { PartitionAttributesFactory paf = new PartitionAttributesFactory(); paf.setTotalNumBuckets(1); RegionFactory rf1 = this.c.createRegionFactory(RegionShortcut.PARTITION); PartitionedRegion r1 = (PartitionedRegion) rf1.setPartitionAttributes(paf.create()).create("r1"); // create the buckets r1.put("blah", "blah"); // hack to get the queue. HDFSParallelGatewaySenderQueue hopqueue = getHDFSQueue(r1, this.c); HDFSBucketRegionQueue brq = (HDFSBucketRegionQueue) ((PartitionedRegion) hopqueue.getRegion()).getDataStore().getLocalBucketById(0); int seq = 0; for (String s : entries) { if (s.equals("roll")) { brq.rolloverSkipList(); } else { String[] kv = s.split("-"); hopqueue.put(getNewEvent(kv[0], kv[1], r1, 0, seq++)); } } byte[] bkey = EntryEventImpl.serialize(key); HDFSGatewayEventImpl evt = hopqueue.get(r1, bkey, 0); if (expected == null) { assertNull(evt); } else { assertEquals(expected.key, evt.getKey()); assertEquals(expected.value, evt.getDeserializedValue()); } }