/** * Return a formatted <code>count</code> representing the number of keys in the map */ public static String getCount(Map<?, ?> map) { return getCount(map.keySet()); }
/** * Return a formatted <code>count</code> representing the number of elements in the iterable */ public static String getCount(Iterable<?> iterable) { return getCount(Iterables.size(iterable)); }
@Override public String toString() { return format("%s - %s", FormatUtils.getCount(count), FormatUtils.getSize(size)); }
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); }
protected void log(ScmExecutable exec) { ScmRequest request = org.kuali.common.util.ScmUtils.cloneOrNew(exec.getRequest()); String adds = FormatUtils.getCount(CollectionUtils.toEmptyList(request.getAdds()).size()); String deletes = FormatUtils.getCount(CollectionUtils.toEmptyList(request.getDeletes()).size()); String commits = FormatUtils.getCount(CollectionUtils.toEmptyList(request.getCommits()).size()); logger.info(" -- SCM --"); logger.info("Adds: {}", adds); logger.info("Deletes: {}", deletes); logger.info("Commits: {}", commits); logger.info("Skip: {}", skip); }
protected void showResult(ExecutionResult result) { String updates = FormatUtils.getCount(result.getUpdateCount()); String statements = FormatUtils.getCount(result.getStatementsExecuted()); String elapsed = FormatUtils.getTime(result.getElapsed()); Object[] args = { updates, statements, elapsed }; logger.info("Rows updated: {} SQL Statements: {} Total time: {}", args); }
@Override public void bucketsCreated(BucketEvent event) { List<SqlBucket> buckets = event.getBuckets(); List<Object[]> argsList = new ArrayList<Object[]>(); for (int i = 0; i < buckets.size(); i++) { SqlBucket bucket = buckets.get(i); List<SqlSupplier> suppliers = bucket.getSuppliers(); String count = FormatUtils.getCount(JdbcUtils.getSqlCount(suppliers)); String srcs = FormatUtils.getCount(suppliers.size()); String size = FormatUtils.getSize(JdbcUtils.getSqlSize(suppliers)); Object[] args = { i + 1, count, srcs, size }; argsList.add(args); } List<String> columns = Arrays.asList("Bucket", "SQL Count", "Sources", "Size"); LoggerUtils.logTable(columns, argsList, level, logger); }
@Override public void execute() { if (skip) { logger.info("Skipping execution"); return; } Assert.notNull(service, "service is null"); Assert.notNull(context, "context is null"); ExecutionResult result = service.executeSql(context); if (result.getStatementsExecuted() > 0) { String updates = FormatUtils.getCount(result.getUpdateCount()); String statements = FormatUtils.getCount(result.getStatementsExecuted()); String elapsed = FormatUtils.getTime(result.getElapsed()); Object[] args = { updates, statements, elapsed }; logger.info("Rows updated: {} SQL Statements: {} Total time: {}", args); } }
public List<String[]> getRows(String bucket, List<BucketDeltaLine> deltaLines) { List<String[]> rows = new ArrayList<String[]>(); for (BucketDeltaLine deltaLine : deltaLines) { String files = FormatUtils.getCount(deltaLine.getFileDelta()); String size = FormatUtils.getSize(deltaLine.getByteDelta()); String start = shortDateFormatter.format(deltaLine.getStartDate()); String end = shortDateFormatter.format(deltaLine.getEndDate()); String interval = FormatUtils.getTime(deltaLine.getInterval()); String[] row = new String[] { bucket, files, size, start, end, interval }; rows.add(row); } return rows; }
public String toString(AccountDeltaSummary summary) { List<String[]> rows = new ArrayList<String[]>(); for (BucketDeltaSummary bds : summary.getBucketDeltaSummaries()) { rows.addAll(getRows(bds.getBucket(), bds.getDeltaLines())); String files = FormatUtils.getCount(bds.getFileDelta()); String bytes = FormatUtils.getSize(bds.getByteDelta()); String start = shortDateFormatter.format(bds.getStartDate()); String end = shortDateFormatter.format(bds.getEndDate()); String interval = FormatUtils.getTime(bds.getInterval()); rows.add(new String[] { "", "", "", "", "", "" }); rows.add(new String[] { "totals", files, bytes, start, end, interval }); rows.add(getPerDayRow(bds)); rows.add(new String[] { "", "", "", "", "", "" }); rows.add(new String[] { "", "", "", "", "", "" }); } List<String> columns = new ArrayList<String>(); columns.add("bucket"); columns.add("files"); columns.add("size"); columns.add("start"); columns.add("end"); columns.add("interval"); return S3Utils.getInstance().toString(columns, rows); }
protected void logStats(ThreadSafeListener listener, ExecutionStatistics stats, List<SqlBucket> buckets) { // Display thread related stats long aggregateTime = listener.getAggregateTime(); long wallTime = stats.getExecutionTime(); String avgMillis = FormatUtils.getTime(aggregateTime / buckets.size()); String aTime = FormatUtils.getTime(aggregateTime); String wTime = FormatUtils.getTime(wallTime); String sqlCount = FormatUtils.getCount(listener.getAggregateSqlCount()); String sqlSize = FormatUtils.getSize(listener.getAggregateSqlSize()); Object[] args = { buckets.size(), wTime, aTime, avgMillis, sqlCount, sqlSize }; logger.debug("Threads - [count: {} time: {} aggregate: {} avg: {} sql: {} - {}]", args); }
protected String[] getPerDayRow(BucketDeltaSummary bds) { String perDay = "per day"; double days = bds.getInterval() / FormatUtils.DAY; String files = FormatUtils.getCount((long) (bds.getFileDelta() / days)); long byteDelta = bds.getByteDelta(); long bytesPerDay = (long) (byteDelta / days); String bytes = FormatUtils.getSize(bytesPerDay); return new String[] { perDay, files, bytes, "", "", "" }; }
@Override public void afterMetaData(SqlMetaDataEvent event) { this.count = JdbcUtils.getSqlCount(event.getContext().getSuppliers()); this.size = JdbcUtils.getSqlSize(event.getContext().getSuppliers()); String count = FormatUtils.getCount(this.count); String sources = FormatUtils.getCount(event.getContext().getSuppliers().size()); String size = FormatUtils.getSize(this.size); Object[] args = { count, sources, size }; LoggerUtils.logMsg("Executing - [SQL Count: {} Sources: {} Size: {}]", args, logger, loggerLevel); }
public String toString(AccountSummary summary) { List<String> columns = getBucketSummaryColumns(); List<String[]> rows = getRows(summary.getBucketSummaries()); // Add a blank row for spacing rows.add(new String[] { "", "", "" }); // Add a row showing total count and size String count = FormatUtils.getCount(summary.getCount()); String size = FormatUtils.getSize(summary.getSize()); rows.add(new String[] { "Totals", count, size }); // Convert the rows to a string and return return toString(columns, rows); }
@Override public void afterMetaData(SqlMetaDataEvent event) { this.count = JdbcUtils.getSqlCount(event.getContext().getSuppliers()); this.size = JdbcUtils.getSqlSize(event.getContext().getSuppliers()); String count = FormatUtils.getCount(this.count); String sources = FormatUtils.getCount(event.getContext().getSuppliers().size()); String size = FormatUtils.getSize(this.size); Object[] args = { label, count, sources, size }; LoggerUtils.logMsg("Executing - [{}: {} Sources: {} Size: {}]", 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, "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); } }
protected String[] getRow(BucketSummary summary) { String[] row = new String[3]; row[0] = summary.getBucket().getName(); row[1] = FormatUtils.getCount(summary.getCount()); row[2] = FormatUtils.getSize(summary.getSize()); return row; }
@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); } }
String aTime = FormatUtils.getTime(aggregateTime); String wTime = FormatUtils.getTime(wallTime); String sqlCount = FormatUtils.getCount(etl.getAggregateSqlCount()); String sqlSize = FormatUtils.getSize(etl.getAggregateSqlSize()); Object[] args = { buckets.size(), wTime, aTime, avgMillis, sqlCount, sqlSize };