HBASE-19720 Rename WALKey#getTabnename to WALKey#getTableName

This commit is contained in:
Chia-Ping Tsai 2018-02-02 20:02:04 +08:00
parent b2fe241089
commit b0bf6f504e
18 changed files with 30 additions and 32 deletions

View File

@ -109,7 +109,7 @@ public class WALPlayer extends Configured implements Tool {
throws IOException {
try {
// skip all other tables
if (Bytes.equals(table, key.getTablename().getName())) {
if (Bytes.equals(table, key.getTableName().getName())) {
for (Cell cell : value.getCells()) {
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
if (WALEdit.isMetaEditFamily(kv)) {
@ -150,7 +150,7 @@ public class WALPlayer extends Configured implements Tool {
throws IOException {
try {
// skip all other tables
if (Bytes.equals(table, key.getTablename().getName())) {
if (Bytes.equals(table, key.getTableName().getName())) {
for (Cell cell : value.getCells()) {
if (WALEdit.isMetaEditFamily(cell)) {
continue;
@ -190,10 +190,10 @@ public class WALPlayer extends Configured implements Tool {
public void map(WALKey key, WALEdit value, Context context)
throws IOException {
try {
if (tables.isEmpty() || tables.containsKey(key.getTablename())) {
if (tables.isEmpty() || tables.containsKey(key.getTableName())) {
TableName targetTable = tables.isEmpty() ?
key.getTablename() :
tables.get(key.getTablename());
key.getTableName() :
tables.get(key.getTableName());
ImmutableBytesWritable tableOut = new ImmutableBytesWritable(targetTable.getName());
Put put = null;
Delete del = null;

View File

@ -794,7 +794,7 @@ public class TestCellBasedImportExport2 {
@Override
public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit) {
if (logKey.getTablename().getNameAsString().equalsIgnoreCase(
if (logKey.getTableName().getNameAsString().equalsIgnoreCase(
this.regionInfo.getTable().getNameAsString()) && (!logEdit.isMetaEdit())) {
isVisited = true;
}

View File

@ -173,7 +173,7 @@ public class TestCellBasedWALPlayer2 {
configuration.set(tableConfigKey, "table");
WALCellMapper mapper = new WALCellMapper();
WALKey key = mock(WALKey.class);
when(key.getTablename()).thenReturn(TableName.valueOf("table"));
when(key.getTableName()).thenReturn(TableName.valueOf("table"));
@SuppressWarnings("unchecked")
Mapper<WALKey, WALEdit, ImmutableBytesWritable, Cell>.Context context = mock(Context.class);
when(context.getConfiguration()).thenReturn(configuration);

View File

@ -794,7 +794,7 @@ public class TestImportExport {
@Override
public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit) {
if (logKey.getTablename().getNameAsString().equalsIgnoreCase(
if (logKey.getTableName().getNameAsString().equalsIgnoreCase(
this.regionInfo.getTable().getNameAsString()) && (!logEdit.isMetaEdit())) {
isVisited = true;
}

View File

@ -173,7 +173,7 @@ public class TestWALPlayer {
configuration.set(tableConfigKey, "table");
WALKeyValueMapper mapper = new WALKeyValueMapper();
WALKey key = mock(WALKey.class);
when(key.getTablename()).thenReturn(TableName.valueOf("table"));
when(key.getTableName()).thenReturn(TableName.valueOf("table"));
@SuppressWarnings("unchecked")
Mapper<WALKey, WALEdit, ImmutableBytesWritable, KeyValue>.Context context = mock(Context.class);
when(context.getConfiguration()).thenReturn(configuration);

View File

@ -46,7 +46,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.wal.WAL.Entry;
import org.apache.hadoop.hbase.wal.WALKey;
@InterfaceAudience.Private
public class ReplicationProtbufUtil {
@ -116,7 +115,7 @@ public class ReplicationProtbufUtil {
UnsafeByteOperations.unsafeWrap(encodedRegionName == null
? key.getEncodedRegionName()
: encodedRegionName));
keyBuilder.setTableName(UnsafeByteOperations.unsafeWrap(key.getTablename().getName()));
keyBuilder.setTableName(UnsafeByteOperations.unsafeWrap(key.getTableName().getName()));
long sequenceId = key.getSequenceId();
keyBuilder.setLogSequenceNumber(sequenceId);
keyBuilder.setWriteTime(key.getWriteTime());

View File

@ -100,7 +100,7 @@ public abstract class ReaderBase implements AbstractFSWALProvider.Reader {
try {
hasEntry = readNext(e);
} catch (IllegalArgumentException iae) {
TableName tableName = e.getKey().getTablename();
TableName tableName = e.getKey().getTableName();
if (tableName != null && tableName.equals(TableName.OLD_ROOT_TABLE_NAME)) {
// It is old ROOT table edit, ignore it
LOG.info("Got an old ROOT edit, ignoring ");

View File

@ -57,7 +57,7 @@ public class NamespaceTableCfWALEntryFilter implements WALEntryFilter, WALCellFi
@Override
public Entry filter(Entry entry) {
TableName tabName = entry.getKey().getTablename();
TableName tabName = entry.getKey().getTableName();
String namespace = tabName.getNamespaceAsString();
ReplicationPeerConfig peerConfig = this.peer.getPeerConfig();
@ -110,10 +110,10 @@ public class NamespaceTableCfWALEntryFilter implements WALEntryFilter, WALCellFi
if (CellUtil.matchingColumn(cell, WALEdit.METAFAMILY, WALEdit.BULK_LOAD)) {
cell = bulkLoadFilter.filterCell(cell,
fam -> filterByExcludeTableCfs(entry.getKey().getTablename(), Bytes.toString(fam),
fam -> filterByExcludeTableCfs(entry.getKey().getTableName(), Bytes.toString(fam),
excludeTableCfs));
} else {
if (filterByExcludeTableCfs(entry.getKey().getTablename(),
if (filterByExcludeTableCfs(entry.getKey().getTableName(),
Bytes.toString(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength()),
excludeTableCfs)) {
return null;
@ -130,9 +130,9 @@ public class NamespaceTableCfWALEntryFilter implements WALEntryFilter, WALCellFi
if (CellUtil.matchingColumn(cell, WALEdit.METAFAMILY, WALEdit.BULK_LOAD)) {
cell = bulkLoadFilter.filterCell(cell,
fam -> filterByTableCfs(entry.getKey().getTablename(), Bytes.toString(fam), tableCfs));
fam -> filterByTableCfs(entry.getKey().getTableName(), Bytes.toString(fam), tableCfs));
} else {
if (filterByTableCfs(entry.getKey().getTablename(),
if (filterByTableCfs(entry.getKey().getTableName(),
Bytes.toString(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength()),
tableCfs)) {
return null;

View File

@ -28,7 +28,7 @@ import org.apache.hadoop.hbase.wal.WAL.Entry;
public class SystemTableWALEntryFilter implements WALEntryFilter {
@Override
public Entry filter(Entry entry) {
if (entry.getKey().getTablename().isSystemTable()) {
if (entry.getKey().getTableName().isSystemTable()) {
return null;
}
return entry;

View File

@ -258,7 +258,7 @@ public class HBaseInterClusterReplicationEndpoint extends HBaseReplicationEndpoi
ArrayList<Entry> thisList = new ArrayList<Entry>(entries.size());
entryLists.add(thisList);
for (Entry e : entries) {
if (!e.getKey().getTablename().equals(table)) {
if (!e.getKey().getTableName().equals(table)) {
thisList.add(e);
}
}

View File

@ -29,7 +29,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
import java.util.UUID;
@ -57,7 +56,7 @@ public interface WALKey extends SequenceId, Comparable<WALKey> {
/**
* @return table name
*/
TableName getTablename();
TableName getTableName();
/**
* @return the write time
@ -96,7 +95,7 @@ public interface WALKey extends SequenceId, Comparable<WALKey> {
*/
default Map<String, Object> toStringMap() {
Map<String, Object> stringMap = new HashMap<>();
stringMap.put("table", getTablename());
stringMap.put("table", getTableName());
stringMap.put("region", Bytes.toStringBinary(getEncodedRegionName()));
stringMap.put("sequence", getSequenceId());
return stringMap;

View File

@ -352,7 +352,7 @@ public class WALKeyImpl implements WALKey {
/** @return table name */
@Override
public TableName getTablename() {
public TableName getTableName() {
return tablename;
}

View File

@ -469,7 +469,7 @@ public class WALSplitter {
static Path getRegionSplitEditsPath(final FileSystem fs,
final Entry logEntry, final Path rootDir, String fileNameBeingSplit)
throws IOException {
Path tableDir = FSUtils.getTableDir(rootDir, logEntry.getKey().getTablename());
Path tableDir = FSUtils.getTableDir(rootDir, logEntry.getKey().getTableName());
String encodedRegionName = Bytes.toString(logEntry.getKey().getEncodedRegionName());
Path regiondir = HRegion.getRegionDir(tableDir, encodedRegionName);
Path dir = getRegionDirRecoveredEditsDir(regiondir);
@ -876,7 +876,7 @@ public class WALSplitter {
synchronized (this) {
buffer = buffers.get(key.getEncodedRegionName());
if (buffer == null) {
buffer = new RegionEntryBuffer(key.getTablename(), key.getEncodedRegionName());
buffer = new RegionEntryBuffer(key.getTableName(), key.getEncodedRegionName());
buffers.put(key.getEncodedRegionName(), buffer);
}
incrHeap= buffer.appendEntry(entry);

View File

@ -600,7 +600,7 @@ public class SimpleRegionObserver implements RegionCoprocessor, RegionObserver {
@Override
public void preWALRestore(ObserverContext<? extends RegionCoprocessorEnvironment> env,
RegionInfo info, WALKey logKey, WALEdit logEdit) throws IOException {
String tableName = logKey.getTablename().getNameAsString();
String tableName = logKey.getTableName().getNameAsString();
if (tableName.equals(TABLE_SKIPPED)) {
// skip recovery of TABLE_SKIPPED for testing purpose
env.bypass();

View File

@ -590,14 +590,14 @@ public class TestWALLockup {
@Override
public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit)
throws IOException {
if (logKey.getTablename().getNameAsString().equalsIgnoreCase("sleep")) {
if (logKey.getTableName().getNameAsString().equalsIgnoreCase("sleep")) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
if (logKey.getTablename().getNameAsString()
if (logKey.getTableName().getNameAsString()
.equalsIgnoreCase("DamagedWALException")) {
throw new DamagedWALException("Failed appending");
}

View File

@ -178,7 +178,7 @@ public abstract class AbstractTestProtobufLog<W extends Closeable> {
assertNotNull(entry);
assertEquals(columnCount, entry.getEdit().size());
assertArrayEquals(hri.getEncodedNameAsBytes(), entry.getKey().getEncodedRegionName());
assertEquals(tableName, entry.getKey().getTablename());
assertEquals(tableName, entry.getKey().getTableName());
int idx = 0;
for (Cell val : entry.getEdit().getCells()) {
assertTrue(Bytes.equals(row, 0, row.length, val.getRowArray(), val.getRowOffset(),

View File

@ -167,7 +167,7 @@ public class TestRegionReplicaReplicationEndpointNoMaster {
public void postWALWrite(ObserverContext<? extends WALCoprocessorEnvironment> ctx,
RegionInfo info, WALKey logKey, WALEdit logEdit) throws IOException {
// only keep primary region's edits
if (logKey.getTablename().equals(tableName) && info.getReplicaId() == 0) {
if (logKey.getTableName().equals(tableName) && info.getReplicaId() == 0) {
// Presume type is a WALKeyImpl
entries.add(new Entry((WALKeyImpl)logKey, logEdit));
}

View File

@ -536,7 +536,7 @@ public class TestWALFactory {
WALKey key = entry.getKey();
WALEdit val = entry.getEdit();
assertTrue(Bytes.equals(info.getEncodedNameAsBytes(), key.getEncodedRegionName()));
assertTrue(htd.getTableName().equals(key.getTablename()));
assertTrue(htd.getTableName().equals(key.getTableName()));
Cell cell = val.getCells().get(0);
assertTrue(Bytes.equals(row, 0, row.length, cell.getRowArray(), cell.getRowOffset(),
cell.getRowLength()));
@ -592,7 +592,7 @@ public class TestWALFactory {
for (Cell val : entry.getEdit().getCells()) {
assertTrue(Bytes.equals(hri.getEncodedNameAsBytes(),
entry.getKey().getEncodedRegionName()));
assertTrue(htd.getTableName().equals(entry.getKey().getTablename()));
assertTrue(htd.getTableName().equals(entry.getKey().getTableName()));
assertTrue(Bytes.equals(row, 0, row.length, val.getRowArray(), val.getRowOffset(),
val.getRowLength()));
assertEquals((byte) (idx + '0'), CellUtil.cloneValue(val)[0]);