MCPcopy Index your code
hub / github.com/OpenTSDB/asynchbase / hbaseShell

Method hbaseShell

test/TestIntegration.java:2316–2340  ·  view source on GitHub ↗
(final String command)

Source from the content-addressed store, hash-verified

2314 }
2315
2316 private static void hbaseShell(final String command) throws Exception {
2317 final ProcessBuilder pb = new ProcessBuilder();
2318 pb.command(HBASE_HOME + "/bin/hbase", "shell");
2319 pb.environment().remove("HBASE_HOME");
2320 LOG.info("Running HBase shell command: " + command);
2321 final Process shell = pb.start();
2322 try {
2323 final OutputStream stdin = shell.getOutputStream();
2324 stdin.write(command.getBytes());
2325 stdin.write('\n');
2326 stdin.flush(); // Technically the JDK doesn't guarantee that close()
2327 stdin.close(); // will flush(), so better do it explicitly to be safe.
2328 // Let's hope that the HBase shell doesn't print more than 4KB of shit
2329 // on stderr, otherwise we're getting deadlocked here. Yeah seriously.
2330 // Dealing with subprocesses in Java is such a royal PITA.
2331 printLines("stdout", shell.getInputStream()); // Confusing method name,
2332 printLines("stderr", shell.getErrorStream()); // courtesy of !@#$% JDK.
2333 final int rv = shell.waitFor();
2334 if (rv != 0) {
2335 throw new RuntimeException("hbase shell returned " + rv);
2336 }
2337 } finally {
2338 shell.destroy(); // Required by the fucking JDK, no matter what.
2339 }
2340 }
2341
2342 private static void printLines(final String what, final InputStream in)
2343 throws Exception {

Callers 4

createTableMethod · 0.95
splitTableMethod · 0.95
alterTableStatusMethod · 0.95
truncateTableMethod · 0.95

Calls 4

printLinesMethod · 0.95
closeMethod · 0.80
removeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected