commit f28c235600c05b06a5aea2914033a1a223dc6a54 Author: Eric Yang Date: Fri Nov 17 17:26:29 2017 -0500 YARN-7399. First draft of the storage interface. diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/catalog/Storage.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/catalog/Storage.java new file mode 100644 index 0000000..71c3bdb --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/catalog/Storage.java @@ -0,0 +1,115 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.yarn.service.catalog; + +import java.security.PrivilegedActionException; +import java.util.List; + +import org.apache.hadoop.classification.InterfaceStability; +import org.apache.hadoop.io.retry.Idempotent; +import org.apache.hadoop.security.UserGroupInformation; +import org.apache.hadoop.yarn.service.api.records.Service; +import org.apache.hadoop.yarn.service.api.records.ServiceTemplate; + +/** + * Application catalog storage interface - This protocol + * describes the list of operations that Yarn Service API + * communicate with storage backend for persist Yarn + * application metadata. + * + */ +@InterfaceStability.Evolving +@InterfaceStability.Unstable +public interface Storage { + + /** + * Register a service template with backend. + * @param service + */ + @Idempotent + public void register(ServiceTemplate service) throws PrivilegedActionException; + + /** + * Overwrite a service template with backend. + */ + @Idempotent + public void save(ServiceTemplate service, final UserGroupInformation ugi) + throws PrivilegedActionException; + + /** + * Search for service template that matches text parameter. + * @param text - search text + * @param start - starting offset + * @param limit - size limit + */ + @Idempotent + public List search(String text, long start, long limit); + + /** + * Retrieve a list of recommended services template. + * @return + */ + @Idempotent + public List getRecommended(); + + /** + * Delete a service template from storage. + * @param service + */ + @Idempotent + public void delete(ServiceTemplate service, final UserGroupInformation ugi) + throws PrivilegedActionException; + + /** + * List currently active services for all users. + */ + @Idempotent + public List list() throws PrivilegedActionException; + + /** + * List currently active services for a user. + * @param user - user name + */ + @Idempotent + public List list(final UserGroupInformation ugi) + throws PrivilegedActionException; + + /** + * Retrieve information about the service. + * @param serviceName - service name + */ + @Idempotent + public Service get(String serviceName, final UserGroupInformation ugi) + throws PrivilegedActionException; + + /** + * Persist information about the service. + * @param service + */ + @Idempotent + public void save(Service service, final UserGroupInformation ugi) + throws PrivilegedActionException; + + /** + * Remove the active service from storage. + * @param serviceName - service name + */ + @Idempotent + public void remove(String serviceName, final UserGroupInformation ugi) + throws PrivilegedActionException; +}