Index: src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (revision 1465359) +++ src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (working copy) @@ -146,6 +146,7 @@ import org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException; import org.apache.hadoop.hbase.regionserver.wal.HLog; import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener; +import org.apache.hadoop.hbase.replication.regionserver.SinkServiceUnavailableException; import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.CompressionTest; @@ -3983,7 +3984,11 @@ public void replicateLogEntries(final HLog.Entry[] entries) throws IOException { checkOpen(); - if (this.replicationSinkHandler == null) return; + if (this.replicationSinkHandler == null) { + LOG.warn("ReplicationSink service is not initialized. hbase.replication may not be configured correctly."); + throw new SinkServiceUnavailableException( + "ReplicationSink service was not initialized"); + } this.replicationSinkHandler.replicateLogEntries(entries); } Index: src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java (revision 1465359) +++ src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java (working copy) @@ -404,7 +404,7 @@ } catch (IOException e) { LOG.warn(peerClusterZnode + " Got while getting file size: ", e); } - } else if (currentNbEntries != 0) { + } else if (currentNbEntries == 0) { LOG.warn(peerClusterZnode + " Got EOF while reading, " + "looks like this file is broken? " + currentPath); considerDumping = true; @@ -715,13 +715,23 @@ this.metrics.refreshAgeOfLastShippedOp(); if (ioe instanceof RemoteException) { ioe = ((RemoteException) ioe).unwrapRemoteException(); - LOG.warn("Can't replicate because of an error on the remote cluster: ", ioe); + boolean shouldSleep = false; + String msg = null; if (ioe instanceof TableNotFoundException) { - if (sleepForRetries("A table is missing in the peer cluster. " - + "Replication cannot proceed without losing data.", sleepMultiplier)) { - sleepMultiplier++; - } + shouldSleep = true; + msg = "A table is missing in the peer cluster. Replication cannot proceed without losing data."; + // Need not to print the error stack trace. + LOG.warn("Can't replicate because of a table is missing in the peer cluster."); + } else if (ioe instanceof SinkServiceUnavailableException) { + shouldSleep = true; + msg = "SinkService is unavailable."; + LOG.warn("Can't replicate because of SinkSevice is unavailable on the remote cluster."); + } else { + LOG.warn("Can't replicate because of an error on the remote cluster: ", ioe); } + if (shouldSleep && sleepForRetries(msg, sleepMultiplier)) { + sleepMultiplier++; + } } else { if (ioe instanceof SocketTimeoutException) { // This exception means we waited for more than 60s and nothing Index: src/main/java/org/apache/hadoop/hbase/replication/regionserver/SinkServiceUnavailableException.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/replication/regionserver/SinkServiceUnavailableException.java (revision 0) +++ src/main/java/org/apache/hadoop/hbase/replication/regionserver/SinkServiceUnavailableException.java (working copy) @@ -0,0 +1,47 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.replication.regionserver; + +import java.io.IOException; + +/** + * Thrown by a region server if it is sent a replication request but SinkService + * is not started yet. + */ +public class SinkServiceUnavailableException extends IOException { + + /** + * serialVersionUID + */ + private static final long serialVersionUID = -2938938013388635709L; + + /** + * Default constructor + */ + public SinkServiceUnavailableException() { + super(); + } + + /** + * Constructor + * @param msg message + */ + public SinkServiceUnavailableException(String msg) { + super(msg); + } +}