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

Thanks in advance to anyone who read this far!

Reply via email to