close();
}
- @Override
- public PeerId getPeerId() {
- return this.peerId;
- }
-
@Override
public void close() {
Preconditions.checkState(this.up, "Already closed.");
new NodeIdentifier(TablesUtil.BMP_ROUTES_QNAME)).build()).build());
}
- void removeTable(final DOMDataWriteTransaction tx) {
- tx.delete(LogicalDatastoreType.OPERATIONAL, this.tableId);
- }
-
void writeRoutes(final DOMDataWriteTransaction tx, final MpReachNlri nlri, final Attributes attributes) {
final ContainerNode domNlri = serializeReachNlri(nlri);
final ContainerNode routeAttributes = serializeAttributes(attributes);
package org.opendaylight.protocol.bmp.impl.spi;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerId;
import org.opendaylight.yangtools.yang.binding.Notification;
/**
*/
public interface BmpRouterPeer extends AutoCloseable {
- /**
- * Peer is identified by it's BGP-ID.
- * @return PeerId peer identifier.
- */
- PeerId getPeerId();
-
/**
* Process peer-peer message that is related to this peer.
* @param message BMP Per-peer message.
import org.junit.Before;
import org.junit.Test;
import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.yang.bmp.impl.MonitoredRouter;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
private BmpDispatcher dispatcher;
private BmpMonitoringStation bmpApp;
private BmpMessageRegistry msgRegistry;
- private List<MonitoredRouter> mrs;
private ModuleInfoBackedContext moduleInfoBackedContext;
this.bmpApp = BmpMonitoringStationImpl.createBmpMonitorInstance(ribExtension, this.dispatcher, getDomBroker(),
MONITOR_ID, new InetSocketAddress(InetAddresses.forString(MONITOR_LOCAL_ADDRESS), MONITOR_LOCAL_PORT), Optional.of(keys),
- this.mappingService.getCodecFactory(), this.moduleInfoBackedContext.getSchemaContext(), this.mrs);
+ this.mappingService.getCodecFactory(), this.moduleInfoBackedContext.getSchemaContext(), null);
readData(InstanceIdentifier.create(BmpMonitor.class), monitor -> {
Assert.assertEquals(1, monitor.getMonitor().size());
public void deploySecondInstance() throws Exception {
final BmpMonitoringStation monitoringStation2 = BmpMonitoringStationImpl.createBmpMonitorInstance(new SimpleRIBExtensionProviderContext(), this.dispatcher, getDomBroker(),
new MonitorId("monitor2"), new InetSocketAddress(InetAddresses.forString(MONITOR_LOCAL_ADDRESS_2), MONITOR_LOCAL_PORT), Optional.of(KeyMapping.getKeyMapping()),
- this.mappingService.getCodecFactory(), this.moduleInfoBackedContext.getSchemaContext(), this.mrs);
+ this.mappingService.getCodecFactory(), this.moduleInfoBackedContext.getSchemaContext(), null);
readData(InstanceIdentifier.create(BmpMonitor.class), monitor -> {
Assert.assertEquals(2, monitor.getMonitor().size());
private static PeerHeader createPeerHeader(final Ipv4Address bgpId, final AdjRibInType ribType) {
return new PeerHeaderBuilder()
.setAddress(new IpAddress(bgpId))
- .setAdjRibInType(AdjRibInType.PrePolicy)
+ .setAdjRibInType(ribType)
.setAs(new AsNumber(ASN))
.setBgpId(bgpId)
.setIpv4(true)
@Test
public void testCreateRouteMonitoringPostPolicy() {
final RouteMonitoringMessage routeMonitoring = BmpMockUtil.createRouteMonitoring(PEER_IP, AdjRibInType.PostPolicy, PREFIX);
- assertEquals(AdjRibInType.PrePolicy, routeMonitoring.getPeerHeader().getAdjRibInType());
+ assertEquals(AdjRibInType.PostPolicy, routeMonitoring.getPeerHeader().getAdjRibInType());
}
@Test(expected=UnsupportedOperationException.class)
throw e.getCause();
}
}
-
}
return routeMirrorMsgBuilder.build();
}
- public static RouteMirroringMessage createRouteMirrorMsg() {
- return createRouteMirrorMsg(IPV4_ADDRESS_10);
- }
-
private static Update createUpdate(final boolean withNormalizedIpv4Prefixes) {
final UpdateBuilder updateBuilder = new UpdateBuilder()
.setAttributes(createAttributes())
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.flowspec.handlers;
-
-import io.netty.buffer.ByteBuf;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.destination.Flowspec;
-
-public interface FlowspecParser {
- Flowspec parseFlowspec(ByteBuf buffer);
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.flowspec.handlers;
-
-import io.netty.buffer.ByteBuf;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.destination.Flowspec;
-
-public interface FlowspecSerializer {
- void serializeFlowspec(Flowspec value, ByteBuf output);
-}
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecCase) (result.getAdvertizedRoutes().getDestinationType()))
.getDestinationFlowspec()
.getFlowspec();
- testFlows(flows, destinationPrefix, sourcePrefix, prots, prots, ps, dps, sps);
+ testFlows(flows, destinationPrefix, sourcePrefix, prots, ps, dps, sps);
final ByteBuf buffer = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mp.setAfi(Ipv4AddressFamily.class).build()).build()).build(), buffer);
assertEquals("all packets to 10.0.1.0/32 AND from 1.2.3.4/32 AND where IP protocol equals to 6 AND where port is greater than or equals to 137 and is less than or equals to 139 or equals to 8080 AND where destination port is greater than 4089 or equals to 179 AND where source port equals to 8080 ", FS_PARSER.stringNlri(flows));
}
- private void testFlows(final List<Flowspec> flows, final DestinationPrefixCase destinationPrefix, final SourcePrefixCase sourcePrefix, final FlowspecType prots, final FlowspecType flowspecType, final PortCase ps, final FlowspecType dps, final FlowspecType sps) {
+ private void testFlows(final List<Flowspec> flows, final DestinationPrefixCase destinationPrefix, final SourcePrefixCase sourcePrefix,
+ final FlowspecType prots, final PortCase ps, final FlowspecType dps, final FlowspecType sps) {
assertEquals(6, flows.size());
assertEquals(destinationPrefix, flows.get(0).getFlowspecType());
assertEquals(sourcePrefix, flows.get(1).getFlowspecType());
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecCase) (result.getAdvertizedRoutes().getDestinationType()))
.getDestinationFlowspec()
.getFlowspec();
- testFlows(flows, destinationPrefix, sourcePrefix, prots, prots, ps, dps, sps);
+ testFlows(flows, destinationPrefix, sourcePrefix, prots, ps, dps, sps);
final ByteBuf buffer = Unpooled.buffer();
parser.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mp.setAfi(Ipv4AddressFamily.class).build()).build()).build(), buffer);
private final static Class safi = UnicastSubsequentAddressFamily.class;
@Mock private SubsequentAddressFamilyRegistry safir;
@Mock private SubsequentAddressFamilyRegistry safirException;
- private final ByteBuf serializedBytes = Unpooled.copiedBuffer(new byte[] {1, 4, 1, 4, 0, 4});
@Before
public void setUp() {
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.parser.spi;
-
-public interface BGPExtensionConsumerActivator {
- void start(BGPExtensionConsumerContext context);
-
- void stop();
-}
\ No newline at end of file
*/
package org.opendaylight.protocol.bgp.parser.spi.pojo;
-import com.google.common.base.Preconditions;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import java.util.concurrent.atomic.AtomicReference;
return this.referenceCache;
}
- public final synchronized int getMaximumCachedObjects() {
- return this.maximumCachedObjects;
- }
-
- public final synchronized void setMaximumCachedObjects(final int maximumCachedObjects) {
- Preconditions.checkArgument(maximumCachedObjects >= 0);
-
- final Cache<Object, Object> newCache = CacheBuilder.newBuilder().maximumSize(maximumCachedObjects).build();
- newCache.putAll(this.cacheRef.get().asMap());
- this.cacheRef.set(newCache);
- }
-
@Override
public AutoCloseable registerExtendedCommunitySerializer(final Class<? extends ExtendedCommunity> extendedCommunityClass,
final ExtendedCommunitySerializer serializer) {
}
}
- @Override
- public boolean isSessionActive() {
- return this.session != null;
- }
-
@Override
public synchronized byte[] getRawIdentifier() {
return Arrays.copyOf(this.rawIdentifier, this.rawIdentifier.length);
}
}
- public synchronized void registerRootRuntimeBean(final BGPPeerRuntimeRegistrator registrator) {
- this.registrator = registrator;
- }
-
@Override
public BgpSessionState getBgpSessionState() {
if (this.session instanceof BGPSessionStats) {
return this.channel != null && this.channel.isWritable();
}
- void schedule(final Runnable task) {
- Preconditions.checkState(this.channel != null);
- this.channel.eventLoop().submit(task);
- }
-
- @VisibleForTesting
- protected synchronized void setLastMessageSentAt(final long lastMessageSentAt) {
- this.lastMessageSentAt = lastMessageSentAt;
- }
-
@Override
public synchronized BgpSessionState getBgpSessionState() {
return this.sessionStats.getBgpSessionState();
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.rib.impl.spi;
-
-import io.netty.channel.ChannelFuture;
-import java.net.InetSocketAddress;
-import org.opendaylight.protocol.concepts.KeyMapping;
-
-/**
- * Dispatcher class for creating BGP server.
- */
-public interface BGPServerDispatcher {
-
- /**
- * Create new BGP server to accept incoming bgp connections (bound to provided socket address).
- *
- * @param peerRegistry BGP peer registry
- * @param address server address
- * @return ChannelFuture promising a server session
- */
- ChannelFuture createServer(BGPPeerRegistry peerRegistry, InetSocketAddress address);
-
- /**
- * Create new BGP server to accept incoming bgp connections (bound to provided socket address).
- *
- * @param peerRegistry BGP peer registry
- * @param address server address
- * @param keys KeyMapping
- * @return ChannelFuture promising a server session
- */
- ChannelFuture createServer(BGPPeerRegistry peerRegistry, InetSocketAddress address, KeyMapping keys);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.rib.impl.spi;
-
-/**
- * Interface that provides the initial acceptable session characteristics with which the session should be started.
- */
-public interface BGPSessionProposal {
- /**
- * Returns BGPSessionPreferences for this IP address.
- *
- * @return BGPSessionPreferences with acceptable session characteristics
- */
- BGPSessionPreferences getProposal();
-}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
import org.opendaylight.yangtools.yang.common.QName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-/**
- * @author Kevin Wang
- */
public final class BGPPeerStatsImpl implements BGPPeerStats {
- private static final Logger LOG = LoggerFactory.getLogger(BGPPeerStatsImpl.class);
-
private final Set<TablesKey> tablesKeySet;
private final PerTableTypeRouteCounter adjRibInRouteCounters;
private final PerTableTypeRouteCounter adjRibOutRouteCounters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * @author Kevin Wang
- */
public final class PerTableTypeRouteCounter {
private static final Logger LOG = LoggerFactory.getLogger(PerTableTypeRouteCounter.class);
return this.counters.getOrDefault(Preconditions.checkNotNull(tablesKey), createCounter(tablesKey));
}
- /**
- * Get the counter with given tablesKey
- * @param tablesKey
- * @return
- */
- public final UnsignedInt32Counter getCounter(@Nonnull final TablesKey tablesKey) {
- return this.counters.get(Preconditions.checkNotNull(tablesKey));
- }
-
/**
* Get the counter with given tablesKey. Create an empty counter if it doesn't exist
* This method will put the created empty counter back to map
private static final int EXP_INSTANCES = 8;
private static final String INSTANCE_NAME = "application-peer-instance";
- private static final String INSTANCE_NAME2 = "application-peer-instance-2";
private static final String FACTORY_NAME = BGPApplicationPeerModuleFactory.NAME;
private static final ApplicationRibId APP_RIB_ID = new ApplicationRibId("application-peer-test");
private static final ApplicationRibId NEW_APP_RIB_ID = new ApplicationRibId("new-application-peer-name");
return transaction.createModule(StrictBgpPeerRegistryModuleFactory.NAME, "peer-registry");
}
- private static BGPDispatcherImplModuleMXBean getBgpDispatcherImplModuleMXBean(final ConfigTransactionJMXClient transaction,
- final BGPPeerModuleMXBean mxBean) {
- final RIBImplModuleMXBean ribProxy = transaction.newMXBeanProxy(mxBean.getRib(), RIBImplModuleMXBean.class);
- final ObjectName dispatcherON = ribProxy.getBgpDispatcher();
- return transaction.newMXBeanProxy(dispatcherON, BGPDispatcherImplModuleMXBean.class);
- }
-
private CommitStatus createBgpPeerInstance() throws Exception {
return createBgpPeerInstance(false);
}
b.addChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(PREFIX_QNAME)).withValue(p).build());
final DataTreeCandidateNode child = Mockito.mock(DataTreeCandidateNode.class);
- Mockito.doReturn(createIdentifier(target, p)).when(child).getIdentifier();
+ Mockito.doReturn(createIdentifier(p)).when(child).getIdentifier();
Mockito.doReturn(Optional.of(b.build())).when(child).getDataAfter();
Mockito.doReturn(type).when(child).getModificationType();
children.add(child);
return col;
}
- public PathArgument createIdentifier(final YangInstanceIdentifier base, final Ipv4Prefix prefix) {
+ public PathArgument createIdentifier(final Ipv4Prefix prefix) {
final NodeIdentifierWithPredicates routekey = new NodeIdentifierWithPredicates(Ipv4Route.QNAME, PREFIX_QNAME, prefix);
return YangInstanceIdentifier.of(PREFIX_QNAME).node(routekey).getLastPathArgument();
}
return this.listMsg;
}
- @Override
- public boolean isSessionActive() {
- return getSession().isWritable();
- }
-
@Override
public void markUptodate(final TablesKey tablesKey) {
LOG.debug("Table marked as up-to-date {}", tablesKey);
import io.netty.buffer.Unpooled;
import java.io.Closeable;
-import java.util.Arrays;
-import java.util.Iterator;
import java.util.List;
import javax.annotation.concurrent.GuardedBy;
return messages;
}
- public synchronized void insertConnectionLostEvent() {
- this.insertMessage(CONNECTION_LOST_MAGIC_MSG);
- }
-
- public synchronized void insertMessages(final List<Notification> messages) {
- for (final Notification message : messages) {
- this.insertMessage(message);
- }
- }
-
- @GuardedBy("this")
- private void insertMessage(final Notification message) {
- this.allPreviousBGPMessages.add(message);
- this.eventBus.post(message);
- }
-
@Override
public synchronized void close() {
// unregister all EventBusRegistration instances
this.openRegistrations.clear();
}
- public boolean isMessageListSame(final List<byte[]> newMessages) {
- if (this.allPreviousBGPMessages.size() != newMessages.size()) {
- return false;
- }
- final Iterator<byte[]> i1 = this.allPreviousByteMessages.iterator();
- final Iterator<byte[]> i2 = newMessages.iterator();
- for (int i = 0; i < this.allPreviousBGPMessages.size(); i++) {
- if (!Arrays.equals(i1.next(), i2.next())) {
- return false;
- }
- }
- return true;
- }
-
- public EventBus getEventBus() {
- return this.eventBus;
- }
-
public ListenerRegistration<BGPSessionListener> registerUpdateListener(final BGPSessionListener listener) {
return EventBusRegistration.createAndRegister(this.eventBus, listener, this.allPreviousBGPMessages);
}
*/
public interface BGPSessionListener extends EventListener {
- /**
- * Returns state of BGP session associated with this listener.
- *
- * @return false if session associated with this listener is null, true if its non-null
- */
- boolean isSessionActive();
-
/**
* Marks synchronization finished for given Table key
*
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.rib.spi;
-
-public interface RIBExtensionConsumerActivator {
- void startRIBExtensionConsumer(RIBExtensionConsumerContext context);
-
- void stopRIBExtensionConsumer(RIBExtensionConsumerContext context);
-}
\ No newline at end of file
this.multiPathSupport = multiPathSupport;
}
- @Override
- public boolean isSessionActive() {
- return true;
- }
-
@Override
public void markUptodate(final TablesKey tablesKey) {
LOG.debug("Table marked as up-to-date {}", tablesKey);
import static com.google.common.base.Strings.isNullOrEmpty;
-import com.google.common.base.Optional;
import java.net.InetAddress;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
-import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.rfc2385.cfg.rev160324.Rfc2385Key;
public final class KeyMapping extends HashMap<InetAddress, byte[]> {
private static final long serialVersionUID = 1L;
super();
}
- private KeyMapping(final int initialCapacity, final float loadFactor) {
- super(initialCapacity, loadFactor);
- }
-
- private KeyMapping(final int initialCapacity) {
- super(initialCapacity);
- }
-
- private KeyMapping(final Map<? extends InetAddress, ? extends byte[]> m) {
- super(m);
- }
-
public static KeyMapping getKeyMapping(@Nonnull final InetAddress inetAddress, @Nullable final String password){
if (!isNullOrEmpty(password)) {
final KeyMapping keyMapping = new KeyMapping();
final KeyMapping keyMapping = new KeyMapping();
return keyMapping;
}
-
- public static KeyMapping getKeyMapping(@Nonnull final InetAddress inetAddress, final Optional<Rfc2385Key> password){
- if (password.isPresent()) {
- return getKeyMapping(inetAddress, password.get().getValue());
- }
- return null;
- }
}
* Factory for generating PCEP Session proposals. Used by a server.
*/
public interface PCEPSessionProposalFactory {
-
- /**
- * Returns one session proposal that is registered to this factory
- *
- * @param address serves as constraint, so that factory is able to return different proposals for different
- * addresses
- * @param sessionId is used for creation of PCEPOpenObject
- * @return specific session proposal
- */
- Open getSessionProposal(InetSocketAddress address, int sessionId);
-
/**
*
* @param address serves as constraint, so that factory is able to return different proposals for different
}
final PcreqMessageBuilder mBuilder = new PcreqMessageBuilder();
mBuilder.setMonitoringRequest(monReq);
- final List<Svec> svecs = getSvecs(objects, errors);
+ final List<Svec> svecs = getSvecs(objects);
if (!svecs.isEmpty()) {
mBuilder.setSvec(svecs);
}
}
final PcreqMessageBuilder mBuilder = new PcreqMessageBuilder();
mBuilder.setMonitoringRequest(getMonitoring(objects));
- final List<Svec> svecs = getSvecs(objects, errors);
+ final List<Svec> svecs = getSvecs(objects);
if (!svecs.isEmpty()) {
mBuilder.setSvec(svecs);
}
return new PcreqBuilder().setPcreqMessage(mBuilder.build()).build();
}
- protected List<Svec> getSvecs(final List<Object> objects, final List<Message> errors) {
+ protected List<Svec> getSvecs(final List<Object> objects) {
final List<Svec> svecList = new ArrayList<>();
while (!objects.isEmpty()) {
final SvecBuilder sBuilder = new SvecBuilder();
public static final int TYPE = 27;
- protected static final int ENTERPRISE_NUM_LENGTH = 4;
-
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
Preconditions.checkArgument(tlv instanceof VsTlv, "Vendor Specific Tlv is mandatory.");
import static org.junit.Assert.assertFalse;
import com.google.common.collect.Lists;
-import com.google.common.primitives.Bytes;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.Before;
}
}
- @Override
- public Open getSessionProposal(final InetSocketAddress address, final int sessionId) {
- return getSessionProposal(address, sessionId, null);
- }
-
@Override
public Open getSessionProposal(final InetSocketAddress address, final int sessionId,
final PCEPPeerProposal peerProposal) {
return oBuilder.setTlvs(builder.build()).build();
}
- public int getKeepAlive() {
- return this.keepAlive;
- }
-
- public int getDeadTimer() {
- return this.deadTimer;
- }
-
@Override
public List<PCEPCapability> getCapabilities() {
return this.capabilities;
import org.opendaylight.protocol.pcep.PCEPSession;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
import org.opendaylight.protocol.pcep.PCEPTerminationReason;
-import org.opendaylight.protocol.pcep.impl.spi.Util;
-import org.opendaylight.protocol.pcep.spi.PCEPErrors;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public boolean down = false;
- public MockPCE() {
- }
-
- public void sendMessage(final Message msg) {
- this.session.handleMessage(msg);
- }
-
- public void sendErrorMessage(final PCEPErrors value, final Open open) {
- this.sendMessage(Util.createErrorMessage(value, open));
- }
-
- public List<Message> getListMsg() {
- return this.listMsg;
- }
-
- public void addSession(final PCEPSessionImpl l) {
- this.session = l;
- }
-
@Override
public void onMessage(final PCEPSession session, final Message message) {
this.listMsg.add(message);
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
-import io.netty.util.concurrent.DefaultPromise;
import io.netty.util.concurrent.EventExecutor;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GlobalEventExecutor;
this.disp2Spy = Mockito.spy(dispatcher2);
this.pccMock = new PCCMock(new DefaultPCEPSessionNegotiatorFactory(sessionProposal, 0),
- new PCEPHandlerFactory(msgReg), new DefaultPromise<PCEPSessionImpl>(
- GlobalEventExecutor.INSTANCE));
+ new PCEPHandlerFactory(msgReg));
}
@Test
private final PCEPHandlerFactory factory;
private final EventExecutor executor;
private final EventLoopGroup workerGroup;
- private final EventLoopGroup bossGroup;
- public PCCMock(final PCEPSessionNegotiatorFactory negotiatorFactory, final PCEPHandlerFactory factory,
- final DefaultPromise<PCEPSessionImpl> defaultPromise) {
- this.bossGroup = Preconditions.checkNotNull(new NioEventLoopGroup());
+ public PCCMock(final PCEPSessionNegotiatorFactory negotiatorFactory, final PCEPHandlerFactory factory) {
this.workerGroup = Preconditions.checkNotNull(new NioEventLoopGroup());
this.negotiatorFactory = Preconditions.checkNotNull(negotiatorFactory);
this.factory = Preconditions.checkNotNull(factory);
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.impl;
-
-import static org.mockito.Mockito.mock;
-import io.netty.channel.Channel;
-import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.GlobalEventExecutor;
-
-import org.opendaylight.protocol.pcep.PCEPCloseTermination;
-import org.opendaylight.protocol.pcep.PCEPSessionListener;
-import org.opendaylight.protocol.pcep.TerminationReason;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
-
-public class ServerSessionMock extends PCEPSessionImpl {
-
- private final MockPCE client;
-
- public ServerSessionMock(final PCEPSessionListener listener, final PCEPSessionListener client) {
- super(listener, 5, mock(Channel.class), new OpenBuilder().setKeepalive((short) 4).setDeadTimer((short) 9).setSessionId(
- (short) 2).build(), new OpenBuilder().setKeepalive((short) 4).setDeadTimer((short) 9).setSessionId((short) 2).build());
- this.client = (MockPCE) client;
- }
-
- @Override
- public Future<Void> sendMessage(final Message msg) {
- this.lastMessageSentAt = System.nanoTime();
- this.client.onMessage(this, msg);
- return GlobalEventExecutor.INSTANCE.newSucceededFuture(null);
- }
-
- @Override
- public void close() {
- this.client.onSessionTerminated(this, new PCEPCloseTermination(TerminationReason.UNKNOWN));
- }
-}
return this.remoteLspDbVersion.getLspDbVersionValue();
}
- public boolean isRemoteLspDbVersionNull() {
- if (this.remoteLspDbVersion == null) {
- return true;
- }
- return false;
- }
-
private static LspDbVersion getLspDbVersion(final Tlvs openTlvs) {
if (openTlvs != null) {
final Tlvs3 tlvs3 = openTlvs.getAugmentation(Tlvs3.class);
import io.netty.util.concurrent.Future;
import java.net.InetSocketAddress;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
import org.opendaylight.protocol.pcep.PCEPCapability;
import org.opendaylight.protocol.pcep.PCEPDispatcher;
import org.opendaylight.protocol.pcep.PCEPSession;
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.spi;
-
-public interface PCEPExtensionConsumerActivator {
- void start(PCEPExtensionConsumerContext context);
-
- void stop();
-}
\ No newline at end of file
return this.pccIdentifier.child(ReportedLsp.class, new ReportedLspKey(name));
}
- protected final InstanceIdentifier<PathComputationClient> getPccIdentifier() {
- return this.pccIdentifier;
- }
-
/**
* Remove LSP from the database.
*
}
}
- public synchronized void removeLspMetadata(final String name) {
- metadata.remove(name);
- }
-
public synchronized void cleanupExcept(final Collection<String> values) {
final Iterator<String> it = metadata.keySet().iterator();
while (it.hasNext()) {
import static org.junit.Assert.fail;
import io.netty.channel.nio.NioEventLoopGroup;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Random;
import javax.management.ObjectName;
import static org.junit.Assert.fail;
import io.netty.channel.nio.NioEventLoopGroup;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import javax.management.ObjectName;
import org.junit.Before;
package org.opendaylight.protocol.rsvp.parser.spi.pojo;
-import com.google.common.base.Preconditions;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import java.util.concurrent.atomic.AtomicReference;
this.cacheRef = new AtomicReference<Cache<Object,Object>>(cache);
}
- public final synchronized int getMaximumCachedObjects() {
- return this.maximumCachedObjects;
- }
-
- public final synchronized void setMaximumCachedObjects(final int maximumCachedObjects) {
- Preconditions.checkArgument(maximumCachedObjects >= 0);
-
- final Cache<Object, Object> newCache = CacheBuilder.newBuilder().maximumSize(maximumCachedObjects).build();
- newCache.putAll(this.cacheRef.get().asMap());
- this.cacheRef.set(newCache);
- }
-
@Override
public ReferenceCache getReferenceCache() {
return this.referenceCache;
public static final int IPV6_PREFIX_BYTE_LENGTH = Ipv6Util.IPV6_LENGTH + 1;
- public static final int AFI_BYTES_LENGTH = 2;
-
- public static final int SAFI_BYTES_LENGTH = 1;
-
private ByteBufWriteUtil() {
throw new UnsupportedOperationException();
}