diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationClientProtocolPB.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationClientProtocolPB.java deleted file mode 100644 index 9e50c54..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationClientProtocolPB.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * 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. - */ -package org.apache.hadoop.yarn.api; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.ipc.ProtocolInfo; -import org.apache.hadoop.yarn.proto.ApplicationClientProtocol.ApplicationClientProtocolService; - -@Private -@Unstable -@ProtocolInfo(protocolName = "org.apache.hadoop.yarn.api.ApplicationClientProtocolPB", - protocolVersion = 1) -public interface ApplicationClientProtocolPB extends ApplicationClientProtocolService.BlockingInterface { - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationMasterProtocolPB.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationMasterProtocolPB.java deleted file mode 100644 index 841ef61..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationMasterProtocolPB.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * 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. - */ -package org.apache.hadoop.yarn.api; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.ipc.ProtocolInfo; -import org.apache.hadoop.yarn.proto.ApplicationMasterProtocol.ApplicationMasterProtocolService; - -@Private -@Unstable -@ProtocolInfo(protocolName = "org.apache.hadoop.yarn.api.ApplicationMasterProtocolPB", - protocolVersion = 1) -public interface ApplicationMasterProtocolPB extends ApplicationMasterProtocolService.BlockingInterface { - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ContainerManagementProtocolPB.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ContainerManagementProtocolPB.java deleted file mode 100644 index 82e9ad0..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ContainerManagementProtocolPB.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * 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. - */ -package org.apache.hadoop.yarn.api; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.ipc.ProtocolInfo; -import org.apache.hadoop.yarn.proto.ContainerManagementProtocol.ContainerManagementProtocolService; - -@Private -@Unstable -@ProtocolInfo( - protocolName = "org.apache.hadoop.yarn.api.ContainerManagementProtocolPB", - protocolVersion = 1) -public interface ContainerManagementProtocolPB extends ContainerManagementProtocolService.BlockingInterface { - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ResourceManagerAdministrationProtocolPB.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ResourceManagerAdministrationProtocolPB.java deleted file mode 100644 index 6979bab..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ResourceManagerAdministrationProtocolPB.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * 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. - */ -package org.apache.hadoop.yarn.api; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.ipc.ProtocolInfo; -import org.apache.hadoop.yarn.proto.ResourceManagerAdministrationProtocol.ResourceManagerAdministrationProtocolService; - -@Private -@Unstable -@ProtocolInfo( - protocolName = "org.apache.hadoop.yarn.api.ResourceManagerAdministrationProtocolPB", - protocolVersion = 1) -public interface ResourceManagerAdministrationProtocolPB extends ResourceManagerAdministrationProtocolService.BlockingInterface { - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateRequestPBImpl.java deleted file mode 100644 index 4584dc9..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateRequestPBImpl.java +++ /dev/null @@ -1,347 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest; -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.ResourceBlacklistRequest; -import org.apache.hadoop.yarn.api.records.ResourceRequest; -import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationAttemptIdPBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.ResourceBlacklistRequestPBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.ResourceRequestPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceBlacklistRequestProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceRequestProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateRequestProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateRequestProtoOrBuilder; - -@Private -@Unstable -public class AllocateRequestPBImpl extends AllocateRequest { - AllocateRequestProto proto = AllocateRequestProto.getDefaultInstance(); - AllocateRequestProto.Builder builder = null; - boolean viaProto = false; - - private ApplicationAttemptId applicationAttemptID = null; - private List ask = null; - private List release = null; - private ResourceBlacklistRequest blacklistRequest = null; - - - public AllocateRequestPBImpl() { - builder = AllocateRequestProto.newBuilder(); - } - - public AllocateRequestPBImpl(AllocateRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public AllocateRequestProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.applicationAttemptID != null) { - builder.setApplicationAttemptId(convertToProtoFormat(this.applicationAttemptID)); - } - if (this.ask != null) { - addAsksToProto(); - } - if (this.release != null) { - addReleasesToProto(); - } - if (this.blacklistRequest != null) { - builder.setBlacklistRequest(convertToProtoFormat(this.blacklistRequest)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = AllocateRequestProto.newBuilder(proto); - } - viaProto = false; - } - - @Override - public ApplicationAttemptId getApplicationAttemptId() { - AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.applicationAttemptID != null) { - return this.applicationAttemptID; - } - if (!p.hasApplicationAttemptId()) { - return null; - } - this.applicationAttemptID = convertFromProtoFormat(p.getApplicationAttemptId()); - return this.applicationAttemptID; - } - - @Override - public void setApplicationAttemptId(ApplicationAttemptId appAttemptId) { - maybeInitBuilder(); - if (appAttemptId == null) - builder.clearApplicationAttemptId(); - this.applicationAttemptID = appAttemptId; - } - - @Override - public int getResponseId() { - AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; - return p.getResponseId(); - } - - @Override - public void setResponseId(int id) { - maybeInitBuilder(); - builder.setResponseId(id); - } - - @Override - public float getProgress() { - AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; - return p.getProgress(); - } - - @Override - public void setProgress(float progress) { - maybeInitBuilder(); - builder.setProgress(progress); - } - - @Override - public List getAskList() { - initAsks(); - return this.ask; - } - - @Override - public void setAskList(final List resourceRequests) { - if(resourceRequests == null) { - return; - } - initAsks(); - this.ask.clear(); - this.ask.addAll(resourceRequests); - } - - @Override - public ResourceBlacklistRequest getResourceBlacklistRequest() { - AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.blacklistRequest != null) { - return this.blacklistRequest; - } - if (!p.hasBlacklistRequest()) { - return null; - } - this.blacklistRequest = convertFromProtoFormat(p.getBlacklistRequest()); - return this.blacklistRequest; - } - - @Override - public void setResourceBlacklistRequest(ResourceBlacklistRequest blacklistRequest) { - maybeInitBuilder(); - if (blacklistRequest == null) { - builder.clearBlacklistRequest(); - } - this.blacklistRequest = blacklistRequest; - } - - private void initAsks() { - if (this.ask != null) { - return; - } - AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getAskList(); - this.ask = new ArrayList(); - - for (ResourceRequestProto c : list) { - this.ask.add(convertFromProtoFormat(c)); - } - } - - private void addAsksToProto() { - maybeInitBuilder(); - builder.clearAsk(); - if (ask == null) - return; - Iterable iterable = new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator iter = ask.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public ResourceRequestProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - builder.addAllAsk(iterable); - } - @Override - public List getReleaseList() { - initReleases(); - return this.release; - } - @Override - public void setReleaseList(List releaseContainers) { - if(releaseContainers == null) { - return; - } - initReleases(); - this.release.clear(); - this.release.addAll(releaseContainers); - } - - private void initReleases() { - if (this.release != null) { - return; - } - AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getReleaseList(); - this.release = new ArrayList(); - - for (ContainerIdProto c : list) { - this.release.add(convertFromProtoFormat(c)); - } - } - - private void addReleasesToProto() { - maybeInitBuilder(); - builder.clearRelease(); - if (release == null) - return; - Iterable iterable = new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator iter = release.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public ContainerIdProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - builder.addAllRelease(iterable); - } - - private ApplicationAttemptIdPBImpl convertFromProtoFormat(ApplicationAttemptIdProto p) { - return new ApplicationAttemptIdPBImpl(p); - } - - private ApplicationAttemptIdProto convertToProtoFormat(ApplicationAttemptId t) { - return ((ApplicationAttemptIdPBImpl)t).getProto(); - } - - private ResourceRequestPBImpl convertFromProtoFormat(ResourceRequestProto p) { - return new ResourceRequestPBImpl(p); - } - - private ResourceRequestProto convertToProtoFormat(ResourceRequest t) { - return ((ResourceRequestPBImpl)t).getProto(); - } - - private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { - return new ContainerIdPBImpl(p); - } - - private ContainerIdProto convertToProtoFormat(ContainerId t) { - return ((ContainerIdPBImpl)t).getProto(); - } - - private ResourceBlacklistRequestPBImpl convertFromProtoFormat(ResourceBlacklistRequestProto p) { - return new ResourceBlacklistRequestPBImpl(p); - } - - private ResourceBlacklistRequestProto convertToProtoFormat(ResourceBlacklistRequest t) { - return ((ResourceBlacklistRequestPBImpl)t).getProto(); - } - - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateResponsePBImpl.java deleted file mode 100644 index f38f91e..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateResponsePBImpl.java +++ /dev/null @@ -1,539 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse; -import org.apache.hadoop.yarn.api.records.AMCommand; -import org.apache.hadoop.yarn.api.records.Container; -import org.apache.hadoop.yarn.api.records.ContainerStatus; -import org.apache.hadoop.yarn.api.records.NMToken; -import org.apache.hadoop.yarn.api.records.NodeReport; -import org.apache.hadoop.yarn.api.records.PreemptionMessage; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerPBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerStatusPBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.NMTokenPBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.NodeReportPBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.PreemptionMessagePBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils; -import org.apache.hadoop.yarn.api.records.impl.pb.ResourcePBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto; -import org.apache.hadoop.yarn.proto.YarnProtos.NodeReportProto; -import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionMessageProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateResponseProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateResponseProtoOrBuilder; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.NMTokenProto; - -@Private -@Unstable -public class AllocateResponsePBImpl extends AllocateResponse { - AllocateResponseProto proto = AllocateResponseProto.getDefaultInstance(); - AllocateResponseProto.Builder builder = null; - boolean viaProto = false; - - Resource limit; - - private List allocatedContainers = null; - private List nmTokens = null; - private List completedContainersStatuses = null; - - private List updatedNodes = null; - private PreemptionMessage preempt; - - - public AllocateResponsePBImpl() { - builder = AllocateResponseProto.newBuilder(); - } - - public AllocateResponsePBImpl(AllocateResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public synchronized AllocateResponseProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private synchronized void mergeLocalToBuilder() { - if (this.allocatedContainers != null) { - builder.clearAllocatedContainers(); - Iterable iterable = - getProtoIterable(this.allocatedContainers); - builder.addAllAllocatedContainers(iterable); - } - if (nmTokens != null) { - builder.clearNmTokens(); - Iterable iterable = getTokenProtoIterable(nmTokens); - builder.addAllNmTokens(iterable); - } - if (this.completedContainersStatuses != null) { - builder.clearCompletedContainerStatuses(); - Iterable iterable = - getContainerStatusProtoIterable(this.completedContainersStatuses); - builder.addAllCompletedContainerStatuses(iterable); - } - if (this.updatedNodes != null) { - builder.clearUpdatedNodes(); - Iterable iterable = - getNodeReportProtoIterable(this.updatedNodes); - builder.addAllUpdatedNodes(iterable); - } - if (this.limit != null) { - builder.setLimit(convertToProtoFormat(this.limit)); - } - if (this.preempt != null) { - builder.setPreempt(convertToProtoFormat(this.preempt)); - } - } - - private synchronized void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private synchronized void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = AllocateResponseProto.newBuilder(proto); - } - viaProto = false; - } - - @Override - public synchronized AMCommand getAMCommand() { - AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasAMCommand()) { - return null; - } - return ProtoUtils.convertFromProtoFormat(p.getAMCommand()); - } - - @Override - public synchronized void setAMCommand(AMCommand command) { - maybeInitBuilder(); - if (command == null) { - builder.clearAMCommand(); - return; - } - builder.setAMCommand(ProtoUtils.convertToProtoFormat(command)); - } - - @Override - public synchronized int getResponseId() { - AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; - return (p.getResponseId()); - } - - @Override - public synchronized void setResponseId(int responseId) { - maybeInitBuilder(); - builder.setResponseId((responseId)); - } - - @Override - public synchronized Resource getAvailableResources() { - if (this.limit != null) { - return this.limit; - } - - AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasLimit()) { - return null; - } - this.limit = convertFromProtoFormat(p.getLimit()); - return this.limit; - } - - @Override - public synchronized void setAvailableResources(Resource limit) { - maybeInitBuilder(); - if (limit == null) - builder.clearLimit(); - this.limit = limit; - } - - @Override - public synchronized List getUpdatedNodes() { - initLocalNewNodeReportList(); - return this.updatedNodes; - } - @Override - public synchronized void setUpdatedNodes( - final List updatedNodes) { - if (updatedNodes == null) { - this.updatedNodes.clear(); - return; - } - this.updatedNodes = new ArrayList(updatedNodes.size()); - this.updatedNodes.addAll(updatedNodes); - } - - @Override - public synchronized List getAllocatedContainers() { - initLocalNewContainerList(); - return this.allocatedContainers; - } - - @Override - public synchronized void setAllocatedContainers( - final List containers) { - if (containers == null) - return; - // this looks like a bug because it results in append and not set - initLocalNewContainerList(); - allocatedContainers.addAll(containers); - } - - //// Finished containers - @Override - public synchronized List getCompletedContainersStatuses() { - initLocalFinishedContainerList(); - return this.completedContainersStatuses; - } - - @Override - public synchronized void setCompletedContainersStatuses( - final List containers) { - if (containers == null) - return; - initLocalFinishedContainerList(); - completedContainersStatuses.addAll(containers); - } - - @Override - public synchronized void setNMTokens(List nmTokens) { - if (nmTokens == null || nmTokens.isEmpty()) { - if (this.nmTokens != null) { - this.nmTokens.clear(); - } - builder.clearNmTokens(); - return; - } - // Implementing it as an append rather than set for consistency - initLocalNewNMTokenList(); - this.nmTokens.addAll(nmTokens); - } - - @Override - public synchronized List getNMTokens() { - initLocalNewNMTokenList(); - return nmTokens; - } - - @Override - public synchronized int getNumClusterNodes() { - AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; - return p.getNumClusterNodes(); - } - - @Override - public synchronized void setNumClusterNodes(int numNodes) { - maybeInitBuilder(); - builder.setNumClusterNodes(numNodes); - } - - @Override - public synchronized PreemptionMessage getPreemptionMessage() { - AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; - if (this.preempt != null) { - return this.preempt; - } - if (!p.hasPreempt()) { - return null; - } - this.preempt = convertFromProtoFormat(p.getPreempt()); - return this.preempt; - } - - @Override - public synchronized void setPreemptionMessage(PreemptionMessage preempt) { - maybeInitBuilder(); - if (null == preempt) { - builder.clearPreempt(); - } - this.preempt = preempt; - } - - // Once this is called. updatedNodes will never be null - until a getProto is - // called. - private synchronized void initLocalNewNodeReportList() { - if (this.updatedNodes != null) { - return; - } - AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getUpdatedNodesList(); - updatedNodes = new ArrayList(list.size()); - - for (NodeReportProto n : list) { - updatedNodes.add(convertFromProtoFormat(n)); - } - } - - // Once this is called. containerList will never be null - until a getProto - // is called. - private synchronized void initLocalNewContainerList() { - if (this.allocatedContainers != null) { - return; - } - AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getAllocatedContainersList(); - allocatedContainers = new ArrayList(); - - for (ContainerProto c : list) { - allocatedContainers.add(convertFromProtoFormat(c)); - } - } - - private synchronized void initLocalNewNMTokenList() { - if (nmTokens != null) { - return; - } - AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getNmTokensList(); - nmTokens = new ArrayList(); - for (NMTokenProto t : list) { - nmTokens.add(convertFromProtoFormat(t)); - } - } - - private synchronized Iterable getProtoIterable( - final List newContainersList) { - maybeInitBuilder(); - return new Iterable() { - @Override - public synchronized Iterator iterator() { - return new Iterator() { - - Iterator iter = newContainersList.iterator(); - - @Override - public synchronized boolean hasNext() { - return iter.hasNext(); - } - - @Override - public synchronized ContainerProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public synchronized void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - } - - private synchronized Iterable getTokenProtoIterable( - final List nmTokenList) { - maybeInitBuilder(); - return new Iterable() { - @Override - public synchronized Iterator iterator() { - return new Iterator() { - - Iterator iter = nmTokenList.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public NMTokenProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - }; - } - - private synchronized Iterable - getContainerStatusProtoIterable( - final List newContainersList) { - maybeInitBuilder(); - return new Iterable() { - @Override - public synchronized Iterator iterator() { - return new Iterator() { - - Iterator iter = newContainersList.iterator(); - - @Override - public synchronized boolean hasNext() { - return iter.hasNext(); - } - - @Override - public synchronized ContainerStatusProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public synchronized void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - } - - private synchronized Iterable - getNodeReportProtoIterable( - final List newNodeReportsList) { - maybeInitBuilder(); - return new Iterable() { - @Override - public synchronized Iterator iterator() { - return new Iterator() { - - Iterator iter = newNodeReportsList.iterator(); - - @Override - public synchronized boolean hasNext() { - return iter.hasNext(); - } - - @Override - public synchronized NodeReportProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public synchronized void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - } - - // Once this is called. containerList will never be null - until a getProto - // is called. - private synchronized void initLocalFinishedContainerList() { - if (this.completedContainersStatuses != null) { - return; - } - AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getCompletedContainerStatusesList(); - completedContainersStatuses = new ArrayList(); - - for (ContainerStatusProto c : list) { - completedContainersStatuses.add(convertFromProtoFormat(c)); - } - } - - private synchronized NodeReportPBImpl convertFromProtoFormat( - NodeReportProto p) { - return new NodeReportPBImpl(p); - } - - private synchronized NodeReportProto convertToProtoFormat(NodeReport t) { - return ((NodeReportPBImpl)t).getProto(); - } - - private synchronized ContainerPBImpl convertFromProtoFormat( - ContainerProto p) { - return new ContainerPBImpl(p); - } - - private synchronized ContainerProto convertToProtoFormat(Container t) { - return ((ContainerPBImpl)t).getProto(); - } - - private synchronized ContainerStatusPBImpl convertFromProtoFormat( - ContainerStatusProto p) { - return new ContainerStatusPBImpl(p); - } - - private synchronized ContainerStatusProto convertToProtoFormat( - ContainerStatus t) { - return ((ContainerStatusPBImpl)t).getProto(); - } - - private synchronized ResourcePBImpl convertFromProtoFormat(ResourceProto p) { - return new ResourcePBImpl(p); - } - - private synchronized ResourceProto convertToProtoFormat(Resource r) { - return ((ResourcePBImpl) r).getProto(); - } - - private synchronized PreemptionMessagePBImpl convertFromProtoFormat(PreemptionMessageProto p) { - return new PreemptionMessagePBImpl(p); - } - - private synchronized PreemptionMessageProto convertToProtoFormat(PreemptionMessage r) { - return ((PreemptionMessagePBImpl)r).getProto(); - } - - private synchronized NMTokenProto convertToProtoFormat(NMToken token) { - return ((NMTokenPBImpl)token).getProto(); - } - - private synchronized NMToken convertFromProtoFormat(NMTokenProto proto) { - return new NMTokenPBImpl(proto); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CancelDelegationTokenRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CancelDelegationTokenRequestPBImpl.java deleted file mode 100644 index e8e926b..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CancelDelegationTokenRequestPBImpl.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenRequestProto; -import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenRequestProtoOrBuilder; -import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; -import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenRequest; -import org.apache.hadoop.yarn.api.records.Token; -import org.apache.hadoop.yarn.api.records.impl.pb.TokenPBImpl; - -@Private -@Unstable -public class CancelDelegationTokenRequestPBImpl extends - CancelDelegationTokenRequest { - - CancelDelegationTokenRequestProto proto = CancelDelegationTokenRequestProto - .getDefaultInstance(); - CancelDelegationTokenRequestProto.Builder builder = null; - boolean viaProto = false; - - public CancelDelegationTokenRequestPBImpl() { - builder = CancelDelegationTokenRequestProto.newBuilder(); - } - - public CancelDelegationTokenRequestPBImpl( - CancelDelegationTokenRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - Token token; - - @Override - public Token getDelegationToken() { - CancelDelegationTokenRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.token != null) { - return this.token; - } - this.token = convertFromProtoFormat(p.getToken()); - return this.token; - } - - @Override - public void setDelegationToken(Token token) { - maybeInitBuilder(); - if (token == null) - builder.clearToken(); - this.token = token; - } - - public CancelDelegationTokenRequestProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (token != null) { - builder.setToken(convertToProtoFormat(this.token)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = CancelDelegationTokenRequestProto.newBuilder(proto); - } - viaProto = false; - } - - private TokenPBImpl convertFromProtoFormat(TokenProto p) { - return new TokenPBImpl(p); - } - - private TokenProto convertToProtoFormat(Token t) { - return ((TokenPBImpl) t).getProto(); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CancelDelegationTokenResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CancelDelegationTokenResponsePBImpl.java deleted file mode 100644 index 334e1ed..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CancelDelegationTokenResponsePBImpl.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenResponseProto; -import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenResponse; - -@Private -@Unstable -public class CancelDelegationTokenResponsePBImpl extends CancelDelegationTokenResponse { - - CancelDelegationTokenResponseProto proto = CancelDelegationTokenResponseProto - .getDefaultInstance(); - - public CancelDelegationTokenResponsePBImpl() { - } - - public CancelDelegationTokenResponsePBImpl( - CancelDelegationTokenResponseProto proto) { - this.proto = proto; - } - - public CancelDelegationTokenResponseProto getProto() { - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/FinishApplicationMasterRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/FinishApplicationMasterRequestPBImpl.java deleted file mode 100644 index cf52896..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/FinishApplicationMasterRequestPBImpl.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterRequest; -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; -import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationAttemptIdPBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.FinalApplicationStatusProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationMasterRequestProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationMasterRequestProtoOrBuilder; - -@Private -@Unstable -public class FinishApplicationMasterRequestPBImpl extends FinishApplicationMasterRequest { - FinishApplicationMasterRequestProto proto = FinishApplicationMasterRequestProto.getDefaultInstance(); - FinishApplicationMasterRequestProto.Builder builder = null; - boolean viaProto = false; - - private ApplicationAttemptId appAttemptId = null; - - - public FinishApplicationMasterRequestPBImpl() { - builder = FinishApplicationMasterRequestProto.newBuilder(); - } - - public FinishApplicationMasterRequestPBImpl(FinishApplicationMasterRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public FinishApplicationMasterRequestProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.appAttemptId != null) { - builder.setApplicationAttemptId(convertToProtoFormat(this.appAttemptId)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = FinishApplicationMasterRequestProto.newBuilder(proto); - } - viaProto = false; - } - - @Override - public ApplicationAttemptId getApplicationAttemptId() { - FinishApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.appAttemptId != null) { - return this.appAttemptId; - } - if (!p.hasApplicationAttemptId()) { - return null; - } - this.appAttemptId = convertFromProtoFormat(p.getApplicationAttemptId()); - return this.appAttemptId; - } - - @Override - public void setAppAttemptId(ApplicationAttemptId applicationAttemptId) { - maybeInitBuilder(); - if (applicationAttemptId == null) - builder.clearApplicationAttemptId(); - this.appAttemptId = applicationAttemptId; - } - - @Override - public String getDiagnostics() { - FinishApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; - return p.getDiagnostics(); - } - - @Override - public void setDiagnostics(String diagnostics) { - maybeInitBuilder(); - builder.setDiagnostics(diagnostics); - } - - @Override - public String getTrackingUrl() { - FinishApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; - return p.getTrackingUrl(); - } - - @Override - public void setTrackingUrl(String url) { - maybeInitBuilder(); - builder.setTrackingUrl(url); - } - - @Override - public FinalApplicationStatus getFinalApplicationStatus() { - FinishApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasFinalApplicationStatus()) { - return null; - } - return convertFromProtoFormat(p.getFinalApplicationStatus()); - } - - @Override - public void setFinalApplicationStatus(FinalApplicationStatus finalState) { - maybeInitBuilder(); - if (finalState == null) { - builder.clearFinalApplicationStatus(); - return; - } - builder.setFinalApplicationStatus(convertToProtoFormat(finalState)); - } - - private ApplicationAttemptIdPBImpl convertFromProtoFormat(ApplicationAttemptIdProto p) { - return new ApplicationAttemptIdPBImpl(p); - } - - private ApplicationAttemptIdProto convertToProtoFormat(ApplicationAttemptId t) { - return ((ApplicationAttemptIdPBImpl)t).getProto(); - } - - private FinalApplicationStatus convertFromProtoFormat(FinalApplicationStatusProto s) { - return ProtoUtils.convertFromProtoFormat(s); - } - - private FinalApplicationStatusProto convertToProtoFormat(FinalApplicationStatus s) { - return ProtoUtils.convertToProtoFormat(s); - } - - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/FinishApplicationMasterResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/FinishApplicationMasterResponsePBImpl.java deleted file mode 100644 index 70f4f96..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/FinishApplicationMasterResponsePBImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterResponse; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationMasterResponseProto; - -@Private -@Unstable -public class FinishApplicationMasterResponsePBImpl extends FinishApplicationMasterResponse { - FinishApplicationMasterResponseProto proto = FinishApplicationMasterResponseProto.getDefaultInstance(); - FinishApplicationMasterResponseProto.Builder builder = null; - boolean viaProto = false; - - public FinishApplicationMasterResponsePBImpl() { - builder = FinishApplicationMasterResponseProto.newBuilder(); - } - - public FinishApplicationMasterResponsePBImpl(FinishApplicationMasterResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public FinishApplicationMasterResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetAllApplicationsRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetAllApplicationsRequestPBImpl.java deleted file mode 100644 index 24b16d0..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetAllApplicationsRequestPBImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetAllApplicationsRequest; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetAllApplicationsRequestProto; - -@Private -@Unstable -public class GetAllApplicationsRequestPBImpl extends GetAllApplicationsRequest { - GetAllApplicationsRequestProto proto = GetAllApplicationsRequestProto.getDefaultInstance(); - GetAllApplicationsRequestProto.Builder builder = null; - boolean viaProto = false; - - public GetAllApplicationsRequestPBImpl() { - builder = GetAllApplicationsRequestProto.newBuilder(); - } - - public GetAllApplicationsRequestPBImpl(GetAllApplicationsRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public GetAllApplicationsRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetAllApplicationsResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetAllApplicationsResponsePBImpl.java deleted file mode 100644 index a26dccd..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetAllApplicationsResponsePBImpl.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetAllApplicationsResponse; -import org.apache.hadoop.yarn.api.records.ApplicationReport; -import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationReportPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationReportProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetAllApplicationsResponseProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetAllApplicationsResponseProtoOrBuilder; - -@Private -@Unstable -public class GetAllApplicationsResponsePBImpl -extends GetAllApplicationsResponse { - - GetAllApplicationsResponseProto proto = - GetAllApplicationsResponseProto.getDefaultInstance(); - GetAllApplicationsResponseProto.Builder builder = null; - boolean viaProto = false; - - List applicationList; - - public GetAllApplicationsResponsePBImpl() { - builder = GetAllApplicationsResponseProto.newBuilder(); - } - - public GetAllApplicationsResponsePBImpl(GetAllApplicationsResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - @Override - public List getApplicationList() { - initLocalApplicationsList(); - return this.applicationList; - } - - @Override - public void setApplicationList(List applications) { - maybeInitBuilder(); - if (applications == null) - builder.clearApplications(); - this.applicationList = applications; - } - - public GetAllApplicationsResponseProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.applicationList != null) { - addLocalApplicationsToProto(); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = GetAllApplicationsResponseProto.newBuilder(proto); - } - viaProto = false; - } - - // Once this is called. containerList will never be null - until a getProto - // is called. - private void initLocalApplicationsList() { - if (this.applicationList != null) { - return; - } - GetAllApplicationsResponseProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getApplicationsList(); - applicationList = new ArrayList(); - - for (ApplicationReportProto a : list) { - applicationList.add(convertFromProtoFormat(a)); - } - } - - private void addLocalApplicationsToProto() { - maybeInitBuilder(); - builder.clearApplications(); - if (applicationList == null) - return; - Iterable iterable = new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator iter = applicationList.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public ApplicationReportProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - builder.addAllApplications(iterable); - } - - private ApplicationReportPBImpl convertFromProtoFormat(ApplicationReportProto p) { - return new ApplicationReportPBImpl(p); - } - - private ApplicationReportProto convertToProtoFormat(ApplicationReport t) { - return ((ApplicationReportPBImpl)t).getProto(); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationReportRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationReportRequestPBImpl.java deleted file mode 100644 index e1e3308..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationReportRequestPBImpl.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationReportRequestProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationReportRequestProtoOrBuilder; - -@Private -@Unstable -public class GetApplicationReportRequestPBImpl extends GetApplicationReportRequest { - GetApplicationReportRequestProto proto = GetApplicationReportRequestProto.getDefaultInstance(); - GetApplicationReportRequestProto.Builder builder = null; - boolean viaProto = false; - - private ApplicationId applicationId = null; - - - public GetApplicationReportRequestPBImpl() { - builder = GetApplicationReportRequestProto.newBuilder(); - } - - public GetApplicationReportRequestPBImpl(GetApplicationReportRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public GetApplicationReportRequestProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (applicationId != null) { - builder.setApplicationId(convertToProtoFormat(this.applicationId)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = GetApplicationReportRequestProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public ApplicationId getApplicationId() { - GetApplicationReportRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.applicationId != null) { - return this.applicationId; - } - if (!p.hasApplicationId()) { - return null; - } - this.applicationId = convertFromProtoFormat(p.getApplicationId()); - return this.applicationId; - } - - @Override - public void setApplicationId(ApplicationId applicationId) { - maybeInitBuilder(); - if (applicationId == null) - builder.clearApplicationId(); - this.applicationId = applicationId; - } - - private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { - return new ApplicationIdPBImpl(p); - } - - private ApplicationIdProto convertToProtoFormat(ApplicationId t) { - return ((ApplicationIdPBImpl)t).getProto(); - } - - - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationReportResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationReportResponsePBImpl.java deleted file mode 100644 index ef61dfa..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationReportResponsePBImpl.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse; -import org.apache.hadoop.yarn.api.records.ApplicationReport; -import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationReportPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationReportProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationReportResponseProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationReportResponseProtoOrBuilder; - -@Private -@Unstable -public class GetApplicationReportResponsePBImpl extends GetApplicationReportResponse { - GetApplicationReportResponseProto proto = GetApplicationReportResponseProto.getDefaultInstance(); - GetApplicationReportResponseProto.Builder builder = null; - boolean viaProto = false; - - private ApplicationReport applicationReport = null; - - - public GetApplicationReportResponsePBImpl() { - builder = GetApplicationReportResponseProto.newBuilder(); - } - - public GetApplicationReportResponsePBImpl(GetApplicationReportResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public GetApplicationReportResponseProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.applicationReport != null) { - builder.setApplicationReport(convertToProtoFormat(this.applicationReport)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = GetApplicationReportResponseProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public ApplicationReport getApplicationReport() { - GetApplicationReportResponseProtoOrBuilder p = viaProto ? proto : builder; - if (this.applicationReport != null) { - return this.applicationReport; - } - if (!p.hasApplicationReport()) { - return null; - } - this.applicationReport = convertFromProtoFormat(p.getApplicationReport()); - return this.applicationReport; - } - - @Override - public void setApplicationReport(ApplicationReport applicationMaster) { - maybeInitBuilder(); - if (applicationMaster == null) - builder.clearApplicationReport(); - this.applicationReport = applicationMaster; - } - - private ApplicationReportPBImpl convertFromProtoFormat(ApplicationReportProto p) { - return new ApplicationReportPBImpl(p); - } - - private ApplicationReportProto convertToProtoFormat(ApplicationReport t) { - return ((ApplicationReportPBImpl)t).getProto(); - } - - - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterMetricsRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterMetricsRequestPBImpl.java deleted file mode 100644 index 9dcad99..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterMetricsRequestPBImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterMetricsRequestProto; - -@Private -@Unstable -public class GetClusterMetricsRequestPBImpl extends GetClusterMetricsRequest { - GetClusterMetricsRequestProto proto = GetClusterMetricsRequestProto.getDefaultInstance(); - GetClusterMetricsRequestProto.Builder builder = null; - boolean viaProto = false; - - public GetClusterMetricsRequestPBImpl() { - builder = GetClusterMetricsRequestProto.newBuilder(); - } - - public GetClusterMetricsRequestPBImpl(GetClusterMetricsRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public GetClusterMetricsRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterMetricsResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterMetricsResponsePBImpl.java deleted file mode 100644 index 635307a..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterMetricsResponsePBImpl.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse; -import org.apache.hadoop.yarn.api.records.YarnClusterMetrics; -import org.apache.hadoop.yarn.api.records.impl.pb.YarnClusterMetricsPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.YarnClusterMetricsProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterMetricsResponseProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterMetricsResponseProtoOrBuilder; - -@Private -@Unstable -public class GetClusterMetricsResponsePBImpl extends GetClusterMetricsResponse { - GetClusterMetricsResponseProto proto = GetClusterMetricsResponseProto.getDefaultInstance(); - GetClusterMetricsResponseProto.Builder builder = null; - boolean viaProto = false; - - private YarnClusterMetrics yarnClusterMetrics = null; - - - public GetClusterMetricsResponsePBImpl() { - builder = GetClusterMetricsResponseProto.newBuilder(); - } - - public GetClusterMetricsResponsePBImpl(GetClusterMetricsResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public GetClusterMetricsResponseProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.yarnClusterMetrics != null) { - builder.setClusterMetrics(convertToProtoFormat(this.yarnClusterMetrics)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = GetClusterMetricsResponseProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public YarnClusterMetrics getClusterMetrics() { - GetClusterMetricsResponseProtoOrBuilder p = viaProto ? proto : builder; - if (this.yarnClusterMetrics != null) { - return this.yarnClusterMetrics; - } - if (!p.hasClusterMetrics()) { - return null; - } - this.yarnClusterMetrics = convertFromProtoFormat(p.getClusterMetrics()); - return this.yarnClusterMetrics; - } - - @Override - public void setClusterMetrics(YarnClusterMetrics clusterMetrics) { - maybeInitBuilder(); - if (clusterMetrics == null) - builder.clearClusterMetrics(); - this.yarnClusterMetrics = clusterMetrics; - } - - private YarnClusterMetricsPBImpl convertFromProtoFormat(YarnClusterMetricsProto p) { - return new YarnClusterMetricsPBImpl(p); - } - - private YarnClusterMetricsProto convertToProtoFormat(YarnClusterMetrics t) { - return ((YarnClusterMetricsPBImpl)t).getProto(); - } - - - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterNodesRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterNodesRequestPBImpl.java deleted file mode 100644 index 766db22..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterNodesRequestPBImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesRequest; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterNodesRequestProto; - -@Private -@Unstable -public class GetClusterNodesRequestPBImpl extends GetClusterNodesRequest { - - GetClusterNodesRequestProto proto = GetClusterNodesRequestProto.getDefaultInstance(); - GetClusterNodesRequestProto.Builder builder = null; - boolean viaProto = false; - - public GetClusterNodesRequestPBImpl() { - builder = GetClusterNodesRequestProto.newBuilder(); - } - - public GetClusterNodesRequestPBImpl(GetClusterNodesRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public GetClusterNodesRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterNodesResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterNodesResponsePBImpl.java deleted file mode 100644 index 23210d4..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterNodesResponsePBImpl.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesResponse; -import org.apache.hadoop.yarn.api.records.NodeReport; -import org.apache.hadoop.yarn.api.records.impl.pb.NodeReportPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.NodeReportProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterNodesResponseProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterNodesResponseProtoOrBuilder; - -@Private -@Unstable -public class GetClusterNodesResponsePBImpl extends GetClusterNodesResponse { - - GetClusterNodesResponseProto proto = - GetClusterNodesResponseProto.getDefaultInstance(); - GetClusterNodesResponseProto.Builder builder = null; - boolean viaProto = false; - - List nodeManagerInfoList; - - public GetClusterNodesResponsePBImpl() { - builder = GetClusterNodesResponseProto.newBuilder(); - } - - public GetClusterNodesResponsePBImpl(GetClusterNodesResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - @Override - public List getNodeReports() { - initLocalNodeManagerInfosList(); - return this.nodeManagerInfoList; - } - - @Override - public void setNodeReports(List nodeManagers) { - if (nodeManagers == null) { - builder.clearNodeReports(); - } - this.nodeManagerInfoList = nodeManagers; - } - - public GetClusterNodesResponseProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.nodeManagerInfoList != null) { - addLocalNodeManagerInfosToProto(); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = GetClusterNodesResponseProto.newBuilder(proto); - } - viaProto = false; - } - - // Once this is called. containerList will never be null - until a getProto - // is called. - private void initLocalNodeManagerInfosList() { - if (this.nodeManagerInfoList != null) { - return; - } - GetClusterNodesResponseProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getNodeReportsList(); - nodeManagerInfoList = new ArrayList(); - - for (NodeReportProto a : list) { - nodeManagerInfoList.add(convertFromProtoFormat(a)); - } - } - - private void addLocalNodeManagerInfosToProto() { - maybeInitBuilder(); - builder.clearNodeReports(); - if (nodeManagerInfoList == null) - return; - Iterable iterable = new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator iter = nodeManagerInfoList.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public NodeReportProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - builder.addAllNodeReports(iterable); - } - - private NodeReportPBImpl convertFromProtoFormat(NodeReportProto p) { - return new NodeReportPBImpl(p); - } - - private NodeReportProto convertToProtoFormat(NodeReport t) { - return ((NodeReportPBImpl)t).getProto(); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusRequestPBImpl.java deleted file mode 100644 index fa88d1f..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusRequestPBImpl.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusRequest; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusRequestProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusRequestProtoOrBuilder; - -@Private -@Unstable -public class GetContainerStatusRequestPBImpl extends GetContainerStatusRequest { - GetContainerStatusRequestProto proto = GetContainerStatusRequestProto.getDefaultInstance(); - GetContainerStatusRequestProto.Builder builder = null; - boolean viaProto = false; - - private ContainerId containerId = null; - - - public GetContainerStatusRequestPBImpl() { - builder = GetContainerStatusRequestProto.newBuilder(); - } - - public GetContainerStatusRequestPBImpl(GetContainerStatusRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public GetContainerStatusRequestProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.containerId != null) { - builder.setContainerId(convertToProtoFormat(this.containerId)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = GetContainerStatusRequestProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public ContainerId getContainerId() { - GetContainerStatusRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.containerId != null) { - return this.containerId; - } - if (!p.hasContainerId()) { - return null; - } - this.containerId = convertFromProtoFormat(p.getContainerId()); - return this.containerId; - } - - @Override - public void setContainerId(ContainerId containerId) { - maybeInitBuilder(); - if (containerId == null) - builder.clearContainerId(); - this.containerId = containerId; - } - - private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { - return new ContainerIdPBImpl(p); - } - - private ContainerIdProto convertToProtoFormat(ContainerId t) { - return ((ContainerIdPBImpl)t).getProto(); - } - - - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusResponsePBImpl.java deleted file mode 100644 index 2b635f9..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusResponsePBImpl.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusResponse; -import org.apache.hadoop.yarn.api.records.ContainerStatus; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerStatusPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusResponseProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusResponseProtoOrBuilder; - -@Private -@Unstable -public class GetContainerStatusResponsePBImpl extends GetContainerStatusResponse { - GetContainerStatusResponseProto proto = GetContainerStatusResponseProto.getDefaultInstance(); - GetContainerStatusResponseProto.Builder builder = null; - boolean viaProto = false; - - private ContainerStatus containerStatus = null; - - - public GetContainerStatusResponsePBImpl() { - builder = GetContainerStatusResponseProto.newBuilder(); - } - - public GetContainerStatusResponsePBImpl(GetContainerStatusResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public GetContainerStatusResponseProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.containerStatus != null) { - builder.setStatus(convertToProtoFormat(this.containerStatus)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = GetContainerStatusResponseProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public ContainerStatus getStatus() { - GetContainerStatusResponseProtoOrBuilder p = viaProto ? proto : builder; - if (this.containerStatus != null) { - return this.containerStatus; - } - if (!p.hasStatus()) { - return null; - } - this.containerStatus = convertFromProtoFormat(p.getStatus()); - return this.containerStatus; - } - - @Override - public void setStatus(ContainerStatus status) { - maybeInitBuilder(); - if (status == null) - builder.clearStatus(); - this.containerStatus = status; - } - - private ContainerStatusPBImpl convertFromProtoFormat(ContainerStatusProto p) { - return new ContainerStatusPBImpl(p); - } - - private ContainerStatusProto convertToProtoFormat(ContainerStatus t) { - return ((ContainerStatusPBImpl)t).getProto(); - } - - - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetDelegationTokenRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetDelegationTokenRequestPBImpl.java deleted file mode 100644 index 8e98c88..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetDelegationTokenRequestPBImpl.java +++ /dev/null @@ -1,112 +0,0 @@ - /** - * 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. - */ -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenRequestProto; -import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenRequestProtoOrBuilder; -import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenRequest; - -@Private -@Unstable -public class GetDelegationTokenRequestPBImpl extends GetDelegationTokenRequest { - - String renewer; - - GetDelegationTokenRequestProto proto = - GetDelegationTokenRequestProto.getDefaultInstance(); - GetDelegationTokenRequestProto.Builder builder = null; - boolean viaProto = false; - - public GetDelegationTokenRequestPBImpl() { - builder = GetDelegationTokenRequestProto.newBuilder(); - } - - public GetDelegationTokenRequestPBImpl ( - GetDelegationTokenRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - @Override - public String getRenewer(){ - GetDelegationTokenRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.renewer != null) { - return this.renewer; - } - this.renewer = p.getRenewer(); - return this.renewer; - } - - @Override - public void setRenewer(String renewer) { - maybeInitBuilder(); - if (renewer == null) - builder.clearRenewer(); - this.renewer = renewer; - } - - public GetDelegationTokenRequestProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (renewer != null) { - builder.setRenewer(this.renewer); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = GetDelegationTokenRequestProto.newBuilder(proto); - } - viaProto = false; - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetDelegationTokenResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetDelegationTokenResponsePBImpl.java deleted file mode 100644 index c51d80d..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetDelegationTokenResponsePBImpl.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenResponseProto; -import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenResponseProtoOrBuilder; -import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; -import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse; -import org.apache.hadoop.yarn.api.records.Token; -import org.apache.hadoop.yarn.api.records.impl.pb.TokenPBImpl; - -@Private -@Unstable -public class GetDelegationTokenResponsePBImpl extends GetDelegationTokenResponse { - - Token appToken; - - - GetDelegationTokenResponseProto proto = - GetDelegationTokenResponseProto.getDefaultInstance(); - GetDelegationTokenResponseProto.Builder builder = null; - boolean viaProto = false; - - public GetDelegationTokenResponsePBImpl() { - builder = GetDelegationTokenResponseProto.newBuilder(); - } - - public GetDelegationTokenResponsePBImpl ( - GetDelegationTokenResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - @Override - public Token getRMDelegationToken() { - GetDelegationTokenResponseProtoOrBuilder p = viaProto ? proto : builder; - if (this.appToken != null) { - return this.appToken; - } - if (!p.hasToken()) { - return null; - } - this.appToken = convertFromProtoFormat(p.getToken()); - return this.appToken; - } - - @Override - public void setRMDelegationToken(Token appToken) { - maybeInitBuilder(); - if (appToken == null) - builder.clearToken(); - this.appToken = appToken; - } - - public GetDelegationTokenResponseProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (appToken != null) { - builder.setToken(convertToProtoFormat(this.appToken)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = GetDelegationTokenResponseProto.newBuilder(proto); - } - viaProto = false; - } - - - private TokenPBImpl convertFromProtoFormat(TokenProto p) { - return new TokenPBImpl(p); - } - - private TokenProto convertToProtoFormat(Token t) { - return ((TokenPBImpl)t).getProto(); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNewApplicationRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNewApplicationRequestPBImpl.java deleted file mode 100644 index 1fb3b70..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNewApplicationRequestPBImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNewApplicationRequestProto; - -@Private -@Unstable -public class GetNewApplicationRequestPBImpl extends GetNewApplicationRequest { - GetNewApplicationRequestProto proto = GetNewApplicationRequestProto.getDefaultInstance(); - GetNewApplicationRequestProto.Builder builder = null; - boolean viaProto = false; - - public GetNewApplicationRequestPBImpl() { - builder = GetNewApplicationRequestProto.newBuilder(); - } - - public GetNewApplicationRequestPBImpl(GetNewApplicationRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public GetNewApplicationRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNewApplicationResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNewApplicationResponsePBImpl.java deleted file mode 100644 index bf1a6c2..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNewApplicationResponsePBImpl.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.ResourcePBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNewApplicationResponseProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNewApplicationResponseProtoOrBuilder; - -@Private -@Unstable -public class GetNewApplicationResponsePBImpl extends GetNewApplicationResponse { - GetNewApplicationResponseProto proto = GetNewApplicationResponseProto.getDefaultInstance(); - GetNewApplicationResponseProto.Builder builder = null; - boolean viaProto = false; - - private ApplicationId applicationId = null; - private Resource maximumResourceCapability = null; - - public GetNewApplicationResponsePBImpl() { - builder = GetNewApplicationResponseProto.newBuilder(); - } - - public GetNewApplicationResponsePBImpl(GetNewApplicationResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public GetNewApplicationResponseProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (applicationId != null) { - builder.setApplicationId(convertToProtoFormat(this.applicationId)); - } - if (maximumResourceCapability != null) { - builder.setMaximumCapability(convertToProtoFormat(this.maximumResourceCapability)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = GetNewApplicationResponseProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public ApplicationId getApplicationId() { - if (this.applicationId != null) { - return this.applicationId; - } - - GetNewApplicationResponseProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasApplicationId()) { - return null; - } - - this.applicationId = convertFromProtoFormat(p.getApplicationId()); - return this.applicationId; - } - - @Override - public void setApplicationId(ApplicationId applicationId) { - maybeInitBuilder(); - if (applicationId == null) - builder.clearApplicationId(); - this.applicationId = applicationId; - } - - @Override - public Resource getMaximumResourceCapability() { - if (this.maximumResourceCapability != null) { - return this.maximumResourceCapability; - } - - GetNewApplicationResponseProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasMaximumCapability()) { - return null; - } - - this.maximumResourceCapability = convertFromProtoFormat(p.getMaximumCapability()); - return this.maximumResourceCapability; - } - - @Override - public void setMaximumResourceCapability(Resource capability) { - maybeInitBuilder(); - if(maximumResourceCapability == null) { - builder.clearMaximumCapability(); - } - this.maximumResourceCapability = capability; - } - - private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { - return new ApplicationIdPBImpl(p); - } - - private ApplicationIdProto convertToProtoFormat(ApplicationId t) { - return ((ApplicationIdPBImpl)t).getProto(); - } - - private Resource convertFromProtoFormat(ResourceProto resource) { - return new ResourcePBImpl(resource); - } - - private ResourceProto convertToProtoFormat(Resource resource) { - return ((ResourcePBImpl)resource).getProto(); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueInfoRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueInfoRequestPBImpl.java deleted file mode 100644 index 664ea23..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueInfoRequestPBImpl.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoRequest; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueInfoRequestProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueInfoRequestProtoOrBuilder; - -@Private -@Unstable -public class GetQueueInfoRequestPBImpl extends GetQueueInfoRequest { - - GetQueueInfoRequestProto proto = - GetQueueInfoRequestProto.getDefaultInstance(); - GetQueueInfoRequestProto.Builder builder = null; - boolean viaProto = false; - - public GetQueueInfoRequestPBImpl() { - builder = GetQueueInfoRequestProto.newBuilder(); - } - - public GetQueueInfoRequestPBImpl(GetQueueInfoRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - @Override - public boolean getIncludeApplications() { - GetQueueInfoRequestProtoOrBuilder p = viaProto ? proto : builder; - return (p.hasIncludeApplications()) ? p.getIncludeApplications() : false; - } - - @Override - public boolean getIncludeChildQueues() { - GetQueueInfoRequestProtoOrBuilder p = viaProto ? proto : builder; - return (p.hasIncludeChildQueues()) ? p.getIncludeChildQueues() : false; - } - - @Override - public String getQueueName() { - GetQueueInfoRequestProtoOrBuilder p = viaProto ? proto : builder; - return (p.hasQueueName()) ? p.getQueueName() : null; - } - - @Override - public boolean getRecursive() { - GetQueueInfoRequestProtoOrBuilder p = viaProto ? proto : builder; - return (p.hasRecursive()) ? p.getRecursive() : false; - } - - @Override - public void setIncludeApplications(boolean includeApplications) { - maybeInitBuilder(); - builder.setIncludeApplications(includeApplications); - } - - @Override - public void setIncludeChildQueues(boolean includeChildQueues) { - maybeInitBuilder(); - builder.setIncludeChildQueues(includeChildQueues); - } - - @Override - public void setQueueName(String queueName) { - maybeInitBuilder(); - if (queueName == null) { - builder.clearQueueName(); - return; - } - builder.setQueueName((queueName)); - } - - @Override - public void setRecursive(boolean recursive) { - maybeInitBuilder(); - builder.setRecursive(recursive); - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = GetQueueInfoRequestProto.newBuilder(proto); - } - viaProto = false; - } - - public GetQueueInfoRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueInfoResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueInfoResponsePBImpl.java deleted file mode 100644 index 7d60ae1..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueInfoResponsePBImpl.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoResponse; -import org.apache.hadoop.yarn.api.records.QueueInfo; -import org.apache.hadoop.yarn.api.records.impl.pb.QueueInfoPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.QueueInfoProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueInfoResponseProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueInfoResponseProtoOrBuilder; - -@Private -@Unstable -public class GetQueueInfoResponsePBImpl extends GetQueueInfoResponse { - - QueueInfo queueInfo; - - GetQueueInfoResponseProto proto = - GetQueueInfoResponseProto.getDefaultInstance(); - GetQueueInfoResponseProto.Builder builder = null; - boolean viaProto = false; - - public GetQueueInfoResponsePBImpl() { - builder = GetQueueInfoResponseProto.newBuilder(); - } - - public GetQueueInfoResponsePBImpl(GetQueueInfoResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public GetQueueInfoResponseProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - @Override - public QueueInfo getQueueInfo() { - if (this.queueInfo != null) { - return this.queueInfo; - } - - GetQueueInfoResponseProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasQueueInfo()) { - return null; - } - this.queueInfo = convertFromProtoFormat(p.getQueueInfo()); - return this.queueInfo; - } - - @Override - public void setQueueInfo(QueueInfo queueInfo) { - maybeInitBuilder(); - if(queueInfo == null) { - builder.clearQueueInfo(); - } - this.queueInfo = queueInfo; - } - - private void mergeLocalToBuilder() { - if (this.queueInfo != null) { - builder.setQueueInfo(convertToProtoFormat(this.queueInfo)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = GetQueueInfoResponseProto.newBuilder(proto); - } - viaProto = false; - } - - private QueueInfo convertFromProtoFormat(QueueInfoProto queueInfo) { - return new QueueInfoPBImpl(queueInfo); - } - - private QueueInfoProto convertToProtoFormat(QueueInfo queueInfo) { - return ((QueueInfoPBImpl)queueInfo).getProto(); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueUserAclsInfoRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueUserAclsInfoRequestPBImpl.java deleted file mode 100644 index d964e85..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueUserAclsInfoRequestPBImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetQueueUserAclsInfoRequest; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueUserAclsInfoRequestProto; - -@Private -@Unstable -public class GetQueueUserAclsInfoRequestPBImpl extends GetQueueUserAclsInfoRequest { - - GetQueueUserAclsInfoRequestProto proto = - GetQueueUserAclsInfoRequestProto.getDefaultInstance(); - GetQueueUserAclsInfoRequestProto.Builder builder = null; - boolean viaProto = false; - - public GetQueueUserAclsInfoRequestPBImpl() { - builder = GetQueueUserAclsInfoRequestProto.newBuilder(); - } - - public GetQueueUserAclsInfoRequestPBImpl(GetQueueUserAclsInfoRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public GetQueueUserAclsInfoRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueUserAclsInfoResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueUserAclsInfoResponsePBImpl.java deleted file mode 100644 index d9fdada..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueUserAclsInfoResponsePBImpl.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.GetQueueUserAclsInfoResponse; -import org.apache.hadoop.yarn.api.records.QueueUserACLInfo; -import org.apache.hadoop.yarn.api.records.impl.pb.QueueUserACLInfoPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.QueueUserACLInfoProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueUserAclsInfoResponseProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueUserAclsInfoResponseProtoOrBuilder; - -@Private -@Unstable -public class GetQueueUserAclsInfoResponsePBImpl extends GetQueueUserAclsInfoResponse { - - List queueUserAclsInfoList; - - GetQueueUserAclsInfoResponseProto proto = - GetQueueUserAclsInfoResponseProto.getDefaultInstance(); - GetQueueUserAclsInfoResponseProto.Builder builder = null; - boolean viaProto = false; - - public GetQueueUserAclsInfoResponsePBImpl() { - builder = GetQueueUserAclsInfoResponseProto.newBuilder(); - } - - public GetQueueUserAclsInfoResponsePBImpl( - GetQueueUserAclsInfoResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - @Override - public List getUserAclsInfoList() { - initLocalQueueUserAclsList(); - return queueUserAclsInfoList; - } - - @Override - public void setUserAclsInfoList(List queueUserAclsList) { - if (queueUserAclsList == null) { - builder.clearQueueUserAcls(); - } - this.queueUserAclsInfoList = queueUserAclsList; - } - - public GetQueueUserAclsInfoResponseProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.queueUserAclsInfoList != null) { - addLocalQueueUserACLInfosToProto(); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = GetQueueUserAclsInfoResponseProto.newBuilder(proto); - } - viaProto = false; - } - - // Once this is called. containerList will never be null - until a getProto - // is called. - private void initLocalQueueUserAclsList() { - if (this.queueUserAclsInfoList != null) { - return; - } - GetQueueUserAclsInfoResponseProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getQueueUserAclsList(); - queueUserAclsInfoList = new ArrayList(); - - for (QueueUserACLInfoProto a : list) { - queueUserAclsInfoList.add(convertFromProtoFormat(a)); - } - } - - private void addLocalQueueUserACLInfosToProto() { - maybeInitBuilder(); - builder.clearQueueUserAcls(); - if (queueUserAclsInfoList == null) - return; - Iterable iterable = new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator iter = queueUserAclsInfoList.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public QueueUserACLInfoProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - builder.addAllQueueUserAcls(iterable); - } - - private QueueUserACLInfoPBImpl convertFromProtoFormat(QueueUserACLInfoProto p) { - return new QueueUserACLInfoPBImpl(p); - } - - private QueueUserACLInfoProto convertToProtoFormat(QueueUserACLInfo t) { - return ((QueueUserACLInfoPBImpl)t).getProto(); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/KillApplicationRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/KillApplicationRequestPBImpl.java deleted file mode 100644 index 2b13a72..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/KillApplicationRequestPBImpl.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.KillApplicationRequestProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.KillApplicationRequestProtoOrBuilder; - -@Private -@Unstable -public class KillApplicationRequestPBImpl extends KillApplicationRequest { - KillApplicationRequestProto proto = KillApplicationRequestProto.getDefaultInstance(); - KillApplicationRequestProto.Builder builder = null; - boolean viaProto = false; - - private ApplicationId applicationId = null; - - - public KillApplicationRequestPBImpl() { - builder = KillApplicationRequestProto.newBuilder(); - } - - public KillApplicationRequestPBImpl(KillApplicationRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public KillApplicationRequestProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.applicationId != null) { - builder.setApplicationId(convertToProtoFormat(this.applicationId)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = KillApplicationRequestProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public ApplicationId getApplicationId() { - KillApplicationRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.applicationId != null) { - return this.applicationId; - } - if (!p.hasApplicationId()) { - return null; - } - this.applicationId = convertFromProtoFormat(p.getApplicationId()); - return this.applicationId; - } - - @Override - public void setApplicationId(ApplicationId applicationId) { - maybeInitBuilder(); - if (applicationId == null) - builder.clearApplicationId(); - this.applicationId = applicationId; - } - - private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { - return new ApplicationIdPBImpl(p); - } - - private ApplicationIdProto convertToProtoFormat(ApplicationId t) { - return ((ApplicationIdPBImpl)t).getProto(); - } - - - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/KillApplicationResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/KillApplicationResponsePBImpl.java deleted file mode 100644 index f16d417..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/KillApplicationResponsePBImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.KillApplicationResponse; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.KillApplicationResponseProto; - -@Private -@Unstable -public class KillApplicationResponsePBImpl extends KillApplicationResponse { - KillApplicationResponseProto proto = KillApplicationResponseProto.getDefaultInstance(); - KillApplicationResponseProto.Builder builder = null; - boolean viaProto = false; - - public KillApplicationResponsePBImpl() { - builder = KillApplicationResponseProto.newBuilder(); - } - - public KillApplicationResponsePBImpl(KillApplicationResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public KillApplicationResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshAdminAclsRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshAdminAclsRequestPBImpl.java deleted file mode 100644 index c4adb52..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshAdminAclsRequestPBImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/** -* 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. -*/ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.RefreshAdminAclsRequest; -import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshAdminAclsRequestProto; - -@Private -@Unstable -public class RefreshAdminAclsRequestPBImpl -extends RefreshAdminAclsRequest { - - RefreshAdminAclsRequestProto proto = RefreshAdminAclsRequestProto.getDefaultInstance(); - RefreshAdminAclsRequestProto.Builder builder = null; - boolean viaProto = false; - - public RefreshAdminAclsRequestPBImpl() { - builder = RefreshAdminAclsRequestProto.newBuilder(); - } - - public RefreshAdminAclsRequestPBImpl(RefreshAdminAclsRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public RefreshAdminAclsRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshAdminAclsResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshAdminAclsResponsePBImpl.java deleted file mode 100644 index a013e61..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshAdminAclsResponsePBImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/** -* 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. -*/ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.RefreshAdminAclsResponse; -import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshAdminAclsResponseProto; - -@Private -@Unstable -public class RefreshAdminAclsResponsePBImpl extends RefreshAdminAclsResponse { - - RefreshAdminAclsResponseProto proto = RefreshAdminAclsResponseProto.getDefaultInstance(); - RefreshAdminAclsResponseProto.Builder builder = null; - boolean viaProto = false; - - public RefreshAdminAclsResponsePBImpl() { - builder = RefreshAdminAclsResponseProto.newBuilder(); - } - - public RefreshAdminAclsResponsePBImpl(RefreshAdminAclsResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public RefreshAdminAclsResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshNodesRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshNodesRequestPBImpl.java deleted file mode 100644 index 631a6d7..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshNodesRequestPBImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/** -* 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. -*/ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.RefreshNodesRequest; -import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshNodesRequestProto; - -@Private -@Unstable -public class RefreshNodesRequestPBImpl extends RefreshNodesRequest { - - RefreshNodesRequestProto proto = RefreshNodesRequestProto.getDefaultInstance(); - RefreshNodesRequestProto.Builder builder = null; - boolean viaProto = false; - - public RefreshNodesRequestPBImpl() { - builder = RefreshNodesRequestProto.newBuilder(); - } - - public RefreshNodesRequestPBImpl(RefreshNodesRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public RefreshNodesRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshNodesResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshNodesResponsePBImpl.java deleted file mode 100644 index 84b709e..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshNodesResponsePBImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/** -* 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. -*/ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.RefreshNodesResponse; -import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshNodesResponseProto; - -@Private -@Unstable -public class RefreshNodesResponsePBImpl extends RefreshNodesResponse { - - RefreshNodesResponseProto proto = RefreshNodesResponseProto.getDefaultInstance(); - RefreshNodesResponseProto.Builder builder = null; - boolean viaProto = false; - - public RefreshNodesResponsePBImpl() { - builder = RefreshNodesResponseProto.newBuilder(); - } - - public RefreshNodesResponsePBImpl(RefreshNodesResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public RefreshNodesResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshQueuesRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshQueuesRequestPBImpl.java deleted file mode 100644 index 3a6f034..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshQueuesRequestPBImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/** -* 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. -*/ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.RefreshQueuesRequest; -import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshQueuesRequestProto; - -@Private -@Unstable -public class RefreshQueuesRequestPBImpl extends RefreshQueuesRequest { - - RefreshQueuesRequestProto proto = RefreshQueuesRequestProto.getDefaultInstance(); - RefreshQueuesRequestProto.Builder builder = null; - boolean viaProto = false; - - public RefreshQueuesRequestPBImpl() { - builder = RefreshQueuesRequestProto.newBuilder(); - } - - public RefreshQueuesRequestPBImpl(RefreshQueuesRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public RefreshQueuesRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshQueuesResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshQueuesResponsePBImpl.java deleted file mode 100644 index a8cc9d699..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshQueuesResponsePBImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/** -* 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. -*/ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.RefreshQueuesResponse; -import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshQueuesResponseProto; - -@Private -@Unstable -public class RefreshQueuesResponsePBImpl extends RefreshQueuesResponse { - - RefreshQueuesResponseProto proto = RefreshQueuesResponseProto.getDefaultInstance(); - RefreshQueuesResponseProto.Builder builder = null; - boolean viaProto = false; - - public RefreshQueuesResponsePBImpl() { - builder = RefreshQueuesResponseProto.newBuilder(); - } - - public RefreshQueuesResponsePBImpl(RefreshQueuesResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public RefreshQueuesResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshServiceAclsRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshServiceAclsRequestPBImpl.java deleted file mode 100644 index 5d88373..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshServiceAclsRequestPBImpl.java +++ /dev/null @@ -1,70 +0,0 @@ -/** -* 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. -*/ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.RefreshServiceAclsRequest; -import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshServiceAclsRequestProto; - -@Private -@Unstable -public class RefreshServiceAclsRequestPBImpl extends RefreshServiceAclsRequest { - - RefreshServiceAclsRequestProto proto = - RefreshServiceAclsRequestProto.getDefaultInstance(); - RefreshServiceAclsRequestProto.Builder builder = null; - boolean viaProto = false; - - public RefreshServiceAclsRequestPBImpl() { - builder = RefreshServiceAclsRequestProto.newBuilder(); - } - - public RefreshServiceAclsRequestPBImpl( - RefreshServiceAclsRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public RefreshServiceAclsRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshServiceAclsResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshServiceAclsResponsePBImpl.java deleted file mode 100644 index ca95a3a..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshServiceAclsResponsePBImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -/** -* 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. -*/ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.RefreshServiceAclsResponse; -import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshServiceAclsResponseProto; - -@Private -@Unstable -public class RefreshServiceAclsResponsePBImpl extends - RefreshServiceAclsResponse { - - RefreshServiceAclsResponseProto proto = - RefreshServiceAclsResponseProto.getDefaultInstance(); - RefreshServiceAclsResponseProto.Builder builder = null; - boolean viaProto = false; - - public RefreshServiceAclsResponsePBImpl() { - builder = RefreshServiceAclsResponseProto.newBuilder(); - } - - public RefreshServiceAclsResponsePBImpl( - RefreshServiceAclsResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public RefreshServiceAclsResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshSuperUserGroupsConfigurationRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshSuperUserGroupsConfigurationRequestPBImpl.java deleted file mode 100644 index 2852bd0..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshSuperUserGroupsConfigurationRequestPBImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/** -* 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. -*/ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.RefreshSuperUserGroupsConfigurationRequest; -import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshSuperUserGroupsConfigurationRequestProto; - -@Private -@Unstable -public class RefreshSuperUserGroupsConfigurationRequestPBImpl -extends RefreshSuperUserGroupsConfigurationRequest { - - RefreshSuperUserGroupsConfigurationRequestProto proto = RefreshSuperUserGroupsConfigurationRequestProto.getDefaultInstance(); - RefreshSuperUserGroupsConfigurationRequestProto.Builder builder = null; - boolean viaProto = false; - - public RefreshSuperUserGroupsConfigurationRequestPBImpl() { - builder = RefreshSuperUserGroupsConfigurationRequestProto.newBuilder(); - } - - public RefreshSuperUserGroupsConfigurationRequestPBImpl(RefreshSuperUserGroupsConfigurationRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public RefreshSuperUserGroupsConfigurationRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshSuperUserGroupsConfigurationResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshSuperUserGroupsConfigurationResponsePBImpl.java deleted file mode 100644 index 89a850c..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshSuperUserGroupsConfigurationResponsePBImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/** -* 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. -*/ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.RefreshSuperUserGroupsConfigurationResponse; -import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshSuperUserGroupsConfigurationResponseProto; - -@Private -@Unstable -public class RefreshSuperUserGroupsConfigurationResponsePBImpl extends RefreshSuperUserGroupsConfigurationResponse { - - RefreshSuperUserGroupsConfigurationResponseProto proto = RefreshSuperUserGroupsConfigurationResponseProto.getDefaultInstance(); - RefreshSuperUserGroupsConfigurationResponseProto.Builder builder = null; - boolean viaProto = false; - - public RefreshSuperUserGroupsConfigurationResponsePBImpl() { - builder = RefreshSuperUserGroupsConfigurationResponseProto.newBuilder(); - } - - public RefreshSuperUserGroupsConfigurationResponsePBImpl(RefreshSuperUserGroupsConfigurationResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public RefreshSuperUserGroupsConfigurationResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshUserToGroupsMappingsRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshUserToGroupsMappingsRequestPBImpl.java deleted file mode 100644 index 382d188..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshUserToGroupsMappingsRequestPBImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/** -* 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. -*/ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.RefreshUserToGroupsMappingsRequest; -import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshUserToGroupsMappingsRequestProto; - -@Private -@Unstable -public class RefreshUserToGroupsMappingsRequestPBImpl -extends RefreshUserToGroupsMappingsRequest { - - RefreshUserToGroupsMappingsRequestProto proto = RefreshUserToGroupsMappingsRequestProto.getDefaultInstance(); - RefreshUserToGroupsMappingsRequestProto.Builder builder = null; - boolean viaProto = false; - - public RefreshUserToGroupsMappingsRequestPBImpl() { - builder = RefreshUserToGroupsMappingsRequestProto.newBuilder(); - } - - public RefreshUserToGroupsMappingsRequestPBImpl(RefreshUserToGroupsMappingsRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public RefreshUserToGroupsMappingsRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshUserToGroupsMappingsResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshUserToGroupsMappingsResponsePBImpl.java deleted file mode 100644 index 6936eb0..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshUserToGroupsMappingsResponsePBImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/** -* 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. -*/ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.RefreshUserToGroupsMappingsResponse; -import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshUserToGroupsMappingsResponseProto; - -@Private -@Unstable -public class RefreshUserToGroupsMappingsResponsePBImpl extends RefreshUserToGroupsMappingsResponse { - - RefreshUserToGroupsMappingsResponseProto proto = RefreshUserToGroupsMappingsResponseProto.getDefaultInstance(); - RefreshUserToGroupsMappingsResponseProto.Builder builder = null; - boolean viaProto = false; - - public RefreshUserToGroupsMappingsResponsePBImpl() { - builder = RefreshUserToGroupsMappingsResponseProto.newBuilder(); - } - - public RefreshUserToGroupsMappingsResponsePBImpl(RefreshUserToGroupsMappingsResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public RefreshUserToGroupsMappingsResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RegisterApplicationMasterRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RegisterApplicationMasterRequestPBImpl.java deleted file mode 100644 index 72f4520..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RegisterApplicationMasterRequestPBImpl.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterRequest; -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationAttemptIdPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterRequestProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterRequestProtoOrBuilder; - -@Private -@Unstable -public class RegisterApplicationMasterRequestPBImpl extends RegisterApplicationMasterRequest { - RegisterApplicationMasterRequestProto proto = RegisterApplicationMasterRequestProto.getDefaultInstance(); - RegisterApplicationMasterRequestProto.Builder builder = null; - boolean viaProto = false; - - private ApplicationAttemptId applicationAttemptId = null; - - - public RegisterApplicationMasterRequestPBImpl() { - builder = RegisterApplicationMasterRequestProto.newBuilder(); - } - - public RegisterApplicationMasterRequestPBImpl(RegisterApplicationMasterRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public RegisterApplicationMasterRequestProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.applicationAttemptId != null && !((ApplicationAttemptIdPBImpl)this.applicationAttemptId).getProto().equals(builder.getApplicationAttemptId())) { - builder.setApplicationAttemptId(convertToProtoFormat(this.applicationAttemptId)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = RegisterApplicationMasterRequestProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public ApplicationAttemptId getApplicationAttemptId() { - RegisterApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.applicationAttemptId != null) { - return this.applicationAttemptId; - } - if (!p.hasApplicationAttemptId()) { - return null; - } - this.applicationAttemptId = convertFromProtoFormat(p.getApplicationAttemptId()); - return this.applicationAttemptId; - } - - @Override - public void setApplicationAttemptId(ApplicationAttemptId applicationMaster) { - maybeInitBuilder(); - if (applicationMaster == null) - builder.clearApplicationAttemptId(); - this.applicationAttemptId = applicationMaster; - } - - @Override - public String getHost() { - RegisterApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; - return p.getHost(); - } - - @Override - public void setHost(String host) { - maybeInitBuilder(); - builder.setHost(host); - } - - @Override - public int getRpcPort() { - RegisterApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; - return p.getRpcPort(); - } - - @Override - public void setRpcPort(int port) { - maybeInitBuilder(); - builder.setRpcPort(port); - } - - @Override - public String getTrackingUrl() { - RegisterApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; - return p.getTrackingUrl(); - } - - @Override - public void setTrackingUrl(String url) { - maybeInitBuilder(); - builder.setTrackingUrl(url); - } - - private ApplicationAttemptIdPBImpl convertFromProtoFormat(ApplicationAttemptIdProto p) { - return new ApplicationAttemptIdPBImpl(p); - } - - private ApplicationAttemptIdProto convertToProtoFormat(ApplicationAttemptId t) { - return ((ApplicationAttemptIdPBImpl)t).getProto(); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RegisterApplicationMasterResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RegisterApplicationMasterResponsePBImpl.java deleted file mode 100644 index e2962e3..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RegisterApplicationMasterResponsePBImpl.java +++ /dev/null @@ -1,235 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse; -import org.apache.hadoop.yarn.api.records.ApplicationAccessType; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils; -import org.apache.hadoop.yarn.api.records.impl.pb.ResourcePBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterResponseProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterResponseProtoOrBuilder; - -import com.google.protobuf.ByteString; - - -@Private -@Unstable -public class RegisterApplicationMasterResponsePBImpl extends - RegisterApplicationMasterResponse { - RegisterApplicationMasterResponseProto proto = - RegisterApplicationMasterResponseProto.getDefaultInstance(); - RegisterApplicationMasterResponseProto.Builder builder = null; - boolean viaProto = false; - - private Resource maximumResourceCapability; - private Map applicationACLS = null; - - public RegisterApplicationMasterResponsePBImpl() { - builder = RegisterApplicationMasterResponseProto.newBuilder(); - } - - public RegisterApplicationMasterResponsePBImpl(RegisterApplicationMasterResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public RegisterApplicationMasterResponseProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void mergeLocalToBuilder() { - if (this.maximumResourceCapability != null) { - builder.setMaximumCapability( - convertToProtoFormat(this.maximumResourceCapability)); - } - if (this.applicationACLS != null) { - addApplicationACLs(); - } - } - - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = RegisterApplicationMasterResponseProto.newBuilder(proto); - } - viaProto = false; - } - - @Override - public Resource getMaximumResourceCapability() { - if (this.maximumResourceCapability != null) { - return this.maximumResourceCapability; - } - - RegisterApplicationMasterResponseProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasMaximumCapability()) { - return null; - } - - this.maximumResourceCapability = convertFromProtoFormat(p.getMaximumCapability()); - return this.maximumResourceCapability; - } - - @Override - public void setMaximumResourceCapability(Resource capability) { - maybeInitBuilder(); - if(maximumResourceCapability == null) { - builder.clearMaximumCapability(); - } - this.maximumResourceCapability = capability; - } - - @Override - public Map getApplicationACLs() { - initApplicationACLs(); - return this.applicationACLS; - } - - private void initApplicationACLs() { - if (this.applicationACLS != null) { - return; - } - RegisterApplicationMasterResponseProtoOrBuilder p = viaProto ? proto - : builder; - List list = p.getApplicationACLsList(); - this.applicationACLS = new HashMap(list - .size()); - - for (ApplicationACLMapProto aclProto : list) { - this.applicationACLS.put(ProtoUtils.convertFromProtoFormat(aclProto - .getAccessType()), aclProto.getAcl()); - } - } - - private void addApplicationACLs() { - maybeInitBuilder(); - builder.clearApplicationACLs(); - if (applicationACLS == null) { - return; - } - Iterable values - = new Iterable() { - - @Override - public Iterator iterator() { - return new Iterator() { - Iterator aclsIterator = applicationACLS - .keySet().iterator(); - - @Override - public boolean hasNext() { - return aclsIterator.hasNext(); - } - - @Override - public ApplicationACLMapProto next() { - ApplicationAccessType key = aclsIterator.next(); - return ApplicationACLMapProto.newBuilder().setAcl( - applicationACLS.get(key)).setAccessType( - ProtoUtils.convertToProtoFormat(key)).build(); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - }; - this.builder.addAllApplicationACLs(values); - } - - @Override - public void setApplicationACLs( - final Map appACLs) { - if (appACLs == null) - return; - initApplicationACLs(); - this.applicationACLS.clear(); - this.applicationACLS.putAll(appACLs); - } - - @Override - public void setClientToAMTokenMasterKey(ByteBuffer key) { - if (key == null) { - return; - } - maybeInitBuilder(); - builder.setClientToAmTokenMasterKey(ByteString.copyFrom(key)); - } - - @Override - public ByteBuffer getClientToAMTokenMasterKey() { - ByteBuffer key = - ByteBuffer.wrap(builder.getClientToAmTokenMasterKey().toByteArray()); - return key; - } - - private Resource convertFromProtoFormat(ResourceProto resource) { - return new ResourcePBImpl(resource); - } - - private ResourceProto convertToProtoFormat(Resource resource) { - return ((ResourcePBImpl)resource).getProto(); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RenewDelegationTokenRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RenewDelegationTokenRequestPBImpl.java deleted file mode 100644 index 3e109c5..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RenewDelegationTokenRequestPBImpl.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProto; -import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProtoOrBuilder; -import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; -import org.apache.hadoop.yarn.api.protocolrecords.RenewDelegationTokenRequest; -import org.apache.hadoop.yarn.api.records.Token; -import org.apache.hadoop.yarn.api.records.impl.pb.TokenPBImpl; - -@Private -@Unstable -public class RenewDelegationTokenRequestPBImpl extends - RenewDelegationTokenRequest { - RenewDelegationTokenRequestProto proto = - RenewDelegationTokenRequestProto.getDefaultInstance(); - RenewDelegationTokenRequestProto.Builder builder = null; - boolean viaProto = false; - - public RenewDelegationTokenRequestPBImpl() { - builder = RenewDelegationTokenRequestProto.newBuilder(); - } - - public RenewDelegationTokenRequestPBImpl ( - RenewDelegationTokenRequestProto proto) { - this.proto = proto; - this.viaProto = true; - } - - Token token; - - @Override - public Token getDelegationToken() { - RenewDelegationTokenRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.token != null) { - return this.token; - } - this.token = convertFromProtoFormat(p.getToken()); - return this.token; - } - - @Override - public void setDelegationToken(Token token) { - maybeInitBuilder(); - if (token == null) - builder.clearToken(); - this.token = token; - } - - public RenewDelegationTokenRequestProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (token != null) { - builder.setToken(convertToProtoFormat(this.token)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = RenewDelegationTokenRequestProto.newBuilder(proto); - } - viaProto = false; - } - - - private TokenPBImpl convertFromProtoFormat(TokenProto p) { - return new TokenPBImpl(p); - } - - private TokenProto convertToProtoFormat(Token t) { - return ((TokenPBImpl)t).getProto(); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RenewDelegationTokenResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RenewDelegationTokenResponsePBImpl.java deleted file mode 100644 index ecf0b30..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RenewDelegationTokenResponsePBImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenResponseProto; -import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenResponseProtoOrBuilder; -import org.apache.hadoop.yarn.api.protocolrecords.RenewDelegationTokenResponse; - -@Private -@Unstable -public class RenewDelegationTokenResponsePBImpl extends - RenewDelegationTokenResponse { - - RenewDelegationTokenResponseProto proto = - RenewDelegationTokenResponseProto.getDefaultInstance(); - RenewDelegationTokenResponseProto.Builder builder = null; - boolean viaProto = false; - - public RenewDelegationTokenResponsePBImpl() { - this.builder = RenewDelegationTokenResponseProto.newBuilder(); - } - - public RenewDelegationTokenResponsePBImpl ( - RenewDelegationTokenResponseProto proto) { - this.proto = proto; - this.viaProto = true; - } - - public RenewDelegationTokenResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = RenewDelegationTokenResponseProto.newBuilder(proto); - } - viaProto = false; - } - - @Override - public long getNextExpirationTime() { - RenewDelegationTokenResponseProtoOrBuilder p = viaProto ? proto : builder; - return p.getNewExpiryTime(); - } - - @Override - public void setNextExpirationTime(long expTime) { - maybeInitBuilder(); - builder.setNewExpiryTime(expTime); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerRequestPBImpl.java deleted file mode 100644 index acb9d34..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerRequestPBImpl.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; -import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest; -import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; -import org.apache.hadoop.yarn.api.records.Token; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerLaunchContextPBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.TokenPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainerRequestProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainerRequestProtoOrBuilder; - -@Private -@Unstable -public class StartContainerRequestPBImpl extends StartContainerRequest { - StartContainerRequestProto proto = StartContainerRequestProto.getDefaultInstance(); - StartContainerRequestProto.Builder builder = null; - boolean viaProto = false; - - private ContainerLaunchContext containerLaunchContext = null; - - private Token containerToken = null; - - public StartContainerRequestPBImpl() { - builder = StartContainerRequestProto.newBuilder(); - } - - public StartContainerRequestPBImpl(StartContainerRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public StartContainerRequestProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.containerLaunchContext != null) { - builder.setContainerLaunchContext(convertToProtoFormat(this.containerLaunchContext)); - } - if(this.containerToken != null) { - builder.setContainerToken(convertToProtoFormat(this.containerToken)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = StartContainerRequestProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public ContainerLaunchContext getContainerLaunchContext() { - StartContainerRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.containerLaunchContext != null) { - return this.containerLaunchContext; - } - if (!p.hasContainerLaunchContext()) { - return null; - } - this.containerLaunchContext = convertFromProtoFormat(p.getContainerLaunchContext()); - return this.containerLaunchContext; - } - - @Override - public void setContainerLaunchContext(ContainerLaunchContext containerLaunchContext) { - maybeInitBuilder(); - if (containerLaunchContext == null) - builder.clearContainerLaunchContext(); - this.containerLaunchContext = containerLaunchContext; - } - - @Override - public Token getContainerToken() { - StartContainerRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.containerToken != null) { - return this.containerToken; - } - if (!p.hasContainerToken()) { - return null; - } - this.containerToken = convertFromProtoFormat(p.getContainerToken()); - return this.containerToken; - } - - @Override - public void setContainerToken(Token containerToken) { - maybeInitBuilder(); - if(containerToken == null) { - builder.clearContainerToken(); - } - this.containerToken = containerToken; - } - - private ContainerLaunchContextPBImpl convertFromProtoFormat(ContainerLaunchContextProto p) { - return new ContainerLaunchContextPBImpl(p); - } - - private ContainerLaunchContextProto convertToProtoFormat(ContainerLaunchContext t) { - return ((ContainerLaunchContextPBImpl)t).getProto(); - } - - - - private TokenPBImpl convertFromProtoFormat(TokenProto containerProto) { - return new TokenPBImpl(containerProto); - } - - private TokenProto convertToProtoFormat(Token container) { - return ((TokenPBImpl)container).getProto(); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerResponsePBImpl.java deleted file mode 100644 index 8edbfa7..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerResponsePBImpl.java +++ /dev/null @@ -1,176 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.StartContainerResponse; -import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils; -import org.apache.hadoop.yarn.proto.YarnProtos.StringBytesMapProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainerResponseProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainerResponseProtoOrBuilder; - -import com.google.protobuf.ByteString; - -@Private -@Unstable -public class StartContainerResponsePBImpl extends StartContainerResponse { - StartContainerResponseProto proto = StartContainerResponseProto.getDefaultInstance(); - StartContainerResponseProto.Builder builder = null; - boolean viaProto = false; - - private Map servicesMetaData = null; - - public StartContainerResponsePBImpl() { - builder = StartContainerResponseProto.newBuilder(); - } - - public StartContainerResponsePBImpl(StartContainerResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public synchronized StartContainerResponseProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private synchronized void mergeLocalToBuilder() { - if (this.servicesMetaData != null) { - addServicesMetaDataToProto(); - } - } - - protected final ByteBuffer convertFromProtoFormat(ByteString byteString) { - return ProtoUtils.convertFromProtoFormat(byteString); - } - - protected final ByteString convertToProtoFormat(ByteBuffer byteBuffer) { - return ProtoUtils.convertToProtoFormat(byteBuffer); - } - - private synchronized void mergeLocalToProto() { - if (viaProto) { - maybeInitBuilder(); - } - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private synchronized void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = StartContainerResponseProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public synchronized Map getAllServicesMetaData() { - initServicesMetaData(); - return this.servicesMetaData; - } - @Override - public synchronized void setAllServicesMetaData( - Map servicesMetaData) { - if(servicesMetaData == null) { - return; - } - initServicesMetaData(); - this.servicesMetaData.clear(); - this.servicesMetaData.putAll(servicesMetaData); - } - - private synchronized void initServicesMetaData() { - if (this.servicesMetaData != null) { - return; - } - StartContainerResponseProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getServicesMetaDataList(); - this.servicesMetaData = new HashMap(); - - for (StringBytesMapProto c : list) { - this.servicesMetaData.put(c.getKey(), convertFromProtoFormat(c.getValue())); - } - } - - private synchronized void addServicesMetaDataToProto() { - maybeInitBuilder(); - builder.clearServicesMetaData(); - if (servicesMetaData == null) - return; - Iterable iterable = new Iterable() { - - @Override - public synchronized Iterator iterator() { - return new Iterator() { - - Iterator keyIter = servicesMetaData.keySet().iterator(); - - @Override - public synchronized void remove() { - throw new UnsupportedOperationException(); - } - - @Override - public synchronized StringBytesMapProto next() { - String key = keyIter.next(); - return StringBytesMapProto.newBuilder().setKey(key).setValue(convertToProtoFormat(servicesMetaData.get(key))).build(); - } - - @Override - public synchronized boolean hasNext() { - return keyIter.hasNext(); - } - }; - } - }; - builder.addAllServicesMetaData(iterable); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainerRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainerRequestPBImpl.java deleted file mode 100644 index dfba527..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainerRequestPBImpl.java +++ /dev/null @@ -1,130 +0,0 @@ -/** -* 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. -*/ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.StopContainerRequest; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainerRequestProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainerRequestProtoOrBuilder; - -@Private -@Unstable -public class StopContainerRequestPBImpl extends StopContainerRequest { - StopContainerRequestProto proto = StopContainerRequestProto.getDefaultInstance(); - StopContainerRequestProto.Builder builder = null; - boolean viaProto = false; - - private ContainerId containerId = null; - - - public StopContainerRequestPBImpl() { - builder = StopContainerRequestProto.newBuilder(); - } - - public StopContainerRequestPBImpl(StopContainerRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public StopContainerRequestProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.containerId != null) { - builder.setContainerId(convertToProtoFormat(this.containerId)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = StopContainerRequestProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public ContainerId getContainerId() { - StopContainerRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.containerId != null) { - return this.containerId; - } - if (!p.hasContainerId()) { - return null; - } - this.containerId = convertFromProtoFormat(p.getContainerId()); - return this.containerId; - } - - @Override - public void setContainerId(ContainerId containerId) { - maybeInitBuilder(); - if (containerId == null) - builder.clearContainerId(); - this.containerId = containerId; - } - - private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { - return new ContainerIdPBImpl(p); - } - - private ContainerIdProto convertToProtoFormat(ContainerId t) { - return ((ContainerIdPBImpl)t).getProto(); - } - - - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainerResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainerResponsePBImpl.java deleted file mode 100644 index 6e3fe21..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainerResponsePBImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/** -* 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. -*/ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.StopContainerResponse; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainerResponseProto; - -@Private -@Unstable -public class StopContainerResponsePBImpl extends StopContainerResponse { - StopContainerResponseProto proto = StopContainerResponseProto.getDefaultInstance(); - StopContainerResponseProto.Builder builder = null; - boolean viaProto = false; - - public StopContainerResponsePBImpl() { - builder = StopContainerResponseProto.newBuilder(); - } - - public StopContainerResponsePBImpl(StopContainerResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public StopContainerResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SubmitApplicationRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SubmitApplicationRequestPBImpl.java deleted file mode 100644 index ab33412..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SubmitApplicationRequestPBImpl.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest; -import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; -import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationSubmissionContextPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationSubmissionContextProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.SubmitApplicationRequestProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.SubmitApplicationRequestProtoOrBuilder; - -@Private -@Unstable -public class SubmitApplicationRequestPBImpl extends SubmitApplicationRequest { - SubmitApplicationRequestProto proto = SubmitApplicationRequestProto.getDefaultInstance(); - SubmitApplicationRequestProto.Builder builder = null; - boolean viaProto = false; - - private ApplicationSubmissionContext applicationSubmissionContext = null; - - - public SubmitApplicationRequestPBImpl() { - builder = SubmitApplicationRequestProto.newBuilder(); - } - - public SubmitApplicationRequestPBImpl(SubmitApplicationRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public SubmitApplicationRequestProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.applicationSubmissionContext != null) { - builder.setApplicationSubmissionContext(convertToProtoFormat(this.applicationSubmissionContext)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = SubmitApplicationRequestProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public ApplicationSubmissionContext getApplicationSubmissionContext() { - SubmitApplicationRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.applicationSubmissionContext != null) { - return this.applicationSubmissionContext; - } - if (!p.hasApplicationSubmissionContext()) { - return null; - } - this.applicationSubmissionContext = convertFromProtoFormat(p.getApplicationSubmissionContext()); - return this.applicationSubmissionContext; - } - - @Override - public void setApplicationSubmissionContext(ApplicationSubmissionContext applicationSubmissionContext) { - maybeInitBuilder(); - if (applicationSubmissionContext == null) - builder.clearApplicationSubmissionContext(); - this.applicationSubmissionContext = applicationSubmissionContext; - } - - private ApplicationSubmissionContextPBImpl convertFromProtoFormat(ApplicationSubmissionContextProto p) { - return new ApplicationSubmissionContextPBImpl(p); - } - - private ApplicationSubmissionContextProto convertToProtoFormat(ApplicationSubmissionContext t) { - return ((ApplicationSubmissionContextPBImpl)t).getProto(); - } - - - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SubmitApplicationResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SubmitApplicationResponsePBImpl.java deleted file mode 100644 index 8ac49f5..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SubmitApplicationResponsePBImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationResponse; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.SubmitApplicationResponseProto; - -@Private -@Unstable -public class SubmitApplicationResponsePBImpl extends SubmitApplicationResponse { - SubmitApplicationResponseProto proto = SubmitApplicationResponseProto.getDefaultInstance(); - SubmitApplicationResponseProto.Builder builder = null; - boolean viaProto = false; - - public SubmitApplicationResponsePBImpl() { - builder = SubmitApplicationResponseProto.newBuilder(); - } - - public SubmitApplicationResponsePBImpl(SubmitApplicationResponseProto proto) { - this.proto = proto; - viaProto = true; - } - - public SubmitApplicationResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/package-info.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/package-info.java deleted file mode 100644 index f9c7e5c..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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. - */ -@InterfaceAudience.Private -package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; -import org.apache.hadoop.classification.InterfaceAudience; diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationAttemptIdPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationAttemptIdPBImpl.java deleted file mode 100644 index 521d9cc..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationAttemptIdPBImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; - -import com.google.common.base.Preconditions; - -@Private -@Unstable -public class ApplicationAttemptIdPBImpl extends ApplicationAttemptId { - ApplicationAttemptIdProto proto = null; - ApplicationAttemptIdProto.Builder builder = null; - private ApplicationId applicationId = null; - - public ApplicationAttemptIdPBImpl() { - builder = ApplicationAttemptIdProto.newBuilder(); - } - - public ApplicationAttemptIdPBImpl(ApplicationAttemptIdProto proto) { - this.proto = proto; - this.applicationId = convertFromProtoFormat(proto.getApplicationId()); - } - - public ApplicationAttemptIdProto getProto() { - return proto; - } - - @Override - public int getAttemptId() { - Preconditions.checkNotNull(proto); - return proto.getAttemptId(); - } - - @Override - protected void setAttemptId(int attemptId) { - Preconditions.checkNotNull(builder); - builder.setAttemptId(attemptId); - } - - @Override - public ApplicationId getApplicationId() { - return this.applicationId; - } - - @Override - public void setApplicationId(ApplicationId appId) { - if (appId != null) { - Preconditions.checkNotNull(builder); - builder.setApplicationId(convertToProtoFormat(appId)); - } - this.applicationId = appId; - } - - private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { - return new ApplicationIdPBImpl(p); - } - - private ApplicationIdProto convertToProtoFormat(ApplicationId t) { - return ((ApplicationIdPBImpl)t).getProto(); - } - - @Override - protected void build() { - proto = builder.build(); - builder = null; - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationIdPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationIdPBImpl.java deleted file mode 100644 index df038e5..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationIdPBImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; - -import com.google.common.base.Preconditions; - -@Private -@Unstable -public class ApplicationIdPBImpl extends ApplicationId { - ApplicationIdProto proto = null; - ApplicationIdProto.Builder builder = null; - - public ApplicationIdPBImpl() { - builder = ApplicationIdProto.newBuilder(); - } - - public ApplicationIdPBImpl(ApplicationIdProto proto) { - this.proto = proto; - } - - public ApplicationIdProto getProto() { - return proto; - } - - @Override - public int getId() { - Preconditions.checkNotNull(proto); - return proto.getId(); - } - - @Override - protected void setId(int id) { - Preconditions.checkNotNull(builder); - builder.setId(id); - } - @Override - public long getClusterTimestamp() { - Preconditions.checkNotNull(proto); - return proto.getClusterTimestamp(); - } - - @Override - protected void setClusterTimestamp(long clusterTimestamp) { - Preconditions.checkNotNull(builder); - builder.setClusterTimestamp((clusterTimestamp)); - } - - @Override - protected void build() { - proto = builder.build(); - builder = null; - } -} \ No newline at end of file diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationReportPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationReportPBImpl.java deleted file mode 100644 index b08db0d..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationReportPBImpl.java +++ /dev/null @@ -1,489 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.ApplicationReport; -import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; -import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; -import org.apache.hadoop.yarn.api.records.Token; -import org.apache.hadoop.yarn.api.records.YarnApplicationState; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationReportProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationReportProtoOrBuilder; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationResourceUsageReportProto; -import org.apache.hadoop.yarn.proto.YarnProtos.FinalApplicationStatusProto; -import org.apache.hadoop.yarn.proto.YarnProtos.YarnApplicationStateProto; - -@Private -@Unstable -public class ApplicationReportPBImpl extends ApplicationReport { - ApplicationReportProto proto = ApplicationReportProto.getDefaultInstance(); - ApplicationReportProto.Builder builder = null; - boolean viaProto = false; - - private ApplicationId applicationId; - private ApplicationAttemptId currentApplicationAttemptId; - private Token clientToAMToken = null; - - public ApplicationReportPBImpl() { - builder = ApplicationReportProto.newBuilder(); - } - - public ApplicationReportPBImpl(ApplicationReportProto proto) { - this.proto = proto; - viaProto = true; - } - - @Override - public ApplicationId getApplicationId() { - if (this.applicationId != null) { - return this.applicationId; - } - - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasApplicationId()) { - return null; - } - this.applicationId = convertFromProtoFormat(p.getApplicationId()); - return this.applicationId; - } - - public void setApplicationResourceUsageReport(ApplicationResourceUsageReport appInfo) { - maybeInitBuilder(); - if (appInfo == null) { - builder.clearAppResourceUsage(); - return; - } - builder.setAppResourceUsage(convertToProtoFormat(appInfo)); - } - - @Override - public ApplicationAttemptId getCurrentApplicationAttemptId() { - if (this.currentApplicationAttemptId != null) { - return this.currentApplicationAttemptId; - } - - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasCurrentApplicationAttemptId()) { - return null; - } - this.currentApplicationAttemptId = convertFromProtoFormat(p.getCurrentApplicationAttemptId()); - return this.currentApplicationAttemptId; - } - - @Override - public ApplicationResourceUsageReport getApplicationResourceUsageReport() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasAppResourceUsage()) { - return null; - } - return convertFromProtoFormat(p.getAppResourceUsage()); - } - - @Override - public String getTrackingUrl() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasTrackingUrl()) { - return null; - } - return p.getTrackingUrl(); - } - - @Override - public String getOriginalTrackingUrl() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasOriginalTrackingUrl()) { - return null; - } - return p.getOriginalTrackingUrl(); - } - - @Override - public String getName() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasName()) { - return null; - } - return p.getName(); - } - - @Override - public String getQueue() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasQueue()) { - return null; - } - return p.getQueue(); - } - - @Override - public YarnApplicationState getYarnApplicationState() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasYarnApplicationState()) { - return null; - } - return convertFromProtoFormat(p.getYarnApplicationState()); - } - - @Override - public String getHost() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasHost()) { - return null; - } - return (p.getHost()); - } - - @Override - public int getRpcPort() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - return (p.getRpcPort()); - } - - @Override - public Token getClientToAMToken() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - if (this.clientToAMToken != null) { - return this.clientToAMToken; - } - if (!p.hasClientToAmToken()) { - return null; - } - this.clientToAMToken = convertFromProtoFormat(p.getClientToAmToken()); - return this.clientToAMToken; - } - - @Override - public String getUser() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasUser()) { - return null; - } - return p.getUser(); - } - - @Override - public String getDiagnostics() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasDiagnostics()) { - return null; - } - return p.getDiagnostics(); - } - - @Override - public long getStartTime() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - return p.getStartTime(); - } - - @Override - public long getFinishTime() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - return p.getFinishTime(); - } - - @Override - public FinalApplicationStatus getFinalApplicationStatus() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasFinalApplicationStatus()) { - return null; - } - return convertFromProtoFormat(p.getFinalApplicationStatus()); - } - - @Override - public float getProgress() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - return p.getProgress(); - } - - @Override - public String getApplicationType() { - ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasApplicationType()) { - return null; - } - return p.getApplicationType(); - } - - @Override - public void setApplicationId(ApplicationId applicationId) { - maybeInitBuilder(); - if (applicationId == null) - builder.clearApplicationId(); - this.applicationId = applicationId; - } - - @Override - public void setCurrentApplicationAttemptId(ApplicationAttemptId applicationAttemptId) { - maybeInitBuilder(); - if (applicationAttemptId == null) - builder.clearCurrentApplicationAttemptId(); - this.currentApplicationAttemptId = applicationAttemptId; - } - - @Override - public void setTrackingUrl(String url) { - maybeInitBuilder(); - if (url == null) { - builder.clearTrackingUrl(); - return; - } - builder.setTrackingUrl(url); - } - - @Override - public void setOriginalTrackingUrl(String url) { - maybeInitBuilder(); - if (url == null) { - builder.clearOriginalTrackingUrl(); - return; - } - builder.setOriginalTrackingUrl(url); - } - - @Override - public void setName(String name) { - maybeInitBuilder(); - if (name == null) { - builder.clearName(); - return; - } - builder.setName(name); - } - - @Override - public void setQueue(String queue) { - maybeInitBuilder(); - if (queue == null) { - builder.clearQueue(); - return; - } - builder.setQueue(queue); - } - - @Override - public void setYarnApplicationState(YarnApplicationState state) { - maybeInitBuilder(); - if (state == null) { - builder.clearYarnApplicationState(); - return; - } - builder.setYarnApplicationState(convertToProtoFormat(state)); - } - - @Override - public void setHost(String host) { - maybeInitBuilder(); - if (host == null) { - builder.clearHost(); - return; - } - builder.setHost((host)); - } - - @Override - public void setRpcPort(int rpcPort) { - maybeInitBuilder(); - builder.setRpcPort((rpcPort)); - } - - @Override - public void setClientToAMToken(Token clientToAMToken) { - maybeInitBuilder(); - if (clientToAMToken == null) - builder.clearClientToAmToken(); - this.clientToAMToken = clientToAMToken; - } - - @Override - public void setUser(String user) { - maybeInitBuilder(); - if (user == null) { - builder.clearUser(); - return; - } - builder.setUser((user)); - } - - @Override - public void setApplicationType(String applicationType) { - maybeInitBuilder(); - if (applicationType == null) { - builder.clearApplicationType(); - return; - } - builder.setApplicationType((applicationType)); - } - - @Override - public void setDiagnostics(String diagnostics) { - maybeInitBuilder(); - if (diagnostics == null) { - builder.clearDiagnostics(); - return; - } - builder.setDiagnostics(diagnostics); - } - - @Override - public void setStartTime(long startTime) { - maybeInitBuilder(); - builder.setStartTime(startTime); - } - - @Override - public void setFinishTime(long finishTime) { - maybeInitBuilder(); - builder.setFinishTime(finishTime); - } - - @Override - public void setFinalApplicationStatus(FinalApplicationStatus finishState) { - maybeInitBuilder(); - if (finishState == null) { - builder.clearFinalApplicationStatus(); - return; - } - builder.setFinalApplicationStatus(convertToProtoFormat(finishState)); - } - - @Override - public void setProgress(float progress) { - maybeInitBuilder(); - builder.setProgress(progress); - } - - public ApplicationReportProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.applicationId != null - && !((ApplicationIdPBImpl) this.applicationId).getProto().equals( - builder.getApplicationId())) { - builder.setApplicationId(convertToProtoFormat(this.applicationId)); - } - if (this.currentApplicationAttemptId != null - && !((ApplicationAttemptIdPBImpl) this.currentApplicationAttemptId).getProto().equals( - builder.getCurrentApplicationAttemptId())) { - builder.setCurrentApplicationAttemptId(convertToProtoFormat(this.currentApplicationAttemptId)); - } - if (this.clientToAMToken != null - && !((TokenPBImpl) this.clientToAMToken).getProto().equals( - builder.getClientToAmToken())) { - builder.setClientToAmToken(convertToProtoFormat(this.clientToAMToken)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = ApplicationReportProto.newBuilder(proto); - } - viaProto = false; - } - - private ApplicationIdProto convertToProtoFormat(ApplicationId t) { - return ((ApplicationIdPBImpl) t).getProto(); - } - - private ApplicationAttemptIdProto convertToProtoFormat(ApplicationAttemptId t) { - return ((ApplicationAttemptIdPBImpl) t).getProto(); - } - - private ApplicationResourceUsageReport convertFromProtoFormat(ApplicationResourceUsageReportProto s) { - return ProtoUtils.convertFromProtoFormat(s); - } - - private ApplicationResourceUsageReportProto convertToProtoFormat(ApplicationResourceUsageReport s) { - return ProtoUtils.convertToProtoFormat(s); - } - - private ApplicationIdPBImpl convertFromProtoFormat( - ApplicationIdProto applicationId) { - return new ApplicationIdPBImpl(applicationId); - } - - private ApplicationAttemptIdPBImpl convertFromProtoFormat( - ApplicationAttemptIdProto applicationAttemptId) { - return new ApplicationAttemptIdPBImpl(applicationAttemptId); - } - - private YarnApplicationState convertFromProtoFormat(YarnApplicationStateProto s) { - return ProtoUtils.convertFromProtoFormat(s); - } - - private YarnApplicationStateProto convertToProtoFormat(YarnApplicationState s) { - return ProtoUtils.convertToProtoFormat(s); - } - - private FinalApplicationStatus convertFromProtoFormat(FinalApplicationStatusProto s) { - return ProtoUtils.convertFromProtoFormat(s); - } - - private FinalApplicationStatusProto convertToProtoFormat(FinalApplicationStatus s) { - return ProtoUtils.convertToProtoFormat(s); - } - - private TokenPBImpl convertFromProtoFormat(TokenProto p) { - return new TokenPBImpl(p); - } - - private TokenProto convertToProtoFormat(Token t) { - return ((TokenPBImpl)t).getProto(); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationResourceUsageReportPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationResourceUsageReportPBImpl.java deleted file mode 100644 index eb83424..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationResourceUsageReportPBImpl.java +++ /dev/null @@ -1,208 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationResourceUsageReportProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationResourceUsageReportProtoOrBuilder; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; - -@Private -@Unstable -public class ApplicationResourceUsageReportPBImpl -extends ApplicationResourceUsageReport { - ApplicationResourceUsageReportProto proto = - ApplicationResourceUsageReportProto.getDefaultInstance(); - ApplicationResourceUsageReportProto.Builder builder = null; - boolean viaProto = false; - - Resource usedResources; - Resource reservedResources; - Resource neededResources; - - public ApplicationResourceUsageReportPBImpl() { - builder = ApplicationResourceUsageReportProto.newBuilder(); - } - - public ApplicationResourceUsageReportPBImpl( - ApplicationResourceUsageReportProto proto) { - this.proto = proto; - viaProto = true; - } - - public synchronized ApplicationResourceUsageReportProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.usedResources != null - && !((ResourcePBImpl) this.usedResources).getProto().equals( - builder.getUsedResources())) { - builder.setUsedResources(convertToProtoFormat(this.usedResources)); - } - if (this.reservedResources != null - && !((ResourcePBImpl) this.reservedResources).getProto().equals( - builder.getReservedResources())) { - builder.setReservedResources( - convertToProtoFormat(this.reservedResources)); - } - if (this.neededResources != null - && !((ResourcePBImpl) this.neededResources).getProto().equals( - builder.getNeededResources())) { - builder.setNeededResources(convertToProtoFormat(this.neededResources)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private synchronized void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = ApplicationResourceUsageReportProto.newBuilder(proto); - } - viaProto = false; - } - - @Override - public synchronized int getNumUsedContainers() { - ApplicationResourceUsageReportProtoOrBuilder p = viaProto ? proto : builder; - return (p.getNumUsedContainers()); - } - - @Override - public synchronized void setNumUsedContainers(int num_containers) { - maybeInitBuilder(); - builder.setNumUsedContainers((num_containers)); - } - - @Override - public synchronized int getNumReservedContainers() { - ApplicationResourceUsageReportProtoOrBuilder p = viaProto ? proto : builder; - return (p.getNumReservedContainers()); - } - - @Override - public synchronized void setNumReservedContainers( - int num_reserved_containers) { - maybeInitBuilder(); - builder.setNumReservedContainers((num_reserved_containers)); - } - - @Override - public synchronized Resource getUsedResources() { - ApplicationResourceUsageReportProtoOrBuilder p = viaProto ? proto : builder; - if (this.usedResources != null) { - return this.usedResources; - } - if (!p.hasUsedResources()) { - return null; - } - this.usedResources = convertFromProtoFormat(p.getUsedResources()); - return this.usedResources; - } - - @Override - public synchronized void setUsedResources(Resource resources) { - maybeInitBuilder(); - if (resources == null) - builder.clearUsedResources(); - this.usedResources = resources; - } - - @Override - public synchronized Resource getReservedResources() { - ApplicationResourceUsageReportProtoOrBuilder p = viaProto ? proto : builder; - if (this.reservedResources != null) { - return this.reservedResources; - } - if (!p.hasReservedResources()) { - return null; - } - this.reservedResources = convertFromProtoFormat(p.getReservedResources()); - return this.reservedResources; - } - - @Override - public synchronized void setReservedResources(Resource reserved_resources) { - maybeInitBuilder(); - if (reserved_resources == null) - builder.clearReservedResources(); - this.reservedResources = reserved_resources; - } - - @Override - public synchronized Resource getNeededResources() { - ApplicationResourceUsageReportProtoOrBuilder p = viaProto ? proto : builder; - if (this.neededResources != null) { - return this.neededResources; - } - if (!p.hasNeededResources()) { - return null; - } - this.neededResources = convertFromProtoFormat(p.getNeededResources()); - return this.neededResources; - } - - @Override - public synchronized void setNeededResources(Resource reserved_resources) { - maybeInitBuilder(); - if (reserved_resources == null) - builder.clearNeededResources(); - this.neededResources = reserved_resources; - } - - private ResourcePBImpl convertFromProtoFormat(ResourceProto p) { - return new ResourcePBImpl(p); - } - - private ResourceProto convertToProtoFormat(Resource t) { - return ((ResourcePBImpl)t).getProto(); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationSubmissionContextPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationSubmissionContextPBImpl.java deleted file mode 100644 index 96f280a..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationSubmissionContextPBImpl.java +++ /dev/null @@ -1,331 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; -import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; -import org.apache.hadoop.yarn.api.records.Priority; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationSubmissionContextProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationSubmissionContextProtoOrBuilder; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProto; -import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; - -@Private -@Unstable -public class ApplicationSubmissionContextPBImpl -extends ApplicationSubmissionContext { - ApplicationSubmissionContextProto proto = - ApplicationSubmissionContextProto.getDefaultInstance(); - ApplicationSubmissionContextProto.Builder builder = null; - boolean viaProto = false; - - private ApplicationId applicationId = null; - private Priority priority = null; - private ContainerLaunchContext amContainer = null; - private Resource resource = null; - - public ApplicationSubmissionContextPBImpl() { - builder = ApplicationSubmissionContextProto.newBuilder(); - } - - public ApplicationSubmissionContextPBImpl( - ApplicationSubmissionContextProto proto) { - this.proto = proto; - viaProto = true; - } - - public ApplicationSubmissionContextProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.applicationId != null) { - builder.setApplicationId(convertToProtoFormat(this.applicationId)); - } - if (this.priority != null) { - builder.setPriority(convertToProtoFormat(this.priority)); - } - if (this.amContainer != null) { - builder.setAmContainerSpec(convertToProtoFormat(this.amContainer)); - } - if (this.resource != null && - !((ResourcePBImpl) this.resource).getProto().equals( - builder.getResource())) { - builder.setResource(convertToProtoFormat(this.resource)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = ApplicationSubmissionContextProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public Priority getPriority() { - ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; - if (this.priority != null) { - return this.priority; - } - if (!p.hasPriority()) { - return null; - } - this.priority = convertFromProtoFormat(p.getPriority()); - return this.priority; - } - - @Override - public void setPriority(Priority priority) { - maybeInitBuilder(); - if (priority == null) - builder.clearPriority(); - this.priority = priority; - } - - @Override - public ApplicationId getApplicationId() { - ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; - if (this.applicationId != null) { - return applicationId; - } // Else via proto - if (!p.hasApplicationId()) { - return null; - } - applicationId = convertFromProtoFormat(p.getApplicationId()); - return applicationId; - } - - @Override - public void setApplicationId(ApplicationId applicationId) { - maybeInitBuilder(); - if (applicationId == null) - builder.clearApplicationId(); - this.applicationId = applicationId; - } - - @Override - public String getApplicationName() { - ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasApplicationName()) { - return null; - } - return (p.getApplicationName()); - } - - @Override - public void setApplicationName(String applicationName) { - maybeInitBuilder(); - if (applicationName == null) { - builder.clearApplicationName(); - return; - } - builder.setApplicationName((applicationName)); - } - - @Override - public String getQueue() { - ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasQueue()) { - return null; - } - return (p.getQueue()); - } - - @Override - public String getApplicationType() { - ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasApplicationType()) { - return null; - } - return (p.getApplicationType()); - } - - @Override - public void setQueue(String queue) { - maybeInitBuilder(); - if (queue == null) { - builder.clearQueue(); - return; - } - builder.setQueue((queue)); - } - - @Override - public void setApplicationType(String applicationType) { - maybeInitBuilder(); - if (applicationType == null) { - builder.clearApplicationType(); - return; - } - builder.setApplicationType((applicationType)); - } - - @Override - public ContainerLaunchContext getAMContainerSpec() { - ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; - if (this.amContainer != null) { - return amContainer; - } // Else via proto - if (!p.hasAmContainerSpec()) { - return null; - } - amContainer = convertFromProtoFormat(p.getAmContainerSpec()); - return amContainer; - } - - @Override - public void setAMContainerSpec(ContainerLaunchContext amContainer) { - maybeInitBuilder(); - if (amContainer == null) { - builder.clearAmContainerSpec(); - } - this.amContainer = amContainer; - } - - @Override - public boolean getUnmanagedAM() { - ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; - return p.getUnmanagedAm(); - } - - @Override - public void setUnmanagedAM(boolean value) { - maybeInitBuilder(); - builder.setUnmanagedAm(value); - } - - @Override - public boolean getCancelTokensWhenComplete() { - ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; - //There is a default so cancelTokens should never be null - return p.getCancelTokensWhenComplete(); - } - - @Override - public void setCancelTokensWhenComplete(boolean cancel) { - maybeInitBuilder(); - builder.setCancelTokensWhenComplete(cancel); - } - - @Override - public int getMaxAppAttempts() { - ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; - return p.getMaxAppAttempts(); - } - - @Override - public void setMaxAppAttempts(int maxAppAttempts) { - maybeInitBuilder(); - builder.setMaxAppAttempts(maxAppAttempts); - } - - @Override - public Resource getResource() { - ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; - if (this.resource != null) { - return this.resource; - } - if (!p.hasResource()) { - return null; - } - this.resource = convertFromProtoFormat(p.getResource()); - return this.resource; - } - - @Override - public void setResource(Resource resource) { - maybeInitBuilder(); - if (resource == null) { - builder.clearResource(); - } - this.resource = resource; - } - - private PriorityPBImpl convertFromProtoFormat(PriorityProto p) { - return new PriorityPBImpl(p); - } - - private PriorityProto convertToProtoFormat(Priority t) { - return ((PriorityPBImpl)t).getProto(); - } - - private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { - return new ApplicationIdPBImpl(p); - } - - private ApplicationIdProto convertToProtoFormat(ApplicationId t) { - return ((ApplicationIdPBImpl)t).getProto(); - } - - private ContainerLaunchContextPBImpl convertFromProtoFormat( - ContainerLaunchContextProto p) { - return new ContainerLaunchContextPBImpl(p); - } - - private ContainerLaunchContextProto convertToProtoFormat(ContainerLaunchContext t) { - return ((ContainerLaunchContextPBImpl)t).getProto(); - } - - private ResourcePBImpl convertFromProtoFormat(ResourceProto p) { - return new ResourcePBImpl(p); - } - - private ResourceProto convertToProtoFormat(Resource t) { - return ((ResourcePBImpl)t).getProto(); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerIdPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerIdPBImpl.java deleted file mode 100644 index 9be829f..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerIdPBImpl.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; - -import com.google.common.base.Preconditions; - -@Private -@Unstable -public class ContainerIdPBImpl extends ContainerId { - ContainerIdProto proto = null; - ContainerIdProto.Builder builder = null; - private ApplicationAttemptId applicationAttemptId = null; - - public ContainerIdPBImpl() { - builder = ContainerIdProto.newBuilder(); - } - - public ContainerIdPBImpl(ContainerIdProto proto) { - this.proto = proto; - this.applicationAttemptId = convertFromProtoFormat(proto.getAppAttemptId()); - } - - public ContainerIdProto getProto() { - return proto; - } - - @Override - public int getId() { - Preconditions.checkNotNull(proto); - return proto.getId(); - } - - @Override - protected void setId(int id) { - Preconditions.checkNotNull(builder); - builder.setId((id)); - } - - - @Override - public ApplicationAttemptId getApplicationAttemptId() { - return this.applicationAttemptId; - } - - @Override - protected void setApplicationAttemptId(ApplicationAttemptId atId) { - if (atId != null) { - Preconditions.checkNotNull(builder); - builder.setAppAttemptId(convertToProtoFormat(atId)); - } - this.applicationAttemptId = atId; - } - - private ApplicationAttemptIdPBImpl convertFromProtoFormat( - ApplicationAttemptIdProto p) { - return new ApplicationAttemptIdPBImpl(p); - } - - private ApplicationAttemptIdProto convertToProtoFormat( - ApplicationAttemptId t) { - return ((ApplicationAttemptIdPBImpl)t).getProto(); - } - - @Override - protected void build() { - proto = builder.build(); - builder = null; - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.java deleted file mode 100644 index 02e0d3b..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.java +++ /dev/null @@ -1,465 +0,0 @@ -/** -* 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. -*/ -package org.apache.hadoop.yarn.api.records.impl.pb; - - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ApplicationAccessType; -import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; -import org.apache.hadoop.yarn.api.records.LocalResource; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProtoOrBuilder; -import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto; -import org.apache.hadoop.yarn.proto.YarnProtos.StringBytesMapProto; -import org.apache.hadoop.yarn.proto.YarnProtos.StringLocalResourceMapProto; -import org.apache.hadoop.yarn.proto.YarnProtos.StringStringMapProto; - -import com.google.protobuf.ByteString; - -@Private -@Unstable -public class ContainerLaunchContextPBImpl -extends ContainerLaunchContext { - ContainerLaunchContextProto proto = - ContainerLaunchContextProto.getDefaultInstance(); - ContainerLaunchContextProto.Builder builder = null; - boolean viaProto = false; - - private Map localResources = null; - private ByteBuffer tokens = null; - private Map serviceData = null; - private Map environment = null; - private List commands = null; - private Map applicationACLS = null; - - public ContainerLaunchContextPBImpl() { - builder = ContainerLaunchContextProto.newBuilder(); - } - - public ContainerLaunchContextPBImpl(ContainerLaunchContextProto proto) { - this.proto = proto; - viaProto = true; - } - - public ContainerLaunchContextProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - protected final ByteBuffer convertFromProtoFormat(ByteString byteString) { - return ProtoUtils.convertFromProtoFormat(byteString); - } - - protected final ByteString convertToProtoFormat(ByteBuffer byteBuffer) { - return ProtoUtils.convertToProtoFormat(byteBuffer); - } - - private void mergeLocalToBuilder() { - if (this.localResources != null) { - addLocalResourcesToProto(); - } - if (this.tokens != null) { - builder.setTokens(convertToProtoFormat(this.tokens)); - } - if (this.serviceData != null) { - addServiceDataToProto(); - } - if (this.environment != null) { - addEnvToProto(); - } - if (this.commands != null) { - addCommandsToProto(); - } - if (this.applicationACLS != null) { - addApplicationACLs(); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = ContainerLaunchContextProto.newBuilder(proto); - } - viaProto = false; - } - - @Override - public List getCommands() { - initCommands(); - return this.commands; - } - - private void initCommands() { - if (this.commands != null) { - return; - } - ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getCommandList(); - this.commands = new ArrayList(); - - for (String c : list) { - this.commands.add(c); - } - } - - @Override - public void setCommands(final List commands) { - if (commands == null) - return; - initCommands(); - this.commands.clear(); - this.commands.addAll(commands); - } - - private void addCommandsToProto() { - maybeInitBuilder(); - builder.clearCommand(); - if (this.commands == null) - return; - builder.addAllCommand(this.commands); - } - - @Override - public Map getLocalResources() { - initLocalResources(); - return this.localResources; - } - - private void initLocalResources() { - if (this.localResources != null) { - return; - } - ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getLocalResourcesList(); - this.localResources = new HashMap(); - - for (StringLocalResourceMapProto c : list) { - this.localResources.put(c.getKey(), convertFromProtoFormat(c.getValue())); - } - } - - @Override - public void setLocalResources( - final Map localResources) { - if (localResources == null) - return; - initLocalResources(); - this.localResources.clear(); - this.localResources.putAll(localResources); - } - - private void addLocalResourcesToProto() { - maybeInitBuilder(); - builder.clearLocalResources(); - if (localResources == null) - return; - Iterable iterable = - new Iterable() { - - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator keyIter = localResources.keySet().iterator(); - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - @Override - public StringLocalResourceMapProto next() { - String key = keyIter.next(); - return StringLocalResourceMapProto.newBuilder().setKey(key). - setValue(convertToProtoFormat(localResources.get(key))).build(); - } - - @Override - public boolean hasNext() { - return keyIter.hasNext(); - } - }; - } - }; - builder.addAllLocalResources(iterable); - } - - @Override - public ByteBuffer getTokens() { - ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; - if (this.tokens != null) { - return this.tokens; - } - if (!p.hasTokens()) { - return null; - } - this.tokens = convertFromProtoFormat(p.getTokens()); - return this.tokens; - } - - @Override - public void setTokens(ByteBuffer tokens) { - maybeInitBuilder(); - if (tokens == null) { - builder.clearTokens(); - } - this.tokens = tokens; - } - - @Override - public Map getServiceData() { - initServiceData(); - return this.serviceData; - } - - private void initServiceData() { - if (this.serviceData != null) { - return; - } - ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getServiceDataList(); - this.serviceData = new HashMap(); - - for (StringBytesMapProto c : list) { - this.serviceData.put(c.getKey(), convertFromProtoFormat(c.getValue())); - } - } - - @Override - public void setServiceData(final Map serviceData) { - if (serviceData == null) - return; - initServiceData(); - this.serviceData.putAll(serviceData); - } - - private void addServiceDataToProto() { - maybeInitBuilder(); - builder.clearServiceData(); - if (serviceData == null) - return; - Iterable iterable = - new Iterable() { - - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator keyIter = serviceData.keySet().iterator(); - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - @Override - public StringBytesMapProto next() { - String key = keyIter.next(); - return StringBytesMapProto.newBuilder().setKey(key).setValue( - convertToProtoFormat(serviceData.get(key))).build(); - } - - @Override - public boolean hasNext() { - return keyIter.hasNext(); - } - }; - } - }; - builder.addAllServiceData(iterable); - } - - @Override - public Map getEnvironment() { - initEnv(); - return this.environment; - } - - private void initEnv() { - if (this.environment != null) { - return; - } - ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getEnvironmentList(); - this.environment = new HashMap(); - - for (StringStringMapProto c : list) { - this.environment.put(c.getKey(), c.getValue()); - } - } - - @Override - public void setEnvironment(final Map env) { - if (env == null) - return; - initEnv(); - this.environment.clear(); - this.environment.putAll(env); - } - - private void addEnvToProto() { - maybeInitBuilder(); - builder.clearEnvironment(); - if (environment == null) - return; - Iterable iterable = - new Iterable() { - - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator keyIter = environment.keySet().iterator(); - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - @Override - public StringStringMapProto next() { - String key = keyIter.next(); - return StringStringMapProto.newBuilder().setKey(key).setValue( - (environment.get(key))).build(); - } - - @Override - public boolean hasNext() { - return keyIter.hasNext(); - } - }; - } - }; - builder.addAllEnvironment(iterable); - } - - @Override - public Map getApplicationACLs() { - initApplicationACLs(); - return this.applicationACLS; - } - - private void initApplicationACLs() { - if (this.applicationACLS != null) { - return; - } - ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getApplicationACLsList(); - this.applicationACLS = new HashMap(list - .size()); - - for (ApplicationACLMapProto aclProto : list) { - this.applicationACLS.put(ProtoUtils.convertFromProtoFormat(aclProto - .getAccessType()), aclProto.getAcl()); - } - } - - private void addApplicationACLs() { - maybeInitBuilder(); - builder.clearApplicationACLs(); - if (applicationACLS == null) { - return; - } - Iterable values - = new Iterable() { - - @Override - public Iterator iterator() { - return new Iterator() { - Iterator aclsIterator = applicationACLS - .keySet().iterator(); - - @Override - public boolean hasNext() { - return aclsIterator.hasNext(); - } - - @Override - public ApplicationACLMapProto next() { - ApplicationAccessType key = aclsIterator.next(); - return ApplicationACLMapProto.newBuilder().setAcl( - applicationACLS.get(key)).setAccessType( - ProtoUtils.convertToProtoFormat(key)).build(); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - }; - this.builder.addAllApplicationACLs(values); - } - - @Override - public void setApplicationACLs( - final Map appACLs) { - if (appACLs == null) - return; - initApplicationACLs(); - this.applicationACLS.clear(); - this.applicationACLS.putAll(appACLs); - } - - private LocalResourcePBImpl convertFromProtoFormat(LocalResourceProto p) { - return new LocalResourcePBImpl(p); - } - - private LocalResourceProto convertToProtoFormat(LocalResource t) { - return ((LocalResourcePBImpl)t).getProto(); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java deleted file mode 100644 index 1700068..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java +++ /dev/null @@ -1,317 +0,0 @@ -/** -* 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. -*/ - -package org.apache.hadoop.yarn.api.records.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; -import org.apache.hadoop.yarn.api.records.Container; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.NodeId; -import org.apache.hadoop.yarn.api.records.Priority; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.api.records.Token; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProtoOrBuilder; -import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; - -@Private -@Unstable -public class ContainerPBImpl extends Container { - - ContainerProto proto = ContainerProto.getDefaultInstance(); - ContainerProto.Builder builder = null; - boolean viaProto = false; - - private ContainerId containerId = null; - private NodeId nodeId = null; - private Resource resource = null; - private Priority priority = null; - private Token containerToken = null; - - public ContainerPBImpl() { - builder = ContainerProto.newBuilder(); - } - - public ContainerPBImpl(ContainerProto proto) { - this.proto = proto; - viaProto = true; - } - - public ContainerProto getProto() { - - mergeLocalToProto(); - 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; - } - - private void mergeLocalToBuilder() { - if (this.containerId != null - && !((ContainerIdPBImpl) containerId).getProto().equals( - builder.getId())) { - builder.setId(convertToProtoFormat(this.containerId)); - } - if (this.nodeId != null - && !((NodeIdPBImpl) nodeId).getProto().equals( - builder.getNodeId())) { - builder.setNodeId(convertToProtoFormat(this.nodeId)); - } - if (this.resource != null - && !((ResourcePBImpl) this.resource).getProto().equals( - builder.getResource())) { - builder.setResource(convertToProtoFormat(this.resource)); - } - if (this.priority != null && - !((PriorityPBImpl) this.priority).getProto().equals( - builder.getPriority())) { - builder.setPriority(convertToProtoFormat(this.priority)); - } - if (this.containerToken != null - && !((TokenPBImpl) this.containerToken).getProto().equals( - builder.getContainerToken())) { - builder.setContainerToken(convertToProtoFormat(this.containerToken)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = ContainerProto.newBuilder(proto); - } - viaProto = false; - } - - @Override - public ContainerId getId() { - ContainerProtoOrBuilder p = viaProto ? proto : builder; - if (this.containerId != null) { - return this.containerId; - } - if (!p.hasId()) { - return null; - } - this.containerId = convertFromProtoFormat(p.getId()); - return this.containerId; - } - - @Override - public void setNodeId(NodeId nodeId) { - maybeInitBuilder(); - if (nodeId == null) - builder.clearNodeId(); - this.nodeId = nodeId; - } - - @Override - public NodeId getNodeId() { - ContainerProtoOrBuilder p = viaProto ? proto : builder; - if (this.nodeId != null) { - return this.nodeId; - } - if (!p.hasNodeId()) { - return null; - } - this.nodeId = convertFromProtoFormat(p.getNodeId()); - return this.nodeId; - } - - @Override - public void setId(ContainerId id) { - maybeInitBuilder(); - if (id == null) - builder.clearId(); - this.containerId = id; - } - - @Override - public String getNodeHttpAddress() { - ContainerProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasNodeHttpAddress()) { - return null; - } - return (p.getNodeHttpAddress()); - } - - @Override - public void setNodeHttpAddress(String nodeHttpAddress) { - maybeInitBuilder(); - if (nodeHttpAddress == null) { - builder.clearNodeHttpAddress(); - return; - } - builder.setNodeHttpAddress(nodeHttpAddress); - } - - @Override - public Resource getResource() { - ContainerProtoOrBuilder p = viaProto ? proto : builder; - if (this.resource != null) { - return this.resource; - } - if (!p.hasResource()) { - return null; - } - this.resource = convertFromProtoFormat(p.getResource()); - return this.resource; - } - - @Override - public void setResource(Resource resource) { - maybeInitBuilder(); - if (resource == null) - builder.clearResource(); - this.resource = resource; - } - - @Override - public Priority getPriority() { - ContainerProtoOrBuilder p = viaProto ? proto : builder; - if (this.priority != null) { - return this.priority; - } - if (!p.hasPriority()) { - return null; - } - this.priority = convertFromProtoFormat(p.getPriority()); - return this.priority; - } - - @Override - public void setPriority(Priority priority) { - maybeInitBuilder(); - if (priority == null) { - builder.clearPriority(); - } - this.priority = priority; - } - - @Override - public Token getContainerToken() { - ContainerProtoOrBuilder p = viaProto ? proto : builder; - if (this.containerToken != null) { - return this.containerToken; - } - if (!p.hasContainerToken()) { - return null; - } - this.containerToken = convertFromProtoFormat(p.getContainerToken()); - return this.containerToken; - } - - @Override - public void setContainerToken(Token containerToken) { - maybeInitBuilder(); - if (containerToken == null) - builder.clearContainerToken(); - this.containerToken = containerToken; - } - - private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { - return new ContainerIdPBImpl(p); - } - - private NodeIdPBImpl convertFromProtoFormat(NodeIdProto p) { - return new NodeIdPBImpl(p); - } - - private ContainerIdProto convertToProtoFormat(ContainerId t) { - return ((ContainerIdPBImpl)t).getProto(); - } - - private NodeIdProto convertToProtoFormat(NodeId t) { - return ((NodeIdPBImpl)t).getProto(); - } - - private ResourcePBImpl convertFromProtoFormat(ResourceProto p) { - return new ResourcePBImpl(p); - } - - private ResourceProto convertToProtoFormat(Resource t) { - return ((ResourcePBImpl)t).getProto(); - } - - private PriorityPBImpl convertFromProtoFormat(PriorityProto p) { - return new PriorityPBImpl(p); - } - - private PriorityProto convertToProtoFormat(Priority p) { - return ((PriorityPBImpl)p).getProto(); - } - - private TokenPBImpl convertFromProtoFormat(TokenProto p) { - return new TokenPBImpl(p); - } - - private TokenProto convertToProtoFormat(Token t) { - return ((TokenPBImpl)t).getProto(); - } - - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("Container: ["); - sb.append("ContainerId: ").append(getId()).append(", "); - sb.append("NodeId: ").append(getNodeId()).append(", "); - sb.append("NodeHttpAddress: ").append(getNodeHttpAddress()).append(", "); - sb.append("Resource: ").append(getResource()).append(", "); - sb.append("Priority: ").append(getPriority()).append(", "); - sb.append("Token: ").append(getContainerToken()).append(", "); - sb.append("]"); - return sb.toString(); - } - - //TODO Comparator - @Override - public int compareTo(Container other) { - if (this.getId().compareTo(other.getId()) == 0) { - if (this.getNodeId().compareTo(other.getNodeId()) == 0) { - return this.getResource().compareTo(other.getResource()); - } else { - return this.getNodeId().compareTo(other.getNodeId()); - } - } else { - return this.getId().compareTo(other.getId()); - } - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java deleted file mode 100644 index a52ae4c..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.ContainerState; -import org.apache.hadoop.yarn.api.records.ContainerStatus; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProtoOrBuilder; - -@Private -@Unstable -public class ContainerStatusPBImpl extends ContainerStatus { - ContainerStatusProto proto = ContainerStatusProto.getDefaultInstance(); - ContainerStatusProto.Builder builder = null; - boolean viaProto = false; - - private ContainerId containerId = null; - - - public ContainerStatusPBImpl() { - builder = ContainerStatusProto.newBuilder(); - } - - public ContainerStatusPBImpl(ContainerStatusProto proto) { - this.proto = proto; - viaProto = true; - } - - public ContainerStatusProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (containerId != null) { - builder.setContainerId(convertToProtoFormat(this.containerId)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = ContainerStatusProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public ContainerState getState() { - ContainerStatusProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasState()) { - return null; - } - return convertFromProtoFormat(p.getState()); - } - - @Override - public void setState(ContainerState state) { - maybeInitBuilder(); - if (state == null) { - builder.clearState(); - return; - } - builder.setState(convertToProtoFormat(state)); - } - @Override - public ContainerId getContainerId() { - ContainerStatusProtoOrBuilder p = viaProto ? proto : builder; - if (this.containerId != null) { - return this.containerId; - } - if (!p.hasContainerId()) { - return null; - } - this.containerId = convertFromProtoFormat(p.getContainerId()); - return this.containerId; - } - - @Override - public void setContainerId(ContainerId containerId) { - maybeInitBuilder(); - if (containerId == null) - builder.clearContainerId(); - this.containerId = containerId; - } - @Override - public int getExitStatus() { - ContainerStatusProtoOrBuilder p = viaProto ? proto : builder; - return p.getExitStatus(); - } - - @Override - public void setExitStatus(int exitStatus) { - maybeInitBuilder(); - builder.setExitStatus(exitStatus); - } - - @Override - public String getDiagnostics() { - ContainerStatusProtoOrBuilder p = viaProto ? proto : builder; - return (p.getDiagnostics()); - } - - @Override - public void setDiagnostics(String diagnostics) { - maybeInitBuilder(); - builder.setDiagnostics(diagnostics); - } - - private ContainerStateProto convertToProtoFormat(ContainerState e) { - return ProtoUtils.convertToProtoFormat(e); - } - - private ContainerState convertFromProtoFormat(ContainerStateProto e) { - return ProtoUtils.convertFromProtoFormat(e); - } - - private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { - return new ContainerIdPBImpl(p); - } - - private ContainerIdProto convertToProtoFormat(ContainerId t) { - return ((ContainerIdPBImpl)t).getProto(); - } - - - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/LocalResourcePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/LocalResourcePBImpl.java deleted file mode 100644 index d2caf0b..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/LocalResourcePBImpl.java +++ /dev/null @@ -1,216 +0,0 @@ -/** -* 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. -*/ -package org.apache.hadoop.yarn.api.records.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.LocalResource; -import org.apache.hadoop.yarn.api.records.LocalResourceType; -import org.apache.hadoop.yarn.api.records.LocalResourceVisibility; -import org.apache.hadoop.yarn.api.records.URL; -import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto; -import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProtoOrBuilder; -import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceTypeProto; -import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceVisibilityProto; -import org.apache.hadoop.yarn.proto.YarnProtos.URLProto; - -@Private -@Unstable -public class LocalResourcePBImpl extends LocalResource { - LocalResourceProto proto = LocalResourceProto.getDefaultInstance(); - LocalResourceProto.Builder builder = null; - boolean viaProto = false; - - private URL url = null; - - public LocalResourcePBImpl() { - builder = LocalResourceProto.newBuilder(); - } - - public LocalResourcePBImpl(LocalResourceProto proto) { - this.proto = proto; - viaProto = true; - } - - public synchronized LocalResourceProto getProto() { - mergeLocalToBuilder(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private synchronized void mergeLocalToBuilder() { - LocalResourceProtoOrBuilder l = viaProto ? proto : builder; - if (this.url != null - && !(l.getResource().equals(((URLPBImpl) url).getProto()))) { - maybeInitBuilder(); - l = builder; - builder.setResource(convertToProtoFormat(this.url)); - } - } - - private synchronized void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = LocalResourceProto.newBuilder(proto); - } - viaProto = false; - } - - @Override - public synchronized long getSize() { - LocalResourceProtoOrBuilder p = viaProto ? proto : builder; - return (p.getSize()); - } - - @Override - public synchronized void setSize(long size) { - maybeInitBuilder(); - builder.setSize((size)); - } - @Override - public synchronized long getTimestamp() { - LocalResourceProtoOrBuilder p = viaProto ? proto : builder; - return (p.getTimestamp()); - } - - @Override - public synchronized void setTimestamp(long timestamp) { - maybeInitBuilder(); - builder.setTimestamp((timestamp)); - } - @Override - public synchronized LocalResourceType getType() { - LocalResourceProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasType()) { - return null; - } - return convertFromProtoFormat(p.getType()); - } - - @Override - public synchronized void setType(LocalResourceType type) { - maybeInitBuilder(); - if (type == null) { - builder.clearType(); - return; - } - builder.setType(convertToProtoFormat(type)); - } - @Override - public synchronized URL getResource() { - LocalResourceProtoOrBuilder p = viaProto ? proto : builder; - if (this.url != null) { - return this.url; - } - if (!p.hasResource()) { - return null; - } - this.url = convertFromProtoFormat(p.getResource()); - return this.url; - } - - @Override - public synchronized void setResource(URL resource) { - maybeInitBuilder(); - if (resource == null) - builder.clearResource(); - this.url = resource; - } - @Override - public synchronized LocalResourceVisibility getVisibility() { - LocalResourceProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasVisibility()) { - return null; - } - return convertFromProtoFormat(p.getVisibility()); - } - - @Override - public synchronized void setVisibility(LocalResourceVisibility visibility) { - maybeInitBuilder(); - if (visibility == null) { - builder.clearVisibility(); - return; - } - builder.setVisibility(convertToProtoFormat(visibility)); - } - - @Override - public synchronized String getPattern() { - LocalResourceProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasPattern()) { - return null; - } - return p.getPattern(); - } - - @Override - public synchronized void setPattern(String pattern) { - maybeInitBuilder(); - if (pattern == null) { - builder.clearPattern(); - return; - } - builder.setPattern(pattern); - } - - private LocalResourceTypeProto convertToProtoFormat(LocalResourceType e) { - return ProtoUtils.convertToProtoFormat(e); - } - - private LocalResourceType convertFromProtoFormat(LocalResourceTypeProto e) { - return ProtoUtils.convertFromProtoFormat(e); - } - - private URLPBImpl convertFromProtoFormat(URLProto p) { - return new URLPBImpl(p); - } - - private URLProto convertToProtoFormat(URL t) { - return ((URLPBImpl)t).getProto(); - } - - private LocalResourceVisibilityProto convertToProtoFormat(LocalResourceVisibility e) { - return ProtoUtils.convertToProtoFormat(e); - } - - private LocalResourceVisibility convertFromProtoFormat(LocalResourceVisibilityProto e) { - return ProtoUtils.convertFromProtoFormat(e); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NMTokenPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NMTokenPBImpl.java deleted file mode 100644 index bcbf0a3..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NMTokenPBImpl.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; -import org.apache.hadoop.yarn.api.records.NMToken; -import org.apache.hadoop.yarn.api.records.NodeId; -import org.apache.hadoop.yarn.api.records.Token; -import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.NMTokenProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.NMTokenProtoOrBuilder; - -@Private -@Unstable -public class NMTokenPBImpl extends NMToken{ - - NMTokenProto proto = NMTokenProto.getDefaultInstance(); - NMTokenProto.Builder builder = null; - boolean viaProto = false; - - private Token token = null; - private NodeId nodeId = null; - - public NMTokenPBImpl() { - builder = NMTokenProto.newBuilder(); - } - - public NMTokenPBImpl(NMTokenProto proto) { - this.proto = proto; - viaProto = true; - } - - @Override - public synchronized NodeId getNodeId() { - NMTokenProtoOrBuilder p = viaProto ? proto : builder; - if (this.nodeId != null) { - return nodeId; - } - if (!p.hasNodeId()) { - return null; - } - this.nodeId = convertFromProtoFormat(p.getNodeId()); - return nodeId; - } - - @Override - public synchronized void setNodeId(NodeId nodeId) { - maybeInitBuilder(); - if (nodeId == null) { - builder.clearNodeId(); - } - this.nodeId = nodeId; - } - - @Override - public synchronized Token getToken() { - NMTokenProtoOrBuilder p = viaProto ? proto : builder; - if (this.token != null) { - return this.token; - } - if (!p.hasToken()) { - return null; - } - this.token = convertFromProtoFormat(p.getToken()); - return token; - } - - @Override - public synchronized void setToken(Token token) { - maybeInitBuilder(); - if (token == null) { - builder.clearToken(); - } - this.token = token; - } - - public synchronized NMTokenProto getProto() { - mergeLocalToProto(); - proto = viaProto ? proto : builder.build(); - viaProto = true; - return proto; - } - - private synchronized void mergeLocalToProto() { - if (viaProto) { - maybeInitBuilder(); - } - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private synchronized void mergeLocalToBuilder() { - if (this.nodeId != null) { - builder.setNodeId(convertToProtoFormat(nodeId)); - } - if (this.token != null) { - builder.setToken(convertToProtoFormat(token)); - } - } - - private synchronized void maybeInitBuilder() { - if(viaProto || builder == null) { - builder = NMTokenProto.newBuilder(proto); - } - viaProto = false; - } - - private synchronized NodeId convertFromProtoFormat(NodeIdProto p) { - return new NodeIdPBImpl(p); - } - - private synchronized NodeIdProto convertToProtoFormat(NodeId nodeId) { - return ((NodeIdPBImpl)nodeId).getProto(); - } - - private synchronized TokenProto convertToProtoFormat(Token token) { - return ((TokenPBImpl)token).getProto(); - } - - private synchronized Token convertFromProtoFormat(TokenProto proto) { - return new TokenPBImpl(proto); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeIdPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeIdPBImpl.java deleted file mode 100644 index 4c725fa..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeIdPBImpl.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.NodeId; -import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; - -import com.google.common.base.Preconditions; - -@Private -@Unstable -public class NodeIdPBImpl extends NodeId { - NodeIdProto proto = null; - NodeIdProto.Builder builder = null; - - public NodeIdPBImpl() { - builder = NodeIdProto.newBuilder(); - } - - public NodeIdPBImpl(NodeIdProto proto) { - this.proto = proto; - } - - public NodeIdProto getProto() { - return proto; - } - - @Override - public String getHost() { - Preconditions.checkNotNull(proto); - return proto.getHost(); - } - - @Override - protected void setHost(String host) { - Preconditions.checkNotNull(builder); - builder.setHost(host); - } - - @Override - public int getPort() { - Preconditions.checkNotNull(proto); - return proto.getPort(); - } - - @Override - protected void setPort(int port) { - Preconditions.checkNotNull(builder); - builder.setPort(port); - } - - @Override - protected void build() { - proto = builder.build(); - builder = null; - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeReportPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeReportPBImpl.java deleted file mode 100644 index e1a66d7..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeReportPBImpl.java +++ /dev/null @@ -1,290 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.NodeId; -import org.apache.hadoop.yarn.api.records.NodeReport; -import org.apache.hadoop.yarn.api.records.NodeState; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.NodeReportProto; -import org.apache.hadoop.yarn.proto.YarnProtos.NodeReportProtoOrBuilder; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; - -@Private -@Unstable -public class NodeReportPBImpl extends NodeReport { - - private NodeReportProto proto = NodeReportProto.getDefaultInstance(); - private NodeReportProto.Builder builder = null; - private boolean viaProto = false; - private NodeId nodeId; - private Resource used; - private Resource capability; - - public NodeReportPBImpl() { - builder = NodeReportProto.newBuilder(); - } - - public NodeReportPBImpl(NodeReportProto proto) { - this.proto = proto; - viaProto = true; - } - - @Override - public Resource getCapability() { - if (this.capability != null) { - return this.capability; - } - - NodeReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasCapability()) { - return null; - } - this.capability = convertFromProtoFormat(p.getCapability()); - return this.capability; - } - - @Override - public String getHealthReport() { - NodeReportProtoOrBuilder p = viaProto ? proto : builder; - return p.getHealthReport(); - } - - @Override - public void setHealthReport(String healthReport) { - maybeInitBuilder(); - if (healthReport == null) { - builder.clearHealthReport(); - return; - } - builder.setHealthReport(healthReport); - } - - @Override - public long getLastHealthReportTime() { - NodeReportProtoOrBuilder p = viaProto ? proto : builder; - return p.getLastHealthReportTime(); - } - - @Override - public void setLastHealthReportTime(long lastHealthReportTime) { - maybeInitBuilder(); - builder.setLastHealthReportTime(lastHealthReportTime); - } - - @Override - public String getHttpAddress() { - NodeReportProtoOrBuilder p = viaProto ? proto : builder; - return (p.hasHttpAddress()) ? p.getHttpAddress() : null; - } - - @Override - public int getNumContainers() { - NodeReportProtoOrBuilder p = viaProto ? proto : builder; - return (p.hasNumContainers()) ? p.getNumContainers() : 0; - } - - @Override - public String getRackName() { - NodeReportProtoOrBuilder p = viaProto ? proto : builder; - return (p.hasRackName()) ? p.getRackName() : null; - } - - @Override - public Resource getUsed() { - if (this.used != null) { - return this.used; - } - - NodeReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasUsed()) { - return null; - } - this.used = convertFromProtoFormat(p.getUsed()); - return this.used; - } - - @Override - public NodeId getNodeId() { - if (this.nodeId != null) { - return this.nodeId; - } - - NodeReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasNodeId()) { - return null; - } - this.nodeId = convertFromProtoFormat(p.getNodeId()); - return this.nodeId; - } - - @Override - public void setNodeId(NodeId nodeId) { - maybeInitBuilder(); - if (nodeId == null) - builder.clearNodeId(); - this.nodeId = nodeId; - } - - @Override - public NodeState getNodeState() { - NodeReportProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasNodeState()) { - return null; - } - return ProtoUtils.convertFromProtoFormat(p.getNodeState()); - } - - @Override - public void setNodeState(NodeState nodeState) { - maybeInitBuilder(); - if (nodeState == null) { - builder.clearNodeState(); - return; - } - builder.setNodeState(ProtoUtils.convertToProtoFormat(nodeState)); - } - - @Override - public void setCapability(Resource capability) { - maybeInitBuilder(); - if (capability == null) - builder.clearCapability(); - this.capability = capability; - } - - @Override - public void setHttpAddress(String httpAddress) { - maybeInitBuilder(); - if (httpAddress == null) { - builder.clearHttpAddress(); - return; - } - builder.setHttpAddress(httpAddress); - } - - @Override - public void setNumContainers(int numContainers) { - maybeInitBuilder(); - if (numContainers == 0) { - builder.clearNumContainers(); - return; - } - builder.setNumContainers(numContainers); - } - - @Override - public void setRackName(String rackName) { - maybeInitBuilder(); - if (rackName == null) { - builder.clearRackName(); - return; - } - builder.setRackName(rackName); - } - - @Override - public void setUsed(Resource used) { - maybeInitBuilder(); - if (used == null) - builder.clearUsed(); - this.used = used; - } - - public NodeReportProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToBuilder() { - if (this.nodeId != null - && !((NodeIdPBImpl) this.nodeId).getProto().equals( - builder.getNodeId())) { - builder.setNodeId(convertToProtoFormat(this.nodeId)); - } - if (this.used != null - && !((ResourcePBImpl) this.used).getProto().equals( - builder.getUsed())) { - builder.setUsed(convertToProtoFormat(this.used)); - } - if (this.capability != null - && !((ResourcePBImpl) this.capability).getProto().equals( - builder.getCapability())) { - builder.setCapability(convertToProtoFormat(this.capability)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = NodeReportProto.newBuilder(proto); - } - viaProto = false; - } - - - private NodeIdPBImpl convertFromProtoFormat(NodeIdProto p) { - return new NodeIdPBImpl(p); - } - - private NodeIdProto convertToProtoFormat(NodeId nodeId) { - return ((NodeIdPBImpl) nodeId).getProto(); - } - - private ResourcePBImpl convertFromProtoFormat(ResourceProto p) { - return new ResourcePBImpl(p); - } - - private ResourceProto convertToProtoFormat(Resource r) { - return ((ResourcePBImpl) r).getProto(); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionContainerPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionContainerPBImpl.java deleted file mode 100644 index 55ead20..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionContainerPBImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * 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. - */ -package org.apache.hadoop.yarn.api.records.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.PreemptionContainer; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionContainerProto; -import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionContainerProtoOrBuilder; - -@Private -@Unstable -public class PreemptionContainerPBImpl extends PreemptionContainer { - - PreemptionContainerProto proto = - PreemptionContainerProto.getDefaultInstance(); - PreemptionContainerProto.Builder builder = null; - - boolean viaProto = false; - private ContainerId id; - - public PreemptionContainerPBImpl() { - builder = PreemptionContainerProto.newBuilder(); - } - - public PreemptionContainerPBImpl(PreemptionContainerProto proto) { - this.proto = proto; - viaProto = true; - } - - public synchronized PreemptionContainerProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void mergeLocalToBuilder() { - if (id != null) { - builder.setId(convertToProtoFormat(id)); - } - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = PreemptionContainerProto.newBuilder(proto); - } - viaProto = false; - } - - @Override - public synchronized ContainerId getId() { - PreemptionContainerProtoOrBuilder p = viaProto ? proto : builder; - if (id != null) { - return id; - } - if (!p.hasId()) { - return null; - } - id = convertFromProtoFormat(p.getId()); - return id; - } - - @Override - public synchronized void setId(final ContainerId id) { - maybeInitBuilder(); - if (null == id) { - builder.clearId(); - } - this.id = id; - } - - private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { - return new ContainerIdPBImpl(p); - } - - private ContainerIdProto convertToProtoFormat(ContainerId t) { - return ((ContainerIdPBImpl)t).getProto(); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionContractPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionContractPBImpl.java deleted file mode 100644 index 07a0af9..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionContractPBImpl.java +++ /dev/null @@ -1,251 +0,0 @@ -/** - * 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. - */ -package org.apache.hadoop.yarn.api.records.impl.pb; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.PreemptionContainer; -import org.apache.hadoop.yarn.api.records.PreemptionContract; -import org.apache.hadoop.yarn.api.records.PreemptionResourceRequest; -import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionContainerProto; -import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionContractProto; -import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionContractProtoOrBuilder; -import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionResourceRequestProto; - -@Private -@Unstable -public class PreemptionContractPBImpl extends PreemptionContract { - - PreemptionContractProto proto = PreemptionContractProto.getDefaultInstance(); - PreemptionContractProto.Builder builder = null; - - boolean viaProto = false; - private Set containers; - private List resources; - - public PreemptionContractPBImpl() { - builder = PreemptionContractProto.newBuilder(); - } - - public PreemptionContractPBImpl(PreemptionContractProto proto) { - this.proto = proto; - viaProto = true; - } - - public synchronized PreemptionContractProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void mergeLocalToBuilder() { - if (this.resources != null) { - addResourcesToProto(); - } - if (this.containers != null) { - addContainersToProto(); - } - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = PreemptionContractProto.newBuilder(proto); - } - viaProto = false; - } - - @Override - public synchronized Set getContainers() { - initPreemptionContainers(); - return containers; - } - - @Override - public synchronized void setContainers( - final Set containers) { - if (null == containers) { - builder.clearContainer(); - } - this.containers = containers; - } - - @Override - public synchronized List getResourceRequest() { - initPreemptionResourceRequests(); - return resources; - } - - @Override - public synchronized void setResourceRequest( - final List req) { - if (null == resources) { - builder.clearResource(); - } - this.resources = req; - } - - private void initPreemptionResourceRequests() { - if (resources != null) { - return; - } - PreemptionContractProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getResourceList(); - resources = new ArrayList(); - - for (PreemptionResourceRequestProto rr : list) { - resources.add(convertFromProtoFormat(rr)); - } - } - - private void addResourcesToProto() { - maybeInitBuilder(); - builder.clearResource(); - if (null == resources) { - return; - } - Iterable iterable = - new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator iter = resources.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public PreemptionResourceRequestProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - builder.addAllResource(iterable); - } - - private void initPreemptionContainers() { - if (containers != null) { - return; - } - PreemptionContractProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getContainerList(); - containers = new HashSet(); - - for (PreemptionContainerProto c : list) { - containers.add(convertFromProtoFormat(c)); - } - } - - private void addContainersToProto() { - maybeInitBuilder(); - builder.clearContainer(); - if (null == containers) { - return; - } - Iterable iterable = - new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator iter = containers.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public PreemptionContainerProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - builder.addAllContainer(iterable); - } - - private PreemptionContainerPBImpl convertFromProtoFormat(PreemptionContainerProto p) { - return new PreemptionContainerPBImpl(p); - } - - private PreemptionContainerProto convertToProtoFormat(PreemptionContainer t) { - return ((PreemptionContainerPBImpl)t).getProto(); - } - - private PreemptionResourceRequestPBImpl convertFromProtoFormat(PreemptionResourceRequestProto p) { - return new PreemptionResourceRequestPBImpl(p); - } - - private PreemptionResourceRequestProto convertToProtoFormat(PreemptionResourceRequest t) { - return ((PreemptionResourceRequestPBImpl)t).getProto(); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionMessagePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionMessagePBImpl.java deleted file mode 100644 index 65dc820..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionMessagePBImpl.java +++ /dev/null @@ -1,165 +0,0 @@ -/** - * 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. - */ -package org.apache.hadoop.yarn.api.records.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.PreemptionContract; -import org.apache.hadoop.yarn.api.records.PreemptionMessage; -import org.apache.hadoop.yarn.api.records.StrictPreemptionContract; -import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionContractProto; -import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionMessageProto; -import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionMessageProtoOrBuilder; -import org.apache.hadoop.yarn.proto.YarnProtos.StrictPreemptionContractProto; - -@Private -@Unstable -public class PreemptionMessagePBImpl extends PreemptionMessage { - - PreemptionMessageProto proto = PreemptionMessageProto.getDefaultInstance(); - PreemptionMessageProto.Builder builder = null; - - boolean viaProto = false; - private StrictPreemptionContract strict; - private PreemptionContract contract; - - public PreemptionMessagePBImpl() { - builder = PreemptionMessageProto.newBuilder(); - } - - public PreemptionMessagePBImpl(PreemptionMessageProto proto) { - this.proto = proto; - viaProto = true; - } - - public synchronized PreemptionMessageProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void mergeLocalToBuilder() { - if (strict != null) { - builder.setStrictContract(convertToProtoFormat(strict)); - } - if (contract != null) { - builder.setContract(convertToProtoFormat(contract)); - } - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = PreemptionMessageProto.newBuilder(proto); - } - viaProto = false; - } - - @Override - public synchronized StrictPreemptionContract getStrictContract() { - PreemptionMessageProtoOrBuilder p = viaProto ? proto : builder; - if (strict != null) { - return strict; - } - if (!p.hasStrictContract()) { - return null; - } - strict = convertFromProtoFormat(p.getStrictContract()); - return strict; - } - - @Override - public synchronized void setStrictContract(StrictPreemptionContract strict) { - maybeInitBuilder(); - if (null == strict) { - builder.clearStrictContract(); - } - this.strict = strict; - } - - @Override - public synchronized PreemptionContract getContract() { - PreemptionMessageProtoOrBuilder p = viaProto ? proto : builder; - if (contract != null) { - return contract; - } - if (!p.hasContract()) { - return null; - } - contract = convertFromProtoFormat(p.getContract()); - return contract; - } - - @Override - public synchronized void setContract(final PreemptionContract c) { - maybeInitBuilder(); - if (null == c) { - builder.clearContract(); - } - this.contract = c; - } - - private StrictPreemptionContractPBImpl convertFromProtoFormat( - StrictPreemptionContractProto p) { - return new StrictPreemptionContractPBImpl(p); - } - - private StrictPreemptionContractProto convertToProtoFormat( - StrictPreemptionContract t) { - return ((StrictPreemptionContractPBImpl)t).getProto(); - } - - private PreemptionContractPBImpl convertFromProtoFormat( - PreemptionContractProto p) { - return new PreemptionContractPBImpl(p); - } - - private PreemptionContractProto convertToProtoFormat( - PreemptionContract t) { - return ((PreemptionContractPBImpl)t).getProto(); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionResourceRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionResourceRequestPBImpl.java deleted file mode 100644 index 97930c3..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionResourceRequestPBImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * 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. - */ -package org.apache.hadoop.yarn.api.records.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.PreemptionResourceRequest; -import org.apache.hadoop.yarn.api.records.ResourceRequest; -import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionResourceRequestProto; -import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionResourceRequestProtoOrBuilder; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceRequestProto; - -@Private -@Unstable -public class PreemptionResourceRequestPBImpl extends PreemptionResourceRequest { - - PreemptionResourceRequestProto proto = - PreemptionResourceRequestProto.getDefaultInstance(); - PreemptionResourceRequestProto.Builder builder = null; - - boolean viaProto = false; - private ResourceRequest rr; - - public PreemptionResourceRequestPBImpl() { - builder = PreemptionResourceRequestProto.newBuilder(); - } - - public PreemptionResourceRequestPBImpl(PreemptionResourceRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public synchronized PreemptionResourceRequestProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void mergeLocalToBuilder() { - if (rr != null) { - builder.setResource(convertToProtoFormat(rr)); - } - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = PreemptionResourceRequestProto.newBuilder(proto); - } - viaProto = false; - } - - @Override - public synchronized ResourceRequest getResourceRequest() { - PreemptionResourceRequestProtoOrBuilder p = viaProto ? proto : builder; - if (rr != null) { - return rr; - } - if (!p.hasResource()) { - return null; - } - rr = convertFromProtoFormat(p.getResource()); - return rr; - } - - @Override - public synchronized void setResourceRequest(final ResourceRequest rr) { - maybeInitBuilder(); - if (null == rr) { - builder.clearResource(); - } - this.rr = rr; - } - - private ResourceRequestPBImpl convertFromProtoFormat(ResourceRequestProto p) { - return new ResourceRequestPBImpl(p); - } - - private ResourceRequestProto convertToProtoFormat(ResourceRequest t) { - return ((ResourceRequestPBImpl)t).getProto(); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PriorityPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PriorityPBImpl.java deleted file mode 100644 index c8abdbe..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PriorityPBImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.Priority; -import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto; -import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProtoOrBuilder; - -@Private -@Unstable -public class PriorityPBImpl extends Priority { - PriorityProto proto = PriorityProto.getDefaultInstance(); - PriorityProto.Builder builder = null; - boolean viaProto = false; - - public PriorityPBImpl() { - builder = PriorityProto.newBuilder(); - } - - public PriorityPBImpl(PriorityProto proto) { - this.proto = proto; - viaProto = true; - } - - public PriorityProto getProto() { - proto = viaProto ? proto : builder.build(); - viaProto = true; - return proto; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = PriorityProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public int getPriority() { - PriorityProtoOrBuilder p = viaProto ? proto : builder; - return (p.getPriority()); - } - - @Override - public void setPriority(int priority) { - maybeInitBuilder(); - builder.setPriority((priority)); - } - - @Override - public String toString() { - return Integer.valueOf(getPriority()).toString(); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoBase.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoBase.java deleted file mode 100644 index 4e8c39b..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoBase.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - -import java.nio.ByteBuffer; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; - -import com.google.protobuf.ByteString; -import com.google.protobuf.Message; - -@Private -@Unstable -public abstract class ProtoBase { - - public abstract T getProto(); - - //TODO Force a comparator? - - @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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - protected final ByteBuffer convertFromProtoFormat(ByteString byteString) { - return ProtoUtils.convertFromProtoFormat(byteString); - } - - protected final ByteString convertToProtoFormat(ByteBuffer byteBuffer) { - return ProtoUtils.convertToProtoFormat(byteBuffer); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoUtils.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoUtils.java deleted file mode 100644 index b660f7d..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoUtils.java +++ /dev/null @@ -1,209 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - -import java.nio.ByteBuffer; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.AMCommand; -import org.apache.hadoop.yarn.api.records.ApplicationAccessType; -import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; -import org.apache.hadoop.yarn.api.records.ContainerState; -import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; -import org.apache.hadoop.yarn.api.records.LocalResourceType; -import org.apache.hadoop.yarn.api.records.LocalResourceVisibility; -import org.apache.hadoop.yarn.api.records.NodeId; -import org.apache.hadoop.yarn.api.records.NodeState; -import org.apache.hadoop.yarn.api.records.QueueACL; -import org.apache.hadoop.yarn.api.records.QueueState; -import org.apache.hadoop.yarn.api.records.YarnApplicationState; -import org.apache.hadoop.yarn.proto.YarnProtos.AMCommandProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAccessTypeProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationResourceUsageReportProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto; -import org.apache.hadoop.yarn.proto.YarnProtos.FinalApplicationStatusProto; -import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceTypeProto; -import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceVisibilityProto; -import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.NodeStateProto; -import org.apache.hadoop.yarn.proto.YarnProtos.QueueACLProto; -import org.apache.hadoop.yarn.proto.YarnProtos.QueueStateProto; -import org.apache.hadoop.yarn.proto.YarnProtos.YarnApplicationStateProto; - -import com.google.protobuf.ByteString; - -@Private -@Unstable -public class ProtoUtils { - - - /* - * ContainerState - */ - private static String CONTAINER_STATE_PREFIX = "C_"; - public static ContainerStateProto convertToProtoFormat(ContainerState e) { - return ContainerStateProto.valueOf(CONTAINER_STATE_PREFIX + e.name()); - } - public static ContainerState convertFromProtoFormat(ContainerStateProto e) { - return ContainerState.valueOf(e.name().replace(CONTAINER_STATE_PREFIX, "")); - } - - /* - * NodeState - */ - private static String NODE_STATE_PREFIX = "NS_"; - public static NodeStateProto convertToProtoFormat(NodeState e) { - return NodeStateProto.valueOf(NODE_STATE_PREFIX + e.name()); - } - public static NodeState convertFromProtoFormat(NodeStateProto e) { - return NodeState.valueOf(e.name().replace(NODE_STATE_PREFIX, "")); - } - - /* - * NodeId - */ - public static NodeIdProto convertToProtoFormat(NodeId e) { - return ((NodeIdPBImpl)e).getProto(); - } - public static NodeId convertFromProtoFormat(NodeIdProto e) { - return new NodeIdPBImpl(e); - } - - /* - * YarnApplicationState - */ - public static YarnApplicationStateProto convertToProtoFormat(YarnApplicationState e) { - return YarnApplicationStateProto.valueOf(e.name()); - } - public static YarnApplicationState convertFromProtoFormat(YarnApplicationStateProto e) { - return YarnApplicationState.valueOf(e.name()); - } - - /* - * ApplicationResourceUsageReport - */ - public static ApplicationResourceUsageReportProto convertToProtoFormat(ApplicationResourceUsageReport e) { - return ((ApplicationResourceUsageReportPBImpl)e).getProto(); - } - - public static ApplicationResourceUsageReport convertFromProtoFormat(ApplicationResourceUsageReportProto e) { - return new ApplicationResourceUsageReportPBImpl(e); - } - - /* - * FinalApplicationStatus - */ - private static String FINAL_APPLICATION_STATUS_PREFIX = "APP_"; - public static FinalApplicationStatusProto convertToProtoFormat(FinalApplicationStatus e) { - return FinalApplicationStatusProto.valueOf(FINAL_APPLICATION_STATUS_PREFIX + e.name()); - } - public static FinalApplicationStatus convertFromProtoFormat(FinalApplicationStatusProto e) { - return FinalApplicationStatus.valueOf(e.name().replace(FINAL_APPLICATION_STATUS_PREFIX, "")); - } - - /* - * LocalResourceType - */ - public static LocalResourceTypeProto convertToProtoFormat(LocalResourceType e) { - return LocalResourceTypeProto.valueOf(e.name()); - } - public static LocalResourceType convertFromProtoFormat(LocalResourceTypeProto e) { - return LocalResourceType.valueOf(e.name()); - } - - /* - * LocalResourceVisibility - */ - public static LocalResourceVisibilityProto convertToProtoFormat(LocalResourceVisibility e) { - return LocalResourceVisibilityProto.valueOf(e.name()); - } - public static LocalResourceVisibility convertFromProtoFormat(LocalResourceVisibilityProto e) { - return LocalResourceVisibility.valueOf(e.name()); - } - - /* - * AMCommand - */ - public static AMCommandProto convertToProtoFormat(AMCommand e) { - return AMCommandProto.valueOf(e.name()); - } - public static AMCommand convertFromProtoFormat(AMCommandProto e) { - return AMCommand.valueOf(e.name()); - } - - /* - * ByteBuffer - */ - public static ByteBuffer convertFromProtoFormat(ByteString byteString) { - int capacity = byteString.asReadOnlyByteBuffer().rewind().remaining(); - byte[] b = new byte[capacity]; - byteString.asReadOnlyByteBuffer().get(b, 0, capacity); - return ByteBuffer.wrap(b); - } - - public static ByteString convertToProtoFormat(ByteBuffer byteBuffer) { -// return ByteString.copyFrom((ByteBuffer)byteBuffer.duplicate().rewind()); - int oldPos = byteBuffer.position(); - byteBuffer.rewind(); - ByteString bs = ByteString.copyFrom(byteBuffer); - byteBuffer.position(oldPos); - return bs; - } - - /* - * QueueState - */ - private static String QUEUE_STATE_PREFIX = "Q_"; - public static QueueStateProto convertToProtoFormat(QueueState e) { - return QueueStateProto.valueOf(QUEUE_STATE_PREFIX + e.name()); - } - public static QueueState convertFromProtoFormat(QueueStateProto e) { - return QueueState.valueOf(e.name().replace(QUEUE_STATE_PREFIX, "")); - } - - /* - * QueueACL - */ - private static String QUEUE_ACL_PREFIX = "QACL_"; - public static QueueACLProto convertToProtoFormat(QueueACL e) { - return QueueACLProto.valueOf(QUEUE_ACL_PREFIX + e.name()); - } - public static QueueACL convertFromProtoFormat(QueueACLProto e) { - return QueueACL.valueOf(e.name().replace(QUEUE_ACL_PREFIX, "")); - } - - - /* - * ApplicationAccessType - */ - private static String APP_ACCESS_TYPE_PREFIX = "APPACCESS_"; - - public static ApplicationAccessTypeProto convertToProtoFormat( - ApplicationAccessType e) { - return ApplicationAccessTypeProto.valueOf(APP_ACCESS_TYPE_PREFIX - + e.name()); - } - - public static ApplicationAccessType convertFromProtoFormat( - ApplicationAccessTypeProto e) { - return ApplicationAccessType.valueOf(e.name().replace( - APP_ACCESS_TYPE_PREFIX, "")); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java deleted file mode 100644 index 529bd8b..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java +++ /dev/null @@ -1,324 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ApplicationReport; -import org.apache.hadoop.yarn.api.records.QueueInfo; -import org.apache.hadoop.yarn.api.records.QueueState; -import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationReportProto; -import org.apache.hadoop.yarn.proto.YarnProtos.QueueInfoProto; -import org.apache.hadoop.yarn.proto.YarnProtos.QueueInfoProtoOrBuilder; -import org.apache.hadoop.yarn.proto.YarnProtos.QueueStateProto; - -@Private -@Unstable -public class QueueInfoPBImpl extends QueueInfo { - - QueueInfoProto proto = QueueInfoProto.getDefaultInstance(); - QueueInfoProto.Builder builder = null; - boolean viaProto = false; - - List applicationsList; - List childQueuesList; - - public QueueInfoPBImpl() { - builder = QueueInfoProto.newBuilder(); - } - - public QueueInfoPBImpl(QueueInfoProto proto) { - this.proto = proto; - viaProto = true; - } - - @Override - public List getApplications() { - initLocalApplicationsList(); - return this.applicationsList; - } - - @Override - public float getCapacity() { - QueueInfoProtoOrBuilder p = viaProto ? proto : builder; - return (p.hasCapacity()) ? p.getCapacity() : -1; - } - - @Override - public List getChildQueues() { - initLocalChildQueuesList(); - return this.childQueuesList; - } - - @Override - public float getCurrentCapacity() { - QueueInfoProtoOrBuilder p = viaProto ? proto : builder; - return (p.hasCurrentCapacity()) ? p.getCurrentCapacity() : 0; - } - - @Override - public float getMaximumCapacity() { - QueueInfoProtoOrBuilder p = viaProto ? proto : builder; - return (p.hasMaximumCapacity()) ? p.getMaximumCapacity() : -1; - } - - @Override - public String getQueueName() { - QueueInfoProtoOrBuilder p = viaProto ? proto : builder; - return (p.hasQueueName()) ? p.getQueueName() : null; - } - - @Override - public QueueState getQueueState() { - QueueInfoProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasState()) { - return null; - } - return convertFromProtoFormat(p.getState()); - } - - @Override - public void setApplications(List applications) { - if (applications == null) { - builder.clearApplications(); - } - this.applicationsList = applications; - } - - @Override - public void setCapacity(float capacity) { - maybeInitBuilder(); - builder.setCapacity(capacity); - } - - @Override - public void setChildQueues(List childQueues) { - if (childQueues == null) { - builder.clearChildQueues(); - } - this.childQueuesList = childQueues; - } - - @Override - public void setCurrentCapacity(float currentCapacity) { - maybeInitBuilder(); - builder.setCurrentCapacity(currentCapacity); - } - - @Override - public void setMaximumCapacity(float maximumCapacity) { - maybeInitBuilder(); - builder.setMaximumCapacity(maximumCapacity); - } - - @Override - public void setQueueName(String queueName) { - maybeInitBuilder(); - if (queueName == null) { - builder.clearQueueName(); - return; - } - builder.setQueueName(queueName); - } - - @Override - public void setQueueState(QueueState queueState) { - maybeInitBuilder(); - if (queueState == null) { - builder.clearState(); - return; - } - builder.setState(convertToProtoFormat(queueState)); - } - - public QueueInfoProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void initLocalApplicationsList() { - if (this.applicationsList != null) { - return; - } - QueueInfoProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getApplicationsList(); - applicationsList = new ArrayList(); - - for (ApplicationReportProto a : list) { - applicationsList.add(convertFromProtoFormat(a)); - } - } - - private void addApplicationsToProto() { - maybeInitBuilder(); - builder.clearApplications(); - if (applicationsList == null) - return; - Iterable iterable = new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator iter = applicationsList.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public ApplicationReportProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - builder.addAllApplications(iterable); - } - - private void initLocalChildQueuesList() { - if (this.childQueuesList != null) { - return; - } - QueueInfoProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getChildQueuesList(); - childQueuesList = new ArrayList(); - - for (QueueInfoProto a : list) { - childQueuesList.add(convertFromProtoFormat(a)); - } - } - - private void addChildQueuesInfoToProto() { - maybeInitBuilder(); - builder.clearChildQueues(); - if (childQueuesList == null) - return; - Iterable iterable = new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator iter = childQueuesList.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public QueueInfoProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - builder.addAllChildQueues(iterable); - } - - private void mergeLocalToBuilder() { - if (this.childQueuesList != null) { - addChildQueuesInfoToProto(); - } - if (this.applicationsList != null) { - addApplicationsToProto(); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = QueueInfoProto.newBuilder(proto); - } - viaProto = false; - } - - - private ApplicationReportPBImpl convertFromProtoFormat(ApplicationReportProto a) { - return new ApplicationReportPBImpl(a); - } - - private ApplicationReportProto convertToProtoFormat(ApplicationReport t) { - return ((ApplicationReportPBImpl)t).getProto(); - } - - private QueueInfoPBImpl convertFromProtoFormat(QueueInfoProto a) { - return new QueueInfoPBImpl(a); - } - - private QueueInfoProto convertToProtoFormat(QueueInfo q) { - return ((QueueInfoPBImpl)q).getProto(); - } - - private QueueState convertFromProtoFormat(QueueStateProto q) { - return ProtoUtils.convertFromProtoFormat(q); - } - - private QueueStateProto convertToProtoFormat(QueueState queueState) { - return ProtoUtils.convertToProtoFormat(queueState); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueUserACLInfoPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueUserACLInfoPBImpl.java deleted file mode 100644 index cf48410..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueUserACLInfoPBImpl.java +++ /dev/null @@ -1,185 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.QueueACL; -import org.apache.hadoop.yarn.api.records.QueueUserACLInfo; -import org.apache.hadoop.yarn.proto.YarnProtos.QueueACLProto; -import org.apache.hadoop.yarn.proto.YarnProtos.QueueUserACLInfoProto; -import org.apache.hadoop.yarn.proto.YarnProtos.QueueUserACLInfoProtoOrBuilder; - -@Private -@Unstable -public class QueueUserACLInfoPBImpl extends QueueUserACLInfo { - - QueueUserACLInfoProto proto = QueueUserACLInfoProto.getDefaultInstance(); - QueueUserACLInfoProto.Builder builder = null; - boolean viaProto = false; - - List userAclsList; - - public QueueUserACLInfoPBImpl() { - builder = QueueUserACLInfoProto.newBuilder(); - } - - public QueueUserACLInfoPBImpl(QueueUserACLInfoProto proto) { - this.proto = proto; - viaProto = true; - } - - @Override - public String getQueueName() { - QueueUserACLInfoProtoOrBuilder p = viaProto ? proto : builder; - return (p.hasQueueName()) ? p.getQueueName() : null; - } - - @Override - public List getUserAcls() { - initLocalQueueUserAclsList(); - return this.userAclsList; - } - - @Override - public void setQueueName(String queueName) { - maybeInitBuilder(); - if (queueName == null) { - builder.clearQueueName(); - return; - } - builder.setQueueName(queueName); - } - - @Override - public void setUserAcls(List userAclsList) { - if (userAclsList == null) { - builder.clearUserAcls(); - } - this.userAclsList = userAclsList; - } - - public QueueUserACLInfoProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void initLocalQueueUserAclsList() { - if (this.userAclsList != null) { - return; - } - QueueUserACLInfoProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getUserAclsList(); - userAclsList = new ArrayList(); - - for (QueueACLProto a : list) { - userAclsList.add(convertFromProtoFormat(a)); - } - } - - private void addQueueACLsToProto() { - maybeInitBuilder(); - builder.clearUserAcls(); - if (userAclsList == null) - return; - Iterable iterable = new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator iter = userAclsList.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public QueueACLProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - builder.addAllUserAcls(iterable); - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = QueueUserACLInfoProto.newBuilder(proto); - } - viaProto = false; - } - - private void mergeLocalToBuilder() { - if (this.userAclsList != null) { - addQueueACLsToProto(); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private QueueACL convertFromProtoFormat(QueueACLProto q) { - return ProtoUtils.convertFromProtoFormat(q); - } - - private QueueACLProto convertToProtoFormat(QueueACL queueAcl) { - return ProtoUtils.convertToProtoFormat(queueAcl); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceBlacklistRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceBlacklistRequestPBImpl.java deleted file mode 100644 index 96cb139..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceBlacklistRequestPBImpl.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ResourceBlacklistRequest; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceBlacklistRequestProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceBlacklistRequestProtoOrBuilder; - -@Private -@Unstable -public class ResourceBlacklistRequestPBImpl extends ResourceBlacklistRequest { - - ResourceBlacklistRequestProto proto = null; - ResourceBlacklistRequestProto.Builder builder = null; - boolean viaProto = false; - - List blacklistAdditions = null; - List blacklistRemovals = null; - - public ResourceBlacklistRequestPBImpl() { - builder = ResourceBlacklistRequestProto.newBuilder(); - } - - public ResourceBlacklistRequestPBImpl(ResourceBlacklistRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public ResourceBlacklistRequestProto getProto() { - mergeLocalToProto(); - proto = viaProto ? proto : builder.build(); - viaProto = true; - return proto; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = ResourceBlacklistRequestProto.newBuilder(proto); - } - viaProto = false; - } - - private void mergeLocalToProto() { - if (viaProto) { - maybeInitBuilder(); - } - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void mergeLocalToBuilder() { - if (this.blacklistAdditions != null) { - addBlacklistAdditionsToProto(); - } - if (this.blacklistRemovals != null) { - addBlacklistRemovalsToProto(); - } - } - - private void addBlacklistAdditionsToProto() { - maybeInitBuilder(); - builder.clearBlacklistAdditions(); - if (this.blacklistAdditions == null) { - return; - } - builder.addAllBlacklistAdditions(this.blacklistAdditions); - } - - private void addBlacklistRemovalsToProto() { - maybeInitBuilder(); - builder.clearBlacklistAdditions(); - if (this.blacklistRemovals == null) { - return; - } - builder.addAllBlacklistRemovals(this.blacklistRemovals); - } - - private void initBlacklistAdditions() { - if (this.blacklistAdditions != null) { - return; - } - ResourceBlacklistRequestProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getBlacklistAdditionsList(); - this.blacklistAdditions = new ArrayList(); - this.blacklistAdditions.addAll(list); - } - - private void initBlacklistRemovals() { - if (this.blacklistRemovals != null) { - return; - } - ResourceBlacklistRequestProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getBlacklistRemovalsList(); - this.blacklistRemovals = new ArrayList(); - this.blacklistRemovals.addAll(list); - } - - @Override - public List getBlacklistAdditions() { - initBlacklistAdditions(); - return this.blacklistAdditions; - } - - @Override - public void setBlacklistAdditions(List resourceNames) { - if (resourceNames == null) { - if (this.blacklistAdditions != null) { - this.blacklistAdditions.clear(); - } - return; - } - initBlacklistAdditions(); - this.blacklistAdditions.clear(); - this.blacklistAdditions.addAll(resourceNames); - } - - @Override - public List getBlacklistRemovals() { - initBlacklistRemovals(); - return this.blacklistRemovals; - } - - @Override - public void setBlacklistRemovals(List resourceNames) { - if (resourceNames == null) { - if (this.blacklistRemovals != null) { - this.blacklistRemovals.clear(); - } - return; - } - initBlacklistRemovals(); - this.blacklistRemovals.clear(); - this.blacklistRemovals.addAll(resourceNames); - } - - @Override - public int hashCode() { - return getProto().hashCode(); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourcePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourcePBImpl.java deleted file mode 100644 index a28c6ed..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourcePBImpl.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProtoOrBuilder; - -@Private -@Unstable -public class ResourcePBImpl extends Resource { - ResourceProto proto = ResourceProto.getDefaultInstance(); - ResourceProto.Builder builder = null; - boolean viaProto = false; - - public ResourcePBImpl() { - builder = ResourceProto.newBuilder(); - } - - public ResourcePBImpl(ResourceProto proto) { - this.proto = proto; - viaProto = true; - } - - public ResourceProto getProto() { - proto = viaProto ? proto : builder.build(); - viaProto = true; - return proto; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = ResourceProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public int getMemory() { - ResourceProtoOrBuilder p = viaProto ? proto : builder; - return (p.getMemory()); - } - - @Override - public void setMemory(int memory) { - maybeInitBuilder(); - builder.setMemory((memory)); - } - - @Override - public int getVirtualCores() { - ResourceProtoOrBuilder p = viaProto ? proto : builder; - return (p.getVirtualCores()); - } - - @Override - public void setVirtualCores(int vCores) { - maybeInitBuilder(); - builder.setVirtualCores((vCores)); - } - - @Override - public int compareTo(Resource other) { - int diff = this.getMemory() - other.getMemory(); - if (diff == 0) { - diff = this.getVirtualCores() - other.getVirtualCores(); - } - return diff; - } - - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceRequestPBImpl.java deleted file mode 100644 index 22863ac..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceRequestPBImpl.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.Priority; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.api.records.ResourceRequest; -import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceRequestProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceRequestProtoOrBuilder; - -@Private -@Unstable -public class ResourceRequestPBImpl extends ResourceRequest { - ResourceRequestProto proto = ResourceRequestProto.getDefaultInstance(); - ResourceRequestProto.Builder builder = null; - boolean viaProto = false; - - private Priority priority = null; - private Resource capability = null; - - - public ResourceRequestPBImpl() { - builder = ResourceRequestProto.newBuilder(); - } - - public ResourceRequestPBImpl(ResourceRequestProto proto) { - this.proto = proto; - viaProto = true; - } - - public ResourceRequestProto getProto() { - mergeLocalToProto(); - proto = viaProto ? proto : builder.build(); - viaProto = true; - return proto; - } - - private void mergeLocalToBuilder() { - if (this.priority != null) { - builder.setPriority(convertToProtoFormat(this.priority)); - } - if (this.capability != null) { - builder.setCapability(convertToProtoFormat(this.capability)); - } - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = ResourceRequestProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public Priority getPriority() { - ResourceRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.priority != null) { - return this.priority; - } - if (!p.hasPriority()) { - return null; - } - this.priority = convertFromProtoFormat(p.getPriority()); - return this.priority; - } - - @Override - public void setPriority(Priority priority) { - maybeInitBuilder(); - if (priority == null) - builder.clearPriority(); - this.priority = priority; - } - @Override - public String getResourceName() { - ResourceRequestProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasResourceName()) { - return null; - } - return (p.getResourceName()); - } - - @Override - public void setResourceName(String resourceName) { - maybeInitBuilder(); - if (resourceName == null) { - builder.clearResourceName(); - return; - } - builder.setResourceName((resourceName)); - } - @Override - public Resource getCapability() { - ResourceRequestProtoOrBuilder p = viaProto ? proto : builder; - if (this.capability != null) { - return this.capability; - } - if (!p.hasCapability()) { - return null; - } - this.capability = convertFromProtoFormat(p.getCapability()); - return this.capability; - } - - @Override - public void setCapability(Resource capability) { - maybeInitBuilder(); - if (capability == null) - builder.clearCapability(); - this.capability = capability; - } - @Override - public int getNumContainers() { - ResourceRequestProtoOrBuilder p = viaProto ? proto : builder; - return (p.getNumContainers()); - } - - @Override - public void setNumContainers(int numContainers) { - maybeInitBuilder(); - builder.setNumContainers((numContainers)); - } - - @Override - public boolean getRelaxLocality() { - ResourceRequestProtoOrBuilder p = viaProto ? proto : builder; - return p.getRelaxLocality(); - } - - @Override - public void setRelaxLocality(boolean relaxLocality) { - maybeInitBuilder(); - builder.setRelaxLocality(relaxLocality); - } - - private PriorityPBImpl convertFromProtoFormat(PriorityProto p) { - return new PriorityPBImpl(p); - } - - private PriorityProto convertToProtoFormat(Priority t) { - return ((PriorityPBImpl)t).getProto(); - } - - private ResourcePBImpl convertFromProtoFormat(ResourceProto p) { - return new ResourcePBImpl(p); - } - - private ResourceProto convertToProtoFormat(Resource t) { - return ((ResourcePBImpl)t).getProto(); - } - - @Override - public String toString() { - return "{Priority: " + getPriority() + ", Capability: " + getCapability() - + ", # Containers: " + getNumContainers() - + ", Location: " + getResourceName() - + ", Relax Locality: " + getRelaxLocality() + "}"; - } -} \ No newline at end of file diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/StrictPreemptionContractPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/StrictPreemptionContractPBImpl.java deleted file mode 100644 index 0d80921..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/StrictPreemptionContractPBImpl.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * 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. - */ -package org.apache.hadoop.yarn.api.records.impl.pb; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.PreemptionContainer; -import org.apache.hadoop.yarn.api.records.StrictPreemptionContract; -import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionContainerProto; -import org.apache.hadoop.yarn.proto.YarnProtos.StrictPreemptionContractProto; -import org.apache.hadoop.yarn.proto.YarnProtos.StrictPreemptionContractProtoOrBuilder; - -@Private -@Unstable -public class StrictPreemptionContractPBImpl extends StrictPreemptionContract { - - StrictPreemptionContractProto proto = - StrictPreemptionContractProto.getDefaultInstance(); - StrictPreemptionContractProto.Builder builder = null; - - boolean viaProto = false; - private Set containers; - - public StrictPreemptionContractPBImpl() { - builder = StrictPreemptionContractProto.newBuilder(); - } - - public StrictPreemptionContractPBImpl(StrictPreemptionContractProto proto) { - this.proto = proto; - viaProto = true; - } - - public synchronized StrictPreemptionContractProto getProto() { - mergeLocalToProto(); - 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void mergeLocalToBuilder() { - if (this.containers != null) { - addContainersToProto(); - } - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = StrictPreemptionContractProto.newBuilder(proto); - } - viaProto = false; - } - - @Override - public synchronized Set getContainers() { - initIds(); - return containers; - } - - @Override - public synchronized void setContainers( - final Set containers) { - if (null == containers) { - builder.clearContainer(); - } - this.containers = containers; - } - - private void initIds() { - if (containers != null) { - return; - } - StrictPreemptionContractProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getContainerList(); - containers = new HashSet(); - - for (PreemptionContainerProto c : list) { - containers.add(convertFromProtoFormat(c)); - } - } - - private void addContainersToProto() { - maybeInitBuilder(); - builder.clearContainer(); - if (containers == null) { - return; - } - Iterable iterable = new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator iter = containers.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public PreemptionContainerProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - - } - }; - - } - }; - builder.addAllContainer(iterable); - } - - private PreemptionContainerPBImpl convertFromProtoFormat(PreemptionContainerProto p) { - return new PreemptionContainerPBImpl(p); - } - - private PreemptionContainerProto convertToProtoFormat(PreemptionContainer t) { - return ((PreemptionContainerPBImpl)t).getProto(); - } - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/TokenPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/TokenPBImpl.java deleted file mode 100644 index 2835cbb..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/TokenPBImpl.java +++ /dev/null @@ -1,192 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - -import java.nio.ByteBuffer; - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; -import org.apache.hadoop.security.proto.SecurityProtos.TokenProtoOrBuilder; -import org.apache.hadoop.yarn.api.records.Token; - -import com.google.protobuf.ByteString; - -@Private -@Unstable -public class TokenPBImpl extends Token { - private TokenProto proto = TokenProto.getDefaultInstance(); - private TokenProto.Builder builder = null; - private boolean viaProto = false; - - private ByteBuffer identifier; - private ByteBuffer password; - - public TokenPBImpl() { - builder = TokenProto.newBuilder(); - } - - public TokenPBImpl(TokenProto proto) { - this.proto = proto; - viaProto = true; - } - - public synchronized TokenProto getProto() { - mergeLocalToProto(); - 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; - } - - protected final ByteBuffer convertFromProtoFormat(ByteString byteString) { - return ProtoUtils.convertFromProtoFormat(byteString); - } - - protected final ByteString convertToProtoFormat(ByteBuffer byteBuffer) { - return ProtoUtils.convertToProtoFormat(byteBuffer); - } - - private synchronized void mergeLocalToBuilder() { - if (this.identifier != null) { - builder.setIdentifier(convertToProtoFormat(this.identifier)); - } - if (this.password != null) { - builder.setPassword(convertToProtoFormat(this.password)); - } - } - - private synchronized void mergeLocalToProto() { - if (viaProto) - maybeInitBuilder(); - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private synchronized void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = TokenProto.newBuilder(proto); - } - viaProto = false; - } - - @Override - public synchronized ByteBuffer getIdentifier() { - TokenProtoOrBuilder p = viaProto ? proto : builder; - if (this.identifier != null) { - return this.identifier; - } - if (!p.hasIdentifier()) { - return null; - } - this.identifier = convertFromProtoFormat(p.getIdentifier()); - return this.identifier; - } - - @Override - public synchronized void setIdentifier(ByteBuffer identifier) { - maybeInitBuilder(); - if (identifier == null) - builder.clearIdentifier(); - this.identifier = identifier; - } - - @Override - public synchronized ByteBuffer getPassword() { - TokenProtoOrBuilder p = viaProto ? proto : builder; - if (this.password != null) { - return this.password; - } - if (!p.hasPassword()) { - return null; - } - this.password = convertFromProtoFormat(p.getPassword()); - return this.password; - } - - @Override - public synchronized void setPassword(ByteBuffer password) { - maybeInitBuilder(); - if (password == null) - builder.clearPassword(); - this.password = password; - } - - @Override - public synchronized String getKind() { - TokenProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasKind()) { - return null; - } - return (p.getKind()); - } - - @Override - public synchronized void setKind(String kind) { - maybeInitBuilder(); - if (kind == null) { - builder.clearKind(); - return; - } - builder.setKind((kind)); - } - - @Override - public synchronized String getService() { - TokenProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasService()) { - return null; - } - return (p.getService()); - } - - @Override - public synchronized void setService(String service) { - maybeInitBuilder(); - if (service == null) { - builder.clearService(); - return; - } - builder.setService((service)); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("Token { "); - sb.append("kind: ").append(getKind()).append(", "); - sb.append("service: ").append(getService()).append(" }"); - return sb.toString(); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/URLPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/URLPBImpl.java deleted file mode 100644 index 14cc762..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/URLPBImpl.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.URL; -import org.apache.hadoop.yarn.proto.YarnProtos.URLProto; -import org.apache.hadoop.yarn.proto.YarnProtos.URLProtoOrBuilder; - -@Private -@Unstable -public class URLPBImpl extends URL { - URLProto proto = URLProto.getDefaultInstance(); - URLProto.Builder builder = null; - boolean viaProto = false; - - public URLPBImpl() { - builder = URLProto.newBuilder(); - } - - public URLPBImpl(URLProto proto) { - this.proto = proto; - viaProto = true; - } - - public URLProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = URLProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public String getFile() { - URLProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasFile()) { - return null; - } - return (p.getFile()); - } - - @Override - public void setFile(String file) { - maybeInitBuilder(); - if (file == null) { - builder.clearFile(); - return; - } - builder.setFile((file)); - } - @Override - public String getScheme() { - URLProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasScheme()) { - return null; - } - return (p.getScheme()); - } - - @Override - public void setScheme(String scheme) { - maybeInitBuilder(); - if (scheme == null) { - builder.clearScheme(); - return; - } - builder.setScheme((scheme)); - } - @Override - public String getHost() { - URLProtoOrBuilder p = viaProto ? proto : builder; - if (!p.hasHost()) { - return null; - } - return (p.getHost()); - } - - @Override - public void setHost(String host) { - maybeInitBuilder(); - if (host == null) { - builder.clearHost(); - return; - } - builder.setHost((host)); - } - @Override - public int getPort() { - URLProtoOrBuilder p = viaProto ? proto : builder; - return (p.getPort()); - } - - @Override - public void setPort(int port) { - maybeInitBuilder(); - builder.setPort((port)); - } - - - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/YarnClusterMetricsPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/YarnClusterMetricsPBImpl.java deleted file mode 100644 index cef6c62..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/YarnClusterMetricsPBImpl.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * 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. - */ - -package org.apache.hadoop.yarn.api.records.impl.pb; - - -import org.apache.hadoop.classification.InterfaceAudience.Private; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.YarnClusterMetrics; -import org.apache.hadoop.yarn.proto.YarnProtos.YarnClusterMetricsProto; -import org.apache.hadoop.yarn.proto.YarnProtos.YarnClusterMetricsProtoOrBuilder; - -@Private -@Unstable -public class YarnClusterMetricsPBImpl extends YarnClusterMetrics { - YarnClusterMetricsProto proto = YarnClusterMetricsProto.getDefaultInstance(); - YarnClusterMetricsProto.Builder builder = null; - boolean viaProto = false; - - public YarnClusterMetricsPBImpl() { - builder = YarnClusterMetricsProto.newBuilder(); - } - - public YarnClusterMetricsPBImpl(YarnClusterMetricsProto proto) { - this.proto = proto; - viaProto = true; - } - - public YarnClusterMetricsProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = YarnClusterMetricsProto.newBuilder(proto); - } - viaProto = false; - } - - - @Override - public int getNumNodeManagers() { - YarnClusterMetricsProtoOrBuilder p = viaProto ? proto : builder; - return (p.getNumNodeManagers()); - } - - @Override - public void setNumNodeManagers(int numNodeManagers) { - maybeInitBuilder(); - builder.setNumNodeManagers((numNodeManagers)); - } - - - -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/package-info.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/package-info.java deleted file mode 100644 index 1f14e60..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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. - */ -@InterfaceAudience.Private -package org.apache.hadoop.yarn.api.records.impl.pb; -import org.apache.hadoop.classification.InterfaceAudience; diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/ApplicationClientProtocolPB.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/ApplicationClientProtocolPB.java new file mode 100644 index 0000000..9e50c54 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/ApplicationClientProtocolPB.java @@ -0,0 +1,31 @@ +/** + * 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. + */ +package org.apache.hadoop.yarn.api; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.ipc.ProtocolInfo; +import org.apache.hadoop.yarn.proto.ApplicationClientProtocol.ApplicationClientProtocolService; + +@Private +@Unstable +@ProtocolInfo(protocolName = "org.apache.hadoop.yarn.api.ApplicationClientProtocolPB", + protocolVersion = 1) +public interface ApplicationClientProtocolPB extends ApplicationClientProtocolService.BlockingInterface { + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/ApplicationMasterProtocolPB.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/ApplicationMasterProtocolPB.java new file mode 100644 index 0000000..841ef61 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/ApplicationMasterProtocolPB.java @@ -0,0 +1,31 @@ +/** + * 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. + */ +package org.apache.hadoop.yarn.api; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.ipc.ProtocolInfo; +import org.apache.hadoop.yarn.proto.ApplicationMasterProtocol.ApplicationMasterProtocolService; + +@Private +@Unstable +@ProtocolInfo(protocolName = "org.apache.hadoop.yarn.api.ApplicationMasterProtocolPB", + protocolVersion = 1) +public interface ApplicationMasterProtocolPB extends ApplicationMasterProtocolService.BlockingInterface { + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/ContainerManagementProtocolPB.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/ContainerManagementProtocolPB.java new file mode 100644 index 0000000..82e9ad0 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/ContainerManagementProtocolPB.java @@ -0,0 +1,32 @@ +/** + * 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. + */ +package org.apache.hadoop.yarn.api; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.ipc.ProtocolInfo; +import org.apache.hadoop.yarn.proto.ContainerManagementProtocol.ContainerManagementProtocolService; + +@Private +@Unstable +@ProtocolInfo( + protocolName = "org.apache.hadoop.yarn.api.ContainerManagementProtocolPB", + protocolVersion = 1) +public interface ContainerManagementProtocolPB extends ContainerManagementProtocolService.BlockingInterface { + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/ResourceManagerAdministrationProtocolPB.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/ResourceManagerAdministrationProtocolPB.java new file mode 100644 index 0000000..6979bab --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/ResourceManagerAdministrationProtocolPB.java @@ -0,0 +1,32 @@ +/** + * 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. + */ +package org.apache.hadoop.yarn.api; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.ipc.ProtocolInfo; +import org.apache.hadoop.yarn.proto.ResourceManagerAdministrationProtocol.ResourceManagerAdministrationProtocolService; + +@Private +@Unstable +@ProtocolInfo( + protocolName = "org.apache.hadoop.yarn.api.ResourceManagerAdministrationProtocolPB", + protocolVersion = 1) +public interface ResourceManagerAdministrationProtocolPB extends ResourceManagerAdministrationProtocolService.BlockingInterface { + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateRequestPBImpl.java new file mode 100644 index 0000000..4584dc9 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateRequestPBImpl.java @@ -0,0 +1,347 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest; +import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.ResourceBlacklistRequest; +import org.apache.hadoop.yarn.api.records.ResourceRequest; +import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationAttemptIdPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.ResourceBlacklistRequestPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.ResourceRequestPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceBlacklistRequestProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceRequestProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateRequestProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateRequestProtoOrBuilder; + +@Private +@Unstable +public class AllocateRequestPBImpl extends AllocateRequest { + AllocateRequestProto proto = AllocateRequestProto.getDefaultInstance(); + AllocateRequestProto.Builder builder = null; + boolean viaProto = false; + + private ApplicationAttemptId applicationAttemptID = null; + private List ask = null; + private List release = null; + private ResourceBlacklistRequest blacklistRequest = null; + + + public AllocateRequestPBImpl() { + builder = AllocateRequestProto.newBuilder(); + } + + public AllocateRequestPBImpl(AllocateRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public AllocateRequestProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.applicationAttemptID != null) { + builder.setApplicationAttemptId(convertToProtoFormat(this.applicationAttemptID)); + } + if (this.ask != null) { + addAsksToProto(); + } + if (this.release != null) { + addReleasesToProto(); + } + if (this.blacklistRequest != null) { + builder.setBlacklistRequest(convertToProtoFormat(this.blacklistRequest)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = AllocateRequestProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public ApplicationAttemptId getApplicationAttemptId() { + AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.applicationAttemptID != null) { + return this.applicationAttemptID; + } + if (!p.hasApplicationAttemptId()) { + return null; + } + this.applicationAttemptID = convertFromProtoFormat(p.getApplicationAttemptId()); + return this.applicationAttemptID; + } + + @Override + public void setApplicationAttemptId(ApplicationAttemptId appAttemptId) { + maybeInitBuilder(); + if (appAttemptId == null) + builder.clearApplicationAttemptId(); + this.applicationAttemptID = appAttemptId; + } + + @Override + public int getResponseId() { + AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; + return p.getResponseId(); + } + + @Override + public void setResponseId(int id) { + maybeInitBuilder(); + builder.setResponseId(id); + } + + @Override + public float getProgress() { + AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; + return p.getProgress(); + } + + @Override + public void setProgress(float progress) { + maybeInitBuilder(); + builder.setProgress(progress); + } + + @Override + public List getAskList() { + initAsks(); + return this.ask; + } + + @Override + public void setAskList(final List resourceRequests) { + if(resourceRequests == null) { + return; + } + initAsks(); + this.ask.clear(); + this.ask.addAll(resourceRequests); + } + + @Override + public ResourceBlacklistRequest getResourceBlacklistRequest() { + AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.blacklistRequest != null) { + return this.blacklistRequest; + } + if (!p.hasBlacklistRequest()) { + return null; + } + this.blacklistRequest = convertFromProtoFormat(p.getBlacklistRequest()); + return this.blacklistRequest; + } + + @Override + public void setResourceBlacklistRequest(ResourceBlacklistRequest blacklistRequest) { + maybeInitBuilder(); + if (blacklistRequest == null) { + builder.clearBlacklistRequest(); + } + this.blacklistRequest = blacklistRequest; + } + + private void initAsks() { + if (this.ask != null) { + return; + } + AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getAskList(); + this.ask = new ArrayList(); + + for (ResourceRequestProto c : list) { + this.ask.add(convertFromProtoFormat(c)); + } + } + + private void addAsksToProto() { + maybeInitBuilder(); + builder.clearAsk(); + if (ask == null) + return; + Iterable iterable = new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator iter = ask.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public ResourceRequestProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + builder.addAllAsk(iterable); + } + @Override + public List getReleaseList() { + initReleases(); + return this.release; + } + @Override + public void setReleaseList(List releaseContainers) { + if(releaseContainers == null) { + return; + } + initReleases(); + this.release.clear(); + this.release.addAll(releaseContainers); + } + + private void initReleases() { + if (this.release != null) { + return; + } + AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getReleaseList(); + this.release = new ArrayList(); + + for (ContainerIdProto c : list) { + this.release.add(convertFromProtoFormat(c)); + } + } + + private void addReleasesToProto() { + maybeInitBuilder(); + builder.clearRelease(); + if (release == null) + return; + Iterable iterable = new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator iter = release.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public ContainerIdProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + builder.addAllRelease(iterable); + } + + private ApplicationAttemptIdPBImpl convertFromProtoFormat(ApplicationAttemptIdProto p) { + return new ApplicationAttemptIdPBImpl(p); + } + + private ApplicationAttemptIdProto convertToProtoFormat(ApplicationAttemptId t) { + return ((ApplicationAttemptIdPBImpl)t).getProto(); + } + + private ResourceRequestPBImpl convertFromProtoFormat(ResourceRequestProto p) { + return new ResourceRequestPBImpl(p); + } + + private ResourceRequestProto convertToProtoFormat(ResourceRequest t) { + return ((ResourceRequestPBImpl)t).getProto(); + } + + private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { + return new ContainerIdPBImpl(p); + } + + private ContainerIdProto convertToProtoFormat(ContainerId t) { + return ((ContainerIdPBImpl)t).getProto(); + } + + private ResourceBlacklistRequestPBImpl convertFromProtoFormat(ResourceBlacklistRequestProto p) { + return new ResourceBlacklistRequestPBImpl(p); + } + + private ResourceBlacklistRequestProto convertToProtoFormat(ResourceBlacklistRequest t) { + return ((ResourceBlacklistRequestPBImpl)t).getProto(); + } + + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateResponsePBImpl.java new file mode 100644 index 0000000..f38f91e --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateResponsePBImpl.java @@ -0,0 +1,539 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse; +import org.apache.hadoop.yarn.api.records.AMCommand; +import org.apache.hadoop.yarn.api.records.Container; +import org.apache.hadoop.yarn.api.records.ContainerStatus; +import org.apache.hadoop.yarn.api.records.NMToken; +import org.apache.hadoop.yarn.api.records.NodeReport; +import org.apache.hadoop.yarn.api.records.PreemptionMessage; +import org.apache.hadoop.yarn.api.records.Resource; +import org.apache.hadoop.yarn.api.records.impl.pb.ContainerPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.ContainerStatusPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.NMTokenPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.NodeReportPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.PreemptionMessagePBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils; +import org.apache.hadoop.yarn.api.records.impl.pb.ResourcePBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto; +import org.apache.hadoop.yarn.proto.YarnProtos.NodeReportProto; +import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionMessageProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateResponseProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.NMTokenProto; + +@Private +@Unstable +public class AllocateResponsePBImpl extends AllocateResponse { + AllocateResponseProto proto = AllocateResponseProto.getDefaultInstance(); + AllocateResponseProto.Builder builder = null; + boolean viaProto = false; + + Resource limit; + + private List allocatedContainers = null; + private List nmTokens = null; + private List completedContainersStatuses = null; + + private List updatedNodes = null; + private PreemptionMessage preempt; + + + public AllocateResponsePBImpl() { + builder = AllocateResponseProto.newBuilder(); + } + + public AllocateResponsePBImpl(AllocateResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public synchronized AllocateResponseProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private synchronized void mergeLocalToBuilder() { + if (this.allocatedContainers != null) { + builder.clearAllocatedContainers(); + Iterable iterable = + getProtoIterable(this.allocatedContainers); + builder.addAllAllocatedContainers(iterable); + } + if (nmTokens != null) { + builder.clearNmTokens(); + Iterable iterable = getTokenProtoIterable(nmTokens); + builder.addAllNmTokens(iterable); + } + if (this.completedContainersStatuses != null) { + builder.clearCompletedContainerStatuses(); + Iterable iterable = + getContainerStatusProtoIterable(this.completedContainersStatuses); + builder.addAllCompletedContainerStatuses(iterable); + } + if (this.updatedNodes != null) { + builder.clearUpdatedNodes(); + Iterable iterable = + getNodeReportProtoIterable(this.updatedNodes); + builder.addAllUpdatedNodes(iterable); + } + if (this.limit != null) { + builder.setLimit(convertToProtoFormat(this.limit)); + } + if (this.preempt != null) { + builder.setPreempt(convertToProtoFormat(this.preempt)); + } + } + + private synchronized void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private synchronized void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = AllocateResponseProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public synchronized AMCommand getAMCommand() { + AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasAMCommand()) { + return null; + } + return ProtoUtils.convertFromProtoFormat(p.getAMCommand()); + } + + @Override + public synchronized void setAMCommand(AMCommand command) { + maybeInitBuilder(); + if (command == null) { + builder.clearAMCommand(); + return; + } + builder.setAMCommand(ProtoUtils.convertToProtoFormat(command)); + } + + @Override + public synchronized int getResponseId() { + AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; + return (p.getResponseId()); + } + + @Override + public synchronized void setResponseId(int responseId) { + maybeInitBuilder(); + builder.setResponseId((responseId)); + } + + @Override + public synchronized Resource getAvailableResources() { + if (this.limit != null) { + return this.limit; + } + + AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasLimit()) { + return null; + } + this.limit = convertFromProtoFormat(p.getLimit()); + return this.limit; + } + + @Override + public synchronized void setAvailableResources(Resource limit) { + maybeInitBuilder(); + if (limit == null) + builder.clearLimit(); + this.limit = limit; + } + + @Override + public synchronized List getUpdatedNodes() { + initLocalNewNodeReportList(); + return this.updatedNodes; + } + @Override + public synchronized void setUpdatedNodes( + final List updatedNodes) { + if (updatedNodes == null) { + this.updatedNodes.clear(); + return; + } + this.updatedNodes = new ArrayList(updatedNodes.size()); + this.updatedNodes.addAll(updatedNodes); + } + + @Override + public synchronized List getAllocatedContainers() { + initLocalNewContainerList(); + return this.allocatedContainers; + } + + @Override + public synchronized void setAllocatedContainers( + final List containers) { + if (containers == null) + return; + // this looks like a bug because it results in append and not set + initLocalNewContainerList(); + allocatedContainers.addAll(containers); + } + + //// Finished containers + @Override + public synchronized List getCompletedContainersStatuses() { + initLocalFinishedContainerList(); + return this.completedContainersStatuses; + } + + @Override + public synchronized void setCompletedContainersStatuses( + final List containers) { + if (containers == null) + return; + initLocalFinishedContainerList(); + completedContainersStatuses.addAll(containers); + } + + @Override + public synchronized void setNMTokens(List nmTokens) { + if (nmTokens == null || nmTokens.isEmpty()) { + if (this.nmTokens != null) { + this.nmTokens.clear(); + } + builder.clearNmTokens(); + return; + } + // Implementing it as an append rather than set for consistency + initLocalNewNMTokenList(); + this.nmTokens.addAll(nmTokens); + } + + @Override + public synchronized List getNMTokens() { + initLocalNewNMTokenList(); + return nmTokens; + } + + @Override + public synchronized int getNumClusterNodes() { + AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; + return p.getNumClusterNodes(); + } + + @Override + public synchronized void setNumClusterNodes(int numNodes) { + maybeInitBuilder(); + builder.setNumClusterNodes(numNodes); + } + + @Override + public synchronized PreemptionMessage getPreemptionMessage() { + AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; + if (this.preempt != null) { + return this.preempt; + } + if (!p.hasPreempt()) { + return null; + } + this.preempt = convertFromProtoFormat(p.getPreempt()); + return this.preempt; + } + + @Override + public synchronized void setPreemptionMessage(PreemptionMessage preempt) { + maybeInitBuilder(); + if (null == preempt) { + builder.clearPreempt(); + } + this.preempt = preempt; + } + + // Once this is called. updatedNodes will never be null - until a getProto is + // called. + private synchronized void initLocalNewNodeReportList() { + if (this.updatedNodes != null) { + return; + } + AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getUpdatedNodesList(); + updatedNodes = new ArrayList(list.size()); + + for (NodeReportProto n : list) { + updatedNodes.add(convertFromProtoFormat(n)); + } + } + + // Once this is called. containerList will never be null - until a getProto + // is called. + private synchronized void initLocalNewContainerList() { + if (this.allocatedContainers != null) { + return; + } + AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getAllocatedContainersList(); + allocatedContainers = new ArrayList(); + + for (ContainerProto c : list) { + allocatedContainers.add(convertFromProtoFormat(c)); + } + } + + private synchronized void initLocalNewNMTokenList() { + if (nmTokens != null) { + return; + } + AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getNmTokensList(); + nmTokens = new ArrayList(); + for (NMTokenProto t : list) { + nmTokens.add(convertFromProtoFormat(t)); + } + } + + private synchronized Iterable getProtoIterable( + final List newContainersList) { + maybeInitBuilder(); + return new Iterable() { + @Override + public synchronized Iterator iterator() { + return new Iterator() { + + Iterator iter = newContainersList.iterator(); + + @Override + public synchronized boolean hasNext() { + return iter.hasNext(); + } + + @Override + public synchronized ContainerProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public synchronized void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + } + + private synchronized Iterable getTokenProtoIterable( + final List nmTokenList) { + maybeInitBuilder(); + return new Iterable() { + @Override + public synchronized Iterator iterator() { + return new Iterator() { + + Iterator iter = nmTokenList.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public NMTokenProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + }; + } + + private synchronized Iterable + getContainerStatusProtoIterable( + final List newContainersList) { + maybeInitBuilder(); + return new Iterable() { + @Override + public synchronized Iterator iterator() { + return new Iterator() { + + Iterator iter = newContainersList.iterator(); + + @Override + public synchronized boolean hasNext() { + return iter.hasNext(); + } + + @Override + public synchronized ContainerStatusProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public synchronized void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + } + + private synchronized Iterable + getNodeReportProtoIterable( + final List newNodeReportsList) { + maybeInitBuilder(); + return new Iterable() { + @Override + public synchronized Iterator iterator() { + return new Iterator() { + + Iterator iter = newNodeReportsList.iterator(); + + @Override + public synchronized boolean hasNext() { + return iter.hasNext(); + } + + @Override + public synchronized NodeReportProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public synchronized void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + } + + // Once this is called. containerList will never be null - until a getProto + // is called. + private synchronized void initLocalFinishedContainerList() { + if (this.completedContainersStatuses != null) { + return; + } + AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getCompletedContainerStatusesList(); + completedContainersStatuses = new ArrayList(); + + for (ContainerStatusProto c : list) { + completedContainersStatuses.add(convertFromProtoFormat(c)); + } + } + + private synchronized NodeReportPBImpl convertFromProtoFormat( + NodeReportProto p) { + return new NodeReportPBImpl(p); + } + + private synchronized NodeReportProto convertToProtoFormat(NodeReport t) { + return ((NodeReportPBImpl)t).getProto(); + } + + private synchronized ContainerPBImpl convertFromProtoFormat( + ContainerProto p) { + return new ContainerPBImpl(p); + } + + private synchronized ContainerProto convertToProtoFormat(Container t) { + return ((ContainerPBImpl)t).getProto(); + } + + private synchronized ContainerStatusPBImpl convertFromProtoFormat( + ContainerStatusProto p) { + return new ContainerStatusPBImpl(p); + } + + private synchronized ContainerStatusProto convertToProtoFormat( + ContainerStatus t) { + return ((ContainerStatusPBImpl)t).getProto(); + } + + private synchronized ResourcePBImpl convertFromProtoFormat(ResourceProto p) { + return new ResourcePBImpl(p); + } + + private synchronized ResourceProto convertToProtoFormat(Resource r) { + return ((ResourcePBImpl) r).getProto(); + } + + private synchronized PreemptionMessagePBImpl convertFromProtoFormat(PreemptionMessageProto p) { + return new PreemptionMessagePBImpl(p); + } + + private synchronized PreemptionMessageProto convertToProtoFormat(PreemptionMessage r) { + return ((PreemptionMessagePBImpl)r).getProto(); + } + + private synchronized NMTokenProto convertToProtoFormat(NMToken token) { + return ((NMTokenPBImpl)token).getProto(); + } + + private synchronized NMToken convertFromProtoFormat(NMTokenProto proto) { + return new NMTokenPBImpl(proto); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CancelDelegationTokenRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CancelDelegationTokenRequestPBImpl.java new file mode 100644 index 0000000..e8e926b --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CancelDelegationTokenRequestPBImpl.java @@ -0,0 +1,124 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenRequestProto; +import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenRequestProtoOrBuilder; +import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; +import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenRequest; +import org.apache.hadoop.yarn.api.records.Token; +import org.apache.hadoop.yarn.api.records.impl.pb.TokenPBImpl; + +@Private +@Unstable +public class CancelDelegationTokenRequestPBImpl extends + CancelDelegationTokenRequest { + + CancelDelegationTokenRequestProto proto = CancelDelegationTokenRequestProto + .getDefaultInstance(); + CancelDelegationTokenRequestProto.Builder builder = null; + boolean viaProto = false; + + public CancelDelegationTokenRequestPBImpl() { + builder = CancelDelegationTokenRequestProto.newBuilder(); + } + + public CancelDelegationTokenRequestPBImpl( + CancelDelegationTokenRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + Token token; + + @Override + public Token getDelegationToken() { + CancelDelegationTokenRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.token != null) { + return this.token; + } + this.token = convertFromProtoFormat(p.getToken()); + return this.token; + } + + @Override + public void setDelegationToken(Token token) { + maybeInitBuilder(); + if (token == null) + builder.clearToken(); + this.token = token; + } + + public CancelDelegationTokenRequestProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (token != null) { + builder.setToken(convertToProtoFormat(this.token)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = CancelDelegationTokenRequestProto.newBuilder(proto); + } + viaProto = false; + } + + private TokenPBImpl convertFromProtoFormat(TokenProto p) { + return new TokenPBImpl(p); + } + + private TokenProto convertToProtoFormat(Token t) { + return ((TokenPBImpl) t).getProto(); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CancelDelegationTokenResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CancelDelegationTokenResponsePBImpl.java new file mode 100644 index 0000000..334e1ed --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CancelDelegationTokenResponsePBImpl.java @@ -0,0 +1,63 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenResponseProto; +import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenResponse; + +@Private +@Unstable +public class CancelDelegationTokenResponsePBImpl extends CancelDelegationTokenResponse { + + CancelDelegationTokenResponseProto proto = CancelDelegationTokenResponseProto + .getDefaultInstance(); + + public CancelDelegationTokenResponsePBImpl() { + } + + public CancelDelegationTokenResponsePBImpl( + CancelDelegationTokenResponseProto proto) { + this.proto = proto; + } + + public CancelDelegationTokenResponseProto getProto() { + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/FinishApplicationMasterRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/FinishApplicationMasterRequestPBImpl.java new file mode 100644 index 0000000..cf52896 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/FinishApplicationMasterRequestPBImpl.java @@ -0,0 +1,182 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterRequest; +import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; +import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; +import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationAttemptIdPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.FinalApplicationStatusProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationMasterRequestProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationMasterRequestProtoOrBuilder; + +@Private +@Unstable +public class FinishApplicationMasterRequestPBImpl extends FinishApplicationMasterRequest { + FinishApplicationMasterRequestProto proto = FinishApplicationMasterRequestProto.getDefaultInstance(); + FinishApplicationMasterRequestProto.Builder builder = null; + boolean viaProto = false; + + private ApplicationAttemptId appAttemptId = null; + + + public FinishApplicationMasterRequestPBImpl() { + builder = FinishApplicationMasterRequestProto.newBuilder(); + } + + public FinishApplicationMasterRequestPBImpl(FinishApplicationMasterRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public FinishApplicationMasterRequestProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.appAttemptId != null) { + builder.setApplicationAttemptId(convertToProtoFormat(this.appAttemptId)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = FinishApplicationMasterRequestProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public ApplicationAttemptId getApplicationAttemptId() { + FinishApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.appAttemptId != null) { + return this.appAttemptId; + } + if (!p.hasApplicationAttemptId()) { + return null; + } + this.appAttemptId = convertFromProtoFormat(p.getApplicationAttemptId()); + return this.appAttemptId; + } + + @Override + public void setAppAttemptId(ApplicationAttemptId applicationAttemptId) { + maybeInitBuilder(); + if (applicationAttemptId == null) + builder.clearApplicationAttemptId(); + this.appAttemptId = applicationAttemptId; + } + + @Override + public String getDiagnostics() { + FinishApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; + return p.getDiagnostics(); + } + + @Override + public void setDiagnostics(String diagnostics) { + maybeInitBuilder(); + builder.setDiagnostics(diagnostics); + } + + @Override + public String getTrackingUrl() { + FinishApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; + return p.getTrackingUrl(); + } + + @Override + public void setTrackingUrl(String url) { + maybeInitBuilder(); + builder.setTrackingUrl(url); + } + + @Override + public FinalApplicationStatus getFinalApplicationStatus() { + FinishApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasFinalApplicationStatus()) { + return null; + } + return convertFromProtoFormat(p.getFinalApplicationStatus()); + } + + @Override + public void setFinalApplicationStatus(FinalApplicationStatus finalState) { + maybeInitBuilder(); + if (finalState == null) { + builder.clearFinalApplicationStatus(); + return; + } + builder.setFinalApplicationStatus(convertToProtoFormat(finalState)); + } + + private ApplicationAttemptIdPBImpl convertFromProtoFormat(ApplicationAttemptIdProto p) { + return new ApplicationAttemptIdPBImpl(p); + } + + private ApplicationAttemptIdProto convertToProtoFormat(ApplicationAttemptId t) { + return ((ApplicationAttemptIdPBImpl)t).getProto(); + } + + private FinalApplicationStatus convertFromProtoFormat(FinalApplicationStatusProto s) { + return ProtoUtils.convertFromProtoFormat(s); + } + + private FinalApplicationStatusProto convertToProtoFormat(FinalApplicationStatus s) { + return ProtoUtils.convertToProtoFormat(s); + } + + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/FinishApplicationMasterResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/FinishApplicationMasterResponsePBImpl.java new file mode 100644 index 0000000..70f4f96 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/FinishApplicationMasterResponsePBImpl.java @@ -0,0 +1,68 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterResponse; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationMasterResponseProto; + +@Private +@Unstable +public class FinishApplicationMasterResponsePBImpl extends FinishApplicationMasterResponse { + FinishApplicationMasterResponseProto proto = FinishApplicationMasterResponseProto.getDefaultInstance(); + FinishApplicationMasterResponseProto.Builder builder = null; + boolean viaProto = false; + + public FinishApplicationMasterResponsePBImpl() { + builder = FinishApplicationMasterResponseProto.newBuilder(); + } + + public FinishApplicationMasterResponsePBImpl(FinishApplicationMasterResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public FinishApplicationMasterResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetAllApplicationsRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetAllApplicationsRequestPBImpl.java new file mode 100644 index 0000000..24b16d0 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetAllApplicationsRequestPBImpl.java @@ -0,0 +1,67 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetAllApplicationsRequest; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetAllApplicationsRequestProto; + +@Private +@Unstable +public class GetAllApplicationsRequestPBImpl extends GetAllApplicationsRequest { + GetAllApplicationsRequestProto proto = GetAllApplicationsRequestProto.getDefaultInstance(); + GetAllApplicationsRequestProto.Builder builder = null; + boolean viaProto = false; + + public GetAllApplicationsRequestPBImpl() { + builder = GetAllApplicationsRequestProto.newBuilder(); + } + + public GetAllApplicationsRequestPBImpl(GetAllApplicationsRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public GetAllApplicationsRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetAllApplicationsResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetAllApplicationsResponsePBImpl.java new file mode 100644 index 0000000..a26dccd --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetAllApplicationsResponsePBImpl.java @@ -0,0 +1,174 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetAllApplicationsResponse; +import org.apache.hadoop.yarn.api.records.ApplicationReport; +import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationReportPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationReportProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetAllApplicationsResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetAllApplicationsResponseProtoOrBuilder; + +@Private +@Unstable +public class GetAllApplicationsResponsePBImpl +extends GetAllApplicationsResponse { + + GetAllApplicationsResponseProto proto = + GetAllApplicationsResponseProto.getDefaultInstance(); + GetAllApplicationsResponseProto.Builder builder = null; + boolean viaProto = false; + + List applicationList; + + public GetAllApplicationsResponsePBImpl() { + builder = GetAllApplicationsResponseProto.newBuilder(); + } + + public GetAllApplicationsResponsePBImpl(GetAllApplicationsResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + @Override + public List getApplicationList() { + initLocalApplicationsList(); + return this.applicationList; + } + + @Override + public void setApplicationList(List applications) { + maybeInitBuilder(); + if (applications == null) + builder.clearApplications(); + this.applicationList = applications; + } + + public GetAllApplicationsResponseProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.applicationList != null) { + addLocalApplicationsToProto(); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = GetAllApplicationsResponseProto.newBuilder(proto); + } + viaProto = false; + } + + // Once this is called. containerList will never be null - until a getProto + // is called. + private void initLocalApplicationsList() { + if (this.applicationList != null) { + return; + } + GetAllApplicationsResponseProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getApplicationsList(); + applicationList = new ArrayList(); + + for (ApplicationReportProto a : list) { + applicationList.add(convertFromProtoFormat(a)); + } + } + + private void addLocalApplicationsToProto() { + maybeInitBuilder(); + builder.clearApplications(); + if (applicationList == null) + return; + Iterable iterable = new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator iter = applicationList.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public ApplicationReportProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + builder.addAllApplications(iterable); + } + + private ApplicationReportPBImpl convertFromProtoFormat(ApplicationReportProto p) { + return new ApplicationReportPBImpl(p); + } + + private ApplicationReportProto convertToProtoFormat(ApplicationReport t) { + return ((ApplicationReportPBImpl)t).getProto(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationReportRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationReportRequestPBImpl.java new file mode 100644 index 0000000..e1e3308 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationReportRequestPBImpl.java @@ -0,0 +1,130 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationReportRequestProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationReportRequestProtoOrBuilder; + +@Private +@Unstable +public class GetApplicationReportRequestPBImpl extends GetApplicationReportRequest { + GetApplicationReportRequestProto proto = GetApplicationReportRequestProto.getDefaultInstance(); + GetApplicationReportRequestProto.Builder builder = null; + boolean viaProto = false; + + private ApplicationId applicationId = null; + + + public GetApplicationReportRequestPBImpl() { + builder = GetApplicationReportRequestProto.newBuilder(); + } + + public GetApplicationReportRequestPBImpl(GetApplicationReportRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public GetApplicationReportRequestProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (applicationId != null) { + builder.setApplicationId(convertToProtoFormat(this.applicationId)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = GetApplicationReportRequestProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public ApplicationId getApplicationId() { + GetApplicationReportRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.applicationId != null) { + return this.applicationId; + } + if (!p.hasApplicationId()) { + return null; + } + this.applicationId = convertFromProtoFormat(p.getApplicationId()); + return this.applicationId; + } + + @Override + public void setApplicationId(ApplicationId applicationId) { + maybeInitBuilder(); + if (applicationId == null) + builder.clearApplicationId(); + this.applicationId = applicationId; + } + + private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { + return new ApplicationIdPBImpl(p); + } + + private ApplicationIdProto convertToProtoFormat(ApplicationId t) { + return ((ApplicationIdPBImpl)t).getProto(); + } + + + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationReportResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationReportResponsePBImpl.java new file mode 100644 index 0000000..ef61dfa --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationReportResponsePBImpl.java @@ -0,0 +1,130 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse; +import org.apache.hadoop.yarn.api.records.ApplicationReport; +import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationReportPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationReportProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationReportResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationReportResponseProtoOrBuilder; + +@Private +@Unstable +public class GetApplicationReportResponsePBImpl extends GetApplicationReportResponse { + GetApplicationReportResponseProto proto = GetApplicationReportResponseProto.getDefaultInstance(); + GetApplicationReportResponseProto.Builder builder = null; + boolean viaProto = false; + + private ApplicationReport applicationReport = null; + + + public GetApplicationReportResponsePBImpl() { + builder = GetApplicationReportResponseProto.newBuilder(); + } + + public GetApplicationReportResponsePBImpl(GetApplicationReportResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public GetApplicationReportResponseProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.applicationReport != null) { + builder.setApplicationReport(convertToProtoFormat(this.applicationReport)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = GetApplicationReportResponseProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public ApplicationReport getApplicationReport() { + GetApplicationReportResponseProtoOrBuilder p = viaProto ? proto : builder; + if (this.applicationReport != null) { + return this.applicationReport; + } + if (!p.hasApplicationReport()) { + return null; + } + this.applicationReport = convertFromProtoFormat(p.getApplicationReport()); + return this.applicationReport; + } + + @Override + public void setApplicationReport(ApplicationReport applicationMaster) { + maybeInitBuilder(); + if (applicationMaster == null) + builder.clearApplicationReport(); + this.applicationReport = applicationMaster; + } + + private ApplicationReportPBImpl convertFromProtoFormat(ApplicationReportProto p) { + return new ApplicationReportPBImpl(p); + } + + private ApplicationReportProto convertToProtoFormat(ApplicationReport t) { + return ((ApplicationReportPBImpl)t).getProto(); + } + + + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterMetricsRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterMetricsRequestPBImpl.java new file mode 100644 index 0000000..9dcad99 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterMetricsRequestPBImpl.java @@ -0,0 +1,68 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterMetricsRequestProto; + +@Private +@Unstable +public class GetClusterMetricsRequestPBImpl extends GetClusterMetricsRequest { + GetClusterMetricsRequestProto proto = GetClusterMetricsRequestProto.getDefaultInstance(); + GetClusterMetricsRequestProto.Builder builder = null; + boolean viaProto = false; + + public GetClusterMetricsRequestPBImpl() { + builder = GetClusterMetricsRequestProto.newBuilder(); + } + + public GetClusterMetricsRequestPBImpl(GetClusterMetricsRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public GetClusterMetricsRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterMetricsResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterMetricsResponsePBImpl.java new file mode 100644 index 0000000..635307a --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterMetricsResponsePBImpl.java @@ -0,0 +1,130 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse; +import org.apache.hadoop.yarn.api.records.YarnClusterMetrics; +import org.apache.hadoop.yarn.api.records.impl.pb.YarnClusterMetricsPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.YarnClusterMetricsProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterMetricsResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterMetricsResponseProtoOrBuilder; + +@Private +@Unstable +public class GetClusterMetricsResponsePBImpl extends GetClusterMetricsResponse { + GetClusterMetricsResponseProto proto = GetClusterMetricsResponseProto.getDefaultInstance(); + GetClusterMetricsResponseProto.Builder builder = null; + boolean viaProto = false; + + private YarnClusterMetrics yarnClusterMetrics = null; + + + public GetClusterMetricsResponsePBImpl() { + builder = GetClusterMetricsResponseProto.newBuilder(); + } + + public GetClusterMetricsResponsePBImpl(GetClusterMetricsResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public GetClusterMetricsResponseProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.yarnClusterMetrics != null) { + builder.setClusterMetrics(convertToProtoFormat(this.yarnClusterMetrics)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = GetClusterMetricsResponseProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public YarnClusterMetrics getClusterMetrics() { + GetClusterMetricsResponseProtoOrBuilder p = viaProto ? proto : builder; + if (this.yarnClusterMetrics != null) { + return this.yarnClusterMetrics; + } + if (!p.hasClusterMetrics()) { + return null; + } + this.yarnClusterMetrics = convertFromProtoFormat(p.getClusterMetrics()); + return this.yarnClusterMetrics; + } + + @Override + public void setClusterMetrics(YarnClusterMetrics clusterMetrics) { + maybeInitBuilder(); + if (clusterMetrics == null) + builder.clearClusterMetrics(); + this.yarnClusterMetrics = clusterMetrics; + } + + private YarnClusterMetricsPBImpl convertFromProtoFormat(YarnClusterMetricsProto p) { + return new YarnClusterMetricsPBImpl(p); + } + + private YarnClusterMetricsProto convertToProtoFormat(YarnClusterMetrics t) { + return ((YarnClusterMetricsPBImpl)t).getProto(); + } + + + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterNodesRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterNodesRequestPBImpl.java new file mode 100644 index 0000000..766db22 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterNodesRequestPBImpl.java @@ -0,0 +1,68 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesRequest; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterNodesRequestProto; + +@Private +@Unstable +public class GetClusterNodesRequestPBImpl extends GetClusterNodesRequest { + + GetClusterNodesRequestProto proto = GetClusterNodesRequestProto.getDefaultInstance(); + GetClusterNodesRequestProto.Builder builder = null; + boolean viaProto = false; + + public GetClusterNodesRequestPBImpl() { + builder = GetClusterNodesRequestProto.newBuilder(); + } + + public GetClusterNodesRequestPBImpl(GetClusterNodesRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public GetClusterNodesRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterNodesResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterNodesResponsePBImpl.java new file mode 100644 index 0000000..23210d4 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterNodesResponsePBImpl.java @@ -0,0 +1,173 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesResponse; +import org.apache.hadoop.yarn.api.records.NodeReport; +import org.apache.hadoop.yarn.api.records.impl.pb.NodeReportPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.NodeReportProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterNodesResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterNodesResponseProtoOrBuilder; + +@Private +@Unstable +public class GetClusterNodesResponsePBImpl extends GetClusterNodesResponse { + + GetClusterNodesResponseProto proto = + GetClusterNodesResponseProto.getDefaultInstance(); + GetClusterNodesResponseProto.Builder builder = null; + boolean viaProto = false; + + List nodeManagerInfoList; + + public GetClusterNodesResponsePBImpl() { + builder = GetClusterNodesResponseProto.newBuilder(); + } + + public GetClusterNodesResponsePBImpl(GetClusterNodesResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + @Override + public List getNodeReports() { + initLocalNodeManagerInfosList(); + return this.nodeManagerInfoList; + } + + @Override + public void setNodeReports(List nodeManagers) { + if (nodeManagers == null) { + builder.clearNodeReports(); + } + this.nodeManagerInfoList = nodeManagers; + } + + public GetClusterNodesResponseProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.nodeManagerInfoList != null) { + addLocalNodeManagerInfosToProto(); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = GetClusterNodesResponseProto.newBuilder(proto); + } + viaProto = false; + } + + // Once this is called. containerList will never be null - until a getProto + // is called. + private void initLocalNodeManagerInfosList() { + if (this.nodeManagerInfoList != null) { + return; + } + GetClusterNodesResponseProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getNodeReportsList(); + nodeManagerInfoList = new ArrayList(); + + for (NodeReportProto a : list) { + nodeManagerInfoList.add(convertFromProtoFormat(a)); + } + } + + private void addLocalNodeManagerInfosToProto() { + maybeInitBuilder(); + builder.clearNodeReports(); + if (nodeManagerInfoList == null) + return; + Iterable iterable = new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator iter = nodeManagerInfoList.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public NodeReportProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + builder.addAllNodeReports(iterable); + } + + private NodeReportPBImpl convertFromProtoFormat(NodeReportProto p) { + return new NodeReportPBImpl(p); + } + + private NodeReportProto convertToProtoFormat(NodeReport t) { + return ((NodeReportPBImpl)t).getProto(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusRequestPBImpl.java new file mode 100644 index 0000000..fa88d1f --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusRequestPBImpl.java @@ -0,0 +1,130 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusRequest; +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusRequestProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusRequestProtoOrBuilder; + +@Private +@Unstable +public class GetContainerStatusRequestPBImpl extends GetContainerStatusRequest { + GetContainerStatusRequestProto proto = GetContainerStatusRequestProto.getDefaultInstance(); + GetContainerStatusRequestProto.Builder builder = null; + boolean viaProto = false; + + private ContainerId containerId = null; + + + public GetContainerStatusRequestPBImpl() { + builder = GetContainerStatusRequestProto.newBuilder(); + } + + public GetContainerStatusRequestPBImpl(GetContainerStatusRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public GetContainerStatusRequestProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.containerId != null) { + builder.setContainerId(convertToProtoFormat(this.containerId)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = GetContainerStatusRequestProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public ContainerId getContainerId() { + GetContainerStatusRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.containerId != null) { + return this.containerId; + } + if (!p.hasContainerId()) { + return null; + } + this.containerId = convertFromProtoFormat(p.getContainerId()); + return this.containerId; + } + + @Override + public void setContainerId(ContainerId containerId) { + maybeInitBuilder(); + if (containerId == null) + builder.clearContainerId(); + this.containerId = containerId; + } + + private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { + return new ContainerIdPBImpl(p); + } + + private ContainerIdProto convertToProtoFormat(ContainerId t) { + return ((ContainerIdPBImpl)t).getProto(); + } + + + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusResponsePBImpl.java new file mode 100644 index 0000000..2b635f9 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusResponsePBImpl.java @@ -0,0 +1,130 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusResponse; +import org.apache.hadoop.yarn.api.records.ContainerStatus; +import org.apache.hadoop.yarn.api.records.impl.pb.ContainerStatusPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusResponseProtoOrBuilder; + +@Private +@Unstable +public class GetContainerStatusResponsePBImpl extends GetContainerStatusResponse { + GetContainerStatusResponseProto proto = GetContainerStatusResponseProto.getDefaultInstance(); + GetContainerStatusResponseProto.Builder builder = null; + boolean viaProto = false; + + private ContainerStatus containerStatus = null; + + + public GetContainerStatusResponsePBImpl() { + builder = GetContainerStatusResponseProto.newBuilder(); + } + + public GetContainerStatusResponsePBImpl(GetContainerStatusResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public GetContainerStatusResponseProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.containerStatus != null) { + builder.setStatus(convertToProtoFormat(this.containerStatus)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = GetContainerStatusResponseProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public ContainerStatus getStatus() { + GetContainerStatusResponseProtoOrBuilder p = viaProto ? proto : builder; + if (this.containerStatus != null) { + return this.containerStatus; + } + if (!p.hasStatus()) { + return null; + } + this.containerStatus = convertFromProtoFormat(p.getStatus()); + return this.containerStatus; + } + + @Override + public void setStatus(ContainerStatus status) { + maybeInitBuilder(); + if (status == null) + builder.clearStatus(); + this.containerStatus = status; + } + + private ContainerStatusPBImpl convertFromProtoFormat(ContainerStatusProto p) { + return new ContainerStatusPBImpl(p); + } + + private ContainerStatusProto convertToProtoFormat(ContainerStatus t) { + return ((ContainerStatusPBImpl)t).getProto(); + } + + + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetDelegationTokenRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetDelegationTokenRequestPBImpl.java new file mode 100644 index 0000000..8e98c88 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetDelegationTokenRequestPBImpl.java @@ -0,0 +1,112 @@ + /** + * 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. + */ +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenRequestProto; +import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenRequestProtoOrBuilder; +import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenRequest; + +@Private +@Unstable +public class GetDelegationTokenRequestPBImpl extends GetDelegationTokenRequest { + + String renewer; + + GetDelegationTokenRequestProto proto = + GetDelegationTokenRequestProto.getDefaultInstance(); + GetDelegationTokenRequestProto.Builder builder = null; + boolean viaProto = false; + + public GetDelegationTokenRequestPBImpl() { + builder = GetDelegationTokenRequestProto.newBuilder(); + } + + public GetDelegationTokenRequestPBImpl ( + GetDelegationTokenRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + @Override + public String getRenewer(){ + GetDelegationTokenRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.renewer != null) { + return this.renewer; + } + this.renewer = p.getRenewer(); + return this.renewer; + } + + @Override + public void setRenewer(String renewer) { + maybeInitBuilder(); + if (renewer == null) + builder.clearRenewer(); + this.renewer = renewer; + } + + public GetDelegationTokenRequestProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (renewer != null) { + builder.setRenewer(this.renewer); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = GetDelegationTokenRequestProto.newBuilder(proto); + } + viaProto = false; + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetDelegationTokenResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetDelegationTokenResponsePBImpl.java new file mode 100644 index 0000000..c51d80d --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetDelegationTokenResponsePBImpl.java @@ -0,0 +1,129 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenResponseProto; +import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenResponseProtoOrBuilder; +import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; +import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse; +import org.apache.hadoop.yarn.api.records.Token; +import org.apache.hadoop.yarn.api.records.impl.pb.TokenPBImpl; + +@Private +@Unstable +public class GetDelegationTokenResponsePBImpl extends GetDelegationTokenResponse { + + Token appToken; + + + GetDelegationTokenResponseProto proto = + GetDelegationTokenResponseProto.getDefaultInstance(); + GetDelegationTokenResponseProto.Builder builder = null; + boolean viaProto = false; + + public GetDelegationTokenResponsePBImpl() { + builder = GetDelegationTokenResponseProto.newBuilder(); + } + + public GetDelegationTokenResponsePBImpl ( + GetDelegationTokenResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + @Override + public Token getRMDelegationToken() { + GetDelegationTokenResponseProtoOrBuilder p = viaProto ? proto : builder; + if (this.appToken != null) { + return this.appToken; + } + if (!p.hasToken()) { + return null; + } + this.appToken = convertFromProtoFormat(p.getToken()); + return this.appToken; + } + + @Override + public void setRMDelegationToken(Token appToken) { + maybeInitBuilder(); + if (appToken == null) + builder.clearToken(); + this.appToken = appToken; + } + + public GetDelegationTokenResponseProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (appToken != null) { + builder.setToken(convertToProtoFormat(this.appToken)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = GetDelegationTokenResponseProto.newBuilder(proto); + } + viaProto = false; + } + + + private TokenPBImpl convertFromProtoFormat(TokenProto p) { + return new TokenPBImpl(p); + } + + private TokenProto convertToProtoFormat(Token t) { + return ((TokenPBImpl)t).getProto(); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNewApplicationRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNewApplicationRequestPBImpl.java new file mode 100644 index 0000000..1fb3b70 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNewApplicationRequestPBImpl.java @@ -0,0 +1,68 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNewApplicationRequestProto; + +@Private +@Unstable +public class GetNewApplicationRequestPBImpl extends GetNewApplicationRequest { + GetNewApplicationRequestProto proto = GetNewApplicationRequestProto.getDefaultInstance(); + GetNewApplicationRequestProto.Builder builder = null; + boolean viaProto = false; + + public GetNewApplicationRequestPBImpl() { + builder = GetNewApplicationRequestProto.newBuilder(); + } + + public GetNewApplicationRequestPBImpl(GetNewApplicationRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public GetNewApplicationRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNewApplicationResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNewApplicationResponsePBImpl.java new file mode 100644 index 0000000..bf1a6c2 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNewApplicationResponsePBImpl.java @@ -0,0 +1,168 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.Resource; +import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.ResourcePBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNewApplicationResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNewApplicationResponseProtoOrBuilder; + +@Private +@Unstable +public class GetNewApplicationResponsePBImpl extends GetNewApplicationResponse { + GetNewApplicationResponseProto proto = GetNewApplicationResponseProto.getDefaultInstance(); + GetNewApplicationResponseProto.Builder builder = null; + boolean viaProto = false; + + private ApplicationId applicationId = null; + private Resource maximumResourceCapability = null; + + public GetNewApplicationResponsePBImpl() { + builder = GetNewApplicationResponseProto.newBuilder(); + } + + public GetNewApplicationResponsePBImpl(GetNewApplicationResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public GetNewApplicationResponseProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (applicationId != null) { + builder.setApplicationId(convertToProtoFormat(this.applicationId)); + } + if (maximumResourceCapability != null) { + builder.setMaximumCapability(convertToProtoFormat(this.maximumResourceCapability)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = GetNewApplicationResponseProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public ApplicationId getApplicationId() { + if (this.applicationId != null) { + return this.applicationId; + } + + GetNewApplicationResponseProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasApplicationId()) { + return null; + } + + this.applicationId = convertFromProtoFormat(p.getApplicationId()); + return this.applicationId; + } + + @Override + public void setApplicationId(ApplicationId applicationId) { + maybeInitBuilder(); + if (applicationId == null) + builder.clearApplicationId(); + this.applicationId = applicationId; + } + + @Override + public Resource getMaximumResourceCapability() { + if (this.maximumResourceCapability != null) { + return this.maximumResourceCapability; + } + + GetNewApplicationResponseProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasMaximumCapability()) { + return null; + } + + this.maximumResourceCapability = convertFromProtoFormat(p.getMaximumCapability()); + return this.maximumResourceCapability; + } + + @Override + public void setMaximumResourceCapability(Resource capability) { + maybeInitBuilder(); + if(maximumResourceCapability == null) { + builder.clearMaximumCapability(); + } + this.maximumResourceCapability = capability; + } + + private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { + return new ApplicationIdPBImpl(p); + } + + private ApplicationIdProto convertToProtoFormat(ApplicationId t) { + return ((ApplicationIdPBImpl)t).getProto(); + } + + private Resource convertFromProtoFormat(ResourceProto resource) { + return new ResourcePBImpl(resource); + } + + private ResourceProto convertToProtoFormat(Resource resource) { + return ((ResourcePBImpl)resource).getProto(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueInfoRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueInfoRequestPBImpl.java new file mode 100644 index 0000000..664ea23 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueInfoRequestPBImpl.java @@ -0,0 +1,129 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoRequest; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueInfoRequestProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueInfoRequestProtoOrBuilder; + +@Private +@Unstable +public class GetQueueInfoRequestPBImpl extends GetQueueInfoRequest { + + GetQueueInfoRequestProto proto = + GetQueueInfoRequestProto.getDefaultInstance(); + GetQueueInfoRequestProto.Builder builder = null; + boolean viaProto = false; + + public GetQueueInfoRequestPBImpl() { + builder = GetQueueInfoRequestProto.newBuilder(); + } + + public GetQueueInfoRequestPBImpl(GetQueueInfoRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + @Override + public boolean getIncludeApplications() { + GetQueueInfoRequestProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasIncludeApplications()) ? p.getIncludeApplications() : false; + } + + @Override + public boolean getIncludeChildQueues() { + GetQueueInfoRequestProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasIncludeChildQueues()) ? p.getIncludeChildQueues() : false; + } + + @Override + public String getQueueName() { + GetQueueInfoRequestProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasQueueName()) ? p.getQueueName() : null; + } + + @Override + public boolean getRecursive() { + GetQueueInfoRequestProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasRecursive()) ? p.getRecursive() : false; + } + + @Override + public void setIncludeApplications(boolean includeApplications) { + maybeInitBuilder(); + builder.setIncludeApplications(includeApplications); + } + + @Override + public void setIncludeChildQueues(boolean includeChildQueues) { + maybeInitBuilder(); + builder.setIncludeChildQueues(includeChildQueues); + } + + @Override + public void setQueueName(String queueName) { + maybeInitBuilder(); + if (queueName == null) { + builder.clearQueueName(); + return; + } + builder.setQueueName((queueName)); + } + + @Override + public void setRecursive(boolean recursive) { + maybeInitBuilder(); + builder.setRecursive(recursive); + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = GetQueueInfoRequestProto.newBuilder(proto); + } + viaProto = false; + } + + public GetQueueInfoRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueInfoResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueInfoResponsePBImpl.java new file mode 100644 index 0000000..7d60ae1 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueInfoResponsePBImpl.java @@ -0,0 +1,129 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoResponse; +import org.apache.hadoop.yarn.api.records.QueueInfo; +import org.apache.hadoop.yarn.api.records.impl.pb.QueueInfoPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.QueueInfoProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueInfoResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueInfoResponseProtoOrBuilder; + +@Private +@Unstable +public class GetQueueInfoResponsePBImpl extends GetQueueInfoResponse { + + QueueInfo queueInfo; + + GetQueueInfoResponseProto proto = + GetQueueInfoResponseProto.getDefaultInstance(); + GetQueueInfoResponseProto.Builder builder = null; + boolean viaProto = false; + + public GetQueueInfoResponsePBImpl() { + builder = GetQueueInfoResponseProto.newBuilder(); + } + + public GetQueueInfoResponsePBImpl(GetQueueInfoResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public GetQueueInfoResponseProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + @Override + public QueueInfo getQueueInfo() { + if (this.queueInfo != null) { + return this.queueInfo; + } + + GetQueueInfoResponseProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasQueueInfo()) { + return null; + } + this.queueInfo = convertFromProtoFormat(p.getQueueInfo()); + return this.queueInfo; + } + + @Override + public void setQueueInfo(QueueInfo queueInfo) { + maybeInitBuilder(); + if(queueInfo == null) { + builder.clearQueueInfo(); + } + this.queueInfo = queueInfo; + } + + private void mergeLocalToBuilder() { + if (this.queueInfo != null) { + builder.setQueueInfo(convertToProtoFormat(this.queueInfo)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = GetQueueInfoResponseProto.newBuilder(proto); + } + viaProto = false; + } + + private QueueInfo convertFromProtoFormat(QueueInfoProto queueInfo) { + return new QueueInfoPBImpl(queueInfo); + } + + private QueueInfoProto convertToProtoFormat(QueueInfo queueInfo) { + return ((QueueInfoPBImpl)queueInfo).getProto(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueUserAclsInfoRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueUserAclsInfoRequestPBImpl.java new file mode 100644 index 0000000..d964e85 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueUserAclsInfoRequestPBImpl.java @@ -0,0 +1,69 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetQueueUserAclsInfoRequest; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueUserAclsInfoRequestProto; + +@Private +@Unstable +public class GetQueueUserAclsInfoRequestPBImpl extends GetQueueUserAclsInfoRequest { + + GetQueueUserAclsInfoRequestProto proto = + GetQueueUserAclsInfoRequestProto.getDefaultInstance(); + GetQueueUserAclsInfoRequestProto.Builder builder = null; + boolean viaProto = false; + + public GetQueueUserAclsInfoRequestPBImpl() { + builder = GetQueueUserAclsInfoRequestProto.newBuilder(); + } + + public GetQueueUserAclsInfoRequestPBImpl(GetQueueUserAclsInfoRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public GetQueueUserAclsInfoRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueUserAclsInfoResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueUserAclsInfoResponsePBImpl.java new file mode 100644 index 0000000..d9fdada --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueUserAclsInfoResponsePBImpl.java @@ -0,0 +1,174 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.GetQueueUserAclsInfoResponse; +import org.apache.hadoop.yarn.api.records.QueueUserACLInfo; +import org.apache.hadoop.yarn.api.records.impl.pb.QueueUserACLInfoPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.QueueUserACLInfoProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueUserAclsInfoResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueUserAclsInfoResponseProtoOrBuilder; + +@Private +@Unstable +public class GetQueueUserAclsInfoResponsePBImpl extends GetQueueUserAclsInfoResponse { + + List queueUserAclsInfoList; + + GetQueueUserAclsInfoResponseProto proto = + GetQueueUserAclsInfoResponseProto.getDefaultInstance(); + GetQueueUserAclsInfoResponseProto.Builder builder = null; + boolean viaProto = false; + + public GetQueueUserAclsInfoResponsePBImpl() { + builder = GetQueueUserAclsInfoResponseProto.newBuilder(); + } + + public GetQueueUserAclsInfoResponsePBImpl( + GetQueueUserAclsInfoResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + @Override + public List getUserAclsInfoList() { + initLocalQueueUserAclsList(); + return queueUserAclsInfoList; + } + + @Override + public void setUserAclsInfoList(List queueUserAclsList) { + if (queueUserAclsList == null) { + builder.clearQueueUserAcls(); + } + this.queueUserAclsInfoList = queueUserAclsList; + } + + public GetQueueUserAclsInfoResponseProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.queueUserAclsInfoList != null) { + addLocalQueueUserACLInfosToProto(); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = GetQueueUserAclsInfoResponseProto.newBuilder(proto); + } + viaProto = false; + } + + // Once this is called. containerList will never be null - until a getProto + // is called. + private void initLocalQueueUserAclsList() { + if (this.queueUserAclsInfoList != null) { + return; + } + GetQueueUserAclsInfoResponseProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getQueueUserAclsList(); + queueUserAclsInfoList = new ArrayList(); + + for (QueueUserACLInfoProto a : list) { + queueUserAclsInfoList.add(convertFromProtoFormat(a)); + } + } + + private void addLocalQueueUserACLInfosToProto() { + maybeInitBuilder(); + builder.clearQueueUserAcls(); + if (queueUserAclsInfoList == null) + return; + Iterable iterable = new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator iter = queueUserAclsInfoList.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public QueueUserACLInfoProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + builder.addAllQueueUserAcls(iterable); + } + + private QueueUserACLInfoPBImpl convertFromProtoFormat(QueueUserACLInfoProto p) { + return new QueueUserACLInfoPBImpl(p); + } + + private QueueUserACLInfoProto convertToProtoFormat(QueueUserACLInfo t) { + return ((QueueUserACLInfoPBImpl)t).getProto(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/KillApplicationRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/KillApplicationRequestPBImpl.java new file mode 100644 index 0000000..2b13a72 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/KillApplicationRequestPBImpl.java @@ -0,0 +1,130 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.KillApplicationRequestProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.KillApplicationRequestProtoOrBuilder; + +@Private +@Unstable +public class KillApplicationRequestPBImpl extends KillApplicationRequest { + KillApplicationRequestProto proto = KillApplicationRequestProto.getDefaultInstance(); + KillApplicationRequestProto.Builder builder = null; + boolean viaProto = false; + + private ApplicationId applicationId = null; + + + public KillApplicationRequestPBImpl() { + builder = KillApplicationRequestProto.newBuilder(); + } + + public KillApplicationRequestPBImpl(KillApplicationRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public KillApplicationRequestProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.applicationId != null) { + builder.setApplicationId(convertToProtoFormat(this.applicationId)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = KillApplicationRequestProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public ApplicationId getApplicationId() { + KillApplicationRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.applicationId != null) { + return this.applicationId; + } + if (!p.hasApplicationId()) { + return null; + } + this.applicationId = convertFromProtoFormat(p.getApplicationId()); + return this.applicationId; + } + + @Override + public void setApplicationId(ApplicationId applicationId) { + maybeInitBuilder(); + if (applicationId == null) + builder.clearApplicationId(); + this.applicationId = applicationId; + } + + private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { + return new ApplicationIdPBImpl(p); + } + + private ApplicationIdProto convertToProtoFormat(ApplicationId t) { + return ((ApplicationIdPBImpl)t).getProto(); + } + + + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/KillApplicationResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/KillApplicationResponsePBImpl.java new file mode 100644 index 0000000..f16d417 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/KillApplicationResponsePBImpl.java @@ -0,0 +1,68 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.KillApplicationResponse; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.KillApplicationResponseProto; + +@Private +@Unstable +public class KillApplicationResponsePBImpl extends KillApplicationResponse { + KillApplicationResponseProto proto = KillApplicationResponseProto.getDefaultInstance(); + KillApplicationResponseProto.Builder builder = null; + boolean viaProto = false; + + public KillApplicationResponsePBImpl() { + builder = KillApplicationResponseProto.newBuilder(); + } + + public KillApplicationResponsePBImpl(KillApplicationResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public KillApplicationResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshAdminAclsRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshAdminAclsRequestPBImpl.java new file mode 100644 index 0000000..c4adb52 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshAdminAclsRequestPBImpl.java @@ -0,0 +1,69 @@ +/** +* 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. +*/ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.RefreshAdminAclsRequest; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshAdminAclsRequestProto; + +@Private +@Unstable +public class RefreshAdminAclsRequestPBImpl +extends RefreshAdminAclsRequest { + + RefreshAdminAclsRequestProto proto = RefreshAdminAclsRequestProto.getDefaultInstance(); + RefreshAdminAclsRequestProto.Builder builder = null; + boolean viaProto = false; + + public RefreshAdminAclsRequestPBImpl() { + builder = RefreshAdminAclsRequestProto.newBuilder(); + } + + public RefreshAdminAclsRequestPBImpl(RefreshAdminAclsRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public RefreshAdminAclsRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshAdminAclsResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshAdminAclsResponsePBImpl.java new file mode 100644 index 0000000..a013e61 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshAdminAclsResponsePBImpl.java @@ -0,0 +1,68 @@ +/** +* 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. +*/ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.RefreshAdminAclsResponse; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshAdminAclsResponseProto; + +@Private +@Unstable +public class RefreshAdminAclsResponsePBImpl extends RefreshAdminAclsResponse { + + RefreshAdminAclsResponseProto proto = RefreshAdminAclsResponseProto.getDefaultInstance(); + RefreshAdminAclsResponseProto.Builder builder = null; + boolean viaProto = false; + + public RefreshAdminAclsResponsePBImpl() { + builder = RefreshAdminAclsResponseProto.newBuilder(); + } + + public RefreshAdminAclsResponsePBImpl(RefreshAdminAclsResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public RefreshAdminAclsResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshNodesRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshNodesRequestPBImpl.java new file mode 100644 index 0000000..631a6d7 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshNodesRequestPBImpl.java @@ -0,0 +1,68 @@ +/** +* 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. +*/ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.RefreshNodesRequest; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshNodesRequestProto; + +@Private +@Unstable +public class RefreshNodesRequestPBImpl extends RefreshNodesRequest { + + RefreshNodesRequestProto proto = RefreshNodesRequestProto.getDefaultInstance(); + RefreshNodesRequestProto.Builder builder = null; + boolean viaProto = false; + + public RefreshNodesRequestPBImpl() { + builder = RefreshNodesRequestProto.newBuilder(); + } + + public RefreshNodesRequestPBImpl(RefreshNodesRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public RefreshNodesRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshNodesResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshNodesResponsePBImpl.java new file mode 100644 index 0000000..84b709e --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshNodesResponsePBImpl.java @@ -0,0 +1,68 @@ +/** +* 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. +*/ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.RefreshNodesResponse; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshNodesResponseProto; + +@Private +@Unstable +public class RefreshNodesResponsePBImpl extends RefreshNodesResponse { + + RefreshNodesResponseProto proto = RefreshNodesResponseProto.getDefaultInstance(); + RefreshNodesResponseProto.Builder builder = null; + boolean viaProto = false; + + public RefreshNodesResponsePBImpl() { + builder = RefreshNodesResponseProto.newBuilder(); + } + + public RefreshNodesResponsePBImpl(RefreshNodesResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public RefreshNodesResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshQueuesRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshQueuesRequestPBImpl.java new file mode 100644 index 0000000..3a6f034 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshQueuesRequestPBImpl.java @@ -0,0 +1,68 @@ +/** +* 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. +*/ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.RefreshQueuesRequest; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshQueuesRequestProto; + +@Private +@Unstable +public class RefreshQueuesRequestPBImpl extends RefreshQueuesRequest { + + RefreshQueuesRequestProto proto = RefreshQueuesRequestProto.getDefaultInstance(); + RefreshQueuesRequestProto.Builder builder = null; + boolean viaProto = false; + + public RefreshQueuesRequestPBImpl() { + builder = RefreshQueuesRequestProto.newBuilder(); + } + + public RefreshQueuesRequestPBImpl(RefreshQueuesRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public RefreshQueuesRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshQueuesResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshQueuesResponsePBImpl.java new file mode 100644 index 0000000..a8cc9d699 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshQueuesResponsePBImpl.java @@ -0,0 +1,68 @@ +/** +* 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. +*/ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.RefreshQueuesResponse; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshQueuesResponseProto; + +@Private +@Unstable +public class RefreshQueuesResponsePBImpl extends RefreshQueuesResponse { + + RefreshQueuesResponseProto proto = RefreshQueuesResponseProto.getDefaultInstance(); + RefreshQueuesResponseProto.Builder builder = null; + boolean viaProto = false; + + public RefreshQueuesResponsePBImpl() { + builder = RefreshQueuesResponseProto.newBuilder(); + } + + public RefreshQueuesResponsePBImpl(RefreshQueuesResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public RefreshQueuesResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshServiceAclsRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshServiceAclsRequestPBImpl.java new file mode 100644 index 0000000..5d88373 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshServiceAclsRequestPBImpl.java @@ -0,0 +1,70 @@ +/** +* 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. +*/ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.RefreshServiceAclsRequest; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshServiceAclsRequestProto; + +@Private +@Unstable +public class RefreshServiceAclsRequestPBImpl extends RefreshServiceAclsRequest { + + RefreshServiceAclsRequestProto proto = + RefreshServiceAclsRequestProto.getDefaultInstance(); + RefreshServiceAclsRequestProto.Builder builder = null; + boolean viaProto = false; + + public RefreshServiceAclsRequestPBImpl() { + builder = RefreshServiceAclsRequestProto.newBuilder(); + } + + public RefreshServiceAclsRequestPBImpl( + RefreshServiceAclsRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public RefreshServiceAclsRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshServiceAclsResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshServiceAclsResponsePBImpl.java new file mode 100644 index 0000000..ca95a3a --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshServiceAclsResponsePBImpl.java @@ -0,0 +1,71 @@ +/** +* 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. +*/ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.RefreshServiceAclsResponse; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshServiceAclsResponseProto; + +@Private +@Unstable +public class RefreshServiceAclsResponsePBImpl extends + RefreshServiceAclsResponse { + + RefreshServiceAclsResponseProto proto = + RefreshServiceAclsResponseProto.getDefaultInstance(); + RefreshServiceAclsResponseProto.Builder builder = null; + boolean viaProto = false; + + public RefreshServiceAclsResponsePBImpl() { + builder = RefreshServiceAclsResponseProto.newBuilder(); + } + + public RefreshServiceAclsResponsePBImpl( + RefreshServiceAclsResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public RefreshServiceAclsResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshSuperUserGroupsConfigurationRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshSuperUserGroupsConfigurationRequestPBImpl.java new file mode 100644 index 0000000..2852bd0 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshSuperUserGroupsConfigurationRequestPBImpl.java @@ -0,0 +1,69 @@ +/** +* 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. +*/ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.RefreshSuperUserGroupsConfigurationRequest; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshSuperUserGroupsConfigurationRequestProto; + +@Private +@Unstable +public class RefreshSuperUserGroupsConfigurationRequestPBImpl +extends RefreshSuperUserGroupsConfigurationRequest { + + RefreshSuperUserGroupsConfigurationRequestProto proto = RefreshSuperUserGroupsConfigurationRequestProto.getDefaultInstance(); + RefreshSuperUserGroupsConfigurationRequestProto.Builder builder = null; + boolean viaProto = false; + + public RefreshSuperUserGroupsConfigurationRequestPBImpl() { + builder = RefreshSuperUserGroupsConfigurationRequestProto.newBuilder(); + } + + public RefreshSuperUserGroupsConfigurationRequestPBImpl(RefreshSuperUserGroupsConfigurationRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public RefreshSuperUserGroupsConfigurationRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshSuperUserGroupsConfigurationResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshSuperUserGroupsConfigurationResponsePBImpl.java new file mode 100644 index 0000000..89a850c --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshSuperUserGroupsConfigurationResponsePBImpl.java @@ -0,0 +1,68 @@ +/** +* 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. +*/ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.RefreshSuperUserGroupsConfigurationResponse; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshSuperUserGroupsConfigurationResponseProto; + +@Private +@Unstable +public class RefreshSuperUserGroupsConfigurationResponsePBImpl extends RefreshSuperUserGroupsConfigurationResponse { + + RefreshSuperUserGroupsConfigurationResponseProto proto = RefreshSuperUserGroupsConfigurationResponseProto.getDefaultInstance(); + RefreshSuperUserGroupsConfigurationResponseProto.Builder builder = null; + boolean viaProto = false; + + public RefreshSuperUserGroupsConfigurationResponsePBImpl() { + builder = RefreshSuperUserGroupsConfigurationResponseProto.newBuilder(); + } + + public RefreshSuperUserGroupsConfigurationResponsePBImpl(RefreshSuperUserGroupsConfigurationResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public RefreshSuperUserGroupsConfigurationResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshUserToGroupsMappingsRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshUserToGroupsMappingsRequestPBImpl.java new file mode 100644 index 0000000..382d188 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshUserToGroupsMappingsRequestPBImpl.java @@ -0,0 +1,69 @@ +/** +* 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. +*/ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.RefreshUserToGroupsMappingsRequest; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshUserToGroupsMappingsRequestProto; + +@Private +@Unstable +public class RefreshUserToGroupsMappingsRequestPBImpl +extends RefreshUserToGroupsMappingsRequest { + + RefreshUserToGroupsMappingsRequestProto proto = RefreshUserToGroupsMappingsRequestProto.getDefaultInstance(); + RefreshUserToGroupsMappingsRequestProto.Builder builder = null; + boolean viaProto = false; + + public RefreshUserToGroupsMappingsRequestPBImpl() { + builder = RefreshUserToGroupsMappingsRequestProto.newBuilder(); + } + + public RefreshUserToGroupsMappingsRequestPBImpl(RefreshUserToGroupsMappingsRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public RefreshUserToGroupsMappingsRequestProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshUserToGroupsMappingsResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshUserToGroupsMappingsResponsePBImpl.java new file mode 100644 index 0000000..6936eb0 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RefreshUserToGroupsMappingsResponsePBImpl.java @@ -0,0 +1,68 @@ +/** +* 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. +*/ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.RefreshUserToGroupsMappingsResponse; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.RefreshUserToGroupsMappingsResponseProto; + +@Private +@Unstable +public class RefreshUserToGroupsMappingsResponsePBImpl extends RefreshUserToGroupsMappingsResponse { + + RefreshUserToGroupsMappingsResponseProto proto = RefreshUserToGroupsMappingsResponseProto.getDefaultInstance(); + RefreshUserToGroupsMappingsResponseProto.Builder builder = null; + boolean viaProto = false; + + public RefreshUserToGroupsMappingsResponsePBImpl() { + builder = RefreshUserToGroupsMappingsResponseProto.newBuilder(); + } + + public RefreshUserToGroupsMappingsResponsePBImpl(RefreshUserToGroupsMappingsResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public RefreshUserToGroupsMappingsResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RegisterApplicationMasterRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RegisterApplicationMasterRequestPBImpl.java new file mode 100644 index 0000000..72f4520 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RegisterApplicationMasterRequestPBImpl.java @@ -0,0 +1,164 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterRequest; +import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; +import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationAttemptIdPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterRequestProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterRequestProtoOrBuilder; + +@Private +@Unstable +public class RegisterApplicationMasterRequestPBImpl extends RegisterApplicationMasterRequest { + RegisterApplicationMasterRequestProto proto = RegisterApplicationMasterRequestProto.getDefaultInstance(); + RegisterApplicationMasterRequestProto.Builder builder = null; + boolean viaProto = false; + + private ApplicationAttemptId applicationAttemptId = null; + + + public RegisterApplicationMasterRequestPBImpl() { + builder = RegisterApplicationMasterRequestProto.newBuilder(); + } + + public RegisterApplicationMasterRequestPBImpl(RegisterApplicationMasterRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public RegisterApplicationMasterRequestProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.applicationAttemptId != null && !((ApplicationAttemptIdPBImpl)this.applicationAttemptId).getProto().equals(builder.getApplicationAttemptId())) { + builder.setApplicationAttemptId(convertToProtoFormat(this.applicationAttemptId)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = RegisterApplicationMasterRequestProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public ApplicationAttemptId getApplicationAttemptId() { + RegisterApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.applicationAttemptId != null) { + return this.applicationAttemptId; + } + if (!p.hasApplicationAttemptId()) { + return null; + } + this.applicationAttemptId = convertFromProtoFormat(p.getApplicationAttemptId()); + return this.applicationAttemptId; + } + + @Override + public void setApplicationAttemptId(ApplicationAttemptId applicationMaster) { + maybeInitBuilder(); + if (applicationMaster == null) + builder.clearApplicationAttemptId(); + this.applicationAttemptId = applicationMaster; + } + + @Override + public String getHost() { + RegisterApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; + return p.getHost(); + } + + @Override + public void setHost(String host) { + maybeInitBuilder(); + builder.setHost(host); + } + + @Override + public int getRpcPort() { + RegisterApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; + return p.getRpcPort(); + } + + @Override + public void setRpcPort(int port) { + maybeInitBuilder(); + builder.setRpcPort(port); + } + + @Override + public String getTrackingUrl() { + RegisterApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; + return p.getTrackingUrl(); + } + + @Override + public void setTrackingUrl(String url) { + maybeInitBuilder(); + builder.setTrackingUrl(url); + } + + private ApplicationAttemptIdPBImpl convertFromProtoFormat(ApplicationAttemptIdProto p) { + return new ApplicationAttemptIdPBImpl(p); + } + + private ApplicationAttemptIdProto convertToProtoFormat(ApplicationAttemptId t) { + return ((ApplicationAttemptIdPBImpl)t).getProto(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RegisterApplicationMasterResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RegisterApplicationMasterResponsePBImpl.java new file mode 100644 index 0000000..e2962e3 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RegisterApplicationMasterResponsePBImpl.java @@ -0,0 +1,235 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse; +import org.apache.hadoop.yarn.api.records.ApplicationAccessType; +import org.apache.hadoop.yarn.api.records.Resource; +import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils; +import org.apache.hadoop.yarn.api.records.impl.pb.ResourcePBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterResponseProtoOrBuilder; + +import com.google.protobuf.ByteString; + + +@Private +@Unstable +public class RegisterApplicationMasterResponsePBImpl extends + RegisterApplicationMasterResponse { + RegisterApplicationMasterResponseProto proto = + RegisterApplicationMasterResponseProto.getDefaultInstance(); + RegisterApplicationMasterResponseProto.Builder builder = null; + boolean viaProto = false; + + private Resource maximumResourceCapability; + private Map applicationACLS = null; + + public RegisterApplicationMasterResponsePBImpl() { + builder = RegisterApplicationMasterResponseProto.newBuilder(); + } + + public RegisterApplicationMasterResponsePBImpl(RegisterApplicationMasterResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public RegisterApplicationMasterResponseProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void mergeLocalToBuilder() { + if (this.maximumResourceCapability != null) { + builder.setMaximumCapability( + convertToProtoFormat(this.maximumResourceCapability)); + } + if (this.applicationACLS != null) { + addApplicationACLs(); + } + } + + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = RegisterApplicationMasterResponseProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public Resource getMaximumResourceCapability() { + if (this.maximumResourceCapability != null) { + return this.maximumResourceCapability; + } + + RegisterApplicationMasterResponseProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasMaximumCapability()) { + return null; + } + + this.maximumResourceCapability = convertFromProtoFormat(p.getMaximumCapability()); + return this.maximumResourceCapability; + } + + @Override + public void setMaximumResourceCapability(Resource capability) { + maybeInitBuilder(); + if(maximumResourceCapability == null) { + builder.clearMaximumCapability(); + } + this.maximumResourceCapability = capability; + } + + @Override + public Map getApplicationACLs() { + initApplicationACLs(); + return this.applicationACLS; + } + + private void initApplicationACLs() { + if (this.applicationACLS != null) { + return; + } + RegisterApplicationMasterResponseProtoOrBuilder p = viaProto ? proto + : builder; + List list = p.getApplicationACLsList(); + this.applicationACLS = new HashMap(list + .size()); + + for (ApplicationACLMapProto aclProto : list) { + this.applicationACLS.put(ProtoUtils.convertFromProtoFormat(aclProto + .getAccessType()), aclProto.getAcl()); + } + } + + private void addApplicationACLs() { + maybeInitBuilder(); + builder.clearApplicationACLs(); + if (applicationACLS == null) { + return; + } + Iterable values + = new Iterable() { + + @Override + public Iterator iterator() { + return new Iterator() { + Iterator aclsIterator = applicationACLS + .keySet().iterator(); + + @Override + public boolean hasNext() { + return aclsIterator.hasNext(); + } + + @Override + public ApplicationACLMapProto next() { + ApplicationAccessType key = aclsIterator.next(); + return ApplicationACLMapProto.newBuilder().setAcl( + applicationACLS.get(key)).setAccessType( + ProtoUtils.convertToProtoFormat(key)).build(); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + }; + this.builder.addAllApplicationACLs(values); + } + + @Override + public void setApplicationACLs( + final Map appACLs) { + if (appACLs == null) + return; + initApplicationACLs(); + this.applicationACLS.clear(); + this.applicationACLS.putAll(appACLs); + } + + @Override + public void setClientToAMTokenMasterKey(ByteBuffer key) { + if (key == null) { + return; + } + maybeInitBuilder(); + builder.setClientToAmTokenMasterKey(ByteString.copyFrom(key)); + } + + @Override + public ByteBuffer getClientToAMTokenMasterKey() { + ByteBuffer key = + ByteBuffer.wrap(builder.getClientToAmTokenMasterKey().toByteArray()); + return key; + } + + private Resource convertFromProtoFormat(ResourceProto resource) { + return new ResourcePBImpl(resource); + } + + private ResourceProto convertToProtoFormat(Resource resource) { + return ((ResourcePBImpl)resource).getProto(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RenewDelegationTokenRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RenewDelegationTokenRequestPBImpl.java new file mode 100644 index 0000000..3e109c5 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RenewDelegationTokenRequestPBImpl.java @@ -0,0 +1,124 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProto; +import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProtoOrBuilder; +import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; +import org.apache.hadoop.yarn.api.protocolrecords.RenewDelegationTokenRequest; +import org.apache.hadoop.yarn.api.records.Token; +import org.apache.hadoop.yarn.api.records.impl.pb.TokenPBImpl; + +@Private +@Unstable +public class RenewDelegationTokenRequestPBImpl extends + RenewDelegationTokenRequest { + RenewDelegationTokenRequestProto proto = + RenewDelegationTokenRequestProto.getDefaultInstance(); + RenewDelegationTokenRequestProto.Builder builder = null; + boolean viaProto = false; + + public RenewDelegationTokenRequestPBImpl() { + builder = RenewDelegationTokenRequestProto.newBuilder(); + } + + public RenewDelegationTokenRequestPBImpl ( + RenewDelegationTokenRequestProto proto) { + this.proto = proto; + this.viaProto = true; + } + + Token token; + + @Override + public Token getDelegationToken() { + RenewDelegationTokenRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.token != null) { + return this.token; + } + this.token = convertFromProtoFormat(p.getToken()); + return this.token; + } + + @Override + public void setDelegationToken(Token token) { + maybeInitBuilder(); + if (token == null) + builder.clearToken(); + this.token = token; + } + + public RenewDelegationTokenRequestProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (token != null) { + builder.setToken(convertToProtoFormat(this.token)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = RenewDelegationTokenRequestProto.newBuilder(proto); + } + viaProto = false; + } + + + private TokenPBImpl convertFromProtoFormat(TokenProto p) { + return new TokenPBImpl(p); + } + + private TokenProto convertToProtoFormat(Token t) { + return ((TokenPBImpl)t).getProto(); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RenewDelegationTokenResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RenewDelegationTokenResponsePBImpl.java new file mode 100644 index 0000000..ecf0b30 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RenewDelegationTokenResponsePBImpl.java @@ -0,0 +1,90 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenResponseProto; +import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenResponseProtoOrBuilder; +import org.apache.hadoop.yarn.api.protocolrecords.RenewDelegationTokenResponse; + +@Private +@Unstable +public class RenewDelegationTokenResponsePBImpl extends + RenewDelegationTokenResponse { + + RenewDelegationTokenResponseProto proto = + RenewDelegationTokenResponseProto.getDefaultInstance(); + RenewDelegationTokenResponseProto.Builder builder = null; + boolean viaProto = false; + + public RenewDelegationTokenResponsePBImpl() { + this.builder = RenewDelegationTokenResponseProto.newBuilder(); + } + + public RenewDelegationTokenResponsePBImpl ( + RenewDelegationTokenResponseProto proto) { + this.proto = proto; + this.viaProto = true; + } + + public RenewDelegationTokenResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = RenewDelegationTokenResponseProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public long getNextExpirationTime() { + RenewDelegationTokenResponseProtoOrBuilder p = viaProto ? proto : builder; + return p.getNewExpiryTime(); + } + + @Override + public void setNextExpirationTime(long expTime) { + maybeInitBuilder(); + builder.setNewExpiryTime(expTime); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerRequestPBImpl.java new file mode 100644 index 0000000..acb9d34 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerRequestPBImpl.java @@ -0,0 +1,166 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; +import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest; +import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; +import org.apache.hadoop.yarn.api.records.Token; +import org.apache.hadoop.yarn.api.records.impl.pb.ContainerLaunchContextPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.TokenPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainerRequestProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainerRequestProtoOrBuilder; + +@Private +@Unstable +public class StartContainerRequestPBImpl extends StartContainerRequest { + StartContainerRequestProto proto = StartContainerRequestProto.getDefaultInstance(); + StartContainerRequestProto.Builder builder = null; + boolean viaProto = false; + + private ContainerLaunchContext containerLaunchContext = null; + + private Token containerToken = null; + + public StartContainerRequestPBImpl() { + builder = StartContainerRequestProto.newBuilder(); + } + + public StartContainerRequestPBImpl(StartContainerRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public StartContainerRequestProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.containerLaunchContext != null) { + builder.setContainerLaunchContext(convertToProtoFormat(this.containerLaunchContext)); + } + if(this.containerToken != null) { + builder.setContainerToken(convertToProtoFormat(this.containerToken)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = StartContainerRequestProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public ContainerLaunchContext getContainerLaunchContext() { + StartContainerRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.containerLaunchContext != null) { + return this.containerLaunchContext; + } + if (!p.hasContainerLaunchContext()) { + return null; + } + this.containerLaunchContext = convertFromProtoFormat(p.getContainerLaunchContext()); + return this.containerLaunchContext; + } + + @Override + public void setContainerLaunchContext(ContainerLaunchContext containerLaunchContext) { + maybeInitBuilder(); + if (containerLaunchContext == null) + builder.clearContainerLaunchContext(); + this.containerLaunchContext = containerLaunchContext; + } + + @Override + public Token getContainerToken() { + StartContainerRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.containerToken != null) { + return this.containerToken; + } + if (!p.hasContainerToken()) { + return null; + } + this.containerToken = convertFromProtoFormat(p.getContainerToken()); + return this.containerToken; + } + + @Override + public void setContainerToken(Token containerToken) { + maybeInitBuilder(); + if(containerToken == null) { + builder.clearContainerToken(); + } + this.containerToken = containerToken; + } + + private ContainerLaunchContextPBImpl convertFromProtoFormat(ContainerLaunchContextProto p) { + return new ContainerLaunchContextPBImpl(p); + } + + private ContainerLaunchContextProto convertToProtoFormat(ContainerLaunchContext t) { + return ((ContainerLaunchContextPBImpl)t).getProto(); + } + + + + private TokenPBImpl convertFromProtoFormat(TokenProto containerProto) { + return new TokenPBImpl(containerProto); + } + + private TokenProto convertToProtoFormat(Token container) { + return ((TokenPBImpl)container).getProto(); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerResponsePBImpl.java new file mode 100644 index 0000000..8edbfa7 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerResponsePBImpl.java @@ -0,0 +1,176 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.StartContainerResponse; +import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils; +import org.apache.hadoop.yarn.proto.YarnProtos.StringBytesMapProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainerResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainerResponseProtoOrBuilder; + +import com.google.protobuf.ByteString; + +@Private +@Unstable +public class StartContainerResponsePBImpl extends StartContainerResponse { + StartContainerResponseProto proto = StartContainerResponseProto.getDefaultInstance(); + StartContainerResponseProto.Builder builder = null; + boolean viaProto = false; + + private Map servicesMetaData = null; + + public StartContainerResponsePBImpl() { + builder = StartContainerResponseProto.newBuilder(); + } + + public StartContainerResponsePBImpl(StartContainerResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public synchronized StartContainerResponseProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private synchronized void mergeLocalToBuilder() { + if (this.servicesMetaData != null) { + addServicesMetaDataToProto(); + } + } + + protected final ByteBuffer convertFromProtoFormat(ByteString byteString) { + return ProtoUtils.convertFromProtoFormat(byteString); + } + + protected final ByteString convertToProtoFormat(ByteBuffer byteBuffer) { + return ProtoUtils.convertToProtoFormat(byteBuffer); + } + + private synchronized void mergeLocalToProto() { + if (viaProto) { + maybeInitBuilder(); + } + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private synchronized void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = StartContainerResponseProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public synchronized Map getAllServicesMetaData() { + initServicesMetaData(); + return this.servicesMetaData; + } + @Override + public synchronized void setAllServicesMetaData( + Map servicesMetaData) { + if(servicesMetaData == null) { + return; + } + initServicesMetaData(); + this.servicesMetaData.clear(); + this.servicesMetaData.putAll(servicesMetaData); + } + + private synchronized void initServicesMetaData() { + if (this.servicesMetaData != null) { + return; + } + StartContainerResponseProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getServicesMetaDataList(); + this.servicesMetaData = new HashMap(); + + for (StringBytesMapProto c : list) { + this.servicesMetaData.put(c.getKey(), convertFromProtoFormat(c.getValue())); + } + } + + private synchronized void addServicesMetaDataToProto() { + maybeInitBuilder(); + builder.clearServicesMetaData(); + if (servicesMetaData == null) + return; + Iterable iterable = new Iterable() { + + @Override + public synchronized Iterator iterator() { + return new Iterator() { + + Iterator keyIter = servicesMetaData.keySet().iterator(); + + @Override + public synchronized void remove() { + throw new UnsupportedOperationException(); + } + + @Override + public synchronized StringBytesMapProto next() { + String key = keyIter.next(); + return StringBytesMapProto.newBuilder().setKey(key).setValue(convertToProtoFormat(servicesMetaData.get(key))).build(); + } + + @Override + public synchronized boolean hasNext() { + return keyIter.hasNext(); + } + }; + } + }; + builder.addAllServicesMetaData(iterable); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainerRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainerRequestPBImpl.java new file mode 100644 index 0000000..dfba527 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainerRequestPBImpl.java @@ -0,0 +1,130 @@ +/** +* 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. +*/ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.StopContainerRequest; +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainerRequestProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainerRequestProtoOrBuilder; + +@Private +@Unstable +public class StopContainerRequestPBImpl extends StopContainerRequest { + StopContainerRequestProto proto = StopContainerRequestProto.getDefaultInstance(); + StopContainerRequestProto.Builder builder = null; + boolean viaProto = false; + + private ContainerId containerId = null; + + + public StopContainerRequestPBImpl() { + builder = StopContainerRequestProto.newBuilder(); + } + + public StopContainerRequestPBImpl(StopContainerRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public StopContainerRequestProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.containerId != null) { + builder.setContainerId(convertToProtoFormat(this.containerId)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = StopContainerRequestProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public ContainerId getContainerId() { + StopContainerRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.containerId != null) { + return this.containerId; + } + if (!p.hasContainerId()) { + return null; + } + this.containerId = convertFromProtoFormat(p.getContainerId()); + return this.containerId; + } + + @Override + public void setContainerId(ContainerId containerId) { + maybeInitBuilder(); + if (containerId == null) + builder.clearContainerId(); + this.containerId = containerId; + } + + private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { + return new ContainerIdPBImpl(p); + } + + private ContainerIdProto convertToProtoFormat(ContainerId t) { + return ((ContainerIdPBImpl)t).getProto(); + } + + + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainerResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainerResponsePBImpl.java new file mode 100644 index 0000000..6e3fe21 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainerResponsePBImpl.java @@ -0,0 +1,68 @@ +/** +* 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. +*/ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.StopContainerResponse; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainerResponseProto; + +@Private +@Unstable +public class StopContainerResponsePBImpl extends StopContainerResponse { + StopContainerResponseProto proto = StopContainerResponseProto.getDefaultInstance(); + StopContainerResponseProto.Builder builder = null; + boolean viaProto = false; + + public StopContainerResponsePBImpl() { + builder = StopContainerResponseProto.newBuilder(); + } + + public StopContainerResponsePBImpl(StopContainerResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public StopContainerResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SubmitApplicationRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SubmitApplicationRequestPBImpl.java new file mode 100644 index 0000000..ab33412 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SubmitApplicationRequestPBImpl.java @@ -0,0 +1,130 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest; +import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; +import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationSubmissionContextPBImpl; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationSubmissionContextProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.SubmitApplicationRequestProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.SubmitApplicationRequestProtoOrBuilder; + +@Private +@Unstable +public class SubmitApplicationRequestPBImpl extends SubmitApplicationRequest { + SubmitApplicationRequestProto proto = SubmitApplicationRequestProto.getDefaultInstance(); + SubmitApplicationRequestProto.Builder builder = null; + boolean viaProto = false; + + private ApplicationSubmissionContext applicationSubmissionContext = null; + + + public SubmitApplicationRequestPBImpl() { + builder = SubmitApplicationRequestProto.newBuilder(); + } + + public SubmitApplicationRequestPBImpl(SubmitApplicationRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public SubmitApplicationRequestProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.applicationSubmissionContext != null) { + builder.setApplicationSubmissionContext(convertToProtoFormat(this.applicationSubmissionContext)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = SubmitApplicationRequestProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public ApplicationSubmissionContext getApplicationSubmissionContext() { + SubmitApplicationRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.applicationSubmissionContext != null) { + return this.applicationSubmissionContext; + } + if (!p.hasApplicationSubmissionContext()) { + return null; + } + this.applicationSubmissionContext = convertFromProtoFormat(p.getApplicationSubmissionContext()); + return this.applicationSubmissionContext; + } + + @Override + public void setApplicationSubmissionContext(ApplicationSubmissionContext applicationSubmissionContext) { + maybeInitBuilder(); + if (applicationSubmissionContext == null) + builder.clearApplicationSubmissionContext(); + this.applicationSubmissionContext = applicationSubmissionContext; + } + + private ApplicationSubmissionContextPBImpl convertFromProtoFormat(ApplicationSubmissionContextProto p) { + return new ApplicationSubmissionContextPBImpl(p); + } + + private ApplicationSubmissionContextProto convertToProtoFormat(ApplicationSubmissionContext t) { + return ((ApplicationSubmissionContextPBImpl)t).getProto(); + } + + + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SubmitApplicationResponsePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SubmitApplicationResponsePBImpl.java new file mode 100644 index 0000000..8ac49f5 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SubmitApplicationResponsePBImpl.java @@ -0,0 +1,68 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationResponse; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.SubmitApplicationResponseProto; + +@Private +@Unstable +public class SubmitApplicationResponsePBImpl extends SubmitApplicationResponse { + SubmitApplicationResponseProto proto = SubmitApplicationResponseProto.getDefaultInstance(); + SubmitApplicationResponseProto.Builder builder = null; + boolean viaProto = false; + + public SubmitApplicationResponsePBImpl() { + builder = SubmitApplicationResponseProto.newBuilder(); + } + + public SubmitApplicationResponsePBImpl(SubmitApplicationResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public SubmitApplicationResponseProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/package-info.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/package-info.java new file mode 100644 index 0000000..f9c7e5c --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ +@InterfaceAudience.Private +package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; +import org.apache.hadoop.classification.InterfaceAudience; diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationAttemptIdPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationAttemptIdPBImpl.java new file mode 100644 index 0000000..521d9cc --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationAttemptIdPBImpl.java @@ -0,0 +1,89 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; + +import com.google.common.base.Preconditions; + +@Private +@Unstable +public class ApplicationAttemptIdPBImpl extends ApplicationAttemptId { + ApplicationAttemptIdProto proto = null; + ApplicationAttemptIdProto.Builder builder = null; + private ApplicationId applicationId = null; + + public ApplicationAttemptIdPBImpl() { + builder = ApplicationAttemptIdProto.newBuilder(); + } + + public ApplicationAttemptIdPBImpl(ApplicationAttemptIdProto proto) { + this.proto = proto; + this.applicationId = convertFromProtoFormat(proto.getApplicationId()); + } + + public ApplicationAttemptIdProto getProto() { + return proto; + } + + @Override + public int getAttemptId() { + Preconditions.checkNotNull(proto); + return proto.getAttemptId(); + } + + @Override + protected void setAttemptId(int attemptId) { + Preconditions.checkNotNull(builder); + builder.setAttemptId(attemptId); + } + + @Override + public ApplicationId getApplicationId() { + return this.applicationId; + } + + @Override + public void setApplicationId(ApplicationId appId) { + if (appId != null) { + Preconditions.checkNotNull(builder); + builder.setApplicationId(convertToProtoFormat(appId)); + } + this.applicationId = appId; + } + + private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { + return new ApplicationIdPBImpl(p); + } + + private ApplicationIdProto convertToProtoFormat(ApplicationId t) { + return ((ApplicationIdPBImpl)t).getProto(); + } + + @Override + protected void build() { + proto = builder.build(); + builder = null; + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationIdPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationIdPBImpl.java new file mode 100644 index 0000000..df038e5 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationIdPBImpl.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 + * + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; + +import com.google.common.base.Preconditions; + +@Private +@Unstable +public class ApplicationIdPBImpl extends ApplicationId { + ApplicationIdProto proto = null; + ApplicationIdProto.Builder builder = null; + + public ApplicationIdPBImpl() { + builder = ApplicationIdProto.newBuilder(); + } + + public ApplicationIdPBImpl(ApplicationIdProto proto) { + this.proto = proto; + } + + public ApplicationIdProto getProto() { + return proto; + } + + @Override + public int getId() { + Preconditions.checkNotNull(proto); + return proto.getId(); + } + + @Override + protected void setId(int id) { + Preconditions.checkNotNull(builder); + builder.setId(id); + } + @Override + public long getClusterTimestamp() { + Preconditions.checkNotNull(proto); + return proto.getClusterTimestamp(); + } + + @Override + protected void setClusterTimestamp(long clusterTimestamp) { + Preconditions.checkNotNull(builder); + builder.setClusterTimestamp((clusterTimestamp)); + } + + @Override + protected void build() { + proto = builder.build(); + builder = null; + } +} \ No newline at end of file diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationReportPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationReportPBImpl.java new file mode 100644 index 0000000..b08db0d --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationReportPBImpl.java @@ -0,0 +1,489 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; +import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.ApplicationReport; +import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; +import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; +import org.apache.hadoop.yarn.api.records.Token; +import org.apache.hadoop.yarn.api.records.YarnApplicationState; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationReportProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationReportProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationResourceUsageReportProto; +import org.apache.hadoop.yarn.proto.YarnProtos.FinalApplicationStatusProto; +import org.apache.hadoop.yarn.proto.YarnProtos.YarnApplicationStateProto; + +@Private +@Unstable +public class ApplicationReportPBImpl extends ApplicationReport { + ApplicationReportProto proto = ApplicationReportProto.getDefaultInstance(); + ApplicationReportProto.Builder builder = null; + boolean viaProto = false; + + private ApplicationId applicationId; + private ApplicationAttemptId currentApplicationAttemptId; + private Token clientToAMToken = null; + + public ApplicationReportPBImpl() { + builder = ApplicationReportProto.newBuilder(); + } + + public ApplicationReportPBImpl(ApplicationReportProto proto) { + this.proto = proto; + viaProto = true; + } + + @Override + public ApplicationId getApplicationId() { + if (this.applicationId != null) { + return this.applicationId; + } + + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasApplicationId()) { + return null; + } + this.applicationId = convertFromProtoFormat(p.getApplicationId()); + return this.applicationId; + } + + public void setApplicationResourceUsageReport(ApplicationResourceUsageReport appInfo) { + maybeInitBuilder(); + if (appInfo == null) { + builder.clearAppResourceUsage(); + return; + } + builder.setAppResourceUsage(convertToProtoFormat(appInfo)); + } + + @Override + public ApplicationAttemptId getCurrentApplicationAttemptId() { + if (this.currentApplicationAttemptId != null) { + return this.currentApplicationAttemptId; + } + + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasCurrentApplicationAttemptId()) { + return null; + } + this.currentApplicationAttemptId = convertFromProtoFormat(p.getCurrentApplicationAttemptId()); + return this.currentApplicationAttemptId; + } + + @Override + public ApplicationResourceUsageReport getApplicationResourceUsageReport() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasAppResourceUsage()) { + return null; + } + return convertFromProtoFormat(p.getAppResourceUsage()); + } + + @Override + public String getTrackingUrl() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasTrackingUrl()) { + return null; + } + return p.getTrackingUrl(); + } + + @Override + public String getOriginalTrackingUrl() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasOriginalTrackingUrl()) { + return null; + } + return p.getOriginalTrackingUrl(); + } + + @Override + public String getName() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasName()) { + return null; + } + return p.getName(); + } + + @Override + public String getQueue() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasQueue()) { + return null; + } + return p.getQueue(); + } + + @Override + public YarnApplicationState getYarnApplicationState() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasYarnApplicationState()) { + return null; + } + return convertFromProtoFormat(p.getYarnApplicationState()); + } + + @Override + public String getHost() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasHost()) { + return null; + } + return (p.getHost()); + } + + @Override + public int getRpcPort() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + return (p.getRpcPort()); + } + + @Override + public Token getClientToAMToken() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + if (this.clientToAMToken != null) { + return this.clientToAMToken; + } + if (!p.hasClientToAmToken()) { + return null; + } + this.clientToAMToken = convertFromProtoFormat(p.getClientToAmToken()); + return this.clientToAMToken; + } + + @Override + public String getUser() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasUser()) { + return null; + } + return p.getUser(); + } + + @Override + public String getDiagnostics() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasDiagnostics()) { + return null; + } + return p.getDiagnostics(); + } + + @Override + public long getStartTime() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + return p.getStartTime(); + } + + @Override + public long getFinishTime() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + return p.getFinishTime(); + } + + @Override + public FinalApplicationStatus getFinalApplicationStatus() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasFinalApplicationStatus()) { + return null; + } + return convertFromProtoFormat(p.getFinalApplicationStatus()); + } + + @Override + public float getProgress() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + return p.getProgress(); + } + + @Override + public String getApplicationType() { + ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasApplicationType()) { + return null; + } + return p.getApplicationType(); + } + + @Override + public void setApplicationId(ApplicationId applicationId) { + maybeInitBuilder(); + if (applicationId == null) + builder.clearApplicationId(); + this.applicationId = applicationId; + } + + @Override + public void setCurrentApplicationAttemptId(ApplicationAttemptId applicationAttemptId) { + maybeInitBuilder(); + if (applicationAttemptId == null) + builder.clearCurrentApplicationAttemptId(); + this.currentApplicationAttemptId = applicationAttemptId; + } + + @Override + public void setTrackingUrl(String url) { + maybeInitBuilder(); + if (url == null) { + builder.clearTrackingUrl(); + return; + } + builder.setTrackingUrl(url); + } + + @Override + public void setOriginalTrackingUrl(String url) { + maybeInitBuilder(); + if (url == null) { + builder.clearOriginalTrackingUrl(); + return; + } + builder.setOriginalTrackingUrl(url); + } + + @Override + public void setName(String name) { + maybeInitBuilder(); + if (name == null) { + builder.clearName(); + return; + } + builder.setName(name); + } + + @Override + public void setQueue(String queue) { + maybeInitBuilder(); + if (queue == null) { + builder.clearQueue(); + return; + } + builder.setQueue(queue); + } + + @Override + public void setYarnApplicationState(YarnApplicationState state) { + maybeInitBuilder(); + if (state == null) { + builder.clearYarnApplicationState(); + return; + } + builder.setYarnApplicationState(convertToProtoFormat(state)); + } + + @Override + public void setHost(String host) { + maybeInitBuilder(); + if (host == null) { + builder.clearHost(); + return; + } + builder.setHost((host)); + } + + @Override + public void setRpcPort(int rpcPort) { + maybeInitBuilder(); + builder.setRpcPort((rpcPort)); + } + + @Override + public void setClientToAMToken(Token clientToAMToken) { + maybeInitBuilder(); + if (clientToAMToken == null) + builder.clearClientToAmToken(); + this.clientToAMToken = clientToAMToken; + } + + @Override + public void setUser(String user) { + maybeInitBuilder(); + if (user == null) { + builder.clearUser(); + return; + } + builder.setUser((user)); + } + + @Override + public void setApplicationType(String applicationType) { + maybeInitBuilder(); + if (applicationType == null) { + builder.clearApplicationType(); + return; + } + builder.setApplicationType((applicationType)); + } + + @Override + public void setDiagnostics(String diagnostics) { + maybeInitBuilder(); + if (diagnostics == null) { + builder.clearDiagnostics(); + return; + } + builder.setDiagnostics(diagnostics); + } + + @Override + public void setStartTime(long startTime) { + maybeInitBuilder(); + builder.setStartTime(startTime); + } + + @Override + public void setFinishTime(long finishTime) { + maybeInitBuilder(); + builder.setFinishTime(finishTime); + } + + @Override + public void setFinalApplicationStatus(FinalApplicationStatus finishState) { + maybeInitBuilder(); + if (finishState == null) { + builder.clearFinalApplicationStatus(); + return; + } + builder.setFinalApplicationStatus(convertToProtoFormat(finishState)); + } + + @Override + public void setProgress(float progress) { + maybeInitBuilder(); + builder.setProgress(progress); + } + + public ApplicationReportProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.applicationId != null + && !((ApplicationIdPBImpl) this.applicationId).getProto().equals( + builder.getApplicationId())) { + builder.setApplicationId(convertToProtoFormat(this.applicationId)); + } + if (this.currentApplicationAttemptId != null + && !((ApplicationAttemptIdPBImpl) this.currentApplicationAttemptId).getProto().equals( + builder.getCurrentApplicationAttemptId())) { + builder.setCurrentApplicationAttemptId(convertToProtoFormat(this.currentApplicationAttemptId)); + } + if (this.clientToAMToken != null + && !((TokenPBImpl) this.clientToAMToken).getProto().equals( + builder.getClientToAmToken())) { + builder.setClientToAmToken(convertToProtoFormat(this.clientToAMToken)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = ApplicationReportProto.newBuilder(proto); + } + viaProto = false; + } + + private ApplicationIdProto convertToProtoFormat(ApplicationId t) { + return ((ApplicationIdPBImpl) t).getProto(); + } + + private ApplicationAttemptIdProto convertToProtoFormat(ApplicationAttemptId t) { + return ((ApplicationAttemptIdPBImpl) t).getProto(); + } + + private ApplicationResourceUsageReport convertFromProtoFormat(ApplicationResourceUsageReportProto s) { + return ProtoUtils.convertFromProtoFormat(s); + } + + private ApplicationResourceUsageReportProto convertToProtoFormat(ApplicationResourceUsageReport s) { + return ProtoUtils.convertToProtoFormat(s); + } + + private ApplicationIdPBImpl convertFromProtoFormat( + ApplicationIdProto applicationId) { + return new ApplicationIdPBImpl(applicationId); + } + + private ApplicationAttemptIdPBImpl convertFromProtoFormat( + ApplicationAttemptIdProto applicationAttemptId) { + return new ApplicationAttemptIdPBImpl(applicationAttemptId); + } + + private YarnApplicationState convertFromProtoFormat(YarnApplicationStateProto s) { + return ProtoUtils.convertFromProtoFormat(s); + } + + private YarnApplicationStateProto convertToProtoFormat(YarnApplicationState s) { + return ProtoUtils.convertToProtoFormat(s); + } + + private FinalApplicationStatus convertFromProtoFormat(FinalApplicationStatusProto s) { + return ProtoUtils.convertFromProtoFormat(s); + } + + private FinalApplicationStatusProto convertToProtoFormat(FinalApplicationStatus s) { + return ProtoUtils.convertToProtoFormat(s); + } + + private TokenPBImpl convertFromProtoFormat(TokenProto p) { + return new TokenPBImpl(p); + } + + private TokenProto convertToProtoFormat(Token t) { + return ((TokenPBImpl)t).getProto(); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationResourceUsageReportPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationResourceUsageReportPBImpl.java new file mode 100644 index 0000000..eb83424 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationResourceUsageReportPBImpl.java @@ -0,0 +1,208 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; +import org.apache.hadoop.yarn.api.records.Resource; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationResourceUsageReportProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationResourceUsageReportProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; + +@Private +@Unstable +public class ApplicationResourceUsageReportPBImpl +extends ApplicationResourceUsageReport { + ApplicationResourceUsageReportProto proto = + ApplicationResourceUsageReportProto.getDefaultInstance(); + ApplicationResourceUsageReportProto.Builder builder = null; + boolean viaProto = false; + + Resource usedResources; + Resource reservedResources; + Resource neededResources; + + public ApplicationResourceUsageReportPBImpl() { + builder = ApplicationResourceUsageReportProto.newBuilder(); + } + + public ApplicationResourceUsageReportPBImpl( + ApplicationResourceUsageReportProto proto) { + this.proto = proto; + viaProto = true; + } + + public synchronized ApplicationResourceUsageReportProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.usedResources != null + && !((ResourcePBImpl) this.usedResources).getProto().equals( + builder.getUsedResources())) { + builder.setUsedResources(convertToProtoFormat(this.usedResources)); + } + if (this.reservedResources != null + && !((ResourcePBImpl) this.reservedResources).getProto().equals( + builder.getReservedResources())) { + builder.setReservedResources( + convertToProtoFormat(this.reservedResources)); + } + if (this.neededResources != null + && !((ResourcePBImpl) this.neededResources).getProto().equals( + builder.getNeededResources())) { + builder.setNeededResources(convertToProtoFormat(this.neededResources)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private synchronized void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = ApplicationResourceUsageReportProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public synchronized int getNumUsedContainers() { + ApplicationResourceUsageReportProtoOrBuilder p = viaProto ? proto : builder; + return (p.getNumUsedContainers()); + } + + @Override + public synchronized void setNumUsedContainers(int num_containers) { + maybeInitBuilder(); + builder.setNumUsedContainers((num_containers)); + } + + @Override + public synchronized int getNumReservedContainers() { + ApplicationResourceUsageReportProtoOrBuilder p = viaProto ? proto : builder; + return (p.getNumReservedContainers()); + } + + @Override + public synchronized void setNumReservedContainers( + int num_reserved_containers) { + maybeInitBuilder(); + builder.setNumReservedContainers((num_reserved_containers)); + } + + @Override + public synchronized Resource getUsedResources() { + ApplicationResourceUsageReportProtoOrBuilder p = viaProto ? proto : builder; + if (this.usedResources != null) { + return this.usedResources; + } + if (!p.hasUsedResources()) { + return null; + } + this.usedResources = convertFromProtoFormat(p.getUsedResources()); + return this.usedResources; + } + + @Override + public synchronized void setUsedResources(Resource resources) { + maybeInitBuilder(); + if (resources == null) + builder.clearUsedResources(); + this.usedResources = resources; + } + + @Override + public synchronized Resource getReservedResources() { + ApplicationResourceUsageReportProtoOrBuilder p = viaProto ? proto : builder; + if (this.reservedResources != null) { + return this.reservedResources; + } + if (!p.hasReservedResources()) { + return null; + } + this.reservedResources = convertFromProtoFormat(p.getReservedResources()); + return this.reservedResources; + } + + @Override + public synchronized void setReservedResources(Resource reserved_resources) { + maybeInitBuilder(); + if (reserved_resources == null) + builder.clearReservedResources(); + this.reservedResources = reserved_resources; + } + + @Override + public synchronized Resource getNeededResources() { + ApplicationResourceUsageReportProtoOrBuilder p = viaProto ? proto : builder; + if (this.neededResources != null) { + return this.neededResources; + } + if (!p.hasNeededResources()) { + return null; + } + this.neededResources = convertFromProtoFormat(p.getNeededResources()); + return this.neededResources; + } + + @Override + public synchronized void setNeededResources(Resource reserved_resources) { + maybeInitBuilder(); + if (reserved_resources == null) + builder.clearNeededResources(); + this.neededResources = reserved_resources; + } + + private ResourcePBImpl convertFromProtoFormat(ResourceProto p) { + return new ResourcePBImpl(p); + } + + private ResourceProto convertToProtoFormat(Resource t) { + return ((ResourcePBImpl)t).getProto(); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationSubmissionContextPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationSubmissionContextPBImpl.java new file mode 100644 index 0000000..96f280a --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationSubmissionContextPBImpl.java @@ -0,0 +1,331 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; +import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; +import org.apache.hadoop.yarn.api.records.Priority; +import org.apache.hadoop.yarn.api.records.Resource; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationSubmissionContextProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationSubmissionContextProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProto; +import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; + +@Private +@Unstable +public class ApplicationSubmissionContextPBImpl +extends ApplicationSubmissionContext { + ApplicationSubmissionContextProto proto = + ApplicationSubmissionContextProto.getDefaultInstance(); + ApplicationSubmissionContextProto.Builder builder = null; + boolean viaProto = false; + + private ApplicationId applicationId = null; + private Priority priority = null; + private ContainerLaunchContext amContainer = null; + private Resource resource = null; + + public ApplicationSubmissionContextPBImpl() { + builder = ApplicationSubmissionContextProto.newBuilder(); + } + + public ApplicationSubmissionContextPBImpl( + ApplicationSubmissionContextProto proto) { + this.proto = proto; + viaProto = true; + } + + public ApplicationSubmissionContextProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.applicationId != null) { + builder.setApplicationId(convertToProtoFormat(this.applicationId)); + } + if (this.priority != null) { + builder.setPriority(convertToProtoFormat(this.priority)); + } + if (this.amContainer != null) { + builder.setAmContainerSpec(convertToProtoFormat(this.amContainer)); + } + if (this.resource != null && + !((ResourcePBImpl) this.resource).getProto().equals( + builder.getResource())) { + builder.setResource(convertToProtoFormat(this.resource)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = ApplicationSubmissionContextProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public Priority getPriority() { + ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; + if (this.priority != null) { + return this.priority; + } + if (!p.hasPriority()) { + return null; + } + this.priority = convertFromProtoFormat(p.getPriority()); + return this.priority; + } + + @Override + public void setPriority(Priority priority) { + maybeInitBuilder(); + if (priority == null) + builder.clearPriority(); + this.priority = priority; + } + + @Override + public ApplicationId getApplicationId() { + ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; + if (this.applicationId != null) { + return applicationId; + } // Else via proto + if (!p.hasApplicationId()) { + return null; + } + applicationId = convertFromProtoFormat(p.getApplicationId()); + return applicationId; + } + + @Override + public void setApplicationId(ApplicationId applicationId) { + maybeInitBuilder(); + if (applicationId == null) + builder.clearApplicationId(); + this.applicationId = applicationId; + } + + @Override + public String getApplicationName() { + ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasApplicationName()) { + return null; + } + return (p.getApplicationName()); + } + + @Override + public void setApplicationName(String applicationName) { + maybeInitBuilder(); + if (applicationName == null) { + builder.clearApplicationName(); + return; + } + builder.setApplicationName((applicationName)); + } + + @Override + public String getQueue() { + ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasQueue()) { + return null; + } + return (p.getQueue()); + } + + @Override + public String getApplicationType() { + ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasApplicationType()) { + return null; + } + return (p.getApplicationType()); + } + + @Override + public void setQueue(String queue) { + maybeInitBuilder(); + if (queue == null) { + builder.clearQueue(); + return; + } + builder.setQueue((queue)); + } + + @Override + public void setApplicationType(String applicationType) { + maybeInitBuilder(); + if (applicationType == null) { + builder.clearApplicationType(); + return; + } + builder.setApplicationType((applicationType)); + } + + @Override + public ContainerLaunchContext getAMContainerSpec() { + ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; + if (this.amContainer != null) { + return amContainer; + } // Else via proto + if (!p.hasAmContainerSpec()) { + return null; + } + amContainer = convertFromProtoFormat(p.getAmContainerSpec()); + return amContainer; + } + + @Override + public void setAMContainerSpec(ContainerLaunchContext amContainer) { + maybeInitBuilder(); + if (amContainer == null) { + builder.clearAmContainerSpec(); + } + this.amContainer = amContainer; + } + + @Override + public boolean getUnmanagedAM() { + ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; + return p.getUnmanagedAm(); + } + + @Override + public void setUnmanagedAM(boolean value) { + maybeInitBuilder(); + builder.setUnmanagedAm(value); + } + + @Override + public boolean getCancelTokensWhenComplete() { + ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; + //There is a default so cancelTokens should never be null + return p.getCancelTokensWhenComplete(); + } + + @Override + public void setCancelTokensWhenComplete(boolean cancel) { + maybeInitBuilder(); + builder.setCancelTokensWhenComplete(cancel); + } + + @Override + public int getMaxAppAttempts() { + ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; + return p.getMaxAppAttempts(); + } + + @Override + public void setMaxAppAttempts(int maxAppAttempts) { + maybeInitBuilder(); + builder.setMaxAppAttempts(maxAppAttempts); + } + + @Override + public Resource getResource() { + ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; + if (this.resource != null) { + return this.resource; + } + if (!p.hasResource()) { + return null; + } + this.resource = convertFromProtoFormat(p.getResource()); + return this.resource; + } + + @Override + public void setResource(Resource resource) { + maybeInitBuilder(); + if (resource == null) { + builder.clearResource(); + } + this.resource = resource; + } + + private PriorityPBImpl convertFromProtoFormat(PriorityProto p) { + return new PriorityPBImpl(p); + } + + private PriorityProto convertToProtoFormat(Priority t) { + return ((PriorityPBImpl)t).getProto(); + } + + private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { + return new ApplicationIdPBImpl(p); + } + + private ApplicationIdProto convertToProtoFormat(ApplicationId t) { + return ((ApplicationIdPBImpl)t).getProto(); + } + + private ContainerLaunchContextPBImpl convertFromProtoFormat( + ContainerLaunchContextProto p) { + return new ContainerLaunchContextPBImpl(p); + } + + private ContainerLaunchContextProto convertToProtoFormat(ContainerLaunchContext t) { + return ((ContainerLaunchContextPBImpl)t).getProto(); + } + + private ResourcePBImpl convertFromProtoFormat(ResourceProto p) { + return new ResourcePBImpl(p); + } + + private ResourceProto convertToProtoFormat(Resource t) { + return ((ResourcePBImpl)t).getProto(); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerIdPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerIdPBImpl.java new file mode 100644 index 0000000..9be829f --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerIdPBImpl.java @@ -0,0 +1,92 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; + +import com.google.common.base.Preconditions; + +@Private +@Unstable +public class ContainerIdPBImpl extends ContainerId { + ContainerIdProto proto = null; + ContainerIdProto.Builder builder = null; + private ApplicationAttemptId applicationAttemptId = null; + + public ContainerIdPBImpl() { + builder = ContainerIdProto.newBuilder(); + } + + public ContainerIdPBImpl(ContainerIdProto proto) { + this.proto = proto; + this.applicationAttemptId = convertFromProtoFormat(proto.getAppAttemptId()); + } + + public ContainerIdProto getProto() { + return proto; + } + + @Override + public int getId() { + Preconditions.checkNotNull(proto); + return proto.getId(); + } + + @Override + protected void setId(int id) { + Preconditions.checkNotNull(builder); + builder.setId((id)); + } + + + @Override + public ApplicationAttemptId getApplicationAttemptId() { + return this.applicationAttemptId; + } + + @Override + protected void setApplicationAttemptId(ApplicationAttemptId atId) { + if (atId != null) { + Preconditions.checkNotNull(builder); + builder.setAppAttemptId(convertToProtoFormat(atId)); + } + this.applicationAttemptId = atId; + } + + private ApplicationAttemptIdPBImpl convertFromProtoFormat( + ApplicationAttemptIdProto p) { + return new ApplicationAttemptIdPBImpl(p); + } + + private ApplicationAttemptIdProto convertToProtoFormat( + ApplicationAttemptId t) { + return ((ApplicationAttemptIdPBImpl)t).getProto(); + } + + @Override + protected void build() { + proto = builder.build(); + builder = null; + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.java new file mode 100644 index 0000000..02e0d3b --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.java @@ -0,0 +1,465 @@ +/** +* 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. +*/ +package org.apache.hadoop.yarn.api.records.impl.pb; + + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ApplicationAccessType; +import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; +import org.apache.hadoop.yarn.api.records.LocalResource; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto; +import org.apache.hadoop.yarn.proto.YarnProtos.StringBytesMapProto; +import org.apache.hadoop.yarn.proto.YarnProtos.StringLocalResourceMapProto; +import org.apache.hadoop.yarn.proto.YarnProtos.StringStringMapProto; + +import com.google.protobuf.ByteString; + +@Private +@Unstable +public class ContainerLaunchContextPBImpl +extends ContainerLaunchContext { + ContainerLaunchContextProto proto = + ContainerLaunchContextProto.getDefaultInstance(); + ContainerLaunchContextProto.Builder builder = null; + boolean viaProto = false; + + private Map localResources = null; + private ByteBuffer tokens = null; + private Map serviceData = null; + private Map environment = null; + private List commands = null; + private Map applicationACLS = null; + + public ContainerLaunchContextPBImpl() { + builder = ContainerLaunchContextProto.newBuilder(); + } + + public ContainerLaunchContextPBImpl(ContainerLaunchContextProto proto) { + this.proto = proto; + viaProto = true; + } + + public ContainerLaunchContextProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + protected final ByteBuffer convertFromProtoFormat(ByteString byteString) { + return ProtoUtils.convertFromProtoFormat(byteString); + } + + protected final ByteString convertToProtoFormat(ByteBuffer byteBuffer) { + return ProtoUtils.convertToProtoFormat(byteBuffer); + } + + private void mergeLocalToBuilder() { + if (this.localResources != null) { + addLocalResourcesToProto(); + } + if (this.tokens != null) { + builder.setTokens(convertToProtoFormat(this.tokens)); + } + if (this.serviceData != null) { + addServiceDataToProto(); + } + if (this.environment != null) { + addEnvToProto(); + } + if (this.commands != null) { + addCommandsToProto(); + } + if (this.applicationACLS != null) { + addApplicationACLs(); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = ContainerLaunchContextProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public List getCommands() { + initCommands(); + return this.commands; + } + + private void initCommands() { + if (this.commands != null) { + return; + } + ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getCommandList(); + this.commands = new ArrayList(); + + for (String c : list) { + this.commands.add(c); + } + } + + @Override + public void setCommands(final List commands) { + if (commands == null) + return; + initCommands(); + this.commands.clear(); + this.commands.addAll(commands); + } + + private void addCommandsToProto() { + maybeInitBuilder(); + builder.clearCommand(); + if (this.commands == null) + return; + builder.addAllCommand(this.commands); + } + + @Override + public Map getLocalResources() { + initLocalResources(); + return this.localResources; + } + + private void initLocalResources() { + if (this.localResources != null) { + return; + } + ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getLocalResourcesList(); + this.localResources = new HashMap(); + + for (StringLocalResourceMapProto c : list) { + this.localResources.put(c.getKey(), convertFromProtoFormat(c.getValue())); + } + } + + @Override + public void setLocalResources( + final Map localResources) { + if (localResources == null) + return; + initLocalResources(); + this.localResources.clear(); + this.localResources.putAll(localResources); + } + + private void addLocalResourcesToProto() { + maybeInitBuilder(); + builder.clearLocalResources(); + if (localResources == null) + return; + Iterable iterable = + new Iterable() { + + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator keyIter = localResources.keySet().iterator(); + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + @Override + public StringLocalResourceMapProto next() { + String key = keyIter.next(); + return StringLocalResourceMapProto.newBuilder().setKey(key). + setValue(convertToProtoFormat(localResources.get(key))).build(); + } + + @Override + public boolean hasNext() { + return keyIter.hasNext(); + } + }; + } + }; + builder.addAllLocalResources(iterable); + } + + @Override + public ByteBuffer getTokens() { + ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; + if (this.tokens != null) { + return this.tokens; + } + if (!p.hasTokens()) { + return null; + } + this.tokens = convertFromProtoFormat(p.getTokens()); + return this.tokens; + } + + @Override + public void setTokens(ByteBuffer tokens) { + maybeInitBuilder(); + if (tokens == null) { + builder.clearTokens(); + } + this.tokens = tokens; + } + + @Override + public Map getServiceData() { + initServiceData(); + return this.serviceData; + } + + private void initServiceData() { + if (this.serviceData != null) { + return; + } + ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getServiceDataList(); + this.serviceData = new HashMap(); + + for (StringBytesMapProto c : list) { + this.serviceData.put(c.getKey(), convertFromProtoFormat(c.getValue())); + } + } + + @Override + public void setServiceData(final Map serviceData) { + if (serviceData == null) + return; + initServiceData(); + this.serviceData.putAll(serviceData); + } + + private void addServiceDataToProto() { + maybeInitBuilder(); + builder.clearServiceData(); + if (serviceData == null) + return; + Iterable iterable = + new Iterable() { + + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator keyIter = serviceData.keySet().iterator(); + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + @Override + public StringBytesMapProto next() { + String key = keyIter.next(); + return StringBytesMapProto.newBuilder().setKey(key).setValue( + convertToProtoFormat(serviceData.get(key))).build(); + } + + @Override + public boolean hasNext() { + return keyIter.hasNext(); + } + }; + } + }; + builder.addAllServiceData(iterable); + } + + @Override + public Map getEnvironment() { + initEnv(); + return this.environment; + } + + private void initEnv() { + if (this.environment != null) { + return; + } + ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getEnvironmentList(); + this.environment = new HashMap(); + + for (StringStringMapProto c : list) { + this.environment.put(c.getKey(), c.getValue()); + } + } + + @Override + public void setEnvironment(final Map env) { + if (env == null) + return; + initEnv(); + this.environment.clear(); + this.environment.putAll(env); + } + + private void addEnvToProto() { + maybeInitBuilder(); + builder.clearEnvironment(); + if (environment == null) + return; + Iterable iterable = + new Iterable() { + + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator keyIter = environment.keySet().iterator(); + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + @Override + public StringStringMapProto next() { + String key = keyIter.next(); + return StringStringMapProto.newBuilder().setKey(key).setValue( + (environment.get(key))).build(); + } + + @Override + public boolean hasNext() { + return keyIter.hasNext(); + } + }; + } + }; + builder.addAllEnvironment(iterable); + } + + @Override + public Map getApplicationACLs() { + initApplicationACLs(); + return this.applicationACLS; + } + + private void initApplicationACLs() { + if (this.applicationACLS != null) { + return; + } + ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getApplicationACLsList(); + this.applicationACLS = new HashMap(list + .size()); + + for (ApplicationACLMapProto aclProto : list) { + this.applicationACLS.put(ProtoUtils.convertFromProtoFormat(aclProto + .getAccessType()), aclProto.getAcl()); + } + } + + private void addApplicationACLs() { + maybeInitBuilder(); + builder.clearApplicationACLs(); + if (applicationACLS == null) { + return; + } + Iterable values + = new Iterable() { + + @Override + public Iterator iterator() { + return new Iterator() { + Iterator aclsIterator = applicationACLS + .keySet().iterator(); + + @Override + public boolean hasNext() { + return aclsIterator.hasNext(); + } + + @Override + public ApplicationACLMapProto next() { + ApplicationAccessType key = aclsIterator.next(); + return ApplicationACLMapProto.newBuilder().setAcl( + applicationACLS.get(key)).setAccessType( + ProtoUtils.convertToProtoFormat(key)).build(); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + }; + this.builder.addAllApplicationACLs(values); + } + + @Override + public void setApplicationACLs( + final Map appACLs) { + if (appACLs == null) + return; + initApplicationACLs(); + this.applicationACLS.clear(); + this.applicationACLS.putAll(appACLs); + } + + private LocalResourcePBImpl convertFromProtoFormat(LocalResourceProto p) { + return new LocalResourcePBImpl(p); + } + + private LocalResourceProto convertToProtoFormat(LocalResource t) { + return ((LocalResourcePBImpl)t).getProto(); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java new file mode 100644 index 0000000..1700068 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java @@ -0,0 +1,317 @@ +/** +* 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. +*/ + +package org.apache.hadoop.yarn.api.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; +import org.apache.hadoop.yarn.api.records.Container; +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.NodeId; +import org.apache.hadoop.yarn.api.records.Priority; +import org.apache.hadoop.yarn.api.records.Resource; +import org.apache.hadoop.yarn.api.records.Token; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; + +@Private +@Unstable +public class ContainerPBImpl extends Container { + + ContainerProto proto = ContainerProto.getDefaultInstance(); + ContainerProto.Builder builder = null; + boolean viaProto = false; + + private ContainerId containerId = null; + private NodeId nodeId = null; + private Resource resource = null; + private Priority priority = null; + private Token containerToken = null; + + public ContainerPBImpl() { + builder = ContainerProto.newBuilder(); + } + + public ContainerPBImpl(ContainerProto proto) { + this.proto = proto; + viaProto = true; + } + + public ContainerProto getProto() { + + mergeLocalToProto(); + 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; + } + + private void mergeLocalToBuilder() { + if (this.containerId != null + && !((ContainerIdPBImpl) containerId).getProto().equals( + builder.getId())) { + builder.setId(convertToProtoFormat(this.containerId)); + } + if (this.nodeId != null + && !((NodeIdPBImpl) nodeId).getProto().equals( + builder.getNodeId())) { + builder.setNodeId(convertToProtoFormat(this.nodeId)); + } + if (this.resource != null + && !((ResourcePBImpl) this.resource).getProto().equals( + builder.getResource())) { + builder.setResource(convertToProtoFormat(this.resource)); + } + if (this.priority != null && + !((PriorityPBImpl) this.priority).getProto().equals( + builder.getPriority())) { + builder.setPriority(convertToProtoFormat(this.priority)); + } + if (this.containerToken != null + && !((TokenPBImpl) this.containerToken).getProto().equals( + builder.getContainerToken())) { + builder.setContainerToken(convertToProtoFormat(this.containerToken)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = ContainerProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public ContainerId getId() { + ContainerProtoOrBuilder p = viaProto ? proto : builder; + if (this.containerId != null) { + return this.containerId; + } + if (!p.hasId()) { + return null; + } + this.containerId = convertFromProtoFormat(p.getId()); + return this.containerId; + } + + @Override + public void setNodeId(NodeId nodeId) { + maybeInitBuilder(); + if (nodeId == null) + builder.clearNodeId(); + this.nodeId = nodeId; + } + + @Override + public NodeId getNodeId() { + ContainerProtoOrBuilder p = viaProto ? proto : builder; + if (this.nodeId != null) { + return this.nodeId; + } + if (!p.hasNodeId()) { + return null; + } + this.nodeId = convertFromProtoFormat(p.getNodeId()); + return this.nodeId; + } + + @Override + public void setId(ContainerId id) { + maybeInitBuilder(); + if (id == null) + builder.clearId(); + this.containerId = id; + } + + @Override + public String getNodeHttpAddress() { + ContainerProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasNodeHttpAddress()) { + return null; + } + return (p.getNodeHttpAddress()); + } + + @Override + public void setNodeHttpAddress(String nodeHttpAddress) { + maybeInitBuilder(); + if (nodeHttpAddress == null) { + builder.clearNodeHttpAddress(); + return; + } + builder.setNodeHttpAddress(nodeHttpAddress); + } + + @Override + public Resource getResource() { + ContainerProtoOrBuilder p = viaProto ? proto : builder; + if (this.resource != null) { + return this.resource; + } + if (!p.hasResource()) { + return null; + } + this.resource = convertFromProtoFormat(p.getResource()); + return this.resource; + } + + @Override + public void setResource(Resource resource) { + maybeInitBuilder(); + if (resource == null) + builder.clearResource(); + this.resource = resource; + } + + @Override + public Priority getPriority() { + ContainerProtoOrBuilder p = viaProto ? proto : builder; + if (this.priority != null) { + return this.priority; + } + if (!p.hasPriority()) { + return null; + } + this.priority = convertFromProtoFormat(p.getPriority()); + return this.priority; + } + + @Override + public void setPriority(Priority priority) { + maybeInitBuilder(); + if (priority == null) { + builder.clearPriority(); + } + this.priority = priority; + } + + @Override + public Token getContainerToken() { + ContainerProtoOrBuilder p = viaProto ? proto : builder; + if (this.containerToken != null) { + return this.containerToken; + } + if (!p.hasContainerToken()) { + return null; + } + this.containerToken = convertFromProtoFormat(p.getContainerToken()); + return this.containerToken; + } + + @Override + public void setContainerToken(Token containerToken) { + maybeInitBuilder(); + if (containerToken == null) + builder.clearContainerToken(); + this.containerToken = containerToken; + } + + private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { + return new ContainerIdPBImpl(p); + } + + private NodeIdPBImpl convertFromProtoFormat(NodeIdProto p) { + return new NodeIdPBImpl(p); + } + + private ContainerIdProto convertToProtoFormat(ContainerId t) { + return ((ContainerIdPBImpl)t).getProto(); + } + + private NodeIdProto convertToProtoFormat(NodeId t) { + return ((NodeIdPBImpl)t).getProto(); + } + + private ResourcePBImpl convertFromProtoFormat(ResourceProto p) { + return new ResourcePBImpl(p); + } + + private ResourceProto convertToProtoFormat(Resource t) { + return ((ResourcePBImpl)t).getProto(); + } + + private PriorityPBImpl convertFromProtoFormat(PriorityProto p) { + return new PriorityPBImpl(p); + } + + private PriorityProto convertToProtoFormat(Priority p) { + return ((PriorityPBImpl)p).getProto(); + } + + private TokenPBImpl convertFromProtoFormat(TokenProto p) { + return new TokenPBImpl(p); + } + + private TokenProto convertToProtoFormat(Token t) { + return ((TokenPBImpl)t).getProto(); + } + + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Container: ["); + sb.append("ContainerId: ").append(getId()).append(", "); + sb.append("NodeId: ").append(getNodeId()).append(", "); + sb.append("NodeHttpAddress: ").append(getNodeHttpAddress()).append(", "); + sb.append("Resource: ").append(getResource()).append(", "); + sb.append("Priority: ").append(getPriority()).append(", "); + sb.append("Token: ").append(getContainerToken()).append(", "); + sb.append("]"); + return sb.toString(); + } + + //TODO Comparator + @Override + public int compareTo(Container other) { + if (this.getId().compareTo(other.getId()) == 0) { + if (this.getNodeId().compareTo(other.getNodeId()) == 0) { + return this.getResource().compareTo(other.getResource()); + } else { + return this.getNodeId().compareTo(other.getNodeId()); + } + } else { + return this.getId().compareTo(other.getId()); + } + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java new file mode 100644 index 0000000..a52ae4c --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java @@ -0,0 +1,180 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.ContainerState; +import org.apache.hadoop.yarn.api.records.ContainerStatus; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProtoOrBuilder; + +@Private +@Unstable +public class ContainerStatusPBImpl extends ContainerStatus { + ContainerStatusProto proto = ContainerStatusProto.getDefaultInstance(); + ContainerStatusProto.Builder builder = null; + boolean viaProto = false; + + private ContainerId containerId = null; + + + public ContainerStatusPBImpl() { + builder = ContainerStatusProto.newBuilder(); + } + + public ContainerStatusPBImpl(ContainerStatusProto proto) { + this.proto = proto; + viaProto = true; + } + + public ContainerStatusProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (containerId != null) { + builder.setContainerId(convertToProtoFormat(this.containerId)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = ContainerStatusProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public ContainerState getState() { + ContainerStatusProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasState()) { + return null; + } + return convertFromProtoFormat(p.getState()); + } + + @Override + public void setState(ContainerState state) { + maybeInitBuilder(); + if (state == null) { + builder.clearState(); + return; + } + builder.setState(convertToProtoFormat(state)); + } + @Override + public ContainerId getContainerId() { + ContainerStatusProtoOrBuilder p = viaProto ? proto : builder; + if (this.containerId != null) { + return this.containerId; + } + if (!p.hasContainerId()) { + return null; + } + this.containerId = convertFromProtoFormat(p.getContainerId()); + return this.containerId; + } + + @Override + public void setContainerId(ContainerId containerId) { + maybeInitBuilder(); + if (containerId == null) + builder.clearContainerId(); + this.containerId = containerId; + } + @Override + public int getExitStatus() { + ContainerStatusProtoOrBuilder p = viaProto ? proto : builder; + return p.getExitStatus(); + } + + @Override + public void setExitStatus(int exitStatus) { + maybeInitBuilder(); + builder.setExitStatus(exitStatus); + } + + @Override + public String getDiagnostics() { + ContainerStatusProtoOrBuilder p = viaProto ? proto : builder; + return (p.getDiagnostics()); + } + + @Override + public void setDiagnostics(String diagnostics) { + maybeInitBuilder(); + builder.setDiagnostics(diagnostics); + } + + private ContainerStateProto convertToProtoFormat(ContainerState e) { + return ProtoUtils.convertToProtoFormat(e); + } + + private ContainerState convertFromProtoFormat(ContainerStateProto e) { + return ProtoUtils.convertFromProtoFormat(e); + } + + private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { + return new ContainerIdPBImpl(p); + } + + private ContainerIdProto convertToProtoFormat(ContainerId t) { + return ((ContainerIdPBImpl)t).getProto(); + } + + + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/LocalResourcePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/LocalResourcePBImpl.java new file mode 100644 index 0000000..d2caf0b --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/LocalResourcePBImpl.java @@ -0,0 +1,216 @@ +/** +* 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. +*/ +package org.apache.hadoop.yarn.api.records.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.LocalResource; +import org.apache.hadoop.yarn.api.records.LocalResourceType; +import org.apache.hadoop.yarn.api.records.LocalResourceVisibility; +import org.apache.hadoop.yarn.api.records.URL; +import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto; +import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceTypeProto; +import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceVisibilityProto; +import org.apache.hadoop.yarn.proto.YarnProtos.URLProto; + +@Private +@Unstable +public class LocalResourcePBImpl extends LocalResource { + LocalResourceProto proto = LocalResourceProto.getDefaultInstance(); + LocalResourceProto.Builder builder = null; + boolean viaProto = false; + + private URL url = null; + + public LocalResourcePBImpl() { + builder = LocalResourceProto.newBuilder(); + } + + public LocalResourcePBImpl(LocalResourceProto proto) { + this.proto = proto; + viaProto = true; + } + + public synchronized LocalResourceProto getProto() { + mergeLocalToBuilder(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private synchronized void mergeLocalToBuilder() { + LocalResourceProtoOrBuilder l = viaProto ? proto : builder; + if (this.url != null + && !(l.getResource().equals(((URLPBImpl) url).getProto()))) { + maybeInitBuilder(); + l = builder; + builder.setResource(convertToProtoFormat(this.url)); + } + } + + private synchronized void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = LocalResourceProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public synchronized long getSize() { + LocalResourceProtoOrBuilder p = viaProto ? proto : builder; + return (p.getSize()); + } + + @Override + public synchronized void setSize(long size) { + maybeInitBuilder(); + builder.setSize((size)); + } + @Override + public synchronized long getTimestamp() { + LocalResourceProtoOrBuilder p = viaProto ? proto : builder; + return (p.getTimestamp()); + } + + @Override + public synchronized void setTimestamp(long timestamp) { + maybeInitBuilder(); + builder.setTimestamp((timestamp)); + } + @Override + public synchronized LocalResourceType getType() { + LocalResourceProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasType()) { + return null; + } + return convertFromProtoFormat(p.getType()); + } + + @Override + public synchronized void setType(LocalResourceType type) { + maybeInitBuilder(); + if (type == null) { + builder.clearType(); + return; + } + builder.setType(convertToProtoFormat(type)); + } + @Override + public synchronized URL getResource() { + LocalResourceProtoOrBuilder p = viaProto ? proto : builder; + if (this.url != null) { + return this.url; + } + if (!p.hasResource()) { + return null; + } + this.url = convertFromProtoFormat(p.getResource()); + return this.url; + } + + @Override + public synchronized void setResource(URL resource) { + maybeInitBuilder(); + if (resource == null) + builder.clearResource(); + this.url = resource; + } + @Override + public synchronized LocalResourceVisibility getVisibility() { + LocalResourceProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasVisibility()) { + return null; + } + return convertFromProtoFormat(p.getVisibility()); + } + + @Override + public synchronized void setVisibility(LocalResourceVisibility visibility) { + maybeInitBuilder(); + if (visibility == null) { + builder.clearVisibility(); + return; + } + builder.setVisibility(convertToProtoFormat(visibility)); + } + + @Override + public synchronized String getPattern() { + LocalResourceProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasPattern()) { + return null; + } + return p.getPattern(); + } + + @Override + public synchronized void setPattern(String pattern) { + maybeInitBuilder(); + if (pattern == null) { + builder.clearPattern(); + return; + } + builder.setPattern(pattern); + } + + private LocalResourceTypeProto convertToProtoFormat(LocalResourceType e) { + return ProtoUtils.convertToProtoFormat(e); + } + + private LocalResourceType convertFromProtoFormat(LocalResourceTypeProto e) { + return ProtoUtils.convertFromProtoFormat(e); + } + + private URLPBImpl convertFromProtoFormat(URLProto p) { + return new URLPBImpl(p); + } + + private URLProto convertToProtoFormat(URL t) { + return ((URLPBImpl)t).getProto(); + } + + private LocalResourceVisibilityProto convertToProtoFormat(LocalResourceVisibility e) { + return ProtoUtils.convertToProtoFormat(e); + } + + private LocalResourceVisibility convertFromProtoFormat(LocalResourceVisibilityProto e) { + return ProtoUtils.convertFromProtoFormat(e); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NMTokenPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NMTokenPBImpl.java new file mode 100644 index 0000000..bcbf0a3 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NMTokenPBImpl.java @@ -0,0 +1,142 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; +import org.apache.hadoop.yarn.api.records.NMToken; +import org.apache.hadoop.yarn.api.records.NodeId; +import org.apache.hadoop.yarn.api.records.Token; +import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.NMTokenProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.NMTokenProtoOrBuilder; + +@Private +@Unstable +public class NMTokenPBImpl extends NMToken{ + + NMTokenProto proto = NMTokenProto.getDefaultInstance(); + NMTokenProto.Builder builder = null; + boolean viaProto = false; + + private Token token = null; + private NodeId nodeId = null; + + public NMTokenPBImpl() { + builder = NMTokenProto.newBuilder(); + } + + public NMTokenPBImpl(NMTokenProto proto) { + this.proto = proto; + viaProto = true; + } + + @Override + public synchronized NodeId getNodeId() { + NMTokenProtoOrBuilder p = viaProto ? proto : builder; + if (this.nodeId != null) { + return nodeId; + } + if (!p.hasNodeId()) { + return null; + } + this.nodeId = convertFromProtoFormat(p.getNodeId()); + return nodeId; + } + + @Override + public synchronized void setNodeId(NodeId nodeId) { + maybeInitBuilder(); + if (nodeId == null) { + builder.clearNodeId(); + } + this.nodeId = nodeId; + } + + @Override + public synchronized Token getToken() { + NMTokenProtoOrBuilder p = viaProto ? proto : builder; + if (this.token != null) { + return this.token; + } + if (!p.hasToken()) { + return null; + } + this.token = convertFromProtoFormat(p.getToken()); + return token; + } + + @Override + public synchronized void setToken(Token token) { + maybeInitBuilder(); + if (token == null) { + builder.clearToken(); + } + this.token = token; + } + + public synchronized NMTokenProto getProto() { + mergeLocalToProto(); + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private synchronized void mergeLocalToProto() { + if (viaProto) { + maybeInitBuilder(); + } + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private synchronized void mergeLocalToBuilder() { + if (this.nodeId != null) { + builder.setNodeId(convertToProtoFormat(nodeId)); + } + if (this.token != null) { + builder.setToken(convertToProtoFormat(token)); + } + } + + private synchronized void maybeInitBuilder() { + if(viaProto || builder == null) { + builder = NMTokenProto.newBuilder(proto); + } + viaProto = false; + } + + private synchronized NodeId convertFromProtoFormat(NodeIdProto p) { + return new NodeIdPBImpl(p); + } + + private synchronized NodeIdProto convertToProtoFormat(NodeId nodeId) { + return ((NodeIdPBImpl)nodeId).getProto(); + } + + private synchronized TokenProto convertToProtoFormat(Token token) { + return ((TokenPBImpl)token).getProto(); + } + + private synchronized Token convertFromProtoFormat(TokenProto proto) { + return new TokenPBImpl(proto); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeIdPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeIdPBImpl.java new file mode 100644 index 0000000..4c725fa --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeIdPBImpl.java @@ -0,0 +1,76 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.NodeId; +import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; + +import com.google.common.base.Preconditions; + +@Private +@Unstable +public class NodeIdPBImpl extends NodeId { + NodeIdProto proto = null; + NodeIdProto.Builder builder = null; + + public NodeIdPBImpl() { + builder = NodeIdProto.newBuilder(); + } + + public NodeIdPBImpl(NodeIdProto proto) { + this.proto = proto; + } + + public NodeIdProto getProto() { + return proto; + } + + @Override + public String getHost() { + Preconditions.checkNotNull(proto); + return proto.getHost(); + } + + @Override + protected void setHost(String host) { + Preconditions.checkNotNull(builder); + builder.setHost(host); + } + + @Override + public int getPort() { + Preconditions.checkNotNull(proto); + return proto.getPort(); + } + + @Override + protected void setPort(int port) { + Preconditions.checkNotNull(builder); + builder.setPort(port); + } + + @Override + protected void build() { + proto = builder.build(); + builder = null; + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeReportPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeReportPBImpl.java new file mode 100644 index 0000000..e1a66d7 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeReportPBImpl.java @@ -0,0 +1,290 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.NodeId; +import org.apache.hadoop.yarn.api.records.NodeReport; +import org.apache.hadoop.yarn.api.records.NodeState; +import org.apache.hadoop.yarn.api.records.Resource; +import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.NodeReportProto; +import org.apache.hadoop.yarn.proto.YarnProtos.NodeReportProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; + +@Private +@Unstable +public class NodeReportPBImpl extends NodeReport { + + private NodeReportProto proto = NodeReportProto.getDefaultInstance(); + private NodeReportProto.Builder builder = null; + private boolean viaProto = false; + private NodeId nodeId; + private Resource used; + private Resource capability; + + public NodeReportPBImpl() { + builder = NodeReportProto.newBuilder(); + } + + public NodeReportPBImpl(NodeReportProto proto) { + this.proto = proto; + viaProto = true; + } + + @Override + public Resource getCapability() { + if (this.capability != null) { + return this.capability; + } + + NodeReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasCapability()) { + return null; + } + this.capability = convertFromProtoFormat(p.getCapability()); + return this.capability; + } + + @Override + public String getHealthReport() { + NodeReportProtoOrBuilder p = viaProto ? proto : builder; + return p.getHealthReport(); + } + + @Override + public void setHealthReport(String healthReport) { + maybeInitBuilder(); + if (healthReport == null) { + builder.clearHealthReport(); + return; + } + builder.setHealthReport(healthReport); + } + + @Override + public long getLastHealthReportTime() { + NodeReportProtoOrBuilder p = viaProto ? proto : builder; + return p.getLastHealthReportTime(); + } + + @Override + public void setLastHealthReportTime(long lastHealthReportTime) { + maybeInitBuilder(); + builder.setLastHealthReportTime(lastHealthReportTime); + } + + @Override + public String getHttpAddress() { + NodeReportProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasHttpAddress()) ? p.getHttpAddress() : null; + } + + @Override + public int getNumContainers() { + NodeReportProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasNumContainers()) ? p.getNumContainers() : 0; + } + + @Override + public String getRackName() { + NodeReportProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasRackName()) ? p.getRackName() : null; + } + + @Override + public Resource getUsed() { + if (this.used != null) { + return this.used; + } + + NodeReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasUsed()) { + return null; + } + this.used = convertFromProtoFormat(p.getUsed()); + return this.used; + } + + @Override + public NodeId getNodeId() { + if (this.nodeId != null) { + return this.nodeId; + } + + NodeReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasNodeId()) { + return null; + } + this.nodeId = convertFromProtoFormat(p.getNodeId()); + return this.nodeId; + } + + @Override + public void setNodeId(NodeId nodeId) { + maybeInitBuilder(); + if (nodeId == null) + builder.clearNodeId(); + this.nodeId = nodeId; + } + + @Override + public NodeState getNodeState() { + NodeReportProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasNodeState()) { + return null; + } + return ProtoUtils.convertFromProtoFormat(p.getNodeState()); + } + + @Override + public void setNodeState(NodeState nodeState) { + maybeInitBuilder(); + if (nodeState == null) { + builder.clearNodeState(); + return; + } + builder.setNodeState(ProtoUtils.convertToProtoFormat(nodeState)); + } + + @Override + public void setCapability(Resource capability) { + maybeInitBuilder(); + if (capability == null) + builder.clearCapability(); + this.capability = capability; + } + + @Override + public void setHttpAddress(String httpAddress) { + maybeInitBuilder(); + if (httpAddress == null) { + builder.clearHttpAddress(); + return; + } + builder.setHttpAddress(httpAddress); + } + + @Override + public void setNumContainers(int numContainers) { + maybeInitBuilder(); + if (numContainers == 0) { + builder.clearNumContainers(); + return; + } + builder.setNumContainers(numContainers); + } + + @Override + public void setRackName(String rackName) { + maybeInitBuilder(); + if (rackName == null) { + builder.clearRackName(); + return; + } + builder.setRackName(rackName); + } + + @Override + public void setUsed(Resource used) { + maybeInitBuilder(); + if (used == null) + builder.clearUsed(); + this.used = used; + } + + public NodeReportProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToBuilder() { + if (this.nodeId != null + && !((NodeIdPBImpl) this.nodeId).getProto().equals( + builder.getNodeId())) { + builder.setNodeId(convertToProtoFormat(this.nodeId)); + } + if (this.used != null + && !((ResourcePBImpl) this.used).getProto().equals( + builder.getUsed())) { + builder.setUsed(convertToProtoFormat(this.used)); + } + if (this.capability != null + && !((ResourcePBImpl) this.capability).getProto().equals( + builder.getCapability())) { + builder.setCapability(convertToProtoFormat(this.capability)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = NodeReportProto.newBuilder(proto); + } + viaProto = false; + } + + + private NodeIdPBImpl convertFromProtoFormat(NodeIdProto p) { + return new NodeIdPBImpl(p); + } + + private NodeIdProto convertToProtoFormat(NodeId nodeId) { + return ((NodeIdPBImpl) nodeId).getProto(); + } + + private ResourcePBImpl convertFromProtoFormat(ResourceProto p) { + return new ResourcePBImpl(p); + } + + private ResourceProto convertToProtoFormat(Resource r) { + return ((ResourcePBImpl) r).getProto(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionContainerPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionContainerPBImpl.java new file mode 100644 index 0000000..55ead20 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionContainerPBImpl.java @@ -0,0 +1,126 @@ +/** + * 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. + */ +package org.apache.hadoop.yarn.api.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.PreemptionContainer; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionContainerProto; +import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionContainerProtoOrBuilder; + +@Private +@Unstable +public class PreemptionContainerPBImpl extends PreemptionContainer { + + PreemptionContainerProto proto = + PreemptionContainerProto.getDefaultInstance(); + PreemptionContainerProto.Builder builder = null; + + boolean viaProto = false; + private ContainerId id; + + public PreemptionContainerPBImpl() { + builder = PreemptionContainerProto.newBuilder(); + } + + public PreemptionContainerPBImpl(PreemptionContainerProto proto) { + this.proto = proto; + viaProto = true; + } + + public synchronized PreemptionContainerProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void mergeLocalToBuilder() { + if (id != null) { + builder.setId(convertToProtoFormat(id)); + } + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = PreemptionContainerProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public synchronized ContainerId getId() { + PreemptionContainerProtoOrBuilder p = viaProto ? proto : builder; + if (id != null) { + return id; + } + if (!p.hasId()) { + return null; + } + id = convertFromProtoFormat(p.getId()); + return id; + } + + @Override + public synchronized void setId(final ContainerId id) { + maybeInitBuilder(); + if (null == id) { + builder.clearId(); + } + this.id = id; + } + + private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { + return new ContainerIdPBImpl(p); + } + + private ContainerIdProto convertToProtoFormat(ContainerId t) { + return ((ContainerIdPBImpl)t).getProto(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionContractPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionContractPBImpl.java new file mode 100644 index 0000000..07a0af9 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionContractPBImpl.java @@ -0,0 +1,251 @@ +/** + * 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. + */ +package org.apache.hadoop.yarn.api.records.impl.pb; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.PreemptionContainer; +import org.apache.hadoop.yarn.api.records.PreemptionContract; +import org.apache.hadoop.yarn.api.records.PreemptionResourceRequest; +import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionContainerProto; +import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionContractProto; +import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionContractProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionResourceRequestProto; + +@Private +@Unstable +public class PreemptionContractPBImpl extends PreemptionContract { + + PreemptionContractProto proto = PreemptionContractProto.getDefaultInstance(); + PreemptionContractProto.Builder builder = null; + + boolean viaProto = false; + private Set containers; + private List resources; + + public PreemptionContractPBImpl() { + builder = PreemptionContractProto.newBuilder(); + } + + public PreemptionContractPBImpl(PreemptionContractProto proto) { + this.proto = proto; + viaProto = true; + } + + public synchronized PreemptionContractProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void mergeLocalToBuilder() { + if (this.resources != null) { + addResourcesToProto(); + } + if (this.containers != null) { + addContainersToProto(); + } + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = PreemptionContractProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public synchronized Set getContainers() { + initPreemptionContainers(); + return containers; + } + + @Override + public synchronized void setContainers( + final Set containers) { + if (null == containers) { + builder.clearContainer(); + } + this.containers = containers; + } + + @Override + public synchronized List getResourceRequest() { + initPreemptionResourceRequests(); + return resources; + } + + @Override + public synchronized void setResourceRequest( + final List req) { + if (null == resources) { + builder.clearResource(); + } + this.resources = req; + } + + private void initPreemptionResourceRequests() { + if (resources != null) { + return; + } + PreemptionContractProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getResourceList(); + resources = new ArrayList(); + + for (PreemptionResourceRequestProto rr : list) { + resources.add(convertFromProtoFormat(rr)); + } + } + + private void addResourcesToProto() { + maybeInitBuilder(); + builder.clearResource(); + if (null == resources) { + return; + } + Iterable iterable = + new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator iter = resources.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public PreemptionResourceRequestProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + builder.addAllResource(iterable); + } + + private void initPreemptionContainers() { + if (containers != null) { + return; + } + PreemptionContractProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getContainerList(); + containers = new HashSet(); + + for (PreemptionContainerProto c : list) { + containers.add(convertFromProtoFormat(c)); + } + } + + private void addContainersToProto() { + maybeInitBuilder(); + builder.clearContainer(); + if (null == containers) { + return; + } + Iterable iterable = + new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator iter = containers.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public PreemptionContainerProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + builder.addAllContainer(iterable); + } + + private PreemptionContainerPBImpl convertFromProtoFormat(PreemptionContainerProto p) { + return new PreemptionContainerPBImpl(p); + } + + private PreemptionContainerProto convertToProtoFormat(PreemptionContainer t) { + return ((PreemptionContainerPBImpl)t).getProto(); + } + + private PreemptionResourceRequestPBImpl convertFromProtoFormat(PreemptionResourceRequestProto p) { + return new PreemptionResourceRequestPBImpl(p); + } + + private PreemptionResourceRequestProto convertToProtoFormat(PreemptionResourceRequest t) { + return ((PreemptionResourceRequestPBImpl)t).getProto(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionMessagePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionMessagePBImpl.java new file mode 100644 index 0000000..65dc820 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionMessagePBImpl.java @@ -0,0 +1,165 @@ +/** + * 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. + */ +package org.apache.hadoop.yarn.api.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.PreemptionContract; +import org.apache.hadoop.yarn.api.records.PreemptionMessage; +import org.apache.hadoop.yarn.api.records.StrictPreemptionContract; +import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionContractProto; +import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionMessageProto; +import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionMessageProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.StrictPreemptionContractProto; + +@Private +@Unstable +public class PreemptionMessagePBImpl extends PreemptionMessage { + + PreemptionMessageProto proto = PreemptionMessageProto.getDefaultInstance(); + PreemptionMessageProto.Builder builder = null; + + boolean viaProto = false; + private StrictPreemptionContract strict; + private PreemptionContract contract; + + public PreemptionMessagePBImpl() { + builder = PreemptionMessageProto.newBuilder(); + } + + public PreemptionMessagePBImpl(PreemptionMessageProto proto) { + this.proto = proto; + viaProto = true; + } + + public synchronized PreemptionMessageProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void mergeLocalToBuilder() { + if (strict != null) { + builder.setStrictContract(convertToProtoFormat(strict)); + } + if (contract != null) { + builder.setContract(convertToProtoFormat(contract)); + } + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = PreemptionMessageProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public synchronized StrictPreemptionContract getStrictContract() { + PreemptionMessageProtoOrBuilder p = viaProto ? proto : builder; + if (strict != null) { + return strict; + } + if (!p.hasStrictContract()) { + return null; + } + strict = convertFromProtoFormat(p.getStrictContract()); + return strict; + } + + @Override + public synchronized void setStrictContract(StrictPreemptionContract strict) { + maybeInitBuilder(); + if (null == strict) { + builder.clearStrictContract(); + } + this.strict = strict; + } + + @Override + public synchronized PreemptionContract getContract() { + PreemptionMessageProtoOrBuilder p = viaProto ? proto : builder; + if (contract != null) { + return contract; + } + if (!p.hasContract()) { + return null; + } + contract = convertFromProtoFormat(p.getContract()); + return contract; + } + + @Override + public synchronized void setContract(final PreemptionContract c) { + maybeInitBuilder(); + if (null == c) { + builder.clearContract(); + } + this.contract = c; + } + + private StrictPreemptionContractPBImpl convertFromProtoFormat( + StrictPreemptionContractProto p) { + return new StrictPreemptionContractPBImpl(p); + } + + private StrictPreemptionContractProto convertToProtoFormat( + StrictPreemptionContract t) { + return ((StrictPreemptionContractPBImpl)t).getProto(); + } + + private PreemptionContractPBImpl convertFromProtoFormat( + PreemptionContractProto p) { + return new PreemptionContractPBImpl(p); + } + + private PreemptionContractProto convertToProtoFormat( + PreemptionContract t) { + return ((PreemptionContractPBImpl)t).getProto(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionResourceRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionResourceRequestPBImpl.java new file mode 100644 index 0000000..97930c3 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionResourceRequestPBImpl.java @@ -0,0 +1,126 @@ +/** + * 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. + */ +package org.apache.hadoop.yarn.api.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.PreemptionResourceRequest; +import org.apache.hadoop.yarn.api.records.ResourceRequest; +import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionResourceRequestProto; +import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionResourceRequestProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceRequestProto; + +@Private +@Unstable +public class PreemptionResourceRequestPBImpl extends PreemptionResourceRequest { + + PreemptionResourceRequestProto proto = + PreemptionResourceRequestProto.getDefaultInstance(); + PreemptionResourceRequestProto.Builder builder = null; + + boolean viaProto = false; + private ResourceRequest rr; + + public PreemptionResourceRequestPBImpl() { + builder = PreemptionResourceRequestProto.newBuilder(); + } + + public PreemptionResourceRequestPBImpl(PreemptionResourceRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public synchronized PreemptionResourceRequestProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void mergeLocalToBuilder() { + if (rr != null) { + builder.setResource(convertToProtoFormat(rr)); + } + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = PreemptionResourceRequestProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public synchronized ResourceRequest getResourceRequest() { + PreemptionResourceRequestProtoOrBuilder p = viaProto ? proto : builder; + if (rr != null) { + return rr; + } + if (!p.hasResource()) { + return null; + } + rr = convertFromProtoFormat(p.getResource()); + return rr; + } + + @Override + public synchronized void setResourceRequest(final ResourceRequest rr) { + maybeInitBuilder(); + if (null == rr) { + builder.clearResource(); + } + this.rr = rr; + } + + private ResourceRequestPBImpl convertFromProtoFormat(ResourceRequestProto p) { + return new ResourceRequestPBImpl(p); + } + + private ResourceRequestProto convertToProtoFormat(ResourceRequest t) { + return ((ResourceRequestPBImpl)t).getProto(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PriorityPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PriorityPBImpl.java new file mode 100644 index 0000000..c8abdbe --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PriorityPBImpl.java @@ -0,0 +1,74 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.Priority; +import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto; +import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProtoOrBuilder; + +@Private +@Unstable +public class PriorityPBImpl extends Priority { + PriorityProto proto = PriorityProto.getDefaultInstance(); + PriorityProto.Builder builder = null; + boolean viaProto = false; + + public PriorityPBImpl() { + builder = PriorityProto.newBuilder(); + } + + public PriorityPBImpl(PriorityProto proto) { + this.proto = proto; + viaProto = true; + } + + public PriorityProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = PriorityProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public int getPriority() { + PriorityProtoOrBuilder p = viaProto ? proto : builder; + return (p.getPriority()); + } + + @Override + public void setPriority(int priority) { + maybeInitBuilder(); + builder.setPriority((priority)); + } + + @Override + public String toString() { + return Integer.valueOf(getPriority()).toString(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoBase.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoBase.java new file mode 100644 index 0000000..4e8c39b --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoBase.java @@ -0,0 +1,64 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + +import java.nio.ByteBuffer; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; + +import com.google.protobuf.ByteString; +import com.google.protobuf.Message; + +@Private +@Unstable +public abstract class ProtoBase { + + public abstract T getProto(); + + //TODO Force a comparator? + + @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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + protected final ByteBuffer convertFromProtoFormat(ByteString byteString) { + return ProtoUtils.convertFromProtoFormat(byteString); + } + + protected final ByteString convertToProtoFormat(ByteBuffer byteBuffer) { + return ProtoUtils.convertToProtoFormat(byteBuffer); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoUtils.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoUtils.java new file mode 100644 index 0000000..b660f7d --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoUtils.java @@ -0,0 +1,209 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + +import java.nio.ByteBuffer; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.AMCommand; +import org.apache.hadoop.yarn.api.records.ApplicationAccessType; +import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; +import org.apache.hadoop.yarn.api.records.ContainerState; +import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; +import org.apache.hadoop.yarn.api.records.LocalResourceType; +import org.apache.hadoop.yarn.api.records.LocalResourceVisibility; +import org.apache.hadoop.yarn.api.records.NodeId; +import org.apache.hadoop.yarn.api.records.NodeState; +import org.apache.hadoop.yarn.api.records.QueueACL; +import org.apache.hadoop.yarn.api.records.QueueState; +import org.apache.hadoop.yarn.api.records.YarnApplicationState; +import org.apache.hadoop.yarn.proto.YarnProtos.AMCommandProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAccessTypeProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationResourceUsageReportProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto; +import org.apache.hadoop.yarn.proto.YarnProtos.FinalApplicationStatusProto; +import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceTypeProto; +import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceVisibilityProto; +import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.NodeStateProto; +import org.apache.hadoop.yarn.proto.YarnProtos.QueueACLProto; +import org.apache.hadoop.yarn.proto.YarnProtos.QueueStateProto; +import org.apache.hadoop.yarn.proto.YarnProtos.YarnApplicationStateProto; + +import com.google.protobuf.ByteString; + +@Private +@Unstable +public class ProtoUtils { + + + /* + * ContainerState + */ + private static String CONTAINER_STATE_PREFIX = "C_"; + public static ContainerStateProto convertToProtoFormat(ContainerState e) { + return ContainerStateProto.valueOf(CONTAINER_STATE_PREFIX + e.name()); + } + public static ContainerState convertFromProtoFormat(ContainerStateProto e) { + return ContainerState.valueOf(e.name().replace(CONTAINER_STATE_PREFIX, "")); + } + + /* + * NodeState + */ + private static String NODE_STATE_PREFIX = "NS_"; + public static NodeStateProto convertToProtoFormat(NodeState e) { + return NodeStateProto.valueOf(NODE_STATE_PREFIX + e.name()); + } + public static NodeState convertFromProtoFormat(NodeStateProto e) { + return NodeState.valueOf(e.name().replace(NODE_STATE_PREFIX, "")); + } + + /* + * NodeId + */ + public static NodeIdProto convertToProtoFormat(NodeId e) { + return ((NodeIdPBImpl)e).getProto(); + } + public static NodeId convertFromProtoFormat(NodeIdProto e) { + return new NodeIdPBImpl(e); + } + + /* + * YarnApplicationState + */ + public static YarnApplicationStateProto convertToProtoFormat(YarnApplicationState e) { + return YarnApplicationStateProto.valueOf(e.name()); + } + public static YarnApplicationState convertFromProtoFormat(YarnApplicationStateProto e) { + return YarnApplicationState.valueOf(e.name()); + } + + /* + * ApplicationResourceUsageReport + */ + public static ApplicationResourceUsageReportProto convertToProtoFormat(ApplicationResourceUsageReport e) { + return ((ApplicationResourceUsageReportPBImpl)e).getProto(); + } + + public static ApplicationResourceUsageReport convertFromProtoFormat(ApplicationResourceUsageReportProto e) { + return new ApplicationResourceUsageReportPBImpl(e); + } + + /* + * FinalApplicationStatus + */ + private static String FINAL_APPLICATION_STATUS_PREFIX = "APP_"; + public static FinalApplicationStatusProto convertToProtoFormat(FinalApplicationStatus e) { + return FinalApplicationStatusProto.valueOf(FINAL_APPLICATION_STATUS_PREFIX + e.name()); + } + public static FinalApplicationStatus convertFromProtoFormat(FinalApplicationStatusProto e) { + return FinalApplicationStatus.valueOf(e.name().replace(FINAL_APPLICATION_STATUS_PREFIX, "")); + } + + /* + * LocalResourceType + */ + public static LocalResourceTypeProto convertToProtoFormat(LocalResourceType e) { + return LocalResourceTypeProto.valueOf(e.name()); + } + public static LocalResourceType convertFromProtoFormat(LocalResourceTypeProto e) { + return LocalResourceType.valueOf(e.name()); + } + + /* + * LocalResourceVisibility + */ + public static LocalResourceVisibilityProto convertToProtoFormat(LocalResourceVisibility e) { + return LocalResourceVisibilityProto.valueOf(e.name()); + } + public static LocalResourceVisibility convertFromProtoFormat(LocalResourceVisibilityProto e) { + return LocalResourceVisibility.valueOf(e.name()); + } + + /* + * AMCommand + */ + public static AMCommandProto convertToProtoFormat(AMCommand e) { + return AMCommandProto.valueOf(e.name()); + } + public static AMCommand convertFromProtoFormat(AMCommandProto e) { + return AMCommand.valueOf(e.name()); + } + + /* + * ByteBuffer + */ + public static ByteBuffer convertFromProtoFormat(ByteString byteString) { + int capacity = byteString.asReadOnlyByteBuffer().rewind().remaining(); + byte[] b = new byte[capacity]; + byteString.asReadOnlyByteBuffer().get(b, 0, capacity); + return ByteBuffer.wrap(b); + } + + public static ByteString convertToProtoFormat(ByteBuffer byteBuffer) { +// return ByteString.copyFrom((ByteBuffer)byteBuffer.duplicate().rewind()); + int oldPos = byteBuffer.position(); + byteBuffer.rewind(); + ByteString bs = ByteString.copyFrom(byteBuffer); + byteBuffer.position(oldPos); + return bs; + } + + /* + * QueueState + */ + private static String QUEUE_STATE_PREFIX = "Q_"; + public static QueueStateProto convertToProtoFormat(QueueState e) { + return QueueStateProto.valueOf(QUEUE_STATE_PREFIX + e.name()); + } + public static QueueState convertFromProtoFormat(QueueStateProto e) { + return QueueState.valueOf(e.name().replace(QUEUE_STATE_PREFIX, "")); + } + + /* + * QueueACL + */ + private static String QUEUE_ACL_PREFIX = "QACL_"; + public static QueueACLProto convertToProtoFormat(QueueACL e) { + return QueueACLProto.valueOf(QUEUE_ACL_PREFIX + e.name()); + } + public static QueueACL convertFromProtoFormat(QueueACLProto e) { + return QueueACL.valueOf(e.name().replace(QUEUE_ACL_PREFIX, "")); + } + + + /* + * ApplicationAccessType + */ + private static String APP_ACCESS_TYPE_PREFIX = "APPACCESS_"; + + public static ApplicationAccessTypeProto convertToProtoFormat( + ApplicationAccessType e) { + return ApplicationAccessTypeProto.valueOf(APP_ACCESS_TYPE_PREFIX + + e.name()); + } + + public static ApplicationAccessType convertFromProtoFormat( + ApplicationAccessTypeProto e) { + return ApplicationAccessType.valueOf(e.name().replace( + APP_ACCESS_TYPE_PREFIX, "")); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java new file mode 100644 index 0000000..529bd8b --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java @@ -0,0 +1,324 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ApplicationReport; +import org.apache.hadoop.yarn.api.records.QueueInfo; +import org.apache.hadoop.yarn.api.records.QueueState; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationReportProto; +import org.apache.hadoop.yarn.proto.YarnProtos.QueueInfoProto; +import org.apache.hadoop.yarn.proto.YarnProtos.QueueInfoProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.QueueStateProto; + +@Private +@Unstable +public class QueueInfoPBImpl extends QueueInfo { + + QueueInfoProto proto = QueueInfoProto.getDefaultInstance(); + QueueInfoProto.Builder builder = null; + boolean viaProto = false; + + List applicationsList; + List childQueuesList; + + public QueueInfoPBImpl() { + builder = QueueInfoProto.newBuilder(); + } + + public QueueInfoPBImpl(QueueInfoProto proto) { + this.proto = proto; + viaProto = true; + } + + @Override + public List getApplications() { + initLocalApplicationsList(); + return this.applicationsList; + } + + @Override + public float getCapacity() { + QueueInfoProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasCapacity()) ? p.getCapacity() : -1; + } + + @Override + public List getChildQueues() { + initLocalChildQueuesList(); + return this.childQueuesList; + } + + @Override + public float getCurrentCapacity() { + QueueInfoProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasCurrentCapacity()) ? p.getCurrentCapacity() : 0; + } + + @Override + public float getMaximumCapacity() { + QueueInfoProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasMaximumCapacity()) ? p.getMaximumCapacity() : -1; + } + + @Override + public String getQueueName() { + QueueInfoProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasQueueName()) ? p.getQueueName() : null; + } + + @Override + public QueueState getQueueState() { + QueueInfoProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasState()) { + return null; + } + return convertFromProtoFormat(p.getState()); + } + + @Override + public void setApplications(List applications) { + if (applications == null) { + builder.clearApplications(); + } + this.applicationsList = applications; + } + + @Override + public void setCapacity(float capacity) { + maybeInitBuilder(); + builder.setCapacity(capacity); + } + + @Override + public void setChildQueues(List childQueues) { + if (childQueues == null) { + builder.clearChildQueues(); + } + this.childQueuesList = childQueues; + } + + @Override + public void setCurrentCapacity(float currentCapacity) { + maybeInitBuilder(); + builder.setCurrentCapacity(currentCapacity); + } + + @Override + public void setMaximumCapacity(float maximumCapacity) { + maybeInitBuilder(); + builder.setMaximumCapacity(maximumCapacity); + } + + @Override + public void setQueueName(String queueName) { + maybeInitBuilder(); + if (queueName == null) { + builder.clearQueueName(); + return; + } + builder.setQueueName(queueName); + } + + @Override + public void setQueueState(QueueState queueState) { + maybeInitBuilder(); + if (queueState == null) { + builder.clearState(); + return; + } + builder.setState(convertToProtoFormat(queueState)); + } + + public QueueInfoProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void initLocalApplicationsList() { + if (this.applicationsList != null) { + return; + } + QueueInfoProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getApplicationsList(); + applicationsList = new ArrayList(); + + for (ApplicationReportProto a : list) { + applicationsList.add(convertFromProtoFormat(a)); + } + } + + private void addApplicationsToProto() { + maybeInitBuilder(); + builder.clearApplications(); + if (applicationsList == null) + return; + Iterable iterable = new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator iter = applicationsList.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public ApplicationReportProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + builder.addAllApplications(iterable); + } + + private void initLocalChildQueuesList() { + if (this.childQueuesList != null) { + return; + } + QueueInfoProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getChildQueuesList(); + childQueuesList = new ArrayList(); + + for (QueueInfoProto a : list) { + childQueuesList.add(convertFromProtoFormat(a)); + } + } + + private void addChildQueuesInfoToProto() { + maybeInitBuilder(); + builder.clearChildQueues(); + if (childQueuesList == null) + return; + Iterable iterable = new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator iter = childQueuesList.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public QueueInfoProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + builder.addAllChildQueues(iterable); + } + + private void mergeLocalToBuilder() { + if (this.childQueuesList != null) { + addChildQueuesInfoToProto(); + } + if (this.applicationsList != null) { + addApplicationsToProto(); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = QueueInfoProto.newBuilder(proto); + } + viaProto = false; + } + + + private ApplicationReportPBImpl convertFromProtoFormat(ApplicationReportProto a) { + return new ApplicationReportPBImpl(a); + } + + private ApplicationReportProto convertToProtoFormat(ApplicationReport t) { + return ((ApplicationReportPBImpl)t).getProto(); + } + + private QueueInfoPBImpl convertFromProtoFormat(QueueInfoProto a) { + return new QueueInfoPBImpl(a); + } + + private QueueInfoProto convertToProtoFormat(QueueInfo q) { + return ((QueueInfoPBImpl)q).getProto(); + } + + private QueueState convertFromProtoFormat(QueueStateProto q) { + return ProtoUtils.convertFromProtoFormat(q); + } + + private QueueStateProto convertToProtoFormat(QueueState queueState) { + return ProtoUtils.convertToProtoFormat(queueState); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueUserACLInfoPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueUserACLInfoPBImpl.java new file mode 100644 index 0000000..cf48410 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueUserACLInfoPBImpl.java @@ -0,0 +1,185 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.QueueACL; +import org.apache.hadoop.yarn.api.records.QueueUserACLInfo; +import org.apache.hadoop.yarn.proto.YarnProtos.QueueACLProto; +import org.apache.hadoop.yarn.proto.YarnProtos.QueueUserACLInfoProto; +import org.apache.hadoop.yarn.proto.YarnProtos.QueueUserACLInfoProtoOrBuilder; + +@Private +@Unstable +public class QueueUserACLInfoPBImpl extends QueueUserACLInfo { + + QueueUserACLInfoProto proto = QueueUserACLInfoProto.getDefaultInstance(); + QueueUserACLInfoProto.Builder builder = null; + boolean viaProto = false; + + List userAclsList; + + public QueueUserACLInfoPBImpl() { + builder = QueueUserACLInfoProto.newBuilder(); + } + + public QueueUserACLInfoPBImpl(QueueUserACLInfoProto proto) { + this.proto = proto; + viaProto = true; + } + + @Override + public String getQueueName() { + QueueUserACLInfoProtoOrBuilder p = viaProto ? proto : builder; + return (p.hasQueueName()) ? p.getQueueName() : null; + } + + @Override + public List getUserAcls() { + initLocalQueueUserAclsList(); + return this.userAclsList; + } + + @Override + public void setQueueName(String queueName) { + maybeInitBuilder(); + if (queueName == null) { + builder.clearQueueName(); + return; + } + builder.setQueueName(queueName); + } + + @Override + public void setUserAcls(List userAclsList) { + if (userAclsList == null) { + builder.clearUserAcls(); + } + this.userAclsList = userAclsList; + } + + public QueueUserACLInfoProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void initLocalQueueUserAclsList() { + if (this.userAclsList != null) { + return; + } + QueueUserACLInfoProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getUserAclsList(); + userAclsList = new ArrayList(); + + for (QueueACLProto a : list) { + userAclsList.add(convertFromProtoFormat(a)); + } + } + + private void addQueueACLsToProto() { + maybeInitBuilder(); + builder.clearUserAcls(); + if (userAclsList == null) + return; + Iterable iterable = new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator iter = userAclsList.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public QueueACLProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + builder.addAllUserAcls(iterable); + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = QueueUserACLInfoProto.newBuilder(proto); + } + viaProto = false; + } + + private void mergeLocalToBuilder() { + if (this.userAclsList != null) { + addQueueACLsToProto(); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private QueueACL convertFromProtoFormat(QueueACLProto q) { + return ProtoUtils.convertFromProtoFormat(q); + } + + private QueueACLProto convertToProtoFormat(QueueACL queueAcl) { + return ProtoUtils.convertToProtoFormat(queueAcl); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceBlacklistRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceBlacklistRequestPBImpl.java new file mode 100644 index 0000000..96cb139 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceBlacklistRequestPBImpl.java @@ -0,0 +1,163 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ResourceBlacklistRequest; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceBlacklistRequestProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceBlacklistRequestProtoOrBuilder; + +@Private +@Unstable +public class ResourceBlacklistRequestPBImpl extends ResourceBlacklistRequest { + + ResourceBlacklistRequestProto proto = null; + ResourceBlacklistRequestProto.Builder builder = null; + boolean viaProto = false; + + List blacklistAdditions = null; + List blacklistRemovals = null; + + public ResourceBlacklistRequestPBImpl() { + builder = ResourceBlacklistRequestProto.newBuilder(); + } + + public ResourceBlacklistRequestPBImpl(ResourceBlacklistRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public ResourceBlacklistRequestProto getProto() { + mergeLocalToProto(); + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = ResourceBlacklistRequestProto.newBuilder(proto); + } + viaProto = false; + } + + private void mergeLocalToProto() { + if (viaProto) { + maybeInitBuilder(); + } + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void mergeLocalToBuilder() { + if (this.blacklistAdditions != null) { + addBlacklistAdditionsToProto(); + } + if (this.blacklistRemovals != null) { + addBlacklistRemovalsToProto(); + } + } + + private void addBlacklistAdditionsToProto() { + maybeInitBuilder(); + builder.clearBlacklistAdditions(); + if (this.blacklistAdditions == null) { + return; + } + builder.addAllBlacklistAdditions(this.blacklistAdditions); + } + + private void addBlacklistRemovalsToProto() { + maybeInitBuilder(); + builder.clearBlacklistAdditions(); + if (this.blacklistRemovals == null) { + return; + } + builder.addAllBlacklistRemovals(this.blacklistRemovals); + } + + private void initBlacklistAdditions() { + if (this.blacklistAdditions != null) { + return; + } + ResourceBlacklistRequestProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getBlacklistAdditionsList(); + this.blacklistAdditions = new ArrayList(); + this.blacklistAdditions.addAll(list); + } + + private void initBlacklistRemovals() { + if (this.blacklistRemovals != null) { + return; + } + ResourceBlacklistRequestProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getBlacklistRemovalsList(); + this.blacklistRemovals = new ArrayList(); + this.blacklistRemovals.addAll(list); + } + + @Override + public List getBlacklistAdditions() { + initBlacklistAdditions(); + return this.blacklistAdditions; + } + + @Override + public void setBlacklistAdditions(List resourceNames) { + if (resourceNames == null) { + if (this.blacklistAdditions != null) { + this.blacklistAdditions.clear(); + } + return; + } + initBlacklistAdditions(); + this.blacklistAdditions.clear(); + this.blacklistAdditions.addAll(resourceNames); + } + + @Override + public List getBlacklistRemovals() { + initBlacklistRemovals(); + return this.blacklistRemovals; + } + + @Override + public void setBlacklistRemovals(List resourceNames) { + if (resourceNames == null) { + if (this.blacklistRemovals != null) { + this.blacklistRemovals.clear(); + } + return; + } + initBlacklistRemovals(); + this.blacklistRemovals.clear(); + this.blacklistRemovals.addAll(resourceNames); + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourcePBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourcePBImpl.java new file mode 100644 index 0000000..a28c6ed --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourcePBImpl.java @@ -0,0 +1,92 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.Resource; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProtoOrBuilder; + +@Private +@Unstable +public class ResourcePBImpl extends Resource { + ResourceProto proto = ResourceProto.getDefaultInstance(); + ResourceProto.Builder builder = null; + boolean viaProto = false; + + public ResourcePBImpl() { + builder = ResourceProto.newBuilder(); + } + + public ResourcePBImpl(ResourceProto proto) { + this.proto = proto; + viaProto = true; + } + + public ResourceProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = ResourceProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public int getMemory() { + ResourceProtoOrBuilder p = viaProto ? proto : builder; + return (p.getMemory()); + } + + @Override + public void setMemory(int memory) { + maybeInitBuilder(); + builder.setMemory((memory)); + } + + @Override + public int getVirtualCores() { + ResourceProtoOrBuilder p = viaProto ? proto : builder; + return (p.getVirtualCores()); + } + + @Override + public void setVirtualCores(int vCores) { + maybeInitBuilder(); + builder.setVirtualCores((vCores)); + } + + @Override + public int compareTo(Resource other) { + int diff = this.getMemory() - other.getMemory(); + if (diff == 0) { + diff = this.getVirtualCores() - other.getVirtualCores(); + } + return diff; + } + + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceRequestPBImpl.java new file mode 100644 index 0000000..22863ac --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceRequestPBImpl.java @@ -0,0 +1,189 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.Priority; +import org.apache.hadoop.yarn.api.records.Resource; +import org.apache.hadoop.yarn.api.records.ResourceRequest; +import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceRequestProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceRequestProtoOrBuilder; + +@Private +@Unstable +public class ResourceRequestPBImpl extends ResourceRequest { + ResourceRequestProto proto = ResourceRequestProto.getDefaultInstance(); + ResourceRequestProto.Builder builder = null; + boolean viaProto = false; + + private Priority priority = null; + private Resource capability = null; + + + public ResourceRequestPBImpl() { + builder = ResourceRequestProto.newBuilder(); + } + + public ResourceRequestPBImpl(ResourceRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public ResourceRequestProto getProto() { + mergeLocalToProto(); + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private void mergeLocalToBuilder() { + if (this.priority != null) { + builder.setPriority(convertToProtoFormat(this.priority)); + } + if (this.capability != null) { + builder.setCapability(convertToProtoFormat(this.capability)); + } + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = ResourceRequestProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public Priority getPriority() { + ResourceRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.priority != null) { + return this.priority; + } + if (!p.hasPriority()) { + return null; + } + this.priority = convertFromProtoFormat(p.getPriority()); + return this.priority; + } + + @Override + public void setPriority(Priority priority) { + maybeInitBuilder(); + if (priority == null) + builder.clearPriority(); + this.priority = priority; + } + @Override + public String getResourceName() { + ResourceRequestProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasResourceName()) { + return null; + } + return (p.getResourceName()); + } + + @Override + public void setResourceName(String resourceName) { + maybeInitBuilder(); + if (resourceName == null) { + builder.clearResourceName(); + return; + } + builder.setResourceName((resourceName)); + } + @Override + public Resource getCapability() { + ResourceRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.capability != null) { + return this.capability; + } + if (!p.hasCapability()) { + return null; + } + this.capability = convertFromProtoFormat(p.getCapability()); + return this.capability; + } + + @Override + public void setCapability(Resource capability) { + maybeInitBuilder(); + if (capability == null) + builder.clearCapability(); + this.capability = capability; + } + @Override + public int getNumContainers() { + ResourceRequestProtoOrBuilder p = viaProto ? proto : builder; + return (p.getNumContainers()); + } + + @Override + public void setNumContainers(int numContainers) { + maybeInitBuilder(); + builder.setNumContainers((numContainers)); + } + + @Override + public boolean getRelaxLocality() { + ResourceRequestProtoOrBuilder p = viaProto ? proto : builder; + return p.getRelaxLocality(); + } + + @Override + public void setRelaxLocality(boolean relaxLocality) { + maybeInitBuilder(); + builder.setRelaxLocality(relaxLocality); + } + + private PriorityPBImpl convertFromProtoFormat(PriorityProto p) { + return new PriorityPBImpl(p); + } + + private PriorityProto convertToProtoFormat(Priority t) { + return ((PriorityPBImpl)t).getProto(); + } + + private ResourcePBImpl convertFromProtoFormat(ResourceProto p) { + return new ResourcePBImpl(p); + } + + private ResourceProto convertToProtoFormat(Resource t) { + return ((ResourcePBImpl)t).getProto(); + } + + @Override + public String toString() { + return "{Priority: " + getPriority() + ", Capability: " + getCapability() + + ", # Containers: " + getNumContainers() + + ", Location: " + getResourceName() + + ", Relax Locality: " + getRelaxLocality() + "}"; + } +} \ No newline at end of file diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/StrictPreemptionContractPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/StrictPreemptionContractPBImpl.java new file mode 100644 index 0000000..0d80921 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/StrictPreemptionContractPBImpl.java @@ -0,0 +1,172 @@ +/** + * 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. + */ +package org.apache.hadoop.yarn.api.records.impl.pb; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.PreemptionContainer; +import org.apache.hadoop.yarn.api.records.StrictPreemptionContract; +import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionContainerProto; +import org.apache.hadoop.yarn.proto.YarnProtos.StrictPreemptionContractProto; +import org.apache.hadoop.yarn.proto.YarnProtos.StrictPreemptionContractProtoOrBuilder; + +@Private +@Unstable +public class StrictPreemptionContractPBImpl extends StrictPreemptionContract { + + StrictPreemptionContractProto proto = + StrictPreemptionContractProto.getDefaultInstance(); + StrictPreemptionContractProto.Builder builder = null; + + boolean viaProto = false; + private Set containers; + + public StrictPreemptionContractPBImpl() { + builder = StrictPreemptionContractProto.newBuilder(); + } + + public StrictPreemptionContractPBImpl(StrictPreemptionContractProto proto) { + this.proto = proto; + viaProto = true; + } + + public synchronized StrictPreemptionContractProto getProto() { + mergeLocalToProto(); + 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void mergeLocalToBuilder() { + if (this.containers != null) { + addContainersToProto(); + } + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = StrictPreemptionContractProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public synchronized Set getContainers() { + initIds(); + return containers; + } + + @Override + public synchronized void setContainers( + final Set containers) { + if (null == containers) { + builder.clearContainer(); + } + this.containers = containers; + } + + private void initIds() { + if (containers != null) { + return; + } + StrictPreemptionContractProtoOrBuilder p = viaProto ? proto : builder; + List list = p.getContainerList(); + containers = new HashSet(); + + for (PreemptionContainerProto c : list) { + containers.add(convertFromProtoFormat(c)); + } + } + + private void addContainersToProto() { + maybeInitBuilder(); + builder.clearContainer(); + if (containers == null) { + return; + } + Iterable iterable = new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator iter = containers.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public PreemptionContainerProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + + } + }; + + } + }; + builder.addAllContainer(iterable); + } + + private PreemptionContainerPBImpl convertFromProtoFormat(PreemptionContainerProto p) { + return new PreemptionContainerPBImpl(p); + } + + private PreemptionContainerProto convertToProtoFormat(PreemptionContainer t) { + return ((PreemptionContainerPBImpl)t).getProto(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/TokenPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/TokenPBImpl.java new file mode 100644 index 0000000..2835cbb --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/TokenPBImpl.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 + * + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + +import java.nio.ByteBuffer; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; +import org.apache.hadoop.security.proto.SecurityProtos.TokenProtoOrBuilder; +import org.apache.hadoop.yarn.api.records.Token; + +import com.google.protobuf.ByteString; + +@Private +@Unstable +public class TokenPBImpl extends Token { + private TokenProto proto = TokenProto.getDefaultInstance(); + private TokenProto.Builder builder = null; + private boolean viaProto = false; + + private ByteBuffer identifier; + private ByteBuffer password; + + public TokenPBImpl() { + builder = TokenProto.newBuilder(); + } + + public TokenPBImpl(TokenProto proto) { + this.proto = proto; + viaProto = true; + } + + public synchronized TokenProto getProto() { + mergeLocalToProto(); + 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; + } + + protected final ByteBuffer convertFromProtoFormat(ByteString byteString) { + return ProtoUtils.convertFromProtoFormat(byteString); + } + + protected final ByteString convertToProtoFormat(ByteBuffer byteBuffer) { + return ProtoUtils.convertToProtoFormat(byteBuffer); + } + + private synchronized void mergeLocalToBuilder() { + if (this.identifier != null) { + builder.setIdentifier(convertToProtoFormat(this.identifier)); + } + if (this.password != null) { + builder.setPassword(convertToProtoFormat(this.password)); + } + } + + private synchronized void mergeLocalToProto() { + if (viaProto) + maybeInitBuilder(); + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private synchronized void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = TokenProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public synchronized ByteBuffer getIdentifier() { + TokenProtoOrBuilder p = viaProto ? proto : builder; + if (this.identifier != null) { + return this.identifier; + } + if (!p.hasIdentifier()) { + return null; + } + this.identifier = convertFromProtoFormat(p.getIdentifier()); + return this.identifier; + } + + @Override + public synchronized void setIdentifier(ByteBuffer identifier) { + maybeInitBuilder(); + if (identifier == null) + builder.clearIdentifier(); + this.identifier = identifier; + } + + @Override + public synchronized ByteBuffer getPassword() { + TokenProtoOrBuilder p = viaProto ? proto : builder; + if (this.password != null) { + return this.password; + } + if (!p.hasPassword()) { + return null; + } + this.password = convertFromProtoFormat(p.getPassword()); + return this.password; + } + + @Override + public synchronized void setPassword(ByteBuffer password) { + maybeInitBuilder(); + if (password == null) + builder.clearPassword(); + this.password = password; + } + + @Override + public synchronized String getKind() { + TokenProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasKind()) { + return null; + } + return (p.getKind()); + } + + @Override + public synchronized void setKind(String kind) { + maybeInitBuilder(); + if (kind == null) { + builder.clearKind(); + return; + } + builder.setKind((kind)); + } + + @Override + public synchronized String getService() { + TokenProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasService()) { + return null; + } + return (p.getService()); + } + + @Override + public synchronized void setService(String service) { + maybeInitBuilder(); + if (service == null) { + builder.clearService(); + return; + } + builder.setService((service)); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Token { "); + sb.append("kind: ").append(getKind()).append(", "); + sb.append("service: ").append(getService()).append(" }"); + return sb.toString(); + } +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/URLPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/URLPBImpl.java new file mode 100644 index 0000000..14cc762 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/URLPBImpl.java @@ -0,0 +1,146 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.URL; +import org.apache.hadoop.yarn.proto.YarnProtos.URLProto; +import org.apache.hadoop.yarn.proto.YarnProtos.URLProtoOrBuilder; + +@Private +@Unstable +public class URLPBImpl extends URL { + URLProto proto = URLProto.getDefaultInstance(); + URLProto.Builder builder = null; + boolean viaProto = false; + + public URLPBImpl() { + builder = URLProto.newBuilder(); + } + + public URLPBImpl(URLProto proto) { + this.proto = proto; + viaProto = true; + } + + public URLProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = URLProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public String getFile() { + URLProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasFile()) { + return null; + } + return (p.getFile()); + } + + @Override + public void setFile(String file) { + maybeInitBuilder(); + if (file == null) { + builder.clearFile(); + return; + } + builder.setFile((file)); + } + @Override + public String getScheme() { + URLProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasScheme()) { + return null; + } + return (p.getScheme()); + } + + @Override + public void setScheme(String scheme) { + maybeInitBuilder(); + if (scheme == null) { + builder.clearScheme(); + return; + } + builder.setScheme((scheme)); + } + @Override + public String getHost() { + URLProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasHost()) { + return null; + } + return (p.getHost()); + } + + @Override + public void setHost(String host) { + maybeInitBuilder(); + if (host == null) { + builder.clearHost(); + return; + } + builder.setHost((host)); + } + @Override + public int getPort() { + URLProtoOrBuilder p = viaProto ? proto : builder; + return (p.getPort()); + } + + @Override + public void setPort(int port) { + maybeInitBuilder(); + builder.setPort((port)); + } + + + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/YarnClusterMetricsPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/YarnClusterMetricsPBImpl.java new file mode 100644 index 0000000..cef6c62 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/YarnClusterMetricsPBImpl.java @@ -0,0 +1,92 @@ +/** + * 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. + */ + +package org.apache.hadoop.yarn.api.records.impl.pb; + + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.YarnClusterMetrics; +import org.apache.hadoop.yarn.proto.YarnProtos.YarnClusterMetricsProto; +import org.apache.hadoop.yarn.proto.YarnProtos.YarnClusterMetricsProtoOrBuilder; + +@Private +@Unstable +public class YarnClusterMetricsPBImpl extends YarnClusterMetrics { + YarnClusterMetricsProto proto = YarnClusterMetricsProto.getDefaultInstance(); + YarnClusterMetricsProto.Builder builder = null; + boolean viaProto = false; + + public YarnClusterMetricsPBImpl() { + builder = YarnClusterMetricsProto.newBuilder(); + } + + public YarnClusterMetricsPBImpl(YarnClusterMetricsProto proto) { + this.proto = proto; + viaProto = true; + } + + public YarnClusterMetricsProto 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 getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " "); + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = YarnClusterMetricsProto.newBuilder(proto); + } + viaProto = false; + } + + + @Override + public int getNumNodeManagers() { + YarnClusterMetricsProtoOrBuilder p = viaProto ? proto : builder; + return (p.getNumNodeManagers()); + } + + @Override + public void setNumNodeManagers(int numNodeManagers) { + maybeInitBuilder(); + builder.setNumNodeManagers((numNodeManagers)); + } + + + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/package-info.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/package-info.java new file mode 100644 index 0000000..1f14e60 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ +@InterfaceAudience.Private +package org.apache.hadoop.yarn.api.records.impl.pb; +import org.apache.hadoop.classification.InterfaceAudience;