use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.
the class CInitiated00PCInitiateMessageParser method getValidRequest.
protected Requests getValidRequest(final List<Object> objects) {
final RequestsBuilder builder = new RequestsBuilder();
builder.setSrp((Srp) objects.get(0));
objects.remove(0);
builder.setLsp((Lsp) objects.get(0));
objects.remove(0);
final List<Metrics> metrics = Lists.newArrayList();
Object obj;
State state = State.INIT;
while (!objects.isEmpty() && !state.equals(State.END)) {
obj = objects.get(0);
state = insertObject(state, obj, builder, metrics);
if (!state.equals(State.END)) {
objects.remove(0);
}
}
builder.setMetrics(metrics);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.
the class CInitiated00PCInitiateMessageParser method validate.
@Override
protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Preconditions.checkArgument(objects != null, "Passed list can't be null.");
final PcinitiateMessageBuilder builder = new PcinitiateMessageBuilder();
final List<Requests> reqs = Lists.newArrayList();
while (!objects.isEmpty()) {
reqs.add(this.getValidRequest(objects));
}
builder.setRequests(reqs);
return new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.
the class PCEPMonitoringRequestMessageParser method validate.
@Override
protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Preconditions.checkArgument(objects != null, "Passed list can't be null.");
if (objects.isEmpty()) {
throw new PCEPDeserializerException("Pcmonreq message cannot be empty.");
}
final MonitoringRequest monReq = getMonitoring(objects);
if (monReq == null) {
errors.add(createErrorMsg(PCEPErrors.MONITORING_OBJECT_MISSING, Optional.absent()));
}
final PcreqMessageBuilder mBuilder = new PcreqMessageBuilder();
mBuilder.setMonitoringRequest(monReq);
final List<Svec> svecs = getSvecs(objects);
if (!svecs.isEmpty()) {
mBuilder.setSvec(svecs);
}
final List<Requests> requests = getRequests(objects, errors);
if (requests != null && !requests.isEmpty()) {
mBuilder.setRequests(requests);
}
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
return new PcmonreqBuilder().setPcreqMessage(mBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method serializeMessage.
@Override
public void serializeMessage(final Message message, final ByteBuf out) {
Preconditions.checkArgument(message instanceof Pcreq, "Wrong instance of Message. Passed instance of %s. Need Pcreq.", message.getClass());
final PcreqMessage msg = ((Pcreq) message).getPcreqMessage();
Preconditions.checkArgument(msg.getRequests() != null && !msg.getRequests().isEmpty(), "Requests cannot be null or empty.");
final ByteBuf buffer = Unpooled.buffer();
if (msg.getMonitoringRequest() != null) {
serializeMonitoringRequest(msg.getMonitoringRequest(), buffer);
}
if (msg.getSvec() != null) {
serializeSvec(msg, buffer);
}
serializeRequest(msg, buffer);
MessageUtil.formatMessage(TYPE, buffer, out);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.
the class ServerSessionManager method takeNodeState.
synchronized TopologyNodeState takeNodeState(final InetAddress address, final TopologySessionListener sessionListener, final boolean retrieveNode) {
final NodeId id = createNodeId(address);
if (this.isClosed.get()) {
LOG.error("Server Session Manager is closed. Unable to create topology node {} with listener {}", id, sessionListener);
return null;
}
LOG.debug("Node {} requested by listener {}", id, sessionListener);
TopologyNodeState ret = this.state.get(id);
if (ret == null) {
ret = new TopologyNodeState(this.dependenciesProvider.getDataBroker(), this.topology, id, DEFAULT_HOLD_STATE_NANOS);
LOG.debug("Created topology node {} for id {} at {}", ret, id, ret.getNodeId());
this.state.put(id, ret);
}
// if another listener requests the same session, close it
final TopologySessionListener existingSessionListener = this.nodes.get(id);
if (existingSessionListener != null && !sessionListener.equals(existingSessionListener)) {
LOG.error("New session listener {} is in conflict with existing session listener {} on node {}," + " closing the existing one.", existingSessionListener, sessionListener, id);
existingSessionListener.close();
}
ret.taken(retrieveNode);
this.nodes.put(id, sessionListener);
LOG.debug("Node {} bound to listener {}", id, sessionListener);
return ret;
}
Aggregations