}
if (dests == null || dests.size() != 1) {
LOG.warn("Null or more than one LinkstateRoute Key was parsed");
+ return null;
}
return dests.get(0);
}
}
@VisibleForTesting
- protected void setLastMessageSentAt(final long lastMessageSentAt) {
+ protected synchronized void setLastMessageSentAt(final long lastMessageSentAt) {
this.lastMessageSentAt = lastMessageSentAt;
}
}
public void addTlv(final TlvsBuilder builder, final Tlv tlv) {
super.addTlv(builder, tlv);
final Tlvs7Builder tlvBuilder = new Tlvs7Builder();
- if (builder != null) {
- final Tlvs7 tlvs = builder.getAugmentation(Tlvs7.class);
- if (tlvs != null && tlvs.getPathSetupType() != null) {
- tlvBuilder.setPathSetupType(tlvs.getPathSetupType());
- }
+ final Tlvs7 tlvs = builder.getAugmentation(Tlvs7.class);
+ if (tlvs != null && tlvs.getPathSetupType() != null) {
+ tlvBuilder.setPathSetupType(tlvs.getPathSetupType());
}
if (tlv instanceof PathSetupType) {
tlvBuilder.setPathSetupType((PathSetupType) tlv);
public class PcepRpObjectWithPstTlvParser extends PCEPRequestParameterObjectParser {
- public PcepRpObjectWithPstTlvParser(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+ public PcepRpObjectWithPstTlvParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
super(tlvReg, viTlvReg);
}
@Override
- public void addTlv(final TlvsBuilder builder, Tlv tlv) {
+ public void addTlv(final TlvsBuilder builder, final Tlv tlv) {
super.addTlv(builder, tlv);
final Tlvs1Builder tlvBuilder = new Tlvs1Builder();
- if (builder != null) {
- final Tlvs1 tlvs = builder.getAugmentation(Tlvs1.class);
- if (tlvs != null && tlvs.getPathSetupType() != null) {
- tlvBuilder.setPathSetupType(tlvs.getPathSetupType());
- }
+ final Tlvs1 tlvs = builder.getAugmentation(Tlvs1.class);
+ if (tlvs != null && tlvs.getPathSetupType() != null) {
+ tlvBuilder.setPathSetupType(tlvs.getPathSetupType());
}
if (tlv instanceof PathSetupType) {
tlvBuilder.setPathSetupType((PathSetupType) tlv);
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-
import io.netty.util.concurrent.FutureListener;
-
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-
import javax.annotation.concurrent.GuardedBy;
-
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
*/
final InetAddress peerAddress = session.getRemoteAddress();
- final TopologyNodeState state = serverSessionManager.takeNodeState(peerAddress, this);
- if (state == null) {
- session.close(TerminationReason.Unknown);
- return;
- }
+ final TopologyNodeState state = this.serverSessionManager.takeNodeState(peerAddress, this);
LOG.trace("Peer {} resolved to topology node {}", peerAddress, state.getNodeId());
this.synced = false;
@GuardedBy("this")
private void tearDown(final PCEPSession session) {
- this.serverSessionManager.releaseNodeState(this.nodeState);
+ this.serverSessionManager.releaseNodeState(this.nodeState, session);
this.nodeState = null;
this.session = null;
LOG.debug("Setting new paths {} to lsp {}", updatedPaths, name);
rlb.setPath(updatedPaths);
}
- Preconditions.checkState(name != null);
rlb.setKey(new ReportedLspKey(name));
rlb.setName(name);
return this.lsps.get(id);
}
- protected synchronized final <T extends DataObject> ListenableFuture<Optional<T>> readOperationalData(final InstanceIdentifier<T> id) {
+ protected final synchronized <T extends DataObject> ListenableFuture<Optional<T>> readOperationalData(final InstanceIdentifier<T> id) {
return this.nodeState.readOperationalData(id);
}
}
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.protocol.framework.SessionListenerFactory;
+import org.opendaylight.protocol.pcep.PCEPSession;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspArgs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.EnsureLspOperationalInput;
return new NodeId("pcc://" + addr.getHostAddress());
}
- synchronized void releaseNodeState(final TopologyNodeState nodeState) {
+ synchronized void releaseNodeState(final TopologyNodeState nodeState, final PCEPSession session) {
LOG.debug("Node {} unbound", nodeState.getNodeId());
- this.nodes.remove(nodeState.getNodeId());
+ this.nodes.remove(createNodeId(session.getRemoteAddress()));
nodeState.released();
}
TopologyNodeState ret = this.state.get(id);
if (ret == null) {
- ret = new TopologyNodeState(broker, topology, id, DEFAULT_HOLD_STATE_NANOS);
+ ret = new TopologyNodeState(this.broker, this.topology, id, DEFAULT_HOLD_STATE_NANOS);
LOG.debug("Created topology node {} for id {} at {}", ret, id, ret.getNodeId());
this.state.put(id, ret);
- } else {
- // FIXME: check for conflicting session
}
+ // FIXME: else check for conflicting session
ret.taken();
this.nodes.put(id, sessionListener);
@Override
public PCEPSessionListener getSessionListener() {
- return listenerFactory.createTopologySessionListener(this);
+ return this.listenerFactory.createTopologySessionListener(this);
}
@Override
@Override
public void close() throws TransactionCommitFailedException {
- for (final TopologySessionListener sessionListener : nodes.values()) {
+ for (final TopologySessionListener sessionListener : this.nodes.values()) {
sessionListener.close();
}
- for (final TopologyNodeState nodeState : state.values()) {
+ for (final TopologyNodeState nodeState : this.state.values()) {
nodeState.close();
}
final WriteTransaction t = this.broker.newWriteOnlyTransaction();