private HBaseClient createHBaseClient() { return new HBaseClientThrift(host, port, readTimeout); }
@Override public void addOrUpdateRows(String tableName, List<Row> rows) { List<BatchMutation> batchMutations = getMutations(rows); addOrUpdateBatchRows(tableName, batchMutations); }
@Override public void addOrUpdateRow(String tableName, Row row) { List<Mutation> mutations = getMutations(row); addOrUpdateRow(tableName, row, mutations); }
@Override public void createTable(String tableName, String... families) { List<ColumnDescriptor> columns = prepareSchema(families); createTable(tableName, columns); }
public static void main(String [] args ){ Options options = defineOptions(); CommandLineParser parser = new GnuParser(); try { CommandLine commandLine = parser.parse(options, args); if (commandLine.hasOption(O_HELP)) { throw new ParseException(""); } String host=commandLine.getOptionValue(O_HOST); String table=commandLine.getOptionValue(O_TABLE); String port=commandLine.getOptionValue(O_PORT, "9090"); String crUser=commandLine.getOptionValue(O_CR_USER); String crPass=commandLine.getOptionValue(O_CR_PASS); HBaseClientThrift client=new HBaseClientThriftWriteFailureResistant(host, Integer.parseInt(port)); client.openConnection(); Augmenter aug=new Augmenter(client, table, crUser, crPass); aug.augment(); client.closeConnection(); } catch (ParseException e) { usage(options); } }
this.getTableNames(); } catch (ReadTableException ex) { if (connectionTries < MAX_CONNECTION_TRIES) { transport.close(); transport = null; openConnection(); } else { throw ex;
@Override public List<Row> getRows(String tableName, Row startRow, int numberOfRows) throws DocumentNotFoundException { List<TRowResult> rawRowsResultList = getRawRows(tableName, startRow, numberOfRows); if (rawRowsResultList.isEmpty()) { throw new DocumentNotFoundException(null); } List<Row> result = convertResultToRows(rawRowsResultList); if (startRow!=null && ! Arrays.equals(startRow.getId(), result.get(FIRST).getId())) { throw new DocumentNotFoundException(null); } return result; }
@Override public void deleteRows(String tableName, List<Row> rows) { for (Row row : rows) { deleteRow(tableName, row); } }
@Override public void addOrUpdateRow(String tableName, Row row) { try { super.addOrUpdateRow(tableName, row); } catch (ModifyTableException e) { LOGGER.debug(DEBUG_INFO, e); closeConnection(); openConnection(); super.addOrUpdateRow(tableName, row); } }
private List<BatchMutation> getMutations(List<Row> rows) { List<BatchMutation> result = new ArrayList<BatchMutation>(); for (Row row : rows) { result.add(new BatchMutation(ByteBuffer.wrap(row.getId()), getMutations(row))); } return result; }
@Override public void addOrUpdateRows(String tableName, List<Row> rows) { int wait=16; Object o=new Object(); while (wait < 65553) { try { super.addOrUpdateRows(tableName, rows); wait=100000; } catch (ModifyTableException e) { LOGGER.debug(DEBUG_INFO, e); closeConnection(); synchronized (o) { try { o.wait(wait); } catch (InterruptedException ex) { LOGGER.error(DEBUG_INFO, ex); } } wait=wait*2; openConnection(); } } }
private List<Row> getRows(int scannerId, int numberOfRows) { List<TRowResult> rawRowsResultList; List<Row> result = new ArrayList<Row>(0); try { synchronized (mutex) { rawRowsResultList = client.scannerGetList(scannerId, numberOfRows); } result = convertResultToRows(rawRowsResultList); } catch (IOError e) { throw new ReadTableException(EXCEPTION_DURING_FETCHING_ROWS, e); } catch (IllegalArgument e) { throw new ReadTableException(EXCEPTION_DURING_FETCHING_ROWS, e); } catch (TException e) { throw new ReadTableException(EXCEPTION_DURING_FETCHING_ROWS, e); } return result; }
public static void main(String [] args ){ ClassLoader cl = ClassLoader.getSystemClassLoader(); URL[] urls = ((URLClassLoader) cl).getURLs(); for (URL url : urls) { System.out.println(url.getFile()); } Options options = defineOptions(); CommandLineParser parser = new GnuParser(); try { CommandLine commandLine = parser.parse(options, args); if (commandLine.hasOption(O_HELP)) { throw new ParseException(""); } String host=commandLine.getOptionValue(O_HOST); String table=commandLine.getOptionValue(O_TABLE); String port=commandLine.getOptionValue(O_PORT, "9090"); String crUser=commandLine.getOptionValue(O_CR_USER); String crPass=commandLine.getOptionValue(O_CR_PASS); HBaseClientThrift client=new HBaseClientThriftWriteFailureResistant(host, Integer.parseInt(port)); client.openConnection(); OrcidZipToHBase aug=new OrcidZipToHBase(client, table, crUser, crPass,commandLine.getOptionValue(O_INPUT_FILE)); aug.process(); client.closeConnection(); } catch (ParseException e) { usage(options); } catch (IOException| JAXBException ex) { log.error(ex.getMessage(),ex); } }
private static HBaseClient prepareHBaseClient(String[] args) throws Exception { String[] parts = args[HOST_PORT_INDEX].split(HOST_PORT_SPLIT_PATTERN); String host = parts[HOST_INDEX]; int port = Integer.parseInt(parts[PORT_INDEX]); if (REST_INTERFACE_NAME.equals(args[INTERFACE_NAME_INDEX])) { return new HBaseClientRest(host, port); } else if (THRIFT_INTERFACE_NAME.equals(args[INTERFACE_NAME_INDEX])) { return new HBaseClientThrift(host, port, TIMEOUT_CONSTANCE); } throw new Exception(EXCEPTION_MESSAGE_WRONG_PARAMETERS); } }