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.backup.impl;
019
020import org.apache.commons.lang3.builder.EqualsBuilder;
021import org.apache.commons.lang3.builder.HashCodeBuilder;
022import org.apache.commons.lang3.builder.ToStringBuilder;
023import org.apache.commons.lang3.builder.ToStringStyle;
024import org.apache.hadoop.hbase.TableName;
025import org.apache.yetus.audience.InterfaceAudience;
026
027/**
028 * The data corresponding to a single bulk-loaded file that is being tracked by the backup logic.
029 */
030@InterfaceAudience.Private
031public class BulkLoad {
032  private final TableName tableName;
033  private final String region;
034  private final String columnFamily;
035  private final String hfilePath;
036  private final byte[] rowKey;
037
038  public BulkLoad(TableName tableName, String region, String columnFamily, String hfilePath,
039    byte[] rowKey) {
040    this.tableName = tableName;
041    this.region = region;
042    this.columnFamily = columnFamily;
043    this.hfilePath = hfilePath;
044    this.rowKey = rowKey;
045  }
046
047  public TableName getTableName() {
048    return tableName;
049  }
050
051  public String getRegion() {
052    return region;
053  }
054
055  public String getColumnFamily() {
056    return columnFamily;
057  }
058
059  public String getHfilePath() {
060    return hfilePath;
061  }
062
063  public byte[] getRowKey() {
064    return rowKey;
065  }
066
067  @Override
068  public boolean equals(Object o) {
069    if (this == o) {
070      return true;
071    }
072    if (!(o instanceof BulkLoad)) {
073      return false;
074    }
075    BulkLoad that = (BulkLoad) o;
076    return new EqualsBuilder().append(tableName, that.tableName).append(region, that.region)
077      .append(columnFamily, that.columnFamily).append(hfilePath, that.hfilePath)
078      .append(rowKey, that.rowKey).isEquals();
079  }
080
081  @Override
082  public int hashCode() {
083    return new HashCodeBuilder().append(tableName).append(region).append(columnFamily)
084      .append(hfilePath).append(rowKey).toHashCode();
085  }
086
087  @Override
088  public String toString() {
089    return new ToStringBuilder(this, ToStringStyle.NO_CLASS_NAME_STYLE)
090      .append("tableName", tableName).append("region", region).append("columnFamily", columnFamily)
091      .append("hfilePath", hfilePath).append("rowKey", rowKey).toString();
092  }
093}