Java Code Examples for com.google.common.base.Stopwatch#stop()

The following examples show how to use com.google.common.base.Stopwatch#stop() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HiveVarcharTruncationReader.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
public void runProjector(BaseVariableWidthVector vector, int recordCount,
                         OperatorContext context,
                         Stopwatch javaCodeGenWatch,
                         Stopwatch gandivaCodeGenWatch) throws Exception {
  if (transferPair == null) {
    return;
  }

  if (castRequired(vector, recordCount, truncLen)) {
    splitter.projectRecords(recordCount, javaCodeGenWatch, gandivaCodeGenWatch);
    context.getStats().addLongStat(ScanOperator.Metric.TOTAL_HIVE_PARQUET_TRUNCATE_VARCHAR, 1);
  } else {
    javaCodeGenWatch.start();
    transferPair.transfer();
    javaCodeGenWatch.stop();
    context.getStats().addLongStat(ScanOperator.Metric.TOTAL_HIVE_PARQUET_TRANSFER_VARCHAR, 1);
  }
  context.getStats().addLongStat(ScanOperator.Metric.HIVE_PARQUET_CHECK_VARCHAR_CAST_TIME,
    varcharCheckCastWatch.elapsed(TimeUnit.NANOSECONDS));
  varcharCheckCastWatch.reset();
}
 
Example 2
Source File: ListShardMap.java    From elastic-db-tools-for-java with MIT License 6 votes vote down vote up
/**
 * Unlocks all mappings in this map that belong to the given <see cref="MappingLockToken"/>.
 *
 * @param mappingLockToken
 *            An instance of <see cref="MappingLockToken"/>
 */
public void unlockMapping(MappingLockToken mappingLockToken) {
    ExceptionUtils.disallowNullArgument(mappingLockToken, "mappingLockToken");

    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        UUID lockOwnerId = mappingLockToken.getLockOwnerId();
        log.info("UnlockAllMappingsWithLockOwnerId", "Start; LockOwnerId:{}", lockOwnerId);

        Stopwatch stopwatch = Stopwatch.createStarted();

        lsm.lockOrUnlockMappings(null, lockOwnerId, LockOwnerIdOpType.UnlockAllMappingsForId);

        stopwatch.stop();

        log.info("UnlockAllMappingsWithLockOwnerId", "Complete; Duration:{}", stopwatch.elapsed(TimeUnit.MILLISECONDS));
    }
}
 
Example 3
Source File: ListShardMap.java    From elastic-db-tools-for-java with MIT License 6 votes vote down vote up
/**
 * Looks up the key value and returns the corresponding mapping.
 *
 * @param key
 *            Input key value.
 * @param lookupOptions
 *            Whether to search in the cache and/or store.
 * @return Mapping that contains the key value.
 */
public PointMapping getMappingForKey(KeyT key,
        LookupOptions lookupOptions) {
    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        log.info("LookupPointMapping", "Start; ShardMap name: {}; Point Mapping Key Type: {}; Lookup " + "Options: {}", this.getName(),
                key.getClass(), lookupOptions);

        Stopwatch stopwatch = Stopwatch.createStarted();

        PointMapping pointMapping = lsm.lookup(key, lookupOptions);

        stopwatch.stop();

        log.info("LookupPointMapping", "Complete; ShardMap name: {}; Point Mapping Key Type: {}; " + "Lookup Options: {}; Duration: {}",
                this.getName(), key.getClass(), lookupOptions, stopwatch.elapsed(TimeUnit.MILLISECONDS));

        return pointMapping;
    }
}
 
Example 4
Source File: RangeShardMap.java    From elastic-db-tools-for-java with MIT License 6 votes vote down vote up
/**
 * Locks the mapping for the specified owner The state of a locked mapping can only be modified by the lock owner.
 *
 * @param mapping
 *            Input range mapping.
 * @param mappingLockToken
 *            An instance of <see cref="MappingLockToken"/>
 */
