This is the last commit. It enforces the checkstyle level to error.
Change-Id: I954f0cbabd68134254e3a05216d6f6f126e33d37
Signed-off-by: David Suarez <david.suarez.fuentes@gmail.com>
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.openflowplugin</groupId>
<artifactId>openflowplugin-impl</artifactId>
<packaging>bundle</packaging>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=warning</propertyExpansion>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <!-- This bundle works with Karaf 3 and 4.0 -->
- <Import-Package>
- org.apache.karaf.shell.commands;version="[3.0.0,4.1)",
- org.apache.karaf.shell.console;version="[3.0.0,4.1)",
- *
- </Import-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
<dependencies>
<dependency>
<groupId>org.opendaylight.openflowplugin</groupId>
<artifactId>openflowplugin-common</artifactId>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <!-- This bundle works with Karaf 3 and 4.0 -->
+ <Import-Package>
+ org.apache.karaf.shell.commands;version="[3.0.0,4.1)",
+ org.apache.karaf.shell.console;version="[3.0.0,4.1)",
+ *
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
* Class converts multipart reply messages to the objects that can be then written to datastore using
* multipart writers.
*/
-public class MultipartReplyTranslatorUtil {
+public final class MultipartReplyTranslatorUtil {
private static final Logger LOG = LoggerFactory.getLogger(MultipartReplyTranslatorUtil.class);
+ private MultipartReplyTranslatorUtil() {
+ }
+
public static Optional<? extends MultipartReplyBody> translate(
final OfHeader message,
final DeviceInfo deviceInfo,
/**
* Multipart writer provider factory.
*/
-public class MultipartWriterProviderFactory {
+public final class MultipartWriterProviderFactory {
+
+ private MultipartWriterProviderFactory() {
+ }
/**
* Create default #{@link MultipartWriterProvider}.
return useSingleLayerSerialization && getDeviceInfo().getVersion() >= OFConstants.OFP_VERSION_1_3;
}
+ // TODO: exception handling should be fixed by using custom checked exception, never RuntimeExceptions
@Override
- @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressWarnings({"checkstyle:IllegalCatch", "checkstyle:AvoidHidingCauseExceptionCheck"})
public void instantiateServiceInstance() {
lazyTransactionManagerInitialization();
.filter(Objects::nonNull)
.count();
- LOG.debug("Finished filling flow registry with {} flows for node: {}", flowCount, deviceInfo
- );
+ LOG.debug("Finished filling flow registry with {} flows for node: {}", flowCount, deviceInfo);
}
this.contextChainMastershipWatcher.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState
.INITIAL_FLOW_REGISTRY_FILL);
LOG.debug("Cancelled filling flow registry with flows for node: {}", deviceInfo);
}
} else {
- LOG.warn("Failed filling flow registry with flows for node: {} with exception: {}", deviceInfo
- , throwable);
+ LOG.warn("Failed filling flow registry with flows for node: {} with exception: {}", deviceInfo,
+ throwable);
}
contextChainMastershipWatcher.onNotAbleToStartMastership(
deviceInfo,
}
/**
- * Get singleton instance
+ * Get singleton instance.
*
* @return instance
*/
}
/**
- * @param features {@link org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput}
+ * Returns the features of the switch.
+ *
+ * @param features
+ * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput}
* @return switch features
*/
public SwitchFeatures buildSwitchFeatures(GetFeaturesOutput features) {
-
if (swFeaturesBuilders.containsKey(features.getVersion())) {
LOG.debug("map contains version {}", features.getVersion());
try {
} else {
LOG.warn("unknown version: {}", features.getVersion());
}
-
return null;
}
-
}
/**
* Util class for injecting new match entry deserializers into OpenflowJava.
*/
-public class MatchDeserializerInjector {
+public final class MatchDeserializerInjector {
+
+ private MatchDeserializerInjector() {
+ }
/**
* Injects deserializers into provided
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
-class MessageDeserializerInjector {
+final class MessageDeserializerInjector {
+
+ private MessageDeserializerInjector() {
+ }
/**
* Injects message deserializers into provided.
*/
@VisibleForTesting
static Function<Integer, Function<Class<? extends OfHeader>, Consumer<OFDeserializer<? extends OfHeader>>>>
- createInjector(
+ createInjector(
final DeserializerExtensionProvider provider,
final short version) {
return code -> retType -> deserializer -> {
import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
-class MultipartDeserializerInjector {
+final class MultipartDeserializerInjector {
+
+ private MultipartDeserializerInjector() {
+ }
/**
* Injects message deserializers into provided
/**
* Utility class for action deserialization.
*/
-public class InstructionUtil {
+public final class InstructionUtil {
+
+ private InstructionUtil() {
+ }
/**
* Deserialize OpenFlow instruction.
/**
* Util class for injecting new instruction serializers into OpenflowJava.
*/
-class InstructionSerializerInjector {
+public final class InstructionSerializerInjector {
+
+ private InstructionSerializerInjector() {
+ }
/**
* Injects serializers into provided
/**
* Util class for injecting new match serializers into OpenflowJava.
*/
-class MatchSerializerInjector {
+public final class MatchSerializerInjector {
+
+ private MatchSerializerInjector() {
+ }
/**
* Injects match serializers into provided
/**
* Util class for injecting new message serializers into OpenflowJava.
*/
-class MessageSerializerInjector {
+final class MessageSerializerInjector {
+
+ private MessageSerializerInjector() {
+ }
/**
* Injects message serializers into provided
/**
* Util class for injecting new multipart match field serializers into OpenflowJava.
*/
-class MultipartMatchFieldSerializerInjector {
+final class MultipartMatchFieldSerializerInjector {
+
+ private MultipartMatchFieldSerializerInjector() {
+ }
/**
* Injects multipart match field serializers into provided
/**
* Util class for injecting new multipart serializers into OpenflowJava.
*/
-class MultipartSerializerInjector {
+final class MultipartSerializerInjector {
+
+ private MultipartSerializerInjector() {
+ }
/**
* Injects multipart serializers into provided
/**
* Util class for injecting new multipart table features serializers into OpenflowJava.
*/
-class MultipartTableFeaturesSerializerInjector {
+final class MultipartTableFeaturesSerializerInjector {
+
+ private MultipartTableFeaturesSerializerInjector() {
+ }
/**
* Injects multipart table features serializers into provided
/**
* Util class for injecting new serializers into OpenflowJava.
*/
-public class SerializerInjector {
+public final class SerializerInjector {
+
+ private SerializerInjector() {
+ }
/**
* Injects serializers into provided
/**
* Utility class for instruction serialization.
*/
-public class InstructionUtil {
+public final class InstructionUtil {
+
+ private InstructionUtil() {
+ }
/**
* Serialize instruction.
@Override
protected OfHeader buildRequest(final Xid xid,
- final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input)
- throws ServiceException {
- final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder =
- new MultipartRequestAggregateCaseBuilder();
+ final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) throws
+ ServiceException {
+ final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder
+ = new MultipartRequestAggregateCaseBuilder();
final MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
final short tableId = MoreObjects.firstNonNull(input.getTableId(), OFConstants.OFPTT_ALL);
mprAggregateRequestBuilder.setTableId(tableId);
if (input.getCookieMask() == null) {
mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
} else {
- mprAggregateRequestBuilder.setCookieMask(MoreObjects.firstNonNull(input.getCookieMask().getValue(),
- OFConstants.DEFAULT_COOKIE_MASK));
+ mprAggregateRequestBuilder.setCookieMask(
+ MoreObjects.firstNonNull(input.getCookieMask().getValue(), OFConstants.DEFAULT_COOKIE_MASK));
}
long outGroup = MoreObjects.firstNonNull(input.getOutGroup(), OFConstants.OFPG_ANY);
mprAggregateRequestBuilder.setOutGroup(outGroup);
FlowCreatorUtil.setWildcardedFlowMatch(version, mprAggregateRequestBuilder);
// Set request body to main multipart request
- multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder
- .build());
+ multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
- final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
- MultipartType.OFPMPAGGREGATE, xid.getValue(), version);
+ final MultipartRequestInputBuilder mprInput = RequestInputUtils
+ .createMultipartHeader(MultipartType.OFPMPAGGREGATE, xid.getValue(), version);
mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
}
@Override
- public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>
- handleAndReply(final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
+ public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> handleAndReply(
+ final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
return Futures.transform(handleServiceCall(input),
- (Function<RpcResult<List<MultipartReply>>,
- RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>) result -> {
+ (Function<RpcResult<List<MultipartReply>>,
+ RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>)
+ result -> {
if (Preconditions.checkNotNull(result).isSuccessful()) {
- final MessageTranslator<MultipartReply, AggregatedFlowStatistics> messageTranslator =
- translatorLibrary
- .lookupTranslator(new TranslatorKey(getVersion(), MultipartReplyAggregateCase.class.getName()));
-
- return RpcResultBuilder
- .success(new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder()
- .setAggregatedFlowStatistics(result
- .getResult()
- .stream()
- .map(multipartReply -> messageTranslator
- .translate(multipartReply, getDeviceInfo(), null))
- .collect(Collectors.toList())))
- .build();
+ final MessageTranslator<MultipartReply, AggregatedFlowStatistics>
+ messageTranslator = translatorLibrary.lookupTranslator(
+ new TranslatorKey(getVersion(),
+ MultipartReplyAggregateCase.class.getName()));
+
+ return RpcResultBuilder.success(
+ new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder()
+ .setAggregatedFlowStatistics(result.getResult().stream()
+ .map(multipartReply ->
+ messageTranslator
+ .translate(
+ multipartReply,
+ getDeviceInfo(),
+ null))
+ .collect(Collectors
+ .toList())))
+ .build();
}
return RpcResultBuilder
- .<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>failed()
- .withRpcErrors(result.getErrors())
- .build();
+ .<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>failed()
+ .withRpcErrors(result.getErrors()).build();
});
}
}
private final SalExperimenterMessageService experimenterMessageService;
public SalBundleServiceImpl(final SalExperimenterMessageService experimenterMessageService) {
- this.experimenterMessageService = Preconditions.checkNotNull(experimenterMessageService,
- "SalExperimenterMessageService can not be null!");
+ this.experimenterMessageService = Preconditions
+ .checkNotNull(experimenterMessageService, "SalExperimenterMessageService can not be null!");
}
@Override
final SendExperimenterInputBuilder experimenterInputBuilder = new SendExperimenterInputBuilder();
experimenterInputBuilder.setNode(input.getNode());
experimenterInputBuilder.setExperimenterMessageOfChoice(
- new BundleControlSalBuilder()
- .setSalControlData(
- new SalControlDataBuilder(input).build()
- )
- .build()
- );
+ new BundleControlSalBuilder().setSalControlData(new SalControlDataBuilder(input).build()).build());
return experimenterMessageService.sendExperimenter(experimenterInputBuilder.build());
}
dataBuilder.setBundleProperty(input.getBundleProperty());
for (Message message : input.getMessages().getMessage()) {
dataBuilder.setBundleInnerMessage(message.getBundleInnerMessage());
- experimenterInputBuilder.setExperimenterMessageOfChoice(bundleAddMessageBuilder
- .setSalAddMessageData(dataBuilder.build()).build());
- ListenableFuture<RpcResult<Void>> res = JdkFutureAdapters.listenInPoolThread(
- experimenterMessageService.sendExperimenter(experimenterInputBuilder.build()));
+ experimenterInputBuilder.setExperimenterMessageOfChoice(
+ bundleAddMessageBuilder.setSalAddMessageData(dataBuilder.build()).build());
+ ListenableFuture<RpcResult<Void>> res = JdkFutureAdapters
+ .listenInPoolThread(experimenterMessageService.sendExperimenter(experimenterInputBuilder.build()));
partialResults.add(res);
}
return processResults(partialResults);
}
- private static Future<RpcResult<Void>> processResults(final List<ListenableFuture<RpcResult<Void>>> partialResults) {
+ private static Future<RpcResult<Void>> processResults(
+ final List<ListenableFuture<RpcResult<Void>>> partialResults) {
final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
Futures.addCallback(Futures.successfulAsList(partialResults), new FutureCallback<List<RpcResult<Void>>>() {
@Override
for (RpcResult<Void> res : results) {
if (res == null) {
errors.add(RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "BundleExtensionService",
- "RpcResult is null."));
+ "RpcResult is null."));
} else if (!res.isSuccessful()) {
errors.addAll(res.getErrors());
}
}
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(Throwable throwable) {
RpcResultBuilder<Void> rpcResultBuilder = RpcResultBuilder.failed();
result.set(rpcResultBuilder.build());
}
.child(Flow.class, new FlowKey(flowDescriptor.getFlowId()));
}
- private class AddFlowCallback implements FutureCallback<RpcResult<AddFlowOutput>> {
+ private final class AddFlowCallback implements FutureCallback<RpcResult<AddFlowOutput>> {
private final AddFlowInput input;
private final FlowRegistryKey flowRegistryKey;
}
}
- private class RemoveFlowCallback implements FutureCallback<RpcResult<RemoveFlowOutput>> {
+ private final class RemoveFlowCallback implements FutureCallback<RpcResult<RemoveFlowOutput>> {
private final RemoveFlowInput input;
private RemoveFlowCallback(final RemoveFlowInput input) {
}
}
- private class UpdateFlowCallback implements FutureCallback<RpcResult<UpdateFlowOutput>> {
+ private final class UpdateFlowCallback implements FutureCallback<RpcResult<UpdateFlowOutput>> {
private final UpdateFlowInput input;
private UpdateFlowCallback(UpdateFlowInput input) {
final UpdateGroupInput updateGroupInput = new UpdateGroupInputBuilder(input)
.setOriginalGroup(new OriginalGroupBuilder(batchGroup.getOriginalBatchedGroup()).build())
.setUpdatedGroup(new UpdatedGroupBuilder(batchGroup.getUpdatedBatchedGroup()).build())
- .setGroupRef(createGroupRef(input.getNode(), batchGroup))
- .setNode(input.getNode())
- .build();
+ .setGroupRef(createGroupRef(input.getNode(), batchGroup)).setNode(input.getNode()).build();
resultsLot.add(JdkFutureAdapters.listenInPoolThread(salGroupService.updateGroup(updateGroupInput)));
}
final Iterable<Group> groups = batchUpdateGroups.stream()
- .map(BatchGroupInputUpdateGrouping::getUpdatedBatchedGroup)
- .collect(Collectors.toList());
+ .map(BatchGroupInputUpdateGrouping::getUpdatedBatchedGroup).collect(Collectors.toList());
- final ListenableFuture<RpcResult<List<BatchFailedGroupsOutput>>> commonResult =
- Futures.transform(Futures.allAsList(resultsLot), GroupUtil.<UpdateGroupOutput>createCumulatingFunction(
- groups, batchUpdateGroups.size()));
+ final ListenableFuture<RpcResult<List<BatchFailedGroupsOutput>>> commonResult = Futures
+ .transform(Futures.allAsList(resultsLot),
+ GroupUtil.<UpdateGroupOutput>createCumulatingFunction(groups, batchUpdateGroups.size()));
- ListenableFuture<RpcResult<UpdateGroupsBatchOutput>> updateGroupsBulkFuture = Futures.transform(
- commonResult, GroupUtil.GROUP_UPDATE_TRANSFORM);
+ ListenableFuture<RpcResult<UpdateGroupsBatchOutput>> updateGroupsBulkFuture = Futures
+ .transform(commonResult, GroupUtil.GROUP_UPDATE_TRANSFORM);
if (input.isBarrierAfter()) {
- updateGroupsBulkFuture = BarrierUtil.chainBarrier(updateGroupsBulkFuture, input.getNode(),
- transactionService, GroupUtil.GROUP_UPDATE_COMPOSING_TRANSFORM);
+ updateGroupsBulkFuture = BarrierUtil
+ .chainBarrier(updateGroupsBulkFuture, input.getNode(), transactionService,
+ GroupUtil.GROUP_UPDATE_COMPOSING_TRANSFORM);
}
return updateGroupsBulkFuture;
final ArrayList<ListenableFuture<RpcResult<AddGroupOutput>>> resultsLot = new ArrayList<>();
for (BatchAddGroups addGroup : input.getBatchAddGroups()) {
final AddGroupInput addGroupInput = new AddGroupInputBuilder(addGroup)
- .setGroupRef(createGroupRef(input.getNode(), addGroup))
- .setNode(input.getNode())
- .build();
+ .setGroupRef(createGroupRef(input.getNode(), addGroup)).setNode(input.getNode()).build();
resultsLot.add(JdkFutureAdapters.listenInPoolThread(salGroupService.addGroup(addGroupInput)));
}
- final ListenableFuture<RpcResult<List<BatchFailedGroupsOutput>>> commonResult =
- Futures.transform(Futures.allAsList(resultsLot),
- GroupUtil.<AddGroupOutput>createCumulatingFunction(input.getBatchAddGroups()));
+ final ListenableFuture<RpcResult<List<BatchFailedGroupsOutput>>> commonResult = Futures
+ .transform(Futures.allAsList(resultsLot),
+ GroupUtil.<AddGroupOutput>createCumulatingFunction(input.getBatchAddGroups()));
- ListenableFuture<RpcResult<AddGroupsBatchOutput>> addGroupsBulkFuture =
- Futures.transform(commonResult, GroupUtil.GROUP_ADD_TRANSFORM);
+ ListenableFuture<RpcResult<AddGroupsBatchOutput>> addGroupsBulkFuture = Futures
+ .transform(commonResult, GroupUtil.GROUP_ADD_TRANSFORM);
if (input.isBarrierAfter()) {
- addGroupsBulkFuture = BarrierUtil.chainBarrier(addGroupsBulkFuture, input.getNode(),
- transactionService, GroupUtil.GROUP_ADD_COMPOSING_TRANSFORM);
+ addGroupsBulkFuture = BarrierUtil.chainBarrier(addGroupsBulkFuture, input.getNode(), transactionService,
+ GroupUtil.GROUP_ADD_COMPOSING_TRANSFORM);
}
return addGroupsBulkFuture;
@Override
public Future<RpcResult<RemoveGroupsBatchOutput>> removeGroupsBatch(final RemoveGroupsBatchInput input) {
- LOG.trace("Removing groups @ {} : {}",
- PathUtil.extractNodeId(input.getNode()),
+ LOG.trace("Removing groups @ {} : {}", PathUtil.extractNodeId(input.getNode()),
input.getBatchRemoveGroups().size());
final ArrayList<ListenableFuture<RpcResult<RemoveGroupOutput>>> resultsLot = new ArrayList<>();
for (BatchRemoveGroups addGroup : input.getBatchRemoveGroups()) {
final RemoveGroupInput removeGroupInput = new RemoveGroupInputBuilder(addGroup)
- .setGroupRef(createGroupRef(input.getNode(), addGroup))
- .setNode(input.getNode())
- .build();
+ .setGroupRef(createGroupRef(input.getNode(), addGroup)).setNode(input.getNode()).build();
resultsLot.add(JdkFutureAdapters.listenInPoolThread(salGroupService.removeGroup(removeGroupInput)));
}
- final ListenableFuture<RpcResult<List<BatchFailedGroupsOutput>>> commonResult =
- Futures.transform(Futures.allAsList(resultsLot),
- GroupUtil.<RemoveGroupOutput>createCumulatingFunction(input.getBatchRemoveGroups()));
+ final ListenableFuture<RpcResult<List<BatchFailedGroupsOutput>>> commonResult = Futures
+ .transform(Futures.allAsList(resultsLot),
+ GroupUtil.<RemoveGroupOutput>createCumulatingFunction(input.getBatchRemoveGroups()));
- ListenableFuture<RpcResult<RemoveGroupsBatchOutput>> removeGroupsBulkFuture =
- Futures.transform(commonResult, GroupUtil.GROUP_REMOVE_TRANSFORM);
+ ListenableFuture<RpcResult<RemoveGroupsBatchOutput>> removeGroupsBulkFuture = Futures
+ .transform(commonResult, GroupUtil.GROUP_REMOVE_TRANSFORM);
if (input.isBarrierAfter()) {
- removeGroupsBulkFuture = BarrierUtil.chainBarrier(removeGroupsBulkFuture, input.getNode(),
- transactionService, GroupUtil.GROUP_REMOVE_COMPOSING_TRANSFORM);
+ removeGroupsBulkFuture = BarrierUtil
+ .chainBarrier(removeGroupsBulkFuture, input.getNode(), transactionService,
+ GroupUtil.GROUP_REMOVE_COMPOSING_TRANSFORM);
}
return removeGroupsBulkFuture;
private static GroupRef createGroupRef(final NodeRef nodeRef, final BatchUpdateGroups batchGroup) {
return GroupUtil.buildGroupPath((InstanceIdentifier<Node>) nodeRef.getValue(),
- batchGroup.getUpdatedBatchedGroup().getGroupId());
+ batchGroup.getUpdatedBatchedGroup().getGroupId());
}
}
@Override
protected OfHeader buildRequest(Xid xid, GetAsyncInput input) throws ServiceException {
- return new GetAsyncInputBuilder()
- .setVersion(getVersion())
- .setXid(xid.getValue())
- .build();
+ return new GetAsyncInputBuilder().setVersion(getVersion()).setXid(xid.getValue()).build();
}
}
\ No newline at end of file
StatisticsContextImpl(@Nonnull final DeviceContext deviceContext,
@Nonnull final ConvertorExecutor convertorExecutor,
@Nonnull final MultipartWriterProvider statisticsWriterProvider,
- @Nonnull final ListeningExecutorService executorService,
- boolean isStatisticsPollingOn,
- boolean isUsingReconciliationFramework,
- long statisticsPollingInterval,
+ @Nonnull final ListeningExecutorService executorService, boolean isStatisticsPollingOn,
+ boolean isUsingReconciliationFramework, long statisticsPollingInterval,
long maximumPollingDelay) {
this.deviceContext = deviceContext;
this.devState = Preconditions.checkNotNull(deviceContext.getDeviceState());
this.isUsingReconciliationFramework = isUsingReconciliationFramework;
statisticsGatheringService = new StatisticsGatheringService<>(this, deviceContext);
- statisticsGatheringOnTheFlyService = new StatisticsGatheringOnTheFlyService<>(this,
- deviceContext, convertorExecutor, statisticsWriterProvider);
+ statisticsGatheringOnTheFlyService = new StatisticsGatheringOnTheFlyService<>(this, deviceContext,
+ convertorExecutor,
+ statisticsWriterProvider);
}
@Override
@Override
public void continueInitializationAfterReconciliation() {
if (deviceContext.initialSubmitTransaction()) {
- contextChainMastershipWatcher.onMasterRoleAcquired(
- deviceInfo,
- ContextChainMastershipState.INITIAL_SUBMIT);
+ contextChainMastershipWatcher.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.INITIAL_SUBMIT);
startGatheringData();
} else {
- contextChainMastershipWatcher.onNotAbleToStartMastershipMandatory(
- deviceInfo,
- "Initial transaction cannot be submitted.");
+ contextChainMastershipWatcher
+ .onNotAbleToStartMastershipMandatory(deviceInfo, "Initial transaction cannot be submitted.");
}
}
StatisticsGatheringUtils.markDeviceStateSnapshotStart(deviceInfo, deviceContext);
// recreate gathering future if it should be recreated
- final ListenableFuture<Boolean> lastDataGathering = Objects.isNull(future) ||
- future.isCancelled() ||
- future.isDone() ?
- Futures.immediateFuture(Boolean.TRUE) :
- future;
+ final ListenableFuture<Boolean> lastDataGathering =
+ Objects.isNull(future) || future.isCancelled() || future.isDone() ? Futures
+ .immediateFuture(Boolean.TRUE) : future;
// build statistics gathering future
- final ListenableFuture<Boolean> newDataGathering = collectingStatType.stream().reduce(
- lastDataGathering,
- this::statChainFuture,
- (a, b) -> Futures.transformAsync(a, result -> b));
+ final ListenableFuture<Boolean> newDataGathering = collectingStatType.stream()
+ .reduce(lastDataGathering, this::statChainFuture,
+ (listenableFuture, asyn) -> Futures.transformAsync(listenableFuture, result -> asyn));
// write end timestamp to state snapshot container
Futures.addCallback(newDataGathering, new FutureCallback<Boolean>() {
}
@Override
- public void onFailure(final Throwable t) {
- if (!(t instanceof TransactionChainClosedException)) {
+ public void onFailure(final Throwable throwable) {
+ if (!(throwable instanceof TransactionChainClosedException)) {
StatisticsGatheringUtils.markDeviceStateSnapshotEnd(deviceInfo, deviceContext, false);
}
}
private ListenableFuture<Boolean> statChainFuture(final ListenableFuture<Boolean> prevFuture,
final MultipartType multipartType) {
- if (ConnectionContext.CONNECTION_STATE.RIP.equals(deviceContext.getPrimaryConnectionContext().getConnectionState())) {
+ if (ConnectionContext.CONNECTION_STATE.RIP
+ .equals(deviceContext.getPrimaryConnectionContext().getConnectionState())) {
final String errMsg = String
.format("Device connection for node %s doesn't exist anymore. Primary connection status : %s",
getDeviceInfo().getNodeId(),
final boolean supported = collectingStatType.contains(multipartType);
// TODO: Refactor twice sending deviceContext into gatheringStatistics
- return supported ? StatisticsGatheringUtils.gatherStatistics(
- onTheFly ? statisticsGatheringOnTheFlyService : statisticsGatheringService,
- getDeviceInfo(),
- multipartType,
- deviceContext,
- deviceContext,
- convertorExecutor,
- statisticsWriterProvider,
- executorService) : Futures.immediateFuture(Boolean.FALSE);
+ return supported ? StatisticsGatheringUtils
+ .gatherStatistics(onTheFly ? statisticsGatheringOnTheFlyService : statisticsGatheringService,
+ getDeviceInfo(), multipartType, deviceContext, deviceContext, convertorExecutor,
+ statisticsWriterProvider, executorService) : Futures
+ .immediateFuture(Boolean.FALSE);
});
}
}
LOG.info("Starting statistics gathering for node {}", deviceInfo);
- final StatisticsPollingService statisticsPollingService = new StatisticsPollingService(timeCounter,
- statisticsPollingInterval, maximumPollingDelay,
- StatisticsContextImpl.this::gatherDynamicData);
+ final StatisticsPollingService statisticsPollingService =
+ new StatisticsPollingService(timeCounter,
+ statisticsPollingInterval,
+ maximumPollingDelay,
+ StatisticsContextImpl.this::gatherDynamicData);
schedulingEnabled.set(true);
statisticsPollingService.startAsync();
LOG.info("Stopping running statistics gathering for node {}", deviceInfo);
cancelLastDataGathering();
- return Optional
- .ofNullable(statisticsPollingService.getAndSet(null))
- .map(StatisticsPollingService::stop)
+ return Optional.ofNullable(statisticsPollingService.getAndSet(null)).map(StatisticsPollingService::stop)
.orElseGet(() -> Futures.immediateFuture(null));
}
}
@VisibleForTesting
- void setStatisticsGatheringOnTheFlyService(final StatisticsGatheringOnTheFlyService<T> statisticsGatheringOnTheFlyService) {
+ void setStatisticsGatheringOnTheFlyService(
+ final StatisticsGatheringOnTheFlyService<T> statisticsGatheringOnTheFlyService) {
this.statisticsGatheringOnTheFlyService = statisticsGatheringOnTheFlyService;
}
private final class InitialSubmitCallback implements FutureCallback<Boolean> {
@Override
public void onSuccess(@Nullable final Boolean result) {
- contextChainMastershipWatcher.onMasterRoleAcquired(
- deviceInfo,
- ContextChainMastershipState.INITIAL_GATHERING
- );
+ contextChainMastershipWatcher
+ .onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.INITIAL_GATHERING);
if (!isUsingReconciliationFramework) {
continueInitializationAfterReconciliation();
@Override
public void onFailure(@Nonnull final Throwable throwable) {
- contextChainMastershipWatcher.onNotAbleToStartMastershipMandatory(
- deviceInfo,
- "Initial gathering statistics unsuccessful: " + throwable.getMessage());
+ contextChainMastershipWatcher.onNotAbleToStartMastershipMandatory(deviceInfo,
+ "Initial gathering statistics "
+ + "unsuccessful: "
+ + throwable.getMessage());
}
}
-}
\ No newline at end of file
+}
}
static <T extends OfHeader> ListenableFuture<Boolean> gatherStatistics(
- final StatisticsGatherer<T> statisticsGatheringService,
- final DeviceInfo deviceInfo,
- final MultipartType type,
- final TxFacade txFacade,
- final DeviceRegistry registry,
- final ConvertorExecutor convertorExecutor,
- final MultipartWriterProvider statisticsWriterProvider,
+ final StatisticsGatherer<T> statisticsGatheringService, final DeviceInfo deviceInfo,
+ final MultipartType type, final TxFacade txFacade, final DeviceRegistry registry,
+ final ConvertorExecutor convertorExecutor, final MultipartWriterProvider statisticsWriterProvider,
final ListeningExecutorService executorService) {
- return Futures.transformAsync(
- statisticsGatheringService.getStatisticsOfType(
- new EventIdentifier(QUEUE2_REQCTX + type.toString(), deviceInfo.getNodeId().toString()),
- type),
- rpcResult -> executorService.submit(() -> {
- final boolean rpcResultIsNull = rpcResult == null;
-
- if (!rpcResultIsNull && rpcResult.isSuccessful()) {
- LOG.debug("Stats reply successfully received for node {} of type {}",
- deviceInfo.getNodeId(), type);
-
- // TODO: in case the result value is null then multipart data probably got processed
- // TODO: on the fly. This contract should by clearly stated and enforced.
- // TODO: Now simple true value is returned
- if (Objects.nonNull(rpcResult.getResult()) && !rpcResult.getResult().isEmpty()) {
- try {
- final List<DataContainer> allMultipartData = rpcResult
- .getResult()
- .stream()
- .map(reply -> MultipartReplyTranslatorUtil
- .translate(reply, deviceInfo, convertorExecutor, null))
- .filter(java.util.Optional::isPresent)
- .map(java.util.Optional::get)
- .collect(Collectors.toList());
-
- return processStatistics(
- type,
- allMultipartData,
- txFacade,
- registry,
- deviceInfo,
- statisticsWriterProvider);
- } catch (final Exception e) {
- LOG.warn("Stats processing of type {} for node {} failed with error: {}",
- type, deviceInfo, e);
- }
- } else {
- LOG.debug("Stats reply was empty for node {} of type {}", deviceInfo.getNodeId(), type);
- }
+ return Futures.transformAsync(statisticsGatheringService.getStatisticsOfType(
+ new EventIdentifier(QUEUE2_REQCTX + type.toString(), deviceInfo.getNodeId().toString()), type),
+ rpcResult -> executorService.submit(() -> {
+ final boolean rpcResultIsNull = rpcResult == null;
+
+ if (!rpcResultIsNull && rpcResult.isSuccessful()) {
+ LOG.debug("Stats reply successfully received for node {} of type {}", deviceInfo.getNodeId(), type);
+ // TODO: in case the result value is null then multipart data probably got processed
+ // TODO: on the fly. This contract should by clearly stated and enforced.
+ // TODO: Now simple true value is returned
+ if (Objects.nonNull(rpcResult.getResult()) && !rpcResult.getResult().isEmpty()) {
+ final List<DataContainer> allMultipartData = rpcResult.getResult().stream()
+ .map(reply -> MultipartReplyTranslatorUtil
+ .translate(reply, deviceInfo, convertorExecutor, null))
+ .filter(java.util.Optional::isPresent).map(java.util.Optional::get)
+ .collect(Collectors.toList());
+
+ return processStatistics(type, allMultipartData, txFacade, registry, deviceInfo,
+ statisticsWriterProvider);
} else {
- LOG.warn("Stats reply FAILED for node {} of type {}: {}", deviceInfo.getNodeId(), type,
- rpcResultIsNull ? "" : rpcResult.getErrors());
+ LOG.debug("Stats reply was empty for node {} of type {}", deviceInfo.getNodeId(), type);
}
-
- return false;
- }));
+ } else {
+ LOG.warn("Stats reply FAILED for node {} of type {}: {}", deviceInfo.getNodeId(), type,
+ rpcResultIsNull ? "" : rpcResult.getErrors());
+ }
+ return false;
+ }));
}
- private static boolean processStatistics(final MultipartType type,
- final List<? extends DataContainer> statistics,
- final TxFacade txFacade,
- final DeviceRegistry deviceRegistry,
+ private static boolean processStatistics(final MultipartType type, final List<? extends DataContainer> statistics,
+ final TxFacade txFacade, final DeviceRegistry deviceRegistry,
final DeviceInfo deviceInfo,
final MultipartWriterProvider statisticsWriterProvider) {
- final InstanceIdentifier<FlowCapableNode> instanceIdentifier = deviceInfo
- .getNodeInstanceIdentifier()
+ final InstanceIdentifier<FlowCapableNode> instanceIdentifier = deviceInfo.getNodeInstanceIdentifier()
.augmentation(FlowCapableNode.class);
switch (type) {
return true;
}
- LOG.warn("Stats processing of type {} for node {} "
- + "failed during write-to-tx step", type, deviceInfo);
+ LOG.warn("Stats processing of type {} for node {} " + "failed during write-to-tx step", type, deviceInfo);
return false;
}
@SuppressWarnings("checkstyle:IllegalCatch")
- private static boolean writeStatistics(final MultipartType type,
- final List<? extends DataContainer> statistics,
+ private static boolean writeStatistics(final MultipartType type, final List<? extends DataContainer> statistics,
final DeviceInfo deviceInfo,
final MultipartWriterProvider statisticsWriterProvider) {
final AtomicBoolean result = new AtomicBoolean(false);
}
}));
} catch (final Exception ex) {
- LOG.warn("Stats processing of type {} for node {} "
- + "failed during write-to-tx step", type, deviceInfo, ex);
+ LOG.warn("Stats processing of type {} for node {} " + "failed during write-to-tx step", type, deviceInfo,
+ ex);
}
return result.get();
final ReadOnlyTransaction readTx = txFacade.getReadTransaction();
try {
- Futures.transform(Futures
- .catchingAsync(readTx.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier), Throwable.class,
- t -> {
+ Futures.transform(Futures.catchingAsync(readTx.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier),
+ Throwable.class, throwable -> {
// we wish to close readTx for fallBack
- readTx.close();
- return Futures.immediateFailedFuture(t);
- }), (Function<Optional<FlowCapableNode>, Void>)
- flowCapNodeOpt -> {
+ readTx.close();
+ return Futures.immediateFailedFuture(throwable);
+ }), (Function<Optional<FlowCapableNode>, Void>) flowCapNodeOpt -> {
// we have to read actual tables with all information before we set empty Flow list,
// merge is expensive and not applicable for lists
if (flowCapNodeOpt != null && flowCapNodeOpt.isPresent()) {
for (final Table tableData : flowCapNodeOpt.get().getTable()) {
- final Table table =
- new TableBuilder(tableData).setFlow(Collections.emptyList()).build();
- final InstanceIdentifier<Table> iiToTable =
- instanceIdentifier.child(Table.class, tableData.getKey());
+ final Table table = new TableBuilder(tableData).setFlow(Collections.emptyList()).build();
+ final InstanceIdentifier<Table> iiToTable = instanceIdentifier
+ .child(Table.class, tableData.getKey());
txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, iiToTable, table);
}
}
-
readTx.close();
return null;
}).get();
public static void deleteAllKnownMeters(final TxFacade txFacade,
final InstanceIdentifier<FlowCapableNode> instanceIdentifier,
final DeviceMeterRegistry meterRegistry) {
- meterRegistry.forEach(meterId -> txFacade
- .addDeleteToTxChain(
- LogicalDatastoreType.OPERATIONAL,
- instanceIdentifier.child(Meter.class, new MeterKey(meterId))));
+ meterRegistry.forEach(meterId -> txFacade.addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL,
+ instanceIdentifier.child(Meter.class,
+ new MeterKey(meterId))));
}
public static void deleteAllKnownGroups(final TxFacade txFacade,
final InstanceIdentifier<FlowCapableNode> instanceIdentifier,
final DeviceGroupRegistry groupRegistry) {
- groupRegistry.forEach(groupId -> txFacade
- .addDeleteToTxChain(
- LogicalDatastoreType.OPERATIONAL,
- instanceIdentifier.child(Group.class, new GroupKey(groupId))));
+ groupRegistry.forEach(groupId -> txFacade.addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL,
+ instanceIdentifier.child(Group.class,
+ new GroupKey(groupId))));
}
/**
* Writes snapshot gathering start timestamp + cleans end mark.
*
* @param deviceInfo device info
- * @param txFacade tx manager
+ * @param txFacade tx manager
*/
static void markDeviceStateSnapshotStart(final DeviceInfo deviceInfo, final TxFacade txFacade) {
final InstanceIdentifier<FlowCapableStatisticsGatheringStatus> statusPath = deviceInfo
final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_AND_TIME_FORMAT);
final FlowCapableStatisticsGatheringStatus gatheringStatus = new FlowCapableStatisticsGatheringStatusBuilder()
.setSnapshotGatheringStatusStart(new SnapshotGatheringStatusStartBuilder()
- .setBegin(new DateAndTime(simpleDateFormat.format(new Date())))
- .build())
+ .setBegin(new DateAndTime(simpleDateFormat.format(new Date())))
+ .build())
.setSnapshotGatheringStatusEnd(null) // TODO: reconsider if really need to clean end mark here
.build();
try {
* Writes snapshot gathering end timestamp + outcome.
*
* @param deviceInfo device info
- * @param txFacade tx manager
- * @param succeeded outcome of currently finished gathering
+ * @param txFacade tx manager
+ * @param succeeded outcome of currently finished gathering
*/
static void markDeviceStateSnapshotEnd(final DeviceInfo deviceInfo, final TxFacade txFacade,
final boolean succeeded) {
- final InstanceIdentifier<SnapshotGatheringStatusEnd> statusEndPath = deviceInfo
- .getNodeInstanceIdentifier().augmentation(FlowCapableStatisticsGatheringStatus.class)
- .child(SnapshotGatheringStatusEnd.class);
+ final InstanceIdentifier<SnapshotGatheringStatusEnd> statusEndPath = deviceInfo.getNodeInstanceIdentifier()
+ .augmentation(FlowCapableStatisticsGatheringStatus.class).child(SnapshotGatheringStatusEnd.class);
final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_AND_TIME_FORMAT);
final SnapshotGatheringStatusEnd gatheringStatus = new SnapshotGatheringStatusEndBuilder()
- .setEnd(new DateAndTime(simpleDateFormat.format(new Date())))
- .setSucceeded(succeeded)
- .build();
+ .setEnd(new DateAndTime(simpleDateFormat.format(new Date()))).setSucceeded(succeeded).build();
try {
txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, statusEndPath, gatheringStatus);
} catch (TransactionChainClosedException e) {
switch (targetWorkMode) {
case COLLECTALL:
context.enableGathering();
+ // FIXME: is it a genuine fall through or an error?
case FULLYDISABLED:
context.disableGathering();
break;
.createDefaultProvider(deviceContext);
final StatisticsContext statisticsContext =
- deviceContext.canUseSingleLayerSerialization() ?
- new StatisticsContextImpl<MultipartReply>(
+ deviceContext.canUseSingleLayerSerialization()
+ ? new StatisticsContextImpl<MultipartReply>(
deviceContext,
converterExecutor,
statisticsWriterProvider,
import java.util.Map;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
-public class SessionStatistics {
+public final class SessionStatistics {
+
+ private SessionStatistics() {
+ }
private static final Map<String, Map<ConnectionStatus, EventCounter>> SESSION_EVENTS = new HashMap<>();
/**
* Pulled out meter stats to notification transformation.
*/
-public class MeterStatisticsToNotificationTransformer {
+public final class MeterStatisticsToNotificationTransformer {
private MeterStatisticsToNotificationTransformer() {
// Hide implicit constructor
/**
* Pulled out port stats to notification transformation.
*/
-public class NodeConnectorStatisticsToNotificationTransformer {
+public final class NodeConnectorStatisticsToNotificationTransformer {
private NodeConnectorStatisticsToNotificationTransformer() {
// Hide implicit constructor
/**
* Pulled out queue stats to notification transformation.
*/
-public class QueueStatisticsToNotificationTransformer {
+public final class QueueStatisticsToNotificationTransformer {
private QueueStatisticsToNotificationTransformer() {
// Hide implicit constructor
* #{@link org.opendaylight.openflowplugin.impl.statistics.services.direct.OpendaylightDirectStatisticsServiceProvider}
* with all multi-layer services already in.
*/
-public class MultiLayerDirectStatisticsProviderInitializer {
+public final class MultiLayerDirectStatisticsProviderInitializer {
+
+ private MultiLayerDirectStatisticsProviderInitializer() {
+ }
public static OpendaylightDirectStatisticsServiceProvider createProvider(
final RequestContextStack requestContextStack,
* #{@link org.opendaylight.openflowplugin.impl.statistics.services.direct.OpendaylightDirectStatisticsServiceProvider}
* with all multi-layer services already in.
*/
-public class SingleLayerDirectStatisticsProviderInitializer {
+public final class SingleLayerDirectStatisticsProviderInitializer {
+
+ private SingleLayerDirectStatisticsProviderInitializer() {
+ }
public static OpendaylightDirectStatisticsServiceProvider createProvider(
final RequestContextStack requestContextStack,
}
@Override
- public PacketReceived translate(final PacketInMessage input,
- final DeviceInfo deviceInfo,
+ public PacketReceived translate(final PacketInMessage input, final DeviceInfo deviceInfo,
final Object connectionDistinguisher) {
PacketReceivedBuilder packetReceivedBuilder = new PacketReceivedBuilder();
}
if (input.getMatch() != null) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match packetInMatch =
- getPacketInMatch(input, datapathId);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match packetInMatch
+ = getPacketInMatch(input, datapathId);
packetReceivedBuilder.setMatch(packetInMatch);
}
}
@VisibleForTesting
- org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match
- getPacketInMatch(final PacketInMessage input, final BigInteger datapathId) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match getPacketInMatch(
+ final PacketInMessage input, final BigInteger datapathId) {
- final VersionDatapathIdConvertorData datapathIdConvertorData =
- new VersionDatapathIdConvertorData(input.getVersion());
+ final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(
+ input.getVersion());
datapathIdConvertorData.setDatapathId(datapathId);
final Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder>
matchOptional = convertorExecutor.convert(input.getMatch(), datapathIdConvertorData);
- final MatchBuilder matchBuilder = matchOptional.map(matchBuilder1 -> new MatchBuilder(matchBuilder1.build())).orElseGet(MatchBuilder::new);
+ final MatchBuilder matchBuilder = matchOptional.map(matchBuilder1 -> new MatchBuilder(matchBuilder1.build()))
+ .orElseGet(MatchBuilder::new);
final AugmentTuple<org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match>
- matchExtensionWrap = MatchExtensionHelper.processAllExtensions(
- input.getMatch().getMatchEntry(),
- OpenflowVersion.get(input.getVersion()),
- MatchPath.PACKETRECEIVED_MATCH);
+ matchExtensionWrap = MatchExtensionHelper
+ .processAllExtensions(input.getMatch().getMatchEntry(), OpenflowVersion.get(input.getVersion()),
+ MatchPath.PACKETRECEIVED_MATCH);
if (matchExtensionWrap != null) {
matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(),
import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
-public class MdSalRegistrationUtils {
+public final class MdSalRegistrationUtils {
//TODO: Make one register and one unregister method for all services
private MdSalRegistrationUtils() {
public abstract class MessageFactory {
/**
+ * Creates hello input.
+ *
* @param helloVersion openflow version for hello message to send to switch
* @param helloXid transaction id for hello message
* @return HelloInput without elements
}
/**
- * @param highestVersion highest openflow version
- * @param xid transaction id
- * @return builder with prepared header
- */
- private static HelloInputBuilder prepareHelloInputBuilder(
- short highestVersion, long xid) {
- HelloInputBuilder helloInputbuilder = new HelloInputBuilder();
- helloInputbuilder.setVersion(highestVersion);
- helloInputbuilder.setXid(xid);
- return helloInputbuilder;
- }
-
- /**
+ * Creates hello input.
+ *
* @param helloVersion openflow version for hello message to send to switch
* @param helloXid transaction id for hello message
* @param versionOrder list of openflow version in order
}
/**
+ * Builder.
+ *
+ * @param highestVersion highest openflow version
+ * @param xid transaction id
+ * @return builder with prepared header
+ */
+ private static HelloInputBuilder prepareHelloInputBuilder(
+ short highestVersion, long xid) {
+ HelloInputBuilder helloInputbuilder = new HelloInputBuilder();
+ helloInputbuilder.setVersion(highestVersion);
+ helloInputbuilder.setXid(xid);
+ return helloInputbuilder;
+ }
+
+ /**
+ * Lists all versions.
+ *
* @param elements list of versions
* @return version boolean list
*/
/**
* Created by Tomas Slusny on 23.3.2016.
*/
-public class NodeConnectorRefToPortTranslator {
+public final class NodeConnectorRefToPortTranslator {
+
+ private NodeConnectorRefToPortTranslator() {
+ }
+
/**
* Converts {@link PacketIn} to {@link NodeConnectorRef}.
* @param packetIn Packet input
}
/**
+ * Get MDSAL packet-in reason.
+ *
* @param reason openflow java packet in reason
* @return corresponding MD-SAL reason class for given OF-API reason
*/
- public static Class<? extends PacketInReason> getMdSalPacketInReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason reason) {
+ public static Class<? extends PacketInReason> getMdSalPacketInReason(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason reason) {
Class<? extends PacketInReason> resultReason = PacketInReason.class;
- if (reason.equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason.OFPRNOMATCH)) {
+ if (reason
+ .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason
+ .OFPRNOMATCH)) {
resultReason = NoMatch.class;
- } else if (reason.equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason.OFPRINVALIDTTL)) {
+ } else if (reason
+ .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason
+ .OFPRINVALIDTTL)) {
resultReason = InvalidTtl.class;
- } else if (reason.equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason.OFPRACTION)) {
+ } else if (reason
+ .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason
+ .OFPRACTION)) {
resultReason = SendToController.class;
}
-
return resultReason;
}
-
}
/**
* Purpose: utility class providing path and {@link InstanceIdentifier} tools.
*/
-public class PathUtil {
+public final class PathUtil {
+
private PathUtil() {
throw new IllegalStateException("This class should not be instantiated.");
}
public abstract class PortTranslatorUtil {
private static final Logger LOG = LoggerFactory.getLogger(PortTranslatorUtil.class);
- public static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures translatePortFeatures(final PortFeatures apf) {
+ public static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures
+ translatePortFeatures(
+ final PortFeatures apf) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures napf = null;
if (apf != null) {
napf = new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures(
return napf;
}
- public static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures translatePortFeatures(
+ public static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures
+ translatePortFeatures(
final PortFeaturesV10 apf) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures napf = null;
if (apf != null) {
apf.is_10gbFd(), //_tenGbFd
apf.is_10mbFd(), //_tenMbFd
apf.is_10mbHd()//_tenMbHd
- );
+ );
}
return napf;
}
return nstate.build();
}
- public static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig translatePortConfig(final PortConfig pc) {
+ public static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig
+ translatePortConfig(
+ final PortConfig pc) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig npc = null;
if (pc != null) {
- npc = new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig(pc.isNoFwd(),
- pc.isNoPacketIn(), pc.isNoRecv(), pc.isPortDown());
+ npc = new org.opendaylight.yang.gen.v1.urn.opendaylight
+ .flow.types.port.rev130925.PortConfig(pc.isNoFwd(),pc.isNoPacketIn(),pc.isNoRecv(),pc.isPortDown());
}
return npc;
}
- public static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig translatePortConfig(
+ public static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig
+ translatePortConfig(
final PortConfigV10 pc) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig npc = null;
if (pc != null) {
- npc = new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig(pc.isNoFwd(),
- pc.isNoPacketIn(), pc.isNoRecv(), pc.isPortDown());
+ npc = new org.opendaylight.yang.gen.v1.urn.opendaylight
+ .flow.types.port.rev130925.PortConfig(pc.isNoFwd(),pc.isNoPacketIn(),pc.isNoRecv(),pc.isPortDown());
}
return npc;
}
- public static NodeConnectorUpdated translatePort(final Short version, final BigInteger datapathId, final Long portNumber, final PortGrouping port) {
+ public static NodeConnectorUpdated translatePort(final Short version, final BigInteger datapathId,
+ final Long portNumber, final PortGrouping port) {
OpenflowVersion ofVersion = OpenflowVersion.get(version);
- NodeConnectorUpdatedBuilder builder = InventoryDataServiceUtil
+ final NodeConnectorUpdatedBuilder builder = InventoryDataServiceUtil
.nodeConnectorUpdatedBuilderFromDatapathIdPortNo(datapathId, port.getPortNo(), ofVersion);
FlowCapableNodeConnectorUpdatedBuilder fcncub = new FlowCapableNodeConnectorUpdatedBuilder();
if (ofVersion == OpenflowVersion.OF13) {
return builder.build();
}
- public static NodeConnectorRemoved translatePortRemoved(final Short version, final BigInteger datapathId, final Long portNumber, final PortGrouping port) {
+ public static NodeConnectorRemoved translatePortRemoved(final Short version, final BigInteger datapathId,
+ final Long portNumber, final PortGrouping port) {
OpenflowVersion ofVersion = OpenflowVersion.get(version);
NodeConnectorRemovedBuilder builder = new NodeConnectorRemovedBuilder();
- builder.setNodeConnectorRef(InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(datapathId, portNumber, ofVersion));
+ builder.setNodeConnectorRef(
+ InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(datapathId, portNumber, ofVersion));
return builder.build();
}
}
import org.slf4j.LoggerFactory;
/**
- * threadPoolExecutor implementation logging exceptions thrown by threads
+ * threadPoolExecutor implementation logging exceptions thrown by threads.
*/
public class ThreadPoolLoggingExecutor extends ThreadPoolExecutor {
private static final Logger LOG = LoggerFactory.getLogger(ThreadPoolLoggingExecutor.class);
/**
+ * Logging executor.
+ *
* @param corePoolSize thread pool size
* @param maximumPoolSize maximum pool size
* @param keepAliveTime keep alive time
* @param workQueue task queue
* @param poolName thread name prefix
*/
- public ThreadPoolLoggingExecutor(int corePoolSize, int maximumPoolSize,
- long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue,
- final String poolName) {
+ public ThreadPoolLoggingExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit,
+ BlockingQueue<Runnable> workQueue, final String poolName) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue,
- new ThreadFactoryBuilder().setNameFormat(poolName + "-%d").build());
+ new ThreadFactoryBuilder().setNameFormat(poolName + "-%d").build());
}
@Override
- protected void afterExecute(Runnable r, Throwable t) {
- super.afterExecute(r, t);
+ protected void afterExecute(Runnable runnable, Throwable throwable) {
+ super.afterExecute(runnable, throwable);
// in case of executing pure Runnable
- if (t != null) {
- LOG.warn("thread in pool stopped with error", t);
+ if (throwable != null) {
+ LOG.warn("thread in pool stopped with error", throwable);
}
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder;
-public class MsgGeneratorTestUtils {
+public final class MsgGeneratorTestUtils {
private MsgGeneratorTestUtils() {
throw new UnsupportedOperationException("Test Utility class");
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
/**
- * Tests for setting switch features for different version of OF plugin
+ * Tests for setting switch features for different version of OF plugin.
*
* @author jsebin
- *
*/
public class SwitchFeaturesUtilTest {
/**
- * initialization of {@link org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder GetFeaturesOutputBuilder}
- * and {@link SwitchFeaturesUtil SwitchFeaturesUtil}
- * @throws Exception
+ * Initialization of
+ * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
+ * .GetFeaturesOutputBuilder GetFeaturesOutputBuilder}
+ * and {@link SwitchFeaturesUtil SwitchFeaturesUtil}.
*/
@Before
public void setUp() throws Exception {
swUtil = SwitchFeaturesUtil.getInstance();
}
- /**
- * @throws Exception
- */
@After
public void tearDown() throws Exception {
featuresOutputBuilder = null;
/**
* Test method for
* {@link SwitchFeaturesUtil#buildSwitchFeatures} for OF 1.0 version
- * and switch feature capabilities
+ * and switch feature capabilities.
* .
*/
@Test
@Before
public void setUp() throws Exception {
final ReadOnlyTransaction readOnlyTx = Mockito.mock(ReadOnlyTransaction.class);
- final CheckedFuture<Optional<Node>, ReadFailedException> noExistNodeFuture =
- Futures.immediateCheckedFuture(Optional.<Node>absent());
+ final CheckedFuture<Optional<Node>, ReadFailedException> noExistNodeFuture = Futures
+ .immediateCheckedFuture(Optional.<Node>absent());
Mockito.when(readOnlyTx.read(LogicalDatastoreType.OPERATIONAL, nodeKeyIdent)).thenReturn(noExistNodeFuture);
Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTx);
Mockito.when(dataBroker.createTransactionChain(Matchers.any(TransactionChainListener.class)))
}
/**
- * test of {@link TransactionChainManager#submitTransaction()}
- * @throws Exception
+ * Tests transaction submit {@link TransactionChainManager#submitTransaction()}.
*/
@Test
public void testSubmitTransaction() throws Exception {
}
/**
- * test of {@link TransactionChainManager#submitTransaction()}: no submit, never enabled
- * @throws Exception
+ * test of {@link TransactionChainManager#submitTransaction()}: no submit, never enabled.
*/
@Test
public void testSubmitTransaction1() throws Exception {
@Test
public void testSubmitTransactionFailed() throws Exception {
- Mockito.when(writeTx.submit()).thenReturn(Futures.<Void, TransactionCommitFailedException>immediateFailedCheckedFuture(new TransactionCommitFailedException("mock")));
+ Mockito.when(writeTx.submit()).thenReturn(
+ Futures.<Void, TransactionCommitFailedException>immediateFailedCheckedFuture(
+ new TransactionCommitFailedException("mock")));
final Node data = new NodeBuilder().setId(nodeId).build();
txChainManager.initialSubmitWriteTransaction();
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
@Test
public void testOnTransactionChainFailed() throws Exception {
- txChainManager.onTransactionChainFailed(txChain, Mockito.mock(AsyncTransaction.class), Mockito.mock(Throwable.class));
+ txChainManager
+ .onTransactionChainFailed(txChain, Mockito.mock(AsyncTransaction.class), Mockito.mock(Throwable.class));
Mockito.verify(txChain).close();
Mockito.verify(dataBroker, Mockito.times(2)).createTransactionChain(txChainManager);
}
@Test
public void testDeactivateTransactionChainManagerFailed() throws Exception {
- Mockito.when(writeTx.submit())
- .thenReturn(Futures.<Void, TransactionCommitFailedException>immediateFailedCheckedFuture(
+ Mockito.when(writeTx.submit()).thenReturn(
+ Futures.<Void, TransactionCommitFailedException>immediateFailedCheckedFuture(
new TransactionCommitFailedException("mock")));
final Node data = new NodeBuilder().setId(nodeId).build();
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
/**
* Flow building helper.
*/
-public class TestFlowHelper {
+public final class TestFlowHelper {
+
+ private TestFlowHelper() {
+ }
+
/**
* Creates flow and statistics builder.
* @param index data seed
service.addBundleMessages(input);
for (Message msg : innerMessages) {
Mockito.verify(experimenterMessageService)
- .sendExperimenter(
- experimenterBuilder.setExperimenterMessageOfChoice(
- addMessageBuilder
- .setSalAddMessageData(
- dataBuilder.setNode(NODE_REF).setBundleInnerMessage(msg.getBundleInnerMessage()).build()
- ).build()
- ).build()
- );
+ .sendExperimenter(experimenterBuilder
+ .setExperimenterMessageOfChoice(addMessageBuilder
+ .setSalAddMessageData(
+ dataBuilder.setNode(NODE_REF).setBundleInnerMessage(
+ msg.getBundleInnerMessage())
+ .build())
+ .build()).build());
}
}
private static List<Message> createMessages() {
List<Message> messages = new ArrayList<>();
- messages.add(new MessageBuilder().setNode(NODE_REF).setBundleInnerMessage(new BundleAddFlowCaseBuilder().build()).build());
- messages.add(new MessageBuilder().setNode(NODE_REF).setBundleInnerMessage(new BundleUpdateFlowCaseBuilder().build()).build());
- messages.add(new MessageBuilder().setNode(NODE_REF).setBundleInnerMessage(new BundleRemoveFlowCaseBuilder().build()).build());
- messages.add(new MessageBuilder().setNode(NODE_REF).setBundleInnerMessage(new BundleAddGroupCaseBuilder().build()).build());
- messages.add(new MessageBuilder().setNode(NODE_REF).setBundleInnerMessage(new BundleUpdateGroupCaseBuilder().build()).build());
- messages.add(new MessageBuilder().setNode(NODE_REF).setBundleInnerMessage(new BundleRemoveGroupCaseBuilder().build()).build());
- messages.add(new MessageBuilder().setNode(NODE_REF).setBundleInnerMessage(new BundleUpdatePortCaseBuilder().build()).build());
+ messages.add(
+ new MessageBuilder().setNode(NODE_REF).setBundleInnerMessage(new BundleAddFlowCaseBuilder().build())
+ .build());
+ messages.add(
+ new MessageBuilder().setNode(NODE_REF).setBundleInnerMessage(new BundleUpdateFlowCaseBuilder().build())
+ .build());
+ messages.add(
+ new MessageBuilder().setNode(NODE_REF).setBundleInnerMessage(new BundleRemoveFlowCaseBuilder().build())
+ .build());
+ messages.add(
+ new MessageBuilder().setNode(NODE_REF).setBundleInnerMessage(new BundleAddGroupCaseBuilder().build())
+ .build());
+ messages.add(
+ new MessageBuilder().setNode(NODE_REF).setBundleInnerMessage(new BundleUpdateGroupCaseBuilder().build())
+ .build());
+ messages.add(
+ new MessageBuilder().setNode(NODE_REF).setBundleInnerMessage(new BundleRemoveGroupCaseBuilder().build())
+ .build());
+ messages.add(
+ new MessageBuilder().setNode(NODE_REF).setBundleInnerMessage(new BundleUpdatePortCaseBuilder().build())
+ .build());
return messages;
}
}
private void initStatisticsContext() {
- statisticsContext = new StatisticsContextImpl<>(
- mockedDeviceContext, convertorManager,
- MultipartWriterProviderFactory.createDefaultProvider(mockedDeviceContext),
- MoreExecutors.newDirectExecutorService(),
- true,
- false, 3000, 50000);
+ statisticsContext = new StatisticsContextImpl<>(mockedDeviceContext, convertorManager,
+ MultipartWriterProviderFactory
+ .createDefaultProvider(mockedDeviceContext),
+ MoreExecutors.newDirectExecutorService(), true, false, 3000,
+ 50000);
statisticsContext.setStatisticsGatheringService(mockedStatisticsGatheringService);
statisticsContext.setStatisticsGatheringOnTheFlyService(mockedStatisticsOnFlyGatheringService);
}
/**
- * There is nothing to check in close method
+ * There is nothing to check in close method.
*/
@Test
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void testClose() throws Exception {
- final StatisticsContextImpl<MultipartReply> statisticsContext = new StatisticsContextImpl<>(
- mockedDeviceContext, convertorManager,
- MultipartWriterProviderFactory.createDefaultProvider(mockedDeviceContext),
- MoreExecutors.newDirectExecutorService(),
- true, false, 3000, 50000);
+ final StatisticsContextImpl<MultipartReply> statisticsContext =
+ new StatisticsContextImpl<>(mockedDeviceContext,
+ convertorManager,
+ MultipartWriterProviderFactory
+ .createDefaultProvider(mockedDeviceContext),
+ MoreExecutors.newDirectExecutorService(),
+ true,
+ false,
+ 3000,50000);
final RequestContext<Object> requestContext = statisticsContext.createRequestContext();
statisticsContext.close();
when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(DUMMY_NODE_ID);
initStatisticsContext();
- when(mockedStatisticsGatheringService.getStatisticsOfType(Matchers.any(EventIdentifier.class),
- Matchers.any(MultipartType.class)))
- .thenReturn(
- Futures.immediateFuture(RpcResultBuilder.success(Collections.<MultipartReply>emptyList())
- .build())
- );
- when(mockedStatisticsOnFlyGatheringService.getStatisticsOfType(Matchers.any(EventIdentifier.class),
- Matchers.any(MultipartType.class)))
- .thenReturn(
- Futures.immediateFuture(RpcResultBuilder.success(Collections.<MultipartReply>emptyList())
- .build())
- );
+ when(mockedStatisticsGatheringService
+ .getStatisticsOfType(Matchers.any(EventIdentifier.class), Matchers.any(MultipartType.class)))
+ .thenReturn(Futures.immediateFuture(
+ RpcResultBuilder.success(Collections.<MultipartReply>emptyList()).build()));
+ when(mockedStatisticsOnFlyGatheringService
+ .getStatisticsOfType(Matchers.any(EventIdentifier.class), Matchers.any(MultipartType.class)))
+ .thenReturn(Futures.immediateFuture(
+ RpcResultBuilder.success(Collections.<MultipartReply>emptyList()).build()));
statisticsContext.registerMastershipWatcher(mockedMastershipWatcher);
statisticsContext.setStatisticsGatheringService(mockedStatisticsGatheringService);
/**
* switching to {@link StatisticsWorkMode#FULLYDISABLED}; no pollTimeout and no lifecycleRegistry.
*
- * @throws Exception
*/
@Test
public void testChangeStatisticsWorkMode1() throws Exception {
/**
* Switching to {@link StatisticsWorkMode#FULLYDISABLED}; with pollTimeout and lifecycleRegistry.
*
- * @throws Exception
*/
@Test
public void testChangeStatisticsWorkMode2() throws Exception {
}
/**
- * switching to {@link StatisticsWorkMode#FULLYDISABLED} and back
- * to {@link StatisticsWorkMode#COLLECTALL}; with lifecycleRegistry and pollTimeout
+ * Tests switching to {@link StatisticsWorkMode#FULLYDISABLED} and back
+ * to {@link StatisticsWorkMode#COLLECTALL}; with lifecycleRegistry and pollTimeout.
*
- * @throws Exception
*/
@Test
public void testChangeStatisticsWorkMode3() throws Exception {
@Override
public void setUp() throws Exception {
- service = new MeterDirectStatisticsService(requestContextStack,
- deviceContext,
- convertorManager,
+ service = new MeterDirectStatisticsService(requestContextStack, deviceContext, convertorManager,
multipartWriterProvider);
}
when(input.getMeterId()).thenReturn(new MeterId(METER_NO));
final MultipartRequestMeterCase body = (MultipartRequestMeterCase) ((MultipartRequestInput) service
- .buildRequest(new Xid(42L), input))
- .getMultipartRequestBody();
+ .buildRequest(new Xid(42L), input)).getMultipartRequestBody();
final MultipartRequestMeter meter = body.getMultipartRequestMeter();
final MultipartReply reply = mock(MultipartReply.class);
final MultipartReplyMeterCase MeterCase = mock(MultipartReplyMeterCase.class);
final MultipartReplyMeter meter = mock(MultipartReplyMeter.class);
- final MeterStats meterStat = new MeterStatsBuilder()
- .setMeterId(new org.opendaylight.yang.gen.v1.urn
- .opendaylight.openflow.common.types.rev130731.MeterId(METER_NO))
- .setByteInCount(BigInteger.ONE)
- .setPacketInCount(BigInteger.ONE)
- .setDurationSec(1L)
- .setDurationNsec(1L)
- .setFlowCount(0L)
- .setMeterBandStats(Collections.emptyList())
- .build();
+ final MeterStats meterStat = new MeterStatsBuilder().setMeterId(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId(METER_NO))
+ .setByteInCount(BigInteger.ONE).setPacketInCount(BigInteger.ONE).setDurationSec(1L).setDurationNsec(1L)
+ .setFlowCount(0L).setMeterBandStats(Collections.emptyList()).build();
final List<MeterStats> meterStats = Collections.singletonList(meterStat);
final List<MultipartReply> input = Collections.singletonList(reply);
final GetMeterStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getMeterStats().size() > 0);
- final org.opendaylight.yang.gen.v1.urn
- .opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats stats = output.getMeterStats().get(0);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats
+ stats = output.getMeterStats().get(0);
assertEquals(stats.getMeterId().getValue(), METER_NO);
}
@Override
public void testStoreStatistics() throws Exception {
- final org.opendaylight.yang.gen.v1.urn
- .opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats stat =
- mock(org.opendaylight.yang.gen.v1.urn
- .opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats.class);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats stat
+ = mock(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats
+ .class);
when(stat.getMeterId()).thenReturn(new MeterId(METER_NO));
- final List<org.opendaylight.yang.gen.v1.urn
- .opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats> stats = Collections.singletonList(stat);
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply
+ .MeterStats>
+ stats = Collections.singletonList(stat);
final GetMeterStatisticsOutput output = mock(GetMeterStatisticsOutput.class);
when(output.getMeterStats()).thenReturn(stats);
when(stat.getMeterId()).thenReturn(new MeterId(METER_NO));
final List<org.opendaylight.yang.gen.v1.urn
- .opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats> stats = Collections.singletonList(stat);
+ .opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats>
+ stats = Collections.singletonList(stat);
final GetMeterStatisticsOutput output = mock(GetMeterStatisticsOutput.class);
when(output.getMeterStats()).thenReturn(stats);
public void testCreateHelloInputWithElements() {
short highestVersion = (short) 0x04;
long xid = 42L;
- Boolean[] expectedVersionBitmap = new Boolean[]{
- false, true, false, false, true};
+ Boolean[] expectedVersionBitmap = new Boolean[]{false, true, false, false, true};
HelloInput helloMsg = MessageFactory.createHelloInput(highestVersion, xid, OFConstants.VERSION_ORDER);
Assert.assertEquals(highestVersion, helloMsg.getVersion().shortValue());
*/
public class PacketInUtilTest {
-
/**
- * Test method for PacketInUtil#getMdSalPacketInReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason);
+ * Test method for PacketInUtil#getMdSalPacketInReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
+ * .common.types.rev130731.PacketInReason).
*/
@Test
public void testGetMdSalPacketInReason() {
- Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInReason> resultReason;
+ Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInReason>
+ resultReason;
resultReason = PacketInUtil.getMdSalPacketInReason(PacketInReason.OFPRACTION);
assertTrue(resultReason.getName().equals(SendToController.class.getName()));
private static final String MAC_ADDRESS = "00:01:02:03:04:05";
private static final String NAME = "PortTranslatorTest";
- private final Boolean[] pfBls = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
- private final boolean[] pfV10Bls = {false, false, false, false, false, false, false, false, false, false, false, false};
+ private final Boolean[] pfBls
+ = {false, false, false, false, false, false, false, false, false, false, false, false, false, false,
+ false, false};
+ private final boolean[] pfV10Bls
+ = {false, false, false, false, false, false, false, false, false, false, false, false};
private final boolean[] portCfgBools = {false, false, false, false};
private final boolean[] portCfgV10bools = {false, false, false, false, false, false, false};
private final boolean[] portStateBools = {false, false, false, false};
private static final Long MAX_SPEED = Long.decode("4294967295");
/**
- * Test method for {@link PortTranslatorUtil#translatePortFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures)}
+ * Test method for
+ * {@link PortTranslatorUtil#translatePortFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight
+ * .openflow.common.types.rev130731.PortFeatures)}.
*/
@Test
public void testTranslatePortFeatures() {
-
-
for (int i = 0; i < pfBls.length; i++) {
pfBls[i] = true;
final PortFeatures apf = getPortFeatures();
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures npf = PortTranslatorUtil.translatePortFeatures(apf);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures npf
+ = PortTranslatorUtil.translatePortFeatures(apf);
assertEqualsPortFeatures(apf, npf);
pfBls[i] = false;
}
-
}
private PortFeatures getPortFeatures() {
- return new PortFeatures(pfBls[0], pfBls[1], pfBls[2], pfBls[3], pfBls[4], pfBls[5], pfBls[6], pfBls[7], pfBls[8],
- pfBls[9], pfBls[10], pfBls[11], pfBls[12], pfBls[13], pfBls[14], pfBls[15]);
+ return new PortFeatures(pfBls[0], pfBls[1], pfBls[2], pfBls[3], pfBls[4], pfBls[5], pfBls[6], pfBls[7],
+ pfBls[8], pfBls[9], pfBls[10], pfBls[11], pfBls[12], pfBls[13], pfBls[14], pfBls[15]);
}
/**
- * Test method for {@link PortTranslatorUtil#translatePortFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10)}
+ * Test method for
+ * {@link PortTranslatorUtil#translatePortFeatures(org.opendaylight.yang.gen.v1.urn
+ * .opendaylight.openflow.common.types.rev130731.PortFeaturesV10)}.
*/
@Test
public void testTranslatePortFeaturesV10() {
pfV10Bls[i] = true;
final PortFeaturesV10 apfV10 = getPortFeaturesV10();
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures npf = PortTranslatorUtil.translatePortFeatures(apfV10);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures npf
+ = PortTranslatorUtil.translatePortFeatures(apfV10);
assertEqualsPortFeaturesV10(apfV10, npf);
pfV10Bls[i] = false;
}
private PortFeaturesV10 getPortFeaturesV10() {
- return new PortFeaturesV10(pfV10Bls[0], pfV10Bls[1], pfV10Bls[2], pfV10Bls[3], pfV10Bls[4], pfV10Bls[5], pfV10Bls[6],
- pfV10Bls[7], pfV10Bls[8], pfV10Bls[9], pfV10Bls[10], pfV10Bls[11]);
+ return new PortFeaturesV10(pfV10Bls[0], pfV10Bls[1], pfV10Bls[2], pfV10Bls[3], pfV10Bls[4], pfV10Bls[5],
+ pfV10Bls[6], pfV10Bls[7], pfV10Bls[8], pfV10Bls[9], pfV10Bls[10], pfV10Bls[11]);
}
/**
- * Test method for {@link PortTranslatorUtil#translatePort(Short, java.math.BigInteger, Long, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping)} ()}
+ * Test method for
+ * {@link PortTranslatorUtil#translatePort(Short, java.math.BigInteger,
+ * Long, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping)} ()}.
*/
@Test
public void testTranslatePort() {
Long portNumber = Long.MAX_VALUE;
PortGrouping portGrouping = mockPortGrouping();
- NodeConnectorUpdated nodeConnectorUpdated = PortTranslatorUtil.translatePort(version, dataPathId, portNumber, portGrouping);
+ NodeConnectorUpdated nodeConnectorUpdated = PortTranslatorUtil
+ .translatePort(version, dataPathId, portNumber, portGrouping);
assertNotNull(nodeConnectorUpdated);
version = OpenflowVersion.OF13.getVersion();
nodeConnectorUpdated = PortTranslatorUtil.translatePort(version, dataPathId, portNumber, portGrouping);
}
private PortConfigV10 getPortConfigV10() {
- return new PortConfigV10(portCfgV10bools[0], portCfgV10bools[1], portCfgV10bools[2], portCfgV10bools[3], portCfgV10bools[4], portCfgV10bools[5], portCfgV10bools[6]);
+ return new PortConfigV10(portCfgV10bools[0], portCfgV10bools[1], portCfgV10bools[2], portCfgV10bools[3],
+ portCfgV10bools[4], portCfgV10bools[5], portCfgV10bools[6]);
}
private PortConfig getPortConfig() {
return new PortConfig(portCfgBools[0], portCfgBools[1], portCfgBools[2], portCfgBools[3]);
}
- private static void assertEqualsPortFeaturesV10(final PortFeaturesV10 apfV10, final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures npf) {
+ private static void assertEqualsPortFeaturesV10(final PortFeaturesV10 apfV10,
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types
+ .port.rev130925.PortFeatures npf) {
assertEquals(apfV10.is_100mbFd(), npf.isHundredMbFd());
assertEquals(apfV10.is_100mbHd(), npf.isHundredMbHd());
assertEquals(apfV10.isPauseAsym(), npf.isPauseAsym());
}
- private static void assertEqualsPortFeatures(final PortFeatures apf, final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures npf) {
+ private static void assertEqualsPortFeatures(final PortFeatures apf,
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port
+ .rev130925.PortFeatures npf) {
assertEquals(apf.is_100gbFd(), npf.isHundredGbFd());
assertEquals(apf.is_100mbFd(), npf.isHundredMbFd());
assertEquals(apf.is_100mbHd(), npf.isHundredMbHd());