|
@@ -26,7 +26,7 @@ import com.google.protobuf.ByteString;
|
|
|
|
|
|
import org.apache.hadoop.fs.StorageType;
|
|
import org.apache.hadoop.fs.StorageType;
|
|
import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
|
|
import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
|
|
-import org.apache.hadoop.ha.proto.HAServiceProtocolProtos;
|
|
|
|
|
|
+import org.apache.hadoop.ha.proto.HAServiceProtocolProtos.HAServiceStateProto;
|
|
import org.apache.hadoop.hdfs.DFSUtilClient;
|
|
import org.apache.hadoop.hdfs.DFSUtilClient;
|
|
import org.apache.hadoop.hdfs.protocol.Block;
|
|
import org.apache.hadoop.hdfs.protocol.Block;
|
|
import org.apache.hadoop.hdfs.protocol.DatanodeID;
|
|
import org.apache.hadoop.hdfs.protocol.DatanodeID;
|
|
@@ -338,7 +338,8 @@ public class PBHelper {
|
|
StorageInfoProto storage = info.getStorageInfo();
|
|
StorageInfoProto storage = info.getStorageInfo();
|
|
return new NamespaceInfo(storage.getNamespceID(), storage.getClusterID(),
|
|
return new NamespaceInfo(storage.getNamespceID(), storage.getClusterID(),
|
|
info.getBlockPoolID(), storage.getCTime(), info.getBuildVersion(),
|
|
info.getBlockPoolID(), storage.getCTime(), info.getBuildVersion(),
|
|
- info.getSoftwareVersion(), info.getCapabilities());
|
|
|
|
|
|
+ info.getSoftwareVersion(), info.getCapabilities(),
|
|
|
|
+ convert(info.getState()));
|
|
}
|
|
}
|
|
|
|
|
|
public static NamenodeCommand convert(NamenodeCommandProto cmd) {
|
|
public static NamenodeCommand convert(NamenodeCommandProto cmd) {
|
|
@@ -744,43 +745,68 @@ public class PBHelper {
|
|
}
|
|
}
|
|
|
|
|
|
public static NamespaceInfoProto convert(NamespaceInfo info) {
|
|
public static NamespaceInfoProto convert(NamespaceInfo info) {
|
|
- return NamespaceInfoProto.newBuilder()
|
|
|
|
- .setBlockPoolID(info.getBlockPoolID())
|
|
|
|
|
|
+ NamespaceInfoProto.Builder builder = NamespaceInfoProto.newBuilder();
|
|
|
|
+ builder.setBlockPoolID(info.getBlockPoolID())
|
|
.setBuildVersion(info.getBuildVersion())
|
|
.setBuildVersion(info.getBuildVersion())
|
|
.setUnused(0)
|
|
.setUnused(0)
|
|
.setStorageInfo(PBHelper.convert((StorageInfo)info))
|
|
.setStorageInfo(PBHelper.convert((StorageInfo)info))
|
|
.setSoftwareVersion(info.getSoftwareVersion())
|
|
.setSoftwareVersion(info.getSoftwareVersion())
|
|
- .setCapabilities(info.getCapabilities())
|
|
|
|
- .build();
|
|
|
|
|
|
+ .setCapabilities(info.getCapabilities());
|
|
|
|
+ HAServiceState state = info.getState();
|
|
|
|
+ if(state != null) {
|
|
|
|
+ builder.setState(convert(info.getState()));
|
|
|
|
+ }
|
|
|
|
+ return builder.build();
|
|
}
|
|
}
|
|
|
|
|
|
- public static NNHAStatusHeartbeat convert(NNHAStatusHeartbeatProto s) {
|
|
|
|
- if (s == null) return null;
|
|
|
|
- switch (s.getState()) {
|
|
|
|
|
|
+ public static HAServiceState convert(HAServiceStateProto s) {
|
|
|
|
+ if (s == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ switch (s) {
|
|
|
|
+ case INITIALIZING:
|
|
|
|
+ return HAServiceState.INITIALIZING;
|
|
case ACTIVE:
|
|
case ACTIVE:
|
|
- return new NNHAStatusHeartbeat(HAServiceState.ACTIVE, s.getTxid());
|
|
|
|
|
|
+ return HAServiceState.ACTIVE;
|
|
case STANDBY:
|
|
case STANDBY:
|
|
- return new NNHAStatusHeartbeat(HAServiceState.STANDBY, s.getTxid());
|
|
|
|
|
|
+ return HAServiceState.STANDBY;
|
|
default:
|
|
default:
|
|
- throw new IllegalArgumentException("Unexpected NNHAStatusHeartbeat.State:" + s.getState());
|
|
|
|
|
|
+ throw new IllegalArgumentException("Unexpected HAServiceStateProto:"
|
|
|
|
+ + s);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static HAServiceStateProto convert(HAServiceState s) {
|
|
|
|
+ if (s == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ switch (s) {
|
|
|
|
+ case INITIALIZING:
|
|
|
|
+ return HAServiceStateProto.INITIALIZING;
|
|
|
|
+ case ACTIVE:
|
|
|
|
+ return HAServiceStateProto.ACTIVE;
|
|
|
|
+ case STANDBY:
|
|
|
|
+ return HAServiceStateProto.STANDBY;
|
|
|
|
+ default:
|
|
|
|
+ throw new IllegalArgumentException("Unexpected HAServiceState:"
|
|
|
|
+ + s);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static NNHAStatusHeartbeat convert(NNHAStatusHeartbeatProto s) {
|
|
|
|
+ if (s == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ return new NNHAStatusHeartbeat(convert(s.getState()), s.getTxid());
|
|
|
|
+ }
|
|
|
|
+
|
|
public static NNHAStatusHeartbeatProto convert(NNHAStatusHeartbeat hb) {
|
|
public static NNHAStatusHeartbeatProto convert(NNHAStatusHeartbeat hb) {
|
|
- if (hb == null) return null;
|
|
|
|
- NNHAStatusHeartbeatProto.Builder builder =
|
|
|
|
- NNHAStatusHeartbeatProto.newBuilder();
|
|
|
|
- switch (hb.getState()) {
|
|
|
|
- case ACTIVE:
|
|
|
|
- builder.setState(HAServiceProtocolProtos.HAServiceStateProto.ACTIVE);
|
|
|
|
- break;
|
|
|
|
- case STANDBY:
|
|
|
|
- builder.setState(HAServiceProtocolProtos.HAServiceStateProto.STANDBY);
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- throw new IllegalArgumentException("Unexpected NNHAStatusHeartbeat.State:" +
|
|
|
|
- hb.getState());
|
|
|
|
|
|
+ if (hb == null) {
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
+ NNHAStatusHeartbeatProto.Builder builder =
|
|
|
|
+ NNHAStatusHeartbeatProto.newBuilder();
|
|
|
|
+ builder.setState(convert(hb.getState()));
|
|
builder.setTxid(hb.getTxId());
|
|
builder.setTxid(hb.getTxId());
|
|
return builder.build();
|
|
return builder.build();
|
|
}
|
|
}
|