-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import com.google.common.collect.Lists;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Optional;
+import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
import org.opendaylight.openflowjava.protocol.api.util.BinContent;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.impl.services.util.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.services.util.ServiceException;
import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
@Override
protected OfHeader buildRequest(final Xid xid,
- final GetAllMeterConfigStatisticsInput input) throws ServiceException {
+ final GetAllMeterConfigStatisticsInput input) {
MultipartRequestInputBuilder mprInput = RequestInputUtils
.createMultipartHeader(MultipartType.OFPMPMETERCONFIG, xid.getValue(), getVersion());
return mprInput.setMultipartRequestBody(METER_CONFIG_CASE).build();
final Optional<List<MeterConfigStats>> meterConfigStatsList =
convertorExecutor.convert(replyBody.getMeterConfig(), data);
- meterConfigStatsList.ifPresent(meterConfigStats -> message.getMeterConfigStats().addAll(meterConfigStats));
+ meterConfigStatsList.ifPresent(meterConfigStats -> {
+ if (message.getMeterConfigStats() == null) {
+ message.setMeterConfigStats(Lists.newArrayList(meterConfigStats));
+ } else {
+ Set<MeterConfigStats> stats = new HashSet<>(message.getMeterConfigStats().values());
+ stats.addAll(meterConfigStats);
+ message.setMeterConfigStats(stats.stream().collect(Collectors.toList()));
+ }
+ });
}
return message.build();