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 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 WorkFlowEngine method execEventTimeoutTask.
/**
* Executes event timeout task.
*
* @param task event timeout task
* @return handler task
*/
private HandlerTask execEventTimeoutTask(EventTimeoutTask task) {
if (!eventMapStore.isEventMapPresent(task.context().name())) {
log.trace("EventMap doesnt exist for taskcontext:{}", task.context().name());
return task;
}
log.debug("execEventTimeoutTask- task: {}, hash: {}", task, stringHash(task.context().distributor()));
WorkflowContext context = (WorkflowContext) (task.context());
Workflow workflow = workflowStore.get(context.workflowId());
if (workflow == null) {
log.error("execEventTimeoutTask: Invalid workflow {}", context.workflowId());
return task;
}
WorkflowContext latestContext = workplaceStore.getContext(context.name());
if (latestContext == null) {
log.error("execEventTimeoutTask: Invalid workflow context {}", context.name());
return task;
}
try {
if (!Objects.equals(latestContext.current(), task.programCounter())) {
log.error("execEventTimeoutTask: Current worklet({}) is not mismatched with task work({}). Ignored.", latestContext.current(), task.programCounter());
return task;
}
Worklet worklet = workflow.getWorkletInstance(task.programCounter());
if (worklet == Worklet.Common.COMPLETED || worklet == Worklet.Common.INIT) {
log.error("execEventTimeoutTask: Current worklet is {}, Ignored", worklet);
return task;
}
initWorkletExecution(latestContext);
eventMapStore.unregisterEventMap(task.eventType(), latestContext.name());
log.info("{} worklet.timeout(for event):{}", latestContext.name(), worklet.tag());
log.trace("{} task:{}, context: {}", latestContext.name(), task, latestContext);
dataModelInjector.inject(worklet, latestContext);
WorkletDescription workletDesc = workflow.getWorkletDesc(task.programCounter());
if (Objects.nonNull(workletDesc)) {
if (!(workletDesc.tag().equals("INIT") || workletDesc.tag().equals("COMPLETED"))) {
staticDataModelInjector.inject(worklet, workletDesc);
}
}
worklet.timeout(latestContext);
dataModelInjector.inhale(worklet, latestContext);
log.info("{} worklet.timeout(for event)(done):{}", latestContext.name(), worklet.tag());
log.trace("{} task:{}, context: {}", latestContext.name(), task, latestContext);
workplaceStore.commitContext(latestContext.name(), latestContext, latestContext.triggerNext());
} catch (WorkflowException e) {
log.error("Exception: ", e);
latestContext.setCause(e.getMessage());
latestContext.setState(WorkflowState.EXCEPTION);
workplaceStore.commitContext(latestContext.name(), latestContext, false);
} catch (StorageException e) {
log.error("Exception: ", e);
// StorageException does not commit context.
} catch (Exception e) {
log.error("Exception: ", e);
latestContext.setCause(e.getMessage());
latestContext.setState(WorkflowState.EXCEPTION);
workplaceStore.commitContext(latestContext.name(), latestContext, false);
}
return task;
}
use of org.onosproject.store.service.StorageException in project onos by opennetworkinglab.
the class WorkFlowEngine method execTimeoutTask.
/**
* Executes timeout task.
*
* @param task time out task
* @return handler task
*/
private HandlerTask execTimeoutTask(TimeoutTask task) {
log.debug("execTimeoutTask- task: {}, hash: {}", task, stringHash(task.context().distributor()));
WorkflowContext context = (WorkflowContext) (task.context());
Workflow workflow = workflowStore.get(context.workflowId());
if (workflow == null) {
log.error("execTimeoutTask: Invalid workflow {}", context.workflowId());
return task;
}
WorkflowContext latestContext = workplaceStore.getContext(context.name());
if (latestContext == null) {
log.error("execTimeoutTask: Invalid workflow context {}", context.name());
return task;
}
try {
if (!Objects.equals(latestContext.current(), task.programCounter())) {
log.error("execTimeoutTask: Current worklet({}) is not mismatched with task work({}). Ignored.", latestContext.current(), task.programCounter());
return task;
}
Worklet worklet = workflow.getWorkletInstance(task.programCounter());
if (worklet == Worklet.Common.COMPLETED || worklet == Worklet.Common.INIT) {
log.error("execTimeoutTask: Current worklet is {}, Ignored", worklet);
return task;
}
initWorkletExecution(latestContext);
log.info("{} worklet.timeout:{}", latestContext.name(), worklet.tag());
log.trace("{} context: {}", latestContext.name(), latestContext);
dataModelInjector.inject(worklet, latestContext);
WorkletDescription workletDesc = workflow.getWorkletDesc(task.programCounter());
if (Objects.nonNull(workletDesc)) {
if (!(workletDesc.tag().equals("INIT") || workletDesc.tag().equals("COMPLETED"))) {
staticDataModelInjector.inject(worklet, workletDesc);
}
}
worklet.timeout(latestContext);
dataModelInjector.inhale(worklet, latestContext);
log.info("{} worklet.timeout(done):{}", latestContext.name(), worklet.tag());
log.trace("{} context: {}", latestContext.name(), latestContext);
workplaceStore.commitContext(latestContext.name(), latestContext, latestContext.triggerNext());
} catch (WorkflowException e) {
log.error("Exception: ", e);
latestContext.setCause(e.getMessage());
latestContext.setState(WorkflowState.EXCEPTION);
workplaceStore.commitContext(latestContext.name(), latestContext, false);
} catch (StorageException e) {
log.error("Exception: ", e);
// StorageException does not commit context.
} catch (Exception e) {
log.error("Exception: ", e);
latestContext.setCause(e.getMessage());
latestContext.setState(WorkflowState.EXCEPTION);
workplaceStore.commitContext(latestContext.name(), latestContext, false);
}
return task;
}
Aggregations