Fix Jdk8 compatibility
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / md / queue / QueueKeeper.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.openflowplugin.api.openflow.md.queue;
9
10 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
11
12 /**
13  * This processing mechanism based on queue. Processing consists of 2 steps: translate and publish.
14  * Proposed workflow (might slightly deviate in implementations):
15  * <ol>
16  * <li>messages of input type are pushed in (via {@link QueueKeeper#push(Object, ConnectionConductor, QueueType)} and similar)</li>
17  * <li>ticket (executable task) is build upon each pushed message and enqueued</li>
18  * <li>ticket is translated using appropriate translator</li>
19  * <li>ticket is dequeued and result is published by appropriate popListener</li>
20  * </ol>
21  * Message order might be not important, e.g. when speed is of the essence
22  * @param <I> source type (IN)
23  */
24 public interface QueueKeeper<I> extends AutoCloseable {
25
26     /** type of message enqueue */
27     public enum QueueType {
28         /** ordered processing */
29         DEFAULT,
30         /** unordered processing - bypass fair processing */
31         UNORDERED}
32
33     /**
34      * enqueue message for processing
35      * @param message
36      * @param conductor source of message
37      * @param queueType - {@link QueueType#DEFAULT} if message order matters, {@link QueueType#UNORDERED} otherwise
38      */
39     void push(I message, ConnectionConductor conductor, QueueType queueType);
40
41     /**
42      * @return oldest item from queue - if available and remove it from queue
43      */
44     QueueItem<I> poll();
45
46     /**
47      * @param processingRegistration the processingRegistration to set (in order to provide close method)
48      */
49     void setPollRegistration(AutoCloseable processingRegistration);
50 }