Change-Id: I669cc2821455423424afa23497340cf95de4aed3
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
12 files changed:
return addToStringAttributes(Objects.toStringHelper(this)).toString();
}
return addToStringAttributes(Objects.toStringHelper(this)).toString();
}
- abstract protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper);
+ protected abstract ToStringHelper addToStringAttributes(ToStringHelper toStringHelper);
- private static final Logger logger = LoggerFactory.getLogger(AbstractPCEPSessionNegotiator.class);
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractPCEPSessionNegotiator.class);
private final Timer timer;
private final Timer timer;
- final synchronized protected void startNegotiation() {
+ protected final synchronized void startNegotiation() {
Preconditions.checkState(this.state == State.Idle);
this.localPrefs = getInitialProposal();
final OpenMessage m = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.OpenBuilder().setOpenMessage(
Preconditions.checkState(this.state == State.Idle);
this.localPrefs = getInitialProposal();
final OpenMessage m = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.OpenBuilder().setOpenMessage(
this.state = State.OpenWait;
scheduleFailTimer();
this.state = State.OpenWait;
scheduleFailTimer();
- logger.debug("Channel {} started sent proposal {}", this.channel, this.localPrefs);
+ LOG.debug("Channel {} started sent proposal {}", this.channel, this.localPrefs);
- final synchronized protected void handleMessage(final Message msg) {
+ protected final synchronized void handleMessage(final Message msg) {
- logger.debug("Channel {} handling message in state {}", this.channel, this.state);
+ LOG.debug("Channel {} handling message in state {}", this.channel, this.state);
switch (this.state) {
case Finished:
switch (this.state) {
case Finished:
} else {
scheduleFailTimer();
this.state = State.OpenWait;
} else {
scheduleFailTimer();
this.state = State.OpenWait;
- logger.debug("Channel {} moved to OpenWait state with localOK=1", this.channel);
+ LOG.debug("Channel {} moved to OpenWait state with localOK=1", this.channel);
} else {
scheduleFailTimer();
this.state = State.KeepWait;
} else {
scheduleFailTimer();
this.state = State.KeepWait;
- logger.debug("Channel {} moved to KeepWait state with remoteOK=1", this.channel);
+ LOG.debug("Channel {} moved to KeepWait state with remoteOK=1", this.channel);
- logger.warn("Channel {} in state {} received unexpected message {}", this.channel, this.state, msg);
+ LOG.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"));
this.state = State.Finished;
sendErrorMessage(PCEPErrors.NON_OR_INVALID_OPEN_MSG);
negotiationFailed(new Exception("Illegal message encountered"));
this.state = State.Finished;
*/
public abstract class AbstractPCEPSessionNegotiatorFactory implements
SessionNegotiatorFactory<Message, 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 static final Comparator<byte[]> COMPARATOR = UnsignedBytes.lexicographicalComparator();
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractPCEPSessionNegotiatorFactory.class);
private final BiMap<byte[], Closeable> sessions = HashBiMap.create();
private final Map<byte[], Short> sessionIds = new WeakHashMap<>();
private final BiMap<byte[], Closeable> sessions = HashBiMap.create();
private final Map<byte[], Short> sessionIds = new WeakHashMap<>();
final Object lock = this;
final Object lock = this;
- logger.debug("Instantiating bootstrap negotiator for channel {}", channel);
+ LOG.debug("Instantiating bootstrap negotiator for channel {}", channel);
return new AbstractSessionNegotiator<Message, PCEPSessionImpl>(promise, channel) {
@Override
protected void startNegotiation() throws Exception {
return new AbstractSessionNegotiator<Message, PCEPSessionImpl>(promise, channel) {
@Override
protected void startNegotiation() throws Exception {
- logger.debug("Bootstrap negotiation for channel {} started", this.channel);
+ LOG.debug("Bootstrap negotiation for channel {} started", this.channel);
/*
* We have a chance to see if there's a client session already
/*
* We have a chance to see if there's a client session already
if (AbstractPCEPSessionNegotiatorFactory.this.sessions.containsKey(clientAddress)) {
final byte[] serverAddress = ((InetSocketAddress) this.channel.localAddress()).getAddress().getAddress();
if (AbstractPCEPSessionNegotiatorFactory.this.sessions.containsKey(clientAddress)) {
final byte[] serverAddress = ((InetSocketAddress) this.channel.localAddress()).getAddress().getAddress();
- if (comparator.compare(serverAddress, clientAddress) > 0) {
+ if (COMPARATOR.compare(serverAddress, clientAddress) > 0) {
final Closeable n = AbstractPCEPSessionNegotiatorFactory.this.sessions.remove(clientAddress);
try {
n.close();
} catch (final IOException e) {
final Closeable n = AbstractPCEPSessionNegotiatorFactory.this.sessions.remove(clientAddress);
try {
n.close();
} catch (final IOException e) {
- logger.warn("Unexpected failure to close old session", e);
+ LOG.warn("Unexpected failure to close old session", e);
}
} else {
negotiationFailed(new RuntimeException("A conflicting session for address "
}
} else {
negotiationFailed(new RuntimeException("A conflicting session for address "
- logger.debug("Replacing bootstrap negotiator for channel {}", this.channel);
+ LOG.debug("Replacing bootstrap negotiator for channel {}", this.channel);
this.channel.pipeline().replace(this, "negotiator", n);
n.startNegotiation();
}
this.channel.pipeline().replace(this, "negotiator", n);
n.startNegotiation();
}
* A PCEP message parser which also does validation.
*/
public final class PCEPByteToMessageDecoder extends ByteToMessageDecoder {
* A PCEP message parser which also does validation.
*/
public final class PCEPByteToMessageDecoder extends ByteToMessageDecoder {
- private final static Logger LOG = LoggerFactory.getLogger(PCEPByteToMessageDecoder.class);
+ private static final Logger LOG = LoggerFactory.getLogger(PCEPByteToMessageDecoder.class);
- private final static int TYPE_SIZE = 1; // bytes
+ private static final int TYPE_SIZE = 1;
- private final static int LENGTH_SIZE = 2; // bytes
+ private static final int LENGTH_SIZE = 2;
private final MessageHandlerRegistry registry;
private final MessageHandlerRegistry registry;
try {
out.add(parse(bytes, errors));
try {
out.add(parse(bytes, errors));
- } catch (PCEPDeserializerException e) {
+ } catch (final PCEPDeserializerException e) {
LOG.debug("Failed to decode protocol message", e);
this.exceptionCaught(ctx, e);
}
LOG.debug("Failed to decode protocol message", e);
this.exceptionCaught(ctx, e);
}
*/
@Sharable
public final class PCEPMessageToByteEncoder extends MessageToByteEncoder<Message> {
*/
@Sharable
public final class PCEPMessageToByteEncoder extends MessageToByteEncoder<Message> {
- private static final Logger logger = LoggerFactory.getLogger(PCEPMessageToByteEncoder.class);
+ private static final Logger LOG = LoggerFactory.getLogger(PCEPMessageToByteEncoder.class);
private static final int VERSION_SF_LENGTH = 3;
private final MessageHandlerRegistry registry;
private static final int VERSION_SF_LENGTH = 3;
private final MessageHandlerRegistry registry;
@Override
protected void encode(final ChannelHandlerContext ctx, final Message msg, final ByteBuf out) throws Exception {
Preconditions.checkNotNull(msg);
@Override
protected void encode(final ChannelHandlerContext ctx, final Message msg, final ByteBuf out) throws Exception {
Preconditions.checkNotNull(msg);
- logger.debug("Sent to encode : {}", msg);
+ LOG.debug("Sent to encode : {}", msg);
final ByteBuf body = Unpooled.buffer();
final MessageSerializer serializer = this.registry.getMessageSerializer(msg);
final ByteBuf body = Unpooled.buffer();
final MessageSerializer serializer = this.registry.getMessageSerializer(msg);
- private final List<Object> parseObjects(final byte[] bytes) throws PCEPDeserializerException {
+ private List<Object> parseObjects(final byte[] bytes) throws PCEPDeserializerException {
int offset = 0;
final List<Object> objs = Lists.newArrayList();
while (bytes.length - offset > 0) {
int offset = 0;
final List<Object> objs = Lists.newArrayList();
while (bytes.length - offset > 0) {
maping.getFromErrorsEnum(e).value).build()).build())).build()).build();
}
maping.getFromErrorsEnum(e).value).build()).build())).build()).build();
}
- abstract protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException;
+ protected abstract Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException;
@Override
public final Message parseMessage(final byte[] buffer, final List<Message> errors) throws PCEPDeserializerException {
@Override
public final Message parseMessage(final byte[] buffer, final List<Message> errors) throws PCEPDeserializerException {
rBuilder.setRp(rpObj);
}
} else {
rBuilder.setRp(rpObj);
}
} else {
- // if RP obj is missing return error only;
+ // if RP obj is missing return error only
errors.add(createErrorMsg(PCEPErrors.RP_MISSING));
return null;
}
errors.add(createErrorMsg(PCEPErrors.RP_MISSING));
return null;
}
protected abstract List<AutoCloseable> startImpl(PCEPExtensionProviderContext context);
@Override
protected abstract List<AutoCloseable> startImpl(PCEPExtensionProviderContext context);
@Override
- public synchronized final void start(final PCEPExtensionProviderContext context) {
+ public final synchronized void start(final PCEPExtensionProviderContext context) {
Preconditions.checkState(this.registrations == null);
this.registrations = Preconditions.checkNotNull(startImpl(context));
}
@Override
Preconditions.checkState(this.registrations == null);
this.registrations = Preconditions.checkNotNull(startImpl(context));
}
@Override
- public synchronized final void stop() {
+ public final synchronized void stop() {
Preconditions.checkState(this.registrations != null);
for (final AutoCloseable r : this.registrations) {
Preconditions.checkState(this.registrations != null);
for (final AutoCloseable r : this.registrations) {
public class TestingSessionListener implements PCEPSessionListener {
public class TestingSessionListener implements PCEPSessionListener {
- public List<Message> messages = Lists.newArrayList();
+ private final List<Message> messages = Lists.newArrayList();
public boolean up = false;
public boolean up = false;
public void onSessionTerminated(final PCEPSession session, final PCEPTerminationReason cause) {
logger.debug("Session terminated. Cause : {}", cause);
}
public void onSessionTerminated(final PCEPSession session, final PCEPTerminationReason cause) {
logger.debug("Session terminated. Cause : {}", cause);
}
+
+ public List<Message> messages() {
+ return this.messages;
+ }
@Test
public void testSimpleSessionListener() {
final TestingSessionListener ssl = new TestingSessionListener();
@Test
public void testSimpleSessionListener() {
final TestingSessionListener ssl = new TestingSessionListener();
- assertEquals(0, ssl.messages.size());
+ assertEquals(0, ssl.messages().size());
ssl.onMessage(null, new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build());
ssl.onMessage(null, new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build());
- assertEquals(1, ssl.messages.size());
- assertTrue(ssl.messages.get(0) instanceof KeepaliveMessage);
+ assertEquals(1, ssl.messages().size());
+ assertTrue(ssl.messages().get(0) instanceof KeepaliveMessage);
assertFalse(ssl.up);
ssl.onSessionUp(null);
assertTrue(ssl.up);
assertFalse(ssl.up);
ssl.onSessionUp(null);
assertTrue(ssl.up);
private long requestId = 1;
private NodeId nodeId;
private long requestId = 1;
private NodeId nodeId;
- final Node topologyNode(final DataModificationTransaction trans, final InetAddress address) {
+ Node topologyNode(final DataModificationTransaction trans, final InetAddress address) {
final String pccId = createNodeId(address);
final Topology topo = (Topology) trans.readOperationalData(ServerSessionManager.this.topology);
final String pccId = createNodeId(address);
final Topology topo = (Topology) trans.readOperationalData(ServerSessionManager.this.topology);
public synchronized void onMessage(final PCEPSession session, final Message message) {
if (!(message instanceof PcrptMessage)) {
LOG.info("Unhandled message {} on session {}", message, session);
public synchronized void onMessage(final PCEPSession session, final Message message) {
if (!(message instanceof PcrptMessage)) {
LOG.info("Unhandled message {} on session {}", message, session);
- session.sendMessage(unhandledMessageError);
+ session.sendMessage(UNHANDLED_MESSAGE_ERROR);
}
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrpt.message.PcrptMessage rpt = ((PcrptMessage) message).getPcrptMessage();
}
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrpt.message.PcrptMessage rpt = ((PcrptMessage) message).getPcrptMessage();
}
private static final Logger LOG = LoggerFactory.getLogger(ServerSessionManager.class);
}
private static final Logger LOG = LoggerFactory.getLogger(ServerSessionManager.class);
- private static final Pcerr unhandledMessageError = new PcerrBuilder().setPcerrMessage(
+ private static final Pcerr UNHANDLED_MESSAGE_ERROR = new PcerrBuilder().setPcerrMessage(
new PcerrMessageBuilder().setErrorType(null).build()).build();
new PcerrMessageBuilder().setErrorType(null).build()).build();
- private static final MessageHeader messageHeader = new MessageHeader() {
+ private static final MessageHeader MESSAGE_HEADER = new MessageHeader() {
private final ProtocolVersion version = new ProtocolVersion((short) 1);
@Override
private final ProtocolVersion version = new ProtocolVersion((short) 1);
@Override
new TopologyBuilder().setKey(k).setTopologyId(k.getTopologyId()).setTopologyTypes(
new TopologyTypesBuilder().addAugmentation(TopologyTypes1.class,
new TopologyTypes1Builder().setTopologyPcep(new TopologyPcepBuilder().build()).build()).build()).setNode(
new TopologyBuilder().setKey(k).setTopologyId(k.getTopologyId()).setTopologyTypes(
new TopologyTypesBuilder().addAugmentation(TopologyTypes1.class,
new TopologyTypes1Builder().setTopologyPcep(new TopologyPcepBuilder().build()).build()).build()).setNode(
- new ArrayList<Node>()).build());
+ new ArrayList<Node>()).build());
- Futures.addCallback(JdkFutureAdapters.listenInPoolThread(t.commit()),
- new FutureCallback<RpcResult<TransactionStatus>>() {
+ Futures.addCallback(JdkFutureAdapters.listenInPoolThread(t.commit()), new FutureCallback<RpcResult<TransactionStatus>>() {
@Override
public void onSuccess(final RpcResult<TransactionStatus> result) {
// Nothing to do
@Override
public void onSuccess(final RpcResult<TransactionStatus> result) {
// Nothing to do
rb.setLsp(new LspBuilder().setAdministrative(input.getArguments().isAdministrative()).setDelegate(Boolean.TRUE).setTlvs(
new TlvsBuilder().setSymbolicPathName(new SymbolicPathNameBuilder().setPathName(input.getName()).build()).build()).build());
rb.setLsp(new LspBuilder().setAdministrative(input.getArguments().isAdministrative()).setDelegate(Boolean.TRUE).setTlvs(
new TlvsBuilder().setSymbolicPathName(new SymbolicPathNameBuilder().setPathName(input.getName()).build()).build()).build());
- final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(messageHeader);
+ final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(MESSAGE_HEADER);
ib.setRequests(ImmutableList.of(rb.build()));
// Send the message
ib.setRequests(ImmutableList.of(rb.build()));
// Send the message
rb.setSrp(new SrpBuilder().setOperationId(l.nextRequest()).setProcessingRule(Boolean.TRUE).setFlags(new Flags(Boolean.TRUE)).build());
rb.setLsp(new LspBuilder().setRemove(Boolean.TRUE).setPlspId(rep.getLsp().getPlspId()).setDelegate(Boolean.TRUE).build());
rb.setSrp(new SrpBuilder().setOperationId(l.nextRequest()).setProcessingRule(Boolean.TRUE).setFlags(new Flags(Boolean.TRUE)).build());
rb.setLsp(new LspBuilder().setRemove(Boolean.TRUE).setPlspId(rep.getLsp().getPlspId()).setDelegate(Boolean.TRUE).build());
- final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(messageHeader);
+ final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(MESSAGE_HEADER);
ib.setRequests(ImmutableList.of(rb.build()));
return l.sendMessage(new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build(), rb.getSrp().getOperationId());
}
ib.setRequests(ImmutableList.of(rb.build()));
return l.sendMessage(new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build(), rb.getSrp().getOperationId());
}
final PathBuilder pb = new PathBuilder();
rb.setPath(pb.setEro(input.getArguments().getEro()).build());
final PathBuilder pb = new PathBuilder();
rb.setPath(pb.setEro(input.getArguments().getEro()).build());
- final PcupdMessageBuilder ub = new PcupdMessageBuilder(messageHeader);
+ final PcupdMessageBuilder ub = new PcupdMessageBuilder(MESSAGE_HEADER);
ub.setUpdates(ImmutableList.of(rb.build()));
return l.sendMessage(new PcupdBuilder().setPcupdMessage(ub.build()).build(), rb.getSrp().getOperationId());
}
ub.setUpdates(ImmutableList.of(rb.build()));
return l.sendMessage(new PcupdBuilder().setPcupdMessage(ub.build()).build(), rb.getSrp().getOperationId());
}
- private NodeId supportingNode(final DataModificationTransaction t, final Node node) {
+ private NodeId supportingNode(final Node node) {
for (final SupportingNode n : node.getSupportingNode()) {
final SupportingNode1 n1 = n.getAugmentation(SupportingNode1.class);
if (n1 != null && n1.getPathComputationClient().isControlling()) {
for (final SupportingNode n : node.getSupportingNode()) {
final SupportingNode1 n1 = n.getAugmentation(SupportingNode1.class);
if (n1 != null && n1.getPathComputationClient().isControlling()) {
final TerminationPoint dp = Preconditions.checkNotNull(dr.getTp());
final AddLspInputBuilder ab = new AddLspInputBuilder();
final TerminationPoint dp = Preconditions.checkNotNull(dr.getTp());
final AddLspInputBuilder ab = new AddLspInputBuilder();
- ab.setNode(Preconditions.checkNotNull(supportingNode(t, sn)));
+ ab.setNode(Preconditions.checkNotNull(supportingNode(sn)));
ab.setName(Preconditions.checkNotNull(input.getSymbolicPathName()));
// The link has to be non-existent
ab.setName(Preconditions.checkNotNull(input.getSymbolicPathName()));
// The link has to be non-existent
final UpdateLspInputBuilder ab = new UpdateLspInputBuilder();
ab.setName(link.getAugmentation(Link1.class).getSymbolicPathName());
final UpdateLspInputBuilder ab = new UpdateLspInputBuilder();
ab.setName(link.getAugmentation(Link1.class).getSymbolicPathName());
- ab.setNode(Preconditions.checkNotNull(supportingNode(t, node)));
+ ab.setNode(Preconditions.checkNotNull(supportingNode(node)));
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.update.lsp.args.ArgumentsBuilder args = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.update.lsp.args.ArgumentsBuilder();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.update.lsp.args.ArgumentsBuilder args = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.update.lsp.args.ArgumentsBuilder();