Fix treatment of NNHAStatusHeartbeat in protobuffer.

Committing without pre-commit review since it's a pretty trivial merge fix


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-1623@1214543 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2011-12-14 23:28:43 +00:00
parent 8134b1c870
commit ecdf9da770
2 changed files with 20 additions and 0 deletions

View File

@ -116,6 +116,7 @@ public class DatanodeProtocolServerSideTranslatorPB implements
} }
} }
} }
builder.setHaStatus(PBHelper.convert(response.getNameNodeHaState()));
return builder.build(); return builder.build();
} }

View File

@ -1259,4 +1259,23 @@ public class PBHelper {
throw new IllegalArgumentException("Unexpected NNHAStatusHeartbeat.State:" + s.getState()); throw new IllegalArgumentException("Unexpected NNHAStatusHeartbeat.State:" + s.getState());
} }
} }
public static NNHAStatusHeartbeatProto convert(NNHAStatusHeartbeat hb) {
if (hb == null) return null;
NNHAStatusHeartbeatProto.Builder builder =
NNHAStatusHeartbeatProto.newBuilder();
switch (hb.getState()) {
case ACTIVE:
builder.setState(NNHAStatusHeartbeatProto.State.ACTIVE);
break;
case STANDBY:
builder.setState(NNHAStatusHeartbeatProto.State.STANDBY);
break;
default:
throw new IllegalArgumentException("Unexpected NNHAStatusHeartbeat.State:" +
hb.getState());
}
builder.setTxid(hb.getTxId());
return builder.build();
}
} }