Java Code Examples for org.apache.hadoop.hdfs.server.namenode.ha.proto.HAZKInfoProtos.ActiveNodeInfo

The following examples show how to use org.apache.hadoop.hdfs.server.namenode.ha.proto.HAZKInfoProtos.ActiveNodeInfo. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hadoop   Source File: DFSZKFailoverController.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected HAServiceTarget dataToTarget(byte[] data) {
  ActiveNodeInfo proto;
  try {
    proto = ActiveNodeInfo.parseFrom(data);
  } catch (InvalidProtocolBufferException e) {
    throw new RuntimeException("Invalid data in ZK: " +
        StringUtils.byteToHexString(data));
  }
  NNHAServiceTarget ret = new NNHAServiceTarget(
      conf, proto.getNameserviceId(), proto.getNamenodeId());
  InetSocketAddress addressFromProtobuf = new InetSocketAddress(
      proto.getHostname(), proto.getPort());
  
  if (!addressFromProtobuf.equals(ret.getAddress())) {
    throw new RuntimeException("Mismatched address stored in ZK for " +
        ret + ": Stored protobuf was " + proto + ", address from our own " +
        "configuration for this NameNode was " + ret.getAddress());
  }
  
  ret.setZkfcPort(proto.getZkfcPort());
  return ret;
}
 
Example 2
Source Project: big-c   Source File: DFSZKFailoverController.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected HAServiceTarget dataToTarget(byte[] data) {
  ActiveNodeInfo proto;
  try {
    proto = ActiveNodeInfo.parseFrom(data);
  } catch (InvalidProtocolBufferException e) {
    throw new RuntimeException("Invalid data in ZK: " +
        StringUtils.byteToHexString(data));
  }
  NNHAServiceTarget ret = new NNHAServiceTarget(
      conf, proto.getNameserviceId(), proto.getNamenodeId());
  InetSocketAddress addressFromProtobuf = new InetSocketAddress(
      proto.getHostname(), proto.getPort());
  
  if (!addressFromProtobuf.equals(ret.getAddress())) {
    throw new RuntimeException("Mismatched address stored in ZK for " +
        ret + ": Stored protobuf was " + proto + ", address from our own " +
        "configuration for this NameNode was " + ret.getAddress());
  }
  
  ret.setZkfcPort(proto.getZkfcPort());
  return ret;
}
 
Example 3
Source Project: hadoop   Source File: DFSZKFailoverController.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected byte[] targetToData(HAServiceTarget target) {
  InetSocketAddress addr = target.getAddress();

  return ActiveNodeInfo.newBuilder()
    .setHostname(addr.getHostName())
    .setPort(addr.getPort())
    .setZkfcPort(target.getZKFCAddress().getPort())
    .setNameserviceId(localNNTarget.getNameServiceId())
    .setNamenodeId(localNNTarget.getNameNodeId())
    .build()
    .toByteArray();
}
 
Example 4
Source Project: big-c   Source File: DFSZKFailoverController.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected byte[] targetToData(HAServiceTarget target) {
  InetSocketAddress addr = target.getAddress();

  return ActiveNodeInfo.newBuilder()
    .setHostname(addr.getHostName())
    .setPort(addr.getPort())
    .setZkfcPort(target.getZKFCAddress().getPort())
    .setNameserviceId(localNNTarget.getNameServiceId())
    .setNamenodeId(localNNTarget.getNameNodeId())
    .build()
    .toByteArray();
}