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