use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader in project openflowplugin by opendaylight.
the class SingleLayerFlowService method buildRequest.
@Override
protected OfHeader buildRequest(final Xid xid, final Flow input) throws ServiceException {
final FlowMessageBuilder flowMessageBuilder = new FlowMessageBuilder(input);
final Class<? extends DataContainer> clazz = input.getImplementedInterface();
if (clazz.equals(AddFlowInput.class) || clazz.equals(UpdatedFlow.class)) {
flowMessageBuilder.setCommand(FlowModCommand.OFPFCADD);
} else if (clazz.equals(RemoveFlowInput.class) || clazz.equals(OriginalFlow.class)) {
flowMessageBuilder.setCommand(Boolean.TRUE.equals(input.isStrict()) ? FlowModCommand.OFPFCDELETESTRICT : FlowModCommand.OFPFCDELETE);
}
return flowMessageBuilder.setVersion(getVersion()).setXid(xid.getValue()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader in project openflowplugin by opendaylight.
the class AbstractService method handleServiceCall.
public ListenableFuture<RpcResult<O>> handleServiceCall(@Nonnull final I input, @Nullable final Function<OfHeader, Boolean> isComplete) {
Preconditions.checkNotNull(input);
final Class<?> requestType = input instanceof DataContainer ? DataContainer.class.cast(input).getImplementedInterface() : input.getClass();
getMessageSpy().spyMessage(requestType, MessageSpy.StatisticsGroup.TO_SWITCH_ENTERED);
LOG.trace("Handling general service call");
final RequestContext<O> requestContext = requestContextStack.createRequestContext();
if (Objects.isNull(requestContext)) {
LOG.trace("Request context refused.");
getMessageSpy().spyMessage(AbstractService.class, MessageSpy.StatisticsGroup.TO_SWITCH_DISREGARDED);
return Futures.immediateFuture(RpcResultBuilder.<O>failed().withError(RpcError.ErrorType.APPLICATION, "", "Request quota exceeded").build());
}
if (Objects.isNull(requestContext.getXid())) {
getMessageSpy().spyMessage(requestContext.getClass(), MessageSpy.StatisticsGroup.TO_SWITCH_RESERVATION_REJECTED);
return RequestContextUtil.closeRequestContextWithRpcError(requestContext, "Outbound queue wasn't able to reserve XID.");
}
getMessageSpy().spyMessage(requestContext.getClass(), MessageSpy.StatisticsGroup.TO_SWITCH_READY_FOR_SUBMIT);
final Xid xid = requestContext.getXid();
OfHeader request = null;
try {
request = buildRequest(xid, input);
Verify.verify(xid.getValue().equals(request.getXid()), "Expected XID %s got %s", xid.getValue(), request.getXid());
} catch (ServiceException ex) {
LOG.error("Failed to build request for {}, forfeiting request {}", input, xid.getValue(), ex);
RequestContextUtil.closeRequestContextWithRpcError(requestContext, "failed to build request input: " + ex.getMessage());
} finally {
final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
if (Objects.nonNull(isComplete)) {
outboundQueue.commitEntry(xid.getValue(), request, createCallback(requestContext, requestType), isComplete);
} else {
outboundQueue.commitEntry(xid.getValue(), request, createCallback(requestContext, requestType));
}
}
return requestContext.getFuture();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader in project openflowplugin by opendaylight.
the class FlowsInTableService method buildRequest.
@Override
protected OfHeader buildRequest(final Xid xid, final GetFlowStatisticsFromFlowTableInput input) throws ServiceException {
final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
if (input.getTableId() != null) {
mprFlowRequestBuilder.setTableId(input.getTableId());
} else {
mprFlowRequestBuilder.setTableId(OFConstants.OFPTT_ALL);
}
if (input.getOutPort() != null) {
mprFlowRequestBuilder.setOutPort(input.getOutPort().longValue());
} else {
mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
}
if (input.getOutGroup() != null) {
mprFlowRequestBuilder.setOutGroup(input.getOutGroup());
} else {
mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
}
if (input.getCookie() != null) {
mprFlowRequestBuilder.setCookie(input.getCookie().getValue());
} else {
mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
}
if (input.getCookieMask() != null) {
mprFlowRequestBuilder.setCookieMask(input.getCookieMask().getValue());
} else {
mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
}
// convert and inject match
final Optional<Object> conversionMatch = convertorExecutor.convert(input.getMatch(), data);
MatchInjector.inject(conversionMatch, mprFlowRequestBuilder, data.getVersion());
// Set request body to main multipart request
multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(MultipartType.OFPMPFLOW, xid.getValue(), getVersion());
mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
return mprInput.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader in project openflowplugin by opendaylight.
the class MeterFeaturesService method buildRequest.
@Override
protected OfHeader buildRequest(final Xid xid, final GetMeterFeaturesInput input) throws ServiceException {
MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(MultipartType.OFPMPMETERFEATURES, xid.getValue(), getVersion());
mprInput.setMultipartRequestBody(METER_FEATURES_CASE);
return mprInput.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader in project openflowplugin by opendaylight.
the class OneQueueOnePortService method buildRequest.
@Override
protected OfHeader buildRequest(final Xid xid, final GetQueueStatisticsFromGivenPortInput input) throws ServiceException {
MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
// Select specific queue
mprQueueBuilder.setQueueId(input.getQueueId().getValue());
// Select specific port
final short version = getVersion();
mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.get(version), input.getNodeConnectorId()));
caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
// Set request body to main multipart request
MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(MultipartType.OFPMPQUEUE, xid.getValue(), version);
mprInput.setMultipartRequestBody(caseBuilder.build());
return mprInput.build();
}
Aggregations