repo
stringlengths
1
191
file
stringlengths
23
351
code
stringlengths
0
5.32M
file_length
int64
0
5.32M
avg_line_length
float64
0
2.9k
max_line_length
int64
0
288k
extension_type
stringclasses
1 value
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainerRequestPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } 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(); } }
5,384
30.863905
94
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/ReleaseSharedCacheResourceResponsePBImpl.java
/** * 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.yarn.api.protocolrecords.ReleaseSharedCacheResourceResponse; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReleaseSharedCacheResourceResponseProto; public class ReleaseSharedCacheResourceResponsePBImpl extends ReleaseSharedCacheResourceResponse { ReleaseSharedCacheResourceResponseProto proto = ReleaseSharedCacheResourceResponseProto.getDefaultInstance(); ReleaseSharedCacheResourceResponseProto.Builder builder = null; boolean viaProto = false; public ReleaseSharedCacheResourceResponsePBImpl() { builder = ReleaseSharedCacheResourceResponseProto.newBuilder(); } public ReleaseSharedCacheResourceResponsePBImpl( ReleaseSharedCacheResourceResponseProto proto) { this.proto = proto; viaProto = true; } public ReleaseSharedCacheResourceResponseProto getProto() { proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = ReleaseSharedCacheResourceResponseProto.newBuilder(proto); } viaProto = false; } }
1,988
35.833333
94
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CancelDelegationTokenRequestPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } 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(); } }
3,786
28.818898
98
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/KillApplicationResponsePBImpl.java
/** * 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; import org.apache.hadoop.yarn.proto.YarnServiceProtos.KillApplicationResponseProtoOrBuilder; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = KillApplicationResponseProto.newBuilder(proto); } viaProto = false; } @Override public boolean getIsKillCompleted() { KillApplicationResponseProtoOrBuilder p = viaProto ? proto : builder; return p.getIsKillCompleted(); } @Override public void setIsKillCompleted(boolean isKillCompleted) { maybeInitBuilder(); builder.setIsKillCompleted(isKillCompleted); } }
2,885
30.369565
92
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationReportRequestPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } 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(); } }
4,052
29.473684
97
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainersRequestPBImpl.java
/** * 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.yarn.api.protocolrecords.GetContainersRequest; 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.GetContainersRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainersRequestProtoOrBuilder; import com.google.protobuf.TextFormat; public class GetContainersRequestPBImpl extends GetContainersRequest { GetContainersRequestProto proto = GetContainersRequestProto .getDefaultInstance(); GetContainersRequestProto.Builder builder = null; boolean viaProto = false; private ApplicationAttemptId applicationAttemptId = null; public GetContainersRequestPBImpl() { builder = GetContainersRequestProto.newBuilder(); } public GetContainersRequestPBImpl(GetContainersRequestProto proto) { this.proto = proto; viaProto = true; } public GetContainersRequestProto 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 TextFormat.shortDebugString(getProto()); } private void mergeLocalToBuilder() { if (applicationAttemptId != null) { 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 = GetContainersRequestProto.newBuilder(proto); } viaProto = false; } @Override public ApplicationAttemptId getApplicationAttemptId() { if (this.applicationAttemptId != null) { return this.applicationAttemptId; } GetContainersRequestProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasApplicationAttemptId()) { return null; } this.applicationAttemptId = convertFromProtoFormat(p.getApplicationAttemptId()); return this.applicationAttemptId; } @Override public void setApplicationAttemptId(ApplicationAttemptId applicationAttemptId) { maybeInitBuilder(); if (applicationAttemptId == null) { builder.clearApplicationAttemptId(); } this.applicationAttemptId = applicationAttemptId; } private ApplicationAttemptIdPBImpl convertFromProtoFormat( ApplicationAttemptIdProto p) { return new ApplicationAttemptIdPBImpl(p); } private ApplicationAttemptIdProto convertToProtoFormat(ApplicationAttemptId t) { return ((ApplicationAttemptIdPBImpl) t).getProto(); } }
4,035
29.575758
89
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetDelegationTokenResponsePBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } 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(); } }
3,853
28.19697
96
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainersResponsePBImpl.java
/** * 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.GetContainersResponse; import org.apache.hadoop.yarn.api.records.ContainerReport; import org.apache.hadoop.yarn.api.records.impl.pb.ContainerReportPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerReportProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainersResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainersResponseProtoOrBuilder; import com.google.protobuf.TextFormat; @Private @Unstable public class GetContainersResponsePBImpl extends GetContainersResponse { GetContainersResponseProto proto = GetContainersResponseProto .getDefaultInstance(); GetContainersResponseProto.Builder builder = null; boolean viaProto = false; List<ContainerReport> containerList; public GetContainersResponsePBImpl() { builder = GetContainersResponseProto.newBuilder(); } public GetContainersResponsePBImpl(GetContainersResponseProto proto) { this.proto = proto; viaProto = true; } @Override public List<ContainerReport> getContainerList() { initLocalContainerList(); return this.containerList; } @Override public void setContainerList(List<ContainerReport> containers) { maybeInitBuilder(); if (containers == null) { builder.clearContainers(); } this.containerList = containers; } public GetContainersResponseProto 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 TextFormat.shortDebugString(getProto()); } private void mergeLocalToBuilder() { if (this.containerList != null) { addLocalContainersToProto(); } } private void mergeLocalToProto() { if (viaProto) { maybeInitBuilder(); } mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = GetContainersResponseProto.newBuilder(proto); } viaProto = false; } // Once this is called. containerList will never be null - until a getProto // is called. private void initLocalContainerList() { if (this.containerList != null) { return; } GetContainersResponseProtoOrBuilder p = viaProto ? proto : builder; List<ContainerReportProto> list = p.getContainersList(); containerList = new ArrayList<ContainerReport>(); for (ContainerReportProto c : list) { containerList.add(convertFromProtoFormat(c)); } } private void addLocalContainersToProto() { maybeInitBuilder(); builder.clearContainers(); if (containerList == null) { return; } Iterable<ContainerReportProto> iterable = new Iterable<ContainerReportProto>() { @Override public Iterator<ContainerReportProto> iterator() { return new Iterator<ContainerReportProto>() { Iterator<ContainerReport> iter = containerList.iterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public ContainerReportProto next() { return convertToProtoFormat(iter.next()); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; builder.addAllContainers(iterable); } private ContainerReportPBImpl convertFromProtoFormat(ContainerReportProto p) { return new ContainerReportPBImpl(p); } private ContainerReportProto convertToProtoFormat(ContainerReport t) { return ((ContainerReportPBImpl) t).getProto(); } }
5,219
27.839779
90
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/FinishApplicationMasterRequestPBImpl.java
/** * 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.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils; import org.apache.hadoop.yarn.proto.YarnProtos.FinalApplicationStatusProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationMasterRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationMasterRequestProtoOrBuilder; import com.google.protobuf.TextFormat; @Private @Unstable public class FinishApplicationMasterRequestPBImpl extends FinishApplicationMasterRequest { FinishApplicationMasterRequestProto proto = FinishApplicationMasterRequestProto.getDefaultInstance(); FinishApplicationMasterRequestProto.Builder builder = null; boolean viaProto = false; 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 TextFormat.shortDebugString(getProto()); } private void mergeLocalToBuilder() { } 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 String getDiagnostics() { FinishApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; return p.getDiagnostics(); } @Override public void setDiagnostics(String diagnostics) { maybeInitBuilder(); if (diagnostics == null) { builder.clearDiagnostics(); return; } builder.setDiagnostics(diagnostics); } @Override public String getTrackingUrl() { FinishApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; return p.getTrackingUrl(); } @Override public void setTrackingUrl(String url) { maybeInitBuilder(); if (url == null) { builder.clearTrackingUrl(); return; } 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 FinalApplicationStatus convertFromProtoFormat(FinalApplicationStatusProto s) { return ProtoUtils.convertFromProtoFormat(s); } private FinalApplicationStatusProto convertToProtoFormat(FinalApplicationStatus s) { return ProtoUtils.convertToProtoFormat(s); } }
4,695
29.296774
103
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusesRequestPBImpl.java
/** * 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.List; import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesRequest; 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.GetContainerStatusesRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusesRequestProtoOrBuilder; import com.google.protobuf.TextFormat; @Private @Unstable public class GetContainerStatusesRequestPBImpl extends GetContainerStatusesRequest { GetContainerStatusesRequestProto proto = GetContainerStatusesRequestProto .getDefaultInstance(); GetContainerStatusesRequestProto.Builder builder = null; boolean viaProto = false; private List<ContainerId> containerIds = null; public GetContainerStatusesRequestPBImpl() { builder = GetContainerStatusesRequestProto.newBuilder(); } public GetContainerStatusesRequestPBImpl( GetContainerStatusesRequestProto proto) { this.proto = proto; viaProto = true; } public GetContainerStatusesRequestProto 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 TextFormat.shortDebugString(getProto()); } private void mergeLocalToBuilder() { if (this.containerIds != null) { addLocalContainerIdsToProto(); } } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = GetContainerStatusesRequestProto.newBuilder(proto); } viaProto = false; } private void addLocalContainerIdsToProto() { maybeInitBuilder(); builder.clearContainerId(); if (this.containerIds == null) return; List<ContainerIdProto> protoList = new ArrayList<ContainerIdProto>(); for (ContainerId id : containerIds) { protoList.add(convertToProtoFormat(id)); } builder.addAllContainerId(protoList); } private void initLocalContainerIds() { if (this.containerIds != null) { return; } GetContainerStatusesRequestProtoOrBuilder p = viaProto ? proto : builder; List<ContainerIdProto> containerIds = p.getContainerIdList(); this.containerIds = new ArrayList<ContainerId>(); for (ContainerIdProto id : containerIds) { this.containerIds.add(convertFromProtoFormat(id)); } } @Override public List<ContainerId> getContainerIds() { initLocalContainerIds(); return this.containerIds; } @Override public void setContainerIds(List<ContainerId> containerIds) { maybeInitBuilder(); if (containerIds == null) builder.clearContainerId(); this.containerIds = containerIds; } private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { return new ContainerIdPBImpl(p); } private ContainerIdProto convertToProtoFormat(ContainerId t) { return ((ContainerIdPBImpl) t).getProto(); } }
4,571
29.278146
96
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationAttemptReportRequestPBImpl.java
/** * 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.GetApplicationAttemptReportRequest; 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.GetApplicationAttemptReportRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationAttemptReportRequestProtoOrBuilder; import com.google.protobuf.TextFormat; @Private @Unstable public class GetApplicationAttemptReportRequestPBImpl extends GetApplicationAttemptReportRequest { GetApplicationAttemptReportRequestProto proto = GetApplicationAttemptReportRequestProto.getDefaultInstance(); GetApplicationAttemptReportRequestProto.Builder builder = null; boolean viaProto = false; private ApplicationAttemptId applicationAttemptId = null; public GetApplicationAttemptReportRequestPBImpl() { builder = GetApplicationAttemptReportRequestProto.newBuilder(); } public GetApplicationAttemptReportRequestPBImpl( GetApplicationAttemptReportRequestProto proto) { this.proto = proto; viaProto = true; } public GetApplicationAttemptReportRequestProto 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 TextFormat.shortDebugString(getProto()); } private void mergeLocalToBuilder() { if (applicationAttemptId != null) { 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 = GetApplicationAttemptReportRequestProto.newBuilder(proto); } viaProto = false; } @Override public ApplicationAttemptId getApplicationAttemptId() { if (this.applicationAttemptId != null) { return this.applicationAttemptId; } GetApplicationAttemptReportRequestProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasApplicationAttemptId()) { return null; } this.applicationAttemptId = convertFromProtoFormat(p.getApplicationAttemptId()); return this.applicationAttemptId; } @Override public void setApplicationAttemptId(ApplicationAttemptId applicationAttemptId) { maybeInitBuilder(); if (applicationAttemptId == null) { builder.clearApplicationAttemptId(); } this.applicationAttemptId = applicationAttemptId; } private ApplicationAttemptIdPBImpl convertFromProtoFormat( ApplicationAttemptIdProto p) { return new ApplicationAttemptIdPBImpl(p); } private ApplicationAttemptIdProto convertToProtoFormat(ApplicationAttemptId t) { return ((ApplicationAttemptIdPBImpl) t).getProto(); } }
4,422
30.368794
103
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerReportRequestPBImpl.java
/** * 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.GetContainerReportRequest; 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.GetContainerReportRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerReportRequestProtoOrBuilder; import com.google.protobuf.TextFormat; @Private @Unstable public class GetContainerReportRequestPBImpl extends GetContainerReportRequest { GetContainerReportRequestProto proto = GetContainerReportRequestProto .getDefaultInstance(); GetContainerReportRequestProto.Builder builder = null; boolean viaProto = false; private ContainerId containerId = null; public GetContainerReportRequestPBImpl() { builder = GetContainerReportRequestProto.newBuilder(); } public GetContainerReportRequestPBImpl(GetContainerReportRequestProto proto) { this.proto = proto; viaProto = true; } public GetContainerReportRequestProto 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 TextFormat.shortDebugString(getProto()); } 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 = GetContainerReportRequestProto.newBuilder(proto); } viaProto = false; } @Override public ContainerId getContainerId() { if (this.containerId != null) { return this.containerId; } GetContainerReportRequestProtoOrBuilder p = viaProto ? proto : builder; 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(); } }
3,953
29.415385
94
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SubmitApplicationRequestPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } 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(); } }
4,453
32.488722
106
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterNodesRequestPBImpl.java
/** * 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.EnumSet; 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.GetClusterNodesRequest; import org.apache.hadoop.yarn.api.records.NodeState; import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils; import org.apache.hadoop.yarn.proto.YarnProtos.NodeStateProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterNodesRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterNodesRequestProtoOrBuilder; import com.google.protobuf.TextFormat; @Private @Unstable public class GetClusterNodesRequestPBImpl extends GetClusterNodesRequest { GetClusterNodesRequestProto proto = GetClusterNodesRequestProto.getDefaultInstance(); GetClusterNodesRequestProto.Builder builder = null; boolean viaProto = false; private EnumSet<NodeState> states = null; public GetClusterNodesRequestPBImpl() { builder = GetClusterNodesRequestProto.newBuilder(); } public GetClusterNodesRequestPBImpl(GetClusterNodesRequestProto proto) { this.proto = proto; viaProto = true; } public GetClusterNodesRequestProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } @Override public EnumSet<NodeState> getNodeStates() { initNodeStates(); return this.states; } @Override public void setNodeStates(final EnumSet<NodeState> states) { initNodeStates(); this.states.clear(); if (states == null) { return; } this.states.addAll(states); } private void mergeLocalToProto() { if (viaProto) { maybeInitBuilder(); } mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = GetClusterNodesRequestProto.newBuilder(proto); } viaProto = false; } private void mergeLocalToBuilder() { if (this.states != null) { maybeInitBuilder(); builder.clearNodeStates(); Iterable<NodeStateProto> iterable = new Iterable<NodeStateProto>() { @Override public Iterator<NodeStateProto> iterator() { return new Iterator<NodeStateProto>() { Iterator<NodeState> iter = states.iterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public NodeStateProto next() { return ProtoUtils.convertToProtoFormat(iter.next()); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; builder.addAllNodeStates(iterable); } } private void initNodeStates() { if (this.states != null) { return; } GetClusterNodesRequestProtoOrBuilder p = viaProto ? proto : builder; List<NodeStateProto> list = p.getNodeStatesList(); this.states = EnumSet.noneOf(NodeState.class); for (NodeStateProto c : list) { this.states.add(ProtoUtils.convertFromProtoFormat(c)); } } @Override public int hashCode() { return getProto().hashCode(); } @Override public boolean equals(Object other) { if (other == null) return false; if (other.getClass().isAssignableFrom(this.getClass())) { return this.getProto().equals(this.getClass().cast(other).getProto()); } return false; } @Override public String toString() { return TextFormat.shortDebugString(getProto()); } }
4,600
27.57764
91
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterMetricsResponsePBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } 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(); } }
4,136
30.105263
94
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SubmitApplicationResponsePBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } }
2,320
31.690141
93
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainersRequestPBImpl.java
/** * 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.List; import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest; import org.apache.hadoop.yarn.api.protocolrecords.StartContainersRequest; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainerRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainersRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainersRequestProtoOrBuilder; public class StartContainersRequestPBImpl extends StartContainersRequest { StartContainersRequestProto proto = StartContainersRequestProto .getDefaultInstance(); StartContainersRequestProto.Builder builder = null; boolean viaProto = false; private List<StartContainerRequest> requests = null; public StartContainersRequestPBImpl() { builder = StartContainersRequestProto.newBuilder(); } public StartContainersRequestPBImpl(StartContainersRequestProto proto) { this.proto = proto; viaProto = true; } public StartContainersRequestProto 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 mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void mergeLocalToBuilder() { if (requests != null) { addLocalRequestsToProto(); } } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = StartContainersRequestProto.newBuilder(proto); } viaProto = false; } private void addLocalRequestsToProto() { maybeInitBuilder(); builder.clearStartContainerRequest(); List<StartContainerRequestProto> protoList = new ArrayList<StartContainerRequestProto>(); for (StartContainerRequest r : this.requests) { protoList.add(convertToProtoFormat(r)); } builder.addAllStartContainerRequest(protoList); } private void initLocalRequests() { StartContainersRequestProtoOrBuilder p = viaProto ? proto : builder; List<StartContainerRequestProto> requestList = p.getStartContainerRequestList(); this.requests = new ArrayList<StartContainerRequest>(); for (StartContainerRequestProto r : requestList) { this.requests.add(convertFromProtoFormat(r)); } } @Override public void setStartContainerRequests(List<StartContainerRequest> requests) { maybeInitBuilder(); if (requests == null) { builder.clearStartContainerRequest(); } this.requests = requests; } @Override public List<StartContainerRequest> getStartContainerRequests() { if (this.requests != null) { return this.requests; } initLocalRequests(); return this.requests; } private StartContainerRequestPBImpl convertFromProtoFormat( StartContainerRequestProto p) { return new StartContainerRequestPBImpl(p); } private StartContainerRequestProto convertToProtoFormat( StartContainerRequest t) { return ((StartContainerRequestPBImpl) t).getProto(); } }
4,305
29.757143
91
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateResponsePBImpl.java
/** * 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.security.proto.SecurityProtos.TokenProto; 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.ContainerResourceDecrease; import org.apache.hadoop.yarn.api.records.ContainerResourceIncrease; 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.Token; import org.apache.hadoop.yarn.api.records.impl.pb.ContainerPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.ContainerResourceDecreasePBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.ContainerResourceIncreasePBImpl; 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.api.records.impl.pb.TokenPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceDecreaseProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceIncreaseProto; 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; import com.google.protobuf.TextFormat; @Private @Unstable public class AllocateResponsePBImpl extends AllocateResponse { AllocateResponseProto proto = AllocateResponseProto.getDefaultInstance(); AllocateResponseProto.Builder builder = null; boolean viaProto = false; Resource limit; private List<Container> allocatedContainers = null; private List<NMToken> nmTokens = null; private List<ContainerStatus> completedContainersStatuses = null; private List<ContainerResourceIncrease> increasedContainers = null; private List<ContainerResourceDecrease> decreasedContainers = null; private List<NodeReport> updatedNodes = null; private PreemptionMessage preempt; private Token amrmToken = null; 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 TextFormat.shortDebugString(getProto()); } private synchronized void mergeLocalToBuilder() { if (this.allocatedContainers != null) { builder.clearAllocatedContainers(); Iterable<ContainerProto> iterable = getContainerProtoIterable(this.allocatedContainers); builder.addAllAllocatedContainers(iterable); } if (nmTokens != null) { builder.clearNmTokens(); Iterable<NMTokenProto> iterable = getTokenProtoIterable(nmTokens); builder.addAllNmTokens(iterable); } if (this.completedContainersStatuses != null) { builder.clearCompletedContainerStatuses(); Iterable<ContainerStatusProto> iterable = getContainerStatusProtoIterable(this.completedContainersStatuses); builder.addAllCompletedContainerStatuses(iterable); } if (this.updatedNodes != null) { builder.clearUpdatedNodes(); Iterable<NodeReportProto> 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)); } if (this.increasedContainers != null) { builder.clearIncreasedContainers(); Iterable<ContainerResourceIncreaseProto> iterable = getIncreaseProtoIterable(this.increasedContainers); builder.addAllIncreasedContainers(iterable); } if (this.decreasedContainers != null) { builder.clearDecreasedContainers(); Iterable<ContainerResourceDecreaseProto> iterable = getChangeProtoIterable(this.decreasedContainers); builder.addAllDecreasedContainers(iterable); } if (this.amrmToken != null) { builder.setAmRmToken(convertToProtoFormat(this.amrmToken)); } } 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<NodeReport> getUpdatedNodes() { initLocalNewNodeReportList(); return this.updatedNodes; } @Override public synchronized void setUpdatedNodes( final List<NodeReport> updatedNodes) { if (updatedNodes == null) { this.updatedNodes.clear(); return; } this.updatedNodes = new ArrayList<NodeReport>(updatedNodes.size()); this.updatedNodes.addAll(updatedNodes); } @Override public synchronized List<Container> getAllocatedContainers() { initLocalNewContainerList(); return this.allocatedContainers; } @Override public synchronized void setAllocatedContainers( final List<Container> 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<ContainerStatus> getCompletedContainersStatuses() { initLocalFinishedContainerList(); return this.completedContainersStatuses; } @Override public synchronized void setCompletedContainersStatuses( final List<ContainerStatus> containers) { if (containers == null) return; initLocalFinishedContainerList(); completedContainersStatuses.addAll(containers); } @Override public synchronized void setNMTokens(List<NMToken> 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<NMToken> 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; } @Override public synchronized List<ContainerResourceIncrease> getIncreasedContainers() { initLocalIncreasedContainerList(); return increasedContainers; } @Override public synchronized void setIncreasedContainers( List<ContainerResourceIncrease> increasedContainers) { if (increasedContainers == null) return; initLocalIncreasedContainerList(); this.increasedContainers.addAll(increasedContainers); } @Override public synchronized List<ContainerResourceDecrease> getDecreasedContainers() { initLocalDecreasedContainerList(); return decreasedContainers; } @Override public synchronized void setDecreasedContainers( List<ContainerResourceDecrease> decreasedContainers) { if (decreasedContainers == null) { return; } initLocalDecreasedContainerList(); this.decreasedContainers.addAll(decreasedContainers); } @Override public synchronized Token getAMRMToken() { AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; if (amrmToken != null) { return amrmToken; } if (!p.hasAmRmToken()) { return null; } this.amrmToken = convertFromProtoFormat(p.getAmRmToken()); return amrmToken; } @Override public synchronized void setAMRMToken(Token amRMToken) { maybeInitBuilder(); if (amRMToken == null) { builder.clearAmRmToken(); } this.amrmToken = amRMToken; } private synchronized void initLocalIncreasedContainerList() { if (this.increasedContainers != null) { return; } AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; List<ContainerResourceIncreaseProto> list = p.getIncreasedContainersList(); increasedContainers = new ArrayList<ContainerResourceIncrease>(); for (ContainerResourceIncreaseProto c : list) { increasedContainers.add(convertFromProtoFormat(c)); } } private synchronized void initLocalDecreasedContainerList() { if (this.decreasedContainers != null) { return; } AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; List<ContainerResourceDecreaseProto> list = p.getDecreasedContainersList(); decreasedContainers = new ArrayList<ContainerResourceDecrease>(); for (ContainerResourceDecreaseProto c : list) { decreasedContainers.add(convertFromProtoFormat(c)); } } // 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<NodeReportProto> list = p.getUpdatedNodesList(); updatedNodes = new ArrayList<NodeReport>(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<ContainerProto> list = p.getAllocatedContainersList(); allocatedContainers = new ArrayList<Container>(); for (ContainerProto c : list) { allocatedContainers.add(convertFromProtoFormat(c)); } } private synchronized void initLocalNewNMTokenList() { if (nmTokens != null) { return; } AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; List<NMTokenProto> list = p.getNmTokensList(); nmTokens = new ArrayList<NMToken>(); for (NMTokenProto t : list) { nmTokens.add(convertFromProtoFormat(t)); } } private synchronized Iterable<ContainerResourceIncreaseProto> getIncreaseProtoIterable( final List<ContainerResourceIncrease> newContainersList) { maybeInitBuilder(); return new Iterable<ContainerResourceIncreaseProto>() { @Override public synchronized Iterator<ContainerResourceIncreaseProto> iterator() { return new Iterator<ContainerResourceIncreaseProto>() { Iterator<ContainerResourceIncrease> iter = newContainersList .iterator(); @Override public synchronized boolean hasNext() { return iter.hasNext(); } @Override public synchronized ContainerResourceIncreaseProto next() { return convertToProtoFormat(iter.next()); } @Override public synchronized void remove() { throw new UnsupportedOperationException(); } }; } }; } private synchronized Iterable<ContainerResourceDecreaseProto> getChangeProtoIterable( final List<ContainerResourceDecrease> newContainersList) { maybeInitBuilder(); return new Iterable<ContainerResourceDecreaseProto>() { @Override public synchronized Iterator<ContainerResourceDecreaseProto> iterator() { return new Iterator<ContainerResourceDecreaseProto>() { Iterator<ContainerResourceDecrease> iter = newContainersList .iterator(); @Override public synchronized boolean hasNext() { return iter.hasNext(); } @Override public synchronized ContainerResourceDecreaseProto next() { return convertToProtoFormat(iter.next()); } @Override public synchronized void remove() { throw new UnsupportedOperationException(); } }; } }; } private synchronized Iterable<ContainerProto> getContainerProtoIterable( final List<Container> newContainersList) { maybeInitBuilder(); return new Iterable<ContainerProto>() { @Override public synchronized Iterator<ContainerProto> iterator() { return new Iterator<ContainerProto>() { Iterator<Container> 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<NMTokenProto> getTokenProtoIterable( final List<NMToken> nmTokenList) { maybeInitBuilder(); return new Iterable<NMTokenProto>() { @Override public synchronized Iterator<NMTokenProto> iterator() { return new Iterator<NMTokenProto>() { Iterator<NMToken> 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<ContainerStatusProto> getContainerStatusProtoIterable( final List<ContainerStatus> newContainersList) { maybeInitBuilder(); return new Iterable<ContainerStatusProto>() { @Override public synchronized Iterator<ContainerStatusProto> iterator() { return new Iterator<ContainerStatusProto>() { Iterator<ContainerStatus> 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<NodeReportProto> getNodeReportProtoIterable( final List<NodeReport> newNodeReportsList) { maybeInitBuilder(); return new Iterable<NodeReportProto>() { @Override public synchronized Iterator<NodeReportProto> iterator() { return new Iterator<NodeReportProto>() { Iterator<NodeReport> 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<ContainerStatusProto> list = p.getCompletedContainerStatusesList(); completedContainersStatuses = new ArrayList<ContainerStatus>(); for (ContainerStatusProto c : list) { completedContainersStatuses.add(convertFromProtoFormat(c)); } } private synchronized ContainerResourceIncrease convertFromProtoFormat( ContainerResourceIncreaseProto p) { return new ContainerResourceIncreasePBImpl(p); } private synchronized ContainerResourceIncreaseProto convertToProtoFormat( ContainerResourceIncrease t) { return ((ContainerResourceIncreasePBImpl) t).getProto(); } private synchronized ContainerResourceDecrease convertFromProtoFormat( ContainerResourceDecreaseProto p) { return new ContainerResourceDecreasePBImpl(p); } private synchronized ContainerResourceDecreaseProto convertToProtoFormat( ContainerResourceDecrease t) { return ((ContainerResourceDecreasePBImpl) t).getProto(); } 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); } private TokenPBImpl convertFromProtoFormat(TokenProto p) { return new TokenPBImpl(p); } private TokenProto convertToProtoFormat(Token t) { return ((TokenPBImpl)t).getProto(); } }
22,941
30.044655
97
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/ReservationSubmissionResponsePBImpl.java
/** * 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.yarn.api.protocolrecords.ReservationSubmissionResponse; import org.apache.hadoop.yarn.api.records.ReservationId; import org.apache.hadoop.yarn.api.records.impl.pb.ReservationIdPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.ReservationIdProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationSubmissionResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationSubmissionResponseProtoOrBuilder; import com.google.protobuf.TextFormat; public class ReservationSubmissionResponsePBImpl extends ReservationSubmissionResponse { ReservationSubmissionResponseProto proto = ReservationSubmissionResponseProto .getDefaultInstance(); ReservationSubmissionResponseProto.Builder builder = null; boolean viaProto = false; private ReservationId reservationId; public ReservationSubmissionResponsePBImpl() { builder = ReservationSubmissionResponseProto.newBuilder(); } public ReservationSubmissionResponsePBImpl( ReservationSubmissionResponseProto proto) { this.proto = proto; viaProto = true; } public ReservationSubmissionResponseProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } private void mergeLocalToBuilder() { if (this.reservationId != null) { builder.setReservationId(convertToProtoFormat(this.reservationId)); } } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = ReservationSubmissionResponseProto.newBuilder(proto); } viaProto = false; } @Override public ReservationId getReservationId() { ReservationSubmissionResponseProtoOrBuilder p = viaProto ? proto : builder; if (reservationId != null) { return reservationId; } if (!p.hasReservationId()) { return null; } reservationId = convertFromProtoFormat(p.getReservationId()); return reservationId; } @Override public void setReservationId(ReservationId reservationId) { maybeInitBuilder(); if (reservationId == null) { builder.clearReservationId(); return; } this.reservationId = reservationId; } private ReservationIdPBImpl convertFromProtoFormat(ReservationIdProto p) { return new ReservationIdPBImpl(p); } private ReservationIdProto convertToProtoFormat(ReservationId t) { return ((ReservationIdPBImpl) t).getProto(); } @Override public int hashCode() { return getProto().hashCode(); } @Override public boolean equals(Object other) { if (other == null) return false; if (other.getClass().isAssignableFrom(this.getClass())) { return this.getProto().equals(this.getClass().cast(other).getProto()); } return false; } @Override public String toString() { return TextFormat.shortDebugString(getProto()); } }
3,922
29.176923
98
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/ReleaseSharedCacheResourceRequestPBImpl.java
/** * 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.yarn.api.protocolrecords.ReleaseSharedCacheResourceRequest; 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.ReleaseSharedCacheResourceRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReleaseSharedCacheResourceRequestProtoOrBuilder; public class ReleaseSharedCacheResourceRequestPBImpl extends ReleaseSharedCacheResourceRequest { ReleaseSharedCacheResourceRequestProto proto = ReleaseSharedCacheResourceRequestProto.getDefaultInstance(); ReleaseSharedCacheResourceRequestProto.Builder builder = null; boolean viaProto = false; private ApplicationId applicationId = null; public ReleaseSharedCacheResourceRequestPBImpl() { builder = ReleaseSharedCacheResourceRequestProto.newBuilder(); } public ReleaseSharedCacheResourceRequestPBImpl( ReleaseSharedCacheResourceRequestProto proto) { this.proto = proto; viaProto = true; } public ReleaseSharedCacheResourceRequestProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } @Override public ApplicationId getAppId() { ReleaseSharedCacheResourceRequestProtoOrBuilder 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 setAppId(ApplicationId id) { maybeInitBuilder(); if (id == null) builder.clearApplicationId(); this.applicationId = id; } @Override public String getResourceKey() { ReleaseSharedCacheResourceRequestProtoOrBuilder p = viaProto ? proto : builder; return (p.hasResourceKey()) ? p.getResourceKey() : null; } @Override public void setResourceKey(String key) { maybeInitBuilder(); if (key == null) { builder.clearResourceKey(); return; } builder.setResourceKey(key); } 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 = ReleaseSharedCacheResourceRequestProto.newBuilder(proto); } viaProto = false; } private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { return new ApplicationIdPBImpl(p); } private ApplicationIdProto convertToProtoFormat(ApplicationId t) { return ((ApplicationIdPBImpl) t).getProto(); } }
3,860
30.390244
102
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueUserAclsInfoRequestPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } }
2,345
31.583333
87
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/ReservationUpdateResponsePBImpl.java
/** * 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.yarn.api.protocolrecords.ReservationUpdateResponse; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationUpdateResponseProto; import com.google.protobuf.TextFormat; public class ReservationUpdateResponsePBImpl extends ReservationUpdateResponse { ReservationUpdateResponseProto proto = ReservationUpdateResponseProto .getDefaultInstance(); ReservationUpdateResponseProto.Builder builder = null; boolean viaProto = false; public ReservationUpdateResponsePBImpl() { builder = ReservationUpdateResponseProto.newBuilder(); } public ReservationUpdateResponsePBImpl(ReservationUpdateResponseProto proto) { this.proto = proto; viaProto = true; } public ReservationUpdateResponseProto getProto() { proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } @Override public int hashCode() { return getProto().hashCode(); } @Override public boolean equals(Object other) { if (other == null) return false; if (other.getClass().isAssignableFrom(this.getClass())) { return this.getProto().equals(this.getClass().cast(other).getProto()); } return false; } @Override public String toString() { return TextFormat.shortDebugString(getProto()); } }
2,167
30.42029
85
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNodesToLabelsRequestPBImpl.java
/** * 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.yarn.api.protocolrecords.GetNodesToLabelsRequest; import com.google.protobuf.TextFormat; import org.apache.hadoop.yarn.proto.YarnServiceProtos; public class GetNodesToLabelsRequestPBImpl extends GetNodesToLabelsRequest { YarnServiceProtos.GetNodesToLabelsRequestProto proto = YarnServiceProtos.GetNodesToLabelsRequestProto .getDefaultInstance(); YarnServiceProtos.GetNodesToLabelsRequestProto.Builder builder = null; boolean viaProto = false; public GetNodesToLabelsRequestPBImpl() { builder = YarnServiceProtos.GetNodesToLabelsRequestProto.newBuilder(); } public GetNodesToLabelsRequestPBImpl( YarnServiceProtos.GetNodesToLabelsRequestProto proto) { this.proto = proto; viaProto = true; } public YarnServiceProtos.GetNodesToLabelsRequestProto getProto() { proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } @Override public int hashCode() { return getProto().hashCode(); } @Override public boolean equals(Object other) { if (other == null) return false; if (other.getClass().isAssignableFrom(this.getClass())) { return this.getProto().equals(this.getClass().cast(other).getProto()); } return false; } @Override public String toString() { return TextFormat.shortDebugString(getProto()); } }
2,238
30.985714
76
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetLabelsToNodesRequestPBImpl.java
/** * 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.HashSet; import java.util.List; import java.util.Set; import org.apache.hadoop.yarn.api.protocolrecords.GetLabelsToNodesRequest; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetLabelsToNodesRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetLabelsToNodesRequestProtoOrBuilder; import com.google.protobuf.TextFormat; public class GetLabelsToNodesRequestPBImpl extends GetLabelsToNodesRequest { Set<String> nodeLabels = null; GetLabelsToNodesRequestProto proto = GetLabelsToNodesRequestProto.getDefaultInstance(); GetLabelsToNodesRequestProto.Builder builder = null; boolean viaProto = false; public GetLabelsToNodesRequestPBImpl() { builder = GetLabelsToNodesRequestProto.newBuilder(); } public GetLabelsToNodesRequestPBImpl(GetLabelsToNodesRequestProto proto) { this.proto = proto; viaProto = true; } public GetLabelsToNodesRequestProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void mergeLocalToBuilder() { if (nodeLabels != null && !nodeLabels.isEmpty()) { builder.clearNodeLabels(); builder.addAllNodeLabels(nodeLabels); } } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = GetLabelsToNodesRequestProto.newBuilder(proto); } viaProto = false; } private void initNodeLabels() { if (this.nodeLabels != null) { return; } GetLabelsToNodesRequestProtoOrBuilder p = viaProto ? proto : builder; List<String> nodeLabelsList = p.getNodeLabelsList(); this.nodeLabels = new HashSet<String>(); this.nodeLabels.addAll(nodeLabelsList); } @Override public Set<String> getNodeLabels() { initNodeLabels(); return this.nodeLabels; } @Override public void setNodeLabels(Set<String> nodeLabels) { maybeInitBuilder(); if (nodeLabels == null) builder.clearNodeLabels(); this.nodeLabels = nodeLabels; } @Override public int hashCode() { return getProto().hashCode(); } @Override public boolean equals(Object other) { if (other == null) return false; if (other.getClass().isAssignableFrom(this.getClass())) { return this.getProto().equals(this.getClass().cast(other).getProto()); } return false; } @Override public String toString() { return TextFormat.shortDebugString(getProto()); } }
3,491
27.859504
92
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/ReservationDeleteResponsePBImpl.java
/** * 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.yarn.api.protocolrecords.ReservationDeleteResponse; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationDeleteResponseProto; import com.google.protobuf.TextFormat; public class ReservationDeleteResponsePBImpl extends ReservationDeleteResponse { ReservationDeleteResponseProto proto = ReservationDeleteResponseProto .getDefaultInstance(); ReservationDeleteResponseProto.Builder builder = null; boolean viaProto = false; public ReservationDeleteResponsePBImpl() { builder = ReservationDeleteResponseProto.newBuilder(); } public ReservationDeleteResponsePBImpl(ReservationDeleteResponseProto proto) { this.proto = proto; viaProto = true; } public ReservationDeleteResponseProto getProto() { proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } @Override public int hashCode() { return getProto().hashCode(); } @Override public boolean equals(Object other) { if (other == null) return false; if (other.getClass().isAssignableFrom(this.getClass())) { return this.getProto().equals(this.getClass().cast(other).getProto()); } return false; } @Override public String toString() { return TextFormat.shortDebugString(getProto()); } }
2,167
30.42029
85
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/FinishApplicationMasterResponsePBImpl.java
/** * 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.YarnProtos.ResourceRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationMasterResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationMasterResponseProtoOrBuilder; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = FinishApplicationMasterResponseProto.newBuilder(proto); } viaProto = false; } @Override public boolean getIsUnregistered() { FinishApplicationMasterResponseProtoOrBuilder p = viaProto ? proto : builder; return p.getIsUnregistered(); } @Override public void setIsUnregistered(boolean isUnregistered) { maybeInitBuilder(); builder.setIsUnregistered(isUnregistered); } }
3,068
32
105
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateRequestPBImpl.java
/** * 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.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerResourceIncreaseRequest; 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.ContainerIdPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.ContainerResourceIncreaseRequestPBImpl; 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.ContainerIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceIncreaseRequestProto; 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; import com.google.protobuf.TextFormat; @Private @Unstable public class AllocateRequestPBImpl extends AllocateRequest { AllocateRequestProto proto = AllocateRequestProto.getDefaultInstance(); AllocateRequestProto.Builder builder = null; boolean viaProto = false; private List<ResourceRequest> ask = null; private List<ContainerId> release = null; private List<ContainerResourceIncreaseRequest> increaseRequests = 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 TextFormat.shortDebugString(getProto()); } private void mergeLocalToBuilder() { if (this.ask != null) { addAsksToProto(); } if (this.release != null) { addReleasesToProto(); } if (this.increaseRequests != null) { addIncreaseRequestsToProto(); } 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 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<ResourceRequest> getAskList() { initAsks(); return this.ask; } @Override public void setAskList(final List<ResourceRequest> resourceRequests) { if(resourceRequests == null) { return; } initAsks(); this.ask.clear(); this.ask.addAll(resourceRequests); } @Override public List<ContainerResourceIncreaseRequest> getIncreaseRequests() { initIncreaseRequests(); return this.increaseRequests; } @Override public void setIncreaseRequests( List<ContainerResourceIncreaseRequest> increaseRequests) { if (increaseRequests == null) { return; } initIncreaseRequests(); this.increaseRequests.clear(); this.increaseRequests.addAll(increaseRequests); } @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<ResourceRequestProto> list = p.getAskList(); this.ask = new ArrayList<ResourceRequest>(); for (ResourceRequestProto c : list) { this.ask.add(convertFromProtoFormat(c)); } } private void addAsksToProto() { maybeInitBuilder(); builder.clearAsk(); if (ask == null) return; Iterable<ResourceRequestProto> iterable = new Iterable<ResourceRequestProto>() { @Override public Iterator<ResourceRequestProto> iterator() { return new Iterator<ResourceRequestProto>() { Iterator<ResourceRequest> 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); } private void initIncreaseRequests() { if (this.increaseRequests != null) { return; } AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; List<ContainerResourceIncreaseRequestProto> list = p.getIncreaseRequestList(); this.increaseRequests = new ArrayList<ContainerResourceIncreaseRequest>(); for (ContainerResourceIncreaseRequestProto c : list) { this.increaseRequests.add(convertFromProtoFormat(c)); } } private void addIncreaseRequestsToProto() { maybeInitBuilder(); builder.clearIncreaseRequest(); if (increaseRequests == null) { return; } Iterable<ContainerResourceIncreaseRequestProto> iterable = new Iterable<ContainerResourceIncreaseRequestProto>() { @Override public Iterator<ContainerResourceIncreaseRequestProto> iterator() { return new Iterator<ContainerResourceIncreaseRequestProto>() { Iterator<ContainerResourceIncreaseRequest> iter = increaseRequests.iterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public ContainerResourceIncreaseRequestProto next() { return convertToProtoFormat(iter.next()); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; builder.addAllIncreaseRequest(iterable); } @Override public List<ContainerId> getReleaseList() { initReleases(); return this.release; } @Override public void setReleaseList(List<ContainerId> 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<ContainerIdProto> list = p.getReleaseList(); this.release = new ArrayList<ContainerId>(); for (ContainerIdProto c : list) { this.release.add(convertFromProtoFormat(c)); } } private void addReleasesToProto() { maybeInitBuilder(); builder.clearRelease(); if (release == null) return; Iterable<ContainerIdProto> iterable = new Iterable<ContainerIdProto>() { @Override public Iterator<ContainerIdProto> iterator() { return new Iterator<ContainerIdProto>() { Iterator<ContainerId> 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 ResourceRequestPBImpl convertFromProtoFormat(ResourceRequestProto p) { return new ResourceRequestPBImpl(p); } private ResourceRequestProto convertToProtoFormat(ResourceRequest t) { return ((ResourceRequestPBImpl)t).getProto(); } private ContainerResourceIncreaseRequestPBImpl convertFromProtoFormat( ContainerResourceIncreaseRequestProto p) { return new ContainerResourceIncreaseRequestPBImpl(p); } private ContainerResourceIncreaseRequestProto convertToProtoFormat( ContainerResourceIncreaseRequest t) { return ((ContainerResourceIncreaseRequestPBImpl) 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(); } }
11,533
28.126263
98
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNodesToLabelsResponsePBImpl.java
/** * 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.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.NodeLabel; import org.apache.hadoop.yarn.api.records.impl.pb.NodeIdPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.NodeLabelPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; import org.apache.hadoop.yarn.api.protocolrecords.GetNodesToLabelsResponse; import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdToLabelsInfoProto; import org.apache.hadoop.yarn.proto.YarnProtos.NodeLabelProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNodesToLabelsResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNodesToLabelsResponseProtoOrBuilder; public class GetNodesToLabelsResponsePBImpl extends GetNodesToLabelsResponse { GetNodesToLabelsResponseProto proto = GetNodesToLabelsResponseProto .getDefaultInstance(); GetNodesToLabelsResponseProto.Builder builder = null; boolean viaProto = false; private Map<NodeId, Set<NodeLabel>> nodeToLabels; public GetNodesToLabelsResponsePBImpl() { this.builder = GetNodesToLabelsResponseProto.newBuilder(); } public GetNodesToLabelsResponsePBImpl(GetNodesToLabelsResponseProto proto) { this.proto = proto; this.viaProto = true; } private void initNodeToLabels() { if (this.nodeToLabels != null) { return; } GetNodesToLabelsResponseProtoOrBuilder p = viaProto ? proto : builder; List<NodeIdToLabelsInfoProto> list = p.getNodeToLabelsList(); this.nodeToLabels = new HashMap<NodeId, Set<NodeLabel>>(); for (NodeIdToLabelsInfoProto c : list) { Set<NodeLabel> labels = new HashSet<NodeLabel>(); for (NodeLabelProto l : c.getNodeLabelsList()) { labels.add(new NodeLabelPBImpl(l)); } this.nodeToLabels.put(new NodeIdPBImpl(c.getNodeId()), labels); } } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = GetNodesToLabelsResponseProto.newBuilder(proto); } viaProto = false; } private void addNodeToLabelsToProto() { maybeInitBuilder(); builder.clearNodeToLabels(); if (nodeToLabels == null) { return; } Iterable<NodeIdToLabelsInfoProto> iterable = new Iterable<NodeIdToLabelsInfoProto>() { @Override public Iterator<NodeIdToLabelsInfoProto> iterator() { return new Iterator<NodeIdToLabelsInfoProto>() { Iterator<Entry<NodeId, Set<NodeLabel>>> iter = nodeToLabels .entrySet().iterator(); @Override public void remove() { throw new UnsupportedOperationException(); } @Override public NodeIdToLabelsInfoProto next() { Entry<NodeId, Set<NodeLabel>> now = iter.next(); Set<NodeLabelProto> labelProtoList = new HashSet<NodeLabelProto>(); for (NodeLabel l : now.getValue()) { labelProtoList.add(convertToProtoFormat(l)); } return NodeIdToLabelsInfoProto.newBuilder() .setNodeId(convertToProtoFormat(now.getKey())) .addAllNodeLabels(labelProtoList).build(); } @Override public boolean hasNext() { return iter.hasNext(); } }; } }; builder.addAllNodeToLabels(iterable); } private void mergeLocalToBuilder() { if (this.nodeToLabels != null) { addNodeToLabelsToProto(); } } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } public GetNodesToLabelsResponseProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } @Override public Map<NodeId, Set<NodeLabel>> getNodeToLabels() { initNodeToLabels(); return this.nodeToLabels; } @Override public void setNodeToLabels(Map<NodeId, Set<NodeLabel>> map) { initNodeToLabels(); nodeToLabels.clear(); nodeToLabels.putAll(map); } private NodeIdProto convertToProtoFormat(NodeId t) { return ((NodeIdPBImpl)t).getProto(); } private NodeLabelProto convertToProtoFormat(NodeLabel t) { return ((NodeLabelPBImpl)t).getProto(); } @Override public int hashCode() { assert false : "hashCode not designed"; return 0; } @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; } }
5,821
30.814208
93
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainersRequestPBImpl.java
/** * 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.List; import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.yarn.api.protocolrecords.StopContainersRequest; 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.StopContainersRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainersRequestProtoOrBuilder; import com.google.protobuf.TextFormat; @Private @Unstable public class StopContainersRequestPBImpl extends StopContainersRequest { StopContainersRequestProto proto = StopContainersRequestProto .getDefaultInstance(); StopContainersRequestProto.Builder builder = null; boolean viaProto = false; private List<ContainerId> containerIds = null; public StopContainersRequestPBImpl() { builder = StopContainersRequestProto.newBuilder(); } public StopContainersRequestPBImpl(StopContainersRequestProto proto) { this.proto = proto; viaProto = true; } public StopContainersRequestProto 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 TextFormat.shortDebugString(getProto()); } private void mergeLocalToBuilder() { if (this.containerIds != null) { addLocalContainerIdsToProto(); } } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = StopContainersRequestProto.newBuilder(proto); } viaProto = false; } private void addLocalContainerIdsToProto() { maybeInitBuilder(); builder.clearContainerId(); if (this.containerIds == null) return; List<ContainerIdProto> protoList = new ArrayList<ContainerIdProto>(); for (ContainerId id : containerIds) { protoList.add(convertToProtoFormat(id)); } builder.addAllContainerId(protoList); } private void initLocalContainerIds() { if (this.containerIds != null) { return; } StopContainersRequestProtoOrBuilder p = viaProto ? proto : builder; List<ContainerIdProto> containerIds = p.getContainerIdList(); this.containerIds = new ArrayList<ContainerId>(); for (ContainerIdProto id : containerIds) { this.containerIds.add(convertFromProtoFormat(id)); } } @Override public List<ContainerId> getContainerIds() { initLocalContainerIds(); return this.containerIds; } @Override public void setContainerIds(List<ContainerId> containerIds) { maybeInitBuilder(); if (containerIds == null) builder.clearContainerId(); this.containerIds = containerIds; } private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { return new ContainerIdPBImpl(p); } private ContainerIdProto convertToProtoFormat(ContainerId t) { return ((ContainerIdPBImpl) t).getProto(); } }
4,469
29.202703
90
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/KillApplicationRequestPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } 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(); } }
3,982
28.947368
91
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/ReservationUpdateRequestPBImpl.java
/** * 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.yarn.api.protocolrecords.ReservationUpdateRequest; import org.apache.hadoop.yarn.api.records.ReservationDefinition; import org.apache.hadoop.yarn.api.records.ReservationId; import org.apache.hadoop.yarn.api.records.impl.pb.ReservationDefinitionPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.ReservationIdPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.ReservationDefinitionProto; import org.apache.hadoop.yarn.proto.YarnProtos.ReservationIdProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationUpdateRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationUpdateRequestProtoOrBuilder; import com.google.protobuf.TextFormat; public class ReservationUpdateRequestPBImpl extends ReservationUpdateRequest { ReservationUpdateRequestProto proto = ReservationUpdateRequestProto .getDefaultInstance(); ReservationUpdateRequestProto.Builder builder = null; boolean viaProto = false; private ReservationDefinition reservationDefinition; private ReservationId reservationId; public ReservationUpdateRequestPBImpl() { builder = ReservationUpdateRequestProto.newBuilder(); } public ReservationUpdateRequestPBImpl(ReservationUpdateRequestProto proto) { this.proto = proto; viaProto = true; } public ReservationUpdateRequestProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } private void mergeLocalToBuilder() { if (this.reservationId != null) { builder.setReservationId(convertToProtoFormat(this.reservationId)); } if (this.reservationDefinition != null) { builder .setReservationDefinition(convertToProtoFormat(reservationDefinition)); } } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = ReservationUpdateRequestProto.newBuilder(proto); } viaProto = false; } @Override public ReservationDefinition getReservationDefinition() { ReservationUpdateRequestProtoOrBuilder p = viaProto ? proto : builder; if (reservationDefinition != null) { return reservationDefinition; } if (!p.hasReservationDefinition()) { return null; } reservationDefinition = convertFromProtoFormat(p.getReservationDefinition()); return reservationDefinition; } @Override public void setReservationDefinition( ReservationDefinition reservationDefinition) { maybeInitBuilder(); if (reservationDefinition == null) { builder.clearReservationDefinition(); } this.reservationDefinition = reservationDefinition; } @Override public ReservationId getReservationId() { ReservationUpdateRequestProtoOrBuilder p = viaProto ? proto : builder; if (reservationId != null) { return reservationId; } if (!p.hasReservationId()) { return null; } reservationId = convertFromProtoFormat(p.getReservationId()); return reservationId; } @Override public void setReservationId(ReservationId reservationId) { maybeInitBuilder(); if (reservationId == null) { builder.clearReservationId(); return; } this.reservationId = reservationId; } private ReservationIdPBImpl convertFromProtoFormat(ReservationIdProto p) { return new ReservationIdPBImpl(p); } private ReservationIdProto convertToProtoFormat(ReservationId t) { return ((ReservationIdPBImpl) t).getProto(); } private ReservationDefinitionProto convertToProtoFormat( ReservationDefinition r) { return ((ReservationDefinitionPBImpl) r).getProto(); } private ReservationDefinitionPBImpl convertFromProtoFormat( ReservationDefinitionProto r) { return new ReservationDefinitionPBImpl(r); } @Override public int hashCode() { return getProto().hashCode(); } @Override public boolean equals(Object other) { if (other == null) return false; if (other.getClass().isAssignableFrom(this.getClass())) { return this.getProto().equals(this.getClass().cast(other).getProto()); } return false; } @Override public String toString() { return TextFormat.shortDebugString(getProto()); } }
5,270
30.005882
93
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/MoveApplicationAcrossQueuesRequestPBImpl.java
/** * 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.MoveApplicationAcrossQueuesRequest; 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.MoveApplicationAcrossQueuesRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.MoveApplicationAcrossQueuesRequestProtoOrBuilder; import com.google.protobuf.TextFormat; @Private @Unstable public class MoveApplicationAcrossQueuesRequestPBImpl extends MoveApplicationAcrossQueuesRequest { MoveApplicationAcrossQueuesRequestProto proto = MoveApplicationAcrossQueuesRequestProto.getDefaultInstance(); MoveApplicationAcrossQueuesRequestProto.Builder builder = null; boolean viaProto = false; private ApplicationId applicationId; private String targetQueue; public MoveApplicationAcrossQueuesRequestPBImpl() { builder = MoveApplicationAcrossQueuesRequestProto.newBuilder(); } public MoveApplicationAcrossQueuesRequestPBImpl(MoveApplicationAcrossQueuesRequestProto proto) { this.proto = proto; viaProto = true; } public MoveApplicationAcrossQueuesRequestProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } @Override public ApplicationId getApplicationId() { if (this.applicationId != null) { return this.applicationId; } MoveApplicationAcrossQueuesRequestProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasApplicationId()) { return null; } this.applicationId = convertFromProtoFormat(p.getApplicationId()); return this.applicationId; } @Override public void setApplicationId(ApplicationId appId) { maybeInitBuilder(); if (applicationId == null) { builder.clearApplicationId(); } applicationId = appId; } @Override public String getTargetQueue() { if (this.targetQueue != null) { return this.targetQueue; } MoveApplicationAcrossQueuesRequestProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasApplicationId()) { return null; } this.targetQueue = p.getTargetQueue(); return this.targetQueue; } @Override public void setTargetQueue(String queue) { maybeInitBuilder(); if (applicationId == null) { builder.clearTargetQueue(); } targetQueue = queue; } private void mergeLocalToBuilder() { if (applicationId != null) { builder.setApplicationId(convertToProtoFormat(this.applicationId)); } if (targetQueue != null) { builder.setTargetQueue(this.targetQueue); } } private void mergeLocalToProto() { if (viaProto) { maybeInitBuilder(); } mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = MoveApplicationAcrossQueuesRequestProto.newBuilder(proto); } viaProto = false; } @Override public int hashCode() { return getProto().hashCode(); } @Override public boolean equals(Object other) { if (other == null) { return false; } if (other.getClass().isAssignableFrom(this.getClass())) { return this.getProto().equals(this.getClass().cast(other).getProto()); } return false; } @Override public String toString() { return TextFormat.shortDebugString(getProto()); } private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) { return new ApplicationIdPBImpl(p); } private ApplicationIdProto convertToProtoFormat(ApplicationId t) { return ((ApplicationIdPBImpl)t).getProto(); } }
4,805
29.226415
111
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainersResponsePBImpl.java
/** * 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.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.StopContainersResponse; import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.SerializedException; import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.SerializedExceptionPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.SerializedExceptionProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ContainerExceptionMapProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainersResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainersResponseProtoOrBuilder; import com.google.protobuf.TextFormat; @Private @Unstable public class StopContainersResponsePBImpl extends StopContainersResponse { StopContainersResponseProto proto = StopContainersResponseProto .getDefaultInstance(); StopContainersResponseProto.Builder builder = null; boolean viaProto = false; private List<ContainerId> succeededRequests = null; private Map<ContainerId, SerializedException> failedRequests = null; public StopContainersResponsePBImpl() { builder = StopContainersResponseProto.newBuilder(); } public StopContainersResponsePBImpl(StopContainersResponseProto proto) { this.proto = proto; viaProto = true; } public StopContainersResponseProto 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 TextFormat.shortDebugString(getProto()); } private void mergeLocalToProto() { if (viaProto) { maybeInitBuilder(); } mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = StopContainersResponseProto.newBuilder(proto); } viaProto = false; } private void mergeLocalToBuilder() { if (this.succeededRequests != null) { addSucceededRequestsToProto(); } if (this.failedRequests != null) { addFailedRequestsToProto(); } } private void addSucceededRequestsToProto() { maybeInitBuilder(); builder.clearSucceededRequests(); if (this.succeededRequests == null) { return; } Iterable<ContainerIdProto> iterable = new Iterable<ContainerIdProto>() { @Override public Iterator<ContainerIdProto> iterator() { return new Iterator<ContainerIdProto>() { Iterator<ContainerId> iter = succeededRequests.iterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public ContainerIdProto next() { return convertToProtoFormat(iter.next()); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; builder.addAllSucceededRequests(iterable); } private void addFailedRequestsToProto() { maybeInitBuilder(); builder.clearFailedRequests(); if (this.failedRequests == null) return; List<ContainerExceptionMapProto> protoList = new ArrayList<ContainerExceptionMapProto>(); for (Map.Entry<ContainerId, SerializedException> entry : this.failedRequests .entrySet()) { protoList.add(ContainerExceptionMapProto.newBuilder() .setContainerId(convertToProtoFormat(entry.getKey())) .setException(convertToProtoFormat(entry.getValue())).build()); } builder.addAllFailedRequests(protoList); } private void initSucceededRequests() { if (this.succeededRequests != null) return; StopContainersResponseProtoOrBuilder p = viaProto ? proto : builder; List<ContainerIdProto> list = p.getSucceededRequestsList(); this.succeededRequests = new ArrayList<ContainerId>(); for (ContainerIdProto c : list) { this.succeededRequests.add(convertFromProtoFormat(c)); } } private void initFailedRequests() { if (this.failedRequests != null) { return; } StopContainersResponseProtoOrBuilder p = viaProto ? proto : builder; List<ContainerExceptionMapProto> protoList = p.getFailedRequestsList(); this.failedRequests = new HashMap<ContainerId, SerializedException>(); for (ContainerExceptionMapProto ce : protoList) { this.failedRequests.put(convertFromProtoFormat(ce.getContainerId()), convertFromProtoFormat(ce.getException())); } } @Override public List<ContainerId> getSuccessfullyStoppedContainers() { initSucceededRequests(); return this.succeededRequests; } @Override public void setSuccessfullyStoppedContainers(List<ContainerId> succeededRequests) { maybeInitBuilder(); if (succeededRequests == null) { builder.clearSucceededRequests(); } this.succeededRequests = succeededRequests; } @Override public Map<ContainerId, SerializedException> getFailedRequests() { initFailedRequests(); return this.failedRequests; } @Override public void setFailedRequests( Map<ContainerId, SerializedException> failedRequests) { maybeInitBuilder(); if (failedRequests == null) builder.clearFailedRequests(); this.failedRequests = failedRequests; } private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { return new ContainerIdPBImpl(p); } private ContainerIdProto convertToProtoFormat(ContainerId t) { return ((ContainerIdPBImpl) t).getProto(); } private SerializedExceptionPBImpl convertFromProtoFormat( SerializedExceptionProto p) { return new SerializedExceptionPBImpl(p); } private SerializedExceptionProto convertToProtoFormat(SerializedException t) { return ((SerializedExceptionPBImpl) t).getProto(); } }
7,394
30.334746
91
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterNodesResponsePBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @Private @Unstable public class GetClusterNodesResponsePBImpl extends GetClusterNodesResponse { GetClusterNodesResponseProto proto = GetClusterNodesResponseProto.getDefaultInstance(); GetClusterNodesResponseProto.Builder builder = null; boolean viaProto = false; List<NodeReport> nodeManagerInfoList; public GetClusterNodesResponsePBImpl() { builder = GetClusterNodesResponseProto.newBuilder(); } public GetClusterNodesResponsePBImpl(GetClusterNodesResponseProto proto) { this.proto = proto; viaProto = true; } @Override public List<NodeReport> getNodeReports() { initLocalNodeManagerInfosList(); return this.nodeManagerInfoList; } @Override public void setNodeReports(List<NodeReport> 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 TextFormat.shortDebugString(getProto()); } 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<NodeReportProto> list = p.getNodeReportsList(); nodeManagerInfoList = new ArrayList<NodeReport>(); for (NodeReportProto a : list) { nodeManagerInfoList.add(convertFromProtoFormat(a)); } } private void addLocalNodeManagerInfosToProto() { maybeInitBuilder(); builder.clearNodeReports(); if (nodeManagerInfoList == null) return; Iterable<NodeReportProto> iterable = new Iterable<NodeReportProto>() { @Override public Iterator<NodeReportProto> iterator() { return new Iterator<NodeReportProto>() { Iterator<NodeReport> 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(); } }
5,112
28.051136
92
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterMetricsRequestPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } }
2,308
31.521127
91
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CancelDelegationTokenResponsePBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } }
2,129
31.272727
90
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetLabelsToNodesResponsePBImpl.java
/** * 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.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceStability.Evolving; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.NodeLabel; import org.apache.hadoop.yarn.api.records.impl.pb.NodeIdPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.NodeLabelPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; import org.apache.hadoop.yarn.api.protocolrecords.GetLabelsToNodesResponse; import org.apache.hadoop.yarn.proto.YarnProtos.LabelsToNodeIdsProto; import org.apache.hadoop.yarn.proto.YarnProtos.NodeLabelProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetLabelsToNodesResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetLabelsToNodesResponseProtoOrBuilder; public class GetLabelsToNodesResponsePBImpl extends GetLabelsToNodesResponse { GetLabelsToNodesResponseProto proto = GetLabelsToNodesResponseProto .getDefaultInstance(); GetLabelsToNodesResponseProto.Builder builder = null; boolean viaProto = false; private Map<NodeLabel, Set<NodeId>> labelsToNodes; public GetLabelsToNodesResponsePBImpl() { this.builder = GetLabelsToNodesResponseProto.newBuilder(); } public GetLabelsToNodesResponsePBImpl(GetLabelsToNodesResponseProto proto) { this.proto = proto; this.viaProto = true; } private void initLabelsToNodes() { if (this.labelsToNodes != null) { return; } GetLabelsToNodesResponseProtoOrBuilder p = viaProto ? proto : builder; List<LabelsToNodeIdsProto> list = p.getLabelsToNodesList(); this.labelsToNodes = new HashMap<NodeLabel, Set<NodeId>>(); for (LabelsToNodeIdsProto c : list) { Set<NodeId> setNodes = new HashSet<NodeId>(); for(NodeIdProto n : c.getNodeIdList()) { NodeId node = new NodeIdPBImpl(n); setNodes.add(node); } if (!setNodes.isEmpty()) { this.labelsToNodes .put(new NodeLabelPBImpl(c.getNodeLabels()), setNodes); } } } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = GetLabelsToNodesResponseProto.newBuilder(proto); } viaProto = false; } private void addLabelsToNodesToProto() { maybeInitBuilder(); builder.clearLabelsToNodes(); if (labelsToNodes == null) { return; } Iterable<LabelsToNodeIdsProto> iterable = new Iterable<LabelsToNodeIdsProto>() { @Override public Iterator<LabelsToNodeIdsProto> iterator() { return new Iterator<LabelsToNodeIdsProto>() { Iterator<Entry<NodeLabel, Set<NodeId>>> iter = labelsToNodes.entrySet().iterator(); @Override public void remove() { throw new UnsupportedOperationException(); } @Override public LabelsToNodeIdsProto next() { Entry<NodeLabel, Set<NodeId>> now = iter.next(); Set<NodeIdProto> nodeProtoSet = new HashSet<NodeIdProto>(); for(NodeId n : now.getValue()) { nodeProtoSet.add(convertToProtoFormat(n)); } return LabelsToNodeIdsProto.newBuilder() .setNodeLabels(convertToProtoFormat(now.getKey())) .addAllNodeId(nodeProtoSet) .build(); } @Override public boolean hasNext() { return iter.hasNext(); } }; } }; builder.addAllLabelsToNodes(iterable); } private void mergeLocalToBuilder() { if (this.labelsToNodes != null) { addLabelsToNodesToProto(); } } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } public GetLabelsToNodesResponseProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } private NodeIdProto convertToProtoFormat(NodeId t) { return ((NodeIdPBImpl)t).getProto(); } private NodeLabelProto convertToProtoFormat(NodeLabel l) { return ((NodeLabelPBImpl)l).getProto(); } @Override public int hashCode() { assert false : "hashCode not designed"; return 0; } @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 @Evolving public void setLabelsToNodes(Map<NodeLabel, Set<NodeId>> map) { initLabelsToNodes(); labelsToNodes.clear(); labelsToNodes.putAll(map); } @Override @Public @Evolving public Map<NodeLabel, Set<NodeId>> getLabelsToNodes() { initLabelsToNodes(); return this.labelsToNodes; } }
6,047
30.5
93
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationAttemptReportResponsePBImpl.java
/** * 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.GetApplicationAttemptReportResponse; import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationAttemptReportPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptReportProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationAttemptReportResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationAttemptReportResponseProtoOrBuilder; import com.google.protobuf.TextFormat; @Private @Unstable public class GetApplicationAttemptReportResponsePBImpl extends GetApplicationAttemptReportResponse { GetApplicationAttemptReportResponseProto proto = GetApplicationAttemptReportResponseProto.getDefaultInstance(); GetApplicationAttemptReportResponseProto.Builder builder = null; boolean viaProto = false; private ApplicationAttemptReport applicationAttemptReport = null; public GetApplicationAttemptReportResponsePBImpl() { builder = GetApplicationAttemptReportResponseProto.newBuilder(); } public GetApplicationAttemptReportResponsePBImpl( GetApplicationAttemptReportResponseProto proto) { this.proto = proto; viaProto = true; } public GetApplicationAttemptReportResponseProto 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 TextFormat.shortDebugString(getProto()); } private void mergeLocalToBuilder() { if (this.applicationAttemptReport != null) { builder .setApplicationAttemptReport(convertToProtoFormat(this.applicationAttemptReport)); } } private void mergeLocalToProto() { if (viaProto) { maybeInitBuilder(); } mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = GetApplicationAttemptReportResponseProto.newBuilder(proto); } viaProto = false; } @Override public ApplicationAttemptReport getApplicationAttemptReport() { if (this.applicationAttemptReport != null) { return this.applicationAttemptReport; } GetApplicationAttemptReportResponseProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasApplicationAttemptReport()) { return null; } this.applicationAttemptReport = convertFromProtoFormat(p.getApplicationAttemptReport()); return this.applicationAttemptReport; } @Override public void setApplicationAttemptReport( ApplicationAttemptReport ApplicationAttemptReport) { maybeInitBuilder(); if (ApplicationAttemptReport == null) { builder.clearApplicationAttemptReport(); } this.applicationAttemptReport = ApplicationAttemptReport; } private ApplicationAttemptReportPBImpl convertFromProtoFormat( ApplicationAttemptReportProto p) { return new ApplicationAttemptReportPBImpl(p); } private ApplicationAttemptReportProto convertToProtoFormat( ApplicationAttemptReport t) { return ((ApplicationAttemptReportPBImpl) t).getProto(); } }
4,560
31.347518
104
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/UseSharedCacheResourceResponsePBImpl.java
/** * 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.yarn.api.protocolrecords.UseSharedCacheResourceResponse; import org.apache.hadoop.yarn.proto.YarnServiceProtos.UseSharedCacheResourceResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.UseSharedCacheResourceResponseProtoOrBuilder; public class UseSharedCacheResourceResponsePBImpl extends UseSharedCacheResourceResponse { UseSharedCacheResourceResponseProto proto = UseSharedCacheResourceResponseProto .getDefaultInstance(); UseSharedCacheResourceResponseProto.Builder builder = null; boolean viaProto = false; public UseSharedCacheResourceResponsePBImpl() { builder = UseSharedCacheResourceResponseProto.newBuilder(); } public UseSharedCacheResourceResponsePBImpl( UseSharedCacheResourceResponseProto proto) { this.proto = proto; viaProto = true; } public UseSharedCacheResourceResponseProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } @Override public String getPath() { UseSharedCacheResourceResponseProtoOrBuilder p = viaProto ? proto : builder; return (p.hasPath()) ? p.getPath() : null; } @Override public void setPath(String path) { maybeInitBuilder(); if (path == null) { builder.clearPath(); return; } builder.setPath(path); } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = UseSharedCacheResourceResponseProto.newBuilder(proto); } viaProto = false; } }
2,553
30.925
99
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationsResponsePBImpl.java
/** * 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.GetApplicationsResponse; 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.GetApplicationsResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationsResponseProtoOrBuilder; import com.google.protobuf.TextFormat; @Private @Unstable public class GetApplicationsResponsePBImpl extends GetApplicationsResponse { GetApplicationsResponseProto proto = GetApplicationsResponseProto.getDefaultInstance(); GetApplicationsResponseProto.Builder builder = null; boolean viaProto = false; List<ApplicationReport> applicationList; public GetApplicationsResponsePBImpl() { builder = GetApplicationsResponseProto.newBuilder(); } public GetApplicationsResponsePBImpl(GetApplicationsResponseProto proto) { this.proto = proto; viaProto = true; } @Override public List<ApplicationReport> getApplicationList() { initLocalApplicationsList(); return this.applicationList; } @Override public void setApplicationList(List<ApplicationReport> applications) { maybeInitBuilder(); if (applications == null) builder.clearApplications(); this.applicationList = applications; } public GetApplicationsResponseProto 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 TextFormat.shortDebugString(getProto()); } 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 = GetApplicationsResponseProto.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; } GetApplicationsResponseProtoOrBuilder p = viaProto ? proto : builder; List<ApplicationReportProto> list = p.getApplicationsList(); applicationList = new ArrayList<ApplicationReport>(); for (ApplicationReportProto a : list) { applicationList.add(convertFromProtoFormat(a)); } } private void addLocalApplicationsToProto() { maybeInitBuilder(); builder.clearApplications(); if (applicationList == null) return; Iterable<ApplicationReportProto> iterable = new Iterable<ApplicationReportProto>() { @Override public Iterator<ApplicationReportProto> iterator() { return new Iterator<ApplicationReportProto>() { Iterator<ApplicationReport> 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(); } }
5,219
28.491525
92
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetQueueInfoRequestPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } }
3,939
28.848485
88
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RegisterApplicationMasterRequestPBImpl.java
/** * 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.proto.YarnServiceProtos.RegisterApplicationMasterRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterRequestProtoOrBuilder; import com.google.protobuf.TextFormat; @Private @Unstable public class RegisterApplicationMasterRequestPBImpl extends RegisterApplicationMasterRequest { RegisterApplicationMasterRequestProto proto = RegisterApplicationMasterRequestProto.getDefaultInstance(); RegisterApplicationMasterRequestProto.Builder builder = null; boolean viaProto = false; 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 TextFormat.shortDebugString(getProto()); } private void mergeLocalToBuilder() { } 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 String getHost() { RegisterApplicationMasterRequestProtoOrBuilder p = viaProto ? proto : builder; return p.getHost(); } @Override public void setHost(String host) { maybeInitBuilder(); if (host == null) { builder.clearHost(); return; } 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(); if (url == null) { builder.clearTrackingUrl(); return; } builder.setTrackingUrl(url); } }
3,873
27.696296
107
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetClusterNodeLabelsResponsePBImpl.java
/** * 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.List; import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodeLabelsResponse; import org.apache.hadoop.yarn.api.records.NodeLabel; import org.apache.hadoop.yarn.api.records.impl.pb.NodeLabelPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.NodeLabelProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterNodeLabelsResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterNodeLabelsResponseProtoOrBuilder; public class GetClusterNodeLabelsResponsePBImpl extends GetClusterNodeLabelsResponse { GetClusterNodeLabelsResponseProto proto = GetClusterNodeLabelsResponseProto .getDefaultInstance(); GetClusterNodeLabelsResponseProto.Builder builder = null; private List<NodeLabel> updatedNodeLabels; boolean viaProto = false; public GetClusterNodeLabelsResponsePBImpl() { builder = GetClusterNodeLabelsResponseProto.newBuilder(); } public GetClusterNodeLabelsResponsePBImpl( GetClusterNodeLabelsResponseProto proto) { this.proto = proto; viaProto = true; } public GetClusterNodeLabelsResponseProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void mergeLocalToBuilder() { if (this.updatedNodeLabels != null) { addNodeLabelsToProto(); } } private void addNodeLabelsToProto() { maybeInitBuilder(); builder.clearNodeLabels(); List<NodeLabelProto> protoList = new ArrayList<NodeLabelProto>(); for (NodeLabel r : this.updatedNodeLabels) { protoList.add(convertToProtoFormat(r)); } builder.addAllNodeLabels(protoList); } @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 int hashCode() { assert false : "hashCode not designed"; return 0; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = GetClusterNodeLabelsResponseProto.newBuilder(proto); } viaProto = false; } @Override public void setNodeLabels(List<NodeLabel> updatedNodeLabels) { maybeInitBuilder(); this.updatedNodeLabels = new ArrayList<>(); if (updatedNodeLabels == null) { builder.clearNodeLabels(); return; } this.updatedNodeLabels.addAll(updatedNodeLabels); } private void initLocalNodeLabels() { GetClusterNodeLabelsResponseProtoOrBuilder p = viaProto ? proto : builder; List<NodeLabelProto> attributesProtoList = p.getNodeLabelsList(); this.updatedNodeLabels = new ArrayList<NodeLabel>(); for (NodeLabelProto r : attributesProtoList) { this.updatedNodeLabels.add(convertFromProtoFormat(r)); } } @Override public List<NodeLabel> getNodeLabels() { if (this.updatedNodeLabels != null) { return this.updatedNodeLabels; } initLocalNodeLabels(); return this.updatedNodeLabels; } private NodeLabel convertFromProtoFormat(NodeLabelProto p) { return new NodeLabelPBImpl(p); } private NodeLabelProto convertToProtoFormat(NodeLabel t) { return ((NodeLabelPBImpl) t).getProto(); } @Override public String toString() { return getProto().toString(); } }
4,442
29.641379
97
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNewApplicationRequestPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } }
2,308
31.521127
91
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/ReservationDeleteRequestPBImpl.java
/** * 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.yarn.api.protocolrecords.ReservationDeleteRequest; import org.apache.hadoop.yarn.api.records.ReservationId; import org.apache.hadoop.yarn.api.records.impl.pb.ReservationIdPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.ReservationIdProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationDeleteRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationDeleteRequestProtoOrBuilder; import com.google.protobuf.TextFormat; public class ReservationDeleteRequestPBImpl extends ReservationDeleteRequest { ReservationDeleteRequestProto proto = ReservationDeleteRequestProto .getDefaultInstance(); ReservationDeleteRequestProto.Builder builder = null; boolean viaProto = false; private ReservationId reservationId; public ReservationDeleteRequestPBImpl() { builder = ReservationDeleteRequestProto.newBuilder(); } public ReservationDeleteRequestPBImpl(ReservationDeleteRequestProto proto) { this.proto = proto; viaProto = true; } public ReservationDeleteRequestProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } private void mergeLocalToBuilder() { if (this.reservationId != null) { builder.setReservationId(convertToProtoFormat(this.reservationId)); } } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = ReservationDeleteRequestProto.newBuilder(proto); } viaProto = false; } @Override public ReservationId getReservationId() { ReservationDeleteRequestProtoOrBuilder p = viaProto ? proto : builder; if (reservationId != null) { return reservationId; } if (!p.hasReservationId()) { return null; } reservationId = convertFromProtoFormat(p.getReservationId()); return reservationId; } @Override public void setReservationId(ReservationId reservationId) { maybeInitBuilder(); if (reservationId == null) { builder.clearReservationId(); return; } this.reservationId = reservationId; } private ReservationIdPBImpl convertFromProtoFormat(ReservationIdProto p) { return new ReservationIdPBImpl(p); } private ReservationIdProto convertToProtoFormat(ReservationId t) { return ((ReservationIdPBImpl) t).getProto(); } @Override public int hashCode() { return getProto().hashCode(); } @Override public boolean equals(Object other) { if (other == null) return false; if (other.getClass().isAssignableFrom(this.getClass())) { return this.getProto().equals(this.getClass().cast(other).getProto()); } return false; } @Override public String toString() { return TextFormat.shortDebugString(getProto()); } }
3,836
28.976563
93
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RegisterApplicationMasterResponsePBImpl.java
/** * 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.*; 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.Container; import org.apache.hadoop.yarn.api.records.NMToken; 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.NMTokenPBImpl; 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.ContainerProto; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.NMTokenProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterResponseProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnServiceProtos.SchedulerResourceTypes; import com.google.protobuf.ByteString; import com.google.protobuf.TextFormat; @Private @Unstable public class RegisterApplicationMasterResponsePBImpl extends RegisterApplicationMasterResponse { RegisterApplicationMasterResponseProto proto = RegisterApplicationMasterResponseProto.getDefaultInstance(); RegisterApplicationMasterResponseProto.Builder builder = null; boolean viaProto = false; private Resource maximumResourceCapability; private Map<ApplicationAccessType, String> applicationACLS = null; private List<Container> containersFromPreviousAttempts = null; private List<NMToken> nmTokens = null; private EnumSet<SchedulerResourceTypes> schedulerResourceTypes = 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 TextFormat.shortDebugString(getProto()); } 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(); } if (this.containersFromPreviousAttempts != null) { addContainersFromPreviousAttemptToProto(); } if (nmTokens != null) { builder.clearNmTokensFromPreviousAttempts(); Iterable<NMTokenProto> iterable = getTokenProtoIterable(nmTokens); builder.addAllNmTokensFromPreviousAttempts(iterable); } if(schedulerResourceTypes != null) { addSchedulerResourceTypes(); } } 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<ApplicationAccessType, String> getApplicationACLs() { initApplicationACLs(); return this.applicationACLS; } private void initApplicationACLs() { if (this.applicationACLS != null) { return; } RegisterApplicationMasterResponseProtoOrBuilder p = viaProto ? proto : builder; List<ApplicationACLMapProto> list = p.getApplicationACLsList(); this.applicationACLS = new HashMap<ApplicationAccessType, String>(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<? extends ApplicationACLMapProto> values = new Iterable<ApplicationACLMapProto>() { @Override public Iterator<ApplicationACLMapProto> iterator() { return new Iterator<ApplicationACLMapProto>() { Iterator<ApplicationAccessType> 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<ApplicationAccessType, String> appACLs) { if (appACLs == null) return; initApplicationACLs(); this.applicationACLS.clear(); this.applicationACLS.putAll(appACLs); } @Override public void setClientToAMTokenMasterKey(ByteBuffer key) { maybeInitBuilder(); if (key == null) { builder.clearClientToAmTokenMasterKey(); return; } builder.setClientToAmTokenMasterKey(ByteString.copyFrom(key)); } @Override public ByteBuffer getClientToAMTokenMasterKey() { maybeInitBuilder(); ByteBuffer key = ByteBuffer.wrap(builder.getClientToAmTokenMasterKey().toByteArray()); return key; } @Override public List<Container> getContainersFromPreviousAttempts() { if (this.containersFromPreviousAttempts != null) { return this.containersFromPreviousAttempts; } initContainersPreviousAttemptList(); return this.containersFromPreviousAttempts; } @Override public void setContainersFromPreviousAttempts(final List<Container> containers) { if (containers == null) { return; } this.containersFromPreviousAttempts = new ArrayList<Container>(); this.containersFromPreviousAttempts.addAll(containers); } @Override public String getQueue() { RegisterApplicationMasterResponseProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasQueue()) { return null; } return p.getQueue(); } @Override public void setQueue(String queue) { maybeInitBuilder(); if (queue == null) { builder.clearQueue(); } else { builder.setQueue(queue); } } private void initContainersPreviousAttemptList() { RegisterApplicationMasterResponseProtoOrBuilder p = viaProto ? proto : builder; List<ContainerProto> list = p.getContainersFromPreviousAttemptsList(); containersFromPreviousAttempts = new ArrayList<Container>(); for (ContainerProto c : list) { containersFromPreviousAttempts.add(convertFromProtoFormat(c)); } } private void addContainersFromPreviousAttemptToProto() { maybeInitBuilder(); builder.clearContainersFromPreviousAttempts(); List<ContainerProto> list = new ArrayList<ContainerProto>(); for (Container c : containersFromPreviousAttempts) { list.add(convertToProtoFormat(c)); } builder.addAllContainersFromPreviousAttempts(list); } @Override public List<NMToken> getNMTokensFromPreviousAttempts() { if (nmTokens != null) { return nmTokens; } initLocalNewNMTokenList(); return nmTokens; } @Override public void setNMTokensFromPreviousAttempts(final List<NMToken> nmTokens) { maybeInitBuilder(); if (nmTokens == null || nmTokens.isEmpty()) { if (this.nmTokens != null) { this.nmTokens.clear(); } builder.clearNmTokensFromPreviousAttempts(); return; } this.nmTokens = new ArrayList<NMToken>(); this.nmTokens.addAll(nmTokens); } private synchronized void initLocalNewNMTokenList() { RegisterApplicationMasterResponseProtoOrBuilder p = viaProto ? proto : builder; List<NMTokenProto> list = p.getNmTokensFromPreviousAttemptsList(); nmTokens = new ArrayList<NMToken>(); for (NMTokenProto t : list) { nmTokens.add(convertFromProtoFormat(t)); } } private synchronized Iterable<NMTokenProto> getTokenProtoIterable( final List<NMToken> nmTokenList) { maybeInitBuilder(); return new Iterable<NMTokenProto>() { @Override public synchronized Iterator<NMTokenProto> iterator() { return new Iterator<NMTokenProto>() { Iterator<NMToken> 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(); } }; } }; } @Override public EnumSet<SchedulerResourceTypes> getSchedulerResourceTypes() { initSchedulerResourceTypes(); return this.schedulerResourceTypes; } private void initSchedulerResourceTypes() { if (this.schedulerResourceTypes != null) { return; } RegisterApplicationMasterResponseProtoOrBuilder p = viaProto ? proto : builder; List<SchedulerResourceTypes> list = p.getSchedulerResourceTypesList(); if (list.isEmpty()) { this.schedulerResourceTypes = EnumSet.noneOf(SchedulerResourceTypes.class); } else { this.schedulerResourceTypes = EnumSet.copyOf(list); } } private void addSchedulerResourceTypes() { maybeInitBuilder(); builder.clearSchedulerResourceTypes(); if (schedulerResourceTypes == null) { return; } Iterable<? extends SchedulerResourceTypes> values = new Iterable<SchedulerResourceTypes>() { @Override public Iterator<SchedulerResourceTypes> iterator() { return new Iterator<SchedulerResourceTypes>() { Iterator<SchedulerResourceTypes> settingsIterator = schedulerResourceTypes.iterator(); @Override public boolean hasNext() { return settingsIterator.hasNext(); } @Override public SchedulerResourceTypes next() { return settingsIterator.next(); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; this.builder.addAllSchedulerResourceTypes(values); } @Override public void setSchedulerResourceTypes(EnumSet<SchedulerResourceTypes> types) { if (types == null) { return; } initSchedulerResourceTypes(); this.schedulerResourceTypes.clear(); this.schedulerResourceTypes.addAll(types); } private Resource convertFromProtoFormat(ResourceProto resource) { return new ResourcePBImpl(resource); } private ResourceProto convertToProtoFormat(Resource resource) { return ((ResourcePBImpl)resource).getProto(); } private ContainerPBImpl convertFromProtoFormat(ContainerProto p) { return new ContainerPBImpl(p); } private ContainerProto convertToProtoFormat(Container t) { return ((ContainerPBImpl) t).getProto(); } private NMTokenProto convertToProtoFormat(NMToken token) { return ((NMTokenPBImpl) token).getProto(); } private NMToken convertFromProtoFormat(NMTokenProto proto) { return new NMTokenPBImpl(proto); } }
14,047
29.53913
102
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/MoveApplicationAcrossQueuesResponsePBImpl.java
/** * 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.MoveApplicationAcrossQueuesResponse; import org.apache.hadoop.yarn.proto.YarnServiceProtos.MoveApplicationAcrossQueuesResponseProto; import com.google.protobuf.TextFormat; @Private @Unstable public class MoveApplicationAcrossQueuesResponsePBImpl extends MoveApplicationAcrossQueuesResponse { MoveApplicationAcrossQueuesResponseProto proto = MoveApplicationAcrossQueuesResponseProto.getDefaultInstance(); MoveApplicationAcrossQueuesResponseProto.Builder builder = null; boolean viaProto = false; public MoveApplicationAcrossQueuesResponsePBImpl() { builder = MoveApplicationAcrossQueuesResponseProto.newBuilder(); } public MoveApplicationAcrossQueuesResponsePBImpl(MoveApplicationAcrossQueuesResponseProto proto) { this.proto = proto; viaProto = true; } public MoveApplicationAcrossQueuesResponseProto getProto() { proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } @Override public int hashCode() { return getProto().hashCode(); } @Override public boolean equals(Object other) { if (other == null) return false; if (other.getClass().isAssignableFrom(this.getClass())) { return this.getProto().equals(this.getClass().cast(other).getProto()); } return false; } @Override public String toString() { return TextFormat.shortDebugString(getProto()); } }
2,436
34.318841
113
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusesResponsePBImpl.java
/** * 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.HashMap; 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.GetContainerStatusesResponse; import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerStatus; import org.apache.hadoop.yarn.api.records.SerializedException; import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.ContainerStatusPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.SerializedExceptionPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto; import org.apache.hadoop.yarn.proto.YarnProtos.SerializedExceptionProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ContainerExceptionMapProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusesResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusesResponseProtoOrBuilder; import com.google.protobuf.TextFormat; @Private @Unstable public class GetContainerStatusesResponsePBImpl extends GetContainerStatusesResponse { GetContainerStatusesResponseProto proto = GetContainerStatusesResponseProto .getDefaultInstance(); GetContainerStatusesResponseProto.Builder builder = null; boolean viaProto = false; private List<ContainerStatus> containerStatuses = null; private Map<ContainerId, SerializedException> failedRequests = null; public GetContainerStatusesResponsePBImpl() { builder = GetContainerStatusesResponseProto.newBuilder(); } public GetContainerStatusesResponsePBImpl( GetContainerStatusesResponseProto proto) { this.proto = proto; viaProto = true; } public GetContainerStatusesResponseProto 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 TextFormat.shortDebugString(getProto()); } private void mergeLocalToBuilder() { if (this.containerStatuses != null) { addLocalContainerStatusesToProto(); } if (this.failedRequests != null) { addFailedRequestsToProto(); } } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = GetContainerStatusesResponseProto.newBuilder(proto); } viaProto = false; } private void addLocalContainerStatusesToProto() { maybeInitBuilder(); builder.clearStatus(); if (this.containerStatuses == null) return; List<ContainerStatusProto> protoList = new ArrayList<ContainerStatusProto>(); for (ContainerStatus status : containerStatuses) { protoList.add(convertToProtoFormat(status)); } builder.addAllStatus(protoList); } private void addFailedRequestsToProto() { maybeInitBuilder(); builder.clearFailedRequests(); if (this.failedRequests == null) return; List<ContainerExceptionMapProto> protoList = new ArrayList<ContainerExceptionMapProto>(); for (Map.Entry<ContainerId, SerializedException> entry : this.failedRequests .entrySet()) { protoList.add(ContainerExceptionMapProto.newBuilder() .setContainerId(convertToProtoFormat(entry.getKey())) .setException(convertToProtoFormat(entry.getValue())).build()); } builder.addAllFailedRequests(protoList); } private void initLocalContainerStatuses() { if (this.containerStatuses != null) { return; } GetContainerStatusesResponseProtoOrBuilder p = viaProto ? proto : builder; List<ContainerStatusProto> statuses = p.getStatusList(); this.containerStatuses = new ArrayList<ContainerStatus>(); for (ContainerStatusProto status : statuses) { this.containerStatuses.add(convertFromProtoFormat(status)); } } private void initFailedRequests() { if (this.failedRequests != null) { return; } GetContainerStatusesResponseProtoOrBuilder p = viaProto ? proto : builder; List<ContainerExceptionMapProto> protoList = p.getFailedRequestsList(); this.failedRequests = new HashMap<ContainerId, SerializedException>(); for (ContainerExceptionMapProto ce : protoList) { this.failedRequests.put(convertFromProtoFormat(ce.getContainerId()), convertFromProtoFormat(ce.getException())); } } @Override public List<ContainerStatus> getContainerStatuses() { initLocalContainerStatuses(); return this.containerStatuses; } @Override public void setContainerStatuses(List<ContainerStatus> statuses) { maybeInitBuilder(); if (statuses == null) builder.clearStatus(); this.containerStatuses = statuses; } @Override public Map<ContainerId, SerializedException> getFailedRequests() { initFailedRequests(); return this.failedRequests; } @Override public void setFailedRequests( Map<ContainerId, SerializedException> failedRequests) { maybeInitBuilder(); if (failedRequests == null) builder.clearFailedRequests(); this.failedRequests = failedRequests; } private ContainerStatusPBImpl convertFromProtoFormat(ContainerStatusProto p) { return new ContainerStatusPBImpl(p); } private ContainerStatusProto convertToProtoFormat(ContainerStatus t) { return ((ContainerStatusPBImpl) t).getProto(); } private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { return new ContainerIdPBImpl(p); } private ContainerIdProto convertToProtoFormat(ContainerId t) { return ((ContainerIdPBImpl) t).getProto(); } private SerializedExceptionPBImpl convertFromProtoFormat( SerializedExceptionProto p) { return new SerializedExceptionPBImpl(p); } private SerializedExceptionProto convertToProtoFormat(SerializedException t) { return ((SerializedExceptionPBImpl) t).getProto(); } }
7,435
32.048889
97
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationReportResponsePBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } 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(); } }
4,188
30.496241
99
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @Private @Unstable public class ContainerLaunchContextPBImpl extends ContainerLaunchContext { ContainerLaunchContextProto proto = ContainerLaunchContextProto.getDefaultInstance(); ContainerLaunchContextProto.Builder builder = null; boolean viaProto = false; private Map<String, LocalResource> localResources = null; private ByteBuffer tokens = null; private Map<String, ByteBuffer> serviceData = null; private Map<String, String> environment = null; private List<String> commands = null; private Map<ApplicationAccessType, String> 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 TextFormat.shortDebugString(getProto()); } 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<String> getCommands() { initCommands(); return this.commands; } private void initCommands() { if (this.commands != null) { return; } ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; List<String> list = p.getCommandList(); this.commands = new ArrayList<String>(); for (String c : list) { this.commands.add(c); } } @Override public void setCommands(final List<String> 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<String, LocalResource> getLocalResources() { initLocalResources(); return this.localResources; } private void initLocalResources() { if (this.localResources != null) { return; } ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; List<StringLocalResourceMapProto> list = p.getLocalResourcesList(); this.localResources = new HashMap<String, LocalResource>(); for (StringLocalResourceMapProto c : list) { this.localResources.put(c.getKey(), convertFromProtoFormat(c.getValue())); } } @Override public void setLocalResources( final Map<String, LocalResource> localResources) { if (localResources == null) return; initLocalResources(); this.localResources.clear(); this.localResources.putAll(localResources); } private void addLocalResourcesToProto() { maybeInitBuilder(); builder.clearLocalResources(); if (localResources == null) return; Iterable<StringLocalResourceMapProto> iterable = new Iterable<StringLocalResourceMapProto>() { @Override public Iterator<StringLocalResourceMapProto> iterator() { return new Iterator<StringLocalResourceMapProto>() { Iterator<String> 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<String, ByteBuffer> getServiceData() { initServiceData(); return this.serviceData; } private void initServiceData() { if (this.serviceData != null) { return; } ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; List<StringBytesMapProto> list = p.getServiceDataList(); this.serviceData = new HashMap<String, ByteBuffer>(); for (StringBytesMapProto c : list) { this.serviceData.put(c.getKey(), convertFromProtoFormat(c.getValue())); } } @Override public void setServiceData(final Map<String, ByteBuffer> serviceData) { if (serviceData == null) return; initServiceData(); this.serviceData.putAll(serviceData); } private void addServiceDataToProto() { maybeInitBuilder(); builder.clearServiceData(); if (serviceData == null) return; Iterable<StringBytesMapProto> iterable = new Iterable<StringBytesMapProto>() { @Override public Iterator<StringBytesMapProto> iterator() { return new Iterator<StringBytesMapProto>() { Iterator<String> 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<String, String> getEnvironment() { initEnv(); return this.environment; } private void initEnv() { if (this.environment != null) { return; } ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; List<StringStringMapProto> list = p.getEnvironmentList(); this.environment = new HashMap<String, String>(); for (StringStringMapProto c : list) { this.environment.put(c.getKey(), c.getValue()); } } @Override public void setEnvironment(final Map<String, String> env) { if (env == null) return; initEnv(); this.environment.clear(); this.environment.putAll(env); } private void addEnvToProto() { maybeInitBuilder(); builder.clearEnvironment(); if (environment == null) return; Iterable<StringStringMapProto> iterable = new Iterable<StringStringMapProto>() { @Override public Iterator<StringStringMapProto> iterator() { return new Iterator<StringStringMapProto>() { Iterator<String> 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<ApplicationAccessType, String> getApplicationACLs() { initApplicationACLs(); return this.applicationACLS; } private void initApplicationACLs() { if (this.applicationACLS != null) { return; } ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; List<ApplicationACLMapProto> list = p.getApplicationACLsList(); this.applicationACLS = new HashMap<ApplicationAccessType, String>(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<? extends ApplicationACLMapProto> values = new Iterable<ApplicationACLMapProto>() { @Override public Iterator<ApplicationACLMapProto> iterator() { return new Iterator<ApplicationACLMapProto>() { Iterator<ApplicationAccessType> 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<ApplicationAccessType, String> 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(); } }
13,485
27.877944
84
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java
/** * 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()); } } }
9,164
27.820755
77
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationResourceUsageReportPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } 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; } @Override public synchronized void setMemorySeconds(long memory_seconds) { maybeInitBuilder(); builder.setMemorySeconds(memory_seconds); } @Override public synchronized long getMemorySeconds() { ApplicationResourceUsageReportProtoOrBuilder p = viaProto ? proto : builder; return p.getMemorySeconds(); } @Override public synchronized void setVcoreSeconds(long vcore_seconds) { maybeInitBuilder(); builder.setVcoreSeconds(vcore_seconds); } @Override public synchronized long getVcoreSeconds() { ApplicationResourceUsageReportProtoOrBuilder p = viaProto ? proto : builder; return (p.getVcoreSeconds()); } private ResourcePBImpl convertFromProtoFormat(ResourceProto p) { return new ResourcePBImpl(p); } private ResourceProto convertToProtoFormat(Resource t) { return ((ResourcePBImpl)t).getProto(); } }
7,336
30.221277
92
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/package-info.java
/* * 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;
945
42
75
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NMTokenPBImpl.java
/** * 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); } }
4,035
27.223776
76
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationReportPBImpl.java
/** * 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.LogAggregationStatus; import org.apache.hadoop.yarn.api.records.Priority; 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.LogAggregationStatusProto; import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto; import org.apache.hadoop.yarn.proto.YarnProtos.YarnApplicationStateProto; import com.google.protobuf.TextFormat; import java.util.HashSet; import java.util.Set; @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; private Token amRmToken = null; private Set<String> applicationTags = null; private Priority priority = 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 Token getAMRMToken() { ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; if (amRmToken != null) { return amRmToken; } if (!p.hasAmRmToken()) { return null; } amRmToken = convertFromProtoFormat(p.getAmRmToken()); return amRmToken; } private void initApplicationTags() { if (this.applicationTags != null) { return; } ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; this.applicationTags = new HashSet<String>(); this.applicationTags.addAll(p.getApplicationTagsList()); } @Override public Set<String> getApplicationTags() { initApplicationTags(); return this.applicationTags; } @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 setApplicationTags(Set<String> tags) { maybeInitBuilder(); if (tags == null || tags.isEmpty()) { builder.clearApplicationTags(); } this.applicationTags = tags; } @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); } @Override public void setAMRMToken(Token amRmToken) { maybeInitBuilder(); if (amRmToken == null) { builder.clearAmRmToken(); } this.amRmToken = amRmToken; } 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 TextFormat.shortDebugString(getProto()); } 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)); } if (this.amRmToken != null && !((TokenPBImpl) this.amRmToken).getProto().equals( builder.getAmRmToken())) { builder.setAmRmToken(convertToProtoFormat(this.amRmToken)); } if (this.applicationTags != null && !this.applicationTags.isEmpty()) { builder.clearApplicationTags(); builder.addAllApplicationTags(this.applicationTags); } if (this.priority != null && !((PriorityPBImpl) this.priority).getProto().equals( builder.getPriority())) { builder.setPriority(convertToProtoFormat(this.priority)); } } 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(); } private PriorityPBImpl convertFromProtoFormat(PriorityProto p) { return new PriorityPBImpl(p); } private PriorityProto convertToProtoFormat(Priority t) { return ((PriorityPBImpl)t).getProto(); } @Override public LogAggregationStatus getLogAggregationStatus() { ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasLogAggregationStatus()) { return null; } return convertFromProtoFormat(p.getLogAggregationStatus()); } @Override public void setLogAggregationStatus( LogAggregationStatus logAggregationStatus) { maybeInitBuilder(); if (logAggregationStatus == null) { builder.clearLogAggregationStatus(); return; } builder.setLogAggregationStatus( convertToProtoFormat(logAggregationStatus)); } private LogAggregationStatus convertFromProtoFormat( LogAggregationStatusProto s) { return ProtoUtils.convertFromProtoFormat(s); } private LogAggregationStatusProto convertToProtoFormat(LogAggregationStatus s) { return ProtoUtils.convertToProtoFormat(s); } @Override public boolean isUnmanagedApp() { ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; return p.getUnmanagedApplication(); } @Override public void setUnmanagedApp(boolean unmanagedApplication) { maybeInitBuilder(); builder.setUnmanagedApplication(unmanagedApplication); } @Override public Priority getPriority() { ApplicationReportProtoOrBuilder 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; } }
17,951
27.315457
104
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionContractPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @Private @Unstable public class PreemptionContractPBImpl extends PreemptionContract { PreemptionContractProto proto = PreemptionContractProto.getDefaultInstance(); PreemptionContractProto.Builder builder = null; boolean viaProto = false; private Set<PreemptionContainer> containers; private List<PreemptionResourceRequest> 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 TextFormat.shortDebugString(getProto()); } 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<PreemptionContainer> getContainers() { initPreemptionContainers(); return containers; } @Override public synchronized void setContainers( final Set<PreemptionContainer> containers) { if (null == containers) { builder.clearContainer(); } this.containers = containers; } @Override public synchronized List<PreemptionResourceRequest> getResourceRequest() { initPreemptionResourceRequests(); return resources; } @Override public synchronized void setResourceRequest( final List<PreemptionResourceRequest> req) { if (null == resources) { builder.clearResource(); } this.resources = req; } private void initPreemptionResourceRequests() { if (resources != null) { return; } PreemptionContractProtoOrBuilder p = viaProto ? proto : builder; List<PreemptionResourceRequestProto> list = p.getResourceList(); resources = new ArrayList<PreemptionResourceRequest>(); for (PreemptionResourceRequestProto rr : list) { resources.add(convertFromProtoFormat(rr)); } } private void addResourcesToProto() { maybeInitBuilder(); builder.clearResource(); if (null == resources) { return; } Iterable<PreemptionResourceRequestProto> iterable = new Iterable<PreemptionResourceRequestProto>() { @Override public Iterator<PreemptionResourceRequestProto> iterator() { return new Iterator<PreemptionResourceRequestProto>() { Iterator<PreemptionResourceRequest> 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<PreemptionContainerProto> list = p.getContainerList(); containers = new HashSet<PreemptionContainer>(); for (PreemptionContainerProto c : list) { containers.add(convertFromProtoFormat(c)); } } private void addContainersToProto() { maybeInitBuilder(); builder.clearContainer(); if (null == containers) { return; } Iterable<PreemptionContainerProto> iterable = new Iterable<PreemptionContainerProto>() { @Override public Iterator<PreemptionContainerProto> iterator() { return new Iterator<PreemptionContainerProto>() { Iterator<PreemptionContainer> 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(); } }
7,255
27.566929
100
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourcePBImpl.java
/** * 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; } }
2,584
26.795699
75
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeLabelPBImpl.java
/** * 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.yarn.api.records.NodeLabel; import org.apache.hadoop.yarn.proto.YarnProtos.NodeLabelProto; import org.apache.hadoop.yarn.proto.YarnProtos.NodeLabelProtoOrBuilder; public class NodeLabelPBImpl extends NodeLabel { NodeLabelProto proto = NodeLabelProto.getDefaultInstance(); NodeLabelProto.Builder builder = null; boolean viaProto = false; public NodeLabelPBImpl() { builder = NodeLabelProto.newBuilder(); } public NodeLabelPBImpl(NodeLabelProto proto) { this.proto = proto; viaProto = true; } public NodeLabelProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); proto = builder.build(); viaProto = true; } @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 maybeInitBuilder() { if (viaProto || builder == null) { builder = NodeLabelProto.newBuilder(proto); } viaProto = false; } @Override public int hashCode() { return getProto().hashCode(); } @Override public String getName() { NodeLabelProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasName()) { return null; } return (p.getName()); } @Override public void setName(String name) { maybeInitBuilder(); if (name == null) { builder.clearName(); return; } builder.setName(name); } @Override public boolean isExclusive() { NodeLabelProtoOrBuilder p = viaProto ? proto : builder; return p.getIsExclusive(); } @Override public void setExclusivity(boolean isExclusive) { maybeInitBuilder(); builder.setIsExclusive(isExclusive); } }
2,845
25.598131
76
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/LogAggregationContextPBImpl.java
/** * 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.yarn.api.records.LogAggregationContext; import org.apache.hadoop.yarn.proto.YarnProtos.LogAggregationContextProto; import org.apache.hadoop.yarn.proto.YarnProtos.LogAggregationContextProtoOrBuilder; import com.google.protobuf.TextFormat; public class LogAggregationContextPBImpl extends LogAggregationContext{ LogAggregationContextProto proto = LogAggregationContextProto.getDefaultInstance(); LogAggregationContextProto.Builder builder = null; boolean viaProto = false; public LogAggregationContextPBImpl() { builder = LogAggregationContextProto.newBuilder(); } public LogAggregationContextPBImpl(LogAggregationContextProto proto) { this.proto = proto; viaProto = true; } public LogAggregationContextProto 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 TextFormat.shortDebugString(getProto()); } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = LogAggregationContextProto.newBuilder(proto); } viaProto = false; } @Override public String getIncludePattern() { LogAggregationContextProtoOrBuilder p = viaProto ? proto : builder; if (! p.hasIncludePattern()) { return null; } return p.getIncludePattern(); } @Override public void setIncludePattern(String includePattern) { maybeInitBuilder(); if (includePattern == null) { builder.clearIncludePattern(); return; } builder.setIncludePattern(includePattern); } @Override public String getExcludePattern() { LogAggregationContextProtoOrBuilder p = viaProto ? proto : builder; if (! p.hasExcludePattern()) { return null; } return p.getExcludePattern(); } @Override public void setExcludePattern(String excludePattern) { maybeInitBuilder(); if (excludePattern == null) { builder.clearExcludePattern(); return; } builder.setExcludePattern(excludePattern); } @Override public String getRolledLogsIncludePattern() { LogAggregationContextProtoOrBuilder p = viaProto ? proto : builder; if (! p.hasRolledLogsIncludePattern()) { return null; } return p.getRolledLogsIncludePattern(); } @Override public void setRolledLogsIncludePattern(String rolledLogsIncludePattern) { maybeInitBuilder(); if (rolledLogsIncludePattern == null) { builder.clearRolledLogsIncludePattern(); return; } builder.setRolledLogsIncludePattern(rolledLogsIncludePattern); } @Override public String getRolledLogsExcludePattern() { LogAggregationContextProtoOrBuilder p = viaProto ? proto : builder; if (! p.hasRolledLogsExcludePattern()) { return null; } return p.getRolledLogsExcludePattern(); } @Override public void setRolledLogsExcludePattern(String rolledLogsExcludePattern) { maybeInitBuilder(); if (rolledLogsExcludePattern == null) { builder.clearRolledLogsExcludePattern(); return; } builder.setRolledLogsExcludePattern(rolledLogsExcludePattern); } }
4,510
27.371069
85
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoBase.java
/** * 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; import com.google.protobuf.TextFormat; @Private @Unstable public abstract class ProtoBase <T extends Message> { 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 TextFormat.shortDebugString(getProto()); } protected final ByteBuffer convertFromProtoFormat(ByteString byteString) { return ProtoUtils.convertFromProtoFormat(byteString); } protected final ByteString convertToProtoFormat(ByteBuffer byteBuffer) { return ProtoUtils.convertToProtoFormat(byteBuffer); } }
2,004
29.378788
76
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceBlacklistRequestPBImpl.java
/** * 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<String> blacklistAdditions = null; List<String> 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.clearBlacklistRemovals(); if (this.blacklistRemovals == null) { return; } builder.addAllBlacklistRemovals(this.blacklistRemovals); } private void initBlacklistAdditions() { if (this.blacklistAdditions != null) { return; } ResourceBlacklistRequestProtoOrBuilder p = viaProto ? proto : builder; List<String> list = p.getBlacklistAdditionsList(); this.blacklistAdditions = new ArrayList<String>(); this.blacklistAdditions.addAll(list); } private void initBlacklistRemovals() { if (this.blacklistRemovals != null) { return; } ResourceBlacklistRequestProtoOrBuilder p = viaProto ? proto : builder; List<String> list = p.getBlacklistRemovalsList(); this.blacklistRemovals = new ArrayList<String>(); this.blacklistRemovals.addAll(list); } @Override public List<String> getBlacklistAdditions() { initBlacklistAdditions(); return this.blacklistAdditions; } @Override public void setBlacklistAdditions(List<String> resourceNames) { if (resourceNames == null || resourceNames.isEmpty()) { if (this.blacklistAdditions != null) { this.blacklistAdditions.clear(); } return; } initBlacklistAdditions(); this.blacklistAdditions.clear(); this.blacklistAdditions.addAll(resourceNames); } @Override public List<String> getBlacklistRemovals() { initBlacklistRemovals(); return this.blacklistRemovals; } @Override public void setBlacklistRemovals(List<String> resourceNames) { if (resourceNames == null || resourceNames.isEmpty()) { if (this.blacklistRemovals != null) { this.blacklistRemovals.clear(); } return; } initBlacklistRemovals(); this.blacklistRemovals.clear(); this.blacklistRemovals.addAll(resourceNames); } @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; } }
5,074
28.33526
86
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationAttemptReportPBImpl.java
/** * 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.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptReportProto; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptReportProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.YarnApplicationAttemptStateProto; import com.google.protobuf.TextFormat; public class ApplicationAttemptReportPBImpl extends ApplicationAttemptReport { ApplicationAttemptReportProto proto = ApplicationAttemptReportProto .getDefaultInstance(); ApplicationAttemptReportProto.Builder builder = null; boolean viaProto = false; private ApplicationAttemptId ApplicationAttemptId; private ContainerId amContainerId; public ApplicationAttemptReportPBImpl() { builder = ApplicationAttemptReportProto.newBuilder(); } public ApplicationAttemptReportPBImpl(ApplicationAttemptReportProto proto) { this.proto = proto; viaProto = true; } @Override public ApplicationAttemptId getApplicationAttemptId() { if (this.ApplicationAttemptId != null) { return this.ApplicationAttemptId; } ApplicationAttemptReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasApplicationAttemptId()) { return null; } this.ApplicationAttemptId = convertFromProtoFormat(p.getApplicationAttemptId()); return this.ApplicationAttemptId; } @Override public String getHost() { ApplicationAttemptReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasHost()) { return null; } return p.getHost(); } @Override public int getRpcPort() { ApplicationAttemptReportProtoOrBuilder p = viaProto ? proto : builder; return p.getRpcPort(); } @Override public String getTrackingUrl() { ApplicationAttemptReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasTrackingUrl()) { return null; } return p.getTrackingUrl(); } @Override public String getOriginalTrackingUrl() { ApplicationAttemptReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasOriginalTrackingUrl()) { return null; } return p.getOriginalTrackingUrl(); } @Override public String getDiagnostics() { ApplicationAttemptReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasDiagnostics()) { return null; } return p.getDiagnostics(); } @Override public YarnApplicationAttemptState getYarnApplicationAttemptState() { ApplicationAttemptReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasYarnApplicationAttemptState()) { return null; } return convertFromProtoFormat(p.getYarnApplicationAttemptState()); } @Override public void setYarnApplicationAttemptState(YarnApplicationAttemptState state) { maybeInitBuilder(); if (state == null) { builder.clearYarnApplicationAttemptState(); return; } builder.setYarnApplicationAttemptState(convertToProtoFormat(state)); } private YarnApplicationAttemptStateProto convertToProtoFormat( YarnApplicationAttemptState state) { return ProtoUtils.convertToProtoFormat(state); } private YarnApplicationAttemptState convertFromProtoFormat( YarnApplicationAttemptStateProto yarnApplicationAttemptState) { return ProtoUtils.convertFromProtoFormat(yarnApplicationAttemptState); } @Override public void setApplicationAttemptId(ApplicationAttemptId applicationAttemptId) { maybeInitBuilder(); if (applicationAttemptId == null) builder.clearApplicationAttemptId(); this.ApplicationAttemptId = applicationAttemptId; } @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 setTrackingUrl(String url) { maybeInitBuilder(); if (url == null) { builder.clearTrackingUrl(); return; } builder.setTrackingUrl(url); } @Override public void setOriginalTrackingUrl(String oUrl) { maybeInitBuilder(); if (oUrl == null) { builder.clearOriginalTrackingUrl(); return; } builder.setOriginalTrackingUrl(oUrl); } @Override public void setDiagnostics(String diagnostics) { maybeInitBuilder(); if (diagnostics == null) { builder.clearDiagnostics(); return; } builder.setDiagnostics(diagnostics); } public ApplicationAttemptReportProto 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 TextFormat.shortDebugString(getProto()); } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = ApplicationAttemptReportProto.newBuilder(proto); } viaProto = false; } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void mergeLocalToBuilder() { if (this.ApplicationAttemptId != null && !((ApplicationAttemptIdPBImpl) this.ApplicationAttemptId).getProto() .equals(builder.getApplicationAttemptId())) { builder .setApplicationAttemptId(convertToProtoFormat(this.ApplicationAttemptId)); } if (this.amContainerId != null && !((ContainerIdPBImpl) this.amContainerId).getProto().equals( builder.getAmContainerId())) { builder.setAmContainerId(convertToProtoFormat(this.amContainerId)); } } private ContainerIdProto convertToProtoFormat(ContainerId amContainerId) { return ((ContainerIdPBImpl) amContainerId).getProto(); } private ContainerIdPBImpl convertFromProtoFormat( ContainerIdProto amContainerId) { return new ContainerIdPBImpl(amContainerId); } private ApplicationAttemptIdProto convertToProtoFormat(ApplicationAttemptId t) { return ((ApplicationAttemptIdPBImpl) t).getProto(); } private ApplicationAttemptIdPBImpl convertFromProtoFormat( ApplicationAttemptIdProto applicationAttemptId) { return new ApplicationAttemptIdPBImpl(applicationAttemptId); } @Override public ContainerId getAMContainerId() { if (this.amContainerId != null) { return this.amContainerId; } ApplicationAttemptReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasAmContainerId()) { return null; } this.amContainerId = convertFromProtoFormat(p.getAmContainerId()); return this.amContainerId; } @Override public void setAMContainerId(ContainerId amContainerId) { maybeInitBuilder(); if (amContainerId == null) builder.clearAmContainerId(); this.amContainerId = amContainerId; } @Override public void setStartTime(long startTime) { maybeInitBuilder(); builder.setStartTime(startTime); } @Override public void setFinishTime(long finishTime) { maybeInitBuilder(); builder.setFinishTime(finishTime); } @Override public long getStartTime() { ApplicationAttemptReportProtoOrBuilder p = viaProto ? proto : builder; return p.getStartTime(); } @Override public long getFinishTime() { ApplicationAttemptReportProtoOrBuilder p = viaProto ? proto : builder; return p.getFinishTime(); } }
8,997
27.656051
86
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeReportPBImpl.java
/** * 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.Set; 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; import com.google.protobuf.TextFormat; @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; Set<String> labels; 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 TextFormat.shortDebugString(getProto()); } 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)); } if (this.labels != null) { builder.clearNodeLabels(); builder.addAllNodeLabels(this.labels); } } 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(); } @Override public Set<String> getNodeLabels() { initNodeLabels(); return this.labels; } @Override public void setNodeLabels(Set<String> nodeLabels) { maybeInitBuilder(); builder.clearNodeLabels(); this.labels = nodeLabels; } private void initNodeLabels() { if (this.labels != null) { return; } NodeReportProtoOrBuilder p = viaProto ? proto : builder; this.labels = new HashSet<String>(); this.labels.addAll(p.getNodeLabelsList()); } }
8,436
25.201863
76
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/SerializedExceptionPBImpl.java
/** * 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.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import org.apache.hadoop.yarn.api.records.SerializedException; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.exceptions.YarnRuntimeException; import org.apache.hadoop.yarn.proto.YarnProtos.SerializedExceptionProto; import org.apache.hadoop.yarn.proto.YarnProtos.SerializedExceptionProtoOrBuilder; public class SerializedExceptionPBImpl extends SerializedException { SerializedExceptionProto proto = null; SerializedExceptionProto.Builder builder = SerializedExceptionProto.newBuilder(); boolean viaProto = false; public SerializedExceptionPBImpl() { } public SerializedExceptionPBImpl(SerializedExceptionProto proto) { this.proto = proto; viaProto = true; } private SerializedExceptionPBImpl(Throwable t) { init(t); } public void init(String message) { maybeInitBuilder(); builder.setMessage(message); } public void init(Throwable t) { maybeInitBuilder(); if (t == null) { return; } if (t.getCause() == null) { } else { builder.setCause(new SerializedExceptionPBImpl(t.getCause()).getProto()); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); pw.close(); if (sw.toString() != null) builder.setTrace(sw.toString()); if (t.getMessage() != null) builder.setMessage(t.getMessage()); builder.setClassName(t.getClass().getCanonicalName()); } public void init(String message, Throwable t) { init(t); if (message != null) builder.setMessage(message); } @SuppressWarnings("unchecked") @Override public Throwable deSerialize() { SerializedException cause = getCause(); SerializedExceptionProtoOrBuilder p = viaProto ? proto : builder; Class<?> realClass = null; try { realClass = Class.forName(p.getClassName()); } catch (ClassNotFoundException e) { throw new YarnRuntimeException(e); } Class classType = null; if (YarnException.class.isAssignableFrom(realClass)) { classType = YarnException.class; } else if (IOException.class.isAssignableFrom(realClass)) { classType = IOException.class; } else if (RuntimeException.class.isAssignableFrom(realClass)) { classType = RuntimeException.class; } else { classType = Throwable.class; } return instantiateException(realClass.asSubclass(classType), getMessage(), cause == null ? null : cause.deSerialize()); } @Override public String getMessage() { SerializedExceptionProtoOrBuilder p = viaProto ? proto : builder; return p.getMessage(); } @Override public String getRemoteTrace() { SerializedExceptionProtoOrBuilder p = viaProto ? proto : builder; return p.getTrace(); } @Override public SerializedException getCause() { SerializedExceptionProtoOrBuilder p = viaProto ? proto : builder; if (p.hasCause()) { return new SerializedExceptionPBImpl(p.getCause()); } else { return null; } } public SerializedExceptionProto 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; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = SerializedExceptionProto.newBuilder(proto); } viaProto = false; } private static <T extends Throwable> T instantiateExceptionImpl( String message, Class<? extends T> cls, Throwable cause) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { Constructor<? extends T> cn; T ex = null; cn = cls.getConstructor(message == null ? new Class[0] : new Class[] {String.class}); cn.setAccessible(true); ex = message == null ? cn.newInstance() : cn.newInstance(message); ex.initCause(cause); return ex; } private static <T extends Throwable> T instantiateException( Class<? extends T> cls, String message, Throwable cause) { T ex = null; try { // Try constructor with String argument, if it fails, try default. try { ex = instantiateExceptionImpl(message, cls, cause); } catch (NoSuchMethodException e) { ex = instantiateExceptionImpl(null, cls, cause); } } catch (SecurityException e) { throw new YarnRuntimeException(e); } catch (NoSuchMethodException e) { throw new YarnRuntimeException(e); } catch (IllegalArgumentException e) { throw new YarnRuntimeException(e); } catch (InstantiationException e) { throw new YarnRuntimeException(e); } catch (IllegalAccessException e) { throw new YarnRuntimeException(e); } catch (InvocationTargetException e) { throw new YarnRuntimeException(e); } return ex; } }
6,204
29.870647
81
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/YarnClusterMetricsPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } 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)); } @Override public int getNumDecommissionedNodeManagers() { YarnClusterMetricsProtoOrBuilder p = viaProto ? proto : builder; if (p.hasNumDecommissionedNms()) { return (p.getNumDecommissionedNms()); } return 0; } @Override public void setNumDecommissionedNodeManagers(int numDecommissionedNodeManagers) { maybeInitBuilder(); builder.setNumDecommissionedNms((numDecommissionedNodeManagers)); } @Override public int getNumActiveNodeManagers() { YarnClusterMetricsProtoOrBuilder p = viaProto ? proto : builder; if (p.hasNumActiveNms()) { return (p.getNumActiveNms()); } return 0; } @Override public void setNumActiveNodeManagers(int numActiveNodeManagers) { maybeInitBuilder(); builder.setNumActiveNms((numActiveNodeManagers)); } @Override public int getNumLostNodeManagers() { YarnClusterMetricsProtoOrBuilder p = viaProto ? proto : builder; if (p.hasNumLostNms()) { return (p.getNumLostNms()); } return 0; } @Override public void setNumLostNodeManagers(int numLostNodeManagers) { maybeInitBuilder(); builder.setNumLostNms((numLostNodeManagers)); } @Override public int getNumUnhealthyNodeManagers() { YarnClusterMetricsProtoOrBuilder p = viaProto ? proto : builder; if (p.hasNumUnhealthyNms()) { return (p.getNumUnhealthyNms()); } return 0; } @Override public void setNumUnhealthyNodeManagers(int numUnhealthyNodeManagers) { maybeInitBuilder(); builder.setNumUnhealthyNms((numUnhealthyNodeManagers)); } @Override public int getNumRebootedNodeManagers() { YarnClusterMetricsProtoOrBuilder p = viaProto ? proto : builder; if (p.hasNumRebootedNms()) { return (p.getNumRebootedNms()); } return 0; } @Override public void setNumRebootedNodeManagers(int numRebootedNodeManagers) { maybeInitBuilder(); builder.setNumRebootedNms((numRebootedNodeManagers)); } }
4,746
27.255952
80
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceRequestPBImpl.java
/** * 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 synchronized int getNumContainers() { ResourceRequestProtoOrBuilder p = viaProto ? proto : builder; return (p.getNumContainers()); } @Override public synchronized 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() + ", Node Label Expression: " + getNodeLabelExpression() + "}"; } @Override public String getNodeLabelExpression() { ResourceRequestProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasNodeLabelExpression()) { return null; } return (p.getNodeLabelExpression().trim()); } @Override public void setNodeLabelExpression(String nodeLabelExpression) { maybeInitBuilder(); if (nodeLabelExpression == null) { builder.clearNodeLabelExpression(); return; } builder.setNodeLabelExpression(nodeLabelExpression); } }
6,051
27.956938
77
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerResourceDecreasePBImpl.java
/** * 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.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerResourceDecrease; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceDecreaseProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceDecreaseProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; public class ContainerResourceDecreasePBImpl extends ContainerResourceDecrease { ContainerResourceDecreaseProto proto = ContainerResourceDecreaseProto .getDefaultInstance(); ContainerResourceDecreaseProto.Builder builder = null; boolean viaProto = false; private ContainerId existingContainerId = null; private Resource targetCapability = null; public ContainerResourceDecreasePBImpl() { builder = ContainerResourceDecreaseProto.newBuilder(); } public ContainerResourceDecreasePBImpl(ContainerResourceDecreaseProto proto) { this.proto = proto; viaProto = true; } public ContainerResourceDecreaseProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } @Override public ContainerId getContainerId() { ContainerResourceDecreaseProtoOrBuilder p = viaProto ? proto : builder; if (this.existingContainerId != null) { return this.existingContainerId; } if (p.hasContainerId()) { this.existingContainerId = convertFromProtoFormat(p.getContainerId()); } return this.existingContainerId; } @Override public void setContainerId(ContainerId existingContainerId) { maybeInitBuilder(); if (existingContainerId == null) { builder.clearContainerId(); } this.existingContainerId = existingContainerId; } @Override public Resource getCapability() { ContainerResourceDecreaseProtoOrBuilder p = viaProto ? proto : builder; if (this.targetCapability != null) { return this.targetCapability; } if (p.hasCapability()) { this.targetCapability = convertFromProtoFormat(p.getCapability()); } return this.targetCapability; } @Override public void setCapability(Resource targetCapability) { maybeInitBuilder(); if (targetCapability == null) { builder.clearCapability(); } this.targetCapability = targetCapability; } private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { return new ContainerIdPBImpl(p); } private ContainerIdProto convertToProtoFormat(ContainerId t) { return ((ContainerIdPBImpl) t).getProto(); } private Resource convertFromProtoFormat(ResourceProto p) { return new ResourcePBImpl(p); } private ResourceProto convertToProtoFormat(Resource t) { return ((ResourcePBImpl) t).getProto(); } private void mergeLocalToProto() { if (viaProto) { maybeInitBuilder(); } mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = ContainerResourceDecreaseProto.newBuilder(proto); } viaProto = false; } private void mergeLocalToBuilder() { if (this.existingContainerId != null) { builder.setContainerId(convertToProtoFormat(this.existingContainerId)); } if (this.targetCapability != null) { builder.setCapability(convertToProtoFormat(this.targetCapability)); } } }
4,365
30.868613
87
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueStatisticsPBImpl.java
/** * 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 com.google.protobuf.TextFormat; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.yarn.api.records.QueueStatistics; import org.apache.hadoop.yarn.proto.YarnProtos.QueueStatisticsProto; import org.apache.hadoop.yarn.proto.YarnProtos.QueueStatisticsProtoOrBuilder; @InterfaceAudience.Private @InterfaceStability.Unstable public class QueueStatisticsPBImpl extends QueueStatistics { QueueStatisticsProto proto = QueueStatisticsProto.getDefaultInstance(); QueueStatisticsProto.Builder builder = null; boolean viaProto = false; public QueueStatisticsPBImpl() { builder = QueueStatisticsProto.newBuilder(); } public QueueStatisticsPBImpl(QueueStatisticsProto proto) { this.proto = proto; viaProto = true; } public QueueStatisticsProto getProto() { proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } @Override public int hashCode() { return getProto().hashCode(); } @Override public boolean equals(Object other) { if (other == null) return false; if (other.getClass().isAssignableFrom(this.getClass())) { return this.getProto().equals(this.getClass().cast(other).getProto()); } return false; } @Override public String toString() { return TextFormat.shortDebugString(getProto()); } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = QueueStatisticsProto.newBuilder(proto); } viaProto = false; } @Override public long getNumAppsSubmitted() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasNumAppsSubmitted()) ? p.getNumAppsSubmitted() : -1; } @Override public void setNumAppsSubmitted(long numAppsSubmitted) { maybeInitBuilder(); builder.setNumAppsSubmitted(numAppsSubmitted); } @Override public long getNumAppsRunning() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasNumAppsRunning()) ? p.getNumAppsRunning() : -1; } @Override public void setNumAppsRunning(long numAppsRunning) { maybeInitBuilder(); builder.setNumAppsRunning(numAppsRunning); } @Override public long getNumAppsPending() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasNumAppsPending()) ? p.getNumAppsPending() : -1; } @Override public void setNumAppsPending(long numAppsPending) { maybeInitBuilder(); builder.setNumAppsPending(numAppsPending); } @Override public long getNumAppsCompleted() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasNumAppsCompleted()) ? p.getNumAppsCompleted() : -1; } @Override public void setNumAppsCompleted(long numAppsCompleted) { maybeInitBuilder(); builder.setNumAppsCompleted(numAppsCompleted); } @Override public long getNumAppsKilled() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasNumAppsKilled()) ? p.getNumAppsKilled() : -1; } @Override public void setNumAppsKilled(long numAppsKilled) { maybeInitBuilder(); builder.setNumAppsKilled(numAppsKilled); } @Override public long getNumAppsFailed() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasNumAppsFailed()) ? p.getNumAppsFailed() : -1; } @Override public void setNumAppsFailed(long numAppsFailed) { maybeInitBuilder(); builder.setNumAppsFailed(numAppsFailed); } @Override public long getNumActiveUsers() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasNumActiveUsers()) ? p.getNumActiveUsers() : -1; } @Override public void setNumActiveUsers(long numActiveUsers) { maybeInitBuilder(); builder.setNumActiveUsers(numActiveUsers); } @Override public long getAvailableMemoryMB() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasAvailableMemoryMB()) ? p.getAvailableMemoryMB() : -1; } @Override public void setAvailableMemoryMB(long availableMemoryMB) { maybeInitBuilder(); builder.setAvailableMemoryMB(availableMemoryMB); } @Override public long getAllocatedMemoryMB() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasAllocatedMemoryMB()) ? p.getAllocatedMemoryMB() : -1; } @Override public void setAllocatedMemoryMB(long allocatedMemoryMB) { maybeInitBuilder(); builder.setAllocatedMemoryMB(allocatedMemoryMB); } @Override public long getPendingMemoryMB() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasPendingMemoryMB()) ? p.getPendingMemoryMB() : -1; } @Override public void setPendingMemoryMB(long pendingMemoryMB) { maybeInitBuilder(); builder.setPendingMemoryMB(pendingMemoryMB); } @Override public long getReservedMemoryMB() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasReservedMemoryMB()) ? p.getReservedMemoryMB() : -1; } @Override public void setReservedMemoryMB(long reservedMemoryMB) { maybeInitBuilder(); builder.setReservedMemoryMB(reservedMemoryMB); } @Override public long getAvailableVCores() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasAvailableVCores()) ? p.getAvailableVCores() : -1; } @Override public void setAvailableVCores(long availableVCores) { maybeInitBuilder(); builder.setAvailableVCores(availableVCores); } @Override public long getAllocatedVCores() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasAllocatedVCores()) ? p.getAllocatedVCores() : -1; } @Override public void setAllocatedVCores(long allocatedVCores) { maybeInitBuilder(); builder.setAllocatedVCores(allocatedVCores); } @Override public long getPendingVCores() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasPendingVCores()) ? p.getPendingVCores() : -1; } @Override public void setPendingVCores(long pendingVCores) { maybeInitBuilder(); builder.setPendingVCores(pendingVCores); } @Override public long getReservedVCores() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasReservedVCores()) ? p.getReservedVCores() : -1; } @Override public void setReservedVCores(long reservedVCores) { maybeInitBuilder(); builder.setReservedVCores(reservedVCores); } @Override public long getPendingContainers() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasPendingContainers()) ? p.getPendingContainers() : -1; } @Override public void setPendingContainers(long pendingContainers) { maybeInitBuilder(); builder.setPendingContainers(pendingContainers); } @Override public long getAllocatedContainers() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasAllocatedContainers()) ? p.getAllocatedContainers() : -1; } @Override public void setAllocatedContainers(long allocatedContainers) { maybeInitBuilder(); builder.setAllocatedContainers(allocatedContainers); } @Override public long getReservedContainers() { QueueStatisticsProtoOrBuilder p = viaProto ? proto : builder; return (p.hasReservedContainers()) ? p.getReservedContainers() : -1; } @Override public void setReservedContainers(long reservedContainers) { maybeInitBuilder(); builder.setReservedContainers(reservedContainers); } }
8,486
27.867347
77
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/StrictPreemptionContractPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @Private @Unstable public class StrictPreemptionContractPBImpl extends StrictPreemptionContract { StrictPreemptionContractProto proto = StrictPreemptionContractProto.getDefaultInstance(); StrictPreemptionContractProto.Builder builder = null; boolean viaProto = false; private Set<PreemptionContainer> 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 TextFormat.shortDebugString(getProto()); } 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<PreemptionContainer> getContainers() { initIds(); return containers; } @Override public synchronized void setContainers( final Set<PreemptionContainer> containers) { if (null == containers) { builder.clearContainer(); } this.containers = containers; } private void initIds() { if (containers != null) { return; } StrictPreemptionContractProtoOrBuilder p = viaProto ? proto : builder; List<PreemptionContainerProto> list = p.getContainerList(); containers = new HashSet<PreemptionContainer>(); for (PreemptionContainerProto c : list) { containers.add(convertFromProtoFormat(c)); } } private void addContainersToProto() { maybeInitBuilder(); builder.clearContainer(); if (containers == null) { return; } Iterable<PreemptionContainerProto> iterable = new Iterable<PreemptionContainerProto>() { @Override public Iterator<PreemptionContainerProto> iterator() { return new Iterator<PreemptionContainerProto>() { Iterator<PreemptionContainer> 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(); } }
5,008
27.622857
92
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/URLPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } 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 getUserInfo() { URLProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasUserInfo()) { return null; } return (p.getUserInfo()); } @Override public void setUserInfo(String userInfo) { maybeInitBuilder(); if (userInfo == null) { builder.clearUserInfo(); return; } builder.setUserInfo((userInfo)); } @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)); } }
3,954
22.402367
76
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/LocalResourcePBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } 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); } @Override public synchronized boolean getShouldBeUploadedToSharedCache() { LocalResourceProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasShouldBeUploadedToSharedCache()) { return false; } return p.getShouldBeUploadedToSharedCache(); } @Override public synchronized void setShouldBeUploadedToSharedCache( boolean shouldBeUploadedToSharedCache) { maybeInitBuilder(); if (!shouldBeUploadedToSharedCache) { builder.clearShouldBeUploadedToSharedCache(); return; } builder.setShouldBeUploadedToSharedCache(shouldBeUploadedToSharedCache); } 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); } }
6,925
27.979079
90
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeIdPBImpl.java
/** * 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; } }
2,050
25.636364
75
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceOptionPBImpl.java
/** * 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.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.ResourceOption; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceOptionProto; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceOptionProtoOrBuilder; import com.google.common.base.Preconditions; public class ResourceOptionPBImpl extends ResourceOption { ResourceOptionProto proto = ResourceOptionProto.getDefaultInstance(); ResourceOptionProto.Builder builder = null; boolean viaProto = false; public ResourceOptionPBImpl() { builder = ResourceOptionProto.newBuilder(); } public ResourceOptionPBImpl(ResourceOptionProto proto) { this.proto = proto; viaProto = true; } public ResourceOptionProto getProto() { proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } @Override public Resource getResource() { ResourceOptionProtoOrBuilder p = viaProto ? proto : builder; return convertFromProtoFormat(p.getResource()); } @Override protected void setResource(Resource resource) { maybeInitBuilder(); builder.setResource(convertToProtoFormat(resource)); } @Override public int getOverCommitTimeout() { ResourceOptionProtoOrBuilder p = viaProto ? proto : builder; return p.getOverCommitTimeout(); } @Override protected void setOverCommitTimeout(int overCommitTimeout) { maybeInitBuilder(); builder.setOverCommitTimeout(overCommitTimeout); } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = ResourceOptionProto.newBuilder(proto); } viaProto = false; } private ResourceProto convertToProtoFormat( Resource resource) { return ((ResourcePBImpl)resource).getProto(); } private ResourcePBImpl convertFromProtoFormat( ResourceProto p) { return new ResourcePBImpl(p); } @Override protected void build() { proto = builder.build(); viaProto = true; builder = null; } @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; } }
3,264
27.640351
76
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ReservationRequestsPBImpl.java
/** * 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.yarn.api.records.ReservationRequest; import org.apache.hadoop.yarn.api.records.ReservationRequestInterpreter; import org.apache.hadoop.yarn.api.records.ReservationRequests; import org.apache.hadoop.yarn.proto.YarnProtos.ReservationRequestInterpreterProto; import org.apache.hadoop.yarn.proto.YarnProtos.ReservationRequestProto; import org.apache.hadoop.yarn.proto.YarnProtos.ReservationRequestsProto; import org.apache.hadoop.yarn.proto.YarnProtos.ReservationRequestsProtoOrBuilder; public class ReservationRequestsPBImpl extends ReservationRequests { ReservationRequestsProto proto = ReservationRequestsProto .getDefaultInstance(); ReservationRequestsProto.Builder builder = null; boolean viaProto = false; public List<ReservationRequest> reservationRequests; public ReservationRequestsPBImpl() { builder = ReservationRequestsProto.newBuilder(); } public ReservationRequestsPBImpl(ReservationRequestsProto proto) { this.proto = proto; viaProto = true; } public ReservationRequestsProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } private void mergeLocalToBuilder() { if (this.reservationRequests != null) { addReservationResourcesToProto(); } } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = ReservationRequestsProto.newBuilder(proto); } viaProto = false; } @Override public List<ReservationRequest> getReservationResources() { initReservationRequestsList(); return reservationRequests; } @Override public void setReservationResources(List<ReservationRequest> resources) { if (resources == null) { builder.clearReservationResources(); return; } this.reservationRequests = resources; } @Override public ReservationRequestInterpreter getInterpreter() { ReservationRequestsProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasInterpreter()) { return null; } return (convertFromProtoFormat(p.getInterpreter())); } @Override public void setInterpreter(ReservationRequestInterpreter interpreter) { maybeInitBuilder(); if (interpreter == null) { builder.clearInterpreter(); return; } builder.setInterpreter(convertToProtoFormat(interpreter)); } private void initReservationRequestsList() { if (this.reservationRequests != null) { return; } ReservationRequestsProtoOrBuilder p = viaProto ? proto : builder; List<ReservationRequestProto> resourceProtos = p.getReservationResourcesList(); reservationRequests = new ArrayList<ReservationRequest>(); for (ReservationRequestProto r : resourceProtos) { reservationRequests.add(convertFromProtoFormat(r)); } } private void addReservationResourcesToProto() { maybeInitBuilder(); builder.clearReservationResources(); if (reservationRequests == null) return; Iterable<ReservationRequestProto> iterable = new Iterable<ReservationRequestProto>() { @Override public Iterator<ReservationRequestProto> iterator() { return new Iterator<ReservationRequestProto>() { Iterator<ReservationRequest> iter = reservationRequests .iterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public ReservationRequestProto next() { return convertToProtoFormat(iter.next()); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; builder.addAllReservationResources(iterable); } private ReservationRequestProto convertToProtoFormat(ReservationRequest r) { return ((ReservationRequestPBImpl) r).getProto(); } private ReservationRequestPBImpl convertFromProtoFormat( ReservationRequestProto r) { return new ReservationRequestPBImpl(r); } private ReservationRequestInterpreterProto convertToProtoFormat( ReservationRequestInterpreter r) { return ProtoUtils.convertToProtoFormat(r); } private ReservationRequestInterpreter convertFromProtoFormat( ReservationRequestInterpreterProto r) { return ProtoUtils.convertFromProtoFormat(r); } @Override public String toString() { return "{Reservation Resources: " + getReservationResources() + ", Reservation Type: " + getInterpreter() + "}"; } @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; } }
6,081
28.668293
82
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationAttemptIdPBImpl.java
/** * 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; } }
2,814
30.277778
76
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionResourceRequestPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } 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(); } }
3,806
28.511628
87
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueUserACLInfoPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @Private @Unstable public class QueueUserACLInfoPBImpl extends QueueUserACLInfo { QueueUserACLInfoProto proto = QueueUserACLInfoProto.getDefaultInstance(); QueueUserACLInfoProto.Builder builder = null; boolean viaProto = false; List<QueueACL> 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<QueueACL> 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<QueueACL> 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 TextFormat.shortDebugString(getProto()); } private void initLocalQueueUserAclsList() { if (this.userAclsList != null) { return; } QueueUserACLInfoProtoOrBuilder p = viaProto ? proto : builder; List<QueueACLProto> list = p.getUserAclsList(); userAclsList = new ArrayList<QueueACL>(); for (QueueACLProto a : list) { userAclsList.add(convertFromProtoFormat(a)); } } private void addQueueACLsToProto() { maybeInitBuilder(); builder.clearUserAcls(); if (userAclsList == null) return; Iterable<QueueACLProto> iterable = new Iterable<QueueACLProto>() { @Override public Iterator<QueueACLProto> iterator() { return new Iterator<QueueACLProto>() { Iterator<QueueACL> 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); } }
5,068
25.962766
78
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 synchronized 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() { StringBuilder sb = new StringBuilder(); sb.append("ContainerStatus: ["); sb.append("ContainerId: ").append(getContainerId()).append(", "); sb.append("State: ").append(getState()).append(", "); sb.append("Diagnostics: ").append(getDiagnostics()).append(", "); sb.append("ExitStatus: ").append(getExitStatus()).append(", "); sb.append("]"); return sb.toString(); } private void mergeLocalToBuilder() { if (containerId != null) { builder.setContainerId(convertToProtoFormat(this.containerId)); } } private synchronized void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private synchronized void maybeInitBuilder() { if (viaProto || builder == null) { builder = ContainerStatusProto.newBuilder(proto); } viaProto = false; } @Override public synchronized ContainerState getState() { ContainerStatusProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasState()) { return null; } return convertFromProtoFormat(p.getState()); } @Override public synchronized void setState(ContainerState state) { maybeInitBuilder(); if (state == null) { builder.clearState(); return; } builder.setState(convertToProtoFormat(state)); } @Override public synchronized 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 synchronized void setContainerId(ContainerId containerId) { maybeInitBuilder(); if (containerId == null) builder.clearContainerId(); this.containerId = containerId; } @Override public synchronized int getExitStatus() { ContainerStatusProtoOrBuilder p = viaProto ? proto : builder; return p.getExitStatus(); } @Override public synchronized void setExitStatus(int exitStatus) { maybeInitBuilder(); builder.setExitStatus(exitStatus); } @Override public synchronized String getDiagnostics() { ContainerStatusProtoOrBuilder p = viaProto ? proto : builder; return (p.getDiagnostics()); } @Override public synchronized 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(); } }
5,563
28.284211
77
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ReservationIdPBImpl.java
/** * 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.ReservationId; import org.apache.hadoop.yarn.proto.YarnProtos.ReservationIdProto; import com.google.common.base.Preconditions; @Private @Unstable public class ReservationIdPBImpl extends ReservationId { ReservationIdProto proto = null; ReservationIdProto.Builder builder = null; public ReservationIdPBImpl() { builder = ReservationIdProto.newBuilder(); } public ReservationIdPBImpl(ReservationIdProto proto) { this.proto = proto; } public ReservationIdProto getProto() { return proto; } @Override public long getId() { Preconditions.checkNotNull(proto); return proto.getId(); } @Override protected void setId(long 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; } }
2,181
28.093333
75
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerReportPBImpl.java
/** * 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.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerReport; import org.apache.hadoop.yarn.api.records.ContainerState; 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.proto.YarnProtos.ContainerIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerReportProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerReportProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto; import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; import com.google.protobuf.TextFormat; public class ContainerReportPBImpl extends ContainerReport { ContainerReportProto proto = ContainerReportProto.getDefaultInstance(); ContainerReportProto.Builder builder = null; boolean viaProto = false; private ContainerId containerId = null; private Resource resource = null; private NodeId nodeId = null; private Priority priority = null; public ContainerReportPBImpl() { builder = ContainerReportProto.newBuilder(); } public ContainerReportPBImpl(ContainerReportProto proto) { this.proto = proto; viaProto = true; } @Override public String toString() { return TextFormat.shortDebugString(getProto()); } @Override public Resource getAllocatedResource() { if (this.resource != null) { return this.resource; } ContainerReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasResource()) { return null; } this.resource = convertFromProtoFormat(p.getResource()); return this.resource; } @Override public NodeId getAssignedNode() { if (this.nodeId != null) { return this.nodeId; } ContainerReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasNodeId()) { return null; } this.nodeId = convertFromProtoFormat(p.getNodeId()); return this.nodeId; } @Override public ContainerId getContainerId() { if (this.containerId != null) { return this.containerId; } ContainerReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasContainerId()) { return null; } this.containerId = convertFromProtoFormat(p.getContainerId()); return this.containerId; } @Override public String getDiagnosticsInfo() { ContainerReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasDiagnosticsInfo()) { return null; } return (p.getDiagnosticsInfo()); } @Override public ContainerState getContainerState() { ContainerReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasContainerState()) { return null; } return convertFromProtoFormat(p.getContainerState()); } @Override public long getFinishTime() { ContainerReportProtoOrBuilder p = viaProto ? proto : builder; return p.getFinishTime(); } @Override public String getLogUrl() { ContainerReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasLogUrl()) { return null; } return (p.getLogUrl()); } @Override public Priority getPriority() { if (this.priority != null) { return this.priority; } ContainerReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasPriority()) { return null; } this.priority = convertFromProtoFormat(p.getPriority()); return this.priority; } @Override public long getCreationTime() { ContainerReportProtoOrBuilder p = viaProto ? proto : builder; return p.getCreationTime(); } @Override public void setAllocatedResource(Resource resource) { maybeInitBuilder(); if (resource == null) builder.clearResource(); this.resource = resource; } @Override public void setAssignedNode(NodeId nodeId) { maybeInitBuilder(); if (nodeId == null) builder.clearNodeId(); this.nodeId = nodeId; } @Override public void setContainerId(ContainerId containerId) { maybeInitBuilder(); if (containerId == null) builder.clearContainerId(); this.containerId = containerId; } @Override public void setDiagnosticsInfo(String diagnosticsInfo) { maybeInitBuilder(); if (diagnosticsInfo == null) { builder.clearDiagnosticsInfo(); return; } builder.setDiagnosticsInfo(diagnosticsInfo); } @Override public void setContainerState(ContainerState containerState) { maybeInitBuilder(); if (containerState == null) { builder.clearContainerState(); return; } builder.setContainerState(convertToProtoFormat(containerState)); } @Override public int getContainerExitStatus() { ContainerReportProtoOrBuilder p = viaProto ? proto : builder; return p.getContainerExitStatus(); } @Override public void setContainerExitStatus(int containerExitStatus) { maybeInitBuilder(); builder.setContainerExitStatus(containerExitStatus); } @Override public void setFinishTime(long finishTime) { maybeInitBuilder(); builder.setFinishTime(finishTime); } @Override public void setLogUrl(String logUrl) { maybeInitBuilder(); if (logUrl == null) { builder.clearLogUrl(); return; } builder.setLogUrl(logUrl); } @Override public void setPriority(Priority priority) { maybeInitBuilder(); if (priority == null) { builder.clearPriority(); } this.priority = priority; } @Override public void setCreationTime(long creationTime) { maybeInitBuilder(); builder.setCreationTime(creationTime); } public ContainerReportProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } @Override public int hashCode() { return this.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.getContainerId())) { builder.setContainerId(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)); } } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = ContainerReportProto.newBuilder(proto); } viaProto = false; } 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 ContainerStateProto convertToProtoFormat(ContainerState containerState) { return ProtoUtils.convertToProtoFormat(containerState); } private ContainerState convertFromProtoFormat( ContainerStateProto containerState) { return ProtoUtils.convertFromProtoFormat(containerState); } @Override public String getNodeHttpAddress() { ContainerReportProtoOrBuilder 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); } }
9,932
26.515235
77
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionContainerPBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } 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(); } }
3,622
27.085271
81
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationSubmissionContextPBImpl.java
/** * 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.Set; import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.util.StringUtils; 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.LogAggregationContext; import org.apache.hadoop.yarn.api.records.Priority; import org.apache.hadoop.yarn.api.records.ReservationId; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.ResourceRequest; import org.apache.hadoop.yarn.conf.YarnConfiguration; 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.LogAggregationContextProto; import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto; import org.apache.hadoop.yarn.proto.YarnProtos.ReservationIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceRequestProto; import com.google.common.base.CharMatcher; import com.google.protobuf.TextFormat; @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; private Set<String> applicationTags = null; private ResourceRequest amResourceRequest = null; private LogAggregationContext logAggregationContext = null; private ReservationId reservationId = 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 TextFormat.shortDebugString(getProto()); } 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)); } if (this.applicationTags != null && !this.applicationTags.isEmpty()) { builder.clearApplicationTags(); builder.addAllApplicationTags(this.applicationTags); } if (this.amResourceRequest != null) { builder.setAmContainerResourceRequest( convertToProtoFormat(this.amResourceRequest)); } if (this.logAggregationContext != null) { builder.setLogAggregationContext( convertToProtoFormat(this.logAggregationContext)); } if (this.reservationId != null) { builder.setReservationId(convertToProtoFormat(this.reservationId)); } } 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()); } private void initApplicationTags() { if (this.applicationTags != null) { return; } ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; this.applicationTags = new HashSet<String>(); this.applicationTags.addAll(p.getApplicationTagsList()); } @Override public Set<String> getApplicationTags() { initApplicationTags(); return this.applicationTags; } @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)); } private void checkTags(Set<String> tags) { if (tags.size() > YarnConfiguration.APPLICATION_MAX_TAGS) { throw new IllegalArgumentException("Too many applicationTags, a maximum of only " + YarnConfiguration.APPLICATION_MAX_TAGS + " are allowed!"); } for (String tag : tags) { if (tag.length() > YarnConfiguration.APPLICATION_MAX_TAG_LENGTH) { throw new IllegalArgumentException("Tag " + tag + " is too long, " + "maximum allowed length of a tag is " + YarnConfiguration.APPLICATION_MAX_TAG_LENGTH); } if (!CharMatcher.ASCII.matchesAllOf(tag)) { throw new IllegalArgumentException("A tag can only have ASCII " + "characters! Invalid tag - " + tag); } } } @Override public void setApplicationTags(Set<String> tags) { maybeInitBuilder(); if (tags == null || tags.isEmpty()) { builder.clearApplicationTags(); this.applicationTags = null; return; } checkTags(tags); // Convert applicationTags to lower case and add this.applicationTags = new HashSet<String>(); for (String tag : tags) { this.applicationTags.add(StringUtils.toLowerCase(tag)); } } @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; } @Override public ReservationId getReservationID() { ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; if (reservationId != null) { return reservationId; } if (!p.hasReservationId()) { return null; } reservationId = convertFromProtoFormat(p.getReservationId()); return reservationId; } @Override public void setReservationID(ReservationId reservationID) { maybeInitBuilder(); if (reservationID == null) { builder.clearReservationId(); return; } this.reservationId = reservationID; } @Override public void setKeepContainersAcrossApplicationAttempts(boolean keepContainers) { maybeInitBuilder(); builder.setKeepContainersAcrossApplicationAttempts(keepContainers); } @Override public boolean getKeepContainersAcrossApplicationAttempts() { ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; return p.getKeepContainersAcrossApplicationAttempts(); } private PriorityPBImpl convertFromProtoFormat(PriorityProto p) { return new PriorityPBImpl(p); } private PriorityProto convertToProtoFormat(Priority t) { return ((PriorityPBImpl)t).getProto(); } private ResourceRequestPBImpl convertFromProtoFormat(ResourceRequestProto p) { return new ResourceRequestPBImpl(p); } private ResourceRequestProto convertToProtoFormat(ResourceRequest t) { return ((ResourceRequestPBImpl)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(); } @Override public String getNodeLabelExpression() { ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasNodeLabelExpression()) { return null; } return p.getNodeLabelExpression(); } @Override public void setNodeLabelExpression(String labelExpression) { maybeInitBuilder(); if (labelExpression == null) { builder.clearNodeLabelExpression(); return; } builder.setNodeLabelExpression(labelExpression); } @Override public ResourceRequest getAMContainerResourceRequest() { ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; if (this.amResourceRequest != null) { return amResourceRequest; } // Else via proto if (!p.hasAmContainerResourceRequest()) { return null; } amResourceRequest = convertFromProtoFormat(p.getAmContainerResourceRequest()); return amResourceRequest; } @Override public void setAMContainerResourceRequest(ResourceRequest request) { maybeInitBuilder(); if (request == null) { builder.clearAmContainerResourceRequest(); } this.amResourceRequest = request; } @Override public long getAttemptFailuresValidityInterval() { ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; return p.getAttemptFailuresValidityInterval(); } @Override public void setAttemptFailuresValidityInterval( long attemptFailuresValidityInterval) { maybeInitBuilder(); builder.setAttemptFailuresValidityInterval(attemptFailuresValidityInterval); } private LogAggregationContextPBImpl convertFromProtoFormat( LogAggregationContextProto p) { return new LogAggregationContextPBImpl(p); } private LogAggregationContextProto convertToProtoFormat( LogAggregationContext t) { return ((LogAggregationContextPBImpl) t).getProto(); } @Override public LogAggregationContext getLogAggregationContext() { ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; if (this.logAggregationContext != null) { return this.logAggregationContext; } // Else via proto if (!p.hasLogAggregationContext()) { return null; } logAggregationContext = convertFromProtoFormat(p.getLogAggregationContext()); return logAggregationContext; } @Override public void setLogAggregationContext( LogAggregationContext logAggregationContext) { maybeInitBuilder(); if (logAggregationContext == null) builder.clearLogAggregationContext(); this.logAggregationContext = logAggregationContext; } private ReservationIdPBImpl convertFromProtoFormat(ReservationIdProto p) { return new ReservationIdPBImpl(p); } private ReservationIdProto convertToProtoFormat(ReservationId t) { return ((ReservationIdPBImpl) t).getProto(); } }
16,755
29.355072
90
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerIdPBImpl.java
/** * 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; } @Deprecated @Override public int getId() { Preconditions.checkNotNull(proto); return (int) proto.getId(); } @Override public long getContainerId() { Preconditions.checkNotNull(proto); return proto.getId(); } @Override protected void setContainerId(long 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; } }
2,951
28.52
80
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoUtils.java
/** * 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.protocolrecords.ApplicationsRequestScope; 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.LogAggregationStatus; 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.ReservationRequestInterpreter; import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState; 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.LogAggregationStatusProto; 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.ReservationRequestInterpreterProto; import org.apache.hadoop.yarn.proto.YarnProtos.YarnApplicationAttemptStateProto; import org.apache.hadoop.yarn.proto.YarnProtos.YarnApplicationStateProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerTypeProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos; import org.apache.hadoop.yarn.server.api.ContainerType; 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()); } /* * YarnApplicationAttemptState */ private static String YARN_APPLICATION_ATTEMPT_STATE_PREFIX = "APP_ATTEMPT_"; public static YarnApplicationAttemptStateProto convertToProtoFormat( YarnApplicationAttemptState e) { return YarnApplicationAttemptStateProto .valueOf(YARN_APPLICATION_ATTEMPT_STATE_PREFIX + e.name()); } public static YarnApplicationAttemptState convertFromProtoFormat( YarnApplicationAttemptStateProto e) { return YarnApplicationAttemptState.valueOf(e.name().replace( YARN_APPLICATION_ATTEMPT_STATE_PREFIX, "")); } /* * ApplicationsRequestScope */ public static YarnServiceProtos.ApplicationsRequestScopeProto convertToProtoFormat(ApplicationsRequestScope e) { return YarnServiceProtos.ApplicationsRequestScopeProto.valueOf(e.name()); } public static ApplicationsRequestScope convertFromProtoFormat (YarnServiceProtos.ApplicationsRequestScopeProto e) { return ApplicationsRequestScope.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, "")); } /* * Reservation Request interpreter type */ public static ReservationRequestInterpreterProto convertToProtoFormat( ReservationRequestInterpreter e) { return ReservationRequestInterpreterProto.valueOf(e.name()); } public static ReservationRequestInterpreter convertFromProtoFormat( ReservationRequestInterpreterProto e) { return ReservationRequestInterpreter.valueOf(e.name()); } /* * Log Aggregation Status */ private static final String LOG_AGGREGATION_STATUS_PREFIX = "LOG_"; public static LogAggregationStatusProto convertToProtoFormat( LogAggregationStatus e) { return LogAggregationStatusProto.valueOf(LOG_AGGREGATION_STATUS_PREFIX + e.name()); } public static LogAggregationStatus convertFromProtoFormat( LogAggregationStatusProto e) { return LogAggregationStatus.valueOf(e.name().replace( LOG_AGGREGATION_STATUS_PREFIX, "")); } /* * ContainerType */ public static ContainerTypeProto convertToProtoFormat(ContainerType e) { return ContainerTypeProto.valueOf(e.name()); } public static ContainerType convertFromProtoFormat(ContainerTypeProto e) { return ContainerType.valueOf(e.name()); } }
10,584
36.01049
110
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ReservationDefinitionPBImpl.java
/** * 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.yarn.api.records.ReservationDefinition; import org.apache.hadoop.yarn.api.records.ReservationRequests; import org.apache.hadoop.yarn.proto.YarnProtos.ReservationDefinitionProto; import org.apache.hadoop.yarn.proto.YarnProtos.ReservationDefinitionProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.ReservationRequestsProto; public class ReservationDefinitionPBImpl extends ReservationDefinition { ReservationDefinitionProto proto = ReservationDefinitionProto .getDefaultInstance(); ReservationDefinitionProto.Builder builder = null; boolean viaProto = false; private ReservationRequests reservationReqs; public ReservationDefinitionPBImpl() { builder = ReservationDefinitionProto.newBuilder(); } public ReservationDefinitionPBImpl(ReservationDefinitionProto proto) { this.proto = proto; viaProto = true; } public ReservationDefinitionProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } private void mergeLocalToBuilder() { if (this.reservationReqs != null) { builder .setReservationRequests(convertToProtoFormat(this.reservationReqs)); } } private void mergeLocalToProto() { if (viaProto) maybeInitBuilder(); mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = ReservationDefinitionProto.newBuilder(proto); } viaProto = false; } @Override public long getArrival() { ReservationDefinitionProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasArrival()) { return 0; } return (p.getArrival()); } @Override public void setArrival(long earliestStartTime) { maybeInitBuilder(); if (earliestStartTime <= 0) { builder.clearArrival(); return; } builder.setArrival(earliestStartTime); } @Override public long getDeadline() { ReservationDefinitionProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasDeadline()) { return 0; } return (p.getDeadline()); } @Override public void setDeadline(long latestEndTime) { maybeInitBuilder(); if (latestEndTime <= 0) { builder.clearDeadline(); return; } builder.setDeadline(latestEndTime); } @Override public ReservationRequests getReservationRequests() { ReservationDefinitionProtoOrBuilder p = viaProto ? proto : builder; if (reservationReqs != null) { return reservationReqs; } if (!p.hasReservationRequests()) { return null; } reservationReqs = convertFromProtoFormat(p.getReservationRequests()); return reservationReqs; } @Override public void setReservationRequests(ReservationRequests reservationRequests) { if (reservationRequests == null) { builder.clearReservationRequests(); return; } this.reservationReqs = reservationRequests; } @Override public String getReservationName() { ReservationDefinitionProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasReservationName()) { return null; } return (p.getReservationName()); } @Override public void setReservationName(String name) { maybeInitBuilder(); if (name == null) { builder.clearReservationName(); return; } builder.setReservationName(name); } private ReservationRequestsPBImpl convertFromProtoFormat( ReservationRequestsProto p) { return new ReservationRequestsPBImpl(p); } private ReservationRequestsProto convertToProtoFormat(ReservationRequests t) { return ((ReservationRequestsPBImpl) t).getProto(); } @Override public String toString() { return "{Arrival: " + getArrival() + ", Deadline: " + getDeadline() + ", Reservation Name: " + getReservationName() + ", Resources: " + getReservationRequests() + "}"; } @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; } }
5,174
26.972973
83
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerResourceIncreaseRequestPBImpl.java
/** * 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.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerResourceIncreaseRequest; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceIncreaseRequestProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceIncreaseRequestProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; public class ContainerResourceIncreaseRequestPBImpl extends ContainerResourceIncreaseRequest { ContainerResourceIncreaseRequestProto proto = ContainerResourceIncreaseRequestProto.getDefaultInstance(); ContainerResourceIncreaseRequestProto.Builder builder = null; boolean viaProto = false; private ContainerId existingContainerId = null; private Resource targetCapability = null; public ContainerResourceIncreaseRequestPBImpl() { builder = ContainerResourceIncreaseRequestProto.newBuilder(); } public ContainerResourceIncreaseRequestPBImpl( ContainerResourceIncreaseRequestProto proto) { this.proto = proto; viaProto = true; } public ContainerResourceIncreaseRequestProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } @Override public ContainerId getContainerId() { ContainerResourceIncreaseRequestProtoOrBuilder p = viaProto ? proto : builder; if (this.existingContainerId != null) { return this.existingContainerId; } if (p.hasContainerId()) { this.existingContainerId = convertFromProtoFormat(p.getContainerId()); } return this.existingContainerId; } @Override public void setContainerId(ContainerId existingContainerId) { maybeInitBuilder(); if (existingContainerId == null) { builder.clearContainerId(); } this.existingContainerId = existingContainerId; } @Override public Resource getCapability() { ContainerResourceIncreaseRequestProtoOrBuilder p = viaProto ? proto : builder; if (this.targetCapability != null) { return this.targetCapability; } if (p.hasCapability()) { this.targetCapability = convertFromProtoFormat(p.getCapability()); } return this.targetCapability; } @Override public void setCapability(Resource targetCapability) { maybeInitBuilder(); if (targetCapability == null) { builder.clearCapability(); } this.targetCapability = targetCapability; } private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { return new ContainerIdPBImpl(p); } private ContainerIdProto convertToProtoFormat(ContainerId t) { return ((ContainerIdPBImpl) t).getProto(); } private Resource convertFromProtoFormat(ResourceProto p) { return new ResourcePBImpl(p); } private ResourceProto convertToProtoFormat(Resource t) { return ((ResourcePBImpl) t).getProto(); } private void mergeLocalToProto() { if (viaProto) { maybeInitBuilder(); } mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = ContainerResourceIncreaseRequestProto.newBuilder(proto); } viaProto = false; } private void mergeLocalToBuilder() { if (this.existingContainerId != null) { builder.setContainerId(convertToProtoFormat(this.existingContainerId)); } if (this.targetCapability != null) { builder.setCapability(convertToProtoFormat(this.targetCapability)); } } }
4,505
30.732394
94
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PriorityPBImpl.java
/** * 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.toString(getPriority()); } }
2,197
28.306667
75
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ReservationRequestPBImpl.java
/** * 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.ReservationRequest; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.proto.YarnProtos.ReservationRequestProto; import org.apache.hadoop.yarn.proto.YarnProtos.ReservationRequestProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; @Private @Unstable public class ReservationRequestPBImpl extends ReservationRequest { ReservationRequestProto proto = ReservationRequestProto.getDefaultInstance(); ReservationRequestProto.Builder builder = null; boolean viaProto = false; private Resource capability = null; public ReservationRequestPBImpl() { builder = ReservationRequestProto.newBuilder(); } public ReservationRequestPBImpl(ReservationRequestProto proto) { this.proto = proto; viaProto = true; } public ReservationRequestProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } private void mergeLocalToBuilder() { 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 = ReservationRequestProto.newBuilder(proto); } viaProto = false; } @Override public Resource getCapability() { ReservationRequestProtoOrBuilder 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() { ReservationRequestProtoOrBuilder p = viaProto ? proto : builder; return (p.getNumContainers()); } @Override public void setNumContainers(int numContainers) { maybeInitBuilder(); builder.setNumContainers((numContainers)); } @Override public int getConcurrency() { ReservationRequestProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasConcurrency()) { return 1; } return (p.getConcurrency()); } @Override public void setConcurrency(int numContainers) { maybeInitBuilder(); builder.setConcurrency(numContainers); } @Override public long getDuration() { ReservationRequestProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasDuration()) { return 0; } return (p.getDuration()); } @Override public void setDuration(long duration) { maybeInitBuilder(); builder.setDuration(duration); } private ResourcePBImpl convertFromProtoFormat(ResourceProto p) { return new ResourcePBImpl(p); } private ResourceProto convertToProtoFormat(Resource t) { return ((ResourcePBImpl) t).getProto(); } @Override public String toString() { return "{Capability: " + getCapability() + ", # Containers: " + getNumContainers() + ", Concurrency: " + getConcurrency() + ", Lease Duration: " + getDuration() + "}"; } }
4,393
27.907895
80
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerResourceIncreasePBImpl.java
/** * 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.security.proto.SecurityProtos.TokenProto; import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerResourceIncrease; 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.ContainerResourceIncreaseProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceIncreaseProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; public class ContainerResourceIncreasePBImpl extends ContainerResourceIncrease { ContainerResourceIncreaseProto proto = ContainerResourceIncreaseProto .getDefaultInstance(); ContainerResourceIncreaseProto.Builder builder = null; boolean viaProto = false; private ContainerId existingContainerId = null; private Resource targetCapability = null; private Token token = null; public ContainerResourceIncreasePBImpl() { builder = ContainerResourceIncreaseProto.newBuilder(); } public ContainerResourceIncreasePBImpl(ContainerResourceIncreaseProto proto) { this.proto = proto; viaProto = true; } public ContainerResourceIncreaseProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; return proto; } @Override public ContainerId getContainerId() { ContainerResourceIncreaseProtoOrBuilder p = viaProto ? proto : builder; if (this.existingContainerId != null) { return this.existingContainerId; } if (p.hasContainerId()) { this.existingContainerId = convertFromProtoFormat(p.getContainerId()); } return this.existingContainerId; } @Override public void setContainerId(ContainerId existingContainerId) { maybeInitBuilder(); if (existingContainerId == null) { builder.clearContainerId(); } this.existingContainerId = existingContainerId; } @Override public Resource getCapability() { ContainerResourceIncreaseProtoOrBuilder p = viaProto ? proto : builder; if (this.targetCapability != null) { return this.targetCapability; } if (p.hasCapability()) { this.targetCapability = convertFromProtoFormat(p.getCapability()); } return this.targetCapability; } @Override public void setCapability(Resource targetCapability) { maybeInitBuilder(); if (targetCapability == null) { builder.clearCapability(); } this.targetCapability = targetCapability; } @Override public Token getContainerToken() { ContainerResourceIncreaseProtoOrBuilder p = viaProto ? proto : builder; if (this.token != null) { return this.token; } if (p.hasContainerToken()) { this.token = convertFromProtoFormat(p.getContainerToken()); } return this.token; } @Override public void setContainerToken(Token token) { maybeInitBuilder(); if (token == null) { builder.clearContainerToken(); } this.token = token; } private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { return new ContainerIdPBImpl(p); } private ContainerIdProto convertToProtoFormat(ContainerId t) { return ((ContainerIdPBImpl) t).getProto(); } private Resource convertFromProtoFormat(ResourceProto p) { return new ResourcePBImpl(p); } private ResourceProto convertToProtoFormat(Resource t) { return ((ResourcePBImpl) t).getProto(); } private Token convertFromProtoFormat(TokenProto p) { return new TokenPBImpl(p); } private TokenProto convertToProtoFormat(Token t) { return ((TokenPBImpl) t).getProto(); } private void mergeLocalToProto() { if (viaProto) { maybeInitBuilder(); } mergeLocalToBuilder(); proto = builder.build(); viaProto = true; } private void maybeInitBuilder() { if (viaProto || builder == null) { builder = ContainerResourceIncreaseProto.newBuilder(proto); } viaProto = false; } private void mergeLocalToBuilder() { if (this.existingContainerId != null) { builder.setContainerId(convertToProtoFormat(this.existingContainerId)); } if (this.targetCapability != null) { builder.setCapability(convertToProtoFormat(this.targetCapability)); } if (this.token != null) { builder.setContainerToken(convertToProtoFormat(this.token)); } } }
5,307
29.860465
87
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PreemptionMessagePBImpl.java
/** * 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; import com.google.protobuf.TextFormat; @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 TextFormat.shortDebugString(getProto()); } 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(); } }
4,928
28.339286
79
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationIdPBImpl.java
/** * 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; } }
2,179
28.066667
75
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java
/** * 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.ApplicationReport; import org.apache.hadoop.yarn.api.records.QueueInfo; import org.apache.hadoop.yarn.api.records.QueueState; import org.apache.hadoop.yarn.api.records.QueueStatistics; 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; import org.apache.hadoop.yarn.proto.YarnProtos.QueueStatisticsProto; import com.google.protobuf.TextFormat; @Private @Unstable public class QueueInfoPBImpl extends QueueInfo { QueueInfoProto proto = QueueInfoProto.getDefaultInstance(); QueueInfoProto.Builder builder = null; boolean viaProto = false; List<ApplicationReport> applicationsList; List<QueueInfo> childQueuesList; Set<String> accessibleNodeLabels; public QueueInfoPBImpl() { builder = QueueInfoProto.newBuilder(); } public QueueInfoPBImpl(QueueInfoProto proto) { this.proto = proto; viaProto = true; } @Override public List<ApplicationReport> getApplications() { initLocalApplicationsList(); return this.applicationsList; } @Override public float getCapacity() { QueueInfoProtoOrBuilder p = viaProto ? proto : builder; return (p.hasCapacity()) ? p.getCapacity() : -1; } @Override public List<QueueInfo> 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<ApplicationReport> applications) { if (applications == null) { builder.clearApplications(); } this.applicationsList = applications; } @Override public void setCapacity(float capacity) { maybeInitBuilder(); builder.setCapacity(capacity); } @Override public void setChildQueues(List<QueueInfo> 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 TextFormat.shortDebugString(getProto()); } private void initLocalApplicationsList() { if (this.applicationsList != null) { return; } QueueInfoProtoOrBuilder p = viaProto ? proto : builder; List<ApplicationReportProto> list = p.getApplicationsList(); applicationsList = new ArrayList<ApplicationReport>(); for (ApplicationReportProto a : list) { applicationsList.add(convertFromProtoFormat(a)); } } private void addApplicationsToProto() { maybeInitBuilder(); builder.clearApplications(); if (applicationsList == null) return; Iterable<ApplicationReportProto> iterable = new Iterable<ApplicationReportProto>() { @Override public Iterator<ApplicationReportProto> iterator() { return new Iterator<ApplicationReportProto>() { Iterator<ApplicationReport> 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<QueueInfoProto> list = p.getChildQueuesList(); childQueuesList = new ArrayList<QueueInfo>(); for (QueueInfoProto a : list) { childQueuesList.add(convertFromProtoFormat(a)); } } private void addChildQueuesInfoToProto() { maybeInitBuilder(); builder.clearChildQueues(); if (childQueuesList == null) return; Iterable<QueueInfoProto> iterable = new Iterable<QueueInfoProto>() { @Override public Iterator<QueueInfoProto> iterator() { return new Iterator<QueueInfoProto>() { Iterator<QueueInfo> 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(); } if (this.accessibleNodeLabels != null) { builder.clearAccessibleNodeLabels(); builder.addAllAccessibleNodeLabels(this.accessibleNodeLabels); } } 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); } @Override public void setAccessibleNodeLabels(Set<String> nodeLabels) { maybeInitBuilder(); builder.clearAccessibleNodeLabels(); this.accessibleNodeLabels = nodeLabels; } private void initNodeLabels() { if (this.accessibleNodeLabels != null) { return; } QueueInfoProtoOrBuilder p = viaProto ? proto : builder; this.accessibleNodeLabels = new HashSet<String>(); this.accessibleNodeLabels.addAll(p.getAccessibleNodeLabelsList()); } @Override public Set<String> getAccessibleNodeLabels() { initNodeLabels(); return this.accessibleNodeLabels; } @Override public String getDefaultNodeLabelExpression() { QueueInfoProtoOrBuilder p = viaProto ? proto : builder; return (p.hasDefaultNodeLabelExpression()) ? p .getDefaultNodeLabelExpression().trim() : null; } @Override public void setDefaultNodeLabelExpression(String defaultNodeLabelExpression) { maybeInitBuilder(); if (defaultNodeLabelExpression == null) { builder.clearDefaultNodeLabelExpression(); return; } builder.setDefaultNodeLabelExpression(defaultNodeLabelExpression); } private QueueStatistics convertFromProtoFormat(QueueStatisticsProto q) { return new QueueStatisticsPBImpl(q); } private QueueStatisticsProto convertToProtoFormat(QueueStatistics q) { return ((QueueStatisticsPBImpl) q).getProto(); } @Override public QueueStatistics getQueueStatistics() { QueueInfoProtoOrBuilder p = viaProto ? proto : builder; return (p.hasQueueStatistics()) ? convertFromProtoFormat(p .getQueueStatistics()) : null; } @Override public void setQueueStatistics(QueueStatistics queueStatistics) { maybeInitBuilder(); if (queueStatistics == null) { builder.clearQueueStatistics(); return; } builder.setQueueStatistics(convertToProtoFormat(queueStatistics)); } }
11,067
26.739348
88
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/TokenPBImpl.java
/** * 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(); } }
5,200
25.948187
76
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/package-info.java
/* * 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.impl.pb.service; import org.apache.hadoop.classification.InterfaceAudience;
944
44
75
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ClientSCMProtocolPBServiceImpl.java
/** * 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.impl.pb.service; import java.io.IOException; import org.apache.hadoop.yarn.api.ClientSCMProtocol; import org.apache.hadoop.yarn.api.ClientSCMProtocolPB; import org.apache.hadoop.yarn.api.protocolrecords.ReleaseSharedCacheResourceResponse; import org.apache.hadoop.yarn.api.protocolrecords.UseSharedCacheResourceResponse; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReleaseSharedCacheResourceRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReleaseSharedCacheResourceResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.UseSharedCacheResourceRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.UseSharedCacheResourceResponsePBImpl; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReleaseSharedCacheResourceRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReleaseSharedCacheResourceResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.UseSharedCacheResourceRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.UseSharedCacheResourceResponseProto; import com.google.protobuf.RpcController; import com.google.protobuf.ServiceException; public class ClientSCMProtocolPBServiceImpl implements ClientSCMProtocolPB { private ClientSCMProtocol real; public ClientSCMProtocolPBServiceImpl(ClientSCMProtocol impl) { this.real = impl; } @Override public UseSharedCacheResourceResponseProto use(RpcController controller, UseSharedCacheResourceRequestProto proto) throws ServiceException { UseSharedCacheResourceRequestPBImpl request = new UseSharedCacheResourceRequestPBImpl(proto); try { UseSharedCacheResourceResponse response = real.use(request); return ((UseSharedCacheResourceResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public ReleaseSharedCacheResourceResponseProto release( RpcController controller, ReleaseSharedCacheResourceRequestProto proto) throws ServiceException { ReleaseSharedCacheResourceRequestPBImpl request = new ReleaseSharedCacheResourceRequestPBImpl(proto); try { ReleaseSharedCacheResourceResponse response = real.release(request); return ((ReleaseSharedCacheResourceResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } }
3,449
42.670886
99
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ApplicationClientProtocolPBServiceImpl.java
/** * 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.impl.pb.service; import java.io.IOException; import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenRequestProto; import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenResponseProto; import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenRequestProto; import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenResponseProto; import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProto; import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenResponseProto; import org.apache.hadoop.yarn.api.ApplicationClientProtocol; import org.apache.hadoop.yarn.api.ApplicationClientProtocolPB; import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodeLabelsResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetContainersResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetLabelsToNodesResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetNodesToLabelsResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetQueueUserAclsInfoResponse; import org.apache.hadoop.yarn.api.protocolrecords.KillApplicationResponse; import org.apache.hadoop.yarn.api.protocolrecords.MoveApplicationAcrossQueuesResponse; import org.apache.hadoop.yarn.api.protocolrecords.RenewDelegationTokenResponse; import org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteResponse; import org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse; import org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateResponse; import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationResponse; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.CancelDelegationTokenRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.CancelDelegationTokenResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationAttemptReportRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationAttemptReportResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationAttemptsRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationAttemptsResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationReportRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationReportResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationsRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationsResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetClusterMetricsRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetClusterMetricsResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetClusterNodeLabelsRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetClusterNodeLabelsResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetClusterNodesRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetClusterNodesResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainerReportRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainerReportResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainersRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainersResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetDelegationTokenRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetDelegationTokenResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetLabelsToNodesRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetLabelsToNodesResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetNewApplicationRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetNewApplicationResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetNodesToLabelsRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetNodesToLabelsResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetQueueInfoRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetQueueInfoResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetQueueUserAclsInfoRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetQueueUserAclsInfoResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.KillApplicationRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.KillApplicationResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.MoveApplicationAcrossQueuesRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.MoveApplicationAcrossQueuesResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.RenewDelegationTokenRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.RenewDelegationTokenResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationDeleteRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationDeleteResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationSubmissionRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationSubmissionResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationUpdateRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReservationUpdateResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SubmitApplicationRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SubmitApplicationResponsePBImpl; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationAttemptReportRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationAttemptReportResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationAttemptsRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationAttemptsResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationReportRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationReportResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationsRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationsResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterMetricsRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterMetricsResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterNodeLabelsRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterNodeLabelsResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterNodesRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterNodesResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerReportRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerReportResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainersRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainersResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetLabelsToNodesRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetLabelsToNodesResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNewApplicationRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNewApplicationResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNodesToLabelsRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNodesToLabelsResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueInfoRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueInfoResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueUserAclsInfoRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetQueueUserAclsInfoResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.KillApplicationRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.KillApplicationResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.MoveApplicationAcrossQueuesRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.MoveApplicationAcrossQueuesResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationDeleteRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationDeleteResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationSubmissionRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationSubmissionResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationUpdateRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReservationUpdateResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.SubmitApplicationRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.SubmitApplicationResponseProto; import com.google.protobuf.RpcController; import com.google.protobuf.ServiceException; @Private public class ApplicationClientProtocolPBServiceImpl implements ApplicationClientProtocolPB { private ApplicationClientProtocol real; public ApplicationClientProtocolPBServiceImpl(ApplicationClientProtocol impl) { this.real = impl; } @Override public KillApplicationResponseProto forceKillApplication(RpcController arg0, KillApplicationRequestProto proto) throws ServiceException { KillApplicationRequestPBImpl request = new KillApplicationRequestPBImpl(proto); try { KillApplicationResponse response = real.forceKillApplication(request); return ((KillApplicationResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetApplicationReportResponseProto getApplicationReport( RpcController arg0, GetApplicationReportRequestProto proto) throws ServiceException { GetApplicationReportRequestPBImpl request = new GetApplicationReportRequestPBImpl(proto); try { GetApplicationReportResponse response = real.getApplicationReport(request); return ((GetApplicationReportResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetClusterMetricsResponseProto getClusterMetrics(RpcController arg0, GetClusterMetricsRequestProto proto) throws ServiceException { GetClusterMetricsRequestPBImpl request = new GetClusterMetricsRequestPBImpl(proto); try { GetClusterMetricsResponse response = real.getClusterMetrics(request); return ((GetClusterMetricsResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetNewApplicationResponseProto getNewApplication( RpcController arg0, GetNewApplicationRequestProto proto) throws ServiceException { GetNewApplicationRequestPBImpl request = new GetNewApplicationRequestPBImpl(proto); try { GetNewApplicationResponse response = real.getNewApplication(request); return ((GetNewApplicationResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public SubmitApplicationResponseProto submitApplication(RpcController arg0, SubmitApplicationRequestProto proto) throws ServiceException { SubmitApplicationRequestPBImpl request = new SubmitApplicationRequestPBImpl(proto); try { SubmitApplicationResponse response = real.submitApplication(request); return ((SubmitApplicationResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetApplicationsResponseProto getApplications( RpcController controller, GetApplicationsRequestProto proto) throws ServiceException { GetApplicationsRequestPBImpl request = new GetApplicationsRequestPBImpl(proto); try { GetApplicationsResponse response = real.getApplications(request); return ((GetApplicationsResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetClusterNodesResponseProto getClusterNodes(RpcController controller, GetClusterNodesRequestProto proto) throws ServiceException { GetClusterNodesRequestPBImpl request = new GetClusterNodesRequestPBImpl(proto); try { GetClusterNodesResponse response = real.getClusterNodes(request); return ((GetClusterNodesResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetQueueInfoResponseProto getQueueInfo(RpcController controller, GetQueueInfoRequestProto proto) throws ServiceException { GetQueueInfoRequestPBImpl request = new GetQueueInfoRequestPBImpl(proto); try { GetQueueInfoResponse response = real.getQueueInfo(request); return ((GetQueueInfoResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetQueueUserAclsInfoResponseProto getQueueUserAcls( RpcController controller, GetQueueUserAclsInfoRequestProto proto) throws ServiceException { GetQueueUserAclsInfoRequestPBImpl request = new GetQueueUserAclsInfoRequestPBImpl(proto); try { GetQueueUserAclsInfoResponse response = real.getQueueUserAcls(request); return ((GetQueueUserAclsInfoResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetDelegationTokenResponseProto getDelegationToken( RpcController controller, GetDelegationTokenRequestProto proto) throws ServiceException { GetDelegationTokenRequestPBImpl request = new GetDelegationTokenRequestPBImpl(proto); try { GetDelegationTokenResponse response = real.getDelegationToken(request); return ((GetDelegationTokenResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public RenewDelegationTokenResponseProto renewDelegationToken( RpcController controller, RenewDelegationTokenRequestProto proto) throws ServiceException { RenewDelegationTokenRequestPBImpl request = new RenewDelegationTokenRequestPBImpl(proto); try { RenewDelegationTokenResponse response = real.renewDelegationToken(request); return ((RenewDelegationTokenResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public CancelDelegationTokenResponseProto cancelDelegationToken( RpcController controller, CancelDelegationTokenRequestProto proto) throws ServiceException { CancelDelegationTokenRequestPBImpl request = new CancelDelegationTokenRequestPBImpl(proto); try { CancelDelegationTokenResponse response = real.cancelDelegationToken(request); return ((CancelDelegationTokenResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public MoveApplicationAcrossQueuesResponseProto moveApplicationAcrossQueues( RpcController controller, MoveApplicationAcrossQueuesRequestProto proto) throws ServiceException { MoveApplicationAcrossQueuesRequestPBImpl request = new MoveApplicationAcrossQueuesRequestPBImpl(proto); try { MoveApplicationAcrossQueuesResponse response = real.moveApplicationAcrossQueues(request); return ((MoveApplicationAcrossQueuesResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetApplicationAttemptReportResponseProto getApplicationAttemptReport( RpcController controller, GetApplicationAttemptReportRequestProto proto) throws ServiceException { GetApplicationAttemptReportRequestPBImpl request = new GetApplicationAttemptReportRequestPBImpl(proto); try { GetApplicationAttemptReportResponse response = real.getApplicationAttemptReport(request); return ((GetApplicationAttemptReportResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetApplicationAttemptsResponseProto getApplicationAttempts( RpcController controller, GetApplicationAttemptsRequestProto proto) throws ServiceException { GetApplicationAttemptsRequestPBImpl request = new GetApplicationAttemptsRequestPBImpl(proto); try { GetApplicationAttemptsResponse response = real.getApplicationAttempts(request); return ((GetApplicationAttemptsResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetContainerReportResponseProto getContainerReport( RpcController controller, GetContainerReportRequestProto proto) throws ServiceException { GetContainerReportRequestPBImpl request = new GetContainerReportRequestPBImpl(proto); try { GetContainerReportResponse response = real.getContainerReport(request); return ((GetContainerReportResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetContainersResponseProto getContainers(RpcController controller, GetContainersRequestProto proto) throws ServiceException { GetContainersRequestPBImpl request = new GetContainersRequestPBImpl(proto); try { GetContainersResponse response = real.getContainers(request); return ((GetContainersResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public ReservationSubmissionResponseProto submitReservation(RpcController controller, ReservationSubmissionRequestProto requestProto) throws ServiceException { ReservationSubmissionRequestPBImpl request = new ReservationSubmissionRequestPBImpl(requestProto); try { ReservationSubmissionResponse response = real.submitReservation(request); return ((ReservationSubmissionResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public ReservationUpdateResponseProto updateReservation(RpcController controller, ReservationUpdateRequestProto requestProto) throws ServiceException { ReservationUpdateRequestPBImpl request = new ReservationUpdateRequestPBImpl(requestProto); try { ReservationUpdateResponse response = real.updateReservation(request); return ((ReservationUpdateResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public ReservationDeleteResponseProto deleteReservation(RpcController controller, ReservationDeleteRequestProto requestProto) throws ServiceException { ReservationDeleteRequestPBImpl request = new ReservationDeleteRequestPBImpl(requestProto); try { ReservationDeleteResponse response = real.deleteReservation(request); return ((ReservationDeleteResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetNodesToLabelsResponseProto getNodeToLabels( RpcController controller, GetNodesToLabelsRequestProto proto) throws ServiceException { GetNodesToLabelsRequestPBImpl request = new GetNodesToLabelsRequestPBImpl(proto); try { GetNodesToLabelsResponse response = real.getNodeToLabels(request); return ((GetNodesToLabelsResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetLabelsToNodesResponseProto getLabelsToNodes( RpcController controller, GetLabelsToNodesRequestProto proto) throws ServiceException { GetLabelsToNodesRequestPBImpl request = new GetLabelsToNodesRequestPBImpl(proto); try { GetLabelsToNodesResponse response = real.getLabelsToNodes(request); return ((GetLabelsToNodesResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetClusterNodeLabelsResponseProto getClusterNodeLabels( RpcController controller, GetClusterNodeLabelsRequestProto proto) throws ServiceException { GetClusterNodeLabelsRequestPBImpl request = new GetClusterNodeLabelsRequestPBImpl(proto); try { GetClusterNodeLabelsResponse response = real.getClusterNodeLabels(request); return ((GetClusterNodeLabelsResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } }
24,836
47.604697
100
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ApplicationHistoryProtocolPBServiceImpl.java
/** * 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.impl.pb.service; import java.io.IOException; import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenRequestProto; import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenResponseProto; import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenRequestProto; import org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenResponseProto; import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProto; import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenResponseProto; import org.apache.hadoop.yarn.api.ApplicationHistoryProtocol; import org.apache.hadoop.yarn.api.ApplicationHistoryProtocolPB; import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetContainersResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse; import org.apache.hadoop.yarn.api.protocolrecords.RenewDelegationTokenResponse; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.CancelDelegationTokenRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.CancelDelegationTokenResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationAttemptReportRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationAttemptReportResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationAttemptsRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationAttemptsResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationReportRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationReportResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationsRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationsResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainerReportRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainerReportResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainersRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainersResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetDelegationTokenRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetDelegationTokenResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.RenewDelegationTokenRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.RenewDelegationTokenResponsePBImpl; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationAttemptReportRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationAttemptReportResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationAttemptsRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationAttemptsResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationReportRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationReportResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationsRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationsResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerReportRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerReportResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainersRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainersResponseProto; import com.google.protobuf.RpcController; import com.google.protobuf.ServiceException; @Private public class ApplicationHistoryProtocolPBServiceImpl implements ApplicationHistoryProtocolPB { private ApplicationHistoryProtocol real; public ApplicationHistoryProtocolPBServiceImpl(ApplicationHistoryProtocol impl) { this.real = impl; } @Override public GetApplicationReportResponseProto getApplicationReport( RpcController arg0, GetApplicationReportRequestProto proto) throws ServiceException { GetApplicationReportRequestPBImpl request = new GetApplicationReportRequestPBImpl(proto); try { GetApplicationReportResponse response = real.getApplicationReport(request); return ((GetApplicationReportResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetApplicationsResponseProto getApplications(RpcController controller, GetApplicationsRequestProto proto) throws ServiceException { GetApplicationsRequestPBImpl request = new GetApplicationsRequestPBImpl(proto); try { GetApplicationsResponse response = real.getApplications(request); return ((GetApplicationsResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetApplicationAttemptReportResponseProto getApplicationAttemptReport( RpcController controller, GetApplicationAttemptReportRequestProto proto) throws ServiceException { GetApplicationAttemptReportRequestPBImpl request = new GetApplicationAttemptReportRequestPBImpl(proto); try { GetApplicationAttemptReportResponse response = real.getApplicationAttemptReport(request); return ((GetApplicationAttemptReportResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetApplicationAttemptsResponseProto getApplicationAttempts( RpcController controller, GetApplicationAttemptsRequestProto proto) throws ServiceException { GetApplicationAttemptsRequestPBImpl request = new GetApplicationAttemptsRequestPBImpl(proto); try { GetApplicationAttemptsResponse response = real.getApplicationAttempts(request); return ((GetApplicationAttemptsResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetContainerReportResponseProto getContainerReport( RpcController controller, GetContainerReportRequestProto proto) throws ServiceException { GetContainerReportRequestPBImpl request = new GetContainerReportRequestPBImpl(proto); try { GetContainerReportResponse response = real.getContainerReport(request); return ((GetContainerReportResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetContainersResponseProto getContainers(RpcController controller, GetContainersRequestProto proto) throws ServiceException { GetContainersRequestPBImpl request = new GetContainersRequestPBImpl(proto); try { GetContainersResponse response = real.getContainers(request); return ((GetContainersResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetDelegationTokenResponseProto getDelegationToken( RpcController controller, GetDelegationTokenRequestProto proto) throws ServiceException { GetDelegationTokenRequestPBImpl request = new GetDelegationTokenRequestPBImpl(proto); try { GetDelegationTokenResponse response = real.getDelegationToken(request); return ((GetDelegationTokenResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public RenewDelegationTokenResponseProto renewDelegationToken( RpcController controller, RenewDelegationTokenRequestProto proto) throws ServiceException { RenewDelegationTokenRequestPBImpl request = new RenewDelegationTokenRequestPBImpl(proto); try { RenewDelegationTokenResponse response = real.renewDelegationToken(request); return ((RenewDelegationTokenResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public CancelDelegationTokenResponseProto cancelDelegationToken( RpcController controller, CancelDelegationTokenRequestProto proto) throws ServiceException { CancelDelegationTokenRequestPBImpl request = new CancelDelegationTokenRequestPBImpl(proto); try { CancelDelegationTokenResponse response = real.cancelDelegationToken(request); return ((CancelDelegationTokenResponsePBImpl) response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } }
10,793
45.727273
100
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ApplicationMasterProtocolPBServiceImpl.java
/** * 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.impl.pb.service; import java.io.IOException; import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.yarn.api.ApplicationMasterProtocol; import org.apache.hadoop.yarn.api.ApplicationMasterProtocolPB; import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse; import org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterResponse; import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.AllocateRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.AllocateResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.FinishApplicationMasterRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.FinishApplicationMasterResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.RegisterApplicationMasterRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.RegisterApplicationMasterResponsePBImpl; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationMasterRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationMasterResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterResponseProto; import com.google.protobuf.RpcController; import com.google.protobuf.ServiceException; @Private public class ApplicationMasterProtocolPBServiceImpl implements ApplicationMasterProtocolPB { private ApplicationMasterProtocol real; public ApplicationMasterProtocolPBServiceImpl(ApplicationMasterProtocol impl) { this.real = impl; } @Override public AllocateResponseProto allocate(RpcController arg0, AllocateRequestProto proto) throws ServiceException { AllocateRequestPBImpl request = new AllocateRequestPBImpl(proto); try { AllocateResponse response = real.allocate(request); return ((AllocateResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public FinishApplicationMasterResponseProto finishApplicationMaster( RpcController arg0, FinishApplicationMasterRequestProto proto) throws ServiceException { FinishApplicationMasterRequestPBImpl request = new FinishApplicationMasterRequestPBImpl(proto); try { FinishApplicationMasterResponse response = real.finishApplicationMaster(request); return ((FinishApplicationMasterResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public RegisterApplicationMasterResponseProto registerApplicationMaster( RpcController arg0, RegisterApplicationMasterRequestProto proto) throws ServiceException { RegisterApplicationMasterRequestPBImpl request = new RegisterApplicationMasterRequestPBImpl(proto); try { RegisterApplicationMasterResponse response = real.registerApplicationMaster(request); return ((RegisterApplicationMasterResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } }
4,499
44.454545
103
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagementProtocolPBServiceImpl.java
/** * 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.impl.pb.service; import java.io.IOException; import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.yarn.api.ContainerManagementProtocol; import org.apache.hadoop.yarn.api.ContainerManagementProtocolPB; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse; import org.apache.hadoop.yarn.api.protocolrecords.StartContainersResponse; import org.apache.hadoop.yarn.api.protocolrecords.StopContainersResponse; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainerStatusesRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainerStatusesResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StartContainersRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StartContainersResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StopContainersRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StopContainersResponsePBImpl; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusesRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusesResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainersRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainersResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainersRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainersResponseProto; import com.google.protobuf.RpcController; import com.google.protobuf.ServiceException; @Private public class ContainerManagementProtocolPBServiceImpl implements ContainerManagementProtocolPB { private ContainerManagementProtocol real; public ContainerManagementProtocolPBServiceImpl(ContainerManagementProtocol impl) { this.real = impl; } @Override public StartContainersResponseProto startContainers(RpcController arg0, StartContainersRequestProto proto) throws ServiceException { StartContainersRequestPBImpl request = new StartContainersRequestPBImpl(proto); try { StartContainersResponse response = real.startContainers(request); return ((StartContainersResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public StopContainersResponseProto stopContainers(RpcController arg0, StopContainersRequestProto proto) throws ServiceException { StopContainersRequestPBImpl request = new StopContainersRequestPBImpl(proto); try { StopContainersResponse response = real.stopContainers(request); return ((StopContainersResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetContainerStatusesResponseProto getContainerStatuses( RpcController arg0, GetContainerStatusesRequestProto proto) throws ServiceException { GetContainerStatusesRequestPBImpl request = new GetContainerStatusesRequestPBImpl(proto); try { GetContainerStatusesResponse response = real.getContainerStatuses(request); return ((GetContainerStatusesResponsePBImpl)response).getProto(); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } } }
4,414
44.05102
97
java
hadoop
hadoop-master/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/package-info.java
/* * 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.impl.pb.client; import org.apache.hadoop.classification.InterfaceAudience;
943
43.952381
75
java