/** * Configures a {@link org.apache.accumulo.core.client.ZooKeeperInstance} for this job. * * @param job * the Hadoop job instance to be configured * @param instanceName * the Accumulo instance name * @param zooKeepers * a comma-separated list of zookeeper servers * @since 1.5.0 * @deprecated since 1.6.0; Use * {@link #setZooKeeperInstance(JobConf, org.apache.accumulo.core.client.ClientConfiguration)} * instead. */ @Deprecated public static void setZooKeeperInstance(JobConf job, String instanceName, String zooKeepers) { setZooKeeperInstance(job, org.apache.accumulo.core.client.ClientConfiguration.create() .withInstance(instanceName).withZkHosts(zooKeepers)); }
protected AccumuloRecordWriter(JobConf job) throws AccumuloException, AccumuloSecurityException { Level l = getLogLevel(job); if (l != null) log.setLevel(getLogLevel(job)); this.simulate = getSimulationMode(job); this.createTables = canCreateTables(job); if (simulate) log.info("Simulating output only. No writes to tables will occur"); this.bws = new HashMap<>(); String tname = getDefaultTableName(job); this.defaultTableName = (tname == null) ? null : new Text(tname); if (!simulate) { this.client = OutputConfigurator.client(CLASS, job); mtbw = client.createMultiTableBatchWriter(getBatchWriterOptions(job)); } }
@Override public void checkOutputSpecs(FileSystem ignored, JobConf job) throws IOException { if (!isConnectorInfoSet(job)) throw new IOException("Connector info has not been set."); try { AccumuloClient c = OutputConfigurator.client(CLASS, job); String principal = getPrincipal(job); AuthenticationToken token = getAuthenticationToken(job); if (!c.securityOperations().authenticateUser(principal, token)) throw new IOException("Unable to authenticate user"); } catch (AccumuloException | AccumuloSecurityException e) { throw new IOException(e); } }
protected AccumuloRecordWriter(JobConf job) throws AccumuloException, AccumuloSecurityException, IOException { Level l = getLogLevel(job); if (l != null) log.setLevel(getLogLevel(job)); this.simulate = getSimulationMode(job); this.createTables = canCreateTables(job); if (simulate) log.info("Simulating output only. No writes to tables will occur"); this.bws = new HashMap<>(); String tname = getDefaultTableName(job); this.defaultTableName = (tname == null) ? null : new Text(tname); if (!simulate) { this.conn = getInstance(job).getConnector(getPrincipal(job), getAuthenticationToken(job)); mtbw = conn.createMultiTableBatchWriter(getBatchWriterOptions(job)); } }
@Override public int run(String[] args) throws Exception { if (args.length != 3) { throw new IllegalArgumentException("Usage : " + MRTokenFileTester.class.getName() + " <token file> <inputtable> <outputtable>"); } String user = getAdminPrincipal(); String tokenFile = args[0]; String table1 = args[1]; String table2 = args[2]; JobConf job = new JobConf(getConf()); job.setJarByClass(this.getClass()); job.setInputFormat(AccumuloInputFormat.class); AccumuloInputFormat.setConnectorInfo(job, user, tokenFile); AccumuloInputFormat.setInputTableName(job, table1); AccumuloInputFormat.setZooKeeperInstance(job, getCluster().getClientConfig()); job.setMapperClass(TestMapper.class); job.setMapOutputKeyClass(Key.class); job.setMapOutputValueClass(Value.class); job.setOutputFormat(AccumuloOutputFormat.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(Mutation.class); AccumuloOutputFormat.setConnectorInfo(job, user, tokenFile); AccumuloOutputFormat.setCreateTables(job, false); AccumuloOutputFormat.setDefaultTableName(job, table2); AccumuloOutputFormat.setZooKeeperInstance(job, getCluster().getClientConfig()); job.setNumReduceTasks(0); return JobClient.runJob(job).isSuccessful() ? 0 : 1; }
AccumuloOutputFormat outputFormat = new AccumuloOutputFormat(); AccumuloOutputFormat.setBatchWriterOptions(job, batchConfig); AccumuloOutputFormat.setZooKeeperInstance(job, cluster.getClientConfig()); AccumuloOutputFormat.setConnectorInfo(job, "root", new PasswordToken(ROOT_PASSWORD)); RecordWriter<Text,Mutation> writer = outputFormat.getRecordWriter(null, job, "Test", null);
@Override public void checkOutputSpecs(FileSystem ignored, JobConf job) throws IOException { if (!isConnectorInfoSet(job)) throw new IOException("Connector info has not been set."); try { // if the instance isn't configured, it will complain here String principal = getPrincipal(job); AuthenticationToken token = getAuthenticationToken(job); Connector c = getInstance(job).getConnector(principal, token); if (!c.securityOperations().authenticateUser(principal, token)) throw new IOException("Unable to authenticate user"); } catch (AccumuloException e) { throw new IOException(e); } catch (AccumuloSecurityException e) { throw new IOException(e); } }
@Override public void checkOutputSpecs(FileSystem ignored, JobConf job) throws IOException { if (!isConnectorInfoSet(job)) throw new IOException("Connector info has not been set."); try { // if the instance isn't configured, it will complain here AccumuloClient c = Accumulo.newClient().usingClientInfo(getClientInfo(job)).build(); String principal = getPrincipal(job); AuthenticationToken token = getAuthenticationToken(job); if (!c.securityOperations().authenticateUser(principal, token)) throw new IOException("Unable to authenticate user"); } catch (AccumuloException | AccumuloSecurityException e) { throw new IOException(e); } }
protected void setAccumuloConnectorInfo(JobConf conf, String username, AuthenticationToken token) throws AccumuloSecurityException { try { AccumuloOutputFormat.setConnectorInfo(conf, username, token); } catch (IllegalStateException e) { // AccumuloOutputFormat complains if you re-set an already set value. We just don't care. log.debug("Ignoring exception setting Accumulo Connector instance for user " + username, e); } }
/** * Gets the serialized token class from either the configuration or the token file. * * @since 1.5.0 * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobConf)} instead. */ @Deprecated protected static String getTokenClass(JobConf job) { return getAuthenticationToken(job).getClass().getName(); }
@Override public RecordWriter<Text,Mutation> getRecordWriter(FileSystem ignored, JobConf job, String name, Progressable progress) throws IOException { configureAccumuloOutputFormat(job); return super.getRecordWriter(ignored, job, name, progress); }
job.setOutputValueClass(Mutation.class); AccumuloOutputFormat.setConnectorInfo(job, user, new PasswordToken(pass)); AccumuloOutputFormat.setCreateTables(job, false); AccumuloOutputFormat.setDefaultTableName(job, table2); AccumuloOutputFormat.setZooKeeperInstance(job, clientConfig);
/** * Calls {@link AccumuloOutputFormat#setConnectorInfo(JobConf, String, AuthenticationToken)} * suppressing exceptions due to setting the configuration multiple times. */ public void setOutputFormatConnectorInfo(JobConf conf, String username, AuthenticationToken token) throws AccumuloSecurityException { try { AccumuloOutputFormat.setConnectorInfo(conf, username, token); } catch (IllegalStateException e) { // AccumuloOutputFormat complains if you re-set an already set value. We just don't care. log.debug("Ignoring exception setting Accumulo Connector instance for user " + username, e); } }
/** * Gets the serialized token from either the configuration or the token file. * * @since 1.5.0 * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobConf)} instead. */ @Deprecated protected static byte[] getToken(JobConf job) { return AuthenticationTokenSerializer.serialize(getAuthenticationToken(job)); }
protected AccumuloRecordWriter(JobConf job) throws AccumuloException, AccumuloSecurityException, IOException { Level l = getLogLevel(job); if (l != null) log.setLevel(getLogLevel(job)); this.simulate = getSimulationMode(job); this.createTables = canCreateTables(job); if (simulate) log.info("Simulating output only. No writes to tables will occur"); this.bws = new HashMap<>(); String tname = getDefaultTableName(job); this.defaultTableName = (tname == null) ? null : new Text(tname); if (!simulate) { this.client = Accumulo.newClient().usingClientInfo(getClientInfo(job)).build(); mtbw = client.createMultiTableBatchWriter(getBatchWriterOptions(job)); } }
/** * Calls {@link AccumuloOutputFormat#setZooKeeperInstance(JobConf, ClientConfiguration)}, * suppressing exceptions due to setting the configuration multiple times. */ public void setOutputFormatZooKeeperInstance(JobConf conf, String instanceName, String zookeepers, boolean isSasl) throws IOException { try { ClientConfiguration clientConf = getClientConfiguration(zookeepers, instanceName, isSasl); AccumuloOutputFormat.setZooKeeperInstance(conf, clientConf); } catch (IllegalStateException ise) { // AccumuloOutputFormat complains if you re-set an already set value. We just don't care. log.debug("Ignoring exception setting ZooKeeper instance of " + instanceName + " at " + zookeepers, ise); } }
/** * Gets the serialized token class from either the configuration or the token file. * * @since 1.5.0 * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobConf)} instead. */ @Deprecated protected static String getTokenClass(JobConf job) { return getAuthenticationToken(job).getClass().getName(); }
@SuppressWarnings("deprecation") protected void setAccumuloZooKeeperInstance(JobConf conf, String instanceName, String zookeepers, boolean isSasl) throws IOException { try { if (isSasl) { // Reflection to support Accumulo 1.5. Remove when Accumulo 1.5 support is dropped // 1.6 works with the deprecated 1.5 method, but must use reflection for 1.7-only // SASL support helper.setZooKeeperInstance(conf, AccumuloOutputFormat.class, zookeepers, instanceName, isSasl); } else { AccumuloOutputFormat.setZooKeeperInstance(conf, instanceName, zookeepers); } } catch (IllegalStateException ise) { // AccumuloOutputFormat complains if you re-set an already set value. We just don't care. log.debug("Ignoring exception setting ZooKeeper instance of " + instanceName + " at " + zookeepers, ise); } }
/** * Gets the serialized token from either the configuration or the token file. * * @since 1.5.0 * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobConf)} instead. */ @Deprecated protected static byte[] getToken(JobConf job) { return AuthenticationTokenSerializer.serialize(getAuthenticationToken(job)); }
/** * Configures a {@link ZooKeeperInstance} for this job. * * @param job * the Hadoop job instance to be configured * @param instanceName * the Accumulo instance name * @param zooKeepers * a comma-separated list of zookeeper servers * @since 1.5.0 * @deprecated since 1.6.0; Use {@link #setZooKeeperInstance(JobConf, ClientConfiguration)} * instead. */ @Deprecated public static void setZooKeeperInstance(JobConf job, String instanceName, String zooKeepers) { setZooKeeperInstance(job, new ClientConfiguration().withInstance(instanceName).withZkHosts(zooKeepers)); }