@Test public void toByteArrayAndBack() { byte[] arrayA = delQuery.toByteArray(); byte[] arrayB; arrayB = new DeletionQuery(arrayA).toByteArray(); assertArrayEquals("The two arrays differ!", arrayA, arrayB); } }
public DeletionQuery(byte[] data) { super(data); ByteBuffer buffer = ByteBuffer.wrap(data, HEADER_LENGTH, data.length-HEADER_LENGTH); dhtKey = readHash(buffer); if (buffer.hasRemaining()) log.debug("Deletion Query has " + buffer.remaining() + " extra bytes."); }
@Override public byte[] toByteArray() { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try { writeHeader(outputStream); outputStream.write(dhtKey.toByteArray()); } catch (IOException e) { log.error("Can't write to ByteArrayOutputStream.", e); } return outputStream.toByteArray(); } }
@Before public void setUp() throws Exception { Hash dhtKey = new Hash(new byte[] {-48, 78, 66, 58, -79, 87, 38, -103, -60, -27, 108, 55, 117, 37, -99, 93, -23, -102, -83, 20, 44, -80, 65, 89, -68, -73, 69, 51, 115, 79, 24, 127}); delQuery = new DeletionQuery(dhtKey); }
DhtStorageHandler storageHandler = storageHandlers.get(EncryptedEmailPacket.class); if (storageHandler instanceof DeletionAwareDhtFolder) { Hash dhtKey = ((DeletionQuery)packet).getDhtKey(); UniqueId delAuthorization = ((DeletionAwareDhtFolder<?>)storageHandler).getDeleteAuthorization(dhtKey);
for (Destination node: closeNodes) if (!localDestination.equals(node)) // local has already been taken care of batch.putPacket(new DeletionQuery(dhtKey), node); sendQueue.send(batch); batch.awaitSendCompletion();