001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.client;
019
020import org.apache.commons.lang3.StringUtils;
021import org.apache.commons.lang3.builder.EqualsBuilder;
022import org.apache.commons.lang3.builder.HashCodeBuilder;
023import org.apache.commons.lang3.builder.ToStringBuilder;
024import org.apache.yetus.audience.InterfaceAudience;
025
026import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
027
028/**
029 * SlowLog params object that contains detailed info as params and region name : to be used for
030 * filter purpose
031 */
032@InterfaceAudience.Private
033public class SlowLogParams {
034
035  private final String regionName;
036  private final String params;
037  private final ClientProtos.Scan scan;
038
039  public SlowLogParams(String regionName, String params, ClientProtos.Scan scan) {
040    this.regionName = regionName;
041    this.params = params;
042    this.scan = scan;
043  }
044
045  public SlowLogParams(String regionName, String params) {
046    this.regionName = regionName;
047    this.params = params;
048    this.scan = null;
049  }
050
051  public SlowLogParams(String params) {
052    this.regionName = StringUtils.EMPTY;
053    this.params = params;
054    this.scan = null;
055  }
056
057  public String getRegionName() {
058    return regionName;
059  }
060
061  public String getParams() {
062    return params;
063  }
064
065  public ClientProtos.Scan getScan() {
066    return scan;
067  }
068
069  @Override
070  public String toString() {
071    return new ToStringBuilder(this).append("regionName", regionName).append("params", params)
072      .append("scan", scan).toString();
073  }
074
075  @Override
076  public boolean equals(Object o) {
077    if (this == o) {
078      return true;
079    }
080    if (!(o instanceof SlowLogParams)) {
081      return false;
082    }
083    SlowLogParams that = (SlowLogParams) o;
084    return new EqualsBuilder().append(regionName, that.regionName).append(params, that.params)
085      .append(scan, that.scan).isEquals();
086  }
087
088  @Override
089  public int hashCode() {
090    return new HashCodeBuilder(17, 37).append(regionName).append(params).append(scan).toHashCode();
091  }
092}