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  private final long timestamp;
038
039  public BulkLoad(TableName tableName, String region, String columnFamily, String hfilePath,
040    byte[] rowKey, long timestamp) {
041    this.tableName = tableName;
042    this.region = region;
043    this.columnFamily = columnFamily;
044    this.hfilePath = hfilePath;
045    this.rowKey = rowKey;
046    this.timestamp = timestamp;
047  }
048
049  public TableName getTableName() {
050    return tableName;
051  }
052
053  public String getRegion() {
054    return region;
055  }
056
057  public String getColumnFamily() {
058    return columnFamily;
059  }
060
061  public String getHfilePath() {
062    return hfilePath;
063  }
064
065  public byte[] getRowKey() {
066    return rowKey;
067  }
068
069  public long getTimestamp() {
070    return timestamp;
071  }
072
073  @Override
074  public boolean equals(Object o) {
075    if (this == o) {
076      return true;
077    }
078    if (!(o instanceof BulkLoad)) {
079      return false;
080    }
081    BulkLoad that = (BulkLoad) o;
082    return new EqualsBuilder().append(tableName, that.tableName).append(region, that.region)
083      .append(columnFamily, that.columnFamily).append(hfilePath, that.hfilePath)
084      .append(rowKey, that.rowKey).append(timestamp, that.timestamp).isEquals();
085  }
086
087  @Override
088  public int hashCode() {
089    return new HashCodeBuilder().append(tableName).append(region).append(columnFamily)
090      .append(hfilePath).append(rowKey).append(timestamp).toHashCode();
091  }
092
093  @Override
094  public String toString() {
095    return new ToStringBuilder(this, ToStringStyle.NO_CLASS_NAME_STYLE)
096      .append("tableName", tableName).append("region", region).append("columnFamily", columnFamily)
097      .append("hfilePath", hfilePath).append("rowKey", rowKey).append("timestamp", timestamp)
098      .toString();
099  }
100}