Source:
public void save(String table, Document document) throws QueryStoreException { table = ElasticsearchUtils.getValidTableName(table); try { if (!tableMetadataManager.exists(table)) { throw new QueryStoreException(QueryStoreException.ErrorCode.NO_SUCH_TABLE, "No table exists with the name: " + table); } if (new DateTime().plusDays(1).minus(document.getTimestamp()).getMillis() < 0) { return; } dataStore.save(tableMetadataManager.get(table), document); long timestamp = document.getTimestamp(); Stopwatch stopwatch = Stopwatch.createUnstarted(); stopwatch.start(); connection.getClient() .prepareIndex() .setIndex(ElasticsearchUtils.getCurrentIndex(table, timestamp)) .setType(ElasticsearchUtils.TYPE_NAME) .setId(document.getId()) .setTimestamp(Long.toString(timestamp)) .setSource(mapper.writeValueAsBytes(document.getData())) .setConsistencyLevel(WriteConsistencyLevel.QUORUM) .execute() .get(2, TimeUnit.SECONDS); logger.info(String.format("ES took : %d table : %s", stopwatch.elapsed(TimeUnit.MILLISECONDS), table)); } catch (QueryStoreException ex) { throw ex; } catch (DataStoreException ex) { DataStoreException.ErrorCode code = ex.getErrorCode(); if (code.equals(DataStoreException.ErrorCode.STORE_INVALID_REQUEST) || code.equals(DataStoreException.ErrorCode.STORE_INVALID_DOCUMENT)) { throw new QueryStoreException(QueryStoreException.ErrorCode.INVALID_REQUEST, ex.getMessage(), ex); } else { throw new QueryStoreException(QueryStoreException.ErrorCode.DOCUMENT_SAVE_ERROR, ex.getMessage(), ex); } } catch (JsonProcessingException ex) { throw new QueryStoreException(QueryStoreException.ErrorCode.INVALID_REQUEST, ex.getMessage(), ex); } catch (Exception ex) { throw new QueryStoreException(QueryStoreException.ErrorCode.DOCUMENT_SAVE_ERROR, ex.getMessage(), ex); } }

Target:
public void save(String table, Document document) throws QueryStoreException { table = ElasticsearchUtils.getValidTableName(table); try { if (!tableMetadataManager.exists(table)) { throw new QueryStoreException(QueryStoreException.ErrorCode.NO_SUCH_TABLE, "No table exists with the name: " + table); } if (new DateTime().plusDays(1).minus(document.getTimestamp()).getMillis() < 0) { return; } final Table tableMeta = tableMetadataManager.get(table); final Document translatedDocuement = dataStore.save(tableMeta, document); long timestamp = translatedDocuement.getTimestamp(); connection.getClient() .prepareIndex() .setIndex(ElasticsearchUtils.getCurrentIndex(table, timestamp)) .setType(ElasticsearchUtils.DOCUMENT_TYPE_NAME) .setId(translatedDocuement.getId()) .setTimestamp(Long.toString(timestamp)) .setSource(convert(translatedDocuement)) .setConsistencyLevel(WriteConsistencyLevel.QUORUM) .execute() .get(2, TimeUnit.SECONDS); } catch (QueryStoreException ex) { throw ex; } catch (DataStoreException ex) { DataStoreException.ErrorCode code = ex.getErrorCode(); if (code.equals(DataStoreException.ErrorCode.STORE_INVALID_REQUEST) || code.equals(DataStoreException.ErrorCode.STORE_INVALID_DOCUMENT)) { throw new QueryStoreException(QueryStoreException.ErrorCode.INVALID_REQUEST, ex.getMessage(), ex); } else { throw new QueryStoreException(QueryStoreException.ErrorCode.DOCUMENT_SAVE_ERROR, ex.getMessage(), ex); } } catch (JsonProcessingException ex) { throw new QueryStoreException(QueryStoreException.ErrorCode.INVALID_REQUEST, ex.getMessage(), ex); } catch (Exception ex) { throw new QueryStoreException(QueryStoreException.ErrorCode.DOCUMENT_SAVE_ERROR, ex.getMessage(), ex); } }