public void lockMapping(RangeMapping mapping,
        MappingLockToken mappingLockToken) {
    ExceptionUtils.disallowNullArgument(mapping, "mapping");
    ExceptionUtils.disallowNullArgument(mappingLockToken, "mappingLockToken");

    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        // Generate a lock owner id
        UUID lockOwnerId = mappingLockToken.getLockOwnerId();

        log.info("Lock Start; LockOwnerId: {}", lockOwnerId);

        Stopwatch stopwatch = Stopwatch.createStarted();

        this.rsm.lockOrUnlockMappings(mapping, lockOwnerId, LockOwnerIdOpType.Lock);

        stopwatch.stop();

        log.info("Lock Complete; Duration: {}; StoreLockOwnerId: {}", stopwatch.elapsed(TimeUnit.MILLISECONDS), lockOwnerId);
    }
}
 
Example 5
Source File: TrieDictionaryTest.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
private void testEnumeratorValues(String file) throws Exception {
    InputStream is = new FileInputStream(file);
    ArrayList<String> str = loadStrings(is);
    TrieDictionaryBuilder<String> b = newDictBuilder(str);
    TrieDictionary<String> dict = b.build(0);
    System.out.println("Dictionary size for file " + file + " is " + dict.getSize());

    Stopwatch sw = new Stopwatch();
    sw.start();
    List<String> values1 = dict.enumeratorValuesByParent();
    System.out.println("By iterating id visit the time cost " + sw.elapsed(TimeUnit.MILLISECONDS) + " ms");
    sw.reset();
    sw.start();
    List<String> values2 = dict.enumeratorValues();
    System.out.println("By pre-order visit the time cost " + sw.elapsed(TimeUnit.MILLISECONDS) + " ms");
    sw.stop();
    assertEquals(Sets.newHashSet(values1), Sets.newHashSet(values2));
}
 
Example 6
Source File: RangeShardMap.java    From elastic-db-tools-for-java with MIT License 6 votes vote down vote up
/**
 * Gets all the range mappings that exist within given range.
 *
 * @param range
 *            Range value, any mapping overlapping with the range will be returned.
 * @param lookupOptions
 *            Whether to search in the cache and/or store.
 * @return Read-only collection of mappings that satisfy the given range constraint.
 */
public List<RangeMapping> getMappings(Range range,
        LookupOptions lookupOptions) {
    ExceptionUtils.disallowNullArgument(range, "range");

    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        log.info("GetMappings Start; Range: {}; Lookup Options: {}", range, lookupOptions);

        Stopwatch stopwatch = Stopwatch.createStarted();

        List<RangeMapping> rangeMappings = this.rsm.getMappingsForRange(range, null, lookupOptions);

        stopwatch.stop();

        log.info("GetMappings Complete; Range: {}; Lookup Options: {}; Duration: {}", range, lookupOptions,
                stopwatch.elapsed(TimeUnit.MILLISECONDS));

        return rangeMappings;
    }
}
 
Example 7
Source File: Program.java    From elastic-db-tools-for-java with MIT License 5 votes vote down vote up
private static <T> Result executeMapOperations(String message,
        List<T> items,
        Func1Param<T, T> keySelector,
        Action1Param<T> a) {
    Result result = new Result();

    int latestWrittenCount = Integer.MIN_VALUE;
    int maxCount = items.size();
    Stopwatch sw;
    for (T item : items) {
        int percentComplete = (result.count * 100) / maxCount;
        if (percentComplete / 10 > latestWrittenCount / 10) {
            latestWrittenCount = percentComplete;
            System.out.printf("%1$s %2$s/%3$s (%4$s)%%" + "\r\n", message, item, Collections.max(items, null), percentComplete);
        }

        T key = keySelector.invoke(item);
        sw = Stopwatch.createStarted();
        a.invoke(key);
        sw.stop();

        result.count++;
        result.totalTicks += sw.elapsed(TimeUnit.MILLISECONDS);
    }

    return result;
}
 
