public static void main(String[] args) throws Exception { if (args.length < 2 || args.length > 4 || (args.length > 2 && !isBoolean(args[2]))) { System.out.println("Invalid arguments!"); System.out.println("Usage: DemoClient host port [secure=false [server-principal=hbase] ]"); System.exit(-1); } port = Integer.parseInt(args[1]); host = args[0]; if (args.length > 2) { secure = Boolean.parseBoolean(args[2]); } if (args.length == 4) { serverPrincipal = args[3]; } final DemoClient client = new DemoClient(); Subject.doAs(getSubject(), new PrivilegedExceptionAction<Void>() { @Override public Void run() throws Exception { client.run(); return null; } }); }
private void printRow(List<TRowResult> rows) { for (TRowResult rowResult : rows) { printRow(rowResult); } }
byte[] t = bytes("demo_table"); System.out.println(" found: " + utf8(name.array())); if (utf8(name.array()).equals(utf8(t))) { if (client.isTableEnabled(name)) { System.out.println(" disabling table: " + utf8(name.array())); client.disableTable(name); System.out.println(" deleting table: " + utf8(name.array())); client.deleteTable(name); ColumnDescriptor col; col = new ColumnDescriptor(); col.name = ByteBuffer.wrap(bytes("entry:")); col.timeToLive = Integer.MAX_VALUE; col.maxVersions = 10; columns.add(col); col = new ColumnDescriptor(); col.name = ByteBuffer.wrap(bytes("unused:")); col.timeToLive = Integer.MAX_VALUE; columns.add(col); System.out.println("creating table: " + utf8(t)); try { client.createTable(ByteBuffer.wrap(t), columns); System.out.println("column families in " + utf8(t) + ": "); Map<ByteBuffer, ColumnDescriptor> columnMap = client.getColumnDescriptors(ByteBuffer.wrap(t)); for (ColumnDescriptor col2 : columnMap.values()) {
byte[] t = bytes("demo_table"); System.out.println(" found: " + utf8(name.array())); if (utf8(name.array()).equals(utf8(t))) { if (client.isTableEnabled(name)) { System.out.println(" disabling table: " + utf8(name.array())); client.disableTable(name); System.out.println(" deleting table: " + utf8(name.array())); client.deleteTable(name); ColumnDescriptor col; col = new ColumnDescriptor(); col.name = ByteBuffer.wrap(bytes("entry:")); col.timeToLive = Integer.MAX_VALUE; col.maxVersions = 10; columns.add(col); col = new ColumnDescriptor(); col.name = ByteBuffer.wrap(bytes("unused:")); col.timeToLive = Integer.MAX_VALUE; columns.add(col); System.out.println("creating table: " + utf8(t)); try { client.createTable(ByteBuffer.wrap(t), columns); System.out.println("column families in " + utf8(t) + ": "); Map<ByteBuffer, ColumnDescriptor> columnMap = client.getColumnDescriptors(ByteBuffer.wrap(t)); for (ColumnDescriptor col2 : columnMap.values()) {
public static void main(String[] args) throws Exception { if (args.length < 2 || args.length > 4 || (args.length > 2 && !isBoolean(args[2]))) { System.out.println("Invalid arguments!"); System.out.println("Usage: DemoClient host port [secure=false [server-principal=hbase] ]"); System.exit(-1); } port = Integer.parseInt(args[1]); host = args[0]; if (args.length > 2) { secure = Boolean.parseBoolean(args[2]); } if (args.length == 4) { serverPrincipal = args[3]; } final DemoClient client = new DemoClient(); Subject.doAs(getSubject(), new PrivilegedExceptionAction<Void>() { @Override public Void run() throws Exception { client.run(); return null; } }); }
private void printRow(TRowResult rowResult) { // copy values into a TreeMap to get them in sorted order TreeMap<String, TCell> sorted = new TreeMap<>(); for (Map.Entry<ByteBuffer, TCell> column : rowResult.columns.entrySet()) { sorted.put(utf8(column.getKey().array()), column.getValue()); } StringBuilder rowStr = new StringBuilder(); for (SortedMap.Entry<String, TCell> entry : sorted.entrySet()) { rowStr.append(entry.getKey()); rowStr.append(" => "); rowStr.append(utf8(entry.getValue().value.array())); rowStr.append("; "); } System.out.println("row: " + utf8(rowResult.row.array()) + ", cols: " + rowStr); }
private void printRow(List<TRowResult> rows) { for (TRowResult rowResult : rows) { printRow(rowResult); } }
private void printRow(TRowResult rowResult) { // copy values into a TreeMap to get them in sorted order TreeMap<String, TCell> sorted = new TreeMap<>(); for (Map.Entry<ByteBuffer, TCell> column : rowResult.columns.entrySet()) { sorted.put(utf8(column.getKey().array()), column.getValue()); } StringBuilder rowStr = new StringBuilder(); for (SortedMap.Entry<String, TCell> entry : sorted.entrySet()) { rowStr.append(entry.getKey()); rowStr.append(" => "); rowStr.append(utf8(entry.getValue().value.array())); rowStr.append("; "); } System.out.println("row: " + utf8(rowResult.row.array()) + ", cols: " + rowStr); }