Java Code Examples for org.apache.nifi.util.FormatUtils#formatHoursMinutesSeconds()
The following examples show how to use
org.apache.nifi.util.FormatUtils#formatHoursMinutesSeconds() .
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: ControllerStatusReportingTask.java From localization_nifi with Apache License 2.0 | 6 votes |
private String toDiff(final long oldValue, final long newValue, final boolean formatDataSize, final boolean formatTime) { if (formatDataSize && formatTime) { throw new IllegalArgumentException("Cannot format units as both data size and time"); } final long diff = Math.abs(newValue - oldValue); final String formattedDiff = formatDataSize ? FormatUtils.formatDataSize(diff) : (formatTime ? FormatUtils.formatHoursMinutesSeconds(diff, TimeUnit.NANOSECONDS) : String.valueOf(diff)); if (oldValue > newValue) { return " (-" + formattedDiff + ")"; } else { return " (+" + formattedDiff + ")"; } }
Example 2
Source File: ControllerStatusReportingTask.java From nifi with Apache License 2.0 | 6 votes |
private String toDiff(final long oldValue, final long newValue, final boolean formatDataSize, final boolean formatTime) { if (formatDataSize && formatTime) { throw new IllegalArgumentException("Cannot format units as both data size and time"); } final long diff = Math.abs(newValue - oldValue); final String formattedDiff = formatDataSize ? FormatUtils.formatDataSize(diff) : (formatTime ? FormatUtils.formatHoursMinutesSeconds(diff, TimeUnit.NANOSECONDS) : String.valueOf(diff)); if (oldValue > newValue) { return " (-" + formattedDiff + ")"; } else { return " (+" + formattedDiff + ")"; } }
Example 3
Source File: ControllerStatusReportingTask.java From localization_nifi with Apache License 2.0 | 4 votes |
private void printProcessorStatus(final ProcessGroupStatus groupStatus, final StringBuilder builder, final boolean showDeltas) { final List<ProcessorStatus> processorStatuses = new ArrayList<>(); populateProcessorStatuses(groupStatus, processorStatuses); Collections.sort(processorStatuses, new Comparator<ProcessorStatus>() { @Override public int compare(final ProcessorStatus o1, final ProcessorStatus o2) { if (o1 == null && o2 == null) { return 0; } if (o1 == null) { return 1; } if (o2 == null) { return -1; } return -Long.compare(o1.getProcessingNanos(), o2.getProcessingNanos()); } }); for (final ProcessorStatus processorStatus : processorStatuses) { // get the stats final String input = processorStatus.getInputCount() + " / " + FormatUtils.formatDataSize(processorStatus.getInputBytes()); final String output = processorStatus.getOutputCount() + " / " + FormatUtils.formatDataSize(processorStatus.getOutputBytes()); final String read = FormatUtils.formatDataSize(processorStatus.getBytesRead()); final String written = FormatUtils.formatDataSize(processorStatus.getBytesWritten()); final String invocations = String.valueOf(processorStatus.getInvocations()); final long nanos = processorStatus.getProcessingNanos(); final String procTime = FormatUtils.formatHoursMinutesSeconds(nanos, TimeUnit.NANOSECONDS); String runStatus = ""; if (processorStatus.getRunStatus() != null) { runStatus = processorStatus.getRunStatus().toString(); } final String inputDiff; final String outputDiff; final String readDiff; final String writtenDiff; final String invocationsDiff; final String procTimeDiff; final ProcessorStatus lastStatus = lastProcessorStatus.get(processorStatus.getId()); if (showDeltas && lastStatus != null) { inputDiff = toDiff(lastStatus.getInputCount(), lastStatus.getInputBytes(), processorStatus.getInputCount(), processorStatus.getInputBytes()); outputDiff = toDiff(lastStatus.getOutputCount(), lastStatus.getOutputBytes(), processorStatus.getOutputCount(), processorStatus.getOutputBytes()); readDiff = toDiff(lastStatus.getBytesRead(), processorStatus.getBytesRead(), true, false); writtenDiff = toDiff(lastStatus.getBytesWritten(), processorStatus.getBytesWritten(), true, false); invocationsDiff = toDiff(lastStatus.getInvocations(), processorStatus.getInvocations()); procTimeDiff = toDiff(lastStatus.getProcessingNanos(), processorStatus.getProcessingNanos(), false, true); } else { inputDiff = toDiff(0L, 0L, processorStatus.getInputCount(), processorStatus.getInputBytes()); outputDiff = toDiff(0L, 0L, processorStatus.getOutputCount(), processorStatus.getOutputBytes()); readDiff = toDiff(0L, processorStatus.getBytesRead(), true, false); writtenDiff = toDiff(0L, processorStatus.getBytesWritten(), true, false); invocationsDiff = toDiff(0L, processorStatus.getInvocations()); procTimeDiff = toDiff(0L, processorStatus.getProcessingNanos(), false, true); } if (showDeltas) { builder.append(String.format(processorLineFormat, processorStatus.getName(), processorStatus.getId(), processorStatus.getType(), runStatus, input + inputDiff, output + outputDiff, read + readDiff, written + writtenDiff, invocations + invocationsDiff, procTime + procTimeDiff)); } else { builder.append(String.format(processorLineFormat, processorStatus.getName(), processorStatus.getId(), processorStatus.getType(), runStatus, input, output, read, written, invocations, procTime)); } lastProcessorStatus.put(processorStatus.getId(), processorStatus); } }
Example 4
Source File: ControllerStatusReportingTask.java From nifi with Apache License 2.0 | 4 votes |
private void printProcessorStatus(final ProcessGroupStatus groupStatus, final StringBuilder builder, final boolean showDeltas) { final List<ProcessorStatus> processorStatuses = new ArrayList<>(); populateProcessorStatuses(groupStatus, processorStatuses); Collections.sort(processorStatuses, new Comparator<ProcessorStatus>() { @Override public int compare(final ProcessorStatus o1, final ProcessorStatus o2) { if (o1 == null && o2 == null) { return 0; } if (o1 == null) { return 1; } if (o2 == null) { return -1; } return -Long.compare(o1.getProcessingNanos(), o2.getProcessingNanos()); } }); for (final ProcessorStatus processorStatus : processorStatuses) { // get the stats final String input = processorStatus.getInputCount() + " / " + FormatUtils.formatDataSize(processorStatus.getInputBytes()); final String output = processorStatus.getOutputCount() + " / " + FormatUtils.formatDataSize(processorStatus.getOutputBytes()); final String read = FormatUtils.formatDataSize(processorStatus.getBytesRead()); final String written = FormatUtils.formatDataSize(processorStatus.getBytesWritten()); final String invocations = String.valueOf(processorStatus.getInvocations()); final long nanos = processorStatus.getProcessingNanos(); final String procTime = FormatUtils.formatHoursMinutesSeconds(nanos, TimeUnit.NANOSECONDS); String runStatus = ""; if (processorStatus.getRunStatus() != null) { runStatus = processorStatus.getRunStatus().toString(); } final String inputDiff; final String outputDiff; final String readDiff; final String writtenDiff; final String invocationsDiff; final String procTimeDiff; final ProcessorStatus lastStatus = lastProcessorStatus.get(processorStatus.getId()); if (showDeltas && lastStatus != null) { inputDiff = toDiff(lastStatus.getInputCount(), lastStatus.getInputBytes(), processorStatus.getInputCount(), processorStatus.getInputBytes()); outputDiff = toDiff(lastStatus.getOutputCount(), lastStatus.getOutputBytes(), processorStatus.getOutputCount(), processorStatus.getOutputBytes()); readDiff = toDiff(lastStatus.getBytesRead(), processorStatus.getBytesRead(), true, false); writtenDiff = toDiff(lastStatus.getBytesWritten(), processorStatus.getBytesWritten(), true, false); invocationsDiff = toDiff(lastStatus.getInvocations(), processorStatus.getInvocations()); procTimeDiff = toDiff(lastStatus.getProcessingNanos(), processorStatus.getProcessingNanos(), false, true); } else { inputDiff = toDiff(0L, 0L, processorStatus.getInputCount(), processorStatus.getInputBytes()); outputDiff = toDiff(0L, 0L, processorStatus.getOutputCount(), processorStatus.getOutputBytes()); readDiff = toDiff(0L, processorStatus.getBytesRead(), true, false); writtenDiff = toDiff(0L, processorStatus.getBytesWritten(), true, false); invocationsDiff = toDiff(0L, processorStatus.getInvocations()); procTimeDiff = toDiff(0L, processorStatus.getProcessingNanos(), false, true); } if (showDeltas) { builder.append(String.format(processorLineFormat, processorStatus.getName(), processorStatus.getId(), processorStatus.getType(), runStatus, input + inputDiff, output + outputDiff, read + readDiff, written + writtenDiff, invocations + invocationsDiff, procTime + procTimeDiff)); } else { builder.append(String.format(processorLineFormat, processorStatus.getName(), processorStatus.getId(), processorStatus.getType(), runStatus, input, output, read, written, invocations, procTime)); } lastProcessorStatus.put(processorStatus.getId(), processorStatus); } }