(String key)
| 42 | .getLogger(MethodHandles.lookup().lookupClass()); |
| 43 | |
| 44 | private void read(String key) throws ClassNotFoundException, IOException, |
| 45 | Exception { |
| 46 | |
| 47 | DataStore<String, Host> datastore = StorageUtils.createWebStore(getConf(), |
| 48 | String.class, Host.class); |
| 49 | |
| 50 | Query<String, Host> query = datastore.newQuery(); |
| 51 | // possibly add a contraint to the query |
| 52 | if (key != null) { |
| 53 | query.setKey(TableUtil.reverseUrl(key)); |
| 54 | } |
| 55 | // query.setFields(Host._ALL_FIELDS); |
| 56 | Result<String, Host> result = datastore.execute(query); |
| 57 | |
| 58 | while (result.next()) { |
| 59 | String hostName = null; |
| 60 | try { |
| 61 | hostName = TableUtil.unreverseUrl(result.getKey()); |
| 62 | Host host = result.get(); |
| 63 | System.out.println(hostName); |
| 64 | System.out.println(host); |
| 65 | } catch (Exception e) { |
| 66 | LOG.error("Failed to get host from hostname {}: {}", hostName, e.getMessage()); |
| 67 | } |
| 68 | } |
| 69 | result.close(); |
| 70 | datastore.close(); |
| 71 | } |
| 72 | |
| 73 | public static void main(String[] args) throws Exception { |
| 74 | int res = ToolRunner.run(NutchConfiguration.create(), new HostDbReader(), |
no test coverage detected