use of org.apache.knox.gateway.shell.table.KnoxShellTable in project knox by apache.
the class WebHDFSCommand method listMounts.
private KnoxShellTable listMounts(Map<String, String> mounts) {
KnoxShellTable table = new KnoxShellTable();
table.header("Mount Point").header("Topology URL");
for (String mountPoint : mounts.keySet()) {
table.row().value(mountPoint).value(mounts.get(mountPoint));
}
return table;
}
use of org.apache.knox.gateway.shell.table.KnoxShellTable in project knox by apache.
the class WebHDFSCommand method buildTableFromListStatus.
private KnoxShellTable buildTableFromListStatus(String directory, List<HashMap<String, String>> list) {
Calendar cal = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
KnoxShellTable table = new KnoxShellTable();
table.title(directory);
table.header("permission").header("owner").header("group").header("length").header("modtime").header("name");
for (Map<String, String> map : list) {
cal.setTimeInMillis(Long.parseLong(map.get("modificationTime")));
table.row().value(map.get("permission")).value(map.get("owner")).value(map.get("group")).value(map.get("length")).value(cal.getTime()).value(map.get("pathSuffix"));
}
return table;
}
use of org.apache.knox.gateway.shell.table.KnoxShellTable in project knox by apache.
the class KnoxLine method executeShell.
private void executeShell() {
String sql;
System.out.println(" _ _ _ ");
System.out.println("| | ___ __ _____ _| (_)_ __ ___ ");
System.out.println("| |/ / '_ \\ / _ \\ \\/ / | | '_ \\ / _ \\");
System.out.println("| <| | | | (_) > <| | | | | | __/");
System.out.println("|_|\\_\\_| |_|\\___/_/\\_\\_|_|_| |_|\\\\__|");
System.out.println("powered by Apache Knox");
System.out.println("");
System.out.println("");
while (true) {
sql = System.console().readLine("knoxline> ");
if (sql != null && !sql.isEmpty()) {
if (sql.startsWith(":ds") || sql.startsWith(":datasource")) {
try {
processDataSourceCommand(sql);
} catch (CredentialCollectionException | SQLException e) {
e.printStackTrace();
}
} else {
// Configure JDBC connection
if (datasource != null) {
System.out.println(sql);
try {
establishConnection();
try (Statement statement = conn.createStatement()) {
if (statement.execute(sql)) {
try (ResultSet resultSet = statement.getResultSet()) {
KnoxShellTable table = KnoxShellTable.builder().jdbc().resultSet(resultSet);
System.out.println(table.toString());
System.out.println("\nRows: " + table.getRows().size() + "\n");
}
}
}
} catch (SQLException e) {
System.out.println("SQL Exception encountered... " + e.getMessage());
}
} else {
System.out.println("No datasource selected. Use :ds select {datasource-name}");
}
}
}
}
}
Aggregations