Example 8
Source File: GIRPTMCalculator.java    From TagRec with GNU Affero General Public License v3.0 5 votes vote down vote up
public static BookmarkReader predictSample(String filename, int trainSize, int sampleSize, boolean userBased, boolean resBased) {
	Timer timerThread = new Timer();
	MemoryThread memoryThread = new MemoryThread();
	timerThread.schedule(memoryThread, 0, MemoryThread.TIME_SPAN);
	
	BookmarkReader reader = new BookmarkReader(trainSize, false);
	reader.readFile(filename);	
	List<int[]> predictionValues = new ArrayList<int[]>();
	Stopwatch timer = new Stopwatch();
	timer.start();
	GIRPTMCalculator calculator = new GIRPTMCalculator(reader, trainSize, userBased, resBased);
	timer.stop();
	long trainingTime = timer.elapsed(TimeUnit.MILLISECONDS);
	
	timer.reset();
	timer.start();
	for (int i = trainSize; i < trainSize + sampleSize; i++) { // the test-set
		Bookmark data = reader.getBookmarks().get(i);
		Map<Integer, Double> map = calculator.getRankedTagList(data.getUserID(), data.getResourceID());
		predictionValues.add(Ints.toArray(map.keySet()));
	}
	timer.stop();
	long testTime = timer.elapsed(TimeUnit.MILLISECONDS);
	
	timeString = PerformanceMeasurement.addTimeMeasurement(timeString, true, trainingTime, testTime, sampleSize);		
	String suffix = "_girp";
	if (userBased && resBased) {
		suffix = "_girptm";
	}
	reader.setTestLines(reader.getBookmarks().subList(trainSize, reader.getBookmarks().size()));
	PredictionFileWriter writer = new PredictionFileWriter(reader, predictionValues);
	writer.writeFile(filename + suffix);
	
	timeString = PerformanceMeasurement.addMemoryMeasurement(timeString, false, memoryThread.getMaxMemory());
	timerThread.cancel();
	Utilities.writeStringToFile("./data/metrics/" + filename + suffix + "_TIME.txt", timeString);		
	return reader;
}
 
Example 9
Source File: ScheduleStateCleaner.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    // we should catch every exception to avoid zombile thread
    try {
        final Stopwatch watch = Stopwatch.createStarted();
        LOG.info("clear schedule states start.");
        client.clearScheduleState(reservedCapacity);
        watch.stop();
        LOG.info("clear schedule states completed. used time milliseconds: {}", watch.elapsed(TimeUnit.MILLISECONDS));
        // reset cached policies
    } catch (Throwable t) {
        LOG.error("fail to clear schedule states due to {}, but continue to run", t.getMessage());
    }
}
 
Example 10
Source File: FSInputStreamWithStatsWrapper.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Override
public int read(byte[] b, int off, int len) throws IOException {
  try (WaitRecorder recorder = OperatorStats.getWaitRecorder(waitStats)) {
    Stopwatch stopwatch = Stopwatch.createStarted();
    int n = super.read(b, off, len);
    stopwatch.stop();
    operatorStats.updateReadIOStats(stopwatch.elapsed(TimeUnit.NANOSECONDS), filePath, n, getPosition());
    return n;
  }
}
 
Example 11
Source File: AbstractRepeater.java    From jvm-sandbox-repeater with Apache License 2.0 5 votes vote down vote up
@Override
public void repeat(RepeatContext context) {
    Stopwatch stopwatch = Stopwatch.createStarted();
    RepeatModel record = new RepeatModel();
    record.setRepeatId(context.getMeta().getRepeatId());
    record.setTraceId(context.getTraceId());
    try {
        // 根据之前生成的traceId开启追踪
        Tracer.start(context.getTraceId());
        // before invoke advice
        RepeatInterceptorFacade.instance().beforeInvoke(context.getRecordModel());
        Object response = executeRepeat(context);
        // after invoke advice
        RepeatInterceptorFacade.instance().beforeReturn(context.getRecordModel(), response);
        stopwatch.stop();
        record.setCost(stopwatch.elapsed(TimeUnit.MILLISECONDS));
        record.setFinish(true);
        record.setResponse(response);
        record.setMockInvocations(RepeatCache.getMockInvocation(context.getTraceId()));
    } catch (Exception e) {
        stopwatch.stop();
        record.setCost(stopwatch.elapsed(TimeUnit.MILLISECONDS));
        record.setResponse(e);
    } finally {
        Tracer.end();
    }
    sendRepeat(record);
}
 
Example 12
Source File: WalletFiles.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
private void saveNowInternal() throws IOException {
    final Stopwatch watch = Stopwatch.createStarted();
    File directory = file.getAbsoluteFile().getParentFile();
    File temp = File.createTempFile("wallet", null, directory);
    final Listener listener = vListener;
    if (listener != null)
        listener.onBeforeAutoSave(temp);
    wallet.saveToFile(temp, file);
    if (listener != null)
        listener.onAfterAutoSave(file);
    watch.stop();
    log.info("Save completed in {}", watch);
}
 
