blob: d2489ad0691bf958b7f92cc6045db6b03e167969 [file] [log] [blame]
Madan Jampani35708a92016-07-06 10:48:19 -07001/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.store.service;
17
18import com.google.common.base.MoreObjects;
19
20/**
21 * Statistics for a {@link WorkQueue}.
22 */
23public final class WorkQueueStats {
24
25 private long totalPending;
26 private long totalInProgress;
27 private long totalCompleted;
28
29 /**
30 * Returns a {@code WorkQueueStats} builder.
31 * @return builder
32 */
33 public static Builder builder() {
34 return new Builder();
35 }
36
37 private WorkQueueStats() {
38 }
39
40 public static class Builder {
41
42 WorkQueueStats workQueueStats = new WorkQueueStats();
43
44 public Builder withTotalPending(long value) {
45 workQueueStats.totalPending = value;
46 return this;
47 }
48
49 public Builder withTotalInProgress(long value) {
50 workQueueStats.totalInProgress = value;
51 return this;
52 }
53
54 public Builder withTotalCompleted(long value) {
55 workQueueStats.totalCompleted = value;
56 return this;
57 }
58
59 public WorkQueueStats build() {
60 return workQueueStats;
61 }
62 }
63
64 /**
65 * Returns the total pending tasks. These are the tasks that are added but not yet picked up.
66 * @return total pending tasks.
67 */
68 public long totalPending() {
69 return this.totalPending;
70 }
71
72 /**
73 * Returns the total in progress tasks. These are the tasks that are currently being worked on.
74 * @return total in progress tasks.
75 */
76 public long totalInProgress() {
77 return this.totalInProgress;
78 }
79
80 /**
81 * Returns the total completed tasks.
82 * @return total completed tasks.
83 */
84 public long totalCompleted() {
85 return this.totalCompleted;
86 }
87
88 @Override
89 public String toString() {
90 return MoreObjects.toStringHelper(getClass())
91 .add("totalPending", totalPending)
92 .add("totalInProgress", totalInProgress)
93 .add("totalCompleted", totalCompleted)
94 .toString();
95 }
96}