@Ignore @Test public void testHintedHandoff() throws Exception { Set<Integer> failedNodes = getFailedNodes(); Multimap<Integer, ByteArray> failedKeys = populateStore(failedNodes); Map<ByteArray, byte[]> dataInSlops = Maps.newHashMap(); Set<ByteArray> slopKeys = makeSlopKeys(failedKeys, Slop.Operation.PUT); for (Store<ByteArray, Slop, byte[]> slopStore : slopStores.values()) { Map<ByteArray, List<Versioned<Slop>>> res = slopStore.getAll(slopKeys, null); for (Map.Entry<ByteArray, List<Versioned<Slop>>> entry : res.entrySet()) { Slop slop = entry.getValue().get(0).getValue(); dataInSlops.put(slop.getKey(), slop.getValue()); if (logger.isTraceEnabled()) logger.trace(slop); } } for (Map.Entry<Integer, ByteArray> failedKey : failedKeys.entries()) { byte[] expected = keyValues.get(failedKey.getValue()).get(); byte[] actual = dataInSlops.get(failedKey.getValue()); assertNotNull("data should be stored in the slop", actual); assertEquals("correct should be stored in slop", 0, ByteUtils.compare(actual, expected)); } }
/** * Returns the approximate size of slop to help in throttling * * @param slopVersioned The versioned slop whose size we want * @return Size in bytes */ private int slopSize(Versioned<Slop> slopVersioned) { int nBytes = 0; Slop slop = slopVersioned.getValue(); nBytes += slop.getKey().length(); nBytes += ((VectorClock) slopVersioned.getVersion()).sizeInBytes(); switch (slop.getOperation()) { case PUT: { nBytes += slop.getValue().length; break; } case DELETE: { break; } default: logger.error("Unknown slop operation: " + slop.getOperation()); } return nBytes; }