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);