@Test(expected = TableNotFoundException.class) public void testCreateEntityListException() throws TableNotFoundException { HBaseEntity dentity = new HBaseEntity(); dentity.setRowKey("rowKey1"); dentity.setTableName("tableName1"); HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setColumnQualifier(TsdrHBaseDataStoreConstants.COLUMN_QUALIFIER_NAME); column.setTimeStamp(1000); column.setValue("metricValue"); List<HBaseColumn> columnList1 = new ArrayList<>(); columnList1.add(column); dentity.setColumns(columnList1); List<HBaseEntity> entityList = new ArrayList<>(); entityList.add(dentity); HBaseDataStore hbasedatastore1 = new HBaseDataStore() { @Override public HTableInterface getConnection(String tableName) throws IOException { throw new IOException(); } }; hbasedatastore1.create(entityList); hbasedatastore1 = new HBaseDataStore() { @Override public HTableInterface getConnection(String tableName) throws IOException { throw new IOException(); } }; hbasedatastore1.create(entityList); hbasedatastore1 = new HBaseDataStore() { @Override public HTableInterface getConnection(String tableName) throws IOException { throw new TableNotFoundException(); } }; hbasedatastore1.create(entityList); }
public HBaseEntity create(final HBaseEntity entity) throws TableNotFoundException { LOG.debug("Entering create(HBaseEntity entity)"); if (entity != null && entity.getRowKey() != null) { Put put = new Put(Bytes.toBytes(entity.getRowKey())); for (HBaseColumn currentColumn : entity.getColumns()) { if (currentColumn.getTimeStamp() == 0) { if (currentColumn.getColumnQualifier() != null) { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), Bytes.toBytes(currentColumn.getColumnQualifier()), Bytes.toBytes(currentColumn.getValue())); } else { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), null, Bytes.toBytes(currentColumn.getValue())); } } else { if (currentColumn.getColumnQualifier() != null) { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), Bytes.toBytes(currentColumn.getColumnQualifier()), currentColumn.getTimeStamp(), Bytes.toBytes(currentColumn.getValue())); } else { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), null, Bytes.toBytes(currentColumn.getValue())); } } } HTableInterface htable = null; try { htable = getConnection(entity.getTableName()); htable.put(put); flushCommit(entity.getTableName()); } catch (TableNotFoundException nfe) { throw nfe; } catch (IOException ioe) { LOG.error("Cannot put Data into HBase", ioe); closeConnection(entity.getTableName()); HConnectionManager.deleteAllConnections(); } finally { close(htable); } } LOG.debug("Exiting create(HBaseEntity entity)"); return entity; }
HBaseDataStore { public HBaseEntity create(final HBaseEntity entity) throws TableNotFoundException { LOG.debug("Entering create(HBaseEntity entity)"); if (entity != null && entity.getRowKey() != null) { Put put = new Put(Bytes.toBytes(entity.getRowKey())); for (HBaseColumn currentColumn : entity.getColumns()) { if (currentColumn.getTimeStamp() == 0) { if (currentColumn.getColumnQualifier() != null) { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), Bytes.toBytes(currentColumn.getColumnQualifier()), Bytes.toBytes(currentColumn.getValue())); } else { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), null, Bytes.toBytes(currentColumn.getValue())); } } else { if (currentColumn.getColumnQualifier() != null) { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), Bytes.toBytes(currentColumn.getColumnQualifier()), currentColumn.getTimeStamp(), Bytes.toBytes(currentColumn.getValue())); } else { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), null, Bytes.toBytes(currentColumn.getValue())); } } } HTableInterface htable = null; try { htable = getConnection(entity.getTableName()); htable.put(put); flushCommit(entity.getTableName()); } catch (TableNotFoundException nfe) { throw nfe; } catch (IOException ioe) { LOG.error("Cannot put Data into HBase", ioe); closeConnection(entity.getTableName()); HConnectionManager.deleteAllConnections(); } finally { close(htable); } } LOG.debug("Exiting create(HBaseEntity entity)"); return entity; } }
HBaseDataStore { public HBaseEntity create(final HBaseEntity entity) throws TableNotFoundException { LOG.debug("Entering create(HBaseEntity entity)"); if (entity != null && entity.getRowKey() != null) { Put put = new Put(Bytes.toBytes(entity.getRowKey())); for (HBaseColumn currentColumn : entity.getColumns()) { if (currentColumn.getTimeStamp() == 0) { if (currentColumn.getColumnQualifier() != null) { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), Bytes.toBytes(currentColumn.getColumnQualifier()), Bytes.toBytes(currentColumn.getValue())); } else { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), null, Bytes.toBytes(currentColumn.getValue())); } } else { if (currentColumn.getColumnQualifier() != null) { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), Bytes.toBytes(currentColumn.getColumnQualifier()), currentColumn.getTimeStamp(), Bytes.toBytes(currentColumn.getValue())); } else { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), null, Bytes.toBytes(currentColumn.getValue())); } } } HTableInterface htable = null; try { htable = getConnection(entity.getTableName()); htable.put(put); flushCommit(entity.getTableName()); } catch (TableNotFoundException nfe) { throw nfe; } catch (IOException ioe) { LOG.error("Cannot put Data into HBase", ioe); closeConnection(entity.getTableName()); HConnectionManager.deleteAllConnections(); } finally { close(htable); } } LOG.debug("Exiting create(HBaseEntity entity)"); return entity; } HBaseDataStore();  HBaseDataStore(HBaseDataStoreContext context); }
HBaseDataStore { public HBaseEntity create(final HBaseEntity entity) throws TableNotFoundException { LOG.debug("Entering create(HBaseEntity entity)"); if (entity != null && entity.getRowKey() != null) { Put put = new Put(Bytes.toBytes(entity.getRowKey())); for (HBaseColumn currentColumn : entity.getColumns()) { if (currentColumn.getTimeStamp() == 0) { if (currentColumn.getColumnQualifier() != null) { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), Bytes.toBytes(currentColumn.getColumnQualifier()), Bytes.toBytes(currentColumn.getValue())); } else { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), null, Bytes.toBytes(currentColumn.getValue())); } } else { if (currentColumn.getColumnQualifier() != null) { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), Bytes.toBytes(currentColumn.getColumnQualifier()), currentColumn.getTimeStamp(), Bytes.toBytes(currentColumn.getValue())); } else { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), null, Bytes.toBytes(currentColumn.getValue())); } } } HTableInterface htable = null; try { htable = getConnection(entity.getTableName()); htable.put(put); flushCommit(entity.getTableName()); } catch (TableNotFoundException nfe) { throw nfe; } catch (IOException ioe) { LOG.error("Cannot put Data into HBase", ioe); closeConnection(entity.getTableName()); HConnectionManager.deleteAllConnections(); } finally { close(htable); } } LOG.debug("Exiting create(HBaseEntity entity)"); return entity; } HBaseDataStore();  HBaseDataStore(HBaseDataStoreContext context); HTableInterface getConnection(String tableName); void createTable(String tableName); HBaseEntity create(final HBaseEntity entity); List<HBaseEntity> create(List<HBaseEntity> entityList); List<HBaseEntity> getDataByRowFamilyQualifier(String tableName, String startRow, String endRow,
            String family, String qualifier); List<HBaseEntity> getDataByRowFamilyQualifier(String tableName, String startRow, String endRow,
            String family, String qualifier, long pageSize); List<HBaseEntity> getDataByRowFamilyQualifier(String tableName, String startRow, String endRow,
            String family, List<String> qualifierList); List<HBaseEntity> getDataByRowFamilyQualifier(String tableName, String startRow, String endRow,
            String family, List<String> qualifierList, long pageSize); List<HBaseEntity> getDataByTimeRange(String tableName, long startTime, long endTime); List<HBaseEntity> getDataByTimeRange(String tableName, List<String> filters, long startTime, long endTime); void deleteByTimestamp(String tableName, long timestamp); HBaseEntity convertResultToEntity(String tableName, Result result); void flushCommit(String tableName); void closeConnection(String tableName); void closeConnection(HTable htable); }
