Skip to content
Snippets Groups Projects
Commit bb834403 authored by Konstantinos Poulakakis's avatar Konstantinos Poulakakis
Browse files

refactor: refactor add policy device two add the policyId to the subscription list.

parent 0d501c75
No related branches found
No related tags found
2 merge requests!235Release TeraFlowSDN 3.0,!197Resolve "(UBI) Refactor Policy"
...@@ -322,10 +322,10 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -322,10 +322,10 @@ public class PolicyServiceImpl implements PolicyService {
return areDevicesValid return areDevicesValid
.onItem() .onItem()
.transform(areDevices -> addDeviceOnContext(areDevices, policyRuleDevice, policyRuleBasic)); .transform(areDevices -> areDeviceOnContext(areDevices, policyRuleDevice, policyRuleBasic));
} }
private PolicyRuleState addDeviceOnContext( private PolicyRuleState areDeviceOnContext(
List<Boolean> areDevices, List<Boolean> areDevices,
PolicyRuleDevice policyRuleDevice, PolicyRuleDevice policyRuleDevice,
PolicyRuleBasic policyRuleBasic) { PolicyRuleBasic policyRuleBasic) {
...@@ -353,7 +353,22 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -353,7 +353,22 @@ public class PolicyServiceImpl implements PolicyService {
return policyRuleState; return policyRuleState;
} }
contextService.setPolicyRule(policyRule).subscribe().with(x -> {}); contextService
.setPolicyRule(policyRule)
.subscribe()
.with(
policyId -> {
startMonitoringBasedOnAlarmDescriptors(
policyId, policyRuleDevice, alarmDescriptorList);
});
return VALIDATED_POLICYRULE_STATE;
}
private void startMonitoringBasedOnAlarmDescriptors(
String policyId,
PolicyRuleDevice policyRuleDevice,
List<AlarmDescriptor> alarmDescriptorList) {
setPolicyRuleDeviceToContext(policyRuleDevice, VALIDATED_POLICYRULE_STATE); setPolicyRuleDeviceToContext(policyRuleDevice, VALIDATED_POLICYRULE_STATE);
noAlarms = 0; noAlarms = 0;
...@@ -366,14 +381,12 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -366,14 +381,12 @@ public class PolicyServiceImpl implements PolicyService {
final var multi = Multi.createBy().merging().streams(alarmResponseStreamList); final var multi = Multi.createBy().merging().streams(alarmResponseStreamList);
setPolicyRuleDeviceToContext(policyRuleDevice, PROVISIONED_POLICYRULE_STATE); setPolicyRuleDeviceToContext(policyRuleDevice, PROVISIONED_POLICYRULE_STATE);
monitorAlarmResponseForDevice(multi); subscriptionList.put(policyId, monitorAlarmResponseForDevice(multi));
// TODO: Resubscribe to the stream, if it has ended // TODO: Resubscribe to the stream, if it has ended
// TODO: Redesign evaluation of action // TODO: Redesign evaluation of action
// evaluateAction(policyRule, alarmDescriptorList, multi); // evaluateAction(policyRule, alarmDescriptorList, multi);
return VALIDATED_POLICYRULE_STATE;
} }
private List<Multi<AlarmResponse>> getAlarmResponse( private List<Multi<AlarmResponse>> getAlarmResponse(
...@@ -569,8 +582,8 @@ public class PolicyServiceImpl implements PolicyService { ...@@ -569,8 +582,8 @@ public class PolicyServiceImpl implements PolicyService {
}); });
} }
private void monitorAlarmResponseForDevice(Multi<AlarmResponse> multi) { private Cancellable monitorAlarmResponseForDevice(Multi<AlarmResponse> multi) {
multi return multi
.subscribe() .subscribe()
.with( .with(
alarmResponse -> { alarmResponse -> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment