@Override public void batch(List<Row> writes, Object[] results) throws IOException, InterruptedException { table.batch(writes, results); table.flushCommits(); }
@Override public void batch(List<Row> writes, Object[] results) throws IOException, InterruptedException { table.batch(writes, results); table.flushCommits(); }
@Override public void batch(List<Row> writes, Object[] results) throws IOException, InterruptedException { table.batch(writes, results); table.flushCommits(); }
/** * Cleanup any state for this DB. * Called once per DB instance; there is one DB instance per client thread. */ public void cleanup() throws DBException { // Get the measurements instance as this is the only client that should // count clean up time like an update since autoflush is off. Measurements measurements = Measurements.getMeasurements(); try { long st = System.nanoTime(); if (hTable != null) { hTable.flushCommits(); } synchronized (THREAD_COUNT) { int threadCount = THREAD_COUNT.decrementAndGet(); if (threadCount <= 0 && hConn != null) { hConn.close(); } } long en = System.nanoTime(); measurements.measure("UPDATE", (int) ((en - st) / 1000)); } catch (IOException e) { throw new DBException(e); } }
@Override protected void deleteResourceImpl(String resPath) throws IOException { HTableInterface table = getConnection().getTable(getAllInOneTableName()); try { Delete del = new Delete(Bytes.toBytes(resPath)); table.delete(del); table.flushCommits(); } finally { IOUtils.closeQuietly(table); } }
@Override protected void putResourceImpl(String resPath, InputStream content, long ts) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); IOUtils.copy(content, bout); bout.close(); HTableInterface table = getConnection().getTable(getAllInOneTableName()); try { byte[] row = Bytes.toBytes(resPath); Put put = buildPut(resPath, ts, row, bout.toByteArray(), table); table.put(put); table.flushCommits(); } finally { IOUtils.closeQuietly(table); } }
@Override protected long checkAndPutResourceImpl(String resPath, byte[] content, long oldTS, long newTS) throws IOException, IllegalStateException { HTableInterface table = getConnection().getTable(getAllInOneTableName()); try { byte[] row = Bytes.toBytes(resPath); byte[] bOldTS = oldTS == 0 ? null : Bytes.toBytes(oldTS); Put put = buildPut(resPath, newTS, row, content, table); boolean ok = table.checkAndPut(row, B_FAMILY, B_COLUMN_TS, bOldTS, put); if (!ok) throw new IllegalStateException("Overwriting conflict " + resPath + ", expect old TS " + oldTS + ", but it is " + getResourceTimestamp(resPath)); table.flushCommits(); return newTS; } finally { IOUtils.closeQuietly(table); } }
@Override protected boolean doCommit() throws IOException { hTable.flushCommits(); return true; }
@Override protected boolean doCommit() throws IOException { hTable.flushCommits(); return true; }
/** * Delegates to {@link HTable.flushCommits()} */ public void flushCommits() throws IOException { table.flushCommits(); }
@Override protected boolean doCommit() throws IOException { hTable.flushCommits(); return true; }
@Override protected boolean doCommit() throws IOException { hTable.flushCommits(); return true; }
@Override protected boolean doCommit() throws IOException { hTable.flushCommits(); return true; }
@Override protected boolean doCommit() throws IOException { hTable.flushCommits(); return true; }
@Override protected boolean doCommit() throws IOException { hTable.flushCommits(); return true; }
@Override protected boolean doCommit() throws IOException { hTable.flushCommits(); return true; }
@Override public void batch(List<Row> writes, Object[] results) throws IOException, InterruptedException { table.batch(writes, results); table.flushCommits(); }
@Override public void close() throws IOException { if (htable != null) { htable.flushCommits(); htable.close(); } if (tableStatsEnabled) { stats.setNumBytes(totalNumBytes); } } }
@Override public void flush() { Preconditions.checkState(state.equals(ReaderWriterState.OPEN), "Attempt to flush a writer in state:%s", state); try { table.flushCommits(); } catch (IOException e) { throw new DatasetIOException("Error flushing commits for table [" + table + "]", e); } }
@Override protected void deleteResourceImpl(String resPath) throws IOException { HTableInterface table = getConnection().getTable(getAllInOneTableName()); try { Delete del = new Delete(Bytes.toBytes(resPath)); table.delete(del); table.flushCommits(); } finally { IOUtils.closeQuietly(table); } }