@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); }
@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 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); } }
@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(); } } }
@Override public void storePublications(Collection<PublicationData> publications) { initializeConnection(tableName, families); List<Row> rows = convertPublicationsToRows(publications); hBaseClient.addOrUpdateRows(tableName, rows); }
@Override public void addOrUpdateRows(String tableName, List<Row> rows) { List<BatchMutation> batchMutations = getMutations(rows); addOrUpdateBatchRows(tableName, batchMutations); }
@Override public void createTable(String tableName, String... families) { HTableDescriptor hTableDescriptor = prepareSchema(tableName, families); createTable(hTableDescriptor); }
private HBaseClient createHBaseClient() { return new HBaseClientThrift(host, port, readTimeout); }
private List<Media> convertPublicationDataToMedia( PublicationData publication) { List<Media> media = new ArrayList<DocumentProtos.Media>(); Media m = convertBwmetaToMedia(publication); media.add(m); if (publication.getPublicationContents() != null) { for (PublicationAttachment entry : publication .getPublicationContents()) { m = convertAttachmentsToMedia(entry); media.add(m); } } return media; }
static ProtocolOptions findProtocolOptions(boolean framed, boolean compact) { for (ProtocolOptions prot : ProtocolOptions.values()) { if (prot.framed == framed && prot.compact == compact) { return prot; } } // this statement should never be reachable return null; }
@Override public void deleteRows(String tableName, List<Row> rows) { for (Row row : rows) { deleteRow(tableName, row); } }
@Override public void deleteRows(String tableName, List<Row> rows) { for (final Row row : rows) { deleteRow(tableName, row); } }
public HBaseClientThrift(String host, int port, int readTimeout, boolean framed, boolean compact) { // framed and compact options set here will be checked at first, but other combinations of those // parameters will be checked too; see the openConnection method this.host = host; this.port = port; this.readTimeout = readTimeout; this.opts = ProtocolOptions.findProtocolOptions(framed, compact); mutex = this; }
@Override public boolean isTableExists(String tableName) { boolean result = false; List<ByteBuffer> tableNames = getTableNames(); for (ByteBuffer tn : tableNames) { if (tn.equals(ByteBuffer.wrap(tableName.getBytes()))) { result = true; break; } } return result; }
@Override public Row getRow(String tableName, Row row) throws DocumentNotFoundException { final List<Row> rows = getRows(tableName, row, ONE); if (rows.isEmpty()) { throw new DocumentNotFoundException(null); } return rows.get(FIRST); }
@Override public Row getRow(String tableName, Row row) throws DocumentNotFoundException { final List<Row> rows = getRows(tableName, row, ONE); if (rows.isEmpty()) { throw new DocumentNotFoundException(null); } return rows.get(FIRST); }
private DocumentWrapper convertMediaToBw2Proto(List<Media> mediaList, String documentKey) { final DocumentProtos.DocumentWrapper.Builder dwb = DocumentProtos.DocumentWrapper .newBuilder(); dwb.setRowId(documentKey); dwb.setMediaContainer(addMedia(mediaList)); return dwb.build(); }
@Override public void storeBatchPublications(Collection<PublicationData> publications) { initializeConnection(tableName, families); List<Row> rows = convertPublicationsToRows(publications); hBaseClient.addOrUpdateRows(tableName, rows); }