|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +package org.apache.nifi.components.connector; |
| 19 | + |
| 20 | +/** |
| 21 | + * A summary of FlowFiles that were dropped from a FlowFile Queue. |
| 22 | + * This class provides information about the number of FlowFiles dropped |
| 23 | + * and the total aggregate size in bytes of those FlowFiles. |
| 24 | + */ |
| 25 | +public class DropFlowFileSummary { |
| 26 | + |
| 27 | + private final int droppedCount; |
| 28 | + private final long droppedBytes; |
| 29 | + |
| 30 | + /** |
| 31 | + * Creates a new DropFlowFileSummary with the given count and byte size. |
| 32 | + * |
| 33 | + * @param droppedCount the number of FlowFiles that were dropped |
| 34 | + * @param droppedBytes the total size in bytes of all dropped FlowFiles |
| 35 | + */ |
| 36 | + public DropFlowFileSummary(final int droppedCount, final long droppedBytes) { |
| 37 | + this.droppedCount = droppedCount; |
| 38 | + this.droppedBytes = droppedBytes; |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * @return the number of FlowFiles that were dropped |
| 43 | + */ |
| 44 | + public int getDroppedCount() { |
| 45 | + return droppedCount; |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @return the total size in bytes of all dropped FlowFiles |
| 50 | + */ |
| 51 | + public long getDroppedBytes() { |
| 52 | + return droppedBytes; |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * Creates a new DropFlowFileSummary that represents the combination of this summary and the given summary. |
| 57 | + * |
| 58 | + * @param other the other summary to add to this one |
| 59 | + * @return a new DropFlowFileSummary representing the combined totals |
| 60 | + */ |
| 61 | + public DropFlowFileSummary add(final DropFlowFileSummary other) { |
| 62 | + return new DropFlowFileSummary(this.droppedCount + other.droppedCount, this.droppedBytes + other.droppedBytes); |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public String toString() { |
| 67 | + return "DropFlowFileSummary[droppedCount=" + droppedCount + ", droppedBytes=" + droppedBytes + "]"; |
| 68 | + } |
| 69 | +} |
0 commit comments