View Javadoc

1   /*
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  package org.apache.hadoop.hbase.namequeues;
21  
22  import com.google.protobuf.Descriptors;
23  import com.google.protobuf.Message;
24  import org.apache.commons.lang.builder.ToStringBuilder;
25  import org.apache.hadoop.hbase.classification.InterfaceAudience;
26  
27  /**
28   * RpcCall details that would be passed on to ring buffer of slow log responses
29   */
30  @InterfaceAudience.Private
31  public class RpcLogDetails extends NamedQueuePayload {
32  
33    public static final int SLOW_LOG_EVENT = 0;
34  
35    private final Descriptors.MethodDescriptor methodDescriptor;
36    private final Message param;
37    private final String clientAddress;
38    private final long responseSize;
39    private final String className;
40    private final boolean isSlowLog;
41    private final boolean isLargeLog;
42    private final long receiveTime;
43    private final long startTime;
44    private final String userName;
45  
46    public RpcLogDetails(Descriptors.MethodDescriptor methodDescriptor, Message param,
47        String clientAddress, long responseSize, String className, boolean isSlowLog,
48        boolean isLargeLog, long receiveTime, long startTime, String userName) {
49      super(SLOW_LOG_EVENT);
50      this.methodDescriptor = methodDescriptor;
51      this.param = param;
52      this.clientAddress = clientAddress;
53      this.responseSize = responseSize;
54      this.className = className;
55      this.isSlowLog = isSlowLog;
56      this.isLargeLog = isLargeLog;
57      this.receiveTime = receiveTime;
58      this.startTime = startTime;
59      this.userName = userName;
60    }
61  
62    public Descriptors.MethodDescriptor getMethodDescriptor() {
63      return methodDescriptor;
64    }
65  
66    public String getClientAddress() {
67      return clientAddress;
68    }
69  
70    public long getResponseSize() {
71      return responseSize;
72    }
73  
74    public String getClassName() {
75      return className;
76    }
77  
78    public boolean isSlowLog() {
79      return isSlowLog;
80    }
81  
82    public boolean isLargeLog() {
83      return isLargeLog;
84    }
85  
86    public Message getParam() {
87      return param;
88    }
89  
90    public long getReceiveTime() {
91      return receiveTime;
92    }
93  
94    public long getStartTime() {
95      return startTime;
96    }
97  
98    public String getUserName() {
99      return userName;
100   }
101 
102   @Override
103   public String toString() {
104     return new ToStringBuilder(this)
105       .append("methodDescriptor", methodDescriptor)
106       .append("param", param)
107       .append("clientAddress", clientAddress)
108       .append("responseSize", responseSize)
109       .append("className", className)
110       .append("isSlowLog", isSlowLog)
111       .append("isLargeLog", isLargeLog)
112       .append("receiveTime", receiveTime)
113       .append("startTime", startTime)
114       .append("userName", userName)
115       .toString();
116   }
117 }