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.replication; 019 020import java.util.UUID; 021import org.apache.hadoop.hbase.Cell; 022import org.apache.hadoop.hbase.CellUtil; 023import org.apache.hadoop.hbase.wal.WAL; 024import org.apache.yetus.audience.InterfaceAudience; 025 026/** 027 * A dummy {@link ReplicationEndpoint} that replicates nothing. 028 * <p/> 029 * Mainly used by ITBLL to check whether all the entries in WAL files are fine, since for normal 030 * case, we will only read the WAL files when there are region servers crash and we need to split 031 * the log, but for replication we will read all the entries and pass them to the 032 * {@link ReplicationEndpoint}, so setting up a replication peer can help finding out whether there 033 * are broken entries in WAL files. 034 */ 035@InterfaceAudience.Private 036public class VerifyWALEntriesReplicationEndpoint extends BaseReplicationEndpoint { 037 038 @Override 039 public boolean canReplicateToSameCluster() { 040 return true; 041 } 042 043 @Override 044 public UUID getPeerUUID() { 045 return ctx.getClusterId(); 046 } 047 048 @Override 049 public WALEntryFilter getWALEntryfilter() { 050 return null; 051 } 052 053 private void checkCell(Cell cell) { 054 // check whether all the fields are fine 055 CellUtil.cloneRow(cell); 056 CellUtil.cloneFamily(cell); 057 CellUtil.cloneQualifier(cell); 058 CellUtil.cloneValue(cell); 059 } 060 061 @Override 062 public boolean replicate(ReplicateContext replicateContext) { 063 replicateContext.entries.stream().map(WAL.Entry::getEdit).flatMap(e -> e.getCells().stream()) 064 .forEach(this::checkCell); 065 return true; 066 } 067 068 @Override 069 public void start() { 070 startAsync(); 071 } 072 073 @Override 074 public void stop() { 075 stopAsync(); 076 } 077 078 @Override 079 protected void doStart() { 080 notifyStarted(); 081 } 082 083 @Override 084 protected void doStop() { 085 notifyStopped(); 086 } 087}