HBaseDataStore { public HBaseEntity create(final HBaseEntity entity) throws TableNotFoundException { LOG.debug("Entering create(HBaseEntity entity)"); if (entity != null && entity.getRowKey() != null) { Put put = new Put(Bytes.toBytes(entity.getRowKey())); for (HBaseColumn currentColumn : entity.getColumns()) { if (currentColumn.getTimeStamp() == 0) { if (currentColumn.getColumnQualifier() != null) { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), Bytes.toBytes(currentColumn.getColumnQualifier()), Bytes.toBytes(currentColumn.getValue())); } else { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), null, Bytes.toBytes(currentColumn.getValue())); } } else { if (currentColumn.getColumnQualifier() != null) { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), Bytes.toBytes(currentColumn.getColumnQualifier()), currentColumn.getTimeStamp(), Bytes.toBytes(currentColumn.getValue())); } else { put.add(Bytes.toBytes(currentColumn.getColumnFamily()), null, Bytes.toBytes(currentColumn.getValue())); } } } HTableInterface htable = null; try { htable = getConnection(entity.getTableName()); htable.put(put); flushCommit(entity.getTableName()); } catch (TableNotFoundException nfe) { throw nfe; } catch (IOException ioe) { LOG.error("Cannot put Data into HBase", ioe); closeConnection(entity.getTableName()); HConnectionManager.deleteAllConnections(); } finally { close(htable); } } LOG.debug("Exiting create(HBaseEntity entity)"); return entity; } HBaseDataStore();  HBaseDataStore(HBaseDataStoreContext context); HTableInterface getConnection(String tableName); void createTable(String tableName); HBaseEntity create(final HBaseEntity entity); List<HBaseEntity> create(List<HBaseEntity> entityList); List<HBaseEntity> getDataByRowFamilyQualifier(String tableName, String startRow, String endRow,
            String family, String qualifier); List<HBaseEntity> getDataByRowFamilyQualifier(String tableName, String startRow, String endRow,
            String family, String qualifier, long pageSize); List<HBaseEntity> getDataByRowFamilyQualifier(String tableName, String startRow, String endRow,
            String family, List<String> qualifierList); List<HBaseEntity> getDataByRowFamilyQualifier(String tableName, String startRow, String endRow,
            String family, List<String> qualifierList, long pageSize); List<HBaseEntity> getDataByTimeRange(String tableName, long startTime, long endTime); List<HBaseEntity> getDataByTimeRange(String tableName, List<String> filters, long startTime, long endTime); void deleteByTimestamp(String tableName, long timestamp); HBaseEntity convertResultToEntity(String tableName, Result result); void flushCommit(String tableName); void closeConnection(String tableName); void closeConnection(HTable htable);  }