001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *      http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    package org.apache.oozie.dependency.hcat;
019    
020    import java.util.Collection;
021    import java.util.Map;
022    import java.util.Set;
023    
024    import org.apache.hadoop.conf.Configuration;
025    import org.apache.oozie.util.HCatURI;
026    
027    public interface HCatDependencyCache {
028    
029        /**
030         * Initialize the cache with configuration
031         *
032         * @param conf configuration
033         */
034        public void init(Configuration conf);
035    
036        /**
037         * Add a missing partition dependency and the actionID waiting on it
038         *
039         * @param hcatURI dependency URI
040         * @param actionID ID of action which is waiting for the dependency
041         */
042        public void addMissingDependency(HCatURI hcatURI, String actionID);
043    
044        /**
045         * Remove a missing partition dependency associated with a actionID
046         *
047         * @param hcatURI dependency URI
048         * @param actionID ID of action which is waiting for the dependency
049         * @return true if successful, else false
050         */
051        public boolean removeMissingDependency(HCatURI hcatURI, String actionID);
052    
053        /**
054         * Get the list of actionIDs waiting for a partition
055         *
056         * @param hcatURI dependency URI
057         * @return list of actionIDs
058         */
059        public Collection<String> getWaitingActions(HCatURI hcatURI);
060    
061        /**
062         * Mark a partition dependency as available
063         *
064         * @param server host:port of the server
065         * @param db name of the database
066         * @param table name of the table
067         * @param partitions list of available partitions
068         * @return list of actionIDs for which the dependency is now available
069         */
070        public Collection<String> markDependencyAvailable(String server, String db, String table, Map<String, String> partitions);
071    
072        /**
073         * Get a list of available dependency URIs for a actionID
074         *
075         * @param actionID action id
076         * @return list of available dependency URIs
077         */
078        public Collection<String> getAvailableDependencyURIs(String actionID);
079    
080        /**
081         * Remove the list of available dependency URIs for a actionID once the missing dependencies are processed.
082         *
083         * @param actionID action id
084         * @param dependencyURIs set of dependency URIs
085         * @return true if successful, else false
086         */
087        public boolean removeAvailableDependencyURIs(String actionID, Collection<String> dependencyURIs);
088    
089        /**
090         * Destroy the cache
091         */
092        public void destroy();
093    
094        /**
095         * Purge stale actions
096         */
097        public void removeNonWaitingCoordActions(Set<String> coordActions);
098    
099        /**
100         * Remove coordAction when all dependencies met
101         */
102        public void removeCoordActionWithDependenciesAvailable(String coordAction);
103    
104    }