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.workflow; 020 021import java.util.Date; 022import java.util.Map; 023import org.apache.hadoop.conf.Configuration; 024 025 026/** 027 * The workflow library provides application parsing and storage capabilities for workflow instances. <p> The 028 * implementation is responsible for doing the store operations in a transactional way, either in autocommit or within 029 * the scope of a transaction. 030 */ 031public interface WorkflowLib { 032 033 /** 034 * Parse a workflow application definition. 035 * 036 * @param wfXml string containing the workflow definition. 037 * @param jobConf job configuration 038 * @param configDefault configuration from config-default.xml 039 * @return the parse workflow application. 040 * @throws WorkflowException thrown if the definition could not be parsed. 041 */ 042 WorkflowApp parseDef(String wfXml, Configuration jobConf, Configuration configDefault) 043 throws WorkflowException; 044 045 /** 046 * Create a workflow instance. 047 * 048 * @param app application to create a workflow instance of. 049 * @param conf job configuration. 050 * @return the newly created workflow instance. 051 * @throws WorkflowException thrown if the instance could not be created. 052 */ 053 WorkflowInstance createInstance(WorkflowApp app, Configuration conf) throws WorkflowException; 054 055 /** 056 * Create a workflow instance with the given wfId and actions endtime map. This will be used for re-running workflows. 057 * 058 * @param app application to create a workflow instance of. 059 * @param conf job configuration. 060 * @param wfId Workflow ID. 061 * @return the newly created workflow instance. 062 * @throws WorkflowException thrown if the instance could not be created. 063 */ 064 WorkflowInstance createInstance(WorkflowApp app, Configuration conf, String wfId) 065 throws WorkflowException; 066 067 /** 068 * Insert a workflow instance in storage. 069 * 070 * @param instance of the workflow instance to insert. 071 * @throws WorkflowException thrown if the instance could not be inserted. 072 */ 073 void insert(WorkflowInstance instance) throws WorkflowException; 074 075 /** 076 * Load a workflow instance from storage. 077 * 078 * @param id ID of the workflow instance to load. 079 * @return the loaded workflow instance. 080 * @throws WorkflowException thrown if the instance could not be loaded. 081 */ 082 WorkflowInstance get(String id) throws WorkflowException; 083 084 /** 085 * Update a workflow instance in storage. 086 * 087 * @param instance workflow instance to update. 088 * @throws WorkflowException thrown if the instance could not be loaded. 089 */ 090 void update(WorkflowInstance instance) throws WorkflowException; 091 092 /** 093 * Delete a workflow instance from storage. 094 * 095 * @param id ID of the workflow instance to delete. 096 * @throws WorkflowException thrown if the instance could not be deleted. 097 */ 098 void delete(String id) throws WorkflowException; 099 100 101 /** 102 * Commit changes to store. 103 * 104 * @throws WorkflowException thrown if the commit could not be done. 105 */ 106 void commit() throws WorkflowException; 107 108 /** 109 * Close store. It rollbacks if there was no commit. 110 * 111 * @throws WorkflowException thrown if the close could not be done. 112 */ 113 void close() throws WorkflowException; 114 115}