001/*
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *     http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019
020package org.apache.hadoop.hbase.client;
021
022import org.apache.commons.lang3.builder.EqualsBuilder;
023import org.apache.commons.lang3.builder.HashCodeBuilder;
024import org.apache.commons.lang3.builder.ToStringBuilder;
025import org.apache.yetus.audience.InterfaceAudience;
026
027/**
028 * Slow/Large Log Query Filter with all filter and limit parameters
029 * Used by Admin API: getSlowLogResponses
030 */
031@InterfaceAudience.Private
032public class LogQueryFilter {
033
034  private String regionName;
035  private String clientAddress;
036  private String tableName;
037  private String userName;
038  private int limit = 10;
039  private Type type = Type.SLOW_LOG;
040  private FilterByOperator filterByOperator = FilterByOperator.OR;
041
042  public enum Type {
043    SLOW_LOG,
044    LARGE_LOG
045  }
046
047  public enum FilterByOperator {
048    AND,
049    OR
050  }
051
052  public String getRegionName() {
053    return regionName;
054  }
055
056  public void setRegionName(String regionName) {
057    this.regionName = regionName;
058  }
059
060  public String getClientAddress() {
061    return clientAddress;
062  }
063
064  public void setClientAddress(String clientAddress) {
065    this.clientAddress = clientAddress;
066  }
067
068  public String getTableName() {
069    return tableName;
070  }
071
072  public void setTableName(String tableName) {
073    this.tableName = tableName;
074  }
075
076  public String getUserName() {
077    return userName;
078  }
079
080  public void setUserName(String userName) {
081    this.userName = userName;
082  }
083
084  public int getLimit() {
085    return limit;
086  }
087
088  public void setLimit(int limit) {
089    this.limit = limit;
090  }
091
092  public Type getType() {
093    return type;
094  }
095
096  public void setType(Type type) {
097    this.type = type;
098  }
099
100  public FilterByOperator getFilterByOperator() {
101    return filterByOperator;
102  }
103
104  public void setFilterByOperator(FilterByOperator filterByOperator) {
105    this.filterByOperator = filterByOperator;
106  }
107
108  @Override
109  public boolean equals(Object o) {
110    if (this == o) {
111      return true;
112    }
113
114    if (o == null || getClass() != o.getClass()) {
115      return false;
116    }
117
118    LogQueryFilter that = (LogQueryFilter) o;
119
120    return new EqualsBuilder()
121      .append(limit, that.limit)
122      .append(regionName, that.regionName)
123      .append(clientAddress, that.clientAddress)
124      .append(tableName, that.tableName)
125      .append(userName, that.userName)
126      .append(type, that.type)
127      .append(filterByOperator, that.filterByOperator)
128      .isEquals();
129  }
130
131  @Override
132  public int hashCode() {
133    return new HashCodeBuilder(17, 37)
134      .append(regionName)
135      .append(clientAddress)
136      .append(tableName)
137      .append(userName)
138      .append(limit)
139      .append(type)
140      .append(filterByOperator)
141      .toHashCode();
142  }
143
144  @Override
145  public String toString() {
146    return new ToStringBuilder(this)
147      .append("regionName", regionName)
148      .append("clientAddress", clientAddress)
149      .append("tableName", tableName)
150      .append("userName", userName)
151      .append("limit", limit)
152      .append("type", type)
153      .append("filterByOperator", filterByOperator)
154      .toString();
155  }
156}