YARN-5307. Federation Application State Store internal APIs
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ea75da73 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ea75da73 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ea75da73 Branch: refs/heads/YARN-2915 Commit: ea75da734db836b16b23055b5224e30b59976e9b Parents: fe7fd95 Author: Subru Krishnan <su...@apache.org> Authored: Fri Aug 5 11:52:44 2016 -0700 Committer: Subru Krishnan <su...@apache.org> Committed: Mon Apr 24 18:58:51 2017 -0700 ---------------------------------------------------------------------- ...ederationApplicationHomeSubClusterStore.java | 126 ++++++++++++ .../AddApplicationHomeSubClusterRequest.java | 72 +++++++ .../AddApplicationHomeSubClusterResponse.java | 44 +++++ .../records/ApplicationHomeSubCluster.java | 124 ++++++++++++ .../DeleteApplicationHomeSubClusterRequest.java | 65 +++++++ ...DeleteApplicationHomeSubClusterResponse.java | 43 +++++ .../GetApplicationHomeSubClusterRequest.java | 64 +++++++ .../GetApplicationHomeSubClusterResponse.java | 73 +++++++ .../GetApplicationsHomeSubClusterRequest.java | 40 ++++ .../GetApplicationsHomeSubClusterResponse.java | 75 ++++++++ .../UpdateApplicationHomeSubClusterRequest.java | 74 ++++++++ ...UpdateApplicationHomeSubClusterResponse.java | 43 +++++ ...dApplicationHomeSubClusterRequestPBImpl.java | 132 +++++++++++++ ...ApplicationHomeSubClusterResponsePBImpl.java | 78 ++++++++ .../pb/ApplicationHomeSubClusterPBImpl.java | 167 ++++++++++++++++ ...eApplicationHomeSubClusterRequestPBImpl.java | 130 +++++++++++++ ...ApplicationHomeSubClusterResponsePBImpl.java | 78 ++++++++ ...tApplicationHomeSubClusterRequestPBImpl.java | 135 +++++++++++++ ...ApplicationHomeSubClusterResponsePBImpl.java | 132 +++++++++++++ ...ApplicationsHomeSubClusterRequestPBImpl.java | 78 ++++++++ ...pplicationsHomeSubClusterResponsePBImpl.java | 190 +++++++++++++++++++ .../pb/GetSubClustersInfoResponsePBImpl.java | 6 +- ...eApplicationHomeSubClusterRequestPBImpl.java | 132 +++++++++++++ ...ApplicationHomeSubClusterResponsePBImpl.java | 78 ++++++++ .../proto/yarn_server_federation_protos.proto | 45 ++++- .../records/TestFederationProtocolRecords.java | 81 ++++++++ 26 files changed, 2301 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/FederationApplicationHomeSubClusterStore.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/FederationApplicationHomeSubClusterStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/FederationApplicationHomeSubClusterStore.java new file mode 100644 index 0000000..217ee2e --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/FederationApplicationHomeSubClusterStore.java @@ -0,0 +1,126 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.exceptions.YarnException; +import org.apache.hadoop.yarn.server.federation.store.records.AddApplicationHomeSubClusterRequest; +import org.apache.hadoop.yarn.server.federation.store.records.AddApplicationHomeSubClusterResponse; +import org.apache.hadoop.yarn.server.federation.store.records.DeleteApplicationHomeSubClusterRequest; +import org.apache.hadoop.yarn.server.federation.store.records.DeleteApplicationHomeSubClusterResponse; +import org.apache.hadoop.yarn.server.federation.store.records.GetApplicationHomeSubClusterRequest; +import org.apache.hadoop.yarn.server.federation.store.records.GetApplicationHomeSubClusterResponse; +import org.apache.hadoop.yarn.server.federation.store.records.GetApplicationsHomeSubClusterRequest; +import org.apache.hadoop.yarn.server.federation.store.records.GetApplicationsHomeSubClusterResponse; +import org.apache.hadoop.yarn.server.federation.store.records.UpdateApplicationHomeSubClusterRequest; +import org.apache.hadoop.yarn.server.federation.store.records.UpdateApplicationHomeSubClusterResponse; +import org.apache.hadoop.yarn.server.records.Version; + +/** + * FederationApplicationHomeSubClusterStore maintains the state of all + * <em>Applications</em> that have been submitted to the federated cluster. + * + * * + * <p> + * The mapping details contains: + * <ul> + * <li>{@code ApplicationId}</li> + * <li>{@code SubClusterId}</li> + * </ul> + * + */ +@Private +@Unstable +public interface FederationApplicationHomeSubClusterStore { + + /** + * Get the {@link Version} of the underlying federation application state + * store. + * + * @return the {@link Version} of the underlying federation application state + * store + */ + Version getApplicationStateStoreVersion(); + + /** + * Register the home {@code SubClusterId} of the newly submitted + * {@code ApplicationId}. Currently response is empty if the operation was + * successful, if not an exception reporting reason for a failure. + * + * @param request the request to register a new application with its home + * sub-cluster + * @return empty on successful registration of the application in the + * StateStore, if not an exception reporting reason for a failure + * @throws YarnException if the request is invalid/fails + */ + AddApplicationHomeSubClusterResponse addApplicationHomeSubClusterMap( + AddApplicationHomeSubClusterRequest request) throws YarnException; + + /** + * Update the home {@code SubClusterId} of a previously submitted + * {@code ApplicationId}. Currently response is empty if the operation was + * successful, if not an exception reporting reason for a failure. + * + * @param request the request to update the home sub-cluster of an + * application. + * @return empty on successful update of the application in the StateStore, if + * not an exception reporting reason for a failure + * @throws YarnException if the request is invalid/fails + */ + UpdateApplicationHomeSubClusterResponse updateApplicationHomeSubClusterMap( + UpdateApplicationHomeSubClusterRequest request) throws YarnException; + + /** + * Get information about the application identified by the input + * {@code ApplicationId}. + * + * @param request contains the application queried + * @return {@code ApplicationHomeSubCluster} containing the application's + * home subcluster + * @throws YarnException if the request is invalid/fails + */ + GetApplicationHomeSubClusterResponse getApplicationHomeSubClusterMap( + GetApplicationHomeSubClusterRequest request) throws YarnException; + + /** + * Get the {@code ApplicationHomeSubCluster} list representing the mapping + * of all submitted applications to it's home sub-cluster. + * + * @param request empty representing all applications + * @return the mapping of all submitted application to it's home sub-cluster + * @throws YarnException if the request is invalid/fails + */ + GetApplicationsHomeSubClusterResponse getApplicationsHomeSubClusterMap( + GetApplicationsHomeSubClusterRequest request) throws YarnException; + + /** + * Delete the mapping of home {@code SubClusterId} of a previously submitted + * {@code ApplicationId}. Currently response is empty if the operation was + * successful, if not an exception reporting reason for a failure. + * + * @param request the request to delete the home sub-cluster of an + * application. + * @return empty on successful update of the application in the StateStore, if + * not an exception reporting reason for a failure + * @throws YarnException if the request is invalid/fails + */ + DeleteApplicationHomeSubClusterResponse deleteApplicationHomeSubClusterMap( + DeleteApplicationHomeSubClusterRequest request) throws YarnException; + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/AddApplicationHomeSubClusterRequest.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/AddApplicationHomeSubClusterRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/AddApplicationHomeSubClusterRequest.java new file mode 100644 index 0000000..9cb0589 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/AddApplicationHomeSubClusterRequest.java @@ -0,0 +1,72 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.util.Records; + +/** + * <p> + * The request sent by the <code>Router</code> to <code>Federation state + * store</code> to map the home subcluster of a newly submitted application. + * + * <p> + * The request includes the mapping details, i.e.: + * <ul> + * <li>{@code ApplicationId}</li> + * <li>{@code SubClusterId}</li> + * </ul> + */ +@Private +@Unstable +public abstract class AddApplicationHomeSubClusterRequest { + + @Private + @Unstable + public static AddApplicationHomeSubClusterRequest newInstance( + ApplicationHomeSubCluster applicationHomeSubCluster) { + AddApplicationHomeSubClusterRequest mapRequest = + Records.newRecord(AddApplicationHomeSubClusterRequest.class); + mapRequest.setApplicationHomeSubCluster(applicationHomeSubCluster); + return mapRequest; + } + + /** + * Get the {@link ApplicationHomeSubCluster} representing the mapping of the + * application to it's home sub-cluster. + * + * @return the mapping of the application to it's home sub-cluster. + */ + @Public + @Unstable + public abstract ApplicationHomeSubCluster getApplicationHomeSubCluster(); + + /** + * Set the {@link ApplicationHomeSubCluster} representing the mapping of the + * application to it's home sub-cluster. + * + * @param applicationHomeSubCluster the mapping of the application to it's + * home sub-cluster. + */ + @Private + @Unstable + public abstract void setApplicationHomeSubCluster( + ApplicationHomeSubCluster applicationHomeSubCluster); +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/AddApplicationHomeSubClusterResponse.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/AddApplicationHomeSubClusterResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/AddApplicationHomeSubClusterResponse.java new file mode 100644 index 0000000..2145dd1 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/AddApplicationHomeSubClusterResponse.java @@ -0,0 +1,44 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.util.Records; + +/** + * AddApplicationHomeSubClusterResponse contains the answer from the + * {@code FederationApplicationHomeSubClusterStore} to a request to insert a + * newly generated applicationId and its owner. Currently response is empty if + * the operation was successful, if not an exception reporting reason for a + * failure. + * + */ +@Private +@Unstable +public abstract class AddApplicationHomeSubClusterResponse { + + @Private + @Unstable + public static AddApplicationHomeSubClusterResponse newInstance() { + AddApplicationHomeSubClusterResponse response = + Records.newRecord(AddApplicationHomeSubClusterResponse.class); + return response; + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/ApplicationHomeSubCluster.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/ApplicationHomeSubCluster.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/ApplicationHomeSubCluster.java new file mode 100644 index 0000000..5e4c7cc --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/ApplicationHomeSubCluster.java @@ -0,0 +1,124 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.util.Records; + +/** + * <p> + * ApplicationHomeSubCluster is a report of the runtime information of the + * application that is running in the federated cluster. + * + * <p> + * It includes information such as: + * <ul> + * <li>{@link ApplicationId}</li> + * <li>{@link SubClusterId}</li> + * </ul> + * + */ +@Private +@Unstable +public abstract class ApplicationHomeSubCluster { + + @Private + @Unstable + public static ApplicationHomeSubCluster newInstance(ApplicationId appId, + SubClusterId homeSubCluster) { + ApplicationHomeSubCluster appMapping = + Records.newRecord(ApplicationHomeSubCluster.class); + appMapping.setApplicationId(appId); + appMapping.setHomeSubCluster(homeSubCluster); + return appMapping; + } + + /** + * Get the {@link ApplicationId} representing the unique identifier of the + * application. + * + * @return the application identifier + */ + @Public + @Unstable + public abstract ApplicationId getApplicationId(); + + /** + * Set the {@link ApplicationId} representing the unique identifier of the + * application. + * + * @param applicationId the application identifier + */ + @Private + @Unstable + public abstract void setApplicationId(ApplicationId applicationId); + + /** + * Get the {@link SubClusterId} representing the unique identifier of the home + * subcluster in which the ApplicationMaster of the application is running. + * + * @return the home subcluster identifier + */ + @Public + @Unstable + public abstract SubClusterId getHomeSubCluster(); + + /** + * Set the {@link SubClusterId} representing the unique identifier of the home + * subcluster in which the ApplicationMaster of the application is running. + * + * @param homeSubCluster the home subcluster identifier + */ + @Private + @Unstable + public abstract void setHomeSubCluster(SubClusterId homeSubCluster); + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ApplicationHomeSubCluster other = (ApplicationHomeSubCluster) obj; + if (!this.getApplicationId().equals(other.getApplicationId())) { + return false; + } + return this.getHomeSubCluster().equals(other.getHomeSubCluster()); + } + + @Override + public int hashCode() { + return getApplicationId().hashCode() * 31 + getHomeSubCluster().hashCode(); + } + + @Override + public String toString() { + return "ApplicationHomeSubCluster [getApplicationId()=" + + getApplicationId() + ", getHomeSubCluster()=" + getHomeSubCluster() + + "]"; + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/DeleteApplicationHomeSubClusterRequest.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/DeleteApplicationHomeSubClusterRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/DeleteApplicationHomeSubClusterRequest.java new file mode 100644 index 0000000..f678aee --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/DeleteApplicationHomeSubClusterRequest.java @@ -0,0 +1,65 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.util.Records; + +/** + * The request to <code>Federation state store</code> to delete the mapping of + * home subcluster of a submitted application. + */ +@Private +@Unstable +public abstract class DeleteApplicationHomeSubClusterRequest { + + @Private + @Unstable + public static DeleteApplicationHomeSubClusterRequest newInstance( + ApplicationId applicationId) { + DeleteApplicationHomeSubClusterRequest deleteApplicationRequest = + Records.newRecord(DeleteApplicationHomeSubClusterRequest.class); + deleteApplicationRequest.setApplicationId(applicationId); + return deleteApplicationRequest; + } + + /** + * Get the identifier of the {@link ApplicationId} to be removed from + * <code>Federation state store</code> . + * + * @return the identifier of the application to be removed from Federation + * State Store. + */ + @Public + @Unstable + public abstract ApplicationId getApplicationId(); + + /** + * Set the identifier of the {@link ApplicationId} to be removed from + * <code>Federation state store</code> . + * + * @param applicationId the identifier of the application to be removed from + * Federation State Store. + */ + @Private + @Unstable + public abstract void setApplicationId(ApplicationId applicationId); +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/DeleteApplicationHomeSubClusterResponse.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/DeleteApplicationHomeSubClusterResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/DeleteApplicationHomeSubClusterResponse.java new file mode 100644 index 0000000..fb1bef9 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/DeleteApplicationHomeSubClusterResponse.java @@ -0,0 +1,43 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.util.Records; + +/** + * DeleteApplicationHomeSubClusterResponse contains the answer from the {@code + * FederationApplicationHomeSubClusterStore} to a request to delete the mapping + * of home subcluster of a submitted application. Currently response is empty if + * the operation was successful, if not an exception reporting reason for a + * failure. + */ +@Private +@Unstable +public abstract class DeleteApplicationHomeSubClusterResponse { + + @Private + @Unstable + public static DeleteApplicationHomeSubClusterResponse newInstance() { + DeleteApplicationHomeSubClusterResponse response = + Records.newRecord(DeleteApplicationHomeSubClusterResponse.class); + return response; + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationHomeSubClusterRequest.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationHomeSubClusterRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationHomeSubClusterRequest.java new file mode 100644 index 0000000..a64d22e --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationHomeSubClusterRequest.java @@ -0,0 +1,64 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.util.Records; + +/** + * Request class to obtain the home sub-cluster for the specified + * {@link ApplicationId}. + */ +@Private +@Unstable +public abstract class GetApplicationHomeSubClusterRequest { + + @Private + @Unstable + public static GetApplicationHomeSubClusterRequest newInstance( + ApplicationId appId) { + GetApplicationHomeSubClusterRequest appMapping = + Records.newRecord(GetApplicationHomeSubClusterRequest.class); + appMapping.setApplicationId(appId); + return appMapping; + } + + /** + * Get the {@link ApplicationId} representing the unique identifier of the + * application. + * + * @return the application identifier + */ + @Public + @Unstable + public abstract ApplicationId getApplicationId(); + + /** + * Set the {@link ApplicationId} representing the unique identifier of the + * application. + * + * @param applicationId the application identifier + */ + @Private + @Unstable + public abstract void setApplicationId(ApplicationId applicationId); + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationHomeSubClusterResponse.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationHomeSubClusterResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationHomeSubClusterResponse.java new file mode 100644 index 0000000..60735b3 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationHomeSubClusterResponse.java @@ -0,0 +1,73 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.util.Records; + +/** + * <p> + * The response sent by <code>Federation state + * store</code> to a query for the home subcluster of a newly submitted + * application. + * + * <p> + * The request includes the mapping details, i.e.: + * <ul> + * <li>{@code ApplicationId}</li> + * <li>{@code SubClusterId}</li> + * </ul> + */ +@Private +@Unstable +public abstract class GetApplicationHomeSubClusterResponse { + + @Private + @Unstable + public static GetApplicationHomeSubClusterResponse newInstance( + ApplicationHomeSubCluster applicationHomeSubCluster) { + GetApplicationHomeSubClusterResponse mapResponse = + Records.newRecord(GetApplicationHomeSubClusterResponse.class); + mapResponse.setApplicationHomeSubCluster(applicationHomeSubCluster); + return mapResponse; + } + + /** + * Get the {@link ApplicationHomeSubCluster} representing the mapping of the + * application to it's home sub-cluster. + * + * @return the mapping of the application to it's home sub-cluster. + */ + @Public + @Unstable + public abstract ApplicationHomeSubCluster getApplicationHomeSubCluster(); + + /** + * Set the {@link ApplicationHomeSubCluster} representing the mapping of the + * application to it's home sub-cluster. + * + * @param applicationHomeSubCluster the mapping of the application to it's + * home sub-cluster. + */ + @Private + @Unstable + public abstract void setApplicationHomeSubCluster( + ApplicationHomeSubCluster applicationHomeSubCluster); +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationsHomeSubClusterRequest.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationsHomeSubClusterRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationsHomeSubClusterRequest.java new file mode 100644 index 0000000..6054972 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationsHomeSubClusterRequest.java @@ -0,0 +1,40 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.util.Records; + +/** + * Request class to obtain the home sub-cluster mapping of all active + * applications. + */ +@Private +@Unstable +public abstract class GetApplicationsHomeSubClusterRequest { + + @Private + @Unstable + public static GetApplicationsHomeSubClusterRequest newInstance() { + GetApplicationsHomeSubClusterRequest request = + Records.newRecord(GetApplicationsHomeSubClusterRequest.class); + return request; + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationsHomeSubClusterResponse.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationsHomeSubClusterResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationsHomeSubClusterResponse.java new file mode 100644 index 0000000..ba3d2c6 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/GetApplicationsHomeSubClusterResponse.java @@ -0,0 +1,75 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records; + +import java.util.List; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.util.Records; + +/** + * <p> + * The response sent by <code>Federation state + * store</code> to a query for the home subcluster of all submitted + * applications. + * + * <p> + * The response includes the mapping details, i.e.: + * <ul> + * <li>{@code ApplicationId}</li> + * <li>{@code SubClusterId}</li> + * </ul> + */ +@Private +@Unstable +public abstract class GetApplicationsHomeSubClusterResponse { + + @Private + @Unstable + public static GetApplicationsHomeSubClusterResponse newInstance( + List<ApplicationHomeSubCluster> appsHomeSubClusters) { + GetApplicationsHomeSubClusterResponse mapResponse = + Records.newRecord(GetApplicationsHomeSubClusterResponse.class); + mapResponse.setAppsHomeSubClusters(appsHomeSubClusters); + return mapResponse; + } + + /** + * Get the {@link ApplicationHomeSubCluster} list representing the mapping of + * all submitted applications to it's home sub-cluster. + * + * @return the mapping of all submitted application to it's home sub-cluster. + */ + @Public + @Unstable + public abstract List<ApplicationHomeSubCluster> getAppsHomeSubClusters(); + + /** + * Set the {@link ApplicationHomeSubCluster} list representing the mapping of + * all submitted applications to it's home sub-cluster. + * + * @param appsHomeSubClusters the mapping of all submitted application to it's + * home sub-cluster. + */ + @Private + @Unstable + public abstract void setAppsHomeSubClusters( + List<ApplicationHomeSubCluster> appsHomeSubClusters); +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/UpdateApplicationHomeSubClusterRequest.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/UpdateApplicationHomeSubClusterRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/UpdateApplicationHomeSubClusterRequest.java new file mode 100644 index 0000000..eaa9252 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/UpdateApplicationHomeSubClusterRequest.java @@ -0,0 +1,74 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.util.Records; + +/** + * <p> + * The request sent by the <code>Router</code> to + * <code>Federation state store</code> to update the home subcluster of a newly + * submitted application. + * + * <p> + * The request includes the mapping details, i.e.: + * <ul> + * <li>{@code ApplicationId}</li> + * <li>{@code SubClusterId}</li> + * </ul> + */ +@Private +@Unstable +public abstract class UpdateApplicationHomeSubClusterRequest { + + @Private + @Unstable + public static UpdateApplicationHomeSubClusterRequest newInstance( + ApplicationHomeSubCluster applicationHomeSubCluster) { + UpdateApplicationHomeSubClusterRequest updateApplicationRequest = + Records.newRecord(UpdateApplicationHomeSubClusterRequest.class); + updateApplicationRequest + .setApplicationHomeSubCluster(applicationHomeSubCluster); + return updateApplicationRequest; + } + + /** + * Get the {@link ApplicationHomeSubCluster} representing the mapping of the + * application to it's home sub-cluster. + * + * @return the mapping of the application to it's home sub-cluster. + */ + @Public + @Unstable + public abstract ApplicationHomeSubCluster getApplicationHomeSubCluster(); + + /** + * Set the {@link ApplicationHomeSubCluster} representing the mapping of the + * application to it's home sub-cluster. + * + * @param applicationHomeSubCluster the mapping of the application to it's + * home sub-cluster. + */ + @Private + @Unstable + public abstract void setApplicationHomeSubCluster( + ApplicationHomeSubCluster applicationHomeSubCluster); +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/UpdateApplicationHomeSubClusterResponse.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/UpdateApplicationHomeSubClusterResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/UpdateApplicationHomeSubClusterResponse.java new file mode 100644 index 0000000..7434335 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/UpdateApplicationHomeSubClusterResponse.java @@ -0,0 +1,43 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.util.Records; + +/** + * UpdateApplicationHomeSubClusterResponse contains the answer from the + * {@code FederationApplicationHomeSubClusterStore} to a request to register the + * home subcluster of a submitted application. Currently response is empty if + * the operation was successful, if not an exception reporting reason for a + * failure. + */ +@Private +@Unstable +public abstract class UpdateApplicationHomeSubClusterResponse { + + @Private + @Unstable + public static UpdateApplicationHomeSubClusterResponse newInstance() { + UpdateApplicationHomeSubClusterResponse response = + Records.newRecord(UpdateApplicationHomeSubClusterResponse.class); + return response; + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/AddApplicationHomeSubClusterRequestPBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/AddApplicationHomeSubClusterRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/AddApplicationHomeSubClusterRequestPBImpl.java new file mode 100644 index 0000000..2387cde --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/AddApplicationHomeSubClusterRequestPBImpl.java @@ -0,0 +1,132 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.AddApplicationHomeSubClusterRequestProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.AddApplicationHomeSubClusterRequestProtoOrBuilder; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.ApplicationHomeSubClusterProto; +import org.apache.hadoop.yarn.server.federation.store.records.AddApplicationHomeSubClusterRequest; +import org.apache.hadoop.yarn.server.federation.store.records.ApplicationHomeSubCluster; + +import com.google.protobuf.TextFormat; + +/** + * Protocol buffer based implementation of + * {@link AddApplicationHomeSubClusterRequest}. + */ +@Private +@Unstable +public class AddApplicationHomeSubClusterRequestPBImpl + extends AddApplicationHomeSubClusterRequest { + + private AddApplicationHomeSubClusterRequestProto proto = + AddApplicationHomeSubClusterRequestProto.getDefaultInstance(); + private AddApplicationHomeSubClusterRequestProto.Builder builder = null; + private boolean viaProto = false; + + public AddApplicationHomeSubClusterRequestPBImpl() { + builder = AddApplicationHomeSubClusterRequestProto.newBuilder(); + } + + public AddApplicationHomeSubClusterRequestPBImpl( + AddApplicationHomeSubClusterRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public AddApplicationHomeSubClusterRequestProto getProto() { + mergeLocalToProto(); + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private void mergeLocalToProto() { + if (viaProto) { + maybeInitBuilder(); + } + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = AddApplicationHomeSubClusterRequestProto.newBuilder(proto); + } + viaProto = false; + } + + private void mergeLocalToBuilder() { + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + + @Override + public ApplicationHomeSubCluster getApplicationHomeSubCluster() { + AddApplicationHomeSubClusterRequestProtoOrBuilder p = + viaProto ? proto : builder; + if (!p.hasAppSubclusterMap()) { + return null; + } + return convertFromProtoFormat(p.getAppSubclusterMap()); + } + + @Override + public void setApplicationHomeSubCluster( + ApplicationHomeSubCluster applicationInfo) { + maybeInitBuilder(); + if (applicationInfo == null) { + builder.clearAppSubclusterMap(); + return; + } + builder.setAppSubclusterMap(convertToProtoFormat(applicationInfo)); + } + + private ApplicationHomeSubCluster convertFromProtoFormat( + ApplicationHomeSubClusterProto sc) { + return new ApplicationHomeSubClusterPBImpl(sc); + } + + private ApplicationHomeSubClusterProto convertToProtoFormat( + ApplicationHomeSubCluster sc) { + return ((ApplicationHomeSubClusterPBImpl) sc).getProto(); + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/AddApplicationHomeSubClusterResponsePBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/AddApplicationHomeSubClusterResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/AddApplicationHomeSubClusterResponsePBImpl.java new file mode 100644 index 0000000..1415981 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/AddApplicationHomeSubClusterResponsePBImpl.java @@ -0,0 +1,78 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.AddApplicationHomeSubClusterResponseProto; +import org.apache.hadoop.yarn.server.federation.store.records.AddApplicationHomeSubClusterResponse; + +import com.google.protobuf.TextFormat; + +/** + * Protocol buffer based implementation of + * {@link AddApplicationHomeSubClusterResponse}. + */ +@Private +@Unstable +public class AddApplicationHomeSubClusterResponsePBImpl + extends AddApplicationHomeSubClusterResponse { + + private AddApplicationHomeSubClusterResponseProto proto = + AddApplicationHomeSubClusterResponseProto.getDefaultInstance(); + private AddApplicationHomeSubClusterResponseProto.Builder builder = null; + private boolean viaProto = false; + + public AddApplicationHomeSubClusterResponsePBImpl() { + builder = AddApplicationHomeSubClusterResponseProto.newBuilder(); + } + + public AddApplicationHomeSubClusterResponsePBImpl( + AddApplicationHomeSubClusterResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public AddApplicationHomeSubClusterResponseProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/ApplicationHomeSubClusterPBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/ApplicationHomeSubClusterPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/ApplicationHomeSubClusterPBImpl.java new file mode 100644 index 0000000..7e6a564 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/ApplicationHomeSubClusterPBImpl.java @@ -0,0 +1,167 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.ApplicationHomeSubClusterProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.ApplicationHomeSubClusterProtoOrBuilder; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; +import org.apache.hadoop.yarn.server.federation.store.records.ApplicationHomeSubCluster; +import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId; + +import com.google.protobuf.TextFormat; + +/** + * Protocol buffer based implementation of {@link ApplicationHomeSubCluster}. + */ +@Private +@Unstable +public class ApplicationHomeSubClusterPBImpl extends ApplicationHomeSubCluster { + + private ApplicationHomeSubClusterProto proto = + ApplicationHomeSubClusterProto.getDefaultInstance(); + private ApplicationHomeSubClusterProto.Builder builder = null; + private boolean viaProto = false; + + private ApplicationId applicationId = null; + private SubClusterId homeSubCluster = null; + + public ApplicationHomeSubClusterPBImpl() { + builder = ApplicationHomeSubClusterProto.newBuilder(); + } + + public ApplicationHomeSubClusterPBImpl(ApplicationHomeSubClusterProto proto) { + this.proto = proto; + viaProto = true; + } + + public ApplicationHomeSubClusterProto getProto() { + mergeLocalToProto(); + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private void mergeLocalToProto() { + if (viaProto) { + maybeInitBuilder(); + } + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = ApplicationHomeSubClusterProto.newBuilder(proto); + } + viaProto = false; + } + + private void mergeLocalToBuilder() { + if (this.applicationId != null) { + builder.setApplicationId(convertToProtoFormat(this.applicationId)); + } + if (this.homeSubCluster != null) { + builder.setHomeSubCluster(convertToProtoFormat(this.homeSubCluster)); + } + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + + @Override + public ApplicationId getApplicationId() { + ApplicationHomeSubClusterProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasApplicationId()) { + return null; + } + this.applicationId = convertFromProtoFormat(p.getApplicationId()); + return applicationId; + } + + @Override + public void setApplicationId(ApplicationId applicationId) { + maybeInitBuilder(); + if (applicationId == null) { + builder.clearApplicationId(); + return; + } + this.applicationId = applicationId; + } + + @Override + public SubClusterId getHomeSubCluster() { + ApplicationHomeSubClusterProtoOrBuilder p = viaProto ? proto : builder; + if (this.homeSubCluster != null) { + return this.homeSubCluster; + } + if (!p.hasHomeSubCluster()) { + return null; + } + this.homeSubCluster = convertFromProtoFormat(p.getHomeSubCluster()); + return this.homeSubCluster; + } + + @Override + public void setHomeSubCluster(SubClusterId homeSubCluster) { + maybeInitBuilder(); + if (homeSubCluster == null) { + builder.clearHomeSubCluster(); + } + this.homeSubCluster = homeSubCluster; + } + + private SubClusterId convertFromProtoFormat(SubClusterIdProto subClusterId) { + return new SubClusterIdPBImpl(subClusterId); + } + + private SubClusterIdProto convertToProtoFormat(SubClusterId subClusterId) { + return ((SubClusterIdPBImpl) subClusterId).getProto(); + } + + private ApplicationId convertFromProtoFormat(ApplicationIdProto appId) { + return new ApplicationIdPBImpl(appId); + } + + private ApplicationIdProto convertToProtoFormat(ApplicationId appId) { + return ((ApplicationIdPBImpl) appId).getProto(); + } +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/DeleteApplicationHomeSubClusterRequestPBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/DeleteApplicationHomeSubClusterRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/DeleteApplicationHomeSubClusterRequestPBImpl.java new file mode 100644 index 0000000..b4ef680 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/DeleteApplicationHomeSubClusterRequestPBImpl.java @@ -0,0 +1,130 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.DeleteApplicationHomeSubClusterRequestProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.DeleteApplicationHomeSubClusterRequestProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; +import org.apache.hadoop.yarn.server.federation.store.records.DeleteApplicationHomeSubClusterRequest; + +import com.google.protobuf.TextFormat; + +/** + * Protocol buffer based implementation of + * {@link DeleteApplicationHomeSubClusterRequest}. + */ +@Private +@Unstable +public class DeleteApplicationHomeSubClusterRequestPBImpl + extends DeleteApplicationHomeSubClusterRequest { + + private DeleteApplicationHomeSubClusterRequestProto proto = + DeleteApplicationHomeSubClusterRequestProto.getDefaultInstance(); + private DeleteApplicationHomeSubClusterRequestProto.Builder builder = null; + private boolean viaProto = false; + + public DeleteApplicationHomeSubClusterRequestPBImpl() { + builder = DeleteApplicationHomeSubClusterRequestProto.newBuilder(); + } + + public DeleteApplicationHomeSubClusterRequestPBImpl( + DeleteApplicationHomeSubClusterRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public DeleteApplicationHomeSubClusterRequestProto getProto() { + mergeLocalToProto(); + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private void mergeLocalToProto() { + if (viaProto) { + maybeInitBuilder(); + } + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = DeleteApplicationHomeSubClusterRequestProto.newBuilder(proto); + } + viaProto = false; + } + + private void mergeLocalToBuilder() { + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + + @Override + public ApplicationId getApplicationId() { + DeleteApplicationHomeSubClusterRequestProtoOrBuilder p = + viaProto ? proto : builder; + if (!p.hasApplicationId()) { + return null; + } + return convertFromProtoFormat(p.getApplicationId()); + } + + @Override + public void setApplicationId(ApplicationId applicationId) { + maybeInitBuilder(); + if (applicationId == null) { + builder.clearApplicationId(); + return; + } + builder.setApplicationId(convertToProtoFormat(applicationId)); + } + + private ApplicationId convertFromProtoFormat(ApplicationIdProto appId) { + return new ApplicationIdPBImpl(appId); + } + + private ApplicationIdProto convertToProtoFormat(ApplicationId appId) { + return ((ApplicationIdPBImpl) appId).getProto(); + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/DeleteApplicationHomeSubClusterResponsePBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/DeleteApplicationHomeSubClusterResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/DeleteApplicationHomeSubClusterResponsePBImpl.java new file mode 100644 index 0000000..8a37b3c --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/DeleteApplicationHomeSubClusterResponsePBImpl.java @@ -0,0 +1,78 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.DeleteApplicationHomeSubClusterResponseProto; +import org.apache.hadoop.yarn.server.federation.store.records.DeleteApplicationHomeSubClusterResponse; + +import com.google.protobuf.TextFormat; + +/** + * Protocol buffer based implementation of + * {@link DeleteApplicationHomeSubClusterResponse}. + */ +@Private +@Unstable +public class DeleteApplicationHomeSubClusterResponsePBImpl + extends DeleteApplicationHomeSubClusterResponse { + + private DeleteApplicationHomeSubClusterResponseProto proto = + DeleteApplicationHomeSubClusterResponseProto.getDefaultInstance(); + private DeleteApplicationHomeSubClusterResponseProto.Builder builder = null; + private boolean viaProto = false; + + public DeleteApplicationHomeSubClusterResponsePBImpl() { + builder = DeleteApplicationHomeSubClusterResponseProto.newBuilder(); + } + + public DeleteApplicationHomeSubClusterResponsePBImpl( + DeleteApplicationHomeSubClusterResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public DeleteApplicationHomeSubClusterResponseProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationHomeSubClusterRequestPBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationHomeSubClusterRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationHomeSubClusterRequestPBImpl.java new file mode 100644 index 0000000..865d0c4 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationHomeSubClusterRequestPBImpl.java @@ -0,0 +1,135 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.GetApplicationHomeSubClusterRequestProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.GetApplicationHomeSubClusterRequestProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; +import org.apache.hadoop.yarn.server.federation.store.records.GetApplicationHomeSubClusterRequest; + +import com.google.protobuf.TextFormat; + +/** + * Protocol buffer based implementation of + * {@link GetApplicationHomeSubClusterRequest}. + */ +@Private +@Unstable +public class GetApplicationHomeSubClusterRequestPBImpl + extends GetApplicationHomeSubClusterRequest { + + private GetApplicationHomeSubClusterRequestProto proto = + GetApplicationHomeSubClusterRequestProto.getDefaultInstance(); + private GetApplicationHomeSubClusterRequestProto.Builder builder = null; + private boolean viaProto = false; + + private ApplicationId applicationId = null; + + public GetApplicationHomeSubClusterRequestPBImpl() { + builder = GetApplicationHomeSubClusterRequestProto.newBuilder(); + } + + public GetApplicationHomeSubClusterRequestPBImpl( + GetApplicationHomeSubClusterRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public GetApplicationHomeSubClusterRequestProto getProto() { + mergeLocalToProto(); + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private void mergeLocalToProto() { + if (viaProto) { + maybeInitBuilder(); + } + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = GetApplicationHomeSubClusterRequestProto.newBuilder(proto); + } + viaProto = false; + } + + private void mergeLocalToBuilder() { + if (this.applicationId != null) { + builder.setApplicationId(convertToProtoFormat(this.applicationId)); + } + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + + @Override + public ApplicationId getApplicationId() { + GetApplicationHomeSubClusterRequestProtoOrBuilder p = + viaProto ? proto : builder; + if (!p.hasApplicationId()) { + return null; + } + this.applicationId = convertFromProtoFormat(p.getApplicationId()); + return applicationId; + } + + @Override + public void setApplicationId(ApplicationId applicationId) { + maybeInitBuilder(); + if (applicationId == null) { + builder.clearApplicationId(); + return; + } + this.applicationId = applicationId; + } + + private ApplicationId convertFromProtoFormat(ApplicationIdProto appId) { + return new ApplicationIdPBImpl(appId); + } + + private ApplicationIdProto convertToProtoFormat(ApplicationId appId) { + return ((ApplicationIdPBImpl) appId).getProto(); + } +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationHomeSubClusterResponsePBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationHomeSubClusterResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationHomeSubClusterResponsePBImpl.java new file mode 100644 index 0000000..1180488 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationHomeSubClusterResponsePBImpl.java @@ -0,0 +1,132 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.ApplicationHomeSubClusterProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.GetApplicationHomeSubClusterResponseProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.GetApplicationHomeSubClusterResponseProtoOrBuilder; +import org.apache.hadoop.yarn.server.federation.store.records.ApplicationHomeSubCluster; +import org.apache.hadoop.yarn.server.federation.store.records.GetApplicationHomeSubClusterResponse; + +import com.google.protobuf.TextFormat; + +/** + * Protocol buffer based implementation of + * {@link GetApplicationHomeSubClusterResponse}. + */ +@Private +@Unstable +public class GetApplicationHomeSubClusterResponsePBImpl + extends GetApplicationHomeSubClusterResponse { + + private GetApplicationHomeSubClusterResponseProto proto = + GetApplicationHomeSubClusterResponseProto.getDefaultInstance(); + private GetApplicationHomeSubClusterResponseProto.Builder builder = null; + private boolean viaProto = false; + + public GetApplicationHomeSubClusterResponsePBImpl() { + builder = GetApplicationHomeSubClusterResponseProto.newBuilder(); + } + + public GetApplicationHomeSubClusterResponsePBImpl( + GetApplicationHomeSubClusterResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public GetApplicationHomeSubClusterResponseProto getProto() { + mergeLocalToProto(); + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + private void mergeLocalToProto() { + if (viaProto) { + maybeInitBuilder(); + } + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = GetApplicationHomeSubClusterResponseProto.newBuilder(proto); + } + viaProto = false; + } + + private void mergeLocalToBuilder() { + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + + @Override + public ApplicationHomeSubCluster getApplicationHomeSubCluster() { + GetApplicationHomeSubClusterResponseProtoOrBuilder p = + viaProto ? proto : builder; + if (!p.hasAppSubclusterMap()) { + return null; + } + return convertFromProtoFormat(p.getAppSubclusterMap()); + } + + @Override + public void setApplicationHomeSubCluster( + ApplicationHomeSubCluster applicationInfo) { + maybeInitBuilder(); + if (applicationInfo == null) { + builder.clearAppSubclusterMap(); + return; + } + builder.setAppSubclusterMap(convertToProtoFormat(applicationInfo)); + } + + private ApplicationHomeSubCluster convertFromProtoFormat( + ApplicationHomeSubClusterProto sc) { + return new ApplicationHomeSubClusterPBImpl(sc); + } + + private ApplicationHomeSubClusterProto convertToProtoFormat( + ApplicationHomeSubCluster sc) { + return ((ApplicationHomeSubClusterPBImpl) sc).getProto(); + } + +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/ea75da73/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationsHomeSubClusterRequestPBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationsHomeSubClusterRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationsHomeSubClusterRequestPBImpl.java new file mode 100644 index 0000000..3ce8d74 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationsHomeSubClusterRequestPBImpl.java @@ -0,0 +1,78 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.hadoop.yarn.server.federation.store.records.impl.pb; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.GetApplicationsHomeSubClusterRequestProto; +import org.apache.hadoop.yarn.server.federation.store.records.GetApplicationsHomeSubClusterRequest; + +import com.google.protobuf.TextFormat; + +/** + * Protocol buffer based implementation of + * {@link GetApplicationsHomeSubClusterRequest}. + */ +@Private +@Unstable +public class GetApplicationsHomeSubClusterRequestPBImpl + extends GetApplicationsHomeSubClusterRequest { + + private GetApplicationsHomeSubClusterRequestProto proto = + GetApplicationsHomeSubClusterRequestProto.getDefaultInstance(); + private GetApplicationsHomeSubClusterRequestProto.Builder builder = null; + private boolean viaProto = false; + + public GetApplicationsHomeSubClusterRequestPBImpl() { + builder = GetApplicationsHomeSubClusterRequestProto.newBuilder(); + } + + public GetApplicationsHomeSubClusterRequestPBImpl( + GetApplicationsHomeSubClusterRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public GetApplicationsHomeSubClusterRequestProto 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()); + } + +} --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org