use of org.onosproject.net.meter.MeterStoreResult in project onos by opennetworkinglab.
the class DistributedMeterStore method deleteMeterFeatures.
@Override
public MeterStoreResult deleteMeterFeatures(DeviceId deviceId) {
MeterStoreResult result = MeterStoreResult.success();
try {
Set<MeterTableKey> keys = metersFeatures.keySet().stream().filter(key -> key.deviceId().equals(deviceId)).collect(Collectors.toUnmodifiableSet());
keys.forEach(k -> metersFeatures.remove(k));
} 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.MeterStoreResult in project onos by opennetworkinglab.
the class DistributedMeterStore method addOrUpdateMeter.
@Override
public CompletableFuture<MeterStoreResult> addOrUpdateMeter(Meter meter) {
checkArgument(validIndex(meter), "Meter index is not valid");
CompletableFuture<MeterStoreResult> future = new CompletableFuture<>();
MeterKey key = MeterKey.key(meter.deviceId(), meter.meterCellId());
MeterData data = new MeterData(meter, null);
futures.put(key, future);
try {
meters.compute(key, (k, v) -> data);
} catch (StorageException e) {
log.error("{} thrown a storage exception: {}", e.getStackTrace()[0].getMethodName(), e.getMessage(), e);
futures.remove(key);
future.completeExceptionally(e);
}
return future;
}
use of org.onosproject.net.meter.MeterStoreResult in project onos by opennetworkinglab.
the class DistributedMeterStore method storeMeterFeatures.
@Override
public MeterStoreResult storeMeterFeatures(MeterFeatures meterfeatures) {
// Store meter features, this is done once for each features of every device
MeterStoreResult result = MeterStoreResult.success();
MeterTableKey key = MeterTableKey.key(meterfeatures.deviceId(), meterfeatures.scope());
try {
metersFeatures.put(key, meterfeatures);
} 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.MeterStoreResult in project onos by opennetworkinglab.
the class SimpleVirtualMeterStore method updateMeter.
@Override
public CompletableFuture<MeterStoreResult> updateMeter(NetworkId networkId, Meter meter) {
ConcurrentMap<MeterKey, MeterData> meters = getMetersByNetwork(networkId);
ConcurrentMap<MeterKey, CompletableFuture<MeterStoreResult>> futures = getFuturesByNetwork(networkId);
CompletableFuture<MeterStoreResult> future = new CompletableFuture<>();
MeterKey key = MeterKey.key(meter.deviceId(), meter.id());
futures.put(key, future);
MeterData data = new MeterData(meter, null, local);
try {
if (meters.computeIfPresent(key, (k, v) -> data) == null) {
future.complete(MeterStoreResult.fail(MeterFailReason.INVALID_METER));
}
} catch (StorageException e) {
future.completeExceptionally(e);
}
return future;
}
use of org.onosproject.net.meter.MeterStoreResult 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