@Test public void testSaveSingle() throws Exception { DocumentTranslator documentTranslator = new DocumentTranslator(TestUtils.createTranslatorConfigWithRawKeyV1()); hbaseDataStore = new HBaseDataStore(hbaseTableConnection, mapper, documentTranslator); Document expectedDocument = new Document(); expectedDocument.setId(UUID.randomUUID() .toString()); expectedDocument.setTimestamp(System.currentTimeMillis()); JsonNode data = mapper.valueToTree(Collections.singletonMap("TEST_NAME", "SINGLE_SAVE_TEST")); expectedDocument.setData(data); hbaseDataStore.save(TEST_APP, expectedDocument); validateSave(v1FormatKey(expectedDocument.getId()), expectedDocument); documentTranslator = new DocumentTranslator(TestUtils.createTranslatorConfigWithRawKeyV2()); hbaseDataStore = new HBaseDataStore(hbaseTableConnection, mapper, documentTranslator); expectedDocument = new Document(); expectedDocument.setId(UUID.randomUUID() .toString()); expectedDocument.setTimestamp(System.currentTimeMillis()); data = mapper.valueToTree(Collections.singletonMap("TEST_NAME", "SINGLE_SAVE_TEST")); expectedDocument.setData(data); hbaseDataStore.save(TEST_APP, expectedDocument); validateSave(documentTranslator.translate(TEST_APP, expectedDocument) .getMetadata() .getRawStorageId(), expectedDocument); }
@Override @Timed public Document save(final Table table, Document document) { if(document == null || document.getData() == null || document.getId() == null) { throw FoxtrotExceptions.createBadRequestException(table.getName(), "Invalid Input Document"); } Document translatedDocument = null; try (org.apache.hadoop.hbase.client.Table hTable = tableWrapper.getTable(table)) { translatedDocument = translator.translate(table, document); hTable.put(getPutForDocument(translatedDocument)); } catch (JsonProcessingException e) { throw FoxtrotExceptions.createBadRequestException(table, e); } catch (IOException e) { throw FoxtrotExceptions.createConnectionException(table, e); } return translatedDocument; }
HBaseDataStore implements DataStore { @Override @Timed public Document save(final Table table, Document document) { if(document == null || document.getData() == null || document.getId() == null) { throw FoxtrotExceptions.createBadRequestException(table.getName(), "Invalid Input Document"); } Document translatedDocument = null; try (org.apache.hadoop.hbase.client.Table hTable = tableWrapper.getTable(table)) { translatedDocument = translator.translate(table, document); hTable.put(getPutForDocument(translatedDocument)); } catch (JsonProcessingException e) { throw FoxtrotExceptions.createBadRequestException(table, e); } catch (IOException e) { throw FoxtrotExceptions.createConnectionException(table, e); } return translatedDocument; } }
HBaseDataStore implements DataStore { @Override @Timed public Document save(final Table table, Document document) { if(document == null || document.getData() == null || document.getId() == null) { throw FoxtrotExceptions.createBadRequestException(table.getName(), "Invalid Input Document"); } Document translatedDocument = null; try (org.apache.hadoop.hbase.client.Table hTable = tableWrapper.getTable(table)) { translatedDocument = translator.translate(table, document); hTable.put(getPutForDocument(translatedDocument)); } catch (JsonProcessingException e) { throw FoxtrotExceptions.createBadRequestException(table, e); } catch (IOException e) { throw FoxtrotExceptions.createConnectionException(table, e); } return translatedDocument; } @Inject  HBaseDataStore(HbaseTableConnection tableWrapper, ObjectMapper mapper, DocumentTranslator translator); }
HBaseDataStore implements DataStore { @Override @Timed public Document save(final Table table, Document document) { if(document == null || document.getData() == null || document.getId() == null) { throw FoxtrotExceptions.createBadRequestException(table.getName(), "Invalid Input Document"); } Document translatedDocument = null; try (org.apache.hadoop.hbase.client.Table hTable = tableWrapper.getTable(table)) { translatedDocument = translator.translate(table, document); hTable.put(getPutForDocument(translatedDocument)); } catch (JsonProcessingException e) { throw FoxtrotExceptions.createBadRequestException(table, e); } catch (IOException e) { throw FoxtrotExceptions.createConnectionException(table, e); } return translatedDocument; } @Inject  HBaseDataStore(HbaseTableConnection tableWrapper, ObjectMapper mapper, DocumentTranslator translator); @Override @Timed void initializeTable(Table table, boolean forceTableCreate); @Override @Timed Document save(final Table table, Document document); @Override @Timed List<Document> saveAll(final Table table, List<Document> documents); @Override @Timed Document get(final Table table, String id); @Override @Timed List<Document> getAll(final Table table, List<String> ids); @VisibleForTesting Put getPutForDocument(Document document); @Override @Timed void updateTable(final Table table); }
HBaseDataStore implements DataStore { @Override @Timed public Document save(final Table table, Document document) { if(document == null || document.getData() == null || document.getId() == null) { throw FoxtrotExceptions.createBadRequestException(table.getName(), "Invalid Input Document"); } Document translatedDocument = null; try (org.apache.hadoop.hbase.client.Table hTable = tableWrapper.getTable(table)) { translatedDocument = translator.translate(table, document); hTable.put(getPutForDocument(translatedDocument)); } catch (JsonProcessingException e) { throw FoxtrotExceptions.createBadRequestException(table, e); } catch (IOException e) { throw FoxtrotExceptions.createConnectionException(table, e); } return translatedDocument; } @Inject  HBaseDataStore(HbaseTableConnection tableWrapper, ObjectMapper mapper, DocumentTranslator translator); @Override @Timed void initializeTable(Table table, boolean forceTableCreate); @Override @Timed Document save(final Table table, Document document); @Override @Timed List<Document> saveAll(final Table table, List<Document> documents); @Override @Timed Document get(final Table table, String id); @Override @Timed List<Document> getAll(final Table table, List<String> ids); @VisibleForTesting Put getPutForDocument(Document document); @Override @Timed void updateTable(final Table table);  }