http://git-wip-us.apache.org/repos/asf/hadoop/blob/9c5d4a46/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterDeregisterRequestPBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterDeregisterRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterDeregisterRequestPBImpl.java new file mode 100644 index 0000000..d4c5451 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterDeregisterRequestPBImpl.java @@ -0,0 +1,156 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterDeregisterRequestProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterDeregisterRequestProtoOrBuilder; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterIdProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterStateProto; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterDeregisterRequest; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterState; + +import com.google.protobuf.TextFormat; + +/** + * Protocol buffer based implementation of {@link SubClusterDeregisterRequest}. + */ +@Private +@Unstable +public class SubClusterDeregisterRequestPBImpl + extends SubClusterDeregisterRequest { + + private SubClusterDeregisterRequestProto proto = + SubClusterDeregisterRequestProto.getDefaultInstance(); + private SubClusterDeregisterRequestProto.Builder builder = null; + private boolean viaProto = false; + + public SubClusterDeregisterRequestPBImpl() { + builder = SubClusterDeregisterRequestProto.newBuilder(); + } + + public SubClusterDeregisterRequestPBImpl( + SubClusterDeregisterRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public SubClusterDeregisterRequestProto getProto() { + mergeLocalToProto(); + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private void mergeLocalToProto() { + if (viaProto) { + maybeInitBuilder(); + } + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = SubClusterDeregisterRequestProto.newBuilder(proto); + } + viaProto = false; + } + + private void mergeLocalToBuilder() { + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + + @Override + public SubClusterId getSubClusterId() { + SubClusterDeregisterRequestProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasSubClusterId()) { + return null; + } + return convertFromProtoFormat(p.getSubClusterId()); + } + + @Override + public void setSubClusterId(SubClusterId subClusterId) { + maybeInitBuilder(); + if (subClusterId == null) { + builder.clearSubClusterId(); + return; + } + builder.setSubClusterId(convertToProtoFormat(subClusterId)); + } + + @Override + public SubClusterState getState() { + SubClusterDeregisterRequestProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasState()) { + return null; + } + return convertFromProtoFormat(p.getState()); + } + + @Override + public void setState(SubClusterState state) { + maybeInitBuilder(); + if (state == null) { + builder.clearState(); + return; + } + builder.setState(convertToProtoFormat(state)); + } + + private SubClusterId convertFromProtoFormat(SubClusterIdProto sc) { + return new SubClusterIdPBImpl(sc); + } + + private SubClusterIdProto convertToProtoFormat(SubClusterId sc) { + return ((SubClusterIdPBImpl) sc).getProto(); + } + + private SubClusterState convertFromProtoFormat(SubClusterStateProto state) { + return SubClusterState.valueOf(state.name()); + } + + private SubClusterStateProto convertToProtoFormat(SubClusterState state) { + return SubClusterStateProto.valueOf(state.name()); + } + +}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/9c5d4a46/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterDeregisterResponsePBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterDeregisterResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterDeregisterResponsePBImpl.java new file mode 100644 index 0000000..9e00796 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterDeregisterResponsePBImpl.java @@ -0,0 +1,77 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterDeregisterResponseProto; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterDeregisterResponse; + +import com.google.protobuf.TextFormat; + +/** + * Protocol buffer based implementation of {@link SubClusterDeregisterResponse}. + */ +@Private +@Unstable +public class SubClusterDeregisterResponsePBImpl + extends SubClusterDeregisterResponse { + + private SubClusterDeregisterResponseProto proto = + SubClusterDeregisterResponseProto.getDefaultInstance(); + private SubClusterDeregisterResponseProto.Builder builder = null; + private boolean viaProto = false; + + public SubClusterDeregisterResponsePBImpl() { + builder = SubClusterDeregisterResponseProto.newBuilder(); + } + + public SubClusterDeregisterResponsePBImpl( + SubClusterDeregisterResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public SubClusterDeregisterResponseProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9c5d4a46/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterHeartbeatRequestPBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterHeartbeatRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterHeartbeatRequestPBImpl.java new file mode 100644 index 0000000..ca6b154 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterHeartbeatRequestPBImpl.java @@ -0,0 +1,192 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterHeartbeatRequestProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterHeartbeatRequestProtoOrBuilder; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterIdProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterStateProto; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterHeartbeatRequest; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterState; + +import com.google.protobuf.TextFormat; + +/** + * Protocol buffer based implementation of {@link SubClusterHeartbeatRequest}. + */ +@Private +@Unstable +public class SubClusterHeartbeatRequestPBImpl + extends SubClusterHeartbeatRequest { + + private SubClusterHeartbeatRequestProto proto = + SubClusterHeartbeatRequestProto.getDefaultInstance(); + private SubClusterHeartbeatRequestProto.Builder builder = null; + private boolean viaProto = false; + + private SubClusterId subClusterId = null; + + public SubClusterHeartbeatRequestPBImpl() { + builder = SubClusterHeartbeatRequestProto.newBuilder(); + } + + public SubClusterHeartbeatRequestPBImpl( + SubClusterHeartbeatRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public SubClusterHeartbeatRequestProto getProto() { + mergeLocalToProto(); + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private void mergeLocalToProto() { + if (viaProto) { + maybeInitBuilder(); + } + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = SubClusterHeartbeatRequestProto.newBuilder(proto); + } + viaProto = false; + } + + private void mergeLocalToBuilder() { + if (this.subClusterId != null) { + builder.setSubClusterId(convertToProtoFormat(this.subClusterId)); + } + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + + @Override + public SubClusterId getSubClusterId() { + SubClusterHeartbeatRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.subClusterId != null) { + return this.subClusterId; + } + if (!p.hasSubClusterId()) { + return null; + } + this.subClusterId = convertFromProtoFormat(p.getSubClusterId()); + return this.subClusterId; + } + + @Override + public void setSubClusterId(SubClusterId subClusterId) { + maybeInitBuilder(); + if (subClusterId == null) { + builder.clearSubClusterId(); + } + this.subClusterId = subClusterId; + } + + @Override + public long getLastHeartBeat() { + SubClusterHeartbeatRequestProtoOrBuilder p = viaProto ? proto : builder; + return p.getLastHeartBeat(); + } + + @Override + public void setLastHeartBeat(long time) { + maybeInitBuilder(); + builder.setLastHeartBeat(time); + } + + @Override + public SubClusterState getState() { + SubClusterHeartbeatRequestProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasState()) { + return null; + } + return convertFromProtoFormat(p.getState()); + } + + @Override + public void setState(SubClusterState state) { + maybeInitBuilder(); + if (state == null) { + builder.clearState(); + return; + } + builder.setState(convertToProtoFormat(state)); + } + + @Override + public String getCapability() { + SubClusterHeartbeatRequestProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasCapability()) ? p.getCapability() : null; + } + + @Override + public void setCapability(String capability) { + maybeInitBuilder(); + if (capability == null) { + builder.clearCapability(); + return; + } + builder.setCapability(capability); + } + + private SubClusterId convertFromProtoFormat(SubClusterIdProto clusterId) { + return new SubClusterIdPBImpl(clusterId); + } + + private SubClusterIdProto convertToProtoFormat(SubClusterId clusterId) { + return ((SubClusterIdPBImpl) clusterId).getProto(); + } + + private SubClusterState convertFromProtoFormat(SubClusterStateProto state) { + return SubClusterState.valueOf(state.name()); + } + + private SubClusterStateProto convertToProtoFormat(SubClusterState state) { + return SubClusterStateProto.valueOf(state.name()); + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9c5d4a46/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterHeartbeatResponsePBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterHeartbeatResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterHeartbeatResponsePBImpl.java new file mode 100644 index 0000000..2020c1a --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterHeartbeatResponsePBImpl.java @@ -0,0 +1,77 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterHeartbeatResponseProto; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterHeartbeatResponse; + +import com.google.protobuf.TextFormat; + +/** + * Protocol buffer based implementation of {@link SubClusterHeartbeatResponse}. + */ +@Private +@Unstable +public class SubClusterHeartbeatResponsePBImpl + extends SubClusterHeartbeatResponse { + + private SubClusterHeartbeatResponseProto proto = + SubClusterHeartbeatResponseProto.getDefaultInstance(); + private SubClusterHeartbeatResponseProto.Builder builder = null; + private boolean viaProto = false; + + public SubClusterHeartbeatResponsePBImpl() { + builder = SubClusterHeartbeatResponseProto.newBuilder(); + } + + public SubClusterHeartbeatResponsePBImpl( + SubClusterHeartbeatResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public SubClusterHeartbeatResponseProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9c5d4a46/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterIdPBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterIdPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterIdPBImpl.java new file mode 100644 index 0000000..1bf96bf --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterIdPBImpl.java @@ -0,0 +1,75 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterIdProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterIdProtoOrBuilder; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId; + +/** + * Protocol buffer based implementation of {@link SubClusterId}. + */ +@Private +@Unstable +public class SubClusterIdPBImpl extends SubClusterId { + + private SubClusterIdProto proto = SubClusterIdProto.getDefaultInstance(); + private SubClusterIdProto.Builder builder = null; + private boolean viaProto = false; + + public SubClusterIdPBImpl() { + builder = SubClusterIdProto.newBuilder(); + } + + public SubClusterIdPBImpl(SubClusterIdProto proto) { + this.proto = proto; + viaProto = true; + } + + public SubClusterIdProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = SubClusterIdProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public String getId() { + SubClusterIdProtoOrBuilder p = viaProto ? proto : builder; + return p.getId(); + } + + @Override + protected void setId(String subClusterId) { + maybeInitBuilder(); + if (subClusterId == null) { + builder.clearId(); + return; + } + builder.setId(subClusterId); + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9c5d4a46/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterInfoPBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterInfoPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterInfoPBImpl.java new file mode 100644 index 0000000..b650b5f --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterInfoPBImpl.java @@ -0,0 +1,267 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterIdProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterInfoProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterInfoProtoOrBuilder; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterStateProto; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterInfo; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterState; + +import com.google.common.base.Preconditions; +import com.google.protobuf.TextFormat; + +/** + * Protocol buffer based implementation of {@link SubClusterInfo}. + */ +@Private +@Unstable +public class SubClusterInfoPBImpl extends SubClusterInfo { + + private SubClusterInfoProto proto = SubClusterInfoProto.getDefaultInstance(); + private SubClusterInfoProto.Builder builder = null; + private boolean viaProto = false; + + private SubClusterId subClusterId = null; + + public SubClusterInfoPBImpl() { + builder = SubClusterInfoProto.newBuilder(); + } + + public SubClusterInfoPBImpl(SubClusterInfoProto proto) { + this.proto = proto; + viaProto = true; + } + + public SubClusterInfoProto getProto() { + mergeLocalToProto(); + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private void mergeLocalToProto() { + if (viaProto) { + maybeInitBuilder(); + } + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = SubClusterInfoProto.newBuilder(proto); + } + viaProto = false; + } + + private void mergeLocalToBuilder() { + if (this.subClusterId != null) { + builder.setSubClusterId(convertToProtoFormat(this.subClusterId)); + } + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + + @Override + public SubClusterId getSubClusterId() { + SubClusterInfoProtoOrBuilder p = viaProto ? proto : builder; + if (this.subClusterId != null) { + return this.subClusterId; + } + if (!p.hasSubClusterId()) { + return null; + } + this.subClusterId = convertFromProtoFormat(p.getSubClusterId()); + return this.subClusterId; + } + + @Override + public void setSubClusterId(SubClusterId subClusterId) { + maybeInitBuilder(); + if (subClusterId == null) { + builder.clearSubClusterId(); + } + this.subClusterId = subClusterId; + } + + @Override + public String getAMRMServiceAddress() { + SubClusterInfoProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasAMRMServiceAddress()) ? p.getAMRMServiceAddress() : null; + } + + @Override + public void setAMRMServiceAddress(String amRMServiceAddress) { + maybeInitBuilder(); + if (amRMServiceAddress == null) { + builder.clearAMRMServiceAddress(); + return; + } + builder.setAMRMServiceAddress(amRMServiceAddress); + } + + @Override + public String getClientRMServiceAddress() { + SubClusterInfoProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasClientRMServiceAddress()) ? p.getClientRMServiceAddress() + : null; + } + + @Override + public void setClientRMServiceAddress(String clientRMServiceAddress) { + maybeInitBuilder(); + if (clientRMServiceAddress == null) { + builder.clearClientRMServiceAddress(); + return; + } + builder.setClientRMServiceAddress(clientRMServiceAddress); + } + + @Override + public String getRMAdminServiceAddress() { + SubClusterInfoProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasRMAdminServiceAddress()) ? p.getRMAdminServiceAddress() : null; + } + + @Override + public void setRMAdminServiceAddress(String rmAdminServiceAddress) { + maybeInitBuilder(); + if (rmAdminServiceAddress == null) { + builder.clearRMAdminServiceAddress(); + return; + } + builder.setRMAdminServiceAddress(rmAdminServiceAddress); + } + + @Override + public String getRMWebServiceAddress() { + SubClusterInfoProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasRMWebServiceAddress()) ? p.getRMWebServiceAddress() : null; + } + + @Override + public void setRMWebServiceAddress(String rmWebServiceAddress) { + maybeInitBuilder(); + if (rmWebServiceAddress == null) { + builder.clearRMWebServiceAddress(); + return; + } + builder.setRMWebServiceAddress(rmWebServiceAddress); + } + + @Override + public long getLastHeartBeat() { + SubClusterInfoProtoOrBuilder p = viaProto ? proto : builder; + return p.getLastHeartBeat(); + } + + @Override + public void setLastHeartBeat(long time) { + maybeInitBuilder(); + builder.setLastHeartBeat(time); + } + + @Override + public SubClusterState getState() { + SubClusterInfoProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasState()) { + return null; + } + return convertFromProtoFormat(p.getState()); + } + + @Override + public void setState(SubClusterState state) { + maybeInitBuilder(); + if (state == null) { + builder.clearState(); + return; + } + builder.setState(convertToProtoFormat(state)); + } + + @Override + public long getLastStartTime() { + SubClusterInfoProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasLastStartTime()) ? p.getLastStartTime() : 0; + } + + @Override + public void setLastStartTime(long lastStartTime) { + Preconditions.checkNotNull(builder); + builder.setLastStartTime(lastStartTime); + } + + @Override + public String getCapability() { + SubClusterInfoProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasCapability()) ? p.getCapability() : null; + } + + @Override + public void setCapability(String capability) { + maybeInitBuilder(); + if (capability == null) { + builder.clearCapability(); + return; + } + builder.setCapability(capability); + } + + private SubClusterId convertFromProtoFormat(SubClusterIdProto clusterId) { + return new SubClusterIdPBImpl(clusterId); + } + + private SubClusterIdProto convertToProtoFormat(SubClusterId clusterId) { + return ((SubClusterIdPBImpl) clusterId).getProto(); + } + + private SubClusterState convertFromProtoFormat(SubClusterStateProto state) { + return SubClusterState.valueOf(state.name()); + } + + private SubClusterStateProto convertToProtoFormat(SubClusterState state) { + return SubClusterStateProto.valueOf(state.name()); + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9c5d4a46/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterRegisterRequestPBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterRegisterRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterRegisterRequestPBImpl.java new file mode 100644 index 0000000..3429cc9 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterRegisterRequestPBImpl.java @@ -0,0 +1,134 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterInfoProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterRegisterRequestProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterRegisterRequestProtoOrBuilder; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterInfo; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterRegisterRequest; + +import com.google.protobuf.TextFormat; + +/** + * Protocol buffer based implementation of {@link SubClusterRegisterRequest}. + */ +@Private +@Unstable +public class SubClusterRegisterRequestPBImpl extends SubClusterRegisterRequest { + + private SubClusterRegisterRequestProto proto = + SubClusterRegisterRequestProto.getDefaultInstance(); + private SubClusterRegisterRequestProto.Builder builder = null; + private boolean viaProto = false; + + private SubClusterInfo subClusterInfo = null; + + public SubClusterRegisterRequestPBImpl() { + builder = SubClusterRegisterRequestProto.newBuilder(); + } + + public SubClusterRegisterRequestPBImpl(SubClusterRegisterRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public SubClusterRegisterRequestProto getProto() { + mergeLocalToProto(); + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private void mergeLocalToProto() { + if (viaProto) { + maybeInitBuilder(); + } + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = SubClusterRegisterRequestProto.newBuilder(proto); + } + viaProto = false; + } + + private void mergeLocalToBuilder() { + if (this.subClusterInfo != null) { + builder.setSubClusterInfo(convertToProtoFormat(this.subClusterInfo)); + } + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + + @Override + public SubClusterInfo getSubClusterInfo() { + SubClusterRegisterRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.subClusterInfo != null) { + return this.subClusterInfo; + } + if (!p.hasSubClusterInfo()) { + return null; + } + this.subClusterInfo = convertFromProtoFormat(p.getSubClusterInfo()); + return this.subClusterInfo; + } + + @Override + public void setSubClusterInfo(SubClusterInfo subClusterInfo) { + maybeInitBuilder(); + if (subClusterInfo == null) { + builder.clearSubClusterInfo(); + } + this.subClusterInfo = subClusterInfo; + } + + private SubClusterInfo convertFromProtoFormat( + SubClusterInfoProto clusterInfo) { + return new SubClusterInfoPBImpl(clusterInfo); + } + + private SubClusterInfoProto convertToProtoFormat(SubClusterInfo clusterInfo) { + return ((SubClusterInfoPBImpl) clusterInfo).getProto(); + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9c5d4a46/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterRegisterResponsePBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterRegisterResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterRegisterResponsePBImpl.java new file mode 100644 index 0000000..68930e3 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterRegisterResponsePBImpl.java @@ -0,0 +1,77 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterRegisterResponseProto; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterRegisterResponse; + +import com.google.protobuf.TextFormat; + +/** + * Protocol buffer based implementation of {@link SubClusterRegisterResponse}. + */ +@Private +@Unstable +public class SubClusterRegisterResponsePBImpl + extends SubClusterRegisterResponse { + + private SubClusterRegisterResponseProto proto = + SubClusterRegisterResponseProto.getDefaultInstance(); + private SubClusterRegisterResponseProto.Builder builder = null; + private boolean viaProto = false; + + public SubClusterRegisterResponsePBImpl() { + builder = SubClusterRegisterResponseProto.newBuilder(); + } + + public SubClusterRegisterResponsePBImpl( + SubClusterRegisterResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public SubClusterRegisterResponseProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/9c5d4a46/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/package-info.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/package-info.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/package-info.java new file mode 100644 index 0000000..2f85c48 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/package-info.java @@ -0,0 +1,17 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.yarn.server.federation.store.records.impl.pb; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hadoop/blob/9c5d4a46/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/package-info.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/package-info.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/package-info.java new file mode 100644 index 0000000..9a9b282 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/package-info.java @@ -0,0 +1,17 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.yarn.server.federation.store.records; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hadoop/blob/9c5d4a46/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_federation_protos.proto ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_federation_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_federation_protos.proto new file mode 100644 index 0000000..1b2e53e --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/proto/yarn_server_federation_protos.proto @@ -0,0 +1,93 @@ +/** + * 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. + */ + +option java_package = "org.apache.hadoop.yarn.federation.proto"; +option java_outer_classname = "YarnServerFederationProtos"; +option java_generic_services = true; +option java_generate_equals_and_hash = true; +package hadoop.yarn; + +import "yarn_protos.proto"; +import "yarn_server_common_protos.proto"; + +message SubClusterIdProto { + optional string id = 1; +} + +enum SubClusterStateProto { + SC_NEW = 1; + SC_RUNNING = 2; + SC_UNHEALTHY = 3; + SC_DECOMMISSIONING = 4; + SC_LOST = 5; + SC_UNREGISTERED = 6; + SC_DECOMMISSIONED = 7; +} + +message SubClusterInfoProto { + optional SubClusterIdProto sub_cluster_id = 1; + optional string aMRM_service_address = 2; + optional string client_rM_service_address = 3; + optional string rM_admin_service_address = 4; + optional string rM_web_service_address = 5; + optional int64 lastHeartBeat = 6; + optional SubClusterStateProto state = 7; + optional int64 lastStartTime = 8; + optional string capability = 9; +} + +message SubClusterRegisterRequestProto { + optional SubClusterInfoProto sub_cluster_info = 1; +} + +message SubClusterRegisterResponseProto { +} + +message SubClusterHeartbeatRequestProto { + optional SubClusterIdProto sub_cluster_id = 1; + optional int64 lastHeartBeat = 2; + optional SubClusterStateProto state = 3; + optional string capability = 4; +} + +message SubClusterHeartbeatResponseProto { +} + +message SubClusterDeregisterRequestProto { + optional SubClusterIdProto sub_cluster_id = 1; + optional SubClusterStateProto state = 2; +} + +message SubClusterDeregisterResponseProto { +} + +message GetSubClusterInfoRequestProto { + optional SubClusterIdProto sub_cluster_id = 1; +} + +message GetSubClusterInfoResponseProto { + optional SubClusterInfoProto sub_cluster_info = 1; +} + +message GetSubClustersInfoRequestProto { + optional bool filter_inactive_subclusters = 1 [default = true]; +} + +message GetSubClustersInfoResponseProto { + repeated SubClusterInfoProto sub_cluster_infos = 1; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hadoop/blob/9c5d4a46/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/records/TestFederationProtocolRecords.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/records/TestFederationProtocolRecords.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/records/TestFederationProtocolRecords.java new file mode 100644 index 0000000..681edb1 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/records/TestFederationProtocolRecords.java @@ -0,0 +1,133 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.yarn.server.federation.store.records; + +import org.apache.hadoop.yarn.api.BasePBImplRecordsTest; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.GetSubClusterInfoRequestProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.GetSubClusterInfoResponseProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.GetSubClustersInfoRequestProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.GetSubClustersInfoResponseProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterDeregisterRequestProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterDeregisterResponseProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterHeartbeatRequestProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterHeartbeatResponseProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterIdProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterInfoProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterRegisterRequestProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterRegisterResponseProto; +import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.GetSubClusterInfoRequestPBImpl; +import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.GetSubClusterInfoResponsePBImpl; +import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.GetSubClustersInfoRequestPBImpl; +import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.GetSubClustersInfoResponsePBImpl; +import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.SubClusterDeregisterRequestPBImpl; +import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.SubClusterDeregisterResponsePBImpl; +import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.SubClusterHeartbeatRequestPBImpl; +import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.SubClusterHeartbeatResponsePBImpl; +import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.SubClusterIdPBImpl; +import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.SubClusterInfoPBImpl; +import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.SubClusterRegisterRequestPBImpl; +import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.SubClusterRegisterResponsePBImpl; +import org.apache.hadoop.yarn.server.records.Version; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Test class for federation protocol records. + */ +public class TestFederationProtocolRecords extends BasePBImplRecordsTest { + + @BeforeClass + public static void setup() throws Exception { + generateByNewInstance(ApplicationId.class); + generateByNewInstance(Version.class); + generateByNewInstance(SubClusterId.class); + generateByNewInstance(SubClusterInfo.class); + } + + @Test + public void testSubClusterId() throws Exception { + validatePBImplRecord(SubClusterIdPBImpl.class, SubClusterIdProto.class); + } + + @Test + public void testSubClusterInfo() throws Exception { + validatePBImplRecord(SubClusterInfoPBImpl.class, SubClusterInfoProto.class); + } + + @Test + public void testSubClusterRegisterRequest() throws Exception { + validatePBImplRecord(SubClusterRegisterRequestPBImpl.class, + SubClusterRegisterRequestProto.class); + } + + @Test + public void testSubClusterRegisterResponse() throws Exception { + validatePBImplRecord(SubClusterRegisterResponsePBImpl.class, + SubClusterRegisterResponseProto.class); + } + + @Test + public void testSubClusterDeregisterRequest() throws Exception { + validatePBImplRecord(SubClusterDeregisterRequestPBImpl.class, + SubClusterDeregisterRequestProto.class); + } + + @Test + public void testSubClusterDeregisterResponse() throws Exception { + validatePBImplRecord(SubClusterDeregisterResponsePBImpl.class, + SubClusterDeregisterResponseProto.class); + } + + @Test + public void testSubClusterHeartbeatRequest() throws Exception { + validatePBImplRecord(SubClusterHeartbeatRequestPBImpl.class, + SubClusterHeartbeatRequestProto.class); + } + + @Test + public void testSubClusterHeartbeatResponse() throws Exception { + validatePBImplRecord(SubClusterHeartbeatResponsePBImpl.class, + SubClusterHeartbeatResponseProto.class); + } + + @Test + public void testGetSubClusterRequest() throws Exception { + validatePBImplRecord(GetSubClusterInfoRequestPBImpl.class, + GetSubClusterInfoRequestProto.class); + } + + @Test + public void testGetSubClusterResponse() throws Exception { + validatePBImplRecord(GetSubClusterInfoResponsePBImpl.class, + GetSubClusterInfoResponseProto.class); + } + + @Test + public void testGetSubClustersInfoRequest() throws Exception { + validatePBImplRecord(GetSubClustersInfoRequestPBImpl.class, + GetSubClustersInfoRequestProto.class); + } + + @Test + public void testGetSubClustersInfoResponse() throws Exception { + validatePBImplRecord(GetSubClustersInfoResponsePBImpl.class, + GetSubClustersInfoResponseProto.class); + } + +} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org