@Override public void addMutation(Mutation m) throws MutationsRejectedException { checkArgument(m != null, "m is null"); bw.addMutation(tableId, m); }
@Override public void close() throws MutationsRejectedException { bw.close(); }
@Override public void flush() throws MutationsRejectedException { bw.flush(); }
public synchronized void close() throws MutationsRejectedException { if (closed) return; Span span = Trace.start("close"); try { closed = true; startProcessing(); waitRTE(() -> totalMemUsed > 0 && !somethingFailed); logStats(); checkForFailures(); } finally { // make a best effort to release these resources writer.binningThreadPool.shutdownNow(); writer.sendThreadPool.shutdownNow(); jtimer.cancel(); span.stop(); } }
public synchronized void flush() throws MutationsRejectedException { if (closed) throw new IllegalStateException("Closed"); Span span = Trace.start("flush"); try { checkForFailures(); if (flushing) { // some other thread is currently flushing, so wait waitRTE(() -> flushing && !somethingFailed); checkForFailures(); return; } flushing = true; startProcessing(); checkForFailures(); waitRTE(() -> totalMemUsed > 0 && !somethingFailed); flushing = false; this.notifyAll(); checkForFailures(); } finally { span.stop(); // somethingFailed = false; } }
private void updateBatchStats(Map<String,TabletServerMutations<Mutation>> binnedMutations) { tabletServersBatchSum.addAndGet(binnedMutations.size()); computeMin(minTabletServersBatch, binnedMutations.size()); computeMax(maxTabletServersBatch, binnedMutations.size()); int numTablets = 0; for (Entry<String,TabletServerMutations<Mutation>> entry : binnedMutations.entrySet()) { TabletServerMutations<Mutation> tsm = entry.getValue(); numTablets += tsm.getMutations().size(); } tabletBatchSum.addAndGet(numTablets); computeMin(minTabletBatch, numTablets); computeMax(maxTabletBatch, numTablets); numBatches.incrementAndGet(); }
public MultiTableBatchWriterImpl(ClientContext context, BatchWriterConfig config) { checkArgument(context != null, "context is null"); checkArgument(config != null, "config is null"); this.context = context; this.bw = new TabletServerBatchWriter(context, config); tableWriters = new ConcurrentHashMap<>(); this.closed = new AtomicBoolean(false); }
/** * Add mutations that previously failed back into the mix */ private synchronized void addFailedMutations(MutationSet failedMutations) { mutations.addAll(failedMutations); if (mutations.getMemoryUsed() >= maxMem / 2 || closed || flushing) { startProcessing(); } }
private void updateAuthorizationFailures(Map<KeyExtent,SecurityErrorCode> authorizationFailures) { if (authorizationFailures.size() > 0) { // was a table deleted? HashSet<Table.ID> tableIds = new HashSet<>(); for (KeyExtent ke : authorizationFailures.keySet()) tableIds.add(ke.getTableId()); Tables.clearCache(context); for (Table.ID tableId : tableIds) if (!Tables.exists(context, tableId)) throw new TableDeletedException(tableId.canonicalID()); synchronized (this) { somethingFailed = true; mergeAuthorizationFailures(this.authorizationFailures, authorizationFailures); this.notifyAll(); } } }
throw new IllegalArgumentException("Can not add empty mutations"); checkForFailures(); waitRTE(() -> (totalMemUsed > maxMem || flushing) && !somethingFailed); checkForFailures(); startProcessing(); checkForFailures();
public BatchWriterImpl(ClientContext context, Table.ID tableId, BatchWriterConfig config) { checkArgument(context != null, "context is null"); checkArgument(tableId != null, "tableId is null"); if (config == null) config = new BatchWriterConfig(); this.tableId = tableId; this.bw = new TabletServerBatchWriter(context, config); }
@Override public void addMutation(Mutation m) throws MutationsRejectedException { checkArgument(m != null, "m is null"); bw.addMutation(tableId, m); }
@Override public void close() throws MutationsRejectedException { this.closed.set(true); bw.close(); }
@Override public void flush() throws MutationsRejectedException { bw.flush(); }
@Override public void addMutations(Iterable<Mutation> iterable) throws MutationsRejectedException { bw.addMutation(tableId, iterable.iterator()); }
public void addMutation(Table.ID table, Iterator<Mutation> iterator) throws MutationsRejectedException { while (iterator.hasNext()) { addMutation(table, iterator.next()); } }
@Override public void addMutations(Iterable<Mutation> iterable) throws MutationsRejectedException { checkArgument(iterable != null, "iterable is null"); bw.addMutation(tableId, iterable.iterator()); }