HBASE-994 IPC interfaces with different versions can cause problems
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@713217 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cbb74b4630
commit
b396f6b5f6
|
@ -10,6 +10,7 @@ Release 0.19.0 - Unreleased
|
|||
HBASE-953 Enable BLOCKCACHE by default [WAS -> Reevaluate HBASE-288 block
|
||||
caching work....?] -- Update your hbad-default.xml file!
|
||||
HBASE-636 java6 as a requirement
|
||||
HBASE-994 IPC interfaces with different versions can cause problems
|
||||
|
||||
BUG FIXES
|
||||
HBASE-891 HRS.validateValuesLength throws IOE, gets caught in the retries
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitor;
|
|||
import org.apache.hadoop.hbase.io.BatchUpdate;
|
||||
import org.apache.hadoop.hbase.io.Cell;
|
||||
import org.apache.hadoop.hbase.io.RowResult;
|
||||
import org.apache.hadoop.hbase.ipc.HBaseRPCProtocolVersion;
|
||||
import org.apache.hadoop.hbase.ipc.HMasterInterface;
|
||||
import org.apache.hadoop.hbase.ipc.HRegionInterface;
|
||||
import org.apache.hadoop.hbase.ipc.HbaseRPC;
|
||||
|
@ -192,7 +193,7 @@ public class HConnectionManager implements HConstants {
|
|||
DEFAULT_MASTER_ADDRESS));
|
||||
try {
|
||||
HMasterInterface tryMaster = (HMasterInterface)HbaseRPC.getProxy(
|
||||
HMasterInterface.class, HMasterInterface.versionID,
|
||||
HMasterInterface.class, HBaseRPCProtocolVersion.versionID,
|
||||
masterLocation.getInetSocketAddress(), this.conf);
|
||||
|
||||
if (tryMaster.isMasterRunning()) {
|
||||
|
@ -729,25 +730,10 @@ public class HConnectionManager implements HConstants {
|
|||
// See if we already have a connection
|
||||
server = this.servers.get(regionServer.toString());
|
||||
if (server == null) { // Get a connection
|
||||
long versionId = 0;
|
||||
try {
|
||||
versionId =
|
||||
serverInterfaceClass.getDeclaredField("versionID").getLong(server);
|
||||
} catch (IllegalAccessException e) {
|
||||
// Should never happen unless visibility of versionID changes
|
||||
throw new UnsupportedOperationException(
|
||||
"Unable to open a connection to a " +
|
||||
serverInterfaceClass.getName() + " server.", e);
|
||||
} catch (NoSuchFieldException e) {
|
||||
// Should never happen unless versionID field name changes in HRegionInterface
|
||||
throw new UnsupportedOperationException(
|
||||
"Unable to open a connection to a " +
|
||||
serverInterfaceClass.getName() + " server.", e);
|
||||
}
|
||||
|
||||
try {
|
||||
server = (HRegionInterface)HbaseRPC.waitForProxy(serverInterfaceClass,
|
||||
versionId, regionServer.getInetSocketAddress(), this.conf,
|
||||
server = (HRegionInterface)HbaseRPC.waitForProxy(
|
||||
serverInterfaceClass, HBaseRPCProtocolVersion.versionID,
|
||||
regionServer.getInetSocketAddress(), this.conf,
|
||||
this.maxRPCAttempts);
|
||||
} catch (RemoteException e) {
|
||||
throw RemoteExceptionHandler.decodeRemoteException(e);
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* Copyright 2008 The Apache Software Foundation
|
||||
*
|
||||
* 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.ipc;
|
||||
|
||||
import org.apache.hadoop.ipc.VersionedProtocol;
|
||||
|
||||
/**
|
||||
* There is one version id for all the RPC interfaces. If any interface
|
||||
* is changed, the versionID must be changed here.
|
||||
*/
|
||||
public interface HBaseRPCProtocolVersion extends VersionedProtocol {
|
||||
/**
|
||||
* Interface version.
|
||||
*
|
||||
* HMasterInterface version history:
|
||||
* <ul>
|
||||
* <li>Version was incremented to 2 when we brought the hadoop RPC local to
|
||||
* hbase HADOOP-2495</li>
|
||||
* <li>Version was incremented to 3 when we changed the RPC to send codes
|
||||
* instead of actual class names (HADOOP-2519).</li>
|
||||
* <li>Version 4 when we moved to all byte arrays (HBASE-42).</li>
|
||||
* <li>Version 5 HBASE-576.</li>
|
||||
* <li>Version 6 modifyTable.</li>
|
||||
* </ul>
|
||||
* <p>HMasterRegionInterface version history:
|
||||
* <ul>
|
||||
* <li>Version 2 was when the regionServerStartup was changed to return a
|
||||
* MapWritable instead of a HbaseMapWritable as part of HBASE-82 changes.</li>
|
||||
* <li>Version 3 was when HMsg was refactored so it could carry optional
|
||||
* messages (HBASE-504).</li>
|
||||
* <li>HBASE-576 we moved this to 4.</li>
|
||||
* </ul>
|
||||
* <p>HRegionInterface version history:
|
||||
* <ul>
|
||||
* <li>Upped to 5 when we added scanner caching</li>
|
||||
* <li>HBASE-576, we moved this to 6.</li>
|
||||
* </ul>
|
||||
* <p>TransactionalRegionInterface version history:
|
||||
* <ul>
|
||||
* <li>Moved to 2 for hbase-576.</li>
|
||||
* </ul>
|
||||
* <p>Unified RPC version number history:
|
||||
* <ul>
|
||||
* <li>Version 10: initial version (had to be > all other RPC versions</li>
|
||||
* </ul>
|
||||
*/
|
||||
public static final long versionID = 10L;
|
||||
|
||||
}
|
|
@ -25,24 +25,17 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
|
|||
import org.apache.hadoop.hbase.HServerAddress;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.io.Writable;
|
||||
import org.apache.hadoop.ipc.VersionedProtocol;
|
||||
|
||||
/**
|
||||
* Clients interact with the HMasterInterface to gain access to meta-level
|
||||
* HBase functionality, like finding an HRegionServer and creating/destroying
|
||||
* tables.
|
||||
*
|
||||
* <p>NOTE: if you change the interface, you must change the RPC version
|
||||
* number in HBaseRPCProtocolVersion
|
||||
*
|
||||
*/
|
||||
public interface HMasterInterface extends VersionedProtocol {
|
||||
/**
|
||||
* Interface version.
|
||||
* Version was incremented to 2 when we brought the hadoop RPC local to hbase
|
||||
* -- HADOOP-2495 and then to 3 when we changed the RPC to send codes instead
|
||||
* of actual class names (HADOOP-2519).
|
||||
* <p>Version 4 when we moved to all byte arrays (HBASE-42).
|
||||
* <p>Version 5 HBASE-576.
|
||||
* <p>Version 6 modifyTable.
|
||||
*/
|
||||
public static final long versionID = 6L;
|
||||
public interface HMasterInterface extends HBaseRPCProtocolVersion {
|
||||
|
||||
/** @return true if master is available */
|
||||
public boolean isMasterRunning();
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.apache.hadoop.hbase.ipc;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.apache.hadoop.io.MapWritable;
|
||||
import org.apache.hadoop.ipc.VersionedProtocol;
|
||||
import org.apache.hadoop.hbase.HServerInfo;
|
||||
import org.apache.hadoop.hbase.HMsg;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
|
@ -32,17 +31,12 @@ import org.apache.hadoop.hbase.HServerAddress;
|
|||
* HRegionServers interact with the HMasterRegionInterface to report on local
|
||||
* goings-on and to obtain data-handling instructions from the HMaster.
|
||||
* <p>Changes here need to be reflected in HbaseObjectWritable HbaseRPC#Invoker.
|
||||
*
|
||||
* <p>NOTE: if you change the interface, you must change the RPC version
|
||||
* number in HBaseRPCProtocolVersion
|
||||
*
|
||||
*/
|
||||
public interface HMasterRegionInterface extends VersionedProtocol {
|
||||
/**
|
||||
* Interface version number.
|
||||
* Version 2 was when the regionServerStartup was changed to return a
|
||||
* MapWritable instead of a HbaseMapWritable as part of HBASE-82 changes.
|
||||
* Version 3 was when HMsg was refactored so it could carry optional
|
||||
* messages (HBASE-504).
|
||||
* <p>HBASE-576 we moved this to 4.
|
||||
*/
|
||||
public static final long versionID = 4L;
|
||||
public interface HMasterRegionInterface extends HBaseRPCProtocolVersion {
|
||||
|
||||
/**
|
||||
* Called when a region server first starts
|
||||
|
|
|
@ -26,20 +26,17 @@ import org.apache.hadoop.hbase.io.BatchUpdate;
|
|||
import org.apache.hadoop.hbase.io.Cell;
|
||||
import org.apache.hadoop.hbase.io.RowResult;
|
||||
|
||||
import org.apache.hadoop.ipc.VersionedProtocol;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.NotServingRegionException;
|
||||
|
||||
/**
|
||||
* Clients interact with HRegionServers using a handle to the HRegionInterface.
|
||||
*
|
||||
* <p>NOTE: if you change the interface, you must change the RPC version
|
||||
* number in HBaseRPCProtocolVersion
|
||||
*
|
||||
*/
|
||||
public interface HRegionInterface extends VersionedProtocol {
|
||||
/**
|
||||
* Protocol version.
|
||||
* Upped to 5 when we added scanner caching
|
||||
* <p>HBASE-576, we moved this to 6.
|
||||
*/
|
||||
public static final long versionID = 6L;
|
||||
public interface HRegionInterface extends HBaseRPCProtocolVersion {
|
||||
|
||||
/**
|
||||
* Get metainfo about an HRegion
|
||||
|
@ -113,6 +110,7 @@ public interface HRegionInterface extends VersionedProtocol {
|
|||
* @param regionName name of the region to update
|
||||
* @param b BatchUpdate[]
|
||||
* @throws IOException
|
||||
* @return number of updates applied
|
||||
*/
|
||||
public int batchUpdates(final byte[] regionName, final BatchUpdate[] b)
|
||||
throws IOException;
|
||||
|
|
|
@ -27,12 +27,11 @@ import org.apache.hadoop.hbase.io.RowResult;
|
|||
/**
|
||||
* Interface for transactional region servers.
|
||||
*
|
||||
* <p>NOTE: if you change the interface, you must change the RPC version
|
||||
* number in HBaseRPCProtocolVersion
|
||||
*
|
||||
*/
|
||||
public interface TransactionalRegionInterface extends HRegionInterface {
|
||||
/** Interface version number
|
||||
* Moved to 2 for hbase-576.
|
||||
*/
|
||||
public static final long versionID = 2L;
|
||||
|
||||
/**
|
||||
* Sent to initiate a transaction.
|
||||
|
|
|
@ -59,6 +59,7 @@ import org.apache.hadoop.hbase.client.ServerConnectionManager;
|
|||
import org.apache.hadoop.hbase.io.Cell;
|
||||
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
|
||||
import org.apache.hadoop.hbase.io.RowResult;
|
||||
import org.apache.hadoop.hbase.ipc.HBaseRPCProtocolVersion;
|
||||
import org.apache.hadoop.hbase.ipc.HMasterInterface;
|
||||
import org.apache.hadoop.hbase.ipc.HMasterRegionInterface;
|
||||
import org.apache.hadoop.hbase.ipc.HRegionInterface;
|
||||
|
@ -90,16 +91,9 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
|||
|
||||
static final Log LOG = LogFactory.getLog(HMaster.class.getName());
|
||||
|
||||
public long getProtocolVersion(String protocol,
|
||||
@SuppressWarnings("unused") long clientVersion)
|
||||
throws IOException {
|
||||
if (protocol.equals(HMasterInterface.class.getName())) {
|
||||
return HMasterInterface.versionID;
|
||||
} else if (protocol.equals(HMasterRegionInterface.class.getName())) {
|
||||
return HMasterRegionInterface.versionID;
|
||||
} else {
|
||||
throw new IOException("Unknown protocol to name node: " + protocol);
|
||||
}
|
||||
public long getProtocolVersion(@SuppressWarnings("unused") String protocol,
|
||||
@SuppressWarnings("unused") long clientVersion) {
|
||||
return HBaseRPCProtocolVersion.versionID;
|
||||
}
|
||||
|
||||
// We start out with closed flag on. Using AtomicBoolean rather than
|
||||
|
|
|
@ -81,6 +81,7 @@ import org.apache.hadoop.hbase.io.BatchUpdate;
|
|||
import org.apache.hadoop.hbase.io.Cell;
|
||||
import org.apache.hadoop.hbase.io.HbaseMapWritable;
|
||||
import org.apache.hadoop.hbase.io.RowResult;
|
||||
import org.apache.hadoop.hbase.ipc.HBaseRPCProtocolVersion;
|
||||
import org.apache.hadoop.hbase.ipc.HMasterRegionInterface;
|
||||
import org.apache.hadoop.hbase.ipc.HRegionInterface;
|
||||
import org.apache.hadoop.hbase.ipc.HbaseRPC;
|
||||
|
@ -783,7 +784,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
|
|||
// Do initial RPC setup. The final argument indicates that the RPC
|
||||
// should retry indefinitely.
|
||||
master = (HMasterRegionInterface)HbaseRPC.waitForProxy(
|
||||
HMasterRegionInterface.class, HMasterRegionInterface.versionID,
|
||||
HMasterRegionInterface.class, HBaseRPCProtocolVersion.versionID,
|
||||
new HServerAddress(conf.get(MASTER_ADDRESS)).getInetSocketAddress(),
|
||||
this.conf, -1);
|
||||
} catch (IOException e) {
|
||||
|
@ -1072,7 +1073,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
|
|||
private static class RegionCloserThread extends Thread {
|
||||
private final HRegion r;
|
||||
|
||||
public RegionCloserThread(final HRegion r) {
|
||||
protected RegionCloserThread(final HRegion r) {
|
||||
super(Thread.currentThread().getName() + ".regionCloser." + r.toString());
|
||||
this.r = r;
|
||||
}
|
||||
|
@ -1790,7 +1791,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
|
|||
@SuppressWarnings("unused") final long clientVersion)
|
||||
throws IOException {
|
||||
if (protocol.equals(HRegionInterface.class.getName())) {
|
||||
return HRegionInterface.versionID;
|
||||
return HBaseRPCProtocolVersion.versionID;
|
||||
}
|
||||
throw new IOException("Unknown protocol to name node: " + protocol);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.apache.hadoop.hbase.io.BatchUpdate;
|
|||
import org.apache.hadoop.hbase.io.Cell;
|
||||
import org.apache.hadoop.hbase.io.HbaseMapWritable;
|
||||
import org.apache.hadoop.hbase.io.RowResult;
|
||||
import org.apache.hadoop.hbase.ipc.HBaseRPCProtocolVersion;
|
||||
import org.apache.hadoop.hbase.ipc.TransactionalRegionInterface;
|
||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
||||
|
@ -86,7 +87,7 @@ public class TransactionalRegionServer extends HRegionServer implements
|
|||
public long getProtocolVersion(final String protocol, final long clientVersion)
|
||||
throws IOException {
|
||||
if (protocol.equals(TransactionalRegionInterface.class.getName())) {
|
||||
return TransactionalRegionInterface.versionID;
|
||||
return HBaseRPCProtocolVersion.versionID;
|
||||
}
|
||||
return super.getProtocolVersion(protocol, clientVersion);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue