diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 668b5ce62658a085faebfb3fd6b9296edf50a928..615872734687120463fe0cd7b292223f6f3d50b3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,7 +34,8 @@ include: - local: '/src/opticalattackmitigator/.gitlab-ci.yml' - local: '/src/opticalcentralizedattackdetector/.gitlab-ci.yml' - local: '/src/automation/.gitlab-ci.yml' - - local: '/src/webui/.gitlab-ci.yml' + - local: '/src/policy/.gitlab-ci.yml' + #- local: '/src/webui/.gitlab-ci.yml' #- local: '/src/l3_distributedattackdetector/.gitlab-ci.yml' #- local: '/src/l3_centralizedattackdetector/.gitlab-ci.yml' #- local: '/src/l3_attackmitigator/.gitlab-ci.yml' diff --git a/report_coverage_slice.sh b/report_coverage_slice.sh deleted file mode 100755 index f783ec069329a9efe100154a2702a72a93e0ad8a..0000000000000000000000000000000000000000 --- a/report_coverage_slice.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./report_coverage_all.sh | grep --color -E -i "^slice/.*$|$" diff --git a/scripts/report_coverage_slice.sh b/scripts/report_coverage_slice.sh new file mode 100755 index 0000000000000000000000000000000000000000..f9b17e8bd162500e2be77a871f7f2976f923ca68 --- /dev/null +++ b/scripts/report_coverage_slice.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +./report_coverage_all.sh | grep --color -E -i "^slice/.*$|$" diff --git a/scripts/run_tests_locally-device-all.sh b/scripts/run_tests_locally-device-all.sh new file mode 100755 index 0000000000000000000000000000000000000000..2cf8faaf50355a3cc5f3a0206498ed4dacb48523 --- /dev/null +++ b/scripts/run_tests_locally-device-all.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +PROJECTDIR=`pwd` + +cd $PROJECTDIR/src +RCFILE=$PROJECTDIR/coverage/.coveragerc + +# Run unitary tests and analyze coverage of code at same time + +# Useful flags for pytest: +#-o log_cli=true -o log_file=device.log -o log_file_level=DEBUG + +coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ + device/tests/test_unitary_emulated.py + +coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ + device/tests/test_unitary_openconfig.py + +coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ + device/tests/test_unitary_tapi.py + +coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ + device/tests/test_unitary_p4.py + +coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ + device/tests/test_unitary_microwave.py diff --git a/scripts/run_tests_in_kubernetes.sh b/scripts/run_tests_locally-device-emulated.sh similarity index 61% rename from scripts/run_tests_in_kubernetes.sh rename to scripts/run_tests_locally-device-emulated.sh index fc0e1425731bf333a88eca6b65a3fc12122c7768..ab4f77adaf9c0549551c91d944c1c6db77a8b9cb 100755 --- a/scripts/run_tests_in_kubernetes.sh +++ b/scripts/run_tests_locally-device-emulated.sh @@ -14,11 +14,15 @@ # limitations under the License. -IMAGE_NAME='integration_tester' -IMAGE_TAG='latest' -CI_REGISTRY_IMAGE='registry.gitlab.com/teraflow-h2020/controller' +PROJECTDIR=`pwd` -kubectl delete pod $(echo $IMAGE_NAME | sed -r 's/[^a-zA-Z0-9\.\-]/-/g') --wait=true --ignore-not-found=true -kubectl get all -kubectl run $(echo $IMAGE_NAME | sed -r 's/[^a-zA-Z0-9\.\-]/-/g') --image "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" --restart=Never --rm -i -kubectl get all +cd $PROJECTDIR/src +RCFILE=$PROJECTDIR/coverage/.coveragerc + +# Run unitary tests and analyze coverage of code at same time + +# Useful flags for pytest: +#-o log_cli=true -o log_file=device.log -o log_file_level=DEBUG + +coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ + device/tests/test_unitary_emulated.py diff --git a/scripts/run_tests_locally-device-microwave.sh b/scripts/run_tests_locally-device-microwave.sh new file mode 100755 index 0000000000000000000000000000000000000000..e03630c9f63c65cae91464b76cc3ddc447835f42 --- /dev/null +++ b/scripts/run_tests_locally-device-microwave.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +PROJECTDIR=`pwd` + +cd $PROJECTDIR/src +RCFILE=$PROJECTDIR/coverage/.coveragerc + +# Run unitary tests and analyze coverage of code at same time + +# Useful flags for pytest: +#-o log_cli=true -o log_file=device.log -o log_file_level=DEBUG + +coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ + device/tests/test_unitary_microwave.py diff --git a/scripts/run_tests_locally-device-openconfig.sh b/scripts/run_tests_locally-device-openconfig.sh new file mode 100755 index 0000000000000000000000000000000000000000..83d4a0545a3386395ead97f40d45c034350c73b9 --- /dev/null +++ b/scripts/run_tests_locally-device-openconfig.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +PROJECTDIR=`pwd` + +cd $PROJECTDIR/src +RCFILE=$PROJECTDIR/coverage/.coveragerc + +# Run unitary tests and analyze coverage of code at same time + +# Useful flags for pytest: +#-o log_cli=true -o log_file=device.log -o log_file_level=DEBUG + +coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ + device/tests/test_unitary_openconfig.py diff --git a/scripts/run_tests_locally-device.sh b/scripts/run_tests_locally-device-p4.sh similarity index 96% rename from scripts/run_tests_locally-device.sh rename to scripts/run_tests_locally-device-p4.sh index ba6c0b6a58031720addc17cc0de9169e592099f5..36b381a3cd9214603456828b41e6d70b8c6c908d 100755 --- a/scripts/run_tests_locally-device.sh +++ b/scripts/run_tests_locally-device-p4.sh @@ -25,4 +25,4 @@ RCFILE=$PROJECTDIR/coverage/.coveragerc #-o log_cli=true -o log_file=device.log -o log_file_level=DEBUG coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ - device/tests/test_unitary.py + device/tests/test_unitary_p4.py diff --git a/scripts/run_tests_locally-device-tapi.sh b/scripts/run_tests_locally-device-tapi.sh new file mode 100755 index 0000000000000000000000000000000000000000..a281466b677f256b2ce9fe7770bf2b052ef59126 --- /dev/null +++ b/scripts/run_tests_locally-device-tapi.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +PROJECTDIR=`pwd` + +cd $PROJECTDIR/src +RCFILE=$PROJECTDIR/coverage/.coveragerc + +# Run unitary tests and analyze coverage of code at same time + +# Useful flags for pytest: +#-o log_cli=true -o log_file=device.log -o log_file_level=DEBUG + +coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ + device/tests/test_unitary_tapi.py diff --git a/scripts/run_tests_locally.sh b/scripts/run_tests_locally.sh index 633510a54c33d0603be7cc35706114c29561b958..4a95fd8be7ac83ff0b5ec5a3db47c0cf4fae06f4 100755 --- a/scripts/run_tests_locally.sh +++ b/scripts/run_tests_locally.sh @@ -63,7 +63,7 @@ coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ context/tests/test_unitary.py coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ - device/tests/test_unitary.py + device/tests/test_unitary_emulated.py coverage run --rcfile=$RCFILE --append -m pytest -s --log-level=INFO --verbose \ l3_centralizedattackdetector/tests/test_unitary.py diff --git a/src/automation/.gitlab-ci.yml b/src/automation/.gitlab-ci.yml index 76cd4ea0d07496af864275cd63c5fbd8f94b7659..87d141d5bef56c8d3fbd5bb5a0a961ac12598dd6 100644 --- a/src/automation/.gitlab-ci.yml +++ b/src/automation/.gitlab-ci.yml @@ -69,7 +69,6 @@ unit_test automation: coverage: '/JaCoCo Coverage Total: ([0-9]{1,3})%/' artifacts: reports: - cobertura: ${REPORTS_PATH}/cobertura.xml junit: - ${REPORTS_PATH}/surefire-reports/TEST-*.xml rules: diff --git a/src/automation/src/main/java/eu/teraflow/automation/AutomationConfiguration.java b/src/automation/src/main/java/eu/teraflow/automation/AutomationConfiguration.java index 55f5cce25e8a03a1a5c0da567f16bd858c668d0f..91b6e159d26c86afaf0412af0406657a9c72f8d5 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/AutomationConfiguration.java +++ b/src/automation/src/main/java/eu/teraflow/automation/AutomationConfiguration.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation; diff --git a/src/automation/src/main/java/eu/teraflow/automation/AutomationGateway.java b/src/automation/src/main/java/eu/teraflow/automation/AutomationGateway.java index 1533643d14cb0d78ababe57242a4f01a50c3b0b8..2d8194c6902037b09cf1f707dc8ff9c264e2f2c5 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/AutomationGateway.java +++ b/src/automation/src/main/java/eu/teraflow/automation/AutomationGateway.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation; diff --git a/src/automation/src/main/java/eu/teraflow/automation/AutomationGatewayImpl.java b/src/automation/src/main/java/eu/teraflow/automation/AutomationGatewayImpl.java index 7f403459a2ff28809046a292c7c64d413c066243..7a68965bf96a2c827219f761f19ba752dd534ffc 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/AutomationGatewayImpl.java +++ b/src/automation/src/main/java/eu/teraflow/automation/AutomationGatewayImpl.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation; @@ -56,7 +56,7 @@ public class AutomationGatewayImpl implements AutomationGateway { return automationService .addDevice(deviceId) .onItem() - .transform( device -> transformToDeviceRoleState(device, devRoleId)); + .transform(device -> transformToDeviceRoleState(device, devRoleId)); } @Override @@ -84,8 +84,9 @@ public class AutomationGatewayImpl implements AutomationGateway { return Uni.createFrom().item(() -> Automation.DeviceDeletionResult.newBuilder().build()); } - // TODO When `DeviceRoleState` domain object will be created, move this method to Serializer class and create related tests - private Automation.DeviceRoleState transformToDeviceRoleState(Device device, String devRoleId){ + // TODO When `DeviceRoleState` domain object will be created, move this method to Serializer class + // and create related tests + private Automation.DeviceRoleState transformToDeviceRoleState(Device device, String devRoleId) { final var deviceRoleId = new DeviceRoleId(devRoleId, device.getDeviceId()); final var serializeDeviceRoleId = serializer.serialize(deviceRoleId); @@ -95,4 +96,4 @@ public class AutomationGatewayImpl implements AutomationGateway { .setDevRoleState(Automation.ZtpDeviceState.ZTP_DEV_STATE_CREATED) .build(); } -} \ No newline at end of file +} diff --git a/src/automation/src/main/java/eu/teraflow/automation/AutomationService.java b/src/automation/src/main/java/eu/teraflow/automation/AutomationService.java index 38d7420ed3ba865ae141843c9ba41a6a345e8f31..9e8927d583ce34cb8bfa0eaa7ba5561981b8dac7 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/AutomationService.java +++ b/src/automation/src/main/java/eu/teraflow/automation/AutomationService.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation; diff --git a/src/automation/src/main/java/eu/teraflow/automation/AutomationServiceImpl.java b/src/automation/src/main/java/eu/teraflow/automation/AutomationServiceImpl.java index 433dffbc727f685fb0d8f80ae0c2e4dc559bae87..3db0d647ebc5c2341337bcb5d91484af8684dfe6 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/AutomationServiceImpl.java +++ b/src/automation/src/main/java/eu/teraflow/automation/AutomationServiceImpl.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation; diff --git a/src/automation/src/main/java/eu/teraflow/automation/ContextSubscriber.java b/src/automation/src/main/java/eu/teraflow/automation/ContextSubscriber.java index cb80a6428fbab7ca69952eb5ead760ae815e99c6..c27a2a844350ce3aeb56c594c82ce4543b7e4d94 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/ContextSubscriber.java +++ b/src/automation/src/main/java/eu/teraflow/automation/ContextSubscriber.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation; diff --git a/src/automation/src/main/java/eu/teraflow/automation/Serializer.java b/src/automation/src/main/java/eu/teraflow/automation/Serializer.java index 1cabde5bf714b4427e4abb5551b39f30b5474a79..78f251439979fff73112e7a77af507d25b9b2dca 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/Serializer.java +++ b/src/automation/src/main/java/eu/teraflow/automation/Serializer.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation; diff --git a/src/automation/src/main/java/eu/teraflow/automation/SimpleLivenessCheck.java b/src/automation/src/main/java/eu/teraflow/automation/SimpleLivenessCheck.java index 056b844d5e702db37cf51cce7f86a9e387fa9c12..7c3a2ccb5409d8df5ea95d3cd02eda8d97d74496 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/SimpleLivenessCheck.java +++ b/src/automation/src/main/java/eu/teraflow/automation/SimpleLivenessCheck.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation; diff --git a/src/automation/src/main/java/eu/teraflow/automation/SimpleReadinessCheck.java b/src/automation/src/main/java/eu/teraflow/automation/SimpleReadinessCheck.java index ef1b4c4efceeeb042adf50f0b20a688c5e1004da..c863a6c285b4abbe9002a0d33c2648d0b1017b45 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/SimpleReadinessCheck.java +++ b/src/automation/src/main/java/eu/teraflow/automation/SimpleReadinessCheck.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation; diff --git a/src/automation/src/main/java/eu/teraflow/automation/context/ContextGateway.java b/src/automation/src/main/java/eu/teraflow/automation/context/ContextGateway.java index 83bcc1afddeeeea8545b64f06d4157457d951e84..3bae4161d61d7c94f639b3953324981dca2a1b3d 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/context/ContextGateway.java +++ b/src/automation/src/main/java/eu/teraflow/automation/context/ContextGateway.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.context; diff --git a/src/automation/src/main/java/eu/teraflow/automation/context/ContextGatewayImpl.java b/src/automation/src/main/java/eu/teraflow/automation/context/ContextGatewayImpl.java index 1b11d09a4ce26c3c98af65aa4d5a13f45c049bb7..7bec6413818342f955abcaa2497f8c174951e8dd 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/context/ContextGatewayImpl.java +++ b/src/automation/src/main/java/eu/teraflow/automation/context/ContextGatewayImpl.java @@ -1,36 +1,34 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.context; import context.ContextOuterClass; import context.MutinyContextServiceGrpc.MutinyContextServiceStub; import eu.teraflow.automation.Serializer; -import eu.teraflow.automation.device.model.*; import eu.teraflow.automation.device.model.Device; +import eu.teraflow.automation.device.model.DeviceEvent; import io.quarkus.grpc.GrpcClient; import io.smallrye.mutiny.Multi; import io.smallrye.mutiny.Uni; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; -import org.jboss.logging.Logger; @ApplicationScoped public class ContextGatewayImpl implements ContextGateway { - private static final Logger LOGGER = Logger.getLogger(ContextGatewayImpl.class); @GrpcClient("context") MutinyContextServiceStub streamingDelegateContext; diff --git a/src/automation/src/main/java/eu/teraflow/automation/context/ContextService.java b/src/automation/src/main/java/eu/teraflow/automation/context/ContextService.java index 8b690782aec7ca1ebf23af4c2d91946330314be6..c3e01a1258c0bf99827fd81f0c2e9c087498d803 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/context/ContextService.java +++ b/src/automation/src/main/java/eu/teraflow/automation/context/ContextService.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.context; diff --git a/src/automation/src/main/java/eu/teraflow/automation/context/ContextServiceImpl.java b/src/automation/src/main/java/eu/teraflow/automation/context/ContextServiceImpl.java index 38a938833628cceb5d67c3f51daa06e93fa464d4..10d16bdf9e8eec3434899ef1454762619afdc805 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/context/ContextServiceImpl.java +++ b/src/automation/src/main/java/eu/teraflow/automation/context/ContextServiceImpl.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.context; diff --git a/src/automation/src/main/java/eu/teraflow/automation/context/model/Event.java b/src/automation/src/main/java/eu/teraflow/automation/context/model/Event.java index 974d8dc93ae83c7fccff234753edb3e9fa0ae05b..2b4a4bab6730e5ba18749eb62cecde8811797e87 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/context/model/Event.java +++ b/src/automation/src/main/java/eu/teraflow/automation/context/model/Event.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.context.model; diff --git a/src/automation/src/main/java/eu/teraflow/automation/context/model/EventTypeEnum.java b/src/automation/src/main/java/eu/teraflow/automation/context/model/EventTypeEnum.java index 4c723b29838ef8d4f2bddbfeba8ae4deda67a60a..38c2cd3f08eed5140e20983b5614428b5f6218c0 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/context/model/EventTypeEnum.java +++ b/src/automation/src/main/java/eu/teraflow/automation/context/model/EventTypeEnum.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.context.model; diff --git a/src/automation/src/main/java/eu/teraflow/automation/device/DeviceGateway.java b/src/automation/src/main/java/eu/teraflow/automation/device/DeviceGateway.java index 6a285c14cfc6f55e1809a6523603396701612872..41a7d18f5a858b2d4c04fbaa1ce3577f3966e4b8 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/device/DeviceGateway.java +++ b/src/automation/src/main/java/eu/teraflow/automation/device/DeviceGateway.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.device; diff --git a/src/automation/src/main/java/eu/teraflow/automation/device/DeviceGatewayImpl.java b/src/automation/src/main/java/eu/teraflow/automation/device/DeviceGatewayImpl.java index e10bd5ee04c6252d0b5af065ff6f60fcbe9f67e8..00270e478c233bbc2cc8ae7924838c835aac013e 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/device/DeviceGatewayImpl.java +++ b/src/automation/src/main/java/eu/teraflow/automation/device/DeviceGatewayImpl.java @@ -1,22 +1,21 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.device; -import context.ContextOuterClass; import device.DeviceService; import eu.teraflow.automation.Serializer; import eu.teraflow.automation.device.model.Device; @@ -25,11 +24,9 @@ import io.quarkus.grpc.GrpcClient; import io.smallrye.mutiny.Uni; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; -import org.jboss.logging.Logger; @ApplicationScoped public class DeviceGatewayImpl implements DeviceGateway { - private static final Logger LOGGER = Logger.getLogger(DeviceGatewayImpl.class); @GrpcClient("device") DeviceService deviceDelegate; diff --git a/src/automation/src/main/java/eu/teraflow/automation/device/DeviceService.java b/src/automation/src/main/java/eu/teraflow/automation/device/DeviceService.java index 1d982bbd5d6e8c01211b4c607232777711e88192..0be0688b50c75184a16766dfc6cda16ad41bf3b6 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/device/DeviceService.java +++ b/src/automation/src/main/java/eu/teraflow/automation/device/DeviceService.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.device; diff --git a/src/automation/src/main/java/eu/teraflow/automation/device/DeviceServiceImpl.java b/src/automation/src/main/java/eu/teraflow/automation/device/DeviceServiceImpl.java index 992c9e07a4daa6620ed92d5aacf1edd5c4f5127c..f58c03ee784f215fb7e64ebba2f26a5d8c203f3f 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/device/DeviceServiceImpl.java +++ b/src/automation/src/main/java/eu/teraflow/automation/device/DeviceServiceImpl.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.device; diff --git a/src/automation/src/main/java/eu/teraflow/automation/device/model/ConfigActionEnum.java b/src/automation/src/main/java/eu/teraflow/automation/device/model/ConfigActionEnum.java index 103703c22a522035710c4aa214074229d7edb56c..bbe8d5916975d8541000c9df748fe1a79c3037f6 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/device/model/ConfigActionEnum.java +++ b/src/automation/src/main/java/eu/teraflow/automation/device/model/ConfigActionEnum.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.device.model; diff --git a/src/automation/src/main/java/eu/teraflow/automation/device/model/ConfigRule.java b/src/automation/src/main/java/eu/teraflow/automation/device/model/ConfigRule.java index b419984b77ea122051fcee3eff9531de484b35aa..d307463d135a95ba65939f6b550bd0f2d9de9dac 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/device/model/ConfigRule.java +++ b/src/automation/src/main/java/eu/teraflow/automation/device/model/ConfigRule.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.device.model; diff --git a/src/automation/src/main/java/eu/teraflow/automation/device/model/Device.java b/src/automation/src/main/java/eu/teraflow/automation/device/model/Device.java index 1cd0f9c324f378e2ecc73d5a24ccdaf093b69268..b5dbae62627ca6c9f9dedbeffb6f72fdce0fb74e 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/device/model/Device.java +++ b/src/automation/src/main/java/eu/teraflow/automation/device/model/Device.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.device.model; diff --git a/src/automation/src/main/java/eu/teraflow/automation/device/model/DeviceConfig.java b/src/automation/src/main/java/eu/teraflow/automation/device/model/DeviceConfig.java index 68248136a34d4c0a0b6c519c4eeec54596f6c962..6365b0ed9eeb1a5ebb0596c060e32e49d2f14e2f 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/device/model/DeviceConfig.java +++ b/src/automation/src/main/java/eu/teraflow/automation/device/model/DeviceConfig.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.device.model; diff --git a/src/automation/src/main/java/eu/teraflow/automation/device/model/DeviceEvent.java b/src/automation/src/main/java/eu/teraflow/automation/device/model/DeviceEvent.java index 6589e224e5dac191435d915b50d410ff40ae1afb..5a021276c751813fa0fc1b0497ce514d5d4d5e72 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/device/model/DeviceEvent.java +++ b/src/automation/src/main/java/eu/teraflow/automation/device/model/DeviceEvent.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.device.model; diff --git a/src/automation/src/main/java/eu/teraflow/automation/device/model/DeviceOperationalStatus.java b/src/automation/src/main/java/eu/teraflow/automation/device/model/DeviceOperationalStatus.java index 397c5276c108924c14c58d5213044f264576a9db..163b34704e6629a0df70e4801ad1f4e665bafc19 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/device/model/DeviceOperationalStatus.java +++ b/src/automation/src/main/java/eu/teraflow/automation/device/model/DeviceOperationalStatus.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.device.model; diff --git a/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRole.java b/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRole.java index fb538fee298e6cc3ec521f474a14a7252c03bc4f..6dffcd1c0300672a3e23fc0ee8372b77b1bb55b7 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRole.java +++ b/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRole.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.model; diff --git a/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRoleId.java b/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRoleId.java index d0b7e6a2ae1e7795f90ae8fc00c8488dedab7567..b11f42ad054a3446370e123e37c7c13b025711f3 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRoleId.java +++ b/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRoleId.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.model; diff --git a/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRoleType.java b/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRoleType.java index e92c88c4ac3e46eb0e53e5bae0a361299f547992..8d55e0cb4e231fcc5378ee4304fe5b19c525548c 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRoleType.java +++ b/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRoleType.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.model; diff --git a/src/automation/src/main/java/eu/teraflow/automation/model/DeviceState.java b/src/automation/src/main/java/eu/teraflow/automation/model/DeviceState.java index 53a6b2712930f698987ce3c6a60277605fb604a1..48bc37ef7797562c48eed16091ea35cdb06eacd6 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/model/DeviceState.java +++ b/src/automation/src/main/java/eu/teraflow/automation/model/DeviceState.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation.model; diff --git a/src/automation/src/test/java/eu/teraflow/automation/AutomationFunctionalServiceTest.java b/src/automation/src/test/java/eu/teraflow/automation/AutomationFunctionalServiceTest.java index f584a86ca72885df1249ea6d956384b50e129268..276a74742f80d4fcf54649241f0432635f40ee4a 100644 --- a/src/automation/src/test/java/eu/teraflow/automation/AutomationFunctionalServiceTest.java +++ b/src/automation/src/test/java/eu/teraflow/automation/AutomationFunctionalServiceTest.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation; @@ -22,8 +22,11 @@ import automation.Automation; import context.ContextOuterClass; import eu.teraflow.automation.context.ContextGateway; import eu.teraflow.automation.device.DeviceGateway; -import eu.teraflow.automation.device.model.*; +import eu.teraflow.automation.device.model.ConfigActionEnum; +import eu.teraflow.automation.device.model.ConfigRule; import eu.teraflow.automation.device.model.Device; +import eu.teraflow.automation.device.model.DeviceConfig; +import eu.teraflow.automation.device.model.DeviceOperationalStatus; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.mockito.InjectMock; import io.smallrye.mutiny.Uni; @@ -37,7 +40,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; @QuarkusTest -public class AutomationFunctionalServiceTest { +class AutomationFunctionalServiceTest { private static final Logger LOGGER = Logger.getLogger(AutomationFunctionalServiceTest.class); @Inject AutomationService automationService; @@ -97,8 +100,7 @@ public class AutomationFunctionalServiceTest { deviceConfig -> { LOGGER.infof("Received response %s", deviceConfig); - assertThat(deviceConfig.getDeviceOperationalStatus().toString()) - .isEqualTo(device.getDeviceOperationalStatus().toString()); + assertThat(deviceConfig).hasToString(device.getDeviceOperationalStatus().toString()); assertThat(deviceConfig.getDeviceConfig().toString()).isNotNull(); @@ -163,8 +165,7 @@ public class AutomationFunctionalServiceTest { deviceConfig -> { LOGGER.infof("Received response %s", deviceConfig); - assertThat(deviceConfig.getDeviceOperationalStatus().toString()) - .isEqualTo(device.getDeviceOperationalStatus().toString()); + assertThat(deviceConfig).hasToString(device.getDeviceOperationalStatus().toString()); assertThat(deviceConfig.getDeviceConfig().toString()).isNotNull(); diff --git a/src/automation/src/test/java/eu/teraflow/automation/AutomationServiceTest.java b/src/automation/src/test/java/eu/teraflow/automation/AutomationServiceTest.java index 56c2743216d7204da4f4b4bd64b6281accb5e604..b1178e2dd458c64e27bd1b9948f6c04a46a957cf 100644 --- a/src/automation/src/test/java/eu/teraflow/automation/AutomationServiceTest.java +++ b/src/automation/src/test/java/eu/teraflow/automation/AutomationServiceTest.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation; @@ -20,13 +20,15 @@ import static org.assertj.core.api.Assertions.assertThat; import automation.Automation; import automation.AutomationService; -import context.ContextOuterClass; -import eu.teraflow.automation.model.DeviceRole; -import eu.teraflow.automation.model.DeviceRoleId; import eu.teraflow.automation.context.ContextGateway; import eu.teraflow.automation.device.DeviceGateway; -import eu.teraflow.automation.device.model.*; +import eu.teraflow.automation.device.model.ConfigActionEnum; +import eu.teraflow.automation.device.model.ConfigRule; import eu.teraflow.automation.device.model.Device; +import eu.teraflow.automation.device.model.DeviceConfig; +import eu.teraflow.automation.device.model.DeviceOperationalStatus; +import eu.teraflow.automation.model.DeviceRole; +import eu.teraflow.automation.model.DeviceRoleId; import eu.teraflow.automation.model.DeviceRoleType; import io.quarkus.grpc.GrpcClient; import io.quarkus.test.junit.QuarkusTest; diff --git a/src/automation/src/test/java/eu/teraflow/automation/ContextSubscriberTest.java b/src/automation/src/test/java/eu/teraflow/automation/ContextSubscriberTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6039de58ec8f991f5ccbe0bcfd21871ee1e4c432 --- /dev/null +++ b/src/automation/src/test/java/eu/teraflow/automation/ContextSubscriberTest.java @@ -0,0 +1,199 @@ +package eu.teraflow.automation; + +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import automation.Automation; +import context.ContextOuterClass; +import eu.teraflow.automation.context.ContextGateway; +import eu.teraflow.automation.context.model.Event; +import eu.teraflow.automation.context.model.EventTypeEnum; +import eu.teraflow.automation.device.model.DeviceEvent; +import io.quarkus.runtime.StartupEvent; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.mockito.InjectMock; +import io.smallrye.mutiny.Multi; +import java.util.UUID; +import javax.inject.Inject; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +@QuarkusTest +class ContextSubscriberTest { + + private static final String UUID_FOR_DEVICE_ROLE_ID = + UUID.fromString("0f14d0ab-9608-7862-a9e4-5ed26688389b").toString(); + private static final String UUID_FOR_DEVICE_ID = + UUID.fromString("9f14d0ab-9608-7862-a9e4-5ed26688389c").toString(); + + @Inject ContextSubscriber contextSubscriber; + + @InjectMock ContextGateway contextGateway; + + @InjectMock AutomationService automationService; + + @InjectMock AutomationConfiguration automationConfiguration; + + @Test + void shouldCallAddDeviceUponCreateEvent() { + final var uuidForDeviceRoleId = + ContextOuterClass.Uuid.newBuilder().setUuid(UUID_FOR_DEVICE_ROLE_ID).build(); + + final var uuidForDeviceId = + ContextOuterClass.Uuid.newBuilder().setUuid(UUID_FOR_DEVICE_ID).build(); + + final var outDeviceId = + ContextOuterClass.DeviceId.newBuilder().setDeviceUuid(uuidForDeviceId).build(); + + final var outDeviceRoleId = + Automation.DeviceRoleId.newBuilder() + .setDevRoleId(uuidForDeviceRoleId) + .setDevId(outDeviceId) + .build(); + + String deviceId = outDeviceRoleId.getDevId().toString(); + + Event event = new Event(3.4, EventTypeEnum.CREATE); + DeviceEvent deviceEvent = new DeviceEvent(deviceId, event); + final var deviceEventsMulti = Multi.createFrom().item(deviceEvent); + + Mockito.when(contextGateway.getDeviceEvents()).thenReturn(deviceEventsMulti); + + contextSubscriber.listenForDeviceEvents(); + + verify(automationService, times(1)).addDevice(deviceId); + } + + @Test + void shouldNotCallAddDeviceUponUpdateEvent() { + final var uuidForDeviceRoleId = + ContextOuterClass.Uuid.newBuilder().setUuid(UUID_FOR_DEVICE_ROLE_ID).build(); + + final var uuidForDeviceId = + ContextOuterClass.Uuid.newBuilder().setUuid(UUID_FOR_DEVICE_ID).build(); + + final var outDeviceId = + ContextOuterClass.DeviceId.newBuilder().setDeviceUuid(uuidForDeviceId).build(); + + final var outDeviceRoleId = + Automation.DeviceRoleId.newBuilder() + .setDevRoleId(uuidForDeviceRoleId) + .setDevId(outDeviceId) + .build(); + + String deviceId = outDeviceRoleId.getDevId().toString(); + + Event event = new Event(3.4, EventTypeEnum.UPDATE); + DeviceEvent deviceEvent = new DeviceEvent(deviceId, event); + final var deviceEventsMulti = Multi.createFrom().item(deviceEvent); + + Mockito.when(contextGateway.getDeviceEvents()).thenReturn(deviceEventsMulti); + + contextSubscriber.listenForDeviceEvents(); + + verify(automationService, times(0)).addDevice(deviceId); + } + + @Test + void shouldNotCallAddDeviceUponRemoveEvent() { + final var uuidForDeviceRoleId = + ContextOuterClass.Uuid.newBuilder().setUuid(UUID_FOR_DEVICE_ROLE_ID).build(); + + final var uuidForDeviceId = + ContextOuterClass.Uuid.newBuilder().setUuid(UUID_FOR_DEVICE_ID).build(); + + final var outDeviceId = + ContextOuterClass.DeviceId.newBuilder().setDeviceUuid(uuidForDeviceId).build(); + + final var outDeviceRoleId = + Automation.DeviceRoleId.newBuilder() + .setDevRoleId(uuidForDeviceRoleId) + .setDevId(outDeviceId) + .build(); + + String deviceId = outDeviceRoleId.getDevId().toString(); + + Event event = new Event(3.4, EventTypeEnum.REMOVE); + DeviceEvent deviceEvent = new DeviceEvent(deviceId, event); + final var deviceEventsMulti = Multi.createFrom().item(deviceEvent); + + Mockito.when(contextGateway.getDeviceEvents()).thenReturn(deviceEventsMulti); + + contextSubscriber.listenForDeviceEvents(); + + verify(automationService, times(0)).addDevice(deviceId); + } + + @Test + void shouldNotCallAddDeviceUponNullEvent() { + final var uuidForDeviceRoleId = + ContextOuterClass.Uuid.newBuilder().setUuid(UUID_FOR_DEVICE_ROLE_ID).build(); + + final var uuidForDeviceId = + ContextOuterClass.Uuid.newBuilder().setUuid(UUID_FOR_DEVICE_ID).build(); + + final var outDeviceId = + ContextOuterClass.DeviceId.newBuilder().setDeviceUuid(uuidForDeviceId).build(); + + final var outDeviceRoleId = + Automation.DeviceRoleId.newBuilder() + .setDevRoleId(uuidForDeviceRoleId) + .setDevId(outDeviceId) + .build(); + + String deviceId = outDeviceRoleId.getDevId().toString(); + + DeviceEvent deviceEvent = new DeviceEvent(deviceId, null); + final var deviceEventsMulti = Multi.createFrom().item(deviceEvent); + + Mockito.when(contextGateway.getDeviceEvents()).thenReturn(deviceEventsMulti); + + contextSubscriber.listenForDeviceEvents(); + + verify(automationService, times(0)).addDevice(deviceId); + } + + @Test + void shouldCallListenForDeviceEventsUponStart() { + final var uuidForDeviceRoleId = + ContextOuterClass.Uuid.newBuilder().setUuid(UUID_FOR_DEVICE_ROLE_ID).build(); + + final var uuidForDeviceId = + ContextOuterClass.Uuid.newBuilder().setUuid(UUID_FOR_DEVICE_ID).build(); + + final var outDeviceId = + ContextOuterClass.DeviceId.newBuilder().setDeviceUuid(uuidForDeviceId).build(); + + final var outDeviceRoleId = + Automation.DeviceRoleId.newBuilder() + .setDevRoleId(uuidForDeviceRoleId) + .setDevId(outDeviceId) + .build(); + + String deviceId = outDeviceRoleId.getDevId().toString(); + + Event event = new Event(3.4, EventTypeEnum.CREATE); + DeviceEvent deviceEvent = new DeviceEvent(deviceId, event); + final var deviceEventsMulti = Multi.createFrom().item(deviceEvent); + + Mockito.when(contextGateway.getDeviceEvents()).thenReturn(deviceEventsMulti); + Mockito.when(automationConfiguration.shouldSubscribeToContextComponent()).thenReturn(true); + + StartupEvent y = new StartupEvent(); + contextSubscriber.onStart(y); + + verify(contextGateway, times(1)).getDeviceEvents(); + verify(automationService, times(1)).addDevice(deviceId); + } + + @Test + void shouldNotCallListenForDeviceEventsUponStart() { + final var automationConfiguration = Mockito.mock(AutomationConfiguration.class); + Mockito.when(automationConfiguration.shouldSubscribeToContextComponent()).thenReturn(false); + + StartupEvent y = new StartupEvent(); + contextSubscriber.onStart(y); + + verify(contextGateway, times(0)).getDeviceEvents(); + } +} diff --git a/src/automation/src/test/java/eu/teraflow/automation/MockAutomationConfiguration.java b/src/automation/src/test/java/eu/teraflow/automation/MockAutomationConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..24c0433e0ed5fb5e3d20ff762f640406d8bf9f1b --- /dev/null +++ b/src/automation/src/test/java/eu/teraflow/automation/MockAutomationConfiguration.java @@ -0,0 +1,18 @@ +package eu.teraflow.automation; + +import io.smallrye.config.SmallRyeConfig; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.ws.rs.Produces; +import org.eclipse.microprofile.config.Config; + +public class MockAutomationConfiguration { + @Inject Config config; + + @Produces + @ApplicationScoped + @io.quarkus.test.Mock + AutomationConfiguration automationConfiguration() { + return config.unwrap(SmallRyeConfig.class).getConfigMapping(AutomationConfiguration.class); + } +} diff --git a/src/automation/src/test/java/eu/teraflow/automation/SerializerTest.java b/src/automation/src/test/java/eu/teraflow/automation/SerializerTest.java index 4d4a57da7286997c1194ccc5d711ab9999d39567..ff74148548e4f0b024a8a6835ee63a2e77d66a55 100644 --- a/src/automation/src/test/java/eu/teraflow/automation/SerializerTest.java +++ b/src/automation/src/test/java/eu/teraflow/automation/SerializerTest.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.automation; @@ -53,7 +53,8 @@ class SerializerTest { final var expectedDeviceId = "expectedDeviceId"; final var deviceIdUuid = serializer.serializeUuid(expectedDeviceId); - final var deviceId = ContextOuterClass.DeviceId.newBuilder().setDeviceUuid(deviceIdUuid).build(); + final var deviceId = + ContextOuterClass.DeviceId.newBuilder().setDeviceUuid(deviceIdUuid).build(); final var serializedDeviceId = serializer.serializeDeviceId(expectedDeviceId); @@ -65,7 +66,8 @@ class SerializerTest { final var expectedDeviceId = "expectedDeviceId"; final var serializedDeviceIdUuid = serializer.serializeUuid("expectedDeviceId"); - final var serializedDeviceId = DeviceId.newBuilder().setDeviceUuid(serializedDeviceIdUuid).build(); + final var serializedDeviceId = + DeviceId.newBuilder().setDeviceUuid(serializedDeviceIdUuid).build(); final var deviceId = serializer.deserialize(serializedDeviceId); @@ -80,7 +82,10 @@ class SerializerTest { final var deviceRoleId = new DeviceRoleId(expectedDevRoleId, expectedDeviceId); final var serializedDeviceRoleIdUuid = serializer.serializeUuid(expectedDevRoleId); final var serializedDeviceRoleDeviceIdUuid = serializer.serializeUuid(expectedDeviceId); - final var serializedDeviceRoleDeviceId = ContextOuterClass.DeviceId.newBuilder().setDeviceUuid(serializedDeviceRoleDeviceIdUuid).build(); + final var serializedDeviceRoleDeviceId = + ContextOuterClass.DeviceId.newBuilder() + .setDeviceUuid(serializedDeviceRoleDeviceIdUuid) + .build(); final var expectedDeviceRoleId = Automation.DeviceRoleId.newBuilder() @@ -88,8 +93,7 @@ class SerializerTest { .setDevId(serializedDeviceRoleDeviceId) .build(); - final var serializedDevRoleId = - serializer.serialize(deviceRoleId); + final var serializedDevRoleId = serializer.serialize(deviceRoleId); assertThat(serializedDevRoleId).usingRecursiveComparison().isEqualTo(expectedDeviceRoleId); } @@ -142,19 +146,21 @@ class SerializerTest { final var serializedDeviceRoleDevRoleIdUuid = serializer.serializeUuid(expectedDevRoleId); final var serializedDeviceRoleDeviceId = serializer.serializeDeviceId(expectedDeviceId); - final var expectedDeviceRoleId = Automation.DeviceRoleId.newBuilder() - .setDevRoleId(serializedDeviceRoleDevRoleIdUuid) - .setDevId(serializedDeviceRoleDeviceId) - .build(); + final var expectedDeviceRoleId = + Automation.DeviceRoleId.newBuilder() + .setDevRoleId(serializedDeviceRoleDevRoleIdUuid) + .setDevId(serializedDeviceRoleDeviceId) + .build(); final var expectedDeviceRoleType = Automation.DeviceRoleType.PIPELINE_CONF; - final var expectedDeviceRole = Automation.DeviceRole.newBuilder() - .setDevRoleId(expectedDeviceRoleId) - .setDevRoleType(expectedDeviceRoleType) - .build(); + final var expectedDeviceRole = + Automation.DeviceRole.newBuilder() + .setDevRoleId(expectedDeviceRoleId) + .setDevRoleType(expectedDeviceRoleType) + .build(); - final var deviceRoleId = new DeviceRoleId(expectedDevRoleId,expectedDeviceId); + final var deviceRoleId = new DeviceRoleId(expectedDevRoleId, expectedDeviceId); final var deviceRoleType = DeviceRoleType.PIPELINE_CONF; final var deviceRole = new DeviceRole(deviceRoleId, deviceRoleType); diff --git a/src/automation/target/generated-sources/grpc/context/ContextOuterClass.java b/src/automation/target/generated-sources/grpc/context/ContextOuterClass.java index 168ddf78b3a0233f3157e984fb7d925783bcd3b0..ee807d7a7c69256b7a4c99c5139fafe076898918 100644 --- a/src/automation/target/generated-sources/grpc/context/ContextOuterClass.java +++ b/src/automation/target/generated-sources/grpc/context/ContextOuterClass.java @@ -661,6 +661,141 @@ public final class ContextOuterClass { // @@protoc_insertion_point(enum_scope:context.ServiceStatusEnum) } + /** + * Protobuf enum {@code context.SliceStatusEnum} + */ + public enum SliceStatusEnum + implements com.google.protobuf.ProtocolMessageEnum { + /** + * <code>SLICESTATUS_UNDEFINED = 0;</code> + */ + SLICESTATUS_UNDEFINED(0), + /** + * <code>SLICESTATUS_PLANNED = 1;</code> + */ + SLICESTATUS_PLANNED(1), + /** + * <code>SLICESTATUS_INIT = 2;</code> + */ + SLICESTATUS_INIT(2), + /** + * <code>SLICESTATUS_ACTIVE = 3;</code> + */ + SLICESTATUS_ACTIVE(3), + /** + * <code>SLICESTATUS_DEINIT = 4;</code> + */ + SLICESTATUS_DEINIT(4), + UNRECOGNIZED(-1), + ; + + /** + * <code>SLICESTATUS_UNDEFINED = 0;</code> + */ + public static final int SLICESTATUS_UNDEFINED_VALUE = 0; + /** + * <code>SLICESTATUS_PLANNED = 1;</code> + */ + public static final int SLICESTATUS_PLANNED_VALUE = 1; + /** + * <code>SLICESTATUS_INIT = 2;</code> + */ + public static final int SLICESTATUS_INIT_VALUE = 2; + /** + * <code>SLICESTATUS_ACTIVE = 3;</code> + */ + public static final int SLICESTATUS_ACTIVE_VALUE = 3; + /** + * <code>SLICESTATUS_DEINIT = 4;</code> + */ + public static final int SLICESTATUS_DEINIT_VALUE = 4; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static SliceStatusEnum valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static SliceStatusEnum forNumber(int value) { + switch (value) { + case 0: return SLICESTATUS_UNDEFINED; + case 1: return SLICESTATUS_PLANNED; + case 2: return SLICESTATUS_INIT; + case 3: return SLICESTATUS_ACTIVE; + case 4: return SLICESTATUS_DEINIT; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap<SliceStatusEnum> + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + SliceStatusEnum> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap<SliceStatusEnum>() { + public SliceStatusEnum findValueByNumber(int number) { + return SliceStatusEnum.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return context.ContextOuterClass.getDescriptor().getEnumTypes().get(5); + } + + private static final SliceStatusEnum[] VALUES = values(); + + public static SliceStatusEnum valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private SliceStatusEnum(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:context.SliceStatusEnum) + } + /** * <pre> * ----- Configuration ------------------------------------------------------------------------------------------------- @@ -756,7 +891,7 @@ public final class ContextOuterClass { } public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return context.ContextOuterClass.getDescriptor().getEnumTypes().get(5); + return context.ContextOuterClass.getDescriptor().getEnumTypes().get(6); } private static final ConfigActionEnum[] VALUES = values(); @@ -27653,49 +27788,64 @@ public final class ContextOuterClass { } - public interface ConnectionIdOrBuilder extends - // @@protoc_insertion_point(interface_extends:context.ConnectionId) + public interface SliceIdOrBuilder extends + // @@protoc_insertion_point(interface_extends:context.SliceId) com.google.protobuf.MessageOrBuilder { /** - * <code>.context.Uuid connection_uuid = 1;</code> - * @return Whether the connectionUuid field is set. + * <code>.context.ContextId context_id = 1;</code> + * @return Whether the contextId field is set. */ - boolean hasConnectionUuid(); + boolean hasContextId(); /** - * <code>.context.Uuid connection_uuid = 1;</code> - * @return The connectionUuid. + * <code>.context.ContextId context_id = 1;</code> + * @return The contextId. */ - context.ContextOuterClass.Uuid getConnectionUuid(); + context.ContextOuterClass.ContextId getContextId(); /** - * <code>.context.Uuid connection_uuid = 1;</code> + * <code>.context.ContextId context_id = 1;</code> */ - context.ContextOuterClass.UuidOrBuilder getConnectionUuidOrBuilder(); + context.ContextOuterClass.ContextIdOrBuilder getContextIdOrBuilder(); + + /** + * <code>.context.Uuid slice_uuid = 2;</code> + * @return Whether the sliceUuid field is set. + */ + boolean hasSliceUuid(); + /** + * <code>.context.Uuid slice_uuid = 2;</code> + * @return The sliceUuid. + */ + context.ContextOuterClass.Uuid getSliceUuid(); + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + context.ContextOuterClass.UuidOrBuilder getSliceUuidOrBuilder(); } /** * <pre> - * ----- Connection ---------------------------------------------------------------------------------------------------- + * ----- Slice --------------------------------------------------------------------------------------------------------- * </pre> * - * Protobuf type {@code context.ConnectionId} + * Protobuf type {@code context.SliceId} */ - public static final class ConnectionId extends + public static final class SliceId extends com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:context.ConnectionId) - ConnectionIdOrBuilder { + // @@protoc_insertion_point(message_implements:context.SliceId) + SliceIdOrBuilder { private static final long serialVersionUID = 0L; - // Use ConnectionId.newBuilder() to construct. - private ConnectionId(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { + // Use SliceId.newBuilder() to construct. + private SliceId(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { super(builder); } - private ConnectionId() { + private SliceId() { } @java.lang.Override @SuppressWarnings({"unused"}) protected java.lang.Object newInstance( UnusedPrivateParameter unused) { - return new ConnectionId(); + return new SliceId(); } @java.lang.Override @@ -27703,7 +27853,7 @@ public final class ContextOuterClass { getUnknownFields() { return this.unknownFields; } - private ConnectionId( + private SliceId( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { @@ -27722,14 +27872,27 @@ public final class ContextOuterClass { done = true; break; case 10: { + context.ContextOuterClass.ContextId.Builder subBuilder = null; + if (contextId_ != null) { + subBuilder = contextId_.toBuilder(); + } + contextId_ = input.readMessage(context.ContextOuterClass.ContextId.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(contextId_); + contextId_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { context.ContextOuterClass.Uuid.Builder subBuilder = null; - if (connectionUuid_ != null) { - subBuilder = connectionUuid_.toBuilder(); + if (sliceUuid_ != null) { + subBuilder = sliceUuid_.toBuilder(); } - connectionUuid_ = input.readMessage(context.ContextOuterClass.Uuid.parser(), extensionRegistry); + sliceUuid_ = input.readMessage(context.ContextOuterClass.Uuid.parser(), extensionRegistry); if (subBuilder != null) { - subBuilder.mergeFrom(connectionUuid_); - connectionUuid_ = subBuilder.buildPartial(); + subBuilder.mergeFrom(sliceUuid_); + sliceUuid_ = subBuilder.buildPartial(); } break; @@ -27755,41 +27918,67 @@ public final class ContextOuterClass { } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return context.ContextOuterClass.internal_static_context_ConnectionId_descriptor; + return context.ContextOuterClass.internal_static_context_SliceId_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { - return context.ContextOuterClass.internal_static_context_ConnectionId_fieldAccessorTable + return context.ContextOuterClass.internal_static_context_SliceId_fieldAccessorTable .ensureFieldAccessorsInitialized( - context.ContextOuterClass.ConnectionId.class, context.ContextOuterClass.ConnectionId.Builder.class); + context.ContextOuterClass.SliceId.class, context.ContextOuterClass.SliceId.Builder.class); } - public static final int CONNECTION_UUID_FIELD_NUMBER = 1; - private context.ContextOuterClass.Uuid connectionUuid_; + public static final int CONTEXT_ID_FIELD_NUMBER = 1; + private context.ContextOuterClass.ContextId contextId_; /** - * <code>.context.Uuid connection_uuid = 1;</code> - * @return Whether the connectionUuid field is set. + * <code>.context.ContextId context_id = 1;</code> + * @return Whether the contextId field is set. */ @java.lang.Override - public boolean hasConnectionUuid() { - return connectionUuid_ != null; + public boolean hasContextId() { + return contextId_ != null; } /** - * <code>.context.Uuid connection_uuid = 1;</code> - * @return The connectionUuid. + * <code>.context.ContextId context_id = 1;</code> + * @return The contextId. */ @java.lang.Override - public context.ContextOuterClass.Uuid getConnectionUuid() { - return connectionUuid_ == null ? context.ContextOuterClass.Uuid.getDefaultInstance() : connectionUuid_; + public context.ContextOuterClass.ContextId getContextId() { + return contextId_ == null ? context.ContextOuterClass.ContextId.getDefaultInstance() : contextId_; } /** - * <code>.context.Uuid connection_uuid = 1;</code> + * <code>.context.ContextId context_id = 1;</code> */ @java.lang.Override - public context.ContextOuterClass.UuidOrBuilder getConnectionUuidOrBuilder() { - return getConnectionUuid(); + public context.ContextOuterClass.ContextIdOrBuilder getContextIdOrBuilder() { + return getContextId(); + } + + public static final int SLICE_UUID_FIELD_NUMBER = 2; + private context.ContextOuterClass.Uuid sliceUuid_; + /** + * <code>.context.Uuid slice_uuid = 2;</code> + * @return Whether the sliceUuid field is set. + */ + @java.lang.Override + public boolean hasSliceUuid() { + return sliceUuid_ != null; + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + * @return The sliceUuid. + */ + @java.lang.Override + public context.ContextOuterClass.Uuid getSliceUuid() { + return sliceUuid_ == null ? context.ContextOuterClass.Uuid.getDefaultInstance() : sliceUuid_; + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + @java.lang.Override + public context.ContextOuterClass.UuidOrBuilder getSliceUuidOrBuilder() { + return getSliceUuid(); } private byte memoizedIsInitialized = -1; @@ -27806,8 +27995,11 @@ public final class ContextOuterClass { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (connectionUuid_ != null) { - output.writeMessage(1, getConnectionUuid()); + if (contextId_ != null) { + output.writeMessage(1, getContextId()); + } + if (sliceUuid_ != null) { + output.writeMessage(2, getSliceUuid()); } unknownFields.writeTo(output); } @@ -27818,9 +28010,13 @@ public final class ContextOuterClass { if (size != -1) return size; size = 0; - if (connectionUuid_ != null) { + if (contextId_ != null) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, getConnectionUuid()); + .computeMessageSize(1, getContextId()); + } + if (sliceUuid_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getSliceUuid()); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -27832,15 +28028,20 @@ public final class ContextOuterClass { if (obj == this) { return true; } - if (!(obj instanceof context.ContextOuterClass.ConnectionId)) { + if (!(obj instanceof context.ContextOuterClass.SliceId)) { return super.equals(obj); } - context.ContextOuterClass.ConnectionId other = (context.ContextOuterClass.ConnectionId) obj; + context.ContextOuterClass.SliceId other = (context.ContextOuterClass.SliceId) obj; - if (hasConnectionUuid() != other.hasConnectionUuid()) return false; - if (hasConnectionUuid()) { - if (!getConnectionUuid() - .equals(other.getConnectionUuid())) return false; + if (hasContextId() != other.hasContextId()) return false; + if (hasContextId()) { + if (!getContextId() + .equals(other.getContextId())) return false; + } + if (hasSliceUuid() != other.hasSliceUuid()) return false; + if (hasSliceUuid()) { + if (!getSliceUuid() + .equals(other.getSliceUuid())) return false; } if (!unknownFields.equals(other.unknownFields)) return false; return true; @@ -27853,78 +28054,82 @@ public final class ContextOuterClass { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); - if (hasConnectionUuid()) { - hash = (37 * hash) + CONNECTION_UUID_FIELD_NUMBER; - hash = (53 * hash) + getConnectionUuid().hashCode(); + if (hasContextId()) { + hash = (37 * hash) + CONTEXT_ID_FIELD_NUMBER; + hash = (53 * hash) + getContextId().hashCode(); + } + if (hasSliceUuid()) { + hash = (37 * hash) + SLICE_UUID_FIELD_NUMBER; + hash = (53 * hash) + getSliceUuid().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static context.ContextOuterClass.ConnectionId parseFrom(byte[] data) + public static context.ContextOuterClass.SliceId parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static context.ContextOuterClass.ConnectionId parseFrom(java.io.InputStream input) + public static context.ContextOuterClass.SliceId parseFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input, extensionRegistry); } - public static context.ContextOuterClass.ConnectionId parseDelimitedFrom(java.io.InputStream input) + public static context.ContextOuterClass.SliceId parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input); } - public static context.ContextOuterClass.ConnectionId parseDelimitedFrom( + public static context.ContextOuterClass.SliceId parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { @@ -27937,7 +28142,7 @@ public final class ContextOuterClass { public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); } - public static Builder newBuilder(context.ContextOuterClass.ConnectionId prototype) { + public static Builder newBuilder(context.ContextOuterClass.SliceId prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } @java.lang.Override @@ -27954,29 +28159,29 @@ public final class ContextOuterClass { } /** * <pre> - * ----- Connection ---------------------------------------------------------------------------------------------------- + * ----- Slice --------------------------------------------------------------------------------------------------------- * </pre> * - * Protobuf type {@code context.ConnectionId} + * Protobuf type {@code context.SliceId} */ public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements - // @@protoc_insertion_point(builder_implements:context.ConnectionId) - context.ContextOuterClass.ConnectionIdOrBuilder { + // @@protoc_insertion_point(builder_implements:context.SliceId) + context.ContextOuterClass.SliceIdOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return context.ContextOuterClass.internal_static_context_ConnectionId_descriptor; + return context.ContextOuterClass.internal_static_context_SliceId_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { - return context.ContextOuterClass.internal_static_context_ConnectionId_fieldAccessorTable + return context.ContextOuterClass.internal_static_context_SliceId_fieldAccessorTable .ensureFieldAccessorsInitialized( - context.ContextOuterClass.ConnectionId.class, context.ContextOuterClass.ConnectionId.Builder.class); + context.ContextOuterClass.SliceId.class, context.ContextOuterClass.SliceId.Builder.class); } - // Construct using context.ContextOuterClass.ConnectionId.newBuilder() + // Construct using context.ContextOuterClass.SliceId.newBuilder() private Builder() { maybeForceBuilderInitialization(); } @@ -27994,11 +28199,17 @@ public final class ContextOuterClass { @java.lang.Override public Builder clear() { super.clear(); - if (connectionUuidBuilder_ == null) { - connectionUuid_ = null; + if (contextIdBuilder_ == null) { + contextId_ = null; } else { - connectionUuid_ = null; - connectionUuidBuilder_ = null; + contextId_ = null; + contextIdBuilder_ = null; + } + if (sliceUuidBuilder_ == null) { + sliceUuid_ = null; + } else { + sliceUuid_ = null; + sliceUuidBuilder_ = null; } return this; } @@ -28006,17 +28217,17 @@ public final class ContextOuterClass { @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return context.ContextOuterClass.internal_static_context_ConnectionId_descriptor; + return context.ContextOuterClass.internal_static_context_SliceId_descriptor; } @java.lang.Override - public context.ContextOuterClass.ConnectionId getDefaultInstanceForType() { - return context.ContextOuterClass.ConnectionId.getDefaultInstance(); + public context.ContextOuterClass.SliceId getDefaultInstanceForType() { + return context.ContextOuterClass.SliceId.getDefaultInstance(); } @java.lang.Override - public context.ContextOuterClass.ConnectionId build() { - context.ContextOuterClass.ConnectionId result = buildPartial(); + public context.ContextOuterClass.SliceId build() { + context.ContextOuterClass.SliceId result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } @@ -28024,12 +28235,6018 @@ public final class ContextOuterClass { } @java.lang.Override - public context.ContextOuterClass.ConnectionId buildPartial() { - context.ContextOuterClass.ConnectionId result = new context.ContextOuterClass.ConnectionId(this); - if (connectionUuidBuilder_ == null) { - result.connectionUuid_ = connectionUuid_; + public context.ContextOuterClass.SliceId buildPartial() { + context.ContextOuterClass.SliceId result = new context.ContextOuterClass.SliceId(this); + if (contextIdBuilder_ == null) { + result.contextId_ = contextId_; } else { - result.connectionUuid_ = connectionUuidBuilder_.build(); + result.contextId_ = contextIdBuilder_.build(); + } + if (sliceUuidBuilder_ == null) { + result.sliceUuid_ = sliceUuid_; + } else { + result.sliceUuid_ = sliceUuidBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof context.ContextOuterClass.SliceId) { + return mergeFrom((context.ContextOuterClass.SliceId)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(context.ContextOuterClass.SliceId other) { + if (other == context.ContextOuterClass.SliceId.getDefaultInstance()) return this; + if (other.hasContextId()) { + mergeContextId(other.getContextId()); + } + if (other.hasSliceUuid()) { + mergeSliceUuid(other.getSliceUuid()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + context.ContextOuterClass.SliceId parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (context.ContextOuterClass.SliceId) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private context.ContextOuterClass.ContextId contextId_; + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.ContextId, context.ContextOuterClass.ContextId.Builder, context.ContextOuterClass.ContextIdOrBuilder> contextIdBuilder_; + /** + * <code>.context.ContextId context_id = 1;</code> + * @return Whether the contextId field is set. + */ + public boolean hasContextId() { + return contextIdBuilder_ != null || contextId_ != null; + } + /** + * <code>.context.ContextId context_id = 1;</code> + * @return The contextId. + */ + public context.ContextOuterClass.ContextId getContextId() { + if (contextIdBuilder_ == null) { + return contextId_ == null ? context.ContextOuterClass.ContextId.getDefaultInstance() : contextId_; + } else { + return contextIdBuilder_.getMessage(); + } + } + /** + * <code>.context.ContextId context_id = 1;</code> + */ + public Builder setContextId(context.ContextOuterClass.ContextId value) { + if (contextIdBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + contextId_ = value; + onChanged(); + } else { + contextIdBuilder_.setMessage(value); + } + + return this; + } + /** + * <code>.context.ContextId context_id = 1;</code> + */ + public Builder setContextId( + context.ContextOuterClass.ContextId.Builder builderForValue) { + if (contextIdBuilder_ == null) { + contextId_ = builderForValue.build(); + onChanged(); + } else { + contextIdBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * <code>.context.ContextId context_id = 1;</code> + */ + public Builder mergeContextId(context.ContextOuterClass.ContextId value) { + if (contextIdBuilder_ == null) { + if (contextId_ != null) { + contextId_ = + context.ContextOuterClass.ContextId.newBuilder(contextId_).mergeFrom(value).buildPartial(); + } else { + contextId_ = value; + } + onChanged(); + } else { + contextIdBuilder_.mergeFrom(value); + } + + return this; + } + /** + * <code>.context.ContextId context_id = 1;</code> + */ + public Builder clearContextId() { + if (contextIdBuilder_ == null) { + contextId_ = null; + onChanged(); + } else { + contextId_ = null; + contextIdBuilder_ = null; + } + + return this; + } + /** + * <code>.context.ContextId context_id = 1;</code> + */ + public context.ContextOuterClass.ContextId.Builder getContextIdBuilder() { + + onChanged(); + return getContextIdFieldBuilder().getBuilder(); + } + /** + * <code>.context.ContextId context_id = 1;</code> + */ + public context.ContextOuterClass.ContextIdOrBuilder getContextIdOrBuilder() { + if (contextIdBuilder_ != null) { + return contextIdBuilder_.getMessageOrBuilder(); + } else { + return contextId_ == null ? + context.ContextOuterClass.ContextId.getDefaultInstance() : contextId_; + } + } + /** + * <code>.context.ContextId context_id = 1;</code> + */ + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.ContextId, context.ContextOuterClass.ContextId.Builder, context.ContextOuterClass.ContextIdOrBuilder> + getContextIdFieldBuilder() { + if (contextIdBuilder_ == null) { + contextIdBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.ContextId, context.ContextOuterClass.ContextId.Builder, context.ContextOuterClass.ContextIdOrBuilder>( + getContextId(), + getParentForChildren(), + isClean()); + contextId_ = null; + } + return contextIdBuilder_; + } + + private context.ContextOuterClass.Uuid sliceUuid_; + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.Uuid, context.ContextOuterClass.Uuid.Builder, context.ContextOuterClass.UuidOrBuilder> sliceUuidBuilder_; + /** + * <code>.context.Uuid slice_uuid = 2;</code> + * @return Whether the sliceUuid field is set. + */ + public boolean hasSliceUuid() { + return sliceUuidBuilder_ != null || sliceUuid_ != null; + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + * @return The sliceUuid. + */ + public context.ContextOuterClass.Uuid getSliceUuid() { + if (sliceUuidBuilder_ == null) { + return sliceUuid_ == null ? context.ContextOuterClass.Uuid.getDefaultInstance() : sliceUuid_; + } else { + return sliceUuidBuilder_.getMessage(); + } + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + public Builder setSliceUuid(context.ContextOuterClass.Uuid value) { + if (sliceUuidBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + sliceUuid_ = value; + onChanged(); + } else { + sliceUuidBuilder_.setMessage(value); + } + + return this; + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + public Builder setSliceUuid( + context.ContextOuterClass.Uuid.Builder builderForValue) { + if (sliceUuidBuilder_ == null) { + sliceUuid_ = builderForValue.build(); + onChanged(); + } else { + sliceUuidBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + public Builder mergeSliceUuid(context.ContextOuterClass.Uuid value) { + if (sliceUuidBuilder_ == null) { + if (sliceUuid_ != null) { + sliceUuid_ = + context.ContextOuterClass.Uuid.newBuilder(sliceUuid_).mergeFrom(value).buildPartial(); + } else { + sliceUuid_ = value; + } + onChanged(); + } else { + sliceUuidBuilder_.mergeFrom(value); + } + + return this; + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + public Builder clearSliceUuid() { + if (sliceUuidBuilder_ == null) { + sliceUuid_ = null; + onChanged(); + } else { + sliceUuid_ = null; + sliceUuidBuilder_ = null; + } + + return this; + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + public context.ContextOuterClass.Uuid.Builder getSliceUuidBuilder() { + + onChanged(); + return getSliceUuidFieldBuilder().getBuilder(); + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + public context.ContextOuterClass.UuidOrBuilder getSliceUuidOrBuilder() { + if (sliceUuidBuilder_ != null) { + return sliceUuidBuilder_.getMessageOrBuilder(); + } else { + return sliceUuid_ == null ? + context.ContextOuterClass.Uuid.getDefaultInstance() : sliceUuid_; + } + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.Uuid, context.ContextOuterClass.Uuid.Builder, context.ContextOuterClass.UuidOrBuilder> + getSliceUuidFieldBuilder() { + if (sliceUuidBuilder_ == null) { + sliceUuidBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.Uuid, context.ContextOuterClass.Uuid.Builder, context.ContextOuterClass.UuidOrBuilder>( + getSliceUuid(), + getParentForChildren(), + isClean()); + sliceUuid_ = null; + } + return sliceUuidBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:context.SliceId) + } + + // @@protoc_insertion_point(class_scope:context.SliceId) + private static final context.ContextOuterClass.SliceId DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new context.ContextOuterClass.SliceId(); + } + + public static context.ContextOuterClass.SliceId getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser<SliceId> + PARSER = new com.google.protobuf.AbstractParser<SliceId>() { + @java.lang.Override + public SliceId parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SliceId(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser<SliceId> parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser<SliceId> getParserForType() { + return PARSER; + } + + @java.lang.Override + public context.ContextOuterClass.SliceId getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SliceOrBuilder extends + // @@protoc_insertion_point(interface_extends:context.Slice) + com.google.protobuf.MessageOrBuilder { + + /** + * <code>.context.SliceId slice_id = 1;</code> + * @return Whether the sliceId field is set. + */ + boolean hasSliceId(); + /** + * <code>.context.SliceId slice_id = 1;</code> + * @return The sliceId. + */ + context.ContextOuterClass.SliceId getSliceId(); + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + context.ContextOuterClass.SliceIdOrBuilder getSliceIdOrBuilder(); + + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + java.util.List<context.ContextOuterClass.EndPointId> + getSliceEndpointIdsList(); + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + context.ContextOuterClass.EndPointId getSliceEndpointIds(int index); + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + int getSliceEndpointIdsCount(); + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + java.util.List<? extends context.ContextOuterClass.EndPointIdOrBuilder> + getSliceEndpointIdsOrBuilderList(); + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + context.ContextOuterClass.EndPointIdOrBuilder getSliceEndpointIdsOrBuilder( + int index); + + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + java.util.List<context.ContextOuterClass.Constraint> + getSliceConstraintsList(); + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + context.ContextOuterClass.Constraint getSliceConstraints(int index); + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + int getSliceConstraintsCount(); + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + java.util.List<? extends context.ContextOuterClass.ConstraintOrBuilder> + getSliceConstraintsOrBuilderList(); + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + context.ContextOuterClass.ConstraintOrBuilder getSliceConstraintsOrBuilder( + int index); + + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + java.util.List<context.ContextOuterClass.ServiceId> + getSliceServiceIdsList(); + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + context.ContextOuterClass.ServiceId getSliceServiceIds(int index); + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + int getSliceServiceIdsCount(); + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + java.util.List<? extends context.ContextOuterClass.ServiceIdOrBuilder> + getSliceServiceIdsOrBuilderList(); + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + context.ContextOuterClass.ServiceIdOrBuilder getSliceServiceIdsOrBuilder( + int index); + + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + java.util.List<context.ContextOuterClass.SliceId> + getSliceSubsliceIdsList(); + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + context.ContextOuterClass.SliceId getSliceSubsliceIds(int index); + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + int getSliceSubsliceIdsCount(); + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + java.util.List<? extends context.ContextOuterClass.SliceIdOrBuilder> + getSliceSubsliceIdsOrBuilderList(); + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + context.ContextOuterClass.SliceIdOrBuilder getSliceSubsliceIdsOrBuilder( + int index); + + /** + * <code>.context.SliceStatus slice_status = 6;</code> + * @return Whether the sliceStatus field is set. + */ + boolean hasSliceStatus(); + /** + * <code>.context.SliceStatus slice_status = 6;</code> + * @return The sliceStatus. + */ + context.ContextOuterClass.SliceStatus getSliceStatus(); + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + context.ContextOuterClass.SliceStatusOrBuilder getSliceStatusOrBuilder(); + } + /** + * Protobuf type {@code context.Slice} + */ + public static final class Slice extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:context.Slice) + SliceOrBuilder { + private static final long serialVersionUID = 0L; + // Use Slice.newBuilder() to construct. + private Slice(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { + super(builder); + } + private Slice() { + sliceEndpointIds_ = java.util.Collections.emptyList(); + sliceConstraints_ = java.util.Collections.emptyList(); + sliceServiceIds_ = java.util.Collections.emptyList(); + sliceSubsliceIds_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new Slice(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Slice( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + context.ContextOuterClass.SliceId.Builder subBuilder = null; + if (sliceId_ != null) { + subBuilder = sliceId_.toBuilder(); + } + sliceId_ = input.readMessage(context.ContextOuterClass.SliceId.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(sliceId_); + sliceId_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + sliceEndpointIds_ = new java.util.ArrayList<context.ContextOuterClass.EndPointId>(); + mutable_bitField0_ |= 0x00000001; + } + sliceEndpointIds_.add( + input.readMessage(context.ContextOuterClass.EndPointId.parser(), extensionRegistry)); + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000002) != 0)) { + sliceConstraints_ = new java.util.ArrayList<context.ContextOuterClass.Constraint>(); + mutable_bitField0_ |= 0x00000002; + } + sliceConstraints_.add( + input.readMessage(context.ContextOuterClass.Constraint.parser(), extensionRegistry)); + break; + } + case 34: { + if (!((mutable_bitField0_ & 0x00000004) != 0)) { + sliceServiceIds_ = new java.util.ArrayList<context.ContextOuterClass.ServiceId>(); + mutable_bitField0_ |= 0x00000004; + } + sliceServiceIds_.add( + input.readMessage(context.ContextOuterClass.ServiceId.parser(), extensionRegistry)); + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000008) != 0)) { + sliceSubsliceIds_ = new java.util.ArrayList<context.ContextOuterClass.SliceId>(); + mutable_bitField0_ |= 0x00000008; + } + sliceSubsliceIds_.add( + input.readMessage(context.ContextOuterClass.SliceId.parser(), extensionRegistry)); + break; + } + case 50: { + context.ContextOuterClass.SliceStatus.Builder subBuilder = null; + if (sliceStatus_ != null) { + subBuilder = sliceStatus_.toBuilder(); + } + sliceStatus_ = input.readMessage(context.ContextOuterClass.SliceStatus.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(sliceStatus_); + sliceStatus_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + sliceEndpointIds_ = java.util.Collections.unmodifiableList(sliceEndpointIds_); + } + if (((mutable_bitField0_ & 0x00000002) != 0)) { + sliceConstraints_ = java.util.Collections.unmodifiableList(sliceConstraints_); + } + if (((mutable_bitField0_ & 0x00000004) != 0)) { + sliceServiceIds_ = java.util.Collections.unmodifiableList(sliceServiceIds_); + } + if (((mutable_bitField0_ & 0x00000008) != 0)) { + sliceSubsliceIds_ = java.util.Collections.unmodifiableList(sliceSubsliceIds_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_Slice_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_Slice_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.Slice.class, context.ContextOuterClass.Slice.Builder.class); + } + + public static final int SLICE_ID_FIELD_NUMBER = 1; + private context.ContextOuterClass.SliceId sliceId_; + /** + * <code>.context.SliceId slice_id = 1;</code> + * @return Whether the sliceId field is set. + */ + @java.lang.Override + public boolean hasSliceId() { + return sliceId_ != null; + } + /** + * <code>.context.SliceId slice_id = 1;</code> + * @return The sliceId. + */ + @java.lang.Override + public context.ContextOuterClass.SliceId getSliceId() { + return sliceId_ == null ? context.ContextOuterClass.SliceId.getDefaultInstance() : sliceId_; + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceIdOrBuilder getSliceIdOrBuilder() { + return getSliceId(); + } + + public static final int SLICE_ENDPOINT_IDS_FIELD_NUMBER = 2; + private java.util.List<context.ContextOuterClass.EndPointId> sliceEndpointIds_; + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + @java.lang.Override + public java.util.List<context.ContextOuterClass.EndPointId> getSliceEndpointIdsList() { + return sliceEndpointIds_; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + @java.lang.Override + public java.util.List<? extends context.ContextOuterClass.EndPointIdOrBuilder> + getSliceEndpointIdsOrBuilderList() { + return sliceEndpointIds_; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + @java.lang.Override + public int getSliceEndpointIdsCount() { + return sliceEndpointIds_.size(); + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + @java.lang.Override + public context.ContextOuterClass.EndPointId getSliceEndpointIds(int index) { + return sliceEndpointIds_.get(index); + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + @java.lang.Override + public context.ContextOuterClass.EndPointIdOrBuilder getSliceEndpointIdsOrBuilder( + int index) { + return sliceEndpointIds_.get(index); + } + + public static final int SLICE_CONSTRAINTS_FIELD_NUMBER = 3; + private java.util.List<context.ContextOuterClass.Constraint> sliceConstraints_; + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + @java.lang.Override + public java.util.List<context.ContextOuterClass.Constraint> getSliceConstraintsList() { + return sliceConstraints_; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + @java.lang.Override + public java.util.List<? extends context.ContextOuterClass.ConstraintOrBuilder> + getSliceConstraintsOrBuilderList() { + return sliceConstraints_; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + @java.lang.Override + public int getSliceConstraintsCount() { + return sliceConstraints_.size(); + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + @java.lang.Override + public context.ContextOuterClass.Constraint getSliceConstraints(int index) { + return sliceConstraints_.get(index); + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + @java.lang.Override + public context.ContextOuterClass.ConstraintOrBuilder getSliceConstraintsOrBuilder( + int index) { + return sliceConstraints_.get(index); + } + + public static final int SLICE_SERVICE_IDS_FIELD_NUMBER = 4; + private java.util.List<context.ContextOuterClass.ServiceId> sliceServiceIds_; + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + @java.lang.Override + public java.util.List<context.ContextOuterClass.ServiceId> getSliceServiceIdsList() { + return sliceServiceIds_; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + @java.lang.Override + public java.util.List<? extends context.ContextOuterClass.ServiceIdOrBuilder> + getSliceServiceIdsOrBuilderList() { + return sliceServiceIds_; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + @java.lang.Override + public int getSliceServiceIdsCount() { + return sliceServiceIds_.size(); + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + @java.lang.Override + public context.ContextOuterClass.ServiceId getSliceServiceIds(int index) { + return sliceServiceIds_.get(index); + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + @java.lang.Override + public context.ContextOuterClass.ServiceIdOrBuilder getSliceServiceIdsOrBuilder( + int index) { + return sliceServiceIds_.get(index); + } + + public static final int SLICE_SUBSLICE_IDS_FIELD_NUMBER = 5; + private java.util.List<context.ContextOuterClass.SliceId> sliceSubsliceIds_; + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + @java.lang.Override + public java.util.List<context.ContextOuterClass.SliceId> getSliceSubsliceIdsList() { + return sliceSubsliceIds_; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + @java.lang.Override + public java.util.List<? extends context.ContextOuterClass.SliceIdOrBuilder> + getSliceSubsliceIdsOrBuilderList() { + return sliceSubsliceIds_; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + @java.lang.Override + public int getSliceSubsliceIdsCount() { + return sliceSubsliceIds_.size(); + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceId getSliceSubsliceIds(int index) { + return sliceSubsliceIds_.get(index); + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceIdOrBuilder getSliceSubsliceIdsOrBuilder( + int index) { + return sliceSubsliceIds_.get(index); + } + + public static final int SLICE_STATUS_FIELD_NUMBER = 6; + private context.ContextOuterClass.SliceStatus sliceStatus_; + /** + * <code>.context.SliceStatus slice_status = 6;</code> + * @return Whether the sliceStatus field is set. + */ + @java.lang.Override + public boolean hasSliceStatus() { + return sliceStatus_ != null; + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + * @return The sliceStatus. + */ + @java.lang.Override + public context.ContextOuterClass.SliceStatus getSliceStatus() { + return sliceStatus_ == null ? context.ContextOuterClass.SliceStatus.getDefaultInstance() : sliceStatus_; + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceStatusOrBuilder getSliceStatusOrBuilder() { + return getSliceStatus(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (sliceId_ != null) { + output.writeMessage(1, getSliceId()); + } + for (int i = 0; i < sliceEndpointIds_.size(); i++) { + output.writeMessage(2, sliceEndpointIds_.get(i)); + } + for (int i = 0; i < sliceConstraints_.size(); i++) { + output.writeMessage(3, sliceConstraints_.get(i)); + } + for (int i = 0; i < sliceServiceIds_.size(); i++) { + output.writeMessage(4, sliceServiceIds_.get(i)); + } + for (int i = 0; i < sliceSubsliceIds_.size(); i++) { + output.writeMessage(5, sliceSubsliceIds_.get(i)); + } + if (sliceStatus_ != null) { + output.writeMessage(6, getSliceStatus()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (sliceId_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getSliceId()); + } + for (int i = 0; i < sliceEndpointIds_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, sliceEndpointIds_.get(i)); + } + for (int i = 0; i < sliceConstraints_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, sliceConstraints_.get(i)); + } + for (int i = 0; i < sliceServiceIds_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, sliceServiceIds_.get(i)); + } + for (int i = 0; i < sliceSubsliceIds_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, sliceSubsliceIds_.get(i)); + } + if (sliceStatus_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, getSliceStatus()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof context.ContextOuterClass.Slice)) { + return super.equals(obj); + } + context.ContextOuterClass.Slice other = (context.ContextOuterClass.Slice) obj; + + if (hasSliceId() != other.hasSliceId()) return false; + if (hasSliceId()) { + if (!getSliceId() + .equals(other.getSliceId())) return false; + } + if (!getSliceEndpointIdsList() + .equals(other.getSliceEndpointIdsList())) return false; + if (!getSliceConstraintsList() + .equals(other.getSliceConstraintsList())) return false; + if (!getSliceServiceIdsList() + .equals(other.getSliceServiceIdsList())) return false; + if (!getSliceSubsliceIdsList() + .equals(other.getSliceSubsliceIdsList())) return false; + if (hasSliceStatus() != other.hasSliceStatus()) return false; + if (hasSliceStatus()) { + if (!getSliceStatus() + .equals(other.getSliceStatus())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasSliceId()) { + hash = (37 * hash) + SLICE_ID_FIELD_NUMBER; + hash = (53 * hash) + getSliceId().hashCode(); + } + if (getSliceEndpointIdsCount() > 0) { + hash = (37 * hash) + SLICE_ENDPOINT_IDS_FIELD_NUMBER; + hash = (53 * hash) + getSliceEndpointIdsList().hashCode(); + } + if (getSliceConstraintsCount() > 0) { + hash = (37 * hash) + SLICE_CONSTRAINTS_FIELD_NUMBER; + hash = (53 * hash) + getSliceConstraintsList().hashCode(); + } + if (getSliceServiceIdsCount() > 0) { + hash = (37 * hash) + SLICE_SERVICE_IDS_FIELD_NUMBER; + hash = (53 * hash) + getSliceServiceIdsList().hashCode(); + } + if (getSliceSubsliceIdsCount() > 0) { + hash = (37 * hash) + SLICE_SUBSLICE_IDS_FIELD_NUMBER; + hash = (53 * hash) + getSliceSubsliceIdsList().hashCode(); + } + if (hasSliceStatus()) { + hash = (37 * hash) + SLICE_STATUS_FIELD_NUMBER; + hash = (53 * hash) + getSliceStatus().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static context.ContextOuterClass.Slice parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.Slice parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.Slice parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.Slice parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.Slice parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.Slice parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.Slice parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.Slice parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.Slice parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static context.ContextOuterClass.Slice parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.Slice parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.Slice parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(context.ContextOuterClass.Slice prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code context.Slice} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements + // @@protoc_insertion_point(builder_implements:context.Slice) + context.ContextOuterClass.SliceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_Slice_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_Slice_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.Slice.class, context.ContextOuterClass.Slice.Builder.class); + } + + // Construct using context.ContextOuterClass.Slice.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getSliceEndpointIdsFieldBuilder(); + getSliceConstraintsFieldBuilder(); + getSliceServiceIdsFieldBuilder(); + getSliceSubsliceIdsFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (sliceIdBuilder_ == null) { + sliceId_ = null; + } else { + sliceId_ = null; + sliceIdBuilder_ = null; + } + if (sliceEndpointIdsBuilder_ == null) { + sliceEndpointIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + sliceEndpointIdsBuilder_.clear(); + } + if (sliceConstraintsBuilder_ == null) { + sliceConstraints_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + sliceConstraintsBuilder_.clear(); + } + if (sliceServiceIdsBuilder_ == null) { + sliceServiceIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + sliceServiceIdsBuilder_.clear(); + } + if (sliceSubsliceIdsBuilder_ == null) { + sliceSubsliceIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + } else { + sliceSubsliceIdsBuilder_.clear(); + } + if (sliceStatusBuilder_ == null) { + sliceStatus_ = null; + } else { + sliceStatus_ = null; + sliceStatusBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return context.ContextOuterClass.internal_static_context_Slice_descriptor; + } + + @java.lang.Override + public context.ContextOuterClass.Slice getDefaultInstanceForType() { + return context.ContextOuterClass.Slice.getDefaultInstance(); + } + + @java.lang.Override + public context.ContextOuterClass.Slice build() { + context.ContextOuterClass.Slice result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public context.ContextOuterClass.Slice buildPartial() { + context.ContextOuterClass.Slice result = new context.ContextOuterClass.Slice(this); + int from_bitField0_ = bitField0_; + if (sliceIdBuilder_ == null) { + result.sliceId_ = sliceId_; + } else { + result.sliceId_ = sliceIdBuilder_.build(); + } + if (sliceEndpointIdsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + sliceEndpointIds_ = java.util.Collections.unmodifiableList(sliceEndpointIds_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.sliceEndpointIds_ = sliceEndpointIds_; + } else { + result.sliceEndpointIds_ = sliceEndpointIdsBuilder_.build(); + } + if (sliceConstraintsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + sliceConstraints_ = java.util.Collections.unmodifiableList(sliceConstraints_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.sliceConstraints_ = sliceConstraints_; + } else { + result.sliceConstraints_ = sliceConstraintsBuilder_.build(); + } + if (sliceServiceIdsBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0)) { + sliceServiceIds_ = java.util.Collections.unmodifiableList(sliceServiceIds_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.sliceServiceIds_ = sliceServiceIds_; + } else { + result.sliceServiceIds_ = sliceServiceIdsBuilder_.build(); + } + if (sliceSubsliceIdsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0)) { + sliceSubsliceIds_ = java.util.Collections.unmodifiableList(sliceSubsliceIds_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.sliceSubsliceIds_ = sliceSubsliceIds_; + } else { + result.sliceSubsliceIds_ = sliceSubsliceIdsBuilder_.build(); + } + if (sliceStatusBuilder_ == null) { + result.sliceStatus_ = sliceStatus_; + } else { + result.sliceStatus_ = sliceStatusBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof context.ContextOuterClass.Slice) { + return mergeFrom((context.ContextOuterClass.Slice)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(context.ContextOuterClass.Slice other) { + if (other == context.ContextOuterClass.Slice.getDefaultInstance()) return this; + if (other.hasSliceId()) { + mergeSliceId(other.getSliceId()); + } + if (sliceEndpointIdsBuilder_ == null) { + if (!other.sliceEndpointIds_.isEmpty()) { + if (sliceEndpointIds_.isEmpty()) { + sliceEndpointIds_ = other.sliceEndpointIds_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.addAll(other.sliceEndpointIds_); + } + onChanged(); + } + } else { + if (!other.sliceEndpointIds_.isEmpty()) { + if (sliceEndpointIdsBuilder_.isEmpty()) { + sliceEndpointIdsBuilder_.dispose(); + sliceEndpointIdsBuilder_ = null; + sliceEndpointIds_ = other.sliceEndpointIds_; + bitField0_ = (bitField0_ & ~0x00000001); + sliceEndpointIdsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSliceEndpointIdsFieldBuilder() : null; + } else { + sliceEndpointIdsBuilder_.addAllMessages(other.sliceEndpointIds_); + } + } + } + if (sliceConstraintsBuilder_ == null) { + if (!other.sliceConstraints_.isEmpty()) { + if (sliceConstraints_.isEmpty()) { + sliceConstraints_ = other.sliceConstraints_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureSliceConstraintsIsMutable(); + sliceConstraints_.addAll(other.sliceConstraints_); + } + onChanged(); + } + } else { + if (!other.sliceConstraints_.isEmpty()) { + if (sliceConstraintsBuilder_.isEmpty()) { + sliceConstraintsBuilder_.dispose(); + sliceConstraintsBuilder_ = null; + sliceConstraints_ = other.sliceConstraints_; + bitField0_ = (bitField0_ & ~0x00000002); + sliceConstraintsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSliceConstraintsFieldBuilder() : null; + } else { + sliceConstraintsBuilder_.addAllMessages(other.sliceConstraints_); + } + } + } + if (sliceServiceIdsBuilder_ == null) { + if (!other.sliceServiceIds_.isEmpty()) { + if (sliceServiceIds_.isEmpty()) { + sliceServiceIds_ = other.sliceServiceIds_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.addAll(other.sliceServiceIds_); + } + onChanged(); + } + } else { + if (!other.sliceServiceIds_.isEmpty()) { + if (sliceServiceIdsBuilder_.isEmpty()) { + sliceServiceIdsBuilder_.dispose(); + sliceServiceIdsBuilder_ = null; + sliceServiceIds_ = other.sliceServiceIds_; + bitField0_ = (bitField0_ & ~0x00000004); + sliceServiceIdsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSliceServiceIdsFieldBuilder() : null; + } else { + sliceServiceIdsBuilder_.addAllMessages(other.sliceServiceIds_); + } + } + } + if (sliceSubsliceIdsBuilder_ == null) { + if (!other.sliceSubsliceIds_.isEmpty()) { + if (sliceSubsliceIds_.isEmpty()) { + sliceSubsliceIds_ = other.sliceSubsliceIds_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.addAll(other.sliceSubsliceIds_); + } + onChanged(); + } + } else { + if (!other.sliceSubsliceIds_.isEmpty()) { + if (sliceSubsliceIdsBuilder_.isEmpty()) { + sliceSubsliceIdsBuilder_.dispose(); + sliceSubsliceIdsBuilder_ = null; + sliceSubsliceIds_ = other.sliceSubsliceIds_; + bitField0_ = (bitField0_ & ~0x00000008); + sliceSubsliceIdsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSliceSubsliceIdsFieldBuilder() : null; + } else { + sliceSubsliceIdsBuilder_.addAllMessages(other.sliceSubsliceIds_); + } + } + } + if (other.hasSliceStatus()) { + mergeSliceStatus(other.getSliceStatus()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + context.ContextOuterClass.Slice parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (context.ContextOuterClass.Slice) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private context.ContextOuterClass.SliceId sliceId_; + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> sliceIdBuilder_; + /** + * <code>.context.SliceId slice_id = 1;</code> + * @return Whether the sliceId field is set. + */ + public boolean hasSliceId() { + return sliceIdBuilder_ != null || sliceId_ != null; + } + /** + * <code>.context.SliceId slice_id = 1;</code> + * @return The sliceId. + */ + public context.ContextOuterClass.SliceId getSliceId() { + if (sliceIdBuilder_ == null) { + return sliceId_ == null ? context.ContextOuterClass.SliceId.getDefaultInstance() : sliceId_; + } else { + return sliceIdBuilder_.getMessage(); + } + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + public Builder setSliceId(context.ContextOuterClass.SliceId value) { + if (sliceIdBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + sliceId_ = value; + onChanged(); + } else { + sliceIdBuilder_.setMessage(value); + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + public Builder setSliceId( + context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceIdBuilder_ == null) { + sliceId_ = builderForValue.build(); + onChanged(); + } else { + sliceIdBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + public Builder mergeSliceId(context.ContextOuterClass.SliceId value) { + if (sliceIdBuilder_ == null) { + if (sliceId_ != null) { + sliceId_ = + context.ContextOuterClass.SliceId.newBuilder(sliceId_).mergeFrom(value).buildPartial(); + } else { + sliceId_ = value; + } + onChanged(); + } else { + sliceIdBuilder_.mergeFrom(value); + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + public Builder clearSliceId() { + if (sliceIdBuilder_ == null) { + sliceId_ = null; + onChanged(); + } else { + sliceId_ = null; + sliceIdBuilder_ = null; + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + public context.ContextOuterClass.SliceId.Builder getSliceIdBuilder() { + + onChanged(); + return getSliceIdFieldBuilder().getBuilder(); + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + public context.ContextOuterClass.SliceIdOrBuilder getSliceIdOrBuilder() { + if (sliceIdBuilder_ != null) { + return sliceIdBuilder_.getMessageOrBuilder(); + } else { + return sliceId_ == null ? + context.ContextOuterClass.SliceId.getDefaultInstance() : sliceId_; + } + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> + getSliceIdFieldBuilder() { + if (sliceIdBuilder_ == null) { + sliceIdBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder>( + getSliceId(), + getParentForChildren(), + isClean()); + sliceId_ = null; + } + return sliceIdBuilder_; + } + + private java.util.List<context.ContextOuterClass.EndPointId> sliceEndpointIds_ = + java.util.Collections.emptyList(); + private void ensureSliceEndpointIdsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + sliceEndpointIds_ = new java.util.ArrayList<context.ContextOuterClass.EndPointId>(sliceEndpointIds_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.EndPointId, context.ContextOuterClass.EndPointId.Builder, context.ContextOuterClass.EndPointIdOrBuilder> sliceEndpointIdsBuilder_; + + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public java.util.List<context.ContextOuterClass.EndPointId> getSliceEndpointIdsList() { + if (sliceEndpointIdsBuilder_ == null) { + return java.util.Collections.unmodifiableList(sliceEndpointIds_); + } else { + return sliceEndpointIdsBuilder_.getMessageList(); + } + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public int getSliceEndpointIdsCount() { + if (sliceEndpointIdsBuilder_ == null) { + return sliceEndpointIds_.size(); + } else { + return sliceEndpointIdsBuilder_.getCount(); + } + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public context.ContextOuterClass.EndPointId getSliceEndpointIds(int index) { + if (sliceEndpointIdsBuilder_ == null) { + return sliceEndpointIds_.get(index); + } else { + return sliceEndpointIdsBuilder_.getMessage(index); + } + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder setSliceEndpointIds( + int index, context.ContextOuterClass.EndPointId value) { + if (sliceEndpointIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.set(index, value); + onChanged(); + } else { + sliceEndpointIdsBuilder_.setMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder setSliceEndpointIds( + int index, context.ContextOuterClass.EndPointId.Builder builderForValue) { + if (sliceEndpointIdsBuilder_ == null) { + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.set(index, builderForValue.build()); + onChanged(); + } else { + sliceEndpointIdsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder addSliceEndpointIds(context.ContextOuterClass.EndPointId value) { + if (sliceEndpointIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.add(value); + onChanged(); + } else { + sliceEndpointIdsBuilder_.addMessage(value); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder addSliceEndpointIds( + int index, context.ContextOuterClass.EndPointId value) { + if (sliceEndpointIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.add(index, value); + onChanged(); + } else { + sliceEndpointIdsBuilder_.addMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder addSliceEndpointIds( + context.ContextOuterClass.EndPointId.Builder builderForValue) { + if (sliceEndpointIdsBuilder_ == null) { + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.add(builderForValue.build()); + onChanged(); + } else { + sliceEndpointIdsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder addSliceEndpointIds( + int index, context.ContextOuterClass.EndPointId.Builder builderForValue) { + if (sliceEndpointIdsBuilder_ == null) { + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.add(index, builderForValue.build()); + onChanged(); + } else { + sliceEndpointIdsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder addAllSliceEndpointIds( + java.lang.Iterable<? extends context.ContextOuterClass.EndPointId> values) { + if (sliceEndpointIdsBuilder_ == null) { + ensureSliceEndpointIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, sliceEndpointIds_); + onChanged(); + } else { + sliceEndpointIdsBuilder_.addAllMessages(values); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder clearSliceEndpointIds() { + if (sliceEndpointIdsBuilder_ == null) { + sliceEndpointIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + sliceEndpointIdsBuilder_.clear(); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder removeSliceEndpointIds(int index) { + if (sliceEndpointIdsBuilder_ == null) { + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.remove(index); + onChanged(); + } else { + sliceEndpointIdsBuilder_.remove(index); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public context.ContextOuterClass.EndPointId.Builder getSliceEndpointIdsBuilder( + int index) { + return getSliceEndpointIdsFieldBuilder().getBuilder(index); + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public context.ContextOuterClass.EndPointIdOrBuilder getSliceEndpointIdsOrBuilder( + int index) { + if (sliceEndpointIdsBuilder_ == null) { + return sliceEndpointIds_.get(index); } else { + return sliceEndpointIdsBuilder_.getMessageOrBuilder(index); + } + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public java.util.List<? extends context.ContextOuterClass.EndPointIdOrBuilder> + getSliceEndpointIdsOrBuilderList() { + if (sliceEndpointIdsBuilder_ != null) { + return sliceEndpointIdsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(sliceEndpointIds_); + } + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public context.ContextOuterClass.EndPointId.Builder addSliceEndpointIdsBuilder() { + return getSliceEndpointIdsFieldBuilder().addBuilder( + context.ContextOuterClass.EndPointId.getDefaultInstance()); + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public context.ContextOuterClass.EndPointId.Builder addSliceEndpointIdsBuilder( + int index) { + return getSliceEndpointIdsFieldBuilder().addBuilder( + index, context.ContextOuterClass.EndPointId.getDefaultInstance()); + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public java.util.List<context.ContextOuterClass.EndPointId.Builder> + getSliceEndpointIdsBuilderList() { + return getSliceEndpointIdsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.EndPointId, context.ContextOuterClass.EndPointId.Builder, context.ContextOuterClass.EndPointIdOrBuilder> + getSliceEndpointIdsFieldBuilder() { + if (sliceEndpointIdsBuilder_ == null) { + sliceEndpointIdsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.EndPointId, context.ContextOuterClass.EndPointId.Builder, context.ContextOuterClass.EndPointIdOrBuilder>( + sliceEndpointIds_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + sliceEndpointIds_ = null; + } + return sliceEndpointIdsBuilder_; + } + + private java.util.List<context.ContextOuterClass.Constraint> sliceConstraints_ = + java.util.Collections.emptyList(); + private void ensureSliceConstraintsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + sliceConstraints_ = new java.util.ArrayList<context.ContextOuterClass.Constraint>(sliceConstraints_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.Constraint, context.ContextOuterClass.Constraint.Builder, context.ContextOuterClass.ConstraintOrBuilder> sliceConstraintsBuilder_; + + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public java.util.List<context.ContextOuterClass.Constraint> getSliceConstraintsList() { + if (sliceConstraintsBuilder_ == null) { + return java.util.Collections.unmodifiableList(sliceConstraints_); + } else { + return sliceConstraintsBuilder_.getMessageList(); + } + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public int getSliceConstraintsCount() { + if (sliceConstraintsBuilder_ == null) { + return sliceConstraints_.size(); + } else { + return sliceConstraintsBuilder_.getCount(); + } + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public context.ContextOuterClass.Constraint getSliceConstraints(int index) { + if (sliceConstraintsBuilder_ == null) { + return sliceConstraints_.get(index); + } else { + return sliceConstraintsBuilder_.getMessage(index); + } + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder setSliceConstraints( + int index, context.ContextOuterClass.Constraint value) { + if (sliceConstraintsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceConstraintsIsMutable(); + sliceConstraints_.set(index, value); + onChanged(); + } else { + sliceConstraintsBuilder_.setMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder setSliceConstraints( + int index, context.ContextOuterClass.Constraint.Builder builderForValue) { + if (sliceConstraintsBuilder_ == null) { + ensureSliceConstraintsIsMutable(); + sliceConstraints_.set(index, builderForValue.build()); + onChanged(); + } else { + sliceConstraintsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder addSliceConstraints(context.ContextOuterClass.Constraint value) { + if (sliceConstraintsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceConstraintsIsMutable(); + sliceConstraints_.add(value); + onChanged(); + } else { + sliceConstraintsBuilder_.addMessage(value); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder addSliceConstraints( + int index, context.ContextOuterClass.Constraint value) { + if (sliceConstraintsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceConstraintsIsMutable(); + sliceConstraints_.add(index, value); + onChanged(); + } else { + sliceConstraintsBuilder_.addMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder addSliceConstraints( + context.ContextOuterClass.Constraint.Builder builderForValue) { + if (sliceConstraintsBuilder_ == null) { + ensureSliceConstraintsIsMutable(); + sliceConstraints_.add(builderForValue.build()); + onChanged(); + } else { + sliceConstraintsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder addSliceConstraints( + int index, context.ContextOuterClass.Constraint.Builder builderForValue) { + if (sliceConstraintsBuilder_ == null) { + ensureSliceConstraintsIsMutable(); + sliceConstraints_.add(index, builderForValue.build()); + onChanged(); + } else { + sliceConstraintsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder addAllSliceConstraints( + java.lang.Iterable<? extends context.ContextOuterClass.Constraint> values) { + if (sliceConstraintsBuilder_ == null) { + ensureSliceConstraintsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, sliceConstraints_); + onChanged(); + } else { + sliceConstraintsBuilder_.addAllMessages(values); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder clearSliceConstraints() { + if (sliceConstraintsBuilder_ == null) { + sliceConstraints_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + sliceConstraintsBuilder_.clear(); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder removeSliceConstraints(int index) { + if (sliceConstraintsBuilder_ == null) { + ensureSliceConstraintsIsMutable(); + sliceConstraints_.remove(index); + onChanged(); + } else { + sliceConstraintsBuilder_.remove(index); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public context.ContextOuterClass.Constraint.Builder getSliceConstraintsBuilder( + int index) { + return getSliceConstraintsFieldBuilder().getBuilder(index); + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public context.ContextOuterClass.ConstraintOrBuilder getSliceConstraintsOrBuilder( + int index) { + if (sliceConstraintsBuilder_ == null) { + return sliceConstraints_.get(index); } else { + return sliceConstraintsBuilder_.getMessageOrBuilder(index); + } + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public java.util.List<? extends context.ContextOuterClass.ConstraintOrBuilder> + getSliceConstraintsOrBuilderList() { + if (sliceConstraintsBuilder_ != null) { + return sliceConstraintsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(sliceConstraints_); + } + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public context.ContextOuterClass.Constraint.Builder addSliceConstraintsBuilder() { + return getSliceConstraintsFieldBuilder().addBuilder( + context.ContextOuterClass.Constraint.getDefaultInstance()); + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public context.ContextOuterClass.Constraint.Builder addSliceConstraintsBuilder( + int index) { + return getSliceConstraintsFieldBuilder().addBuilder( + index, context.ContextOuterClass.Constraint.getDefaultInstance()); + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public java.util.List<context.ContextOuterClass.Constraint.Builder> + getSliceConstraintsBuilderList() { + return getSliceConstraintsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.Constraint, context.ContextOuterClass.Constraint.Builder, context.ContextOuterClass.ConstraintOrBuilder> + getSliceConstraintsFieldBuilder() { + if (sliceConstraintsBuilder_ == null) { + sliceConstraintsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.Constraint, context.ContextOuterClass.Constraint.Builder, context.ContextOuterClass.ConstraintOrBuilder>( + sliceConstraints_, + ((bitField0_ & 0x00000002) != 0), + getParentForChildren(), + isClean()); + sliceConstraints_ = null; + } + return sliceConstraintsBuilder_; + } + + private java.util.List<context.ContextOuterClass.ServiceId> sliceServiceIds_ = + java.util.Collections.emptyList(); + private void ensureSliceServiceIdsIsMutable() { + if (!((bitField0_ & 0x00000004) != 0)) { + sliceServiceIds_ = new java.util.ArrayList<context.ContextOuterClass.ServiceId>(sliceServiceIds_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.ServiceId, context.ContextOuterClass.ServiceId.Builder, context.ContextOuterClass.ServiceIdOrBuilder> sliceServiceIdsBuilder_; + + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public java.util.List<context.ContextOuterClass.ServiceId> getSliceServiceIdsList() { + if (sliceServiceIdsBuilder_ == null) { + return java.util.Collections.unmodifiableList(sliceServiceIds_); + } else { + return sliceServiceIdsBuilder_.getMessageList(); + } + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public int getSliceServiceIdsCount() { + if (sliceServiceIdsBuilder_ == null) { + return sliceServiceIds_.size(); + } else { + return sliceServiceIdsBuilder_.getCount(); + } + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public context.ContextOuterClass.ServiceId getSliceServiceIds(int index) { + if (sliceServiceIdsBuilder_ == null) { + return sliceServiceIds_.get(index); + } else { + return sliceServiceIdsBuilder_.getMessage(index); + } + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder setSliceServiceIds( + int index, context.ContextOuterClass.ServiceId value) { + if (sliceServiceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.set(index, value); + onChanged(); + } else { + sliceServiceIdsBuilder_.setMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder setSliceServiceIds( + int index, context.ContextOuterClass.ServiceId.Builder builderForValue) { + if (sliceServiceIdsBuilder_ == null) { + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.set(index, builderForValue.build()); + onChanged(); + } else { + sliceServiceIdsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder addSliceServiceIds(context.ContextOuterClass.ServiceId value) { + if (sliceServiceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.add(value); + onChanged(); + } else { + sliceServiceIdsBuilder_.addMessage(value); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder addSliceServiceIds( + int index, context.ContextOuterClass.ServiceId value) { + if (sliceServiceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.add(index, value); + onChanged(); + } else { + sliceServiceIdsBuilder_.addMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder addSliceServiceIds( + context.ContextOuterClass.ServiceId.Builder builderForValue) { + if (sliceServiceIdsBuilder_ == null) { + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.add(builderForValue.build()); + onChanged(); + } else { + sliceServiceIdsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder addSliceServiceIds( + int index, context.ContextOuterClass.ServiceId.Builder builderForValue) { + if (sliceServiceIdsBuilder_ == null) { + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.add(index, builderForValue.build()); + onChanged(); + } else { + sliceServiceIdsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder addAllSliceServiceIds( + java.lang.Iterable<? extends context.ContextOuterClass.ServiceId> values) { + if (sliceServiceIdsBuilder_ == null) { + ensureSliceServiceIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, sliceServiceIds_); + onChanged(); + } else { + sliceServiceIdsBuilder_.addAllMessages(values); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder clearSliceServiceIds() { + if (sliceServiceIdsBuilder_ == null) { + sliceServiceIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + sliceServiceIdsBuilder_.clear(); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder removeSliceServiceIds(int index) { + if (sliceServiceIdsBuilder_ == null) { + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.remove(index); + onChanged(); + } else { + sliceServiceIdsBuilder_.remove(index); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public context.ContextOuterClass.ServiceId.Builder getSliceServiceIdsBuilder( + int index) { + return getSliceServiceIdsFieldBuilder().getBuilder(index); + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public context.ContextOuterClass.ServiceIdOrBuilder getSliceServiceIdsOrBuilder( + int index) { + if (sliceServiceIdsBuilder_ == null) { + return sliceServiceIds_.get(index); } else { + return sliceServiceIdsBuilder_.getMessageOrBuilder(index); + } + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public java.util.List<? extends context.ContextOuterClass.ServiceIdOrBuilder> + getSliceServiceIdsOrBuilderList() { + if (sliceServiceIdsBuilder_ != null) { + return sliceServiceIdsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(sliceServiceIds_); + } + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public context.ContextOuterClass.ServiceId.Builder addSliceServiceIdsBuilder() { + return getSliceServiceIdsFieldBuilder().addBuilder( + context.ContextOuterClass.ServiceId.getDefaultInstance()); + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public context.ContextOuterClass.ServiceId.Builder addSliceServiceIdsBuilder( + int index) { + return getSliceServiceIdsFieldBuilder().addBuilder( + index, context.ContextOuterClass.ServiceId.getDefaultInstance()); + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public java.util.List<context.ContextOuterClass.ServiceId.Builder> + getSliceServiceIdsBuilderList() { + return getSliceServiceIdsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.ServiceId, context.ContextOuterClass.ServiceId.Builder, context.ContextOuterClass.ServiceIdOrBuilder> + getSliceServiceIdsFieldBuilder() { + if (sliceServiceIdsBuilder_ == null) { + sliceServiceIdsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.ServiceId, context.ContextOuterClass.ServiceId.Builder, context.ContextOuterClass.ServiceIdOrBuilder>( + sliceServiceIds_, + ((bitField0_ & 0x00000004) != 0), + getParentForChildren(), + isClean()); + sliceServiceIds_ = null; + } + return sliceServiceIdsBuilder_; + } + + private java.util.List<context.ContextOuterClass.SliceId> sliceSubsliceIds_ = + java.util.Collections.emptyList(); + private void ensureSliceSubsliceIdsIsMutable() { + if (!((bitField0_ & 0x00000008) != 0)) { + sliceSubsliceIds_ = new java.util.ArrayList<context.ContextOuterClass.SliceId>(sliceSubsliceIds_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> sliceSubsliceIdsBuilder_; + + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public java.util.List<context.ContextOuterClass.SliceId> getSliceSubsliceIdsList() { + if (sliceSubsliceIdsBuilder_ == null) { + return java.util.Collections.unmodifiableList(sliceSubsliceIds_); + } else { + return sliceSubsliceIdsBuilder_.getMessageList(); + } + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public int getSliceSubsliceIdsCount() { + if (sliceSubsliceIdsBuilder_ == null) { + return sliceSubsliceIds_.size(); + } else { + return sliceSubsliceIdsBuilder_.getCount(); + } + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public context.ContextOuterClass.SliceId getSliceSubsliceIds(int index) { + if (sliceSubsliceIdsBuilder_ == null) { + return sliceSubsliceIds_.get(index); + } else { + return sliceSubsliceIdsBuilder_.getMessage(index); + } + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder setSliceSubsliceIds( + int index, context.ContextOuterClass.SliceId value) { + if (sliceSubsliceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.set(index, value); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.setMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder setSliceSubsliceIds( + int index, context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceSubsliceIdsBuilder_ == null) { + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.set(index, builderForValue.build()); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder addSliceSubsliceIds(context.ContextOuterClass.SliceId value) { + if (sliceSubsliceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.add(value); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.addMessage(value); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder addSliceSubsliceIds( + int index, context.ContextOuterClass.SliceId value) { + if (sliceSubsliceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.add(index, value); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.addMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder addSliceSubsliceIds( + context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceSubsliceIdsBuilder_ == null) { + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.add(builderForValue.build()); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder addSliceSubsliceIds( + int index, context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceSubsliceIdsBuilder_ == null) { + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.add(index, builderForValue.build()); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder addAllSliceSubsliceIds( + java.lang.Iterable<? extends context.ContextOuterClass.SliceId> values) { + if (sliceSubsliceIdsBuilder_ == null) { + ensureSliceSubsliceIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, sliceSubsliceIds_); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.addAllMessages(values); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder clearSliceSubsliceIds() { + if (sliceSubsliceIdsBuilder_ == null) { + sliceSubsliceIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.clear(); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder removeSliceSubsliceIds(int index) { + if (sliceSubsliceIdsBuilder_ == null) { + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.remove(index); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.remove(index); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public context.ContextOuterClass.SliceId.Builder getSliceSubsliceIdsBuilder( + int index) { + return getSliceSubsliceIdsFieldBuilder().getBuilder(index); + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public context.ContextOuterClass.SliceIdOrBuilder getSliceSubsliceIdsOrBuilder( + int index) { + if (sliceSubsliceIdsBuilder_ == null) { + return sliceSubsliceIds_.get(index); } else { + return sliceSubsliceIdsBuilder_.getMessageOrBuilder(index); + } + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public java.util.List<? extends context.ContextOuterClass.SliceIdOrBuilder> + getSliceSubsliceIdsOrBuilderList() { + if (sliceSubsliceIdsBuilder_ != null) { + return sliceSubsliceIdsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(sliceSubsliceIds_); + } + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public context.ContextOuterClass.SliceId.Builder addSliceSubsliceIdsBuilder() { + return getSliceSubsliceIdsFieldBuilder().addBuilder( + context.ContextOuterClass.SliceId.getDefaultInstance()); + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public context.ContextOuterClass.SliceId.Builder addSliceSubsliceIdsBuilder( + int index) { + return getSliceSubsliceIdsFieldBuilder().addBuilder( + index, context.ContextOuterClass.SliceId.getDefaultInstance()); + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public java.util.List<context.ContextOuterClass.SliceId.Builder> + getSliceSubsliceIdsBuilderList() { + return getSliceSubsliceIdsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> + getSliceSubsliceIdsFieldBuilder() { + if (sliceSubsliceIdsBuilder_ == null) { + sliceSubsliceIdsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder>( + sliceSubsliceIds_, + ((bitField0_ & 0x00000008) != 0), + getParentForChildren(), + isClean()); + sliceSubsliceIds_ = null; + } + return sliceSubsliceIdsBuilder_; + } + + private context.ContextOuterClass.SliceStatus sliceStatus_; + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceStatus, context.ContextOuterClass.SliceStatus.Builder, context.ContextOuterClass.SliceStatusOrBuilder> sliceStatusBuilder_; + /** + * <code>.context.SliceStatus slice_status = 6;</code> + * @return Whether the sliceStatus field is set. + */ + public boolean hasSliceStatus() { + return sliceStatusBuilder_ != null || sliceStatus_ != null; + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + * @return The sliceStatus. + */ + public context.ContextOuterClass.SliceStatus getSliceStatus() { + if (sliceStatusBuilder_ == null) { + return sliceStatus_ == null ? context.ContextOuterClass.SliceStatus.getDefaultInstance() : sliceStatus_; + } else { + return sliceStatusBuilder_.getMessage(); + } + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + public Builder setSliceStatus(context.ContextOuterClass.SliceStatus value) { + if (sliceStatusBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + sliceStatus_ = value; + onChanged(); + } else { + sliceStatusBuilder_.setMessage(value); + } + + return this; + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + public Builder setSliceStatus( + context.ContextOuterClass.SliceStatus.Builder builderForValue) { + if (sliceStatusBuilder_ == null) { + sliceStatus_ = builderForValue.build(); + onChanged(); + } else { + sliceStatusBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + public Builder mergeSliceStatus(context.ContextOuterClass.SliceStatus value) { + if (sliceStatusBuilder_ == null) { + if (sliceStatus_ != null) { + sliceStatus_ = + context.ContextOuterClass.SliceStatus.newBuilder(sliceStatus_).mergeFrom(value).buildPartial(); + } else { + sliceStatus_ = value; + } + onChanged(); + } else { + sliceStatusBuilder_.mergeFrom(value); + } + + return this; + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + public Builder clearSliceStatus() { + if (sliceStatusBuilder_ == null) { + sliceStatus_ = null; + onChanged(); + } else { + sliceStatus_ = null; + sliceStatusBuilder_ = null; + } + + return this; + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + public context.ContextOuterClass.SliceStatus.Builder getSliceStatusBuilder() { + + onChanged(); + return getSliceStatusFieldBuilder().getBuilder(); + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + public context.ContextOuterClass.SliceStatusOrBuilder getSliceStatusOrBuilder() { + if (sliceStatusBuilder_ != null) { + return sliceStatusBuilder_.getMessageOrBuilder(); + } else { + return sliceStatus_ == null ? + context.ContextOuterClass.SliceStatus.getDefaultInstance() : sliceStatus_; + } + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceStatus, context.ContextOuterClass.SliceStatus.Builder, context.ContextOuterClass.SliceStatusOrBuilder> + getSliceStatusFieldBuilder() { + if (sliceStatusBuilder_ == null) { + sliceStatusBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceStatus, context.ContextOuterClass.SliceStatus.Builder, context.ContextOuterClass.SliceStatusOrBuilder>( + getSliceStatus(), + getParentForChildren(), + isClean()); + sliceStatus_ = null; + } + return sliceStatusBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:context.Slice) + } + + // @@protoc_insertion_point(class_scope:context.Slice) + private static final context.ContextOuterClass.Slice DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new context.ContextOuterClass.Slice(); + } + + public static context.ContextOuterClass.Slice getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser<Slice> + PARSER = new com.google.protobuf.AbstractParser<Slice>() { + @java.lang.Override + public Slice parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Slice(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser<Slice> parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser<Slice> getParserForType() { + return PARSER; + } + + @java.lang.Override + public context.ContextOuterClass.Slice getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SliceStatusOrBuilder extends + // @@protoc_insertion_point(interface_extends:context.SliceStatus) + com.google.protobuf.MessageOrBuilder { + + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @return The enum numeric value on the wire for sliceStatus. + */ + int getSliceStatusValue(); + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @return The sliceStatus. + */ + context.ContextOuterClass.SliceStatusEnum getSliceStatus(); + } + /** + * Protobuf type {@code context.SliceStatus} + */ + public static final class SliceStatus extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:context.SliceStatus) + SliceStatusOrBuilder { + private static final long serialVersionUID = 0L; + // Use SliceStatus.newBuilder() to construct. + private SliceStatus(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { + super(builder); + } + private SliceStatus() { + sliceStatus_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SliceStatus(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SliceStatus( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + int rawValue = input.readEnum(); + + sliceStatus_ = rawValue; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceStatus_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceStatus_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceStatus.class, context.ContextOuterClass.SliceStatus.Builder.class); + } + + public static final int SLICE_STATUS_FIELD_NUMBER = 1; + private int sliceStatus_; + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @return The enum numeric value on the wire for sliceStatus. + */ + @java.lang.Override public int getSliceStatusValue() { + return sliceStatus_; + } + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @return The sliceStatus. + */ + @java.lang.Override public context.ContextOuterClass.SliceStatusEnum getSliceStatus() { + @SuppressWarnings("deprecation") + context.ContextOuterClass.SliceStatusEnum result = context.ContextOuterClass.SliceStatusEnum.valueOf(sliceStatus_); + return result == null ? context.ContextOuterClass.SliceStatusEnum.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (sliceStatus_ != context.ContextOuterClass.SliceStatusEnum.SLICESTATUS_UNDEFINED.getNumber()) { + output.writeEnum(1, sliceStatus_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (sliceStatus_ != context.ContextOuterClass.SliceStatusEnum.SLICESTATUS_UNDEFINED.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, sliceStatus_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof context.ContextOuterClass.SliceStatus)) { + return super.equals(obj); + } + context.ContextOuterClass.SliceStatus other = (context.ContextOuterClass.SliceStatus) obj; + + if (sliceStatus_ != other.sliceStatus_) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SLICE_STATUS_FIELD_NUMBER; + hash = (53 * hash) + sliceStatus_; + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static context.ContextOuterClass.SliceStatus parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceStatus parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceStatus parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceStatus parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceStatus parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceStatus parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceStatus parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceStatus parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceStatus parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceStatus parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceStatus parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceStatus parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(context.ContextOuterClass.SliceStatus prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code context.SliceStatus} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements + // @@protoc_insertion_point(builder_implements:context.SliceStatus) + context.ContextOuterClass.SliceStatusOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceStatus_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceStatus_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceStatus.class, context.ContextOuterClass.SliceStatus.Builder.class); + } + + // Construct using context.ContextOuterClass.SliceStatus.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + sliceStatus_ = 0; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return context.ContextOuterClass.internal_static_context_SliceStatus_descriptor; + } + + @java.lang.Override + public context.ContextOuterClass.SliceStatus getDefaultInstanceForType() { + return context.ContextOuterClass.SliceStatus.getDefaultInstance(); + } + + @java.lang.Override + public context.ContextOuterClass.SliceStatus build() { + context.ContextOuterClass.SliceStatus result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public context.ContextOuterClass.SliceStatus buildPartial() { + context.ContextOuterClass.SliceStatus result = new context.ContextOuterClass.SliceStatus(this); + result.sliceStatus_ = sliceStatus_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof context.ContextOuterClass.SliceStatus) { + return mergeFrom((context.ContextOuterClass.SliceStatus)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(context.ContextOuterClass.SliceStatus other) { + if (other == context.ContextOuterClass.SliceStatus.getDefaultInstance()) return this; + if (other.sliceStatus_ != 0) { + setSliceStatusValue(other.getSliceStatusValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + context.ContextOuterClass.SliceStatus parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (context.ContextOuterClass.SliceStatus) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int sliceStatus_ = 0; + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @return The enum numeric value on the wire for sliceStatus. + */ + @java.lang.Override public int getSliceStatusValue() { + return sliceStatus_; + } + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @param value The enum numeric value on the wire for sliceStatus to set. + * @return This builder for chaining. + */ + public Builder setSliceStatusValue(int value) { + + sliceStatus_ = value; + onChanged(); + return this; + } + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @return The sliceStatus. + */ + @java.lang.Override + public context.ContextOuterClass.SliceStatusEnum getSliceStatus() { + @SuppressWarnings("deprecation") + context.ContextOuterClass.SliceStatusEnum result = context.ContextOuterClass.SliceStatusEnum.valueOf(sliceStatus_); + return result == null ? context.ContextOuterClass.SliceStatusEnum.UNRECOGNIZED : result; + } + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @param value The sliceStatus to set. + * @return This builder for chaining. + */ + public Builder setSliceStatus(context.ContextOuterClass.SliceStatusEnum value) { + if (value == null) { + throw new NullPointerException(); + } + + sliceStatus_ = value.getNumber(); + onChanged(); + return this; + } + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @return This builder for chaining. + */ + public Builder clearSliceStatus() { + + sliceStatus_ = 0; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:context.SliceStatus) + } + + // @@protoc_insertion_point(class_scope:context.SliceStatus) + private static final context.ContextOuterClass.SliceStatus DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new context.ContextOuterClass.SliceStatus(); + } + + public static context.ContextOuterClass.SliceStatus getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser<SliceStatus> + PARSER = new com.google.protobuf.AbstractParser<SliceStatus>() { + @java.lang.Override + public SliceStatus parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SliceStatus(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser<SliceStatus> parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser<SliceStatus> getParserForType() { + return PARSER; + } + + @java.lang.Override + public context.ContextOuterClass.SliceStatus getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SliceIdListOrBuilder extends + // @@protoc_insertion_point(interface_extends:context.SliceIdList) + com.google.protobuf.MessageOrBuilder { + + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + java.util.List<context.ContextOuterClass.SliceId> + getSliceIdsList(); + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + context.ContextOuterClass.SliceId getSliceIds(int index); + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + int getSliceIdsCount(); + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + java.util.List<? extends context.ContextOuterClass.SliceIdOrBuilder> + getSliceIdsOrBuilderList(); + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + context.ContextOuterClass.SliceIdOrBuilder getSliceIdsOrBuilder( + int index); + } + /** + * Protobuf type {@code context.SliceIdList} + */ + public static final class SliceIdList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:context.SliceIdList) + SliceIdListOrBuilder { + private static final long serialVersionUID = 0L; + // Use SliceIdList.newBuilder() to construct. + private SliceIdList(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { + super(builder); + } + private SliceIdList() { + sliceIds_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SliceIdList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SliceIdList( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + sliceIds_ = new java.util.ArrayList<context.ContextOuterClass.SliceId>(); + mutable_bitField0_ |= 0x00000001; + } + sliceIds_.add( + input.readMessage(context.ContextOuterClass.SliceId.parser(), extensionRegistry)); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + sliceIds_ = java.util.Collections.unmodifiableList(sliceIds_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceIdList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceIdList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceIdList.class, context.ContextOuterClass.SliceIdList.Builder.class); + } + + public static final int SLICE_IDS_FIELD_NUMBER = 1; + private java.util.List<context.ContextOuterClass.SliceId> sliceIds_; + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + @java.lang.Override + public java.util.List<context.ContextOuterClass.SliceId> getSliceIdsList() { + return sliceIds_; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + @java.lang.Override + public java.util.List<? extends context.ContextOuterClass.SliceIdOrBuilder> + getSliceIdsOrBuilderList() { + return sliceIds_; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + @java.lang.Override + public int getSliceIdsCount() { + return sliceIds_.size(); + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceId getSliceIds(int index) { + return sliceIds_.get(index); + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceIdOrBuilder getSliceIdsOrBuilder( + int index) { + return sliceIds_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < sliceIds_.size(); i++) { + output.writeMessage(1, sliceIds_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < sliceIds_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, sliceIds_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof context.ContextOuterClass.SliceIdList)) { + return super.equals(obj); + } + context.ContextOuterClass.SliceIdList other = (context.ContextOuterClass.SliceIdList) obj; + + if (!getSliceIdsList() + .equals(other.getSliceIdsList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getSliceIdsCount() > 0) { + hash = (37 * hash) + SLICE_IDS_FIELD_NUMBER; + hash = (53 * hash) + getSliceIdsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static context.ContextOuterClass.SliceIdList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceIdList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceIdList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceIdList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceIdList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceIdList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceIdList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceIdList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceIdList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceIdList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceIdList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceIdList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(context.ContextOuterClass.SliceIdList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code context.SliceIdList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements + // @@protoc_insertion_point(builder_implements:context.SliceIdList) + context.ContextOuterClass.SliceIdListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceIdList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceIdList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceIdList.class, context.ContextOuterClass.SliceIdList.Builder.class); + } + + // Construct using context.ContextOuterClass.SliceIdList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getSliceIdsFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (sliceIdsBuilder_ == null) { + sliceIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + sliceIdsBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return context.ContextOuterClass.internal_static_context_SliceIdList_descriptor; + } + + @java.lang.Override + public context.ContextOuterClass.SliceIdList getDefaultInstanceForType() { + return context.ContextOuterClass.SliceIdList.getDefaultInstance(); + } + + @java.lang.Override + public context.ContextOuterClass.SliceIdList build() { + context.ContextOuterClass.SliceIdList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public context.ContextOuterClass.SliceIdList buildPartial() { + context.ContextOuterClass.SliceIdList result = new context.ContextOuterClass.SliceIdList(this); + int from_bitField0_ = bitField0_; + if (sliceIdsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + sliceIds_ = java.util.Collections.unmodifiableList(sliceIds_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.sliceIds_ = sliceIds_; + } else { + result.sliceIds_ = sliceIdsBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof context.ContextOuterClass.SliceIdList) { + return mergeFrom((context.ContextOuterClass.SliceIdList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(context.ContextOuterClass.SliceIdList other) { + if (other == context.ContextOuterClass.SliceIdList.getDefaultInstance()) return this; + if (sliceIdsBuilder_ == null) { + if (!other.sliceIds_.isEmpty()) { + if (sliceIds_.isEmpty()) { + sliceIds_ = other.sliceIds_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureSliceIdsIsMutable(); + sliceIds_.addAll(other.sliceIds_); + } + onChanged(); + } + } else { + if (!other.sliceIds_.isEmpty()) { + if (sliceIdsBuilder_.isEmpty()) { + sliceIdsBuilder_.dispose(); + sliceIdsBuilder_ = null; + sliceIds_ = other.sliceIds_; + bitField0_ = (bitField0_ & ~0x00000001); + sliceIdsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSliceIdsFieldBuilder() : null; + } else { + sliceIdsBuilder_.addAllMessages(other.sliceIds_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + context.ContextOuterClass.SliceIdList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (context.ContextOuterClass.SliceIdList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List<context.ContextOuterClass.SliceId> sliceIds_ = + java.util.Collections.emptyList(); + private void ensureSliceIdsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + sliceIds_ = new java.util.ArrayList<context.ContextOuterClass.SliceId>(sliceIds_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> sliceIdsBuilder_; + + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public java.util.List<context.ContextOuterClass.SliceId> getSliceIdsList() { + if (sliceIdsBuilder_ == null) { + return java.util.Collections.unmodifiableList(sliceIds_); + } else { + return sliceIdsBuilder_.getMessageList(); + } + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public int getSliceIdsCount() { + if (sliceIdsBuilder_ == null) { + return sliceIds_.size(); + } else { + return sliceIdsBuilder_.getCount(); + } + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public context.ContextOuterClass.SliceId getSliceIds(int index) { + if (sliceIdsBuilder_ == null) { + return sliceIds_.get(index); + } else { + return sliceIdsBuilder_.getMessage(index); + } + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder setSliceIds( + int index, context.ContextOuterClass.SliceId value) { + if (sliceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceIdsIsMutable(); + sliceIds_.set(index, value); + onChanged(); + } else { + sliceIdsBuilder_.setMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder setSliceIds( + int index, context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceIdsBuilder_ == null) { + ensureSliceIdsIsMutable(); + sliceIds_.set(index, builderForValue.build()); + onChanged(); + } else { + sliceIdsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder addSliceIds(context.ContextOuterClass.SliceId value) { + if (sliceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceIdsIsMutable(); + sliceIds_.add(value); + onChanged(); + } else { + sliceIdsBuilder_.addMessage(value); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder addSliceIds( + int index, context.ContextOuterClass.SliceId value) { + if (sliceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceIdsIsMutable(); + sliceIds_.add(index, value); + onChanged(); + } else { + sliceIdsBuilder_.addMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder addSliceIds( + context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceIdsBuilder_ == null) { + ensureSliceIdsIsMutable(); + sliceIds_.add(builderForValue.build()); + onChanged(); + } else { + sliceIdsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder addSliceIds( + int index, context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceIdsBuilder_ == null) { + ensureSliceIdsIsMutable(); + sliceIds_.add(index, builderForValue.build()); + onChanged(); + } else { + sliceIdsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder addAllSliceIds( + java.lang.Iterable<? extends context.ContextOuterClass.SliceId> values) { + if (sliceIdsBuilder_ == null) { + ensureSliceIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, sliceIds_); + onChanged(); + } else { + sliceIdsBuilder_.addAllMessages(values); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder clearSliceIds() { + if (sliceIdsBuilder_ == null) { + sliceIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + sliceIdsBuilder_.clear(); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder removeSliceIds(int index) { + if (sliceIdsBuilder_ == null) { + ensureSliceIdsIsMutable(); + sliceIds_.remove(index); + onChanged(); + } else { + sliceIdsBuilder_.remove(index); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public context.ContextOuterClass.SliceId.Builder getSliceIdsBuilder( + int index) { + return getSliceIdsFieldBuilder().getBuilder(index); + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public context.ContextOuterClass.SliceIdOrBuilder getSliceIdsOrBuilder( + int index) { + if (sliceIdsBuilder_ == null) { + return sliceIds_.get(index); } else { + return sliceIdsBuilder_.getMessageOrBuilder(index); + } + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public java.util.List<? extends context.ContextOuterClass.SliceIdOrBuilder> + getSliceIdsOrBuilderList() { + if (sliceIdsBuilder_ != null) { + return sliceIdsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(sliceIds_); + } + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public context.ContextOuterClass.SliceId.Builder addSliceIdsBuilder() { + return getSliceIdsFieldBuilder().addBuilder( + context.ContextOuterClass.SliceId.getDefaultInstance()); + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public context.ContextOuterClass.SliceId.Builder addSliceIdsBuilder( + int index) { + return getSliceIdsFieldBuilder().addBuilder( + index, context.ContextOuterClass.SliceId.getDefaultInstance()); + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public java.util.List<context.ContextOuterClass.SliceId.Builder> + getSliceIdsBuilderList() { + return getSliceIdsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> + getSliceIdsFieldBuilder() { + if (sliceIdsBuilder_ == null) { + sliceIdsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder>( + sliceIds_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + sliceIds_ = null; + } + return sliceIdsBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:context.SliceIdList) + } + + // @@protoc_insertion_point(class_scope:context.SliceIdList) + private static final context.ContextOuterClass.SliceIdList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new context.ContextOuterClass.SliceIdList(); + } + + public static context.ContextOuterClass.SliceIdList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser<SliceIdList> + PARSER = new com.google.protobuf.AbstractParser<SliceIdList>() { + @java.lang.Override + public SliceIdList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SliceIdList(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser<SliceIdList> parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser<SliceIdList> getParserForType() { + return PARSER; + } + + @java.lang.Override + public context.ContextOuterClass.SliceIdList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SliceListOrBuilder extends + // @@protoc_insertion_point(interface_extends:context.SliceList) + com.google.protobuf.MessageOrBuilder { + + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + java.util.List<context.ContextOuterClass.Slice> + getSlicesList(); + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + context.ContextOuterClass.Slice getSlices(int index); + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + int getSlicesCount(); + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + java.util.List<? extends context.ContextOuterClass.SliceOrBuilder> + getSlicesOrBuilderList(); + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + context.ContextOuterClass.SliceOrBuilder getSlicesOrBuilder( + int index); + } + /** + * Protobuf type {@code context.SliceList} + */ + public static final class SliceList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:context.SliceList) + SliceListOrBuilder { + private static final long serialVersionUID = 0L; + // Use SliceList.newBuilder() to construct. + private SliceList(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { + super(builder); + } + private SliceList() { + slices_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SliceList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SliceList( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + slices_ = new java.util.ArrayList<context.ContextOuterClass.Slice>(); + mutable_bitField0_ |= 0x00000001; + } + slices_.add( + input.readMessage(context.ContextOuterClass.Slice.parser(), extensionRegistry)); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + slices_ = java.util.Collections.unmodifiableList(slices_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceList.class, context.ContextOuterClass.SliceList.Builder.class); + } + + public static final int SLICES_FIELD_NUMBER = 1; + private java.util.List<context.ContextOuterClass.Slice> slices_; + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + @java.lang.Override + public java.util.List<context.ContextOuterClass.Slice> getSlicesList() { + return slices_; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + @java.lang.Override + public java.util.List<? extends context.ContextOuterClass.SliceOrBuilder> + getSlicesOrBuilderList() { + return slices_; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + @java.lang.Override + public int getSlicesCount() { + return slices_.size(); + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + @java.lang.Override + public context.ContextOuterClass.Slice getSlices(int index) { + return slices_.get(index); + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceOrBuilder getSlicesOrBuilder( + int index) { + return slices_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < slices_.size(); i++) { + output.writeMessage(1, slices_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < slices_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, slices_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof context.ContextOuterClass.SliceList)) { + return super.equals(obj); + } + context.ContextOuterClass.SliceList other = (context.ContextOuterClass.SliceList) obj; + + if (!getSlicesList() + .equals(other.getSlicesList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getSlicesCount() > 0) { + hash = (37 * hash) + SLICES_FIELD_NUMBER; + hash = (53 * hash) + getSlicesList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static context.ContextOuterClass.SliceList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(context.ContextOuterClass.SliceList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code context.SliceList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements + // @@protoc_insertion_point(builder_implements:context.SliceList) + context.ContextOuterClass.SliceListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceList.class, context.ContextOuterClass.SliceList.Builder.class); + } + + // Construct using context.ContextOuterClass.SliceList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getSlicesFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (slicesBuilder_ == null) { + slices_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + slicesBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return context.ContextOuterClass.internal_static_context_SliceList_descriptor; + } + + @java.lang.Override + public context.ContextOuterClass.SliceList getDefaultInstanceForType() { + return context.ContextOuterClass.SliceList.getDefaultInstance(); + } + + @java.lang.Override + public context.ContextOuterClass.SliceList build() { + context.ContextOuterClass.SliceList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public context.ContextOuterClass.SliceList buildPartial() { + context.ContextOuterClass.SliceList result = new context.ContextOuterClass.SliceList(this); + int from_bitField0_ = bitField0_; + if (slicesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + slices_ = java.util.Collections.unmodifiableList(slices_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.slices_ = slices_; + } else { + result.slices_ = slicesBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof context.ContextOuterClass.SliceList) { + return mergeFrom((context.ContextOuterClass.SliceList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(context.ContextOuterClass.SliceList other) { + if (other == context.ContextOuterClass.SliceList.getDefaultInstance()) return this; + if (slicesBuilder_ == null) { + if (!other.slices_.isEmpty()) { + if (slices_.isEmpty()) { + slices_ = other.slices_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureSlicesIsMutable(); + slices_.addAll(other.slices_); + } + onChanged(); + } + } else { + if (!other.slices_.isEmpty()) { + if (slicesBuilder_.isEmpty()) { + slicesBuilder_.dispose(); + slicesBuilder_ = null; + slices_ = other.slices_; + bitField0_ = (bitField0_ & ~0x00000001); + slicesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSlicesFieldBuilder() : null; + } else { + slicesBuilder_.addAllMessages(other.slices_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + context.ContextOuterClass.SliceList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (context.ContextOuterClass.SliceList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List<context.ContextOuterClass.Slice> slices_ = + java.util.Collections.emptyList(); + private void ensureSlicesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + slices_ = new java.util.ArrayList<context.ContextOuterClass.Slice>(slices_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.Slice, context.ContextOuterClass.Slice.Builder, context.ContextOuterClass.SliceOrBuilder> slicesBuilder_; + + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public java.util.List<context.ContextOuterClass.Slice> getSlicesList() { + if (slicesBuilder_ == null) { + return java.util.Collections.unmodifiableList(slices_); + } else { + return slicesBuilder_.getMessageList(); + } + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public int getSlicesCount() { + if (slicesBuilder_ == null) { + return slices_.size(); + } else { + return slicesBuilder_.getCount(); + } + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public context.ContextOuterClass.Slice getSlices(int index) { + if (slicesBuilder_ == null) { + return slices_.get(index); + } else { + return slicesBuilder_.getMessage(index); + } + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder setSlices( + int index, context.ContextOuterClass.Slice value) { + if (slicesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSlicesIsMutable(); + slices_.set(index, value); + onChanged(); + } else { + slicesBuilder_.setMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder setSlices( + int index, context.ContextOuterClass.Slice.Builder builderForValue) { + if (slicesBuilder_ == null) { + ensureSlicesIsMutable(); + slices_.set(index, builderForValue.build()); + onChanged(); + } else { + slicesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder addSlices(context.ContextOuterClass.Slice value) { + if (slicesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSlicesIsMutable(); + slices_.add(value); + onChanged(); + } else { + slicesBuilder_.addMessage(value); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder addSlices( + int index, context.ContextOuterClass.Slice value) { + if (slicesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSlicesIsMutable(); + slices_.add(index, value); + onChanged(); + } else { + slicesBuilder_.addMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder addSlices( + context.ContextOuterClass.Slice.Builder builderForValue) { + if (slicesBuilder_ == null) { + ensureSlicesIsMutable(); + slices_.add(builderForValue.build()); + onChanged(); + } else { + slicesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder addSlices( + int index, context.ContextOuterClass.Slice.Builder builderForValue) { + if (slicesBuilder_ == null) { + ensureSlicesIsMutable(); + slices_.add(index, builderForValue.build()); + onChanged(); + } else { + slicesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder addAllSlices( + java.lang.Iterable<? extends context.ContextOuterClass.Slice> values) { + if (slicesBuilder_ == null) { + ensureSlicesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, slices_); + onChanged(); + } else { + slicesBuilder_.addAllMessages(values); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder clearSlices() { + if (slicesBuilder_ == null) { + slices_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + slicesBuilder_.clear(); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder removeSlices(int index) { + if (slicesBuilder_ == null) { + ensureSlicesIsMutable(); + slices_.remove(index); + onChanged(); + } else { + slicesBuilder_.remove(index); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public context.ContextOuterClass.Slice.Builder getSlicesBuilder( + int index) { + return getSlicesFieldBuilder().getBuilder(index); + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public context.ContextOuterClass.SliceOrBuilder getSlicesOrBuilder( + int index) { + if (slicesBuilder_ == null) { + return slices_.get(index); } else { + return slicesBuilder_.getMessageOrBuilder(index); + } + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public java.util.List<? extends context.ContextOuterClass.SliceOrBuilder> + getSlicesOrBuilderList() { + if (slicesBuilder_ != null) { + return slicesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(slices_); + } + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public context.ContextOuterClass.Slice.Builder addSlicesBuilder() { + return getSlicesFieldBuilder().addBuilder( + context.ContextOuterClass.Slice.getDefaultInstance()); + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public context.ContextOuterClass.Slice.Builder addSlicesBuilder( + int index) { + return getSlicesFieldBuilder().addBuilder( + index, context.ContextOuterClass.Slice.getDefaultInstance()); + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public java.util.List<context.ContextOuterClass.Slice.Builder> + getSlicesBuilderList() { + return getSlicesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.Slice, context.ContextOuterClass.Slice.Builder, context.ContextOuterClass.SliceOrBuilder> + getSlicesFieldBuilder() { + if (slicesBuilder_ == null) { + slicesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.Slice, context.ContextOuterClass.Slice.Builder, context.ContextOuterClass.SliceOrBuilder>( + slices_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + slices_ = null; + } + return slicesBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:context.SliceList) + } + + // @@protoc_insertion_point(class_scope:context.SliceList) + private static final context.ContextOuterClass.SliceList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new context.ContextOuterClass.SliceList(); + } + + public static context.ContextOuterClass.SliceList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser<SliceList> + PARSER = new com.google.protobuf.AbstractParser<SliceList>() { + @java.lang.Override + public SliceList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SliceList(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser<SliceList> parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser<SliceList> getParserForType() { + return PARSER; + } + + @java.lang.Override + public context.ContextOuterClass.SliceList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SliceEventOrBuilder extends + // @@protoc_insertion_point(interface_extends:context.SliceEvent) + com.google.protobuf.MessageOrBuilder { + + /** + * <code>.context.Event event = 1;</code> + * @return Whether the event field is set. + */ + boolean hasEvent(); + /** + * <code>.context.Event event = 1;</code> + * @return The event. + */ + context.ContextOuterClass.Event getEvent(); + /** + * <code>.context.Event event = 1;</code> + */ + context.ContextOuterClass.EventOrBuilder getEventOrBuilder(); + + /** + * <code>.context.SliceId slice_id = 2;</code> + * @return Whether the sliceId field is set. + */ + boolean hasSliceId(); + /** + * <code>.context.SliceId slice_id = 2;</code> + * @return The sliceId. + */ + context.ContextOuterClass.SliceId getSliceId(); + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + context.ContextOuterClass.SliceIdOrBuilder getSliceIdOrBuilder(); + } + /** + * Protobuf type {@code context.SliceEvent} + */ + public static final class SliceEvent extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:context.SliceEvent) + SliceEventOrBuilder { + private static final long serialVersionUID = 0L; + // Use SliceEvent.newBuilder() to construct. + private SliceEvent(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { + super(builder); + } + private SliceEvent() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SliceEvent(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SliceEvent( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + context.ContextOuterClass.Event.Builder subBuilder = null; + if (event_ != null) { + subBuilder = event_.toBuilder(); + } + event_ = input.readMessage(context.ContextOuterClass.Event.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(event_); + event_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + context.ContextOuterClass.SliceId.Builder subBuilder = null; + if (sliceId_ != null) { + subBuilder = sliceId_.toBuilder(); + } + sliceId_ = input.readMessage(context.ContextOuterClass.SliceId.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(sliceId_); + sliceId_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceEvent_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceEvent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceEvent.class, context.ContextOuterClass.SliceEvent.Builder.class); + } + + public static final int EVENT_FIELD_NUMBER = 1; + private context.ContextOuterClass.Event event_; + /** + * <code>.context.Event event = 1;</code> + * @return Whether the event field is set. + */ + @java.lang.Override + public boolean hasEvent() { + return event_ != null; + } + /** + * <code>.context.Event event = 1;</code> + * @return The event. + */ + @java.lang.Override + public context.ContextOuterClass.Event getEvent() { + return event_ == null ? context.ContextOuterClass.Event.getDefaultInstance() : event_; + } + /** + * <code>.context.Event event = 1;</code> + */ + @java.lang.Override + public context.ContextOuterClass.EventOrBuilder getEventOrBuilder() { + return getEvent(); + } + + public static final int SLICE_ID_FIELD_NUMBER = 2; + private context.ContextOuterClass.SliceId sliceId_; + /** + * <code>.context.SliceId slice_id = 2;</code> + * @return Whether the sliceId field is set. + */ + @java.lang.Override + public boolean hasSliceId() { + return sliceId_ != null; + } + /** + * <code>.context.SliceId slice_id = 2;</code> + * @return The sliceId. + */ + @java.lang.Override + public context.ContextOuterClass.SliceId getSliceId() { + return sliceId_ == null ? context.ContextOuterClass.SliceId.getDefaultInstance() : sliceId_; + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceIdOrBuilder getSliceIdOrBuilder() { + return getSliceId(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (event_ != null) { + output.writeMessage(1, getEvent()); + } + if (sliceId_ != null) { + output.writeMessage(2, getSliceId()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (event_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getEvent()); + } + if (sliceId_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getSliceId()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof context.ContextOuterClass.SliceEvent)) { + return super.equals(obj); + } + context.ContextOuterClass.SliceEvent other = (context.ContextOuterClass.SliceEvent) obj; + + if (hasEvent() != other.hasEvent()) return false; + if (hasEvent()) { + if (!getEvent() + .equals(other.getEvent())) return false; + } + if (hasSliceId() != other.hasSliceId()) return false; + if (hasSliceId()) { + if (!getSliceId() + .equals(other.getSliceId())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasEvent()) { + hash = (37 * hash) + EVENT_FIELD_NUMBER; + hash = (53 * hash) + getEvent().hashCode(); + } + if (hasSliceId()) { + hash = (37 * hash) + SLICE_ID_FIELD_NUMBER; + hash = (53 * hash) + getSliceId().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static context.ContextOuterClass.SliceEvent parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceEvent parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceEvent parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceEvent parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceEvent parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceEvent parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceEvent parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceEvent parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceEvent parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceEvent parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceEvent parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceEvent parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(context.ContextOuterClass.SliceEvent prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code context.SliceEvent} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements + // @@protoc_insertion_point(builder_implements:context.SliceEvent) + context.ContextOuterClass.SliceEventOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceEvent_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceEvent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceEvent.class, context.ContextOuterClass.SliceEvent.Builder.class); + } + + // Construct using context.ContextOuterClass.SliceEvent.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (eventBuilder_ == null) { + event_ = null; + } else { + event_ = null; + eventBuilder_ = null; + } + if (sliceIdBuilder_ == null) { + sliceId_ = null; + } else { + sliceId_ = null; + sliceIdBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return context.ContextOuterClass.internal_static_context_SliceEvent_descriptor; + } + + @java.lang.Override + public context.ContextOuterClass.SliceEvent getDefaultInstanceForType() { + return context.ContextOuterClass.SliceEvent.getDefaultInstance(); + } + + @java.lang.Override + public context.ContextOuterClass.SliceEvent build() { + context.ContextOuterClass.SliceEvent result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public context.ContextOuterClass.SliceEvent buildPartial() { + context.ContextOuterClass.SliceEvent result = new context.ContextOuterClass.SliceEvent(this); + if (eventBuilder_ == null) { + result.event_ = event_; + } else { + result.event_ = eventBuilder_.build(); + } + if (sliceIdBuilder_ == null) { + result.sliceId_ = sliceId_; + } else { + result.sliceId_ = sliceIdBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof context.ContextOuterClass.SliceEvent) { + return mergeFrom((context.ContextOuterClass.SliceEvent)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(context.ContextOuterClass.SliceEvent other) { + if (other == context.ContextOuterClass.SliceEvent.getDefaultInstance()) return this; + if (other.hasEvent()) { + mergeEvent(other.getEvent()); + } + if (other.hasSliceId()) { + mergeSliceId(other.getSliceId()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + context.ContextOuterClass.SliceEvent parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (context.ContextOuterClass.SliceEvent) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private context.ContextOuterClass.Event event_; + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.Event, context.ContextOuterClass.Event.Builder, context.ContextOuterClass.EventOrBuilder> eventBuilder_; + /** + * <code>.context.Event event = 1;</code> + * @return Whether the event field is set. + */ + public boolean hasEvent() { + return eventBuilder_ != null || event_ != null; + } + /** + * <code>.context.Event event = 1;</code> + * @return The event. + */ + public context.ContextOuterClass.Event getEvent() { + if (eventBuilder_ == null) { + return event_ == null ? context.ContextOuterClass.Event.getDefaultInstance() : event_; + } else { + return eventBuilder_.getMessage(); + } + } + /** + * <code>.context.Event event = 1;</code> + */ + public Builder setEvent(context.ContextOuterClass.Event value) { + if (eventBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + event_ = value; + onChanged(); + } else { + eventBuilder_.setMessage(value); + } + + return this; + } + /** + * <code>.context.Event event = 1;</code> + */ + public Builder setEvent( + context.ContextOuterClass.Event.Builder builderForValue) { + if (eventBuilder_ == null) { + event_ = builderForValue.build(); + onChanged(); + } else { + eventBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * <code>.context.Event event = 1;</code> + */ + public Builder mergeEvent(context.ContextOuterClass.Event value) { + if (eventBuilder_ == null) { + if (event_ != null) { + event_ = + context.ContextOuterClass.Event.newBuilder(event_).mergeFrom(value).buildPartial(); + } else { + event_ = value; + } + onChanged(); + } else { + eventBuilder_.mergeFrom(value); + } + + return this; + } + /** + * <code>.context.Event event = 1;</code> + */ + public Builder clearEvent() { + if (eventBuilder_ == null) { + event_ = null; + onChanged(); + } else { + event_ = null; + eventBuilder_ = null; + } + + return this; + } + /** + * <code>.context.Event event = 1;</code> + */ + public context.ContextOuterClass.Event.Builder getEventBuilder() { + + onChanged(); + return getEventFieldBuilder().getBuilder(); + } + /** + * <code>.context.Event event = 1;</code> + */ + public context.ContextOuterClass.EventOrBuilder getEventOrBuilder() { + if (eventBuilder_ != null) { + return eventBuilder_.getMessageOrBuilder(); + } else { + return event_ == null ? + context.ContextOuterClass.Event.getDefaultInstance() : event_; + } + } + /** + * <code>.context.Event event = 1;</code> + */ + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.Event, context.ContextOuterClass.Event.Builder, context.ContextOuterClass.EventOrBuilder> + getEventFieldBuilder() { + if (eventBuilder_ == null) { + eventBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.Event, context.ContextOuterClass.Event.Builder, context.ContextOuterClass.EventOrBuilder>( + getEvent(), + getParentForChildren(), + isClean()); + event_ = null; + } + return eventBuilder_; + } + + private context.ContextOuterClass.SliceId sliceId_; + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> sliceIdBuilder_; + /** + * <code>.context.SliceId slice_id = 2;</code> + * @return Whether the sliceId field is set. + */ + public boolean hasSliceId() { + return sliceIdBuilder_ != null || sliceId_ != null; + } + /** + * <code>.context.SliceId slice_id = 2;</code> + * @return The sliceId. + */ + public context.ContextOuterClass.SliceId getSliceId() { + if (sliceIdBuilder_ == null) { + return sliceId_ == null ? context.ContextOuterClass.SliceId.getDefaultInstance() : sliceId_; + } else { + return sliceIdBuilder_.getMessage(); + } + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + public Builder setSliceId(context.ContextOuterClass.SliceId value) { + if (sliceIdBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + sliceId_ = value; + onChanged(); + } else { + sliceIdBuilder_.setMessage(value); + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + public Builder setSliceId( + context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceIdBuilder_ == null) { + sliceId_ = builderForValue.build(); + onChanged(); + } else { + sliceIdBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + public Builder mergeSliceId(context.ContextOuterClass.SliceId value) { + if (sliceIdBuilder_ == null) { + if (sliceId_ != null) { + sliceId_ = + context.ContextOuterClass.SliceId.newBuilder(sliceId_).mergeFrom(value).buildPartial(); + } else { + sliceId_ = value; + } + onChanged(); + } else { + sliceIdBuilder_.mergeFrom(value); + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + public Builder clearSliceId() { + if (sliceIdBuilder_ == null) { + sliceId_ = null; + onChanged(); + } else { + sliceId_ = null; + sliceIdBuilder_ = null; + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + public context.ContextOuterClass.SliceId.Builder getSliceIdBuilder() { + + onChanged(); + return getSliceIdFieldBuilder().getBuilder(); + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + public context.ContextOuterClass.SliceIdOrBuilder getSliceIdOrBuilder() { + if (sliceIdBuilder_ != null) { + return sliceIdBuilder_.getMessageOrBuilder(); + } else { + return sliceId_ == null ? + context.ContextOuterClass.SliceId.getDefaultInstance() : sliceId_; + } + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> + getSliceIdFieldBuilder() { + if (sliceIdBuilder_ == null) { + sliceIdBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder>( + getSliceId(), + getParentForChildren(), + isClean()); + sliceId_ = null; + } + return sliceIdBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:context.SliceEvent) + } + + // @@protoc_insertion_point(class_scope:context.SliceEvent) + private static final context.ContextOuterClass.SliceEvent DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new context.ContextOuterClass.SliceEvent(); + } + + public static context.ContextOuterClass.SliceEvent getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser<SliceEvent> + PARSER = new com.google.protobuf.AbstractParser<SliceEvent>() { + @java.lang.Override + public SliceEvent parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SliceEvent(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser<SliceEvent> parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser<SliceEvent> getParserForType() { + return PARSER; + } + + @java.lang.Override + public context.ContextOuterClass.SliceEvent getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ConnectionIdOrBuilder extends + // @@protoc_insertion_point(interface_extends:context.ConnectionId) + com.google.protobuf.MessageOrBuilder { + + /** + * <code>.context.Uuid connection_uuid = 1;</code> + * @return Whether the connectionUuid field is set. + */ + boolean hasConnectionUuid(); + /** + * <code>.context.Uuid connection_uuid = 1;</code> + * @return The connectionUuid. + */ + context.ContextOuterClass.Uuid getConnectionUuid(); + /** + * <code>.context.Uuid connection_uuid = 1;</code> + */ + context.ContextOuterClass.UuidOrBuilder getConnectionUuidOrBuilder(); + } + /** + * <pre> + * ----- Connection ---------------------------------------------------------------------------------------------------- + * </pre> + * + * Protobuf type {@code context.ConnectionId} + */ + public static final class ConnectionId extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:context.ConnectionId) + ConnectionIdOrBuilder { + private static final long serialVersionUID = 0L; + // Use ConnectionId.newBuilder() to construct. + private ConnectionId(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { + super(builder); + } + private ConnectionId() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new ConnectionId(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ConnectionId( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + context.ContextOuterClass.Uuid.Builder subBuilder = null; + if (connectionUuid_ != null) { + subBuilder = connectionUuid_.toBuilder(); + } + connectionUuid_ = input.readMessage(context.ContextOuterClass.Uuid.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(connectionUuid_); + connectionUuid_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_ConnectionId_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_ConnectionId_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.ConnectionId.class, context.ContextOuterClass.ConnectionId.Builder.class); + } + + public static final int CONNECTION_UUID_FIELD_NUMBER = 1; + private context.ContextOuterClass.Uuid connectionUuid_; + /** + * <code>.context.Uuid connection_uuid = 1;</code> + * @return Whether the connectionUuid field is set. + */ + @java.lang.Override + public boolean hasConnectionUuid() { + return connectionUuid_ != null; + } + /** + * <code>.context.Uuid connection_uuid = 1;</code> + * @return The connectionUuid. + */ + @java.lang.Override + public context.ContextOuterClass.Uuid getConnectionUuid() { + return connectionUuid_ == null ? context.ContextOuterClass.Uuid.getDefaultInstance() : connectionUuid_; + } + /** + * <code>.context.Uuid connection_uuid = 1;</code> + */ + @java.lang.Override + public context.ContextOuterClass.UuidOrBuilder getConnectionUuidOrBuilder() { + return getConnectionUuid(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (connectionUuid_ != null) { + output.writeMessage(1, getConnectionUuid()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (connectionUuid_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getConnectionUuid()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof context.ContextOuterClass.ConnectionId)) { + return super.equals(obj); + } + context.ContextOuterClass.ConnectionId other = (context.ContextOuterClass.ConnectionId) obj; + + if (hasConnectionUuid() != other.hasConnectionUuid()) return false; + if (hasConnectionUuid()) { + if (!getConnectionUuid() + .equals(other.getConnectionUuid())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasConnectionUuid()) { + hash = (37 * hash) + CONNECTION_UUID_FIELD_NUMBER; + hash = (53 * hash) + getConnectionUuid().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static context.ContextOuterClass.ConnectionId parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.ConnectionId parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.ConnectionId parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.ConnectionId parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.ConnectionId parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.ConnectionId parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.ConnectionId parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.ConnectionId parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.ConnectionId parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static context.ContextOuterClass.ConnectionId parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.ConnectionId parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.ConnectionId parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(context.ContextOuterClass.ConnectionId prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * <pre> + * ----- Connection ---------------------------------------------------------------------------------------------------- + * </pre> + * + * Protobuf type {@code context.ConnectionId} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements + // @@protoc_insertion_point(builder_implements:context.ConnectionId) + context.ContextOuterClass.ConnectionIdOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_ConnectionId_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_ConnectionId_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.ConnectionId.class, context.ContextOuterClass.ConnectionId.Builder.class); + } + + // Construct using context.ContextOuterClass.ConnectionId.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (connectionUuidBuilder_ == null) { + connectionUuid_ = null; + } else { + connectionUuid_ = null; + connectionUuidBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return context.ContextOuterClass.internal_static_context_ConnectionId_descriptor; + } + + @java.lang.Override + public context.ContextOuterClass.ConnectionId getDefaultInstanceForType() { + return context.ContextOuterClass.ConnectionId.getDefaultInstance(); + } + + @java.lang.Override + public context.ContextOuterClass.ConnectionId build() { + context.ContextOuterClass.ConnectionId result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public context.ContextOuterClass.ConnectionId buildPartial() { + context.ContextOuterClass.ConnectionId result = new context.ContextOuterClass.ConnectionId(this); + if (connectionUuidBuilder_ == null) { + result.connectionUuid_ = connectionUuid_; + } else { + result.connectionUuid_ = connectionUuidBuilder_.build(); } onBuilt(); return result; @@ -37615,6 +43832,36 @@ public final class ContextOuterClass { private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_context_ServiceEvent_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_context_SliceId_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_context_SliceId_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_context_Slice_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_context_Slice_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_context_SliceStatus_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_context_SliceStatus_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_context_SliceIdList_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_context_SliceIdList_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_context_SliceList_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_context_SliceList_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_context_SliceEvent_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_context_SliceEvent_fieldAccessorTable; private static final com.google.protobuf.Descriptors.Descriptor internal_static_context_ConnectionId_descriptor; private static final @@ -37744,107 +43991,134 @@ public final class ContextOuterClass { "\"\n\010services\030\001 \003(\0132\020.context.Service\"U\n\014S" + "erviceEvent\022\035\n\005event\030\001 \001(\0132\016.context.Eve" + "nt\022&\n\nservice_id\030\002 \001(\0132\022.context.Service" + - "Id\"6\n\014ConnectionId\022&\n\017connection_uuid\030\001 " + - "\001(\0132\r.context.Uuid\"\304\001\n\nConnection\022,\n\rcon" + - "nection_id\030\001 \001(\0132\025.context.ConnectionId\022" + - "&\n\nservice_id\030\002 \001(\0132\022.context.ServiceId\022" + - "3\n\026path_hops_endpoint_ids\030\003 \003(\0132\023.contex" + - "t.EndPointId\022+\n\017sub_service_ids\030\004 \003(\0132\022." + - "context.ServiceId\"A\n\020ConnectionIdList\022-\n" + - "\016connection_ids\030\001 \003(\0132\025.context.Connecti" + - "onId\":\n\016ConnectionList\022(\n\013connections\030\001 " + - "\003(\0132\023.context.Connection\"^\n\017ConnectionEv" + - "ent\022\035\n\005event\030\001 \001(\0132\016.context.Event\022,\n\rco" + - "nnection_id\030\002 \001(\0132\025.context.ConnectionId" + - "\"\202\001\n\nEndPointId\022(\n\013topology_id\030\001 \001(\0132\023.c" + - "ontext.TopologyId\022$\n\tdevice_id\030\002 \001(\0132\021.c" + - "ontext.DeviceId\022$\n\rendpoint_uuid\030\003 \001(\0132\r" + - ".context.Uuid\"\206\001\n\010EndPoint\022(\n\013endpoint_i" + - "d\030\001 \001(\0132\023.context.EndPointId\022\025\n\rendpoint" + - "_type\030\002 \001(\t\0229\n\020kpi_sample_types\030\003 \003(\0162\037." + - "kpi_sample_types.KpiSampleType\"e\n\nConfig" + - "Rule\022)\n\006action\030\001 \001(\0162\031.context.ConfigAct" + - "ionEnum\022\024\n\014resource_key\030\002 \001(\t\022\026\n\016resourc" + - "e_value\030\003 \001(\t\"?\n\nConstraint\022\027\n\017constrain" + - "t_type\030\001 \001(\t\022\030\n\020constraint_value\030\002 \001(\t\"^" + - "\n\022TeraFlowController\022&\n\ncontext_id\030\001 \001(\013" + - "2\022.context.ContextId\022\022\n\nip_address\030\002 \001(\t" + - "\022\014\n\004port\030\003 \001(\r\"U\n\024AuthenticationResult\022&" + - "\n\ncontext_id\030\001 \001(\0132\022.context.ContextId\022\025" + - "\n\rauthenticated\030\002 \001(\010*j\n\rEventTypeEnum\022\027" + - "\n\023EVENTTYPE_UNDEFINED\020\000\022\024\n\020EVENTTYPE_CRE" + - "ATE\020\001\022\024\n\020EVENTTYPE_UPDATE\020\002\022\024\n\020EVENTTYPE" + - "_REMOVE\020\003*\305\001\n\020DeviceDriverEnum\022\032\n\026DEVICE" + - "DRIVER_UNDEFINED\020\000\022\033\n\027DEVICEDRIVER_OPENC" + - "ONFIG\020\001\022\036\n\032DEVICEDRIVER_TRANSPORT_API\020\002\022" + - "\023\n\017DEVICEDRIVER_P4\020\003\022&\n\"DEVICEDRIVER_IET" + - "F_NETWORK_TOPOLOGY\020\004\022\033\n\027DEVICEDRIVER_ONF" + - "_TR_352\020\005*\217\001\n\033DeviceOperationalStatusEnu" + - "m\022%\n!DEVICEOPERATIONALSTATUS_UNDEFINED\020\000" + - "\022$\n DEVICEOPERATIONALSTATUS_DISABLED\020\001\022#" + - "\n\037DEVICEOPERATIONALSTATUS_ENABLED\020\002*\201\001\n\017" + - "ServiceTypeEnum\022\027\n\023SERVICETYPE_UNKNOWN\020\000" + - "\022\024\n\020SERVICETYPE_L3NM\020\001\022\024\n\020SERVICETYPE_L2" + - "NM\020\002\022)\n%SERVICETYPE_TAPI_CONNECTIVITY_SE" + - "RVICE\020\003*\210\001\n\021ServiceStatusEnum\022\033\n\027SERVICE" + - "STATUS_UNDEFINED\020\000\022\031\n\025SERVICESTATUS_PLAN" + - "NED\020\001\022\030\n\024SERVICESTATUS_ACTIVE\020\002\022!\n\035SERVI" + - "CESTATUS_PENDING_REMOVAL\020\003*]\n\020ConfigActi" + - "onEnum\022\032\n\026CONFIGACTION_UNDEFINED\020\000\022\024\n\020CO" + - "NFIGACTION_SET\020\001\022\027\n\023CONFIGACTION_DELETE\020" + - "\0022\255\020\n\016ContextService\022:\n\016ListContextIds\022\016" + - ".context.Empty\032\026.context.ContextIdList\"\000" + - "\0226\n\014ListContexts\022\016.context.Empty\032\024.conte" + - "xt.ContextList\"\000\0224\n\nGetContext\022\022.context" + - ".ContextId\032\020.context.Context\"\000\0224\n\nSetCon" + - "text\022\020.context.Context\032\022.context.Context" + - "Id\"\000\0225\n\rRemoveContext\022\022.context.ContextI" + - "d\032\016.context.Empty\"\000\022=\n\020GetContextEvents\022" + - "\016.context.Empty\032\025.context.ContextEvent\"\000" + - "0\001\022@\n\017ListTopologyIds\022\022.context.ContextI" + - "d\032\027.context.TopologyIdList\"\000\022=\n\016ListTopo" + - "logies\022\022.context.ContextId\032\025.context.Top" + - "ologyList\"\000\0227\n\013GetTopology\022\023.context.Top" + - "ologyId\032\021.context.Topology\"\000\0227\n\013SetTopol" + - "ogy\022\021.context.Topology\032\023.context.Topolog" + - "yId\"\000\0227\n\016RemoveTopology\022\023.context.Topolo" + - "gyId\032\016.context.Empty\"\000\022?\n\021GetTopologyEve" + - "nts\022\016.context.Empty\032\026.context.TopologyEv" + - "ent\"\0000\001\0228\n\rListDeviceIds\022\016.context.Empty" + - "\032\025.context.DeviceIdList\"\000\0224\n\013ListDevices" + - "\022\016.context.Empty\032\023.context.DeviceList\"\000\022" + - "1\n\tGetDevice\022\021.context.DeviceId\032\017.contex" + - "t.Device\"\000\0221\n\tSetDevice\022\017.context.Device" + - "\032\021.context.DeviceId\"\000\0223\n\014RemoveDevice\022\021." + - "context.DeviceId\032\016.context.Empty\"\000\022;\n\017Ge" + - "tDeviceEvents\022\016.context.Empty\032\024.context." + - "DeviceEvent\"\0000\001\0224\n\013ListLinkIds\022\016.context" + - ".Empty\032\023.context.LinkIdList\"\000\0220\n\tListLin" + - "ks\022\016.context.Empty\032\021.context.LinkList\"\000\022" + - "+\n\007GetLink\022\017.context.LinkId\032\r.context.Li" + - "nk\"\000\022+\n\007SetLink\022\r.context.Link\032\017.context" + - ".LinkId\"\000\022/\n\nRemoveLink\022\017.context.LinkId" + - "\032\016.context.Empty\"\000\0227\n\rGetLinkEvents\022\016.co" + - "ntext.Empty\032\022.context.LinkEvent\"\0000\001\022>\n\016L" + - "istServiceIds\022\022.context.ContextId\032\026.cont" + - "ext.ServiceIdList\"\000\022:\n\014ListServices\022\022.co" + - "ntext.ContextId\032\024.context.ServiceList\"\000\022" + - "4\n\nGetService\022\022.context.ServiceId\032\020.cont" + - "ext.Service\"\000\0224\n\nSetService\022\020.context.Se" + - "rvice\032\022.context.ServiceId\"\000\0225\n\rRemoveSer" + - "vice\022\022.context.ServiceId\032\016.context.Empty" + - "\"\000\022=\n\020GetServiceEvents\022\016.context.Empty\032\025" + - ".context.ServiceEvent\"\0000\001\022D\n\021ListConnect" + - "ionIds\022\022.context.ServiceId\032\031.context.Con" + - "nectionIdList\"\000\022@\n\017ListConnections\022\022.con" + - "text.ServiceId\032\027.context.ConnectionList\"" + - "\000\022=\n\rGetConnection\022\025.context.ConnectionI" + - "d\032\023.context.Connection\"\000\022=\n\rSetConnectio" + - "n\022\023.context.Connection\032\025.context.Connect" + - "ionId\"\000\022;\n\020RemoveConnection\022\025.context.Co" + - "nnectionId\032\016.context.Empty\"\000\022C\n\023GetConne" + - "ctionEvents\022\016.context.Empty\032\030.context.Co" + - "nnectionEvent\"\0000\001b\006proto3" + "Id\"T\n\007SliceId\022&\n\ncontext_id\030\001 \001(\0132\022.cont" + + "ext.ContextId\022!\n\nslice_uuid\030\002 \001(\0132\r.cont" + + "ext.Uuid\"\225\002\n\005Slice\022\"\n\010slice_id\030\001 \001(\0132\020.c" + + "ontext.SliceId\022/\n\022slice_endpoint_ids\030\002 \003" + + "(\0132\023.context.EndPointId\022.\n\021slice_constra" + + "ints\030\003 \003(\0132\023.context.Constraint\022-\n\021slice" + + "_service_ids\030\004 \003(\0132\022.context.ServiceId\022," + + "\n\022slice_subslice_ids\030\005 \003(\0132\020.context.Sli" + + "ceId\022*\n\014slice_status\030\006 \001(\0132\024.context.Sli" + + "ceStatus\"=\n\013SliceStatus\022.\n\014slice_status\030" + + "\001 \001(\0162\030.context.SliceStatusEnum\"2\n\013Slice" + + "IdList\022#\n\tslice_ids\030\001 \003(\0132\020.context.Slic" + + "eId\"+\n\tSliceList\022\036\n\006slices\030\001 \003(\0132\016.conte" + + "xt.Slice\"O\n\nSliceEvent\022\035\n\005event\030\001 \001(\0132\016." + + "context.Event\022\"\n\010slice_id\030\002 \001(\0132\020.contex" + + "t.SliceId\"6\n\014ConnectionId\022&\n\017connection_" + + "uuid\030\001 \001(\0132\r.context.Uuid\"\304\001\n\nConnection" + + "\022,\n\rconnection_id\030\001 \001(\0132\025.context.Connec" + + "tionId\022&\n\nservice_id\030\002 \001(\0132\022.context.Ser" + + "viceId\0223\n\026path_hops_endpoint_ids\030\003 \003(\0132\023" + + ".context.EndPointId\022+\n\017sub_service_ids\030\004" + + " \003(\0132\022.context.ServiceId\"A\n\020ConnectionId" + + "List\022-\n\016connection_ids\030\001 \003(\0132\025.context.C" + + "onnectionId\":\n\016ConnectionList\022(\n\013connect" + + "ions\030\001 \003(\0132\023.context.Connection\"^\n\017Conne" + + "ctionEvent\022\035\n\005event\030\001 \001(\0132\016.context.Even" + + "t\022,\n\rconnection_id\030\002 \001(\0132\025.context.Conne" + + "ctionId\"\202\001\n\nEndPointId\022(\n\013topology_id\030\001 " + + "\001(\0132\023.context.TopologyId\022$\n\tdevice_id\030\002 " + + "\001(\0132\021.context.DeviceId\022$\n\rendpoint_uuid\030" + + "\003 \001(\0132\r.context.Uuid\"\206\001\n\010EndPoint\022(\n\013end" + + "point_id\030\001 \001(\0132\023.context.EndPointId\022\025\n\re" + + "ndpoint_type\030\002 \001(\t\0229\n\020kpi_sample_types\030\003" + + " \003(\0162\037.kpi_sample_types.KpiSampleType\"e\n" + + "\nConfigRule\022)\n\006action\030\001 \001(\0162\031.context.Co" + + "nfigActionEnum\022\024\n\014resource_key\030\002 \001(\t\022\026\n\016" + + "resource_value\030\003 \001(\t\"?\n\nConstraint\022\027\n\017co" + + "nstraint_type\030\001 \001(\t\022\030\n\020constraint_value\030" + + "\002 \001(\t\"^\n\022TeraFlowController\022&\n\ncontext_i" + + "d\030\001 \001(\0132\022.context.ContextId\022\022\n\nip_addres" + + "s\030\002 \001(\t\022\014\n\004port\030\003 \001(\r\"U\n\024AuthenticationR" + + "esult\022&\n\ncontext_id\030\001 \001(\0132\022.context.Cont" + + "extId\022\025\n\rauthenticated\030\002 \001(\010*j\n\rEventTyp" + + "eEnum\022\027\n\023EVENTTYPE_UNDEFINED\020\000\022\024\n\020EVENTT" + + "YPE_CREATE\020\001\022\024\n\020EVENTTYPE_UPDATE\020\002\022\024\n\020EV" + + "ENTTYPE_REMOVE\020\003*\305\001\n\020DeviceDriverEnum\022\032\n" + + "\026DEVICEDRIVER_UNDEFINED\020\000\022\033\n\027DEVICEDRIVE" + + "R_OPENCONFIG\020\001\022\036\n\032DEVICEDRIVER_TRANSPORT" + + "_API\020\002\022\023\n\017DEVICEDRIVER_P4\020\003\022&\n\"DEVICEDRI" + + "VER_IETF_NETWORK_TOPOLOGY\020\004\022\033\n\027DEVICEDRI" + + "VER_ONF_TR_352\020\005*\217\001\n\033DeviceOperationalSt" + + "atusEnum\022%\n!DEVICEOPERATIONALSTATUS_UNDE" + + "FINED\020\000\022$\n DEVICEOPERATIONALSTATUS_DISAB" + + "LED\020\001\022#\n\037DEVICEOPERATIONALSTATUS_ENABLED" + + "\020\002*\201\001\n\017ServiceTypeEnum\022\027\n\023SERVICETYPE_UN" + + "KNOWN\020\000\022\024\n\020SERVICETYPE_L3NM\020\001\022\024\n\020SERVICE" + + "TYPE_L2NM\020\002\022)\n%SERVICETYPE_TAPI_CONNECTI" + + "VITY_SERVICE\020\003*\210\001\n\021ServiceStatusEnum\022\033\n\027" + + "SERVICESTATUS_UNDEFINED\020\000\022\031\n\025SERVICESTAT" + + "US_PLANNED\020\001\022\030\n\024SERVICESTATUS_ACTIVE\020\002\022!" + + "\n\035SERVICESTATUS_PENDING_REMOVAL\020\003*\213\001\n\017Sl" + + "iceStatusEnum\022\031\n\025SLICESTATUS_UNDEFINED\020\000" + + "\022\027\n\023SLICESTATUS_PLANNED\020\001\022\024\n\020SLICESTATUS" + + "_INIT\020\002\022\026\n\022SLICESTATUS_ACTIVE\020\003\022\026\n\022SLICE" + + "STATUS_DEINIT\020\004*]\n\020ConfigActionEnum\022\032\n\026C" + + "ONFIGACTION_UNDEFINED\020\000\022\024\n\020CONFIGACTION_" + + "SET\020\001\022\027\n\023CONFIGACTION_DELETE\020\0022\357\022\n\016Conte" + + "xtService\022:\n\016ListContextIds\022\016.context.Em" + + "pty\032\026.context.ContextIdList\"\000\0226\n\014ListCon" + + "texts\022\016.context.Empty\032\024.context.ContextL" + + "ist\"\000\0224\n\nGetContext\022\022.context.ContextId\032" + + "\020.context.Context\"\000\0224\n\nSetContext\022\020.cont" + + "ext.Context\032\022.context.ContextId\"\000\0225\n\rRem" + + "oveContext\022\022.context.ContextId\032\016.context" + + ".Empty\"\000\022=\n\020GetContextEvents\022\016.context.E" + + "mpty\032\025.context.ContextEvent\"\0000\001\022@\n\017ListT" + + "opologyIds\022\022.context.ContextId\032\027.context" + + ".TopologyIdList\"\000\022=\n\016ListTopologies\022\022.co" + + "ntext.ContextId\032\025.context.TopologyList\"\000" + + "\0227\n\013GetTopology\022\023.context.TopologyId\032\021.c" + + "ontext.Topology\"\000\0227\n\013SetTopology\022\021.conte" + + "xt.Topology\032\023.context.TopologyId\"\000\0227\n\016Re" + + "moveTopology\022\023.context.TopologyId\032\016.cont" + + "ext.Empty\"\000\022?\n\021GetTopologyEvents\022\016.conte" + + "xt.Empty\032\026.context.TopologyEvent\"\0000\001\0228\n\r" + + "ListDeviceIds\022\016.context.Empty\032\025.context." + + "DeviceIdList\"\000\0224\n\013ListDevices\022\016.context." + + "Empty\032\023.context.DeviceList\"\000\0221\n\tGetDevic" + + "e\022\021.context.DeviceId\032\017.context.Device\"\000\022" + + "1\n\tSetDevice\022\017.context.Device\032\021.context." + + "DeviceId\"\000\0223\n\014RemoveDevice\022\021.context.Dev" + + "iceId\032\016.context.Empty\"\000\022;\n\017GetDeviceEven" + + "ts\022\016.context.Empty\032\024.context.DeviceEvent" + + "\"\0000\001\0224\n\013ListLinkIds\022\016.context.Empty\032\023.co" + + "ntext.LinkIdList\"\000\0220\n\tListLinks\022\016.contex" + + "t.Empty\032\021.context.LinkList\"\000\022+\n\007GetLink\022" + + "\017.context.LinkId\032\r.context.Link\"\000\022+\n\007Set" + + "Link\022\r.context.Link\032\017.context.LinkId\"\000\022/" + + "\n\nRemoveLink\022\017.context.LinkId\032\016.context." + + "Empty\"\000\0227\n\rGetLinkEvents\022\016.context.Empty" + + "\032\022.context.LinkEvent\"\0000\001\022>\n\016ListServiceI" + + "ds\022\022.context.ContextId\032\026.context.Service" + + "IdList\"\000\022:\n\014ListServices\022\022.context.Conte" + + "xtId\032\024.context.ServiceList\"\000\0224\n\nGetServi" + + "ce\022\022.context.ServiceId\032\020.context.Service" + + "\"\000\0224\n\nSetService\022\020.context.Service\032\022.con" + + "text.ServiceId\"\000\0225\n\rRemoveService\022\022.cont" + + "ext.ServiceId\032\016.context.Empty\"\000\022=\n\020GetSe" + + "rviceEvents\022\016.context.Empty\032\025.context.Se" + + "rviceEvent\"\0000\001\022:\n\014ListSliceIds\022\022.context" + + ".ContextId\032\024.context.SliceIdList\"\000\0226\n\nLi" + + "stSlices\022\022.context.ContextId\032\022.context.S" + + "liceList\"\000\022.\n\010GetSlice\022\020.context.SliceId" + + "\032\016.context.Slice\"\000\022.\n\010SetSlice\022\016.context" + + ".Slice\032\020.context.SliceId\"\000\0221\n\013RemoveSlic" + + "e\022\020.context.SliceId\032\016.context.Empty\"\000\0229\n" + + "\016GetSliceEvents\022\016.context.Empty\032\023.contex" + + "t.SliceEvent\"\0000\001\022D\n\021ListConnectionIds\022\022." + + "context.ServiceId\032\031.context.ConnectionId" + + "List\"\000\022@\n\017ListConnections\022\022.context.Serv" + + "iceId\032\027.context.ConnectionList\"\000\022=\n\rGetC" + + "onnection\022\025.context.ConnectionId\032\023.conte" + + "xt.Connection\"\000\022=\n\rSetConnection\022\023.conte" + + "xt.Connection\032\025.context.ConnectionId\"\000\022;" + + "\n\020RemoveConnection\022\025.context.ConnectionI" + + "d\032\016.context.Empty\"\000\022C\n\023GetConnectionEven" + + "ts\022\016.context.Empty\032\030.context.ConnectionE" + + "vent\"\0000\001b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -38037,68 +44311,104 @@ public final class ContextOuterClass { com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_ServiceEvent_descriptor, new java.lang.String[] { "Event", "ServiceId", }); - internal_static_context_ConnectionId_descriptor = + internal_static_context_SliceId_descriptor = getDescriptor().getMessageTypes().get(31); + internal_static_context_SliceId_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_context_SliceId_descriptor, + new java.lang.String[] { "ContextId", "SliceUuid", }); + internal_static_context_Slice_descriptor = + getDescriptor().getMessageTypes().get(32); + internal_static_context_Slice_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_context_Slice_descriptor, + new java.lang.String[] { "SliceId", "SliceEndpointIds", "SliceConstraints", "SliceServiceIds", "SliceSubsliceIds", "SliceStatus", }); + internal_static_context_SliceStatus_descriptor = + getDescriptor().getMessageTypes().get(33); + internal_static_context_SliceStatus_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_context_SliceStatus_descriptor, + new java.lang.String[] { "SliceStatus", }); + internal_static_context_SliceIdList_descriptor = + getDescriptor().getMessageTypes().get(34); + internal_static_context_SliceIdList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_context_SliceIdList_descriptor, + new java.lang.String[] { "SliceIds", }); + internal_static_context_SliceList_descriptor = + getDescriptor().getMessageTypes().get(35); + internal_static_context_SliceList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_context_SliceList_descriptor, + new java.lang.String[] { "Slices", }); + internal_static_context_SliceEvent_descriptor = + getDescriptor().getMessageTypes().get(36); + internal_static_context_SliceEvent_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_context_SliceEvent_descriptor, + new java.lang.String[] { "Event", "SliceId", }); + internal_static_context_ConnectionId_descriptor = + getDescriptor().getMessageTypes().get(37); internal_static_context_ConnectionId_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_ConnectionId_descriptor, new java.lang.String[] { "ConnectionUuid", }); internal_static_context_Connection_descriptor = - getDescriptor().getMessageTypes().get(32); + getDescriptor().getMessageTypes().get(38); internal_static_context_Connection_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_Connection_descriptor, new java.lang.String[] { "ConnectionId", "ServiceId", "PathHopsEndpointIds", "SubServiceIds", }); internal_static_context_ConnectionIdList_descriptor = - getDescriptor().getMessageTypes().get(33); + getDescriptor().getMessageTypes().get(39); internal_static_context_ConnectionIdList_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_ConnectionIdList_descriptor, new java.lang.String[] { "ConnectionIds", }); internal_static_context_ConnectionList_descriptor = - getDescriptor().getMessageTypes().get(34); + getDescriptor().getMessageTypes().get(40); internal_static_context_ConnectionList_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_ConnectionList_descriptor, new java.lang.String[] { "Connections", }); internal_static_context_ConnectionEvent_descriptor = - getDescriptor().getMessageTypes().get(35); + getDescriptor().getMessageTypes().get(41); internal_static_context_ConnectionEvent_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_ConnectionEvent_descriptor, new java.lang.String[] { "Event", "ConnectionId", }); internal_static_context_EndPointId_descriptor = - getDescriptor().getMessageTypes().get(36); + getDescriptor().getMessageTypes().get(42); internal_static_context_EndPointId_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_EndPointId_descriptor, new java.lang.String[] { "TopologyId", "DeviceId", "EndpointUuid", }); internal_static_context_EndPoint_descriptor = - getDescriptor().getMessageTypes().get(37); + getDescriptor().getMessageTypes().get(43); internal_static_context_EndPoint_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_EndPoint_descriptor, new java.lang.String[] { "EndpointId", "EndpointType", "KpiSampleTypes", }); internal_static_context_ConfigRule_descriptor = - getDescriptor().getMessageTypes().get(38); + getDescriptor().getMessageTypes().get(44); internal_static_context_ConfigRule_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_ConfigRule_descriptor, new java.lang.String[] { "Action", "ResourceKey", "ResourceValue", }); internal_static_context_Constraint_descriptor = - getDescriptor().getMessageTypes().get(39); + getDescriptor().getMessageTypes().get(45); internal_static_context_Constraint_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_Constraint_descriptor, new java.lang.String[] { "ConstraintType", "ConstraintValue", }); internal_static_context_TeraFlowController_descriptor = - getDescriptor().getMessageTypes().get(40); + getDescriptor().getMessageTypes().get(46); internal_static_context_TeraFlowController_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_TeraFlowController_descriptor, new java.lang.String[] { "ContextId", "IpAddress", "Port", }); internal_static_context_AuthenticationResult_descriptor = - getDescriptor().getMessageTypes().get(41); + getDescriptor().getMessageTypes().get(47); internal_static_context_AuthenticationResult_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_AuthenticationResult_descriptor, diff --git a/src/automation/target/generated-sources/grpc/context/ContextService.java b/src/automation/target/generated-sources/grpc/context/ContextService.java index cbd51163f340212839e0eeb2ad096032fdba8109..d54c56057ca53e40071490d3b9aa313a13a77665 100644 --- a/src/automation/target/generated-sources/grpc/context/ContextService.java +++ b/src/automation/target/generated-sources/grpc/context/ContextService.java @@ -58,6 +58,16 @@ public interface ContextService extends MutinyService { io.smallrye.mutiny.Uni<context.ContextOuterClass.Empty> removeService(context.ContextOuterClass.ServiceId request); + io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceIdList> listSliceIds(context.ContextOuterClass.ContextId request); + + io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceList> listSlices(context.ContextOuterClass.ContextId request); + + io.smallrye.mutiny.Uni<context.ContextOuterClass.Slice> getSlice(context.ContextOuterClass.SliceId request); + + io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceId> setSlice(context.ContextOuterClass.Slice request); + + io.smallrye.mutiny.Uni<context.ContextOuterClass.Empty> removeSlice(context.ContextOuterClass.SliceId request); + io.smallrye.mutiny.Uni<context.ContextOuterClass.ConnectionIdList> listConnectionIds(context.ContextOuterClass.ServiceId request); io.smallrye.mutiny.Uni<context.ContextOuterClass.ConnectionList> listConnections(context.ContextOuterClass.ServiceId request); @@ -79,6 +89,8 @@ public interface ContextService extends MutinyService { io.smallrye.mutiny.Multi<context.ContextOuterClass.ServiceEvent> getServiceEvents(context.ContextOuterClass.Empty request); + io.smallrye.mutiny.Multi<context.ContextOuterClass.SliceEvent> getSliceEvents(context.ContextOuterClass.Empty request); + io.smallrye.mutiny.Multi<context.ContextOuterClass.ConnectionEvent> getConnectionEvents(context.ContextOuterClass.Empty request); diff --git a/src/automation/target/generated-sources/grpc/context/ContextServiceBean.java b/src/automation/target/generated-sources/grpc/context/ContextServiceBean.java index 6900cf3c8a09ad6e3df1aaf2cc403c32490d3289..f552294b8e6d645af41cc30632ae0432504bbc67 100644 --- a/src/automation/target/generated-sources/grpc/context/ContextServiceBean.java +++ b/src/automation/target/generated-sources/grpc/context/ContextServiceBean.java @@ -216,6 +216,46 @@ public class ContextServiceBean extends MutinyContextServiceGrpc.ContextServiceI } } @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceIdList> listSliceIds(context.ContextOuterClass.ContextId request) { + try { + return delegate.listSliceIds(request); + } catch (UnsupportedOperationException e) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceList> listSlices(context.ContextOuterClass.ContextId request) { + try { + return delegate.listSlices(request); + } catch (UnsupportedOperationException e) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Slice> getSlice(context.ContextOuterClass.SliceId request) { + try { + return delegate.getSlice(request); + } catch (UnsupportedOperationException e) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceId> setSlice(context.ContextOuterClass.Slice request) { + try { + return delegate.setSlice(request); + } catch (UnsupportedOperationException e) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Empty> removeSlice(context.ContextOuterClass.SliceId request) { + try { + return delegate.removeSlice(request); + } catch (UnsupportedOperationException e) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + } + @Override public io.smallrye.mutiny.Uni<context.ContextOuterClass.ConnectionIdList> listConnectionIds(context.ContextOuterClass.ServiceId request) { try { return delegate.listConnectionIds(request); @@ -301,6 +341,15 @@ public class ContextServiceBean extends MutinyContextServiceGrpc.ContextServiceI } } + @Override + public io.smallrye.mutiny.Multi<context.ContextOuterClass.SliceEvent> getSliceEvents(context.ContextOuterClass.Empty request) { + try { + return delegate.getSliceEvents(request); + } catch (UnsupportedOperationException e) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + } + @Override public io.smallrye.mutiny.Multi<context.ContextOuterClass.ConnectionEvent> getConnectionEvents(context.ContextOuterClass.Empty request) { try { diff --git a/src/automation/target/generated-sources/grpc/context/ContextServiceClient.java b/src/automation/target/generated-sources/grpc/context/ContextServiceClient.java index a3d74cb7dfce2b3ffd259570a6dc65699f85f0cc..c6493bd4d381967238e5eb87dd717f679d028526 100644 --- a/src/automation/target/generated-sources/grpc/context/ContextServiceClient.java +++ b/src/automation/target/generated-sources/grpc/context/ContextServiceClient.java @@ -121,6 +121,26 @@ public class ContextServiceClient implements ContextService, MutinyClient<Mutiny return stub.removeService(request); } @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceIdList> listSliceIds(context.ContextOuterClass.ContextId request) { + return stub.listSliceIds(request); + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceList> listSlices(context.ContextOuterClass.ContextId request) { + return stub.listSlices(request); + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Slice> getSlice(context.ContextOuterClass.SliceId request) { + return stub.getSlice(request); + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceId> setSlice(context.ContextOuterClass.Slice request) { + return stub.setSlice(request); + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Empty> removeSlice(context.ContextOuterClass.SliceId request) { + return stub.removeSlice(request); + } + @Override public io.smallrye.mutiny.Uni<context.ContextOuterClass.ConnectionIdList> listConnectionIds(context.ContextOuterClass.ServiceId request) { return stub.listConnectionIds(request); } @@ -166,6 +186,11 @@ public class ContextServiceClient implements ContextService, MutinyClient<Mutiny return stub.getServiceEvents(request); } + @Override + public io.smallrye.mutiny.Multi<context.ContextOuterClass.SliceEvent> getSliceEvents(context.ContextOuterClass.Empty request) { + return stub.getSliceEvents(request); + } + @Override public io.smallrye.mutiny.Multi<context.ContextOuterClass.ConnectionEvent> getConnectionEvents(context.ContextOuterClass.Empty request) { return stub.getConnectionEvents(request); diff --git a/src/automation/target/generated-sources/grpc/context/ContextServiceGrpc.java b/src/automation/target/generated-sources/grpc/context/ContextServiceGrpc.java index be9f381ffee96febd202beb540bce862c1347378..be720c127439e50f68c2518332f85f750d6579ee 100644 --- a/src/automation/target/generated-sources/grpc/context/ContextServiceGrpc.java +++ b/src/automation/target/generated-sources/grpc/context/ContextServiceGrpc.java @@ -944,6 +944,192 @@ public final class ContextServiceGrpc { return getGetServiceEventsMethod; } + private static volatile io.grpc.MethodDescriptor<context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceIdList> getListSliceIdsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListSliceIds", + requestType = context.ContextOuterClass.ContextId.class, + responseType = context.ContextOuterClass.SliceIdList.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor<context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceIdList> getListSliceIdsMethod() { + io.grpc.MethodDescriptor<context.ContextOuterClass.ContextId, context.ContextOuterClass.SliceIdList> getListSliceIdsMethod; + if ((getListSliceIdsMethod = ContextServiceGrpc.getListSliceIdsMethod) == null) { + synchronized (ContextServiceGrpc.class) { + if ((getListSliceIdsMethod = ContextServiceGrpc.getListSliceIdsMethod) == null) { + ContextServiceGrpc.getListSliceIdsMethod = getListSliceIdsMethod = + io.grpc.MethodDescriptor.<context.ContextOuterClass.ContextId, context.ContextOuterClass.SliceIdList>newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListSliceIds")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.ContextId.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.SliceIdList.getDefaultInstance())) + .setSchemaDescriptor(new ContextServiceMethodDescriptorSupplier("ListSliceIds")) + .build(); + } + } + } + return getListSliceIdsMethod; + } + + private static volatile io.grpc.MethodDescriptor<context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceList> getListSlicesMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListSlices", + requestType = context.ContextOuterClass.ContextId.class, + responseType = context.ContextOuterClass.SliceList.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor<context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceList> getListSlicesMethod() { + io.grpc.MethodDescriptor<context.ContextOuterClass.ContextId, context.ContextOuterClass.SliceList> getListSlicesMethod; + if ((getListSlicesMethod = ContextServiceGrpc.getListSlicesMethod) == null) { + synchronized (ContextServiceGrpc.class) { + if ((getListSlicesMethod = ContextServiceGrpc.getListSlicesMethod) == null) { + ContextServiceGrpc.getListSlicesMethod = getListSlicesMethod = + io.grpc.MethodDescriptor.<context.ContextOuterClass.ContextId, context.ContextOuterClass.SliceList>newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListSlices")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.ContextId.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.SliceList.getDefaultInstance())) + .setSchemaDescriptor(new ContextServiceMethodDescriptorSupplier("ListSlices")) + .build(); + } + } + } + return getListSlicesMethod; + } + + private static volatile io.grpc.MethodDescriptor<context.ContextOuterClass.SliceId, + context.ContextOuterClass.Slice> getGetSliceMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetSlice", + requestType = context.ContextOuterClass.SliceId.class, + responseType = context.ContextOuterClass.Slice.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor<context.ContextOuterClass.SliceId, + context.ContextOuterClass.Slice> getGetSliceMethod() { + io.grpc.MethodDescriptor<context.ContextOuterClass.SliceId, context.ContextOuterClass.Slice> getGetSliceMethod; + if ((getGetSliceMethod = ContextServiceGrpc.getGetSliceMethod) == null) { + synchronized (ContextServiceGrpc.class) { + if ((getGetSliceMethod = ContextServiceGrpc.getGetSliceMethod) == null) { + ContextServiceGrpc.getGetSliceMethod = getGetSliceMethod = + io.grpc.MethodDescriptor.<context.ContextOuterClass.SliceId, context.ContextOuterClass.Slice>newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetSlice")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.SliceId.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.Slice.getDefaultInstance())) + .setSchemaDescriptor(new ContextServiceMethodDescriptorSupplier("GetSlice")) + .build(); + } + } + } + return getGetSliceMethod; + } + + private static volatile io.grpc.MethodDescriptor<context.ContextOuterClass.Slice, + context.ContextOuterClass.SliceId> getSetSliceMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "SetSlice", + requestType = context.ContextOuterClass.Slice.class, + responseType = context.ContextOuterClass.SliceId.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor<context.ContextOuterClass.Slice, + context.ContextOuterClass.SliceId> getSetSliceMethod() { + io.grpc.MethodDescriptor<context.ContextOuterClass.Slice, context.ContextOuterClass.SliceId> getSetSliceMethod; + if ((getSetSliceMethod = ContextServiceGrpc.getSetSliceMethod) == null) { + synchronized (ContextServiceGrpc.class) { + if ((getSetSliceMethod = ContextServiceGrpc.getSetSliceMethod) == null) { + ContextServiceGrpc.getSetSliceMethod = getSetSliceMethod = + io.grpc.MethodDescriptor.<context.ContextOuterClass.Slice, context.ContextOuterClass.SliceId>newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "SetSlice")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.Slice.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.SliceId.getDefaultInstance())) + .setSchemaDescriptor(new ContextServiceMethodDescriptorSupplier("SetSlice")) + .build(); + } + } + } + return getSetSliceMethod; + } + + private static volatile io.grpc.MethodDescriptor<context.ContextOuterClass.SliceId, + context.ContextOuterClass.Empty> getRemoveSliceMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "RemoveSlice", + requestType = context.ContextOuterClass.SliceId.class, + responseType = context.ContextOuterClass.Empty.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor<context.ContextOuterClass.SliceId, + context.ContextOuterClass.Empty> getRemoveSliceMethod() { + io.grpc.MethodDescriptor<context.ContextOuterClass.SliceId, context.ContextOuterClass.Empty> getRemoveSliceMethod; + if ((getRemoveSliceMethod = ContextServiceGrpc.getRemoveSliceMethod) == null) { + synchronized (ContextServiceGrpc.class) { + if ((getRemoveSliceMethod = ContextServiceGrpc.getRemoveSliceMethod) == null) { + ContextServiceGrpc.getRemoveSliceMethod = getRemoveSliceMethod = + io.grpc.MethodDescriptor.<context.ContextOuterClass.SliceId, context.ContextOuterClass.Empty>newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "RemoveSlice")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.SliceId.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.Empty.getDefaultInstance())) + .setSchemaDescriptor(new ContextServiceMethodDescriptorSupplier("RemoveSlice")) + .build(); + } + } + } + return getRemoveSliceMethod; + } + + private static volatile io.grpc.MethodDescriptor<context.ContextOuterClass.Empty, + context.ContextOuterClass.SliceEvent> getGetSliceEventsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetSliceEvents", + requestType = context.ContextOuterClass.Empty.class, + responseType = context.ContextOuterClass.SliceEvent.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor<context.ContextOuterClass.Empty, + context.ContextOuterClass.SliceEvent> getGetSliceEventsMethod() { + io.grpc.MethodDescriptor<context.ContextOuterClass.Empty, context.ContextOuterClass.SliceEvent> getGetSliceEventsMethod; + if ((getGetSliceEventsMethod = ContextServiceGrpc.getGetSliceEventsMethod) == null) { + synchronized (ContextServiceGrpc.class) { + if ((getGetSliceEventsMethod = ContextServiceGrpc.getGetSliceEventsMethod) == null) { + ContextServiceGrpc.getGetSliceEventsMethod = getGetSliceEventsMethod = + io.grpc.MethodDescriptor.<context.ContextOuterClass.Empty, context.ContextOuterClass.SliceEvent>newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetSliceEvents")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.Empty.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.SliceEvent.getDefaultInstance())) + .setSchemaDescriptor(new ContextServiceMethodDescriptorSupplier("GetSliceEvents")) + .build(); + } + } + } + return getGetSliceEventsMethod; + } + private static volatile io.grpc.MethodDescriptor<context.ContextOuterClass.ServiceId, context.ContextOuterClass.ConnectionIdList> getListConnectionIdsMethod; @@ -1388,6 +1574,48 @@ public final class ContextServiceGrpc { io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetServiceEventsMethod(), responseObserver); } + /** + */ + public void listSliceIds(context.ContextOuterClass.ContextId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceIdList> responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getListSliceIdsMethod(), responseObserver); + } + + /** + */ + public void listSlices(context.ContextOuterClass.ContextId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceList> responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getListSlicesMethod(), responseObserver); + } + + /** + */ + public void getSlice(context.ContextOuterClass.SliceId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.Slice> responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetSliceMethod(), responseObserver); + } + + /** + */ + public void setSlice(context.ContextOuterClass.Slice request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceId> responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getSetSliceMethod(), responseObserver); + } + + /** + */ + public void removeSlice(context.ContextOuterClass.SliceId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.Empty> responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getRemoveSliceMethod(), responseObserver); + } + + /** + */ + public void getSliceEvents(context.ContextOuterClass.Empty request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceEvent> responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetSliceEventsMethod(), responseObserver); + } + /** */ public void listConnectionIds(context.ContextOuterClass.ServiceId request, @@ -1642,6 +1870,48 @@ public final class ContextServiceGrpc { context.ContextOuterClass.Empty, context.ContextOuterClass.ServiceEvent>( this, METHODID_GET_SERVICE_EVENTS))) + .addMethod( + getListSliceIdsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceIdList>( + this, METHODID_LIST_SLICE_IDS))) + .addMethod( + getListSlicesMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceList>( + this, METHODID_LIST_SLICES))) + .addMethod( + getGetSliceMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.SliceId, + context.ContextOuterClass.Slice>( + this, METHODID_GET_SLICE))) + .addMethod( + getSetSliceMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.Slice, + context.ContextOuterClass.SliceId>( + this, METHODID_SET_SLICE))) + .addMethod( + getRemoveSliceMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.SliceId, + context.ContextOuterClass.Empty>( + this, METHODID_REMOVE_SLICE))) + .addMethod( + getGetSliceEventsMethod(), + io.grpc.stub.ServerCalls.asyncServerStreamingCall( + new MethodHandlers< + context.ContextOuterClass.Empty, + context.ContextOuterClass.SliceEvent>( + this, METHODID_GET_SLICE_EVENTS))) .addMethod( getListConnectionIdsMethod(), io.grpc.stub.ServerCalls.asyncUnaryCall( @@ -1942,6 +2212,54 @@ public final class ContextServiceGrpc { getChannel().newCall(getGetServiceEventsMethod(), getCallOptions()), request, responseObserver); } + /** + */ + public void listSliceIds(context.ContextOuterClass.ContextId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceIdList> responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListSliceIdsMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void listSlices(context.ContextOuterClass.ContextId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceList> responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListSlicesMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getSlice(context.ContextOuterClass.SliceId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.Slice> responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetSliceMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void setSlice(context.ContextOuterClass.Slice request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceId> responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getSetSliceMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void removeSlice(context.ContextOuterClass.SliceId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.Empty> responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getRemoveSliceMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getSliceEvents(context.ContextOuterClass.Empty request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceEvent> responseObserver) { + io.grpc.stub.ClientCalls.asyncServerStreamingCall( + getChannel().newCall(getGetSliceEventsMethod(), getCallOptions()), request, responseObserver); + } + /** */ public void listConnectionIds(context.ContextOuterClass.ServiceId request, @@ -2220,6 +2538,49 @@ public final class ContextServiceGrpc { getChannel(), getGetServiceEventsMethod(), getCallOptions(), request); } + /** + */ + public context.ContextOuterClass.SliceIdList listSliceIds(context.ContextOuterClass.ContextId request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListSliceIdsMethod(), getCallOptions(), request); + } + + /** + */ + public context.ContextOuterClass.SliceList listSlices(context.ContextOuterClass.ContextId request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListSlicesMethod(), getCallOptions(), request); + } + + /** + */ + public context.ContextOuterClass.Slice getSlice(context.ContextOuterClass.SliceId request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetSliceMethod(), getCallOptions(), request); + } + + /** + */ + public context.ContextOuterClass.SliceId setSlice(context.ContextOuterClass.Slice request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getSetSliceMethod(), getCallOptions(), request); + } + + /** + */ + public context.ContextOuterClass.Empty removeSlice(context.ContextOuterClass.SliceId request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getRemoveSliceMethod(), getCallOptions(), request); + } + + /** + */ + public java.util.Iterator<context.ContextOuterClass.SliceEvent> getSliceEvents( + context.ContextOuterClass.Empty request) { + return io.grpc.stub.ClientCalls.blockingServerStreamingCall( + getChannel(), getGetSliceEventsMethod(), getCallOptions(), request); + } + /** */ public context.ContextOuterClass.ConnectionIdList listConnectionIds(context.ContextOuterClass.ServiceId request) { @@ -2478,6 +2839,46 @@ public final class ContextServiceGrpc { getChannel().newCall(getRemoveServiceMethod(), getCallOptions()), request); } + /** + */ + public com.google.common.util.concurrent.ListenableFuture<context.ContextOuterClass.SliceIdList> listSliceIds( + context.ContextOuterClass.ContextId request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListSliceIdsMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture<context.ContextOuterClass.SliceList> listSlices( + context.ContextOuterClass.ContextId request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListSlicesMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture<context.ContextOuterClass.Slice> getSlice( + context.ContextOuterClass.SliceId request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetSliceMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture<context.ContextOuterClass.SliceId> setSlice( + context.ContextOuterClass.Slice request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getSetSliceMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture<context.ContextOuterClass.Empty> removeSlice( + context.ContextOuterClass.SliceId request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getRemoveSliceMethod(), getCallOptions()), request); + } + /** */ public com.google.common.util.concurrent.ListenableFuture<context.ContextOuterClass.ConnectionIdList> listConnectionIds( @@ -2549,12 +2950,18 @@ public final class ContextServiceGrpc { private static final int METHODID_SET_SERVICE = 27; private static final int METHODID_REMOVE_SERVICE = 28; private static final int METHODID_GET_SERVICE_EVENTS = 29; - private static final int METHODID_LIST_CONNECTION_IDS = 30; - private static final int METHODID_LIST_CONNECTIONS = 31; - private static final int METHODID_GET_CONNECTION = 32; - private static final int METHODID_SET_CONNECTION = 33; - private static final int METHODID_REMOVE_CONNECTION = 34; - private static final int METHODID_GET_CONNECTION_EVENTS = 35; + private static final int METHODID_LIST_SLICE_IDS = 30; + private static final int METHODID_LIST_SLICES = 31; + private static final int METHODID_GET_SLICE = 32; + private static final int METHODID_SET_SLICE = 33; + private static final int METHODID_REMOVE_SLICE = 34; + private static final int METHODID_GET_SLICE_EVENTS = 35; + private static final int METHODID_LIST_CONNECTION_IDS = 36; + private static final int METHODID_LIST_CONNECTIONS = 37; + private static final int METHODID_GET_CONNECTION = 38; + private static final int METHODID_SET_CONNECTION = 39; + private static final int METHODID_REMOVE_CONNECTION = 40; + private static final int METHODID_GET_CONNECTION_EVENTS = 41; private static final class MethodHandlers<Req, Resp> implements io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>, @@ -2693,6 +3100,30 @@ public final class ContextServiceGrpc { serviceImpl.getServiceEvents((context.ContextOuterClass.Empty) request, (io.grpc.stub.StreamObserver<context.ContextOuterClass.ServiceEvent>) responseObserver); break; + case METHODID_LIST_SLICE_IDS: + serviceImpl.listSliceIds((context.ContextOuterClass.ContextId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceIdList>) responseObserver); + break; + case METHODID_LIST_SLICES: + serviceImpl.listSlices((context.ContextOuterClass.ContextId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceList>) responseObserver); + break; + case METHODID_GET_SLICE: + serviceImpl.getSlice((context.ContextOuterClass.SliceId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.Slice>) responseObserver); + break; + case METHODID_SET_SLICE: + serviceImpl.setSlice((context.ContextOuterClass.Slice) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceId>) responseObserver); + break; + case METHODID_REMOVE_SLICE: + serviceImpl.removeSlice((context.ContextOuterClass.SliceId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.Empty>) responseObserver); + break; + case METHODID_GET_SLICE_EVENTS: + serviceImpl.getSliceEvents((context.ContextOuterClass.Empty) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceEvent>) responseObserver); + break; case METHODID_LIST_CONNECTION_IDS: serviceImpl.listConnectionIds((context.ContextOuterClass.ServiceId) request, (io.grpc.stub.StreamObserver<context.ContextOuterClass.ConnectionIdList>) responseObserver); @@ -2808,6 +3239,12 @@ public final class ContextServiceGrpc { .addMethod(getSetServiceMethod()) .addMethod(getRemoveServiceMethod()) .addMethod(getGetServiceEventsMethod()) + .addMethod(getListSliceIdsMethod()) + .addMethod(getListSlicesMethod()) + .addMethod(getGetSliceMethod()) + .addMethod(getSetSliceMethod()) + .addMethod(getRemoveSliceMethod()) + .addMethod(getGetSliceEventsMethod()) .addMethod(getListConnectionIdsMethod()) .addMethod(getListConnectionsMethod()) .addMethod(getGetConnectionMethod()) diff --git a/src/automation/target/generated-sources/grpc/context/MutinyContextServiceGrpc.java b/src/automation/target/generated-sources/grpc/context/MutinyContextServiceGrpc.java index 85abba20a9f315f684f964d16db4ad0cd7e91299..9f71b53786e40922546dc59cfd4328040a40bd7c 100644 --- a/src/automation/target/generated-sources/grpc/context/MutinyContextServiceGrpc.java +++ b/src/automation/target/generated-sources/grpc/context/MutinyContextServiceGrpc.java @@ -161,6 +161,31 @@ public final class MutinyContextServiceGrpc implements io.quarkus.grpc.runtime.M } + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceIdList> listSliceIds(context.ContextOuterClass.ContextId request) { + return io.quarkus.grpc.runtime.ClientCalls.oneToOne(request, delegateStub::listSliceIds); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceList> listSlices(context.ContextOuterClass.ContextId request) { + return io.quarkus.grpc.runtime.ClientCalls.oneToOne(request, delegateStub::listSlices); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Slice> getSlice(context.ContextOuterClass.SliceId request) { + return io.quarkus.grpc.runtime.ClientCalls.oneToOne(request, delegateStub::getSlice); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceId> setSlice(context.ContextOuterClass.Slice request) { + return io.quarkus.grpc.runtime.ClientCalls.oneToOne(request, delegateStub::setSlice); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Empty> removeSlice(context.ContextOuterClass.SliceId request) { + return io.quarkus.grpc.runtime.ClientCalls.oneToOne(request, delegateStub::removeSlice); + } + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.ConnectionIdList> listConnectionIds(context.ContextOuterClass.ServiceId request) { return io.quarkus.grpc.runtime.ClientCalls.oneToOne(request, delegateStub::listConnectionIds); } @@ -211,6 +236,11 @@ public final class MutinyContextServiceGrpc implements io.quarkus.grpc.runtime.M } + public io.smallrye.mutiny.Multi<context.ContextOuterClass.SliceEvent> getSliceEvents(context.ContextOuterClass.Empty request) { + return io.quarkus.grpc.runtime.ClientCalls.oneToMany(request, delegateStub::getSliceEvents); + } + + public io.smallrye.mutiny.Multi<context.ContextOuterClass.ConnectionEvent> getConnectionEvents(context.ContextOuterClass.Empty request) { return io.quarkus.grpc.runtime.ClientCalls.oneToMany(request, delegateStub::getConnectionEvents); } @@ -358,6 +388,31 @@ public final class MutinyContextServiceGrpc implements io.quarkus.grpc.runtime.M } + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceIdList> listSliceIds(context.ContextOuterClass.ContextId request) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceList> listSlices(context.ContextOuterClass.ContextId request) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Slice> getSlice(context.ContextOuterClass.SliceId request) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceId> setSlice(context.ContextOuterClass.Slice request) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Empty> removeSlice(context.ContextOuterClass.SliceId request) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.ConnectionIdList> listConnectionIds(context.ContextOuterClass.ServiceId request) { throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); } @@ -408,6 +463,11 @@ public final class MutinyContextServiceGrpc implements io.quarkus.grpc.runtime.M } + public io.smallrye.mutiny.Multi<context.ContextOuterClass.SliceEvent> getSliceEvents(context.ContextOuterClass.Empty request) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + + public io.smallrye.mutiny.Multi<context.ContextOuterClass.ConnectionEvent> getConnectionEvents(context.ContextOuterClass.Empty request) { throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); } @@ -624,6 +684,48 @@ public final class MutinyContextServiceGrpc implements io.quarkus.grpc.runtime.M context.ContextOuterClass.Empty, context.ContextOuterClass.ServiceEvent>( this, METHODID_GET_SERVICE_EVENTS, compression))) + .addMethod( + context.ContextServiceGrpc.getListSliceIdsMethod(), + asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceIdList>( + this, METHODID_LIST_SLICE_IDS, compression))) + .addMethod( + context.ContextServiceGrpc.getListSlicesMethod(), + asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceList>( + this, METHODID_LIST_SLICES, compression))) + .addMethod( + context.ContextServiceGrpc.getGetSliceMethod(), + asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.SliceId, + context.ContextOuterClass.Slice>( + this, METHODID_GET_SLICE, compression))) + .addMethod( + context.ContextServiceGrpc.getSetSliceMethod(), + asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.Slice, + context.ContextOuterClass.SliceId>( + this, METHODID_SET_SLICE, compression))) + .addMethod( + context.ContextServiceGrpc.getRemoveSliceMethod(), + asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.SliceId, + context.ContextOuterClass.Empty>( + this, METHODID_REMOVE_SLICE, compression))) + .addMethod( + context.ContextServiceGrpc.getGetSliceEventsMethod(), + asyncServerStreamingCall( + new MethodHandlers< + context.ContextOuterClass.Empty, + context.ContextOuterClass.SliceEvent>( + this, METHODID_GET_SLICE_EVENTS, compression))) .addMethod( context.ContextServiceGrpc.getListConnectionIdsMethod(), asyncUnaryCall( @@ -700,12 +802,18 @@ public final class MutinyContextServiceGrpc implements io.quarkus.grpc.runtime.M private static final int METHODID_SET_SERVICE = 27; private static final int METHODID_REMOVE_SERVICE = 28; private static final int METHODID_GET_SERVICE_EVENTS = 29; - private static final int METHODID_LIST_CONNECTION_IDS = 30; - private static final int METHODID_LIST_CONNECTIONS = 31; - private static final int METHODID_GET_CONNECTION = 32; - private static final int METHODID_SET_CONNECTION = 33; - private static final int METHODID_REMOVE_CONNECTION = 34; - private static final int METHODID_GET_CONNECTION_EVENTS = 35; + private static final int METHODID_LIST_SLICE_IDS = 30; + private static final int METHODID_LIST_SLICES = 31; + private static final int METHODID_GET_SLICE = 32; + private static final int METHODID_SET_SLICE = 33; + private static final int METHODID_REMOVE_SLICE = 34; + private static final int METHODID_GET_SLICE_EVENTS = 35; + private static final int METHODID_LIST_CONNECTION_IDS = 36; + private static final int METHODID_LIST_CONNECTIONS = 37; + private static final int METHODID_GET_CONNECTION = 38; + private static final int METHODID_SET_CONNECTION = 39; + private static final int METHODID_REMOVE_CONNECTION = 40; + private static final int METHODID_GET_CONNECTION_EVENTS = 41; private static final class MethodHandlers<Req, Resp> implements io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>, @@ -906,6 +1014,42 @@ public final class MutinyContextServiceGrpc implements io.quarkus.grpc.runtime.M compression, serviceImpl::getServiceEvents); break; + case METHODID_LIST_SLICE_IDS: + io.quarkus.grpc.runtime.ServerCalls.oneToOne((context.ContextOuterClass.ContextId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceIdList>) responseObserver, + compression, + serviceImpl::listSliceIds); + break; + case METHODID_LIST_SLICES: + io.quarkus.grpc.runtime.ServerCalls.oneToOne((context.ContextOuterClass.ContextId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceList>) responseObserver, + compression, + serviceImpl::listSlices); + break; + case METHODID_GET_SLICE: + io.quarkus.grpc.runtime.ServerCalls.oneToOne((context.ContextOuterClass.SliceId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.Slice>) responseObserver, + compression, + serviceImpl::getSlice); + break; + case METHODID_SET_SLICE: + io.quarkus.grpc.runtime.ServerCalls.oneToOne((context.ContextOuterClass.Slice) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceId>) responseObserver, + compression, + serviceImpl::setSlice); + break; + case METHODID_REMOVE_SLICE: + io.quarkus.grpc.runtime.ServerCalls.oneToOne((context.ContextOuterClass.SliceId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.Empty>) responseObserver, + compression, + serviceImpl::removeSlice); + break; + case METHODID_GET_SLICE_EVENTS: + io.quarkus.grpc.runtime.ServerCalls.oneToMany((context.ContextOuterClass.Empty) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceEvent>) responseObserver, + compression, + serviceImpl::getSliceEvents); + break; case METHODID_LIST_CONNECTION_IDS: io.quarkus.grpc.runtime.ServerCalls.oneToOne((context.ContextOuterClass.ServiceId) request, (io.grpc.stub.StreamObserver<context.ContextOuterClass.ConnectionIdList>) responseObserver, diff --git a/src/automation/target/kubernetes/kubernetes.yml b/src/automation/target/kubernetes/kubernetes.yml index d8d4dc5449107b29174cfd8fecf660a28b5d558e..0e4bc0c62fdeb19644d596189a295bba3e53dd97 100644 --- a/src/automation/target/kubernetes/kubernetes.yml +++ b/src/automation/target/kubernetes/kubernetes.yml @@ -1,36 +1,22 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - --- apiVersion: v1 kind: Service metadata: annotations: - app.quarkus.io/commit-id: 644f8ea4385acb720eab7317de057f9d1d8ebfe6 - app.quarkus.io/build-timestamp: 2022-02-14 - 10:21:58 +0000 + app.quarkus.io/commit-id: fee580ca578000e6006c77704c0d6240e261de0f + app.quarkus.io/build-timestamp: 2022-05-27 - 08:02:36 +0000 labels: app.kubernetes.io/name: automationservice app: automationservice name: automationservice spec: ports: - - name: http - port: 8080 - targetPort: 8080 - name: grpc-server port: 9999 targetPort: 9999 + - name: http + port: 8080 + targetPort: 8080 selector: app.kubernetes.io/name: automationservice type: ClusterIP @@ -39,8 +25,8 @@ apiVersion: apps/v1 kind: Deployment metadata: annotations: - app.quarkus.io/commit-id: 644f8ea4385acb720eab7317de057f9d1d8ebfe6 - app.quarkus.io/build-timestamp: 2022-02-14 - 10:21:58 +0000 + app.quarkus.io/commit-id: fee580ca578000e6006c77704c0d6240e261de0f + app.quarkus.io/build-timestamp: 2022-05-27 - 08:02:36 +0000 labels: app: automationservice app.kubernetes.io/name: automationservice @@ -53,8 +39,8 @@ spec: template: metadata: annotations: - app.quarkus.io/commit-id: 644f8ea4385acb720eab7317de057f9d1d8ebfe6 - app.quarkus.io/build-timestamp: 2022-02-14 - 10:21:58 +0000 + app.quarkus.io/commit-id: fee580ca578000e6006c77704c0d6240e261de0f + app.quarkus.io/build-timestamp: 2022-05-27 - 08:02:36 +0000 labels: app: automationservice app.kubernetes.io/name: automationservice @@ -65,10 +51,10 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - - name: DEVICE_SERVICE_HOST - value: deviceservice - name: CONTEXT_SERVICE_HOST - value: contextservice + value: ContextService + - name: DEVICE_SERVICE_HOST + value: DeviceService image: registry.gitlab.com/teraflow-h2020/controller/automation:0.2.0 imagePullPolicy: Always livenessProbe: @@ -83,12 +69,12 @@ spec: timeoutSeconds: 10 name: automationservice ports: - - containerPort: 8080 - name: http - protocol: TCP - containerPort: 9999 name: grpc-server protocol: TCP + - containerPort: 8080 + name: http + protocol: TCP readinessProbe: failureThreshold: 3 httpGet: diff --git a/src/common/Constants.py b/src/common/Constants.py index 9d5edc235f582f7df4a274b15bf646413d14b1bd..dbe4124e792db73e122a7b436ca19be814aed761 100644 --- a/src/common/Constants.py +++ b/src/common/Constants.py @@ -12,5 +12,64 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging +from enum import Enum + +# Default logging level +DEFAULT_LOG_LEVEL = logging.WARNING + +# Default gRPC server settings +DEFAULT_GRPC_BIND_ADDRESS = '0.0.0.0' +DEFAULT_GRPC_MAX_WORKERS = 10 +DEFAULT_GRPC_GRACE_PERIOD = 60 + +# Default HTTP server settings +DEFAULT_HTTP_BIND_ADDRESS = '0.0.0.0' + +# Default Prometheus settings +DEFAULT_METRICS_PORT = 9192 + +# Default context and topology UUIDs DEFAULT_CONTEXT_UUID = 'admin' DEFAULT_TOPOLOGY_UUID = 'admin' + +# Default service names +class ServiceNameEnum(Enum): + CONTEXT = 'context' + DEVICE = 'device' + SERVICE = 'service' + SLICE = 'slice' + AUTOMATION = 'automation' + POLICY = 'policy' + MONITORING = 'monitoring' + DLT = 'dlt' + COMPUTE = 'compute' + CYBERSECURITY = 'cybersecurity' + INTERDOMAIN = 'interdomain' + +# Default gRPC service ports +DEFAULT_SERVICE_GRPC_PORTS = { + ServiceNameEnum.CONTEXT .value : 1010, + ServiceNameEnum.DEVICE .value : 2020, + ServiceNameEnum.SERVICE .value : 3030, + ServiceNameEnum.SLICE .value : 4040, + ServiceNameEnum.AUTOMATION .value : 5050, + ServiceNameEnum.POLICY .value : 6060, + ServiceNameEnum.MONITORING .value : 7070, + ServiceNameEnum.DLT .value : 8080, + ServiceNameEnum.COMPUTE .value : 9090, + ServiceNameEnum.CYBERSECURITY.value : 10000, + ServiceNameEnum.INTERDOMAIN .value : 10010, +} + +# Default HTTP/REST-API service ports +DEFAULT_SERVICE_HTTP_PORTS = { + ServiceNameEnum.CONTEXT .value : 8080, + ServiceNameEnum.COMPUTE .value : 8080, +} + +# Default HTTP/REST-API service base URLs +DEFAULT_SERVICE_HTTP_BASEURLS = { + ServiceNameEnum.CONTEXT .value : '/api', + ServiceNameEnum.COMPUTE .value : '/restconf/data', +} diff --git a/src/common/DeviceTypes.py b/src/common/DeviceTypes.py index 432f8d19c0cf698ff2fcae54bc35dbe2491ceb28..8554ea3cf97f33cc71f60e37310798cc335234a0 100644 --- a/src/common/DeviceTypes.py +++ b/src/common/DeviceTypes.py @@ -19,6 +19,7 @@ class DeviceTypeEnum(Enum): EMULATED_OPTICAL_LINE_SYSTEM = 'emu-optical-line-system' EMULATED_PACKET_ROUTER = 'emu-packet-router' DATACENTER = 'datacenter' + MICROVAWE_RADIO_SYSTEM = 'microwave-radio-system' OPTICAL_ROADM = 'optical-roadm' OPTICAL_TRANDPONDER = 'optical-trandponder' OPTICAL_LINE_SYSTEM = 'optical-line-system' diff --git a/src/common/Settings.py b/src/common/Settings.py index f6bc214bf7500227c621b197e2626e09f2dafb93..e9d5f406d2acad0d31ae94b604183c129d28f146 100644 --- a/src/common/Settings.py +++ b/src/common/Settings.py @@ -14,15 +14,33 @@ import logging, os, time from typing import List +from common.Constants import ( + DEFAULT_GRPC_BIND_ADDRESS, DEFAULT_GRPC_GRACE_PERIOD, DEFAULT_GRPC_MAX_WORKERS, DEFAULT_HTTP_BIND_ADDRESS, + DEFAULT_LOG_LEVEL, DEFAULT_METRICS_PORT, DEFAULT_SERVICE_GRPC_PORTS, DEFAULT_SERVICE_HTTP_BASEURLS, + DEFAULT_SERVICE_HTTP_PORTS, ServiceNameEnum +) LOGGER = logging.getLogger(__name__) DEFAULT_RESTART_DELAY = 5.0 # seconds +ENVVAR_KUBERNETES_PORT = 'KUBERNETES_PORT' +ENVVAR_GRPC_BIND_ADDRESS = 'GRPC_BIND_ADDRESS' +ENVVAR_GRPC_MAX_WORKERS = 'GRPC_MAX_WORKERS' +ENVVAR_GRPC_GRACE_PERIOD = 'GRPC_GRACE_PERIOD' +ENVVAR_HTTP_BIND_ADDRESS = 'HTTP_BIND_ADDRESS' +ENVVAR_LOG_LEVEL = 'LOG_LEVEL' +ENVVAR_METRICS_PORT = 'METRICS_PORT' + +ENVVAR_SUFIX_SERVICE_BASEURL_HTTP = 'SERVICE_BASEURL_HTTP' +ENVVAR_SUFIX_SERVICE_HOST = 'SERVICE_HOST' +ENVVAR_SUFIX_SERVICE_PORT_GRPC = 'SERVICE_PORT_GRPC' +ENVVAR_SUFIX_SERVICE_PORT_HTTP = 'SERVICE_PORT_HTTP' + def wait_for_environment_variables( required_environment_variables : List[str] = [], wait_delay_seconds : float = DEFAULT_RESTART_DELAY ): - if 'KUBERNETES_PORT' not in os.environ: return # We're not running in Kubernetes, nothing to wait for + if ENVVAR_KUBERNETES_PORT not in os.environ: return # We're not running in Kubernetes, nothing to wait for missing_variables = set(required_environment_variables).difference(set(os.environ.keys())) if len(missing_variables) == 0: return # We have all environment variables defined msg = 'Variables({:s}) are missing in Environment({:s}), restarting in {:f} seconds...' @@ -36,4 +54,45 @@ def get_setting(name, **kwargs): value = kwargs['settings'].pop(name, value) if value is not None: return value if 'default' in kwargs: return kwargs['default'] - raise Exception('Setting({}) not specified in environment or configuration'.format(name)) + raise Exception('Setting({:s}) not specified in environment or configuration'.format(str(name))) + +def get_env_var_name(service_name : ServiceNameEnum, env_var_group): + return ('{:s}SERVICE_{:s}'.format(service_name.value, env_var_group)).upper() + +def get_service_host(service_name : ServiceNameEnum): + envvar_name = get_env_var_name(service_name, ENVVAR_SUFIX_SERVICE_HOST) + default_value = ('{:s}service'.format(service_name.value)) + return get_setting(envvar_name, default=default_value) + +def get_service_port_grpc(service_name : ServiceNameEnum): + envvar_name = get_env_var_name(service_name, ENVVAR_SUFIX_SERVICE_PORT_GRPC) + default_value = DEFAULT_SERVICE_GRPC_PORTS.get(service_name.value) + return get_setting(envvar_name, default=default_value) + +def get_service_port_http(service_name : ServiceNameEnum): + envvar_name = get_env_var_name(service_name, ENVVAR_SUFIX_SERVICE_PORT_HTTP) + default_value = DEFAULT_SERVICE_HTTP_PORTS.get(service_name.value) + return get_setting(envvar_name, default=default_value) + +def get_service_baseurl_http(service_name : ServiceNameEnum): + envvar_name = get_env_var_name(service_name, ENVVAR_SUFIX_SERVICE_BASEURL_HTTP) + default_value = DEFAULT_SERVICE_HTTP_BASEURLS.get(service_name.value) + return get_setting(envvar_name, default=default_value) + +def get_log_level(): + return get_setting(ENVVAR_LOG_LEVEL, default=DEFAULT_LOG_LEVEL) + +def get_metrics_port(): + return get_setting(ENVVAR_METRICS_PORT, default=DEFAULT_METRICS_PORT) + +def get_grpc_bind_address(): + return get_setting(ENVVAR_GRPC_BIND_ADDRESS, default=DEFAULT_GRPC_BIND_ADDRESS) + +def get_grpc_max_workers(): + return get_setting(ENVVAR_GRPC_MAX_WORKERS, default=DEFAULT_GRPC_MAX_WORKERS) + +def get_grpc_grace_period(): + return get_setting(ENVVAR_GRPC_GRACE_PERIOD, default=DEFAULT_GRPC_GRACE_PERIOD) + +def get_http_bind_address(): + return get_setting(ENVVAR_HTTP_BIND_ADDRESS, default=DEFAULT_HTTP_BIND_ADDRESS) diff --git a/src/common/tests/MockService.py b/src/common/tests/MockService.py deleted file mode 100644 index 25f36e009be3a65c1ba9c18c7707742a75253a75..0000000000000000000000000000000000000000 --- a/src/common/tests/MockService.py +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import grpc, logging -from concurrent import futures - -GRPC_MAX_WORKERS = 10 -GRPC_GRACE_PERIOD = 60 - -class MockService: - def __init__(self, address, port, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD, cls_name=__name__): - self.logger = logging.getLogger(cls_name) - self.address = address - self.port = port - self.endpoint = None - self.max_workers = max_workers - self.grace_period = grace_period - self.pool = None - self.server = None - - def install_servicers(self): - pass - - def start(self): - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) - self.logger.info('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( - str(self.endpoint), str(self.max_workers))) - - self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) - self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) - - self.install_servicers() - - port = self.server.add_insecure_port(self.endpoint) - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(port)) - self.logger.info('Listening on {:s}...'.format(str(self.endpoint))) - self.server.start() - - self.logger.debug('Service started') - - def stop(self): - self.logger.debug('Stopping service (grace period {:s} seconds)...'.format(str(self.grace_period))) - self.server.stop(self.grace_period) - self.logger.debug('Service stopped') diff --git a/src/device/tests/MockMonitoringServiceServicerImpl.py b/src/common/tests/MockServicerImpl_Monitoring.py similarity index 70% rename from src/device/tests/MockMonitoringServiceServicerImpl.py rename to src/common/tests/MockServicerImpl_Monitoring.py index 05ca43dda0418df151bc3dfe255a90d75b50a088..9f646c3667485ae3240c59284a73fef01bffb7bb 100644 --- a/src/device/tests/MockMonitoringServiceServicerImpl.py +++ b/src/common/tests/MockServicerImpl_Monitoring.py @@ -12,18 +12,23 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging + +import grpc, logging from queue import Queue +from common.tools.grpc.Tools import grpc_message_to_json_string from monitoring.proto.context_pb2 import Empty from monitoring.proto.monitoring_pb2 import Kpi from monitoring.proto.monitoring_pb2_grpc import MonitoringServiceServicer LOGGER = logging.getLogger(__name__) -class MockMonitoringServiceServicerImpl(MonitoringServiceServicer): +class MockServicerImpl_Monitoring(MonitoringServiceServicer): def __init__(self, queue_samples : Queue): + LOGGER.info('[__init__] Creating Servicer...') self.queue_samples = queue_samples + LOGGER.info('[__init__] Servicer Created') - def IncludeKpi(self, request : Kpi, context) -> Empty: + def IncludeKpi(self, request : Kpi, context : grpc.ServicerContext) -> Empty: + LOGGER.info('[IncludeKpi] request={:s}'.format(grpc_message_to_json_string(request))) self.queue_samples.put(request) return Empty() diff --git a/src/common/tools/object_factory/Device.py b/src/common/tools/object_factory/Device.py index 3a016f51b2d79a9269371b77d88dce6b3ea65ff5..08fe7d169d757c20f4ec74bca8f4e999bf027560 100644 --- a/src/common/tools/object_factory/Device.py +++ b/src/common/tools/object_factory/Device.py @@ -21,8 +21,8 @@ from context.proto.context_pb2 import DeviceDriverEnum, DeviceOperationalStatusE DEVICE_DISABLED = DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_DISABLED DEVICE_EMUDC_TYPE = DeviceTypeEnum.EMULATED_DATACENTER.value +DEVICE_EMUOLS_TYPE = DeviceTypeEnum.EMULATED_OPTICAL_LINE_SYSTEM.value DEVICE_EMUPR_TYPE = DeviceTypeEnum.EMULATED_PACKET_ROUTER.value -DEVICE_EMUOLS_TYPE = DeviceTypeEnum.EMULATED_OPTICAL_LINE_SYSTEM.value DEVICE_EMU_DRIVERS = [DeviceDriverEnum.DEVICEDRIVER_UNDEFINED] DEVICE_EMU_ADDRESS = '127.0.0.1' DEVICE_EMU_PORT = '0' @@ -33,6 +33,10 @@ DEVICE_PR_DRIVERS = [DeviceDriverEnum.DEVICEDRIVER_OPENCONFIG] DEVICE_TAPI_TYPE = DeviceTypeEnum.OPTICAL_LINE_SYSTEM.value DEVICE_TAPI_DRIVERS = [DeviceDriverEnum.DEVICEDRIVER_TRANSPORT_API] +# check which enum type and value assign to microwave device +DEVICE_MICROWAVE_TYPE = DeviceTypeEnum.MICROVAWE_RADIO_SYSTEM.value +DEVICE_MICROWAVE_DRIVERS = [DeviceDriverEnum.DEVICEDRIVER_IETF_NETWORK_TOPOLOGY] + DEVICE_P4_TYPE = DeviceTypeEnum.P4_SWITCH.value DEVICE_P4_DRIVERS = [DeviceDriverEnum.DEVICEDRIVER_P4] @@ -90,6 +94,14 @@ def json_device_tapi_disabled( return json_device( device_uuid, DEVICE_TAPI_TYPE, DEVICE_DISABLED, endpoints=endpoints, config_rules=config_rules, drivers=drivers) +def json_device_microwave_disabled( + device_uuid : str, endpoints : List[Dict] = [], config_rules : List[Dict] = [], + drivers : List[Dict] = DEVICE_MICROWAVE_DRIVERS + ): + return json_device( + device_uuid, DEVICE_MICROWAVE_TYPE, DEVICE_DISABLED, endpoints=endpoints, config_rules=config_rules, + drivers=drivers) + def json_device_p4_disabled( device_uuid : str, endpoints : List[Dict] = [], config_rules : List[Dict] = [], drivers : List[Dict] = DEVICE_P4_DRIVERS diff --git a/src/common/tools/object_factory/EndPoint.py b/src/common/tools/object_factory/EndPoint.py index d750604365fc616536374dd3541a17613da4746f..9eca5e96371713d1e095eba4666ee806ad6cf71e 100644 --- a/src/common/tools/object_factory/EndPoint.py +++ b/src/common/tools/object_factory/EndPoint.py @@ -13,13 +13,21 @@ # limitations under the License. import copy -from typing import Dict, List, Optional +from typing import Dict, List, Optional, Tuple def json_endpoint_id(device_id : Dict, endpoint_uuid : str, topology_id : Optional[Dict] = None): result = {'device_id': copy.deepcopy(device_id), 'endpoint_uuid': {'uuid': endpoint_uuid}} if topology_id is not None: result['topology_id'] = copy.deepcopy(topology_id) return result +def json_endpoint_ids( + device_id : Dict, endpoint_descriptors : List[Tuple[str, str, List[int]]], topology_id : Optional[Dict] = None + ): + return [ + json_endpoint_id(device_id, endpoint_uuid, topology_id=topology_id) + for endpoint_uuid, _, _ in endpoint_descriptors + ] + def json_endpoint( device_id : Dict, endpoint_uuid : str, endpoint_type : str, topology_id : Optional[Dict] = None, kpi_sample_types : List[int] = [] @@ -31,3 +39,13 @@ def json_endpoint( } if len(kpi_sample_types) > 0: result['kpi_sample_types'] = copy.deepcopy(kpi_sample_types) return result + +def json_endpoints( + device_id : Dict, endpoint_descriptors : List[Tuple[str, str, List[int]]], topology_id : Optional[Dict] = None + ): + return [ + json_endpoint( + device_id, endpoint_uuid, endpoint_type, topology_id=topology_id, + kpi_sample_types=endpoint_sample_types) + for endpoint_uuid, endpoint_type, endpoint_sample_types in endpoint_descriptors + ] diff --git a/src/common/tools/object_factory/Link.py b/src/common/tools/object_factory/Link.py index fac27945912be6ee24b3808f567ea160e017fb37..624cbb8dcc868ce3575062e31ae3b0609c300637 100644 --- a/src/common/tools/object_factory/Link.py +++ b/src/common/tools/object_factory/Link.py @@ -15,6 +15,11 @@ import copy from typing import Dict, List +def get_link_uuid(a_device_id : Dict, a_endpoint_id : Dict, z_device_id : Dict, z_endpoint_id : Dict) -> str: + return '{:s}/{:s}=={:s}/{:s}'.format( + a_device_id['device_uuid']['uuid'], a_endpoint_id['endpoint_uuid']['uuid'], + z_device_id['device_uuid']['uuid'], z_endpoint_id['endpoint_uuid']['uuid']) + def json_link_id(link_uuid : str): return {'link_uuid': {'uuid': link_uuid}} diff --git a/src/common/tools/service/GenericGrpcService.py b/src/common/tools/service/GenericGrpcService.py new file mode 100644 index 0000000000000000000000000000000000000000..61fccdb02b5a6cbd23600093bcba4c69bf142d83 --- /dev/null +++ b/src/common/tools/service/GenericGrpcService.py @@ -0,0 +1,71 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Optional, Union +import grpc, logging +from concurrent import futures +from grpc_health.v1.health import HealthServicer, OVERALL_HEALTH +from grpc_health.v1.health_pb2 import HealthCheckResponse +from grpc_health.v1.health_pb2_grpc import add_HealthServicer_to_server +from common.Settings import get_grpc_bind_address, get_grpc_grace_period, get_grpc_max_workers + +class GenericGrpcService: + def __init__( + self, bind_port : Union[str, int], bind_address : Optional[str] = None, max_workers : Optional[int] = None, + grace_period : Optional[int] = None, enable_health_servicer : bool = True, cls_name : str = __name__ + ) -> None: + self.logger = logging.getLogger(cls_name) + self.bind_port = bind_port + self.bind_address = get_grpc_bind_address() if bind_address is None else bind_address + self.max_workers = get_grpc_max_workers() if max_workers is None else max_workers + self.grace_period = get_grpc_grace_period() if grace_period is None else grace_period + self.enable_health_servicer = enable_health_servicer + self.endpoint = None + self.health_servicer = None + self.pool = None + self.server = None + + def install_servicers(self): + pass + + def start(self): + self.endpoint = '{:s}:{:s}'.format(str(self.bind_address), str(self.bind_port)) + self.logger.info('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( + str(self.endpoint), str(self.max_workers))) + + self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) + self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) + + self.install_servicers() + + if self.enable_health_servicer: + self.health_servicer = HealthServicer( + experimental_non_blocking=True, experimental_thread_pool=futures.ThreadPoolExecutor(max_workers=1)) + add_HealthServicer_to_server(self.health_servicer, self.server) + + self.bind_port = self.server.add_insecure_port(self.endpoint) + self.endpoint = '{:s}:{:s}'.format(str(self.bind_address), str(self.bind_port)) + self.logger.info('Listening on {:s}...'.format(str(self.endpoint))) + self.server.start() + if self.enable_health_servicer: + self.health_servicer.set(OVERALL_HEALTH, HealthCheckResponse.SERVING) # pylint: disable=maybe-no-member + + self.logger.debug('Service started') + + def stop(self): + self.logger.debug('Stopping service (grace period {:s} seconds)...'.format(str(self.grace_period))) + if self.enable_health_servicer: + self.health_servicer.enter_graceful_shutdown() + self.server.stop(self.grace_period) + self.logger.debug('Service stopped') diff --git a/src/common/tools/service/GenericRestServer.py b/src/common/tools/service/GenericRestServer.py new file mode 100644 index 0000000000000000000000000000000000000000..4325fe1dbc0169665a1281b27e6993670add337c --- /dev/null +++ b/src/common/tools/service/GenericRestServer.py @@ -0,0 +1,59 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import functools, logging, threading, time +from typing import Optional, Union +from flask import Flask, request +from flask_restful import Api, Resource +from werkzeug.serving import make_server +from common.Settings import get_http_bind_address + +logging.getLogger('werkzeug').setLevel(logging.WARNING) + + +def log_request(logger, response): + timestamp = time.strftime('[%Y-%b-%d %H:%M]') + logger.info('%s %s %s %s %s', timestamp, request.remote_addr, request.method, request.full_path, response.status) + return response + +class GenericRestServer(threading.Thread): + def __init__( + self, bind_port : Union[str, int], base_url : str, bind_address : Optional[str] = None, + cls_name : str = __name__ + ) -> None: + threading.Thread.__init__(self, daemon=True) + self.logger = logging.getLogger(cls_name) + self.bind_port = bind_port + self.base_url = base_url + self.bind_address = get_http_bind_address() if bind_address is None else bind_address + self.endpoint = 'http://{:s}:{:s}{:s}'.format(str(self.bind_address), str(self.bind_port), str(self.base_url)) + self.srv = None + self.ctx = None + self.app = Flask(__name__) + self.app.after_request(functools.partial(log_request, self.logger)) + self.api = Api(self.app, prefix=self.base_url) + + def add_resource(self, resource : Resource, *urls, **kwargs): + self.api.add_resource(resource, *urls, **kwargs) + + def run(self): + self.srv = make_server(self.bind_address, self.bind_port, self.app, threaded=True) + self.ctx = self.app.app_context() + self.ctx.push() + + self.logger.info('Listening on {:s}...'.format(str(self.endpoint))) + self.srv.serve_forever() + + def shutdown(self): + self.srv.shutdown() diff --git a/src/common/tools/service/__init__.py b/src/common/tools/service/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..70a33251242c51f49140e596b8208a19dd5245f7 --- /dev/null +++ b/src/common/tools/service/__init__.py @@ -0,0 +1,14 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/src/compute/.gitlab-ci.yml b/src/compute/.gitlab-ci.yml index 7daa1764a9c10a79df3cc1b2aadb270b982c1224..f3d7c0f306b9d62a89382578bfb6c4c740b389e6 100644 --- a/src/compute/.gitlab-ci.yml +++ b/src/compute/.gitlab-ci.yml @@ -56,7 +56,6 @@ unit test compute: - docker ps -a - docker logs $IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - - docker exec -i $IMAGE_NAME bash -c "coverage xml -o /opt/results/${IMAGE_NAME}_coverage.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: @@ -64,7 +63,7 @@ unit test compute: - docker network rm teraflowbridge rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' - - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' + - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' - changes: - src/$IMAGE_NAME/**/*.{py,in,yml} - src/$IMAGE_NAME/Dockerfile @@ -76,7 +75,6 @@ unit test compute: when: always reports: junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml - cobertura: src/$IMAGE_NAME/tests/${IMAGE_NAME}_coverage.xml # Deployment of the service in Kubernetes Cluster deploy compute: diff --git a/src/compute/Config.py b/src/compute/Config.py index c568be4476326be0080aad9f88be0183d82ef833..341ae77f506ce1d2488c3d494262ee26ca6dd7eb 100644 --- a/src/compute/Config.py +++ b/src/compute/Config.py @@ -12,23 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging from werkzeug.security import generate_password_hash -# General settings -LOG_LEVEL = logging.WARNING - -# gRPC settings -GRPC_SERVICE_PORT = 9090 -GRPC_MAX_WORKERS = 10 -GRPC_GRACE_PERIOD = 60 - -# REST-API settings -RESTAPI_SERVICE_PORT = 8080 -RESTAPI_BASE_URL = '/restconf/data' +# REST-API users RESTAPI_USERS = { # TODO: implement a database of credentials and permissions 'admin': generate_password_hash('admin'), } - -# Prometheus settings -METRICS_PORT = 9192 diff --git a/src/compute/client/ComputeClient.py b/src/compute/client/ComputeClient.py index ac85500294f0288e7d0e86f77cd7c415f28ef5e5..5c2cfa8b68406e463467ab3a565b6aae6de56e99 100644 --- a/src/compute/client/ComputeClient.py +++ b/src/compute/client/ComputeClient.py @@ -13,7 +13,10 @@ # limitations under the License. import grpc, logging +from common.Constants import ServiceNameEnum +from common.Settings import get_service_host, get_service_port_grpc from common.tools.client.RetryDecorator import retry, delay_exponential +from common.tools.grpc.Tools import grpc_message_to_json_string from compute.proto.compute_pb2_grpc import ComputeServiceStub from compute.proto.context_pb2 import ( AuthenticationResult, Empty, Service, ServiceId, ServiceIdList, ServiceStatus, TeraFlowController) @@ -24,8 +27,10 @@ DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) RETRY_DECORATOR = retry(max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') class ComputeClient: - def __init__(self, address, port): - self.endpoint = '{:s}:{:s}'.format(str(address), str(port)) + def __init__(self, host=None, port=None): + if not host: host = get_service_host(ServiceNameEnum.COMPUTE) + if not port: port = get_service_port_grpc(ServiceNameEnum.COMPUTE) + self.endpoint = '{:s}:{:s}'.format(str(host), str(port)) LOGGER.debug('Creating channel to {:s}...'.format(str(self.endpoint))) self.channel = None self.stub = None @@ -37,55 +42,55 @@ class ComputeClient: self.stub = ComputeServiceStub(self.channel) def close(self): - if(self.channel is not None): self.channel.close() + if self.channel is not None: self.channel.close() self.channel = None self.stub = None @RETRY_DECORATOR def CheckCredentials(self, request : TeraFlowController) -> AuthenticationResult: - LOGGER.debug('CheckCredentials request: {:s}'.format(str(request))) + LOGGER.debug('CheckCredentials request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.CheckCredentials(request) - LOGGER.debug('CheckCredentials result: {:s}'.format(str(response))) + LOGGER.debug('CheckCredentials result: {:s}'.format(grpc_message_to_json_string(response))) return response @RETRY_DECORATOR def GetConnectivityServiceStatus(self, request : ServiceId) -> ServiceStatus: - LOGGER.debug('GetConnectivityServiceStatus request: {:s}'.format(str(request))) + LOGGER.debug('GetConnectivityServiceStatus request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.GetConnectivityServiceStatus(request) - LOGGER.debug('GetConnectivityServiceStatus result: {:s}'.format(str(response))) + LOGGER.debug('GetConnectivityServiceStatus result: {:s}'.format(grpc_message_to_json_string(response))) return response @RETRY_DECORATOR def CreateConnectivityService(self, request : Service) -> ServiceId: - LOGGER.debug('CreateConnectivityService request: {:s}'.format(str(request))) + LOGGER.debug('CreateConnectivityService request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.CreateConnectivityService(request) - LOGGER.debug('CreateConnectivityService result: {:s}'.format(str(response))) + LOGGER.debug('CreateConnectivityService result: {:s}'.format(grpc_message_to_json_string(response))) return response @RETRY_DECORATOR def EditConnectivityService(self, request : Service) -> ServiceId: - LOGGER.debug('EditConnectivityService request: {:s}'.format(str(request))) + LOGGER.debug('EditConnectivityService request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.EditConnectivityService(request) - LOGGER.debug('EditConnectivityService result: {:s}'.format(str(response))) + LOGGER.debug('EditConnectivityService result: {:s}'.format(grpc_message_to_json_string(response))) return response @RETRY_DECORATOR def DeleteConnectivityService(self, request : Service) -> Empty: - LOGGER.debug('DeleteConnectivityService request: {:s}'.format(str(request))) + LOGGER.debug('DeleteConnectivityService request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.DeleteConnectivityService(request) - LOGGER.debug('DeleteConnectivityService result: {:s}'.format(str(response))) + LOGGER.debug('DeleteConnectivityService result: {:s}'.format(grpc_message_to_json_string(response))) return response @RETRY_DECORATOR def GetAllActiveConnectivityServices(self, request : Empty) -> ServiceIdList: - LOGGER.debug('GetAllActiveConnectivityServices request: {:s}'.format(str(request))) + LOGGER.debug('GetAllActiveConnectivityServices request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.GetAllActiveConnectivityServices(request) - LOGGER.debug('GetAllActiveConnectivityServices result: {:s}'.format(str(response))) + LOGGER.debug('GetAllActiveConnectivityServices result: {:s}'.format(grpc_message_to_json_string(response))) return response @RETRY_DECORATOR def ClearAllConnectivityServices(self, request : Empty) -> Empty: - LOGGER.debug('ClearAllConnectivityServices request: {:s}'.format(str(request))) + LOGGER.debug('ClearAllConnectivityServices request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.ClearAllConnectivityServices(request) - LOGGER.debug('ClearAllConnectivityServices result: {:s}'.format(str(response))) + LOGGER.debug('ClearAllConnectivityServices result: {:s}'.format(grpc_message_to_json_string(response))) return response diff --git a/src/compute/service/ComputeService.py b/src/compute/service/ComputeService.py index 1f523793d28526bdce1dd50cba7677aa04481171..f8476e102fcfbdd12480f8c40a797d6c84d70982 100644 --- a/src/compute/service/ComputeService.py +++ b/src/compute/service/ComputeService.py @@ -12,56 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc, logging -from concurrent import futures -from grpc_health.v1.health import HealthServicer, OVERALL_HEALTH -from grpc_health.v1.health_pb2 import HealthCheckResponse -from grpc_health.v1.health_pb2_grpc import add_HealthServicer_to_server +from common.Constants import ServiceNameEnum +from common.Settings import get_service_port_grpc +from common.tools.service.GenericGrpcService import GenericGrpcService from compute.proto.compute_pb2_grpc import add_ComputeServiceServicer_to_server from compute.service.ComputeServiceServicerImpl import ComputeServiceServicerImpl -from compute.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD - -BIND_ADDRESS = '0.0.0.0' -LOGGER = logging.getLogger(__name__) - -class ComputeService: - def __init__(self, address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, - grace_period=GRPC_GRACE_PERIOD): - self.address = address - self.port = port - self.endpoint = None - self.max_workers = max_workers - self.grace_period = grace_period - self.compute_servicer = None - self.health_servicer = None - self.pool = None - self.server = None - - def start(self): - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) - LOGGER.debug('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( - str(self.endpoint), str(self.max_workers))) - - self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) - self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) +class ComputeService(GenericGrpcService): + def __init__(self, cls_name: str = __name__) -> None: + port = get_service_port_grpc(ServiceNameEnum.COMPUTE) + super().__init__(port, cls_name=cls_name) self.compute_servicer = ComputeServiceServicerImpl() - add_ComputeServiceServicer_to_server(self.compute_servicer, self.server) - self.health_servicer = HealthServicer( - experimental_non_blocking=True, experimental_thread_pool=futures.ThreadPoolExecutor(max_workers=1)) - add_HealthServicer_to_server(self.health_servicer, self.server) - - port = self.server.add_insecure_port(self.endpoint) - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(port)) - LOGGER.info('Listening on {:s}...'.format(str(self.endpoint))) - self.server.start() - self.health_servicer.set(OVERALL_HEALTH, HealthCheckResponse.SERVING) # pylint: disable=maybe-no-member - - LOGGER.debug('Service started') - - def stop(self): - LOGGER.debug('Stopping service (grace period {:s} seconds)...'.format(str(self.grace_period))) - self.health_servicer.enter_graceful_shutdown() - self.server.stop(self.grace_period) - LOGGER.debug('Service stopped') + def install_servicers(self): + add_ComputeServiceServicer_to_server(self.compute_servicer, self.server) diff --git a/src/compute/service/__main__.py b/src/compute/service/__main__.py index cf6f8241010d26d8aff9718b8bc531c2f7f43d22..345b2fdd6950ecda802e8bd1c86e1421b5c60d84 100644 --- a/src/compute/service/__main__.py +++ b/src/compute/service/__main__.py @@ -14,10 +14,10 @@ import logging, signal, sys, threading from prometheus_client import start_http_server -from common.Settings import get_setting, wait_for_environment_variables -from compute.Config import ( - GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL, RESTAPI_SERVICE_PORT, RESTAPI_BASE_URL, - METRICS_PORT) +from common.Constants import ServiceNameEnum +from common.Settings import ( + ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_log_level, get_metrics_port, + wait_for_environment_variables) from .ComputeService import ComputeService from .rest_server.RestServer import RestServer from .rest_server.nbi_plugins.ietf_l2vpn import register_ietf_l2vpn @@ -32,20 +32,13 @@ def signal_handler(signal, frame): # pylint: disable=redefined-outer-name def main(): global LOGGER # pylint: disable=global-statement - grpc_service_port = get_setting('COMPUTESERVICE_SERVICE_PORT_GRPC', default=GRPC_SERVICE_PORT ) - max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS ) - grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD ) - log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL ) - restapi_service_port = get_setting('RESTAPI_SERVICE_PORT', default=RESTAPI_SERVICE_PORT) - restapi_base_url = get_setting('RESTAPI_BASE_URL', default=RESTAPI_BASE_URL ) - metrics_port = get_setting('METRICS_PORT', default=METRICS_PORT ) - + log_level = get_log_level() logging.basicConfig(level=log_level) LOGGER = logging.getLogger(__name__) wait_for_environment_variables([ - 'CONTEXTSERVICE_SERVICE_HOST', 'CONTEXTSERVICE_SERVICE_PORT_GRPC', - 'SERVICESERVICE_SERVICE_HOST', 'SERVICESERVICE_SERVICE_PORT_GRPC' + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST ), + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC), ]) signal.signal(signal.SIGINT, signal_handler) @@ -54,13 +47,14 @@ def main(): LOGGER.info('Starting...') # Start metrics server + metrics_port = get_metrics_port() start_http_server(metrics_port) # Starting compute service - grpc_service = ComputeService(port=grpc_service_port, max_workers=max_workers, grace_period=grace_period) + grpc_service = ComputeService() grpc_service.start() - rest_server = RestServer(port=restapi_service_port, base_url=restapi_base_url) + rest_server = RestServer() register_ietf_l2vpn(rest_server) rest_server.start() diff --git a/src/compute/service/rest_server/RestServer.py b/src/compute/service/rest_server/RestServer.py index 26055f8dfa319ae715e96241a13860fd8283a5aa..d9b6cd9157a77f61f6e3349de690e3314a2b41d9 100644 --- a/src/compute/service/rest_server/RestServer.py +++ b/src/compute/service/rest_server/RestServer.py @@ -12,45 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging, threading, time -from flask import Flask, request -from flask_restful import Api, Resource -from werkzeug.serving import make_server -from compute.Config import RESTAPI_BASE_URL, RESTAPI_SERVICE_PORT - -logging.getLogger('werkzeug').setLevel(logging.WARNING) - -BIND_ADDRESS = '0.0.0.0' -LOGGER = logging.getLogger(__name__) - -def log_request(response): - timestamp = time.strftime('[%Y-%b-%d %H:%M]') - LOGGER.info('%s %s %s %s %s', timestamp, request.remote_addr, request.method, request.full_path, response.status) - return response - -class RestServer(threading.Thread): - def __init__(self, host=BIND_ADDRESS, port=RESTAPI_SERVICE_PORT, base_url=RESTAPI_BASE_URL): - threading.Thread.__init__(self, daemon=True) - self.host = host - self.port = port - self.base_url = base_url - self.srv = None - self.ctx = None - self.app = Flask(__name__) - self.app.after_request(log_request) - self.api = Api(self.app, prefix=self.base_url) - - def add_resource(self, resource : Resource, *urls, **kwargs): - self.api.add_resource(resource, *urls, **kwargs) - - def run(self): - self.srv = make_server(self.host, self.port, self.app, threaded=True) - self.ctx = self.app.app_context() - self.ctx.push() - - endpoint = 'http://{:s}:{:s}{:s}'.format(str(self.host), str(self.port), str(self.base_url)) - LOGGER.info('Listening on {:s}...'.format(str(endpoint))) - self.srv.serve_forever() - - def shutdown(self): - self.srv.shutdown() +from common.Constants import ServiceNameEnum +from common.Settings import get_service_baseurl_http, get_service_port_http +from common.tools.service.GenericRestServer import GenericRestServer + +class RestServer(GenericRestServer): + def __init__(self, cls_name: str = __name__) -> None: + bind_port = get_service_port_http(ServiceNameEnum.COMPUTE) + base_url = get_service_baseurl_http(ServiceNameEnum.COMPUTE) + super().__init__(bind_port, base_url, cls_name=cls_name) diff --git a/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_Service.py b/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_Service.py index ecaf9281f1a21784f9050c40c07be373faf76a4b..72027b5c752b7e8cdea81c4fa5161d054bfb9fd4 100644 --- a/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_Service.py +++ b/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_Service.py @@ -17,7 +17,6 @@ from flask import request from flask.json import jsonify from flask_restful import Resource from common.Constants import DEFAULT_CONTEXT_UUID -from common.Settings import get_setting from context.client.ContextClient import ContextClient from context.proto.context_pb2 import ServiceId, SliceStatusEnum from service.client.ServiceClient import ServiceClient @@ -29,13 +28,6 @@ from .tools.HttpStatusCodes import HTTP_GATEWAYTIMEOUT, HTTP_NOCONTENT, HTTP_OK, LOGGER = logging.getLogger(__name__) class L2VPN_Service(Resource): - def __init__(self) -> None: - super().__init__() - self.context_client = ContextClient( - get_setting('CONTEXTSERVICE_SERVICE_HOST'), get_setting('CONTEXTSERVICE_SERVICE_PORT_GRPC')) - self.service_client = ServiceClient( - get_setting('SERVICESERVICE_SERVICE_HOST'), get_setting('SERVICESERVICE_SERVICE_PORT_GRPC')) - @HTTP_AUTH.login_required def get(self, vpn_id : str): LOGGER.debug('VPN_Id: {:s}'.format(str(vpn_id))) @@ -47,7 +39,9 @@ class L2VPN_Service(Resource): return response try: - target = get_service(self.context_client, vpn_id) + context_client = ContextClient() + + target = get_service(context_client, vpn_id) if target is not None: if target.service_id.service_uuid.uuid != vpn_id: # pylint: disable=no-member raise Exception('Service retrieval failed. Wrong Service Id was returned') @@ -56,7 +50,7 @@ class L2VPN_Service(Resource): response.status_code = HTTP_OK if service_status == service_ready_status else HTTP_GATEWAYTIMEOUT return response - target = get_slice(self.context_client, vpn_id) + target = get_slice(context_client, vpn_id) if target is not None: if target.slice_id.slice_uuid.uuid != vpn_id: # pylint: disable=no-member raise Exception('Slice retrieval failed. Wrong Slice Id was returned') @@ -83,7 +77,8 @@ class L2VPN_Service(Resource): service_id_request.service_uuid.uuid = vpn_id try: - self.service_client.DeleteService(service_id_request) + service_client = ServiceClient() + service_client.DeleteService(service_id_request) response = jsonify({}) response.status_code = HTTP_NOCONTENT except Exception as e: # pylint: disable=broad-except diff --git a/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_Services.py b/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_Services.py index 6d39cfe2db2ccba5ca75fe6861599b8ef178a038..e0de1b7321d5618d3a7d33af4a59b47b12482e3a 100644 --- a/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_Services.py +++ b/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_Services.py @@ -19,7 +19,6 @@ from flask.json import jsonify from flask_restful import Resource from werkzeug.exceptions import UnsupportedMediaType from common.Constants import DEFAULT_CONTEXT_UUID -from common.Settings import get_setting from service.client.ServiceClient import ServiceClient from service.proto.context_pb2 import Service, ServiceStatusEnum, ServiceTypeEnum from slice.client.SliceClient import SliceClient @@ -32,13 +31,6 @@ from .tools.Validator import validate_message LOGGER = logging.getLogger(__name__) class L2VPN_Services(Resource): - def __init__(self) -> None: - super().__init__() - self.service_client = ServiceClient( - get_setting('SERVICESERVICE_SERVICE_HOST'), get_setting('SERVICESERVICE_SERVICE_PORT_GRPC')) - self.slice_client = SliceClient( - get_setting('SLICESERVICE_SERVICE_HOST'), get_setting('SLICESERVICE_SERVICE_PORT_GRPC')) - @HTTP_AUTH.login_required def get(self): return {} @@ -62,7 +54,8 @@ class L2VPN_Services(Resource): service_request.service_type = ServiceTypeEnum.SERVICETYPE_L3NM service_request.service_status.service_status = ServiceStatusEnum.SERVICESTATUS_PLANNED - service_reply = self.service_client.CreateService(service_request) + service_client = ServiceClient() + service_reply = service_client.CreateService(service_request) if service_reply != service_request.service_id: # pylint: disable=no-member raise Exception('Service creation failed. Wrong Service Id was returned') elif vpn_service_type == 'vpls': @@ -72,7 +65,8 @@ class L2VPN_Services(Resource): slice_request.slice_id.slice_uuid.uuid = vpn_service['vpn-id'] slice_request.slice_status.slice_status = SliceStatusEnum.SLICESTATUS_PLANNED - slice_reply = self.slice_client.CreateSlice(slice_request) + slice_client = SliceClient() + slice_reply = slice_client.CreateSlice(slice_request) if slice_reply != slice_request.slice_id: # pylint: disable=no-member raise Exception('Slice creation failed. Wrong Slice Id was returned') diff --git a/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_SiteNetworkAccesses.py b/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_SiteNetworkAccesses.py index 3f6b1760fcea23c4877b97e5abede0e17e626f75..edfa572f907afd7c2c18c2d52d1fa24ec897049a 100644 --- a/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_SiteNetworkAccesses.py +++ b/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_SiteNetworkAccesses.py @@ -239,25 +239,20 @@ def process_list_site_network_access( return response class L2VPN_SiteNetworkAccesses(Resource): - def __init__(self) -> None: - super().__init__() - self.context_client = ContextClient( - get_setting('CONTEXTSERVICE_SERVICE_HOST'), get_setting('CONTEXTSERVICE_SERVICE_PORT_GRPC')) - self.service_client = ServiceClient( - get_setting('SERVICESERVICE_SERVICE_HOST'), get_setting('SERVICESERVICE_SERVICE_PORT_GRPC')) - self.slice_client = SliceClient( - get_setting('SLICESERVICE_SERVICE_HOST'), get_setting('SLICESERVICE_SERVICE_PORT_GRPC')) - @HTTP_AUTH.login_required def post(self, site_id : str): if not request.is_json: raise UnsupportedMediaType('JSON payload is required') LOGGER.debug('Site_Id: {:s}'.format(str(site_id))) - return process_list_site_network_access( - self.context_client, self.service_client, self.slice_client, request.json) + context_client = ContextClient() + service_client = ServiceClient() + slice_client = SliceClient() + return process_list_site_network_access(context_client, service_client, slice_client, request.json) @HTTP_AUTH.login_required def put(self, site_id : str): if not request.is_json: raise UnsupportedMediaType('JSON payload is required') LOGGER.debug('Site_Id: {:s}'.format(str(site_id))) - return process_list_site_network_access( - self.context_client, self.service_client, self.slice_client, request.json) + context_client = ContextClient() + service_client = ServiceClient() + slice_client = SliceClient() + return process_list_site_network_access(context_client, service_client, slice_client, request.json) diff --git a/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/__init__.py b/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/__init__.py index 79be6b7433a4e448febb37777cd0b310d5bf132d..c8b23bcee09bb7f16d75bde02e6f3a7f4ca66b4d 100644 --- a/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/__init__.py +++ b/src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/__init__.py @@ -21,7 +21,7 @@ from .L2VPN_Services import L2VPN_Services from .L2VPN_Service import L2VPN_Service from .L2VPN_SiteNetworkAccesses import L2VPN_SiteNetworkAccesses -URL_PREFIX = '/ietf-l2vpn-svc:l2vpn-svc' +URL_PREFIX = '/ietf-l2vpn-svc:l2vpn-svc' def _add_resource(rest_server : RestServer, resource : Resource, *urls, **kwargs): urls = [(URL_PREFIX + url) for url in urls] diff --git a/src/compute/tests/MockService_Dependencies.py b/src/compute/tests/MockService_Dependencies.py new file mode 100644 index 0000000000000000000000000000000000000000..8b0e4b3cc49d39a245b76ab5c4099f682ca4c92c --- /dev/null +++ b/src/compute/tests/MockService_Dependencies.py @@ -0,0 +1,58 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from typing import Union +from common.Constants import ServiceNameEnum +from common.Settings import ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name +from common.tests.MockServicerImpl_Context import MockServicerImpl_Context +from common.tests.MockServicerImpl_Service import MockServicerImpl_Service +from common.tests.MockServicerImpl_Slice import MockServicerImpl_Slice +from common.tools.service.GenericGrpcService import GenericGrpcService +from context.proto.context_pb2_grpc import add_ContextServiceServicer_to_server +from service.proto.service_pb2_grpc import add_ServiceServiceServicer_to_server +from slice.proto.slice_pb2_grpc import add_SliceServiceServicer_to_server + +LOCAL_HOST = '127.0.0.1' + +SERVICE_CONTEXT = ServiceNameEnum.CONTEXT +SERVICE_SERVICE = ServiceNameEnum.SERVICE +SERVICE_SLICE = ServiceNameEnum.SLICE + +class MockService_Dependencies(GenericGrpcService): + # Mock Service implementing Context, Service and Slice to simplify unitary tests of Compute + + def __init__(self, bind_port: Union[str, int]) -> None: + super().__init__(bind_port, LOCAL_HOST, enable_health_servicer=False, cls_name='MockService') + + # pylint: disable=attribute-defined-outside-init + def install_servicers(self): + self.context_servicer = MockServicerImpl_Context() + add_ContextServiceServicer_to_server(self.context_servicer, self.server) + + self.service_servicer = MockServicerImpl_Service() + add_ServiceServiceServicer_to_server(self.service_servicer, self.server) + + self.slice_servicer = MockServicerImpl_Slice() + add_SliceServiceServicer_to_server(self.slice_servicer, self.server) + + def configure_env_vars(self): + os.environ[get_env_var_name(SERVICE_CONTEXT, ENVVAR_SUFIX_SERVICE_HOST )] = str(self.bind_address) + os.environ[get_env_var_name(SERVICE_CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(self.bind_port) + + os.environ[get_env_var_name(SERVICE_SERVICE, ENVVAR_SUFIX_SERVICE_HOST )] = str(self.bind_address) + os.environ[get_env_var_name(SERVICE_SERVICE, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(self.bind_port) + + os.environ[get_env_var_name(SERVICE_SLICE, ENVVAR_SUFIX_SERVICE_HOST )] = str(self.bind_address) + os.environ[get_env_var_name(SERVICE_SLICE, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(self.bind_port) diff --git a/src/compute/tests/PrepareTestScenario.py b/src/compute/tests/PrepareTestScenario.py new file mode 100644 index 0000000000000000000000000000000000000000..d534a4a28280c80964096a9cb7291c498ebe6b93 --- /dev/null +++ b/src/compute/tests/PrepareTestScenario.py @@ -0,0 +1,52 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os, pytest, time +from common.Constants import ServiceNameEnum +from common.Settings import ( + ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_HTTP, get_env_var_name, get_service_port_http) +from compute.service.rest_server.RestServer import RestServer +from compute.service.rest_server.nbi_plugins.ietf_l2vpn import register_ietf_l2vpn +from compute.tests.MockService_Dependencies import MockService_Dependencies +from .mock_osm.MockOSM import MockOSM +from .Constants import WIM_MAPPING, WIM_USERNAME, WIM_PASSWORD + +LOCAL_HOST = '127.0.0.1' +MOCKSERVICE_PORT = 10000 +COMPUTE_SERVICE_PORT = MOCKSERVICE_PORT + get_service_port_http(ServiceNameEnum.COMPUTE) # avoid privileged ports +os.environ[get_env_var_name(ServiceNameEnum.COMPUTE, ENVVAR_SUFIX_SERVICE_HOST )] = str(LOCAL_HOST) +os.environ[get_env_var_name(ServiceNameEnum.COMPUTE, ENVVAR_SUFIX_SERVICE_PORT_HTTP)] = str(COMPUTE_SERVICE_PORT) + +@pytest.fixture(scope='session') +def mock_service(): + _service = MockService_Dependencies(MOCKSERVICE_PORT) + _service.configure_env_vars() + _service.start() + yield _service + _service.stop() + +@pytest.fixture(scope='session') +def compute_service_rest(mock_service): # pylint: disable=redefined-outer-name + _rest_server = RestServer() + register_ietf_l2vpn(_rest_server) + _rest_server.start() + time.sleep(1) # bring time for the server to start + yield _rest_server + _rest_server.shutdown() + _rest_server.join() + +@pytest.fixture(scope='session') +def osm_wim(compute_service_rest): # pylint: disable=redefined-outer-name + wim_url = 'http://{:s}:{:d}'.format(LOCAL_HOST, COMPUTE_SERVICE_PORT) + return MockOSM(wim_url, WIM_MAPPING, WIM_USERNAME, WIM_PASSWORD) diff --git a/src/compute/tests/test_unitary.py b/src/compute/tests/test_unitary.py index 1fbc74ecc7fc49129b789ba99af7276a94bd662e..05c45c1b3554d21084a4a20cac6856b049fe7ca3 100644 --- a/src/compute/tests/test_unitary.py +++ b/src/compute/tests/test_unitary.py @@ -12,75 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging, os, pytest, time -from common.tests.MockService import MockService -from common.tests.MockServicerImpl_Context import MockServicerImpl_Context -from common.tests.MockServicerImpl_Service import MockServicerImpl_Service -from common.tests.MockServicerImpl_Slice import MockServicerImpl_Slice -from compute.Config import RESTAPI_SERVICE_PORT, RESTAPI_BASE_URL -from compute.service.rest_server.RestServer import RestServer -from context.proto.context_pb2_grpc import add_ContextServiceServicer_to_server -from service.proto.service_pb2_grpc import add_ServiceServiceServicer_to_server -from slice.proto.slice_pb2_grpc import add_SliceServiceServicer_to_server +import logging from .mock_osm.MockOSM import MockOSM -from .Constants import ( - SERVICE_CONNECTION_POINTS_1, SERVICE_CONNECTION_POINTS_2, SERVICE_TYPE, WIM_MAPPING, WIM_USERNAME, WIM_PASSWORD) +from .Constants import SERVICE_CONNECTION_POINTS_1, SERVICE_CONNECTION_POINTS_2, SERVICE_TYPE +from .PrepareTestScenario import ( # pylint: disable=unused-import + # be careful, order of symbols is important here! + mock_service, compute_service_rest, osm_wim) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) -LOCALHOST = '127.0.0.1' -MOCKSERVER_GRPC_PORT = 10000 -COMPUTE_RESTAPI_PORT = 10000 + RESTAPI_SERVICE_PORT # avoid privileged ports - -class MockService_ContextService(MockService): - # Mock Server implementing Context and Service to simplify unitary tests of Compute - - def __init__(self, cls_name='MockService_Service'): - super().__init__(LOCALHOST, MOCKSERVER_GRPC_PORT, cls_name=cls_name) - - # pylint: disable=attribute-defined-outside-init - def install_servicers(self): - self.context_servicer = MockServicerImpl_Context() - add_ContextServiceServicer_to_server(self.context_servicer, self.server) - self.service_servicer = MockServicerImpl_Service() - add_ServiceServiceServicer_to_server(self.service_servicer, self.server) - self.slice_servicer = MockServicerImpl_Slice() - add_SliceServiceServicer_to_server(self.slice_servicer, self.server) - -os.environ['CONTEXTSERVICE_SERVICE_HOST'] = LOCALHOST -os.environ['CONTEXTSERVICE_SERVICE_PORT_GRPC'] = str(MOCKSERVER_GRPC_PORT) -os.environ['SERVICESERVICE_SERVICE_HOST'] = LOCALHOST -os.environ['SERVICESERVICE_SERVICE_PORT_GRPC'] = str(MOCKSERVER_GRPC_PORT) -os.environ['SLICESERVICE_SERVICE_HOST'] = LOCALHOST -os.environ['SLICESERVICE_SERVICE_PORT_GRPC'] = str(MOCKSERVER_GRPC_PORT) - -# NBI Plugin IETF L2VPN requires environment variables CONTEXTSERVICE_SERVICE_HOST, CONTEXTSERVICE_SERVICE_PORT_GRPC, -# SERVICESERVICE_SERVICE_HOST, and SERVICESERVICE_SERVICE_PORT_GRPC to work properly. -# pylint: disable=wrong-import-position,ungrouped-imports -from compute.service.rest_server.nbi_plugins.ietf_l2vpn import register_ietf_l2vpn - -@pytest.fixture(scope='session') -def mockservice(): - _service = MockService_ContextService() - _service.start() - yield _service - _service.stop() - -@pytest.fixture(scope='session') -def compute_service_rest(mockservice): # pylint: disable=redefined-outer-name - _rest_server = RestServer(port=COMPUTE_RESTAPI_PORT, base_url=RESTAPI_BASE_URL) - register_ietf_l2vpn(_rest_server) - _rest_server.start() - time.sleep(1) # bring time for the server to start - yield _rest_server - _rest_server.shutdown() - _rest_server.join() - -@pytest.fixture(scope='session') -def osm_wim(compute_service_rest): # pylint: disable=redefined-outer-name - wim_url = 'http://{:s}:{:d}'.format(LOCALHOST, COMPUTE_RESTAPI_PORT) - return MockOSM(wim_url, WIM_MAPPING, WIM_USERNAME, WIM_PASSWORD) def test_compute_create_connectivity_service_rest_api(osm_wim : MockOSM): # pylint: disable=redefined-outer-name osm_wim.create_connectivity_service(SERVICE_TYPE, SERVICE_CONNECTION_POINTS_1) diff --git a/src/context/.gitlab-ci.yml b/src/context/.gitlab-ci.yml index c0cbef8d7d8e2165e5d2f64c79fa2e6215ef8b96..dc302cbd3aa7dbe197450c91a0e9c90714df6110 100644 --- a/src/context/.gitlab-ci.yml +++ b/src/context/.gitlab-ci.yml @@ -58,7 +58,6 @@ unit test context: - docker ps -a - docker logs $IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - - docker exec -i $IMAGE_NAME bash -c "coverage xml -o /opt/results/${IMAGE_NAME}_coverage.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: @@ -79,7 +78,6 @@ unit test context: when: always reports: junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml - cobertura: src/$IMAGE_NAME/tests/${IMAGE_NAME}_coverage.xml # Deployment of the service in Kubernetes Cluster deploy context: diff --git a/src/context/Config.py b/src/context/Config.py index 328610fc81561f60d97b8ef3080930c4affce20e..6f5d1dc0b347dc5db27a2cfae973a4e5bdf7b4cc 100644 --- a/src/context/Config.py +++ b/src/context/Config.py @@ -12,22 +12,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging - -# General settings -LOG_LEVEL = logging.INFO - -# gRPC settings -GRPC_SERVICE_PORT = 1010 -GRPC_MAX_WORKERS = 200 # multiple clients might keep connections alive for Get*Events() RPC methods -GRPC_GRACE_PERIOD = 60 - -# REST-API settings -RESTAPI_SERVICE_PORT = 8080 -RESTAPI_BASE_URL = '/api' - -# Prometheus settings -METRICS_PORT = 9192 - # Autopopulate the component with fake data for testing purposes? POPULATE_FAKE_DATA = False diff --git a/src/context/client/ContextClient.py b/src/context/client/ContextClient.py index 3206e4a366ef2f6cb7d3aeb366b287572b8d49da..34214fac00d03f5d7595bf118b35026642ba9426 100644 --- a/src/context/client/ContextClient.py +++ b/src/context/client/ContextClient.py @@ -12,8 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Iterator import grpc, logging +from typing import Iterator +from common.Constants import ServiceNameEnum +from common.Settings import get_service_host, get_service_port_grpc from common.tools.client.RetryDecorator import retry, delay_exponential from common.tools.grpc.Tools import grpc_message_to_json_string from context.proto.context_pb2 import ( @@ -29,9 +31,11 @@ DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) RETRY_DECORATOR = retry(max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') class ContextClient: - def __init__(self, address, port): - self.endpoint = '{:s}:{:s}'.format(str(address), str(port)) - LOGGER.debug('Creating channel to {:s}...'.format(self.endpoint)) + def __init__(self, host=None, port=None): + if not host: host = get_service_host(ServiceNameEnum.CONTEXT) + if not port: port = get_service_port_grpc(ServiceNameEnum.CONTEXT) + self.endpoint = '{:s}:{:s}'.format(str(host), str(port)) + LOGGER.debug('Creating channel to {:s}...'.format(str(self.endpoint))) self.channel = None self.stub = None self.connect() diff --git a/src/context/service/Populate.py b/src/context/service/Populate.py index f4630182d864a891095caa6689dde9f656ea1c0e..ace630900d82fc36a82d290f12e466018dc82587 100644 --- a/src/context/service/Populate.py +++ b/src/context/service/Populate.py @@ -20,8 +20,8 @@ from context.tests.Objects import ( LINK_R1_R2, LINK_R1_R2_ID, LINK_R1_R3, LINK_R1_R3_ID, LINK_R2_R3, LINK_R2_R3_ID, SERVICE_R1_R2, SERVICE_R1_R3, SERVICE_R2_R3) -def populate(address, port): - client = ContextClient(address=address, port=port) +def populate(host=None, port=None): + client = ContextClient(host=host, port=port) client.SetContext(Context(**CONTEXT)) client.SetTopology(Topology(**TOPOLOGY)) diff --git a/src/context/service/__main__.py b/src/context/service/__main__.py index 180a1f44cb6a37b487e6bce0a13706952ff73bc2..53754caf4f9d2621ed8a6fdfd325d42f77f44a4f 100644 --- a/src/context/service/__main__.py +++ b/src/context/service/__main__.py @@ -14,17 +14,15 @@ import logging, signal, sys, threading from prometheus_client import start_http_server -from common.Settings import get_setting +from common.Settings import get_log_level, get_metrics_port, get_setting from common.orm.Database import Database from common.orm.Factory import get_database_backend from common.message_broker.Factory import get_messagebroker_backend from common.message_broker.MessageBroker import MessageBroker -from context.Config import ( - GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL, POPULATE_FAKE_DATA, RESTAPI_SERVICE_PORT, - RESTAPI_BASE_URL, METRICS_PORT) +from context.Config import POPULATE_FAKE_DATA from .grpc_server.ContextService import ContextService from .rest_server.Resources import RESOURCES -from .rest_server.Server import Server +from .rest_server.RestServer import RestServer from .Populate import populate terminate = threading.Event() @@ -37,16 +35,7 @@ def signal_handler(signal, frame): # pylint: disable=redefined-outer-name def main(): global LOGGER # pylint: disable=global-statement - grpc_service_port = get_setting('CONTEXTSERVICE_SERVICE_PORT_GRPC', default=GRPC_SERVICE_PORT ) - max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS ) - grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD ) - log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL ) - restapi_service_port = get_setting('CONTEXTSERVICE_SERVICE_PORT_HTTP', default=RESTAPI_SERVICE_PORT) - restapi_base_url = get_setting('RESTAPI_BASE_URL', default=RESTAPI_BASE_URL ) - metrics_port = get_setting('METRICS_PORT', default=METRICS_PORT ) - populate_fake_data = get_setting('POPULATE_FAKE_DATA', default=POPULATE_FAKE_DATA ) - if isinstance(populate_fake_data, str): populate_fake_data = (populate_fake_data.upper() in {'T', '1', 'TRUE'}) - + log_level = get_log_level() logging.basicConfig(level=log_level) LOGGER = logging.getLogger(__name__) @@ -56,6 +45,7 @@ def main(): LOGGER.info('Starting...') # Start metrics server + metrics_port = get_metrics_port() start_http_server(metrics_port) # Get database instance @@ -65,18 +55,19 @@ def main(): messagebroker = MessageBroker(get_messagebroker_backend()) # Starting context service - grpc_service = ContextService( - database, messagebroker, port=grpc_service_port, max_workers=max_workers, grace_period=grace_period) + grpc_service = ContextService(database, messagebroker) grpc_service.start() - rest_server = Server(port=restapi_service_port, base_url=restapi_base_url) + rest_server = RestServer() for endpoint_name, resource_class, resource_url in RESOURCES: rest_server.add_resource(resource_class, resource_url, endpoint=endpoint_name, resource_class_args=(database,)) rest_server.start() + populate_fake_data = get_setting('POPULATE_FAKE_DATA', default=POPULATE_FAKE_DATA) + if isinstance(populate_fake_data, str): populate_fake_data = (populate_fake_data.upper() in {'T', '1', 'TRUE'}) if populate_fake_data: LOGGER.info('Populating fake data...') - populate('127.0.0.1', grpc_service_port) + populate(host='127.0.0.1', port=grpc_service.bind_port) LOGGER.info('Fake Data populated') # Wait for Ctrl+C or termination signal diff --git a/src/context/service/grpc_server/ContextService.py b/src/context/service/grpc_server/ContextService.py index 87ca94a70aa2e1733b8ec443c70a4623d2e0c471..c338b0f0d499e3c9a2a32a8ca77e386333af0456 100644 --- a/src/context/service/grpc_server/ContextService.py +++ b/src/context/service/grpc_server/ContextService.py @@ -12,61 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc -import logging -from concurrent import futures -from grpc_health.v1.health import HealthServicer, OVERALL_HEALTH -from grpc_health.v1.health_pb2 import HealthCheckResponse -from grpc_health.v1.health_pb2_grpc import add_HealthServicer_to_server -from context.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD +from common.Constants import ServiceNameEnum +from common.Settings import get_service_port_grpc +from common.message_broker.MessageBroker import MessageBroker +from common.orm.Database import Database +from common.tools.service.GenericGrpcService import GenericGrpcService from context.proto.context_pb2_grpc import add_ContextServiceServicer_to_server from .ContextServiceServicerImpl import ContextServiceServicerImpl -BIND_ADDRESS = '0.0.0.0' -LOGGER = logging.getLogger(__name__) +# Custom gRPC settings +GRPC_MAX_WORKERS = 200 # multiple clients might keep connections alive for Get*Events() RPC methods -class ContextService: - def __init__( - self, database, messagebroker, address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, - grace_period=GRPC_GRACE_PERIOD): +class ContextService(GenericGrpcService): + def __init__(self, database : Database, messagebroker : MessageBroker, cls_name: str = __name__) -> None: + port = get_service_port_grpc(ServiceNameEnum.CONTEXT) + super().__init__(port, max_workers=GRPC_MAX_WORKERS, cls_name=cls_name) + self.context_servicer = ContextServiceServicerImpl(database, messagebroker) - self.database = database - self.messagebroker = messagebroker - self.address = address - self.port = port - self.endpoint = None - self.max_workers = max_workers - self.grace_period = grace_period - self.context_servicer = None - self.health_servicer = None - self.pool = None - self.server = None - - def start(self): - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) - LOGGER.info('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( - str(self.endpoint), str(self.max_workers))) - - self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) - self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) - - self.context_servicer = ContextServiceServicerImpl(self.database, self.messagebroker) + def install_servicers(self): add_ContextServiceServicer_to_server(self.context_servicer, self.server) - - self.health_servicer = HealthServicer( - experimental_non_blocking=True, experimental_thread_pool=futures.ThreadPoolExecutor(max_workers=1)) - add_HealthServicer_to_server(self.health_servicer, self.server) - - port = self.server.add_insecure_port(self.endpoint) - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(port)) - LOGGER.info('Listening on {:s}...'.format(str(self.endpoint))) - self.server.start() - self.health_servicer.set(OVERALL_HEALTH, HealthCheckResponse.SERVING) # pylint: disable=maybe-no-member - - LOGGER.debug('Service started') - - def stop(self): - LOGGER.debug('Stopping service (grace period {:s} seconds)...'.format(str(self.grace_period))) - self.health_servicer.enter_graceful_shutdown() - self.server.stop(self.grace_period) - LOGGER.debug('Service stopped') diff --git a/src/context/service/rest_server/RestServer.py b/src/context/service/rest_server/RestServer.py new file mode 100644 index 0000000000000000000000000000000000000000..289e92a3c1b74e207a261b133130a551c3c55918 --- /dev/null +++ b/src/context/service/rest_server/RestServer.py @@ -0,0 +1,23 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from common.Constants import ServiceNameEnum +from common.Settings import get_service_baseurl_http, get_service_port_http +from common.tools.service.GenericRestServer import GenericRestServer + +class RestServer(GenericRestServer): + def __init__(self, cls_name: str = __name__) -> None: + bind_port = get_service_port_http(ServiceNameEnum.CONTEXT) + base_url = get_service_baseurl_http(ServiceNameEnum.CONTEXT) + super().__init__(bind_port, base_url, cls_name=cls_name) diff --git a/src/context/service/rest_server/Server.py b/src/context/service/rest_server/Server.py deleted file mode 100644 index ac4888d41bd9a84c57fc2d2f308bde4558787cbc..0000000000000000000000000000000000000000 --- a/src/context/service/rest_server/Server.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import logging, threading -from flask import Flask -from flask_restful import Api -from werkzeug.serving import make_server -from context.Config import RESTAPI_BASE_URL, RESTAPI_SERVICE_PORT - -logging.getLogger('werkzeug').setLevel(logging.WARNING) - -BIND_ADDRESS = '0.0.0.0' -LOGGER = logging.getLogger(__name__) - -class Server(threading.Thread): - def __init__(self, host=BIND_ADDRESS, port=RESTAPI_SERVICE_PORT, base_url=RESTAPI_BASE_URL): - threading.Thread.__init__(self, daemon=True) - self.host = host - self.port = port - self.base_url = base_url - self.srv = None - self.ctx = None - self.app = Flask(__name__) - self.api = Api(self.app, prefix=self.base_url) - - def add_resource(self, resource, *urls, **kwargs): - self.api.add_resource(resource, *urls, **kwargs) - - def run(self): - self.srv = make_server(self.host, self.port, self.app, threaded=True) - self.ctx = self.app.app_context() - self.ctx.push() - - endpoint = 'http://{:s}:{:s}{:s}'.format(str(self.host), str(self.port), str(self.base_url)) - LOGGER.info('Listening on {:s}...'.format(str(endpoint))) - self.srv.serve_forever() - - def shutdown(self): - self.srv.shutdown() diff --git a/src/context/tests/test_unitary.py b/src/context/tests/test_unitary.py index 10f44d9ad87a71d5935151f4ae724e9d04b5d5ce..0705477aece433cc7d796921afbd40e6d4df05eb 100644 --- a/src/context/tests/test_unitary.py +++ b/src/context/tests/test_unitary.py @@ -15,7 +15,8 @@ # pylint: disable=too-many-lines import copy, grpc, logging, os, pytest, requests, time, urllib from typing import Tuple -from common.Constants import DEFAULT_CONTEXT_UUID, DEFAULT_TOPOLOGY_UUID +from common.Constants import DEFAULT_CONTEXT_UUID, DEFAULT_TOPOLOGY_UUID, ServiceNameEnum +from common.Settings import ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, ENVVAR_SUFIX_SERVICE_PORT_HTTP, get_env_var_name, get_service_baseurl_http, get_service_port_grpc, get_service_port_http from common.orm.Database import Database from common.orm.Factory import get_database_backend, BackendEnum as DatabaseBackendEnum from common.message_broker.Factory import get_messagebroker_backend, BackendEnum as MessageBrokerBackendEnum @@ -25,8 +26,6 @@ from common.type_checkers.Assertions import ( validate_contexts, validate_device, validate_device_ids, validate_devices, validate_link, validate_link_ids, validate_links, validate_service, validate_service_ids, validate_services, validate_topologies, validate_topology, validate_topology_ids) -from context.Config import ( - GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, RESTAPI_SERVICE_PORT, RESTAPI_BASE_URL) from context.client.ContextClient import ContextClient from context.client.EventsCollector import EventsCollector from context.proto.context_pb2 import ( @@ -37,7 +36,7 @@ from context.service.database.Tools import ( FASTHASHER_DATA_ACCEPTED_FORMAT, FASTHASHER_ITEM_ACCEPTED_FORMAT, fast_hasher) from context.service.grpc_server.ContextService import ContextService from context.service.Populate import populate -from context.service.rest_server.Server import Server as RestServer +from context.service.rest_server.RestServer import RestServer from context.service.rest_server.Resources import RESOURCES from .Objects import ( CONNECTION_R1_R3, CONNECTION_R1_R3_ID, CONNECTION_R1_R3_UUID, CONTEXT, CONTEXT_ID, DEVICE_R1, DEVICE_R1_ID, @@ -48,10 +47,15 @@ from .Objects import ( LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) -GRPC_PORT = 10000 + GRPC_SERVICE_PORT # avoid privileged ports -RESTAPI_PORT = 10000 + RESTAPI_SERVICE_PORT # avoid privileged ports +LOCAL_HOST = '127.0.0.1' +GRPC_PORT = 10000 + get_service_port_grpc(ServiceNameEnum.CONTEXT) # avoid privileged ports +HTTP_PORT = 10000 + get_service_port_http(ServiceNameEnum.CONTEXT) # avoid privileged ports -DEFAULT_REDIS_SERVICE_HOST = '127.0.0.1' +os.environ[get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST )] = str(LOCAL_HOST) +os.environ[get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(GRPC_PORT) +os.environ[get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_HTTP)] = str(HTTP_PORT) + +DEFAULT_REDIS_SERVICE_HOST = LOCAL_HOST DEFAULT_REDIS_SERVICE_PORT = 6379 DEFAULT_REDIS_DATABASE_ID = 0 @@ -78,9 +82,7 @@ def context_db_mb(request) -> Tuple[Database, MessageBroker]: @pytest.fixture(scope='session') def context_service_grpc(context_db_mb : Tuple[Database, MessageBroker]): # pylint: disable=redefined-outer-name - _service = ContextService( - context_db_mb[0], context_db_mb[1], port=GRPC_PORT, max_workers=GRPC_MAX_WORKERS, - grace_period=GRPC_GRACE_PERIOD) + _service = ContextService(context_db_mb[0], context_db_mb[1]) _service.start() yield _service _service.stop() @@ -88,7 +90,7 @@ def context_service_grpc(context_db_mb : Tuple[Database, MessageBroker]): # pyli @pytest.fixture(scope='session') def context_service_rest(context_db_mb : Tuple[Database, MessageBroker]): # pylint: disable=redefined-outer-name database = context_db_mb[0] - _rest_server = RestServer(port=RESTAPI_PORT, base_url=RESTAPI_BASE_URL) + _rest_server = RestServer() for endpoint_name, resource_class, resource_url in RESOURCES: _rest_server.add_resource(resource_class, resource_url, endpoint=endpoint_name, resource_class_args=(database,)) _rest_server.start() @@ -99,12 +101,13 @@ def context_service_rest(context_db_mb : Tuple[Database, MessageBroker]): # pyli @pytest.fixture(scope='session') def context_client_grpc(context_service_grpc : ContextService): # pylint: disable=redefined-outer-name - _client = ContextClient(address='127.0.0.1', port=GRPC_PORT) + _client = ContextClient() yield _client _client.close() def do_rest_request(url : str): - request_url = 'http://127.0.0.1:{:s}{:s}{:s}'.format(str(RESTAPI_PORT), str(RESTAPI_BASE_URL), url) + base_url = get_service_baseurl_http(ServiceNameEnum.CONTEXT) + request_url = 'http://{:s}:{:s}{:s}{:s}'.format(str(LOCAL_HOST), str(HTTP_PORT), str(base_url), url) LOGGER.warning('Request: GET {:s}'.format(str(request_url))) reply = requests.get(request_url) LOGGER.warning('Reply: {:s}'.format(str(reply.text))) @@ -1172,7 +1175,7 @@ def test_rest_populate_database( ): database = context_db_mb[0] database.clear_all() - populate('127.0.0.1', GRPC_PORT) + populate(LOCAL_HOST, GRPC_PORT) def test_rest_get_context_ids(context_service_rest : RestServer): # pylint: disable=redefined-outer-name reply = do_rest_request('/context_ids') diff --git a/src/dbscanserving/.gitlab-ci.yml b/src/dbscanserving/.gitlab-ci.yml index 1e499fae232ff805fe3f70d1b1c586a9c9a8de5f..fd0d66bac25bbb5417a9f90415f3d0732312516b 100644 --- a/src/dbscanserving/.gitlab-ci.yml +++ b/src/dbscanserving/.gitlab-ci.yml @@ -56,7 +56,6 @@ unit test dbscanserving: - docker ps -a - docker logs $IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - - docker exec -i $IMAGE_NAME bash -c "coverage xml -o /opt/results/${IMAGE_NAME}_coverage.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: @@ -76,7 +75,6 @@ unit test dbscanserving: when: always reports: junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml - cobertura: src/$IMAGE_NAME/tests/${IMAGE_NAME}_coverage.xml # Deployment of the dbscanserving service in Kubernetes Cluster diff --git a/src/device/.gitlab-ci.yml b/src/device/.gitlab-ci.yml index aa2f9114a8c1507397171286e79d4daf8c348899..4e337f37e17006cee0943dfadce6d933b656c4bf 100644 --- a/src/device/.gitlab-ci.yml +++ b/src/device/.gitlab-ci.yml @@ -54,8 +54,7 @@ unit test device: - sleep 5 - docker ps -a - docker logs $IMAGE_NAME - - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - - docker exec -i $IMAGE_NAME bash -c "coverage xml -o /opt/results/${IMAGE_NAME}_coverage.xml" + - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary_emulated.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: @@ -75,7 +74,6 @@ unit test device: when: always reports: junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml - cobertura: src/$IMAGE_NAME/tests/${IMAGE_NAME}_coverage.xml # Deployment of the service in Kubernetes Cluster deploy device: diff --git a/src/device/Config.py b/src/device/Config.py index 415ae7b01ced740a0dc09f215ae71ad553a2672e..70a33251242c51f49140e596b8208a19dd5245f7 100644 --- a/src/device/Config.py +++ b/src/device/Config.py @@ -12,21 +12,3 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging - -# General settings -LOG_LEVEL = logging.WARNING - -# gRPC settings -GRPC_SERVICE_PORT = 2020 -GRPC_MAX_WORKERS = 10 -GRPC_GRACE_PERIOD = 60 - -# Prometheus settings -METRICS_PORT = 9192 - -# Dependency micro-service connection settings -CONTEXT_SERVICE_HOST = '127.0.0.1' -CONTEXT_SERVICE_PORT = 1010 -MONITORING_SERVICE_HOST = '127.0.0.1' -MONITORING_SERVICE_PORT = 7070 diff --git a/src/device/client/DeviceClient.py b/src/device/client/DeviceClient.py index 2a9512411a2d9e55e4c5b0fa75d48fc54d810713..7fe54cb23babee7a2f3bc9d21082732d924f5eff 100644 --- a/src/device/client/DeviceClient.py +++ b/src/device/client/DeviceClient.py @@ -13,7 +13,10 @@ # limitations under the License. import grpc, logging +from common.Constants import ServiceNameEnum +from common.Settings import get_service_host, get_service_port_grpc from common.tools.client.RetryDecorator import retry, delay_exponential +from common.tools.grpc.Tools import grpc_message_to_json_string from device.proto.context_pb2 import Device, DeviceConfig, DeviceId, Empty from device.proto.device_pb2 import MonitoringSettings from device.proto.device_pb2_grpc import DeviceServiceStub @@ -24,8 +27,10 @@ DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) RETRY_DECORATOR = retry(max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') class DeviceClient: - def __init__(self, address, port): - self.endpoint = '{:s}:{:s}'.format(str(address), str(port)) + def __init__(self, host=None, port=None): + if not host: host = get_service_host(ServiceNameEnum.DEVICE) + if not port: port = get_service_port_grpc(ServiceNameEnum.DEVICE) + self.endpoint = '{:s}:{:s}'.format(str(host), str(port)) LOGGER.debug('Creating channel to {:s}...'.format(str(self.endpoint))) self.channel = None self.stub = None @@ -37,41 +42,41 @@ class DeviceClient: self.stub = DeviceServiceStub(self.channel) def close(self): - if(self.channel is not None): self.channel.close() + if self.channel is not None: self.channel.close() self.channel = None self.stub = None @RETRY_DECORATOR def AddDevice(self, request : Device) -> DeviceId: - LOGGER.debug('AddDevice request: {:s}'.format(str(request))) + LOGGER.debug('AddDevice request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.AddDevice(request) - LOGGER.debug('AddDevice result: {:s}'.format(str(response))) + LOGGER.debug('AddDevice result: {:s}'.format(grpc_message_to_json_string(response))) return response @RETRY_DECORATOR def ConfigureDevice(self, request : Device) -> DeviceId: - LOGGER.debug('ConfigureDevice request: {:s}'.format(str(request))) + LOGGER.debug('ConfigureDevice request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.ConfigureDevice(request) - LOGGER.debug('ConfigureDevice result: {:s}'.format(str(response))) + LOGGER.debug('ConfigureDevice result: {:s}'.format(grpc_message_to_json_string(response))) return response @RETRY_DECORATOR def DeleteDevice(self, request : DeviceId) -> Empty: - LOGGER.debug('DeleteDevice request: {:s}'.format(str(request))) + LOGGER.debug('DeleteDevice request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.DeleteDevice(request) - LOGGER.debug('DeleteDevice result: {:s}'.format(str(response))) + LOGGER.debug('DeleteDevice result: {:s}'.format(grpc_message_to_json_string(response))) return response @RETRY_DECORATOR def GetInitialConfig(self, request : DeviceId) -> DeviceConfig: - LOGGER.debug('GetInitialConfig request: {:s}'.format(str(request))) + LOGGER.debug('GetInitialConfig request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.GetInitialConfig(request) - LOGGER.debug('GetInitialConfig result: {:s}'.format(str(response))) + LOGGER.debug('GetInitialConfig result: {:s}'.format(grpc_message_to_json_string(response))) return response @RETRY_DECORATOR def MonitorDeviceKpi(self, request : MonitoringSettings) -> Empty: - LOGGER.debug('MonitorDeviceKpi request: {:s}'.format(str(request))) + LOGGER.debug('MonitorDeviceKpi request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.MonitorDeviceKpi(request) - LOGGER.debug('MonitorDeviceKpi result: {:s}'.format(str(response))) + LOGGER.debug('MonitorDeviceKpi result: {:s}'.format(grpc_message_to_json_string(response))) return response diff --git a/src/device/requirements.in b/src/device/requirements.in index dde08cf195ecb503c7a10f75a2df9ca9f1a0c651..3bac91e712575d62a6a3809f56a663427a36e5c3 100644 --- a/src/device/requirements.in +++ b/src/device/requirements.in @@ -4,7 +4,7 @@ fastcache==1.1.0 grpcio==1.43.0 grpcio-health-checking==1.43.0 Jinja2==3.0.3 -netconf-client==2.0.0 #1.7.3 +ncclient==0.6.13 p4runtime==1.3.0 paramiko==2.9.2 prometheus-client==0.13.0 diff --git a/src/device/service/DeviceService.py b/src/device/service/DeviceService.py index bb2cc09535af579a24cf05687d2883d81c7c914b..4f9b032e8a224e89e48daebf52687cc892ca534a 100644 --- a/src/device/service/DeviceService.py +++ b/src/device/service/DeviceService.py @@ -12,76 +12,29 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc, logging -from concurrent import futures -from grpc_health.v1.health import HealthServicer, OVERALL_HEALTH -from grpc_health.v1.health_pb2 import HealthCheckResponse -from grpc_health.v1.health_pb2_grpc import add_HealthServicer_to_server +from common.Constants import ServiceNameEnum +from common.Settings import get_service_port_grpc from common.orm.backend.BackendEnum import BackendEnum from common.orm.Database import Database from common.orm.Factory import get_database_backend -from context.client.ContextClient import ContextClient -from device.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD +from common.tools.service.GenericGrpcService import GenericGrpcService from device.proto.device_pb2_grpc import add_DeviceServiceServicer_to_server -from monitoring.client.monitoring_client import MonitoringClient from .driver_api.DriverInstanceCache import DriverInstanceCache from .DeviceServiceServicerImpl import DeviceServiceServicerImpl from .MonitoringLoops import MonitoringLoops -BIND_ADDRESS = '0.0.0.0' -LOGGER = logging.getLogger(__name__) - -class DeviceService: - def __init__( - self, context_client : ContextClient, monitoring_client : MonitoringClient, - driver_instance_cache : DriverInstanceCache, - address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD): - - self.context_client = context_client - self.monitoring_client = monitoring_client - self.driver_instance_cache = driver_instance_cache - self.address = address - self.port = port - self.endpoint = None - self.max_workers = max_workers - self.grace_period = grace_period - self.device_servicer = None - self.health_servicer = None - self.pool = None - self.server = None - - self.database = Database(get_database_backend(backend=BackendEnum.INMEMORY)) - self.monitoring_loops = MonitoringLoops(monitoring_client, self.database) - - def start(self): - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) - LOGGER.info('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( - str(self.endpoint), str(self.max_workers))) +class DeviceService(GenericGrpcService): + def __init__(self, driver_instance_cache : DriverInstanceCache, cls_name: str = __name__) -> None: + port = get_service_port_grpc(ServiceNameEnum.DEVICE) + super().__init__(port, cls_name=cls_name) + database = Database(get_database_backend(backend=BackendEnum.INMEMORY)) + self.monitoring_loops = MonitoringLoops(database) + self.device_servicer = DeviceServiceServicerImpl(database, driver_instance_cache, self.monitoring_loops) + def install_servicers(self): self.monitoring_loops.start() - - self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) - self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) - - self.device_servicer = DeviceServiceServicerImpl( - self.context_client, self.database, self.driver_instance_cache, self.monitoring_loops) add_DeviceServiceServicer_to_server(self.device_servicer, self.server) - self.health_servicer = HealthServicer( - experimental_non_blocking=True, experimental_thread_pool=futures.ThreadPoolExecutor(max_workers=1)) - add_HealthServicer_to_server(self.health_servicer, self.server) - - port = self.server.add_insecure_port(self.endpoint) - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(port)) - LOGGER.info('Listening on {:s}...'.format(str(self.endpoint))) - self.server.start() - self.health_servicer.set(OVERALL_HEALTH, HealthCheckResponse.SERVING) # pylint: disable=maybe-no-member - - LOGGER.debug('Service started') - def stop(self): - LOGGER.debug('Stopping service (grace period {:s} seconds)...'.format(str(self.grace_period))) - self.health_servicer.enter_graceful_shutdown() - self.server.stop(self.grace_period) + super().stop() self.monitoring_loops.stop() - LOGGER.debug('Service stopped') diff --git a/src/device/service/DeviceServiceServicerImpl.py b/src/device/service/DeviceServiceServicerImpl.py index 8e00b344f0462ae56b289cfc5d33e6c1b1c42b7e..e328c76cdd29147163adc9713c86fc0efc31555d 100644 --- a/src/device/service/DeviceServiceServicerImpl.py +++ b/src/device/service/DeviceServiceServicerImpl.py @@ -49,11 +49,10 @@ METRICS = create_metrics(SERVICE_NAME, METHOD_NAMES) class DeviceServiceServicerImpl(DeviceServiceServicer): def __init__( - self, context_client : ContextClient, database : Database, driver_instance_cache : DriverInstanceCache, - monitoring_loops : MonitoringLoops): - + self, database : Database, driver_instance_cache : DriverInstanceCache, monitoring_loops : MonitoringLoops + ) -> None: LOGGER.debug('Creating Servicer...') - self.context_client = context_client + self.context_client = ContextClient() self.database = database self.driver_instance_cache = driver_instance_cache self.monitoring_loops = monitoring_loops diff --git a/src/device/service/MonitoringLoops.py b/src/device/service/MonitoringLoops.py index e5b671f7f06beade5ab9f8b6539527999d49b9e8..eff634c75537ed26fd77f02f6adb85f0b0555aa8 100644 --- a/src/device/service/MonitoringLoops.py +++ b/src/device/service/MonitoringLoops.py @@ -18,7 +18,7 @@ from typing import Dict from common.orm.Database import Database from common.orm.HighLevel import get_object from common.orm.backend.Tools import key_to_str -from monitoring.client.monitoring_client import MonitoringClient +from monitoring.client.MonitoringClient import MonitoringClient from monitoring.proto.monitoring_pb2 import Kpi from .database.KpiModel import KpiModel from .database.RelationModels import EndPointMonitorKpiModel @@ -55,8 +55,8 @@ class MonitoringLoop: self._collector_thread.join() class MonitoringLoops: - def __init__(self, monitoring_client : MonitoringClient, database : Database) -> None: - self._monitoring_client = monitoring_client + def __init__(self, database : Database) -> None: + self._monitoring_client = MonitoringClient() self._database = database self._samples_queue = queue.Queue() self._running = threading.Event() @@ -82,7 +82,6 @@ class MonitoringLoops: def start(self): self._exporter_thread.start() - self._running.set() @property def is_running(self): return self._running.is_set() @@ -96,6 +95,7 @@ class MonitoringLoops: LOGGER.error('[MonitoringLoops:_export] Database not set. Terminating Exporter.') return + self._running.set() while not self._terminate.is_set(): try: sample = self._samples_queue.get(block=True, timeout=QUEUE_GET_WAIT_TIMEOUT) @@ -149,3 +149,5 @@ class MonitoringLoops: })) except: # pylint: disable=bare-except LOGGER.exception('Unable to format/send Kpi') + + self._running.clear() diff --git a/src/device/service/__main__.py b/src/device/service/__main__.py index 0e92cabba4ddae84a9d4cd938c7e8b31ab4f0531..1f0adfa8f1dd8b3e307ed202967b1d5195171f11 100644 --- a/src/device/service/__main__.py +++ b/src/device/service/__main__.py @@ -14,12 +14,10 @@ import logging, signal, sys, threading from prometheus_client import start_http_server -from common.Settings import get_setting, wait_for_environment_variables -from context.client.ContextClient import ContextClient -from device.Config import ( - CONTEXT_SERVICE_HOST, CONTEXT_SERVICE_PORT, GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL, - METRICS_PORT, MONITORING_SERVICE_HOST, MONITORING_SERVICE_PORT) -from monitoring.client.monitoring_client import MonitoringClient +from common.Constants import ServiceNameEnum +from common.Settings import ( + ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_log_level, get_metrics_port, + wait_for_environment_variables) from .DeviceService import DeviceService from .driver_api.DriverFactory import DriverFactory from .driver_api.DriverInstanceCache import DriverInstanceCache @@ -35,12 +33,7 @@ def signal_handler(signal, frame): # pylint: disable=redefined-outer-name def main(): global LOGGER # pylint: disable=global-statement - grpc_service_port = get_setting('DEVICESERVICE_SERVICE_PORT_GRPC', default=GRPC_SERVICE_PORT ) - max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS ) - grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD ) - log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL ) - metrics_port = get_setting('METRICS_PORT', default=METRICS_PORT ) - + log_level = get_log_level() logging.basicConfig(level=log_level) logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING) logging.getLogger('apscheduler.scheduler').setLevel(logging.WARNING) @@ -48,43 +41,25 @@ def main(): LOGGER = logging.getLogger(__name__) wait_for_environment_variables([ - 'CONTEXTSERVICE_SERVICE_HOST', 'CONTEXTSERVICE_SERVICE_PORT_GRPC', - 'MONITORINGSERVICE_SERVICE_HOST', 'MONITORINGSERVICE_SERVICE_PORT_GRPC' + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST ), + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC), ]) - context_service_host = get_setting('CONTEXTSERVICE_SERVICE_HOST', default=CONTEXT_SERVICE_HOST ) - context_service_port = get_setting('CONTEXTSERVICE_SERVICE_PORT_GRPC', default=CONTEXT_SERVICE_PORT ) - monitoring_service_host = get_setting('MONITORINGSERVICE_SERVICE_HOST', default=MONITORING_SERVICE_HOST) - monitoring_service_port = get_setting('MONITORINGSERVICE_SERVICE_PORT_GRPC', default=MONITORING_SERVICE_PORT) - signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) LOGGER.info('Starting...') # Start metrics server + metrics_port = get_metrics_port() start_http_server(metrics_port) - # Initialize Context Client - if context_service_host is None or context_service_port is None: - raise Exception('Wrong address({:s}):port({:s}) of Context component'.format( - str(context_service_host), str(context_service_port))) - context_client = ContextClient(context_service_host, context_service_port) - - # Initialize Monitoring Client - if monitoring_service_host is None or monitoring_service_port is None: - raise Exception('Wrong address({:s}):port({:s}) of Monitoring component'.format( - str(monitoring_service_host), str(monitoring_service_port))) - monitoring_client = MonitoringClient(monitoring_service_host, monitoring_service_port) - # Initialize Driver framework driver_factory = DriverFactory(DRIVERS) driver_instance_cache = DriverInstanceCache(driver_factory) # Starting device service - grpc_service = DeviceService( - context_client, monitoring_client, driver_instance_cache, port=grpc_service_port, max_workers=max_workers, - grace_period=grace_period) + grpc_service = DeviceService(driver_instance_cache) grpc_service.start() # Wait for Ctrl+C or termination signal diff --git a/src/device/service/database/EndPointModel.py b/src/device/service/database/EndPointModel.py index 286a51db69738782a6d1acaed5b1d7846ac67b2b..84d0c97073481af162b1e66f7e35c93bc6e1eed5 100644 --- a/src/device/service/database/EndPointModel.py +++ b/src/device/service/database/EndPointModel.py @@ -15,6 +15,7 @@ import logging from typing import Dict, List from common.orm.Database import Database +from common.orm.HighLevel import update_or_create_object from common.orm.backend.Tools import key_to_str from common.orm.fields.EnumeratedField import EnumeratedField from common.orm.fields.ForeignKeyField import ForeignKeyField @@ -72,9 +73,14 @@ def set_endpoint_monitors(database : Database, db_endpoint : EndPointModel, grpc db_endpoint_pk = db_endpoint.pk for kpi_sample_type in grpc_endpoint_kpi_sample_types: orm_kpi_sample_type = grpc_to_enum__kpi_sample_type(kpi_sample_type) - str_endpoint_kpi_sample_type_key = key_to_str([db_endpoint_pk, orm_kpi_sample_type.name]) - db_endpoint_kpi_sample_type = EndPointMonitorModel(database, str_endpoint_kpi_sample_type_key) - db_endpoint_kpi_sample_type.endpoint_fk = db_endpoint - db_endpoint_kpi_sample_type.resource_key = '' # during initialization, allow empty value - db_endpoint_kpi_sample_type.kpi_sample_type = orm_kpi_sample_type - db_endpoint_kpi_sample_type.save() + str_endpoint_kpi_sample_type_key = key_to_str([db_endpoint_pk, str(orm_kpi_sample_type.value)]) + #db_endpoint_kpi_sample_type = EndPointMonitorModel(database, str_endpoint_kpi_sample_type_key) + #db_endpoint_kpi_sample_type.endpoint_fk = db_endpoint + #db_endpoint_kpi_sample_type.resource_key = '' # during initialization, allow empty value + #db_endpoint_kpi_sample_type.kpi_sample_type = orm_kpi_sample_type + #db_endpoint_kpi_sample_type.save() + update_or_create_object(database, EndPointMonitorModel, str_endpoint_kpi_sample_type_key, { + 'endpoint_fk' : db_endpoint, + #'resource_key' : '', # during initialization, allow empty value + 'kpi_sample_type': orm_kpi_sample_type, + }) diff --git a/src/device/service/driver_api/DriverFactory.py b/src/device/service/driver_api/DriverFactory.py index 1e79b4ba45593d3f24f7193648010071d766ec58..b2b6c467a9d7c941a430e7bc7aaa1ab123053750 100644 --- a/src/device/service/driver_api/DriverFactory.py +++ b/src/device/service/driver_api/DriverFactory.py @@ -76,6 +76,7 @@ class DriverFactory: field_candidate_driver_classes = field_candidate_driver_classes.union(field_indice_drivers) if candidate_driver_classes is None: + if len(field_candidate_driver_classes) == 0: continue candidate_driver_classes = {k:1 for k in field_candidate_driver_classes} else: for candidate_driver_class in candidate_driver_classes: diff --git a/src/device/service/driver_api/_Driver.py b/src/device/service/driver_api/_Driver.py index f30165a178a5946c414157da5d09df07bf060a39..7dbb9eddb238dcaae9d00b579a1851aacf53225d 100644 --- a/src/device/service/driver_api/_Driver.py +++ b/src/device/service/driver_api/_Driver.py @@ -21,6 +21,7 @@ RESOURCE_ENDPOINTS = '__endpoints__' RESOURCE_INTERFACES = '__interfaces__' RESOURCE_NETWORK_INSTANCES = '__network_instances__' RESOURCE_ROUTING_POLICIES = '__routing_policies__' +RESOURCE_ACL = '__acl__' class _Driver: def __init__(self, address : str, port : int, **settings) -> None: diff --git a/src/device/service/drivers/__init__.py b/src/device/service/drivers/__init__.py index 7479d43641b1ecd0803b3c790f51256a03e2c7fa..40912f50b98f1d5fc9555d87a4855a12ab8e0c07 100644 --- a/src/device/service/drivers/__init__.py +++ b/src/device/service/drivers/__init__.py @@ -18,10 +18,16 @@ from .emulated.EmulatedDriver import EmulatedDriver from .openconfig.OpenConfigDriver import OpenConfigDriver from .transport_api.TransportApiDriver import TransportApiDriver from .p4.p4_driver import P4Driver +from .microwave.IETFApiDriver import IETFApiDriver DRIVERS = [ (EmulatedDriver, [ { + # Driver==unspecified & no device type specified => use Emulated + FilterFieldEnum.DRIVER: ORM_DeviceDriverEnum.UNDEFINED, + }, + { + # Emulated OLS/Packet Router, specifying Undefined/OpenConfig/TAPI Driver => use EmulatedDriver FilterFieldEnum.DEVICE_TYPE: [ DeviceTypeEnum.EMULATED_OPTICAL_LINE_SYSTEM, DeviceTypeEnum.EMULATED_PACKET_ROUTER, @@ -35,20 +41,29 @@ DRIVERS = [ ]), (OpenConfigDriver, [ { + # Real Packet Router, specifying OpenConfig Driver => use OpenConfigDriver FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.PACKET_ROUTER, FilterFieldEnum.DRIVER : ORM_DeviceDriverEnum.OPENCONFIG, } ]), (TransportApiDriver, [ { + # Real OLS, specifying TAPI Driver => use TransportApiDriver FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.OPTICAL_LINE_SYSTEM, FilterFieldEnum.DRIVER : ORM_DeviceDriverEnum.TRANSPORT_API, } ]), (P4Driver, [ { + # Real P4 Switch, specifying P4 Driver => use P4Driver FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.P4_SWITCH, FilterFieldEnum.DRIVER : ORM_DeviceDriverEnum.P4, } ]), + (IETFApiDriver, [ + { + FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.MICROVAWE_RADIO_SYSTEM, + FilterFieldEnum.DRIVER : ORM_DeviceDriverEnum.IETF_NETWORK_TOPOLOGY, + } + ]), ] diff --git a/src/device/service/drivers/microwave/IETFApiDriver.py b/src/device/service/drivers/microwave/IETFApiDriver.py new file mode 100644 index 0000000000000000000000000000000000000000..4d5ec439f4085575fc0f7fddb228d30dab3010b5 --- /dev/null +++ b/src/device/service/drivers/microwave/IETFApiDriver.py @@ -0,0 +1,110 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging, requests, threading +from typing import Any, Iterator, List, Optional, Tuple, Union +from common.type_checkers.Checkers import chk_string, chk_type +from device.service.driver_api._Driver import _Driver +from . import ALL_RESOURCE_KEYS +from .Tools import create_connectivity_service, find_key, config_getter, delete_connectivity_service + +LOGGER = logging.getLogger(__name__) + +class IETFApiDriver(_Driver): + def __init__(self, address: str, port: int, **settings) -> None: # pylint: disable=super-init-not-called + self.__lock = threading.Lock() + self.__started = threading.Event() + self.__terminate = threading.Event() + self.__ietf_root = 'https://' + address + ':' + str(port) + self.__timeout = int(settings.get('timeout', 120)) + + def Connect(self) -> bool: + url = self.__ietf_root + '/nmswebs/restconf/data/ietf-network:networks' + with self.__lock: + if self.__started.is_set(): return True + try: + requests.get(url, timeout=self.__timeout, verify=False) + except requests.exceptions.Timeout: + LOGGER.exception('Timeout connecting {:s}'.format(str(self.__ietf_root))) + return False + except Exception: # pylint: disable=broad-except + LOGGER.exception('Exception connecting {:s}'.format(str(self.__ietf_root))) + return False + else: + self.__started.set() + return True + + def Disconnect(self) -> bool: + with self.__lock: + self.__terminate.set() + return True + + def GetInitialConfig(self) -> List[Tuple[str, Any]]: + with self.__lock: + return [] + + def GetConfig(self, resource_keys : List[str] = []) -> List[Tuple[str, Union[Any, None, Exception]]]: + chk_type('resources', resource_keys, list) + results = [] + with self.__lock: + if len(resource_keys) == 0: resource_keys = ALL_RESOURCE_KEYS + for i, resource_key in enumerate(resource_keys): + str_resource_name = 'resource_key[#{:d}]'.format(i) + chk_string(str_resource_name, resource_key, allow_empty=False) + results.extend(config_getter(self.__ietf_root, resource_key, self.__timeout)) + return results + + def SetConfig(self, resources: List[Tuple[str, Any]]) -> List[Union[bool, Exception]]: + results = [] + if len(resources) == 0: + return results + with self.__lock: + for resource in resources: + LOGGER.info('resource = {:s}'.format(str(resource))) + + node_id_src = find_key(resource, 'node_id_src') + tp_id_src = find_key(resource, 'tp_id_src') + node_id_dst = find_key(resource, 'node_id_dst') + tp_id_dst = find_key(resource, 'tp_id_dst') + vlan_id = find_key(resource, 'vlan_id') + uuid = find_key(resource, 'uuid') + + data = create_connectivity_service( + self.__ietf_root, self.__timeout, uuid, node_id_src, tp_id_src, node_id_dst, tp_id_dst, vlan_id) + results.extend(data) + return results + + def DeleteConfig(self, resources: List[Tuple[str, Any]]) -> List[Union[bool, Exception]]: + results = [] + if len(resources) == 0: return results + with self.__lock: + for resource in resources: + LOGGER.info('resource = {:s}'.format(str(resource))) + uuid = find_key(resource, 'uuid') + results.extend(delete_connectivity_service(self.__ietf_root, self.__timeout, uuid)) + return results + + def SubscribeState(self, subscriptions : List[Tuple[str, float, float]]) -> List[Union[bool, Exception]]: + # TODO: IETF API Driver does not support monitoring by now + return [False for _ in subscriptions] + + def UnsubscribeState(self, subscriptions : List[Tuple[str, float, float]]) -> List[Union[bool, Exception]]: + # TODO: IETF API Driver does not support monitoring by now + return [False for _ in subscriptions] + + def GetState( + self, blocking=False, terminate : Optional[threading.Event] = None + ) -> Iterator[Tuple[float, str, Any]]: + # TODO: IETF API Driver does not support monitoring by now + return [] diff --git a/src/device/service/drivers/microwave/Tools.py b/src/device/service/drivers/microwave/Tools.py new file mode 100644 index 0000000000000000000000000000000000000000..93498f72d4646e1837e934903b6b3e2da6e52259 --- /dev/null +++ b/src/device/service/drivers/microwave/Tools.py @@ -0,0 +1,151 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json, logging, requests +from device.service.driver_api._Driver import RESOURCE_ENDPOINTS + +LOGGER = logging.getLogger(__name__) + + +def find_key(resource, key): + return json.loads(resource[1])[key] + +# this function exports only the endpoints which are not already involved in a microwave physical link +def is_exportable_endpoint(node, termination_point_id, links): + # for each link we check if the endpoint (termination_point_id) is already used by an existing link + for link in links: + src = link['source'] + dest = link['destination'] + if dest['dest-node'] == node and dest['dest-tp'] == termination_point_id: + return False + if src['source-node'] == node and src['source-tp'] == termination_point_id: + return False + return True + +def config_getter(root_url, resource_key, timeout): + # getting endpoints + network_name = 'SIAE-ETH-TOPOLOGY' + FIELDS = ''.join([ + 'ietf-network-topology:', + 'link(link-id;destination(dest-node;dest-tp);source(source-node;source-tp));', + 'node(node-id;ietf-network-topology:termination-point(tp-id;ietf-te-topology:te/name)))', + ]) + URL_TEMPLATE = '{:s}/nmswebs/restconf/data/ietf-network:networks/network={:s}?fields={:s}' + url = URL_TEMPLATE.format(root_url, network_name, FIELDS) + + result = [] + try: + response = requests.get(url, timeout=timeout, verify=False) + except requests.exceptions.Timeout: + LOGGER.exception('Timeout connecting {:s}'.format(url)) + except Exception as e: # pylint: disable=broad-except + LOGGER.exception('Exception retrieving {:s}'.format(resource_key)) + result.append((resource_key, e)) + else: + context = json.loads(response.content) + if resource_key == RESOURCE_ENDPOINTS: + network_instance = context.get('ietf-network:network', {}) + links = network_instance.get('ietf-network-topology:link', []) + for sip in network_instance['node']: + tp = sip['ietf-network-topology:termination-point'] + node_id = sip['node-id'] + for te in tp: + tp_id = te['tp-id'] + if not is_exportable_endpoint(node_id, tp_id, links): continue + resource_key = '/endpoints/endpoint[{:s}:{:s}]'.format(node_id,tp_id) + resource_value = {'uuid': tp_id, 'type': te['ietf-te-topology:te']['name']} + result.append((resource_key, resource_value)) + + # getting created services + url = '{:s}/nmswebs/restconf/data/ietf-eth-tran-service:etht-svc'.format(root_url) + try: + response = requests.get(url, timeout=timeout, verify=False) + except requests.exceptions.Timeout: + LOGGER.exception('Timeout connecting {:s}'.format(url)) + except Exception as e: # pylint: disable=broad-except + LOGGER.exception('Exception retrieving {:s}'.format(resource_key)) + result.append((resource_key, e)) + else: + context = json.loads(response.content) + if resource_key == RESOURCE_ENDPOINTS: + etht_service = context.get('ietf-eth-tran-service:etht-svc', {}) + service_instances = etht_service.get('etht-svc-instances', []) + for service in service_instances: + service_name = service['etht-svc-name'] + resource_key = '/services/service[{:s}]'.format(service_name) + resource_value = {'uuid': service_name, 'type': service['etht-svc-type']} + result.append((resource_key, resource_value)) + return result + +def create_connectivity_service( + root_url, timeout, uuid, node_id_src, tp_id_src, node_id_dst, tp_id_dst, vlan_id): + + url = '{:s}/nmswebs/restconf/data/ietf-eth-tran-service:etht-svc'.format(root_url) + headers = {'content-type': 'application/json'} + data = { + 'etht-svc-instances': [ + { + 'etht-svc-name': uuid, + 'etht-svc-type': 'ietf-eth-tran-types:p2p-svc', + 'etht-svc-end-points': [ + { + 'etht-svc-access-points': [ + {'access-node-id': node_id_src, 'access-ltp-id': tp_id_src, 'access-point-id': '1'} + ], + 'outer-tag': {'vlan-value': vlan_id, 'tag-type': 'ietf-eth-tran-types:classify-c-vlan'}, + 'etht-svc-end-point-name': '{:s}:{:s}'.format(str(node_id_src), str(tp_id_src)), + 'service-classification-type': 'ietf-eth-tran-types:vlan-classification' + }, + { + 'etht-svc-access-points': [ + {'access-node-id': node_id_dst, 'access-ltp-id': tp_id_dst, 'access-point-id': '2'} + ], + 'outer-tag': {'vlan-value': vlan_id, 'tag-type': 'ietf-eth-tran-types:classify-c-vlan'}, + 'etht-svc-end-point-name': '{:s}:{:s}'.format(str(node_id_dst), str(tp_id_dst)), + 'service-classification-type': 'ietf-eth-tran-types:vlan-classification' + } + ] + } + ] + } + results = [] + try: + LOGGER.info('Connectivity service {:s}: {:s}'.format(str(uuid), str(data))) + response = requests.post(url=url, data=json.dumps(data), timeout=timeout, headers=headers, verify=False) + LOGGER.info('Microwave Driver response: {:s}'.format(str(response))) + except Exception as e: # pylint: disable=broad-except + LOGGER.exception('Exception creating ConnectivityService(uuid={:s}, data={:s})'.format(str(uuid), str(data))) + results.append(e) + else: + if response.status_code != 201: + msg = 'Could not create ConnectivityService(uuid={:s}, data={:s}). status_code={:s} reply={:s}' + LOGGER.error(msg.format(str(uuid), str(data), str(response.status_code), str(response))) + results.append(response.status_code == 201) + return results + +def delete_connectivity_service(root_url, timeout, uuid): + url = '{:s}/nmswebs/restconf/data/ietf-eth-tran-service:etht-svc/etht-svc-instances={:s}' + url = url.format(root_url, uuid) + results = [] + try: + response = requests.delete(url=url, timeout=timeout, verify=False) + except Exception as e: # pylint: disable=broad-except + LOGGER.exception('Exception deleting ConnectivityService(uuid={:s})'.format(str(uuid))) + results.append(e) + else: + if response.status_code != 201: + msg = 'Could not delete ConnectivityService(uuid={:s}). status_code={:s} reply={:s}' + LOGGER.error(msg.format(str(uuid), str(response.status_code), str(response))) + results.append(response.status_code == 202) + return results diff --git a/src/device/service/drivers/microwave/__init__.py b/src/device/service/drivers/microwave/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..925746998061f4e05c468133dfacaaa0414551c8 --- /dev/null +++ b/src/device/service/drivers/microwave/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from device.service.driver_api._Driver import RESOURCE_ENDPOINTS, RESOURCE_INTERFACES, RESOURCE_NETWORK_INSTANCES + +ALL_RESOURCE_KEYS = [ + RESOURCE_ENDPOINTS, + RESOURCE_INTERFACES, + RESOURCE_NETWORK_INSTANCES, +] + +RESOURCE_KEY_MAPPINGS = { + RESOURCE_ENDPOINTS : 'component', + RESOURCE_INTERFACES : 'interface', + RESOURCE_NETWORK_INSTANCES: 'network_instance', +} diff --git a/src/device/service/drivers/openconfig/OpenConfigDriver.py b/src/device/service/drivers/openconfig/OpenConfigDriver.py index 7f582c4880bafd08aee0204c7498ea3a3e7ad279..b282178989fa3f357a77fd6a1aa8fb6900fd430d 100644 --- a/src/device/service/drivers/openconfig/OpenConfigDriver.py +++ b/src/device/service/drivers/openconfig/OpenConfigDriver.py @@ -20,8 +20,7 @@ from apscheduler.executors.pool import ThreadPoolExecutor from apscheduler.job import Job from apscheduler.jobstores.memory import MemoryJobStore from apscheduler.schedulers.background import BackgroundScheduler -from netconf_client.connect import connect_ssh, Session -from netconf_client.ncclient import Manager +from ncclient.manager import Manager, connect_ssh from common.tools.client.RetryDecorator import delay_exponential from common.type_checkers.Checkers import chk_length, chk_string, chk_type, chk_float from device.service.driver_api.Exceptions import UnsupportedResourceKeyException @@ -31,8 +30,10 @@ from device.service.driver_api.AnyTreeTools import TreeNode, get_subnode, set_su from .templates import ALL_RESOURCE_KEYS, EMPTY_CONFIG, compose_config, get_filter, parse from .RetryDecorator import retry + DEBUG_MODE = False -#logging.getLogger('ncclient.transport.ssh').setLevel(logging.DEBUG if DEBUG_MODE else logging.WARNING) +logging.getLogger('ncclient.manager').setLevel(logging.DEBUG if DEBUG_MODE else logging.WARNING) +logging.getLogger('ncclient.transport.ssh').setLevel(logging.DEBUG if DEBUG_MODE else logging.WARNING) logging.getLogger('apscheduler.executors.default').setLevel(logging.INFO if DEBUG_MODE else logging.ERROR) logging.getLogger('apscheduler.scheduler').setLevel(logging.INFO if DEBUG_MODE else logging.ERROR) logging.getLogger('monitoring-client').setLevel(logging.INFO if DEBUG_MODE else logging.ERROR) @@ -59,29 +60,41 @@ class NetconfSessionHandler: self.__connected = threading.Event() self.__address = address self.__port = int(port) - self.__username = settings.get('username') - self.__password = settings.get('password') - self.__timeout = int(settings.get('timeout', 120)) - self.__netconf_session : Session = None - self.__netconf_manager : Manager = None + self.__username = settings.get('username') + self.__password = settings.get('password') + self.__key_filename = settings.get('key_filename') + self.__hostkey_verify = settings.get('hostkey_verify', True) + self.__look_for_keys = settings.get('look_for_keys', True) + self.__allow_agent = settings.get('allow_agent', True) + self.__force_running = settings.get('force_running', False) + self.__device_params = settings.get('device_params', {}) + self.__manager_params = settings.get('manager_params', {}) + self.__nc_params = settings.get('nc_params', {}) + self.__manager : Manager = None + self.__candidate_supported = False def connect(self): with self.__lock: - self.__netconf_session = connect_ssh( - host=self.__address, port=self.__port, username=self.__username, password=self.__password) - self.__netconf_manager = Manager(self.__netconf_session, timeout=self.__timeout) - self.__netconf_manager.set_logger_level(logging.DEBUG if DEBUG_MODE else logging.WARNING) + self.__manager = connect_ssh( + host=self.__address, port=self.__port, username=self.__username, password=self.__password, + device_params=self.__device_params, manager_params=self.__manager_params, nc_params=self.__nc_params, + key_filename=self.__key_filename, hostkey_verify=self.__hostkey_verify, allow_agent=self.__allow_agent, + look_for_keys=self.__look_for_keys) + self.__candidate_supported = ':candidate' in self.__manager.server_capabilities self.__connected.set() def disconnect(self): if not self.__connected.is_set(): return with self.__lock: - self.__netconf_manager.close_session() + self.__manager.close_session() + + @property + def use_candidate(self): return self.__candidate_supported and not self.__force_running @RETRY_DECORATOR def get(self, filter=None, with_defaults=None): # pylint: disable=redefined-builtin with self.__lock: - return self.__netconf_manager.get(filter=filter, with_defaults=with_defaults) + return self.__manager.get(filter=filter, with_defaults=with_defaults) @RETRY_DECORATOR def edit_config( @@ -90,10 +103,16 @@ class NetconfSessionHandler: ): if config == EMPTY_CONFIG: return with self.__lock: - self.__netconf_manager.edit_config( + self.__manager.edit_config( config, target=target, default_operation=default_operation, test_option=test_option, error_option=error_option, format=format) + def locked(self, target): + return self.__manager.locked(target=target) + + def commit(self, confirmed=False, timeout=None, persist=None, persist_id=None): + return self.__manager.commit(confirmed=confirmed, timeout=timeout, persist=persist, persist_id=persist_id) + def compute_delta_sample(previous_sample, previous_timestamp, current_sample, current_timestamp): if previous_sample is None: return None if previous_timestamp is None: return None @@ -162,6 +181,36 @@ def do_sampling(samples_cache : SamplesCache, resource_key : str, out_samples : except: # pylint: disable=bare-except LOGGER.exception('Error retrieving samples') +def edit_config( + netconf_handler : NetconfSessionHandler, resources : List[Tuple[str, Any]], delete=False, target='running', + default_operation='merge', test_option=None, error_option=None, format='xml' # pylint: disable=redefined-builtin +): + str_method = 'DeleteConfig' if delete else 'SetConfig' + LOGGER.info('[{:s}] resources = {:s}'.format(str_method, str(resources))) + results = [None for _ in resources] + for i,resource in enumerate(resources): + str_resource_name = 'resources[#{:d}]'.format(i) + try: + LOGGER.info('[{:s}] resource = {:s}'.format(str_method, str(resource))) + chk_type(str_resource_name, resource, (list, tuple)) + chk_length(str_resource_name, resource, min_length=2, max_length=2) + resource_key,resource_value = resource + chk_string(str_resource_name + '.key', resource_key, allow_empty=False) + str_config_message = compose_config(resource_key, resource_value, delete=delete) + if str_config_message is None: raise UnsupportedResourceKeyException(resource_key) + LOGGER.info('[{:s}] str_config_message[{:d}] = {:s}'.format( + str_method, len(str_config_message), str(str_config_message))) + netconf_handler.edit_config( + config=str_config_message, target=target, default_operation=default_operation, + test_option=test_option, error_option=error_option, format=format) + results[i] = True + except Exception as e: # pylint: disable=broad-except + str_operation = 'preparing' if target == 'candidate' else ('deleting' if delete else 'setting') + msg = '[{:s}] Exception {:s} {:s}: {:s}' + LOGGER.exception(msg.format(str_method, str_operation, str_resource_name, str(resource))) + results[i] = e # if validation fails, store the exception + return results + class OpenConfigDriver(_Driver): def __init__(self, address : str, port : int, **settings) -> None: # pylint: disable=super-init-not-called self.__lock = threading.Lock() @@ -227,51 +276,33 @@ class OpenConfigDriver(_Driver): def SetConfig(self, resources : List[Tuple[str, Any]]) -> List[Union[bool, Exception]]: chk_type('resources', resources, list) if len(resources) == 0: return [] - results = [] - LOGGER.info('[SetConfig] resources = {:s}'.format(str(resources))) with self.__lock: - for i,resource in enumerate(resources): - str_resource_name = 'resources[#{:d}]'.format(i) - try: - LOGGER.info('[SetConfig] resource = {:s}'.format(str(resource))) - chk_type(str_resource_name, resource, (list, tuple)) - chk_length(str_resource_name, resource, min_length=2, max_length=2) - resource_key,resource_value = resource - chk_string(str_resource_name + '.key', resource_key, allow_empty=False) - str_config_message = compose_config(resource_key, resource_value) - if str_config_message is None: raise UnsupportedResourceKeyException(resource_key) - LOGGER.info('[SetConfig] str_config_message[{:d}] = {:s}'.format( - len(str_config_message), str(str_config_message))) - self.__netconf_handler.edit_config(str_config_message, target='running') - results.append(True) - except Exception as e: # pylint: disable=broad-except - LOGGER.exception('Exception setting {:s}: {:s}'.format(str_resource_name, str(resource))) - results.append(e) # if validation fails, store the exception + if self.__netconf_handler.use_candidate: + with self.__netconf_handler.locked(target='candidate'): + results = edit_config(self.__netconf_handler, resources, target='candidate') + try: + self.__netconf_handler.commit() + except Exception as e: # pylint: disable=broad-except + LOGGER.exception('[SetConfig] Exception commiting resources: {:s}'.format(str(resources))) + results = [e for _ in resources] # if commit fails, set exception in each resource + else: + results = edit_config(self.__netconf_handler, resources) return results def DeleteConfig(self, resources : List[Tuple[str, Any]]) -> List[Union[bool, Exception]]: chk_type('resources', resources, list) if len(resources) == 0: return [] - results = [] - LOGGER.info('[DeleteConfig] resources = {:s}'.format(str(resources))) with self.__lock: - for i,resource in enumerate(resources): - str_resource_name = 'resources[#{:d}]'.format(i) - try: - LOGGER.info('[DeleteConfig] resource = {:s}'.format(str(resource))) - chk_type(str_resource_name, resource, (list, tuple)) - chk_length(str_resource_name, resource, min_length=2, max_length=2) - resource_key,resource_value = resource - chk_string(str_resource_name + '.key', resource_key, allow_empty=False) - str_config_message = compose_config(resource_key, resource_value, delete=True) - if str_config_message is None: raise UnsupportedResourceKeyException(resource_key) - LOGGER.info('[DeleteConfig] str_config_message[{:d}] = {:s}'.format( - len(str_config_message), str(str_config_message))) - self.__netconf_handler.edit_config(str_config_message, target='running') - results.append(True) - except Exception as e: # pylint: disable=broad-except - LOGGER.exception('Exception deleting {:s}: {:s}'.format(str_resource_name, str(resource_key))) - results.append(e) # if validation fails, store the exception + if self.__netconf_handler.use_candidate: + with self.__netconf_handler.locked(target='candidate'): + results = edit_config(self.__netconf_handler, resources, target='candidate', delete=True) + try: + self.__netconf_handler.commit() + except Exception as e: # pylint: disable=broad-except + LOGGER.exception('[DeleteConfig] Exception commiting resources: {:s}'.format(str(resources))) + results = [e for _ in resources] # if commit fails, set exception in each resource + else: + results = edit_config(self.__netconf_handler, resources, delete=True) return results def SubscribeState(self, subscriptions : List[Tuple[str, float, float]]) -> List[Union[bool, Exception]]: diff --git a/src/device/service/drivers/openconfig/templates/Acl.py b/src/device/service/drivers/openconfig/templates/Acl.py new file mode 100644 index 0000000000000000000000000000000000000000..6cd90f373427e2ab55550985929c4cfcd8798702 --- /dev/null +++ b/src/device/service/drivers/openconfig/templates/Acl.py @@ -0,0 +1,123 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging, lxml.etree as ET +from typing import Any, Dict, List, Tuple +from .Namespace import NAMESPACES +from .Tools import add_value_from_tag + +LOGGER = logging.getLogger(__name__) + +XPATH_ACL_SET = "//ocacl:acl/ocacl:acl-sets/ocacl:acl-set" +XPATH_A_ACL_ENTRY = ".//ocacl:acl-entries/ocacl:ecl-entry" +XPATH_A_IPv4 = ".//ocacl:ipv4/ocacl:config" +XPATH_A_TRANSPORT = ".//ocacl:transport/ocacl:config" +XPATH_A_ACTIONS = ".//ocacl:actions/ocacl:config" + +XPATH_INTERFACE = "//ocacl:acl/ocacl:interfaces/ocacl:interface" +XPATH_I_INGRESS = ".//ocacl:ingress-acl-sets/ocacl:ingress-acl-set" +XPATH_I_EGRESS = ".//ocacl:egress-acl-sets/ocacl:egress-acl-set" + +def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]: + #LOGGER.info('[ACL] xml_data = {:s}'.format(str(ET.tostring(xml_data)))) + + response = [] + acl = {} + + for xml_acl in xml_data.xpath(XPATH_ACL_SET, namespaces=NAMESPACES): + #LOGGER.info('xml_acl = {:s}'.format(str(ET.tostring(xml_acl)))) + + acl_name = xml_acl.find('ocacl:name', namespaces=NAMESPACES) + if acl_name is None or acl_name.text is None: continue + add_value_from_tag(acl, 'name', acl_name) + + acl_type = xml_acl.find('ocacl:type', namespaces=NAMESPACES) + add_value_from_tag(acl, 'type', acl_type) + + for xml_acl_entries in xml_acl.xpath(XPATH_A_ACL_ENTRY, namespaces=NAMESPACES): + + acl_id = xml_acl_entries.find('ocacl:sequence_id', namespaces=NAMESPACES) + add_value_from_tag(acl, 'sequence_id', acl_id) + + for xml_ipv4 in xml_acl_entries.xpath(XPATH_A_IPv4, namespaces=NAMESPACES): + + ipv4_source = xml_ipv4.find('ocacl:source_address', namespaces=NAMESPACES) + add_value_from_tag(acl, 'source_address' , ipv4_source) + + ipv4_destination = xml_ipv4.find('ocacl:destination_address', namespaces=NAMESPACES) + add_value_from_tag(acl, 'destination_address' , ipv4_destination) + + ipv4_protocol = xml_ipv4.find('ocacl:protocol', namespaces=NAMESPACES) + add_value_from_tag(acl, 'protocol' , ipv4_protocol) + + ipv4_dscp = xml_ipv4.find('ocacl:dscp', namespaces=NAMESPACES) + add_value_from_tag(acl, 'dscp' , ipv4_dscp) + + ipv4_hop_limit = xml_ipv4.find('ocacl:hop_limit', namespaces=NAMESPACES) + add_value_from_tag(acl, 'hop_limit' , ipv4_hop_limit) + + for xml_transport in xml_acl_entries.xpath(XPATH_A_TRANSPORT, namespaces=NAMESPACES): + + transport_source = xml_transport.find('ocacl:source_port', namespaces=NAMESPACES) + add_value_from_tag(acl, 'source_port' ,transport_source) + + transport_destination = xml_transport.find('ocacl:destination_port', namespaces=NAMESPACES) + add_value_from_tag(acl, 'destination_port' ,transport_destination) + + transport_tcp_flags = xml_transport.find('ocacl:tcp_flags', namespaces=NAMESPACES) + add_value_from_tag(acl, 'tcp_flags' ,transport_tcp_flags) + + for xml_action in xml_acl_entries.xpath(XPATH_A_ACTIONS, namespaces=NAMESPACES): + + action = xml_action.find('ocacl:forwarding_action', namespaces=NAMESPACES) + add_value_from_tag(acl, 'forwarding_action' ,action) + + log_action = xml_action.find('ocacl:log_action', namespaces=NAMESPACES) + add_value_from_tag(acl, 'log_action' ,log_action) + + resource_key = '/acl/acl-set[{:s}][{:s}]/acl-entry[{:s}]'.format( + acl['name'], acl['type'], acl['sequence-id']) + response.append((resource_key,acl)) + + for xml_interface in xml_data.xpath(XPATH_INTERFACE, namespaces=NAMESPACES): + + interface = {} + + interface_id = xml_interface.find('ocacl:id', namespaces=NAMESPACES) + add_value_from_tag(interface, 'id' , interface_id) + + for xml_ingress in xml_interface.xpath(XPATH_I_INGRESS, namespaces=NAMESPACES): + + i_name = xml_ingress.find('ocacl:set_name_ingress', namespaces=NAMESPACES) + add_value_from_tag(interface, 'ingress_set_name' , i_name) + + i_type = xml_ingress.find('ocacl:type_ingress', namespaces=NAMESPACES) + add_value_from_tag(interface, 'ingress_type' , i_type) + + resource_key = '/acl/interfaces/ingress[{:s}][{:s}]'.format( + acl['name'], acl['type']) + response.append((resource_key,interface)) + + for xml_egress in xml_interface.xpath(XPATH_I_EGRESS, namespaces=NAMESPACES): + + e_name = xml_egress.find('ocacl:set_name_egress', namespaces=NAMESPACES) + add_value_from_tag(interface, 'egress_set_name' , e_name) + + e_type = xml_egress.find('ocacl:type_egress', namespaces=NAMESPACES) + add_value_from_tag(interface, 'egress_type' , e_type) + + resource_key = '/acl/interfaces/egress[{:s}][{:s}]'.format( + acl['name'], acl['type']) + response.append((resource_key,interface)) + return response diff --git a/src/device/service/drivers/openconfig/templates/Namespace.py b/src/device/service/drivers/openconfig/templates/Namespace.py index 35be5827db892541847a3c02af42e2fd08ee0e1d..94af95566f33751a25fb1cb1c817cbffa910eec4 100644 --- a/src/device/service/drivers/openconfig/templates/Namespace.py +++ b/src/device/service/drivers/openconfig/templates/Namespace.py @@ -13,8 +13,9 @@ # limitations under the License. -NAMESPACE_NETCONF = 'urn:ietf:params:xml:ns:netconf:base:1.0' +NAMESPACE_NETCONF = 'urn:ietf:params:xml:ns:netconf:base:1.0' +NAMESPACE_ACL = 'http://openconfig.net/yang/acl' NAMESPACE_BGP_POLICY = 'http://openconfig.net/yang/bgp-policy' NAMESPACE_INTERFACES = 'http://openconfig.net/yang/interfaces' NAMESPACE_INTERFACES_IP = 'http://openconfig.net/yang/interfaces/ip' @@ -30,6 +31,7 @@ NAMESPACE_VLAN = 'http://openconfig.net/yang/vlan' NAMESPACES = { 'nc' : NAMESPACE_NETCONF, + 'ocacl': NAMESPACE_ACL, 'ocbp' : NAMESPACE_BGP_POLICY, 'oci' : NAMESPACE_INTERFACES, 'ociip': NAMESPACE_INTERFACES_IP, diff --git a/src/device/service/drivers/openconfig/templates/RoutingPolicy.py b/src/device/service/drivers/openconfig/templates/RoutingPolicy.py index aae8483706646801dccf6d3018eb9860209bf52b..369732de3fe58c52a2e9ab2227899160d091ff68 100644 --- a/src/device/service/drivers/openconfig/templates/RoutingPolicy.py +++ b/src/device/service/drivers/openconfig/templates/RoutingPolicy.py @@ -15,7 +15,7 @@ import copy, logging, lxml.etree as ET from typing import Any, Dict, List, Tuple from .Namespace import NAMESPACES -from .Tools import add_value_from_collection, add_value_from_tag +from .Tools import add_value_from_tag LOGGER = logging.getLogger(__name__) diff --git a/src/device/service/drivers/openconfig/templates/__init__.py b/src/device/service/drivers/openconfig/templates/__init__.py index eb7842ea8d5b62798f08429776700a792f69dc91..901f5cf0291dca1bda155e20abd16db5989df7dc 100644 --- a/src/device/service/drivers/openconfig/templates/__init__.py +++ b/src/device/service/drivers/openconfig/templates/__init__.py @@ -16,17 +16,19 @@ import json, logging, lxml.etree as ET, re from typing import Any, Dict from jinja2 import Environment, PackageLoader, select_autoescape from device.service.driver_api._Driver import ( - RESOURCE_ENDPOINTS, RESOURCE_INTERFACES, RESOURCE_NETWORK_INSTANCES, RESOURCE_ROUTING_POLICIES) + RESOURCE_ENDPOINTS, RESOURCE_INTERFACES, RESOURCE_NETWORK_INSTANCES, RESOURCE_ROUTING_POLICIES, RESOURCE_ACL) from .EndPoints import parse as parse_endpoints from .Interfaces import parse as parse_interfaces, parse_counters from .NetworkInstances import parse as parse_network_instances from .RoutingPolicy import parse as parse_routing_policy +from .Acl import parse as parse_acl ALL_RESOURCE_KEYS = [ RESOURCE_ENDPOINTS, RESOURCE_INTERFACES, RESOURCE_ROUTING_POLICIES, # routing policies should come before network instances RESOURCE_NETWORK_INSTANCES, + RESOURCE_ACL, ] RESOURCE_KEY_MAPPINGS = { @@ -34,6 +36,7 @@ RESOURCE_KEY_MAPPINGS = { RESOURCE_INTERFACES : 'interface', RESOURCE_NETWORK_INSTANCES: 'network_instance', RESOURCE_ROUTING_POLICIES : 'routing_policy', + RESOURCE_ACL : 'acl', } RESOURCE_PARSERS = { @@ -42,6 +45,7 @@ RESOURCE_PARSERS = { 'network_instance': parse_network_instances, 'routing_policy' : parse_routing_policy, 'interfaces/interface/state/counters': parse_counters, + 'acl' : parse_acl, } LOGGER = logging.getLogger(__name__) diff --git a/src/device/service/drivers/openconfig/templates/acl/acl-set/acl-entry/edit_config.xml b/src/device/service/drivers/openconfig/templates/acl/acl-set/acl-entry/edit_config.xml new file mode 100644 index 0000000000000000000000000000000000000000..fac259b6fdcd3cbded93088ddc6335ea2bfe5f69 --- /dev/null +++ b/src/device/service/drivers/openconfig/templates/acl/acl-set/acl-entry/edit_config.xml @@ -0,0 +1,42 @@ +<acl xmlns="http://openconfig.net/yang/acl"> + <acl-sets> + <acl-set{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}> + <name>{{name}}</name> + <type>{{type}}</type> + <config> + <name>{{name}}</name> + <type>{{type}}</type> + </config> + <acl-entries> + <acl-entry> + <sequence-id>{{sequence_id}}</sequence-id> + <config> + <sequence-id>{{sequence_id}}</sequence-id> + </config> + <ipv4> + <config> + {% if source_address is defined %}<source-address>{{source_address}}</source-address>{% endif%} + {% if destination_address is defined %}<destination-address>{{destination_address}}</destination-address>{% endif%} + {% if protocol is defined %}<protocol>{{protocol}}</protocol>{% endif%} + {% if dscp is defined %}<dscp>{{dscp}}</dscp>{% endif%} + {% if hop_limit is defined %}<hop-limit>{{hop_limit}}</hop-limit>{% endif%} + </config> + </ipv4> + <transport> + <config> + {% if source_port is defined %}<source-port>{{source_port}}</source-port>{% endif%} + {% if destination_port is defined %}<destination-port>{{destination_port}}</destination-port>{% endif%} + {% if tcp_flags is defined %}<tcp-flags>{{tcp_flags}}</tcp-flags>{% endif%} + </config> + </transport> + <actions> + <config> + {% if forwarding_action is defined %}<forwarding-action>{{forwarding_action}}</forwarding-action>{% endif%} + {% if log_action is defined %}<log-action>{{log_action}}</log-action>{% endif%} + </config> + </actions> + </acl-entry> + </acl-entries> + </acl-set> + </acl-sets> +</acl> diff --git a/src/device/service/drivers/openconfig/templates/acl/get.xml b/src/device/service/drivers/openconfig/templates/acl/get.xml new file mode 100644 index 0000000000000000000000000000000000000000..dfed162427d03953890ecf1f90352cc26a76cbc9 --- /dev/null +++ b/src/device/service/drivers/openconfig/templates/acl/get.xml @@ -0,0 +1,7 @@ +<acl xmlns="http://openconfig.net/yang/acl"> + <acl-sets> + </acl-sets> + <interfaces> + </interfaces> +</acl> + \ No newline at end of file diff --git a/src/device/service/drivers/openconfig/templates/acl/interfaces/egress/edit_config.xml b/src/device/service/drivers/openconfig/templates/acl/interfaces/egress/edit_config.xml new file mode 100644 index 0000000000000000000000000000000000000000..d987b0cc4b40298533f140f71af83c6fad884020 --- /dev/null +++ b/src/device/service/drivers/openconfig/templates/acl/interfaces/egress/edit_config.xml @@ -0,0 +1,26 @@ +<acl xmlns="http://openconfig.net/yang/acl"> + <interfaces> + <interface{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}> + <id>{{id}}</id> + <config> + <id>{{id}}</id> + </config> + <interface-ref> + <config> + <interface>{{interface}}</interface> + {% if subinterface is defined %}<subinterface>{{subinterface}}</subinterface>{% endif%} + </config> + </interface-ref> + <egress-acl-sets> + <egress-acl-set> + <set-name>{{set_name_egress}}</set-name> + <type>{{type_egress}}</type> + <config> + <set-name>{{set_name_egress}}</set-name> + <type>{{type_egress}}</type> + </config> + </egress-acl-set> + </egress-acl-sets> + </interface> + </interfaces> +</acl> diff --git a/src/device/service/drivers/openconfig/templates/acl/interfaces/ingress/edit_config.xml b/src/device/service/drivers/openconfig/templates/acl/interfaces/ingress/edit_config.xml new file mode 100644 index 0000000000000000000000000000000000000000..144a03c55477e532379541be5443063fe3aa2f10 --- /dev/null +++ b/src/device/service/drivers/openconfig/templates/acl/interfaces/ingress/edit_config.xml @@ -0,0 +1,26 @@ +<acl xmlns="http://openconfig.net/yang/acl"> + <interfaces> + <interface{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}> + <id>{{id}}</id> + <config> + <id>{{id}}</id> + </config> + <interface-ref> + <config> + <interface>{{interface}}</interface> + {% if subinterface is defined %}<subinterface>{{subinterface}}</subinterface>{% endif%} + </config> + </interface-ref> + <ingress-acl-sets> + <ingress-acl-set> + <set-name>{{set_name_ingress}}</set-name> + <type>{{type_ingress}}</type> + <config> + <set-name>{{set_name_ingress}}</set-name> + <type>{{type_ingress}}</type> + </config> + </ingress-acl-set> + </ingress-acl-sets> + </interface> + </interfaces> +</acl> diff --git a/src/device/tests/.gitignore b/src/device/tests/.gitignore index b5f6bc13b7b17daa79d9e67c5fc0c50338d089a1..4cbf5059c2f905c16aac6234e2b9ca0ac7584c09 100644 --- a/src/device/tests/.gitignore +++ b/src/device/tests/.gitignore @@ -1,3 +1,5 @@ # Add here your files containing confidential testbed details such as IP addresses, ports, usernames, passwords, etc. +Device_OpenConfig_Adva* +Device_OpenConfig_Cisco* Device_OpenConfig_Infinera* Device_Transport_Api* diff --git a/src/device/tests/Device_Microwave_Template.py b/src/device/tests/Device_Microwave_Template.py new file mode 100644 index 0000000000000000000000000000000000000000..710d28becad9c0bb50b639f3c5d0ef8fa1abe145 --- /dev/null +++ b/src/device/tests/Device_Microwave_Template.py @@ -0,0 +1,46 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from common.tools.object_factory.ConfigRule import json_config_rule_delete, json_config_rule_set +from common.tools.object_factory.Device import ( + json_device_connect_rules, json_device_id, json_device_microwave_disabled) + +DEVICE_MICROWAVE_UUID = 'DEVICE-MICROWAVE' # populate 'device-uuid' of the MICROWAVE SMDC server +DEVICE_MICROWAVE_ADDRESS = '127.0.0.1' # populate 'address' of the MICROWAVE SMDC server +DEVICE_MICROWAVE_PORT = 8443 # populate 'port' of the MICROWAVE SMDC server +DEVICE_MICROWAVE_TIMEOUT = 120 # populate 'timeout' of the MICROWAVE SMDC server + +DEVICE_MICROWAVE_ID = json_device_id(DEVICE_MICROWAVE_UUID) +DEVICE_MICROWAVE = json_device_microwave_disabled(DEVICE_MICROWAVE_UUID) + +DEVICE_MICROWAVE_CONNECT_RULES = json_device_connect_rules(DEVICE_MICROWAVE_ADDRESS, DEVICE_MICROWAVE_PORT, { + 'timeout' : DEVICE_MICROWAVE_TIMEOUT, +}) + +DEVICE_MICROWAVE_CONFIG_RULES = [ + json_config_rule_set('/services/service[service_uuid]', { + 'uuid' : 'service-uuid', # populate 'service_name of the service to test + 'node_id_src': '172.26.60.243', # populate 'node_id_src' of the service to test + 'tp_id_src' : 9, # populate 'tp_id_src' of the service to test + 'node_id_dst': '172.26.60.244', # populate 'node_id_dst' of the service to test + 'tp_id_dst' : 9, # populate 'tp_id_dst' of the service to test + 'vlan_id' : 121, # populate 'vlan_id' of the service to test + }) +] + +DEVICE_MICROWAVE_DECONFIG_RULES = [ + json_config_rule_delete('/services/service[service-uuid]', { + 'uuid': 'service-uuid' # populate 'service_name' of the service to test + }) +] diff --git a/src/device/tests/Device_OpenConfig_Template.py b/src/device/tests/Device_OpenConfig_Template.py index df588b3d8a65883e0ebbfeacb222648bda0455ed..6afa2721ff920c39de243b308b9b9a4749cb013b 100644 --- a/src/device/tests/Device_OpenConfig_Template.py +++ b/src/device/tests/Device_OpenConfig_Template.py @@ -20,15 +20,20 @@ DEVICE_OC_ADDRESS = '127.0.0.1' # populate the Netconf Server IP address of th DEVICE_OC_PORT = 830 # populate the Netconf Server port of the device to test DEVICE_OC_USERNAME = 'username' # populate the Netconf Server username of the device to test DEVICE_OC_PASSWORD = 'password' # populate the Netconf Server password of the device to test -DEVICE_OC_TIMEOUT = 120 +DEVICE_OC_TIMEOUT = 15 DEVICE_OC_ID = json_device_id(DEVICE_OC_UUID) DEVICE_OC = json_device_packetrouter_disabled(DEVICE_OC_UUID) DEVICE_OC_CONNECT_RULES = json_device_connect_rules(DEVICE_OC_ADDRESS, DEVICE_OC_PORT, { - 'username': DEVICE_OC_USERNAME, - 'password': DEVICE_OC_PASSWORD, - 'timeout' : DEVICE_OC_TIMEOUT, + 'username' : DEVICE_OC_USERNAME, + 'password' : DEVICE_OC_PASSWORD, + 'force_running' : False, + 'hostkey_verify' : True, + 'look_for_keys' : True, + 'allow_agent' : True, + 'device_params' : {'name': 'default'}, + 'manager_params' : {'timeout' : DEVICE_OC_TIMEOUT}, }) DEVICE_OC_CONFIG_RULES = [] # populate your configuration rules to test diff --git a/src/device/tests/MockMonitoringService.py b/src/device/tests/MockMonitoringService.py deleted file mode 100644 index 3e8550058daa905517f26a659a08c66db1172d74..0000000000000000000000000000000000000000 --- a/src/device/tests/MockMonitoringService.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import grpc, logging -from concurrent import futures -from queue import Queue -from monitoring.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD -from monitoring.proto.monitoring_pb2_grpc import add_MonitoringServiceServicer_to_server -from .MockMonitoringServiceServicerImpl import MockMonitoringServiceServicerImpl - -BIND_ADDRESS = '0.0.0.0' -LOGGER = logging.getLogger(__name__) - -class MockMonitoringService: - def __init__( - self, address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, - grace_period=GRPC_GRACE_PERIOD): - - self.queue_samples = Queue() - self.address = address - self.port = port - self.endpoint = None - self.max_workers = max_workers - self.grace_period = grace_period - self.monitoring_servicer = None - self.pool = None - self.server = None - - def start(self): - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) - LOGGER.info('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( - str(self.endpoint), str(self.max_workers))) - - self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) - self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) - - self.monitoring_servicer = MockMonitoringServiceServicerImpl(self.queue_samples) - add_MonitoringServiceServicer_to_server(self.monitoring_servicer, self.server) - - port = self.server.add_insecure_port(self.endpoint) - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(port)) - LOGGER.info('Listening on {:s}...'.format(str(self.endpoint))) - self.server.start() - - LOGGER.debug('Service started') - - def stop(self): - LOGGER.debug('Stopping service (grace period {:s} seconds)...'.format(str(self.grace_period))) - self.server.stop(self.grace_period) - LOGGER.debug('Service stopped') diff --git a/src/device/tests/MockService_Dependencies.py b/src/device/tests/MockService_Dependencies.py new file mode 100644 index 0000000000000000000000000000000000000000..6b2a7788fa3fa242edb9cc7c4b10e22244d7c99a --- /dev/null +++ b/src/device/tests/MockService_Dependencies.py @@ -0,0 +1,50 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os, queue +from typing import Union +from common.Constants import ServiceNameEnum +from common.Settings import ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name +from common.tests.MockServicerImpl_Context import MockServicerImpl_Context +from common.tests.MockServicerImpl_Monitoring import MockServicerImpl_Monitoring +from common.tools.service.GenericGrpcService import GenericGrpcService +from context.proto.context_pb2_grpc import add_ContextServiceServicer_to_server +from monitoring.proto.monitoring_pb2_grpc import add_MonitoringServiceServicer_to_server + +LOCAL_HOST = '127.0.0.1' + +SERVICE_CONTEXT = ServiceNameEnum.CONTEXT +SERVICE_MONITORING = ServiceNameEnum.MONITORING + +class MockService_Dependencies(GenericGrpcService): + # Mock Service implementing Context and Monitoring to simplify unitary tests of Device + + def __init__(self, bind_port: Union[str, int]) -> None: + super().__init__(bind_port, LOCAL_HOST, enable_health_servicer=False, cls_name='MockService') + + # pylint: disable=attribute-defined-outside-init + def install_servicers(self): + self.context_servicer = MockServicerImpl_Context() + add_ContextServiceServicer_to_server(self.context_servicer, self.server) + + self.queue_samples = queue.Queue() + self.monitoring_servicer = MockServicerImpl_Monitoring(queue_samples=self.queue_samples) + add_MonitoringServiceServicer_to_server(self.monitoring_servicer, self.server) + + def configure_env_vars(self): + os.environ[get_env_var_name(SERVICE_CONTEXT, ENVVAR_SUFIX_SERVICE_HOST )] = str(self.bind_address) + os.environ[get_env_var_name(SERVICE_CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(self.bind_port) + + os.environ[get_env_var_name(SERVICE_MONITORING, ENVVAR_SUFIX_SERVICE_HOST )] = str(self.bind_address) + os.environ[get_env_var_name(SERVICE_MONITORING, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(self.bind_port) diff --git a/src/device/tests/PrepareTestScenario.py b/src/device/tests/PrepareTestScenario.py new file mode 100644 index 0000000000000000000000000000000000000000..08991221a3f5121c587ecfd4644a6b28156ccefd --- /dev/null +++ b/src/device/tests/PrepareTestScenario.py @@ -0,0 +1,80 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest, os +from common.Constants import ServiceNameEnum +from common.Settings import ( + ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_service_port_grpc) +from context.client.ContextClient import ContextClient +from context.proto.context_pb2 import Context, Topology +from device.client.DeviceClient import DeviceClient +from device.service.DeviceService import DeviceService +from device.service.driver_api.DriverFactory import DriverFactory +from device.service.driver_api.DriverInstanceCache import DriverInstanceCache +from device.service.drivers import DRIVERS +from device.tests.CommonObjects import CONTEXT, TOPOLOGY +from device.tests.MockService_Dependencies import MockService_Dependencies +from monitoring.client.MonitoringClient import MonitoringClient + +LOCAL_HOST = '127.0.0.1' +MOCKSERVICE_PORT = 10000 +DEVICE_SERVICE_PORT = MOCKSERVICE_PORT + get_service_port_grpc(ServiceNameEnum.DEVICE) # avoid privileged ports +os.environ[get_env_var_name(ServiceNameEnum.DEVICE, ENVVAR_SUFIX_SERVICE_HOST )] = str(LOCAL_HOST) +os.environ[get_env_var_name(ServiceNameEnum.DEVICE, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(DEVICE_SERVICE_PORT) + +@pytest.fixture(scope='session') +def mock_service(): + _service = MockService_Dependencies(MOCKSERVICE_PORT) + _service.configure_env_vars() + _service.start() + yield _service + _service.stop() + +@pytest.fixture(scope='session') +def context_client(mock_service : MockService_Dependencies): # pylint: disable=redefined-outer-name + _client = ContextClient() + yield _client + _client.close() + +@pytest.fixture(scope='session') +def monitoring_client(mock_service : MockService_Dependencies): # pylint: disable=redefined-outer-name + _client = MonitoringClient() + yield _client + _client.close() + +@pytest.fixture(scope='session') +def device_service( + context_client : ContextClient, # pylint: disable=redefined-outer-name + monitoring_client : MonitoringClient): # pylint: disable=redefined-outer-name + + _driver_factory = DriverFactory(DRIVERS) + _driver_instance_cache = DriverInstanceCache(_driver_factory) + _service = DeviceService(_driver_instance_cache) + _service.start() + yield _service + _service.stop() + +@pytest.fixture(scope='session') +def device_client(device_service : DeviceService): # pylint: disable=redefined-outer-name + _client = DeviceClient() + yield _client + _client.close() + +def test_prepare_environment( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService): # pylint: disable=redefined-outer-name + + context_client.SetContext(Context(**CONTEXT)) + context_client.SetTopology(Topology(**TOPOLOGY)) diff --git a/src/device/tests/test_unitary.py b/src/device/tests/test_unitary.py deleted file mode 100644 index 411cbba05957425687b0b03e3e868febe82a944d..0000000000000000000000000000000000000000 --- a/src/device/tests/test_unitary.py +++ /dev/null @@ -1,1007 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import calendar, copy, dateutil.parser, grpc, json, logging, operator, os, pytest, queue, time -from datetime import datetime, timezone -from typing import Tuple -from common.orm.Database import Database -from common.orm.Factory import get_database_backend, BackendEnum as DatabaseBackendEnum -from common.message_broker.Factory import get_messagebroker_backend, BackendEnum as MessageBrokerBackendEnum -from common.message_broker.MessageBroker import MessageBroker -from common.tools.grpc.Tools import grpc_message_to_json_string -from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_id -from context.Config import ( - GRPC_SERVICE_PORT as CONTEXT_GRPC_SERVICE_PORT, GRPC_MAX_WORKERS as CONTEXT_GRPC_MAX_WORKERS, - GRPC_GRACE_PERIOD as CONTEXT_GRPC_GRACE_PERIOD) -from context.client.ContextClient import ContextClient -from context.proto.context_pb2 import DeviceId, DeviceOperationalStatusEnum -from context.service.grpc_server.ContextService import ContextService -from device.Config import ( - GRPC_SERVICE_PORT as DEVICE_GRPC_SERVICE_PORT, GRPC_MAX_WORKERS as DEVICE_GRPC_MAX_WORKERS, - GRPC_GRACE_PERIOD as DEVICE_GRPC_GRACE_PERIOD) -from device.client.DeviceClient import DeviceClient -from device.proto.context_pb2 import ConfigActionEnum, Context, Device, Topology -from device.proto.device_pb2 import MonitoringSettings -from device.proto.kpi_sample_types_pb2 import KpiSampleType -from device.service.DeviceService import DeviceService -from device.service.driver_api._Driver import _Driver -from device.service.driver_api.DriverFactory import DriverFactory -from device.service.driver_api.DriverInstanceCache import DriverInstanceCache -from device.service.drivers import DRIVERS -from device.tests.MockMonitoringService import MockMonitoringService -from monitoring.Config import ( - GRPC_SERVICE_PORT as MONITORING_GRPC_SERVICE_PORT, GRPC_MAX_WORKERS as MONITORING_GRPC_MAX_WORKERS, - GRPC_GRACE_PERIOD as MONITORING_GRPC_GRACE_PERIOD) -from monitoring.client.monitoring_client import MonitoringClient -from .CommonObjects import CONTEXT, TOPOLOGY - -from .Device_Emulated import ( - DEVICE_EMU, DEVICE_EMU_CONFIG_ADDRESSES, DEVICE_EMU_CONFIG_ENDPOINTS, DEVICE_EMU_CONNECT_RULES, - DEVICE_EMU_DECONFIG_ADDRESSES, DEVICE_EMU_DECONFIG_ENDPOINTS, DEVICE_EMU_EP_DESCS, DEVICE_EMU_ENDPOINTS_COOKED, - DEVICE_EMU_ID, DEVICE_EMU_RECONFIG_ADDRESSES, DEVICE_EMU_UUID) -ENABLE_EMULATED = True - -try: - from .Device_OpenConfig_Infinera1 import( - #from .Device_OpenConfig_Infinera2 import( - DEVICE_OC, DEVICE_OC_CONFIG_RULES, DEVICE_OC_DECONFIG_RULES, DEVICE_OC_CONNECT_RULES, DEVICE_OC_ID, - DEVICE_OC_UUID) - ENABLE_OPENCONFIG = True -except ImportError: - ENABLE_OPENCONFIG = False - -try: - from .Device_Transport_Api_CTTC import ( - DEVICE_TAPI, DEVICE_TAPI_CONNECT_RULES, DEVICE_TAPI_UUID, DEVICE_TAPI_ID, DEVICE_TAPI_CONFIG_RULES, - DEVICE_TAPI_DECONFIG_RULES) - ENABLE_TAPI = True -except ImportError: - ENABLE_TAPI = False - -from .mock_p4runtime_service import MockP4RuntimeService -try: - from .device_p4 import( - DEVICE_P4, DEVICE_P4_ID, DEVICE_P4_UUID, DEVICE_P4_NAME, DEVICE_P4_ADDRESS, DEVICE_P4_PORT, DEVICE_P4_WORKERS, - DEVICE_P4_GRACE_PERIOD, DEVICE_P4_CONNECT_RULES, DEVICE_P4_CONFIG_RULES) - ENABLE_P4 = True -except ImportError: - ENABLE_P4 = False - -#ENABLE_EMULATED = False # set to False to disable tests of Emulated devices -#ENABLE_OPENCONFIG = False # set to False to disable tests of OpenConfig devices -#ENABLE_TAPI = False # set to False to disable tests of TAPI devices -#ENABLE_P4 = False # set to False to disable tests of P4 devices - -ENABLE_OPENCONFIG_CONFIGURE = True -ENABLE_OPENCONFIG_MONITOR = True -ENABLE_OPENCONFIG_DECONFIGURE = True - - -logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING) -logging.getLogger('apscheduler.scheduler').setLevel(logging.WARNING) -logging.getLogger('monitoring-client').setLevel(logging.WARNING) - -LOGGER = logging.getLogger(__name__) -LOGGER.setLevel(logging.DEBUG) - -CONTEXT_GRPC_SERVICE_PORT = 10000 + CONTEXT_GRPC_SERVICE_PORT # avoid privileged ports -DEVICE_GRPC_SERVICE_PORT = 10000 + DEVICE_GRPC_SERVICE_PORT # avoid privileged ports -MONITORING_GRPC_SERVICE_PORT = 10000 + MONITORING_GRPC_SERVICE_PORT # avoid privileged ports - -DEFAULT_REDIS_SERVICE_HOST = '127.0.0.1' -DEFAULT_REDIS_SERVICE_PORT = 6379 -DEFAULT_REDIS_DATABASE_ID = 0 - -REDIS_CONFIG = { - 'REDIS_SERVICE_HOST': os.environ.get('REDIS_SERVICE_HOST', DEFAULT_REDIS_SERVICE_HOST), - 'REDIS_SERVICE_PORT': os.environ.get('REDIS_SERVICE_PORT', DEFAULT_REDIS_SERVICE_PORT), - 'REDIS_DATABASE_ID' : os.environ.get('REDIS_DATABASE_ID', DEFAULT_REDIS_DATABASE_ID ), -} - -SCENARIOS = [ - ('all_inmemory', DatabaseBackendEnum.INMEMORY, {}, MessageBrokerBackendEnum.INMEMORY, {} ), - #('all_redis', DatabaseBackendEnum.REDIS, REDIS_CONFIG, MessageBrokerBackendEnum.REDIS, REDIS_CONFIG), -] - -@pytest.fixture(scope='session', ids=[str(scenario[0]) for scenario in SCENARIOS], params=SCENARIOS) -def context_db_mb(request) -> Tuple[Database, MessageBroker]: - name,db_backend,db_settings,mb_backend,mb_settings = request.param - msg = 'Running scenario {:s} db_backend={:s}, db_settings={:s}, mb_backend={:s}, mb_settings={:s}...' - LOGGER.info(msg.format(str(name), str(db_backend.value), str(db_settings), str(mb_backend.value), str(mb_settings))) - _database = Database(get_database_backend(backend=db_backend, **db_settings)) - _message_broker = MessageBroker(get_messagebroker_backend(backend=mb_backend, **mb_settings)) - yield _database, _message_broker - _message_broker.terminate() - -@pytest.fixture(scope='session') -def context_service(context_db_mb : Tuple[Database, MessageBroker]): # pylint: disable=redefined-outer-name - _service = ContextService( - context_db_mb[0], context_db_mb[1], port=CONTEXT_GRPC_SERVICE_PORT, max_workers=CONTEXT_GRPC_MAX_WORKERS, - grace_period=CONTEXT_GRPC_GRACE_PERIOD) - _service.start() - yield _service - _service.stop() - -@pytest.fixture(scope='session') -def context_client(context_service : ContextService): # pylint: disable=redefined-outer-name - _client = ContextClient(address='127.0.0.1', port=CONTEXT_GRPC_SERVICE_PORT) - yield _client - _client.close() - -@pytest.fixture(scope='session') -def monitoring_service(): - _service = MockMonitoringService(port=MONITORING_GRPC_SERVICE_PORT, max_workers=MONITORING_GRPC_MAX_WORKERS, - grace_period=MONITORING_GRPC_GRACE_PERIOD) - _service.start() - yield _service - _service.stop() - -@pytest.fixture(scope='session') -def monitoring_client(monitoring_service : MockMonitoringService): # pylint: disable=redefined-outer-name - _client = MonitoringClient(server='127.0.0.1', port=MONITORING_GRPC_SERVICE_PORT) - #yield _client - #_client.close() - return _client - -@pytest.fixture(scope='session') -def device_service( - context_client : ContextClient, # pylint: disable=redefined-outer-name - monitoring_client : MonitoringClient): # pylint: disable=redefined-outer-name - - _driver_factory = DriverFactory(DRIVERS) - _driver_instance_cache = DriverInstanceCache(_driver_factory) - _service = DeviceService( - context_client, monitoring_client, _driver_instance_cache, port=DEVICE_GRPC_SERVICE_PORT, - max_workers=DEVICE_GRPC_MAX_WORKERS, grace_period=DEVICE_GRPC_GRACE_PERIOD) - _service.start() - yield _service - _service.stop() - -@pytest.fixture(scope='session') -def device_client(device_service : DeviceService): # pylint: disable=redefined-outer-name - _client = DeviceClient(address='127.0.0.1', port=DEVICE_GRPC_SERVICE_PORT) - yield _client - _client.close() - -@pytest.fixture(scope='session') -def p4runtime_service(): - _service = MockP4RuntimeService( - address=DEVICE_P4_ADDRESS, port=DEVICE_P4_PORT, - max_workers=DEVICE_P4_WORKERS, - grace_period=DEVICE_P4_GRACE_PERIOD) - _service.start() - yield _service - _service.stop() - - -def test_prepare_environment( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService): # pylint: disable=redefined-outer-name - - context_client.SetContext(Context(**CONTEXT)) - context_client.SetTopology(Topology(**TOPOLOGY)) - - -# ----- Test Device Driver Emulated -------------------------------------------- -# Device Driver Emulated tests are used to validate Driver API as well as Emulated Device Driver. Note that other -# Drivers might support a different set of resource paths, and attributes/values per resource; however, they must -# implement the Driver API. - -def test_device_emulated_add_error_cases( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_EMULATED: pytest.skip('Skipping test: No Emulated device has been configured') - - with pytest.raises(grpc.RpcError) as e: - DEVICE_EMU_WITH_ENDPOINTS = copy.deepcopy(DEVICE_EMU) - DEVICE_EMU_WITH_ENDPOINTS['device_endpoints'].append(json_endpoint(DEVICE_EMU_ID, 'ep-id', 'ep-type')) - device_client.AddDevice(Device(**DEVICE_EMU_WITH_ENDPOINTS)) - assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT - msg_head = 'device.device_endpoints([' - msg_tail = ']) is invalid; RPC method AddDevice does not accept Endpoints. '\ - 'Endpoints are discovered through interrogation of the physical device.' - except_msg = str(e.value.details()) - assert except_msg.startswith(msg_head) and except_msg.endswith(msg_tail) - - with pytest.raises(grpc.RpcError) as e: - DEVICE_EMU_WITH_EXTRA_RULES = copy.deepcopy(DEVICE_EMU) - DEVICE_EMU_WITH_EXTRA_RULES['device_config']['config_rules'].extend(DEVICE_EMU_CONNECT_RULES) - DEVICE_EMU_WITH_EXTRA_RULES['device_config']['config_rules'].extend(DEVICE_EMU_CONFIG_ENDPOINTS) - device_client.AddDevice(Device(**DEVICE_EMU_WITH_EXTRA_RULES)) - assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT - msg_head = 'device.device_config.config_rules([' - msg_tail = ']) is invalid; RPC method AddDevice only accepts connection Config Rules that should start '\ - 'with "_connect/" tag. Others should be configured after adding the device.' - except_msg = str(e.value.details()) - assert except_msg.startswith(msg_head) and except_msg.endswith(msg_tail) - - -def test_device_emulated_add_correct( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_EMULATED: pytest.skip('Skipping test: No Emulated device has been configured') - - DEVICE_EMU_WITH_CONNECT_RULES = copy.deepcopy(DEVICE_EMU) - DEVICE_EMU_WITH_CONNECT_RULES['device_config']['config_rules'].extend(DEVICE_EMU_CONNECT_RULES) - device_client.AddDevice(Device(**DEVICE_EMU_WITH_CONNECT_RULES)) - driver : _Driver = device_service.driver_instance_cache.get(DEVICE_EMU_UUID) # we know the driver exists now - assert driver is not None - - -def test_device_emulated_get( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_EMULATED: pytest.skip('Skipping test: No Emulated device has been configured') - - initial_config = device_client.GetInitialConfig(DeviceId(**DEVICE_EMU_ID)) - LOGGER.info('initial_config = {:s}'.format(grpc_message_to_json_string(initial_config))) - - device_data = context_client.GetDevice(DeviceId(**DEVICE_EMU_ID)) - LOGGER.info('device_data = {:s}'.format(grpc_message_to_json_string(device_data))) - - -def test_device_emulated_configure( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_EMULATED: pytest.skip('Skipping test: No Emulated device has been configured') - - driver : _Driver = device_service.driver_instance_cache.get(DEVICE_EMU_UUID) # we know the driver exists now - assert driver is not None - - driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) - #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) - assert len(driver_config) == len(DEVICE_EMU_ENDPOINTS_COOKED) - for endpoint_cooked in DEVICE_EMU_ENDPOINTS_COOKED: - assert endpoint_cooked in driver_config - - DEVICE_EMU_WITH_CONFIG_RULES = copy.deepcopy(DEVICE_EMU) - DEVICE_EMU_WITH_CONFIG_RULES['device_config']['config_rules'].extend(DEVICE_EMU_CONFIG_ENDPOINTS) - device_client.ConfigureDevice(Device(**DEVICE_EMU_WITH_CONFIG_RULES)) - - DEVICE_EMU_WITH_CONFIG_RULES = copy.deepcopy(DEVICE_EMU) - DEVICE_EMU_WITH_CONFIG_RULES['device_config']['config_rules'].extend(DEVICE_EMU_CONFIG_ADDRESSES) - device_client.ConfigureDevice(Device(**DEVICE_EMU_WITH_CONFIG_RULES)) - - DEVICE_EMU_WITH_OPERATIONAL_STATUS = copy.deepcopy(DEVICE_EMU) - DEVICE_EMU_WITH_OPERATIONAL_STATUS['device_operational_status'] = \ - DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_ENABLED - device_client.ConfigureDevice(Device(**DEVICE_EMU_WITH_OPERATIONAL_STATUS)) - - driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) - #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) - assert len(driver_config) == len(DEVICE_EMU_ENDPOINTS_COOKED) + len(DEVICE_EMU_CONFIG_ADDRESSES) - for endpoint_cooked in DEVICE_EMU_ENDPOINTS_COOKED: - endpoint_cooked = copy.deepcopy(endpoint_cooked) - endpoint_cooked[1]['enabled'] = True - assert endpoint_cooked in driver_config - for config_rule in DEVICE_EMU_CONFIG_ADDRESSES: - assert (config_rule['resource_key'], json.loads(config_rule['resource_value'])) in driver_config - - device_data = context_client.GetDevice(DeviceId(**DEVICE_EMU_ID)) - assert device_data.device_operational_status == DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_ENABLED - - config_rules = [ - (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) - for config_rule in device_data.device_config.config_rules - ] - #LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( - # '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) - RESULTING_CONFIG_ENDPOINTS = {cr['resource_key']:cr for cr in copy.deepcopy(DEVICE_EMU_CONFIG_ENDPOINTS)} - for endpoint_cooked in DEVICE_EMU_ENDPOINTS_COOKED: - values = json.loads(RESULTING_CONFIG_ENDPOINTS[endpoint_cooked[0]]['resource_value']) - values.update(endpoint_cooked[1]) - RESULTING_CONFIG_ENDPOINTS[endpoint_cooked[0]]['resource_value'] = json.dumps(values, sort_keys=True) - for config_rule in RESULTING_CONFIG_ENDPOINTS.values(): - config_rule = ( - ConfigActionEnum.Name(config_rule['action']), config_rule['resource_key'], - json.loads(json.dumps(config_rule['resource_value']))) - assert config_rule in config_rules - for config_rule in DEVICE_EMU_CONFIG_ADDRESSES: - config_rule = ( - ConfigActionEnum.Name(config_rule['action']), config_rule['resource_key'], - json.loads(json.dumps(config_rule['resource_value']))) - assert config_rule in config_rules - - # Try to reconfigure... - - DEVICE_EMU_WITH_RECONFIG_RULES = copy.deepcopy(DEVICE_EMU) - DEVICE_EMU_WITH_RECONFIG_RULES['device_operational_status'] = \ - DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_ENABLED - DEVICE_EMU_WITH_RECONFIG_RULES['device_config']['config_rules'].extend(DEVICE_EMU_RECONFIG_ADDRESSES) - device_client.ConfigureDevice(Device(**DEVICE_EMU_WITH_RECONFIG_RULES)) - - RESULTING_CONFIG_RULES = {cr['resource_key']:cr for cr in copy.deepcopy(DEVICE_EMU_CONFIG_ENDPOINTS)} - for endpoint_cooked in DEVICE_EMU_ENDPOINTS_COOKED: - values = json.loads(RESULTING_CONFIG_RULES[endpoint_cooked[0]]['resource_value']) - values.update(endpoint_cooked[1]) - RESULTING_CONFIG_RULES[endpoint_cooked[0]]['resource_value'] = json.dumps(values, sort_keys=True) - RESULTING_CONFIG_RULES.update({cr['resource_key']:cr for cr in copy.deepcopy(DEVICE_EMU_CONFIG_ADDRESSES)}) - for reconfig_rule in DEVICE_EMU_RECONFIG_ADDRESSES: - if reconfig_rule['action'] == ConfigActionEnum.CONFIGACTION_DELETE: - RESULTING_CONFIG_RULES.pop(reconfig_rule['resource_key'], None) - else: - RESULTING_CONFIG_RULES[reconfig_rule['resource_key']] = reconfig_rule - RESULTING_CONFIG_RULES = RESULTING_CONFIG_RULES.values() - #LOGGER.info('RESULTING_CONFIG_RULES = {:s}'.format(str(RESULTING_CONFIG_RULES))) - - driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) - driver_config = json.loads(json.dumps(driver_config)) # prevent integer keys to fail matching with string keys - #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) - assert len(driver_config) == len(RESULTING_CONFIG_RULES) - for config_rule in RESULTING_CONFIG_RULES: - resource = [config_rule['resource_key'], json.loads(config_rule['resource_value'])] - assert resource in driver_config - - device_data = context_client.GetDevice(DeviceId(**DEVICE_EMU_ID)) - config_rules = [ - (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) - for config_rule in device_data.device_config.config_rules - ] - #LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( - # '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) - for config_rule in RESULTING_CONFIG_RULES: - config_rule = ( - ConfigActionEnum.Name(config_rule['action']), config_rule['resource_key'], config_rule['resource_value']) - assert config_rule in config_rules - - -def test_device_emulated_monitor( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService, # pylint: disable=redefined-outer-name - monitoring_service : MockMonitoringService): # pylint: disable=redefined-outer-name - - if not ENABLE_EMULATED: pytest.skip('Skipping test: No Emulated device has been configured') - - device_uuid = DEVICE_EMU_UUID - json_device_id = DEVICE_EMU_ID - device_id = DeviceId(**json_device_id) - device_data = context_client.GetDevice(device_id) - #LOGGER.info('device_data = \n{:s}'.format(str(device_data))) - - driver : _Driver = device_service.driver_instance_cache.get(device_uuid) # we know the driver exists now - assert driver is not None - #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) - #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) - #assert len(driver_config) == len(DEVICE_EMU_ENDPOINTS_COOKED) + len(DEVICE_EMU_CONFIG_ADDRESSES) - - SAMPLING_DURATION_SEC = 10.0 - SAMPLING_INTERVAL_SEC = 2.0 - - MONITORING_SETTINGS_LIST = [] - KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED = {} - for endpoint in device_data.device_endpoints: - endpoint_uuid = endpoint.endpoint_id.endpoint_uuid.uuid - for sample_type_id in endpoint.kpi_sample_types: - sample_type_name = str(KpiSampleType.Name(sample_type_id)).upper().replace('KPISAMPLETYPE_', '') - kpi_uuid = '{:s}-{:s}-{:s}-kpi_uuid'.format(device_uuid, endpoint_uuid, str(sample_type_id)) - monitoring_settings = { - 'kpi_id' : {'kpi_id': {'uuid': kpi_uuid}}, - 'kpi_descriptor': { - 'kpi_description': 'Metric {:s} for Endpoint {:s} in Device {:s}'.format( - sample_type_name, endpoint_uuid, device_uuid), - 'kpi_sample_type': sample_type_id, - 'device_id': json_device_id, - 'endpoint_id': json_endpoint_id(json_device_id, endpoint_uuid), - }, - 'sampling_duration_s': SAMPLING_DURATION_SEC, - 'sampling_interval_s': SAMPLING_INTERVAL_SEC, - } - MONITORING_SETTINGS_LIST.append(monitoring_settings) - KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED[kpi_uuid] = 0 - - NUM_SAMPLES_EXPECTED_PER_KPI = SAMPLING_DURATION_SEC / SAMPLING_INTERVAL_SEC - NUM_SAMPLES_EXPECTED = len(MONITORING_SETTINGS_LIST) * NUM_SAMPLES_EXPECTED_PER_KPI - - # Start monitoring the device - t_start_monitoring = datetime.timestamp(datetime.utcnow()) - for monitoring_settings in MONITORING_SETTINGS_LIST: - device_client.MonitorDeviceKpi(MonitoringSettings(**monitoring_settings)) - - # wait to receive the expected number of samples - # if takes more than 1.5 times the sampling duration, assume there is an error - time_ini = time.time() - queue_samples : queue.Queue = monitoring_service.queue_samples - received_samples = [] - while (len(received_samples) < NUM_SAMPLES_EXPECTED) and (time.time() - time_ini < SAMPLING_DURATION_SEC * 1.5): - try: - received_sample = queue_samples.get(block=True, timeout=SAMPLING_INTERVAL_SEC / NUM_SAMPLES_EXPECTED) - #LOGGER.info('received_sample = {:s}'.format(str(received_sample))) - received_samples.append(received_sample) - except queue.Empty: - continue - - t_end_monitoring = datetime.timestamp(datetime.utcnow()) - - #LOGGER.info('received_samples = {:s}'.format(str(received_samples))) - LOGGER.info('len(received_samples) = {:s}'.format(str(len(received_samples)))) - LOGGER.info('NUM_SAMPLES_EXPECTED = {:s}'.format(str(NUM_SAMPLES_EXPECTED))) - assert len(received_samples) == NUM_SAMPLES_EXPECTED - for received_sample in received_samples: - kpi_uuid = received_sample.kpi_id.kpi_id.uuid - assert kpi_uuid in KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED - assert isinstance(received_sample.timestamp, str) - try: - timestamp = float(received_sample.timestamp) - except ValueError: - dt_time = dateutil.parser.isoparse(received_sample.timestamp).replace(tzinfo=timezone.utc) - timestamp = float(calendar.timegm(dt_time.timetuple())) + (dt_time.microsecond / 1.e6) - assert timestamp > t_start_monitoring - assert timestamp < t_end_monitoring - assert received_sample.kpi_value.HasField('floatVal') or received_sample.kpi_value.HasField('intVal') - kpi_value = getattr(received_sample.kpi_value, received_sample.kpi_value.WhichOneof('value')) - assert isinstance(kpi_value, (float, int)) - KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED[kpi_uuid] += 1 - - LOGGER.info('KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED = {:s}'.format(str(KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED))) - for kpi_uuid, num_samples_received in KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED.items(): - assert num_samples_received == NUM_SAMPLES_EXPECTED_PER_KPI - - # Unsubscribe monitoring - for kpi_uuid in KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED.keys(): - MONITORING_SETTINGS_UNSUBSCRIBE = { - 'kpi_id' : {'kpi_id': {'uuid': kpi_uuid}}, - 'sampling_duration_s': -1, # negative value in sampling_duration_s or sampling_interval_s means unsibscribe - 'sampling_interval_s': -1, # kpi_id is mandatory to unsibscribe - } - device_client.MonitorDeviceKpi(MonitoringSettings(**MONITORING_SETTINGS_UNSUBSCRIBE)) - - -def test_device_emulated_deconfigure( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_EMULATED: pytest.skip('Skipping test: No Emulated device has been configured') - - driver : _Driver = device_service.driver_instance_cache.get(DEVICE_EMU_UUID) # we know the driver exists now - assert driver is not None - - driver_config = driver.GetConfig() - #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) - - DEVICE_EMU_WITH_DECONFIG_RULES = copy.deepcopy(DEVICE_EMU) - DEVICE_EMU_WITH_DECONFIG_RULES['device_operational_status'] = \ - DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_DISABLED - DEVICE_EMU_WITH_DECONFIG_RULES['device_config']['config_rules'].extend(DEVICE_EMU_DECONFIG_ADDRESSES) - device_client.ConfigureDevice(Device(**DEVICE_EMU_WITH_DECONFIG_RULES)) - - RESULTING_CONFIG_RULES = {cr['resource_key']:cr for cr in copy.deepcopy(DEVICE_EMU_CONFIG_ENDPOINTS)} - for endpoint_cooked in DEVICE_EMU_ENDPOINTS_COOKED: - values = json.loads(RESULTING_CONFIG_RULES[endpoint_cooked[0]]['resource_value']) - values.update(endpoint_cooked[1]) - RESULTING_CONFIG_RULES[endpoint_cooked[0]]['resource_value'] = json.dumps(values, sort_keys=True) - RESULTING_CONFIG_RULES = RESULTING_CONFIG_RULES.values() - driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) - driver_config = json.loads(json.dumps(driver_config)) # prevent integer keys to fail matching with string keys - driver_config = list(filter( - lambda config_rule: ( - not isinstance(config_rule[1], str) or not config_rule[1].startswith('do_sampling (trigger:')), - driver_config)) - LOGGER.info('driver_config = {:s}'.format(str(driver_config))) - LOGGER.info('RESULTING_CONFIG_RULES = {:s}'.format(str(RESULTING_CONFIG_RULES))) - assert len(driver_config) == len(RESULTING_CONFIG_RULES) - for config_rule in RESULTING_CONFIG_RULES: - config_rule = [config_rule['resource_key'], json.loads(config_rule['resource_value'])] - #LOGGER.info('config_rule = {:s}'.format(str(config_rule))) - assert config_rule in driver_config - - DEVICE_EMU_WITH_DECONFIG_RULES = copy.deepcopy(DEVICE_EMU) - DEVICE_EMU_WITH_DECONFIG_RULES['device_config']['config_rules'].extend(DEVICE_EMU_DECONFIG_ENDPOINTS) - device_client.ConfigureDevice(Device(**DEVICE_EMU_WITH_DECONFIG_RULES)) - - driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) - driver_config = json.loads(json.dumps(driver_config)) # prevent integer keys to fail matching with string keys - #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) - assert len(driver_config) == 0 - - device_data = context_client.GetDevice(DeviceId(**DEVICE_EMU_ID)) - config_rules = device_data.device_config.config_rules - LOGGER.info('config_rules = {:s}'.format(str(config_rules))) - clean_config_rules = [] - for config_rule in config_rules: - config_rule_value = json.loads(config_rule.resource_value) - if not isinstance(config_rule_value, str): clean_config_rules.append(config_rule) - if config_rule_value.startswith('do_sampling (trigger:'): continue - clean_config_rules.append(config_rule) - LOGGER.info('clean_config_rules = {:s}'.format(str(clean_config_rules))) - assert len(clean_config_rules) == 0 - - -def test_device_emulated_delete( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_EMULATED: pytest.skip('Skipping test: No Emulated device has been configured') - - device_client.DeleteDevice(DeviceId(**DEVICE_EMU_ID)) - driver : _Driver = device_service.driver_instance_cache.get(DEVICE_EMU_UUID, {}) - assert driver is None - - -# ----- Test Device Driver OpenConfig ------------------------------------------ - -def test_device_openconfig_add_error_cases( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_OPENCONFIG: pytest.skip('Skipping test: No OpenConfig device has been configured') - - with pytest.raises(grpc.RpcError) as e: - DEVICE_OC_WITH_EXTRA_RULES = copy.deepcopy(DEVICE_OC) - DEVICE_OC_WITH_EXTRA_RULES['device_config']['config_rules'].extend(DEVICE_OC_CONNECT_RULES) - DEVICE_OC_WITH_EXTRA_RULES['device_config']['config_rules'].extend(DEVICE_OC_CONFIG_RULES) - device_client.AddDevice(Device(**DEVICE_OC_WITH_EXTRA_RULES)) - assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT - msg_head = 'device.device_config.config_rules([' - msg_tail = ']) is invalid; RPC method AddDevice only accepts connection Config Rules that should start '\ - 'with "_connect/" tag. Others should be configured after adding the device.' - except_msg = str(e.value.details()) - assert except_msg.startswith(msg_head) and except_msg.endswith(msg_tail) - - -def test_device_openconfig_add_correct( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_OPENCONFIG: pytest.skip('Skipping test: No OpenConfig device has been configured') - - DEVICE_OC_WITH_CONNECT_RULES = copy.deepcopy(DEVICE_OC) - DEVICE_OC_WITH_CONNECT_RULES['device_config']['config_rules'].extend(DEVICE_OC_CONNECT_RULES) - device_client.AddDevice(Device(**DEVICE_OC_WITH_CONNECT_RULES)) - driver : _Driver = device_service.driver_instance_cache.get(DEVICE_OC_UUID) # we know the driver exists now - assert driver is not None - - device_data = context_client.GetDevice(DeviceId(**DEVICE_OC_ID)) - config_rules = [ - (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) - for config_rule in device_data.device_config.config_rules - ] - LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( - '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) - - -def test_device_openconfig_get( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_OPENCONFIG: pytest.skip('Skipping test: No OpenConfig device has been configured') - - initial_config = device_client.GetInitialConfig(DeviceId(**DEVICE_OC_ID)) - LOGGER.info('initial_config = {:s}'.format(grpc_message_to_json_string(initial_config))) - - device_data = context_client.GetDevice(DeviceId(**DEVICE_OC_ID)) - LOGGER.info('device_data = {:s}'.format(grpc_message_to_json_string(device_data))) - - -def test_device_openconfig_configure( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_OPENCONFIG: pytest.skip('Skipping test: No OpenConfig device has been configured') - if not ENABLE_OPENCONFIG_CONFIGURE: pytest.skip('Skipping test OpenConfig configure') - - driver : _Driver = device_service.driver_instance_cache.get(DEVICE_OC_UUID) # we know the driver exists now - assert driver is not None - - # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. - #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) - #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) - - DEVICE_OC_WITH_CONFIG_RULES = copy.deepcopy(DEVICE_OC) - DEVICE_OC_WITH_CONFIG_RULES['device_config']['config_rules'].extend(DEVICE_OC_CONFIG_RULES) - device_client.ConfigureDevice(Device(**DEVICE_OC_WITH_CONFIG_RULES)) - - # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. - #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) - #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) - - device_data = context_client.GetDevice(DeviceId(**DEVICE_OC_ID)) - config_rules = [ - (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) - for config_rule in device_data.device_config.config_rules - ] - LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( - '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) - for config_rule in DEVICE_OC_CONFIG_RULES: - config_rule = ( - ConfigActionEnum.Name(config_rule['action']), config_rule['resource_key'], config_rule['resource_value']) - assert config_rule in config_rules - - -def test_device_openconfig_monitor( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService, # pylint: disable=redefined-outer-name - monitoring_service : MockMonitoringService): # pylint: disable=redefined-outer-name - - if not ENABLE_OPENCONFIG: pytest.skip('Skipping test: No OpenConfig device has been configured') - if not ENABLE_OPENCONFIG_MONITOR: pytest.skip('Skipping test OpenConfig monitor') - - device_uuid = DEVICE_OC_UUID - json_device_id = DEVICE_OC_ID - device_id = DeviceId(**json_device_id) - device_data = context_client.GetDevice(device_id) - #LOGGER.info('device_data = \n{:s}'.format(str(device_data))) - - driver : _Driver = device_service.driver_instance_cache.get(device_uuid) # we know the driver exists now - assert driver is not None - - SAMPLING_DURATION_SEC = 60.0 - SAMPLING_INTERVAL_SEC = 15.0 - - MONITORING_SETTINGS_LIST = [] - KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED = {} - for endpoint in device_data.device_endpoints: - endpoint_uuid = endpoint.endpoint_id.endpoint_uuid.uuid - for sample_type_id in endpoint.kpi_sample_types: - sample_type_name = str(KpiSampleType.Name(sample_type_id)).upper().replace('KPISAMPLETYPE_', '') - kpi_uuid = '{:s}-{:s}-{:s}-kpi_uuid'.format(device_uuid, endpoint_uuid, str(sample_type_id)) - monitoring_settings = { - 'kpi_id' : {'kpi_id': {'uuid': kpi_uuid}}, - 'kpi_descriptor': { - 'kpi_description': 'Metric {:s} for Endpoint {:s} in Device {:s}'.format( - sample_type_name, endpoint_uuid, device_uuid), - 'kpi_sample_type': sample_type_id, - 'device_id': json_device_id, - 'endpoint_id': json_endpoint_id(json_device_id, endpoint_uuid), - }, - 'sampling_duration_s': SAMPLING_DURATION_SEC, - 'sampling_interval_s': SAMPLING_INTERVAL_SEC, - } - MONITORING_SETTINGS_LIST.append(monitoring_settings) - KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED[kpi_uuid] = 0 - - NUM_SAMPLES_EXPECTED_PER_KPI = SAMPLING_DURATION_SEC / SAMPLING_INTERVAL_SEC - NUM_SAMPLES_EXPECTED = len(MONITORING_SETTINGS_LIST) * NUM_SAMPLES_EXPECTED_PER_KPI - - # Start monitoring the device - t_start_monitoring = datetime.timestamp(datetime.utcnow()) - for monitoring_settings in MONITORING_SETTINGS_LIST: - device_client.MonitorDeviceKpi(MonitoringSettings(**monitoring_settings)) - - # wait to receive the expected number of samples - # if takes more than 1.5 times the sampling duration, assume there is an error - time_ini = time.time() - queue_samples : queue.Queue = monitoring_service.queue_samples - received_samples = [] - while (len(received_samples) < NUM_SAMPLES_EXPECTED) and (time.time() - time_ini < SAMPLING_DURATION_SEC * 1.5): - try: - received_sample = queue_samples.get(block=True, timeout=SAMPLING_INTERVAL_SEC / NUM_SAMPLES_EXPECTED) - #LOGGER.info('received_sample = {:s}'.format(str(received_sample))) - received_samples.append(received_sample) - except queue.Empty: - continue - - t_end_monitoring = datetime.timestamp(datetime.utcnow()) - - #LOGGER.info('received_samples = {:s}'.format(str(received_samples))) - LOGGER.info('len(received_samples) = {:s}'.format(str(len(received_samples)))) - LOGGER.info('NUM_SAMPLES_EXPECTED = {:s}'.format(str(NUM_SAMPLES_EXPECTED))) - #assert len(received_samples) == NUM_SAMPLES_EXPECTED - for received_sample in received_samples: - kpi_uuid = received_sample.kpi_id.kpi_id.uuid - assert kpi_uuid in KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED - assert isinstance(received_sample.timestamp, str) - try: - timestamp = float(received_sample.timestamp) - except ValueError: - dt_time = dateutil.parser.isoparse(received_sample.timestamp).replace(tzinfo=timezone.utc) - timestamp = float(calendar.timegm(dt_time.timetuple())) + (dt_time.microsecond / 1.e6) - assert timestamp > t_start_monitoring - assert timestamp < t_end_monitoring - assert received_sample.kpi_value.HasField('floatVal') or received_sample.kpi_value.HasField('intVal') - kpi_value = getattr(received_sample.kpi_value, received_sample.kpi_value.WhichOneof('value')) - assert isinstance(kpi_value, (float, int)) - KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED[kpi_uuid] += 1 - - LOGGER.info('KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED = {:s}'.format(str(KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED))) - # TODO: review why num_samples_received per KPI != NUM_SAMPLES_EXPECTED_PER_KPI - #for kpi_uuid, num_samples_received in KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED.items(): - # assert num_samples_received == NUM_SAMPLES_EXPECTED_PER_KPI - - # Unsubscribe monitoring - for kpi_uuid in KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED.keys(): - MONITORING_SETTINGS_UNSUBSCRIBE = { - 'kpi_id' : {'kpi_id': {'uuid': kpi_uuid}}, - 'sampling_duration_s': -1, # negative value in sampling_duration_s or sampling_interval_s means unsibscribe - 'sampling_interval_s': -1, # kpi_id is mandatory to unsibscribe - } - device_client.MonitorDeviceKpi(MonitoringSettings(**MONITORING_SETTINGS_UNSUBSCRIBE)) - - -def test_device_openconfig_deconfigure( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_OPENCONFIG: pytest.skip('Skipping test: No OpenConfig device has been configured') - if not ENABLE_OPENCONFIG_DECONFIGURE: pytest.skip('Skipping test OpenConfig deconfigure') - - driver : _Driver = device_service.driver_instance_cache.get(DEVICE_OC_UUID) # we know the driver exists now - assert driver is not None - - # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. - #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) - #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) - - DEVICE_OC_WITH_DECONFIG_RULES = copy.deepcopy(DEVICE_OC) - DEVICE_OC_WITH_DECONFIG_RULES['device_config']['config_rules'].extend(DEVICE_OC_DECONFIG_RULES) - device_client.ConfigureDevice(Device(**DEVICE_OC_WITH_DECONFIG_RULES)) - - # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. - #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) - #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) - - device_data = context_client.GetDevice(DeviceId(**DEVICE_OC_ID)) - config_rules = [ - (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) - for config_rule in device_data.device_config.config_rules - ] - LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( - '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) - for config_rule in DEVICE_OC_DECONFIG_RULES: - action_set = ConfigActionEnum.Name(ConfigActionEnum.CONFIGACTION_SET) - config_rule = (action_set, config_rule['resource_key'], config_rule['resource_value']) - assert config_rule not in config_rules - - -def test_device_openconfig_delete( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_OPENCONFIG: pytest.skip('Skipping test: No OpenConfig device has been configured') - - device_client.DeleteDevice(DeviceId(**DEVICE_OC_ID)) - driver : _Driver = device_service.driver_instance_cache.get(DEVICE_OC_UUID, {}) - assert driver is None - - -# ----- Test Device Driver TAPI ------------------------------------------------ - -def test_device_tapi_add_error_cases( - device_client : DeviceClient): # pylint: disable=redefined-outer-name - - if not ENABLE_TAPI: pytest.skip('Skipping test: No TAPI device has been configured') - - with pytest.raises(grpc.RpcError) as e: - DEVICE_TAPI_WITH_EXTRA_RULES = copy.deepcopy(DEVICE_TAPI) - DEVICE_TAPI_WITH_EXTRA_RULES['device_config']['config_rules'].extend(DEVICE_TAPI_CONNECT_RULES) - DEVICE_TAPI_WITH_EXTRA_RULES['device_config']['config_rules'].extend(DEVICE_TAPI_CONFIG_RULES) - device_client.AddDevice(Device(**DEVICE_TAPI_WITH_EXTRA_RULES)) - assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT - msg_head = 'device.device_config.config_rules([' - msg_tail = ']) is invalid; RPC method AddDevice only accepts connection Config Rules that should start '\ - 'with "_connect/" tag. Others should be configured after adding the device.' - except_msg = str(e.value.details()) - assert except_msg.startswith(msg_head) and except_msg.endswith(msg_tail) - - -def test_device_tapi_add_correct( - device_client: DeviceClient, # pylint: disable=redefined-outer-name - device_service: DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_TAPI: pytest.skip('Skipping test: No TAPI device has been configured') - - DEVICE_TAPI_WITH_CONNECT_RULES = copy.deepcopy(DEVICE_TAPI) - DEVICE_TAPI_WITH_CONNECT_RULES['device_config']['config_rules'].extend(DEVICE_TAPI_CONNECT_RULES) - device_client.AddDevice(Device(**DEVICE_TAPI_WITH_CONNECT_RULES)) - driver: _Driver = device_service.driver_instance_cache.get(DEVICE_TAPI_UUID) - assert driver is not None - - -def test_device_tapi_get( - context_client: ContextClient, # pylint: disable=redefined-outer-name - device_client: DeviceClient): # pylint: disable=redefined-outer-name - - if not ENABLE_TAPI: pytest.skip('Skipping test: No TAPI device has been configured') - - initial_config = device_client.GetInitialConfig(DeviceId(**DEVICE_TAPI_ID)) - LOGGER.info('initial_config = {:s}'.format(grpc_message_to_json_string(initial_config))) - - device_data = context_client.GetDevice(DeviceId(**DEVICE_TAPI_ID)) - LOGGER.info('device_data = {:s}'.format(grpc_message_to_json_string(device_data))) - - -def test_device_tapi_configure( - context_client: ContextClient, # pylint: disable=redefined-outer-name - device_client: DeviceClient, # pylint: disable=redefined-outer-name - device_service: DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_TAPI: pytest.skip('Skipping test: No TAPI device has been configured') - - driver : _Driver = device_service.driver_instance_cache.get(DEVICE_TAPI_UUID) - assert driver is not None - - # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. - #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) - #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) - - DEVICE_TAPI_WITH_CONFIG_RULES = copy.deepcopy(DEVICE_TAPI) - DEVICE_TAPI_WITH_CONFIG_RULES['device_config']['config_rules'].extend(DEVICE_TAPI_CONFIG_RULES) - device_client.ConfigureDevice(Device(**DEVICE_TAPI_WITH_CONFIG_RULES)) - - # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. - #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) - #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) - - device_data = context_client.GetDevice(DeviceId(**DEVICE_TAPI_ID)) - config_rules = [ - (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) - for config_rule in device_data.device_config.config_rules - ] - LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( - '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) - for config_rule in DEVICE_TAPI_CONFIG_RULES: - config_rule = ( - ConfigActionEnum.Name(config_rule['action']), config_rule['resource_key'], config_rule['resource_value']) - assert config_rule in config_rules - - -def test_device_tapi_deconfigure( - context_client: ContextClient, # pylint: disable=redefined-outer-name - device_client: DeviceClient, # pylint: disable=redefined-outer-name - device_service: DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_TAPI: pytest.skip('Skipping test: No TAPI device has been configured') - - driver: _Driver = device_service.driver_instance_cache.get(DEVICE_TAPI_UUID) - assert driver is not None - - # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. - #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) - #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) - - DEVICE_TAPI_WITH_DECONFIG_RULES = copy.deepcopy(DEVICE_TAPI) - DEVICE_TAPI_WITH_DECONFIG_RULES['device_config']['config_rules'].extend(DEVICE_TAPI_DECONFIG_RULES) - device_client.ConfigureDevice(Device(**DEVICE_TAPI_WITH_DECONFIG_RULES)) - - # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. - #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) - #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) - - device_data = context_client.GetDevice(DeviceId(**DEVICE_TAPI_ID)) - config_rules = [ - (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) - for config_rule in device_data.device_config.config_rules - ] - LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( - '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) - for config_rule in DEVICE_TAPI_DECONFIG_RULES: - action_set = ConfigActionEnum.Name(ConfigActionEnum.CONFIGACTION_SET) - config_rule = (action_set, config_rule['resource_key'], config_rule['resource_value']) - assert config_rule not in config_rules - - -def test_device_tapi_delete( - device_client : DeviceClient, # pylint: disable=redefined-outer-name - device_service : DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_TAPI: pytest.skip('Skipping test: No TAPI device has been configured') - - device_client.DeleteDevice(DeviceId(**DEVICE_TAPI_ID)) - driver : _Driver = device_service.driver_instance_cache.get(DEVICE_TAPI_UUID, {}) - assert driver is None - - -# ----- Test Device Driver P4 -------------------------------------------------- - -def test_device_p4_add_error_cases( - context_client: ContextClient, # pylint: disable=redefined-outer-name - device_client: DeviceClient, # pylint: disable=redefined-outer-name - device_service: DeviceService): # pylint: disable=redefined-outer-name - - if not ENABLE_P4: pytest.skip( - 'Skipping test: No P4 device has been configured') - - with pytest.raises(grpc.RpcError) as e: - device_p4_with_extra_rules = copy.deepcopy(DEVICE_P4) - device_p4_with_extra_rules['device_config']['config_rules'].extend( - DEVICE_P4_CONNECT_RULES) - device_p4_with_extra_rules['device_config']['config_rules'].extend( - DEVICE_P4_CONFIG_RULES) - device_client.AddDevice(Device(**device_p4_with_extra_rules)) - assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT - msg_head = 'device.device_config.config_rules([' - msg_tail = ']) is invalid; RPC method AddDevice only accepts connection Config Rules that should start '\ - 'with "_connect/" tag. Others should be configured after adding the device.' - except_msg = str(e.value.details()) - assert except_msg.startswith(msg_head) and except_msg.endswith(msg_tail) - - -def test_device_p4_add_correct( - context_client: ContextClient, # pylint: disable=redefined-outer-name - device_client: DeviceClient, # pylint: disable=redefined-outer-name - device_service: DeviceService, # pylint: disable=redefined-outer-name - p4runtime_service: MockP4RuntimeService): # pylint: disable=redefined-outer-name - - if not ENABLE_P4: pytest.skip( - 'Skipping test: No P4 device has been configured') - - device_p4_with_connect_rules = copy.deepcopy(DEVICE_P4) - device_p4_with_connect_rules['device_config']['config_rules'].extend( - DEVICE_P4_CONNECT_RULES) - device_client.AddDevice(Device(**device_p4_with_connect_rules)) - driver : _Driver = device_service.driver_instance_cache.get(DEVICE_P4_UUID) - assert driver is not None - - -def test_device_p4_get( - context_client: ContextClient, # pylint: disable=redefined-outer-name - device_client: DeviceClient, # pylint: disable=redefined-outer-name - device_service: DeviceService, # pylint: disable=redefined-outer-name - p4runtime_service: MockP4RuntimeService): # pylint: disable=redefined-outer-name - - if not ENABLE_P4: pytest.skip( - 'Skipping test: No P4 device has been configured') - - initial_config = device_client.GetInitialConfig(DeviceId(**DEVICE_P4_ID)) - LOGGER.info('initial_config = {:s}'.format( - grpc_message_to_json_string(initial_config))) - - device_data = context_client.GetDevice(DeviceId(**DEVICE_P4_ID)) - LOGGER.info('device_data = {:s}'.format( - grpc_message_to_json_string(device_data))) - - -def test_device_p4_configure( - context_client: ContextClient, # pylint: disable=redefined-outer-name - device_client: DeviceClient, # pylint: disable=redefined-outer-name - device_service: DeviceService, # pylint: disable=redefined-outer-name - p4runtime_service: MockP4RuntimeService): # pylint: disable=redefined-outer-name - - if not ENABLE_P4: pytest.skip( - 'Skipping test: No P4 device has been configured') - - pytest.skip('Skipping test for unimplemented method') - - -def test_device_p4_deconfigure( - context_client: ContextClient, # pylint: disable=redefined-outer-name - device_client: DeviceClient, # pylint: disable=redefined-outer-name - device_service: DeviceService, # pylint: disable=redefined-outer-name - p4runtime_service: MockP4RuntimeService): # pylint: disable=redefined-outer-name - - if not ENABLE_P4: pytest.skip( - 'Skipping test: No P4 device has been configured') - - pytest.skip('Skipping test for unimplemented method') - - -def test_device_p4_delete( - context_client: ContextClient, # pylint: disable=redefined-outer-name - device_client: DeviceClient, # pylint: disable=redefined-outer-name - device_service: DeviceService, # pylint: disable=redefined-outer-name - p4runtime_service: MockP4RuntimeService): # pylint: disable=redefined-outer-name - - if not ENABLE_P4: pytest.skip('Skipping test: No P4 device has been configured') - - device_client.DeleteDevice(DeviceId(**DEVICE_P4_ID)) - driver : _Driver = device_service.driver_instance_cache.get(DEVICE_P4_UUID) - assert driver is None diff --git a/src/device/tests/test_unitary_emulated.py b/src/device/tests/test_unitary_emulated.py new file mode 100644 index 0000000000000000000000000000000000000000..67a2e9c33c11711ed3343c688f7bc5a88316eca0 --- /dev/null +++ b/src/device/tests/test_unitary_emulated.py @@ -0,0 +1,378 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import calendar, copy, dateutil.parser, grpc, json, logging, operator, pytest, queue, time +from datetime import datetime, timezone +from common.tools.grpc.Tools import grpc_message_to_json_string +from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_id +from context.client.ContextClient import ContextClient +from context.proto.context_pb2 import DeviceId, DeviceOperationalStatusEnum +from device.client.DeviceClient import DeviceClient +from device.proto.context_pb2 import ConfigActionEnum, Device +from device.proto.device_pb2 import MonitoringSettings +from device.proto.kpi_sample_types_pb2 import KpiSampleType +from device.service.DeviceService import DeviceService +from device.service.driver_api._Driver import _Driver +from .MockService_Dependencies import MockService_Dependencies +from .PrepareTestScenario import ( # pylint: disable=unused-import + # be careful, order of symbols is important here! + mock_service, device_service, context_client, device_client, monitoring_client, test_prepare_environment) + +from .Device_Emulated import ( + DEVICE_EMU, DEVICE_EMU_CONFIG_ADDRESSES, DEVICE_EMU_CONFIG_ENDPOINTS, DEVICE_EMU_CONNECT_RULES, + DEVICE_EMU_DECONFIG_ADDRESSES, DEVICE_EMU_DECONFIG_ENDPOINTS, DEVICE_EMU_ENDPOINTS_COOKED, DEVICE_EMU_ID, + DEVICE_EMU_RECONFIG_ADDRESSES, DEVICE_EMU_UUID) + +logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING) +logging.getLogger('apscheduler.scheduler').setLevel(logging.WARNING) +logging.getLogger('monitoring-client').setLevel(logging.WARNING) + +LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.DEBUG) + +# ----- Test Device Driver Emulated -------------------------------------------- +# Device Driver Emulated tests are used to validate Driver API as well as Emulated Device Driver. Note that other +# Drivers might support a different set of resource paths, and attributes/values per resource; however, they must +# implement the Driver API. + +def test_device_emulated_add_error_cases( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService): # pylint: disable=redefined-outer-name + + with pytest.raises(grpc.RpcError) as e: + DEVICE_EMU_WITH_ENDPOINTS = copy.deepcopy(DEVICE_EMU) + DEVICE_EMU_WITH_ENDPOINTS['device_endpoints'].append(json_endpoint(DEVICE_EMU_ID, 'ep-id', 'ep-type')) + device_client.AddDevice(Device(**DEVICE_EMU_WITH_ENDPOINTS)) + assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT + msg_head = 'device.device_endpoints([' + msg_tail = ']) is invalid; RPC method AddDevice does not accept Endpoints. '\ + 'Endpoints are discovered through interrogation of the physical device.' + except_msg = str(e.value.details()) + assert except_msg.startswith(msg_head) and except_msg.endswith(msg_tail) + + with pytest.raises(grpc.RpcError) as e: + DEVICE_EMU_WITH_EXTRA_RULES = copy.deepcopy(DEVICE_EMU) + DEVICE_EMU_WITH_EXTRA_RULES['device_config']['config_rules'].extend(DEVICE_EMU_CONNECT_RULES) + DEVICE_EMU_WITH_EXTRA_RULES['device_config']['config_rules'].extend(DEVICE_EMU_CONFIG_ENDPOINTS) + device_client.AddDevice(Device(**DEVICE_EMU_WITH_EXTRA_RULES)) + assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT + msg_head = 'device.device_config.config_rules([' + msg_tail = ']) is invalid; RPC method AddDevice only accepts connection Config Rules that should start '\ + 'with "_connect/" tag. Others should be configured after adding the device.' + except_msg = str(e.value.details()) + assert except_msg.startswith(msg_head) and except_msg.endswith(msg_tail) + + +def test_device_emulated_add_correct( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService): # pylint: disable=redefined-outer-name + + DEVICE_EMU_WITH_CONNECT_RULES = copy.deepcopy(DEVICE_EMU) + DEVICE_EMU_WITH_CONNECT_RULES['device_config']['config_rules'].extend(DEVICE_EMU_CONNECT_RULES) + device_client.AddDevice(Device(**DEVICE_EMU_WITH_CONNECT_RULES)) + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(DEVICE_EMU_UUID) # we know the driver exists now + assert driver is not None + + +def test_device_emulated_get( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService): # pylint: disable=redefined-outer-name + + initial_config = device_client.GetInitialConfig(DeviceId(**DEVICE_EMU_ID)) + LOGGER.info('initial_config = {:s}'.format(grpc_message_to_json_string(initial_config))) + + device_data = context_client.GetDevice(DeviceId(**DEVICE_EMU_ID)) + LOGGER.info('device_data = {:s}'.format(grpc_message_to_json_string(device_data))) + + +def test_device_emulated_configure( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService): # pylint: disable=redefined-outer-name + + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(DEVICE_EMU_UUID) # we know the driver exists now + assert driver is not None + + driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + assert len(driver_config) == len(DEVICE_EMU_ENDPOINTS_COOKED) + for endpoint_cooked in DEVICE_EMU_ENDPOINTS_COOKED: + assert endpoint_cooked in driver_config + + DEVICE_EMU_WITH_CONFIG_RULES = copy.deepcopy(DEVICE_EMU) + DEVICE_EMU_WITH_CONFIG_RULES['device_config']['config_rules'].extend(DEVICE_EMU_CONFIG_ENDPOINTS) + device_client.ConfigureDevice(Device(**DEVICE_EMU_WITH_CONFIG_RULES)) + + DEVICE_EMU_WITH_CONFIG_RULES = copy.deepcopy(DEVICE_EMU) + DEVICE_EMU_WITH_CONFIG_RULES['device_config']['config_rules'].extend(DEVICE_EMU_CONFIG_ADDRESSES) + device_client.ConfigureDevice(Device(**DEVICE_EMU_WITH_CONFIG_RULES)) + + DEVICE_EMU_WITH_OPERATIONAL_STATUS = copy.deepcopy(DEVICE_EMU) + DEVICE_EMU_WITH_OPERATIONAL_STATUS['device_operational_status'] = \ + DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_ENABLED + device_client.ConfigureDevice(Device(**DEVICE_EMU_WITH_OPERATIONAL_STATUS)) + + driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + assert len(driver_config) == len(DEVICE_EMU_ENDPOINTS_COOKED) + len(DEVICE_EMU_CONFIG_ADDRESSES) + for endpoint_cooked in DEVICE_EMU_ENDPOINTS_COOKED: + endpoint_cooked = copy.deepcopy(endpoint_cooked) + endpoint_cooked[1]['enabled'] = True + assert endpoint_cooked in driver_config + for config_rule in DEVICE_EMU_CONFIG_ADDRESSES: + assert (config_rule['resource_key'], json.loads(config_rule['resource_value'])) in driver_config + + device_data = context_client.GetDevice(DeviceId(**DEVICE_EMU_ID)) + assert device_data.device_operational_status == DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_ENABLED + + config_rules = [ + (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) + for config_rule in device_data.device_config.config_rules + ] + #LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( + # '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) + RESULTING_CONFIG_ENDPOINTS = {cr['resource_key']:cr for cr in copy.deepcopy(DEVICE_EMU_CONFIG_ENDPOINTS)} + for endpoint_cooked in DEVICE_EMU_ENDPOINTS_COOKED: + values = json.loads(RESULTING_CONFIG_ENDPOINTS[endpoint_cooked[0]]['resource_value']) + values.update(endpoint_cooked[1]) + RESULTING_CONFIG_ENDPOINTS[endpoint_cooked[0]]['resource_value'] = json.dumps(values, sort_keys=True) + for config_rule in RESULTING_CONFIG_ENDPOINTS.values(): + config_rule = ( + ConfigActionEnum.Name(config_rule['action']), config_rule['resource_key'], + json.loads(json.dumps(config_rule['resource_value']))) + assert config_rule in config_rules + for config_rule in DEVICE_EMU_CONFIG_ADDRESSES: + config_rule = ( + ConfigActionEnum.Name(config_rule['action']), config_rule['resource_key'], + json.loads(json.dumps(config_rule['resource_value']))) + assert config_rule in config_rules + + # Try to reconfigure... + + DEVICE_EMU_WITH_RECONFIG_RULES = copy.deepcopy(DEVICE_EMU) + DEVICE_EMU_WITH_RECONFIG_RULES['device_operational_status'] = \ + DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_ENABLED + DEVICE_EMU_WITH_RECONFIG_RULES['device_config']['config_rules'].extend(DEVICE_EMU_RECONFIG_ADDRESSES) + device_client.ConfigureDevice(Device(**DEVICE_EMU_WITH_RECONFIG_RULES)) + + RESULTING_CONFIG_RULES = {cr['resource_key']:cr for cr in copy.deepcopy(DEVICE_EMU_CONFIG_ENDPOINTS)} + for endpoint_cooked in DEVICE_EMU_ENDPOINTS_COOKED: + values = json.loads(RESULTING_CONFIG_RULES[endpoint_cooked[0]]['resource_value']) + values.update(endpoint_cooked[1]) + RESULTING_CONFIG_RULES[endpoint_cooked[0]]['resource_value'] = json.dumps(values, sort_keys=True) + RESULTING_CONFIG_RULES.update({cr['resource_key']:cr for cr in copy.deepcopy(DEVICE_EMU_CONFIG_ADDRESSES)}) + for reconfig_rule in DEVICE_EMU_RECONFIG_ADDRESSES: + if reconfig_rule['action'] == ConfigActionEnum.CONFIGACTION_DELETE: + RESULTING_CONFIG_RULES.pop(reconfig_rule['resource_key'], None) + else: + RESULTING_CONFIG_RULES[reconfig_rule['resource_key']] = reconfig_rule + RESULTING_CONFIG_RULES = RESULTING_CONFIG_RULES.values() + #LOGGER.info('RESULTING_CONFIG_RULES = {:s}'.format(str(RESULTING_CONFIG_RULES))) + + driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + driver_config = json.loads(json.dumps(driver_config)) # prevent integer keys to fail matching with string keys + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + assert len(driver_config) == len(RESULTING_CONFIG_RULES) + for config_rule in RESULTING_CONFIG_RULES: + resource = [config_rule['resource_key'], json.loads(config_rule['resource_value'])] + assert resource in driver_config + + device_data = context_client.GetDevice(DeviceId(**DEVICE_EMU_ID)) + config_rules = [ + (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) + for config_rule in device_data.device_config.config_rules + ] + #LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( + # '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) + for config_rule in RESULTING_CONFIG_RULES: + config_rule = ( + ConfigActionEnum.Name(config_rule['action']), config_rule['resource_key'], config_rule['resource_value']) + assert config_rule in config_rules + + +def test_device_emulated_monitor( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService, # pylint: disable=redefined-outer-name + mock_service : MockService_Dependencies): # pylint: disable=redefined-outer-name + + device_uuid = DEVICE_EMU_UUID + json_device_id = DEVICE_EMU_ID + device_id = DeviceId(**json_device_id) + device_data = context_client.GetDevice(device_id) + LOGGER.info('device_data = \n{:s}'.format(str(device_data))) + + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(device_uuid) # we know the driver exists now + assert driver is not None + #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + #assert len(driver_config) == len(DEVICE_EMU_ENDPOINTS_COOKED) + len(DEVICE_EMU_CONFIG_ADDRESSES) + + SAMPLING_DURATION_SEC = 10.0 + SAMPLING_INTERVAL_SEC = 2.0 + + MONITORING_SETTINGS_LIST = [] + KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED = {} + for endpoint in device_data.device_endpoints: + endpoint_uuid = endpoint.endpoint_id.endpoint_uuid.uuid + for sample_type_id in endpoint.kpi_sample_types: + sample_type_name = str(KpiSampleType.Name(sample_type_id)).upper().replace('KPISAMPLETYPE_', '') + kpi_uuid = '{:s}-{:s}-{:s}-kpi_uuid'.format(device_uuid, endpoint_uuid, str(sample_type_id)) + monitoring_settings = { + 'kpi_id' : {'kpi_id': {'uuid': kpi_uuid}}, + 'kpi_descriptor': { + 'kpi_description': 'Metric {:s} for Endpoint {:s} in Device {:s}'.format( + sample_type_name, endpoint_uuid, device_uuid), + 'kpi_sample_type': sample_type_id, + 'device_id': json_device_id, + 'endpoint_id': json_endpoint_id(json_device_id, endpoint_uuid), + }, + 'sampling_duration_s': SAMPLING_DURATION_SEC, + 'sampling_interval_s': SAMPLING_INTERVAL_SEC, + } + MONITORING_SETTINGS_LIST.append(monitoring_settings) + KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED[kpi_uuid] = 0 + + NUM_SAMPLES_EXPECTED_PER_KPI = SAMPLING_DURATION_SEC / SAMPLING_INTERVAL_SEC + NUM_SAMPLES_EXPECTED = len(MONITORING_SETTINGS_LIST) * NUM_SAMPLES_EXPECTED_PER_KPI + + # Start monitoring the device + t_start_monitoring = datetime.timestamp(datetime.utcnow()) + for monitoring_settings in MONITORING_SETTINGS_LIST: + device_client.MonitorDeviceKpi(MonitoringSettings(**monitoring_settings)) + + # wait to receive the expected number of samples + # if takes more than 1.5 times the sampling duration, assume there is an error + time_ini = time.time() + queue_samples : queue.Queue = mock_service.queue_samples + received_samples = [] + while (len(received_samples) < NUM_SAMPLES_EXPECTED) and (time.time() - time_ini < SAMPLING_DURATION_SEC * 1.5): + try: + received_sample = queue_samples.get(block=True, timeout=SAMPLING_INTERVAL_SEC / NUM_SAMPLES_EXPECTED) + #LOGGER.info('received_sample = {:s}'.format(str(received_sample))) + received_samples.append(received_sample) + except queue.Empty: + continue + + t_end_monitoring = datetime.timestamp(datetime.utcnow()) + + #LOGGER.info('received_samples = {:s}'.format(str(received_samples))) + LOGGER.info('len(received_samples) = {:s}'.format(str(len(received_samples)))) + LOGGER.info('NUM_SAMPLES_EXPECTED = {:s}'.format(str(NUM_SAMPLES_EXPECTED))) + assert len(received_samples) == NUM_SAMPLES_EXPECTED + for received_sample in received_samples: + kpi_uuid = received_sample.kpi_id.kpi_id.uuid + assert kpi_uuid in KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED + assert isinstance(received_sample.timestamp, str) + try: + timestamp = float(received_sample.timestamp) + except ValueError: + dt_time = dateutil.parser.isoparse(received_sample.timestamp).replace(tzinfo=timezone.utc) + timestamp = float(calendar.timegm(dt_time.timetuple())) + (dt_time.microsecond / 1.e6) + assert timestamp > t_start_monitoring + assert timestamp < t_end_monitoring + assert received_sample.kpi_value.HasField('floatVal') or received_sample.kpi_value.HasField('intVal') + kpi_value = getattr(received_sample.kpi_value, received_sample.kpi_value.WhichOneof('value')) + assert isinstance(kpi_value, (float, int)) + KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED[kpi_uuid] += 1 + + LOGGER.info('KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED = {:s}'.format(str(KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED))) + for kpi_uuid, num_samples_received in KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED.items(): + assert num_samples_received == NUM_SAMPLES_EXPECTED_PER_KPI + + # Unsubscribe monitoring + for kpi_uuid in KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED.keys(): + MONITORING_SETTINGS_UNSUBSCRIBE = { + 'kpi_id' : {'kpi_id': {'uuid': kpi_uuid}}, + 'sampling_duration_s': -1, # negative value in sampling_duration_s or sampling_interval_s means unsibscribe + 'sampling_interval_s': -1, # kpi_id is mandatory to unsibscribe + } + device_client.MonitorDeviceKpi(MonitoringSettings(**MONITORING_SETTINGS_UNSUBSCRIBE)) + + +def test_device_emulated_deconfigure( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService): # pylint: disable=redefined-outer-name + + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(DEVICE_EMU_UUID) # we know the driver exists now + assert driver is not None + + driver_config = driver.GetConfig() + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + + DEVICE_EMU_WITH_DECONFIG_RULES = copy.deepcopy(DEVICE_EMU) + DEVICE_EMU_WITH_DECONFIG_RULES['device_operational_status'] = \ + DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_DISABLED + DEVICE_EMU_WITH_DECONFIG_RULES['device_config']['config_rules'].extend(DEVICE_EMU_DECONFIG_ADDRESSES) + device_client.ConfigureDevice(Device(**DEVICE_EMU_WITH_DECONFIG_RULES)) + + RESULTING_CONFIG_RULES = {cr['resource_key']:cr for cr in copy.deepcopy(DEVICE_EMU_CONFIG_ENDPOINTS)} + for endpoint_cooked in DEVICE_EMU_ENDPOINTS_COOKED: + values = json.loads(RESULTING_CONFIG_RULES[endpoint_cooked[0]]['resource_value']) + values.update(endpoint_cooked[1]) + RESULTING_CONFIG_RULES[endpoint_cooked[0]]['resource_value'] = json.dumps(values, sort_keys=True) + RESULTING_CONFIG_RULES = RESULTING_CONFIG_RULES.values() + driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + driver_config = json.loads(json.dumps(driver_config)) # prevent integer keys to fail matching with string keys + driver_config = list(filter( + lambda config_rule: ( + not isinstance(config_rule[1], str) or not config_rule[1].startswith('do_sampling (trigger:')), + driver_config)) + LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + LOGGER.info('RESULTING_CONFIG_RULES = {:s}'.format(str(RESULTING_CONFIG_RULES))) + assert len(driver_config) == len(RESULTING_CONFIG_RULES) + for config_rule in RESULTING_CONFIG_RULES: + config_rule = [config_rule['resource_key'], json.loads(config_rule['resource_value'])] + #LOGGER.info('config_rule = {:s}'.format(str(config_rule))) + assert config_rule in driver_config + + DEVICE_EMU_WITH_DECONFIG_RULES = copy.deepcopy(DEVICE_EMU) + DEVICE_EMU_WITH_DECONFIG_RULES['device_config']['config_rules'].extend(DEVICE_EMU_DECONFIG_ENDPOINTS) + device_client.ConfigureDevice(Device(**DEVICE_EMU_WITH_DECONFIG_RULES)) + + driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + driver_config = json.loads(json.dumps(driver_config)) # prevent integer keys to fail matching with string keys + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + assert len(driver_config) == 0 + + device_data = context_client.GetDevice(DeviceId(**DEVICE_EMU_ID)) + config_rules = device_data.device_config.config_rules + LOGGER.info('config_rules = {:s}'.format(str(config_rules))) + clean_config_rules = [] + for config_rule in config_rules: + if config_rule.resource_key.startswith('/endpoints/endpoint'): continue + config_rule_value = json.loads(config_rule.resource_value) + if isinstance(config_rule_value, str) and config_rule_value.startswith('do_sampling (trigger:'): continue + clean_config_rules.append(config_rule) + LOGGER.info('clean_config_rules = {:s}'.format(str(clean_config_rules))) + assert len(clean_config_rules) == 0 + + +def test_device_emulated_delete( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService): # pylint: disable=redefined-outer-name + + device_client.DeleteDevice(DeviceId(**DEVICE_EMU_ID)) + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(DEVICE_EMU_UUID, {}) + assert driver is None diff --git a/src/device/tests/test_unitary_microwave.py b/src/device/tests/test_unitary_microwave.py new file mode 100644 index 0000000000000000000000000000000000000000..c5cd70b993971812cd89dd970e9835cfd04a548f --- /dev/null +++ b/src/device/tests/test_unitary_microwave.py @@ -0,0 +1,167 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import copy, grpc, logging, pytest +from common.tools.grpc.Tools import grpc_message_to_json_string +from context.client.ContextClient import ContextClient +from context.proto.context_pb2 import DeviceId +from device.client.DeviceClient import DeviceClient +from device.proto.context_pb2 import ConfigActionEnum, Device +from device.service.DeviceService import DeviceService +from device.service.driver_api._Driver import _Driver +from .PrepareTestScenario import ( # pylint: disable=unused-import + # be careful, order of symbols is important here! + mock_service, device_service, context_client, device_client, monitoring_client, test_prepare_environment) + +try: + from .Device_Microwave_Template import ( + DEVICE_MICROWAVE, DEVICE_MICROWAVE_CONNECT_RULES, DEVICE_MICROWAVE_UUID, DEVICE_MICROWAVE_ID, + DEVICE_MICROWAVE_CONFIG_RULES, DEVICE_MICROWAVE_DECONFIG_RULES) + ENABLE_MICROWAVE = True +except ImportError: + ENABLE_MICROWAVE = False + +LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.DEBUG) + + +# ----- Test Device Driver Microwave ------------------------------------------------ + +def test_device_microwave_add_error_cases( + device_client : DeviceClient): # pylint: disable=redefined-outer-name + + if not ENABLE_MICROWAVE: pytest.skip('Skipping test: No TAPI device has been configured') + + with pytest.raises(grpc.RpcError) as e: + DEVICE_MICROWAVE_WITH_EXTRA_RULES = copy.deepcopy(DEVICE_MICROWAVE) + DEVICE_MICROWAVE_WITH_EXTRA_RULES['device_config']['config_rules'].extend(DEVICE_MICROWAVE_CONNECT_RULES) + DEVICE_MICROWAVE_WITH_EXTRA_RULES['device_config']['config_rules'].extend(DEVICE_MICROWAVE_CONFIG_RULES) + device_client.AddDevice(Device(**DEVICE_MICROWAVE_WITH_EXTRA_RULES)) + assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT + msg_head = 'device.device_config.config_rules([' + msg_tail = ']) is invalid; RPC method AddDevice only accepts connection Config Rules that should start '\ + 'with "_connect/" tag. Others should be configured after adding the device.' + except_msg = str(e.value.details()) + assert except_msg.startswith(msg_head) and except_msg.endswith(msg_tail) + + +def test_device_microwave_add_correct( + device_client: DeviceClient, # pylint: disable=redefined-outer-name + device_service: DeviceService): # pylint: disable=redefined-outer-name + + if not ENABLE_MICROWAVE: pytest.skip('Skipping test: No MICROWAVE device has been configured') + + DEVICE_MICROWAVE_WITH_CONNECT_RULES = copy.deepcopy(DEVICE_MICROWAVE) + DEVICE_MICROWAVE_WITH_CONNECT_RULES['device_config']['config_rules'].extend(DEVICE_MICROWAVE_CONNECT_RULES) + device_client.AddDevice(Device(**DEVICE_MICROWAVE_WITH_CONNECT_RULES)) + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver: _Driver = driver_instance_cache.get(DEVICE_MICROWAVE_UUID) + assert driver is not None + + +def test_device_microwave_get( + context_client: ContextClient, # pylint: disable=redefined-outer-name + device_client: DeviceClient): # pylint: disable=redefined-outer-name + + if not ENABLE_MICROWAVE: pytest.skip('Skipping test: No MICROWAVE device has been configured') + + initial_config = device_client.GetInitialConfig(DeviceId(**DEVICE_MICROWAVE_ID)) + LOGGER.info('initial_config = {:s}'.format(grpc_message_to_json_string(initial_config))) + + device_data = context_client.GetDevice(DeviceId(**DEVICE_MICROWAVE_ID)) + LOGGER.info('device_data = {:s}'.format(grpc_message_to_json_string(device_data))) + + +def test_device_microwave_configure( + context_client: ContextClient, # pylint: disable=redefined-outer-name + device_client: DeviceClient, # pylint: disable=redefined-outer-name + device_service: DeviceService): # pylint: disable=redefined-outer-name + + if not ENABLE_MICROWAVE: pytest.skip('Skipping test: No MICROWAVE device has been configured') + + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(DEVICE_MICROWAVE_UUID) + assert driver is not None + + # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. + #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + + DEVICE_MICROWAVE_WITH_CONFIG_RULES = copy.deepcopy(DEVICE_MICROWAVE) + DEVICE_MICROWAVE_WITH_CONFIG_RULES['device_config']['config_rules'].extend(DEVICE_MICROWAVE_CONFIG_RULES) + device_client.ConfigureDevice(Device(**DEVICE_MICROWAVE_WITH_CONFIG_RULES)) + + # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. + #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + + device_data = context_client.GetDevice(DeviceId(**DEVICE_MICROWAVE_ID)) + config_rules = [ + (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) + for config_rule in device_data.device_config.config_rules + ] + LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( + '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) + for config_rule in DEVICE_MICROWAVE_CONFIG_RULES: + config_rule = ( + ConfigActionEnum.Name(config_rule['action']), config_rule['resource_key'], config_rule['resource_value']) + assert config_rule in config_rules + + +def test_device_microwave_deconfigure( + context_client: ContextClient, # pylint: disable=redefined-outer-name + device_client: DeviceClient, # pylint: disable=redefined-outer-name + device_service: DeviceService): # pylint: disable=redefined-outer-name + + if not ENABLE_MICROWAVE: pytest.skip('Skipping test: No MICROWAVE device has been configured') + + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver: _Driver = driver_instance_cache.get(DEVICE_MICROWAVE_UUID) + assert driver is not None + + # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. + #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + + DEVICE_MICROWAVE_WITH_DECONFIG_RULES = copy.deepcopy(DEVICE_MICROWAVE) + DEVICE_MICROWAVE_WITH_DECONFIG_RULES['device_config']['config_rules'].extend(DEVICE_MICROWAVE_DECONFIG_RULES) + device_client.ConfigureDevice(Device(**DEVICE_MICROWAVE_WITH_DECONFIG_RULES)) + + # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. + #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + + device_data = context_client.GetDevice(DeviceId(**DEVICE_MICROWAVE_ID)) + config_rules = [ + (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) + for config_rule in device_data.device_config.config_rules + ] + LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( + '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) + for config_rule in DEVICE_MICROWAVE_DECONFIG_RULES: + action_set = ConfigActionEnum.Name(ConfigActionEnum.CONFIGACTION_SET) + config_rule = (action_set, config_rule['resource_key'], config_rule['resource_value']) + assert config_rule not in config_rules + + +def test_device_microwave_delete( + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService): # pylint: disable=redefined-outer-name + + if not ENABLE_MICROWAVE: pytest.skip('Skipping test: No MICROWAVE device has been configured') + + device_client.DeleteDevice(DeviceId(**DEVICE_MICROWAVE_ID)) + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(DEVICE_MICROWAVE_UUID, {}) + assert driver is None \ No newline at end of file diff --git a/src/device/tests/test_unitary_openconfig.py b/src/device/tests/test_unitary_openconfig.py new file mode 100644 index 0000000000000000000000000000000000000000..968272c04a1304b313d8a988ce0a432e3749a9b8 --- /dev/null +++ b/src/device/tests/test_unitary_openconfig.py @@ -0,0 +1,299 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import calendar, copy, dateutil.parser, grpc, logging, pytest, queue, time +from datetime import datetime, timezone +from common.tools.grpc.Tools import grpc_message_to_json_string +from common.tools.object_factory.EndPoint import json_endpoint_id +from context.client.ContextClient import ContextClient +from context.proto.context_pb2 import DeviceId +from device.client.DeviceClient import DeviceClient +from device.proto.context_pb2 import ConfigActionEnum, Device +from device.proto.device_pb2 import MonitoringSettings +from device.proto.kpi_sample_types_pb2 import KpiSampleType +from device.service.DeviceService import DeviceService +from device.service.driver_api._Driver import _Driver +from .MockService_Dependencies import MockService_Dependencies +from .PrepareTestScenario import ( # pylint: disable=unused-import + # be careful, order of symbols is important here! + mock_service, device_service, context_client, device_client, monitoring_client, test_prepare_environment) + +try: + from .Device_OpenConfig_Infinera1 import( + #from .Device_OpenConfig_Infinera2 import( + DEVICE_OC, DEVICE_OC_CONFIG_RULES, DEVICE_OC_DECONFIG_RULES, DEVICE_OC_CONNECT_RULES, DEVICE_OC_ID, + DEVICE_OC_UUID) + ENABLE_OPENCONFIG = True +except ImportError: + ENABLE_OPENCONFIG = False + +ENABLE_OPENCONFIG_CONFIGURE = True +ENABLE_OPENCONFIG_MONITOR = True +ENABLE_OPENCONFIG_DECONFIGURE = True + + +logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING) +logging.getLogger('apscheduler.scheduler').setLevel(logging.WARNING) +logging.getLogger('monitoring-client').setLevel(logging.WARNING) + +LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.DEBUG) + + +# ----- Test Device Driver OpenConfig ------------------------------------------ + +def test_device_openconfig_add_error_cases( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService): # pylint: disable=redefined-outer-name + + if not ENABLE_OPENCONFIG: pytest.skip('Skipping test: No OpenConfig device has been configured') + + with pytest.raises(grpc.RpcError) as e: + DEVICE_OC_WITH_EXTRA_RULES = copy.deepcopy(DEVICE_OC) + DEVICE_OC_WITH_EXTRA_RULES['device_config']['config_rules'].extend(DEVICE_OC_CONNECT_RULES) + DEVICE_OC_WITH_EXTRA_RULES['device_config']['config_rules'].extend(DEVICE_OC_CONFIG_RULES) + device_client.AddDevice(Device(**DEVICE_OC_WITH_EXTRA_RULES)) + assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT + msg_head = 'device.device_config.config_rules([' + msg_tail = ']) is invalid; RPC method AddDevice only accepts connection Config Rules that should start '\ + 'with "_connect/" tag. Others should be configured after adding the device.' + except_msg = str(e.value.details()) + assert except_msg.startswith(msg_head) and except_msg.endswith(msg_tail) + + +def test_device_openconfig_add_correct( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService): # pylint: disable=redefined-outer-name + + if not ENABLE_OPENCONFIG: pytest.skip('Skipping test: No OpenConfig device has been configured') + + DEVICE_OC_WITH_CONNECT_RULES = copy.deepcopy(DEVICE_OC) + DEVICE_OC_WITH_CONNECT_RULES['device_config']['config_rules'].extend(DEVICE_OC_CONNECT_RULES) + device_client.AddDevice(Device(**DEVICE_OC_WITH_CONNECT_RULES)) + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(DEVICE_OC_UUID) # we know the driver exists now + assert driver is not None + + device_data = context_client.GetDevice(DeviceId(**DEVICE_OC_ID)) + config_rules = [ + (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) + for config_rule in device_data.device_config.config_rules + ] + LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( + '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) + + +def test_device_openconfig_get( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService): # pylint: disable=redefined-outer-name + + if not ENABLE_OPENCONFIG: pytest.skip('Skipping test: No OpenConfig device has been configured') + + initial_config = device_client.GetInitialConfig(DeviceId(**DEVICE_OC_ID)) + LOGGER.info('initial_config = {:s}'.format(grpc_message_to_json_string(initial_config))) + + device_data = context_client.GetDevice(DeviceId(**DEVICE_OC_ID)) + LOGGER.info('device_data = {:s}'.format(grpc_message_to_json_string(device_data))) + + +def test_device_openconfig_configure( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService): # pylint: disable=redefined-outer-name + + if not ENABLE_OPENCONFIG: pytest.skip('Skipping test: No OpenConfig device has been configured') + if not ENABLE_OPENCONFIG_CONFIGURE: pytest.skip('Skipping test OpenConfig configure') + + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(DEVICE_OC_UUID) # we know the driver exists now + assert driver is not None + + # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. + #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + + DEVICE_OC_WITH_CONFIG_RULES = copy.deepcopy(DEVICE_OC) + DEVICE_OC_WITH_CONFIG_RULES['device_config']['config_rules'].extend(DEVICE_OC_CONFIG_RULES) + device_client.ConfigureDevice(Device(**DEVICE_OC_WITH_CONFIG_RULES)) + + # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. + #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + + device_data = context_client.GetDevice(DeviceId(**DEVICE_OC_ID)) + config_rules = [ + (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) + for config_rule in device_data.device_config.config_rules + ] + LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( + '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) + for config_rule in DEVICE_OC_CONFIG_RULES: + config_rule = ( + ConfigActionEnum.Name(config_rule['action']), config_rule['resource_key'], config_rule['resource_value']) + assert config_rule in config_rules + + +def test_device_openconfig_monitor( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService, # pylint: disable=redefined-outer-name + mock_service : MockService_Dependencies): # pylint: disable=redefined-outer-name + + if not ENABLE_OPENCONFIG: pytest.skip('Skipping test: No OpenConfig device has been configured') + if not ENABLE_OPENCONFIG_MONITOR: pytest.skip('Skipping test OpenConfig monitor') + + device_uuid = DEVICE_OC_UUID + json_device_id = DEVICE_OC_ID + device_id = DeviceId(**json_device_id) + device_data = context_client.GetDevice(device_id) + #LOGGER.info('device_data = \n{:s}'.format(str(device_data))) + + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(device_uuid) # we know the driver exists now + assert driver is not None + + SAMPLING_DURATION_SEC = 60.0 + SAMPLING_INTERVAL_SEC = 15.0 + + MONITORING_SETTINGS_LIST = [] + KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED = {} + for endpoint in device_data.device_endpoints: + endpoint_uuid = endpoint.endpoint_id.endpoint_uuid.uuid + for sample_type_id in endpoint.kpi_sample_types: + sample_type_name = str(KpiSampleType.Name(sample_type_id)).upper().replace('KPISAMPLETYPE_', '') + kpi_uuid = '{:s}-{:s}-{:s}-kpi_uuid'.format(device_uuid, endpoint_uuid, str(sample_type_id)) + monitoring_settings = { + 'kpi_id' : {'kpi_id': {'uuid': kpi_uuid}}, + 'kpi_descriptor': { + 'kpi_description': 'Metric {:s} for Endpoint {:s} in Device {:s}'.format( + sample_type_name, endpoint_uuid, device_uuid), + 'kpi_sample_type': sample_type_id, + 'device_id': json_device_id, + 'endpoint_id': json_endpoint_id(json_device_id, endpoint_uuid), + }, + 'sampling_duration_s': SAMPLING_DURATION_SEC, + 'sampling_interval_s': SAMPLING_INTERVAL_SEC, + } + MONITORING_SETTINGS_LIST.append(monitoring_settings) + KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED[kpi_uuid] = 0 + + NUM_SAMPLES_EXPECTED_PER_KPI = SAMPLING_DURATION_SEC / SAMPLING_INTERVAL_SEC + NUM_SAMPLES_EXPECTED = len(MONITORING_SETTINGS_LIST) * NUM_SAMPLES_EXPECTED_PER_KPI + + # Start monitoring the device + t_start_monitoring = datetime.timestamp(datetime.utcnow()) + for monitoring_settings in MONITORING_SETTINGS_LIST: + device_client.MonitorDeviceKpi(MonitoringSettings(**monitoring_settings)) + + # wait to receive the expected number of samples + # if takes more than 1.5 times the sampling duration, assume there is an error + time_ini = time.time() + queue_samples : queue.Queue = mock_service.queue_samples + received_samples = [] + while (len(received_samples) < NUM_SAMPLES_EXPECTED) and (time.time() - time_ini < SAMPLING_DURATION_SEC * 1.5): + try: + received_sample = queue_samples.get(block=True, timeout=SAMPLING_INTERVAL_SEC / NUM_SAMPLES_EXPECTED) + #LOGGER.info('received_sample = {:s}'.format(str(received_sample))) + received_samples.append(received_sample) + except queue.Empty: + continue + + t_end_monitoring = datetime.timestamp(datetime.utcnow()) + + #LOGGER.info('received_samples = {:s}'.format(str(received_samples))) + LOGGER.info('len(received_samples) = {:s}'.format(str(len(received_samples)))) + LOGGER.info('NUM_SAMPLES_EXPECTED = {:s}'.format(str(NUM_SAMPLES_EXPECTED))) + #assert len(received_samples) == NUM_SAMPLES_EXPECTED + for received_sample in received_samples: + kpi_uuid = received_sample.kpi_id.kpi_id.uuid + assert kpi_uuid in KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED + assert isinstance(received_sample.timestamp, str) + try: + timestamp = float(received_sample.timestamp) + except ValueError: + dt_time = dateutil.parser.isoparse(received_sample.timestamp).replace(tzinfo=timezone.utc) + timestamp = float(calendar.timegm(dt_time.timetuple())) + (dt_time.microsecond / 1.e6) + assert timestamp > t_start_monitoring + assert timestamp < t_end_monitoring + assert received_sample.kpi_value.HasField('floatVal') or received_sample.kpi_value.HasField('intVal') + kpi_value = getattr(received_sample.kpi_value, received_sample.kpi_value.WhichOneof('value')) + assert isinstance(kpi_value, (float, int)) + KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED[kpi_uuid] += 1 + + LOGGER.info('KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED = {:s}'.format(str(KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED))) + # TODO: review why num_samples_received per KPI != NUM_SAMPLES_EXPECTED_PER_KPI + #for kpi_uuid, num_samples_received in KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED.items(): + # assert num_samples_received == NUM_SAMPLES_EXPECTED_PER_KPI + + # Unsubscribe monitoring + for kpi_uuid in KPI_UUIDS__TO__NUM_SAMPLES_RECEIVED: + MONITORING_SETTINGS_UNSUBSCRIBE = { + 'kpi_id' : {'kpi_id': {'uuid': kpi_uuid}}, + 'sampling_duration_s': -1, # negative value in sampling_duration_s or sampling_interval_s means unsibscribe + 'sampling_interval_s': -1, # kpi_id is mandatory to unsibscribe + } + device_client.MonitorDeviceKpi(MonitoringSettings(**MONITORING_SETTINGS_UNSUBSCRIBE)) + + +def test_device_openconfig_deconfigure( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService): # pylint: disable=redefined-outer-name + + if not ENABLE_OPENCONFIG: pytest.skip('Skipping test: No OpenConfig device has been configured') + if not ENABLE_OPENCONFIG_DECONFIGURE: pytest.skip('Skipping test OpenConfig deconfigure') + + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(DEVICE_OC_UUID) # we know the driver exists now + assert driver is not None + + # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. + #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + + DEVICE_OC_WITH_DECONFIG_RULES = copy.deepcopy(DEVICE_OC) + DEVICE_OC_WITH_DECONFIG_RULES['device_config']['config_rules'].extend(DEVICE_OC_DECONFIG_RULES) + device_client.ConfigureDevice(Device(**DEVICE_OC_WITH_DECONFIG_RULES)) + + # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. + #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + + device_data = context_client.GetDevice(DeviceId(**DEVICE_OC_ID)) + config_rules = [ + (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) + for config_rule in device_data.device_config.config_rules + ] + LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( + '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) + for config_rule in DEVICE_OC_DECONFIG_RULES: + action_set = ConfigActionEnum.Name(ConfigActionEnum.CONFIGACTION_SET) + config_rule = (action_set, config_rule['resource_key'], config_rule['resource_value']) + assert config_rule not in config_rules + + +def test_device_openconfig_delete( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService): # pylint: disable=redefined-outer-name + + if not ENABLE_OPENCONFIG: pytest.skip('Skipping test: No OpenConfig device has been configured') + + device_client.DeleteDevice(DeviceId(**DEVICE_OC_ID)) + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(DEVICE_OC_UUID, {}) + assert driver is None diff --git a/src/device/tests/test_unitary_p4.py b/src/device/tests/test_unitary_p4.py new file mode 100644 index 0000000000000000000000000000000000000000..d8a5d37b8f01685f10ab2d2ec967d09312fc4cc4 --- /dev/null +++ b/src/device/tests/test_unitary_p4.py @@ -0,0 +1,146 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import copy, grpc, logging, pytest +from common.tools.grpc.Tools import grpc_message_to_json_string +from context.client.ContextClient import ContextClient +from context.proto.context_pb2 import DeviceId +from device.client.DeviceClient import DeviceClient +from device.proto.context_pb2 import Device +from device.service.DeviceService import DeviceService +from device.service.driver_api._Driver import _Driver +from .PrepareTestScenario import ( # pylint: disable=unused-import + # be careful, order of symbols is important here! + mock_service, device_service, context_client, device_client, monitoring_client, test_prepare_environment) + +from .mock_p4runtime_service import MockP4RuntimeService +try: + from .device_p4 import( + DEVICE_P4, DEVICE_P4_ID, DEVICE_P4_UUID, DEVICE_P4_ADDRESS, DEVICE_P4_PORT, DEVICE_P4_WORKERS, + DEVICE_P4_GRACE_PERIOD, DEVICE_P4_CONNECT_RULES, DEVICE_P4_CONFIG_RULES) + ENABLE_P4 = True +except ImportError: + ENABLE_P4 = False + +LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.DEBUG) + +@pytest.fixture(scope='session') +def p4runtime_service(): + _service = MockP4RuntimeService( + address=DEVICE_P4_ADDRESS, port=DEVICE_P4_PORT, + max_workers=DEVICE_P4_WORKERS, + grace_period=DEVICE_P4_GRACE_PERIOD) + _service.start() + yield _service + _service.stop() + + +# ----- Test Device Driver P4 -------------------------------------------------- + +def test_device_p4_add_error_cases( + context_client: ContextClient, # pylint: disable=redefined-outer-name + device_client: DeviceClient, # pylint: disable=redefined-outer-name + device_service: DeviceService): # pylint: disable=redefined-outer-name + + if not ENABLE_P4: pytest.skip( + 'Skipping test: No P4 device has been configured') + + with pytest.raises(grpc.RpcError) as e: + device_p4_with_extra_rules = copy.deepcopy(DEVICE_P4) + device_p4_with_extra_rules['device_config']['config_rules'].extend( + DEVICE_P4_CONNECT_RULES) + device_p4_with_extra_rules['device_config']['config_rules'].extend( + DEVICE_P4_CONFIG_RULES) + device_client.AddDevice(Device(**device_p4_with_extra_rules)) + assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT + msg_head = 'device.device_config.config_rules([' + msg_tail = ']) is invalid; RPC method AddDevice only accepts connection Config Rules that should start '\ + 'with "_connect/" tag. Others should be configured after adding the device.' + except_msg = str(e.value.details()) + assert except_msg.startswith(msg_head) and except_msg.endswith(msg_tail) + + +def test_device_p4_add_correct( + context_client: ContextClient, # pylint: disable=redefined-outer-name + device_client: DeviceClient, # pylint: disable=redefined-outer-name + device_service: DeviceService, # pylint: disable=redefined-outer-name + p4runtime_service: MockP4RuntimeService): # pylint: disable=redefined-outer-name + + if not ENABLE_P4: pytest.skip( + 'Skipping test: No P4 device has been configured') + + device_p4_with_connect_rules = copy.deepcopy(DEVICE_P4) + device_p4_with_connect_rules['device_config']['config_rules'].extend( + DEVICE_P4_CONNECT_RULES) + device_client.AddDevice(Device(**device_p4_with_connect_rules)) + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(DEVICE_P4_UUID) + assert driver is not None + + +def test_device_p4_get( + context_client: ContextClient, # pylint: disable=redefined-outer-name + device_client: DeviceClient, # pylint: disable=redefined-outer-name + device_service: DeviceService, # pylint: disable=redefined-outer-name + p4runtime_service: MockP4RuntimeService): # pylint: disable=redefined-outer-name + + if not ENABLE_P4: pytest.skip( + 'Skipping test: No P4 device has been configured') + + initial_config = device_client.GetInitialConfig(DeviceId(**DEVICE_P4_ID)) + LOGGER.info('initial_config = {:s}'.format( + grpc_message_to_json_string(initial_config))) + + device_data = context_client.GetDevice(DeviceId(**DEVICE_P4_ID)) + LOGGER.info('device_data = {:s}'.format( + grpc_message_to_json_string(device_data))) + + +def test_device_p4_configure( + context_client: ContextClient, # pylint: disable=redefined-outer-name + device_client: DeviceClient, # pylint: disable=redefined-outer-name + device_service: DeviceService, # pylint: disable=redefined-outer-name + p4runtime_service: MockP4RuntimeService): # pylint: disable=redefined-outer-name + + if not ENABLE_P4: pytest.skip( + 'Skipping test: No P4 device has been configured') + + pytest.skip('Skipping test for unimplemented method') + + +def test_device_p4_deconfigure( + context_client: ContextClient, # pylint: disable=redefined-outer-name + device_client: DeviceClient, # pylint: disable=redefined-outer-name + device_service: DeviceService, # pylint: disable=redefined-outer-name + p4runtime_service: MockP4RuntimeService): # pylint: disable=redefined-outer-name + + if not ENABLE_P4: pytest.skip( + 'Skipping test: No P4 device has been configured') + + pytest.skip('Skipping test for unimplemented method') + + +def test_device_p4_delete( + context_client: ContextClient, # pylint: disable=redefined-outer-name + device_client: DeviceClient, # pylint: disable=redefined-outer-name + device_service: DeviceService, # pylint: disable=redefined-outer-name + p4runtime_service: MockP4RuntimeService): # pylint: disable=redefined-outer-name + + if not ENABLE_P4: pytest.skip('Skipping test: No P4 device has been configured') + + device_client.DeleteDevice(DeviceId(**DEVICE_P4_ID)) + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(DEVICE_P4_UUID) + assert driver is None diff --git a/src/device/tests/test_unitary_tapi.py b/src/device/tests/test_unitary_tapi.py new file mode 100644 index 0000000000000000000000000000000000000000..ce01619ce6b8144ac81ddd73c700310e23c0b52e --- /dev/null +++ b/src/device/tests/test_unitary_tapi.py @@ -0,0 +1,167 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import copy, grpc, logging, pytest +from common.tools.grpc.Tools import grpc_message_to_json_string +from context.client.ContextClient import ContextClient +from context.proto.context_pb2 import DeviceId +from device.client.DeviceClient import DeviceClient +from device.proto.context_pb2 import ConfigActionEnum, Device +from device.service.DeviceService import DeviceService +from device.service.driver_api._Driver import _Driver +from .PrepareTestScenario import ( # pylint: disable=unused-import + # be careful, order of symbols is important here! + mock_service, device_service, context_client, device_client, monitoring_client, test_prepare_environment) + +try: + from .Device_Transport_Api_CTTC import ( + DEVICE_TAPI, DEVICE_TAPI_CONNECT_RULES, DEVICE_TAPI_UUID, DEVICE_TAPI_ID, DEVICE_TAPI_CONFIG_RULES, + DEVICE_TAPI_DECONFIG_RULES) + ENABLE_TAPI = True +except ImportError: + ENABLE_TAPI = False + +LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.DEBUG) + + +# ----- Test Device Driver TAPI ------------------------------------------------ + +def test_device_tapi_add_error_cases( + device_client : DeviceClient): # pylint: disable=redefined-outer-name + + if not ENABLE_TAPI: pytest.skip('Skipping test: No TAPI device has been configured') + + with pytest.raises(grpc.RpcError) as e: + DEVICE_TAPI_WITH_EXTRA_RULES = copy.deepcopy(DEVICE_TAPI) + DEVICE_TAPI_WITH_EXTRA_RULES['device_config']['config_rules'].extend(DEVICE_TAPI_CONNECT_RULES) + DEVICE_TAPI_WITH_EXTRA_RULES['device_config']['config_rules'].extend(DEVICE_TAPI_CONFIG_RULES) + device_client.AddDevice(Device(**DEVICE_TAPI_WITH_EXTRA_RULES)) + assert e.value.code() == grpc.StatusCode.INVALID_ARGUMENT + msg_head = 'device.device_config.config_rules([' + msg_tail = ']) is invalid; RPC method AddDevice only accepts connection Config Rules that should start '\ + 'with "_connect/" tag. Others should be configured after adding the device.' + except_msg = str(e.value.details()) + assert except_msg.startswith(msg_head) and except_msg.endswith(msg_tail) + + +def test_device_tapi_add_correct( + device_client: DeviceClient, # pylint: disable=redefined-outer-name + device_service: DeviceService): # pylint: disable=redefined-outer-name + + if not ENABLE_TAPI: pytest.skip('Skipping test: No TAPI device has been configured') + + DEVICE_TAPI_WITH_CONNECT_RULES = copy.deepcopy(DEVICE_TAPI) + DEVICE_TAPI_WITH_CONNECT_RULES['device_config']['config_rules'].extend(DEVICE_TAPI_CONNECT_RULES) + device_client.AddDevice(Device(**DEVICE_TAPI_WITH_CONNECT_RULES)) + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver: _Driver = driver_instance_cache.get(DEVICE_TAPI_UUID) + assert driver is not None + + +def test_device_tapi_get( + context_client: ContextClient, # pylint: disable=redefined-outer-name + device_client: DeviceClient): # pylint: disable=redefined-outer-name + + if not ENABLE_TAPI: pytest.skip('Skipping test: No TAPI device has been configured') + + initial_config = device_client.GetInitialConfig(DeviceId(**DEVICE_TAPI_ID)) + LOGGER.info('initial_config = {:s}'.format(grpc_message_to_json_string(initial_config))) + + device_data = context_client.GetDevice(DeviceId(**DEVICE_TAPI_ID)) + LOGGER.info('device_data = {:s}'.format(grpc_message_to_json_string(device_data))) + + +def test_device_tapi_configure( + context_client: ContextClient, # pylint: disable=redefined-outer-name + device_client: DeviceClient, # pylint: disable=redefined-outer-name + device_service: DeviceService): # pylint: disable=redefined-outer-name + + if not ENABLE_TAPI: pytest.skip('Skipping test: No TAPI device has been configured') + + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(DEVICE_TAPI_UUID) + assert driver is not None + + # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. + #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + + DEVICE_TAPI_WITH_CONFIG_RULES = copy.deepcopy(DEVICE_TAPI) + DEVICE_TAPI_WITH_CONFIG_RULES['device_config']['config_rules'].extend(DEVICE_TAPI_CONFIG_RULES) + device_client.ConfigureDevice(Device(**DEVICE_TAPI_WITH_CONFIG_RULES)) + + # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. + #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + + device_data = context_client.GetDevice(DeviceId(**DEVICE_TAPI_ID)) + config_rules = [ + (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) + for config_rule in device_data.device_config.config_rules + ] + LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( + '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) + for config_rule in DEVICE_TAPI_CONFIG_RULES: + config_rule = ( + ConfigActionEnum.Name(config_rule['action']), config_rule['resource_key'], config_rule['resource_value']) + assert config_rule in config_rules + + +def test_device_tapi_deconfigure( + context_client: ContextClient, # pylint: disable=redefined-outer-name + device_client: DeviceClient, # pylint: disable=redefined-outer-name + device_service: DeviceService): # pylint: disable=redefined-outer-name + + if not ENABLE_TAPI: pytest.skip('Skipping test: No TAPI device has been configured') + + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver: _Driver = driver_instance_cache.get(DEVICE_TAPI_UUID) + assert driver is not None + + # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. + #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + + DEVICE_TAPI_WITH_DECONFIG_RULES = copy.deepcopy(DEVICE_TAPI) + DEVICE_TAPI_WITH_DECONFIG_RULES['device_config']['config_rules'].extend(DEVICE_TAPI_DECONFIG_RULES) + device_client.ConfigureDevice(Device(**DEVICE_TAPI_WITH_DECONFIG_RULES)) + + # Requires to retrieve data from device; might be slow. Uncomment only when needed and test does not pass directly. + #driver_config = sorted(driver.GetConfig(), key=operator.itemgetter(0)) + #LOGGER.info('driver_config = {:s}'.format(str(driver_config))) + + device_data = context_client.GetDevice(DeviceId(**DEVICE_TAPI_ID)) + config_rules = [ + (ConfigActionEnum.Name(config_rule.action), config_rule.resource_key, config_rule.resource_value) + for config_rule in device_data.device_config.config_rules + ] + LOGGER.info('device_data.device_config.config_rules = \n{:s}'.format( + '\n'.join(['{:s} {:s} = {:s}'.format(*config_rule) for config_rule in config_rules]))) + for config_rule in DEVICE_TAPI_DECONFIG_RULES: + action_set = ConfigActionEnum.Name(ConfigActionEnum.CONFIGACTION_SET) + config_rule = (action_set, config_rule['resource_key'], config_rule['resource_value']) + assert config_rule not in config_rules + + +def test_device_tapi_delete( + device_client : DeviceClient, # pylint: disable=redefined-outer-name + device_service : DeviceService): # pylint: disable=redefined-outer-name + + if not ENABLE_TAPI: pytest.skip('Skipping test: No TAPI device has been configured') + + device_client.DeleteDevice(DeviceId(**DEVICE_TAPI_ID)) + driver_instance_cache = device_service.device_servicer.driver_instance_cache + driver : _Driver = driver_instance_cache.get(DEVICE_TAPI_UUID, {}) + assert driver is None diff --git a/src/interdomain/.gitlab-ci.yml b/src/interdomain/.gitlab-ci.yml index f4dd49fd0cd674a95768eccf2193ac6deb0db490..a91f9e4edb8cae14029897df3aafa2b6f1bea3a9 100644 --- a/src/interdomain/.gitlab-ci.yml +++ b/src/interdomain/.gitlab-ci.yml @@ -54,7 +54,8 @@ unit test service: - sleep 5 - docker ps -a - docker logs $IMAGE_NAME - - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml; coverage xml -o /opt/results/${IMAGE_NAME}_coverage.xml; coverage report --include='${IMAGE_NAME}/*' --show-missing" + - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" + - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: - docker rm -f $IMAGE_NAME @@ -73,7 +74,6 @@ unit test service: when: always reports: junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml - cobertura: src/$IMAGE_NAME/tests/${IMAGE_NAME}_coverage.xml # Deployment of the service in Kubernetes Cluster deploy service: diff --git a/src/interdomain/client/InterdomainClient.py b/src/interdomain/client/InterdomainClient.py index 345dfa3ec8b6edd8ca3c4c840e2368ec5d3faf12..a34f31537e2dab3747c5499c640b0b73a4392cf9 100644 --- a/src/interdomain/client/InterdomainClient.py +++ b/src/interdomain/client/InterdomainClient.py @@ -13,6 +13,8 @@ # limitations under the License. import grpc, logging +from common.Constants import ServiceNameEnum +from common.Settings import get_service_host, get_service_port_grpc from common.tools.client.RetryDecorator import retry, delay_exponential from common.tools.grpc.Tools import grpc_message_to_json_string from interdomain.proto.context_pb2 import AuthenticationResult, Slice, SliceId, SliceStatus, TeraFlowController @@ -24,8 +26,10 @@ DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) RETRY_DECORATOR = retry(max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') class InterdomainClient: - def __init__(self, address, port): - self.endpoint = '{:s}:{:s}'.format(str(address), str(port)) + def __init__(self, host=None, port=None): + if not host: host = get_service_host(ServiceNameEnum.INTERDOMAIN) + if not port: port = get_service_port_grpc(ServiceNameEnum.INTERDOMAIN) + self.endpoint = '{:s}:{:s}'.format(str(host), str(port)) LOGGER.debug('Creating channel to {:s}...'.format(self.endpoint)) self.channel = None self.stub = None diff --git a/src/interdomain/service/InterdomainService.py b/src/interdomain/service/InterdomainService.py index debc943cf17ef2444b231d9a7f10338e5bc5f5b6..cca6bcb85869b53d644e510e8581de20f1e9c825 100644 --- a/src/interdomain/service/InterdomainService.py +++ b/src/interdomain/service/InterdomainService.py @@ -12,65 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc, logging -from concurrent import futures -from grpc_health.v1.health import HealthServicer, OVERALL_HEALTH -from grpc_health.v1.health_pb2 import HealthCheckResponse -from grpc_health.v1.health_pb2_grpc import add_HealthServicer_to_server -from context.client.ContextClient import ContextClient -from interdomain.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD +from common.Constants import ServiceNameEnum +from common.Settings import get_service_port_grpc +from common.tools.service.GenericGrpcService import GenericGrpcService from interdomain.proto.interdomain_pb2_grpc import add_InterdomainServiceServicer_to_server -from slice.client.SliceClient import SliceClient from .InterdomainServiceServicerImpl import InterdomainServiceServicerImpl from .RemoteDomainClients import RemoteDomainClients -BIND_ADDRESS = '0.0.0.0' -LOGGER = logging.getLogger(__name__) +class InterdomainService(GenericGrpcService): + def __init__(self, remote_domain_clients : RemoteDomainClients, cls_name: str = __name__) -> None: + port = get_service_port_grpc(ServiceNameEnum.INTERDOMAIN) + super().__init__(port, cls_name=cls_name) + self.interdomain_servicer = InterdomainServiceServicerImpl(remote_domain_clients) -class InterdomainService: - def __init__( - self, context_client : ContextClient, slice_client : SliceClient, remote_domain_clients : RemoteDomainClients, - address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD - ): - self.context_client = context_client - self.slice_client = slice_client - self.remote_domain_clients = remote_domain_clients - self.address = address - self.port = port - self.endpoint = None - self.max_workers = max_workers - self.grace_period = grace_period - self.interdomain_servicer = None - self.health_servicer = None - self.pool = None - self.server = None - - def start(self): - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) - LOGGER.info('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( - str(self.endpoint), str(self.max_workers))) - - self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) - self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) - - self.interdomain_servicer = InterdomainServiceServicerImpl( - self.context_client, self.slice_client, self.remote_domain_clients) + def install_servicers(self): add_InterdomainServiceServicer_to_server(self.interdomain_servicer, self.server) - - self.health_servicer = HealthServicer( - experimental_non_blocking=True, experimental_thread_pool=futures.ThreadPoolExecutor(max_workers=1)) - add_HealthServicer_to_server(self.health_servicer, self.server) - - port = self.server.add_insecure_port(self.endpoint) - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(port)) - LOGGER.info('Listening on {:s}...'.format(str(self.endpoint))) - self.server.start() - self.health_servicer.set(OVERALL_HEALTH, HealthCheckResponse.SERVING) # pylint: disable=maybe-no-member - - LOGGER.debug('Service started') - - def stop(self): - LOGGER.debug('Stopping service (grace period {:s} seconds)...'.format(str(self.grace_period))) - self.health_servicer.enter_graceful_shutdown() - self.server.stop(self.grace_period) - LOGGER.debug('Service stopped') diff --git a/src/interdomain/service/InterdomainServiceServicerImpl.py b/src/interdomain/service/InterdomainServiceServicerImpl.py index e76297625e344f3dd46fbdd951e9705e7b171d36..20ae74eef816fdb3fbf7352913673cb51f222ba8 100644 --- a/src/interdomain/service/InterdomainServiceServicerImpl.py +++ b/src/interdomain/service/InterdomainServiceServicerImpl.py @@ -14,7 +14,7 @@ import grpc, logging from common.rpc_method_wrapper.Decorator import create_metrics, safe_and_metered_rpc_method -from common.tools.grpc.Tools import grpc_message_to_json_string +#from common.tools.grpc.Tools import grpc_message_to_json_string from context.client.ContextClient import ContextClient from context.proto.context_pb2 import SliceStatusEnum from interdomain.proto.context_pb2 import AuthenticationResult, Slice, SliceId, SliceStatus, TeraFlowController @@ -29,18 +29,16 @@ METHOD_NAMES = ['RequestSlice', 'Authenticate', 'LookUpSlice', 'OrderSliceFromCa METRICS = create_metrics(SERVICE_NAME, METHOD_NAMES) class InterdomainServiceServicerImpl(InterdomainServiceServicer): - def __init__( - self, context_client : ContextClient, slice_client : SliceClient, - remote_domain_clients : RemoteDomainClients - ): + def __init__(self, remote_domain_clients : RemoteDomainClients): LOGGER.debug('Creating Servicer...') - self.context_client = context_client - self.slice_client = slice_client self.remote_domain_clients = remote_domain_clients LOGGER.debug('Servicer Created') @safe_and_metered_rpc_method(METRICS, LOGGER) def RequestSlice(self, request : Slice, context : grpc.ServicerContext) -> SliceId: + context_client = ContextClient() + slice_client = SliceClient() + domains_to_endpoints = {} local_domain_uuid = None for slice_endpoint_id in request.slice_endpoint_ids: @@ -90,7 +88,7 @@ class InterdomainServiceServicerImpl(InterdomainServiceServicer): if remote_slice.slice_status.slice_status != SliceStatusEnum.SLICESTATUS_ACTIVE: raise Exception('Remote Slice creation failed. Wrong Slice status returned') - #self.context_client.SetSlice(remote_slice) + #context_client.SetSlice(remote_slice) #subslice_id = reply.slice_subslice_ids.add() #subslice_id.CopyFrom(remote_slice.slice_id) @@ -112,7 +110,7 @@ class InterdomainServiceServicerImpl(InterdomainServiceServicer): slice_endpoint_id.device_id.device_uuid.uuid = 'R1@D2' slice_endpoint_id.endpoint_uuid.uuid = '2/1' - local_slice_reply = self.slice_client.CreateSlice(local_slice_request) + local_slice_reply = slice_client.CreateSlice(local_slice_request) if local_slice_reply != local_slice_request.slice_id: # pylint: disable=no-member raise Exception('Local Slice creation failed. Wrong Slice Id was returned') @@ -120,7 +118,7 @@ class InterdomainServiceServicerImpl(InterdomainServiceServicer): subslice_id.context_id.context_uuid.uuid = local_slice_request.slice_id.context_id.context_uuid.uuid subslice_id.slice_uuid.uuid = local_slice_request.slice_id.slice_uuid.uuid - self.context_client.SetSlice(reply) + context_client.SetSlice(reply) return reply.slice_id @safe_and_metered_rpc_method(METRICS, LOGGER) @@ -133,7 +131,8 @@ class InterdomainServiceServicerImpl(InterdomainServiceServicer): @safe_and_metered_rpc_method(METRICS, LOGGER) def LookUpSlice(self, request : Slice, context : grpc.ServicerContext) -> SliceId: try: - slice_ = self.context_client.GetSlice(request.slice_id) + context_client = ContextClient() + slice_ = context_client.GetSlice(request.slice_id) return slice_.slice_id except grpc.RpcError: #LOGGER.exception('Unable to get slice({:s})'.format(grpc_message_to_json_string(request.slice_id))) @@ -146,7 +145,9 @@ class InterdomainServiceServicerImpl(InterdomainServiceServicer): @safe_and_metered_rpc_method(METRICS, LOGGER) def CreateSliceAndAddToCatalog(self, request : Slice, context : grpc.ServicerContext) -> Slice: - reply = self.slice_client.CreateSlice(request) + context_client = ContextClient() + slice_client = SliceClient() + reply = slice_client.CreateSlice(request) if reply != request.slice_id: # pylint: disable=no-member raise Exception('Slice creation failed. Wrong Slice Id was returned') - return self.context_client.GetSlice(request.slice_id) + return context_client.GetSlice(request.slice_id) diff --git a/src/interdomain/service/RemoteDomainClients.py b/src/interdomain/service/RemoteDomainClients.py index 709aa3c07e545ab5babf8d7e051fa7120fdb7a99..8fde3f4422b2febc7374f08536c0015bfd4719e4 100644 --- a/src/interdomain/service/RemoteDomainClients.py +++ b/src/interdomain/service/RemoteDomainClients.py @@ -26,16 +26,16 @@ class RemoteDomainClients: self.peer_domain = {} def add_peer( - self, domain_name : str, address : str, port : int, context_uuid : str = DEFAULT_CONTEXT_UUID + self, domain_name : str, host : str, port : int, context_uuid : str = DEFAULT_CONTEXT_UUID ) -> None: while True: try: - remote_teraflow_ip = socket.gethostbyname(address) + remote_teraflow_ip = socket.gethostbyname(host) if len(remote_teraflow_ip) > 0: break except socket.gaierror as e: if str(e) == '[Errno -2] Name or service not known': continue - interdomain_client = InterdomainClient(address, port) + interdomain_client = InterdomainClient(host=host, port=port) request = TeraFlowController() request.context_id.context_uuid.uuid = DEFAULT_CONTEXT_UUID # pylint: disable=no-member request.ip_address = get_setting('INTERDOMAINSERVICE_SERVICE_HOST', default='0.0.0.0') diff --git a/src/interdomain/service/__main__.py b/src/interdomain/service/__main__.py index ff19271ee4fee7fb975294e11b21de18060607f4..c0a078f4ded85ab957011d21d56c97c8d303dc2a 100644 --- a/src/interdomain/service/__main__.py +++ b/src/interdomain/service/__main__.py @@ -14,14 +14,12 @@ import logging, signal, sys, threading from prometheus_client import start_http_server -from common.Settings import get_setting, wait_for_environment_variables -from context.client.ContextClient import ContextClient -from interdomain.service.RemoteDomainClients import RemoteDomainClients -from interdomain.Config import ( - CONTEXT_SERVICE_HOST, CONTEXT_SERVICE_PORT, SLICE_SERVICE_HOST, SLICE_SERVICE_PORT, GRPC_SERVICE_PORT, - GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL, METRICS_PORT) -from slice.client.SliceClient import SliceClient +from common.Constants import ServiceNameEnum +from common.Settings import ( + ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_log_level, get_metrics_port, + get_service_port_grpc, wait_for_environment_variables) from .InterdomainService import InterdomainService +from .RemoteDomainClients import RemoteDomainClients terminate = threading.Event() LOGGER : logging.Logger = None @@ -33,55 +31,36 @@ def signal_handler(signal, frame): # pylint: disable=redefined-outer-name def main(): global LOGGER # pylint: disable=global-statement - grpc_service_port = get_setting('INTERDOMAINSERVICE_SERVICE_PORT_GRPC', default=GRPC_SERVICE_PORT ) - max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS ) - grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD ) - log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL ) - metrics_port = get_setting('METRICS_PORT', default=METRICS_PORT ) - + log_level = get_log_level() logging.basicConfig(level=log_level) LOGGER = logging.getLogger(__name__) wait_for_environment_variables([ - 'CONTEXTSERVICE_SERVICE_HOST', 'CONTEXTSERVICE_SERVICE_PORT_GRPC', - 'SLICESERVICE_SERVICE_HOST', 'SLICESERVICE_SERVICE_PORT_GRPC', + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST ), + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC), + get_env_var_name(ServiceNameEnum.SLICE, ENVVAR_SUFIX_SERVICE_HOST ), + get_env_var_name(ServiceNameEnum.SLICE, ENVVAR_SUFIX_SERVICE_PORT_GRPC), ]) - context_service_host = get_setting('CONTEXTSERVICE_SERVICE_HOST', default=CONTEXT_SERVICE_HOST ) - context_service_port = get_setting('CONTEXTSERVICE_SERVICE_PORT_GRPC', default=CONTEXT_SERVICE_PORT ) - slice_service_host = get_setting('SLICESERVICE_SERVICE_HOST', default=SLICE_SERVICE_HOST ) - slice_service_port = get_setting('SLICESERVICE_SERVICE_PORT_GRPC', default=SLICE_SERVICE_PORT ) - signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) LOGGER.info('Starting...') # Start metrics server + metrics_port = get_metrics_port() start_http_server(metrics_port) - # Initialize Context Client - if context_service_host is None or context_service_port is None: - raise Exception('Wrong address({:s}):port({:s}) of Context component'.format( - str(context_service_host), str(context_service_port))) - context_client = ContextClient(context_service_host, context_service_port) - - # Initialize Slice Client - if slice_service_host is None or slice_service_port is None: - raise Exception('Wrong address({:s}):port({:s}) of Slice component'.format( - str(slice_service_host), str(slice_service_port))) - slice_client = SliceClient(slice_service_host, slice_service_port) - # Define remote domain clients remote_domain_clients = RemoteDomainClients() # Starting Interdomain service - grpc_service = InterdomainService( - context_client, slice_client, remote_domain_clients, port=grpc_service_port, max_workers=max_workers, - grace_period=grace_period) + grpc_service = InterdomainService(remote_domain_clients) grpc_service.start() - remote_domain_clients.add_peer('remote-teraflow', 'remote-teraflow', GRPC_SERVICE_PORT) + # TODO: improve with configuration the definition of the remote peers + interdomain_service_port_grpc = get_service_port_grpc(ServiceNameEnum.INTERDOMAIN) + remote_domain_clients.add_peer('remote-teraflow', 'remote-teraflow', interdomain_service_port_grpc) # Wait for Ctrl+C or termination signal while not terminate.wait(timeout=0.1): pass diff --git a/src/interdomain/tests/test_unitary.py b/src/interdomain/tests/test_unitary.py index bcc6bb9c9cae702f69b0c8f62e483f57d396fb6e..7fe1acc7cec5cbf3663dc7db68c45a22b56d3a6d 100644 --- a/src/interdomain/tests/test_unitary.py +++ b/src/interdomain/tests/test_unitary.py @@ -13,134 +13,131 @@ # limitations under the License. -import logging, grpc -import os -import sqlite3 - -import pytest -from typing import Tuple - -from interdomain.proto import context_pb2, kpi_sample_types_pb2, monitoring_pb2 -from interdomain.client.interdomain_client import InterdomainClient -from interdomain.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD -from interdomain.service.InterdomainService import InterdomainService - -from common.orm.Database import Database -from common.orm.Factory import get_database_backend, BackendEnum as DatabaseBackendEnum -from common.message_broker.Factory import get_messagebroker_backend, BackendEnum as MessageBrokerBackendEnum -from common.message_broker.MessageBroker import MessageBroker - -LOGGER = logging.getLogger(__name__) -LOGGER.setLevel(logging.DEBUG) - -########################### -# Tests Setup -########################### - -SERVER_ADDRESS = '127.0.0.1' -LISTEN_ADDRESS = '[::]' -GRPC_PORT_MONITORING = 9090 - -GRPC_PORT_CONTEXT = 10000 + grpc_port_context # avoid privileged ports - -SCENARIOS = [ # comment/uncomment scenarios to activate/deactivate them in the test unit - ('all_inmemory', DatabaseBackendEnum.INMEMORY, {}, MessageBrokerBackendEnum.INMEMORY, {} ), -] - - -# This fixture will be requested by test cases and last during testing session -@pytest.fixture(scope='session') -def interdomain_service(): - LOGGER.warning('interdomain_service begin') - - interdomain_port = GRPC_INTERDOMAIN_PORT - max_workers = GRPC_MAX_WORKERS - grace_period = GRPC_GRACE_PERIOD - - LOGGER.info('Initializing InterdomainService...') - grpc_service = InterdomainService(port=interdomain_port, max_workers=max_workers, grace_period=grace_period) - server = grpc_service.start() - - # yield the server, when test finishes, execution will resume to stop it - LOGGER.warning('interdomain_service yielding') - yield server - - LOGGER.info('Terminating InterdomainService...') - grpc_service.stop() - -# This fixture will be requested by test cases and last during testing session. -# The client requires the server, so client fixture has the server as dependency. -@pytest.fixture(scope='session') -def interdomain_client(interdomain_service): - LOGGER.warning('interdomain_client begin') - client = InterdomainClient(server=SERVER_ADDRESS, port=GRPC_PORT_INTERDOMAIN) # instantiate the client - LOGGER.warning('interdomain_client returning') - return client - -# This fixture will be requested by test cases and last during testing session. -@pytest.fixture(scope='session') -def create_TeraFlowController(): - LOGGER.warning('create_TeraFlowController begin') - # form request - tf_ctl = context_pb2.TeraFlowController() - tf_ctl.context_id = context_pb2.ContextId() - tf_ctl.context_id.context_uuid = context_pb2.Uuid() - tf_ctl.context_id.context_uuid.uuid = str(1) - tf_ctl.ip_address = "127.0.0.1" - tf_ctl.port = 9090 - return tf_ctl - -@pytest.fixture(scope='session') -def create_TransportSlice(): - LOGGER.warning('create_TransportSlice begin') - - # form request - slice_req = slice_pb2.TransportSlice() - slice_req.contextId = context_pb2.ContextId() - slice_req.contextId.context_uuid = context_pb2.Uuid() - slice_req.contextId.context_uuid.uuid = str(1) - slice_req.slice_id = context_pb2.Uuid() - slice_req.slice_id.context_uuid.uuid = str(1) - - return slice_req - - -########################### -# Tests Implementation -########################### - - -# Test case that makes use of client fixture to test server's CreateKpi method -def test_Authenticate(interdomain_client,create_TeraFlowController): - # make call to server - LOGGER.warning('test_Authenticate requesting') - response = interdomain_client.Authenticate(create_TeraFlowController) - LOGGER.debug(str(response)) - assert isinstance(response, context.AuthenticationResult) - -# Test case that makes use of client fixture to test server's MonitorKpi method -def test_LookUpSlice(interdomain_client,create_TransportSlice): - LOGGER.warning('test_LookUpSlice begin') - - response = interdomain_client.LookUpSlice(create_TransportSlice) - LOGGER.debug(str(response)) - assert isinstance(response, slice.SliceId) - -# Test case that makes use of client fixture to test server's GetStreamKpi method -def test_CreateSliceAndAddToCatalog(interdomain_client,create_TransportSlice): - LOGGER.warning('test_CreateSliceAndAddToCatalog begin') - response = interdomain_client.CreateSliceAndAddToCatalog(create_TransportSlice) - LOGGER.debug(str(response)) - assert isinstance(response, slice.SliceId) - -# Test case that makes use of client fixture to test server's IncludeKpi method -def test_OrderSliceFromCatalog(interdomain_client,create_TransportSlice): - # make call to server - LOGGER.warning('test_OrderSliceFromCatalog requesting') - response = interdomain_client.OrderSliceFromCatalog(create_TransportSlice) - LOGGER.debug(str(response)) - assert isinstance(response, slice.SliceId) - - - - +#import logging, grpc +#import os +#import sqlite3 +# +#import pytest +#from typing import Tuple +# +#from interdomain.proto import context_pb2, kpi_sample_types_pb2, monitoring_pb2 +#from interdomain.client.interdomain_client import InterdomainClient +#from interdomain.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD +#from interdomain.service.InterdomainService import InterdomainService +# +#from common.orm.Database import Database +#from common.orm.Factory import get_database_backend, BackendEnum as DatabaseBackendEnum +#from common.message_broker.Factory import get_messagebroker_backend, BackendEnum as MessageBrokerBackendEnum +#from common.message_broker.MessageBroker import MessageBroker +# +#LOGGER = logging.getLogger(__name__) +#LOGGER.setLevel(logging.DEBUG) +# +############################ +## Tests Setup +############################ +# +#SERVER_ADDRESS = '127.0.0.1' +#LISTEN_ADDRESS = '[::]' +#GRPC_PORT_MONITORING = 9090 +# +#GRPC_PORT_CONTEXT = 10000 + grpc_port_context # avoid privileged ports +# +#SCENARIOS = [ # comment/uncomment scenarios to activate/deactivate them in the test unit +# ('all_inmemory', DatabaseBackendEnum.INMEMORY, {}, MessageBrokerBackendEnum.INMEMORY, {} ), +#] +# +# +## This fixture will be requested by test cases and last during testing session +#@pytest.fixture(scope='session') +#def interdomain_service(): +# LOGGER.warning('interdomain_service begin') +# +# interdomain_port = GRPC_INTERDOMAIN_PORT +# max_workers = GRPC_MAX_WORKERS +# grace_period = GRPC_GRACE_PERIOD +# +# LOGGER.info('Initializing InterdomainService...') +# grpc_service = InterdomainService(port=interdomain_port, max_workers=max_workers, grace_period=grace_period) +# server = grpc_service.start() +# +# # yield the server, when test finishes, execution will resume to stop it +# LOGGER.warning('interdomain_service yielding') +# yield server +# +# LOGGER.info('Terminating InterdomainService...') +# grpc_service.stop() +# +## This fixture will be requested by test cases and last during testing session. +## The client requires the server, so client fixture has the server as dependency. +#@pytest.fixture(scope='session') +#def interdomain_client(interdomain_service): +# LOGGER.warning('interdomain_client begin') +# client = InterdomainClient(server=SERVER_ADDRESS, port=GRPC_PORT_INTERDOMAIN) # instantiate the client +# LOGGER.warning('interdomain_client returning') +# return client +# +## This fixture will be requested by test cases and last during testing session. +#@pytest.fixture(scope='session') +#def create_TeraFlowController(): +# LOGGER.warning('create_TeraFlowController begin') +# # form request +# tf_ctl = context_pb2.TeraFlowController() +# tf_ctl.context_id = context_pb2.ContextId() +# tf_ctl.context_id.context_uuid = context_pb2.Uuid() +# tf_ctl.context_id.context_uuid.uuid = str(1) +# tf_ctl.ip_address = "127.0.0.1" +# tf_ctl.port = 9090 +# return tf_ctl +# +#@pytest.fixture(scope='session') +#def create_TransportSlice(): +# LOGGER.warning('create_TransportSlice begin') +# +# # form request +# slice_req = slice_pb2.TransportSlice() +# slice_req.contextId = context_pb2.ContextId() +# slice_req.contextId.context_uuid = context_pb2.Uuid() +# slice_req.contextId.context_uuid.uuid = str(1) +# slice_req.slice_id = context_pb2.Uuid() +# slice_req.slice_id.context_uuid.uuid = str(1) +# +# return slice_req +# +# +############################ +## Tests Implementation +############################ +# +# +## Test case that makes use of client fixture to test server's CreateKpi method +#def test_Authenticate(interdomain_client,create_TeraFlowController): +# # make call to server +# LOGGER.warning('test_Authenticate requesting') +# response = interdomain_client.Authenticate(create_TeraFlowController) +# LOGGER.debug(str(response)) +# assert isinstance(response, context.AuthenticationResult) +# +## Test case that makes use of client fixture to test server's MonitorKpi method +#def test_LookUpSlice(interdomain_client,create_TransportSlice): +# LOGGER.warning('test_LookUpSlice begin') +# +# response = interdomain_client.LookUpSlice(create_TransportSlice) +# LOGGER.debug(str(response)) +# assert isinstance(response, slice.SliceId) +# +## Test case that makes use of client fixture to test server's GetStreamKpi method +#def test_CreateSliceAndAddToCatalog(interdomain_client,create_TransportSlice): +# LOGGER.warning('test_CreateSliceAndAddToCatalog begin') +# response = interdomain_client.CreateSliceAndAddToCatalog(create_TransportSlice) +# LOGGER.debug(str(response)) +# assert isinstance(response, slice.SliceId) +# +## Test case that makes use of client fixture to test server's IncludeKpi method +#def test_OrderSliceFromCatalog(interdomain_client,create_TransportSlice): +# # make call to server +# LOGGER.warning('test_OrderSliceFromCatalog requesting') +# response = interdomain_client.OrderSliceFromCatalog(create_TransportSlice) +# LOGGER.debug(str(response)) +# assert isinstance(response, slice.SliceId) +# diff --git a/src/l3_attackmitigator/.gitlab-ci.yml b/src/l3_attackmitigator/.gitlab-ci.yml index dbf8d90fcbcb38a0574de4130b4181e77cf5afd6..28d5ad4cf109cd438da2625a08689b327688ea37 100644 --- a/src/l3_attackmitigator/.gitlab-ci.yml +++ b/src/l3_attackmitigator/.gitlab-ci.yml @@ -55,7 +55,6 @@ unit test l3_attackmitigator: - docker ps -a - docker logs $IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - - docker exec -i $IMAGE_NAME bash -c "coverage xml -o /opt/results/${IMAGE_NAME}_coverage.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: @@ -75,7 +74,6 @@ unit test l3_attackmitigator: when: always reports: junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml - cobertura: src/$IMAGE_NAME/tests/${IMAGE_NAME}_coverage.xml # Deployment of the service in Kubernetes Cluster deploy l3_attackmitigator: diff --git a/src/l3_centralizedattackdetector/.gitlab-ci.yml b/src/l3_centralizedattackdetector/.gitlab-ci.yml index 43ca269d3c8c1456d86717f423c81fafbc5b03af..ca95af8816ce01b433d462a5d09d8ef14776734f 100644 --- a/src/l3_centralizedattackdetector/.gitlab-ci.yml +++ b/src/l3_centralizedattackdetector/.gitlab-ci.yml @@ -55,7 +55,6 @@ unit test l3_centralizedattackdetector: - docker ps -a - docker logs $IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - - docker exec -i $IMAGE_NAME bash -c "coverage xml -o /opt/results/${IMAGE_NAME}_coverage.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: @@ -75,7 +74,6 @@ unit test l3_centralizedattackdetector: when: always reports: junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml - cobertura: src/$IMAGE_NAME/tests/${IMAGE_NAME}_coverage.xml # Deployment of the service in Kubernetes Cluster deploy l3_centralizedattackdetector: diff --git a/src/l3_distributedattackdetector/.gitlab-ci.yml b/src/l3_distributedattackdetector/.gitlab-ci.yml index 1e34c6c7e44d5bfdac06aabb2e738e368b633675..7ced7a62c19c717e2c4091f08c73579a79ad383b 100644 --- a/src/l3_distributedattackdetector/.gitlab-ci.yml +++ b/src/l3_distributedattackdetector/.gitlab-ci.yml @@ -55,7 +55,6 @@ unit test l3_distributedattackdetector: - docker ps -a - docker logs $IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - - docker exec -i $IMAGE_NAME bash -c "coverage xml -o /opt/results/${IMAGE_NAME}_coverage.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: @@ -75,7 +74,6 @@ unit test l3_distributedattackdetector: when: always reports: junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml - cobertura: src/$IMAGE_NAME/tests/${IMAGE_NAME}_coverage.xml # Deployment of the service in Kubernetes Cluster deploy l3_distributedattackdetector: diff --git a/src/monitoring/.gitlab-ci.yml b/src/monitoring/.gitlab-ci.yml index f715417765de6d7517f2430e9bf3a2a9937fa8d6..61aec5fb3b29b40bc413a5d9a6452086d0005dce 100644 --- a/src/monitoring/.gitlab-ci.yml +++ b/src/monitoring/.gitlab-ci.yml @@ -58,7 +58,6 @@ unit test monitoring: - docker ps -a - docker logs $IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - - docker exec -i $IMAGE_NAME bash -c "coverage xml -o /opt/results/${IMAGE_NAME}_coverage.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: @@ -79,7 +78,6 @@ unit test monitoring: when: always reports: junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml - cobertura: src/$IMAGE_NAME/tests/${IMAGE_NAME}_coverage.xml # Deployment of the service in Kubernetes Cluster deploy monitoring: diff --git a/src/monitoring/Dockerfile b/src/monitoring/Dockerfile index c1bba549eaaf5cfaaacd16d01a9d2204bc09c393..ca18929f18816176a503126f43514b7ef32a3a12 100644 --- a/src/monitoring/Dockerfile +++ b/src/monitoring/Dockerfile @@ -39,8 +39,6 @@ RUN mkdir -p /var/teraflow/common RUN mkdir -p /var/teraflow/common/tools RUN mkdir -p /var/teraflow/common/rpc_method_wrapper RUN mkdir -p /var/teraflow/device -RUN mkdir -p /var/teraflow/device/proto -RUN mkdir -p /var/teraflow/device/client RUN mkdir -p /var/teraflow/context # Get Python packages per module @@ -50,11 +48,9 @@ RUN python3 -m pip install -r requirements.txt # add files into working directory COPY monitoring/. monitoring -COPY device/proto/. device/proto -COPY device/client/. device/client -COPY device/Config.py device COPY common/. common COPY context/. context +COPY device/. device RUN rm -r common/message_broker/tests RUN rm -r common/orm/tests diff --git a/src/monitoring/client/MonitoringClient.py b/src/monitoring/client/MonitoringClient.py new file mode 100644 index 0000000000000000000000000000000000000000..d8b39b8bf8d0ae84da19fa651da00633486e6bc6 --- /dev/null +++ b/src/monitoring/client/MonitoringClient.py @@ -0,0 +1,99 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import grpc, logging +from typing import Iterator +from common.Constants import ServiceNameEnum +from common.Settings import get_service_host, get_service_port_grpc +from common.tools.client.RetryDecorator import retry, delay_exponential +from common.tools.grpc.Tools import grpc_message_to_json_string +from monitoring.proto.context_pb2 import Empty +from monitoring.proto.monitoring_pb2 import Kpi, KpiDescriptor, KpiId, MonitorKpiRequest +from monitoring.proto.monitoring_pb2_grpc import MonitoringServiceStub + +LOGGER = logging.getLogger(__name__) +MAX_RETRIES = 15 +DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) +RETRY_DECORATOR = retry(max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') + +class MonitoringClient: + def __init__(self, host=None, port=None): + if not host: host = get_service_host(ServiceNameEnum.MONITORING) + if not port: port = get_service_port_grpc(ServiceNameEnum.MONITORING) + self.endpoint = '{:s}:{:s}'.format(str(host), str(port)) + LOGGER.debug('Creating channel to {:s}...'.format(str(self.endpoint))) + self.channel = None + self.stub = None + self.connect() + LOGGER.debug('Channel created') + + def connect(self): + self.channel = grpc.insecure_channel(self.endpoint) + self.stub = MonitoringServiceStub(self.channel) + + def close(self): + if self.channel is not None: self.channel.close() + self.channel = None + self.stub = None + + @RETRY_DECORATOR + def CreateKpi(self, request : KpiDescriptor) -> KpiId: + LOGGER.debug('CreateKpi: {:s}'.format(grpc_message_to_json_string(request))) + response = self.stub.CreateKpi(request) + LOGGER.debug('CreateKpi result: {:s}'.format(grpc_message_to_json_string(response))) + return response + + @RETRY_DECORATOR + def GetKpiDescriptor(self, request : KpiId) -> KpiDescriptor: + LOGGER.debug('GetKpiDescriptor: {:s}'.format(grpc_message_to_json_string(request))) + response = self.stub.GetKpiDescriptor(request) + LOGGER.debug('GetKpiDescriptor result: {:s}'.format(grpc_message_to_json_string(response))) + return response + + @RETRY_DECORATOR + def IncludeKpi(self, request : Kpi) -> Empty: + LOGGER.debug('IncludeKpi: {:s}'.format(grpc_message_to_json_string(request))) + response = self.stub.IncludeKpi(request) + LOGGER.debug('IncludeKpi result: {:s}'.format(grpc_message_to_json_string(response))) + return response + + @RETRY_DECORATOR + def MonitorKpi(self, request : MonitorKpiRequest) -> Empty: + LOGGER.debug('MonitorKpi: {:s}'.format(grpc_message_to_json_string(request))) + response = self.stub.MonitorKpi(request) + LOGGER.debug('MonitorKpi result: {:s}'.format(grpc_message_to_json_string(response))) + return response + + @RETRY_DECORATOR + def GetStreamKpi(self, request : KpiId) -> Iterator[Kpi]: + LOGGER.debug('GetStreamKpi: {:s}'.format(grpc_message_to_json_string(request))) + response = self.stub.GetStreamKpi(request) + LOGGER.debug('GetStreamKpi result: {:s}'.format(grpc_message_to_json_string(response))) + return response + + @RETRY_DECORATOR + def GetInstantKpi(self, request : KpiId) -> Kpi: + LOGGER.debug('GetInstantKpi: {:s}'.format(grpc_message_to_json_string(request))) + response = self.stub.GetInstantKpi(request) + LOGGER.debug('GetInstantKpi result: {:s}'.format(grpc_message_to_json_string(response))) + return response + + +if __name__ == '__main__': + import sys + # get port + _port = sys.argv[1] if len(sys.argv) > 1 else '7070' + + # make call to server + client = MonitoringClient(port=_port) diff --git a/src/monitoring/client/monitoring_client.py b/src/monitoring/client/monitoring_client.py deleted file mode 100644 index 62bfb519e7649427cad5b8f9e3bc0f849a9b9a39..0000000000000000000000000000000000000000 --- a/src/monitoring/client/monitoring_client.py +++ /dev/null @@ -1,75 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import sys -import grpc - -from monitoring.proto import monitoring_pb2 -from monitoring.proto import monitoring_pb2_grpc -from monitoring.proto import context_pb2 - -from common.logger import getJSONLogger -LOGGER = getJSONLogger('monitoring-client') -LOGGER.setLevel('DEBUG') - -class MonitoringClient: - - def __init__(self, server='monitoring', port='7070'): - endpoint = '{}:{}'.format(server, port) - LOGGER.info('init monitoringClient {}'.format(endpoint)) - self.channel = grpc.insecure_channel(endpoint) - self.server = monitoring_pb2_grpc.MonitoringServiceStub(self.channel) - - def CreateKpi(self, request): - LOGGER.info('CreateKpi: {}'.format(request)) - response = self.server.CreateKpi(request) - LOGGER.info('CreateKpi result: {}'.format(response)) - return response - - def MonitorKpi(self, request): - LOGGER.info('MonitorKpi: {}'.format(request)) - response = self.server.MonitorKpi(request) - LOGGER.info('MonitorKpi result: {}'.format(response)) - return response - - def IncludeKpi(self, request): - LOGGER.info('IncludeKpi: {}'.format(request)) - response = self.server.IncludeKpi(request) - LOGGER.info('IncludeKpi result: {}'.format(response)) - return response - - def GetStreamKpi(self, request): - LOGGER.info('GetStreamKpi: {}'.format(request)) - response = self.server.GetStreamKpi(request) - LOGGER.info('GetStreamKpi result: {}'.format(response)) - yield monitoring_pb2.Kpi() - - def GetInstantKpi(self, request): - LOGGER.info('GetInstantKpi: {}'.format(request)) - response = self.server.GetInstantKpi(request) - LOGGER.info('GetInstantKpi result: {}'.format(response)) - return monitoring_pb2.Kpi() - - def GetKpiDescriptor(self, request): - LOGGER.info('GetKpiDescriptor: {}'.format(request)) - response = self.server.GetKpiDescriptor(request) - LOGGER.info('GetKpiDescriptor result: {}'.format(response)) - return response - -if __name__ == '__main__': - # get port - port = sys.argv[1] if len(sys.argv) > 1 else '7070' - - # make call to server - client = MonitoringClient(port=port) diff --git a/src/monitoring/requirements.in b/src/monitoring/requirements.in index 839ea33af0fbd448f9a5c4d6cb053e71bd420468..4d4f057bdc6b66d699ef1e723b64c05d60f5cc0e 100644 --- a/src/monitoring/requirements.in +++ b/src/monitoring/requirements.in @@ -1,17 +1,25 @@ -#google-api-core +anytree==2.8.0 +APScheduler==3.8.1 +fastcache==1.1.0 grpcio==1.43.0 grpcio-health-checking==1.43.0 +#google-api-core #opencensus[stackdriver] -python-json-logger #google-cloud-profiler #numpy +Jinja2==3.0.3 +ncclient==0.6.13 +p4runtime==1.3.0 +paramiko==2.9.2 prometheus-client==0.13.0 protobuf==3.19.3 pytest==6.2.5 pytest-benchmark==3.4.1 influxdb +python-dateutil==2.8.2 +python-json-logger==2.0.2 +pytz==2021.3 redis==4.1.2 -#anytree==2.8.0 -#APScheduler==3.8.1 -#xmltodict==0.12.0 +requests==2.27.1 +xmltodict==0.12.0 coverage==6.3 diff --git a/src/monitoring/service/EventTools.py b/src/monitoring/service/EventTools.py index 636556425af9ac02487386d81b9d8d4e786aa560..04c06e74203efcd3fab7566b2687dcdfc7e62658 100644 --- a/src/monitoring/service/EventTools.py +++ b/src/monitoring/service/EventTools.py @@ -19,26 +19,27 @@ import grpc from common.rpc_method_wrapper.ServiceExceptions import ServiceException from context.client.ContextClient import ContextClient -from context.proto import kpi_sample_types_pb2 +#from context.proto import kpi_sample_types_pb2 from context.proto.context_pb2 import Empty, EventTypeEnum from common.logger import getJSONLogger -from monitoring.client.monitoring_client import MonitoringClient +from monitoring.client.MonitoringClient import MonitoringClient from monitoring.proto import monitoring_pb2 LOGGER = getJSONLogger('monitoringservice-server') LOGGER.setLevel('DEBUG') class EventsDeviceCollector: - def __init__(self, context_client_grpc : ContextClient, monitoring_client_grpc : MonitoringClient) -> None: # pylint: disable=redefined-outer-name + def __init__(self) -> None: # pylint: disable=redefined-outer-name self._events_queue = Queue() - self._device_stream = context_client_grpc.GetDeviceEvents(Empty()) - self._context_client = context_client_grpc - self._channel = context_client_grpc.channel - self._monitoring_client = monitoring_client_grpc + self._context_client_grpc = ContextClient() + self._device_stream = self._context_client_grpc.GetDeviceEvents(Empty()) + self._context_client = self._context_client_grpc + self._channel = self._context_client_grpc.channel + self._monitoring_client = MonitoringClient(host='127.0.0.1') - self._device_thread = threading.Thread(target=self._collect, args=(self._device_stream ,), daemon=False) + self._device_thread = threading.Thread(target=self._collect, args=(self._device_stream,), daemon=False) def grpc_server_on(self): try: diff --git a/src/monitoring/service/MonitoringService.py b/src/monitoring/service/MonitoringService.py index f1ecba3664dfee74fddb7093ff352724791b4f7d..0736eba435820344750225c28e5b1348c7f7dfbc 100644 --- a/src/monitoring/service/MonitoringService.py +++ b/src/monitoring/service/MonitoringService.py @@ -12,63 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -from concurrent import futures - -import grpc, logging - -from monitoring.service.MonitoringServiceServicerImpl import MonitoringServiceServicerImpl -from monitoring.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD -from monitoring.proto.monitoring_pb2_grpc import add_MonitoringServiceServicer_to_server - -from grpc_health.v1 import health -from grpc_health.v1 import health_pb2 -from grpc_health.v1.health_pb2_grpc import add_HealthServicer_to_server - -from common.logger import getJSONLogger -LOGGER = getJSONLogger('monitoring-server') - -BIND_ADDRESS = '0.0.0.0' - -class MonitoringService: - def __init__(self, address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, - grace_period=GRPC_GRACE_PERIOD): - self.address = address - self.port = port - self.endpoint = None - self.max_workers = max_workers - self.grace_period = grace_period - self.monitoring_servicer = None - self.health_servicer = None - self.pool = None - self.server = None - - def start(self): - # create gRPC server - self.server = grpc.server(futures.ThreadPoolExecutor(max_workers=self.max_workers)) # ,interceptors=(tracer_interceptor,)) - - # add monitoring servicer class to gRPC server +from common.Constants import ServiceNameEnum +from common.Settings import get_service_port_grpc +from common.tools.service.GenericGrpcService import GenericGrpcService +from monitoring.proto.monitoring_pb2_grpc import add_MonitoringServiceServicer_to_server +from .MonitoringServiceServicerImpl import MonitoringServiceServicerImpl + +class MonitoringService(GenericGrpcService): + def __init__(self, cls_name: str = __name__) -> None: + port = get_service_port_grpc(ServiceNameEnum.MONITORING) + super().__init__(port, cls_name=cls_name) self.monitoring_servicer = MonitoringServiceServicerImpl() - add_MonitoringServiceServicer_to_server(self.monitoring_servicer, self.server) - - # add gRPC health checker servicer class to gRPC server - self.health_servicer = health.HealthServicer( - experimental_non_blocking=True, experimental_thread_pool=futures.ThreadPoolExecutor(max_workers=1)) - add_HealthServicer_to_server(self.health_servicer, self.server) - - # start server - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) - LOGGER.info('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( - str(self.endpoint), str(self.max_workers))) - - self.server.add_insecure_port(self.endpoint) - self.server.start() - self.health_servicer.set('', health_pb2.HealthCheckResponse.SERVING) # pylint: disable=maybe-no-member - - LOGGER.debug('Service started') - - def stop(self): - LOGGER.debug('Stopping service (grace period {} seconds)...'.format(self.grace_period)) - self.health_servicer.enter_graceful_shutdown() - self.server.stop(self.grace_period) - LOGGER.debug('Service stopped') + def install_servicers(self): + add_MonitoringServiceServicer_to_server(self.monitoring_servicer, self.server) diff --git a/src/monitoring/service/MonitoringServiceServicerImpl.py b/src/monitoring/service/MonitoringServiceServicerImpl.py index 88cd2d3a83357dec5c49e1894ed4243ceb1b4b6e..28c1ed12045a8d6dfbd9669e8ce2f081248cabd4 100644 --- a/src/monitoring/service/MonitoringServiceServicerImpl.py +++ b/src/monitoring/service/MonitoringServiceServicerImpl.py @@ -12,29 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os,grpc, logging -import socket - -from prometheus_client import Summary -from prometheus_client import Counter -from common.Settings import get_setting - -from monitoring.Config import DEVICE_GRPC_SERVICE_PORT, DEVICE_SERVICE_HOST +import os, grpc, logging +from prometheus_client import Counter, Summary from monitoring.proto.kpi_sample_types_pb2 import KpiSampleType from monitoring.service import SqliteTools, InfluxTools from monitoring.proto import monitoring_pb2 from monitoring.proto import monitoring_pb2_grpc - from common.rpc_method_wrapper.ServiceExceptions import ServiceException - from context.proto import context_pb2 - from device.client.DeviceClient import DeviceClient from device.proto import device_pb2 LOGGER = logging.getLogger(__name__) -MONITORING_GETINSTANTKPI_REQUEST_TIME = Summary('monitoring_getinstantkpi_processing_seconds', 'Time spent processing monitoring instant kpi request') +MONITORING_GETINSTANTKPI_REQUEST_TIME = Summary( + 'monitoring_getinstantkpi_processing_seconds', 'Time spent processing monitoring instant kpi request') MONITORING_INCLUDEKPI_COUNTER = Counter('monitoring_includekpi_counter', 'Monitoring include kpi request counter') INFLUXDB_HOSTNAME = os.environ.get("INFLUXDB_HOSTNAME") @@ -42,9 +34,6 @@ INFLUXDB_USER = os.environ.get("INFLUXDB_USER") INFLUXDB_PASSWORD = os.environ.get("INFLUXDB_PASSWORD") INFLUXDB_DATABASE = os.environ.get("INFLUXDB_DATABASE") -DEVICE_SERVICE_HOST = get_setting('DEVICESERVICE_SERVICE_HOST', default=DEVICE_SERVICE_HOST ) -DEVICE_SERVICE_PORT = get_setting('DEVICESERVICE_SERVICE_PORT_GRPC', default=DEVICE_GRPC_SERVICE_PORT) - class MonitoringServiceServicerImpl(monitoring_pb2_grpc.MonitoringServiceServicer): def __init__(self): @@ -52,13 +41,14 @@ class MonitoringServiceServicerImpl(monitoring_pb2_grpc.MonitoringServiceService # Init sqlite monitoring db self.sql_db = SqliteTools.SQLite('monitoring.db') - self.deviceClient = DeviceClient(address=DEVICE_SERVICE_HOST, port=DEVICE_GRPC_SERVICE_PORT) # instantiate the client # Create influx_db client self.influx_db = InfluxTools.Influx(INFLUXDB_HOSTNAME,"8086",INFLUXDB_USER,INFLUXDB_PASSWORD,INFLUXDB_DATABASE) # CreateKpi (CreateKpiRequest) returns (KpiId) {} - def CreateKpi(self, request : monitoring_pb2.KpiDescriptor, grpc_context : grpc.ServicerContext) -> monitoring_pb2.KpiId : + def CreateKpi( + self, request : monitoring_pb2.KpiDescriptor, grpc_context : grpc.ServicerContext + ) -> monitoring_pb2.KpiId: # CREATEKPI_COUNTER_STARTED.inc() LOGGER.info('CreateKpi') try: @@ -71,7 +61,8 @@ class MonitoringServiceServicerImpl(monitoring_pb2_grpc.MonitoringServiceService kpi_endpoint_id = request.endpoint_id.endpoint_uuid.uuid kpi_service_id = request.service_id.service_uuid.uuid - data = self.sql_db.insert_KPI(kpi_description, kpi_sample_type, kpi_device_id, kpi_endpoint_id, kpi_service_id) + data = self.sql_db.insert_KPI( + kpi_description, kpi_sample_type, kpi_device_id, kpi_endpoint_id, kpi_service_id) kpi_id.kpi_id.uuid = str(data) @@ -87,7 +78,9 @@ class MonitoringServiceServicerImpl(monitoring_pb2_grpc.MonitoringServiceService grpc_context.abort(grpc.StatusCode.INTERNAL, str(e)) # rpc MonitorKpi (MonitorKpiRequest) returns (context.Empty) {} - def MonitorKpi ( self, request : monitoring_pb2.MonitorKpiRequest, grpc_context : grpc.ServicerContext) -> context_pb2.Empty: + def MonitorKpi( + self, request : monitoring_pb2.MonitorKpiRequest, grpc_context : grpc.ServicerContext + ) -> context_pb2.Empty: LOGGER.info('MonitorKpi') try: @@ -97,25 +90,23 @@ class MonitoringServiceServicerImpl(monitoring_pb2_grpc.MonitoringServiceService kpiDescriptor = self.GetKpiDescriptor(request.kpi_id, grpc_context) monitor_device_request.kpi_descriptor.CopyFrom(kpiDescriptor) - monitor_device_request.kpi_id.kpi_id.uuid = request.kpi_id.kpi_id.uuid - monitor_device_request.sampling_duration_s = request.sampling_duration_s - monitor_device_request.sampling_interval_s = request.sampling_interval_s + monitor_device_request.kpi_id.kpi_id.uuid = request.kpi_id.kpi_id.uuid + monitor_device_request.sampling_duration_s = request.sampling_duration_s + monitor_device_request.sampling_interval_s = request.sampling_interval_s - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - if s.connect_ex((DEVICE_SERVICE_HOST, DEVICE_GRPC_SERVICE_PORT)) == 0: - self.deviceClient.MonitorDeviceKpi(monitor_device_request) - else: - LOGGER.warning('Device service is not reachable') + device_client = DeviceClient() + device_client.MonitorDeviceKpi(monitor_device_request) - return context_pb2.Empty() except ServiceException as e: LOGGER.exception('MonitorKpi exception') # CREATEKPI_COUNTER_FAILED.inc() grpc_context.abort(e.code, e.details) except Exception as e: # pragma: no cover LOGGER.exception('MonitorKpi exception') + grpc_context.abort(grpc.StatusCode.INTERNAL, str(e)) # CREATEKPI_COUNTER_FAILED.inc() + return context_pb2.Empty() # rpc IncludeKpi(IncludeKpiRequest) returns(context.Empty) {} def IncludeKpi(self, request : monitoring_pb2.Kpi, grpc_context : grpc.ServicerContext) -> context_pb2.Empty: @@ -145,7 +136,7 @@ class MonitoringServiceServicerImpl(monitoring_pb2_grpc.MonitoringServiceService LOGGER.exception('IncludeKpi exception') # CREATEKPI_COUNTER_FAILED.inc() grpc_context.abort(e.code, e.details) - except Exception as e: # pragma: no cover + except Exception: # pragma: no cover LOGGER.exception('IncludeKpi exception') # CREATEKPI_COUNTER_FAILED.inc() return context_pb2.Empty() @@ -162,7 +153,9 @@ class MonitoringServiceServicerImpl(monitoring_pb2_grpc.MonitoringServiceService return monitoring_pb2.Kpi() - def GetKpiDescriptor(self, request : monitoring_pb2.KpiId, grpc_context : grpc.ServicerContext) -> monitoring_pb2.KpiDescriptor: + def GetKpiDescriptor( + self, request : monitoring_pb2.KpiId, grpc_context : grpc.ServicerContext + ) -> monitoring_pb2.KpiDescriptor: LOGGER.info('getting Kpi by KpiID') try: kpi_db = self.sql_db.get_KPI(int(request.kpi_id.uuid)) @@ -183,5 +176,5 @@ class MonitoringServiceServicerImpl(monitoring_pb2_grpc.MonitoringServiceService LOGGER.exception('GetKpiDescriptor exception') grpc_context.abort(e.code, e.details) - except Exception as e: # pragma: no cover + except Exception: # pragma: no cover LOGGER.exception('GetKpiDescriptor exception') diff --git a/src/monitoring/service/__main__.py b/src/monitoring/service/__main__.py index 7835b4fc8a37f27419cebebfd0bf75b86820f38d..714046517e7b0ea591dce7411c5cb91ca3b867a6 100644 --- a/src/monitoring/service/__main__.py +++ b/src/monitoring/service/__main__.py @@ -12,44 +12,27 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging, signal, sys, threading, socket - -from common.Settings import get_setting, wait_for_environment_variables -from context.client.ContextClient import ContextClient -from monitoring.Config import ( - GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL, METRICS_PORT, CONTEXT_GRPC_SERVICE_PORT, - CONTEXT_SERVICE_HOST) - -from monitoring.client.monitoring_client import MonitoringClient -from monitoring.proto import monitoring_pb2 -from monitoring.service.EventTools import EventsDeviceCollector -from monitoring.service.MonitoringService import MonitoringService - +import logging, signal, sys, threading from prometheus_client import start_http_server +from common.Constants import ServiceNameEnum +from common.Settings import ( + ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_log_level, get_metrics_port, + wait_for_environment_variables) +from monitoring.proto import monitoring_pb2 +from .EventTools import EventsDeviceCollector +from .MonitoringService import MonitoringService terminate = threading.Event() LOGGER = None -LOCALHOST = '127.0.0.1' -def signal_handler(signal, frame): +def signal_handler(signal, frame): # pylint: disable=redefined-outer-name LOGGER.warning('Terminate signal received') terminate.set() def start_monitoring(): LOGGER.info('Start Monitoring...',) - grpc_service_port = get_setting('MONITORINGSERVICE_SERVICE_PORT_GRPC', default=GRPC_SERVICE_PORT ) - context_service_host = get_setting('CONTEXTSERVICE_SERVICE_HOST', default=CONTEXT_SERVICE_HOST ) - context_service_port = get_setting('CONTEXTSERVICE_SERVICE_PORT_GRPC', default=CONTEXT_GRPC_SERVICE_PORT) - - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - if s.connect_ex((context_service_host, int(context_service_port))) != 0: - LOGGER.info('Context service is not reachable') - return - - context_client_grpc = ContextClient(address=context_service_host, port=context_service_port) - monitoring_client = MonitoringClient(server=LOCALHOST, port=grpc_service_port) # instantiate the client - events_collector = EventsDeviceCollector(context_client_grpc, monitoring_client) + events_collector = EventsDeviceCollector() events_collector.start() # Iterate while terminate is not set @@ -64,8 +47,7 @@ def start_monitoring(): monitor_kpi_request.kpi_id.CopyFrom(kpi_id) monitor_kpi_request.sampling_duration_s = 86400 monitor_kpi_request.sampling_interval_s = 30 - - monitoring_client.MonitorKpi(monitor_kpi_request) + events_collector._monitoring_client.MonitorKpi(monitor_kpi_request) else: # Terminate is set, looping terminates LOGGER.warning("Stopping execution...") @@ -73,31 +55,28 @@ def start_monitoring(): events_collector.start() def main(): - global LOGGER - - grpc_service_port = get_setting('MONITORINGSERVICE_SERVICE_PORT_GRPC', default=GRPC_SERVICE_PORT) - max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS ) - grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD) - log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL ) - metrics_port = get_setting('METRICS_PORT', default=METRICS_PORT ) + global LOGGER # pylint: disable=global-statement + log_level = get_log_level() logging.basicConfig(level=log_level) LOGGER = logging.getLogger(__name__) wait_for_environment_variables([ - 'CONTEXTSERVICE_SERVICE_HOST', 'CONTEXTSERVICE_SERVICE_PORT_GRPC', - 'DEVICESERVICE_SERVICE_HOST', 'DEVICESERVICE_SERVICE_PORT_GRPC' + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST ), + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC), ]) signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) LOGGER.info('Starting...') + # Start metrics server + metrics_port = get_metrics_port() start_http_server(metrics_port) # Starting monitoring service - grpc_service = MonitoringService(port=grpc_service_port, max_workers=max_workers, grace_period=grace_period) + grpc_service = MonitoringService() grpc_service.start() start_monitoring() @@ -112,4 +91,4 @@ def main(): return 0 if __name__ == '__main__': - sys.exit(main()) \ No newline at end of file + sys.exit(main()) diff --git a/src/monitoring/tests/Messages.py b/src/monitoring/tests/Messages.py new file mode 100644 index 0000000000000000000000000000000000000000..dd4db01fdd6f94e0e376129b90c89b6475b48449 --- /dev/null +++ b/src/monitoring/tests/Messages.py @@ -0,0 +1,49 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from monitoring.proto import monitoring_pb2 +from monitoring.proto.kpi_sample_types_pb2 import KpiSampleType + +def kpi(): + _kpi = monitoring_pb2.Kpi() + _kpi.kpi_id.kpi_id.uuid = 'KPIID0000' # pylint: disable=maybe-no-member + return _kpi + +def kpi_id(): + _kpi_id = monitoring_pb2.KpiId() + _kpi_id.kpi_id.uuid = str(1) # pylint: disable=maybe-no-member + return _kpi_id + +def create_kpi_request(): + _create_kpi_request = monitoring_pb2.KpiDescriptor() + _create_kpi_request.kpi_description = 'KPI Description Test' + _create_kpi_request.kpi_sample_type = KpiSampleType.KPISAMPLETYPE_PACKETS_TRANSMITTED + _create_kpi_request.device_id.device_uuid.uuid = 'DEV1' # pylint: disable=maybe-no-member + _create_kpi_request.service_id.service_uuid.uuid = 'SERV1' # pylint: disable=maybe-no-member + _create_kpi_request.endpoint_id.endpoint_uuid.uuid = 'END1' # pylint: disable=maybe-no-member + return _create_kpi_request + +def monitor_kpi_request(kpi_uuid, sampling_duration_s, sampling_interval_s): + _monitor_kpi_request = monitoring_pb2.MonitorKpiRequest() + _monitor_kpi_request.kpi_id.kpi_id.uuid = kpi_uuid # pylint: disable=maybe-no-member + _monitor_kpi_request.sampling_duration_s = sampling_duration_s + _monitor_kpi_request.sampling_interval_s = sampling_interval_s + return _monitor_kpi_request + +def include_kpi_request(): + _include_kpi_request = monitoring_pb2.Kpi() + _include_kpi_request.kpi_id.kpi_id.uuid = str(1) # pylint: disable=maybe-no-member + _include_kpi_request.timestamp = "2021-10-12T13:14:42Z" + _include_kpi_request.kpi_value.intVal = 500 # pylint: disable=maybe-no-member + return _include_kpi_request diff --git a/src/monitoring/tests/Objects.py b/src/monitoring/tests/Objects.py new file mode 100644 index 0000000000000000000000000000000000000000..852da6bc98dee441a1e21e60e1b3ae7436b98ebf --- /dev/null +++ b/src/monitoring/tests/Objects.py @@ -0,0 +1,30 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from common.tools.object_factory.Device import ( + json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled) +from context.proto.kpi_sample_types_pb2 import KpiSampleType + +PACKET_PORT_SAMPLE_TYPES = [ + KpiSampleType.KPISAMPLETYPE_PACKETS_TRANSMITTED, + KpiSampleType.KPISAMPLETYPE_PACKETS_RECEIVED, + KpiSampleType.KPISAMPLETYPE_BYTES_TRANSMITTED, + KpiSampleType.KPISAMPLETYPE_BYTES_RECEIVED, +] + +DEVICE_DEV1_UUID = 'DEV1' +ENDPOINT_END1_UUID = 'END1' +DEVICE_DEV1_ENDPOINT_DEFS = [(ENDPOINT_END1_UUID, 'copper', PACKET_PORT_SAMPLE_TYPES)] +DEVICE_DEV1 = json_device_emulated_packet_router_disabled(DEVICE_DEV1_UUID) +DEVICE_DEV1_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_DEV1_ENDPOINT_DEFS) diff --git a/src/monitoring/tests/test_unitary.py b/src/monitoring/tests/test_unitary.py index 0701c5ce8bc56ee34d0a90760b0d6e88fdbbee42..d3799689eee4a1a12f4d4d7998d92482c59adb16 100644 --- a/src/monitoring/tests/test_unitary.py +++ b/src/monitoring/tests/test_unitary.py @@ -12,36 +12,35 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging -import os -import socket -import pytest +import copy, logging, os, pytest from typing import Tuple - - -from monitoring.client.monitoring_client import MonitoringClient -from monitoring.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, DEVICE_GRPC_SERVICE_PORT -from monitoring.proto import context_pb2, monitoring_pb2 -from monitoring.proto.kpi_sample_types_pb2 import KpiSampleType -from monitoring.service import SqliteTools, InfluxTools -from monitoring.service.MonitoringService import MonitoringService -from monitoring.service.EventTools import EventsDeviceCollector - +from common.Constants import ServiceNameEnum +from common.Settings import ( + ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_service_port_grpc) from common.orm.Database import Database from common.orm.Factory import get_database_backend, BackendEnum as DatabaseBackendEnum from common.message_broker.Factory import get_messagebroker_backend, BackendEnum as MessageBrokerBackendEnum from common.message_broker.MessageBroker import MessageBroker -from context.Config import ( - GRPC_SERVICE_PORT as grpc_port_context, - GRPC_MAX_WORKERS as grpc_workers_context, - GRPC_GRACE_PERIOD as grpc_grace_context -) from context.client.ContextClient import ContextClient from context.service.grpc_server.ContextService import ContextService -from context.service.Populate import populate from context.proto.context_pb2 import EventTypeEnum, DeviceEvent, Device -from context.tests.Objects import (DEVICE_R1, DEVICE_R1_UUID) + +from device.client.DeviceClient import DeviceClient +from device.service.DeviceService import DeviceService +from device.service.driver_api.DriverFactory import DriverFactory +from device.service.driver_api.DriverInstanceCache import DriverInstanceCache +from device.service.drivers import DRIVERS + +from monitoring.client.MonitoringClient import MonitoringClient +from monitoring.proto import context_pb2, monitoring_pb2 +from monitoring.proto.kpi_sample_types_pb2 import KpiSampleType +from monitoring.service import SqliteTools, InfluxTools +from monitoring.service.MonitoringService import MonitoringService +from monitoring.service.EventTools import EventsDeviceCollector +from monitoring.tests.Messages import create_kpi_request, include_kpi_request, kpi, kpi_id, monitor_kpi_request +from monitoring.tests.Objects import DEVICE_DEV1, DEVICE_DEV1_CONNECT_RULES, DEVICE_DEV1_UUID + LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) @@ -50,18 +49,19 @@ LOGGER.setLevel(logging.DEBUG) # Tests Setup ########################### -SERVER_ADDRESS = '127.0.0.1' -LISTEN_ADDRESS = '[::]' -GRPC_PORT_MONITORING = 7070 +LOCAL_HOST = '127.0.0.1' -GRPC_PORT_CONTEXT = 10000 + grpc_port_context # avoid privileged ports -DEVICE_GRPC_SERVICE_PORT = 10000 + DEVICE_GRPC_SERVICE_PORT # avoid privileged ports -MONITORING_GRPC_SERVICE_PORT = GRPC_PORT_MONITORING # avoid privileged ports +CONTEXT_SERVICE_PORT = 10000 + get_service_port_grpc(ServiceNameEnum.CONTEXT) # avoid privileged ports +os.environ[get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST )] = str(LOCAL_HOST) +os.environ[get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(CONTEXT_SERVICE_PORT) +DEVICE_SERVICE_PORT = 10000 + get_service_port_grpc(ServiceNameEnum.DEVICE) # avoid privileged ports +os.environ[get_env_var_name(ServiceNameEnum.DEVICE, ENVVAR_SUFIX_SERVICE_HOST )] = str(LOCAL_HOST) +os.environ[get_env_var_name(ServiceNameEnum.DEVICE, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(DEVICE_SERVICE_PORT) -SCENARIOS = [ # comment/uncomment scenarios to activate/deactivate them in the test unit - ('all_inmemory', DatabaseBackendEnum.INMEMORY, {}, MessageBrokerBackendEnum.INMEMORY, {} ), -] +MONITORING_SERVICE_PORT = 10000 + get_service_port_grpc(ServiceNameEnum.MONITORING) # avoid privileged ports +os.environ[get_env_var_name(ServiceNameEnum.MONITORING, ENVVAR_SUFIX_SERVICE_HOST )] = str(LOCAL_HOST) +os.environ[get_env_var_name(ServiceNameEnum.MONITORING, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(MONITORING_SERVICE_PORT) INFLUXDB_HOSTNAME = os.environ.get("INFLUXDB_HOSTNAME") INFLUXDB_PORT = os.environ.get("INFLUXDB_PORT") @@ -69,49 +69,61 @@ INFLUXDB_USER = os.environ.get("INFLUXDB_USER") INFLUXDB_PASSWORD = os.environ.get("INFLUXDB_PASSWORD") INFLUXDB_DATABASE = os.environ.get("INFLUXDB_DATABASE") -@pytest.fixture(scope='session', ids=[str(scenario[0]) for scenario in SCENARIOS], params=SCENARIOS) -def context_db_mb(request) -> Tuple[Database, MessageBroker]: - name,db_backend,db_settings,mb_backend,mb_settings = request.param - msg = 'Running scenario {:s} db_backend={:s}, db_settings={:s}, mb_backend={:s}, mb_settings={:s}...' - LOGGER.info(msg.format(str(name), str(db_backend.value), str(db_settings), str(mb_backend.value), str(mb_settings))) - _database = Database(get_database_backend(backend=db_backend, **db_settings)) - _message_broker = MessageBroker(get_messagebroker_backend(backend=mb_backend, **mb_settings)) +@pytest.fixture(scope='session') +def context_db_mb() -> Tuple[Database, MessageBroker]: + _database = Database(get_database_backend(backend=DatabaseBackendEnum.INMEMORY)) + _message_broker = MessageBroker(get_messagebroker_backend(backend=MessageBrokerBackendEnum.INMEMORY)) yield _database, _message_broker _message_broker.terminate() @pytest.fixture(scope='session') -def context_service_grpc(context_db_mb : Tuple[Database, MessageBroker]): # pylint: disable=redefined-outer-name - database = context_db_mb[0] +def context_service(context_db_mb : Tuple[Database, MessageBroker]): # pylint: disable=redefined-outer-name + database, message_broker = context_db_mb database.clear_all() - _service = ContextService( - database, context_db_mb[1], port=GRPC_PORT_CONTEXT, max_workers=grpc_workers_context, - grace_period=grpc_grace_context) + _service = ContextService(database, message_broker) _service.start() yield _service _service.stop() @pytest.fixture(scope='session') -def context_client_grpc(context_service_grpc : ContextService): # pylint: disable=redefined-outer-name - _client = ContextClient(address='localhost', port=GRPC_PORT_CONTEXT) +def context_client(context_service : ContextService): # pylint: disable=redefined-outer-name + _client = ContextClient() yield _client _client.close() - -# This fixture will be requested by test cases and last during testing session @pytest.fixture(scope='session') -def monitoring_service(): - LOGGER.warning('monitoring_service begin') +def device_service(context_service : ContextService): # pylint: disable=redefined-outer-name + LOGGER.info('Initializing DeviceService...') + driver_factory = DriverFactory(DRIVERS) + driver_instance_cache = DriverInstanceCache(driver_factory) + _service = DeviceService(driver_instance_cache) + _service.start() - service_port = GRPC_SERVICE_PORT - max_workers = GRPC_MAX_WORKERS - grace_period = GRPC_GRACE_PERIOD + # yield the server, when test finishes, execution will resume to stop it + LOGGER.info('Yielding DeviceService...') + yield _service + + LOGGER.info('Terminating DeviceService...') + _service.stop() + +@pytest.fixture(scope='session') +def device_client(device_service : DeviceService): # pylint: disable=redefined-outer-name + _client = DeviceClient() + yield _client + _client.close() +# This fixture will be requested by test cases and last during testing session +@pytest.fixture(scope='session') +def monitoring_service( + context_service : ContextService, # pylint: disable=redefined-outer-name + device_service : DeviceService # pylint: disable=redefined-outer-name + ): LOGGER.info('Initializing MonitoringService...') - _service = MonitoringService(port=service_port, max_workers=max_workers, grace_period=grace_period) + _service = MonitoringService() _service.start() # yield the server, when test finishes, execution will resume to stop it - LOGGER.warning('monitoring_service yielding') + LOGGER.info('Yielding MonitoringService...') yield _service LOGGER.info('Terminating MonitoringService...') @@ -120,224 +132,187 @@ def monitoring_service(): # This fixture will be requested by test cases and last during testing session. # The client requires the server, so client fixture has the server as dependency. @pytest.fixture(scope='session') -def monitoring_client(monitoring_service): - LOGGER.warning('monitoring_client begin') - client = MonitoringClient(server=SERVER_ADDRESS, port=GRPC_PORT_MONITORING) # instantiate the client - LOGGER.warning('monitoring_client returning') - return client +def monitoring_client(monitoring_service : MonitoringService): # pylint: disable=redefined-outer-name + LOGGER.info('Initializing MonitoringClient...') + _client = MonitoringClient() -# This fixture will be requested by test cases and last during testing session. -@pytest.fixture(scope='session') -def kpi(): - LOGGER.warning('test_include_kpi begin') - # form request - kpi = monitoring_pb2.Kpi() - kpi.kpi_id.kpi_id.uuid = 'KPIID0000' - kpi.kpiDescription = 'KPI Desc' - return kpi - -@pytest.fixture(scope='session') -def kpi_id(): - LOGGER.warning('test_include_kpi begin') - - # form request - kpi_id = monitoring_pb2.KpiId() - kpi_id.kpi_id.uuid = str(1) + # yield the server, when test finishes, execution will resume to stop it + LOGGER.info('Yielding MonitoringClient...') + yield _client - return kpi_id + LOGGER.info('Closing MonitoringClient...') + _client.close() @pytest.fixture(scope='session') def sql_db(): - sql_db = SqliteTools.SQLite('monitoring.db') - return sql_db + _sql_db = SqliteTools.SQLite('monitoring.db') + return _sql_db @pytest.fixture(scope='session') def influx_db(): - influx_db = InfluxTools.Influx(INFLUXDB_HOSTNAME, INFLUXDB_PORT, INFLUXDB_USER, INFLUXDB_PASSWORD, INFLUXDB_DATABASE) - return influx_db - -@pytest.fixture(scope='session') -def create_kpi_request(): - LOGGER.warning('test_include_kpi begin') - - create_kpi_request = monitoring_pb2.KpiDescriptor() - create_kpi_request.kpi_description = 'KPI Description Test' - create_kpi_request.kpi_sample_type = KpiSampleType.KPISAMPLETYPE_PACKETS_TRANSMITTED - create_kpi_request.device_id.device_uuid.uuid = 'DEV1' # pylint: disable=maybe-no-member - create_kpi_request.service_id.service_uuid.uuid = "SERV1" - create_kpi_request.endpoint_id.endpoint_uuid.uuid = "END1" - - return create_kpi_request - -@pytest.fixture(scope='session') -def monitor_kpi_request(): - LOGGER.warning('test_monitor_kpi begin') - - monitor_kpi_request = monitoring_pb2.MonitorKpiRequest() - monitor_kpi_request.kpi_id.kpi_id.uuid = str(1) - monitor_kpi_request.sampling_duration_s = 120 - monitor_kpi_request.sampling_interval_s = 5 - - return monitor_kpi_request - - -@pytest.fixture(scope='session') -def include_kpi_request(): - LOGGER.warning('test_include_kpi begin') - - include_kpi_request = monitoring_pb2.Kpi() - include_kpi_request.kpi_id.kpi_id.uuid = str(1) - include_kpi_request.timestamp = "2021-10-12T13:14:42Z" - include_kpi_request.kpi_value.intVal = 500 - - return include_kpi_request - -@pytest.fixture(scope='session') -def address(): - address = '127.0.0.1' - return address + _influx_db = InfluxTools.Influx( + INFLUXDB_HOSTNAME, INFLUXDB_PORT, INFLUXDB_USER, INFLUXDB_PASSWORD, INFLUXDB_DATABASE) + return _influx_db -@pytest.fixture(scope='session') -def port(): - port = 7070 - return port ########################### # Tests Implementation ########################### # Test case that makes use of client fixture to test server's CreateKpi method -def test_create_kpi(monitoring_client,create_kpi_request): +def test_create_kpi(monitoring_client): # pylint: disable=redefined-outer-name # make call to server LOGGER.warning('test_create_kpi requesting') - response = monitoring_client.CreateKpi(create_kpi_request) + response = monitoring_client.CreateKpi(create_kpi_request()) LOGGER.debug(str(response)) assert isinstance(response, monitoring_pb2.KpiId) # Test case that makes use of client fixture to test server's MonitorKpi method -def test_monitor_kpi(monitoring_client,create_kpi_request): +def test_monitor_kpi( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + monitoring_client : MonitoringClient, # pylint: disable=redefined-outer-name + context_db_mb : Tuple[Database, MessageBroker] # pylint: disable=redefined-outer-name + ): LOGGER.warning('test_monitor_kpi begin') - response = monitoring_client.CreateKpi(create_kpi_request) + context_database = context_db_mb[0] - monitor_kpi_request = monitoring_pb2.MonitorKpiRequest() - monitor_kpi_request.kpi_id.kpi_id.uuid = response.kpi_id.uuid - monitor_kpi_request.sampling_duration_s = 120 - monitor_kpi_request.sampling_interval_s = 5 + # ----- Clean the database ----------------------------------------------------------------------------------------- + context_database.clear_all() - response = monitoring_client.MonitorKpi(monitor_kpi_request) + # ----- Dump state of database before create the object ------------------------------------------------------------ + db_entries = context_database.dump() + LOGGER.info('----- Database Dump [{:3d} entries] -------------------------'.format(len(db_entries))) + for db_entry in db_entries: + LOGGER.info(' [{:>4s}] {:40s} :: {:s}'.format(*db_entry)) # pragma: no cover + LOGGER.info('-----------------------------------------------------------') + assert len(db_entries) == 0 + + # ----- Update the object ------------------------------------------------------------------------------------------ + LOGGER.info('Adding Device {:s}'.format(DEVICE_DEV1_UUID)) + device_with_connect_rules = copy.deepcopy(DEVICE_DEV1) + device_with_connect_rules['device_config']['config_rules'].extend(DEVICE_DEV1_CONNECT_RULES) + response = device_client.AddDevice(Device(**device_with_connect_rules)) + assert response.device_uuid.uuid == DEVICE_DEV1_UUID + + response = monitoring_client.CreateKpi(create_kpi_request()) + _monitor_kpi_request = monitor_kpi_request(response.kpi_id.uuid, 120, 5) # pylint: disable=maybe-no-member + response = monitoring_client.MonitorKpi(_monitor_kpi_request) LOGGER.debug(str(response)) assert isinstance(response, context_pb2.Empty) # Test case that makes use of client fixture to test server's IncludeKpi method -def test_include_kpi(monitoring_client,include_kpi_request): +def test_include_kpi(monitoring_client): # pylint: disable=redefined-outer-name # make call to server LOGGER.warning('test_include_kpi requesting') - response = monitoring_client.IncludeKpi(include_kpi_request) + response = monitoring_client.IncludeKpi(include_kpi_request()) LOGGER.debug(str(response)) assert isinstance(response, context_pb2.Empty) # Test case that makes use of client fixture to test server's GetStreamKpi method -def test_get_stream_kpi(monitoring_client,include_kpi_request): +def test_get_stream_kpi(monitoring_client): # pylint: disable=redefined-outer-name LOGGER.warning('test_getstream_kpi begin') - response = monitoring_client.GetStreamKpi(kpi) + response = monitoring_client.GetStreamKpi(kpi()) LOGGER.debug(str(response)) #assert isinstance(response, monitoring_pb2.Kpi) # Test case that makes use of client fixture to test server's GetInstantKpi method -def test_get_instant_kpi(monitoring_client,kpi_id): +def test_get_instant_kpi(monitoring_client): # pylint: disable=redefined-outer-name LOGGER.warning('test_getinstant_kpi begin') - response = monitoring_client.GetInstantKpi(kpi_id) + response = monitoring_client.GetInstantKpi(kpi_id()) LOGGER.debug(str(response)) assert isinstance(response, monitoring_pb2.Kpi) # Test case that makes use of client fixture to test server's GetInstantKpi method -def test_get_kpidescritor_kpi(monitoring_client,create_kpi_request): +def test_get_kpidescritor_kpi(monitoring_client): # pylint: disable=redefined-outer-name LOGGER.warning('test_getkpidescritor_kpi begin') - - response = monitoring_client.CreateKpi(create_kpi_request) - + response = monitoring_client.CreateKpi(create_kpi_request()) response = monitoring_client.GetKpiDescriptor(response) LOGGER.debug(str(response)) assert isinstance(response, monitoring_pb2.KpiDescriptor) -def test_sqlitedb_tools_insert_kpi(sql_db, create_kpi_request): +def test_sqlitedb_tools_insert_kpi(sql_db): # pylint: disable=redefined-outer-name LOGGER.warning('test_sqlitedb_tools_insert_kpi begin') - - kpi_description = create_kpi_request.kpi_description - kpi_sample_type = create_kpi_request.kpi_sample_type - kpi_device_id = create_kpi_request.device_id.device_uuid.uuid - kpi_endpoint_id = create_kpi_request.endpoint_id.endpoint_uuid.uuid - kpi_service_id = create_kpi_request.service_id.service_uuid.uuid + _create_kpi_request = create_kpi_request() + kpi_description = _create_kpi_request.kpi_description # pylint: disable=maybe-no-member + kpi_sample_type = _create_kpi_request.kpi_sample_type # pylint: disable=maybe-no-member + kpi_device_id = _create_kpi_request.device_id.device_uuid.uuid # pylint: disable=maybe-no-member + kpi_endpoint_id = _create_kpi_request.endpoint_id.endpoint_uuid.uuid # pylint: disable=maybe-no-member + kpi_service_id = _create_kpi_request.service_id.service_uuid.uuid # pylint: disable=maybe-no-member response = sql_db.insert_KPI(kpi_description, kpi_sample_type, kpi_device_id, kpi_endpoint_id, kpi_service_id) assert isinstance(response, int) -def test_sqlitedb_tools_get_kpi(sql_db, create_kpi_request): +def test_sqlitedb_tools_get_kpi(sql_db): # pylint: disable=redefined-outer-name LOGGER.warning('test_sqlitedb_tools_get_kpi begin') - - kpi_description = create_kpi_request.kpi_description - kpi_sample_type = create_kpi_request.kpi_sample_type - kpi_device_id = create_kpi_request.device_id.device_uuid.uuid - kpi_endpoint_id = create_kpi_request.endpoint_id.endpoint_uuid.uuid - kpi_service_id = create_kpi_request.service_id.service_uuid.uuid - - kpi_id = sql_db.insert_KPI(kpi_description, kpi_sample_type, kpi_device_id, kpi_endpoint_id, kpi_service_id) - - response = sql_db.get_KPI(kpi_id) + _create_kpi_request = create_kpi_request() + kpi_description = _create_kpi_request.kpi_description # pylint: disable=maybe-no-member + kpi_sample_type = _create_kpi_request.kpi_sample_type # pylint: disable=maybe-no-member + kpi_device_id = _create_kpi_request.device_id.device_uuid.uuid # pylint: disable=maybe-no-member + kpi_endpoint_id = _create_kpi_request.endpoint_id.endpoint_uuid.uuid # pylint: disable=maybe-no-member + kpi_service_id = _create_kpi_request.service_id.service_uuid.uuid # pylint: disable=maybe-no-member + + _kpi_id = sql_db.insert_KPI(kpi_description, kpi_sample_type, kpi_device_id, kpi_endpoint_id, kpi_service_id) + response = sql_db.get_KPI(_kpi_id) assert isinstance(response, tuple) -def test_sqlitedb_tools_get_kpis(sql_db): +def test_sqlitedb_tools_get_kpis(sql_db): # pylint: disable=redefined-outer-name LOGGER.warning('test_sqlitedb_tools_get_kpis begin') response = sql_db.get_KPIS() assert isinstance(response, list) -def test_sqlitedb_tools_delete_kpi(sql_db, create_kpi_request): +def test_sqlitedb_tools_delete_kpi(sql_db): # pylint: disable=redefined-outer-name LOGGER.warning('test_sqlitedb_tools_get_kpi begin') response = sql_db.delete_KPI("DEV1",KpiSampleType.KPISAMPLETYPE_PACKETS_TRANSMITTED) - if response == False: - kpi_description = create_kpi_request.kpi_description - kpi_sample_type = create_kpi_request.kpi_sample_type - kpi_device_id = create_kpi_request.device_id.device_uuid.uuid - kpi_endpoint_id = create_kpi_request.endpoint_id.endpoint_uuid.uuid - kpi_service_id = create_kpi_request.service_id.service_uuid.uuid + if not response: + _create_kpi_request = create_kpi_request() + kpi_description = _create_kpi_request.kpi_description # pylint: disable=maybe-no-member + kpi_sample_type = _create_kpi_request.kpi_sample_type # pylint: disable=maybe-no-member + kpi_device_id = _create_kpi_request.device_id.device_uuid.uuid # pylint: disable=maybe-no-member + kpi_endpoint_id = _create_kpi_request.endpoint_id.endpoint_uuid.uuid # pylint: disable=maybe-no-member + kpi_service_id = _create_kpi_request.service_id.service_uuid.uuid # pylint: disable=maybe-no-member sql_db.insert_KPI(kpi_description, kpi_sample_type, kpi_device_id, kpi_endpoint_id, kpi_service_id) response = sql_db.delete_KPI("DEV1", KpiSampleType.KPISAMPLETYPE_PACKETS_TRANSMITTED) - assert response == True + assert response -def test_sqlitedb_tools_delete_kpid_id(sql_db, create_kpi_request): +def test_sqlitedb_tools_delete_kpid_id(sql_db): # pylint: disable=redefined-outer-name LOGGER.warning('test_sqlitedb_tools_delete_kpid_id begin') response = sql_db.delete_kpid_id(1) - if response == False: - kpi_description = create_kpi_request.kpi_description - kpi_sample_type = create_kpi_request.kpi_sample_type - kpi_device_id = create_kpi_request.device_id.device_uuid.uuid - kpi_endpoint_id = create_kpi_request.endpoint_id.endpoint_uuid.uuid - kpi_service_id = create_kpi_request.service_id.service_uuid.uuid + if not response: + _create_kpi_request = create_kpi_request() + kpi_description = _create_kpi_request.kpi_description # pylint: disable=maybe-no-member + kpi_sample_type = _create_kpi_request.kpi_sample_type # pylint: disable=maybe-no-member + kpi_device_id = _create_kpi_request.device_id.device_uuid.uuid # pylint: disable=maybe-no-member + kpi_endpoint_id = _create_kpi_request.endpoint_id.endpoint_uuid.uuid # pylint: disable=maybe-no-member + kpi_service_id = _create_kpi_request.service_id.service_uuid.uuid # pylint: disable=maybe-no-member - kpi_id = sql_db.insert_KPI(kpi_description, kpi_sample_type, kpi_device_id, kpi_endpoint_id, kpi_service_id) - response = sql_db.delete_kpid_id(kpi_id) + _kpi_id = sql_db.insert_KPI(kpi_description, kpi_sample_type, kpi_device_id, kpi_endpoint_id, kpi_service_id) + response = sql_db.delete_kpid_id(_kpi_id) - assert response == True + assert response -def test_influxdb_tools_write_kpi(influx_db): +def test_influxdb_tools_write_kpi(influx_db): # pylint: disable=redefined-outer-name LOGGER.warning('test_influxdb_tools_write_kpi begin') -def test_influxdb_tools_read_kpi_points(influx_db): +def test_influxdb_tools_read_kpi_points(influx_db): # pylint: disable=redefined-outer-name LOGGER.warning('test_influxdb_tools_read_kpi_points begin') -def test_events_tools(context_client_grpc: ContextClient, # pylint: disable=redefined-outer-name - monitoring_client : MonitoringClient, - context_db_mb: Tuple[Database, MessageBroker]): +def test_events_tools( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + monitoring_client : MonitoringClient, # pylint: disable=redefined-outer-name + context_db_mb : Tuple[Database, MessageBroker] # pylint: disable=redefined-outer-name + ): LOGGER.warning('test_get_device_events begin') context_database = context_db_mb[0] @@ -346,10 +321,10 @@ def test_events_tools(context_client_grpc: ContextClient, # pylint: disable=red context_database.clear_all() # ----- Initialize the EventsCollector ----------------------------------------------------------------------------- - events_collector = EventsDeviceCollector(context_client_grpc, monitoring_client) + events_collector = EventsDeviceCollector() events_collector.start() - # # ----- Dump state of database before create the object ------------------------------------------------------------ + # ----- Dump state of database before create the object ------------------------------------------------------------ db_entries = context_database.dump() LOGGER.info('----- Database Dump [{:3d} entries] -------------------------'.format(len(db_entries))) for db_entry in db_entries: @@ -357,18 +332,22 @@ def test_events_tools(context_client_grpc: ContextClient, # pylint: disable=red LOGGER.info('-----------------------------------------------------------') assert len(db_entries) == 0 - populate('localhost', GRPC_PORT_CONTEXT) # place this call in the appropriate line, according to your tests - # ----- Update the object ------------------------------------------------------------------------------------------ - response = context_client_grpc.SetDevice(Device(**DEVICE_R1)) - assert response.device_uuid.uuid == DEVICE_R1_UUID + LOGGER.info('Adding Device {:s}'.format(DEVICE_DEV1_UUID)) + device_with_connect_rules = copy.deepcopy(DEVICE_DEV1) + device_with_connect_rules['device_config']['config_rules'].extend(DEVICE_DEV1_CONNECT_RULES) + response = device_client.AddDevice(Device(**device_with_connect_rules)) + assert response.device_uuid.uuid == DEVICE_DEV1_UUID events_collector.stop() -def test_get_device_events(context_client_grpc: ContextClient, # pylint: disable=redefined-outer-name - monitoring_client : MonitoringClient, - context_db_mb: Tuple[Database, MessageBroker]): +def test_get_device_events( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + monitoring_client : MonitoringClient, # pylint: disable=redefined-outer-name + context_db_mb : Tuple[Database, MessageBroker] # pylint: disable=redefined-outer-name + ): LOGGER.warning('test_get_device_events begin') @@ -378,10 +357,10 @@ def test_get_device_events(context_client_grpc: ContextClient, # pylint: disabl context_database.clear_all() # ----- Initialize the EventsCollector ----------------------------------------------------------------------------- - events_collector = EventsDeviceCollector(context_client_grpc,monitoring_client) + events_collector = EventsDeviceCollector() events_collector.start() - # # ----- Dump state of database before create the object ------------------------------------------------------------ + # ----- Dump state of database before create the object ------------------------------------------------------------ db_entries = context_database.dump() LOGGER.info('----- Database Dump [{:3d} entries] -------------------------'.format(len(db_entries))) for db_entry in db_entries: @@ -389,20 +368,26 @@ def test_get_device_events(context_client_grpc: ContextClient, # pylint: disabl LOGGER.info('-----------------------------------------------------------') assert len(db_entries) == 0 - populate('localhost', GRPC_PORT_CONTEXT) # place this call in the appropriate line, according to your tests - # ----- Check create event ----------------------------------------------------------------------------------------- - event = events_collector.get_event(block=True) + LOGGER.info('Adding Device {:s}'.format(DEVICE_DEV1_UUID)) + device_with_connect_rules = copy.deepcopy(DEVICE_DEV1) + device_with_connect_rules['device_config']['config_rules'].extend(DEVICE_DEV1_CONNECT_RULES) + response = device_client.AddDevice(Device(**device_with_connect_rules)) + assert response.device_uuid.uuid == DEVICE_DEV1_UUID + event = events_collector.get_event(block=True) assert isinstance(event, DeviceEvent) assert event.event.event_type == EventTypeEnum.EVENTTYPE_CREATE - assert event.device_id.device_uuid.uuid == DEVICE_R1_UUID + assert event.device_id.device_uuid.uuid == DEVICE_DEV1_UUID events_collector.stop() -def test_listen_events(monitoring_client: MonitoringClient, - context_client_grpc: ContextClient, # pylint: disable=redefined-outer-name - context_db_mb: Tuple[Database, MessageBroker]): +def test_listen_events( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient, # pylint: disable=redefined-outer-name + monitoring_client : MonitoringClient, # pylint: disable=redefined-outer-name + context_db_mb : Tuple[Database, MessageBroker] # pylint: disable=redefined-outer-name + ): LOGGER.warning('test_listen_events begin') @@ -412,10 +397,10 @@ def test_listen_events(monitoring_client: MonitoringClient, context_database.clear_all() # ----- Initialize the EventsCollector ----------------------------------------------------------------------------- - events_collector = EventsDeviceCollector(context_client_grpc,monitoring_client) + events_collector = EventsDeviceCollector() events_collector.start() - # # ----- Dump state of database before create the object ------------------------------------------------------------ + # ----- Dump state of database before create the object ------------------------------------------------------------ db_entries = context_database.dump() LOGGER.info('----- Database Dump [{:3d} entries] -------------------------'.format(len(db_entries))) for db_entry in db_entries: @@ -423,18 +408,12 @@ def test_listen_events(monitoring_client: MonitoringClient, LOGGER.info('-----------------------------------------------------------') assert len(db_entries) == 0 - populate('localhost', GRPC_PORT_CONTEXT) # place this call in the appropriate line, according to your tests + LOGGER.info('Adding Device {:s}'.format(DEVICE_DEV1_UUID)) + device_with_connect_rules = copy.deepcopy(DEVICE_DEV1) + device_with_connect_rules['device_config']['config_rules'].extend(DEVICE_DEV1_CONNECT_RULES) + response = device_client.AddDevice(Device(**device_with_connect_rules)) + assert response.device_uuid.uuid == DEVICE_DEV1_UUID kpi_id_list = events_collector.listen_events() - assert bool(kpi_id_list) == True - -def test_socket_ports(address, port): - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - result = s.connect_ex((address,port)) - - if result == 0: - print('socket is open') - else: - print('socket is not open') - s.close() + assert len(kpi_id_list) > 0 diff --git a/src/opticalattackmitigator/.gitlab-ci.yml b/src/opticalattackmitigator/.gitlab-ci.yml index a39a83f6f4a7f98cce08fd4b7d5b9a0379105935..5b9a133bd0cbf4b7dc4a4b6cf290a3be9adf663e 100644 --- a/src/opticalattackmitigator/.gitlab-ci.yml +++ b/src/opticalattackmitigator/.gitlab-ci.yml @@ -55,7 +55,6 @@ unit test opticalattackmitigator: - sleep 5 - docker ps -a - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - - docker exec -i $IMAGE_NAME bash -c "coverage xml -o /opt/results/${IMAGE_NAME}_coverage.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: @@ -75,7 +74,6 @@ unit test opticalattackmitigator: when: always reports: junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml - cobertura: src/$IMAGE_NAME/tests/${IMAGE_NAME}_coverage.xml # Deployment of the opticalattackmitigator service in Kubernetes Cluster diff --git a/src/opticalcentralizedattackdetector/.gitlab-ci.yml b/src/opticalcentralizedattackdetector/.gitlab-ci.yml index 8a1445e80347fe64dac1beb1780894fa98ba85fd..c3d91aec6e10c7450cfda0b74d0bc3bbe613558b 100644 --- a/src/opticalcentralizedattackdetector/.gitlab-ci.yml +++ b/src/opticalcentralizedattackdetector/.gitlab-ci.yml @@ -55,7 +55,6 @@ unit test opticalcentralizedattackdetector: - sleep 5 - docker ps -a - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - - docker exec -i $IMAGE_NAME bash -c "coverage xml -o /opt/results/${IMAGE_NAME}_coverage.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: @@ -75,7 +74,6 @@ unit test opticalcentralizedattackdetector: when: always reports: junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml - cobertura: src/$IMAGE_NAME/tests/${IMAGE_NAME}_coverage.xml # Deployment of the opticalcentralizedattackdetector service in Kubernetes Cluster diff --git a/src/opticalcentralizedattackdetector/service/OpticalCentralizedAttackDetectorServiceServicerImpl.py b/src/opticalcentralizedattackdetector/service/OpticalCentralizedAttackDetectorServiceServicerImpl.py index 9c77a959cbdc484af143015a2868121af3845b0a..d4c71476f016081f7d230a3cfe87e73b35654987 100644 --- a/src/opticalcentralizedattackdetector/service/OpticalCentralizedAttackDetectorServiceServicerImpl.py +++ b/src/opticalcentralizedattackdetector/service/OpticalCentralizedAttackDetectorServiceServicerImpl.py @@ -16,11 +16,8 @@ import os, grpc, logging, random from influxdb import InfluxDBClient from common.rpc_method_wrapper.Decorator import create_metrics, safe_and_metered_rpc_method from context.client.ContextClient import ContextClient -from context.Config import GRPC_SERVICE_PORT as CONTEXT_GRPC_SERVICE_PORT -from monitoring.client.monitoring_client import MonitoringClient -from monitoring.Config import GRPC_SERVICE_PORT as MONITORING_GRPC_SERVICE_PORT +from monitoring.client.MonitoringClient import MonitoringClient from service.client.ServiceClient import ServiceClient -from service.Config import GRPC_SERVICE_PORT as SERVICE_GRPC_SERVICE_PORT from dbscanserving.proto.dbscanserving_pb2 import DetectionRequest, DetectionResponse, Sample from dbscanserving.client.DbscanServingClient import DbscanServingClient from dbscanserving.Config import GRPC_SERVICE_PORT as DBSCANSERVING_GRPC_SERVICE_PORT @@ -35,8 +32,7 @@ from opticalcentralizedattackdetector.proto.monitoring_pb2 import KpiList from opticalcentralizedattackdetector.proto.optical_centralized_attack_detector_pb2_grpc import ( OpticalCentralizedAttackDetectorServiceServicer) from opticalcentralizedattackdetector.Config import ( - CONTEXT_SERVICE_ADDRESS, SERVICE_SERVICE_ADDRESS, INFERENCE_SERVICE_ADDRESS, MONITORING_SERVICE_ADDRESS, - ATTACK_MITIGATOR_SERVICE_ADDRESS) + INFERENCE_SERVICE_ADDRESS, MONITORING_SERVICE_ADDRESS, ATTACK_MITIGATOR_SERVICE_ADDRESS) LOGGER = logging.getLogger(__name__) @@ -49,12 +45,16 @@ INFLUXDB_HOSTNAME = os.environ.get("INFLUXDB_HOSTNAME") INFLUXDB_USER = os.environ.get("INFLUXDB_USER") INFLUXDB_PASSWORD = os.environ.get("INFLUXDB_PASSWORD") INFLUXDB_DATABASE = os.environ.get("INFLUXDB_DATABASE") -context_client: ContextClient = ContextClient(address=CONTEXT_SERVICE_ADDRESS, port=CONTEXT_GRPC_SERVICE_PORT) -influxdb_client: InfluxDBClient = InfluxDBClient(host=MONITORING_SERVICE_ADDRESS, port=8086, username=INFLUXDB_USER, password=INFLUXDB_PASSWORD, database=INFLUXDB_DATABASE) -monitoring_client: MonitoringClient = MonitoringClient(server=MONITORING_SERVICE_ADDRESS, port=MONITORING_GRPC_SERVICE_PORT) -dbscanserving_client: DbscanServingClient = DbscanServingClient(address=INFERENCE_SERVICE_ADDRESS, port=DBSCANSERVING_GRPC_SERVICE_PORT) -service_client: ServiceClient = ServiceClient(SERVICE_SERVICE_ADDRESS, SERVICE_GRPC_SERVICE_PORT) -attack_mitigator_client: OpticalAttackMitigatorClient = OpticalAttackMitigatorClient(address=ATTACK_MITIGATOR_SERVICE_ADDRESS, port=ATTACK_MITIGATOR_GRPC_SERVICE_PORT) +context_client: ContextClient = ContextClient() +influxdb_client: InfluxDBClient = InfluxDBClient( + host=MONITORING_SERVICE_ADDRESS, port=8086, username=INFLUXDB_USER, password=INFLUXDB_PASSWORD, + database=INFLUXDB_DATABASE) +monitoring_client: MonitoringClient = MonitoringClient() +dbscanserving_client: DbscanServingClient = DbscanServingClient( + address=INFERENCE_SERVICE_ADDRESS, port=DBSCANSERVING_GRPC_SERVICE_PORT) +service_client: ServiceClient = ServiceClient() +attack_mitigator_client: OpticalAttackMitigatorClient = OpticalAttackMitigatorClient( + address=ATTACK_MITIGATOR_SERVICE_ADDRESS, port=ATTACK_MITIGATOR_GRPC_SERVICE_PORT) class OpticalCentralizedAttackDetectorServiceServicerImpl(OpticalCentralizedAttackDetectorServiceServicer): diff --git a/src/policy/.gitlab-ci.yml b/src/policy/.gitlab-ci.yml index 1f855bb18188790697b1adcaa998fe9196d71055..164540a05172666375f503549f098ef3a90cdf06 100644 --- a/src/policy/.gitlab-ci.yml +++ b/src/policy/.gitlab-ci.yml @@ -12,45 +12,71 @@ # See the License for the specific language governing permissions and # limitations under the License. +variables: + IMAGE_NAME_POLICY: 'policy' + REPORTS_PATH_POLICY: "src/${IMAGE_NAME_POLICY}/reports" + BUILD_ENV_POLICY: build-policy.env + # Package application needed to run tests & build the image on next stage build policy: - variables: - IMAGE_NAME: 'policy' # name of the microservice - IMAGE_NAME_TEST: 'policy-test' # name of the microservice - IMAGE_TAG: '0.1.0' # tag of the container image (production, development, etc) stage: build script: - - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME/ --target builder + - export IMAGE_TAG=$(grep -m1 '<version>' ./src/$IMAGE_NAME_POLICY/pom.xml | grep -oP '(?<=>).*(?=<)') + - echo "IMAGE_TAG=${IMAGE_TAG}" >> ${BUILD_ENV_POLICY} + - cat ${BUILD_ENV_POLICY} + - docker build -t "$IMAGE_NAME_POLICY:$IMAGE_TAG" -f ./src/$IMAGE_NAME_POLICY/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME_POLICY/ --target builder + after_script: + - docker images --filter="dangling=true" --quiet | xargs -r docker rmi + artifacts: + reports: + dotenv: ${BUILD_ENV_POLICY} rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' - changes: - - src/$IMAGE_NAME/** - - manifests/${IMAGE_NAME}service.yaml + - src/$IMAGE_NAME_POLICY/** + - manifests/${IMAGE_NAME_POLICY}service.yaml - .gitlab-ci.yml # Run tests, build & push the image unit_test policy: variables: - IMAGE_NAME: 'policy' # name of the microservice - IMAGE_NAME_TEST: 'policy-test' # name of the microservice - IMAGE_TAG: '0.1.0' # tag of the container image (production, development, etc) + REPORTS_CONTAINER: "${IMAGE_NAME_POLICY}-reports" stage: unit_test needs: - build policy before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + - docker rm ${REPORTS_CONTAINER} || true script: - - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME/ --target unit-test - - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME/ --target release - - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" - - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" + - echo "Running tests for image ${IMAGE_TAG}" + - docker build -t "$IMAGE_NAME_POLICY:$IMAGE_TAG" -f ./src/$IMAGE_NAME_POLICY/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME_POLICY/ --target unit-test + # Transfer JaCoCo and Surefire reports from within tests image + - docker create --name ${REPORTS_CONTAINER} "$IMAGE_NAME_POLICY:$IMAGE_TAG" + - mkdir -p ${REPORTS_PATH_POLICY} + - docker cp ${REPORTS_CONTAINER}:/app/target/site/jacoco/index.html ${REPORTS_PATH_POLICY}/coverage.html + - docker cp ${REPORTS_CONTAINER}:/app/target/site/jacoco/jacoco.xml ${REPORTS_PATH_POLICY}/jacoco.xml + - docker cp ${REPORTS_CONTAINER}:/app/target/surefire-reports/ ${REPORTS_PATH_POLICY}/ + - cat ${REPORTS_PATH_POLICY}/coverage.html | grep -o 'Total[^%]*%' | sed 's/<.*>/ /; s/Total/JaCoCo Coverage Total:/' + - docker run -v "$(pwd)/src/${IMAGE_NAME_POLICY}:/${IMAGE_NAME_POLICY}" --rm registry.gitlab.com/haynes/jacoco2cobertura:1.0.7 python /opt/cover2cover.py ${IMAGE_NAME_POLICY}/reports/jacoco.xml ${IMAGE_NAME_POLICY}/src/main/java > ${REPORTS_PATH_POLICY}/cobertura.xml + # Build final image + - docker build -t "$IMAGE_NAME_POLICY:$IMAGE_TAG" -f ./src/$IMAGE_NAME_POLICY/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME_POLICY/ --target release + - docker tag "$IMAGE_NAME_POLICY:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME_POLICY:$IMAGE_TAG" + - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME_POLICY:$IMAGE_TAG" + after_script: + - docker rm ${REPORTS_CONTAINER} + - docker rm -f "$IMAGE_NAME_POLICY:$IMAGE_TAG" + coverage: '/JaCoCo Coverage Total: ([0-9]{1,3})%/' + artifacts: + reports: + junit: + - ${REPORTS_PATH_POLICY}/surefire-reports/TEST-*.xml rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' - changes: - - src/$IMAGE_NAME/** - - manifests/${IMAGE_NAME}service.yaml + - src/$IMAGE_NAME_POLICY/** + - manifests/${IMAGE_NAME_POLICY}service.yaml - .gitlab-ci.yml # Deployment of policy service in Kubernetes Cluster diff --git a/src/policy/pom.xml b/src/policy/pom.xml index 02077d79a1649b0531aa7dca09fa08fe806f82b5..6233d3edb8b1e66ef0e9dce27dfca0eb08359399 100644 --- a/src/policy/pom.xml +++ b/src/policy/pom.xml @@ -99,6 +99,12 @@ </dependencyManagement> <dependencies> + <dependency> + <groupId>io.github.project-openubl</groupId> + <artifactId>quarkus-bouncycastle</artifactId> + <version>1.2.2.Final</version> + </dependency> + <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-grpc</artifactId> diff --git a/src/policy/src/main/docker/Dockerfile.multistage.jvm b/src/policy/src/main/docker/Dockerfile.multistage.jvm index 280e4142d00fa6acdf837e27def9881015484e3c..e153b7d84c21a89276d2d3622ead316508b22cef 100644 --- a/src/policy/src/main/docker/Dockerfile.multistage.jvm +++ b/src/policy/src/main/docker/Dockerfile.multistage.jvm @@ -29,7 +29,7 @@ RUN mvn --errors --batch-mode package -Dmaven.test.skip=true # Stage 2 FROM builder AS unit-test -RUN mvn --errors --batch-mode test +RUN mvn --errors --batch-mode -Pgenerate-consolidated-coverage verify # Stage 3 FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 AS release diff --git a/src/policy/src/main/java/eu/teraflow/policy/PolicyGateway.java b/src/policy/src/main/java/eu/teraflow/policy/PolicyGateway.java index b6d1de94a45b2ac5b09d28d6b749cbf1c02413ea..2e8f9bba41f20c03e1db624f711b824a5fe37c9b 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/PolicyGateway.java +++ b/src/policy/src/main/java/eu/teraflow/policy/PolicyGateway.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy; diff --git a/src/policy/src/main/java/eu/teraflow/policy/PolicyGatewayImpl.java b/src/policy/src/main/java/eu/teraflow/policy/PolicyGatewayImpl.java index 45eed4c910a95eee2851231be33e944a5b779668..b95271708bf66833e09d9eed97b0b24ecfe09552 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/PolicyGatewayImpl.java +++ b/src/policy/src/main/java/eu/teraflow/policy/PolicyGatewayImpl.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy; diff --git a/src/policy/src/main/java/eu/teraflow/policy/PolicyService.java b/src/policy/src/main/java/eu/teraflow/policy/PolicyService.java index 5659fd61bbb40ff0a8877bb66de734ad707f7da0..d20775cc137240611b665c08adeaa725e15ad35e 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/PolicyService.java +++ b/src/policy/src/main/java/eu/teraflow/policy/PolicyService.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy; diff --git a/src/policy/src/main/java/eu/teraflow/policy/PolicyServiceImpl.java b/src/policy/src/main/java/eu/teraflow/policy/PolicyServiceImpl.java index 4b8ceba90b3c969912ad813cc934a7bd4cde40fc..d8025d0809526934b4fa3959781ab88f5f10160a 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/PolicyServiceImpl.java +++ b/src/policy/src/main/java/eu/teraflow/policy/PolicyServiceImpl.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy; diff --git a/src/policy/src/main/java/eu/teraflow/policy/SimpleLivenessCheck.java b/src/policy/src/main/java/eu/teraflow/policy/SimpleLivenessCheck.java index 3b60e1ad772d8356776d131e251b7d217bf92a24..bee4157d08ada23e738282e5f7732c1db99a9dee 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/SimpleLivenessCheck.java +++ b/src/policy/src/main/java/eu/teraflow/policy/SimpleLivenessCheck.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy; @@ -27,6 +27,6 @@ public class SimpleLivenessCheck implements HealthCheck { @Override public HealthCheckResponse call() { - return HealthCheckResponse.up("Policy Service"); + return HealthCheckResponse.up("Policy Service is live"); } } diff --git a/src/policy/src/main/java/eu/teraflow/policy/SimpleReadinessCheck.java b/src/policy/src/main/java/eu/teraflow/policy/SimpleReadinessCheck.java new file mode 100644 index 0000000000000000000000000000000000000000..0fe0c43b0cf98fd6a9432ed26ff57f03e1816095 --- /dev/null +++ b/src/policy/src/main/java/eu/teraflow/policy/SimpleReadinessCheck.java @@ -0,0 +1,32 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.policy; + +import javax.enterprise.context.ApplicationScoped; +import org.eclipse.microprofile.health.HealthCheck; +import org.eclipse.microprofile.health.HealthCheckResponse; +import org.eclipse.microprofile.health.Readiness; + +@Readiness +@ApplicationScoped +public class SimpleReadinessCheck implements HealthCheck { + + @Override + public HealthCheckResponse call() { + return HealthCheckResponse.up("Policy Service is ready"); + } +} diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/ContextService.java b/src/policy/src/main/java/eu/teraflow/policy/context/ContextService.java index f8803f5147155ac795a4b852ab424ef96c1cbef5..4d2b317cb3e76b043f919fa7112147a6bda8697e 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/context/ContextService.java +++ b/src/policy/src/main/java/eu/teraflow/policy/context/ContextService.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.context; diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ContextId.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ContextId.java index c5c2229427358ac0a1d5495f0c21653026141c03..47bcf543e15c5235dfdd8be076e9352c85ace892 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/context/model/ContextId.java +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ContextId.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.context.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/DeviceId.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/DeviceId.java index af82cd4d41c417e201d5d014527304842ca472bb..4277bf693ee78de9d15a0c34e2b6e6093a2aedfb 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/context/model/DeviceId.java +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/DeviceId.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.context.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/Event.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/Event.java index 309f8e077b67409f92ab0b83f784b0a14b5583e8..a9d532e06874b51e9b0283b31f6cdd225b4e4a0b 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/context/model/Event.java +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/Event.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.context.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/EventTypeEnum.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/EventTypeEnum.java index 30b890e60e6fe1fd73521a7445e2143ef0805a0c..2a45a89a7b026ad17ff12c8a725ebab0ed0c0af5 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/context/model/EventTypeEnum.java +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/EventTypeEnum.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.context.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/ServiceId.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/ServiceId.java index 3680cb5ef385e4333f5e8e9707dca17d5351c9b7..e8027d82c843e440384e1018251266330e07b1f2 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/context/model/ServiceId.java +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/ServiceId.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.context.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/context/model/Uuid.java b/src/policy/src/main/java/eu/teraflow/policy/context/model/Uuid.java index 857f7a51a2a8fed2ee954da8a9f4244a57c237be..9a429f5acbade01a50efdee4b9e8d36ea1400ae2 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/context/model/Uuid.java +++ b/src/policy/src/main/java/eu/teraflow/policy/context/model/Uuid.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.context.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRule.java b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRule.java index d9f597405300c941b3ab569fdf925fcc29b5e802..20f78eb817aca50fb0d711bee032deec1a43068e 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRule.java +++ b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRule.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleAction.java b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleAction.java index d3a3fd036b0b257e5b230860a529c30ad858b8b1..8592262aea9b8a82aaef9a348b7e215958414705 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleAction.java +++ b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleAction.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleCondition.java b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleCondition.java index 8f7b74e3f4de1d0019555dcc58de8958042ece13..22d65124c44be3ba1b93683c009860a6dc223da4 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleCondition.java +++ b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleCondition.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleEvent.java b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleEvent.java index c5660b95d456d6322eafacf5c32580778bb78c2f..476d1948215f502d7791ca95648e6a2089aa9434 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleEvent.java +++ b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleEvent.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleId.java b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleId.java index e3a25557a8ee7012196572a6db41e5095ccc4581..cc95d9e5d6ecd6ff583b68dbed5236eee26e8348 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleId.java +++ b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleId.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRulePriority.java b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRulePriority.java index 7113a20fa7756ecc707197232dcca6fe74d27898..c85bb9a3657265ca28e195cf4477c9ce6fd43df2 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRulePriority.java +++ b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRulePriority.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleState.java b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleState.java index 465187a5fd2a717e8b022fabd4f0062d4a454dda..43b93403073fcc78a614b721bd4a169894322841 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleState.java +++ b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleState.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleType.java b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleType.java index 1b46b249e3ca5ac49f8d23c3210cf1bb08204237..6becad243c2ab3d0bbe4cdb3a943fc0ab2ad9bd3 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleType.java +++ b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleType.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleValue.java b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleValue.java index 2e6498f233d9a31a21d7349cd53a9f36874b7413..9a928c4a22158ec2691acc4486ea9acd21ff28f8 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleValue.java +++ b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleValue.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleVariable.java b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleVariable.java index 10f86bbcadfcf936b2260fe81d0b6cfa4721752d..fa35d270a7cd00ec9772f6d3678d38f67972eea5 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleVariable.java +++ b/src/policy/src/main/java/eu/teraflow/policy/model/PolicyRuleVariable.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.model; diff --git a/src/policy/src/main/java/eu/teraflow/policy/model/RuleState.java b/src/policy/src/main/java/eu/teraflow/policy/model/RuleState.java index 05e051348652256bb0707c686e9e201b565042d8..6c8aabdb04399176714f06e85b1a00d18e6e867d 100644 --- a/src/policy/src/main/java/eu/teraflow/policy/model/RuleState.java +++ b/src/policy/src/main/java/eu/teraflow/policy/model/RuleState.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy.model; diff --git a/src/policy/src/main/resources/application.yml b/src/policy/src/main/resources/application.yml index 2a5a96ccc973f519d7515f7f13e6d8b50048da2a..2e09b2302d0311d06a36f3ee262e2a7a900c1ddc 100644 --- a/src/policy/src/main/resources/application.yml +++ b/src/policy/src/main/resources/application.yml @@ -13,28 +13,32 @@ # limitations under the License. quarkus: + banner: + path: teraflow-policy-banner.txt grpc: server: port: 9999 enable-reflection-service: true http: port: 8080 + container-image: group: teraflow-h2020 name: controller/policy registry: registry.gitlab.com + kubernetes: name: policyservice image-pull-policy: Always - add-version-to-label-selectors: false labels: app: policyservice + add-version-to-label-selectors: false readiness-probe: - initial-delay: 5s - period: 45s + initial-delay: 2s + period: 10s liveness-probe: - initial-delay: 5s - period: 45s + initial-delay: 2s + period: 10s ports: http: host-port: 8080 diff --git a/src/policy/src/main/resources/teraflow-policy-banner.txt b/src/policy/src/main/resources/teraflow-policy-banner.txt new file mode 100644 index 0000000000000000000000000000000000000000..d5effd98e7cf1fae8cd623674a3675181b00296f --- /dev/null +++ b/src/policy/src/main/resources/teraflow-policy-banner.txt @@ -0,0 +1,9 @@ + + _______ ______ _ _____ _ _ + |__ __| | ____| | | __ \ | (_) + | | ___ _ __ __ _| |__ | | _____ __ | |__) |__ | |_ ___ _ _ + | |/ _ \ '__/ _` | __| | |/ _ \ \ /\ / / | ___/ _ \| | |/ __| | | | + | | __/ | | (_| | | | | (_) \ V V / | | | (_) | | | (__| |_| | + |_|\___|_| \__,_|_| |_|\___/ \_/\_/ |_| \___/|_|_|\___|\__, | + __/ | + |___/ diff --git a/src/policy/src/test/java/eu/teraflow/policy/PolicyServiceTest.java b/src/policy/src/test/java/eu/teraflow/policy/PolicyServiceTest.java index abb9bdd369a7722b201e209ac27557e99e957d65..47a5502d15bb06c5851a01693e469a9c88588bfe 100644 --- a/src/policy/src/test/java/eu/teraflow/policy/PolicyServiceTest.java +++ b/src/policy/src/test/java/eu/teraflow/policy/PolicyServiceTest.java @@ -1,18 +1,18 @@ /* - * Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package eu.teraflow.policy; diff --git a/src/policy/target/generated-sources/grpc/context/ContextOuterClass.java b/src/policy/target/generated-sources/grpc/context/ContextOuterClass.java index 168ddf78b3a0233f3157e984fb7d925783bcd3b0..ee807d7a7c69256b7a4c99c5139fafe076898918 100644 --- a/src/policy/target/generated-sources/grpc/context/ContextOuterClass.java +++ b/src/policy/target/generated-sources/grpc/context/ContextOuterClass.java @@ -661,6 +661,141 @@ public final class ContextOuterClass { // @@protoc_insertion_point(enum_scope:context.ServiceStatusEnum) } + /** + * Protobuf enum {@code context.SliceStatusEnum} + */ + public enum SliceStatusEnum + implements com.google.protobuf.ProtocolMessageEnum { + /** + * <code>SLICESTATUS_UNDEFINED = 0;</code> + */ + SLICESTATUS_UNDEFINED(0), + /** + * <code>SLICESTATUS_PLANNED = 1;</code> + */ + SLICESTATUS_PLANNED(1), + /** + * <code>SLICESTATUS_INIT = 2;</code> + */ + SLICESTATUS_INIT(2), + /** + * <code>SLICESTATUS_ACTIVE = 3;</code> + */ + SLICESTATUS_ACTIVE(3), + /** + * <code>SLICESTATUS_DEINIT = 4;</code> + */ + SLICESTATUS_DEINIT(4), + UNRECOGNIZED(-1), + ; + + /** + * <code>SLICESTATUS_UNDEFINED = 0;</code> + */ + public static final int SLICESTATUS_UNDEFINED_VALUE = 0; + /** + * <code>SLICESTATUS_PLANNED = 1;</code> + */ + public static final int SLICESTATUS_PLANNED_VALUE = 1; + /** + * <code>SLICESTATUS_INIT = 2;</code> + */ + public static final int SLICESTATUS_INIT_VALUE = 2; + /** + * <code>SLICESTATUS_ACTIVE = 3;</code> + */ + public static final int SLICESTATUS_ACTIVE_VALUE = 3; + /** + * <code>SLICESTATUS_DEINIT = 4;</code> + */ + public static final int SLICESTATUS_DEINIT_VALUE = 4; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static SliceStatusEnum valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static SliceStatusEnum forNumber(int value) { + switch (value) { + case 0: return SLICESTATUS_UNDEFINED; + case 1: return SLICESTATUS_PLANNED; + case 2: return SLICESTATUS_INIT; + case 3: return SLICESTATUS_ACTIVE; + case 4: return SLICESTATUS_DEINIT; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap<SliceStatusEnum> + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + SliceStatusEnum> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap<SliceStatusEnum>() { + public SliceStatusEnum findValueByNumber(int number) { + return SliceStatusEnum.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return context.ContextOuterClass.getDescriptor().getEnumTypes().get(5); + } + + private static final SliceStatusEnum[] VALUES = values(); + + public static SliceStatusEnum valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private SliceStatusEnum(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:context.SliceStatusEnum) + } + /** * <pre> * ----- Configuration ------------------------------------------------------------------------------------------------- @@ -756,7 +891,7 @@ public final class ContextOuterClass { } public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return context.ContextOuterClass.getDescriptor().getEnumTypes().get(5); + return context.ContextOuterClass.getDescriptor().getEnumTypes().get(6); } private static final ConfigActionEnum[] VALUES = values(); @@ -27653,49 +27788,64 @@ public final class ContextOuterClass { } - public interface ConnectionIdOrBuilder extends - // @@protoc_insertion_point(interface_extends:context.ConnectionId) + public interface SliceIdOrBuilder extends + // @@protoc_insertion_point(interface_extends:context.SliceId) com.google.protobuf.MessageOrBuilder { /** - * <code>.context.Uuid connection_uuid = 1;</code> - * @return Whether the connectionUuid field is set. + * <code>.context.ContextId context_id = 1;</code> + * @return Whether the contextId field is set. */ - boolean hasConnectionUuid(); + boolean hasContextId(); /** - * <code>.context.Uuid connection_uuid = 1;</code> - * @return The connectionUuid. + * <code>.context.ContextId context_id = 1;</code> + * @return The contextId. */ - context.ContextOuterClass.Uuid getConnectionUuid(); + context.ContextOuterClass.ContextId getContextId(); /** - * <code>.context.Uuid connection_uuid = 1;</code> + * <code>.context.ContextId context_id = 1;</code> */ - context.ContextOuterClass.UuidOrBuilder getConnectionUuidOrBuilder(); + context.ContextOuterClass.ContextIdOrBuilder getContextIdOrBuilder(); + + /** + * <code>.context.Uuid slice_uuid = 2;</code> + * @return Whether the sliceUuid field is set. + */ + boolean hasSliceUuid(); + /** + * <code>.context.Uuid slice_uuid = 2;</code> + * @return The sliceUuid. + */ + context.ContextOuterClass.Uuid getSliceUuid(); + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + context.ContextOuterClass.UuidOrBuilder getSliceUuidOrBuilder(); } /** * <pre> - * ----- Connection ---------------------------------------------------------------------------------------------------- + * ----- Slice --------------------------------------------------------------------------------------------------------- * </pre> * - * Protobuf type {@code context.ConnectionId} + * Protobuf type {@code context.SliceId} */ - public static final class ConnectionId extends + public static final class SliceId extends com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:context.ConnectionId) - ConnectionIdOrBuilder { + // @@protoc_insertion_point(message_implements:context.SliceId) + SliceIdOrBuilder { private static final long serialVersionUID = 0L; - // Use ConnectionId.newBuilder() to construct. - private ConnectionId(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { + // Use SliceId.newBuilder() to construct. + private SliceId(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { super(builder); } - private ConnectionId() { + private SliceId() { } @java.lang.Override @SuppressWarnings({"unused"}) protected java.lang.Object newInstance( UnusedPrivateParameter unused) { - return new ConnectionId(); + return new SliceId(); } @java.lang.Override @@ -27703,7 +27853,7 @@ public final class ContextOuterClass { getUnknownFields() { return this.unknownFields; } - private ConnectionId( + private SliceId( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { @@ -27722,14 +27872,27 @@ public final class ContextOuterClass { done = true; break; case 10: { + context.ContextOuterClass.ContextId.Builder subBuilder = null; + if (contextId_ != null) { + subBuilder = contextId_.toBuilder(); + } + contextId_ = input.readMessage(context.ContextOuterClass.ContextId.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(contextId_); + contextId_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { context.ContextOuterClass.Uuid.Builder subBuilder = null; - if (connectionUuid_ != null) { - subBuilder = connectionUuid_.toBuilder(); + if (sliceUuid_ != null) { + subBuilder = sliceUuid_.toBuilder(); } - connectionUuid_ = input.readMessage(context.ContextOuterClass.Uuid.parser(), extensionRegistry); + sliceUuid_ = input.readMessage(context.ContextOuterClass.Uuid.parser(), extensionRegistry); if (subBuilder != null) { - subBuilder.mergeFrom(connectionUuid_); - connectionUuid_ = subBuilder.buildPartial(); + subBuilder.mergeFrom(sliceUuid_); + sliceUuid_ = subBuilder.buildPartial(); } break; @@ -27755,41 +27918,67 @@ public final class ContextOuterClass { } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return context.ContextOuterClass.internal_static_context_ConnectionId_descriptor; + return context.ContextOuterClass.internal_static_context_SliceId_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { - return context.ContextOuterClass.internal_static_context_ConnectionId_fieldAccessorTable + return context.ContextOuterClass.internal_static_context_SliceId_fieldAccessorTable .ensureFieldAccessorsInitialized( - context.ContextOuterClass.ConnectionId.class, context.ContextOuterClass.ConnectionId.Builder.class); + context.ContextOuterClass.SliceId.class, context.ContextOuterClass.SliceId.Builder.class); } - public static final int CONNECTION_UUID_FIELD_NUMBER = 1; - private context.ContextOuterClass.Uuid connectionUuid_; + public static final int CONTEXT_ID_FIELD_NUMBER = 1; + private context.ContextOuterClass.ContextId contextId_; /** - * <code>.context.Uuid connection_uuid = 1;</code> - * @return Whether the connectionUuid field is set. + * <code>.context.ContextId context_id = 1;</code> + * @return Whether the contextId field is set. */ @java.lang.Override - public boolean hasConnectionUuid() { - return connectionUuid_ != null; + public boolean hasContextId() { + return contextId_ != null; } /** - * <code>.context.Uuid connection_uuid = 1;</code> - * @return The connectionUuid. + * <code>.context.ContextId context_id = 1;</code> + * @return The contextId. */ @java.lang.Override - public context.ContextOuterClass.Uuid getConnectionUuid() { - return connectionUuid_ == null ? context.ContextOuterClass.Uuid.getDefaultInstance() : connectionUuid_; + public context.ContextOuterClass.ContextId getContextId() { + return contextId_ == null ? context.ContextOuterClass.ContextId.getDefaultInstance() : contextId_; } /** - * <code>.context.Uuid connection_uuid = 1;</code> + * <code>.context.ContextId context_id = 1;</code> */ @java.lang.Override - public context.ContextOuterClass.UuidOrBuilder getConnectionUuidOrBuilder() { - return getConnectionUuid(); + public context.ContextOuterClass.ContextIdOrBuilder getContextIdOrBuilder() { + return getContextId(); + } + + public static final int SLICE_UUID_FIELD_NUMBER = 2; + private context.ContextOuterClass.Uuid sliceUuid_; + /** + * <code>.context.Uuid slice_uuid = 2;</code> + * @return Whether the sliceUuid field is set. + */ + @java.lang.Override + public boolean hasSliceUuid() { + return sliceUuid_ != null; + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + * @return The sliceUuid. + */ + @java.lang.Override + public context.ContextOuterClass.Uuid getSliceUuid() { + return sliceUuid_ == null ? context.ContextOuterClass.Uuid.getDefaultInstance() : sliceUuid_; + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + @java.lang.Override + public context.ContextOuterClass.UuidOrBuilder getSliceUuidOrBuilder() { + return getSliceUuid(); } private byte memoizedIsInitialized = -1; @@ -27806,8 +27995,11 @@ public final class ContextOuterClass { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (connectionUuid_ != null) { - output.writeMessage(1, getConnectionUuid()); + if (contextId_ != null) { + output.writeMessage(1, getContextId()); + } + if (sliceUuid_ != null) { + output.writeMessage(2, getSliceUuid()); } unknownFields.writeTo(output); } @@ -27818,9 +28010,13 @@ public final class ContextOuterClass { if (size != -1) return size; size = 0; - if (connectionUuid_ != null) { + if (contextId_ != null) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, getConnectionUuid()); + .computeMessageSize(1, getContextId()); + } + if (sliceUuid_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getSliceUuid()); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -27832,15 +28028,20 @@ public final class ContextOuterClass { if (obj == this) { return true; } - if (!(obj instanceof context.ContextOuterClass.ConnectionId)) { + if (!(obj instanceof context.ContextOuterClass.SliceId)) { return super.equals(obj); } - context.ContextOuterClass.ConnectionId other = (context.ContextOuterClass.ConnectionId) obj; + context.ContextOuterClass.SliceId other = (context.ContextOuterClass.SliceId) obj; - if (hasConnectionUuid() != other.hasConnectionUuid()) return false; - if (hasConnectionUuid()) { - if (!getConnectionUuid() - .equals(other.getConnectionUuid())) return false; + if (hasContextId() != other.hasContextId()) return false; + if (hasContextId()) { + if (!getContextId() + .equals(other.getContextId())) return false; + } + if (hasSliceUuid() != other.hasSliceUuid()) return false; + if (hasSliceUuid()) { + if (!getSliceUuid() + .equals(other.getSliceUuid())) return false; } if (!unknownFields.equals(other.unknownFields)) return false; return true; @@ -27853,78 +28054,82 @@ public final class ContextOuterClass { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); - if (hasConnectionUuid()) { - hash = (37 * hash) + CONNECTION_UUID_FIELD_NUMBER; - hash = (53 * hash) + getConnectionUuid().hashCode(); + if (hasContextId()) { + hash = (37 * hash) + CONTEXT_ID_FIELD_NUMBER; + hash = (53 * hash) + getContextId().hashCode(); + } + if (hasSliceUuid()) { + hash = (37 * hash) + SLICE_UUID_FIELD_NUMBER; + hash = (53 * hash) + getSliceUuid().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static context.ContextOuterClass.ConnectionId parseFrom(byte[] data) + public static context.ContextOuterClass.SliceId parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static context.ContextOuterClass.ConnectionId parseFrom(java.io.InputStream input) + public static context.ContextOuterClass.SliceId parseFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input, extensionRegistry); } - public static context.ContextOuterClass.ConnectionId parseDelimitedFrom(java.io.InputStream input) + public static context.ContextOuterClass.SliceId parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input); } - public static context.ContextOuterClass.ConnectionId parseDelimitedFrom( + public static context.ContextOuterClass.SliceId parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } - public static context.ContextOuterClass.ConnectionId parseFrom( + public static context.ContextOuterClass.SliceId parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { @@ -27937,7 +28142,7 @@ public final class ContextOuterClass { public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); } - public static Builder newBuilder(context.ContextOuterClass.ConnectionId prototype) { + public static Builder newBuilder(context.ContextOuterClass.SliceId prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } @java.lang.Override @@ -27954,29 +28159,29 @@ public final class ContextOuterClass { } /** * <pre> - * ----- Connection ---------------------------------------------------------------------------------------------------- + * ----- Slice --------------------------------------------------------------------------------------------------------- * </pre> * - * Protobuf type {@code context.ConnectionId} + * Protobuf type {@code context.SliceId} */ public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements - // @@protoc_insertion_point(builder_implements:context.ConnectionId) - context.ContextOuterClass.ConnectionIdOrBuilder { + // @@protoc_insertion_point(builder_implements:context.SliceId) + context.ContextOuterClass.SliceIdOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return context.ContextOuterClass.internal_static_context_ConnectionId_descriptor; + return context.ContextOuterClass.internal_static_context_SliceId_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { - return context.ContextOuterClass.internal_static_context_ConnectionId_fieldAccessorTable + return context.ContextOuterClass.internal_static_context_SliceId_fieldAccessorTable .ensureFieldAccessorsInitialized( - context.ContextOuterClass.ConnectionId.class, context.ContextOuterClass.ConnectionId.Builder.class); + context.ContextOuterClass.SliceId.class, context.ContextOuterClass.SliceId.Builder.class); } - // Construct using context.ContextOuterClass.ConnectionId.newBuilder() + // Construct using context.ContextOuterClass.SliceId.newBuilder() private Builder() { maybeForceBuilderInitialization(); } @@ -27994,11 +28199,17 @@ public final class ContextOuterClass { @java.lang.Override public Builder clear() { super.clear(); - if (connectionUuidBuilder_ == null) { - connectionUuid_ = null; + if (contextIdBuilder_ == null) { + contextId_ = null; } else { - connectionUuid_ = null; - connectionUuidBuilder_ = null; + contextId_ = null; + contextIdBuilder_ = null; + } + if (sliceUuidBuilder_ == null) { + sliceUuid_ = null; + } else { + sliceUuid_ = null; + sliceUuidBuilder_ = null; } return this; } @@ -28006,17 +28217,17 @@ public final class ContextOuterClass { @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return context.ContextOuterClass.internal_static_context_ConnectionId_descriptor; + return context.ContextOuterClass.internal_static_context_SliceId_descriptor; } @java.lang.Override - public context.ContextOuterClass.ConnectionId getDefaultInstanceForType() { - return context.ContextOuterClass.ConnectionId.getDefaultInstance(); + public context.ContextOuterClass.SliceId getDefaultInstanceForType() { + return context.ContextOuterClass.SliceId.getDefaultInstance(); } @java.lang.Override - public context.ContextOuterClass.ConnectionId build() { - context.ContextOuterClass.ConnectionId result = buildPartial(); + public context.ContextOuterClass.SliceId build() { + context.ContextOuterClass.SliceId result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } @@ -28024,12 +28235,6018 @@ public final class ContextOuterClass { } @java.lang.Override - public context.ContextOuterClass.ConnectionId buildPartial() { - context.ContextOuterClass.ConnectionId result = new context.ContextOuterClass.ConnectionId(this); - if (connectionUuidBuilder_ == null) { - result.connectionUuid_ = connectionUuid_; + public context.ContextOuterClass.SliceId buildPartial() { + context.ContextOuterClass.SliceId result = new context.ContextOuterClass.SliceId(this); + if (contextIdBuilder_ == null) { + result.contextId_ = contextId_; } else { - result.connectionUuid_ = connectionUuidBuilder_.build(); + result.contextId_ = contextIdBuilder_.build(); + } + if (sliceUuidBuilder_ == null) { + result.sliceUuid_ = sliceUuid_; + } else { + result.sliceUuid_ = sliceUuidBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof context.ContextOuterClass.SliceId) { + return mergeFrom((context.ContextOuterClass.SliceId)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(context.ContextOuterClass.SliceId other) { + if (other == context.ContextOuterClass.SliceId.getDefaultInstance()) return this; + if (other.hasContextId()) { + mergeContextId(other.getContextId()); + } + if (other.hasSliceUuid()) { + mergeSliceUuid(other.getSliceUuid()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + context.ContextOuterClass.SliceId parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (context.ContextOuterClass.SliceId) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private context.ContextOuterClass.ContextId contextId_; + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.ContextId, context.ContextOuterClass.ContextId.Builder, context.ContextOuterClass.ContextIdOrBuilder> contextIdBuilder_; + /** + * <code>.context.ContextId context_id = 1;</code> + * @return Whether the contextId field is set. + */ + public boolean hasContextId() { + return contextIdBuilder_ != null || contextId_ != null; + } + /** + * <code>.context.ContextId context_id = 1;</code> + * @return The contextId. + */ + public context.ContextOuterClass.ContextId getContextId() { + if (contextIdBuilder_ == null) { + return contextId_ == null ? context.ContextOuterClass.ContextId.getDefaultInstance() : contextId_; + } else { + return contextIdBuilder_.getMessage(); + } + } + /** + * <code>.context.ContextId context_id = 1;</code> + */ + public Builder setContextId(context.ContextOuterClass.ContextId value) { + if (contextIdBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + contextId_ = value; + onChanged(); + } else { + contextIdBuilder_.setMessage(value); + } + + return this; + } + /** + * <code>.context.ContextId context_id = 1;</code> + */ + public Builder setContextId( + context.ContextOuterClass.ContextId.Builder builderForValue) { + if (contextIdBuilder_ == null) { + contextId_ = builderForValue.build(); + onChanged(); + } else { + contextIdBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * <code>.context.ContextId context_id = 1;</code> + */ + public Builder mergeContextId(context.ContextOuterClass.ContextId value) { + if (contextIdBuilder_ == null) { + if (contextId_ != null) { + contextId_ = + context.ContextOuterClass.ContextId.newBuilder(contextId_).mergeFrom(value).buildPartial(); + } else { + contextId_ = value; + } + onChanged(); + } else { + contextIdBuilder_.mergeFrom(value); + } + + return this; + } + /** + * <code>.context.ContextId context_id = 1;</code> + */ + public Builder clearContextId() { + if (contextIdBuilder_ == null) { + contextId_ = null; + onChanged(); + } else { + contextId_ = null; + contextIdBuilder_ = null; + } + + return this; + } + /** + * <code>.context.ContextId context_id = 1;</code> + */ + public context.ContextOuterClass.ContextId.Builder getContextIdBuilder() { + + onChanged(); + return getContextIdFieldBuilder().getBuilder(); + } + /** + * <code>.context.ContextId context_id = 1;</code> + */ + public context.ContextOuterClass.ContextIdOrBuilder getContextIdOrBuilder() { + if (contextIdBuilder_ != null) { + return contextIdBuilder_.getMessageOrBuilder(); + } else { + return contextId_ == null ? + context.ContextOuterClass.ContextId.getDefaultInstance() : contextId_; + } + } + /** + * <code>.context.ContextId context_id = 1;</code> + */ + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.ContextId, context.ContextOuterClass.ContextId.Builder, context.ContextOuterClass.ContextIdOrBuilder> + getContextIdFieldBuilder() { + if (contextIdBuilder_ == null) { + contextIdBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.ContextId, context.ContextOuterClass.ContextId.Builder, context.ContextOuterClass.ContextIdOrBuilder>( + getContextId(), + getParentForChildren(), + isClean()); + contextId_ = null; + } + return contextIdBuilder_; + } + + private context.ContextOuterClass.Uuid sliceUuid_; + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.Uuid, context.ContextOuterClass.Uuid.Builder, context.ContextOuterClass.UuidOrBuilder> sliceUuidBuilder_; + /** + * <code>.context.Uuid slice_uuid = 2;</code> + * @return Whether the sliceUuid field is set. + */ + public boolean hasSliceUuid() { + return sliceUuidBuilder_ != null || sliceUuid_ != null; + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + * @return The sliceUuid. + */ + public context.ContextOuterClass.Uuid getSliceUuid() { + if (sliceUuidBuilder_ == null) { + return sliceUuid_ == null ? context.ContextOuterClass.Uuid.getDefaultInstance() : sliceUuid_; + } else { + return sliceUuidBuilder_.getMessage(); + } + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + public Builder setSliceUuid(context.ContextOuterClass.Uuid value) { + if (sliceUuidBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + sliceUuid_ = value; + onChanged(); + } else { + sliceUuidBuilder_.setMessage(value); + } + + return this; + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + public Builder setSliceUuid( + context.ContextOuterClass.Uuid.Builder builderForValue) { + if (sliceUuidBuilder_ == null) { + sliceUuid_ = builderForValue.build(); + onChanged(); + } else { + sliceUuidBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + public Builder mergeSliceUuid(context.ContextOuterClass.Uuid value) { + if (sliceUuidBuilder_ == null) { + if (sliceUuid_ != null) { + sliceUuid_ = + context.ContextOuterClass.Uuid.newBuilder(sliceUuid_).mergeFrom(value).buildPartial(); + } else { + sliceUuid_ = value; + } + onChanged(); + } else { + sliceUuidBuilder_.mergeFrom(value); + } + + return this; + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + public Builder clearSliceUuid() { + if (sliceUuidBuilder_ == null) { + sliceUuid_ = null; + onChanged(); + } else { + sliceUuid_ = null; + sliceUuidBuilder_ = null; + } + + return this; + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + public context.ContextOuterClass.Uuid.Builder getSliceUuidBuilder() { + + onChanged(); + return getSliceUuidFieldBuilder().getBuilder(); + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + public context.ContextOuterClass.UuidOrBuilder getSliceUuidOrBuilder() { + if (sliceUuidBuilder_ != null) { + return sliceUuidBuilder_.getMessageOrBuilder(); + } else { + return sliceUuid_ == null ? + context.ContextOuterClass.Uuid.getDefaultInstance() : sliceUuid_; + } + } + /** + * <code>.context.Uuid slice_uuid = 2;</code> + */ + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.Uuid, context.ContextOuterClass.Uuid.Builder, context.ContextOuterClass.UuidOrBuilder> + getSliceUuidFieldBuilder() { + if (sliceUuidBuilder_ == null) { + sliceUuidBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.Uuid, context.ContextOuterClass.Uuid.Builder, context.ContextOuterClass.UuidOrBuilder>( + getSliceUuid(), + getParentForChildren(), + isClean()); + sliceUuid_ = null; + } + return sliceUuidBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:context.SliceId) + } + + // @@protoc_insertion_point(class_scope:context.SliceId) + private static final context.ContextOuterClass.SliceId DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new context.ContextOuterClass.SliceId(); + } + + public static context.ContextOuterClass.SliceId getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser<SliceId> + PARSER = new com.google.protobuf.AbstractParser<SliceId>() { + @java.lang.Override + public SliceId parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SliceId(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser<SliceId> parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser<SliceId> getParserForType() { + return PARSER; + } + + @java.lang.Override + public context.ContextOuterClass.SliceId getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SliceOrBuilder extends + // @@protoc_insertion_point(interface_extends:context.Slice) + com.google.protobuf.MessageOrBuilder { + + /** + * <code>.context.SliceId slice_id = 1;</code> + * @return Whether the sliceId field is set. + */ + boolean hasSliceId(); + /** + * <code>.context.SliceId slice_id = 1;</code> + * @return The sliceId. + */ + context.ContextOuterClass.SliceId getSliceId(); + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + context.ContextOuterClass.SliceIdOrBuilder getSliceIdOrBuilder(); + + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + java.util.List<context.ContextOuterClass.EndPointId> + getSliceEndpointIdsList(); + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + context.ContextOuterClass.EndPointId getSliceEndpointIds(int index); + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + int getSliceEndpointIdsCount(); + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + java.util.List<? extends context.ContextOuterClass.EndPointIdOrBuilder> + getSliceEndpointIdsOrBuilderList(); + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + context.ContextOuterClass.EndPointIdOrBuilder getSliceEndpointIdsOrBuilder( + int index); + + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + java.util.List<context.ContextOuterClass.Constraint> + getSliceConstraintsList(); + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + context.ContextOuterClass.Constraint getSliceConstraints(int index); + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + int getSliceConstraintsCount(); + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + java.util.List<? extends context.ContextOuterClass.ConstraintOrBuilder> + getSliceConstraintsOrBuilderList(); + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + context.ContextOuterClass.ConstraintOrBuilder getSliceConstraintsOrBuilder( + int index); + + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + java.util.List<context.ContextOuterClass.ServiceId> + getSliceServiceIdsList(); + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + context.ContextOuterClass.ServiceId getSliceServiceIds(int index); + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + int getSliceServiceIdsCount(); + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + java.util.List<? extends context.ContextOuterClass.ServiceIdOrBuilder> + getSliceServiceIdsOrBuilderList(); + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + context.ContextOuterClass.ServiceIdOrBuilder getSliceServiceIdsOrBuilder( + int index); + + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + java.util.List<context.ContextOuterClass.SliceId> + getSliceSubsliceIdsList(); + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + context.ContextOuterClass.SliceId getSliceSubsliceIds(int index); + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + int getSliceSubsliceIdsCount(); + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + java.util.List<? extends context.ContextOuterClass.SliceIdOrBuilder> + getSliceSubsliceIdsOrBuilderList(); + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + context.ContextOuterClass.SliceIdOrBuilder getSliceSubsliceIdsOrBuilder( + int index); + + /** + * <code>.context.SliceStatus slice_status = 6;</code> + * @return Whether the sliceStatus field is set. + */ + boolean hasSliceStatus(); + /** + * <code>.context.SliceStatus slice_status = 6;</code> + * @return The sliceStatus. + */ + context.ContextOuterClass.SliceStatus getSliceStatus(); + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + context.ContextOuterClass.SliceStatusOrBuilder getSliceStatusOrBuilder(); + } + /** + * Protobuf type {@code context.Slice} + */ + public static final class Slice extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:context.Slice) + SliceOrBuilder { + private static final long serialVersionUID = 0L; + // Use Slice.newBuilder() to construct. + private Slice(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { + super(builder); + } + private Slice() { + sliceEndpointIds_ = java.util.Collections.emptyList(); + sliceConstraints_ = java.util.Collections.emptyList(); + sliceServiceIds_ = java.util.Collections.emptyList(); + sliceSubsliceIds_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new Slice(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Slice( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + context.ContextOuterClass.SliceId.Builder subBuilder = null; + if (sliceId_ != null) { + subBuilder = sliceId_.toBuilder(); + } + sliceId_ = input.readMessage(context.ContextOuterClass.SliceId.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(sliceId_); + sliceId_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + sliceEndpointIds_ = new java.util.ArrayList<context.ContextOuterClass.EndPointId>(); + mutable_bitField0_ |= 0x00000001; + } + sliceEndpointIds_.add( + input.readMessage(context.ContextOuterClass.EndPointId.parser(), extensionRegistry)); + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000002) != 0)) { + sliceConstraints_ = new java.util.ArrayList<context.ContextOuterClass.Constraint>(); + mutable_bitField0_ |= 0x00000002; + } + sliceConstraints_.add( + input.readMessage(context.ContextOuterClass.Constraint.parser(), extensionRegistry)); + break; + } + case 34: { + if (!((mutable_bitField0_ & 0x00000004) != 0)) { + sliceServiceIds_ = new java.util.ArrayList<context.ContextOuterClass.ServiceId>(); + mutable_bitField0_ |= 0x00000004; + } + sliceServiceIds_.add( + input.readMessage(context.ContextOuterClass.ServiceId.parser(), extensionRegistry)); + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000008) != 0)) { + sliceSubsliceIds_ = new java.util.ArrayList<context.ContextOuterClass.SliceId>(); + mutable_bitField0_ |= 0x00000008; + } + sliceSubsliceIds_.add( + input.readMessage(context.ContextOuterClass.SliceId.parser(), extensionRegistry)); + break; + } + case 50: { + context.ContextOuterClass.SliceStatus.Builder subBuilder = null; + if (sliceStatus_ != null) { + subBuilder = sliceStatus_.toBuilder(); + } + sliceStatus_ = input.readMessage(context.ContextOuterClass.SliceStatus.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(sliceStatus_); + sliceStatus_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + sliceEndpointIds_ = java.util.Collections.unmodifiableList(sliceEndpointIds_); + } + if (((mutable_bitField0_ & 0x00000002) != 0)) { + sliceConstraints_ = java.util.Collections.unmodifiableList(sliceConstraints_); + } + if (((mutable_bitField0_ & 0x00000004) != 0)) { + sliceServiceIds_ = java.util.Collections.unmodifiableList(sliceServiceIds_); + } + if (((mutable_bitField0_ & 0x00000008) != 0)) { + sliceSubsliceIds_ = java.util.Collections.unmodifiableList(sliceSubsliceIds_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_Slice_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_Slice_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.Slice.class, context.ContextOuterClass.Slice.Builder.class); + } + + public static final int SLICE_ID_FIELD_NUMBER = 1; + private context.ContextOuterClass.SliceId sliceId_; + /** + * <code>.context.SliceId slice_id = 1;</code> + * @return Whether the sliceId field is set. + */ + @java.lang.Override + public boolean hasSliceId() { + return sliceId_ != null; + } + /** + * <code>.context.SliceId slice_id = 1;</code> + * @return The sliceId. + */ + @java.lang.Override + public context.ContextOuterClass.SliceId getSliceId() { + return sliceId_ == null ? context.ContextOuterClass.SliceId.getDefaultInstance() : sliceId_; + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceIdOrBuilder getSliceIdOrBuilder() { + return getSliceId(); + } + + public static final int SLICE_ENDPOINT_IDS_FIELD_NUMBER = 2; + private java.util.List<context.ContextOuterClass.EndPointId> sliceEndpointIds_; + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + @java.lang.Override + public java.util.List<context.ContextOuterClass.EndPointId> getSliceEndpointIdsList() { + return sliceEndpointIds_; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + @java.lang.Override + public java.util.List<? extends context.ContextOuterClass.EndPointIdOrBuilder> + getSliceEndpointIdsOrBuilderList() { + return sliceEndpointIds_; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + @java.lang.Override + public int getSliceEndpointIdsCount() { + return sliceEndpointIds_.size(); + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + @java.lang.Override + public context.ContextOuterClass.EndPointId getSliceEndpointIds(int index) { + return sliceEndpointIds_.get(index); + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + @java.lang.Override + public context.ContextOuterClass.EndPointIdOrBuilder getSliceEndpointIdsOrBuilder( + int index) { + return sliceEndpointIds_.get(index); + } + + public static final int SLICE_CONSTRAINTS_FIELD_NUMBER = 3; + private java.util.List<context.ContextOuterClass.Constraint> sliceConstraints_; + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + @java.lang.Override + public java.util.List<context.ContextOuterClass.Constraint> getSliceConstraintsList() { + return sliceConstraints_; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + @java.lang.Override + public java.util.List<? extends context.ContextOuterClass.ConstraintOrBuilder> + getSliceConstraintsOrBuilderList() { + return sliceConstraints_; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + @java.lang.Override + public int getSliceConstraintsCount() { + return sliceConstraints_.size(); + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + @java.lang.Override + public context.ContextOuterClass.Constraint getSliceConstraints(int index) { + return sliceConstraints_.get(index); + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + @java.lang.Override + public context.ContextOuterClass.ConstraintOrBuilder getSliceConstraintsOrBuilder( + int index) { + return sliceConstraints_.get(index); + } + + public static final int SLICE_SERVICE_IDS_FIELD_NUMBER = 4; + private java.util.List<context.ContextOuterClass.ServiceId> sliceServiceIds_; + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + @java.lang.Override + public java.util.List<context.ContextOuterClass.ServiceId> getSliceServiceIdsList() { + return sliceServiceIds_; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + @java.lang.Override + public java.util.List<? extends context.ContextOuterClass.ServiceIdOrBuilder> + getSliceServiceIdsOrBuilderList() { + return sliceServiceIds_; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + @java.lang.Override + public int getSliceServiceIdsCount() { + return sliceServiceIds_.size(); + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + @java.lang.Override + public context.ContextOuterClass.ServiceId getSliceServiceIds(int index) { + return sliceServiceIds_.get(index); + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + @java.lang.Override + public context.ContextOuterClass.ServiceIdOrBuilder getSliceServiceIdsOrBuilder( + int index) { + return sliceServiceIds_.get(index); + } + + public static final int SLICE_SUBSLICE_IDS_FIELD_NUMBER = 5; + private java.util.List<context.ContextOuterClass.SliceId> sliceSubsliceIds_; + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + @java.lang.Override + public java.util.List<context.ContextOuterClass.SliceId> getSliceSubsliceIdsList() { + return sliceSubsliceIds_; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + @java.lang.Override + public java.util.List<? extends context.ContextOuterClass.SliceIdOrBuilder> + getSliceSubsliceIdsOrBuilderList() { + return sliceSubsliceIds_; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + @java.lang.Override + public int getSliceSubsliceIdsCount() { + return sliceSubsliceIds_.size(); + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceId getSliceSubsliceIds(int index) { + return sliceSubsliceIds_.get(index); + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceIdOrBuilder getSliceSubsliceIdsOrBuilder( + int index) { + return sliceSubsliceIds_.get(index); + } + + public static final int SLICE_STATUS_FIELD_NUMBER = 6; + private context.ContextOuterClass.SliceStatus sliceStatus_; + /** + * <code>.context.SliceStatus slice_status = 6;</code> + * @return Whether the sliceStatus field is set. + */ + @java.lang.Override + public boolean hasSliceStatus() { + return sliceStatus_ != null; + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + * @return The sliceStatus. + */ + @java.lang.Override + public context.ContextOuterClass.SliceStatus getSliceStatus() { + return sliceStatus_ == null ? context.ContextOuterClass.SliceStatus.getDefaultInstance() : sliceStatus_; + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceStatusOrBuilder getSliceStatusOrBuilder() { + return getSliceStatus(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (sliceId_ != null) { + output.writeMessage(1, getSliceId()); + } + for (int i = 0; i < sliceEndpointIds_.size(); i++) { + output.writeMessage(2, sliceEndpointIds_.get(i)); + } + for (int i = 0; i < sliceConstraints_.size(); i++) { + output.writeMessage(3, sliceConstraints_.get(i)); + } + for (int i = 0; i < sliceServiceIds_.size(); i++) { + output.writeMessage(4, sliceServiceIds_.get(i)); + } + for (int i = 0; i < sliceSubsliceIds_.size(); i++) { + output.writeMessage(5, sliceSubsliceIds_.get(i)); + } + if (sliceStatus_ != null) { + output.writeMessage(6, getSliceStatus()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (sliceId_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getSliceId()); + } + for (int i = 0; i < sliceEndpointIds_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, sliceEndpointIds_.get(i)); + } + for (int i = 0; i < sliceConstraints_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, sliceConstraints_.get(i)); + } + for (int i = 0; i < sliceServiceIds_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, sliceServiceIds_.get(i)); + } + for (int i = 0; i < sliceSubsliceIds_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, sliceSubsliceIds_.get(i)); + } + if (sliceStatus_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, getSliceStatus()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof context.ContextOuterClass.Slice)) { + return super.equals(obj); + } + context.ContextOuterClass.Slice other = (context.ContextOuterClass.Slice) obj; + + if (hasSliceId() != other.hasSliceId()) return false; + if (hasSliceId()) { + if (!getSliceId() + .equals(other.getSliceId())) return false; + } + if (!getSliceEndpointIdsList() + .equals(other.getSliceEndpointIdsList())) return false; + if (!getSliceConstraintsList() + .equals(other.getSliceConstraintsList())) return false; + if (!getSliceServiceIdsList() + .equals(other.getSliceServiceIdsList())) return false; + if (!getSliceSubsliceIdsList() + .equals(other.getSliceSubsliceIdsList())) return false; + if (hasSliceStatus() != other.hasSliceStatus()) return false; + if (hasSliceStatus()) { + if (!getSliceStatus() + .equals(other.getSliceStatus())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasSliceId()) { + hash = (37 * hash) + SLICE_ID_FIELD_NUMBER; + hash = (53 * hash) + getSliceId().hashCode(); + } + if (getSliceEndpointIdsCount() > 0) { + hash = (37 * hash) + SLICE_ENDPOINT_IDS_FIELD_NUMBER; + hash = (53 * hash) + getSliceEndpointIdsList().hashCode(); + } + if (getSliceConstraintsCount() > 0) { + hash = (37 * hash) + SLICE_CONSTRAINTS_FIELD_NUMBER; + hash = (53 * hash) + getSliceConstraintsList().hashCode(); + } + if (getSliceServiceIdsCount() > 0) { + hash = (37 * hash) + SLICE_SERVICE_IDS_FIELD_NUMBER; + hash = (53 * hash) + getSliceServiceIdsList().hashCode(); + } + if (getSliceSubsliceIdsCount() > 0) { + hash = (37 * hash) + SLICE_SUBSLICE_IDS_FIELD_NUMBER; + hash = (53 * hash) + getSliceSubsliceIdsList().hashCode(); + } + if (hasSliceStatus()) { + hash = (37 * hash) + SLICE_STATUS_FIELD_NUMBER; + hash = (53 * hash) + getSliceStatus().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static context.ContextOuterClass.Slice parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.Slice parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.Slice parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.Slice parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.Slice parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.Slice parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.Slice parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.Slice parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.Slice parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static context.ContextOuterClass.Slice parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.Slice parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.Slice parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(context.ContextOuterClass.Slice prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code context.Slice} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements + // @@protoc_insertion_point(builder_implements:context.Slice) + context.ContextOuterClass.SliceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_Slice_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_Slice_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.Slice.class, context.ContextOuterClass.Slice.Builder.class); + } + + // Construct using context.ContextOuterClass.Slice.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getSliceEndpointIdsFieldBuilder(); + getSliceConstraintsFieldBuilder(); + getSliceServiceIdsFieldBuilder(); + getSliceSubsliceIdsFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (sliceIdBuilder_ == null) { + sliceId_ = null; + } else { + sliceId_ = null; + sliceIdBuilder_ = null; + } + if (sliceEndpointIdsBuilder_ == null) { + sliceEndpointIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + sliceEndpointIdsBuilder_.clear(); + } + if (sliceConstraintsBuilder_ == null) { + sliceConstraints_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + sliceConstraintsBuilder_.clear(); + } + if (sliceServiceIdsBuilder_ == null) { + sliceServiceIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + sliceServiceIdsBuilder_.clear(); + } + if (sliceSubsliceIdsBuilder_ == null) { + sliceSubsliceIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + } else { + sliceSubsliceIdsBuilder_.clear(); + } + if (sliceStatusBuilder_ == null) { + sliceStatus_ = null; + } else { + sliceStatus_ = null; + sliceStatusBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return context.ContextOuterClass.internal_static_context_Slice_descriptor; + } + + @java.lang.Override + public context.ContextOuterClass.Slice getDefaultInstanceForType() { + return context.ContextOuterClass.Slice.getDefaultInstance(); + } + + @java.lang.Override + public context.ContextOuterClass.Slice build() { + context.ContextOuterClass.Slice result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public context.ContextOuterClass.Slice buildPartial() { + context.ContextOuterClass.Slice result = new context.ContextOuterClass.Slice(this); + int from_bitField0_ = bitField0_; + if (sliceIdBuilder_ == null) { + result.sliceId_ = sliceId_; + } else { + result.sliceId_ = sliceIdBuilder_.build(); + } + if (sliceEndpointIdsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + sliceEndpointIds_ = java.util.Collections.unmodifiableList(sliceEndpointIds_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.sliceEndpointIds_ = sliceEndpointIds_; + } else { + result.sliceEndpointIds_ = sliceEndpointIdsBuilder_.build(); + } + if (sliceConstraintsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + sliceConstraints_ = java.util.Collections.unmodifiableList(sliceConstraints_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.sliceConstraints_ = sliceConstraints_; + } else { + result.sliceConstraints_ = sliceConstraintsBuilder_.build(); + } + if (sliceServiceIdsBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0)) { + sliceServiceIds_ = java.util.Collections.unmodifiableList(sliceServiceIds_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.sliceServiceIds_ = sliceServiceIds_; + } else { + result.sliceServiceIds_ = sliceServiceIdsBuilder_.build(); + } + if (sliceSubsliceIdsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0)) { + sliceSubsliceIds_ = java.util.Collections.unmodifiableList(sliceSubsliceIds_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.sliceSubsliceIds_ = sliceSubsliceIds_; + } else { + result.sliceSubsliceIds_ = sliceSubsliceIdsBuilder_.build(); + } + if (sliceStatusBuilder_ == null) { + result.sliceStatus_ = sliceStatus_; + } else { + result.sliceStatus_ = sliceStatusBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof context.ContextOuterClass.Slice) { + return mergeFrom((context.ContextOuterClass.Slice)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(context.ContextOuterClass.Slice other) { + if (other == context.ContextOuterClass.Slice.getDefaultInstance()) return this; + if (other.hasSliceId()) { + mergeSliceId(other.getSliceId()); + } + if (sliceEndpointIdsBuilder_ == null) { + if (!other.sliceEndpointIds_.isEmpty()) { + if (sliceEndpointIds_.isEmpty()) { + sliceEndpointIds_ = other.sliceEndpointIds_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.addAll(other.sliceEndpointIds_); + } + onChanged(); + } + } else { + if (!other.sliceEndpointIds_.isEmpty()) { + if (sliceEndpointIdsBuilder_.isEmpty()) { + sliceEndpointIdsBuilder_.dispose(); + sliceEndpointIdsBuilder_ = null; + sliceEndpointIds_ = other.sliceEndpointIds_; + bitField0_ = (bitField0_ & ~0x00000001); + sliceEndpointIdsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSliceEndpointIdsFieldBuilder() : null; + } else { + sliceEndpointIdsBuilder_.addAllMessages(other.sliceEndpointIds_); + } + } + } + if (sliceConstraintsBuilder_ == null) { + if (!other.sliceConstraints_.isEmpty()) { + if (sliceConstraints_.isEmpty()) { + sliceConstraints_ = other.sliceConstraints_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureSliceConstraintsIsMutable(); + sliceConstraints_.addAll(other.sliceConstraints_); + } + onChanged(); + } + } else { + if (!other.sliceConstraints_.isEmpty()) { + if (sliceConstraintsBuilder_.isEmpty()) { + sliceConstraintsBuilder_.dispose(); + sliceConstraintsBuilder_ = null; + sliceConstraints_ = other.sliceConstraints_; + bitField0_ = (bitField0_ & ~0x00000002); + sliceConstraintsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSliceConstraintsFieldBuilder() : null; + } else { + sliceConstraintsBuilder_.addAllMessages(other.sliceConstraints_); + } + } + } + if (sliceServiceIdsBuilder_ == null) { + if (!other.sliceServiceIds_.isEmpty()) { + if (sliceServiceIds_.isEmpty()) { + sliceServiceIds_ = other.sliceServiceIds_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.addAll(other.sliceServiceIds_); + } + onChanged(); + } + } else { + if (!other.sliceServiceIds_.isEmpty()) { + if (sliceServiceIdsBuilder_.isEmpty()) { + sliceServiceIdsBuilder_.dispose(); + sliceServiceIdsBuilder_ = null; + sliceServiceIds_ = other.sliceServiceIds_; + bitField0_ = (bitField0_ & ~0x00000004); + sliceServiceIdsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSliceServiceIdsFieldBuilder() : null; + } else { + sliceServiceIdsBuilder_.addAllMessages(other.sliceServiceIds_); + } + } + } + if (sliceSubsliceIdsBuilder_ == null) { + if (!other.sliceSubsliceIds_.isEmpty()) { + if (sliceSubsliceIds_.isEmpty()) { + sliceSubsliceIds_ = other.sliceSubsliceIds_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.addAll(other.sliceSubsliceIds_); + } + onChanged(); + } + } else { + if (!other.sliceSubsliceIds_.isEmpty()) { + if (sliceSubsliceIdsBuilder_.isEmpty()) { + sliceSubsliceIdsBuilder_.dispose(); + sliceSubsliceIdsBuilder_ = null; + sliceSubsliceIds_ = other.sliceSubsliceIds_; + bitField0_ = (bitField0_ & ~0x00000008); + sliceSubsliceIdsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSliceSubsliceIdsFieldBuilder() : null; + } else { + sliceSubsliceIdsBuilder_.addAllMessages(other.sliceSubsliceIds_); + } + } + } + if (other.hasSliceStatus()) { + mergeSliceStatus(other.getSliceStatus()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + context.ContextOuterClass.Slice parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (context.ContextOuterClass.Slice) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private context.ContextOuterClass.SliceId sliceId_; + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> sliceIdBuilder_; + /** + * <code>.context.SliceId slice_id = 1;</code> + * @return Whether the sliceId field is set. + */ + public boolean hasSliceId() { + return sliceIdBuilder_ != null || sliceId_ != null; + } + /** + * <code>.context.SliceId slice_id = 1;</code> + * @return The sliceId. + */ + public context.ContextOuterClass.SliceId getSliceId() { + if (sliceIdBuilder_ == null) { + return sliceId_ == null ? context.ContextOuterClass.SliceId.getDefaultInstance() : sliceId_; + } else { + return sliceIdBuilder_.getMessage(); + } + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + public Builder setSliceId(context.ContextOuterClass.SliceId value) { + if (sliceIdBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + sliceId_ = value; + onChanged(); + } else { + sliceIdBuilder_.setMessage(value); + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + public Builder setSliceId( + context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceIdBuilder_ == null) { + sliceId_ = builderForValue.build(); + onChanged(); + } else { + sliceIdBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + public Builder mergeSliceId(context.ContextOuterClass.SliceId value) { + if (sliceIdBuilder_ == null) { + if (sliceId_ != null) { + sliceId_ = + context.ContextOuterClass.SliceId.newBuilder(sliceId_).mergeFrom(value).buildPartial(); + } else { + sliceId_ = value; + } + onChanged(); + } else { + sliceIdBuilder_.mergeFrom(value); + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + public Builder clearSliceId() { + if (sliceIdBuilder_ == null) { + sliceId_ = null; + onChanged(); + } else { + sliceId_ = null; + sliceIdBuilder_ = null; + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + public context.ContextOuterClass.SliceId.Builder getSliceIdBuilder() { + + onChanged(); + return getSliceIdFieldBuilder().getBuilder(); + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + public context.ContextOuterClass.SliceIdOrBuilder getSliceIdOrBuilder() { + if (sliceIdBuilder_ != null) { + return sliceIdBuilder_.getMessageOrBuilder(); + } else { + return sliceId_ == null ? + context.ContextOuterClass.SliceId.getDefaultInstance() : sliceId_; + } + } + /** + * <code>.context.SliceId slice_id = 1;</code> + */ + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> + getSliceIdFieldBuilder() { + if (sliceIdBuilder_ == null) { + sliceIdBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder>( + getSliceId(), + getParentForChildren(), + isClean()); + sliceId_ = null; + } + return sliceIdBuilder_; + } + + private java.util.List<context.ContextOuterClass.EndPointId> sliceEndpointIds_ = + java.util.Collections.emptyList(); + private void ensureSliceEndpointIdsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + sliceEndpointIds_ = new java.util.ArrayList<context.ContextOuterClass.EndPointId>(sliceEndpointIds_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.EndPointId, context.ContextOuterClass.EndPointId.Builder, context.ContextOuterClass.EndPointIdOrBuilder> sliceEndpointIdsBuilder_; + + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public java.util.List<context.ContextOuterClass.EndPointId> getSliceEndpointIdsList() { + if (sliceEndpointIdsBuilder_ == null) { + return java.util.Collections.unmodifiableList(sliceEndpointIds_); + } else { + return sliceEndpointIdsBuilder_.getMessageList(); + } + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public int getSliceEndpointIdsCount() { + if (sliceEndpointIdsBuilder_ == null) { + return sliceEndpointIds_.size(); + } else { + return sliceEndpointIdsBuilder_.getCount(); + } + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public context.ContextOuterClass.EndPointId getSliceEndpointIds(int index) { + if (sliceEndpointIdsBuilder_ == null) { + return sliceEndpointIds_.get(index); + } else { + return sliceEndpointIdsBuilder_.getMessage(index); + } + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder setSliceEndpointIds( + int index, context.ContextOuterClass.EndPointId value) { + if (sliceEndpointIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.set(index, value); + onChanged(); + } else { + sliceEndpointIdsBuilder_.setMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder setSliceEndpointIds( + int index, context.ContextOuterClass.EndPointId.Builder builderForValue) { + if (sliceEndpointIdsBuilder_ == null) { + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.set(index, builderForValue.build()); + onChanged(); + } else { + sliceEndpointIdsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder addSliceEndpointIds(context.ContextOuterClass.EndPointId value) { + if (sliceEndpointIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.add(value); + onChanged(); + } else { + sliceEndpointIdsBuilder_.addMessage(value); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder addSliceEndpointIds( + int index, context.ContextOuterClass.EndPointId value) { + if (sliceEndpointIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.add(index, value); + onChanged(); + } else { + sliceEndpointIdsBuilder_.addMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder addSliceEndpointIds( + context.ContextOuterClass.EndPointId.Builder builderForValue) { + if (sliceEndpointIdsBuilder_ == null) { + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.add(builderForValue.build()); + onChanged(); + } else { + sliceEndpointIdsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder addSliceEndpointIds( + int index, context.ContextOuterClass.EndPointId.Builder builderForValue) { + if (sliceEndpointIdsBuilder_ == null) { + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.add(index, builderForValue.build()); + onChanged(); + } else { + sliceEndpointIdsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder addAllSliceEndpointIds( + java.lang.Iterable<? extends context.ContextOuterClass.EndPointId> values) { + if (sliceEndpointIdsBuilder_ == null) { + ensureSliceEndpointIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, sliceEndpointIds_); + onChanged(); + } else { + sliceEndpointIdsBuilder_.addAllMessages(values); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder clearSliceEndpointIds() { + if (sliceEndpointIdsBuilder_ == null) { + sliceEndpointIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + sliceEndpointIdsBuilder_.clear(); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public Builder removeSliceEndpointIds(int index) { + if (sliceEndpointIdsBuilder_ == null) { + ensureSliceEndpointIdsIsMutable(); + sliceEndpointIds_.remove(index); + onChanged(); + } else { + sliceEndpointIdsBuilder_.remove(index); + } + return this; + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public context.ContextOuterClass.EndPointId.Builder getSliceEndpointIdsBuilder( + int index) { + return getSliceEndpointIdsFieldBuilder().getBuilder(index); + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public context.ContextOuterClass.EndPointIdOrBuilder getSliceEndpointIdsOrBuilder( + int index) { + if (sliceEndpointIdsBuilder_ == null) { + return sliceEndpointIds_.get(index); } else { + return sliceEndpointIdsBuilder_.getMessageOrBuilder(index); + } + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public java.util.List<? extends context.ContextOuterClass.EndPointIdOrBuilder> + getSliceEndpointIdsOrBuilderList() { + if (sliceEndpointIdsBuilder_ != null) { + return sliceEndpointIdsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(sliceEndpointIds_); + } + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public context.ContextOuterClass.EndPointId.Builder addSliceEndpointIdsBuilder() { + return getSliceEndpointIdsFieldBuilder().addBuilder( + context.ContextOuterClass.EndPointId.getDefaultInstance()); + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public context.ContextOuterClass.EndPointId.Builder addSliceEndpointIdsBuilder( + int index) { + return getSliceEndpointIdsFieldBuilder().addBuilder( + index, context.ContextOuterClass.EndPointId.getDefaultInstance()); + } + /** + * <code>repeated .context.EndPointId slice_endpoint_ids = 2;</code> + */ + public java.util.List<context.ContextOuterClass.EndPointId.Builder> + getSliceEndpointIdsBuilderList() { + return getSliceEndpointIdsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.EndPointId, context.ContextOuterClass.EndPointId.Builder, context.ContextOuterClass.EndPointIdOrBuilder> + getSliceEndpointIdsFieldBuilder() { + if (sliceEndpointIdsBuilder_ == null) { + sliceEndpointIdsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.EndPointId, context.ContextOuterClass.EndPointId.Builder, context.ContextOuterClass.EndPointIdOrBuilder>( + sliceEndpointIds_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + sliceEndpointIds_ = null; + } + return sliceEndpointIdsBuilder_; + } + + private java.util.List<context.ContextOuterClass.Constraint> sliceConstraints_ = + java.util.Collections.emptyList(); + private void ensureSliceConstraintsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + sliceConstraints_ = new java.util.ArrayList<context.ContextOuterClass.Constraint>(sliceConstraints_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.Constraint, context.ContextOuterClass.Constraint.Builder, context.ContextOuterClass.ConstraintOrBuilder> sliceConstraintsBuilder_; + + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public java.util.List<context.ContextOuterClass.Constraint> getSliceConstraintsList() { + if (sliceConstraintsBuilder_ == null) { + return java.util.Collections.unmodifiableList(sliceConstraints_); + } else { + return sliceConstraintsBuilder_.getMessageList(); + } + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public int getSliceConstraintsCount() { + if (sliceConstraintsBuilder_ == null) { + return sliceConstraints_.size(); + } else { + return sliceConstraintsBuilder_.getCount(); + } + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public context.ContextOuterClass.Constraint getSliceConstraints(int index) { + if (sliceConstraintsBuilder_ == null) { + return sliceConstraints_.get(index); + } else { + return sliceConstraintsBuilder_.getMessage(index); + } + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder setSliceConstraints( + int index, context.ContextOuterClass.Constraint value) { + if (sliceConstraintsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceConstraintsIsMutable(); + sliceConstraints_.set(index, value); + onChanged(); + } else { + sliceConstraintsBuilder_.setMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder setSliceConstraints( + int index, context.ContextOuterClass.Constraint.Builder builderForValue) { + if (sliceConstraintsBuilder_ == null) { + ensureSliceConstraintsIsMutable(); + sliceConstraints_.set(index, builderForValue.build()); + onChanged(); + } else { + sliceConstraintsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder addSliceConstraints(context.ContextOuterClass.Constraint value) { + if (sliceConstraintsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceConstraintsIsMutable(); + sliceConstraints_.add(value); + onChanged(); + } else { + sliceConstraintsBuilder_.addMessage(value); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder addSliceConstraints( + int index, context.ContextOuterClass.Constraint value) { + if (sliceConstraintsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceConstraintsIsMutable(); + sliceConstraints_.add(index, value); + onChanged(); + } else { + sliceConstraintsBuilder_.addMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder addSliceConstraints( + context.ContextOuterClass.Constraint.Builder builderForValue) { + if (sliceConstraintsBuilder_ == null) { + ensureSliceConstraintsIsMutable(); + sliceConstraints_.add(builderForValue.build()); + onChanged(); + } else { + sliceConstraintsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder addSliceConstraints( + int index, context.ContextOuterClass.Constraint.Builder builderForValue) { + if (sliceConstraintsBuilder_ == null) { + ensureSliceConstraintsIsMutable(); + sliceConstraints_.add(index, builderForValue.build()); + onChanged(); + } else { + sliceConstraintsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder addAllSliceConstraints( + java.lang.Iterable<? extends context.ContextOuterClass.Constraint> values) { + if (sliceConstraintsBuilder_ == null) { + ensureSliceConstraintsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, sliceConstraints_); + onChanged(); + } else { + sliceConstraintsBuilder_.addAllMessages(values); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder clearSliceConstraints() { + if (sliceConstraintsBuilder_ == null) { + sliceConstraints_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + sliceConstraintsBuilder_.clear(); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public Builder removeSliceConstraints(int index) { + if (sliceConstraintsBuilder_ == null) { + ensureSliceConstraintsIsMutable(); + sliceConstraints_.remove(index); + onChanged(); + } else { + sliceConstraintsBuilder_.remove(index); + } + return this; + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public context.ContextOuterClass.Constraint.Builder getSliceConstraintsBuilder( + int index) { + return getSliceConstraintsFieldBuilder().getBuilder(index); + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public context.ContextOuterClass.ConstraintOrBuilder getSliceConstraintsOrBuilder( + int index) { + if (sliceConstraintsBuilder_ == null) { + return sliceConstraints_.get(index); } else { + return sliceConstraintsBuilder_.getMessageOrBuilder(index); + } + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public java.util.List<? extends context.ContextOuterClass.ConstraintOrBuilder> + getSliceConstraintsOrBuilderList() { + if (sliceConstraintsBuilder_ != null) { + return sliceConstraintsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(sliceConstraints_); + } + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public context.ContextOuterClass.Constraint.Builder addSliceConstraintsBuilder() { + return getSliceConstraintsFieldBuilder().addBuilder( + context.ContextOuterClass.Constraint.getDefaultInstance()); + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public context.ContextOuterClass.Constraint.Builder addSliceConstraintsBuilder( + int index) { + return getSliceConstraintsFieldBuilder().addBuilder( + index, context.ContextOuterClass.Constraint.getDefaultInstance()); + } + /** + * <code>repeated .context.Constraint slice_constraints = 3;</code> + */ + public java.util.List<context.ContextOuterClass.Constraint.Builder> + getSliceConstraintsBuilderList() { + return getSliceConstraintsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.Constraint, context.ContextOuterClass.Constraint.Builder, context.ContextOuterClass.ConstraintOrBuilder> + getSliceConstraintsFieldBuilder() { + if (sliceConstraintsBuilder_ == null) { + sliceConstraintsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.Constraint, context.ContextOuterClass.Constraint.Builder, context.ContextOuterClass.ConstraintOrBuilder>( + sliceConstraints_, + ((bitField0_ & 0x00000002) != 0), + getParentForChildren(), + isClean()); + sliceConstraints_ = null; + } + return sliceConstraintsBuilder_; + } + + private java.util.List<context.ContextOuterClass.ServiceId> sliceServiceIds_ = + java.util.Collections.emptyList(); + private void ensureSliceServiceIdsIsMutable() { + if (!((bitField0_ & 0x00000004) != 0)) { + sliceServiceIds_ = new java.util.ArrayList<context.ContextOuterClass.ServiceId>(sliceServiceIds_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.ServiceId, context.ContextOuterClass.ServiceId.Builder, context.ContextOuterClass.ServiceIdOrBuilder> sliceServiceIdsBuilder_; + + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public java.util.List<context.ContextOuterClass.ServiceId> getSliceServiceIdsList() { + if (sliceServiceIdsBuilder_ == null) { + return java.util.Collections.unmodifiableList(sliceServiceIds_); + } else { + return sliceServiceIdsBuilder_.getMessageList(); + } + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public int getSliceServiceIdsCount() { + if (sliceServiceIdsBuilder_ == null) { + return sliceServiceIds_.size(); + } else { + return sliceServiceIdsBuilder_.getCount(); + } + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public context.ContextOuterClass.ServiceId getSliceServiceIds(int index) { + if (sliceServiceIdsBuilder_ == null) { + return sliceServiceIds_.get(index); + } else { + return sliceServiceIdsBuilder_.getMessage(index); + } + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder setSliceServiceIds( + int index, context.ContextOuterClass.ServiceId value) { + if (sliceServiceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.set(index, value); + onChanged(); + } else { + sliceServiceIdsBuilder_.setMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder setSliceServiceIds( + int index, context.ContextOuterClass.ServiceId.Builder builderForValue) { + if (sliceServiceIdsBuilder_ == null) { + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.set(index, builderForValue.build()); + onChanged(); + } else { + sliceServiceIdsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder addSliceServiceIds(context.ContextOuterClass.ServiceId value) { + if (sliceServiceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.add(value); + onChanged(); + } else { + sliceServiceIdsBuilder_.addMessage(value); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder addSliceServiceIds( + int index, context.ContextOuterClass.ServiceId value) { + if (sliceServiceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.add(index, value); + onChanged(); + } else { + sliceServiceIdsBuilder_.addMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder addSliceServiceIds( + context.ContextOuterClass.ServiceId.Builder builderForValue) { + if (sliceServiceIdsBuilder_ == null) { + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.add(builderForValue.build()); + onChanged(); + } else { + sliceServiceIdsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder addSliceServiceIds( + int index, context.ContextOuterClass.ServiceId.Builder builderForValue) { + if (sliceServiceIdsBuilder_ == null) { + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.add(index, builderForValue.build()); + onChanged(); + } else { + sliceServiceIdsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder addAllSliceServiceIds( + java.lang.Iterable<? extends context.ContextOuterClass.ServiceId> values) { + if (sliceServiceIdsBuilder_ == null) { + ensureSliceServiceIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, sliceServiceIds_); + onChanged(); + } else { + sliceServiceIdsBuilder_.addAllMessages(values); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder clearSliceServiceIds() { + if (sliceServiceIdsBuilder_ == null) { + sliceServiceIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + sliceServiceIdsBuilder_.clear(); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public Builder removeSliceServiceIds(int index) { + if (sliceServiceIdsBuilder_ == null) { + ensureSliceServiceIdsIsMutable(); + sliceServiceIds_.remove(index); + onChanged(); + } else { + sliceServiceIdsBuilder_.remove(index); + } + return this; + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public context.ContextOuterClass.ServiceId.Builder getSliceServiceIdsBuilder( + int index) { + return getSliceServiceIdsFieldBuilder().getBuilder(index); + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public context.ContextOuterClass.ServiceIdOrBuilder getSliceServiceIdsOrBuilder( + int index) { + if (sliceServiceIdsBuilder_ == null) { + return sliceServiceIds_.get(index); } else { + return sliceServiceIdsBuilder_.getMessageOrBuilder(index); + } + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public java.util.List<? extends context.ContextOuterClass.ServiceIdOrBuilder> + getSliceServiceIdsOrBuilderList() { + if (sliceServiceIdsBuilder_ != null) { + return sliceServiceIdsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(sliceServiceIds_); + } + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public context.ContextOuterClass.ServiceId.Builder addSliceServiceIdsBuilder() { + return getSliceServiceIdsFieldBuilder().addBuilder( + context.ContextOuterClass.ServiceId.getDefaultInstance()); + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public context.ContextOuterClass.ServiceId.Builder addSliceServiceIdsBuilder( + int index) { + return getSliceServiceIdsFieldBuilder().addBuilder( + index, context.ContextOuterClass.ServiceId.getDefaultInstance()); + } + /** + * <code>repeated .context.ServiceId slice_service_ids = 4;</code> + */ + public java.util.List<context.ContextOuterClass.ServiceId.Builder> + getSliceServiceIdsBuilderList() { + return getSliceServiceIdsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.ServiceId, context.ContextOuterClass.ServiceId.Builder, context.ContextOuterClass.ServiceIdOrBuilder> + getSliceServiceIdsFieldBuilder() { + if (sliceServiceIdsBuilder_ == null) { + sliceServiceIdsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.ServiceId, context.ContextOuterClass.ServiceId.Builder, context.ContextOuterClass.ServiceIdOrBuilder>( + sliceServiceIds_, + ((bitField0_ & 0x00000004) != 0), + getParentForChildren(), + isClean()); + sliceServiceIds_ = null; + } + return sliceServiceIdsBuilder_; + } + + private java.util.List<context.ContextOuterClass.SliceId> sliceSubsliceIds_ = + java.util.Collections.emptyList(); + private void ensureSliceSubsliceIdsIsMutable() { + if (!((bitField0_ & 0x00000008) != 0)) { + sliceSubsliceIds_ = new java.util.ArrayList<context.ContextOuterClass.SliceId>(sliceSubsliceIds_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> sliceSubsliceIdsBuilder_; + + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public java.util.List<context.ContextOuterClass.SliceId> getSliceSubsliceIdsList() { + if (sliceSubsliceIdsBuilder_ == null) { + return java.util.Collections.unmodifiableList(sliceSubsliceIds_); + } else { + return sliceSubsliceIdsBuilder_.getMessageList(); + } + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public int getSliceSubsliceIdsCount() { + if (sliceSubsliceIdsBuilder_ == null) { + return sliceSubsliceIds_.size(); + } else { + return sliceSubsliceIdsBuilder_.getCount(); + } + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public context.ContextOuterClass.SliceId getSliceSubsliceIds(int index) { + if (sliceSubsliceIdsBuilder_ == null) { + return sliceSubsliceIds_.get(index); + } else { + return sliceSubsliceIdsBuilder_.getMessage(index); + } + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder setSliceSubsliceIds( + int index, context.ContextOuterClass.SliceId value) { + if (sliceSubsliceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.set(index, value); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.setMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder setSliceSubsliceIds( + int index, context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceSubsliceIdsBuilder_ == null) { + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.set(index, builderForValue.build()); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder addSliceSubsliceIds(context.ContextOuterClass.SliceId value) { + if (sliceSubsliceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.add(value); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.addMessage(value); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder addSliceSubsliceIds( + int index, context.ContextOuterClass.SliceId value) { + if (sliceSubsliceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.add(index, value); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.addMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder addSliceSubsliceIds( + context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceSubsliceIdsBuilder_ == null) { + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.add(builderForValue.build()); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder addSliceSubsliceIds( + int index, context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceSubsliceIdsBuilder_ == null) { + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.add(index, builderForValue.build()); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder addAllSliceSubsliceIds( + java.lang.Iterable<? extends context.ContextOuterClass.SliceId> values) { + if (sliceSubsliceIdsBuilder_ == null) { + ensureSliceSubsliceIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, sliceSubsliceIds_); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.addAllMessages(values); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder clearSliceSubsliceIds() { + if (sliceSubsliceIdsBuilder_ == null) { + sliceSubsliceIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.clear(); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public Builder removeSliceSubsliceIds(int index) { + if (sliceSubsliceIdsBuilder_ == null) { + ensureSliceSubsliceIdsIsMutable(); + sliceSubsliceIds_.remove(index); + onChanged(); + } else { + sliceSubsliceIdsBuilder_.remove(index); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public context.ContextOuterClass.SliceId.Builder getSliceSubsliceIdsBuilder( + int index) { + return getSliceSubsliceIdsFieldBuilder().getBuilder(index); + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public context.ContextOuterClass.SliceIdOrBuilder getSliceSubsliceIdsOrBuilder( + int index) { + if (sliceSubsliceIdsBuilder_ == null) { + return sliceSubsliceIds_.get(index); } else { + return sliceSubsliceIdsBuilder_.getMessageOrBuilder(index); + } + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public java.util.List<? extends context.ContextOuterClass.SliceIdOrBuilder> + getSliceSubsliceIdsOrBuilderList() { + if (sliceSubsliceIdsBuilder_ != null) { + return sliceSubsliceIdsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(sliceSubsliceIds_); + } + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public context.ContextOuterClass.SliceId.Builder addSliceSubsliceIdsBuilder() { + return getSliceSubsliceIdsFieldBuilder().addBuilder( + context.ContextOuterClass.SliceId.getDefaultInstance()); + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public context.ContextOuterClass.SliceId.Builder addSliceSubsliceIdsBuilder( + int index) { + return getSliceSubsliceIdsFieldBuilder().addBuilder( + index, context.ContextOuterClass.SliceId.getDefaultInstance()); + } + /** + * <code>repeated .context.SliceId slice_subslice_ids = 5;</code> + */ + public java.util.List<context.ContextOuterClass.SliceId.Builder> + getSliceSubsliceIdsBuilderList() { + return getSliceSubsliceIdsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> + getSliceSubsliceIdsFieldBuilder() { + if (sliceSubsliceIdsBuilder_ == null) { + sliceSubsliceIdsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder>( + sliceSubsliceIds_, + ((bitField0_ & 0x00000008) != 0), + getParentForChildren(), + isClean()); + sliceSubsliceIds_ = null; + } + return sliceSubsliceIdsBuilder_; + } + + private context.ContextOuterClass.SliceStatus sliceStatus_; + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceStatus, context.ContextOuterClass.SliceStatus.Builder, context.ContextOuterClass.SliceStatusOrBuilder> sliceStatusBuilder_; + /** + * <code>.context.SliceStatus slice_status = 6;</code> + * @return Whether the sliceStatus field is set. + */ + public boolean hasSliceStatus() { + return sliceStatusBuilder_ != null || sliceStatus_ != null; + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + * @return The sliceStatus. + */ + public context.ContextOuterClass.SliceStatus getSliceStatus() { + if (sliceStatusBuilder_ == null) { + return sliceStatus_ == null ? context.ContextOuterClass.SliceStatus.getDefaultInstance() : sliceStatus_; + } else { + return sliceStatusBuilder_.getMessage(); + } + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + public Builder setSliceStatus(context.ContextOuterClass.SliceStatus value) { + if (sliceStatusBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + sliceStatus_ = value; + onChanged(); + } else { + sliceStatusBuilder_.setMessage(value); + } + + return this; + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + public Builder setSliceStatus( + context.ContextOuterClass.SliceStatus.Builder builderForValue) { + if (sliceStatusBuilder_ == null) { + sliceStatus_ = builderForValue.build(); + onChanged(); + } else { + sliceStatusBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + public Builder mergeSliceStatus(context.ContextOuterClass.SliceStatus value) { + if (sliceStatusBuilder_ == null) { + if (sliceStatus_ != null) { + sliceStatus_ = + context.ContextOuterClass.SliceStatus.newBuilder(sliceStatus_).mergeFrom(value).buildPartial(); + } else { + sliceStatus_ = value; + } + onChanged(); + } else { + sliceStatusBuilder_.mergeFrom(value); + } + + return this; + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + public Builder clearSliceStatus() { + if (sliceStatusBuilder_ == null) { + sliceStatus_ = null; + onChanged(); + } else { + sliceStatus_ = null; + sliceStatusBuilder_ = null; + } + + return this; + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + public context.ContextOuterClass.SliceStatus.Builder getSliceStatusBuilder() { + + onChanged(); + return getSliceStatusFieldBuilder().getBuilder(); + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + public context.ContextOuterClass.SliceStatusOrBuilder getSliceStatusOrBuilder() { + if (sliceStatusBuilder_ != null) { + return sliceStatusBuilder_.getMessageOrBuilder(); + } else { + return sliceStatus_ == null ? + context.ContextOuterClass.SliceStatus.getDefaultInstance() : sliceStatus_; + } + } + /** + * <code>.context.SliceStatus slice_status = 6;</code> + */ + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceStatus, context.ContextOuterClass.SliceStatus.Builder, context.ContextOuterClass.SliceStatusOrBuilder> + getSliceStatusFieldBuilder() { + if (sliceStatusBuilder_ == null) { + sliceStatusBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceStatus, context.ContextOuterClass.SliceStatus.Builder, context.ContextOuterClass.SliceStatusOrBuilder>( + getSliceStatus(), + getParentForChildren(), + isClean()); + sliceStatus_ = null; + } + return sliceStatusBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:context.Slice) + } + + // @@protoc_insertion_point(class_scope:context.Slice) + private static final context.ContextOuterClass.Slice DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new context.ContextOuterClass.Slice(); + } + + public static context.ContextOuterClass.Slice getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser<Slice> + PARSER = new com.google.protobuf.AbstractParser<Slice>() { + @java.lang.Override + public Slice parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Slice(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser<Slice> parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser<Slice> getParserForType() { + return PARSER; + } + + @java.lang.Override + public context.ContextOuterClass.Slice getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SliceStatusOrBuilder extends + // @@protoc_insertion_point(interface_extends:context.SliceStatus) + com.google.protobuf.MessageOrBuilder { + + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @return The enum numeric value on the wire for sliceStatus. + */ + int getSliceStatusValue(); + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @return The sliceStatus. + */ + context.ContextOuterClass.SliceStatusEnum getSliceStatus(); + } + /** + * Protobuf type {@code context.SliceStatus} + */ + public static final class SliceStatus extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:context.SliceStatus) + SliceStatusOrBuilder { + private static final long serialVersionUID = 0L; + // Use SliceStatus.newBuilder() to construct. + private SliceStatus(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { + super(builder); + } + private SliceStatus() { + sliceStatus_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SliceStatus(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SliceStatus( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + int rawValue = input.readEnum(); + + sliceStatus_ = rawValue; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceStatus_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceStatus_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceStatus.class, context.ContextOuterClass.SliceStatus.Builder.class); + } + + public static final int SLICE_STATUS_FIELD_NUMBER = 1; + private int sliceStatus_; + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @return The enum numeric value on the wire for sliceStatus. + */ + @java.lang.Override public int getSliceStatusValue() { + return sliceStatus_; + } + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @return The sliceStatus. + */ + @java.lang.Override public context.ContextOuterClass.SliceStatusEnum getSliceStatus() { + @SuppressWarnings("deprecation") + context.ContextOuterClass.SliceStatusEnum result = context.ContextOuterClass.SliceStatusEnum.valueOf(sliceStatus_); + return result == null ? context.ContextOuterClass.SliceStatusEnum.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (sliceStatus_ != context.ContextOuterClass.SliceStatusEnum.SLICESTATUS_UNDEFINED.getNumber()) { + output.writeEnum(1, sliceStatus_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (sliceStatus_ != context.ContextOuterClass.SliceStatusEnum.SLICESTATUS_UNDEFINED.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, sliceStatus_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof context.ContextOuterClass.SliceStatus)) { + return super.equals(obj); + } + context.ContextOuterClass.SliceStatus other = (context.ContextOuterClass.SliceStatus) obj; + + if (sliceStatus_ != other.sliceStatus_) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SLICE_STATUS_FIELD_NUMBER; + hash = (53 * hash) + sliceStatus_; + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static context.ContextOuterClass.SliceStatus parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceStatus parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceStatus parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceStatus parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceStatus parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceStatus parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceStatus parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceStatus parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceStatus parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceStatus parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceStatus parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceStatus parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(context.ContextOuterClass.SliceStatus prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code context.SliceStatus} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements + // @@protoc_insertion_point(builder_implements:context.SliceStatus) + context.ContextOuterClass.SliceStatusOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceStatus_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceStatus_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceStatus.class, context.ContextOuterClass.SliceStatus.Builder.class); + } + + // Construct using context.ContextOuterClass.SliceStatus.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + sliceStatus_ = 0; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return context.ContextOuterClass.internal_static_context_SliceStatus_descriptor; + } + + @java.lang.Override + public context.ContextOuterClass.SliceStatus getDefaultInstanceForType() { + return context.ContextOuterClass.SliceStatus.getDefaultInstance(); + } + + @java.lang.Override + public context.ContextOuterClass.SliceStatus build() { + context.ContextOuterClass.SliceStatus result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public context.ContextOuterClass.SliceStatus buildPartial() { + context.ContextOuterClass.SliceStatus result = new context.ContextOuterClass.SliceStatus(this); + result.sliceStatus_ = sliceStatus_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof context.ContextOuterClass.SliceStatus) { + return mergeFrom((context.ContextOuterClass.SliceStatus)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(context.ContextOuterClass.SliceStatus other) { + if (other == context.ContextOuterClass.SliceStatus.getDefaultInstance()) return this; + if (other.sliceStatus_ != 0) { + setSliceStatusValue(other.getSliceStatusValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + context.ContextOuterClass.SliceStatus parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (context.ContextOuterClass.SliceStatus) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int sliceStatus_ = 0; + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @return The enum numeric value on the wire for sliceStatus. + */ + @java.lang.Override public int getSliceStatusValue() { + return sliceStatus_; + } + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @param value The enum numeric value on the wire for sliceStatus to set. + * @return This builder for chaining. + */ + public Builder setSliceStatusValue(int value) { + + sliceStatus_ = value; + onChanged(); + return this; + } + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @return The sliceStatus. + */ + @java.lang.Override + public context.ContextOuterClass.SliceStatusEnum getSliceStatus() { + @SuppressWarnings("deprecation") + context.ContextOuterClass.SliceStatusEnum result = context.ContextOuterClass.SliceStatusEnum.valueOf(sliceStatus_); + return result == null ? context.ContextOuterClass.SliceStatusEnum.UNRECOGNIZED : result; + } + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @param value The sliceStatus to set. + * @return This builder for chaining. + */ + public Builder setSliceStatus(context.ContextOuterClass.SliceStatusEnum value) { + if (value == null) { + throw new NullPointerException(); + } + + sliceStatus_ = value.getNumber(); + onChanged(); + return this; + } + /** + * <code>.context.SliceStatusEnum slice_status = 1;</code> + * @return This builder for chaining. + */ + public Builder clearSliceStatus() { + + sliceStatus_ = 0; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:context.SliceStatus) + } + + // @@protoc_insertion_point(class_scope:context.SliceStatus) + private static final context.ContextOuterClass.SliceStatus DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new context.ContextOuterClass.SliceStatus(); + } + + public static context.ContextOuterClass.SliceStatus getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser<SliceStatus> + PARSER = new com.google.protobuf.AbstractParser<SliceStatus>() { + @java.lang.Override + public SliceStatus parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SliceStatus(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser<SliceStatus> parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser<SliceStatus> getParserForType() { + return PARSER; + } + + @java.lang.Override + public context.ContextOuterClass.SliceStatus getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SliceIdListOrBuilder extends + // @@protoc_insertion_point(interface_extends:context.SliceIdList) + com.google.protobuf.MessageOrBuilder { + + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + java.util.List<context.ContextOuterClass.SliceId> + getSliceIdsList(); + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + context.ContextOuterClass.SliceId getSliceIds(int index); + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + int getSliceIdsCount(); + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + java.util.List<? extends context.ContextOuterClass.SliceIdOrBuilder> + getSliceIdsOrBuilderList(); + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + context.ContextOuterClass.SliceIdOrBuilder getSliceIdsOrBuilder( + int index); + } + /** + * Protobuf type {@code context.SliceIdList} + */ + public static final class SliceIdList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:context.SliceIdList) + SliceIdListOrBuilder { + private static final long serialVersionUID = 0L; + // Use SliceIdList.newBuilder() to construct. + private SliceIdList(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { + super(builder); + } + private SliceIdList() { + sliceIds_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SliceIdList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SliceIdList( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + sliceIds_ = new java.util.ArrayList<context.ContextOuterClass.SliceId>(); + mutable_bitField0_ |= 0x00000001; + } + sliceIds_.add( + input.readMessage(context.ContextOuterClass.SliceId.parser(), extensionRegistry)); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + sliceIds_ = java.util.Collections.unmodifiableList(sliceIds_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceIdList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceIdList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceIdList.class, context.ContextOuterClass.SliceIdList.Builder.class); + } + + public static final int SLICE_IDS_FIELD_NUMBER = 1; + private java.util.List<context.ContextOuterClass.SliceId> sliceIds_; + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + @java.lang.Override + public java.util.List<context.ContextOuterClass.SliceId> getSliceIdsList() { + return sliceIds_; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + @java.lang.Override + public java.util.List<? extends context.ContextOuterClass.SliceIdOrBuilder> + getSliceIdsOrBuilderList() { + return sliceIds_; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + @java.lang.Override + public int getSliceIdsCount() { + return sliceIds_.size(); + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceId getSliceIds(int index) { + return sliceIds_.get(index); + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceIdOrBuilder getSliceIdsOrBuilder( + int index) { + return sliceIds_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < sliceIds_.size(); i++) { + output.writeMessage(1, sliceIds_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < sliceIds_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, sliceIds_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof context.ContextOuterClass.SliceIdList)) { + return super.equals(obj); + } + context.ContextOuterClass.SliceIdList other = (context.ContextOuterClass.SliceIdList) obj; + + if (!getSliceIdsList() + .equals(other.getSliceIdsList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getSliceIdsCount() > 0) { + hash = (37 * hash) + SLICE_IDS_FIELD_NUMBER; + hash = (53 * hash) + getSliceIdsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static context.ContextOuterClass.SliceIdList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceIdList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceIdList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceIdList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceIdList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceIdList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceIdList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceIdList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceIdList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceIdList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceIdList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceIdList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(context.ContextOuterClass.SliceIdList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code context.SliceIdList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements + // @@protoc_insertion_point(builder_implements:context.SliceIdList) + context.ContextOuterClass.SliceIdListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceIdList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceIdList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceIdList.class, context.ContextOuterClass.SliceIdList.Builder.class); + } + + // Construct using context.ContextOuterClass.SliceIdList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getSliceIdsFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (sliceIdsBuilder_ == null) { + sliceIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + sliceIdsBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return context.ContextOuterClass.internal_static_context_SliceIdList_descriptor; + } + + @java.lang.Override + public context.ContextOuterClass.SliceIdList getDefaultInstanceForType() { + return context.ContextOuterClass.SliceIdList.getDefaultInstance(); + } + + @java.lang.Override + public context.ContextOuterClass.SliceIdList build() { + context.ContextOuterClass.SliceIdList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public context.ContextOuterClass.SliceIdList buildPartial() { + context.ContextOuterClass.SliceIdList result = new context.ContextOuterClass.SliceIdList(this); + int from_bitField0_ = bitField0_; + if (sliceIdsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + sliceIds_ = java.util.Collections.unmodifiableList(sliceIds_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.sliceIds_ = sliceIds_; + } else { + result.sliceIds_ = sliceIdsBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof context.ContextOuterClass.SliceIdList) { + return mergeFrom((context.ContextOuterClass.SliceIdList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(context.ContextOuterClass.SliceIdList other) { + if (other == context.ContextOuterClass.SliceIdList.getDefaultInstance()) return this; + if (sliceIdsBuilder_ == null) { + if (!other.sliceIds_.isEmpty()) { + if (sliceIds_.isEmpty()) { + sliceIds_ = other.sliceIds_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureSliceIdsIsMutable(); + sliceIds_.addAll(other.sliceIds_); + } + onChanged(); + } + } else { + if (!other.sliceIds_.isEmpty()) { + if (sliceIdsBuilder_.isEmpty()) { + sliceIdsBuilder_.dispose(); + sliceIdsBuilder_ = null; + sliceIds_ = other.sliceIds_; + bitField0_ = (bitField0_ & ~0x00000001); + sliceIdsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSliceIdsFieldBuilder() : null; + } else { + sliceIdsBuilder_.addAllMessages(other.sliceIds_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + context.ContextOuterClass.SliceIdList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (context.ContextOuterClass.SliceIdList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List<context.ContextOuterClass.SliceId> sliceIds_ = + java.util.Collections.emptyList(); + private void ensureSliceIdsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + sliceIds_ = new java.util.ArrayList<context.ContextOuterClass.SliceId>(sliceIds_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> sliceIdsBuilder_; + + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public java.util.List<context.ContextOuterClass.SliceId> getSliceIdsList() { + if (sliceIdsBuilder_ == null) { + return java.util.Collections.unmodifiableList(sliceIds_); + } else { + return sliceIdsBuilder_.getMessageList(); + } + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public int getSliceIdsCount() { + if (sliceIdsBuilder_ == null) { + return sliceIds_.size(); + } else { + return sliceIdsBuilder_.getCount(); + } + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public context.ContextOuterClass.SliceId getSliceIds(int index) { + if (sliceIdsBuilder_ == null) { + return sliceIds_.get(index); + } else { + return sliceIdsBuilder_.getMessage(index); + } + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder setSliceIds( + int index, context.ContextOuterClass.SliceId value) { + if (sliceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceIdsIsMutable(); + sliceIds_.set(index, value); + onChanged(); + } else { + sliceIdsBuilder_.setMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder setSliceIds( + int index, context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceIdsBuilder_ == null) { + ensureSliceIdsIsMutable(); + sliceIds_.set(index, builderForValue.build()); + onChanged(); + } else { + sliceIdsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder addSliceIds(context.ContextOuterClass.SliceId value) { + if (sliceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceIdsIsMutable(); + sliceIds_.add(value); + onChanged(); + } else { + sliceIdsBuilder_.addMessage(value); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder addSliceIds( + int index, context.ContextOuterClass.SliceId value) { + if (sliceIdsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSliceIdsIsMutable(); + sliceIds_.add(index, value); + onChanged(); + } else { + sliceIdsBuilder_.addMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder addSliceIds( + context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceIdsBuilder_ == null) { + ensureSliceIdsIsMutable(); + sliceIds_.add(builderForValue.build()); + onChanged(); + } else { + sliceIdsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder addSliceIds( + int index, context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceIdsBuilder_ == null) { + ensureSliceIdsIsMutable(); + sliceIds_.add(index, builderForValue.build()); + onChanged(); + } else { + sliceIdsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder addAllSliceIds( + java.lang.Iterable<? extends context.ContextOuterClass.SliceId> values) { + if (sliceIdsBuilder_ == null) { + ensureSliceIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, sliceIds_); + onChanged(); + } else { + sliceIdsBuilder_.addAllMessages(values); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder clearSliceIds() { + if (sliceIdsBuilder_ == null) { + sliceIds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + sliceIdsBuilder_.clear(); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public Builder removeSliceIds(int index) { + if (sliceIdsBuilder_ == null) { + ensureSliceIdsIsMutable(); + sliceIds_.remove(index); + onChanged(); + } else { + sliceIdsBuilder_.remove(index); + } + return this; + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public context.ContextOuterClass.SliceId.Builder getSliceIdsBuilder( + int index) { + return getSliceIdsFieldBuilder().getBuilder(index); + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public context.ContextOuterClass.SliceIdOrBuilder getSliceIdsOrBuilder( + int index) { + if (sliceIdsBuilder_ == null) { + return sliceIds_.get(index); } else { + return sliceIdsBuilder_.getMessageOrBuilder(index); + } + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public java.util.List<? extends context.ContextOuterClass.SliceIdOrBuilder> + getSliceIdsOrBuilderList() { + if (sliceIdsBuilder_ != null) { + return sliceIdsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(sliceIds_); + } + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public context.ContextOuterClass.SliceId.Builder addSliceIdsBuilder() { + return getSliceIdsFieldBuilder().addBuilder( + context.ContextOuterClass.SliceId.getDefaultInstance()); + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public context.ContextOuterClass.SliceId.Builder addSliceIdsBuilder( + int index) { + return getSliceIdsFieldBuilder().addBuilder( + index, context.ContextOuterClass.SliceId.getDefaultInstance()); + } + /** + * <code>repeated .context.SliceId slice_ids = 1;</code> + */ + public java.util.List<context.ContextOuterClass.SliceId.Builder> + getSliceIdsBuilderList() { + return getSliceIdsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> + getSliceIdsFieldBuilder() { + if (sliceIdsBuilder_ == null) { + sliceIdsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder>( + sliceIds_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + sliceIds_ = null; + } + return sliceIdsBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:context.SliceIdList) + } + + // @@protoc_insertion_point(class_scope:context.SliceIdList) + private static final context.ContextOuterClass.SliceIdList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new context.ContextOuterClass.SliceIdList(); + } + + public static context.ContextOuterClass.SliceIdList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser<SliceIdList> + PARSER = new com.google.protobuf.AbstractParser<SliceIdList>() { + @java.lang.Override + public SliceIdList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SliceIdList(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser<SliceIdList> parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser<SliceIdList> getParserForType() { + return PARSER; + } + + @java.lang.Override + public context.ContextOuterClass.SliceIdList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SliceListOrBuilder extends + // @@protoc_insertion_point(interface_extends:context.SliceList) + com.google.protobuf.MessageOrBuilder { + + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + java.util.List<context.ContextOuterClass.Slice> + getSlicesList(); + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + context.ContextOuterClass.Slice getSlices(int index); + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + int getSlicesCount(); + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + java.util.List<? extends context.ContextOuterClass.SliceOrBuilder> + getSlicesOrBuilderList(); + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + context.ContextOuterClass.SliceOrBuilder getSlicesOrBuilder( + int index); + } + /** + * Protobuf type {@code context.SliceList} + */ + public static final class SliceList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:context.SliceList) + SliceListOrBuilder { + private static final long serialVersionUID = 0L; + // Use SliceList.newBuilder() to construct. + private SliceList(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { + super(builder); + } + private SliceList() { + slices_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SliceList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SliceList( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + slices_ = new java.util.ArrayList<context.ContextOuterClass.Slice>(); + mutable_bitField0_ |= 0x00000001; + } + slices_.add( + input.readMessage(context.ContextOuterClass.Slice.parser(), extensionRegistry)); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + slices_ = java.util.Collections.unmodifiableList(slices_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceList.class, context.ContextOuterClass.SliceList.Builder.class); + } + + public static final int SLICES_FIELD_NUMBER = 1; + private java.util.List<context.ContextOuterClass.Slice> slices_; + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + @java.lang.Override + public java.util.List<context.ContextOuterClass.Slice> getSlicesList() { + return slices_; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + @java.lang.Override + public java.util.List<? extends context.ContextOuterClass.SliceOrBuilder> + getSlicesOrBuilderList() { + return slices_; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + @java.lang.Override + public int getSlicesCount() { + return slices_.size(); + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + @java.lang.Override + public context.ContextOuterClass.Slice getSlices(int index) { + return slices_.get(index); + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceOrBuilder getSlicesOrBuilder( + int index) { + return slices_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < slices_.size(); i++) { + output.writeMessage(1, slices_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < slices_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, slices_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof context.ContextOuterClass.SliceList)) { + return super.equals(obj); + } + context.ContextOuterClass.SliceList other = (context.ContextOuterClass.SliceList) obj; + + if (!getSlicesList() + .equals(other.getSlicesList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getSlicesCount() > 0) { + hash = (37 * hash) + SLICES_FIELD_NUMBER; + hash = (53 * hash) + getSlicesList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static context.ContextOuterClass.SliceList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(context.ContextOuterClass.SliceList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code context.SliceList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements + // @@protoc_insertion_point(builder_implements:context.SliceList) + context.ContextOuterClass.SliceListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceList.class, context.ContextOuterClass.SliceList.Builder.class); + } + + // Construct using context.ContextOuterClass.SliceList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getSlicesFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (slicesBuilder_ == null) { + slices_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + slicesBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return context.ContextOuterClass.internal_static_context_SliceList_descriptor; + } + + @java.lang.Override + public context.ContextOuterClass.SliceList getDefaultInstanceForType() { + return context.ContextOuterClass.SliceList.getDefaultInstance(); + } + + @java.lang.Override + public context.ContextOuterClass.SliceList build() { + context.ContextOuterClass.SliceList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public context.ContextOuterClass.SliceList buildPartial() { + context.ContextOuterClass.SliceList result = new context.ContextOuterClass.SliceList(this); + int from_bitField0_ = bitField0_; + if (slicesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + slices_ = java.util.Collections.unmodifiableList(slices_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.slices_ = slices_; + } else { + result.slices_ = slicesBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof context.ContextOuterClass.SliceList) { + return mergeFrom((context.ContextOuterClass.SliceList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(context.ContextOuterClass.SliceList other) { + if (other == context.ContextOuterClass.SliceList.getDefaultInstance()) return this; + if (slicesBuilder_ == null) { + if (!other.slices_.isEmpty()) { + if (slices_.isEmpty()) { + slices_ = other.slices_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureSlicesIsMutable(); + slices_.addAll(other.slices_); + } + onChanged(); + } + } else { + if (!other.slices_.isEmpty()) { + if (slicesBuilder_.isEmpty()) { + slicesBuilder_.dispose(); + slicesBuilder_ = null; + slices_ = other.slices_; + bitField0_ = (bitField0_ & ~0x00000001); + slicesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSlicesFieldBuilder() : null; + } else { + slicesBuilder_.addAllMessages(other.slices_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + context.ContextOuterClass.SliceList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (context.ContextOuterClass.SliceList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List<context.ContextOuterClass.Slice> slices_ = + java.util.Collections.emptyList(); + private void ensureSlicesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + slices_ = new java.util.ArrayList<context.ContextOuterClass.Slice>(slices_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.Slice, context.ContextOuterClass.Slice.Builder, context.ContextOuterClass.SliceOrBuilder> slicesBuilder_; + + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public java.util.List<context.ContextOuterClass.Slice> getSlicesList() { + if (slicesBuilder_ == null) { + return java.util.Collections.unmodifiableList(slices_); + } else { + return slicesBuilder_.getMessageList(); + } + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public int getSlicesCount() { + if (slicesBuilder_ == null) { + return slices_.size(); + } else { + return slicesBuilder_.getCount(); + } + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public context.ContextOuterClass.Slice getSlices(int index) { + if (slicesBuilder_ == null) { + return slices_.get(index); + } else { + return slicesBuilder_.getMessage(index); + } + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder setSlices( + int index, context.ContextOuterClass.Slice value) { + if (slicesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSlicesIsMutable(); + slices_.set(index, value); + onChanged(); + } else { + slicesBuilder_.setMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder setSlices( + int index, context.ContextOuterClass.Slice.Builder builderForValue) { + if (slicesBuilder_ == null) { + ensureSlicesIsMutable(); + slices_.set(index, builderForValue.build()); + onChanged(); + } else { + slicesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder addSlices(context.ContextOuterClass.Slice value) { + if (slicesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSlicesIsMutable(); + slices_.add(value); + onChanged(); + } else { + slicesBuilder_.addMessage(value); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder addSlices( + int index, context.ContextOuterClass.Slice value) { + if (slicesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSlicesIsMutable(); + slices_.add(index, value); + onChanged(); + } else { + slicesBuilder_.addMessage(index, value); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder addSlices( + context.ContextOuterClass.Slice.Builder builderForValue) { + if (slicesBuilder_ == null) { + ensureSlicesIsMutable(); + slices_.add(builderForValue.build()); + onChanged(); + } else { + slicesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder addSlices( + int index, context.ContextOuterClass.Slice.Builder builderForValue) { + if (slicesBuilder_ == null) { + ensureSlicesIsMutable(); + slices_.add(index, builderForValue.build()); + onChanged(); + } else { + slicesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder addAllSlices( + java.lang.Iterable<? extends context.ContextOuterClass.Slice> values) { + if (slicesBuilder_ == null) { + ensureSlicesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, slices_); + onChanged(); + } else { + slicesBuilder_.addAllMessages(values); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder clearSlices() { + if (slicesBuilder_ == null) { + slices_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + slicesBuilder_.clear(); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public Builder removeSlices(int index) { + if (slicesBuilder_ == null) { + ensureSlicesIsMutable(); + slices_.remove(index); + onChanged(); + } else { + slicesBuilder_.remove(index); + } + return this; + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public context.ContextOuterClass.Slice.Builder getSlicesBuilder( + int index) { + return getSlicesFieldBuilder().getBuilder(index); + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public context.ContextOuterClass.SliceOrBuilder getSlicesOrBuilder( + int index) { + if (slicesBuilder_ == null) { + return slices_.get(index); } else { + return slicesBuilder_.getMessageOrBuilder(index); + } + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public java.util.List<? extends context.ContextOuterClass.SliceOrBuilder> + getSlicesOrBuilderList() { + if (slicesBuilder_ != null) { + return slicesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(slices_); + } + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public context.ContextOuterClass.Slice.Builder addSlicesBuilder() { + return getSlicesFieldBuilder().addBuilder( + context.ContextOuterClass.Slice.getDefaultInstance()); + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public context.ContextOuterClass.Slice.Builder addSlicesBuilder( + int index) { + return getSlicesFieldBuilder().addBuilder( + index, context.ContextOuterClass.Slice.getDefaultInstance()); + } + /** + * <code>repeated .context.Slice slices = 1;</code> + */ + public java.util.List<context.ContextOuterClass.Slice.Builder> + getSlicesBuilderList() { + return getSlicesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.Slice, context.ContextOuterClass.Slice.Builder, context.ContextOuterClass.SliceOrBuilder> + getSlicesFieldBuilder() { + if (slicesBuilder_ == null) { + slicesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + context.ContextOuterClass.Slice, context.ContextOuterClass.Slice.Builder, context.ContextOuterClass.SliceOrBuilder>( + slices_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + slices_ = null; + } + return slicesBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:context.SliceList) + } + + // @@protoc_insertion_point(class_scope:context.SliceList) + private static final context.ContextOuterClass.SliceList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new context.ContextOuterClass.SliceList(); + } + + public static context.ContextOuterClass.SliceList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser<SliceList> + PARSER = new com.google.protobuf.AbstractParser<SliceList>() { + @java.lang.Override + public SliceList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SliceList(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser<SliceList> parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser<SliceList> getParserForType() { + return PARSER; + } + + @java.lang.Override + public context.ContextOuterClass.SliceList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SliceEventOrBuilder extends + // @@protoc_insertion_point(interface_extends:context.SliceEvent) + com.google.protobuf.MessageOrBuilder { + + /** + * <code>.context.Event event = 1;</code> + * @return Whether the event field is set. + */ + boolean hasEvent(); + /** + * <code>.context.Event event = 1;</code> + * @return The event. + */ + context.ContextOuterClass.Event getEvent(); + /** + * <code>.context.Event event = 1;</code> + */ + context.ContextOuterClass.EventOrBuilder getEventOrBuilder(); + + /** + * <code>.context.SliceId slice_id = 2;</code> + * @return Whether the sliceId field is set. + */ + boolean hasSliceId(); + /** + * <code>.context.SliceId slice_id = 2;</code> + * @return The sliceId. + */ + context.ContextOuterClass.SliceId getSliceId(); + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + context.ContextOuterClass.SliceIdOrBuilder getSliceIdOrBuilder(); + } + /** + * Protobuf type {@code context.SliceEvent} + */ + public static final class SliceEvent extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:context.SliceEvent) + SliceEventOrBuilder { + private static final long serialVersionUID = 0L; + // Use SliceEvent.newBuilder() to construct. + private SliceEvent(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { + super(builder); + } + private SliceEvent() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SliceEvent(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SliceEvent( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + context.ContextOuterClass.Event.Builder subBuilder = null; + if (event_ != null) { + subBuilder = event_.toBuilder(); + } + event_ = input.readMessage(context.ContextOuterClass.Event.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(event_); + event_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + context.ContextOuterClass.SliceId.Builder subBuilder = null; + if (sliceId_ != null) { + subBuilder = sliceId_.toBuilder(); + } + sliceId_ = input.readMessage(context.ContextOuterClass.SliceId.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(sliceId_); + sliceId_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceEvent_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceEvent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceEvent.class, context.ContextOuterClass.SliceEvent.Builder.class); + } + + public static final int EVENT_FIELD_NUMBER = 1; + private context.ContextOuterClass.Event event_; + /** + * <code>.context.Event event = 1;</code> + * @return Whether the event field is set. + */ + @java.lang.Override + public boolean hasEvent() { + return event_ != null; + } + /** + * <code>.context.Event event = 1;</code> + * @return The event. + */ + @java.lang.Override + public context.ContextOuterClass.Event getEvent() { + return event_ == null ? context.ContextOuterClass.Event.getDefaultInstance() : event_; + } + /** + * <code>.context.Event event = 1;</code> + */ + @java.lang.Override + public context.ContextOuterClass.EventOrBuilder getEventOrBuilder() { + return getEvent(); + } + + public static final int SLICE_ID_FIELD_NUMBER = 2; + private context.ContextOuterClass.SliceId sliceId_; + /** + * <code>.context.SliceId slice_id = 2;</code> + * @return Whether the sliceId field is set. + */ + @java.lang.Override + public boolean hasSliceId() { + return sliceId_ != null; + } + /** + * <code>.context.SliceId slice_id = 2;</code> + * @return The sliceId. + */ + @java.lang.Override + public context.ContextOuterClass.SliceId getSliceId() { + return sliceId_ == null ? context.ContextOuterClass.SliceId.getDefaultInstance() : sliceId_; + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + @java.lang.Override + public context.ContextOuterClass.SliceIdOrBuilder getSliceIdOrBuilder() { + return getSliceId(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (event_ != null) { + output.writeMessage(1, getEvent()); + } + if (sliceId_ != null) { + output.writeMessage(2, getSliceId()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (event_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getEvent()); + } + if (sliceId_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getSliceId()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof context.ContextOuterClass.SliceEvent)) { + return super.equals(obj); + } + context.ContextOuterClass.SliceEvent other = (context.ContextOuterClass.SliceEvent) obj; + + if (hasEvent() != other.hasEvent()) return false; + if (hasEvent()) { + if (!getEvent() + .equals(other.getEvent())) return false; + } + if (hasSliceId() != other.hasSliceId()) return false; + if (hasSliceId()) { + if (!getSliceId() + .equals(other.getSliceId())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasEvent()) { + hash = (37 * hash) + EVENT_FIELD_NUMBER; + hash = (53 * hash) + getEvent().hashCode(); + } + if (hasSliceId()) { + hash = (37 * hash) + SLICE_ID_FIELD_NUMBER; + hash = (53 * hash) + getSliceId().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static context.ContextOuterClass.SliceEvent parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceEvent parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceEvent parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceEvent parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceEvent parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.SliceEvent parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.SliceEvent parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceEvent parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceEvent parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceEvent parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.SliceEvent parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.SliceEvent parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(context.ContextOuterClass.SliceEvent prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code context.SliceEvent} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements + // @@protoc_insertion_point(builder_implements:context.SliceEvent) + context.ContextOuterClass.SliceEventOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_SliceEvent_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_SliceEvent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.SliceEvent.class, context.ContextOuterClass.SliceEvent.Builder.class); + } + + // Construct using context.ContextOuterClass.SliceEvent.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (eventBuilder_ == null) { + event_ = null; + } else { + event_ = null; + eventBuilder_ = null; + } + if (sliceIdBuilder_ == null) { + sliceId_ = null; + } else { + sliceId_ = null; + sliceIdBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return context.ContextOuterClass.internal_static_context_SliceEvent_descriptor; + } + + @java.lang.Override + public context.ContextOuterClass.SliceEvent getDefaultInstanceForType() { + return context.ContextOuterClass.SliceEvent.getDefaultInstance(); + } + + @java.lang.Override + public context.ContextOuterClass.SliceEvent build() { + context.ContextOuterClass.SliceEvent result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public context.ContextOuterClass.SliceEvent buildPartial() { + context.ContextOuterClass.SliceEvent result = new context.ContextOuterClass.SliceEvent(this); + if (eventBuilder_ == null) { + result.event_ = event_; + } else { + result.event_ = eventBuilder_.build(); + } + if (sliceIdBuilder_ == null) { + result.sliceId_ = sliceId_; + } else { + result.sliceId_ = sliceIdBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof context.ContextOuterClass.SliceEvent) { + return mergeFrom((context.ContextOuterClass.SliceEvent)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(context.ContextOuterClass.SliceEvent other) { + if (other == context.ContextOuterClass.SliceEvent.getDefaultInstance()) return this; + if (other.hasEvent()) { + mergeEvent(other.getEvent()); + } + if (other.hasSliceId()) { + mergeSliceId(other.getSliceId()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + context.ContextOuterClass.SliceEvent parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (context.ContextOuterClass.SliceEvent) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private context.ContextOuterClass.Event event_; + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.Event, context.ContextOuterClass.Event.Builder, context.ContextOuterClass.EventOrBuilder> eventBuilder_; + /** + * <code>.context.Event event = 1;</code> + * @return Whether the event field is set. + */ + public boolean hasEvent() { + return eventBuilder_ != null || event_ != null; + } + /** + * <code>.context.Event event = 1;</code> + * @return The event. + */ + public context.ContextOuterClass.Event getEvent() { + if (eventBuilder_ == null) { + return event_ == null ? context.ContextOuterClass.Event.getDefaultInstance() : event_; + } else { + return eventBuilder_.getMessage(); + } + } + /** + * <code>.context.Event event = 1;</code> + */ + public Builder setEvent(context.ContextOuterClass.Event value) { + if (eventBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + event_ = value; + onChanged(); + } else { + eventBuilder_.setMessage(value); + } + + return this; + } + /** + * <code>.context.Event event = 1;</code> + */ + public Builder setEvent( + context.ContextOuterClass.Event.Builder builderForValue) { + if (eventBuilder_ == null) { + event_ = builderForValue.build(); + onChanged(); + } else { + eventBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * <code>.context.Event event = 1;</code> + */ + public Builder mergeEvent(context.ContextOuterClass.Event value) { + if (eventBuilder_ == null) { + if (event_ != null) { + event_ = + context.ContextOuterClass.Event.newBuilder(event_).mergeFrom(value).buildPartial(); + } else { + event_ = value; + } + onChanged(); + } else { + eventBuilder_.mergeFrom(value); + } + + return this; + } + /** + * <code>.context.Event event = 1;</code> + */ + public Builder clearEvent() { + if (eventBuilder_ == null) { + event_ = null; + onChanged(); + } else { + event_ = null; + eventBuilder_ = null; + } + + return this; + } + /** + * <code>.context.Event event = 1;</code> + */ + public context.ContextOuterClass.Event.Builder getEventBuilder() { + + onChanged(); + return getEventFieldBuilder().getBuilder(); + } + /** + * <code>.context.Event event = 1;</code> + */ + public context.ContextOuterClass.EventOrBuilder getEventOrBuilder() { + if (eventBuilder_ != null) { + return eventBuilder_.getMessageOrBuilder(); + } else { + return event_ == null ? + context.ContextOuterClass.Event.getDefaultInstance() : event_; + } + } + /** + * <code>.context.Event event = 1;</code> + */ + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.Event, context.ContextOuterClass.Event.Builder, context.ContextOuterClass.EventOrBuilder> + getEventFieldBuilder() { + if (eventBuilder_ == null) { + eventBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.Event, context.ContextOuterClass.Event.Builder, context.ContextOuterClass.EventOrBuilder>( + getEvent(), + getParentForChildren(), + isClean()); + event_ = null; + } + return eventBuilder_; + } + + private context.ContextOuterClass.SliceId sliceId_; + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> sliceIdBuilder_; + /** + * <code>.context.SliceId slice_id = 2;</code> + * @return Whether the sliceId field is set. + */ + public boolean hasSliceId() { + return sliceIdBuilder_ != null || sliceId_ != null; + } + /** + * <code>.context.SliceId slice_id = 2;</code> + * @return The sliceId. + */ + public context.ContextOuterClass.SliceId getSliceId() { + if (sliceIdBuilder_ == null) { + return sliceId_ == null ? context.ContextOuterClass.SliceId.getDefaultInstance() : sliceId_; + } else { + return sliceIdBuilder_.getMessage(); + } + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + public Builder setSliceId(context.ContextOuterClass.SliceId value) { + if (sliceIdBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + sliceId_ = value; + onChanged(); + } else { + sliceIdBuilder_.setMessage(value); + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + public Builder setSliceId( + context.ContextOuterClass.SliceId.Builder builderForValue) { + if (sliceIdBuilder_ == null) { + sliceId_ = builderForValue.build(); + onChanged(); + } else { + sliceIdBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + public Builder mergeSliceId(context.ContextOuterClass.SliceId value) { + if (sliceIdBuilder_ == null) { + if (sliceId_ != null) { + sliceId_ = + context.ContextOuterClass.SliceId.newBuilder(sliceId_).mergeFrom(value).buildPartial(); + } else { + sliceId_ = value; + } + onChanged(); + } else { + sliceIdBuilder_.mergeFrom(value); + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + public Builder clearSliceId() { + if (sliceIdBuilder_ == null) { + sliceId_ = null; + onChanged(); + } else { + sliceId_ = null; + sliceIdBuilder_ = null; + } + + return this; + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + public context.ContextOuterClass.SliceId.Builder getSliceIdBuilder() { + + onChanged(); + return getSliceIdFieldBuilder().getBuilder(); + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + public context.ContextOuterClass.SliceIdOrBuilder getSliceIdOrBuilder() { + if (sliceIdBuilder_ != null) { + return sliceIdBuilder_.getMessageOrBuilder(); + } else { + return sliceId_ == null ? + context.ContextOuterClass.SliceId.getDefaultInstance() : sliceId_; + } + } + /** + * <code>.context.SliceId slice_id = 2;</code> + */ + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder> + getSliceIdFieldBuilder() { + if (sliceIdBuilder_ == null) { + sliceIdBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.SliceId, context.ContextOuterClass.SliceId.Builder, context.ContextOuterClass.SliceIdOrBuilder>( + getSliceId(), + getParentForChildren(), + isClean()); + sliceId_ = null; + } + return sliceIdBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:context.SliceEvent) + } + + // @@protoc_insertion_point(class_scope:context.SliceEvent) + private static final context.ContextOuterClass.SliceEvent DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new context.ContextOuterClass.SliceEvent(); + } + + public static context.ContextOuterClass.SliceEvent getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser<SliceEvent> + PARSER = new com.google.protobuf.AbstractParser<SliceEvent>() { + @java.lang.Override + public SliceEvent parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SliceEvent(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser<SliceEvent> parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser<SliceEvent> getParserForType() { + return PARSER; + } + + @java.lang.Override + public context.ContextOuterClass.SliceEvent getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ConnectionIdOrBuilder extends + // @@protoc_insertion_point(interface_extends:context.ConnectionId) + com.google.protobuf.MessageOrBuilder { + + /** + * <code>.context.Uuid connection_uuid = 1;</code> + * @return Whether the connectionUuid field is set. + */ + boolean hasConnectionUuid(); + /** + * <code>.context.Uuid connection_uuid = 1;</code> + * @return The connectionUuid. + */ + context.ContextOuterClass.Uuid getConnectionUuid(); + /** + * <code>.context.Uuid connection_uuid = 1;</code> + */ + context.ContextOuterClass.UuidOrBuilder getConnectionUuidOrBuilder(); + } + /** + * <pre> + * ----- Connection ---------------------------------------------------------------------------------------------------- + * </pre> + * + * Protobuf type {@code context.ConnectionId} + */ + public static final class ConnectionId extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:context.ConnectionId) + ConnectionIdOrBuilder { + private static final long serialVersionUID = 0L; + // Use ConnectionId.newBuilder() to construct. + private ConnectionId(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { + super(builder); + } + private ConnectionId() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new ConnectionId(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ConnectionId( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + context.ContextOuterClass.Uuid.Builder subBuilder = null; + if (connectionUuid_ != null) { + subBuilder = connectionUuid_.toBuilder(); + } + connectionUuid_ = input.readMessage(context.ContextOuterClass.Uuid.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(connectionUuid_); + connectionUuid_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_ConnectionId_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_ConnectionId_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.ConnectionId.class, context.ContextOuterClass.ConnectionId.Builder.class); + } + + public static final int CONNECTION_UUID_FIELD_NUMBER = 1; + private context.ContextOuterClass.Uuid connectionUuid_; + /** + * <code>.context.Uuid connection_uuid = 1;</code> + * @return Whether the connectionUuid field is set. + */ + @java.lang.Override + public boolean hasConnectionUuid() { + return connectionUuid_ != null; + } + /** + * <code>.context.Uuid connection_uuid = 1;</code> + * @return The connectionUuid. + */ + @java.lang.Override + public context.ContextOuterClass.Uuid getConnectionUuid() { + return connectionUuid_ == null ? context.ContextOuterClass.Uuid.getDefaultInstance() : connectionUuid_; + } + /** + * <code>.context.Uuid connection_uuid = 1;</code> + */ + @java.lang.Override + public context.ContextOuterClass.UuidOrBuilder getConnectionUuidOrBuilder() { + return getConnectionUuid(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (connectionUuid_ != null) { + output.writeMessage(1, getConnectionUuid()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (connectionUuid_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getConnectionUuid()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof context.ContextOuterClass.ConnectionId)) { + return super.equals(obj); + } + context.ContextOuterClass.ConnectionId other = (context.ContextOuterClass.ConnectionId) obj; + + if (hasConnectionUuid() != other.hasConnectionUuid()) return false; + if (hasConnectionUuid()) { + if (!getConnectionUuid() + .equals(other.getConnectionUuid())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasConnectionUuid()) { + hash = (37 * hash) + CONNECTION_UUID_FIELD_NUMBER; + hash = (53 * hash) + getConnectionUuid().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static context.ContextOuterClass.ConnectionId parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.ConnectionId parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.ConnectionId parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.ConnectionId parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.ConnectionId parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static context.ContextOuterClass.ConnectionId parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static context.ContextOuterClass.ConnectionId parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.ConnectionId parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.ConnectionId parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static context.ContextOuterClass.ConnectionId parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static context.ContextOuterClass.ConnectionId parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static context.ContextOuterClass.ConnectionId parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(context.ContextOuterClass.ConnectionId prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * <pre> + * ----- Connection ---------------------------------------------------------------------------------------------------- + * </pre> + * + * Protobuf type {@code context.ConnectionId} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements + // @@protoc_insertion_point(builder_implements:context.ConnectionId) + context.ContextOuterClass.ConnectionIdOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return context.ContextOuterClass.internal_static_context_ConnectionId_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return context.ContextOuterClass.internal_static_context_ConnectionId_fieldAccessorTable + .ensureFieldAccessorsInitialized( + context.ContextOuterClass.ConnectionId.class, context.ContextOuterClass.ConnectionId.Builder.class); + } + + // Construct using context.ContextOuterClass.ConnectionId.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (connectionUuidBuilder_ == null) { + connectionUuid_ = null; + } else { + connectionUuid_ = null; + connectionUuidBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return context.ContextOuterClass.internal_static_context_ConnectionId_descriptor; + } + + @java.lang.Override + public context.ContextOuterClass.ConnectionId getDefaultInstanceForType() { + return context.ContextOuterClass.ConnectionId.getDefaultInstance(); + } + + @java.lang.Override + public context.ContextOuterClass.ConnectionId build() { + context.ContextOuterClass.ConnectionId result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public context.ContextOuterClass.ConnectionId buildPartial() { + context.ContextOuterClass.ConnectionId result = new context.ContextOuterClass.ConnectionId(this); + if (connectionUuidBuilder_ == null) { + result.connectionUuid_ = connectionUuid_; + } else { + result.connectionUuid_ = connectionUuidBuilder_.build(); } onBuilt(); return result; @@ -37615,6 +43832,36 @@ public final class ContextOuterClass { private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_context_ServiceEvent_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_context_SliceId_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_context_SliceId_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_context_Slice_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_context_Slice_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_context_SliceStatus_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_context_SliceStatus_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_context_SliceIdList_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_context_SliceIdList_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_context_SliceList_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_context_SliceList_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_context_SliceEvent_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_context_SliceEvent_fieldAccessorTable; private static final com.google.protobuf.Descriptors.Descriptor internal_static_context_ConnectionId_descriptor; private static final @@ -37744,107 +43991,134 @@ public final class ContextOuterClass { "\"\n\010services\030\001 \003(\0132\020.context.Service\"U\n\014S" + "erviceEvent\022\035\n\005event\030\001 \001(\0132\016.context.Eve" + "nt\022&\n\nservice_id\030\002 \001(\0132\022.context.Service" + - "Id\"6\n\014ConnectionId\022&\n\017connection_uuid\030\001 " + - "\001(\0132\r.context.Uuid\"\304\001\n\nConnection\022,\n\rcon" + - "nection_id\030\001 \001(\0132\025.context.ConnectionId\022" + - "&\n\nservice_id\030\002 \001(\0132\022.context.ServiceId\022" + - "3\n\026path_hops_endpoint_ids\030\003 \003(\0132\023.contex" + - "t.EndPointId\022+\n\017sub_service_ids\030\004 \003(\0132\022." + - "context.ServiceId\"A\n\020ConnectionIdList\022-\n" + - "\016connection_ids\030\001 \003(\0132\025.context.Connecti" + - "onId\":\n\016ConnectionList\022(\n\013connections\030\001 " + - "\003(\0132\023.context.Connection\"^\n\017ConnectionEv" + - "ent\022\035\n\005event\030\001 \001(\0132\016.context.Event\022,\n\rco" + - "nnection_id\030\002 \001(\0132\025.context.ConnectionId" + - "\"\202\001\n\nEndPointId\022(\n\013topology_id\030\001 \001(\0132\023.c" + - "ontext.TopologyId\022$\n\tdevice_id\030\002 \001(\0132\021.c" + - "ontext.DeviceId\022$\n\rendpoint_uuid\030\003 \001(\0132\r" + - ".context.Uuid\"\206\001\n\010EndPoint\022(\n\013endpoint_i" + - "d\030\001 \001(\0132\023.context.EndPointId\022\025\n\rendpoint" + - "_type\030\002 \001(\t\0229\n\020kpi_sample_types\030\003 \003(\0162\037." + - "kpi_sample_types.KpiSampleType\"e\n\nConfig" + - "Rule\022)\n\006action\030\001 \001(\0162\031.context.ConfigAct" + - "ionEnum\022\024\n\014resource_key\030\002 \001(\t\022\026\n\016resourc" + - "e_value\030\003 \001(\t\"?\n\nConstraint\022\027\n\017constrain" + - "t_type\030\001 \001(\t\022\030\n\020constraint_value\030\002 \001(\t\"^" + - "\n\022TeraFlowController\022&\n\ncontext_id\030\001 \001(\013" + - "2\022.context.ContextId\022\022\n\nip_address\030\002 \001(\t" + - "\022\014\n\004port\030\003 \001(\r\"U\n\024AuthenticationResult\022&" + - "\n\ncontext_id\030\001 \001(\0132\022.context.ContextId\022\025" + - "\n\rauthenticated\030\002 \001(\010*j\n\rEventTypeEnum\022\027" + - "\n\023EVENTTYPE_UNDEFINED\020\000\022\024\n\020EVENTTYPE_CRE" + - "ATE\020\001\022\024\n\020EVENTTYPE_UPDATE\020\002\022\024\n\020EVENTTYPE" + - "_REMOVE\020\003*\305\001\n\020DeviceDriverEnum\022\032\n\026DEVICE" + - "DRIVER_UNDEFINED\020\000\022\033\n\027DEVICEDRIVER_OPENC" + - "ONFIG\020\001\022\036\n\032DEVICEDRIVER_TRANSPORT_API\020\002\022" + - "\023\n\017DEVICEDRIVER_P4\020\003\022&\n\"DEVICEDRIVER_IET" + - "F_NETWORK_TOPOLOGY\020\004\022\033\n\027DEVICEDRIVER_ONF" + - "_TR_352\020\005*\217\001\n\033DeviceOperationalStatusEnu" + - "m\022%\n!DEVICEOPERATIONALSTATUS_UNDEFINED\020\000" + - "\022$\n DEVICEOPERATIONALSTATUS_DISABLED\020\001\022#" + - "\n\037DEVICEOPERATIONALSTATUS_ENABLED\020\002*\201\001\n\017" + - "ServiceTypeEnum\022\027\n\023SERVICETYPE_UNKNOWN\020\000" + - "\022\024\n\020SERVICETYPE_L3NM\020\001\022\024\n\020SERVICETYPE_L2" + - "NM\020\002\022)\n%SERVICETYPE_TAPI_CONNECTIVITY_SE" + - "RVICE\020\003*\210\001\n\021ServiceStatusEnum\022\033\n\027SERVICE" + - "STATUS_UNDEFINED\020\000\022\031\n\025SERVICESTATUS_PLAN" + - "NED\020\001\022\030\n\024SERVICESTATUS_ACTIVE\020\002\022!\n\035SERVI" + - "CESTATUS_PENDING_REMOVAL\020\003*]\n\020ConfigActi" + - "onEnum\022\032\n\026CONFIGACTION_UNDEFINED\020\000\022\024\n\020CO" + - "NFIGACTION_SET\020\001\022\027\n\023CONFIGACTION_DELETE\020" + - "\0022\255\020\n\016ContextService\022:\n\016ListContextIds\022\016" + - ".context.Empty\032\026.context.ContextIdList\"\000" + - "\0226\n\014ListContexts\022\016.context.Empty\032\024.conte" + - "xt.ContextList\"\000\0224\n\nGetContext\022\022.context" + - ".ContextId\032\020.context.Context\"\000\0224\n\nSetCon" + - "text\022\020.context.Context\032\022.context.Context" + - "Id\"\000\0225\n\rRemoveContext\022\022.context.ContextI" + - "d\032\016.context.Empty\"\000\022=\n\020GetContextEvents\022" + - "\016.context.Empty\032\025.context.ContextEvent\"\000" + - "0\001\022@\n\017ListTopologyIds\022\022.context.ContextI" + - "d\032\027.context.TopologyIdList\"\000\022=\n\016ListTopo" + - "logies\022\022.context.ContextId\032\025.context.Top" + - "ologyList\"\000\0227\n\013GetTopology\022\023.context.Top" + - "ologyId\032\021.context.Topology\"\000\0227\n\013SetTopol" + - "ogy\022\021.context.Topology\032\023.context.Topolog" + - "yId\"\000\0227\n\016RemoveTopology\022\023.context.Topolo" + - "gyId\032\016.context.Empty\"\000\022?\n\021GetTopologyEve" + - "nts\022\016.context.Empty\032\026.context.TopologyEv" + - "ent\"\0000\001\0228\n\rListDeviceIds\022\016.context.Empty" + - "\032\025.context.DeviceIdList\"\000\0224\n\013ListDevices" + - "\022\016.context.Empty\032\023.context.DeviceList\"\000\022" + - "1\n\tGetDevice\022\021.context.DeviceId\032\017.contex" + - "t.Device\"\000\0221\n\tSetDevice\022\017.context.Device" + - "\032\021.context.DeviceId\"\000\0223\n\014RemoveDevice\022\021." + - "context.DeviceId\032\016.context.Empty\"\000\022;\n\017Ge" + - "tDeviceEvents\022\016.context.Empty\032\024.context." + - "DeviceEvent\"\0000\001\0224\n\013ListLinkIds\022\016.context" + - ".Empty\032\023.context.LinkIdList\"\000\0220\n\tListLin" + - "ks\022\016.context.Empty\032\021.context.LinkList\"\000\022" + - "+\n\007GetLink\022\017.context.LinkId\032\r.context.Li" + - "nk\"\000\022+\n\007SetLink\022\r.context.Link\032\017.context" + - ".LinkId\"\000\022/\n\nRemoveLink\022\017.context.LinkId" + - "\032\016.context.Empty\"\000\0227\n\rGetLinkEvents\022\016.co" + - "ntext.Empty\032\022.context.LinkEvent\"\0000\001\022>\n\016L" + - "istServiceIds\022\022.context.ContextId\032\026.cont" + - "ext.ServiceIdList\"\000\022:\n\014ListServices\022\022.co" + - "ntext.ContextId\032\024.context.ServiceList\"\000\022" + - "4\n\nGetService\022\022.context.ServiceId\032\020.cont" + - "ext.Service\"\000\0224\n\nSetService\022\020.context.Se" + - "rvice\032\022.context.ServiceId\"\000\0225\n\rRemoveSer" + - "vice\022\022.context.ServiceId\032\016.context.Empty" + - "\"\000\022=\n\020GetServiceEvents\022\016.context.Empty\032\025" + - ".context.ServiceEvent\"\0000\001\022D\n\021ListConnect" + - "ionIds\022\022.context.ServiceId\032\031.context.Con" + - "nectionIdList\"\000\022@\n\017ListConnections\022\022.con" + - "text.ServiceId\032\027.context.ConnectionList\"" + - "\000\022=\n\rGetConnection\022\025.context.ConnectionI" + - "d\032\023.context.Connection\"\000\022=\n\rSetConnectio" + - "n\022\023.context.Connection\032\025.context.Connect" + - "ionId\"\000\022;\n\020RemoveConnection\022\025.context.Co" + - "nnectionId\032\016.context.Empty\"\000\022C\n\023GetConne" + - "ctionEvents\022\016.context.Empty\032\030.context.Co" + - "nnectionEvent\"\0000\001b\006proto3" + "Id\"T\n\007SliceId\022&\n\ncontext_id\030\001 \001(\0132\022.cont" + + "ext.ContextId\022!\n\nslice_uuid\030\002 \001(\0132\r.cont" + + "ext.Uuid\"\225\002\n\005Slice\022\"\n\010slice_id\030\001 \001(\0132\020.c" + + "ontext.SliceId\022/\n\022slice_endpoint_ids\030\002 \003" + + "(\0132\023.context.EndPointId\022.\n\021slice_constra" + + "ints\030\003 \003(\0132\023.context.Constraint\022-\n\021slice" + + "_service_ids\030\004 \003(\0132\022.context.ServiceId\022," + + "\n\022slice_subslice_ids\030\005 \003(\0132\020.context.Sli" + + "ceId\022*\n\014slice_status\030\006 \001(\0132\024.context.Sli" + + "ceStatus\"=\n\013SliceStatus\022.\n\014slice_status\030" + + "\001 \001(\0162\030.context.SliceStatusEnum\"2\n\013Slice" + + "IdList\022#\n\tslice_ids\030\001 \003(\0132\020.context.Slic" + + "eId\"+\n\tSliceList\022\036\n\006slices\030\001 \003(\0132\016.conte" + + "xt.Slice\"O\n\nSliceEvent\022\035\n\005event\030\001 \001(\0132\016." + + "context.Event\022\"\n\010slice_id\030\002 \001(\0132\020.contex" + + "t.SliceId\"6\n\014ConnectionId\022&\n\017connection_" + + "uuid\030\001 \001(\0132\r.context.Uuid\"\304\001\n\nConnection" + + "\022,\n\rconnection_id\030\001 \001(\0132\025.context.Connec" + + "tionId\022&\n\nservice_id\030\002 \001(\0132\022.context.Ser" + + "viceId\0223\n\026path_hops_endpoint_ids\030\003 \003(\0132\023" + + ".context.EndPointId\022+\n\017sub_service_ids\030\004" + + " \003(\0132\022.context.ServiceId\"A\n\020ConnectionId" + + "List\022-\n\016connection_ids\030\001 \003(\0132\025.context.C" + + "onnectionId\":\n\016ConnectionList\022(\n\013connect" + + "ions\030\001 \003(\0132\023.context.Connection\"^\n\017Conne" + + "ctionEvent\022\035\n\005event\030\001 \001(\0132\016.context.Even" + + "t\022,\n\rconnection_id\030\002 \001(\0132\025.context.Conne" + + "ctionId\"\202\001\n\nEndPointId\022(\n\013topology_id\030\001 " + + "\001(\0132\023.context.TopologyId\022$\n\tdevice_id\030\002 " + + "\001(\0132\021.context.DeviceId\022$\n\rendpoint_uuid\030" + + "\003 \001(\0132\r.context.Uuid\"\206\001\n\010EndPoint\022(\n\013end" + + "point_id\030\001 \001(\0132\023.context.EndPointId\022\025\n\re" + + "ndpoint_type\030\002 \001(\t\0229\n\020kpi_sample_types\030\003" + + " \003(\0162\037.kpi_sample_types.KpiSampleType\"e\n" + + "\nConfigRule\022)\n\006action\030\001 \001(\0162\031.context.Co" + + "nfigActionEnum\022\024\n\014resource_key\030\002 \001(\t\022\026\n\016" + + "resource_value\030\003 \001(\t\"?\n\nConstraint\022\027\n\017co" + + "nstraint_type\030\001 \001(\t\022\030\n\020constraint_value\030" + + "\002 \001(\t\"^\n\022TeraFlowController\022&\n\ncontext_i" + + "d\030\001 \001(\0132\022.context.ContextId\022\022\n\nip_addres" + + "s\030\002 \001(\t\022\014\n\004port\030\003 \001(\r\"U\n\024AuthenticationR" + + "esult\022&\n\ncontext_id\030\001 \001(\0132\022.context.Cont" + + "extId\022\025\n\rauthenticated\030\002 \001(\010*j\n\rEventTyp" + + "eEnum\022\027\n\023EVENTTYPE_UNDEFINED\020\000\022\024\n\020EVENTT" + + "YPE_CREATE\020\001\022\024\n\020EVENTTYPE_UPDATE\020\002\022\024\n\020EV" + + "ENTTYPE_REMOVE\020\003*\305\001\n\020DeviceDriverEnum\022\032\n" + + "\026DEVICEDRIVER_UNDEFINED\020\000\022\033\n\027DEVICEDRIVE" + + "R_OPENCONFIG\020\001\022\036\n\032DEVICEDRIVER_TRANSPORT" + + "_API\020\002\022\023\n\017DEVICEDRIVER_P4\020\003\022&\n\"DEVICEDRI" + + "VER_IETF_NETWORK_TOPOLOGY\020\004\022\033\n\027DEVICEDRI" + + "VER_ONF_TR_352\020\005*\217\001\n\033DeviceOperationalSt" + + "atusEnum\022%\n!DEVICEOPERATIONALSTATUS_UNDE" + + "FINED\020\000\022$\n DEVICEOPERATIONALSTATUS_DISAB" + + "LED\020\001\022#\n\037DEVICEOPERATIONALSTATUS_ENABLED" + + "\020\002*\201\001\n\017ServiceTypeEnum\022\027\n\023SERVICETYPE_UN" + + "KNOWN\020\000\022\024\n\020SERVICETYPE_L3NM\020\001\022\024\n\020SERVICE" + + "TYPE_L2NM\020\002\022)\n%SERVICETYPE_TAPI_CONNECTI" + + "VITY_SERVICE\020\003*\210\001\n\021ServiceStatusEnum\022\033\n\027" + + "SERVICESTATUS_UNDEFINED\020\000\022\031\n\025SERVICESTAT" + + "US_PLANNED\020\001\022\030\n\024SERVICESTATUS_ACTIVE\020\002\022!" + + "\n\035SERVICESTATUS_PENDING_REMOVAL\020\003*\213\001\n\017Sl" + + "iceStatusEnum\022\031\n\025SLICESTATUS_UNDEFINED\020\000" + + "\022\027\n\023SLICESTATUS_PLANNED\020\001\022\024\n\020SLICESTATUS" + + "_INIT\020\002\022\026\n\022SLICESTATUS_ACTIVE\020\003\022\026\n\022SLICE" + + "STATUS_DEINIT\020\004*]\n\020ConfigActionEnum\022\032\n\026C" + + "ONFIGACTION_UNDEFINED\020\000\022\024\n\020CONFIGACTION_" + + "SET\020\001\022\027\n\023CONFIGACTION_DELETE\020\0022\357\022\n\016Conte" + + "xtService\022:\n\016ListContextIds\022\016.context.Em" + + "pty\032\026.context.ContextIdList\"\000\0226\n\014ListCon" + + "texts\022\016.context.Empty\032\024.context.ContextL" + + "ist\"\000\0224\n\nGetContext\022\022.context.ContextId\032" + + "\020.context.Context\"\000\0224\n\nSetContext\022\020.cont" + + "ext.Context\032\022.context.ContextId\"\000\0225\n\rRem" + + "oveContext\022\022.context.ContextId\032\016.context" + + ".Empty\"\000\022=\n\020GetContextEvents\022\016.context.E" + + "mpty\032\025.context.ContextEvent\"\0000\001\022@\n\017ListT" + + "opologyIds\022\022.context.ContextId\032\027.context" + + ".TopologyIdList\"\000\022=\n\016ListTopologies\022\022.co" + + "ntext.ContextId\032\025.context.TopologyList\"\000" + + "\0227\n\013GetTopology\022\023.context.TopologyId\032\021.c" + + "ontext.Topology\"\000\0227\n\013SetTopology\022\021.conte" + + "xt.Topology\032\023.context.TopologyId\"\000\0227\n\016Re" + + "moveTopology\022\023.context.TopologyId\032\016.cont" + + "ext.Empty\"\000\022?\n\021GetTopologyEvents\022\016.conte" + + "xt.Empty\032\026.context.TopologyEvent\"\0000\001\0228\n\r" + + "ListDeviceIds\022\016.context.Empty\032\025.context." + + "DeviceIdList\"\000\0224\n\013ListDevices\022\016.context." + + "Empty\032\023.context.DeviceList\"\000\0221\n\tGetDevic" + + "e\022\021.context.DeviceId\032\017.context.Device\"\000\022" + + "1\n\tSetDevice\022\017.context.Device\032\021.context." + + "DeviceId\"\000\0223\n\014RemoveDevice\022\021.context.Dev" + + "iceId\032\016.context.Empty\"\000\022;\n\017GetDeviceEven" + + "ts\022\016.context.Empty\032\024.context.DeviceEvent" + + "\"\0000\001\0224\n\013ListLinkIds\022\016.context.Empty\032\023.co" + + "ntext.LinkIdList\"\000\0220\n\tListLinks\022\016.contex" + + "t.Empty\032\021.context.LinkList\"\000\022+\n\007GetLink\022" + + "\017.context.LinkId\032\r.context.Link\"\000\022+\n\007Set" + + "Link\022\r.context.Link\032\017.context.LinkId\"\000\022/" + + "\n\nRemoveLink\022\017.context.LinkId\032\016.context." + + "Empty\"\000\0227\n\rGetLinkEvents\022\016.context.Empty" + + "\032\022.context.LinkEvent\"\0000\001\022>\n\016ListServiceI" + + "ds\022\022.context.ContextId\032\026.context.Service" + + "IdList\"\000\022:\n\014ListServices\022\022.context.Conte" + + "xtId\032\024.context.ServiceList\"\000\0224\n\nGetServi" + + "ce\022\022.context.ServiceId\032\020.context.Service" + + "\"\000\0224\n\nSetService\022\020.context.Service\032\022.con" + + "text.ServiceId\"\000\0225\n\rRemoveService\022\022.cont" + + "ext.ServiceId\032\016.context.Empty\"\000\022=\n\020GetSe" + + "rviceEvents\022\016.context.Empty\032\025.context.Se" + + "rviceEvent\"\0000\001\022:\n\014ListSliceIds\022\022.context" + + ".ContextId\032\024.context.SliceIdList\"\000\0226\n\nLi" + + "stSlices\022\022.context.ContextId\032\022.context.S" + + "liceList\"\000\022.\n\010GetSlice\022\020.context.SliceId" + + "\032\016.context.Slice\"\000\022.\n\010SetSlice\022\016.context" + + ".Slice\032\020.context.SliceId\"\000\0221\n\013RemoveSlic" + + "e\022\020.context.SliceId\032\016.context.Empty\"\000\0229\n" + + "\016GetSliceEvents\022\016.context.Empty\032\023.contex" + + "t.SliceEvent\"\0000\001\022D\n\021ListConnectionIds\022\022." + + "context.ServiceId\032\031.context.ConnectionId" + + "List\"\000\022@\n\017ListConnections\022\022.context.Serv" + + "iceId\032\027.context.ConnectionList\"\000\022=\n\rGetC" + + "onnection\022\025.context.ConnectionId\032\023.conte" + + "xt.Connection\"\000\022=\n\rSetConnection\022\023.conte" + + "xt.Connection\032\025.context.ConnectionId\"\000\022;" + + "\n\020RemoveConnection\022\025.context.ConnectionI" + + "d\032\016.context.Empty\"\000\022C\n\023GetConnectionEven" + + "ts\022\016.context.Empty\032\030.context.ConnectionE" + + "vent\"\0000\001b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -38037,68 +44311,104 @@ public final class ContextOuterClass { com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_ServiceEvent_descriptor, new java.lang.String[] { "Event", "ServiceId", }); - internal_static_context_ConnectionId_descriptor = + internal_static_context_SliceId_descriptor = getDescriptor().getMessageTypes().get(31); + internal_static_context_SliceId_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_context_SliceId_descriptor, + new java.lang.String[] { "ContextId", "SliceUuid", }); + internal_static_context_Slice_descriptor = + getDescriptor().getMessageTypes().get(32); + internal_static_context_Slice_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_context_Slice_descriptor, + new java.lang.String[] { "SliceId", "SliceEndpointIds", "SliceConstraints", "SliceServiceIds", "SliceSubsliceIds", "SliceStatus", }); + internal_static_context_SliceStatus_descriptor = + getDescriptor().getMessageTypes().get(33); + internal_static_context_SliceStatus_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_context_SliceStatus_descriptor, + new java.lang.String[] { "SliceStatus", }); + internal_static_context_SliceIdList_descriptor = + getDescriptor().getMessageTypes().get(34); + internal_static_context_SliceIdList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_context_SliceIdList_descriptor, + new java.lang.String[] { "SliceIds", }); + internal_static_context_SliceList_descriptor = + getDescriptor().getMessageTypes().get(35); + internal_static_context_SliceList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_context_SliceList_descriptor, + new java.lang.String[] { "Slices", }); + internal_static_context_SliceEvent_descriptor = + getDescriptor().getMessageTypes().get(36); + internal_static_context_SliceEvent_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_context_SliceEvent_descriptor, + new java.lang.String[] { "Event", "SliceId", }); + internal_static_context_ConnectionId_descriptor = + getDescriptor().getMessageTypes().get(37); internal_static_context_ConnectionId_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_ConnectionId_descriptor, new java.lang.String[] { "ConnectionUuid", }); internal_static_context_Connection_descriptor = - getDescriptor().getMessageTypes().get(32); + getDescriptor().getMessageTypes().get(38); internal_static_context_Connection_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_Connection_descriptor, new java.lang.String[] { "ConnectionId", "ServiceId", "PathHopsEndpointIds", "SubServiceIds", }); internal_static_context_ConnectionIdList_descriptor = - getDescriptor().getMessageTypes().get(33); + getDescriptor().getMessageTypes().get(39); internal_static_context_ConnectionIdList_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_ConnectionIdList_descriptor, new java.lang.String[] { "ConnectionIds", }); internal_static_context_ConnectionList_descriptor = - getDescriptor().getMessageTypes().get(34); + getDescriptor().getMessageTypes().get(40); internal_static_context_ConnectionList_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_ConnectionList_descriptor, new java.lang.String[] { "Connections", }); internal_static_context_ConnectionEvent_descriptor = - getDescriptor().getMessageTypes().get(35); + getDescriptor().getMessageTypes().get(41); internal_static_context_ConnectionEvent_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_ConnectionEvent_descriptor, new java.lang.String[] { "Event", "ConnectionId", }); internal_static_context_EndPointId_descriptor = - getDescriptor().getMessageTypes().get(36); + getDescriptor().getMessageTypes().get(42); internal_static_context_EndPointId_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_EndPointId_descriptor, new java.lang.String[] { "TopologyId", "DeviceId", "EndpointUuid", }); internal_static_context_EndPoint_descriptor = - getDescriptor().getMessageTypes().get(37); + getDescriptor().getMessageTypes().get(43); internal_static_context_EndPoint_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_EndPoint_descriptor, new java.lang.String[] { "EndpointId", "EndpointType", "KpiSampleTypes", }); internal_static_context_ConfigRule_descriptor = - getDescriptor().getMessageTypes().get(38); + getDescriptor().getMessageTypes().get(44); internal_static_context_ConfigRule_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_ConfigRule_descriptor, new java.lang.String[] { "Action", "ResourceKey", "ResourceValue", }); internal_static_context_Constraint_descriptor = - getDescriptor().getMessageTypes().get(39); + getDescriptor().getMessageTypes().get(45); internal_static_context_Constraint_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_Constraint_descriptor, new java.lang.String[] { "ConstraintType", "ConstraintValue", }); internal_static_context_TeraFlowController_descriptor = - getDescriptor().getMessageTypes().get(40); + getDescriptor().getMessageTypes().get(46); internal_static_context_TeraFlowController_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_TeraFlowController_descriptor, new java.lang.String[] { "ContextId", "IpAddress", "Port", }); internal_static_context_AuthenticationResult_descriptor = - getDescriptor().getMessageTypes().get(41); + getDescriptor().getMessageTypes().get(47); internal_static_context_AuthenticationResult_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_context_AuthenticationResult_descriptor, diff --git a/src/policy/target/generated-sources/grpc/context/ContextService.java b/src/policy/target/generated-sources/grpc/context/ContextService.java index cbd51163f340212839e0eeb2ad096032fdba8109..d54c56057ca53e40071490d3b9aa313a13a77665 100644 --- a/src/policy/target/generated-sources/grpc/context/ContextService.java +++ b/src/policy/target/generated-sources/grpc/context/ContextService.java @@ -58,6 +58,16 @@ public interface ContextService extends MutinyService { io.smallrye.mutiny.Uni<context.ContextOuterClass.Empty> removeService(context.ContextOuterClass.ServiceId request); + io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceIdList> listSliceIds(context.ContextOuterClass.ContextId request); + + io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceList> listSlices(context.ContextOuterClass.ContextId request); + + io.smallrye.mutiny.Uni<context.ContextOuterClass.Slice> getSlice(context.ContextOuterClass.SliceId request); + + io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceId> setSlice(context.ContextOuterClass.Slice request); + + io.smallrye.mutiny.Uni<context.ContextOuterClass.Empty> removeSlice(context.ContextOuterClass.SliceId request); + io.smallrye.mutiny.Uni<context.ContextOuterClass.ConnectionIdList> listConnectionIds(context.ContextOuterClass.ServiceId request); io.smallrye.mutiny.Uni<context.ContextOuterClass.ConnectionList> listConnections(context.ContextOuterClass.ServiceId request); @@ -79,6 +89,8 @@ public interface ContextService extends MutinyService { io.smallrye.mutiny.Multi<context.ContextOuterClass.ServiceEvent> getServiceEvents(context.ContextOuterClass.Empty request); + io.smallrye.mutiny.Multi<context.ContextOuterClass.SliceEvent> getSliceEvents(context.ContextOuterClass.Empty request); + io.smallrye.mutiny.Multi<context.ContextOuterClass.ConnectionEvent> getConnectionEvents(context.ContextOuterClass.Empty request); diff --git a/src/policy/target/generated-sources/grpc/context/ContextServiceBean.java b/src/policy/target/generated-sources/grpc/context/ContextServiceBean.java index 6900cf3c8a09ad6e3df1aaf2cc403c32490d3289..f552294b8e6d645af41cc30632ae0432504bbc67 100644 --- a/src/policy/target/generated-sources/grpc/context/ContextServiceBean.java +++ b/src/policy/target/generated-sources/grpc/context/ContextServiceBean.java @@ -216,6 +216,46 @@ public class ContextServiceBean extends MutinyContextServiceGrpc.ContextServiceI } } @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceIdList> listSliceIds(context.ContextOuterClass.ContextId request) { + try { + return delegate.listSliceIds(request); + } catch (UnsupportedOperationException e) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceList> listSlices(context.ContextOuterClass.ContextId request) { + try { + return delegate.listSlices(request); + } catch (UnsupportedOperationException e) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Slice> getSlice(context.ContextOuterClass.SliceId request) { + try { + return delegate.getSlice(request); + } catch (UnsupportedOperationException e) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceId> setSlice(context.ContextOuterClass.Slice request) { + try { + return delegate.setSlice(request); + } catch (UnsupportedOperationException e) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Empty> removeSlice(context.ContextOuterClass.SliceId request) { + try { + return delegate.removeSlice(request); + } catch (UnsupportedOperationException e) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + } + @Override public io.smallrye.mutiny.Uni<context.ContextOuterClass.ConnectionIdList> listConnectionIds(context.ContextOuterClass.ServiceId request) { try { return delegate.listConnectionIds(request); @@ -301,6 +341,15 @@ public class ContextServiceBean extends MutinyContextServiceGrpc.ContextServiceI } } + @Override + public io.smallrye.mutiny.Multi<context.ContextOuterClass.SliceEvent> getSliceEvents(context.ContextOuterClass.Empty request) { + try { + return delegate.getSliceEvents(request); + } catch (UnsupportedOperationException e) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + } + @Override public io.smallrye.mutiny.Multi<context.ContextOuterClass.ConnectionEvent> getConnectionEvents(context.ContextOuterClass.Empty request) { try { diff --git a/src/policy/target/generated-sources/grpc/context/ContextServiceClient.java b/src/policy/target/generated-sources/grpc/context/ContextServiceClient.java index a3d74cb7dfce2b3ffd259570a6dc65699f85f0cc..c6493bd4d381967238e5eb87dd717f679d028526 100644 --- a/src/policy/target/generated-sources/grpc/context/ContextServiceClient.java +++ b/src/policy/target/generated-sources/grpc/context/ContextServiceClient.java @@ -121,6 +121,26 @@ public class ContextServiceClient implements ContextService, MutinyClient<Mutiny return stub.removeService(request); } @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceIdList> listSliceIds(context.ContextOuterClass.ContextId request) { + return stub.listSliceIds(request); + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceList> listSlices(context.ContextOuterClass.ContextId request) { + return stub.listSlices(request); + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Slice> getSlice(context.ContextOuterClass.SliceId request) { + return stub.getSlice(request); + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceId> setSlice(context.ContextOuterClass.Slice request) { + return stub.setSlice(request); + } + @Override + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Empty> removeSlice(context.ContextOuterClass.SliceId request) { + return stub.removeSlice(request); + } + @Override public io.smallrye.mutiny.Uni<context.ContextOuterClass.ConnectionIdList> listConnectionIds(context.ContextOuterClass.ServiceId request) { return stub.listConnectionIds(request); } @@ -166,6 +186,11 @@ public class ContextServiceClient implements ContextService, MutinyClient<Mutiny return stub.getServiceEvents(request); } + @Override + public io.smallrye.mutiny.Multi<context.ContextOuterClass.SliceEvent> getSliceEvents(context.ContextOuterClass.Empty request) { + return stub.getSliceEvents(request); + } + @Override public io.smallrye.mutiny.Multi<context.ContextOuterClass.ConnectionEvent> getConnectionEvents(context.ContextOuterClass.Empty request) { return stub.getConnectionEvents(request); diff --git a/src/policy/target/generated-sources/grpc/context/ContextServiceGrpc.java b/src/policy/target/generated-sources/grpc/context/ContextServiceGrpc.java index be9f381ffee96febd202beb540bce862c1347378..be720c127439e50f68c2518332f85f750d6579ee 100644 --- a/src/policy/target/generated-sources/grpc/context/ContextServiceGrpc.java +++ b/src/policy/target/generated-sources/grpc/context/ContextServiceGrpc.java @@ -944,6 +944,192 @@ public final class ContextServiceGrpc { return getGetServiceEventsMethod; } + private static volatile io.grpc.MethodDescriptor<context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceIdList> getListSliceIdsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListSliceIds", + requestType = context.ContextOuterClass.ContextId.class, + responseType = context.ContextOuterClass.SliceIdList.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor<context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceIdList> getListSliceIdsMethod() { + io.grpc.MethodDescriptor<context.ContextOuterClass.ContextId, context.ContextOuterClass.SliceIdList> getListSliceIdsMethod; + if ((getListSliceIdsMethod = ContextServiceGrpc.getListSliceIdsMethod) == null) { + synchronized (ContextServiceGrpc.class) { + if ((getListSliceIdsMethod = ContextServiceGrpc.getListSliceIdsMethod) == null) { + ContextServiceGrpc.getListSliceIdsMethod = getListSliceIdsMethod = + io.grpc.MethodDescriptor.<context.ContextOuterClass.ContextId, context.ContextOuterClass.SliceIdList>newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListSliceIds")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.ContextId.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.SliceIdList.getDefaultInstance())) + .setSchemaDescriptor(new ContextServiceMethodDescriptorSupplier("ListSliceIds")) + .build(); + } + } + } + return getListSliceIdsMethod; + } + + private static volatile io.grpc.MethodDescriptor<context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceList> getListSlicesMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListSlices", + requestType = context.ContextOuterClass.ContextId.class, + responseType = context.ContextOuterClass.SliceList.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor<context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceList> getListSlicesMethod() { + io.grpc.MethodDescriptor<context.ContextOuterClass.ContextId, context.ContextOuterClass.SliceList> getListSlicesMethod; + if ((getListSlicesMethod = ContextServiceGrpc.getListSlicesMethod) == null) { + synchronized (ContextServiceGrpc.class) { + if ((getListSlicesMethod = ContextServiceGrpc.getListSlicesMethod) == null) { + ContextServiceGrpc.getListSlicesMethod = getListSlicesMethod = + io.grpc.MethodDescriptor.<context.ContextOuterClass.ContextId, context.ContextOuterClass.SliceList>newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListSlices")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.ContextId.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.SliceList.getDefaultInstance())) + .setSchemaDescriptor(new ContextServiceMethodDescriptorSupplier("ListSlices")) + .build(); + } + } + } + return getListSlicesMethod; + } + + private static volatile io.grpc.MethodDescriptor<context.ContextOuterClass.SliceId, + context.ContextOuterClass.Slice> getGetSliceMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetSlice", + requestType = context.ContextOuterClass.SliceId.class, + responseType = context.ContextOuterClass.Slice.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor<context.ContextOuterClass.SliceId, + context.ContextOuterClass.Slice> getGetSliceMethod() { + io.grpc.MethodDescriptor<context.ContextOuterClass.SliceId, context.ContextOuterClass.Slice> getGetSliceMethod; + if ((getGetSliceMethod = ContextServiceGrpc.getGetSliceMethod) == null) { + synchronized (ContextServiceGrpc.class) { + if ((getGetSliceMethod = ContextServiceGrpc.getGetSliceMethod) == null) { + ContextServiceGrpc.getGetSliceMethod = getGetSliceMethod = + io.grpc.MethodDescriptor.<context.ContextOuterClass.SliceId, context.ContextOuterClass.Slice>newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetSlice")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.SliceId.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.Slice.getDefaultInstance())) + .setSchemaDescriptor(new ContextServiceMethodDescriptorSupplier("GetSlice")) + .build(); + } + } + } + return getGetSliceMethod; + } + + private static volatile io.grpc.MethodDescriptor<context.ContextOuterClass.Slice, + context.ContextOuterClass.SliceId> getSetSliceMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "SetSlice", + requestType = context.ContextOuterClass.Slice.class, + responseType = context.ContextOuterClass.SliceId.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor<context.ContextOuterClass.Slice, + context.ContextOuterClass.SliceId> getSetSliceMethod() { + io.grpc.MethodDescriptor<context.ContextOuterClass.Slice, context.ContextOuterClass.SliceId> getSetSliceMethod; + if ((getSetSliceMethod = ContextServiceGrpc.getSetSliceMethod) == null) { + synchronized (ContextServiceGrpc.class) { + if ((getSetSliceMethod = ContextServiceGrpc.getSetSliceMethod) == null) { + ContextServiceGrpc.getSetSliceMethod = getSetSliceMethod = + io.grpc.MethodDescriptor.<context.ContextOuterClass.Slice, context.ContextOuterClass.SliceId>newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "SetSlice")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.Slice.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.SliceId.getDefaultInstance())) + .setSchemaDescriptor(new ContextServiceMethodDescriptorSupplier("SetSlice")) + .build(); + } + } + } + return getSetSliceMethod; + } + + private static volatile io.grpc.MethodDescriptor<context.ContextOuterClass.SliceId, + context.ContextOuterClass.Empty> getRemoveSliceMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "RemoveSlice", + requestType = context.ContextOuterClass.SliceId.class, + responseType = context.ContextOuterClass.Empty.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor<context.ContextOuterClass.SliceId, + context.ContextOuterClass.Empty> getRemoveSliceMethod() { + io.grpc.MethodDescriptor<context.ContextOuterClass.SliceId, context.ContextOuterClass.Empty> getRemoveSliceMethod; + if ((getRemoveSliceMethod = ContextServiceGrpc.getRemoveSliceMethod) == null) { + synchronized (ContextServiceGrpc.class) { + if ((getRemoveSliceMethod = ContextServiceGrpc.getRemoveSliceMethod) == null) { + ContextServiceGrpc.getRemoveSliceMethod = getRemoveSliceMethod = + io.grpc.MethodDescriptor.<context.ContextOuterClass.SliceId, context.ContextOuterClass.Empty>newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "RemoveSlice")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.SliceId.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.Empty.getDefaultInstance())) + .setSchemaDescriptor(new ContextServiceMethodDescriptorSupplier("RemoveSlice")) + .build(); + } + } + } + return getRemoveSliceMethod; + } + + private static volatile io.grpc.MethodDescriptor<context.ContextOuterClass.Empty, + context.ContextOuterClass.SliceEvent> getGetSliceEventsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetSliceEvents", + requestType = context.ContextOuterClass.Empty.class, + responseType = context.ContextOuterClass.SliceEvent.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor<context.ContextOuterClass.Empty, + context.ContextOuterClass.SliceEvent> getGetSliceEventsMethod() { + io.grpc.MethodDescriptor<context.ContextOuterClass.Empty, context.ContextOuterClass.SliceEvent> getGetSliceEventsMethod; + if ((getGetSliceEventsMethod = ContextServiceGrpc.getGetSliceEventsMethod) == null) { + synchronized (ContextServiceGrpc.class) { + if ((getGetSliceEventsMethod = ContextServiceGrpc.getGetSliceEventsMethod) == null) { + ContextServiceGrpc.getGetSliceEventsMethod = getGetSliceEventsMethod = + io.grpc.MethodDescriptor.<context.ContextOuterClass.Empty, context.ContextOuterClass.SliceEvent>newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetSliceEvents")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.Empty.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + context.ContextOuterClass.SliceEvent.getDefaultInstance())) + .setSchemaDescriptor(new ContextServiceMethodDescriptorSupplier("GetSliceEvents")) + .build(); + } + } + } + return getGetSliceEventsMethod; + } + private static volatile io.grpc.MethodDescriptor<context.ContextOuterClass.ServiceId, context.ContextOuterClass.ConnectionIdList> getListConnectionIdsMethod; @@ -1388,6 +1574,48 @@ public final class ContextServiceGrpc { io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetServiceEventsMethod(), responseObserver); } + /** + */ + public void listSliceIds(context.ContextOuterClass.ContextId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceIdList> responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getListSliceIdsMethod(), responseObserver); + } + + /** + */ + public void listSlices(context.ContextOuterClass.ContextId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceList> responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getListSlicesMethod(), responseObserver); + } + + /** + */ + public void getSlice(context.ContextOuterClass.SliceId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.Slice> responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetSliceMethod(), responseObserver); + } + + /** + */ + public void setSlice(context.ContextOuterClass.Slice request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceId> responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getSetSliceMethod(), responseObserver); + } + + /** + */ + public void removeSlice(context.ContextOuterClass.SliceId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.Empty> responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getRemoveSliceMethod(), responseObserver); + } + + /** + */ + public void getSliceEvents(context.ContextOuterClass.Empty request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceEvent> responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetSliceEventsMethod(), responseObserver); + } + /** */ public void listConnectionIds(context.ContextOuterClass.ServiceId request, @@ -1642,6 +1870,48 @@ public final class ContextServiceGrpc { context.ContextOuterClass.Empty, context.ContextOuterClass.ServiceEvent>( this, METHODID_GET_SERVICE_EVENTS))) + .addMethod( + getListSliceIdsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceIdList>( + this, METHODID_LIST_SLICE_IDS))) + .addMethod( + getListSlicesMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceList>( + this, METHODID_LIST_SLICES))) + .addMethod( + getGetSliceMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.SliceId, + context.ContextOuterClass.Slice>( + this, METHODID_GET_SLICE))) + .addMethod( + getSetSliceMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.Slice, + context.ContextOuterClass.SliceId>( + this, METHODID_SET_SLICE))) + .addMethod( + getRemoveSliceMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.SliceId, + context.ContextOuterClass.Empty>( + this, METHODID_REMOVE_SLICE))) + .addMethod( + getGetSliceEventsMethod(), + io.grpc.stub.ServerCalls.asyncServerStreamingCall( + new MethodHandlers< + context.ContextOuterClass.Empty, + context.ContextOuterClass.SliceEvent>( + this, METHODID_GET_SLICE_EVENTS))) .addMethod( getListConnectionIdsMethod(), io.grpc.stub.ServerCalls.asyncUnaryCall( @@ -1942,6 +2212,54 @@ public final class ContextServiceGrpc { getChannel().newCall(getGetServiceEventsMethod(), getCallOptions()), request, responseObserver); } + /** + */ + public void listSliceIds(context.ContextOuterClass.ContextId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceIdList> responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListSliceIdsMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void listSlices(context.ContextOuterClass.ContextId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceList> responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListSlicesMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getSlice(context.ContextOuterClass.SliceId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.Slice> responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetSliceMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void setSlice(context.ContextOuterClass.Slice request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceId> responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getSetSliceMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void removeSlice(context.ContextOuterClass.SliceId request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.Empty> responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getRemoveSliceMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getSliceEvents(context.ContextOuterClass.Empty request, + io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceEvent> responseObserver) { + io.grpc.stub.ClientCalls.asyncServerStreamingCall( + getChannel().newCall(getGetSliceEventsMethod(), getCallOptions()), request, responseObserver); + } + /** */ public void listConnectionIds(context.ContextOuterClass.ServiceId request, @@ -2220,6 +2538,49 @@ public final class ContextServiceGrpc { getChannel(), getGetServiceEventsMethod(), getCallOptions(), request); } + /** + */ + public context.ContextOuterClass.SliceIdList listSliceIds(context.ContextOuterClass.ContextId request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListSliceIdsMethod(), getCallOptions(), request); + } + + /** + */ + public context.ContextOuterClass.SliceList listSlices(context.ContextOuterClass.ContextId request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListSlicesMethod(), getCallOptions(), request); + } + + /** + */ + public context.ContextOuterClass.Slice getSlice(context.ContextOuterClass.SliceId request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetSliceMethod(), getCallOptions(), request); + } + + /** + */ + public context.ContextOuterClass.SliceId setSlice(context.ContextOuterClass.Slice request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getSetSliceMethod(), getCallOptions(), request); + } + + /** + */ + public context.ContextOuterClass.Empty removeSlice(context.ContextOuterClass.SliceId request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getRemoveSliceMethod(), getCallOptions(), request); + } + + /** + */ + public java.util.Iterator<context.ContextOuterClass.SliceEvent> getSliceEvents( + context.ContextOuterClass.Empty request) { + return io.grpc.stub.ClientCalls.blockingServerStreamingCall( + getChannel(), getGetSliceEventsMethod(), getCallOptions(), request); + } + /** */ public context.ContextOuterClass.ConnectionIdList listConnectionIds(context.ContextOuterClass.ServiceId request) { @@ -2478,6 +2839,46 @@ public final class ContextServiceGrpc { getChannel().newCall(getRemoveServiceMethod(), getCallOptions()), request); } + /** + */ + public com.google.common.util.concurrent.ListenableFuture<context.ContextOuterClass.SliceIdList> listSliceIds( + context.ContextOuterClass.ContextId request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListSliceIdsMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture<context.ContextOuterClass.SliceList> listSlices( + context.ContextOuterClass.ContextId request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListSlicesMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture<context.ContextOuterClass.Slice> getSlice( + context.ContextOuterClass.SliceId request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetSliceMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture<context.ContextOuterClass.SliceId> setSlice( + context.ContextOuterClass.Slice request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getSetSliceMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture<context.ContextOuterClass.Empty> removeSlice( + context.ContextOuterClass.SliceId request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getRemoveSliceMethod(), getCallOptions()), request); + } + /** */ public com.google.common.util.concurrent.ListenableFuture<context.ContextOuterClass.ConnectionIdList> listConnectionIds( @@ -2549,12 +2950,18 @@ public final class ContextServiceGrpc { private static final int METHODID_SET_SERVICE = 27; private static final int METHODID_REMOVE_SERVICE = 28; private static final int METHODID_GET_SERVICE_EVENTS = 29; - private static final int METHODID_LIST_CONNECTION_IDS = 30; - private static final int METHODID_LIST_CONNECTIONS = 31; - private static final int METHODID_GET_CONNECTION = 32; - private static final int METHODID_SET_CONNECTION = 33; - private static final int METHODID_REMOVE_CONNECTION = 34; - private static final int METHODID_GET_CONNECTION_EVENTS = 35; + private static final int METHODID_LIST_SLICE_IDS = 30; + private static final int METHODID_LIST_SLICES = 31; + private static final int METHODID_GET_SLICE = 32; + private static final int METHODID_SET_SLICE = 33; + private static final int METHODID_REMOVE_SLICE = 34; + private static final int METHODID_GET_SLICE_EVENTS = 35; + private static final int METHODID_LIST_CONNECTION_IDS = 36; + private static final int METHODID_LIST_CONNECTIONS = 37; + private static final int METHODID_GET_CONNECTION = 38; + private static final int METHODID_SET_CONNECTION = 39; + private static final int METHODID_REMOVE_CONNECTION = 40; + private static final int METHODID_GET_CONNECTION_EVENTS = 41; private static final class MethodHandlers<Req, Resp> implements io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>, @@ -2693,6 +3100,30 @@ public final class ContextServiceGrpc { serviceImpl.getServiceEvents((context.ContextOuterClass.Empty) request, (io.grpc.stub.StreamObserver<context.ContextOuterClass.ServiceEvent>) responseObserver); break; + case METHODID_LIST_SLICE_IDS: + serviceImpl.listSliceIds((context.ContextOuterClass.ContextId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceIdList>) responseObserver); + break; + case METHODID_LIST_SLICES: + serviceImpl.listSlices((context.ContextOuterClass.ContextId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceList>) responseObserver); + break; + case METHODID_GET_SLICE: + serviceImpl.getSlice((context.ContextOuterClass.SliceId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.Slice>) responseObserver); + break; + case METHODID_SET_SLICE: + serviceImpl.setSlice((context.ContextOuterClass.Slice) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceId>) responseObserver); + break; + case METHODID_REMOVE_SLICE: + serviceImpl.removeSlice((context.ContextOuterClass.SliceId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.Empty>) responseObserver); + break; + case METHODID_GET_SLICE_EVENTS: + serviceImpl.getSliceEvents((context.ContextOuterClass.Empty) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceEvent>) responseObserver); + break; case METHODID_LIST_CONNECTION_IDS: serviceImpl.listConnectionIds((context.ContextOuterClass.ServiceId) request, (io.grpc.stub.StreamObserver<context.ContextOuterClass.ConnectionIdList>) responseObserver); @@ -2808,6 +3239,12 @@ public final class ContextServiceGrpc { .addMethod(getSetServiceMethod()) .addMethod(getRemoveServiceMethod()) .addMethod(getGetServiceEventsMethod()) + .addMethod(getListSliceIdsMethod()) + .addMethod(getListSlicesMethod()) + .addMethod(getGetSliceMethod()) + .addMethod(getSetSliceMethod()) + .addMethod(getRemoveSliceMethod()) + .addMethod(getGetSliceEventsMethod()) .addMethod(getListConnectionIdsMethod()) .addMethod(getListConnectionsMethod()) .addMethod(getGetConnectionMethod()) diff --git a/src/policy/target/generated-sources/grpc/context/MutinyContextServiceGrpc.java b/src/policy/target/generated-sources/grpc/context/MutinyContextServiceGrpc.java index 85abba20a9f315f684f964d16db4ad0cd7e91299..9f71b53786e40922546dc59cfd4328040a40bd7c 100644 --- a/src/policy/target/generated-sources/grpc/context/MutinyContextServiceGrpc.java +++ b/src/policy/target/generated-sources/grpc/context/MutinyContextServiceGrpc.java @@ -161,6 +161,31 @@ public final class MutinyContextServiceGrpc implements io.quarkus.grpc.runtime.M } + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceIdList> listSliceIds(context.ContextOuterClass.ContextId request) { + return io.quarkus.grpc.runtime.ClientCalls.oneToOne(request, delegateStub::listSliceIds); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceList> listSlices(context.ContextOuterClass.ContextId request) { + return io.quarkus.grpc.runtime.ClientCalls.oneToOne(request, delegateStub::listSlices); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Slice> getSlice(context.ContextOuterClass.SliceId request) { + return io.quarkus.grpc.runtime.ClientCalls.oneToOne(request, delegateStub::getSlice); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceId> setSlice(context.ContextOuterClass.Slice request) { + return io.quarkus.grpc.runtime.ClientCalls.oneToOne(request, delegateStub::setSlice); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Empty> removeSlice(context.ContextOuterClass.SliceId request) { + return io.quarkus.grpc.runtime.ClientCalls.oneToOne(request, delegateStub::removeSlice); + } + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.ConnectionIdList> listConnectionIds(context.ContextOuterClass.ServiceId request) { return io.quarkus.grpc.runtime.ClientCalls.oneToOne(request, delegateStub::listConnectionIds); } @@ -211,6 +236,11 @@ public final class MutinyContextServiceGrpc implements io.quarkus.grpc.runtime.M } + public io.smallrye.mutiny.Multi<context.ContextOuterClass.SliceEvent> getSliceEvents(context.ContextOuterClass.Empty request) { + return io.quarkus.grpc.runtime.ClientCalls.oneToMany(request, delegateStub::getSliceEvents); + } + + public io.smallrye.mutiny.Multi<context.ContextOuterClass.ConnectionEvent> getConnectionEvents(context.ContextOuterClass.Empty request) { return io.quarkus.grpc.runtime.ClientCalls.oneToMany(request, delegateStub::getConnectionEvents); } @@ -358,6 +388,31 @@ public final class MutinyContextServiceGrpc implements io.quarkus.grpc.runtime.M } + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceIdList> listSliceIds(context.ContextOuterClass.ContextId request) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceList> listSlices(context.ContextOuterClass.ContextId request) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Slice> getSlice(context.ContextOuterClass.SliceId request) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.SliceId> setSlice(context.ContextOuterClass.Slice request) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.Empty> removeSlice(context.ContextOuterClass.SliceId request) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + + public io.smallrye.mutiny.Uni<context.ContextOuterClass.ConnectionIdList> listConnectionIds(context.ContextOuterClass.ServiceId request) { throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); } @@ -408,6 +463,11 @@ public final class MutinyContextServiceGrpc implements io.quarkus.grpc.runtime.M } + public io.smallrye.mutiny.Multi<context.ContextOuterClass.SliceEvent> getSliceEvents(context.ContextOuterClass.Empty request) { + throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); + } + + public io.smallrye.mutiny.Multi<context.ContextOuterClass.ConnectionEvent> getConnectionEvents(context.ContextOuterClass.Empty request) { throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); } @@ -624,6 +684,48 @@ public final class MutinyContextServiceGrpc implements io.quarkus.grpc.runtime.M context.ContextOuterClass.Empty, context.ContextOuterClass.ServiceEvent>( this, METHODID_GET_SERVICE_EVENTS, compression))) + .addMethod( + context.ContextServiceGrpc.getListSliceIdsMethod(), + asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceIdList>( + this, METHODID_LIST_SLICE_IDS, compression))) + .addMethod( + context.ContextServiceGrpc.getListSlicesMethod(), + asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.ContextId, + context.ContextOuterClass.SliceList>( + this, METHODID_LIST_SLICES, compression))) + .addMethod( + context.ContextServiceGrpc.getGetSliceMethod(), + asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.SliceId, + context.ContextOuterClass.Slice>( + this, METHODID_GET_SLICE, compression))) + .addMethod( + context.ContextServiceGrpc.getSetSliceMethod(), + asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.Slice, + context.ContextOuterClass.SliceId>( + this, METHODID_SET_SLICE, compression))) + .addMethod( + context.ContextServiceGrpc.getRemoveSliceMethod(), + asyncUnaryCall( + new MethodHandlers< + context.ContextOuterClass.SliceId, + context.ContextOuterClass.Empty>( + this, METHODID_REMOVE_SLICE, compression))) + .addMethod( + context.ContextServiceGrpc.getGetSliceEventsMethod(), + asyncServerStreamingCall( + new MethodHandlers< + context.ContextOuterClass.Empty, + context.ContextOuterClass.SliceEvent>( + this, METHODID_GET_SLICE_EVENTS, compression))) .addMethod( context.ContextServiceGrpc.getListConnectionIdsMethod(), asyncUnaryCall( @@ -700,12 +802,18 @@ public final class MutinyContextServiceGrpc implements io.quarkus.grpc.runtime.M private static final int METHODID_SET_SERVICE = 27; private static final int METHODID_REMOVE_SERVICE = 28; private static final int METHODID_GET_SERVICE_EVENTS = 29; - private static final int METHODID_LIST_CONNECTION_IDS = 30; - private static final int METHODID_LIST_CONNECTIONS = 31; - private static final int METHODID_GET_CONNECTION = 32; - private static final int METHODID_SET_CONNECTION = 33; - private static final int METHODID_REMOVE_CONNECTION = 34; - private static final int METHODID_GET_CONNECTION_EVENTS = 35; + private static final int METHODID_LIST_SLICE_IDS = 30; + private static final int METHODID_LIST_SLICES = 31; + private static final int METHODID_GET_SLICE = 32; + private static final int METHODID_SET_SLICE = 33; + private static final int METHODID_REMOVE_SLICE = 34; + private static final int METHODID_GET_SLICE_EVENTS = 35; + private static final int METHODID_LIST_CONNECTION_IDS = 36; + private static final int METHODID_LIST_CONNECTIONS = 37; + private static final int METHODID_GET_CONNECTION = 38; + private static final int METHODID_SET_CONNECTION = 39; + private static final int METHODID_REMOVE_CONNECTION = 40; + private static final int METHODID_GET_CONNECTION_EVENTS = 41; private static final class MethodHandlers<Req, Resp> implements io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>, @@ -906,6 +1014,42 @@ public final class MutinyContextServiceGrpc implements io.quarkus.grpc.runtime.M compression, serviceImpl::getServiceEvents); break; + case METHODID_LIST_SLICE_IDS: + io.quarkus.grpc.runtime.ServerCalls.oneToOne((context.ContextOuterClass.ContextId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceIdList>) responseObserver, + compression, + serviceImpl::listSliceIds); + break; + case METHODID_LIST_SLICES: + io.quarkus.grpc.runtime.ServerCalls.oneToOne((context.ContextOuterClass.ContextId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceList>) responseObserver, + compression, + serviceImpl::listSlices); + break; + case METHODID_GET_SLICE: + io.quarkus.grpc.runtime.ServerCalls.oneToOne((context.ContextOuterClass.SliceId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.Slice>) responseObserver, + compression, + serviceImpl::getSlice); + break; + case METHODID_SET_SLICE: + io.quarkus.grpc.runtime.ServerCalls.oneToOne((context.ContextOuterClass.Slice) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceId>) responseObserver, + compression, + serviceImpl::setSlice); + break; + case METHODID_REMOVE_SLICE: + io.quarkus.grpc.runtime.ServerCalls.oneToOne((context.ContextOuterClass.SliceId) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.Empty>) responseObserver, + compression, + serviceImpl::removeSlice); + break; + case METHODID_GET_SLICE_EVENTS: + io.quarkus.grpc.runtime.ServerCalls.oneToMany((context.ContextOuterClass.Empty) request, + (io.grpc.stub.StreamObserver<context.ContextOuterClass.SliceEvent>) responseObserver, + compression, + serviceImpl::getSliceEvents); + break; case METHODID_LIST_CONNECTION_IDS: io.quarkus.grpc.runtime.ServerCalls.oneToOne((context.ContextOuterClass.ServiceId) request, (io.grpc.stub.StreamObserver<context.ContextOuterClass.ConnectionIdList>) responseObserver, diff --git a/src/policy/target/kubernetes/kubernetes.yml b/src/policy/target/kubernetes/kubernetes.yml index 269478f972d87478f02223336448174ccf03a174..3625e9d859ea0a58fc1aff47eeab15cb0434ff03 100644 --- a/src/policy/target/kubernetes/kubernetes.yml +++ b/src/policy/target/kubernetes/kubernetes.yml @@ -1,36 +1,22 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - --- apiVersion: v1 kind: Service metadata: annotations: - app.quarkus.io/commit-id: 43bda7817c976a9fb8ed7a410ad4f0ea13f62498 - app.quarkus.io/build-timestamp: 2022-02-15 - 14:44:53 +0000 + app.quarkus.io/commit-id: 54b760b9045db694a08b0f291f52b28aa4d8c5d2 + app.quarkus.io/build-timestamp: 2022-05-23 - 13:57:10 +0000 labels: app.kubernetes.io/name: policyservice app: policyservice name: policyservice spec: ports: - - name: grpc-server - port: 9999 - targetPort: 9999 - name: http port: 8080 targetPort: 8080 + - name: grpc-server + port: 9999 + targetPort: 9999 selector: app.kubernetes.io/name: policyservice type: ClusterIP @@ -39,8 +25,8 @@ apiVersion: apps/v1 kind: Deployment metadata: annotations: - app.quarkus.io/commit-id: 43bda7817c976a9fb8ed7a410ad4f0ea13f62498 - app.quarkus.io/build-timestamp: 2022-02-15 - 14:44:53 +0000 + app.quarkus.io/commit-id: 54b760b9045db694a08b0f291f52b28aa4d8c5d2 + app.quarkus.io/build-timestamp: 2022-05-23 - 13:57:10 +0000 labels: app: policyservice app.kubernetes.io/name: policyservice @@ -53,8 +39,8 @@ spec: template: metadata: annotations: - app.quarkus.io/commit-id: 43bda7817c976a9fb8ed7a410ad4f0ea13f62498 - app.quarkus.io/build-timestamp: 2022-02-15 - 14:44:53 +0000 + app.quarkus.io/commit-id: 54b760b9045db694a08b0f291f52b28aa4d8c5d2 + app.quarkus.io/build-timestamp: 2022-05-23 - 13:57:10 +0000 labels: app: policyservice app.kubernetes.io/name: policyservice @@ -73,25 +59,25 @@ spec: path: /q/health/live port: 8080 scheme: HTTP - initialDelaySeconds: 5 - periodSeconds: 45 + initialDelaySeconds: 2 + periodSeconds: 10 successThreshold: 1 timeoutSeconds: 10 name: policyservice ports: - - containerPort: 9999 - name: grpc-server - protocol: TCP - containerPort: 8080 name: http protocol: TCP + - containerPort: 9999 + name: grpc-server + protocol: TCP readinessProbe: failureThreshold: 3 httpGet: path: /q/health/ready port: 8080 scheme: HTTP - initialDelaySeconds: 5 - periodSeconds: 45 + initialDelaySeconds: 2 + periodSeconds: 10 successThreshold: 1 timeoutSeconds: 10 diff --git a/src/service/.gitlab-ci.yml b/src/service/.gitlab-ci.yml index 3f845a9dd960b6a9dcfd140720b3b8db923f8ddf..a91f9e4edb8cae14029897df3aafa2b6f1bea3a9 100644 --- a/src/service/.gitlab-ci.yml +++ b/src/service/.gitlab-ci.yml @@ -55,7 +55,6 @@ unit test service: - docker ps -a - docker logs $IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - - docker exec -i $IMAGE_NAME bash -c "coverage xml -o /opt/results/${IMAGE_NAME}_coverage.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: @@ -75,7 +74,6 @@ unit test service: when: always reports: junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml - cobertura: src/$IMAGE_NAME/tests/${IMAGE_NAME}_coverage.xml # Deployment of the service in Kubernetes Cluster deploy service: diff --git a/src/service/Config.py b/src/service/Config.py index 5d551b023fc21202a1411ae46781682055fdef91..70a33251242c51f49140e596b8208a19dd5245f7 100644 --- a/src/service/Config.py +++ b/src/service/Config.py @@ -12,22 +12,3 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging - -# General settings -LOG_LEVEL = logging.WARNING - -# gRPC settings -GRPC_SERVICE_PORT = 3030 -GRPC_MAX_WORKERS = 10 -GRPC_GRACE_PERIOD = 60 - -# Prometheus settings -METRICS_PORT = 9192 - -# Dependency micro-service connection settings -CONTEXT_SERVICE_HOST = '127.0.0.1' -CONTEXT_SERVICE_PORT = 1010 - -DEVICE_SERVICE_HOST = '127.0.0.1' -DEVICE_SERVICE_PORT = 2020 diff --git a/src/service/client/ServiceClient.py b/src/service/client/ServiceClient.py index a44842768b9ee112288653f57706c5c4549503e9..a6335bfceedeec02cd223f4e960e9f69afe7a35e 100644 --- a/src/service/client/ServiceClient.py +++ b/src/service/client/ServiceClient.py @@ -13,6 +13,8 @@ # limitations under the License. import grpc, logging +from common.Constants import ServiceNameEnum +from common.Settings import get_service_host, get_service_port_grpc from common.tools.client.RetryDecorator import retry, delay_exponential from common.tools.grpc.Tools import grpc_message_to_json_string from service.proto.context_pb2 import Empty, Service, ServiceId @@ -24,9 +26,11 @@ DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) RETRY_DECORATOR = retry(max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') class ServiceClient: - def __init__(self, address, port): - self.endpoint = '{:s}:{:s}'.format(str(address), str(port)) - LOGGER.debug('Creating channel to {:s}...'.format(self.endpoint)) + def __init__(self, host=None, port=None): + if not host: host = get_service_host(ServiceNameEnum.SERVICE) + if not port: port = get_service_port_grpc(ServiceNameEnum.SERVICE) + self.endpoint = '{:s}:{:s}'.format(str(host), str(port)) + LOGGER.debug('Creating channel to {:s}...'.format(str(self.endpoint))) self.channel = None self.stub = None self.connect() diff --git a/src/service/service/ServiceService.py b/src/service/service/ServiceService.py index 21945b7d3c2fe75e27bfa37bc7465f75e7b660f1..356c314c380e8df151b60ed826c41d294f9462ca 100644 --- a/src/service/service/ServiceService.py +++ b/src/service/service/ServiceService.py @@ -12,72 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc, logging -from concurrent import futures -from grpc_health.v1.health import HealthServicer, OVERALL_HEALTH -from grpc_health.v1.health_pb2 import HealthCheckResponse -from grpc_health.v1.health_pb2_grpc import add_HealthServicer_to_server +from common.Constants import ServiceNameEnum +from common.Settings import get_service_port_grpc from common.orm.backend.BackendEnum import BackendEnum from common.orm.Database import Database from common.orm.Factory import get_database_backend -from context.client.ContextClient import ContextClient -from device.client.DeviceClient import DeviceClient -from service.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD +from common.tools.service.GenericGrpcService import GenericGrpcService from service.proto.service_pb2_grpc import add_ServiceServiceServicer_to_server from .ServiceServiceServicerImpl import ServiceServiceServicerImpl from .service_handler_api.ServiceHandlerFactory import ServiceHandlerFactory -BIND_ADDRESS = '0.0.0.0' -LOGGER = logging.getLogger(__name__) +class ServiceService(GenericGrpcService): + def __init__(self, service_handler_factory : ServiceHandlerFactory, cls_name: str = __name__) -> None: + port = get_service_port_grpc(ServiceNameEnum.SERVICE) + super().__init__(port, cls_name=cls_name) + database = Database(get_database_backend(backend=BackendEnum.INMEMORY)) + self.service_servicer = ServiceServiceServicerImpl(database, service_handler_factory) -class ServiceService: - def __init__( - self, context_client : ContextClient, device_client : DeviceClient, - service_handler_factory : ServiceHandlerFactory, - address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, - grace_period=GRPC_GRACE_PERIOD): - - self.context_client = context_client - self.device_client = device_client - self.service_handler_factory = service_handler_factory - self.address = address - self.port = port - self.endpoint = None - self.max_workers = max_workers - self.grace_period = grace_period - self.service_servicer = None - self.health_servicer = None - self.pool = None - self.server = None - - self.database = Database(get_database_backend(backend=BackendEnum.INMEMORY)) - - def start(self): - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) - LOGGER.info('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( - str(self.endpoint), str(self.max_workers))) - - self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) - self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) - - self.service_servicer = ServiceServiceServicerImpl( - self.context_client, self.device_client, self.database, self.service_handler_factory) + def install_servicers(self): add_ServiceServiceServicer_to_server(self.service_servicer, self.server) - - self.health_servicer = HealthServicer( - experimental_non_blocking=True, experimental_thread_pool=futures.ThreadPoolExecutor(max_workers=1)) - add_HealthServicer_to_server(self.health_servicer, self.server) - - port = self.server.add_insecure_port(self.endpoint) - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(port)) - LOGGER.info('Listening on {:s}...'.format(str(self.endpoint))) - self.server.start() - self.health_servicer.set(OVERALL_HEALTH, HealthCheckResponse.SERVING) # pylint: disable=maybe-no-member - - LOGGER.debug('Service started') - - def stop(self): - LOGGER.debug('Stopping service (grace period {:s} seconds)...'.format(str(self.grace_period))) - self.health_servicer.enter_graceful_shutdown() - self.server.stop(self.grace_period) - LOGGER.debug('Service stopped') diff --git a/src/service/service/ServiceServiceServicerImpl.py b/src/service/service/ServiceServiceServicerImpl.py index 7720699321daa4f1b77af60a9059e3fc9d7eec79..f34b99d6367d12f4d6d995db2f5fc1a691933bca 100644 --- a/src/service/service/ServiceServiceServicerImpl.py +++ b/src/service/service/ServiceServiceServicerImpl.py @@ -39,13 +39,10 @@ METHOD_NAMES = ['CreateService', 'UpdateService', 'DeleteService'] METRICS = create_metrics(SERVICE_NAME, METHOD_NAMES) class ServiceServiceServicerImpl(ServiceServiceServicer): - def __init__( - self, context_client : ContextClient, device_client : DeviceClient, database : Database, - service_handler_factory : ServiceHandlerFactory): - + def __init__(self, database : Database, service_handler_factory : ServiceHandlerFactory) -> None: LOGGER.debug('Creating Servicer...') - self.context_client = context_client - self.device_client = device_client + self.context_client = ContextClient() + self.device_client = DeviceClient() self.database = database self.service_handler_factory = service_handler_factory LOGGER.debug('Servicer Created') diff --git a/src/service/service/__main__.py b/src/service/service/__main__.py index cc1b008958572020ebbe54fdfcda27ed4218f80e..1a67a309ff19bda2bf3174c80dfb908e99f72d14 100644 --- a/src/service/service/__main__.py +++ b/src/service/service/__main__.py @@ -14,12 +14,10 @@ import logging, signal, sys, threading from prometheus_client import start_http_server -from common.Settings import get_setting, wait_for_environment_variables -from context.client.ContextClient import ContextClient -from device.client.DeviceClient import DeviceClient -from service.Config import ( - CONTEXT_SERVICE_HOST, CONTEXT_SERVICE_PORT, DEVICE_SERVICE_HOST, DEVICE_SERVICE_PORT, GRPC_SERVICE_PORT, - GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL, METRICS_PORT) +from common.Constants import ServiceNameEnum +from common.Settings import ( + ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_log_level, get_metrics_port, + wait_for_environment_variables) from .ServiceService import ServiceService from .service_handler_api.ServiceHandlerFactory import ServiceHandlerFactory from .service_handlers import SERVICE_HANDLERS @@ -34,51 +32,31 @@ def signal_handler(signal, frame): # pylint: disable=redefined-outer-name def main(): global LOGGER # pylint: disable=global-statement - grpc_service_port = get_setting('SERVICESERVICE_SERVICE_PORT_GRPC', default=GRPC_SERVICE_PORT ) - max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS ) - grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD ) - log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL ) - metrics_port = get_setting('METRICS_PORT', default=METRICS_PORT ) - + log_level = get_log_level() logging.basicConfig(level=log_level) LOGGER = logging.getLogger(__name__) wait_for_environment_variables([ - 'CONTEXTSERVICE_SERVICE_HOST', 'CONTEXTSERVICE_SERVICE_PORT_GRPC', - 'DEVICESERVICE_SERVICE_HOST', 'DEVICESERVICE_SERVICE_PORT_GRPC' + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST ), + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC), + get_env_var_name(ServiceNameEnum.DEVICE, ENVVAR_SUFIX_SERVICE_HOST ), + get_env_var_name(ServiceNameEnum.DEVICE, ENVVAR_SUFIX_SERVICE_PORT_GRPC), ]) - context_service_host = get_setting('CONTEXTSERVICE_SERVICE_HOST', default=CONTEXT_SERVICE_HOST) - context_service_port = get_setting('CONTEXTSERVICE_SERVICE_PORT_GRPC', default=CONTEXT_SERVICE_PORT) - device_service_host = get_setting('DEVICESERVICE_SERVICE_HOST', default=DEVICE_SERVICE_HOST ) - device_service_port = get_setting('DEVICESERVICE_SERVICE_PORT_GRPC', default=DEVICE_SERVICE_PORT ) - signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) LOGGER.info('Starting...') # Start metrics server + metrics_port = get_metrics_port() start_http_server(metrics_port) - # Initialize Context Client - if context_service_host is None or context_service_port is None: - raise Exception('Wrong address({:s}):port({:s}) of Context component'.format( - str(context_service_host), str(context_service_port))) - context_client = ContextClient(context_service_host, context_service_port) - - # Initialize Device Client - if device_service_host is None or device_service_port is None: - raise Exception('Wrong address({:s}):port({:s}) of Device component'.format( - str(device_service_host), str(device_service_port))) - device_client = DeviceClient(device_service_host, device_service_port) - + # Initialize ServiceHandler Factory service_handler_factory = ServiceHandlerFactory(SERVICE_HANDLERS) # Starting service service - grpc_service = ServiceService( - context_client, device_client, service_handler_factory, port=grpc_service_port, max_workers=max_workers, - grace_period=grace_period) + grpc_service = ServiceService(service_handler_factory) grpc_service.start() # Wait for Ctrl+C or termination signal diff --git a/src/service/tests/MockService_Dependencies.py b/src/service/tests/MockService_Dependencies.py new file mode 100644 index 0000000000000000000000000000000000000000..8194ba94347b6439e9d71fda1c79a94b4ddb3f9d --- /dev/null +++ b/src/service/tests/MockService_Dependencies.py @@ -0,0 +1,49 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from typing import Union +from common.Constants import ServiceNameEnum +from common.Settings import ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name +from common.tests.MockServicerImpl_Context import MockServicerImpl_Context +from common.tests.MockServicerImpl_Device import MockServicerImpl_Device +from common.tools.service.GenericGrpcService import GenericGrpcService +from context.proto.context_pb2_grpc import add_ContextServiceServicer_to_server +from device.proto.device_pb2_grpc import add_DeviceServiceServicer_to_server + +LOCAL_HOST = '127.0.0.1' + +SERVICE_CONTEXT = ServiceNameEnum.CONTEXT +SERVICE_DEVICE = ServiceNameEnum.DEVICE + +class MockService_Dependencies(GenericGrpcService): + # Mock Service implementing Context and Device to simplify unitary tests of Device + + def __init__(self, bind_port: Union[str, int]) -> None: + super().__init__(bind_port, LOCAL_HOST, enable_health_servicer=False, cls_name='MockService') + + # pylint: disable=attribute-defined-outside-init + def install_servicers(self): + self.context_servicer = MockServicerImpl_Context() + add_ContextServiceServicer_to_server(self.context_servicer, self.server) + + self.device_servicer = MockServicerImpl_Device() + add_DeviceServiceServicer_to_server(self.device_servicer, self.server) + + def configure_env_vars(self): + os.environ[get_env_var_name(SERVICE_CONTEXT, ENVVAR_SUFIX_SERVICE_HOST )] = str(self.bind_address) + os.environ[get_env_var_name(SERVICE_CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(self.bind_port) + + os.environ[get_env_var_name(SERVICE_DEVICE, ENVVAR_SUFIX_SERVICE_HOST )] = str(self.bind_address) + os.environ[get_env_var_name(SERVICE_DEVICE, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(self.bind_port) diff --git a/src/service/tests/PrepareTestScenario.py b/src/service/tests/PrepareTestScenario.py new file mode 100644 index 0000000000000000000000000000000000000000..bcf3cd156ab04e932e440837dc8ca0df645dc0cc --- /dev/null +++ b/src/service/tests/PrepareTestScenario.py @@ -0,0 +1,68 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest, os +from common.Constants import ServiceNameEnum +from common.Settings import ( + ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_service_port_grpc) +from context.client.ContextClient import ContextClient +from device.client.DeviceClient import DeviceClient +from service.client.ServiceClient import ServiceClient +from service.service.ServiceService import ServiceService +from service.service.service_handler_api.ServiceHandlerFactory import ServiceHandlerFactory +from service.service.service_handlers import SERVICE_HANDLERS +from service.tests.MockService_Dependencies import MockService_Dependencies + +LOCAL_HOST = '127.0.0.1' +MOCKSERVICE_PORT = 10000 +SERVICE_SERVICE_PORT = MOCKSERVICE_PORT + get_service_port_grpc(ServiceNameEnum.SERVICE) # avoid privileged ports +os.environ[get_env_var_name(ServiceNameEnum.SERVICE, ENVVAR_SUFIX_SERVICE_HOST )] = str(LOCAL_HOST) +os.environ[get_env_var_name(ServiceNameEnum.SERVICE, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(SERVICE_SERVICE_PORT) + +@pytest.fixture(scope='session') +def mock_service(): + _service = MockService_Dependencies(MOCKSERVICE_PORT) + _service.configure_env_vars() + _service.start() + yield _service + _service.stop() + +@pytest.fixture(scope='session') +def context_client(mock_service : MockService_Dependencies): # pylint: disable=redefined-outer-name + _client = ContextClient() + yield _client + _client.close() + +@pytest.fixture(scope='session') +def device_client(mock_service : MockService_Dependencies): # pylint: disable=redefined-outer-name + _client = DeviceClient() + yield _client + _client.close() + +@pytest.fixture(scope='session') +def service_service( + context_client : ContextClient, # pylint: disable=redefined-outer-name + device_client : DeviceClient): # pylint: disable=redefined-outer-name + + _service_handler_factory = ServiceHandlerFactory(SERVICE_HANDLERS) + _service = ServiceService(_service_handler_factory) + _service.start() + yield _service + _service.stop() + +@pytest.fixture(scope='session') +def service_client(service_service : ServiceService): # pylint: disable=redefined-outer-name + _client = ServiceClient() + yield _client + _client.close() diff --git a/src/service/tests/test_unitary.py b/src/service/tests/test_unitary.py index 812a65c5c4353925dcf0b186a0ebb5401a4ecfa1..60fd17371771c6d5764b18255595f8b4520e8447 100644 --- a/src/service/tests/test_unitary.py +++ b/src/service/tests/test_unitary.py @@ -12,90 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -import copy, grpc, logging, os, pytest -from common.tests.MockService import MockService -from common.tests.MockServicerImpl_Context import MockServicerImpl_Context -from common.tests.MockServicerImpl_Device import MockServicerImpl_Device +import copy, grpc, logging, pytest from common.tests.PytestGenerateTests import pytest_generate_tests # (required) pylint: disable=unused-import from common.tools.grpc.Tools import grpc_message_to_json_string from context.client.ContextClient import ContextClient from context.proto.context_pb2 import Context, ContextId, DeviceId, Link, LinkId, Topology, Device, TopologyId -from context.proto.context_pb2_grpc import add_ContextServiceServicer_to_server from device.client.DeviceClient import DeviceClient -from device.proto.device_pb2_grpc import add_DeviceServiceServicer_to_server -from service.Config import ( - GRPC_SERVICE_PORT as SERVICE_GRPC_SERVICE_PORT, GRPC_MAX_WORKERS as SERVICE_GRPC_MAX_WORKERS, - GRPC_GRACE_PERIOD as SERVICE_GRPC_GRACE_PERIOD) from service.client.ServiceClient import ServiceClient from service.proto.context_pb2 import Service, ServiceId -from service.service.ServiceService import ServiceService -from service.service.service_handler_api.ServiceHandlerFactory import ServiceHandlerFactory -from service.service.service_handlers import SERVICE_HANDLERS +from .PrepareTestScenario import ( # pylint: disable=unused-import + # be careful, order of symbols is important here! + mock_service, service_service, context_client, device_client, service_client) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) -SERVICE_GRPC_SERVICE_PORT = 10000 + SERVICE_GRPC_SERVICE_PORT # avoid privileged ports - -LOCALHOST = '127.0.0.1' -MOCKSERVER_GRPC_PORT = 10000 - -class MockService_Combined(MockService): - # Mock Server implementing Context and Service to simplify unitary tests of Compute - - def __init__(self, cls_name='MockService_Service'): - super().__init__(LOCALHOST, MOCKSERVER_GRPC_PORT, cls_name=cls_name) - - # pylint: disable=attribute-defined-outside-init - def install_servicers(self): - self.context_servicer = MockServicerImpl_Context() - add_ContextServiceServicer_to_server(self.context_servicer, self.server) - self.device_servicer = MockServicerImpl_Device() - add_DeviceServiceServicer_to_server(self.device_servicer, self.server) - -os.environ['CONTEXTSERVICE_SERVICE_HOST'] = LOCALHOST -os.environ['CONTEXTSERVICE_SERVICE_PORT_GRPC'] = str(MOCKSERVER_GRPC_PORT) -os.environ['DEVICESERVICE_SERVICE_HOST'] = LOCALHOST -os.environ['DEVICESERVICE_SERVICE_PORT_GRPC'] = str(MOCKSERVER_GRPC_PORT) - -@pytest.fixture(scope='session') -def mockservice(): - _service = MockService_Combined() - _service.start() - yield _service - _service.stop() - -@pytest.fixture(scope='session') -def context_client(mockservice : MockService_Combined): # pylint: disable=redefined-outer-name - _client = ContextClient(address=LOCALHOST, port=MOCKSERVER_GRPC_PORT) - yield _client - _client.close() - -@pytest.fixture(scope='session') -def device_client(mockservice : MockService_Combined): # pylint: disable=redefined-outer-name - _client = DeviceClient(address=LOCALHOST, port=MOCKSERVER_GRPC_PORT) - yield _client - _client.close() - -@pytest.fixture(scope='session') -def service_service( - context_client : ContextClient, # pylint: disable=redefined-outer-name - device_client : DeviceClient): # pylint: disable=redefined-outer-name - - _service_handler_factory = ServiceHandlerFactory(SERVICE_HANDLERS) - _service = ServiceService( - context_client, device_client, _service_handler_factory, - port=SERVICE_GRPC_SERVICE_PORT, max_workers=SERVICE_GRPC_MAX_WORKERS, grace_period=SERVICE_GRPC_GRACE_PERIOD) - _service.start() - yield _service - _service.stop() - -@pytest.fixture(scope='session') -def service_client(service_service : ServiceService): # pylint: disable=redefined-outer-name - _client = ServiceClient(address=LOCALHOST, port=SERVICE_GRPC_SERVICE_PORT) - yield _client - _client.close() - try: from .ServiceHandlersToTest import SERVICE_HANDLERS_TO_TEST except ImportError: diff --git a/src/slice/Config.py b/src/slice/Config.py index e6d770d000cc249d73cccf17dd17f21ccb001f7d..70a33251242c51f49140e596b8208a19dd5245f7 100644 --- a/src/slice/Config.py +++ b/src/slice/Config.py @@ -1,22 +1,14 @@ -import logging +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. -# General settings -LOG_LEVEL = logging.WARNING - -# gRPC settings -GRPC_SERVICE_PORT = 4040 -GRPC_MAX_WORKERS = 10 -GRPC_GRACE_PERIOD = 60 - -# Prometheus settings -METRICS_PORT = 9192 - -# Dependency micro-service connection settings -CONTEXT_SERVICE_HOST = '127.0.0.1' -CONTEXT_SERVICE_PORT = 1010 - -SERVICE_SERVICE_HOST = '127.0.0.1' -SERVICE_SERVICE_PORT = 3030 - -INTERDOMAIN_SERVICE_HOST = '127.0.0.1' -INTERDOMAIN_SERVICE_PORT = 10010 diff --git a/src/slice/client/SliceClient.py b/src/slice/client/SliceClient.py index 5566108f83a68cbac695a117b17b7a3fd1bd3de1..d1783e882faf2ea0e89fd3d1e034d8cba02dc24b 100644 --- a/src/slice/client/SliceClient.py +++ b/src/slice/client/SliceClient.py @@ -13,6 +13,8 @@ # limitations under the License. import grpc, logging +from common.Constants import ServiceNameEnum +from common.Settings import get_service_host, get_service_port_grpc from common.tools.client.RetryDecorator import retry, delay_exponential from common.tools.grpc.Tools import grpc_message_to_json_string from slice.proto.context_pb2 import Empty, Slice, SliceId @@ -24,8 +26,10 @@ DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) RETRY_DECORATOR = retry(max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') class SliceClient: - def __init__(self, address, port): - self.endpoint = '{:s}:{:s}'.format(str(address), str(port)) + def __init__(self, host=None, port=None): + if not host: host = get_service_host(ServiceNameEnum.SLICE) + if not port: port = get_service_port_grpc(ServiceNameEnum.SLICE) + self.endpoint = '{:s}:{:s}'.format(str(host), str(port)) LOGGER.debug('Creating channel to {:s}...'.format(self.endpoint)) self.channel = None self.stub = None diff --git a/src/slice/service/SliceService.py b/src/slice/service/SliceService.py index a7ad2694698333d0450aef9e670dd2a4fe9b30e5..7121ae4676d63977953bb3f66cb0754c8d89de88 100644 --- a/src/slice/service/SliceService.py +++ b/src/slice/service/SliceService.py @@ -12,65 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc, logging -from concurrent import futures -from grpc_health.v1.health import HealthServicer, OVERALL_HEALTH -from grpc_health.v1.health_pb2 import HealthCheckResponse -from grpc_health.v1.health_pb2_grpc import add_HealthServicer_to_server -from context.client.ContextClient import ContextClient -from interdomain.client.InterdomainClient import InterdomainClient -from service.client.ServiceClient import ServiceClient +from common.Constants import ServiceNameEnum +from common.Settings import get_service_port_grpc +from common.tools.service.GenericGrpcService import GenericGrpcService from slice.proto.slice_pb2_grpc import add_SliceServiceServicer_to_server from slice.service.SliceServiceServicerImpl import SliceServiceServicerImpl -from slice.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD -BIND_ADDRESS = '0.0.0.0' -LOGGER = logging.getLogger(__name__) +class SliceService(GenericGrpcService): + def __init__(self, cls_name: str = __name__) -> None: + port = get_service_port_grpc(ServiceNameEnum.SLICE) + super().__init__(port, cls_name=cls_name) + self.slice_servicer = SliceServiceServicerImpl() -class SliceService: - def __init__( - self, context_client : ContextClient, interdomain_client : InterdomainClient, service_client : ServiceClient, - address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD): - - self.context_client = context_client - self.interdomain_client = interdomain_client - self.service_client = service_client - self.address = address - self.port = port - self.endpoint = None - self.max_workers = max_workers - self.grace_period = grace_period - self.slice_servicer = None - self.health_servicer = None - self.pool = None - self.server = None - - def start(self): - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) - LOGGER.info('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( - str(self.endpoint), str(self.max_workers))) - - self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) - self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) - - self.slice_servicer = SliceServiceServicerImpl( - self.context_client, self.interdomain_client, self.service_client) + def install_servicers(self): add_SliceServiceServicer_to_server(self.slice_servicer, self.server) - - self.health_servicer = HealthServicer( - experimental_non_blocking=True, experimental_thread_pool=futures.ThreadPoolExecutor(max_workers=1)) - add_HealthServicer_to_server(self.health_servicer, self.server) - - port = self.server.add_insecure_port(self.endpoint) - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(port)) - LOGGER.info('Listening on {:s}...'.format(str(self.endpoint))) - self.server.start() - self.health_servicer.set(OVERALL_HEALTH, HealthCheckResponse.SERVING) # pylint: disable=maybe-no-member - - LOGGER.debug('Service started') - - def stop(self): - LOGGER.debug('Stopping service (grace period {:s} seconds)...'.format(str(self.grace_period))) - self.health_servicer.enter_graceful_shutdown() - self.server.stop(self.grace_period) - LOGGER.debug('Service stopped') diff --git a/src/slice/service/SliceServiceServicerImpl.py b/src/slice/service/SliceServiceServicerImpl.py index bd26d19435092bd8ebea5748d49488975d4d675b..eae45240066cb4f88fd095ac3966daa5a270d5f4 100644 --- a/src/slice/service/SliceServiceServicerImpl.py +++ b/src/slice/service/SliceServiceServicerImpl.py @@ -28,17 +28,14 @@ METHOD_NAMES = ['CreateSlice', 'UpdateSlice', 'DeleteSlice'] METRICS = create_metrics(SERVICE_NAME, METHOD_NAMES) class SliceServiceServicerImpl(SliceServiceServicer): - def __init__( - self, context_client : ContextClient, interdomain_client : InterdomainClient, service_client : ServiceClient - ): + def __init__(self): LOGGER.debug('Creating Servicer...') - self.context_client = context_client - self.interdomain_client = interdomain_client - self.service_client = service_client LOGGER.debug('Servicer Created') def create_update(self, request : Slice) -> SliceId: - slice_id = self.context_client.SetSlice(request) + context_client = ContextClient() + + slice_id = context_client.SetSlice(request) if len(request.slice_endpoint_ids) != 2: return slice_id domains = set() @@ -48,7 +45,8 @@ class SliceServiceServicerImpl(SliceServiceServicer): is_multi_domain = len(domains) == 2 if is_multi_domain: - slice_id = self.interdomain_client.RequestSlice(request) + interdomain_client = InterdomainClient() + slice_id = interdomain_client.RequestSlice(request) else: # pylint: disable=no-member service_request = Service() @@ -57,7 +55,8 @@ class SliceServiceServicerImpl(SliceServiceServicer): service_request.service_type = ServiceTypeEnum.SERVICETYPE_L3NM service_request.service_status.service_status = ServiceStatusEnum.SERVICESTATUS_PLANNED - service_reply = self.service_client.CreateService(service_request) + service_client = ServiceClient() + service_reply = service_client.CreateService(service_request) if service_reply != service_request.service_id: # pylint: disable=no-member raise Exception('Service creation failed. Wrong Service Id was returned') @@ -84,7 +83,7 @@ class SliceServiceServicerImpl(SliceServiceServicer): 'address_ip': '0.0.0.0', 'address_prefix': 0}, sort_keys=True) - service_reply = self.service_client.UpdateService(service_request) + service_reply = service_client.UpdateService(service_request) if service_reply != service_request.service_id: # pylint: disable=no-member raise Exception('Service update failed. Wrong Service Id was returned') @@ -92,29 +91,29 @@ class SliceServiceServicerImpl(SliceServiceServicer): reply.CopyFrom(request) slice_service_id = reply.slice_service_ids.add() slice_service_id.CopyFrom(service_reply) - self.context_client.SetSlice(reply) + context_client.SetSlice(reply) slice_id = reply.slice_id - slice_ = self.context_client.GetSlice(slice_id) + slice_ = context_client.GetSlice(slice_id) slice_active = Slice() slice_active.CopyFrom(slice_) slice_active.slice_status.slice_status = SliceStatusEnum.SLICESTATUS_ACTIVE - self.context_client.SetSlice(slice_active) + context_client.SetSlice(slice_active) return slice_id @safe_and_metered_rpc_method(METRICS, LOGGER) def CreateSlice(self, request : Slice, context : grpc.ServicerContext) -> SliceId: #try: - # slice_ = self.context_client.GetSlice(request.slice_id) + # slice_ = context_client.GetSlice(request.slice_id) # slice_id = slice_.slice_id #except grpc.RpcError: - # slice_id = self.context_client.SetSlice(request) + # slice_id = context_client.SetSlice(request) #return slice_id return self.create_update(request) @safe_and_metered_rpc_method(METRICS, LOGGER) def UpdateSlice(self, request : Slice, context : grpc.ServicerContext) -> SliceId: - #slice_id = self.context_client.SetSlice(request) + #slice_id = context_client.SetSlice(request) #if len(request.slice_endpoint_ids) != 2: return slice_id # #domains = set() @@ -124,7 +123,8 @@ class SliceServiceServicerImpl(SliceServiceServicer): # #is_multi_domain = len(domains) == 2 #if is_multi_domain: - # return self.interdomain_client.LookUpSlice(request) + # interdomain_client = InterdomainClient() + # return interdomain_client.LookUpSlice(request) #else: # raise NotImplementedError('Slice should create local services for single domain slice') return self.create_update(request) diff --git a/src/slice/service/__main__.py b/src/slice/service/__main__.py index 76bb5fa34eac45c828413d4671e023958a886d1b..f77d86bffe9b722f414be4f85adcaf0ef2cc4a8e 100644 --- a/src/slice/service/__main__.py +++ b/src/slice/service/__main__.py @@ -14,14 +14,8 @@ import logging, signal, sys, threading from prometheus_client import start_http_server -from common.Settings import get_setting, wait_for_environment_variables -from context.client.ContextClient import ContextClient -from interdomain.client.InterdomainClient import InterdomainClient -from service.client.ServiceClient import ServiceClient -from slice.Config import ( - CONTEXT_SERVICE_HOST, CONTEXT_SERVICE_PORT, GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, - INTERDOMAIN_SERVICE_HOST, INTERDOMAIN_SERVICE_PORT, LOG_LEVEL, METRICS_PORT, SERVICE_SERVICE_HOST, - SERVICE_SERVICE_PORT) +from common.Constants import ServiceNameEnum +from common.Settings import ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_log_level, get_metrics_port, wait_for_environment_variables from .SliceService import SliceService terminate = threading.Event() @@ -34,58 +28,28 @@ def signal_handler(signal, frame): # pylint: disable=redefined-outer-name def main(): global LOGGER # pylint: disable=global-statement - grpc_service_port = get_setting('SLICESERVICE_SERVICE_PORT_GRPC', default=GRPC_SERVICE_PORT ) - max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS ) - grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD ) - log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL ) - metrics_port = get_setting('METRICS_PORT', default=METRICS_PORT ) - + log_level = get_log_level() logging.basicConfig(level=log_level) LOGGER = logging.getLogger(__name__) wait_for_environment_variables([ - 'CONTEXTSERVICE_SERVICE_HOST', 'CONTEXTSERVICE_SERVICE_PORT_GRPC', - 'INTERDOMAINSERVICE_SERVICE_HOST', 'INTERDOMAINSERVICE_SERVICE_PORT_GRPC', - 'SERVICESERVICE_SERVICE_HOST', 'SERVICESERVICE_SERVICE_PORT_GRPC', + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST ), + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC), + get_env_var_name(ServiceNameEnum.SERVICE, ENVVAR_SUFIX_SERVICE_HOST ), + get_env_var_name(ServiceNameEnum.SERVICE, ENVVAR_SUFIX_SERVICE_PORT_GRPC), ]) - context_service_host = get_setting('CONTEXTSERVICE_SERVICE_HOST', default=CONTEXT_SERVICE_HOST ) - context_service_port = get_setting('CONTEXTSERVICE_SERVICE_PORT_GRPC', default=CONTEXT_SERVICE_PORT ) - interdomain_service_host = get_setting('INTERDOMAINSERVICE_SERVICE_HOST', default=INTERDOMAIN_SERVICE_HOST) - interdomain_service_port = get_setting('INTERDOMAINSERVICE_SERVICE_PORT_GRPC', default=INTERDOMAIN_SERVICE_PORT) - service_service_host = get_setting('SERVICESERVICE_SERVICE_HOST', default=SERVICE_SERVICE_HOST ) - service_service_port = get_setting('SERVICESERVICE_SERVICE_PORT_GRPC', default=SERVICE_SERVICE_PORT ) - signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) LOGGER.info('Starting...') # Start metrics server + metrics_port = get_metrics_port() start_http_server(metrics_port) - # Initialize Context Client - if context_service_host is None or context_service_port is None: - raise Exception('Wrong address({:s}):port({:s}) of Context component'.format( - str(context_service_host), str(context_service_port))) - context_client = ContextClient(context_service_host, context_service_port) - - # Initialize Interdomain Client - if interdomain_service_host is None or interdomain_service_port is None: - raise Exception('Wrong address({:s}):port({:s}) of Interdomain component'.format( - str(interdomain_service_host), str(interdomain_service_port))) - interdomain_client = InterdomainClient(interdomain_service_host, interdomain_service_port) - - # Initialize Service Client - if service_service_host is None or service_service_port is None: - raise Exception('Wrong address({:s}):port({:s}) of Service component'.format( - str(service_service_host), str(service_service_port))) - service_client = ServiceClient(service_service_host, service_service_port) - # Starting slice service - grpc_service = SliceService( - context_client, interdomain_client, service_client, port=grpc_service_port, max_workers=max_workers, - grace_period=grace_period) + grpc_service = SliceService() grpc_service.start() # Wait for Ctrl+C or termination signal diff --git a/src/slice/tests/test_unitary.py b/src/slice/tests/test_unitary.py index fb58b51536793ab6029da1fc3c1444591d6f2bdd..1fd5a75b4dc1bb0192c8eeda6a0d452c0a9465dd 100644 --- a/src/slice/tests/test_unitary.py +++ b/src/slice/tests/test_unitary.py @@ -12,34 +12,32 @@ # See the License for the specific language governing permissions and # limitations under the License. -import copy, grpc, logging, pytest -from common.database.Factory import get_database, DatabaseEngineEnum +import logging, os, pytest +from common.Constants import ServiceNameEnum +from common.Settings import ( + ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_service_port_grpc) from slice.client.SliceClient import SliceClient -from slice.proto.slice_pb2 import TransportSlice from slice.service.SliceService import SliceService -from slice.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD -port = 10000 + GRPC_SERVICE_PORT # avoid privileged ports +LOCAL_HOST = '127.0.0.1' +MOCKSERVICE_PORT = 10000 +SLICE_SERVICE_PORT = MOCKSERVICE_PORT + get_service_port_grpc(ServiceNameEnum.SLICE) # avoid privileged ports +os.environ[get_env_var_name(ServiceNameEnum.SLICE, ENVVAR_SUFIX_SERVICE_HOST )] = str(LOCAL_HOST) +os.environ[get_env_var_name(ServiceNameEnum.SLICE, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(SLICE_SERVICE_PORT) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) @pytest.fixture(scope='session') -def slice_database(): - _database = get_database(engine=DatabaseEngineEnum.INMEMORY) - return _database - -@pytest.fixture(scope='session') -def slice_service(slice_database): - _service = SliceService( - slice_database, port=port, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD) +def slice_service(): + _service = SliceService() _service.start() yield _service _service.stop() @pytest.fixture(scope='session') -def slice_client(slice_service): - _client = SliceClient(address='127.0.0.1', port=port) +def slice_client(slice_service : SliceService): # pylint: disable=redefined-outer-name + _client = SliceClient() yield _client _client.close() diff --git a/src/webui/.gitlab-ci.yml b/src/webui/.gitlab-ci.yml index 65fd7127848224d2afb7c45280a3d15ffbcab6c5..3865541d040a4320bac02caaa42f66f1e8ca10e9 100644 --- a/src/webui/.gitlab-ci.yml +++ b/src/webui/.gitlab-ci.yml @@ -55,7 +55,8 @@ unit test webui: - sleep 5 - docker ps -a - docker logs $IMAGE_NAME - - docker exec --user root -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=DEBUG --verbose ${IMAGE_NAME}/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml; coverage xml -o /opt/results/${IMAGE_NAME}_coverage.xml; ls -la /opt/results; coverage report --include='${IMAGE_NAME}/*' --show-missing" + - docker exec --user root -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=DEBUG --verbose ${IMAGE_NAME}/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" + - docker exec --user root -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: - docker rm -f $IMAGE_NAME @@ -74,7 +75,6 @@ unit test webui: when: always reports: junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml - cobertura: src/$IMAGE_NAME/tests/${IMAGE_NAME}_coverage.xml # Deployment of the webui service in Kubernetes Cluster deploy webui: