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 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
13 * factory for {@link QueueKeeper} implementations
15 public abstract class QueueKeeperFactory {
18 * @param sourceRegistrator
19 * @param capacity blocking queue capacity
20 * @return fair reading implementation of {@link QueueKeeper} (not registered = not started yet)
22 public static QueueKeeper<OfHeader> createFairQueueKeeper(
23 MessageSourcePollRegistrator<QueueKeeper<OfHeader>> sourceRegistrator, int capacity) {
24 QueueKeeperFairImpl queueKeeper = new QueueKeeperFairImpl();
25 queueKeeper.setCapacity(capacity);
26 queueKeeper.setHarvesterHandle(sourceRegistrator.getHarvesterHandle());
33 * register queue by harvester, start processing it. Use {@link QueueKeeperFairImpl#close()} to kill the queue and stop processing.
34 * @param sourceRegistrator
37 public static <V> void plugQueue(
38 MessageSourcePollRegistrator<QueueKeeper<V>> sourceRegistrator,
39 QueueKeeper<V> queueKeeper) {
40 AutoCloseable registration = sourceRegistrator.registerMessageSource(queueKeeper);
41 queueKeeper.setPollRegistration(registration);