public Data get(Number640 key) { long startTime = System.currentTimeMillis(); FutureGet futureGet = peerDHT .get(key.locationKey()) .contentKey(key.contentKey()) .domainKey(key.domainKey()) .versionKey(key.versionKey()) .routingConfiguration(routingConfig) .requestP2PConfiguration(requestConfig) .start() .awaitUninterruptibly(); putStats.report(System.currentTimeMillis() - startTime, futureGet.isSuccess()); LOG.debug("Get is success {}. Reason: {}", futureGet.isSuccess(), futureGet.failedReason()); if (futureGet.data() != null) { return futureGet.data(); } else { return null; } }
@Test public void testLogout() throws ClassNotFoundException, IOException, NoSessionException, NoPeerConnectionException { NetworkManager client = network.get(0); IH2HSerialize serializer = client.getDataManager().getSerializer(); // verify the locations map before logout FutureGet futureGet = client .getDataManager() .getUnblocked( new Parameters() .setLocationKey(userCredentials.getUserId()) .setContentKey(H2HConstants.USER_LOCATIONS)); futureGet.awaitUninterruptibly(); futureGet.futureRequests().awaitUninterruptibly(); Locations locations = (Locations) serializer.deserialize(futureGet.data().toBytes()); Assert.assertEquals(1, locations.getPeerAddresses().size()); // logout IProcessComponent<Void> process = ProcessFactory.instance().createLogoutProcess(client); TestExecutionUtil.executeProcessTillSucceded(process); // verify the locations map after logout FutureGet futureGet2 = client .getDataManager() .getUnblocked( new Parameters() .setLocationKey(userCredentials.getUserId()) .setContentKey(H2HConstants.USER_LOCATIONS)); futureGet2.awaitUninterruptibly(); futureGet2.futureRequests().awaitUninterruptibly(); Locations locations2 = (Locations) serializer.deserialize(futureGet2.data().toBytes()); Assert.assertEquals(0, locations2.getPeerAddresses().size()); }