2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.openflowplugin.openflow.md.queue;
10 import java.util.Collection;
11 import java.util.List;
14 import org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductor;
15 import org.opendaylight.openflowplugin.openflow.md.core.IMDMessageTranslator;
16 import org.opendaylight.openflowplugin.openflow.md.core.TranslatorKey;
19 * This processing mechanism based on queue. Processing consists of 2 steps: translate and publish.
20 * Proposed workflow (might slightly deviate in implementations):
22 * <li>messages of input type are pushed in (via {@link QueueKeeper#push(Object, ConnectionConductor)} and similar)</li>
23 * <li>ticket (executable task) is build upon each pushed message and enqueued</li>
24 * <li>ticket is translated using appropriate translator</li>
25 * <li>ticket is dequeued and result is published by appropriate popListener</li>
27 * Message order might be not important, e.g. when speed is of the essence
28 * @param <IN> source type
29 * @param <OUT> result type
31 public interface QueueKeeper<IN, OUT> {
33 /** type of message enqueue */
34 public enum QueueType {
35 /** ordered processing */
37 /** unordered processing - bypass fair processing */
41 * @param translatorMapping translators for message processing
43 void setTranslatorMapping(Map<TranslatorKey, Collection<IMDMessageTranslator<IN, List<OUT>>>> translatorMapping);
46 * enqueue message for processing using {@link QueueType#DEFAULT}
48 * @param conductor source of message
50 void push(IN message, ConnectionConductor conductor);
53 * enqueue message for processing
55 * @param conductor source of message
56 * @param queueType - {@link QueueType#DEFAULT} if message order matters, {@link QueueType#UNORDERED} otherwise
58 void push(IN message, ConnectionConductor conductor, QueueType queueType);
61 * @param popListenersMapping listeners invoked when processing done
63 void setPopListenersMapping(Map<Class<? extends OUT>, Collection<PopListener<OUT>>> popListenersMapping);