Accumulo, mail # user - Using Java7, fetch instance name or uuid WITHOUT Connector class? - 2014-01-28, 17:27
 Search Hadoop and all its subprojects:

Switch to Plain View
Copy link to this message
Using Java7, fetch instance name or uuid WITHOUT Connector class?
I am making a more user friendly (Swing) tool for performing import/exports of table data via (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");
        } catch (Exception err) {

Then I create a ZooKeeperInstance, and call the 'getConnector' method to get a connector used for scanning:
        try {
            connector = zooInstance.getConnector(username, password.getBytes());
        } catch (Exception err) {

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: 1.5.0
<br><span class='smalltext'>Instance ID: a85286bf-031c-4e24-9b47-f6aca34401b8</span>
<br><span class='smalltext'>Tue Jan 28 12:15:41 EST 2014</span></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?

Thanks in advance to anyone who read this far!

Keith Turner 2014-01-28, 18:41
Ott, Charles H. 2014-01-28, 19:00
Mike Drob 2014-01-28, 20:18
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB