org.opendaylight.protocol.pcep.subobject,
org.opendaylight.protocol.pcep.tlv,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.*,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.*,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.*,
</Export-Package>
<Import-Package>
+++ /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;
-
-import java.util.List;
-
-/**
- * Basic structure for PCEP Message. Cannot be instantiated directly. Current PCEP version is 1. Each message contains a
- * list of PCEP objects.
- *
- */
-public abstract class PCEPMessage {
-
- private static final long serialVersionUID = 4293319459468168384L;
-
- /**
- * Current supported version of PCEP.
- */
- public static final int PCEP_VERSION = 1;
-
- private final List<PCEPObject> objects;
-
- /**
- * Constructor is protected to prevent direct instantiation, but to allow to call this constructor via super().
- *
- * @param objects
- */
- protected PCEPMessage(final List<PCEPObject> objects) {
- if (objects.contains(null)) {
- throw new IllegalArgumentException("Object list contains null element at offset " + objects.indexOf(null));
- }
-
- this.objects = objects;
- }
-
- /**
- * Returns list of all objects that the message contains
- *
- * @return list of all objects that the message contains
- */
- public List<PCEPObject> getAllObjects() {
- return this.objects;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((this.objects == null) ? 0 : this.objects.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (this.getClass() != obj.getClass()) {
- return false;
- }
- final PCEPMessage other = (PCEPMessage) obj;
- if (this.objects == null) {
- if (other.objects != null) {
- return false;
- }
- } else if (!this.objects.equals(other.objects)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("PCEPMessage [objects=");
- builder.append(this.objects);
- builder.append("]");
- return builder.toString();
- }
-
-}
import org.opendaylight.protocol.framework.ProtocolSession;
import org.opendaylight.protocol.pcep.object.PCEPCloseObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* PCEP Session represents the finite state machine in PCEP, including timers and its purpose is to create a PCEP
* manually. If the session is up, it has to redirect messages to/from user. Handles also malformed messages and unknown
* requests.
*/
-public interface PCEPSession extends ProtocolSession<PCEPMessage> {
+public interface PCEPSession extends ProtocolSession<Message> {
/**
* Sends message from user to PCE/PCC. If the user sends an Open Message, the session returns an error (open message
*
* @param message message to be sent
*/
- public void sendMessage(PCEPMessage message);
+ public void sendMessage(Message message);
public void close(PCEPCloseObject.Reason reason);
}
package org.opendaylight.protocol.pcep;
import org.opendaylight.protocol.framework.SessionListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* Listener that receives session informations from the session.
*/
-public interface PCEPSessionListener extends SessionListener<PCEPMessage, PCEPSession, PCEPTerminationReason> {
+public interface PCEPSessionListener extends SessionListener<Message, PCEPSession, PCEPTerminationReason> {
}
*/
package org.opendaylight.protocol.pcep.message;
-import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.object.CompositeInstantiationObject;
import org.opendaylight.protocol.pcep.object.CompositeStateReportObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
/**
- * @see <a href="http://www.ietf.org/id/draft-crabbe-pce-pce-initiated-lsp-00.txt">5.1. The LSP Create Message</a>
+ * @see <a href="http://www.ietf.org/id/draft-crabbe-pce-pce-initiated-lsp-00.txt">5.1. The LSP Create Message</a>
*/
-public class PCCreateMessage extends PCEPMessage {
-
- private static final long serialVersionUID = -2407399568579836171L;
+public class PCCreateMessage implements Message {
private final List<CompositeInstantiationObject> lsps;
+ private final List<PCEPObject> objects;
+
/**
* Constructs {@link PCCreateMessage}.
- *
- * @throws IllegalArgumentException
- * if there is not even one {@link CompositeInstantiationObject}
- * in the list.
- *
- * @param lsps
- * List<CompositeInstantiationObject>. Can't be empty or null.
+ *
+ * @throws IllegalArgumentException if there is not even one {@link CompositeInstantiationObject} in the list.
+ *
+ * @param lsps List<CompositeInstantiationObject>. Can't be empty or null.
*/
public PCCreateMessage(final List<CompositeInstantiationObject> lsps) {
- super(new ArrayList<PCEPObject>() {
-
- private static final long serialVersionUID = 1L;
-
- {
- if (lsps != null)
- for (final CompositeInstantiationObject cio : lsps) {
- this.addAll(cio.getCompositeAsList());
- }
- }
- });
if (lsps == null || lsps.isEmpty())
throw new IllegalArgumentException("At least one CompositeStateReportObject is mandatory.");
this.lsps = lsps;
+ this.objects = Lists.newArrayList();
+ for (final CompositeInstantiationObject cio : lsps) {
+ this.objects.addAll(cio.getCompositeAsList());
+ }
}
/**
* Gets list of {@link CompositeStateReportObject}.
- *
+ *
* @return List<CompositeStateReportObject>. Can't be null or empty.
*/
public List<CompositeInstantiationObject> getLSPs() {
return this.lsps;
}
+ public List<PCEPObject> getAllObjects() {
+ return this.objects;
+ }
+
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
*/
package org.opendaylight.protocol.pcep.message;
-import java.util.ArrayList;
+import java.util.List;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.object.PCEPCloseObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
/**
* Structure of Close Message.
- *
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.8">Close
- * Message</a>
+ *
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.8">Close Message</a>
*/
-public class PCEPCloseMessage extends PCEPMessage {
-
- private static final long serialVersionUID = -2365304678646268281L;
+public class PCEPCloseMessage implements Message {
private final PCEPCloseObject closeObj;
+ private final List<PCEPObject> objects;
+
/**
- * Constructs a new Close Message, which has to include PCEP Close Object.
- * Is used to close an established session between PCEP Peers.
- *
- * @throws IllegalArgumentException
- * if the CloseObject passed, is null.
- *
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.8">Close
- * Message</a>
- *
- * @param closeObj
- * Can't be null.
+ * Constructs a new Close Message, which has to include PCEP Close Object. Is used to close an established session
+ * between PCEP Peers.
+ *
+ * @throws IllegalArgumentException if the CloseObject passed, is null.
+ *
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.8">Close Message</a>
+ *
+ * @param closeObj Can't be null.
*/
public PCEPCloseMessage(final PCEPCloseObject closeObj) {
- super(new ArrayList<PCEPObject>() {
-
- private static final long serialVersionUID = -8094080277421295531L;
-
- {
- if (closeObj != null)
- this.add(closeObj);
- }
- });
if (closeObj == null)
throw new IllegalArgumentException("PCEPCloseObject is mandatory. Can't be null.");
this.closeObj = closeObj;
+ this.objects = Lists.newArrayList();
+ if (closeObj != null)
+ this.objects.add(closeObj);
}
/**
- * Gets {@link PCEPCloseObject}, which is mandatory object of PCEP Close
- * Message.
- *
+ * Gets {@link PCEPCloseObject}, which is mandatory object of PCEP Close Message.
+ *
* @return {@link PCEPCloseObject} . Can't be null.
*/
public PCEPCloseObject getCloseObject() {
return this.closeObj;
}
+ public List<PCEPObject> getAllObjects() {
+ return this.objects;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
import java.util.Collections;
import java.util.List;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.object.CompositeErrorObject;
import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
/**
* Structure of Error Message.
- *
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.7">Error
- * Message</a>
+ *
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.7">Error Message</a>
*/
-public class PCEPErrorMessage extends PCEPMessage {
-
- private static final long serialVersionUID = 604782651368689577L;
+public class PCEPErrorMessage implements Message {
private PCEPOpenObject openObj;
private final List<CompositeErrorObject> errors;
+ private final List<PCEPObject> objects;
+
public PCEPErrorMessage(final PCEPErrorObject errorObject) {
this(new ArrayList<PCEPErrorObject>() {
private static final long serialVersionUID = 72172137965955228L;
}
/**
- * Constructs Error Message from list of {@link PCEPErrorObject} or
- * {@link CompositeErrorObject}.
- *
- * @param errorObjects
- * List<?> either objects of type: {@link PCEPErrorObject} or
- * {@link CompositeErrorObject}
- *
- * @throws IllegalArgumentException
- * if any other type is passed in the list, that cannot be
- * processed
+ * Constructs Error Message from list of {@link PCEPErrorObject} or {@link CompositeErrorObject}.
+ *
+ * @param errorObjects List<?> either objects of type: {@link PCEPErrorObject} or {@link CompositeErrorObject}
+ *
+ * @throws IllegalArgumentException if any other type is passed in the list, that cannot be processed
*/
public PCEPErrorMessage(final List<?> errorObjects) {
- super(new ArrayList<PCEPObject>() {
-
- private static final long serialVersionUID = -8607527575304297642L;
-
- {
- if (errorObjects != null)
- for (int i = 0; i < errorObjects.size(); i++) {
- if (errorObjects.get(i) instanceof CompositeErrorObject) {
- this.addAll(((CompositeErrorObject) errorObjects.get(i)).getCompositeAsList());
- } else if (errorObjects.get(i) instanceof PCEPErrorObject) {
- this.add((PCEPErrorObject) errorObjects.get(i));
- }
- }
+ this.objects = Lists.newArrayList();
+ if (errorObjects != null)
+ for (int i = 0; i < errorObjects.size(); i++) {
+ if (errorObjects.get(i) instanceof CompositeErrorObject) {
+ this.objects.addAll(((CompositeErrorObject) errorObjects.get(i)).getCompositeAsList());
+ } else if (errorObjects.get(i) instanceof PCEPErrorObject) {
+ this.objects.add((PCEPErrorObject) errorObjects.get(i));
+ }
}
- });
this.errors = new ArrayList<CompositeErrorObject>();
this.errorObjects = new ArrayList<PCEPErrorObject>();
}
/**
- * Constructs Error Message from list of {@link PCEPErrorObject} and
- * {@link CompositeErrorObject} and {@link PCEPOpenObject} that cannot be
- * null. This constructor is used during PCEP handshake to suggest new
- * session characteristics for the session that are listen in
- * {@link PCEPOpenObject}.
- *
- * @param openObj
- * {@link PCEPOpenObject} cannot be null
- * @param errorObjects
- * List<PCEPErrorObject> list of error objects
- * @param errors
- * List<CompositeErrorObject> list of composite error objects
+ * Constructs Error Message from list of {@link PCEPErrorObject} and {@link CompositeErrorObject} and
+ * {@link PCEPOpenObject} that cannot be null. This constructor is used during PCEP handshake to suggest new session
+ * characteristics for the session that are listen in {@link PCEPOpenObject}.
+ *
+ * @param openObj {@link PCEPOpenObject} cannot be null
+ * @param errorObjects List<PCEPErrorObject> list of error objects
+ * @param errors List<CompositeErrorObject> list of composite error objects
*/
public PCEPErrorMessage(final PCEPOpenObject openObj, final List<PCEPErrorObject> errorObjects, final List<CompositeErrorObject> errors) {
- super(new ArrayList<PCEPObject>() {
-
- private static final long serialVersionUID = -4238105145756981972L;
-
- {
- if (errorObjects != null)
- this.addAll(errorObjects);
- if (openObj != null)
- this.add(openObj);
- if (errors != null)
- for (final CompositeErrorObject ceo : errors) {
- this.addAll(ceo.getCompositeAsList());
- }
+ this.objects = Lists.newArrayList();
+ if (errorObjects != null)
+ this.objects.addAll(errorObjects);
+ if (openObj != null)
+ this.objects.add(openObj);
+ if (errors != null)
+ for (final CompositeErrorObject ceo : errors) {
+ this.objects.addAll(ceo.getCompositeAsList());
}
- });
+
this.openObj = openObj;
if (errorObjects == null)
}
/**
- * Gets {@link PCEPOpenObject} if this is included. If its included, it
- * proposes alternative acceptable session characteristic values.
- *
+ * Gets {@link PCEPOpenObject} if this is included. If its included, it proposes alternative acceptable session
+ * characteristic values.
+ *
* @return PCEPOpenObject. May be null.
*/
public PCEPOpenObject getOpenObject() {
}
/**
- * In unsolicited manner can be included List of
- * <code>PCEPErrorObjects</code> <code>PCEPErrorMessage</code>, which is not
- * sent in response to a request.
- *
+ * In unsolicited manner can be included List of <code>PCEPErrorObjects</code> <code>PCEPErrorMessage</code>, which
+ * is not sent in response to a request.
+ *
* @return List<PCEPErrorObject>
*/
public List<PCEPErrorObject> getErrorObjects() {
}
/**
- * If the PCErr message is sent in response to a request, the PCErr message
- * MUST include set of RP objects related to pending path computation
- * requests that triggered the error condition. In this situation it is
- * constructed as {@link org.opendaylight.protocol.pcep.object.CompositeErrorObject
- * CompCompositeErrorObject}. That includes list of RP objects.
- *
+ * If the PCErr message is sent in response to a request, the PCErr message MUST include set of RP objects related
+ * to pending path computation requests that triggered the error condition. In this situation it is constructed as
+ * {@link org.opendaylight.protocol.pcep.object.CompositeErrorObject CompCompositeErrorObject}. That includes list
+ * of RP objects.
+ *
* @return CompositeErrorObject. May be null.
*/
public List<CompositeErrorObject> getErrors() {
return this.errors;
}
+ public List<PCEPObject> getAllObjects() {
+ return this.objects;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
*/
package org.opendaylight.protocol.pcep.message;
-import java.util.Collections;
-
-import org.opendaylight.protocol.pcep.PCEPMessage;
-import org.opendaylight.protocol.pcep.PCEPObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* Structure of Keepalive Message
- *
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.3">KeepAlive
- * Message</a>
+ *
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.3">KeepAlive Message</a>
*/
-public final class PCEPKeepAliveMessage extends PCEPMessage {
-
- private static final long serialVersionUID = 8133032616718362219L;
+public final class PCEPKeepAliveMessage implements Message {
/**
* Default constructor PCEPKeepAliveMessage.
*/
public PCEPKeepAliveMessage() {
- super(Collections.<PCEPObject> emptyList());
}
@Override
*/
package org.opendaylight.protocol.pcep.message;
-import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.object.CompositeNotifyObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
/**
* Structure of Notification Message.
- *
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.6">Notification
- * Message</a>
+ *
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.6">Notification Message</a>
*/
-public class PCEPNotificationMessage extends PCEPMessage {
-
- private static final long serialVersionUID = 2647656169727976386L;
+public class PCEPNotificationMessage implements Message {
private final List<CompositeNotifyObject> notifications;
+ private final List<PCEPObject> objects;
+
/**
* Constructs new Notification Message.
- *
- * @throws IllegalArgumentException
- * if there is not even one {@link CompositeNotifyObject} in the
- * list.
- *
- * @param notifications
- * List<CompositeNotifyObject>. Can't be empty or null.
+ *
+ * @throws IllegalArgumentException if there is not even one {@link CompositeNotifyObject} in the list.
+ *
+ * @param notifications List<CompositeNotifyObject>. Can't be empty or null.
*/
public PCEPNotificationMessage(final List<CompositeNotifyObject> notifications) {
- super(new ArrayList<PCEPObject>() {
-
- private static final long serialVersionUID = 8359665614469883203L;
-
- {
- if (notifications != null)
- for (final CompositeNotifyObject cno : notifications) {
- this.addAll(cno.getCompositeAsList());
- }
+ this.objects = Lists.newArrayList();
+ if (notifications != null) {
+ for (final CompositeNotifyObject cno : notifications) {
+ this.objects.addAll(cno.getCompositeAsList());
}
- });
-
+ }
if (notifications == null || notifications.isEmpty())
throw new IllegalArgumentException("At least one CompositeNotifyObject is mandatory.");
}
/**
- * Gets list of {@link org.opendaylight.protocol.pcep.object.CompositeNotifyObject
- * CompositeNotifyObjects}.
- *
+ * Gets list of {@link org.opendaylight.protocol.pcep.object.CompositeNotifyObject CompositeNotifyObjects}.
+ *
* @return List<CompositeNotifyObject>. Can't be null or empty.
*/
public List<CompositeNotifyObject> getNotifications() {
return this.notifications;
}
+ public List<PCEPObject> getAllObjects() {
+ return this.objects;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
*/
package org.opendaylight.protocol.pcep.message;
-import java.util.ArrayList;
+import java.util.List;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
/**
* Structure of Open Message.
- *
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.2">Open
- * Message</a>
+ *
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.2">Open Message</a>
*/
-public class PCEPOpenMessage extends PCEPMessage {
-
- private static final long serialVersionUID = -588927926753235030L;
+public class PCEPOpenMessage implements Message {
private final PCEPOpenObject openObj;
+ private final List<PCEPObject> objects;
+
/**
* Constructs new Open Message.
- *
- * @throws IllegalArgumentException
- * if the PCEPOpenObject is null.
- *
- * @param openObj
- * {@link PCEPOpenObject}. Can't be null.
+ *
+ * @throws IllegalArgumentException if the PCEPOpenObject is null.
+ *
+ * @param openObj {@link PCEPOpenObject}. Can't be null.
*/
public PCEPOpenMessage(final PCEPOpenObject openObj) {
- super(new ArrayList<PCEPObject>() {
-
- private static final long serialVersionUID = -1339062869814655362L;
-
- {
- if (openObj != null)
- this.add(openObj);
- }
- });
-
- if (openObj == null)
+ this.objects = Lists.newArrayList();
+ if (openObj != null)
+ this.objects.add(openObj);
+ else
throw new IllegalArgumentException("PCEPOpenObject is mandatory.");
this.openObj = openObj;
/**
* Gets {@link PCEPOpenObject}
- *
+ *
* @return {@link PCEPOpenObject}. Can't be null.
*/
public PCEPOpenObject getOpenObject() {
return this.openObj;
}
+ public List<PCEPObject> getAllObjects() {
+ return this.objects;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
*/
package org.opendaylight.protocol.pcep.message;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.object.CompositeReplySvecObject;
import org.opendaylight.protocol.pcep.object.CompositeResponseObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
/**
* Structure for Reply Message.
- *
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.5">Reply
- * Message</a>
+ *
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.5">Reply Message</a>
*/
-public class PCEPReplyMessage extends PCEPMessage {
-
- private static final long serialVersionUID = -4604680426345882626L;
+public class PCEPReplyMessage implements Message {
private final List<CompositeReplySvecObject> svecList;
private final List<CompositeResponseObject> responses;
+ private final List<PCEPObject> objects;
+
/**
* Constructs new Reply Message.
- *
- * @throws IllegalArgumentException
- * if there is not even one {@link CompositeResponseObject} in
- * the list.
- *
- * @param responses
- * List<CompositeResponseObject>. Can't be empty or null.
+ *
+ * @throws IllegalArgumentException if there is not even one {@link CompositeResponseObject} in the list.
+ *
+ * @param responses List<CompositeResponseObject>. Can't be empty or null.
*/
public PCEPReplyMessage(final List<CompositeResponseObject> responses) {
this(responses, null);
/**
* Constructs {@link PCEPReplyMessage}.
- *
- * @throws IllegalArgumentException
- * if there is not even one {@link CompositeResponseObject} in
- * the list.
- *
- * @param svecList
- * List<CompositeSvecObject>
- * @param responses
- * List<CompositeResponseObject>. Can't be empty or null.
+ *
+ * @throws IllegalArgumentException if there is not even one {@link CompositeResponseObject} in the list.
+ *
+ * @param svecList List<CompositeSvecObject>
+ * @param responses List<CompositeResponseObject>. Can't be empty or null.
*/
public PCEPReplyMessage(final List<CompositeResponseObject> responses, final List<CompositeReplySvecObject> svecList) {
- super(new ArrayList<PCEPObject>() {
-
- private static final long serialVersionUID = 4464502017081110298L;
-
- {
- if (svecList != null)
- for (final CompositeReplySvecObject cno : svecList) {
- this.addAll(cno.getCompositeAsList());
- }
- if (responses != null)
- for (final CompositeResponseObject cno : responses) {
- this.addAll(cno.getCompositeAsList());
- }
+ this.objects = Lists.newArrayList();
+ if (svecList != null)
+ for (final CompositeReplySvecObject cno : svecList) {
+ this.objects.addAll(cno.getCompositeAsList());
+ }
+ if (responses != null)
+ for (final CompositeResponseObject cno : responses) {
+ this.objects.addAll(cno.getCompositeAsList());
}
- });
if (responses == null || responses.isEmpty())
throw new IllegalArgumentException("At least one CompositeResponseObject is mandatory.");
/**
* Gets list of {@link CompositeResponseObject}.
- *
+ *
* @return List<CompositeResponseObject>. Can't be null or empty.
*/
public List<CompositeResponseObject> getResponses() {
/**
* Gets list of {@link CompositeReplySvecObject}.
- *
+ *
* @return List<CompositeReplySvecObject>. Can't be null but may be empty.
*/
public List<CompositeReplySvecObject> getSvecList() {
return this.svecList;
}
+ public List<PCEPObject> getAllObjects() {
+ return this.objects;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
*/
package org.opendaylight.protocol.pcep.message;
-import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.object.CompositeStateReportObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
/**
* Structure of Report Message
- *
- * @see <a
- * href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-02#section-6.1">State
- * Report Message</a>
+ *
+ * @see <a href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-02#section-6.1">State Report Message</a>
*/
-public class PCEPReportMessage extends PCEPMessage {
-
- private static final long serialVersionUID = -3319055709351802748L;
+public class PCEPReportMessage implements Message {
private final List<CompositeStateReportObject> reports;
+ private final List<PCEPObject> objects;
+
/**
* Constructs {@link PCEPReportMessage}.
- *
- * @throws IllegalArgumentException
- * if there is not even one {@link CompositeStateReportObject}
- * in the list.
- *
- * @param reports
- * List<CompositeStateReportObject>. Can't be empty or null.
+ *
+ * @throws IllegalArgumentException if there is not even one {@link CompositeStateReportObject} in the list.
+ *
+ * @param reports List<CompositeStateReportObject>. Can't be empty or null.
*/
public PCEPReportMessage(final List<CompositeStateReportObject> reports) {
- super(new ArrayList<PCEPObject>() {
-
- private static final long serialVersionUID = 2785287687806615951L;
-
- {
- if (reports != null)
- for (final CompositeStateReportObject csro : reports) {
- this.addAll(csro.getCompositeAsList());
- }
+ this.objects = Lists.newArrayList();
+ if (reports != null)
+ for (final CompositeStateReportObject csro : reports) {
+ this.objects.addAll(csro.getCompositeAsList());
}
- });
if (reports == null || reports.isEmpty())
throw new IllegalArgumentException("At least one CompositeStateReportObject is mandatory.");
/**
* Gets list of {@link CompositeStateReportObject}.
- *
+ *
* @return List<CompositeStateReportObject>. Can't be null or empty.
*/
public List<CompositeStateReportObject> getStateReports() {
return this.reports;
}
+ public List<PCEPObject> getAllObjects() {
+ return this.objects;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
*/
package org.opendaylight.protocol.pcep.message;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.object.CompositeRequestObject;
import org.opendaylight.protocol.pcep.object.CompositeRequestSvecObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
/**
* Structure of Request Message.
- *
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.4">Request
- * Message</a>
+ *
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.4">Request Message</a>
*/
-public class PCEPRequestMessage extends PCEPMessage {
-
- private static final long serialVersionUID = -1914670070018415483L;
+public class PCEPRequestMessage implements Message {
private final List<CompositeRequestSvecObject> svecList;
private final List<CompositeRequestObject> requests;
+ private final List<PCEPObject> objects;
+
/**
* Constructs new Request Message.
- *
- * @throws IllegalArgumentException
- * if there is not even one {@link CompositeRequestObject} in
- * the list.
- *
- * @param requests
- * List<CompositeRequestObject>. Can't be empty or null.
+ *
+ * @throws IllegalArgumentException if there is not even one {@link CompositeRequestObject} in the list.
+ *
+ * @param requests List<CompositeRequestObject>. Can't be empty or null.
*/
public PCEPRequestMessage(final List<CompositeRequestObject> requests) {
this(null, requests);
/**
* Constructs new Request Message.
- *
- * @throws IllegalArgumentException
- * if there is not even one {@link CompositeRequestObject} in
- * the list.
- *
- * @param svecList
- * List<CompositeSvecObject>
- * @param requests
- * List<CompositeRequestObject>. Can't be null or empty.
+ *
+ * @throws IllegalArgumentException if there is not even one {@link CompositeRequestObject} in the list.
+ *
+ * @param svecList List<CompositeSvecObject>
+ * @param requests List<CompositeRequestObject>. Can't be null or empty.
*/
public PCEPRequestMessage(final List<CompositeRequestSvecObject> svecList, final List<CompositeRequestObject> requests) {
- super(new ArrayList<PCEPObject>() {
-
- private static final long serialVersionUID = -6183368691183167076L;
-
- {
- if (svecList != null)
- for (final CompositeRequestSvecObject cso : svecList) {
- this.addAll(cso.getCompositeAsList());
- }
- if (requests != null)
- for (final CompositeRequestObject cro : requests) {
- this.addAll(cro.getCompositeAsList());
- }
+ this.objects = Lists.newArrayList();
+ if (svecList != null)
+ for (final CompositeRequestSvecObject cso : svecList) {
+ this.objects.addAll(cso.getCompositeAsList());
}
- });
+ if (requests != null)
+ for (final CompositeRequestObject cro : requests) {
+ this.objects.addAll(cro.getCompositeAsList());
+ }
+
if (svecList != null)
this.svecList = svecList;
else
/**
* Gets list of {@link CompositeRequestSvecObject}.
- *
+ *
* @return List<CompositeSvecObject>. Can't be null, but may be empty.
*/
public List<CompositeRequestSvecObject> getSvecObjects() {
/**
* Gets list of {@link CompositeRequestObject}.
- *
+ *
* @return List<CompositeRequestObject>. Can't be null or empty.
*/
public List<CompositeRequestObject> getRequests() {
return this.requests;
}
+ public List<PCEPObject> getAllObjects() {
+ return this.objects;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
*/
package org.opendaylight.protocol.pcep.message;
-import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.object.CompositeUpdateRequestObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
/**
* Structure of Update Request Message.
- *
- * @see <a
- * href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-02#section-6.2">Update
- * Request Message</a>
+ *
+ * @see <a href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-02#section-6.2">Update Request Message</a>
*/
-public class PCEPUpdateRequestMessage extends PCEPMessage {
-
- private static final long serialVersionUID = 3577204028363946097L;
+public class PCEPUpdateRequestMessage implements Message {
private final List<CompositeUpdateRequestObject> updateRequests;
+ private final List<PCEPObject> objects;
+
/**
* Constructs new Update Request Message.
- *
- * @throws IllegalArgumentException
- * if there is not even one {@link CompositeUpdateRequestObject}
- * in the list.
- *
- * @param updateRequests
- * List<CompositeUpdateRequestObject>. Can't be empty or null.
+ *
+ * @throws IllegalArgumentException if there is not even one {@link CompositeUpdateRequestObject} in the list.
+ *
+ * @param updateRequests List<CompositeUpdateRequestObject>. Can't be empty or null.
*/
public PCEPUpdateRequestMessage(final List<CompositeUpdateRequestObject> updateRequests) {
- super(new ArrayList<PCEPObject>() {
-
- private static final long serialVersionUID = 8591736379229064997L;
-
- {
- if (updateRequests != null)
- for (final CompositeUpdateRequestObject curo : updateRequests) {
- this.addAll(curo.getCompositeAsList());
- }
+ this.objects = Lists.newArrayList();
+ if (updateRequests != null)
+ for (final CompositeUpdateRequestObject curo : updateRequests) {
+ this.objects.addAll(curo.getCompositeAsList());
}
- });
if (updateRequests == null || updateRequests.isEmpty())
throw new IllegalArgumentException("At least one CompositeUpdateRequestObject is mandatory.");
/**
* Gets list of {@link CompositeUpdateRequestObject}.
- *
+ *
* @return List<CompositeUpdateRequestObject>. Can't be null or empty.
*/
public List<CompositeUpdateRequestObject> getUpdateRequests() {
return this.updateRequests;
}
+ public List<PCEPObject> getAllObjects() {
+ return this.objects;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
-import java.util.ArrayList;
-import java.util.List;
-
import org.junit.Test;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
import org.opendaylight.protocol.pcep.subobject.EROAsNumberSubobject;
assertEquals(PCEPErrors.C_BIT_SET, de.getError());
}
- @Test
- public void testPCEPMessage() {
- final List<PCEPObject> objs = new ArrayList<PCEPObject>();
- objs.add(new PCEPErrorObject(PCEPErrors.ATTEMPT_2ND_SESSION));
- final PCEPMessage msg1 = new PCEPMessage(objs) {
- private static final long serialVersionUID = 1L;
- };
- final PCEPMessage msg2 = new PCEPMessage(objs) {
- private static final long serialVersionUID = 1L;
- };
-
- assertNotSame(msg1, msg2); // not same because they are anonymous classes
- assertEquals(msg1.hashCode(), msg2.hashCode());
- assertEquals(msg1.toString(), msg2.toString());
- }
-
@Test
public void testPCEPObject() {
final PCEPObject obj1 = new PCEPObject(true, false) {
+++ /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.api;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-
-import org.opendaylight.protocol.concepts.IPv4Address;
-import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.message.PCEPCloseMessage;
-import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
-import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
-import org.opendaylight.protocol.pcep.message.PCEPNotificationMessage;
-import org.opendaylight.protocol.pcep.message.PCEPOpenMessage;
-import org.opendaylight.protocol.pcep.message.PCEPReplyMessage;
-import org.opendaylight.protocol.pcep.message.PCEPReportMessage;
-import org.opendaylight.protocol.pcep.message.PCEPRequestMessage;
-import org.opendaylight.protocol.pcep.message.PCEPUpdateRequestMessage;
-import org.opendaylight.protocol.pcep.object.CompositeErrorObject;
-import org.opendaylight.protocol.pcep.object.CompositeNotifyObject;
-import org.opendaylight.protocol.pcep.object.CompositeRequestObject;
-import org.opendaylight.protocol.pcep.object.CompositeResponseObject;
-import org.opendaylight.protocol.pcep.object.CompositeStateReportObject;
-import org.opendaylight.protocol.pcep.object.CompositeUpdateRequestObject;
-import org.opendaylight.protocol.pcep.object.PCEPCloseObject;
-import org.opendaylight.protocol.pcep.object.PCEPCloseObject.Reason;
-import org.opendaylight.protocol.pcep.object.PCEPEndPointsObject;
-import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
-import org.opendaylight.protocol.pcep.object.PCEPLspObject;
-import org.opendaylight.protocol.pcep.object.PCEPNotificationObject;
-import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
-import org.opendaylight.protocol.pcep.object.PCEPRequestParameterObject;
-
-public class MessagesTest {
-
- @Test
- public void errorMessageTest() {
- final List<PCEPErrorObject> errorObjs = new ArrayList<PCEPErrorObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPErrorObject(PCEPErrors.ATTEMPT_2ND_SESSION));
- this.add(new PCEPErrorObject(PCEPErrors.ATTEMPT_2ND_SESSION));
- }
- };
- final List<CompositeErrorObject> errors = new ArrayList<CompositeErrorObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new CompositeErrorObject(errorObjs));
- }
- };
-
- final List<?> objs = new ArrayList<Object>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new CompositeErrorObject(errorObjs));
- this.add(new PCEPErrorObject(PCEPErrors.BANDWIDTH_MISSING));
- }
- };
-
- final PCEPErrorMessage m = new PCEPErrorMessage(new PCEPOpenObject(10, 10, 1), errorObjs, errors);
- final PCEPErrorMessage m2 = new PCEPErrorMessage(new PCEPOpenObject(10, 10, 1), errorObjs, errors);
- final PCEPErrorMessage m3 = new PCEPErrorMessage(objs);
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getOpenObject(), m2.getOpenObject());
- assertEquals(m.getErrors(), m2.getErrors());
- assertEquals(m.getErrorObjects(), m2.getErrorObjects());
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPCloseMessage(new PCEPCloseObject(Reason.EXP_DEADTIMER))));
- assertTrue(m.equals(m));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void closeMessageTest() {
- final PCEPCloseMessage m = new PCEPCloseMessage(new PCEPCloseObject(Reason.EXP_DEADTIMER));
- final PCEPCloseMessage m2 = new PCEPCloseMessage(new PCEPCloseObject(Reason.EXP_DEADTIMER));
- final PCEPCloseMessage m3 = new PCEPCloseMessage(new PCEPCloseObject(Reason.MALFORMED_MSG));
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getCloseObject(), m2.getCloseObject());
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
-
- new PCEPCloseMessage(null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void openMessageTest() {
- final PCEPOpenMessage m = new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1));
- final PCEPOpenMessage m2 = new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1));
- final PCEPOpenMessage m3 = new PCEPOpenMessage(new PCEPOpenObject(5, 5, 1));
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getOpenObject(), m2.getOpenObject());
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPCloseMessage(new PCEPCloseObject(Reason.EXP_DEADTIMER))));
- assertTrue(m.equals(m));
-
- new PCEPOpenMessage(null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void keepAliveMessageTest() {
- final PCEPKeepAliveMessage m = new PCEPKeepAliveMessage();
- final PCEPKeepAliveMessage m2 = new PCEPKeepAliveMessage();
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertFalse(m.equals(null));
- assertFalse(m.equals(new PCEPCloseMessage(new PCEPCloseObject(Reason.EXP_DEADTIMER))));
- assertTrue(m.equals(m));
-
- new PCEPOpenMessage(null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void notifyMessageTest() {
- final List<CompositeNotifyObject> notifications = new ArrayList<CompositeNotifyObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new CompositeNotifyObject(new ArrayList<PCEPNotificationObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPNotificationObject((short) 2, (short) 3));
- }
- }));
- }
- };
-
- final PCEPNotificationMessage m = new PCEPNotificationMessage(notifications);
- final PCEPNotificationMessage m2 = new PCEPNotificationMessage(notifications);
- final PCEPNotificationMessage m3 = new PCEPNotificationMessage(new ArrayList<CompositeNotifyObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new CompositeNotifyObject(new ArrayList<PCEPNotificationObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPNotificationObject((short) 2, (short) 5));
- }
- }));
- }
- });
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getNotifications(), m2.getNotifications());
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
-
- new PCEPNotificationMessage(null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void replyMessageTest() {
- final List<CompositeResponseObject> replies = new ArrayList<CompositeResponseObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new CompositeResponseObject(new PCEPRequestParameterObject(true, true, true, true, true, false, false, false, (short) 1, 1, true,
- false)));
- }
- };
-
- final PCEPReplyMessage m = new PCEPReplyMessage(replies);
- final PCEPReplyMessage m2 = new PCEPReplyMessage(replies);
- final PCEPReplyMessage m3 = new PCEPReplyMessage(new ArrayList<CompositeResponseObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new CompositeResponseObject(new PCEPRequestParameterObject(true, true, true, false, true, false, false, false, (short) 2, 1, false,
- false)));
- }
- });
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getResponses(), m2.getResponses());
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
-
- new PCEPReplyMessage(null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void reportMessageTest() {
- final List<CompositeStateReportObject> reports = new ArrayList<CompositeStateReportObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new CompositeStateReportObject(new PCEPLspObject(1, true, true, true, true)));
- }
- };
-
- final PCEPReportMessage m = new PCEPReportMessage(reports);
- final PCEPReportMessage m2 = new PCEPReportMessage(reports);
- final PCEPReportMessage m3 = new PCEPReportMessage(new ArrayList<CompositeStateReportObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new CompositeStateReportObject(new PCEPLspObject(5, false, true, true, true)));
- }
- });
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getStateReports(), m2.getStateReports());
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
-
- new PCEPReportMessage(null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void requestMessageTest() {
- final List<CompositeRequestObject> reports = new ArrayList<CompositeRequestObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new CompositeRequestObject(
- new PCEPRequestParameterObject(true, true, true, true, true, false, false, false, (short) 5, 5, true, true),
- new PCEPEndPointsObject<IPv4Address>(
- new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 1 }),
- new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 1 }))));
- }
- };
-
- final PCEPRequestMessage m = new PCEPRequestMessage(reports);
- final PCEPRequestMessage m2 = new PCEPRequestMessage(reports);
- final PCEPRequestMessage m3 = new PCEPRequestMessage(new ArrayList<CompositeRequestObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new CompositeRequestObject(
- new PCEPRequestParameterObject(true, true, true, false, true, false, false, false, (short) 5, 5, true, true),
- new PCEPEndPointsObject<IPv4Address>(
- new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }),
- new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 1 }))));
- }
- });
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getSvecObjects(), m2.getSvecObjects());
- assertEquals(m.getRequests(), m2.getRequests());
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
-
- new PCEPRequestMessage(null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void updateRequestMessageTest() {
- final List<CompositeUpdateRequestObject> reports = new ArrayList<CompositeUpdateRequestObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, true, true, true)));
- }
- };
-
- final PCEPUpdateRequestMessage m = new PCEPUpdateRequestMessage(reports);
- final PCEPUpdateRequestMessage m2 = new PCEPUpdateRequestMessage(reports);
- final PCEPUpdateRequestMessage m3 = new PCEPUpdateRequestMessage(new ArrayList<CompositeUpdateRequestObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new CompositeUpdateRequestObject(new PCEPLspObject(5, true, true, true, true)));
- }
- });
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getUpdateRequests(), m2.getUpdateRequests());
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
-
- new PCEPUpdateRequestMessage(null);
- }
-}
import org.opendaylight.protocol.framework.AbstractSessionNegotiator;
import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
-import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
import org.opendaylight.protocol.pcep.message.PCEPOpenMessage;
import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
+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.keepalive.message.KeepaliveMessageBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableList;
/**
- * Abstract PCEP session negotiator. Takes care of basic handshake without
- * implementing a specific policy. Policies need to be provided by a specific
- * subclass.
+ * Abstract PCEP session negotiator. Takes care of basic handshake without implementing a specific policy. Policies need
+ * to be provided by a specific subclass.
*/
-public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegotiator<PCEPMessage, PCEPSessionImpl> {
+public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegotiator<Message, PCEPSessionImpl> {
/**
* Unified KeepWait and OpenWait timer expiration, in seconds.
*/
public static final int FAIL_TIMER_VALUE = 60;
/**
- * PCEP session negotiation state transitions are described in RFC5440.
- * Simplification the two timers (KeepWait and OpenWait) are merged into
- * a FailTimer, as they are mutually exclusive, have the same timeout
- * value and their action is to terminate negotiation. This timer is
- * restarted between state transitions and runs in all states except
- * Idle and Finished.
+ * PCEP session negotiation state transitions are described in RFC5440. Simplification the two timers (KeepWait and
+ * OpenWait) are merged into a FailTimer, as they are mutually exclusive, have the same timeout value and their
+ * action is to terminate negotiation. This timer is restarted between state transitions and runs in all states
+ * except Idle and Finished.
*/
private enum State {
/**
- * Negotiation has not begun. It will be activated once we are asked
- * to provide our initial proposal, at which point we move into
- * OpenWait state.
+ * Negotiation has not begun. It will be activated once we are asked to provide our initial proposal, at which
+ * point we move into OpenWait state.
*/
Idle,
/**
/**
* Get the initial session parameters proposal.
+ *
* @return Session parameters proposal.
*/
protected abstract PCEPOpenObject getInitialProposal();
/**
- * Get the revised session parameters proposal based on the feedback
- * the peer has provided to us.
+ * Get the revised session parameters proposal based on the feedback the peer has provided to us.
*
* @param suggestion Peer-provided suggested session parameters
* @return Session parameters proposal.
protected abstract boolean isProposalAcceptable(PCEPOpenObject proposal);
/**
- * Given a peer-provided session parameters proposal which we found
- * unacceptable, provide a counter-proposal. The requirement is that
- * the isProposalAcceptable() method has to return true when presented
- * with this proposal.
+ * Given a peer-provided session parameters proposal which we found unacceptable, provide a counter-proposal. The
+ * requirement is that the isProposalAcceptable() method has to return true when presented with this proposal.
*
* @param proposal unacceptable peer proposal
- * @return our counter-proposal, or null if there is no way to negotiate
- * an acceptable proposal
+ * @return our counter-proposal, or null if there is no way to negotiate an acceptable proposal
*/
protected abstract PCEPOpenObject getCounterProposal(PCEPOpenObject proposal);
* @param remotePrefs Session preferences proposed by the peer and accepted by us.
* @return New protocol session.
*/
- protected abstract PCEPSessionImpl createSession(Timer timer, Channel channel,
- PCEPOpenObject localPrefs, PCEPOpenObject remotePrefs);
+ protected abstract PCEPSessionImpl createSession(Timer timer, Channel channel, PCEPOpenObject localPrefs, PCEPOpenObject remotePrefs);
/**
* Sends PCEP Error Message with one PCEPError.
* @param value
*/
private void sendErrorMessage(final PCEPErrors value) {
- channel.writeAndFlush(new PCEPErrorMessage(ImmutableList.of(new PCEPErrorObject(value))));
+ this.channel.writeAndFlush(new PCEPErrorMessage(ImmutableList.of(new PCEPErrorObject(value))));
}
private void scheduleFailTimer() {
final Object lock = this;
- failTimer = timer.newTimeout(new TimerTask() {
+ this.failTimer = this.timer.newTimeout(new TimerTask() {
@Override
public void run(final Timeout timeout) throws Exception {
synchronized (lock) {
// This closes the race between timer expiring and new timer
// being armed while it waits for the lock.
- if (failTimer == timeout) {
- switch (state) {
+ if (AbstractPCEPSessionNegotiator.this.failTimer == timeout) {
+ switch (AbstractPCEPSessionNegotiator.this.state) {
case Finished:
case Idle:
break;
case KeepWait:
sendErrorMessage(PCEPErrors.NO_MSG_BEFORE_EXP_KEEPWAIT);
negotiationFailed(new TimeoutException("KeepWait timer expired"));
- state = State.Finished;
+ AbstractPCEPSessionNegotiator.this.state = State.Finished;
break;
case OpenWait:
sendErrorMessage(PCEPErrors.NO_OPEN_BEFORE_EXP_OPENWAIT);
negotiationFailed(new TimeoutException("OpenWait timer expired"));
- state = State.Finished;
+ AbstractPCEPSessionNegotiator.this.state = State.Finished;
break;
}
}
@Override
final synchronized protected void startNegotiation() {
- Preconditions.checkState(state == State.Idle);
- localPrefs = getInitialProposal();
- channel.writeAndFlush(new PCEPOpenMessage(localPrefs));
- state = State.OpenWait;
+ Preconditions.checkState(this.state == State.Idle);
+ this.localPrefs = getInitialProposal();
+ this.channel.writeAndFlush(new PCEPOpenMessage(this.localPrefs));
+ this.state = State.OpenWait;
scheduleFailTimer();
- logger.debug("Channel {} started sent proposal {}", channel, localPrefs);
+ logger.debug("Channel {} started sent proposal {}", this.channel, this.localPrefs);
}
@Override
- final synchronized protected void handleMessage(final PCEPMessage msg) throws Exception {
- failTimer.cancel();
+ final synchronized protected void handleMessage(final Message msg) throws Exception {
+ this.failTimer.cancel();
- logger.debug("Channel {} handling message in state {}", channel, state);
+ logger.debug("Channel {} handling message in state {}", this.channel, this.state);
- switch (state) {
+ switch (this.state) {
case Finished:
case Idle:
- throw new IllegalStateException("Unexpected handleMessage in state " + state);
+ throw new IllegalStateException("Unexpected handleMessage in state " + this.state);
case KeepWait:
- if (msg instanceof PCEPKeepAliveMessage) {
- localOK = true;
- if (remoteOK) {
- negotiationSuccessful(createSession(timer, channel, localPrefs, remotePrefs));
- state = State.Finished;
+ if (msg instanceof KeepaliveMessage) {
+ this.localOK = true;
+ if (this.remoteOK) {
+ negotiationSuccessful(createSession(this.timer, this.channel, this.localPrefs, this.remotePrefs));
+ this.state = State.Finished;
} else {
scheduleFailTimer();
- state = State.OpenWait;
- logger.debug("Channel {} moved to OpenWait state with localOK=1", channel);
+ this.state = State.OpenWait;
+ logger.debug("Channel {} moved to OpenWait state with localOK=1", this.channel);
}
return;
} else if (msg instanceof PCEPErrorMessage) {
final PCEPErrorMessage err = (PCEPErrorMessage) msg;
- localPrefs = getRevisedProposal(err.getOpenObject());
- if (localPrefs == null) {
+ this.localPrefs = getRevisedProposal(err.getOpenObject());
+ if (this.localPrefs == null) {
sendErrorMessage(PCEPErrors.PCERR_NON_ACC_SESSION_CHAR);
negotiationFailed(new RuntimeException("Peer suggested unacceptable retry proposal"));
- state = State.Finished;
+ this.state = State.Finished;
return;
}
- if (!remoteOK) {
- state = State.OpenWait;
+ if (!this.remoteOK) {
+ this.state = State.OpenWait;
}
scheduleFailTimer();
return;
if (msg instanceof PCEPOpenMessage) {
final PCEPOpenObject open = ((PCEPOpenMessage) msg).getOpenObject();
if (isProposalAcceptable(open)) {
- channel.writeAndFlush(new PCEPKeepAliveMessage());
- remotePrefs = open;
- remoteOK = true;
- if (localOK) {
- negotiationSuccessful(createSession(timer, channel, localPrefs, remotePrefs));
- state = State.Finished;
+ this.channel.writeAndFlush(new KeepaliveMessageBuilder().build());
+ this.remotePrefs = open;
+ this.remoteOK = true;
+ if (this.localOK) {
+ negotiationSuccessful(createSession(this.timer, this.channel, this.localPrefs, this.remotePrefs));
+ this.state = State.Finished;
} else {
scheduleFailTimer();
- state = State.KeepWait;
- logger.debug("Channel {} moved to KeepWait state with remoteOK=1", channel);
+ this.state = State.KeepWait;
+ logger.debug("Channel {} moved to KeepWait state with remoteOK=1", this.channel);
}
return;
}
- if (openRetry) {
+ if (this.openRetry) {
sendErrorMessage(PCEPErrors.SECOND_OPEN_MSG);
negotiationFailed(new RuntimeException("OPEN renegotiation failed"));
- state = State.Finished;
+ this.state = State.Finished;
return;
}
if (newPrefs == null) {
sendErrorMessage(PCEPErrors.NON_ACC_NON_NEG_SESSION_CHAR);
negotiationFailed(new RuntimeException("Peer sent unacceptable session parameters"));
- state = State.Finished;
+ this.state = State.Finished;
return;
}
- channel.writeAndFlush(
- new PCEPErrorMessage(newPrefs, ImmutableList.of(
- new PCEPErrorObject(PCEPErrors.NON_ACC_NEG_SESSION_CHAR)), null));
+ this.channel.writeAndFlush(new PCEPErrorMessage(newPrefs, ImmutableList.of(new PCEPErrorObject(PCEPErrors.NON_ACC_NEG_SESSION_CHAR)), null));
- openRetry = true;
- state = localOK ? State.OpenWait : State.KeepWait;
+ this.openRetry = true;
+ this.state = this.localOK ? State.OpenWait : State.KeepWait;
scheduleFailTimer();
return;
}
break;
}
- logger.warn("Channel {} in state {} received unexpected message {}", channel, state, msg);
+ logger.warn("Channel {} in state {} received unexpected message {}", this.channel, this.state, msg);
sendErrorMessage(PCEPErrors.NON_OR_INVALID_OPEN_MSG);
negotiationFailed(new Exception("Illegal message encountered"));
- state = State.Finished;
+ this.state = State.Finished;
}
}
import org.opendaylight.protocol.framework.SessionListenerFactory;
import org.opendaylight.protocol.framework.SessionNegotiator;
import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.primitives.UnsignedBytes;
/**
- * SessionNegotiator which takes care of making sure sessions between PCEP
- * peers are kept unique. This needs to be further subclassed to provide
- * either a client or server factory.
+ * SessionNegotiator which takes care of making sure sessions between PCEP peers are kept unique. This needs to be
+ * further subclassed to provide either a client or server factory.
*/
-public abstract class AbstractPCEPSessionNegotiatorFactory implements SessionNegotiatorFactory<PCEPMessage, PCEPSessionImpl, PCEPSessionListener> {
+public abstract class AbstractPCEPSessionNegotiatorFactory implements
+ SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> {
private static final Comparator<byte[]> comparator = UnsignedBytes.lexicographicalComparator();
private static final Logger logger = LoggerFactory.getLogger(AbstractPCEPSessionNegotiatorFactory.class);
private final BiMap<byte[], Closeable> sessions = HashBiMap.create();
private final Map<byte[], Short> sessionIds = new WeakHashMap<>();
/**
- * Create a new negotiator. This method needs to be implemented by
- * subclasses to actually provide a negotiator.
+ * Create a new negotiator. This method needs to be implemented by subclasses to actually provide a negotiator.
*
* @param promise Session promise to be completed by the negotiator
* @param channel Associated channel
final Object lock = this;
logger.debug("Instantiating bootstrap negotiator for channel {}", channel);
- return new AbstractSessionNegotiator<PCEPMessage, PCEPSessionImpl>(promise, channel) {
+ return new AbstractSessionNegotiator<Message, PCEPSessionImpl>(promise, channel) {
@Override
protected void startNegotiation() throws Exception {
- logger.debug("Bootstrap negotiation for channel {} started", channel);
+ logger.debug("Bootstrap negotiation for channel {} started", this.channel);
/*
* We have a chance to see if there's a client session already
* registered for this client.
*/
- final byte[] clientAddress = ((InetSocketAddress) channel.remoteAddress()).getAddress().getAddress();
+ final byte[] clientAddress = ((InetSocketAddress) this.channel.remoteAddress()).getAddress().getAddress();
synchronized (lock) {
- if (sessions.containsKey(clientAddress)) {
+ if (AbstractPCEPSessionNegotiatorFactory.this.sessions.containsKey(clientAddress)) {
// FIXME: cross-reference this to RFC5440
- final byte[] serverAddress = ((InetSocketAddress) channel.localAddress()).getAddress().getAddress();
+ final byte[] serverAddress = ((InetSocketAddress) this.channel.localAddress()).getAddress().getAddress();
if (comparator.compare(serverAddress, clientAddress) > 0) {
- final Closeable n = sessions.remove(clientAddress);
+ final Closeable n = AbstractPCEPSessionNegotiatorFactory.this.sessions.remove(clientAddress);
try {
n.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
logger.warn("Unexpected failure to close old session", e);
}
} else {
- negotiationFailed(new RuntimeException("A conflicting session for address " +
- ((InetSocketAddress) channel.remoteAddress()).getAddress() + " found."));
+ negotiationFailed(new RuntimeException("A conflicting session for address "
+ + ((InetSocketAddress) this.channel.remoteAddress()).getAddress() + " found."));
return;
}
}
final short sessionId = nextSession(clientAddress);
- final AbstractPCEPSessionNegotiator n = createNegotiator(promise, factory.getSessionListener(), channel, sessionId);
+ final AbstractPCEPSessionNegotiator n = createNegotiator(promise, factory.getSessionListener(), this.channel, sessionId);
- sessions.put(clientAddress, new Closeable() {
+ AbstractPCEPSessionNegotiatorFactory.this.sessions.put(clientAddress, new Closeable() {
@Override
public void close() {
channel.close();
- }});
+ }
+ });
- channel.closeFuture().addListener(new ChannelFutureListener() {
+ this.channel.closeFuture().addListener(new ChannelFutureListener() {
@Override
public void operationComplete(final ChannelFuture future) throws Exception {
synchronized (lock) {
- sessions.inverse().remove(this);
+ AbstractPCEPSessionNegotiatorFactory.this.sessions.inverse().remove(this);
}
}
});
- logger.debug("Replacing bootstrap negotiator for channel {}", channel);
- channel.pipeline().replace(this, "negotiator", n);
+ logger.debug("Replacing bootstrap negotiator for channel {}", this.channel);
+ this.channel.pipeline().replace(this, "negotiator", n);
n.startNegotiation();
}
}
@Override
- protected void handleMessage(final PCEPMessage msg) throws Exception {
+ protected void handleMessage(final Message msg) throws Exception {
throw new IllegalStateException("Bootstrap negotiator should have been replaced");
}
};
* - no duplicate IDs are assigned
* - we retain former session IDs for a reasonable time
*/
- Short next = sessionIds.get(clientAddress);
+ Short next = this.sessionIds.get(clientAddress);
if (next == null) {
next = 0;
}
- sessionIds.put(clientAddress, (short)((next + 1) % 255));
+ this.sessionIds.put(clientAddress, (short) ((next + 1) % 255));
return next;
}
}
import org.opendaylight.protocol.framework.SessionListenerFactory;
import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
import org.opendaylight.protocol.pcep.PCEPDispatcher;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import com.google.common.base.Preconditions;
*/
public class PCEPDispatcherImpl extends AbstractDispatcher<PCEPSessionImpl, PCEPSessionListener> implements PCEPDispatcher {
- private final SessionNegotiatorFactory<PCEPMessage, PCEPSessionImpl, PCEPSessionListener> snf;
+ private final SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> snf;
private final PCEPHandlerFactory hf = new PCEPHandlerFactory();
*
* @throws IOException if some error occurred during opening the selector
*/
- public PCEPDispatcherImpl(final SessionNegotiatorFactory<PCEPMessage, PCEPSessionImpl, PCEPSessionListener> negotiatorFactory) {
+ public PCEPDispatcherImpl(final SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> negotiatorFactory) {
super();
this.snf = Preconditions.checkNotNull(negotiatorFactory);
}
return super.createServer(address, new PipelineInitializer<PCEPSessionImpl>() {
@Override
public void initializeChannel(final SocketChannel ch, final Promise<PCEPSessionImpl> promise) {
- ch.pipeline().addLast(hf.getDecoders());
- ch.pipeline().addLast("negotiator", snf.getSessionNegotiator(listenerFactory, ch, promise));
- ch.pipeline().addLast(hf.getEncoders());
+ ch.pipeline().addLast(PCEPDispatcherImpl.this.hf.getDecoders());
+ ch.pipeline().addLast("negotiator", PCEPDispatcherImpl.this.snf.getSessionNegotiator(listenerFactory, ch, promise));
+ ch.pipeline().addLast(PCEPDispatcherImpl.this.hf.getEncoders());
}
});
}
import org.opendaylight.protocol.framework.ProtocolHandlerFactory;
import org.opendaylight.protocol.framework.ProtocolMessageDecoder;
import org.opendaylight.protocol.framework.ProtocolMessageEncoder;
-import org.opendaylight.protocol.pcep.PCEPMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* PCEP specific factory for protocol inbound/outbound handlers.
*/
-public class PCEPHandlerFactory extends ProtocolHandlerFactory<PCEPMessage> {
- private final ProtocolMessageEncoder<PCEPMessage> encoder;
+public class PCEPHandlerFactory extends ProtocolHandlerFactory<Message> {
+ private final ProtocolMessageEncoder<Message> encoder;
public PCEPHandlerFactory() {
super(new PCEPMessageFactory());
- this.encoder = new ProtocolMessageEncoder<PCEPMessage>(this.msgFactory);
+ this.encoder = new ProtocolMessageEncoder<Message>(this.msgFactory);
}
@Override
@Override
public ChannelHandler[] getDecoders() {
- return new ChannelHandler[] { new PCEPMessageHeaderDecoder(), new ProtocolMessageDecoder<PCEPMessage>(this.msgFactory) };
+ return new ChannelHandler[] { new PCEPMessageHeaderDecoder(), new ProtocolMessageDecoder<Message>(this.msgFactory) };
}
}
import org.opendaylight.protocol.framework.DocumentedException;
import org.opendaylight.protocol.framework.ProtocolMessageFactory;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.spi.RawMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import com.google.common.base.Preconditions;
/**
* A PCEP message parser which also does validation.
*/
-public final class PCEPMessageFactory implements ProtocolMessageFactory<PCEPMessage> {
+public final class PCEPMessageFactory implements ProtocolMessageFactory<Message> {
private static final RawPCEPMessageFactory rawFactory = new RawPCEPMessageFactory();
@Override
- public List<PCEPMessage> parse(final byte[] bytes) throws DeserializerException, DocumentedException {
- final List<PCEPMessage> parsed = rawFactory.parse(bytes);
- final List<PCEPMessage> validated = new ArrayList<>(parsed.size());
+ public List<Message> parse(final byte[] bytes) throws DeserializerException, DocumentedException {
+ final List<Message> parsed = rawFactory.parse(bytes);
+ final List<Message> validated = new ArrayList<>(parsed.size());
- for (PCEPMessage msg : parsed) {
+ for (final Message msg : parsed) {
Preconditions.checkState(msg instanceof RawMessage);
final RawMessage raw = (RawMessage) msg;
validated.addAll(PCEPMessageValidator.getValidator(raw.getMsgType()).validate(raw.getAllObjects()));
} catch (final PCEPDeserializerException e) {
// FIXME: at validation time we may want to terminate with:
- //logger.error("Malformed message, terminating. ", e);
+ // logger.error("Malformed message, terminating. ", e);
// this.terminate(Reason.MALFORMED_MSG);
throw e;
}
}
@Override
- public byte[] put(final PCEPMessage msg) {
+ public byte[] put(final Message msg) {
return rawFactory.put(msg);
}
}
*/
package org.opendaylight.protocol.pcep.impl;
-import org.opendaylight.protocol.pcep.PCEPMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* Interface for specific message parsers
*/
public interface PCEPMessageParser {
- public byte[] put(PCEPMessage obj);
+ public byte[] put(Message obj);
}
import java.util.List;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.impl.message.PCCreateMessageValidator;
import org.opendaylight.protocol.pcep.impl.message.PCEPCloseMessageValidator;
import org.opendaylight.protocol.pcep.impl.message.PCEPRequestMessageValidator;
import org.opendaylight.protocol.pcep.impl.message.PCEPUpdateRequestMessageValidator;
import org.opendaylight.protocol.pcep.spi.PCEPMessageType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* Base class for message validators
}
}
- public abstract List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException;
+ public abstract List<Message> validate(List<PCEPObject> objects) throws PCEPDeserializerException;
public static PCEPMessageValidator getValidator(final PCEPMessageType msgType) {
return MapOfValidators.getInstance().get(msgType);
import org.opendaylight.protocol.framework.AbstractProtocolSession;
import org.opendaylight.protocol.pcep.PCEPCloseTermination;
import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPSession;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
import org.opendaylight.protocol.pcep.PCEPTlv;
import org.opendaylight.protocol.pcep.message.PCEPCloseMessage;
import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
-import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
import org.opendaylight.protocol.pcep.message.PCEPOpenMessage;
import org.opendaylight.protocol.pcep.object.PCEPCloseObject;
import org.opendaylight.protocol.pcep.object.PCEPCloseObject.Reason;
import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
import org.opendaylight.protocol.pcep.tlv.NodeIdentifierTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
+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.keepalive.message.KeepaliveMessageBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* Implementation of PCEPSession. (Not final for testing.)
*/
@VisibleForTesting
-public class PCEPSessionImpl extends AbstractProtocolSession<PCEPMessage> implements PCEPSession, PCEPSessionRuntimeMXBean {
+public class PCEPSessionImpl extends AbstractProtocolSession<Message> implements PCEPSession, PCEPSessionRuntimeMXBean {
/**
* System.nanoTime value about when was sent the last message Protected to be updated also in tests.
*/
private final Channel channel;
+ private final KeepaliveMessage kaMessage = (KeepaliveMessage) new KeepaliveMessageBuilder().build();
+
PCEPSessionImpl(final Timer timer, final PCEPSessionListener listener, final int maxUnknownMessages, final Channel channel,
final PCEPOpenObject localOpen, final PCEPOpenObject remoteOpen) {
this.listener = Preconditions.checkNotNull(listener);
if (this.channel.isActive()) {
if (ct >= nextKeepalive) {
- this.sendMessage(new PCEPKeepAliveMessage());
+ this.sendMessage(this.kaMessage);
nextKeepalive = this.lastMessageSentAt + TimeUnit.SECONDS.toNanos(getKeepAliveTimerValue());
}
* @param msg to be sent
*/
@Override
- public void sendMessage(final PCEPMessage msg) {
+ public void sendMessage(final Message msg) {
try {
this.channel.writeAndFlush(msg);
this.lastMessageSentAt = System.nanoTime();
- if (!(msg instanceof PCEPKeepAliveMessage)) {
+ if (!(msg instanceof KeepaliveMessage)) {
logger.debug("Sent message: " + msg);
}
this.sentMsgCount++;
public synchronized void close(final PCEPCloseObject.Reason reason) {
logger.debug("Closing session: {}", this);
this.closed = true;
- this.sendMessage(new PCEPCloseMessage(new PCEPCloseObject(reason)));
+ // FIXME: just to get rid of compilation errors
+ this.sendMessage((Message) new PCEPCloseMessage(new PCEPCloseObject(reason)));
this.channel.close();
}
private synchronized void terminate(final PCEPCloseObject.Reason reason) {
this.listener.onSessionTerminated(this, new PCEPCloseTermination(reason));
this.closed = true;
- this.sendMessage(new PCEPCloseMessage(new PCEPCloseObject(reason)));
+ // FIXME: just to get rid of compilation errors
+ this.sendMessage((Message) new PCEPCloseMessage(new PCEPCloseObject(reason)));
this.close();
}
final PCEPErrorObject error = new PCEPErrorObject(value);
final List<PCEPErrorObject> errors = new ArrayList<PCEPErrorObject>();
errors.add(error);
- this.sendMessage(new PCEPErrorMessage(open, errors, null));
+ // FIXME: just to get rid of compilation errors
+ this.sendMessage((Message) new PCEPErrorMessage(open, errors, null));
}
/**
* @param msg incoming message
*/
@Override
- public void handleMessage(final PCEPMessage msg) {
+ public void handleMessage(final Message msg) {
// Update last reception time
this.lastMessageReceivedAt = System.nanoTime();
this.receivedMsgCount++;
// Internal message handling. The user does not see these messages
- if (msg instanceof PCEPKeepAliveMessage) {
+ if (msg instanceof KeepaliveMessage) {
// Do nothing, the timer has been already reset
} else if (msg instanceof PCEPOpenMessage) {
this.sendErrorMessage(PCEPErrors.ATTEMPT_2ND_SESSION);
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.impl.message.PCCreateMessageParser;
import org.opendaylight.protocol.pcep.impl.message.PCEPCloseMessageParser;
import org.opendaylight.protocol.pcep.impl.message.PCEPErrorMessageParser;
import org.opendaylight.protocol.pcep.message.PCCreateMessage;
import org.opendaylight.protocol.pcep.message.PCEPCloseMessage;
import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
-import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
import org.opendaylight.protocol.pcep.message.PCEPNotificationMessage;
import org.opendaylight.protocol.pcep.message.PCEPOpenMessage;
import org.opendaylight.protocol.pcep.message.PCEPReplyMessage;
import org.opendaylight.protocol.pcep.spi.PCEPMessageType;
import org.opendaylight.protocol.pcep.spi.RawMessage;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.primitives.UnsignedBytes;
/**
- * Factory for subclasses of {@link org.opendaylight.protocol.pcep.PCEPMessage PCEPMessage}
+ * Factory for subclasses of {@link Message}
*/
-class RawPCEPMessageFactory implements ProtocolMessageFactory<PCEPMessage> {
+class RawPCEPMessageFactory implements ProtocolMessageFactory<Message> {
private final static Logger logger = LoggerFactory.getLogger(PCEPMessageFactory.class);
public final static int COMMON_HEADER_LENGTH = 4; // bytes
+ /**
+ * Current supported version of PCEP.
+ */
+ public static final int PCEP_VERSION = 1;
+
private static class MapOfParsers extends HashMap<PCEPMessageType, PCEPMessageParser> {
private static final long serialVersionUID = -5715193806554448822L;
*/
@Override
- public List<PCEPMessage> parse(final byte[] bytes) throws DeserializerException, DocumentedException {
+ public List<Message> parse(final byte[] bytes) throws DeserializerException, DocumentedException {
Preconditions.checkArgument(bytes != null, "Bytes may not be null");
Preconditions.checkArgument(bytes.length != 0, "Bytes may not be empty");
final byte[] msgBody = ByteArray.cutBytes(bytes, TYPE_SIZE + 1 + LENGTH_SIZE);
if (msgBody.length != msgLength - COMMON_HEADER_LENGTH) {
- throw new DeserializerException("Body size " + msgBody.length + " does not match header size " + (msgLength - COMMON_HEADER_LENGTH));
+ throw new DeserializerException("Body size " + msgBody.length + " does not match header size "
+ + (msgLength - COMMON_HEADER_LENGTH));
}
/*
* if PCEPObjectIdentifier.getObjectClassFromInt() dont't throws
* exception and if returned null we know the error type
*/
- PCEPMessageType msgType = PCEPMessageType.getFromInt(type);
+ final PCEPMessageType msgType = PCEPMessageType.getFromInt(type);
if (msgType == null) {
logger.debug("Unknown message type {}", type);
throw new DocumentedException("Unhandled message type " + type, new PCEPDocumentedException("Unhandled message type " + type, PCEPErrors.CAPABILITY_NOT_SUPPORTED));
}
- PCEPMessage msg;
+ Message msg;
try {
msg = new RawMessage(PCEPObjectFactory.parseObjects(msgBody), msgType);
} catch (final PCEPDeserializerException e) {
}
@Override
- public byte[] put(final PCEPMessage msg) {
+ public byte[] put(final Message msg) {
if (msg == null) {
throw new IllegalArgumentException("PCEPMessage is mandatory.");
}
if (msg instanceof PCEPOpenMessage) {
msgType = PCEPMessageType.OPEN;
- } else if (msg instanceof PCEPKeepAliveMessage) {
+ } else if (msg instanceof KeepaliveMessage) {
msgType = PCEPMessageType.KEEPALIVE;
} else if (msg instanceof PCEPCloseMessage) {
msgType = PCEPMessageType.CLOSE;
final byte[] msgBody = MapOfParsers.getInstance().get(msgType).put(msg);
final PCEPMessageHeader msgHeader = new PCEPMessageHeader(msgType.getIdentifier(), msgBody.length
- + PCEPMessageHeader.COMMON_HEADER_LENGTH, PCEPMessage.PCEP_VERSION);
+ + PCEPMessageHeader.COMMON_HEADER_LENGTH, PCEP_VERSION);
final byte[] headerBytes = msgHeader.toBytes();
final byte[] retBytes = new byte[headerBytes.length + msgBody.length];
*/
package org.opendaylight.protocol.pcep.impl.message;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
import org.opendaylight.protocol.pcep.message.PCCreateMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* Parser for {@link PCCreateMessage}
* )
*/
@Override
- public byte[] put(PCEPMessage msg) {
+ public byte[] put(final Message msg) {
if (!(msg instanceof PCCreateMessage))
- throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Needed PCCreateMessage.");
+ throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+ + ". Needed PCCreateMessage.");
return PCEPObjectFactory.put(((PCCreateMessage) msg).getAllObjects());
}
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
import org.opendaylight.protocol.pcep.object.PCEPLspaObject;
import org.opendaylight.protocol.pcep.object.PCEPMetricObject;
import org.opendaylight.protocol.pcep.object.PCEPRequestedPathBandwidthObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* PCCCreateMessage validator. Validates message integrity.
*/
public class PCCreateMessageValidator extends PCEPMessageValidator {
- @Override
- public List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException {
- if (objects == null)
- throw new IllegalArgumentException("Passed list can't be null.");
+ @Override
+ public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
+ if (objects == null)
+ throw new IllegalArgumentException("Passed list can't be null.");
- final List<CompositeInstantiationObject> insts = new ArrayList<CompositeInstantiationObject>();
+ final List<CompositeInstantiationObject> insts = new ArrayList<CompositeInstantiationObject>();
- CompositeInstantiationObject inst;
- while (!objects.isEmpty()) {
- try {
- if ((inst = this.getValidInstantiationObject(objects)) == null)
- break;
- } catch (final PCEPDocumentedException e) {
- return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
- }
+ CompositeInstantiationObject inst;
+ while (!objects.isEmpty()) {
+ try {
+ if ((inst = this.getValidInstantiationObject(objects)) == null)
+ break;
+ } catch (final PCEPDocumentedException e) {
+ return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
+ }
- insts.add(inst);
- }
+ insts.add(inst);
+ }
+
+ if (insts.isEmpty())
+ throw new PCEPDeserializerException("At least one CompositeInstantiationObject is mandatory.");
- if (insts.isEmpty())
- throw new PCEPDeserializerException("At least one CompositeInstantiationObject is mandatory.");
-
- if (!objects.isEmpty())
- throw new PCEPDeserializerException("Unprocessed objects: " + objects);
-
- return Arrays.asList((PCEPMessage) new PCCreateMessage(insts));
- }
-
- private CompositeInstantiationObject getValidInstantiationObject(List<PCEPObject> objects) throws PCEPDocumentedException {
- if (objects.get(0) instanceof UnknownObject)
- throw new PCEPDocumentedException("Unknown object", ((UnknownObject) objects.get(0)).getError());
- if (!(objects.get(0) instanceof PCEPEndPointsObject<?>))
- return null;
-
- final PCEPEndPointsObject<?> endPoints = ((PCEPEndPointsObject<?>) objects.get(0));
- objects.remove(0);
-
- if (objects.get(0) instanceof UnknownObject)
- throw new PCEPDocumentedException("Unknown object", ((UnknownObject) objects.get(0)).getError());
- if (!(objects.get(0) instanceof PCEPLspaObject))
- throw new PCEPDocumentedException("LSPA Object must be second.", PCEPErrors.LSPA_MISSING);
- final PCEPLspaObject lspa = (PCEPLspaObject) objects.get(0);
- objects.remove(0);
-
- PCEPExplicitRouteObject ero = null;
- PCEPRequestedPathBandwidthObject bandwidth = null;
- final List<PCEPMetricObject> metrics = new ArrayList<PCEPMetricObject>();
-
- PCEPObject obj;
- int state = 1;
- while (!objects.isEmpty()) {
- obj = objects.get(0);
- if (obj instanceof UnknownObject) {
- throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
- }
-
- switch (state) {
- case 1:
- state = 2;
- if (obj instanceof PCEPExplicitRouteObject) {
- ero = (PCEPExplicitRouteObject) obj;
- break;
- }
- case 2:
- state = 3;
- if (obj instanceof PCEPRequestedPathBandwidthObject) {
- bandwidth = (PCEPRequestedPathBandwidthObject) obj;
- break;
- }
- case 3:
- state = 4;
- if (obj instanceof PCEPMetricObject) {
- metrics.add((PCEPMetricObject) obj);
- state = 3;
- break;
- }
- }
-
- if (state == 4)
- break;
-
- objects.remove(0);
+ if (!objects.isEmpty())
+ throw new PCEPDeserializerException("Unprocessed objects: " + objects);
+
+ return Arrays.asList((Message) new PCCreateMessage(insts));
}
- return new CompositeInstantiationObject(endPoints, lspa, ero, bandwidth, metrics);
- }
+ private CompositeInstantiationObject getValidInstantiationObject(final List<PCEPObject> objects) throws PCEPDocumentedException {
+ if (objects.get(0) instanceof UnknownObject)
+ throw new PCEPDocumentedException("Unknown object", ((UnknownObject) objects.get(0)).getError());
+ if (!(objects.get(0) instanceof PCEPEndPointsObject<?>))
+ return null;
+
+ final PCEPEndPointsObject<?> endPoints = ((PCEPEndPointsObject<?>) objects.get(0));
+ objects.remove(0);
+
+ if (objects.get(0) instanceof UnknownObject)
+ throw new PCEPDocumentedException("Unknown object", ((UnknownObject) objects.get(0)).getError());
+ if (!(objects.get(0) instanceof PCEPLspaObject))
+ throw new PCEPDocumentedException("LSPA Object must be second.", PCEPErrors.LSPA_MISSING);
+ final PCEPLspaObject lspa = (PCEPLspaObject) objects.get(0);
+ objects.remove(0);
+
+ PCEPExplicitRouteObject ero = null;
+ PCEPRequestedPathBandwidthObject bandwidth = null;
+ final List<PCEPMetricObject> metrics = new ArrayList<PCEPMetricObject>();
+
+ PCEPObject obj;
+ int state = 1;
+ while (!objects.isEmpty()) {
+ obj = objects.get(0);
+ if (obj instanceof UnknownObject) {
+ throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
+ }
+
+ switch (state) {
+ case 1:
+ state = 2;
+ if (obj instanceof PCEPExplicitRouteObject) {
+ ero = (PCEPExplicitRouteObject) obj;
+ break;
+ }
+ case 2:
+ state = 3;
+ if (obj instanceof PCEPRequestedPathBandwidthObject) {
+ bandwidth = (PCEPRequestedPathBandwidthObject) obj;
+ break;
+ }
+ case 3:
+ state = 4;
+ if (obj instanceof PCEPMetricObject) {
+ metrics.add((PCEPMetricObject) obj);
+ state = 3;
+ break;
+ }
+ }
+
+ if (state == 4)
+ break;
+
+ objects.remove(0);
+ }
+
+ return new CompositeInstantiationObject(endPoints, lspa, ero, bandwidth, metrics);
+ }
}
*/
package org.opendaylight.protocol.pcep.impl.message;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
import org.opendaylight.protocol.pcep.message.PCEPCloseMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
- * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPCloseMessage
- * PCEPCloseMessage}
+ * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPCloseMessage PCEPCloseMessage}
*/
public class PCEPCloseMessageParser implements PCEPMessageParser {
- @Override
- public byte[] put(PCEPMessage msg) {
- if (!(msg instanceof PCEPCloseMessage))
- throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Nedded PCEPCloseMessage.");
+ @Override
+ public byte[] put(final Message msg) {
+ if (!(msg instanceof PCEPCloseMessage))
+ throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+ + ". Nedded PCEPCloseMessage.");
- return PCEPObjectFactory.put(((PCEPCloseMessage) msg).getAllObjects());
- }
+ return PCEPObjectFactory.put(((PCEPCloseMessage) msg).getAllObjects());
+ }
}
import java.util.List;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
import org.opendaylight.protocol.pcep.message.PCEPCloseMessage;
import org.opendaylight.protocol.pcep.object.PCEPCloseObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* PCEPCloseMessage validator. Validates message integrity.
public class PCEPCloseMessageValidator extends PCEPMessageValidator {
@Override
- public List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException {
+ public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
if (objects == null)
throw new IllegalArgumentException("Passed list can't be null.");
if (!objects.isEmpty())
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
- return new ArrayList<PCEPMessage>() {
+ return new ArrayList<Message>() {
private static final long serialVersionUID = 1L;
{
this.add(msg);
*/
package org.opendaylight.protocol.pcep.impl.message;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
- * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPErrorMessage
- * PCEPErrorMessage}
+ * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPErrorMessage PCEPErrorMessage}
*/
public class PCEPErrorMessageParser implements PCEPMessageParser {
@Override
- public byte[] put(PCEPMessage msg) {
+ public byte[] put(final Message msg) {
if (!(msg instanceof PCEPErrorMessage))
- throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance " + msg.getClass() + ". Nedded PCEPErrorMessage.");
+ throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance " + msg.getClass()
+ + ". Nedded PCEPErrorMessage.");
return PCEPObjectFactory.put(((PCEPErrorMessage) msg).getAllObjects());
}
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
import org.opendaylight.protocol.pcep.object.PCEPRequestParameterObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* PCEPErrorMessage validator. Validates message integrity.
public class PCEPErrorMessageValidator extends PCEPMessageValidator {
@Override
- public List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException {
+ public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
if (objects == null)
throw new IllegalArgumentException("Passed list can't be null.");
obj = objects.get(0);
if (obj instanceof UnknownObject)
- return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) obj).getError())));
+ return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) obj).getError())));
switch (state) {
- case 1:
- if (obj instanceof PCEPErrorObject) {
- errorObjects.add((PCEPErrorObject) obj);
- break;
- }
- state = 2;
- case 2:
- state = 3;
- if (obj instanceof PCEPOpenObject) {
- openObj = (PCEPOpenObject) obj;
- break;
+ case 1:
+ if (obj instanceof PCEPErrorObject) {
+ errorObjects.add((PCEPErrorObject) obj);
+ break;
+ }
+ state = 2;
+ case 2:
+ state = 3;
+ if (obj instanceof PCEPOpenObject) {
+ openObj = (PCEPOpenObject) obj;
+ break;
+ }
+ case 3:
+ while (!objects.isEmpty()) {
+ CompositeErrorObject comObj;
+
+ try {
+ comObj = getValidErrorComposite(objects);
+ } catch (final PCEPDocumentedException e) {
+ return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
}
- case 3:
- while (!objects.isEmpty()) {
- CompositeErrorObject comObj;
-
- try {
- comObj = getValidErrorComposite(objects);
- } catch (final PCEPDocumentedException e) {
- return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
- }
- if (comObj == null)
- break;
+ if (comObj == null)
+ break;
- errors.add(comObj);
- }
+ errors.add(comObj);
+ }
- state = 4;
- break;
+ state = 4;
+ break;
}
if (state == 4) {
if (!objects.isEmpty())
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
- return Arrays.asList((PCEPMessage) new PCEPErrorMessage(openObj, errorObjects, errors));
+ return Arrays.asList((Message) new PCEPErrorMessage(openObj, errorObjects, errors));
}
- private static CompositeErrorObject getValidErrorComposite(List<PCEPObject> objects) throws PCEPDocumentedException, PCEPDeserializerException {
+ private static CompositeErrorObject getValidErrorComposite(final List<PCEPObject> objects) throws PCEPDocumentedException,
+ PCEPDeserializerException {
final List<PCEPRequestParameterObject> requestParameters = new ArrayList<PCEPRequestParameterObject>();
final List<PCEPErrorObject> errors = new ArrayList<PCEPErrorObject>();
PCEPObject obj;
throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
switch (state) {
- case 1:
+ case 1:
+ state = 2;
+ if (obj instanceof PCEPRequestParameterObject) {
+ if (((PCEPRequestParameterObject) obj).isProcessed())
+ throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
+ requestParameters.add((PCEPRequestParameterObject) obj);
+ state = 1;
+ break;
+ }
+ case 2:
+ if (obj instanceof PCEPErrorObject) {
+ errors.add((PCEPErrorObject) obj);
state = 2;
- if (obj instanceof PCEPRequestParameterObject) {
- if (((PCEPRequestParameterObject) obj).isProcessed())
- throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
- requestParameters.add((PCEPRequestParameterObject) obj);
- state = 1;
- break;
- }
- case 2:
- if (obj instanceof PCEPErrorObject) {
- errors.add((PCEPErrorObject) obj);
- state = 2;
- break;
- }
- state = 3;
+ break;
+ }
+ state = 3;
}
if (state == 3)
*/
package org.opendaylight.protocol.pcep.impl.message;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
- * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage
- * PCEPKeepAliveMessage}
+ * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage PCEPKeepAliveMessage}
*/
public class PCEPKeepAliveMessageParser implements PCEPMessageParser {
@Override
- public byte[] put(PCEPMessage msg) {
+ public byte[] put(final Message msg) {
if (!(msg instanceof PCEPKeepAliveMessage))
- throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Nedded PCEPKeepAliveMessage.");
+ throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+ + ". Nedded PCEPKeepAliveMessage.");
return new byte[0];
}
import java.util.List;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* PCEPKeepAliveMessage validator. Validates message integrity.
public class PCEPKeepAliveMessageValidator extends PCEPMessageValidator {
@Override
- public List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException {
+ public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
if (objects != null && !objects.isEmpty())
throw new PCEPDeserializerException("KeepAlive message has content.");
- return new ArrayList<PCEPMessage>() {
+ return new ArrayList<Message>() {
private static final long serialVersionUID = 1L;
{
*/
package org.opendaylight.protocol.pcep.impl.message;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
import org.opendaylight.protocol.pcep.message.PCEPNotificationMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
- * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPNotificationMessage
- * PCEPNotificationMessage}
+ * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPNotificationMessage PCEPNotificationMessage}
*/
public class PCEPNotificationMessageParser implements PCEPMessageParser {
@Override
- public byte[] put(PCEPMessage msg) {
+ public byte[] put(final Message msg) {
if (!(msg instanceof PCEPNotificationMessage))
- throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Needed PCEPNotificationMessage.");
+ throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+ + ". Needed PCEPNotificationMessage.");
return PCEPObjectFactory.put(((PCEPNotificationMessage) msg).getAllObjects());
}
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
import org.opendaylight.protocol.pcep.object.PCEPNotificationObject;
import org.opendaylight.protocol.pcep.object.PCEPRequestParameterObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* PCEPNotificationMessage validator. Validates message integrity.
public class PCEPNotificationMessageValidator extends PCEPMessageValidator {
@Override
- public List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException {
+ public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
if (objects == null)
throw new IllegalArgumentException("Passed list can't be null.");
try {
comObj = getValidNotificationComposite(objects);
} catch (final PCEPDocumentedException e) {
- return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
+ return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
}
if (comObj == null)
if (!objects.isEmpty())
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
- return Arrays.asList((PCEPMessage) new PCEPNotificationMessage(compositeNotifications));
+ return Arrays.asList((Message) new PCEPNotificationMessage(compositeNotifications));
}
- private static CompositeNotifyObject getValidNotificationComposite(List<PCEPObject> objects) throws PCEPDocumentedException {
+ private static CompositeNotifyObject getValidNotificationComposite(final List<PCEPObject> objects) throws PCEPDocumentedException {
final List<PCEPRequestParameterObject> requestParameters = new ArrayList<PCEPRequestParameterObject>();
final List<PCEPNotificationObject> notifications = new ArrayList<PCEPNotificationObject>();
PCEPObject obj;
throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
switch (state) {
- case 1:
+ case 1:
+ state = 2;
+ if (obj instanceof PCEPRequestParameterObject) {
+ if (((PCEPRequestParameterObject) obj).isProcessed())
+ throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
+ requestParameters.add((PCEPRequestParameterObject) obj);
+ state = 1;
+ break;
+ }
+ case 2:
+ if (obj instanceof PCEPNotificationObject) {
+ notifications.add((PCEPNotificationObject) obj);
state = 2;
- if (obj instanceof PCEPRequestParameterObject) {
- if (((PCEPRequestParameterObject) obj).isProcessed())
- throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
- requestParameters.add((PCEPRequestParameterObject) obj);
- state = 1;
- break;
- }
- case 2:
- if (obj instanceof PCEPNotificationObject) {
- notifications.add((PCEPNotificationObject) obj);
- state = 2;
- break;
- }
- state = 3;
+ break;
+ }
+ state = 3;
}
if (state == 3)
*/
package org.opendaylight.protocol.pcep.impl.message;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
import org.opendaylight.protocol.pcep.message.PCEPOpenMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* Parser for {@link org.opendaylight.protocol.pcep.message.PCEPOpenMessage PCEPOpenMessage}
*/
public class PCEPOpenMessageParser implements PCEPMessageParser {
- @Override
- public byte[] put(PCEPMessage msg) {
- if (!(msg instanceof PCEPOpenMessage))
- throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance " + msg.getClass() + ". Nedded PCEPOpenMessage.");
+ @Override
+ public byte[] put(final Message msg) {
+ if (!(msg instanceof PCEPOpenMessage))
+ throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance " + msg.getClass()
+ + ". Nedded PCEPOpenMessage.");
- return PCEPObjectFactory.put(((PCEPOpenMessage) msg).getAllObjects());
- }
+ return PCEPObjectFactory.put(((PCEPOpenMessage) msg).getAllObjects());
+ }
}
import java.util.List;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
import org.opendaylight.protocol.pcep.message.PCEPOpenMessage;
import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* PCEPOpenMessage validator. Validates message integrity.
public class PCEPOpenMessageValidator extends PCEPMessageValidator {
@Override
- public List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException {
+ public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
if (objects == null)
throw new IllegalArgumentException("Passed list can't be null.");
if (!objects.isEmpty())
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
- return new ArrayList<PCEPMessage>() {
+ return new ArrayList<Message>() {
private static final long serialVersionUID = 1L;
{
this.add(msg);
*/
package org.opendaylight.protocol.pcep.impl.message;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
import org.opendaylight.protocol.pcep.message.PCEPReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
- * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPReplyMessage
- * PCEPReplyMessage}
+ * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPReplyMessage PCEPReplyMessage}
*/
public class PCEPReplyMessageParser implements PCEPMessageParser {
@Override
- public byte[] put(PCEPMessage msg) {
+ public byte[] put(final Message msg) {
if (!(msg instanceof PCEPReplyMessage))
- throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Nedded PCEPReplyMessage.");
+ throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+ + ". Nedded PCEPReplyMessage.");
return PCEPObjectFactory.put(((PCEPReplyMessage) msg).getAllObjects());
}
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
import org.opendaylight.protocol.pcep.object.PCEPRequestParameterObject;
import org.opendaylight.protocol.pcep.object.PCEPRequestedPathBandwidthObject;
import org.opendaylight.protocol.pcep.object.PCEPSvecObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
/**
* PCEPReplyMessage validator. Validates message integrity.
private boolean requestRejected = true;
- private List<PCEPMessage> msgs = new ArrayList<PCEPMessage>();
+ private List<Message> msgs = Lists.newArrayList();
private PCEPRequestParameterObject rpObj;
private void init() {
this.requestRejected = false;
- this.msgs = new ArrayList<PCEPMessage>();
+ this.msgs = Lists.newArrayList();
this.noPath = null;
this.lsp = null;
this.paths = new ArrayList<CompositePathObject>();
}
- public List<PCEPMessage> validate(List<PCEPObject> objects, List<CompositeReplySvecObject> svecList) {
+ public List<Message> validate(final List<PCEPObject> objects, final List<CompositeReplySvecObject> svecList) {
this.init();
if (!(objects.get(0) instanceof PCEPRequestParameterObject))
obj = objects.get(0);
if (obj instanceof UnknownObject) {
if (((UnknownObject) obj).isProcessed()) {
- this.msgs.add(new PCEPErrorMessage(
- new CompositeErrorObject(copyRP(rpObj, false), new PCEPErrorObject(((UnknownObject) obj).getError()))));
+ this.msgs.add(new PCEPErrorMessage(new CompositeErrorObject(copyRP(rpObj, false), new PCEPErrorObject(((UnknownObject) obj).getError()))));
this.requestRejected = true;
}
}
switch (state) {
- case 1:
- state = 2;
- if (obj instanceof PCEPNoPathObject) {
- this.noPath = (PCEPNoPathObject) obj;
- break;
- }
- case 2:
- state = 3;
- if (obj instanceof PCEPLspObject) {
- this.lsp = (PCEPLspObject) obj;
- break;
- }
- case 3:
- state = 4;
- if (obj instanceof PCEPLspaObject) {
- this.lspa = (PCEPLspaObject) obj;
- break;
- }
- case 4:
+ case 1:
+ state = 2;
+ if (obj instanceof PCEPNoPathObject) {
+ this.noPath = (PCEPNoPathObject) obj;
+ break;
+ }
+ case 2:
+ state = 3;
+ if (obj instanceof PCEPLspObject) {
+ this.lsp = (PCEPLspObject) obj;
+ break;
+ }
+ case 3:
+ state = 4;
+ if (obj instanceof PCEPLspaObject) {
+ this.lspa = (PCEPLspaObject) obj;
+ break;
+ }
+ case 4:
+ state = 5;
+ if (obj instanceof PCEPRequestedPathBandwidthObject) {
+ this.bandwidth = (PCEPRequestedPathBandwidthObject) obj;
+ break;
+ }
+ case 5:
+ state = 6;
+ if (obj instanceof PCEPMetricObject) {
+ this.metrics.add((PCEPMetricObject) obj);
state = 5;
- if (obj instanceof PCEPRequestedPathBandwidthObject) {
- this.bandwidth = (PCEPRequestedPathBandwidthObject) obj;
- break;
- }
- case 5:
- state = 6;
- if (obj instanceof PCEPMetricObject) {
- this.metrics.add((PCEPMetricObject) obj);
- state = 5;
- break;
- }
- case 6:
- state = 7;
- if (obj instanceof PCEPIncludeRouteObject) {
- this.iro = (PCEPIncludeRouteObject) obj;
- state = 8;
- break;
- }
+ break;
+ }
+ case 6:
+ state = 7;
+ if (obj instanceof PCEPIncludeRouteObject) {
+ this.iro = (PCEPIncludeRouteObject) obj;
+ state = 8;
+ break;
+ }
}
if (state == 7)
}
if (!this.requestRejected) {
- this.msgs.add(new PCEPReplyMessage(Collections.unmodifiableList(Arrays.asList(new CompositeResponseObject(rpObj, this.noPath, this.lsp,
- this.lspa, this.bandwidth, this.metrics, this.iro, this.paths))), Collections.unmodifiableList(svecList)));
+ this.msgs.add(new PCEPReplyMessage(Collections.unmodifiableList(Arrays.asList(new CompositeResponseObject(rpObj, this.noPath, this.lsp, this.lspa, this.bandwidth, this.metrics, this.iro, this.paths))), Collections.unmodifiableList(svecList)));
}
return this.msgs;
}
- private CompositePathObject getValidCompositePath(List<PCEPObject> objects) {
+ private CompositePathObject getValidCompositePath(final List<PCEPObject> objects) {
if (!(objects.get(0) instanceof PCEPExplicitRouteObject))
return null;
obj = objects.get(0);
if (obj instanceof UnknownObject) {
if (((UnknownObject) obj).isProcessed()) {
- this.msgs.add(new PCEPErrorMessage(new CompositeErrorObject(copyRP(this.rpObj, false), new PCEPErrorObject(((UnknownObject) obj)
- .getError()))));
+ this.msgs.add(new PCEPErrorMessage(new CompositeErrorObject(copyRP(this.rpObj, false), new PCEPErrorObject(((UnknownObject) obj).getError()))));
this.requestRejected = true;
}
objects.remove(0);
}
switch (state) {
- case 1:
- state = 2;
- if (obj instanceof PCEPLspaObject) {
- pathLspa = (PCEPLspaObject) obj;
- break;
- }
- case 2:
+ case 1:
+ state = 2;
+ if (obj instanceof PCEPLspaObject) {
+ pathLspa = (PCEPLspaObject) obj;
+ break;
+ }
+ case 2:
+ state = 3;
+ if (obj instanceof PCEPRequestedPathBandwidthObject) {
+ pathBandwidth = (PCEPRequestedPathBandwidthObject) obj;
+ break;
+ }
+ case 3:
+ state = 4;
+ if (obj instanceof PCEPMetricObject) {
+ pathMetrics.add((PCEPMetricObject) obj);
state = 3;
- if (obj instanceof PCEPRequestedPathBandwidthObject) {
- pathBandwidth = (PCEPRequestedPathBandwidthObject) obj;
- break;
- }
- case 3:
- state = 4;
- if (obj instanceof PCEPMetricObject) {
- pathMetrics.add((PCEPMetricObject) obj);
- state = 3;
- break;
- }
- case 4:
- state = 5;
- if (obj instanceof PCEPIncludeRouteObject) {
- pathIro = (PCEPIncludeRouteObject) obj;
- state = 6;
- break;
- }
+ break;
+ }
+ case 4:
+ state = 5;
+ if (obj instanceof PCEPIncludeRouteObject) {
+ pathIro = (PCEPIncludeRouteObject) obj;
+ state = 6;
+ break;
+ }
}
}
@Override
- public List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException {
+ public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
if (objects == null)
throw new IllegalArgumentException("Passed list can't be null.");
- final List<PCEPMessage> msgs = new ArrayList<PCEPMessage>();
+ final List<Message> msgs = Lists.newArrayList();
final List<CompositeReplySvecObject> svecList = new ArrayList<CompositeReplySvecObject>();
CompositeReplySvecObject svecComp;
svecList.add(svecComp);
}
- List<PCEPMessage> subMessages;
+ List<Message> subMessages;
final SubReplyValidator subValidator = new SubReplyValidator();
while (!objects.isEmpty()) {
subMessages = subValidator.validate(objects, svecList);
return msgs;
}
- private CompositeReplySvecObject getValidSvecComposite(List<PCEPObject> objects) throws PCEPDocumentedException {
+ private CompositeReplySvecObject getValidSvecComposite(final List<PCEPObject> objects) throws PCEPDocumentedException {
if (objects == null)
throw new IllegalArgumentException("List cannot be null.");
throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
switch (state) {
- case 1:
+ case 1:
+ state = 2;
+ if (obj instanceof PCEPObjectiveFunctionObject) {
+ of = (PCEPObjectiveFunctionObject) obj;
+ break;
+ }
+ case 2:
+ state = 3;
+ if (obj instanceof PCEPMetricObject) {
+ metrics.add((PCEPMetricObject) obj);
state = 2;
- if (obj instanceof PCEPObjectiveFunctionObject) {
- of = (PCEPObjectiveFunctionObject) obj;
- break;
- }
- case 2:
- state = 3;
- if (obj instanceof PCEPMetricObject) {
- metrics.add((PCEPMetricObject) obj);
- state = 2;
- break;
- }
+ break;
+ }
}
if (state == 3)
return new CompositeReplySvecObject(svec, of, metrics);
}
- private static PCEPRequestParameterObject copyRP(PCEPRequestParameterObject origRp, boolean processed) {
- return new PCEPRequestParameterObject(origRp.isLoose(), origRp.isBidirectional(), origRp.isReoptimized(), origRp.isMakeBeforeBreak(),
- origRp.isReportRequestOrder(), origRp.isSuplyOFOnResponse(), origRp.isFragmentation(), origRp.isP2mp(), origRp.isEroCompression(),
- origRp.getPriority(), origRp.getRequestID(), origRp.getTlvs(), processed, origRp.isIgnored());
+ private static PCEPRequestParameterObject copyRP(final PCEPRequestParameterObject origRp, final boolean processed) {
+ return new PCEPRequestParameterObject(origRp.isLoose(), origRp.isBidirectional(), origRp.isReoptimized(), origRp.isMakeBeforeBreak(), origRp.isReportRequestOrder(), origRp.isSuplyOFOnResponse(), origRp.isFragmentation(), origRp.isP2mp(), origRp.isEroCompression(), origRp.getPriority(), origRp.getRequestID(), origRp.getTlvs(), processed, origRp.isIgnored());
}
}
*/
package org.opendaylight.protocol.pcep.impl.message;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
import org.opendaylight.protocol.pcep.message.PCEPReportMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
- * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPReportMessage
- * PCEPReportMessage}
+ * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPReportMessage PCEPReportMessage}
*/
public class PCEPReportMessageParser implements PCEPMessageParser {
@Override
- public byte[] put(PCEPMessage msg) {
+ public byte[] put(final Message msg) {
if (!(msg instanceof PCEPReportMessage))
- throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Nedded PCEPReportMessage.");
+ throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+ + ". Nedded PCEPReportMessage.");
return PCEPObjectFactory.put(((PCEPReportMessage) msg).getAllObjects());
}
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
import org.opendaylight.protocol.pcep.object.PCEPLspaObject;
import org.opendaylight.protocol.pcep.object.PCEPMetricObject;
import org.opendaylight.protocol.pcep.object.PCEPReportedRouteObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* PCEPReportMessage validator. Validates message integrity.
public class PCEPReportMessageValidator extends PCEPMessageValidator {
@Override
- public List<PCEPMessage> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
+ public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
if (objects == null)
throw new IllegalArgumentException("Passed list can't be null.");
while (!objects.isEmpty()) {
if (objects.get(0) instanceof UnknownObject)
- return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) objects.get(0)).getError())));
+ return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) objects.get(0)).getError())));
if (!(objects.get(0) instanceof PCEPLspObject))
- return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
+ return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
final PCEPLspObject lsp = (PCEPLspObject) objects.get(0);
objects.remove(0);
path = this.getValidCompositePath(objects);
}
} catch (final PCEPDocumentedException e) {
- return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
+ return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
}
}
if (!objects.isEmpty()) {
if (objects.get(0) instanceof UnknownObject)
- return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) objects.get(0)).getError())));
+ return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) objects.get(0)).getError())));
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
- return Arrays.asList((PCEPMessage) new PCEPReportMessage(report));
+ return Arrays.asList((Message) new PCEPReportMessage(report));
}
private CompositeRptPathObject getValidCompositePath(final List<PCEPObject> objects) throws PCEPDocumentedException {
}
switch (state) {
- case 1:
- state = 2;
- if (obj instanceof PCEPLspaObject) {
- pathLspa = (PCEPLspaObject) obj;
- break;
- }
- case 2:
- state = 3;
- if (obj instanceof PCEPExistingPathBandwidthObject) {
- pathBandwidth = (PCEPExistingPathBandwidthObject) obj;
- break;
- }
+ case 1:
+ state = 2;
+ if (obj instanceof PCEPLspaObject) {
+ pathLspa = (PCEPLspaObject) obj;
+ break;
+ }
+ case 2:
+ state = 3;
+ if (obj instanceof PCEPExistingPathBandwidthObject) {
+ pathBandwidth = (PCEPExistingPathBandwidthObject) obj;
+ break;
+ }
- case 3:
+ case 3:
+ state = 4;
+ if (obj instanceof PCEPReportedRouteObject) {
+ pathRro = (PCEPReportedRouteObject) obj;
+ break;
+ }
+ case 4:
+ state = 5;
+ if (obj instanceof PCEPMetricObject) {
+ pathMetrics.add((PCEPMetricObject) obj);
state = 4;
- if (obj instanceof PCEPReportedRouteObject) {
- pathRro = (PCEPReportedRouteObject) obj;
- break;
- }
- case 4:
- state = 5;
- if (obj instanceof PCEPMetricObject) {
- pathMetrics.add((PCEPMetricObject) obj);
- state = 4;
- break;
- }
+ break;
+ }
}
if (state == 5)
*/
package org.opendaylight.protocol.pcep.impl.message;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
import org.opendaylight.protocol.pcep.message.PCEPRequestMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
- * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPReportMessage
- * PCEPReportMessage}
+ * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPReportMessage PCEPReportMessage}
*/
public class PCEPRequestMessageParser implements PCEPMessageParser {
@Override
- public byte[] put(PCEPMessage msg) {
+ public byte[] put(final Message msg) {
if (!(msg instanceof PCEPRequestMessage))
- throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Needed PCEPRequestMessage.");
+ throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+ + ". Needed PCEPRequestMessage.");
return PCEPObjectFactory.put(((PCEPRequestMessage) msg).getAllObjects());
}
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
import org.opendaylight.protocol.pcep.object.PCEPRequestedPathBandwidthObject;
import org.opendaylight.protocol.pcep.object.PCEPSvecObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nps.concepts.rev130930.Bandwidth;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
/**
* PCEPRequestMessage validator. Validates message integrity.
public class PCEPRequestMessageValidator extends PCEPMessageValidator {
@Override
- public List<PCEPMessage> validate(final List<PCEPObject> objects) {
+ public List<Message> validate(final List<PCEPObject> objects) {
if (objects == null)
throw new IllegalArgumentException("Passed list can't be null.");
- final List<PCEPMessage> msgs = new ArrayList<PCEPMessage>();
+ final List<Message> msgs = Lists.newArrayList();
final List<CompositeRequestSvecObject> svecList = new ArrayList<CompositeRequestSvecObject>();
CompositeRequestSvecObject svecComp;
*/
package org.opendaylight.protocol.pcep.impl.message;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
import org.opendaylight.protocol.pcep.message.PCEPUpdateRequestMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
public class PCEPUpdateRequestMessageParser implements PCEPMessageParser {
@Override
- public byte[] put(PCEPMessage msg) {
+ public byte[] put(final Message msg) {
if (!(msg instanceof PCEPUpdateRequestMessage))
- throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Nedded PCEPUpdateRequestMessage.");
+ throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+ + ". Nedded PCEPUpdateRequestMessage.");
return PCEPObjectFactory.put(((PCEPUpdateRequestMessage) msg).getAllObjects());
}
import java.util.Arrays;
import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
import org.opendaylight.protocol.pcep.object.PCEPLspaObject;
import org.opendaylight.protocol.pcep.object.PCEPMetricObject;
import org.opendaylight.protocol.pcep.object.PCEPRequestedPathBandwidthObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* PCEPUpdateRequestMessage validator. Validates message integrity.
private static final Logger logger = LoggerFactory.getLogger(PCEPUpdateRequestMessageValidator.class);
@Override
- public List<PCEPMessage> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
+ public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
if (objects == null)
throw new IllegalArgumentException("Passed list can't be null.");
while (!objects.isEmpty()) {
if (objects.get(0) instanceof UnknownObject) {
logger.warn("Unknown object found (should be Lsp) - {}.", objects.get(0));
- return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) objects.get(0)).getError())));
+ return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) objects.get(0)).getError())));
}
if (!(objects.get(0) instanceof PCEPLspObject))
- return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
+ return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
final PCEPLspObject lsp = (PCEPLspObject) objects.get(0);
objects.remove(0);
}
} catch (final PCEPDocumentedException e) {
logger.warn("Serializing failed: {}.", e);
- return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
+ return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
}
}
}
if (updateRequests.isEmpty())
- return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
+ return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
if (!objects.isEmpty())
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
- return Arrays.asList((PCEPMessage) new PCEPUpdateRequestMessage(updateRequests));
+ return Arrays.asList((Message) new PCEPUpdateRequestMessage(updateRequests));
}
private CompositeUpdPathObject getValidCompositePath(final List<PCEPObject> objects) throws PCEPDocumentedException {
}
switch (state) {
- case 1:
- state = 2;
- if (obj instanceof PCEPLspaObject) {
- pathLspa = (PCEPLspaObject) obj;
- break;
- }
- case 2:
+ case 1:
+ state = 2;
+ if (obj instanceof PCEPLspaObject) {
+ pathLspa = (PCEPLspaObject) obj;
+ break;
+ }
+ case 2:
+ state = 3;
+ if (obj instanceof PCEPRequestedPathBandwidthObject) {
+ pathBandwidth = (PCEPRequestedPathBandwidthObject) obj;
+ break;
+ }
+ case 3:
+ state = 4;
+ if (obj instanceof PCEPMetricObject) {
+ pathMetrics.add((PCEPMetricObject) obj);
state = 3;
- if (obj instanceof PCEPRequestedPathBandwidthObject) {
- pathBandwidth = (PCEPRequestedPathBandwidthObject) obj;
- break;
- }
- case 3:
- state = 4;
- if (obj instanceof PCEPMetricObject) {
- pathMetrics.add((PCEPMetricObject) obj);
- state = 3;
- break;
- }
+ break;
+ }
}
if (state == 4)
import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
-import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
import org.opendaylight.protocol.pcep.message.PCEPNotificationMessage;
import org.opendaylight.protocol.pcep.message.PCEPOpenMessage;
import org.opendaylight.protocol.pcep.object.CompositeNotifyObject;
import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
import org.opendaylight.protocol.pcep.object.PCEPNotificationObject;
import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
+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.keepalive.message.KeepaliveMessageBuilder;
public class FiniteStateMachineTest {
}
/**
- * Both PCEs accept session characteristics. Also tests KeepAliveTimer and
- * error message and when pce attempts to establish pce session for the 2nd
- * time.
- *
+ * Both PCEs accept session characteristics. Also tests KeepAliveTimer and error message and when pce attempts to
+ * establish pce session for the 2nd time.
+ *
* @throws InterruptedException
*/
@Test
@Ignore
public void testSessionCharsAccBoth() throws InterruptedException {
- //this.serverSession.startSession();
+ // this.serverSession.startSession();
assertEquals(1, this.client.getListMsg().size());
assertTrue(this.client.getListMsg().get(0) instanceof PCEPOpenMessage);
this.client.sendMessage(new PCEPOpenMessage(new PCEPOpenObject(3, 9, 2)));
assertEquals(2, this.client.getListMsg().size());
- assertTrue(this.client.getListMsg().get(1) instanceof PCEPKeepAliveMessage);
- this.client.sendMessage(new PCEPKeepAliveMessage());
+ assertTrue(this.client.getListMsg().get(1) instanceof KeepaliveMessage);
+ this.client.sendMessage((Message) new KeepaliveMessageBuilder().build());
synchronized (this.serverListener) {
while (!this.serverListener.up) {
try {
}
}
assertTrue(this.serverListener.up);
- // Thread.sleep(PCEPSessionImpl.KEEP_ALIVE_TIMER_VALUE * 1000);
- // assertEquals(3, this.client.getListMsg().size());
- // assertTrue(this.client.getListMsg().get(2) instanceof PCEPKeepAliveMessage); // test of keepalive timer
+ // Thread.sleep(PCEPSessionImpl.KEEP_ALIVE_TIMER_VALUE * 1000);
+ // assertEquals(3, this.client.getListMsg().size());
+ // assertTrue(this.client.getListMsg().get(2) instanceof PCEPKeepAliveMessage); // test of keepalive timer
this.client.sendMessage(new PCEPOpenMessage(new PCEPOpenObject(1, 1, 1)));
assertEquals(3, this.client.getListMsg().size());
assertTrue(this.client.getListMsg().get(2) instanceof PCEPErrorMessage);
- for (final PCEPMessage m : this.client.getListMsg()) {
+ for (final Message m : this.client.getListMsg()) {
if (m instanceof PCEPErrorMessage) {
final PCEPErrorObject obj = ((PCEPErrorMessage) m).getErrorObjects().get(0);
assertEquals(PCEPErrors.ATTEMPT_2ND_SESSION, obj.getError()); // test of error type 9
/**
* Mock PCE does not accept session characteristics the first time.
- *
+ *
* @throws InterruptedException
*/
@Test
@Ignore
public void testSessionCharsAccMe() throws InterruptedException {
- //this.serverSession.startSession();
+ // this.serverSession.startSession();
this.client.sendMessage(new PCEPOpenMessage(new PCEPOpenObject(4, 9, 2)));
assertEquals(2, this.client.getListMsg().size());
assertTrue(this.client.getListMsg().get(0) instanceof PCEPOpenMessage);
- assertTrue(this.client.getListMsg().get(1) instanceof PCEPKeepAliveMessage);
+ assertTrue(this.client.getListMsg().get(1) instanceof KeepaliveMessage);
this.client.sendErrorMessage(PCEPErrors.NON_ACC_NEG_SESSION_CHAR, new PCEPOpenObject(3, 7, 2, null));
assertEquals(3, this.client.getListMsg().size());
assertTrue(this.client.getListMsg().get(2) instanceof PCEPOpenMessage);
- this.client.sendMessage(new PCEPKeepAliveMessage());
+ this.client.sendMessage((Message) new KeepaliveMessageBuilder().build());
synchronized (this.serverListener) {
while (!this.serverListener.up) {
try {
/**
* Sending different PCEP Message than Open in session establishment phase.
- *
+ *
* @throws InterruptedException
*/
@Test
@Ignore
public void testErrorOneOne() throws InterruptedException {
- //this.serverSession.startSession();
+ // this.serverSession.startSession();
assertEquals(1, this.client.getListMsg().size());
assertTrue(this.client.getListMsg().get(0) instanceof PCEPOpenMessage);
this.client.sendMessage(new PCEPNotificationMessage(new ArrayList<CompositeNotifyObject>() {
}));
}
}));
- for (final PCEPMessage m : this.client.getListMsg()) {
+ for (final Message m : this.client.getListMsg()) {
if (m instanceof PCEPErrorMessage) {
final PCEPErrorObject obj = ((PCEPErrorMessage) m).getErrorObjects().get(0);
assertEquals(PCEPErrors.NON_OR_INVALID_OPEN_MSG, obj.getError());
/**
* OpenWait timer expired.
- *
+ *
* @throws InterruptedException
*/
@Test
@Ignore
public void testErrorOneTwo() throws InterruptedException {
- //this.serverSession.startSession();
+ // this.serverSession.startSession();
assertEquals(1, this.client.getListMsg().size());
assertTrue(this.client.getListMsg().get(0) instanceof PCEPOpenMessage);
Thread.sleep(60 * 1000);
- for (final PCEPMessage m : this.client.getListMsg()) {
+ for (final Message m : this.client.getListMsg()) {
if (m instanceof PCEPErrorMessage) {
final PCEPErrorObject obj = ((PCEPErrorMessage) m).getErrorObjects().get(0);
assertEquals(PCEPErrors.NO_OPEN_BEFORE_EXP_OPENWAIT, obj.getError());
/**
* KeepWaitTimer expired.
- *
+ *
* @throws InterruptedException
*/
@Test
@Ignore
public void testErrorOneSeven() throws InterruptedException {
- //this.serverSession.startSession();
+ // this.serverSession.startSession();
assertEquals(1, this.client.getListMsg().size());
assertTrue(this.client.getListMsg().get(0) instanceof PCEPOpenMessage);
this.client.sendMessage(new PCEPOpenMessage(new PCEPOpenObject(3, 9, 2)));
- Thread.sleep(serverSession.getKeepAliveTimerValue() * 1000);
- for (final PCEPMessage m : this.client.getListMsg()) {
+ Thread.sleep(this.serverSession.getKeepAliveTimerValue() * 1000);
+ for (final Message m : this.client.getListMsg()) {
if (m instanceof PCEPErrorMessage) {
final PCEPErrorObject obj = ((PCEPErrorMessage) m).getErrorObjects().get(0);
assertEquals(PCEPErrors.NO_MSG_BEFORE_EXP_KEEPWAIT, obj.getError());
import java.util.List;
import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPSession;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
import org.opendaylight.protocol.pcep.PCEPTerminationReason;
import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MockPCE implements PCEPSessionListener {
- private final List<PCEPMessage> listMsg = new ArrayList<PCEPMessage>();
+ private final List<Message> listMsg = new ArrayList<Message>();
private PCEPSessionImpl session = null;
public MockPCE() {
}
- public void sendMessage(final PCEPMessage msg) {
+ public void sendMessage(final Message msg) {
this.session.handleMessage(msg);
}
this.sendMessage(new PCEPErrorMessage(open, errors, null));
}
- public List<PCEPMessage> getListMsg() {
+ public List<Message> getListMsg() {
return this.listMsg;
}
}
@Override
- public void onMessage(final PCEPSession session, final PCEPMessage message) {
+ public void onMessage(final PCEPSession session, final Message message) {
this.listMsg.add(message);
logger.debug("Message received: {}", message);
}
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPOFCodes;
import org.opendaylight.protocol.pcep.PCEPObject;
import org.opendaylight.protocol.pcep.PCEPTlv;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nps.concepts.rev130930.Bandwidth;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
public class PCEPValidatorTest {
// private final PCEPClassTypeObjectProvider classTypeProvider = new
// PCEPClassTypeObjectProvider((short) 7, true);
- private static List<PCEPMessage> deserMsg(final String srcFile) throws IOException, DeserializerException, DocumentedException,
+ private static List<Message> deserMsg(final String srcFile) throws IOException, DeserializerException, DocumentedException,
PCEPDeserializerException {
final byte[] bytesFromFile = ByteArray.fileToBytes(srcFile);
final RawMessage rawMessage = (RawMessage) msgFactory.parse(bytesFromFile).get(0);
public void testOpenMessageValidationFromBin() throws IOException, DeserializerException, DocumentedException,
PCEPDeserializerException {
assertEquals(
- deserMsg("src/test/resources/PCEPOpenMessage1.bin"),
- asList(new PCEPOpenMessage(new PCEPOpenObject(30, 120, 1, asList(new PCEStatefulCapabilityTlv(false, true, true),
- new LSPStateDBVersionTlv(0x80))))));
+ deserMsg("src/test/resources/PCEPOpenMessage1.bin").toString(),
+ asList(
+ new PCEPOpenMessage(new PCEPOpenObject(30, 120, 1, asList(new PCEStatefulCapabilityTlv(false, true, true),
+ new LSPStateDBVersionTlv(0x80))))).toString());
- assertEquals(deserMsg("src/test/resources/Open.1.bin"), asList(new PCEPOpenMessage(new PCEPOpenObject(1, 4, 1))));
+ assertEquals(deserMsg("src/test/resources/Open.1.bin").toString(),
+ asList(new PCEPOpenMessage(new PCEPOpenObject(1, 4, 1))).toString());
assertEquals(
- deserMsg("src/test/resources/Open.3.bin"),
- asList(new PCEPOpenMessage(new PCEPOpenObject(1, 4, 1, asList(new PCEStatefulCapabilityTlv(false, true, true),
- new LSPStateDBVersionTlv(53))))));
+ deserMsg("src/test/resources/Open.3.bin").toString(),
+ asList(
+ new PCEPOpenMessage(new PCEPOpenObject(1, 4, 1, asList(new PCEStatefulCapabilityTlv(false, true, true),
+ new LSPStateDBVersionTlv(53))))).toString());
}
@Test
public void testKeepAliveMessageValidationFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
DeserializerException, DocumentedException {
- assertEquals(deserMsg("src/test/resources/PCEPKeepAliveMessage1.bin"), asList(new PCEPKeepAliveMessage()));
- assertEquals(deserMsg("src/test/resources/Keepalive.1.bin"), asList(new PCEPKeepAliveMessage()));
+ assertEquals(deserMsg("src/test/resources/PCEPKeepAliveMessage1.bin").toString(),
+ asList((Message) new PCEPKeepAliveMessage()).toString());
+ assertEquals(deserMsg("src/test/resources/Keepalive.1.bin").toString(), asList(new PCEPKeepAliveMessage()).toString());
}
@Test
public void testCloseMsg() throws PCEPDeserializerException, IOException, PCEPDocumentedException, DeserializerException,
DocumentedException {
- assertEquals(deserMsg("src/test/resources/PCEPCloseMessage1.bin"),
- asList(new PCEPCloseMessage(new PCEPCloseObject(Reason.TOO_MANY_UNKNOWN_MSG))));
- assertEquals(deserMsg("src/test/resources/Close.1.bin"), asList(new PCEPCloseMessage(new PCEPCloseObject(Reason.UNKNOWN))));
+ assertEquals(deserMsg("src/test/resources/PCEPCloseMessage1.bin").toString(),
+ asList(new PCEPCloseMessage(new PCEPCloseObject(Reason.TOO_MANY_UNKNOWN_MSG))).toString());
+ assertEquals(deserMsg("src/test/resources/Close.1.bin").toString(),
+ asList(new PCEPCloseMessage(new PCEPCloseObject(Reason.UNKNOWN))).toString());
}
@Test
final byte[] ipAdress = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
requests.add(new CompositeRequestObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 5, 0xDEADBEEFL, true, false), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress), new IPv4Address(ipAdress))));
PCEPRequestMessage specMessage = new PCEPRequestMessage(requests);
- List<PCEPMessage> deserMsgs = deserMsg("src/test/resources/PCEPRequestMessage1.bin");
- final List<PCEPMessage> specMessages = new ArrayList<PCEPMessage>();
+ List<Message> deserMsgs = deserMsg("src/test/resources/PCEPRequestMessage1.bin");
+ final List<Message> specMessages = Lists.newArrayList();
specMessages.add(specMessage);
- assertEquals(deserMsgs, specMessages);
+ assertEquals(deserMsgs.toString(), specMessages.toString());
requests = new ArrayList<CompositeRequestObject>();
final byte[] ipAdress2 = { (byte) 0x7F, (byte) 0x00, (byte) 0x00, (byte) 0x01 };
deserMsgs = deserMsg("src/test/resources/PCReq.1.bin");
specMessages.clear();
specMessages.add(specMessage);
- assertEquals(deserMsgs, specMessages);
+ assertEquals(deserMsgs.toString(), specMessages.toString());
requests = new ArrayList<CompositeRequestObject>();
requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, null, null, null, null, null, null, null, new PCEPLoadBalancingObject(3, new Bandwidth(ByteArray.floatToBytes((float) 1024.75)), false)));
deserMsgs = deserMsg("src/test/resources/PCReq.2.bin");
specMessages.clear();
specMessages.add(specMessage);
- // FIXME BUG-89
- // assertEquals(deserMsgs, specMessages);
+ assertEquals(deserMsgs.toString(), specMessages.toString());
requests = new ArrayList<CompositeRequestObject>();
requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, new PCEPLspObject(1, false, false, true, false), PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(1000)), false, false), new ArrayList<PCEPMetricObject>() {
specMessages.add(new PCEPRequestMessage(requests));
deserMsgs = deserMsg("src/test/resources/PCReq.4.bin");
- assertEquals(deserMsgs, specMessages);
+ assertEquals(deserMsgs.toString(), specMessages.toString());
specMessages.clear();
svecList = new ArrayList<CompositeRequestSvecObject>();
}, new PCEPReportedRouteObject(this.rroSubobjects, false), new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPIncludeRouteObject(this.eroSubobjects, false, false), new PCEPLoadBalancingObject(5, new Bandwidth(ByteArray.floatToBytes(3f)), false)));
deserMsgs = deserMsg("src/test/resources/PCReq.5.bin");
specMessages.add(new PCEPRequestMessage(svecList, requests));
- // FIXME BUG-89
+ // FIXME
// assertEquals(deserMsgs, specMessages);
// FIXME: need construct with invalid processed parameter
@Test
public void testRequestMessageValidationFromRawMsg() throws PCEPDeserializerException {
List<PCEPObject> objs = new ArrayList<PCEPObject>();
- List<PCEPMessage> msgs;
+ List<Message> msgs;
PCEPRequestParameterObject tmpRP;
// test unrecognized object in svec list
msgs = PCEPMessageValidator.getValidator(PCEPMessageType.REQUEST).validate(objs);
- assertEquals(msgs.get(0), new PCEPErrorMessage(new ArrayList<PCEPErrorObject>() {
+ assertEquals(msgs.get(0).toString(), new PCEPErrorMessage(new ArrayList<PCEPErrorObject>() {
private static final long serialVersionUID = 1L;
{
this.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
}
- }));
+ }).toString());
// test with request p flag not set and ignoracion of more than one
// end-points objects
List<PCEPReplyMessage> specMessages = new ArrayList<PCEPReplyMessage>();
specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 5, 0xDEADBEEFL, true, true)))));
specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, true, true, false, false, false, false, false, (short) 7, 0x12345678L, false, false)))));
- assertEquals(deserMsg("src/test/resources/PCEPReplyMessage1.bin"), specMessages);
+ assertEquals(deserMsg("src/test/resources/PCEPReplyMessage1.bin").toString(), specMessages.toString());
specMessages = new ArrayList<PCEPReplyMessage>();
specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false)))));
- assertEquals(deserMsg("src/test/resources/PCRep.1.bin"), specMessages);
+ assertEquals(deserMsg("src/test/resources/PCRep.1.bin").toString(), specMessages.toString());
specMessages = new ArrayList<PCEPReplyMessage>();
specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false)))));
specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(false, false, false, false, false, false, false, false, (short) 5, 2, false, false), new PCEPNoPathObject((short) 0, false, false), null, null, null, null, null, null))));
- assertEquals(deserMsg("src/test/resources/PCRep.2.bin"), specMessages);
+ assertEquals(deserMsg("src/test/resources/PCRep.2.bin").toString(), specMessages.toString());
specMessages = new ArrayList<PCEPReplyMessage>();
specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false), new PCEPNoPathObject((short) 1, true, false), new PCEPLspObject(1, true, true, false, true), PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(500)), false, false), new ArrayList<PCEPMetricObject>() {
specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 2, 4, false, false)))));
specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(false, false, false, false, false, false, false, false, (short) 3, 4, false, false)))));
specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(false, false, false, false, false, false, false, false, (short) 6, 5, false, false)))));
- assertEquals(deserMsg("src/test/resources/PCRep.4.bin"), specMessages);
+ assertEquals(deserMsg("src/test/resources/PCRep.4.bin").toString(), specMessages.toString());
specMessages = new ArrayList<PCEPReplyMessage>();
final List<Long> requestIDs = new ArrayList<Long>();
}, new PCEPIncludeRouteObject(PCEPValidatorTest.this.eroSubobjects, false, false)));
}
})), svecList));
- // FIXME : BUG-89
- // assertEquals(deserMsg("src/test/resources/PCRep.5.bin"), specMessages);
+ assertEquals(deserMsg("src/test/resources/PCRep.5.bin").toString(), specMessages.toString());
}
@Test
public void testUpdMessageValidatorFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
DeserializerException, DocumentedException {
- List<PCEPMessage> specMessages = new ArrayList<PCEPMessage>();
+ List<Message> specMessages = Lists.newArrayList();
List<CompositeUpdateRequestObject> requests = new ArrayList<CompositeUpdateRequestObject>();
requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
specMessages.add(new PCEPUpdateRequestMessage(requests));
- assertEquals(deserMsg("src/test/resources/PCUpd.1.bin"), specMessages);
+ assertEquals(deserMsg("src/test/resources/PCUpd.1.bin").toString(), specMessages.toString());
- specMessages = new ArrayList<PCEPMessage>();
+ specMessages = Lists.newArrayList();
List<CompositeUpdPathObject> paths = new ArrayList<CompositeUpdPathObject>();
paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, null, null));
requests = new ArrayList<CompositeUpdateRequestObject>();
requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true), paths));
specMessages.add(new PCEPUpdateRequestMessage(requests));
- assertEquals(deserMsg("src/test/resources/PCUpd.2.bin"), specMessages);
+ assertEquals(deserMsg("src/test/resources/PCUpd.2.bin").toString(), specMessages.toString());
- specMessages = new ArrayList<PCEPMessage>();
+ specMessages = Lists.newArrayList();
paths = new ArrayList<CompositeUpdPathObject>();
paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new ArrayList<PCEPMetricObject>() {
private static final long serialVersionUID = 1L;
requests = new ArrayList<CompositeUpdateRequestObject>();
requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true), paths));
specMessages.add(new PCEPUpdateRequestMessage(requests));
- // FIXME BUG-89
- // assertEquals(deserMsg("src/test/resources/PCUpd.3.bin"), specMessages);
+ assertEquals(deserMsg("src/test/resources/PCUpd.3.bin").toString(), specMessages.toString());
- specMessages = new ArrayList<PCEPMessage>();
+ specMessages = Lists.newArrayList();
requests = new ArrayList<CompositeUpdateRequestObject>();
requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
specMessages.add(new PCEPUpdateRequestMessage(requests));
- assertEquals(deserMsg("src/test/resources/PCUpd.4.bin"), specMessages);
+ assertEquals(deserMsg("src/test/resources/PCUpd.4.bin").toString(), specMessages.toString());
- specMessages = new ArrayList<PCEPMessage>();
+ specMessages = Lists.newArrayList();
requests = new ArrayList<CompositeUpdateRequestObject>();
requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
paths = new ArrayList<CompositeUpdPathObject>();
}));
requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true), paths));
specMessages.add(new PCEPUpdateRequestMessage(requests));
- // FIXME BUG-89
- // assertEquals(deserMsg("src/test/resources/PCUpd.5.bin"), specMessages);
+ assertEquals(deserMsg("src/test/resources/PCUpd.5.bin").toString(), specMessages.toString());
}
@Test
public void testRptMessageValidatorFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
DeserializerException, DocumentedException {
- List<PCEPMessage> specMessages = new ArrayList<PCEPMessage>();
+ List<Message> specMessages = Lists.newArrayList();
List<CompositeStateReportObject> reports = new ArrayList<CompositeStateReportObject>();
reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
specMessages.add(new PCEPReportMessage(reports));
- assertEquals(deserMsg("src/test/resources/PCRpt.1.bin"), specMessages);
+ assertEquals(deserMsg("src/test/resources/PCRpt.1.bin").toString(), specMessages.toString());
- specMessages = new ArrayList<PCEPMessage>();
+ specMessages = Lists.newArrayList();
List<CompositeRptPathObject> paths = new ArrayList<CompositeRptPathObject>();
paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, null, null, null));
reports = new ArrayList<CompositeStateReportObject>();
reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true), paths));
specMessages.add(new PCEPReportMessage(reports));
- assertEquals(deserMsg("src/test/resources/PCRpt.2.bin"), specMessages);
+ assertEquals(deserMsg("src/test/resources/PCRpt.2.bin").toString(), specMessages.toString());
- specMessages = new ArrayList<PCEPMessage>();
+ specMessages = Lists.newArrayList();
paths = new ArrayList<CompositeRptPathObject>();
paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPReportedRouteObject(this.rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
private static final long serialVersionUID = 1L;
reports = new ArrayList<CompositeStateReportObject>();
reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true), paths));
specMessages.add(new PCEPReportMessage(reports));
- // FIXME:
+
+ // FIXME
// assertEquals(deserMsg("src/test/resources/PCRpt.3.bin"), specMessages);
- specMessages = new ArrayList<PCEPMessage>();
+ specMessages = Lists.newArrayList();
reports = new ArrayList<CompositeStateReportObject>();
reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
specMessages.add(new PCEPReportMessage(reports));
- assertEquals(deserMsg("src/test/resources/PCRpt.4.bin"), specMessages);
+ assertEquals(deserMsg("src/test/resources/PCRpt.4.bin").toString(), specMessages.toString());
- specMessages = new ArrayList<PCEPMessage>();
+ specMessages = Lists.newArrayList();
reports = new ArrayList<CompositeStateReportObject>();
paths = new ArrayList<CompositeRptPathObject>();
paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPReportedRouteObject(this.rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true), paths));
specMessages.add(new PCEPReportMessage(reports));
// FIXME
- // assertEquals(deserMsg("src/test/resources/PCRpt.5.bin"), specMessages);
+ // assertEquals(deserMsg("src/test/resources/PCRpt.5.bin").toString(), specMessages.toString());
}
@Test
// FIXME: need construct with invalid processed parameter
final RawMessage rawMessage = (RawMessage) msgFactory.parse(bytes).get(0);
- assertEquals(PCEPMessageValidator.getValidator(rawMessage.getMsgType()).validate(rawMessage.getAllObjects()),
- asList((PCEPMessage) msg));
+ assertEquals(PCEPMessageValidator.getValidator(rawMessage.getMsgType()).validate(rawMessage.getAllObjects()).toString(),
+ asList((Message) msg).toString());
}
@Test
notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
notifications.add(new CompositeNotifyObject(notificationsList));
PCEPNotificationMessage specMessage = new PCEPNotificationMessage(notifications);
- assertEquals(deserMsg("src/test/resources/PCNtf.1.bin"), asList((PCEPMessage) specMessage));
+ assertEquals(deserMsg("src/test/resources/PCNtf.1.bin").toString(), asList((Message) specMessage).toString());
notifications = new ArrayList<CompositeNotifyObject>();
notificationsList = new ArrayList<PCEPNotificationObject>();
requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false));
notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
specMessage = new PCEPNotificationMessage(notifications);
- assertEquals(deserMsg("src/test/resources/PCNtf.2.bin"), asList((PCEPMessage) specMessage));
+ assertEquals(deserMsg("src/test/resources/PCNtf.2.bin").toString(), asList((Message) specMessage).toString());
notifications = new ArrayList<CompositeNotifyObject>();
notificationsList = new ArrayList<PCEPNotificationObject>();
requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 10, false, false));
notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
specMessage = new PCEPNotificationMessage(notifications);
- assertEquals(deserMsg("src/test/resources/PCNtf.3.bin"), asList((PCEPMessage) specMessage));
+ assertEquals(deserMsg("src/test/resources/PCNtf.3.bin").toString(), asList((Message) specMessage).toString());
notifications = new ArrayList<CompositeNotifyObject>();
notificationsList = new ArrayList<PCEPNotificationObject>();
notificationsList.add(new PCEPNotificationObject((short) 2, (short) 2));
notifications.add(new CompositeNotifyObject(notificationsList));
specMessage = new PCEPNotificationMessage(notifications);
- assertEquals(deserMsg("src/test/resources/PCNtf.4.bin"), asList((PCEPMessage) specMessage));
+ assertEquals(deserMsg("src/test/resources/PCNtf.4.bin").toString(), asList((Message) specMessage).toString());
notifications = new ArrayList<CompositeNotifyObject>();
notificationsList = new ArrayList<PCEPNotificationObject>();
requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 10, false, false));
notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
specMessage = new PCEPNotificationMessage(notifications);
- assertEquals(deserMsg("src/test/resources/PCNtf.5.bin"), asList((PCEPMessage) specMessage));
+ assertEquals(deserMsg("src/test/resources/PCNtf.5.bin").toString(), asList((Message) specMessage).toString());
}
@Test
errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
PCEPErrorMessage specMessage = new PCEPErrorMessage(errorsList);
- assertEquals(deserMsg("src/test/resources/PCErr.1.bin"), asList((PCEPMessage) specMessage));
+ assertEquals(deserMsg("src/test/resources/PCErr.1.bin").toString(), asList((Message) specMessage).toString());
List<PCEPRequestParameterObject> requests = new ArrayList<PCEPRequestParameterObject>();
requests.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false));
errors.add(new CompositeErrorObject(requests, errorsList));
specMessage = new PCEPErrorMessage(errors);
- assertEquals(deserMsg("src/test/resources/PCErr.2.bin"), asList((PCEPMessage) specMessage));
+ assertEquals(deserMsg("src/test/resources/PCErr.2.bin").toString(), asList((Message) specMessage).toString());
specMessage = new PCEPErrorMessage(new PCEPOpenObject(0, 0, 0), errorsList, null);
- assertEquals(deserMsg("src/test/resources/PCErr.3.bin"), asList((PCEPMessage) specMessage));
+ assertEquals(deserMsg("src/test/resources/PCErr.3.bin").toString(), asList((Message) specMessage).toString());
requests = new ArrayList<PCEPRequestParameterObject>();
requests.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 53, false, false));
errors.add(new CompositeErrorObject(requests, errorsList));
specMessage = new PCEPErrorMessage(errors);
- assertEquals(deserMsg("src/test/resources/PCErr.3b.bin"), asList((PCEPMessage) specMessage));
+ assertEquals(deserMsg("src/test/resources/PCErr.3b.bin").toString(), asList((Message) specMessage).toString());
errorsList = new ArrayList<PCEPErrorObject>();
errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
specMessage = new PCEPErrorMessage(null, errorsList, null);
- assertEquals(deserMsg("src/test/resources/PCErr.4.bin"), asList((PCEPMessage) specMessage));
+ assertEquals(deserMsg("src/test/resources/PCErr.4.bin").toString(), asList((Message) specMessage).toString());
requests = new ArrayList<PCEPRequestParameterObject>();
requests.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 53, false, false));
errors.add(new CompositeErrorObject(requests, errorsList));
specMessage = new PCEPErrorMessage(errors);
- assertEquals(deserMsg("src/test/resources/PCErr.5.bin"), asList((PCEPMessage) specMessage));
+ assertEquals(deserMsg("src/test/resources/PCErr.5.bin").toString(), asList((Message) specMessage).toString());
}
}
import io.netty.util.HashedWheelTimer;
import org.opendaylight.protocol.pcep.PCEPCloseTermination;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
import org.opendaylight.protocol.pcep.object.PCEPCloseObject.Reason;
import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
public class ServerSessionMock extends PCEPSessionImpl {
}
@Override
- public void sendMessage(final PCEPMessage msg) {
+ public void sendMessage(final Message msg) {
this.lastMessageSentAt = System.nanoTime();
this.client.onMessage(this, msg);
}
*/
package org.opendaylight.protocol.pcep.impl;
-import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPSession;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
import org.opendaylight.protocol.pcep.PCEPTerminationReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.collect.Lists;
+
/**
* Simple Session Listener that is notified about messages and changes in the session.
*/
public class SimpleSessionListener implements PCEPSessionListener {
- public List<PCEPMessage> messages = new ArrayList<PCEPMessage>();
+ public List<Message> messages = Lists.newArrayList();
public boolean up = false;
}
@Override
- public void onMessage(final PCEPSession session, final PCEPMessage message) {
+ public void onMessage(final PCEPSession session, final Message message) {
logger.debug("Received message: {} {}", message.getClass(), message);
this.messages.add(message);
}
import java.util.List;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
* Class representing raw message.
*/
-public class RawMessage extends PCEPMessage {
+public class RawMessage implements Message {
private final PCEPMessageType msgType;
+ private final List<PCEPObject> objects;
public RawMessage(final List<PCEPObject> objects, final PCEPMessageType msgType) {
- super(objects);
this.msgType = msgType;
+ if (objects.contains(null)) {
+ throw new IllegalArgumentException("Object list contains null element at offset " + objects.indexOf(null));
+ }
+ this.objects = objects;
}
public PCEPMessageType getMsgType() {
return this.msgType;
}
+ public List<PCEPObject> getAllObjects() {
+ return this.objects;
+ }
}
import org.opendaylight.protocol.concepts.IPv4Address;
import org.opendaylight.protocol.concepts.IPv4Prefix;
import org.opendaylight.protocol.concepts.Prefix;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPSession;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
import org.opendaylight.protocol.pcep.PCEPTerminationReason;
import org.opendaylight.protocol.pcep.object.PCEPLspaObject;
import org.opendaylight.protocol.pcep.subobject.EROIPPrefixSubobject;
import org.opendaylight.protocol.pcep.subobject.ExplicitRouteSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*/
public class SimpleSessionListener implements PCEPSessionListener {
- public List<PCEPMessage> messages = new ArrayList<PCEPMessage>();
+ public List<Message> messages = Lists.newArrayList();
private static final Logger logger = LoggerFactory.getLogger(SimpleSessionListener.class);
}
@Override
- public void onMessage(final PCEPSession session, final PCEPMessage message) {
+ public void onMessage(final PCEPSession session, final Message message) {
logger.debug("Received message: {}", message);
this.messages.add(message);
}
*/
package org.opendaylight.protocol.pcep.testtool;
-import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPSession;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
import org.opendaylight.protocol.pcep.PCEPTerminationReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.collect.Lists;
+
public class TestingSessionListener implements PCEPSessionListener {
- public List<PCEPMessage> messages = new ArrayList<PCEPMessage>();
+ public List<Message> messages = Lists.newArrayList();
public boolean up = false;
}
@Override
- public void onMessage(final PCEPSession session, final PCEPMessage message) {
+ public void onMessage(final PCEPSession session, final Message message) {
logger.debug("Received message: {}", message);
this.messages.add(message);
}
import org.opendaylight.protocol.framework.SessionListener;
import org.opendaylight.protocol.framework.SessionListenerFactory;
import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
-import org.opendaylight.protocol.pcep.PCEPMessage;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
import org.opendaylight.protocol.pcep.PCEPTlv;
import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
import org.opendaylight.protocol.pcep.impl.PCEPSessionImpl;
import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
import org.opendaylight.protocol.pcep.tlv.NodeIdentifierTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
-public class PCCMock<M, S extends ProtocolSession<M>, L extends SessionListener<M, ?, ?>> extends
-AbstractDispatcher<S, L> {
+public class PCCMock<M, S extends ProtocolSession<M>, L extends SessionListener<M, ?, ?>> extends AbstractDispatcher<S, L> {
private final SessionNegotiatorFactory<M, S, L> negotiatorFactory;
private final ProtocolHandlerFactory<?> factory;
this.factory = Preconditions.checkNotNull(factory);
}
- public Future<S> createClient(final InetSocketAddress address, final ReconnectStrategy strategy, final SessionListenerFactory<L> listenerFactory) {
+ public Future<S> createClient(final InetSocketAddress address, final ReconnectStrategy strategy,
+ final SessionListenerFactory<L> listenerFactory) {
return super.createClient(address, strategy, new PipelineInitializer<S>() {
@Override
public void initializeChannel(final SocketChannel ch, final Promise<S> promise) {
- ch.pipeline().addLast(factory.getDecoders());
- ch.pipeline().addLast("negotiator", negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise));
- ch.pipeline().addLast(factory.getEncoders());
+ ch.pipeline().addLast(PCCMock.this.factory.getDecoders());
+ ch.pipeline().addLast("negotiator", PCCMock.this.negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise));
+ ch.pipeline().addLast(PCCMock.this.factory.getEncoders());
}
});
}
final List<PCEPTlv> tlvs = Lists.newArrayList();
tlvs.add(new NodeIdentifierTlv(new byte[] { (byte) 127, (byte) 2, (byte) 3, (byte) 7 }));
- final SessionNegotiatorFactory<PCEPMessage, PCEPSessionImpl, PCEPSessionListener> snf = new DefaultPCEPSessionNegotiatorFactory(new HashedWheelTimer(), new PCEPOpenObject(30, 120, 0, tlvs), 0);
+ final SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> snf = new DefaultPCEPSessionNegotiatorFactory(new HashedWheelTimer(), new PCEPOpenObject(30, 120, 0, tlvs), 0);
- final PCCMock<PCEPMessage, PCEPSessionImpl, PCEPSessionListener> pcc = new PCCMock<>(snf, new PCEPHandlerFactory(), new DefaultPromise<PCEPSessionImpl>(GlobalEventExecutor.INSTANCE));
+ final PCCMock<Message, PCEPSessionImpl, PCEPSessionListener> pcc = new PCCMock<>(snf, new PCEPHandlerFactory(), new DefaultPromise<PCEPSessionImpl>(GlobalEventExecutor.INSTANCE));
pcc.createClient(new InetSocketAddress("127.0.0.3", 12345), new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 2000),
new SessionListenerFactory<PCEPSessionListener>() {
- @Override
- public PCEPSessionListener getSessionListener() {
- return new SimpleSessionListener();
- }
- }).get();
+ @Override
+ public PCEPSessionListener getSessionListener() {
+ return new SimpleSessionListener();
+ }
+ }).get();
}
}