HBASE-26921 Rewrite the counting cells part in TestMultiVersions (#4316)
[hbase.git] / hbase-client / src / main / java / org / apache / hadoop / hbase / ServerTaskBuilder.java
blobd4937373789efd503f11dfd44c0483fb02520b92
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org.apache.hadoop.hbase;
20 import org.apache.yetus.audience.InterfaceAudience;
22 /** Builder for information about active monitored server tasks */
23 @InterfaceAudience.Private
24 public final class ServerTaskBuilder {
26 public static ServerTaskBuilder newBuilder() {
27 return new ServerTaskBuilder();
30 private String description = "";
31 private String status = "";
32 private ServerTask.State state = ServerTask.State.RUNNING;
33 private long startTime;
34 private long completionTime;
36 private ServerTaskBuilder() { }
38 private static final class ServerTaskImpl implements ServerTask {
40 private final String description;
41 private final String status;
42 private final ServerTask.State state;
43 private final long startTime;
44 private final long completionTime;
46 private ServerTaskImpl(final String description, final String status,
47 final ServerTask.State state, final long startTime, final long completionTime) {
48 this.description = description;
49 this.status = status;
50 this.state = state;
51 this.startTime = startTime;
52 this.completionTime = completionTime;
55 @Override
56 public String getDescription() {
57 return description;
60 @Override
61 public String getStatus() {
62 return status;
65 @Override
66 public State getState() {
67 return state;
70 @Override
71 public long getStartTime() {
72 return startTime;
75 @Override
76 public long getCompletionTime() {
77 return completionTime;
80 @Override
81 public String toString() {
82 StringBuilder sb = new StringBuilder(512);
83 sb.append(getDescription());
84 sb.append(": status=");
85 sb.append(getStatus());
86 sb.append(", state=");
87 sb.append(getState());
88 sb.append(", startTime=");
89 sb.append(getStartTime());
90 sb.append(", completionTime=");
91 sb.append(getCompletionTime());
92 return sb.toString();
97 public ServerTaskBuilder setDescription(final String description) {
98 this.description = description;
99 return this;
102 public ServerTaskBuilder setStatus(final String status) {
103 this.status = status;
104 return this;
107 public ServerTaskBuilder setState(final ServerTask.State state) {
108 this.state = state;
109 return this;
112 public ServerTaskBuilder setStartTime(final long startTime) {
113 this.startTime = startTime;
114 return this;
117 public ServerTaskBuilder setCompletionTime(final long completionTime) {
118 this.completionTime = completionTime;
119 return this;
122 public ServerTask build() {
123 return new ServerTaskImpl(description, status, state, startTime, completionTime);