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 while (flushing && !somethingFailed) waitRTE(); checkForFailures(); return; } flushing = true; startProcessing(); checkForFailures(); while (totalMemUsed > 0 && !somethingFailed) { waitRTE(); } flushing = false; this.notifyAll(); checkForFailures(); } finally { span.stop(); } }
void addMutations(MutationSet mutationsToSend) { Map<String, TabletServerMutations<Mutation>> binnedMutations = new HashMap<String, TabletServerMutations<Mutation>>(); Span span = Trace.start("binMutations"); try { long t1 = System.currentTimeMillis(); binMutations(mutationsToSend, binnedMutations); long t2 = System.currentTimeMillis(); updateBinningStats(mutationsToSend.size(), (t2 - t1), binnedMutations); } finally { span.stop(); } addMutations(binnedMutations); }
public synchronized void close() throws MutationsRejectedException { if (closed) return; Span span = Trace.start("close"); try { closed = true; startProcessing(); while (totalMemUsed > 0 && !somethingFailed) { waitRTE(); } logStats(); checkForFailures(); } finally { // make a best effort to release these resources writer.sendThreadPool.shutdownNow(); jtimer.cancel(); span.stop(); } }
public void send(TabletServerMutations<Mutation> tsm) throws AccumuloServerException, AccumuloSecurityException { MutationSet failures = null; String oldName = Thread.currentThread().getName(); Map<KeyExtent, List<Mutation>> mutationBatch = tsm.getMutations(); try { long count = 0; for (List<Mutation> list : mutationBatch.values()) { count += list.size(); } String msg = "sending " + String.format("%,d", count) + " mutations to " + String.format("%,d", mutationBatch.size()) + " tablets at " + location; Thread.currentThread().setName(msg); Span span = Trace.start("sendMutations"); try { TimeoutTracker timeoutTracker = timeoutTrackers.get(location); if (timeoutTracker == null) { timeoutTracker = new TimeoutTracker(location, timeout); timeoutTrackers.put(location, timeoutTracker); } long st1 = System.currentTimeMillis(); failures = sendMutationsToTabletServer(location, mutationBatch, timeoutTracker); long st2 = System.currentTimeMillis(); if (log.isTraceEnabled()) log.trace( "sent " + String.format("%,d", count) + " mutations to " + location + " in " + String.format( "%.2f secs (%,.2f mutations/sec) with %,d failures", (st2 - st1) / 1000.0, count / ((st2 - st1) / 1000.0), failures.size())); long successBytes = 0; for (Entry<KeyExtent, List<Mutation>> entry : mutationBatch.entrySet()) { for (Mutation mutation : entry.getValue()) { successBytes += mutation.estimatedMemoryUsed(); } } if (failures.size() > 0) { failedMutations.add(failures); successBytes -= failures.getMemoryUsed(); } updateSendStats(count, st2 - st1); decrementMemUsed(successBytes); } finally { span.stop(); } } catch (IOException e) { if (log.isTraceEnabled()) log.trace("failed to send mutations to " + location + " : " + e.getMessage()); HashSet<String> tables = new HashSet<String>(); for (KeyExtent ke : mutationBatch.keySet()) tables.add(ke.getTableId().toString()); for (String table : tables) TabletLocator.getLocator(instance, new Text(table)).invalidateCache(location); failedMutations.add(location, tsm); } finally { Thread.currentThread().setName(oldName); } }