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.event; 019 020 import java.io.Serializable; 021 import java.util.List; 022 023 import org.apache.hadoop.conf.Configuration; 024 import org.apache.oozie.client.event.Event; 025 026 /** 027 * Interface to define the queue operations for the events system 028 */ 029 public interface EventQueue { 030 031 public class EventQueueElement implements Serializable { 032 033 private static final long serialVersionUID = 1L; 034 Event event; 035 036 public EventQueueElement(Event e) { 037 event = e; 038 } 039 } 040 041 /** 042 * Initialize the event queue 043 * @param conf 044 */ 045 public void init(Configuration conf); 046 047 /** 048 * Add event to queue 049 * @param event 050 */ 051 public void add(Event e); 052 053 /** 054 * Fetch events from queue in batch 055 * @return events set 056 */ 057 public List<Event> pollBatch(); 058 059 /** 060 * Fetch single event from queue 061 * @return event 062 */ 063 public Event poll(); 064 065 /** 066 * Find out if queue is empty 067 * @return boolean 068 */ 069 public boolean isEmpty(); 070 071 /** 072 * Get current queue size 073 * @return size 074 */ 075 public int size(); 076 077 /** 078 * Read topmost event from queue but do not pop from it 079 * @return event 080 */ 081 public Event peek(); 082 083 /** 084 * Get the batch size used during polling events 085 * @return batchSize 086 */ 087 public int getBatchSize(); 088 089 /** 090 * Clear the events queue 091 */ 092 public void clear(); 093 094 }