/** * Configure a job to use a mock Accumulo instance. * @param job Job to configure * @param instance Name of the mock instance */ public static void setMockInstance(final Job job, final String instance) { AccumuloOutputFormat.setMockInstance(job, instance); job.getConfiguration().setBoolean(ConfigUtils.USE_MOCK_INSTANCE, true); job.getConfiguration().setBoolean(MRUtils.AC_MOCK_PROP, true); }
/** * Configure a job to use a mock Accumulo instance. * @param job Job to configure * @param instance Name of the mock instance */ public static void setMockInstance(final Job job, final String instance) { AccumuloOutputFormat.setMockInstance(job, instance); job.getConfiguration().setBoolean(ConfigUtils.USE_MOCK_INSTANCE, true); job.getConfiguration().setBoolean(MRUtils.AC_MOCK_PROP, true); }
private static void setAccumuloOutput(final String instStr, final String zooStr, final String userStr, final String passStr, final Job job, final String tableName) throws AccumuloSecurityException { final AuthenticationToken token = new PasswordToken(passStr); AccumuloOutputFormat.setConnectorInfo(job, userStr, token); AccumuloOutputFormat.setDefaultTableName(job, tableName); AccumuloOutputFormat.setCreateTables(job, true); //TODO best way to do this? if (zooStr.equals("mock")) { AccumuloOutputFormat.setMockInstance(job, instStr); } else { AccumuloOutputFormat.setZooKeeperInstance(job, instStr, zooStr); } job.setOutputFormatClass(AccumuloOutputFormat.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(Mutation.class); }
public static void initMRJob(final Job job, final String table, final String outtable, final String[] auths) throws AccumuloSecurityException { final Configuration conf = job.getConfiguration(); final String username = conf.get(USERNAME); final String password = conf.get(PASSWORD); final String instance = conf.get(INSTANCE); final String zookeepers = conf.get(ZOOKEEPERS); final String mock = conf.get(MOCK); //input if (Boolean.parseBoolean(mock)) { AccumuloInputFormat.setMockInstance(job, instance); AccumuloOutputFormat.setMockInstance(job, instance); } else if (zookeepers != null) { AccumuloInputFormat.setZooKeeperInstance(job, instance, zookeepers); AccumuloOutputFormat.setZooKeeperInstance(job, instance, zookeepers); } else { throw new IllegalArgumentException("Must specify either mock or zookeepers"); } AccumuloInputFormat.setConnectorInfo(job, username, new PasswordToken(password.getBytes(StandardCharsets.UTF_8))); AccumuloInputFormat.setInputTableName(job, table); job.setInputFormatClass(AccumuloInputFormat.class); AccumuloInputFormat.setScanAuthorizations(job, new Authorizations(auths)); // OUTPUT job.setOutputFormatClass(AccumuloOutputFormat.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(Mutation.class); AccumuloOutputFormat.setConnectorInfo(job, username, new PasswordToken(password.getBytes(StandardCharsets.UTF_8))); AccumuloOutputFormat.setDefaultTableName(job, outtable); }
AccumuloOutputFormat.setZooKeeperInstance(job, new ClientConfiguration().withInstance(childInstance).withZkHosts(childZk)); } else { AccumuloOutputFormat.setMockInstance(job, childInstance);
/** * Sets up Accumulo output for a job: allows the job to write (String, * Mutation) pairs, where the Mutation will be written to the table named by * the String. * @param job Job to configure * @param outputTable Default table to send output to * @throws AccumuloSecurityException if connecting to Accumulo with the * given username and password fails */ protected void setupAccumuloOutput(Job job, String outputTable) throws AccumuloSecurityException { AccumuloOutputFormat.setConnectorInfo(job, userName, new PasswordToken(pwd)); AccumuloOutputFormat.setCreateTables(job, true); AccumuloOutputFormat.setDefaultTableName(job, outputTable); if (mock) { AccumuloOutputFormat.setMockInstance(job, instance); } else { ClientConfiguration clientConfig = ClientConfiguration.loadDefault() .withInstance(instance).withZkHosts(zk); AccumuloOutputFormat.setZooKeeperInstance(job, clientConfig); } job.setOutputFormatClass(AccumuloOutputFormat.class); }
/** * Sets up Accumulo output for a job: allows the job to write (String, * Mutation) pairs, where the Mutation will be written to the table named by * the String. * @param job Job to configure * @param outputTable Default table to send output to * @throws AccumuloSecurityException if connecting to Accumulo with the * given username and password fails */ protected void setupAccumuloOutput(Job job, String outputTable) throws AccumuloSecurityException { AccumuloOutputFormat.setConnectorInfo(job, userName, new PasswordToken(pwd)); AccumuloOutputFormat.setCreateTables(job, true); AccumuloOutputFormat.setDefaultTableName(job, outputTable); if (mock) { AccumuloOutputFormat.setMockInstance(job, instance); } else { ClientConfiguration clientConfig = ClientConfiguration.loadDefault() .withInstance(instance).withZkHosts(zk); AccumuloOutputFormat.setZooKeeperInstance(job, clientConfig); } job.setOutputFormatClass(AccumuloOutputFormat.class); }
public AccumuloConfiguration(Instance instance, String accumuloUser, String accumuloPassword, boolean isMock) throws AccumuloSecurityException, IOException { //NOTE: new Job(new Configuration()) does not work in scala shell due to the toString method's implementation //to get it to work in scala override the toString method and it will work //initialize fields, these are needed for lazy initialization of connector this.zkInstance = instance; this.accumuloUser = accumuloUser; this.accumuloPassword = accumuloPassword; this.job = new Job(new Configuration()); AbstractInputFormat.setConnectorInfo(job, accumuloUser, new PasswordToken(accumuloPassword)); AccumuloOutputFormat.setConnectorInfo(job, accumuloUser, new PasswordToken(accumuloPassword)); AbstractInputFormat.setScanAuthorizations(job, new Authorizations()); if (isMock) { AbstractInputFormat.setMockInstance(job, instance.getInstanceName()); AccumuloOutputFormat.setMockInstance(job, instance.getInstanceName()); } else { this.clientConfig = new ClientConfiguration(); this.clientConfig.withInstance(instance.getInstanceName()); this.clientConfig.withZkHosts(instance.getZooKeepers()); AbstractInputFormat.setZooKeeperInstance(job, clientConfig); AccumuloOutputFormat.setZooKeeperInstance(job, this.clientConfig); } }