Bug 1764 - created new bundle responsible for default OF switch configuration
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / 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.openflow.md.queue;
9
10 import org.opendaylight.openflowplugin.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)} 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 <IN> source type
23  * @param <OUT> result type
24  */
25 public interface QueueKeeper<IN> extends AutoCloseable {
26     
27     /** type of message enqueue */
28     public enum QueueType {
29         /** ordered processing */
30         DEFAULT,
31         /** unordered processing - bypass fair processing */
32         UNORDERED}
33
34     /**
35      * enqueue message for processing
36      * @param message
37      * @param conductor source of message
38      * @param queueType - {@link QueueType#DEFAULT} if message order matters, {@link QueueType#UNORDERED} otherwise
39      */
40     void push(IN message, ConnectionConductor conductor, QueueType queueType);
41
42     /**
43      * @return oldest item from queue - if available and remove it from queue
44      */
45     QueueItem<IN> poll();
46
47     /**
48      * @param processingRegistration the processingRegistration to set (in order to provide close method)
49      */
50     void setPollRegistration(AutoCloseable processingRegistration);
51 }