// send a delete request to a server // 1 < key < max key number // server: id of server to delete the key private void sendDeleteRequest(int key, int server) { IQueryRequest queryReq = new QueryRequest(mRequestId++, server, key); try { if (mDhtServerArray[server - 1] != null) { UnicastRemoteObject.exportObject(queryReq); mDhtServerArray[server - 1].delete(queryReq); appendOutput("DHT Server:\n" + queryReq.getMessage()); } else appendOutput("sendDeleteRequest: server " + server + " is not initialized"); } catch (Exception e) { appendOutput("sendDeleteRequest: " + server + e.getMessage()); } }
// send a lookup request to a server // 1 < key < max key number // server: id of server to lookup the key private void sendLookupRequest(int key, int server) { IQueryRequest queryReq = new QueryRequest(mRequestId++, server, key); try { if (mDhtServerArray[server - 1] != null) { UnicastRemoteObject.exportObject(queryReq); String value = (String) mDhtServerArray[server - 1].lookup(queryReq); appendOutput( "DHT Server:\n" + queryReq.getMessage() + "\nDHT Client:\nlookup value is " + value); } else appendOutput("sendLookupRequest: server " + server + " is not initialized"); } catch (Exception e) { appendOutput("sendLookupRequest: " + server + e.getMessage()); } }