Java Code Examples for org.apache.accumulo.core.client.Connector#whoami()

The following examples show how to use org.apache.accumulo.core.client.Connector#whoami() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlinkEnvManagerTest.java    From OSTMap with Apache License 2.0 5 votes vote down vote up
@Test
public void testFlinkEnvManager() throws Exception{

    tmpSettingsDir.create();
    File settings = tmpSettingsDir.newFile("settings");

    Connector conn = amc.getConnector();

    //create settings file with data of Mini Accumulo Cluster
    FileOutputStream fos = new FileOutputStream(settings, false);
    BufferedWriter br = new BufferedWriter(new OutputStreamWriter(fos));
    String parameters = "accumulo.instance=" + conn.getInstance().getInstanceName() + "\n"+
            "accumulo.user=" + conn.whoami() +"\n"+
            "accumulo.password=password\n"+
            "accumulo.zookeeper=" + conn.getInstance().getZooKeepers();

    System.out.println(parameters);
    br.write(parameters);
    br.flush();
    br.close();
    fos.flush();
    fos.close();

    FlinkEnvManager fem = new FlinkEnvManager(settings.getAbsolutePath(),"testJob",
            TableIdentifier.RAW_TWITTER_DATA.get(),
            TableIdentifier.TERM_INDEX.get());

    assertNotNull(fem.getDataFromAccumulo());
    assertNotNull(fem.getExecutionEnvironment());
    assertNotNull(fem.getHadoopOF());


}
 
Example 2
Source File: CreateFluoPcj.java    From rya with Apache License 2.0 5 votes vote down vote up
private String[] getAuths(final Connector accumulo) {
    Authorizations auths;
    try {
        auths = accumulo.securityOperations().getUserAuthorizations(accumulo.whoami());
        final List<byte[]> authList = auths.getAuthorizations();
        final String[] authArray = new String[authList.size()];
        for(int i = 0; i < authList.size(); i++){
            authArray[i] = new String(authList.get(i), "UTF-8");
        }
        return authArray;
    } catch (AccumuloException | AccumuloSecurityException | UnsupportedEncodingException e) {
        throw new RuntimeException("Cannot read authorizations for user: " + accumulo.whoami());
    }
}
 
Example 3
Source File: AccumuloPeriodicQueryResultStorage.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a AccumuloPeriodicQueryResultStorage Object.
 * @param accumuloConn - Accumulo Connector for connecting to an Accumulo instance
 * @param ryaInstance - Rya Instance name for connecting to Rya
 */
public AccumuloPeriodicQueryResultStorage(final Connector accumuloConn, final String ryaInstance) {
    this.accumuloConn = Preconditions.checkNotNull(accumuloConn);
    this.ryaInstance = Preconditions.checkNotNull(ryaInstance);
    final String user = accumuloConn.whoami();
    try {
        this.auths = accumuloConn.securityOperations().getUserAuthorizations(user);
    } catch (AccumuloException | AccumuloSecurityException e) {
        throw new RuntimeException("Unable access user: " + user + "authorizations.");
    }
}