use of org.onosproject.store.service.StorageException in project onos by opennetworkinglab.
the class SimpleVirtualMeterStore method storeMeter.
@Override
public CompletableFuture<MeterStoreResult> storeMeter(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 {
meters.put(key, data);
} catch (StorageException e) {
future.completeExceptionally(e);
}
return future;
}
use of org.onosproject.store.service.StorageException in project onos by opennetworkinglab.
the class SimpleVirtualMeterStore method deleteMeter.
@Override
public CompletableFuture<MeterStoreResult> deleteMeter(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);
// that it has been removed from the dataplane.
try {
if (meters.computeIfPresent(key, (k, v) -> data) == null) {
future.complete(MeterStoreResult.success());
}
} catch (StorageException e) {
future.completeExceptionally(e);
}
return future;
}
use of org.onosproject.store.service.StorageException 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.store.service.StorageException 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.store.service.StorageException in project onos by opennetworkinglab.
the class DistributedMeterStore method purgeMeter.
@Override
public void purgeMeter(Meter m) {
// Once we receive the ack from the sb, create the key
// remove definitely the meter and free the id
MeterKey key = MeterKey.key(m.deviceId(), m.meterCellId());
try {
if (Versioned.valueOrNull(meters.remove(key)) != null) {
MeterScope scope;
if (m.meterCellId().type() == PIPELINE_INDEPENDENT) {
PiMeterCellId piMeterCellId = (PiMeterCellId) m.meterCellId();
scope = MeterScope.of(piMeterCellId.meterId().id());
} else {
scope = MeterScope.globalScope();
}
MeterTableKey meterTableKey = MeterTableKey.key(m.deviceId(), scope);
freeMeterId(meterTableKey, m.meterCellId());
}
} catch (StorageException e) {
log.error("{} thrown a storage exception: {}", e.getStackTrace()[0].getMethodName(), e.getMessage(), e);
}
}
Aggregations