use of org.onosproject.net.meter.MeterFeatures in project onos by opennetworkinglab.
the class SimpleVirtualMeterStore method deleteMeterFeatures.
@Override
public MeterStoreResult deleteMeterFeatures(NetworkId networkId, DeviceId deviceId) {
ConcurrentMap<MeterFeaturesKey, MeterFeatures> meterFeatures = getMeterFeaturesByNetwork(networkId);
MeterStoreResult result = MeterStoreResult.success();
MeterFeaturesKey key = MeterFeaturesKey.key(deviceId);
try {
meterFeatures.remove(key);
} catch (StorageException e) {
result = MeterStoreResult.fail(TIMEOUT);
}
return result;
}
use of org.onosproject.net.meter.MeterFeatures in project onos by opennetworkinglab.
the class SimpleVirtualMeterStore method getMaxMeters.
@Override
public long getMaxMeters(NetworkId networkId, MeterFeaturesKey key) {
ConcurrentMap<MeterFeaturesKey, MeterFeatures> meterFeatures = getMeterFeaturesByNetwork(networkId);
MeterFeatures features = meterFeatures.get(key);
return features == null ? 0L : features.maxMeter();
}
use of org.onosproject.net.meter.MeterFeatures in project onos by opennetworkinglab.
the class DistributedMeterStore method validIndex.
// Validate index using the meter features, useful mainly
// when user defined index mode is enabled
private boolean validIndex(Meter meter) {
long index;
MeterTableKey key;
if (meter.meterCellId().type() == PIPELINE_INDEPENDENT) {
PiMeterCellId piMeterCellId = (PiMeterCellId) meter.meterCellId();
index = piMeterCellId.index();
key = MeterTableKey.key(meter.deviceId(), MeterScope.of(piMeterCellId.meterId().id()));
} else if (meter.meterCellId().type() == INDEX) {
MeterId meterId = (MeterId) meter.meterCellId();
index = meterId.id();
key = MeterTableKey.key(meter.deviceId(), MeterScope.globalScope());
} else {
log.warn("Unable to validate index unsupported cell type {}", meter.meterCellId().type());
return false;
}
MeterFeatures features = metersFeatures.get(key);
long startIndex = features == null ? -1L : features.startIndex();
long endIndex = features == null ? -1L : features.endIndex();
return index >= startIndex && index <= endIndex;
}
use of org.onosproject.net.meter.MeterFeatures in project onos by opennetworkinglab.
the class DistributedMeterStore method deleteMeterFeatures.
@Override
public MeterStoreResult deleteMeterFeatures(Collection<MeterFeatures> meterfeatures) {
// Same logic of storeMeterFeatures
MeterStoreResult result = MeterStoreResult.success();
for (MeterFeatures mf : meterfeatures) {
try {
MeterTableKey key = MeterTableKey.key(mf.deviceId(), mf.scope());
metersFeatures.remove(key);
} catch (StorageException e) {
log.error("{} thrown a storage exception: {}", e.getStackTrace()[0].getMethodName(), e.getMessage(), e);
result = MeterStoreResult.fail(TIMEOUT);
}
}
return result;
}
use of org.onosproject.net.meter.MeterFeatures in project onos by opennetworkinglab.
the class SimpleVirtualMeterStore method storeMeterFeatures.
@Override
public MeterStoreResult storeMeterFeatures(NetworkId networkId, MeterFeatures meterfeatures) {
ConcurrentMap<MeterFeaturesKey, MeterFeatures> meterFeatures = getMeterFeaturesByNetwork(networkId);
MeterStoreResult result = MeterStoreResult.success();
MeterFeaturesKey key = MeterFeaturesKey.key(meterfeatures.deviceId());
try {
meterFeatures.putIfAbsent(key, meterfeatures);
} catch (StorageException e) {
result = MeterStoreResult.fail(TIMEOUT);
}
return result;
}
Aggregations