That'll work. I'm already prompting the user to enter the zookeeper host when adding the 'server' to the tool, so I'll just add a field to support the instance name as well. Thanks.
From: [email protected] [mailto:[email protected]] On Behalf Of Keith Turner Sent: Tuesday, January 28, 2014 1:41 PM To: [email protected] Subject: Re: Using Java7, fetch instance name or uuid WITHOUT Connector class? On Tue, Jan 28, 2014 at 12:26 PM, Ott, Charles H. <[email protected]> wrote: I am making a more user friendly (Swing) tool for performing import/exports of table data via hadoop.io.sequencefile. (Currently using Accumulo 1.5.0 w/ cdh4u5) The first thing I do is load a list of tables into a swing component using the http://monitorURL/xml URL and JAXB: private void loadTables() { try { jaxbContext = JAXBContext.newInstance(Stats.class); jaxbUnmarshaller = jaxbContext.createUnmarshaller(); jaxbMarshaller = jaxbContext.createMarshaller(); Stats stats = (Stats) jaxbUnmarshaller.unmarshal( new URL("http://" + associatedHost.getHostname() + ":" + associatedHost.getUi_port() + "/xml")); String results = new String(); for (Table t : stats.getTables().getTable()) { results = results.concat(t.getTablename() + "\r\n"); } jEditorPane1.setText(results); } catch (Exception err) { err.printStackTrace(); } } Then I create a ZooKeeperInstance, and call the 'getConnector' method to get a connector used for scanning: try { connector = zooInstance.getConnector(username, password.getBytes()); getUserAuths(); } catch (Exception err) { err.printStackTrace(); } Since, I now have the connector, I can get the 'user' Authorizations class for the export tool's client.Scanner: this.authorizations = connector.securityOperations().getUserAuthorizations(username); The part I am not sure how to do is automatically determine the 'instance name' or 'instance uuid' when constructing the ZooKeeperInstance. I can see both strings displayed on the header of the Accumulo Monitor: <div id='subheader'>Instance Name: gm Version:&nbs p;1.5.0 <br><span class='smalltext'>Instance ID: a85286bf-031c-4e24-9b47-f6aca34 401b8</span> <br><span class='smalltext'>Tue Jan 28 12:15:41 EST 2014< /span></div> </div> But I do not see any 'clean' way to retrieve it using the Java API, without doing a parse of the monitor's HTML. Which feels dirty. This leaves me with one option, for the user to specify the instance name before clicking 'Export Tables'. Which I think is a bit silly considering the user has already entered and saved the MonitorURL, dbUsername and dbPassword within the tool. Thoughts? Maybe start off asking the user for the instance name and zookeepers instead of the monitor URL. Once you create a connector you can use connector.tableOperations() to get a list of tables w/o accessing the monitor. Thanks in advance to anyone who read this far!