Example 13
Source File: MonitoringContextImpl.java    From phoenix-omid with Apache License 2.0 5 votes vote down vote up
public void timerStop(String name) {
    if (flag) {
        LOG.warn("timerStop({}) called after publish. Measurement was ignored. {}", name, Throwables.getStackTraceAsString(new Exception()));
        return;
    }
    Stopwatch activeStopwatch = timers.get(name);
    if (activeStopwatch == null) {
        throw new IllegalStateException(
                String.format("There is no %s timer in the %s monitoring context.", name, this));
    }
    activeStopwatch.stop();
    elapsedTimeMsMap.put(name, activeStopwatch.elapsedTime(TimeUnit.NANOSECONDS));
    timers.remove(name);
}
 
Example 14
Source File: HdfsStatsService.java    From hraven with Apache License 2.0 4 votes vote down vote up
/**
 * Scans the hbase table and populates the hdfs stats
 * @param cluster
 * @param scan
 * @param maxCount
 * @return
 * @throws IOException
 */
private List<HdfsStats> createFromScanResults(String cluster, String path,
    Scan scan, int maxCount, boolean checkPath, long starttime, long endtime)
    throws IOException {
  Map<HdfsStatsKey, HdfsStats> hdfsStats =
      new HashMap<HdfsStatsKey, HdfsStats>();
  ResultScanner scanner = null;
  Stopwatch timer = new Stopwatch().start();
  int rowCount = 0;
  long colCount = 0;
  long resultSize = 0;

  Table hdfsUsageTable = null;

  try {
    hdfsUsageTable = hbaseConnection
        .getTable(TableName.valueOf(HdfsConstants.HDFS_USAGE_TABLE));
    scanner = hdfsUsageTable.getScanner(scan);
    for (Result result : scanner) {
      if (result != null && !result.isEmpty()) {
        colCount += result.size();
        // TODO dogpiledays resultSize += result.getWritableSize();
        rowCount = populateHdfsStats(result, hdfsStats, checkPath, path,
            starttime, endtime, rowCount);
        // return if we've already hit the limit
        if (rowCount >= maxCount) {
          break;
        }
      }
    }

    timer.stop();
    LOG.info("In createFromScanResults For cluster " + cluster
        + " Fetched from hbase " + rowCount + " rows, " + colCount
        + " columns, " + resultSize + " bytes ( " + resultSize / (1024 * 1024)
        + ") MB, in total time of " + timer);
  } finally {
    try {
      if (scanner != null) {
        scanner.close();
      }
    } finally {
      if (hdfsUsageTable != null) {
        hdfsUsageTable.close();
      }
    }
  }

  List<HdfsStats> values = new ArrayList<HdfsStats>(hdfsStats.values());
  // sort so that timestamps are arranged in descending order
  Collections.sort(values);
  return values;
}
 
Example 15
Source File: ListShardMap.java    From elastic-db-tools-for-java with MIT License 4 votes vote down vote up
/**
 * Gets the lock owner id of the specified mapping.
 *
 * @param mapping
 *            Input range mapping.
 * @return An instance of <see cref="MappingLockToken"/>
 */
public MappingLockToken getMappingLockOwner(PointMapping mapping) {
    ExceptionUtils.disallowNullArgument(mapping, "mapping");

    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        log.info("LookupLockOwner", "Start");

        Stopwatch stopwatch = Stopwatch.createStarted();

        UUID storeLockOwnerId = lsm.getLockOwnerForMapping(mapping);

        stopwatch.stop();

        log.info("LookupLockOwner", "Complete; Duration: {}; StoreLockOwnerId:{}", stopwatch.elapsed(TimeUnit.MILLISECONDS), storeLockOwnerId);

        return new MappingLockToken(storeLockOwnerId);
    }
}
 
Example 16
Source File: BaseDAO.java    From WeBASE-Collect-Bee with Apache License 2.0 4 votes vote down vote up
public static <T, U> void saveWithTimeLog(BiConsumer<T, U> bi, T t, U u) {
    Stopwatch st = Stopwatch.createStarted();
    bi.accept(t, u);
    Stopwatch st1 = st.stop();
    log.debug("{} save succeed, use time {}ms", u.getClass().getName(), st1.elapsed(TimeUnit.MILLISECONDS));
}
 
Example 17
Source File: ShardMapManagerFactory.java    From elastic-db-tools-for-java with MIT License 4 votes vote down vote up
/**
 * Creates a <see cref="ShardMapManager"/> and its corresponding storage structures in the specified SQL Server database.
 *
 * @param connectionString
 *            Connection parameters used for creating shard map manager database.
 * @param createMode
 *            Describes the option selected by the user for creating shard map manager database.
 * @param retryBehavior
 *            Behavior for performing retries on connections to shard map manager database.
 * @param targetVersion
 *            Target version of Store to deploy, this is mainly used for upgrade testing.
 * @param retryEventHandler
 *            Event handler for store operation retry events.
 * @return A shard map manager object used for performing management and read operations for shard maps, shards and shard mappings.
 */
private static ShardMapManager createSqlShardMapManagerImpl(String connectionString,
        ShardMapManagerCreateMode createMode,
        RetryBehavior retryBehavior,
        EventHandler<RetryingEventArgs> retryEventHandler,
        Version targetVersion) {
    ExceptionUtils.disallowNullArgument(connectionString, "connectionString");
    ExceptionUtils.disallowNullArgument(retryBehavior, "retryBehavior");

    if (createMode != ShardMapManagerCreateMode.KeepExisting && createMode != ShardMapManagerCreateMode.ReplaceExisting) {
        throw new IllegalArgumentException(StringUtilsLocal.formatInvariant(Errors._General_InvalidArgumentValue, createMode, "createMode"),
                new Throwable("createMode"));
    }

    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        log.info("ShardMapManagerFactory CreateSqlShardMapManager Start; ");

        Stopwatch stopwatch = Stopwatch.createStarted();

        SqlShardMapManagerCredentials credentials = new SqlShardMapManagerCredentials(connectionString);

        RetryPolicy retryPolicy = new RetryPolicy(new ShardManagementTransientErrorDetectionStrategy(retryBehavior),
                RetryPolicy.getDefaultRetryPolicy().getExponentialRetryStrategy());

        EventHandler<RetryingEventArgs> handler = (sender,
                args) -> {
            if (retryEventHandler != null) {
                retryEventHandler.invoke(sender, new RetryingEventArgs(args));
            }
        };

        try {
            retryPolicy.retrying.addListener(handler);

            // specifying targetVersion as GlobalConstants.GsmVersionClient
            // to deploy latest store by default.
            try (IStoreOperationGlobal op = (new StoreOperationFactory()).createCreateShardMapManagerGlobalOperation(credentials, retryPolicy,
                    "CreateSqlShardMapManager", createMode, targetVersion)) {
                op.doGlobal();
            }
            catch (Exception e) {
                e.printStackTrace();
                ExceptionUtils.throwStronglyTypedException(e);
            }

            stopwatch.stop();

            log.info("ShardMapManagerFactory CreateSqlShardMapManager Complete; Duration:{}", stopwatch.elapsed(TimeUnit.MILLISECONDS));
        }
        finally {
            retryPolicy.retrying.removeListener(handler);
        }

        return new ShardMapManager(credentials, new SqlStoreConnectionFactory(), new StoreOperationFactory(), new CacheStore(),
                ShardMapManagerLoadPolicy.Lazy, RetryPolicy.getDefaultRetryPolicy(), retryBehavior, retryEventHandler);
    }
}
 
Example 18
Source File: ShardedDataTypeHandler.java    From datawave with Apache License 2.0 4 votes vote down vote up
/**
 * @param event
 * @param fields
 * @param reporter
 */
