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 019package org.apache.oozie.dependency.hcat; 020 021import java.util.Collection; 022import java.util.Map; 023import java.util.Set; 024 025import org.apache.hadoop.conf.Configuration; 026import org.apache.oozie.util.HCatURI; 027 028public interface HCatDependencyCache { 029 030 /** 031 * Initialize the cache with configuration 032 * 033 * @param conf configuration 034 */ 035 void init(Configuration conf); 036 037 /** 038 * Add a missing partition dependency and the actionID waiting on it 039 * 040 * @param hcatURI dependency URI 041 * @param actionID ID of action which is waiting for the dependency 042 */ 043 void addMissingDependency(HCatURI hcatURI, String actionID); 044 045 /** 046 * Remove a missing partition dependency associated with a actionID 047 * 048 * @param hcatURI dependency URI 049 * @param actionID ID of action which is waiting for the dependency 050 * @return true if successful, else false 051 */ 052 boolean removeMissingDependency(HCatURI hcatURI, String actionID); 053 054 /** 055 * Get the list of actionIDs waiting for a partition 056 * 057 * @param hcatURI dependency URI 058 * @return list of actionIDs 059 */ 060 Collection<String> getWaitingActions(HCatURI hcatURI); 061 062 /** 063 * Mark a partition dependency as available 064 * 065 * @param server host:port of the server 066 * @param db name of the database 067 * @param table name of the table 068 * @param partitions list of available partitions 069 * @return list of actionIDs for which the dependency is now available 070 */ 071 Collection<String> markDependencyAvailable(String server, String db, String table, Map<String, String> partitions); 072 073 /** 074 * Get a list of available dependency URIs for a actionID 075 * 076 * @param actionID action id 077 * @return list of available dependency URIs 078 */ 079 Collection<String> getAvailableDependencyURIs(String actionID); 080 081 /** 082 * Remove the list of available dependency URIs for a actionID once the missing dependencies are processed. 083 * 084 * @param actionID action id 085 * @param dependencyURIs set of dependency URIs 086 * @return true if successful, else false 087 */ 088 boolean removeAvailableDependencyURIs(String actionID, Collection<String> dependencyURIs); 089 090 /** 091 * Destroy the cache 092 */ 093 void destroy(); 094 095 /** 096 * Purge stale actions 097 */ 098 void removeNonWaitingCoordActions(Set<String> coordActions); 099 100 /** 101 * Remove coordAction when all dependencies met 102 */ 103 void removeCoordActionWithDependenciesAvailable(String coordAction); 104 105}