/** * Given a number of bytes and the number of milliseconds it took to transfer that number of bytes, return bytes/s, KB/s, MB/s, GB/s, TB/s, PB/s, or EB/s as appropriate */ public static String getRate(long millis, long bytes) { return getRate(millis, bytes, rateFormatter); }
protected static void logCopy(String src, String dst, long elapsed) { String rate = ""; String size = ""; if (LocationUtils.isExistingFile(src)) { long bytes = new File(src).length(); rate = FormatUtils.getRate(elapsed, bytes); size = FormatUtils.getSize(bytes); } Object[] args = { dst, size, FormatUtils.getTime(elapsed), rate }; logger.debug("Source -> [{}]", src); logger.debug(" created [{}] - [{} {} {}]", args); }
protected void afterDump(MySqlDumpContext context, long elapsed, long lineCount, long skippedCount) { long length = context.getOutputFile().length(); String time = FormatUtils.getTime(elapsed); String size = FormatUtils.getSize(length); String rate = FormatUtils.getRate(elapsed, length); String lines = FormatUtils.getCount(lineCount); String skipped = FormatUtils.getCount(skippedCount); Object[] args = { time, size, rate, lines, skipped }; logger.info("Dump completed. [Time:{}, Size:{}, Rate:{}, Lines:{} Skipped:{}]", args); }
/** * Show information about the transfer of data from a remote server */ protected void from(String absolutePath, CopyResult result) { if (context.isEcho()) { String elapsed = FormatUtils.getTime(result.getElapsedMillis()); String rate = FormatUtils.getRate(result.getElapsedMillis(), result.getAmountInBytes()); Object[] args = { absolutePath, elapsed, rate }; logger.info("copied <- [{}] - [{}, {}]", args); } }
/** * Show information about the transfer of data to a remote server */ protected void to(RemoteFile destination, CopyResult result) { if (context.isEcho()) { String elapsed = FormatUtils.getTime(result.getElapsedMillis()); String rate = FormatUtils.getRate(result.getElapsedMillis(), result.getAmountInBytes()); Object[] args = { destination.getAbsolutePath(), elapsed, rate }; logger.info("created -> [{}] - [{}, {}]", args); } }
@Override public void afterExecution(SqlExecutionEvent event) { long elapsed = event.getStopTimeMillis() - event.getStartTimeMillis(); String count = FormatUtils.getCount(this.count); String sources = FormatUtils.getCount(event.getContext().getSuppliers().size()); String size = FormatUtils.getSize(this.size); String time = FormatUtils.getTime(elapsed); String rate = FormatUtils.getRate(elapsed, this.size); String throughput = FormatUtils.getThroughputInSeconds(elapsed, this.count, "SQL/s"); Object[] args = { count, sources, size, time, throughput, rate }; if (showRate) { LoggerUtils.logMsg("Completed - [SQL Count: {} Sources: {} Size: {} Time: {} Throughput: {} Rate: {}]", args, logger, loggerLevel); } else { LoggerUtils.logMsg("Completed - [SQL Count: {} Sources: {} Size: {} Time: {} Throughput: {}]", args, logger, loggerLevel); } }
@Override public void afterExecution(SqlExecutionEvent event) { long elapsed = event.getStopTimeMillis() - event.getStartTimeMillis(); String count = FormatUtils.getCount(this.count); String sources = FormatUtils.getCount(event.getContext().getSuppliers().size()); String size = FormatUtils.getSize(this.size); String time = FormatUtils.getTime(elapsed); String rate = FormatUtils.getRate(elapsed, this.size); String throughput = FormatUtils.getThroughputInSeconds(elapsed, this.count, throughputLabel); Object[] args = { label, count, sources, size, time, throughput, rate }; if (showRate) { LoggerUtils.logMsg("Completed - [{}: {} Sources: {} Size: {} Time: {} Throughput: {} Rate: {}]", args, logger, loggerLevel); } else { LoggerUtils.logMsg("Completed - [{}: {} Sources: {} Size: {} Time: {} Throughput: {}]", args, logger, loggerLevel); } }