protected Value createBloomFilter(RawRecordContainer event, Multimap<String,NormalizedContentInterface> fields, StatusReporter reporter) {
    Value filterValue = DataTypeHandler.NULL_VALUE;
    if (this.bloomFiltersEnabled) {
        
        try {
            // Create and start the stopwatch
            final Stopwatch stopWatch = new Stopwatch();
            stopWatch.start();
            
            // Create the bloom filter, which may involve NGram expansion
            final BloomFilterWrapper result = this.createBloomFilter(fields);
            final BloomFilter<String> bloomFilter = result.getFilter();
            filterValue = MemberShipTest.toValue(bloomFilter);
            
            // Stop the stopwatch
            stopWatch.stop();
            
            if (null != reporter) {
                final Counter filterCounter = reporter.getCounter(MemberShipTest.class.getSimpleName(), "BloomFilterCreated");
                if (null != filterCounter) {
                    filterCounter.increment(1);
                }
                
                final Counter sizeCounter = reporter.getCounter(MemberShipTest.class.getSimpleName(), "BloomFilterSize");
                if (null != sizeCounter) {
                    sizeCounter.increment(filterValue.getSize());
                }
                
                final Counter fieldsCounter = reporter.getCounter(MemberShipTest.class.getSimpleName(), "BloomFilterAppliedFields");
                if (null != fieldsCounter) {
                    fieldsCounter.increment(result.getFieldValuesAppliedToFilter());
                }
                
                final Counter ngramsCounter = reporter.getCounter(MemberShipTest.class.getSimpleName(), "BloomFilterAppliedNGrams");
                if (null != ngramsCounter) {
                    ngramsCounter.increment(result.getNGramsAppliedToFilter());
                }
                
                final Counter prunedCounter = reporter.getCounter(MemberShipTest.class.getSimpleName(), "BloomFilterPrunedNGrams");
                if (null != prunedCounter) {
                    prunedCounter.increment(result.getNGramsPrunedFromFilter());
                }
                
                final Counter creationTime = reporter.getCounter(MemberShipTest.class.getSimpleName(), "Creation Time-(ms)");
                if (null != creationTime) {
                    creationTime.increment(stopWatch.elapsed(TimeUnit.MILLISECONDS));
                }
            }
        } catch (Exception e) {
            if (null != reporter) {
                final Counter errorCounter = reporter.getCounter(MemberShipTest.class.getSimpleName(), "BloomFilterError");
                if (null != errorCounter) {
                    errorCounter.increment(filterValue.getSize());
                }
            }
        }
    }
    
    return filterValue;
    
}
 
Example 19
Source File: RangeShardMap.java    From elastic-db-tools-for-java with MIT License 4 votes vote down vote up
/**
 * Gets all the range mappings that exist within given range.
 *
 * @param range
 *            Range value, any mapping overlapping with the range will be returned.
 * @return Read-only collection of mappings that satisfy the given range constraint.
 */
public List<RangeMapping> getMappings(Range range) {
    ExceptionUtils.disallowNullArgument(range, "range");

    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        log.info("GetMappings Start; Range: {}", range);

        Stopwatch stopwatch = Stopwatch.createStarted();

        List<RangeMapping> rangeMappings = this.rsm.getMappingsForRange(range, null, LookupOptions.LOOKUP_IN_STORE);

        stopwatch.stop();

        log.info("GetMappings Complete; Range: {}; Duration: {}", range, stopwatch.elapsed(TimeUnit.MILLISECONDS));

        return rangeMappings;
    }
}
 
Example 20
Source File: VerticaMetricRepo.java    From monasca-persister with Apache License 2.0 2 votes vote down vote up
@Override
public int flush(String id) throws RepoException {

  try {

    Stopwatch swOuter = Stopwatch.createStarted();

    Timer.Context context = commitTimer.time();

    executeBatches(id);

    writeRowsFromTempStagingTablesToPermTables(id);

    Stopwatch swInner = Stopwatch.createStarted();

    handle.commit();
    swInner.stop();

    logger.debug("[{}]: committing transaction took: {}", id, swInner);

    swInner.reset().start();
    handle.begin();
    swInner.stop();

    logger.debug("[{}]: beginning new transaction took: {}", id, swInner);

    context.stop();

    swOuter.stop();

    logger.debug("[{}]: total time for writing measurements, definitions, and dimensions to vertica took {}",
                 id, swOuter);

    updateIdCaches(id);

    int commitCnt = this.measurementCnt;

    this.measurementCnt = 0;

    return commitCnt;

  } catch (Exception e) {

    logger.error("[{}]: failed to write measurements, definitions, and dimensions to vertica", id,
                 e);

    throw new RepoException("failed to commit batch to vertica", e);

  }
}