Example usage for org.apache.hadoop.io VersionMismatchException toString

List of usage examples for org.apache.hadoop.io VersionMismatchException toString

Introduction

In this page you can find the example usage for org.apache.hadoop.io VersionMismatchException toString.

Prototype

@Override
public String toString() 

Source Link

Document

Returns a string representation of this object.

Usage

From source file:com.hortonworks.hbase.replication.bridge.Invocation.java

License:Apache License

public void readFields(DataInput in) throws IOException {
    try {// w  w w .j a  v  a  2  s  . co  m
        super.readFields(in);
        methodName = in.readUTF();
        clientVersion = in.readLong();
        clientMethodsHash = in.readInt();
    } catch (VersionMismatchException e) {
        // VersionMismatchException doesn't provide an API to access
        // expectedVersion and foundVersion.  This is really sad.
        if (e.toString().endsWith("found v0")) {
            // Try to be a bit backwards compatible.  In previous versions of
            // HBase (before HBASE-3939 in 0.92) Invocation wasn't a
            // VersionedWritable and thus the first thing on the wire was always
            // the 2-byte length of the method name.  Because no method name is
            // longer than 255 characters, and all method names are in ASCII,
            // The following code is equivalent to `in.readUTF()', which we can't
            // call again here, because `super.readFields(in)' already consumed
            // the first byte of input, which can't be "unread" back into `in'.
            final short len = (short) (in.readByte() & 0xFF); // Unsigned byte.
            final byte[] buf = new byte[len];
            in.readFully(buf, 0, len);
            methodName = new String(buf);
        }
    }
    parameters = new Object[in.readInt()];
    parameterClasses = new Class[parameters.length];
    HbaseObjectWritable objectWritable = new HbaseObjectWritable();
    for (int i = 0; i < parameters.length; i++) {
        parameters[i] = HbaseObjectWritable.readObject(in, objectWritable, this.conf);
        parameterClasses[i] = objectWritable.getDeclaredClass();
    }
}