private TableListing createOptionTableListing() { return new TableListing.Builder().addField("").addField("", true) .wrapWidth(MAX_LINE_WIDTH).build(); }
public Builder addField(String title, boolean wrap) { return addField(title, Justification.LEFT, wrap); }
@Override public int run(String[] args) throws Exception { int exitCode = 0; try { exitCode = init(args); if (exitCode != 0 || subcommand == null) { printShellUsage(); return exitCode; } if (subcommand.validate()) { subcommand.execute(); } else { printShellUsage(); exitCode = 1; } } catch (Exception e) { printShellUsage(); printException(e); return 1; } return exitCode; }
@Override public boolean runDistCp(List<Path> srcPaths, Path dst, Configuration conf) throws IOException { DistCpOptions options = new DistCpOptions.Builder(srcPaths, dst) .withSyncFolder(true) .withCRC(true) .preserve(FileAttribute.BLOCKSIZE) .build(); // Creates the command-line parameters for distcp List<String> params = constructDistCpParams(srcPaths, dst, conf); try { conf.setBoolean("mapred.mapper.new-api", true); DistCp distcp = new DistCp(conf, options); // HIVE-13704 states that we should use run() instead of execute() due to a hadoop known issue // added by HADOOP-10459 if (distcp.run(params.toArray(new String[0])) == 0) { return true; } else { return false; } } catch (Exception e) { throw new IOException("Cannot execute DistCp process: " + e, e); } finally { conf.setBoolean("mapred.mapper.new-api", false); } }
private int listSpanReceivers(List<String> args) throws IOException { SpanReceiverInfo infos[] = remote.listSpanReceivers(); if (infos.length == 0) { System.out.println("[no span receivers found]"); return 0; } TableListing listing = new TableListing.Builder(). addField("ID"). addField("CLASS"). showHeaders(). build(); for (SpanReceiverInfo info : infos) { listing.addRow("" + info.getId(), info.getClassName()); } System.out.println(listing.toString()); return 0; }
@Override public GetGroupsForUserResponseProto getGroupsForUser( RpcController controller, GetGroupsForUserRequestProto request) throws ServiceException { String[] groups; try { groups = impl.getGroupsForUser(request.getUser()); } catch (IOException e) { throw new ServiceException(e); } GetGroupsForUserResponseProto.Builder builder = GetGroupsForUserResponseProto .newBuilder(); for (String g : groups) { builder.addGroups(g); } return builder.build(); } }
final HadoopArchives har = new HadoopArchives(newConf); int rc = ToolRunner.run(har, args); if (rc != 0) {
/** * Get the groups for the users given and print formatted output to the * {@link PrintStream} configured earlier. */ @Override public int run(String[] args) throws Exception { if (args.length == 0) { args = new String[] { UserGroupInformation.getCurrentUser().getUserName() }; } for (String username : args) { StringBuilder sb = new StringBuilder(); sb.append(username + " :"); for (String group : getUgmProtocol().getGroupsForUser(username)) { sb.append(" "); sb.append(group); } out.println(sb); } return 0; }
/** * Get a client of the {@link GetUserMappingsProtocol}. * @return A {@link GetUserMappingsProtocol} client proxy. * @throws IOException */ protected GetUserMappingsProtocol getUgmProtocol() throws IOException { GetUserMappingsProtocol userGroupMappingProtocol = RPC.getProxy(GetUserMappingsProtocol.class, GetUserMappingsProtocol.versionID, getProtocolAddress(getConf()), UserGroupInformation.getCurrentUser(), getConf(), NetUtils.getSocketFactory(getConf(), GetUserMappingsProtocol.class)); return userGroupMappingProtocol; }
return super.createInputFileListing(job); totalBytesExpected += fst.getLen(); Text key = getKey(path); writer.append(key, new CopyListingFileStatus(fst));
/** * Create a new TableListing. */ public TableListing build() { return new TableListing(columns.toArray(new Column[0]), showHeader, wrapWidth); } }
Column(String title, Justification justification, boolean wrap) { this.rows = new ArrayList<String>(); this.justification = justification; this.wrap = wrap; this.maxWidth = 0; addRow(title); }
/** * Add a new field to the Table under construction. * * @param title Field title. * @param justification Right or left justification. Defaults to left. * @param wrap Width at which to auto-wrap the content of the cell. * Defaults to Integer.MAX_VALUE. * @return This Builder object */ public Builder addField(String title, Justification justification, boolean wrap) { columns.add(new Column(title, justification, wrap)); return this; }
int maxColumnLines = 0; for (int j = 0; j < columns.length; j++) { columnLines[j] = columns[j].getRow(i); if (columnLines[j].length > maxColumnLines) { maxColumnLines = columnLines[j].length;
@SuppressWarnings("unchecked") private List<Path> getSourcePaths(Field fieldInputOptions) throws IOException{ Object options; try { options = fieldInputOptions.get(this); if (options instanceof DistCpOptions) { return ((DistCpOptions) options).getSourcePaths(); } else { // Hadoop 3 Class<?> classContext = Class.forName("org.apache.hadoop.tools.DistCpContext"); Method methodGetSourcePaths = classContext.getDeclaredMethod("getSourcePaths"); methodGetSourcePaths.setAccessible(true); return (List<Path>) methodGetSourcePaths.invoke(options); } } catch (IllegalArgumentException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | SecurityException | InvocationTargetException e) { throw new IOException(e); } }
protected final void printShellUsage() { if (subcommand != null) { out.println(subcommand.getUsage()); } else { out.println(getCommandUsage()); } out.flush(); }
public static boolean runDistCp(List<Path> srcPaths, Path dst, Configuration conf) throws IOException { DistCpOptions options = new DistCpOptions.Builder(srcPaths, dst) .withSyncFolder(true) .withCRC(true) .preserve(FileAttribute.BLOCKSIZE) .build(); // Creates the command-line parameters for distcp List<String> params = constructDistCpParams(srcPaths, dst, conf); try { conf.setBoolean("mapred.mapper.new-api", true); DistCp distcp = new DistCp(conf, options); // HIVE-13704 states that we should use run() instead of execute() due to a hadoop known issue // added by HADOOP-10459 if (distcp.run(params.toArray(new String[params.size()])) == 0) { return true; } else { return false; } } catch (Exception e) { throw new IOException("Cannot execute DistCp process: " + e, e); } finally { conf.setBoolean("mapred.mapper.new-api", false); } }
public Builder addField(String title) { return addField(title, Justification.LEFT, false); }
public Builder addField(String title, Justification justification) { return addField(title, justification, false); }