diff --git a/.gitignore b/.gitignore index 5b47069a354d9dea93458c5f8e1e492526bbc8c4..672318fd492569dbe86c0bbff0e56fcbf4f40967 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ +.devcontainer +*.pro.user* +cmake-build-debug ccs/qrc_* -.vscode/ ccs/compile_commands.json .scannerwork asan_leak_suppression.txt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index db4aaae19b0f6a78b5a16eb2bf6248b78c111b2f..86de85b54a1a443b930fe15e9a666469a4747878 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -63,7 +63,7 @@ test_u_14_04_gcc49: script: - git config --global user.name "Claudio Bisegni" - git config --global user.email "Claudio.Bisegni@lnf.infn.it" - - apt-get update + - apt-get -y update - apt-get -y install lcov gcovr - export PPROF_PATH=chaos-distrib-x86_64-Linux/bin/pprof - export LD_LIBRARY_PATH=/builds/chaos-lnf-control/chaosframework/chaos-distrib-x86_64-Linux/lib @@ -107,7 +107,7 @@ build_u_16_04_gcc5: - git config --global user.name "Claudio Bisegni" - git config --global user.email "Claudio.Bisegni@lnf.infn.it" - tools/chaos_clean.sh - - cmake -DCHAOS_VERSION_MAJOR="$CI_COMMIT_REF_NAME.$CHAOS_LIB_HASH" -DCHAOS_VERSION_MINOR="$CI_JOB_STAGE.$CI_COMMIT_SHA" -DCHAOS_BUILD_ID=${CI_PIPELINE_ID} -DCHAOS_ARCHITECTURE_TEST=ON -DCHAOS_SANITIZER=TestFramework . + - cmake -DCHAOS_VERSION_MAJOR="$CI_COMMIT_REF_NAME.$CHAOS_LIB_HASH" -DCHAOS_VERSION_MINOR="$CI_JOB_STAGE.$CI_COMMIT_SHA" -DCHAOS_BUILD_ID=${CI_PIPELINE_ID} -DCHAOS_ARCHITECTURE_TEST=ON -DCHAOS_SANITIZER=TestFramework . - make clean - make -j $NPROC - make install @@ -163,8 +163,10 @@ build_u_18_04_gcc73: script: - git config --global user.name "Claudio Bisegni" - git config --global user.email "Claudio.Bisegni@lnf.infn.it" + - apt -y update + - apt -y install zlib1g-dev libcurl4-gnutls-dev - tools/chaos_clean.sh - - cmake -DCHAOS_VERSION_MAJOR="$CI_COMMIT_REF_NAME.$CHAOS_LIB_HASH" -DCHAOS_VERSION_MINOR="$CI_JOB_STAGE.$CI_COMMIT_SHA" -DCHAOS_BUILD_ID=${CI_PIPELINE_ID} -DCHAOS_ARCHITECTURE_TEST=ON -DUSE_GPT=ON . + - cmake -DCHAOS_PROMETHEUS=ON -DCHAOS_VERSION_MAJOR="$CI_COMMIT_REF_NAME.$CHAOS_LIB_HASH" -DCHAOS_VERSION_MINOR="$CI_JOB_STAGE.$CI_COMMIT_SHA" -DCHAOS_BUILD_ID=${CI_PIPELINE_ID} -DCHAOS_ARCHITECTURE_TEST=ON -DUSE_GPT=ON . - make clean - make -j $NPROC - make install @@ -221,7 +223,9 @@ build_dbg_c7: - git config --global user.name "Claudio Bisegni" - git config --global user.email "Claudio.Bisegni@lnf.infn.it" - tools/chaos_clean.sh - - cmake -DCHAOS_AGENT=OFF -DCHAOS_VERSION_MAJOR="$CI_COMMIT_REF_NAME.$CHAOS_LIB_HASH" -DCHAOS_VERSION_MINOR="$CI_JOB_STAGE.$CI_COMMIT_SHA" -DCHAOS_BUILD_ID=${CI_PIPELINE_ID} -DCHAOS_ARCHITECTURE_TEST=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo . + - yum -y update + - yum -y install libcurl-devel + - cmake -DCHAOS_PROMETHEUS=ON -DCHAOS_AGENT=OFF -DCHAOS_VERSION_MAJOR="$CI_COMMIT_REF_NAME.$CHAOS_LIB_HASH" -DCHAOS_VERSION_MINOR="$CI_JOB_STAGE.$CI_COMMIT_SHA" -DCHAOS_BUILD_ID=${CI_PIPELINE_ID} -DCHAOS_ARCHITECTURE_TEST=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo . - make clean - make -j $NPROC - make install @@ -254,7 +258,7 @@ test_dbg_c7: - git config --global user.name "Claudio Bisegni" - git config --global user.email "Claudio.Bisegni@lnf.infn.it" - export PPROF_PATH=chaos-distrib-x86_64-Linux/bin/pprof - - export LD_LIBRARY_PATH=/builds/chaos-lnf-control/chaosframework/chaos-distrib-x86_64-Linux/lib + - export LD_LIBRARY_PATH=/builds/chaos-lnf-control/chaosframework/chaos-distrib-x86_64-Linux/lib:/builds/chaos-lnf-control/chaosframework/chaos-distrib-x86_64-Linux/lib64 - export HEAPCHECK=normal - chaos-distrib-x86_64-Linux/bin/TestFramework --gtest_repeat=10 --gtest_break_on_failure artifacts: @@ -307,7 +311,9 @@ build_rel_c7: - git config --global user.name "Claudio Bisegni" - git config --global user.email "Claudio.Bisegni@lnf.infn.it" - tools/chaos_clean.sh - - cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCHAOS_VERSION_MAJOR="$CI_COMMIT_REF_NAME.$CHAOS_LIB_HASH" -DCHAOS_VERSION_MINOR="$CI_JOB_STAGE.$CI_COMMIT_SHA" -DCHAOS_BUILD_ID=${CI_PIPELINE_ID} -DCHAOS_ARCHITECTURE_TEST=ON . + - yum -y update + - yum -y install libcurl-devel + - cmake -DCHAOS_PROMETHEUS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCHAOS_VERSION_MAJOR="$CI_COMMIT_REF_NAME.$CHAOS_LIB_HASH" -DCHAOS_VERSION_MINOR="$CI_JOB_STAGE.$CI_COMMIT_SHA" -DCHAOS_BUILD_ID=${CI_PIPELINE_ID} -DCHAOS_ARCHITECTURE_TEST=ON . - make clean - make -j $NPROC - make install diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000000000000000000000000000000000000..f969eb7ac3c6828996cbb9663d20cd068f49e905 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,21 @@ +{ + "configurations": [ + { + "name": "Mac", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "macFrameworkPath": [ + "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks" + ], + "compilerPath": "/usr/bin/clang", + "cStandard": "c11", + "cppStandard": "c++17", + "intelliSenseMode": "clang-x64", + "compileCommands": "${workspaceFolder}/build/compile_commands.json", + "configurationProvider": "vector-of-bool.cmake-tools" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/cmake-variants.yaml b/.vscode/cmake-variants.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ef6d781c4cb254f4c35e7fa299e426ab5c8711ae --- /dev/null +++ b/.vscode/cmake-variants.yaml @@ -0,0 +1,60 @@ +buildType: + default: debug + choices: + debug: + short: Debug + long: Emit debug information + buildType: Debug + release: + short: Release + long: Optimize generated code + buildType: Release + asan: + short: Asan + long: Instrument with Address Sanitizer + buildType: Asan + tsan: + short: Tsan + long: Instrument with Thread Sanitizer + buildType: Tsan +prometheus: + default: off + choices: + on: + short: PrometheusON + long: Active the prometeus metrics + settings: + CHAOS_PROMETHEUS: ON + off: + short: PrometheusOFF + long: Disable the prometeus metrics + settings: + CHAOS_PROMETHEUS: OFF + +boost_dynamic: + default: off + choices: + on: + short: BoostDynON + long: Active the boost dinamic link + settings: + CHAOS_BOOST_DYNAMIC: ON + off: + short: BoostDynOFF + long: Disable the boost dinamic link + settings: + CHAOS_BOOST_DYNAMIC: OFF + +test: + default: on + choices: + on: + short: TestON + long: Active the test building + settings: + CHAOS_ARCHITECTURE_TEST: ON + off: + short: TestOFF + long: Disable the test building + settings: + CHAOS_ARCHITECTURE_TEST: OFF \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000000000000000000000000000000000..c72ea1f3812abe70fb19e242c19ff4a3b8549c0b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "(lldb) Launch", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/a.out", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": true, + "MIMode": "lldb" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..c4d2515283c9902be7b84fbec8ec6758a2af6dab --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,29 @@ +{ + "C_Cpp.default.configurationProvider": "go2sh.cmake-integration", + "fileHeaderCommentHelper.languageConfigs": { + "language_cpp":{ + "template": [ + "/*", + "* Copyright 2012, 2019 INFN", + "*", + "* Licensed under the EUPL, Version 1.2 or – as soon they", + "* will be approved by the European Commission - subsequent", + "* versions of the EUPL (the "Licence");", + "* You may not use this work except in compliance with the", + "* Licence.", + "* You may obtain a copy of the Licence at:", + "*", + "* https://joinup.ec.europa.eu/software/page/eupl", + "*", + "* Unless required by applicable law or agreed to in", + "* writing, software distributed under the Licence is", + "* distributed on an "AS IS" basis,", + "* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either", + "* express or implied.", + "* See the Licence for the specific language governing", + "* permissions and limitations under the Licence.", + "*/" + ] + } + } +} \ No newline at end of file diff --git a/CHAOSFramework.xcodeproj/project.pbxproj b/CHAOSFramework.xcodeproj/project.pbxproj index 13994577194bf15c5d71ffb1d8ac371499137160..4e94dd879db74313bb75e7b3e88fd406c68c2380 100644 --- a/CHAOSFramework.xcodeproj/project.pbxproj +++ b/CHAOSFramework.xcodeproj/project.pbxproj @@ -170,6 +170,8 @@ 3234BE7B1B034AFC00AE6B08 /* AbstractQuantumKeyAttributeHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 3234BE791B034AFC00AE6B08 /* AbstractQuantumKeyAttributeHandler.h */; }; 3234BE801B04CC9400AE6B08 /* HealtStatusAttributeHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 3234BE7E1B04CC9400AE6B08 /* HealtStatusAttributeHandler.h */; }; 3235110A17B3EAE500E39E14 /* TemplatedConcurrentQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 3235110817B3EAE500E39E14 /* TemplatedConcurrentQueue.h */; }; + 323595E822ECBC3200CFB66C /* MetricManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 323595E622ECBC3200CFB66C /* MetricManager.cpp */; }; + 323595E922ECBC3200CFB66C /* MetricManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 323595E722ECBC3200CFB66C /* MetricManager.h */; }; 3235FDD61A6FF8A800EC83A9 /* MongoDBUnitServerDataAccess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3235FDD41A6FF8A800EC83A9 /* MongoDBUnitServerDataAccess.cpp */; }; 3235FDD91A6FFA6600EC83A9 /* MongoDBPersistenceDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3235FDD71A6FFA6600EC83A9 /* MongoDBPersistenceDriver.cpp */; }; 32362C211ADD0C45000CA079 /* SetInstanceDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32362C1F1ADD0C45000CA079 /* SetInstanceDescription.cpp */; }; @@ -479,7 +481,6 @@ 326ACF9C1E01594C00AD011E /* QueryDataConsumer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 326ACF991E01594C00AD011E /* QueryDataConsumer.cpp */; }; 326ACFA81E0159C600AD011E /* DataWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 326ACF9E1E0159C600AD011E /* DataWorker.cpp */; }; 326ACFA91E0159C600AD011E /* DeviceSharedDataWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 326ACFA01E0159C600AD011E /* DeviceSharedDataWorker.cpp */; }; - 326ACFAA1E0159C600AD011E /* DeviceSharedDataWorkerMetric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 326ACFA21E0159C600AD011E /* DeviceSharedDataWorkerMetric.cpp */; }; 326ACFAB1E0159C600AD011E /* DeviceSharedDataWorkerMetricCollector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 326ACFA41E0159C600AD011E /* DeviceSharedDataWorkerMetricCollector.cpp */; }; 326BB29E1E3753DB00BFA602 /* ProxyControlUnit.h in Headers */ = {isa = PBXBuildFile; fileRef = 326BB29C1E3753DB00BFA602 /* ProxyControlUnit.h */; }; 326BB29F1E3753E200BFA602 /* ProxyControlUnit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 326BB29B1E3753DB00BFA602 /* ProxyControlUnit.cpp */; }; @@ -710,8 +711,6 @@ 329C1F061B5643EF00A84D55 /* DirectIODispatcherMetricCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = 329C1F041B5643EF00A84D55 /* DirectIODispatcherMetricCollector.h */; }; 329C1F091B567C8400A84D55 /* DirectIOClientConnectionMetricCollector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 329C1F071B567C8400A84D55 /* DirectIOClientConnectionMetricCollector.cpp */; }; 329C1F0A1B567C8400A84D55 /* DirectIOClientConnectionMetricCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = 329C1F081B567C8400A84D55 /* DirectIOClientConnectionMetricCollector.h */; }; - 329C1F0D1B568EA600A84D55 /* DirectIOClientConnectionSharedMetricIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 329C1F0B1B568EA600A84D55 /* DirectIOClientConnectionSharedMetricIO.cpp */; }; - 329C1F0E1B568EA600A84D55 /* DirectIOClientConnectionSharedMetricIO.h in Headers */ = {isa = PBXBuildFile; fileRef = 329C1F0C1B568EA600A84D55 /* DirectIOClientConnectionSharedMetricIO.h */; }; 329CFCF318CDEE2F002C37CF /* ObjectSlot.h in Headers */ = {isa = PBXBuildFile; fileRef = 329CFCF218CDEE2F002C37CF /* ObjectSlot.h */; }; 329DEB731D2E457F0050E914 /* chaos_errors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 329DEB721D2E457F0050E914 /* chaos_errors.cpp */; }; 329FFFD1170712CE00D69CDE /* ManagedMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 329FFFCF170712CE00D69CDE /* ManagedMemory.cpp */; }; @@ -1116,10 +1115,6 @@ 32EBDEFB1B4E58F300278C42 /* MetricCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = 32EBDEF91B4E58F300278C42 /* MetricCollector.h */; }; 32EBDEFE1B4E6FC700278C42 /* RpcClientMetricCollector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32EBDEFC1B4E6FC700278C42 /* RpcClientMetricCollector.cpp */; }; 32EBDEFF1B4E6FC700278C42 /* RpcClientMetricCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = 32EBDEFD1B4E6FC700278C42 /* RpcClientMetricCollector.h */; }; - 32EBDF021B4FBD8800278C42 /* AbstractMetricBackend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32EBDF001B4FBD8800278C42 /* AbstractMetricBackend.cpp */; }; - 32EBDF031B4FBD8800278C42 /* AbstractMetricBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 32EBDF011B4FBD8800278C42 /* AbstractMetricBackend.h */; }; - 32EBDF061B4FCA6F00278C42 /* ConsoleMetricBackend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32EBDF041B4FCA6F00278C42 /* ConsoleMetricBackend.cpp */; }; - 32EBDF071B4FCA6F00278C42 /* ConsoleMetricBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 32EBDF051B4FCA6F00278C42 /* ConsoleMetricBackend.h */; }; 32EBDF0E1B53A32600278C42 /* ManageCUType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32EBDF0C1B53A32600278C42 /* ManageCUType.cpp */; }; 32EBDF0F1B53A32600278C42 /* ManageCUType.h in Headers */ = {isa = PBXBuildFile; fileRef = 32EBDF0D1B53A32600278C42 /* ManageCUType.h */; }; 32ED648E14E2DCFC00A73CF9 /* SingleBufferCircularBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 32ED648D14E2DCFC00A73CF9 /* SingleBufferCircularBuffer.h */; }; @@ -1133,10 +1128,6 @@ 32F2241F179AEED500853F62 /* SCAbstractControlUnit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32F2241D179AEED500853F62 /* SCAbstractControlUnit.cpp */; }; 32F22420179AEED500853F62 /* SCAbstractControlUnit.h in Headers */ = {isa = PBXBuildFile; fileRef = 32F2241E179AEED500853F62 /* SCAbstractControlUnit.h */; }; 32F466DE155EDBDE00AD3D81 /* IODataDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32F466DD155EDBDE00AD3D81 /* IODataDriver.cpp */; }; - 32F5B0061B5F8EBF00457A63 /* FileMetricBackend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32F5B0041B5F8EBF00457A63 /* FileMetricBackend.cpp */; }; - 32F5B0071B5F8EBF00457A63 /* FileMetricBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 32F5B0051B5F8EBF00457A63 /* FileMetricBackend.h */; }; - 32F5B00A1B5F998F00457A63 /* CSVFileMetricBackend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32F5B0081B5F998F00457A63 /* CSVFileMetricBackend.cpp */; }; - 32F5B00B1B5F998F00457A63 /* CSVFileMetricBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 32F5B0091B5F998F00457A63 /* CSVFileMetricBackend.h */; }; 32F7AB141C9960A700E18D3E /* NodeMonitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32F7AB121C9960A700E18D3E /* NodeMonitor.cpp */; }; 32F7AB151C9960A700E18D3E /* NodeMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 32F7AB131C9960A700E18D3E /* NodeMonitor.h */; }; 32F7AB191C9964AE00E18D3E /* node_monitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 32F7AB171C9964AE00E18D3E /* node_monitor.h */; }; @@ -1461,6 +1452,8 @@ 3234BE7E1B04CC9400AE6B08 /* HealtStatusAttributeHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HealtStatusAttributeHandler.h; sourceTree = "<group>"; }; 3234BE811B04F49F00AE6B08 /* HealtHeartbeatAttributeHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HealtHeartbeatAttributeHandler.h; sourceTree = "<group>"; }; 3235110817B3EAE500E39E14 /* TemplatedConcurrentQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemplatedConcurrentQueue.h; sourceTree = "<group>"; }; + 323595E622ECBC3200CFB66C /* MetricManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MetricManager.cpp; sourceTree = "<group>"; }; + 323595E722ECBC3200CFB66C /* MetricManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MetricManager.h; sourceTree = "<group>"; }; 3235FDCB1A6FF51D00EC83A9 /* persistence.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = persistence.h; sourceTree = "<group>"; }; 3235FDD41A6FF8A800EC83A9 /* MongoDBUnitServerDataAccess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MongoDBUnitServerDataAccess.cpp; sourceTree = "<group>"; }; 3235FDD51A6FF8A800EC83A9 /* MongoDBUnitServerDataAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MongoDBUnitServerDataAccess.h; sourceTree = "<group>"; }; @@ -1886,8 +1879,6 @@ 326ACF9F1E0159C600AD011E /* DataWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataWorker.h; sourceTree = "<group>"; }; 326ACFA01E0159C600AD011E /* DeviceSharedDataWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceSharedDataWorker.cpp; sourceTree = "<group>"; }; 326ACFA11E0159C600AD011E /* DeviceSharedDataWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceSharedDataWorker.h; sourceTree = "<group>"; }; - 326ACFA21E0159C600AD011E /* DeviceSharedDataWorkerMetric.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceSharedDataWorkerMetric.cpp; sourceTree = "<group>"; }; - 326ACFA31E0159C600AD011E /* DeviceSharedDataWorkerMetric.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceSharedDataWorkerMetric.h; sourceTree = "<group>"; }; 326ACFA41E0159C600AD011E /* DeviceSharedDataWorkerMetricCollector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceSharedDataWorkerMetricCollector.cpp; sourceTree = "<group>"; }; 326ACFA51E0159C600AD011E /* DeviceSharedDataWorkerMetricCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceSharedDataWorkerMetricCollector.h; sourceTree = "<group>"; }; 326BB29B1E3753DB00BFA602 /* ProxyControlUnit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProxyControlUnit.cpp; sourceTree = "<group>"; }; @@ -2160,8 +2151,6 @@ 329C1F041B5643EF00A84D55 /* DirectIODispatcherMetricCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectIODispatcherMetricCollector.h; sourceTree = "<group>"; }; 329C1F071B567C8400A84D55 /* DirectIOClientConnectionMetricCollector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DirectIOClientConnectionMetricCollector.cpp; sourceTree = "<group>"; }; 329C1F081B567C8400A84D55 /* DirectIOClientConnectionMetricCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectIOClientConnectionMetricCollector.h; sourceTree = "<group>"; }; - 329C1F0B1B568EA600A84D55 /* DirectIOClientConnectionSharedMetricIO.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DirectIOClientConnectionSharedMetricIO.cpp; sourceTree = "<group>"; }; - 329C1F0C1B568EA600A84D55 /* DirectIOClientConnectionSharedMetricIO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectIOClientConnectionSharedMetricIO.h; sourceTree = "<group>"; }; 329C1F101B58F46700A84D55 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; }; 329CFCF218CDEE2F002C37CF /* ObjectSlot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectSlot.h; sourceTree = "<group>"; }; 329DEB721D2E457F0050E914 /* chaos_errors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chaos_errors.cpp; sourceTree = "<group>"; }; @@ -2711,10 +2700,6 @@ 32EBDEF91B4E58F300278C42 /* MetricCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MetricCollector.h; sourceTree = "<group>"; }; 32EBDEFC1B4E6FC700278C42 /* RpcClientMetricCollector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = RpcClientMetricCollector.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 32EBDEFD1B4E6FC700278C42 /* RpcClientMetricCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RpcClientMetricCollector.h; sourceTree = "<group>"; }; - 32EBDF001B4FBD8800278C42 /* AbstractMetricBackend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AbstractMetricBackend.cpp; sourceTree = "<group>"; }; - 32EBDF011B4FBD8800278C42 /* AbstractMetricBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractMetricBackend.h; sourceTree = "<group>"; }; - 32EBDF041B4FCA6F00278C42 /* ConsoleMetricBackend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConsoleMetricBackend.cpp; sourceTree = "<group>"; }; - 32EBDF051B4FCA6F00278C42 /* ConsoleMetricBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConsoleMetricBackend.h; sourceTree = "<group>"; }; 32EBDF081B4FEFDC00278C42 /* metric.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = metric.h; sourceTree = "<group>"; }; 32EBDF0C1B53A32600278C42 /* ManageCUType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ManageCUType.cpp; sourceTree = "<group>"; }; 32EBDF0D1B53A32600278C42 /* ManageCUType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ManageCUType.h; sourceTree = "<group>"; }; @@ -2730,10 +2715,6 @@ 32F2241D179AEED500853F62 /* SCAbstractControlUnit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SCAbstractControlUnit.cpp; sourceTree = "<group>"; }; 32F2241E179AEED500853F62 /* SCAbstractControlUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCAbstractControlUnit.h; sourceTree = "<group>"; }; 32F466DD155EDBDE00AD3D81 /* IODataDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IODataDriver.cpp; sourceTree = "<group>"; }; - 32F5B0041B5F8EBF00457A63 /* FileMetricBackend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileMetricBackend.cpp; sourceTree = "<group>"; }; - 32F5B0051B5F8EBF00457A63 /* FileMetricBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileMetricBackend.h; sourceTree = "<group>"; }; - 32F5B0081B5F998F00457A63 /* CSVFileMetricBackend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSVFileMetricBackend.cpp; sourceTree = "<group>"; }; - 32F5B0091B5F998F00457A63 /* CSVFileMetricBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSVFileMetricBackend.h; sourceTree = "<group>"; }; 32F7AB121C9960A700E18D3E /* NodeMonitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NodeMonitor.cpp; sourceTree = "<group>"; }; 32F7AB131C9960A700E18D3E /* NodeMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeMonitor.h; sourceTree = "<group>"; }; 32F7AB171C9964AE00E18D3E /* node_monitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = node_monitor.h; sourceTree = "<group>"; }; @@ -4218,8 +4199,6 @@ 326ACF9F1E0159C600AD011E /* DataWorker.h */, 326ACFA01E0159C600AD011E /* DeviceSharedDataWorker.cpp */, 326ACFA11E0159C600AD011E /* DeviceSharedDataWorker.h */, - 326ACFA21E0159C600AD011E /* DeviceSharedDataWorkerMetric.cpp */, - 326ACFA31E0159C600AD011E /* DeviceSharedDataWorkerMetric.h */, 326ACFA41E0159C600AD011E /* DeviceSharedDataWorkerMetricCollector.cpp */, 326ACFA51E0159C600AD011E /* DeviceSharedDataWorkerMetricCollector.h */, ); @@ -4750,8 +4729,6 @@ 328556A317F2E36000A64ED2 /* DirectIOServer.h */, 3219E69D18CC7AE600C2F795 /* DirectIOClientConnection.cpp */, 3219E69E18CC7AE600C2F795 /* DirectIOClientConnection.h */, - 329C1F0B1B568EA600A84D55 /* DirectIOClientConnectionSharedMetricIO.cpp */, - 329C1F0C1B568EA600A84D55 /* DirectIOClientConnectionSharedMetricIO.h */, 329C1F071B567C8400A84D55 /* DirectIOClientConnectionMetricCollector.cpp */, 329C1F081B567C8400A84D55 /* DirectIOClientConnectionMetricCollector.h */, 32EA501018A152BE00782435 /* DirectIOServerEndpoint.cpp */, @@ -5795,18 +5772,12 @@ 32EBDEF31B4E586000278C42 /* metric */ = { isa = PBXGroup; children = ( + 323595E622ECBC3200CFB66C /* MetricManager.cpp */, + 323595E722ECBC3200CFB66C /* MetricManager.h */, 32EBDEF81B4E58F300278C42 /* MetricCollector.cpp */, 32EBDEF91B4E58F300278C42 /* MetricCollector.h */, 329C1EFF1B5540F900A84D55 /* MetricCollectorIO.cpp */, 329C1F001B5540F900A84D55 /* MetricCollectorIO.h */, - 32EBDF001B4FBD8800278C42 /* AbstractMetricBackend.cpp */, - 32EBDF011B4FBD8800278C42 /* AbstractMetricBackend.h */, - 32EBDF041B4FCA6F00278C42 /* ConsoleMetricBackend.cpp */, - 32EBDF051B4FCA6F00278C42 /* ConsoleMetricBackend.h */, - 32F5B0041B5F8EBF00457A63 /* FileMetricBackend.cpp */, - 32F5B0051B5F8EBF00457A63 /* FileMetricBackend.h */, - 32F5B0081B5F998F00457A63 /* CSVFileMetricBackend.cpp */, - 32F5B0091B5F998F00457A63 /* CSVFileMetricBackend.h */, 32EBDF081B4FEFDC00278C42 /* metric.h */, ); path = metric; @@ -6122,7 +6093,6 @@ 32A88BE01CF8228A001DBAF5 /* lstate.h in Headers */, 32A88BCD1CF8228A001DBAF5 /* lgc.h in Headers */, 325013D815E980C800DCB13E /* AsioImplEventClient.h in Headers */, - 32EBDF071B4FCA6F00278C42 /* ConsoleMetricBackend.h in Headers */, 32FB20211A3F2E7300307A86 /* AbstractSharedDomainCache.h in Headers */, 32571D9D1C7C901A0001D884 /* BatchCommandLoggingChannel.h in Headers */, 3206CE751FA767AC0059A4A4 /* bson-iso8601-private.h in Headers */, @@ -6171,11 +6141,11 @@ 3206CE831FA767AC0059A4A4 /* bson-private.h in Headers */, 3244C0C6168CB96B007C802C /* Record.h in Headers */, 32B73E9B18D9A8FF00F0B187 /* DirectIOPerformanceServerChannel.h in Headers */, + 323595E922ECBC3200CFB66C /* MetricManager.h in Headers */, 3206CE7F1FA767AC0059A4A4 /* bson-error.h in Headers */, 32C0CC99168CC16400BC2DA7 /* Entity.h in Headers */, 32B73E9718D9A74600F0B187 /* DirectIOPerformanceClientChannel.h in Headers */, 3219E6A018CC7AE600C2F795 /* DirectIOClientConnection.h in Headers */, - 32F5B00B1B5F998F00457A63 /* CSVFileMetricBackend.h in Headers */, 3206CE901FA767AC0059A4A4 /* bson-md5.h in Headers */, 32F7FEAB18A5066600FC03AB /* FastDelegate.h in Headers */, 32B5C9591C6B97590021159C /* ErrorLoggingChannel.h in Headers */, @@ -6199,7 +6169,6 @@ 32C25E131DBFB8DC00A46C2B /* alarm.h in Headers */, 32A862231D58CB2300A7D707 /* trigger.h in Headers */, 32C25DEC1DB7A4B900A46C2B /* HealthStat.h in Headers */, - 32F5B0071B5F8EBF00457A63 /* FileMetricBackend.h in Headers */, 322EC1B81D3406650012467C /* StateFlag.h in Headers */, 329C1F061B5643EF00A84D55 /* DirectIODispatcherMetricCollector.h in Headers */, 32C35467178860E5009ED581 /* extension.hpp in Headers */, @@ -6241,7 +6210,6 @@ 32640A36169DCC5800450962 /* DataElement.h in Headers */, 32640A37169DCC5800450962 /* SmartData.h in Headers */, 32640A38169DCC5800450962 /* Element.h in Headers */, - 32EBDF031B4FBD8800278C42 /* AbstractMetricBackend.h in Headers */, 32640A39169DCC5800450962 /* IdFactory.h in Headers */, 325545E61F8E56E700781908 /* ExternalUnitServerEndpoint.h in Headers */, 32640A3A169DCC5800450962 /* MillisTime.h in Headers */, @@ -6290,7 +6258,6 @@ 32A8F7D2172BE3FD0090DB78 /* KeyGroupCache.h in Headers */, 32A88BDA1CF8228A001DBAF5 /* lopcodes.h in Headers */, 32FF2AAA1E6D79EC00117985 /* DataBuffer.h in Headers */, - 329C1F0E1B568EA600A84D55 /* DirectIOClientConnectionSharedMetricIO.h in Headers */, 32A88BD11CF8228A001DBAF5 /* llex.h in Headers */, 3298487E1736814700C158DF /* ChannelValueAccessor.h in Headers */, 32B73E9F18D9D80F00F0B187 /* PerformanceManagment.h in Headers */, @@ -6902,7 +6869,6 @@ 32A626C6213FBC0600D63009 /* SetInputDatasetAttributeValues.cpp in Sources */, 32E9781A2018E41000882958 /* GetAgentForNode.cpp in Sources */, 32514EF21EA8BA13001FF6B8 /* UpdateScriptOnNode.cpp in Sources */, - 326ACFAA1E0159C600AD011E /* DeviceSharedDataWorkerMetric.cpp in Sources */, 328E78061A7A9FE40008C070 /* AbstractApi.cpp in Sources */, 32B6B79D213EA6DD00D7ECF8 /* SearchScript.cpp in Sources */, 32B6B737213E736D00D7ECF8 /* SubmitEntry.cpp in Sources */, @@ -7050,11 +7016,11 @@ 326DB43314B38BC00018A8D0 /* DeclareAction.cpp in Sources */, 326DB43514B38BC00018A8D0 /* DomainActions.cpp in Sources */, 325A84CF2108970D0036C1CA /* FSUtility.cpp in Sources */, + 323595E822ECBC3200CFB66C /* MetricManager.cpp in Sources */, 326DB45A14B38BC00018A8D0 /* GlobalConfiguration.cpp in Sources */, 32A88BE11CF8228A001DBAF5 /* lstring.c in Sources */, 32995C4E1BB421D400F68148 /* AggregatedCheckList.cpp in Sources */, 32F9F8121D8FD45A0023948D /* CronusManager.cpp in Sources */, - 32F5B00A1B5F998F00457A63 /* CSVFileMetricBackend.cpp in Sources */, 32FB20181A3F0FAB00307A86 /* AttributeValue.cpp in Sources */, 32995C4A1BB2FF2600F68148 /* CheckList.cpp in Sources */, 3275B1731FC4316A00BB7C77 /* ExternalBSONJsonSerialization.cpp in Sources */, @@ -7092,7 +7058,6 @@ 32FC49B31E0AAFBE0087D82C /* AbstractSandbox.cpp in Sources */, 32EA501618A15BF000782435 /* DirectIODispatcher.cpp in Sources */, 32A88BCA1CF8228A001DBAF5 /* lfunc.c in Sources */, - 32F5B0061B5F8EBF00457A63 /* FileMetricBackend.cpp in Sources */, 329C1EFD1B55286100A84D55 /* RpcServerMetricCollector.cpp in Sources */, 32C25DF81DB9F29200A46C2B /* AlarmLoggingChannel.cpp in Sources */, 32C100FB191B847800478F40 /* TimerHandler.cpp in Sources */, @@ -7100,7 +7065,6 @@ 32A968521D522FB800BD636C /* PropertyGroup.cpp in Sources */, 32A88BC91CF8228A001DBAF5 /* ldump.c in Sources */, 327967B815DFAAF40003C6DA /* RpcServer.cpp in Sources */, - 329C1F0D1B568EA600A84D55 /* DirectIOClientConnectionSharedMetricIO.cpp in Sources */, 32B6BD341E1E88F800A9F86C /* SharedCommandDispatcher.cpp in Sources */, 32F9F8161D8FD7030023948D /* CronJob.cpp in Sources */, 327967D515E029C70003C6DA /* AsioImplEventServer.cpp in Sources */, @@ -7209,7 +7173,6 @@ 326420671F8A1CDB00B58E3E /* HTTPServerAdapter.cpp in Sources */, 3268CE37161608D100FCDB10 /* ZMQServer.cpp in Sources */, 325D2FCD1AFA19E500B2A706 /* HealtManager.cpp in Sources */, - 32EBDF021B4FBD8800278C42 /* AbstractMetricBackend.cpp in Sources */, 32B6BD3C1E23CD8900A9F86C /* DeviceMessageChannel.cpp in Sources */, 322E157A161B629700C3003C /* NetworkBroker.cpp in Sources */, 32BF74AD167CEB57007F8A57 /* EntityDB.cpp in Sources */, @@ -7240,7 +7203,6 @@ 3230BEC2181A6ADB00EA5793 /* DatasetDB.cpp in Sources */, 32AF7D4018DAEAF300537DE6 /* PerformanceNodeChannel.cpp in Sources */, 324928531F597E4500409E83 /* PropertyCollector.cpp in Sources */, - 32EBDF061B4FCA6F00278C42 /* ConsoleMetricBackend.cpp in Sources */, 32067EA11CABEE8800DE568A /* CDataVariant.cpp in Sources */, 3206CE631FA767AC0059A4A4 /* bson-context.c in Sources */, 324544F81D4A55ED0081F90B /* AbstractListener.cpp in Sources */, @@ -7613,14 +7575,19 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/usr/local/bin"; COPY_PHASE_STRIP = NO; + EXCLUDED_SOURCE_FILE_NAMES = ( + "CacheDriverMetricCollector.*", + "CacheDriverSharedMetricIO.*", + "DeviceSharedDataWorkerMetricCollector.*", + ); GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = "USE_CASSANDRA_DRIVER=1"; - "GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = ( + GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", + "USE_CASSANDRA_DRIVER=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_VERSION = ""; @@ -7639,12 +7606,12 @@ MACOSX_DEPLOYMENT_TARGET = 10.10; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = ( + "$(inherited)", "-lchaos_common", "-ljsoncpp", "-levent", "-lcassandra", "-lmongoclient", - "-lboost_random", "-lmongocxx", "-lbsoncxx", "-lboost_timer", @@ -7666,6 +7633,7 @@ CONFIGURATION_BUILD_DIR = "$(SRCROOT)/usr/local/bin"; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + EXCLUDED_SOURCE_FILE_NAMES = "DeviceSharedDataWorkerMetricCollector.*"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_OPTIMIZATION_LEVEL = 0; @@ -7685,12 +7653,12 @@ LIBRARY_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; MACOSX_DEPLOYMENT_TARGET = 10.10; OTHER_LDFLAGS = ( + "$(inherited)", "-lchaos_common", "-ljsoncpp", "-levent", "-lcassandra", "-lmongoclient", - "-lboost_random", "-lmongocxx", "-lbsoncxx", "-lboost_timer", @@ -8104,7 +8072,18 @@ usr/local/include, ); LIBRARY_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; - ONLY_ACTIVE_ARCH = YES; + ONLY_ACTIVE_ARCH = NO; + OTHER_LDFLAGS = ( + "-lboost_log_setup", + "-lboost_random", + "-lboost_log", + "-lboost_filesystem", + "-lboost_regex", + "-lboost_program_options", + "-lboost_thread", + "-lboost_system", + "-lboost_chrono", + ); }; name = Debug; }; @@ -8121,6 +8100,18 @@ usr/local/include, ); LIBRARY_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; + ONLY_ACTIVE_ARCH = NO; + OTHER_LDFLAGS = ( + "-lboost_log_setup", + "-lboost_random", + "-lboost_log", + "-lboost_filesystem", + "-lboost_regex", + "-lboost_program_options", + "-lboost_thread", + "-lboost_system", + "-lboost_chrono", + ); }; name = Release; }; @@ -8132,6 +8123,15 @@ CONFIGURATION_BUILD_DIR = "$(SRCROOT)/usr/local/lib"; COPY_PHASE_STRIP = NO; DSTROOT = /; + EXCLUDED_SOURCE_FILE_NAMES = ( + metric.h, + "Metric*.h", + "Metric*.cpp", + "RpcClientMetricCollector.*", + "RpcServerMetricCollector.*", + "DirectIOClientConnectionMetricCollector.*", + "DirectIODispatcherMetricCollector.*", + ); EXECUTABLE_PREFIX = lib; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; @@ -8158,15 +8158,7 @@ ONLY_ACTIVE_ARCH = YES; OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; OTHER_LDFLAGS = ( - "-lboost_chrono", - "-lboost_system", - "-lboost_thread", - "-lboost_program_options", - "-lboost_regex", - "-lboost_filesystem", - "-lboost_log", - "-lboost_random", - "-lboost_log_setup", + "$(inherited)", "-lzmq", "-ljsoncpp", ); @@ -8204,15 +8196,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.10; OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; OTHER_LDFLAGS = ( - "-lboost_chrono", - "-lboost_system", - "-lboost_thread", - "-lboost_program_options", - "-lboost_regex", - "-lboost_filesystem", - "-lboost_log", - "-lboost_random", - "-lboost_log_setup", + "$(inherited)", "-lzmq", "-ljsoncpp", ); @@ -8253,7 +8237,10 @@ MACOSX_DEPLOYMENT_TARGET = 10.10; ONLY_ACTIVE_ARCH = YES; OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; - OTHER_LDFLAGS = "-lchaos_common"; + OTHER_LDFLAGS = ( + "$(inherited)", + "-lchaos_common", + ); PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; }; @@ -8284,7 +8271,10 @@ LIBRARY_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; MACOSX_DEPLOYMENT_TARGET = 10.10; OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; - OTHER_LDFLAGS = "-lchaos_common"; + OTHER_LDFLAGS = ( + "$(inherited)", + "-lchaos_common", + ); PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; }; @@ -8623,6 +8613,604 @@ }; name = Release; }; + 32CDED1A22EC8DC2002B5C20 /* Prometheus */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + COMPILER_INDEX_STORE_ENABLE = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_PREPROCESSOR_DEFINITIONS = "CHAOS_PROMETHEUS=1"; + HEADER_SEARCH_PATHS = ( + ., + usr/local/include, + ); + LIBRARY_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ( + "-lboost_log_setup", + "-lboost_random", + "-lboost_log", + "-lboost_filesystem", + "-lboost_regex", + "-lboost_program_options", + "-lboost_thread", + "-lboost_system", + "-lboost_chrono", + ); + }; + name = Prometheus; + }; + 32CDED1B22EC8DC2002B5C20 /* Prometheus */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CONFIGURATION_BUILD_DIR = "$(SRCROOT)/usr/local/lib"; + COPY_PHASE_STRIP = NO; + DSTROOT = /; + EXECUTABLE_PREFIX = lib; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_LINK_WITH_DYNAMIC_LIBRARIES = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = ""; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + ., + usr/local/include, + ); + INSTALL_PATH = "$(SRCROOT)/usr/local/lib"; + LIBRARY_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; + MACOSX_DEPLOYMENT_TARGET = 10.10; + ONLY_ACTIVE_ARCH = YES; + OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; + OTHER_LDFLAGS = ( + "$(inherited)", + "-lzmq", + "-ljsoncpp", + "-lprometheus-cpp-core", + "-lprometheus-cpp-pull", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Prometheus; + }; + 32CDED1C22EC8DC2002B5C20 /* Prometheus */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ENABLE_CODE_COVERAGE = YES; + CONFIGURATION_BUILD_DIR = "$(SRCROOT)/usr/local/lib"; + COPY_PHASE_STRIP = NO; + DSTROOT = /; + EXECUTABLE_PREFIX = lib; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = ""; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + ., + usr/local/include, + ); + INSTALL_PATH = "$(SRCROOT)/usr/local/lib"; + LIBRARY_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; + MACOSX_DEPLOYMENT_TARGET = 10.10; + ONLY_ACTIVE_ARCH = YES; + OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; + OTHER_LDFLAGS = ( + "$(inherited)", + "-lchaos_common", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Prometheus; + }; + 32CDED1D22EC8DC2002B5C20 /* Prometheus */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CONFIGURATION_BUILD_DIR = "$(SRCROOT)/usr/local/lib"; + COPY_PHASE_STRIP = NO; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + ENABLE_STRICT_OBJC_MSGSEND = YES; + EXECUTABLE_PREFIX = lib; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + ., + usr/local/include, + ); + INSTALL_PATH = "$(SRCROOT)/usr/local/lib"; + LIBRARY_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = "-lchaos_common"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Prometheus; + }; + 32CDED1E22EC8DC2002B5C20 /* Prometheus */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + CONFIGURATION_BUILD_DIR = "$(SRCROOT)/usr/local/lib"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = ZZ5BMKV37Y; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + EXECUTABLE_PREFIX = lib; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_CPP_EXCEPTIONS = YES; + GCC_ENABLE_CPP_RTTI = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + ., + usr/local/include, + ); + INSTALL_PATH = "$(SRCROOT)/usr/local/lib"; + LIBRARY_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; + MACOSX_DEPLOYMENT_TARGET = 10.12; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = "-lboost_system"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Prometheus; + }; + 32CDED1F22EC8DC2002B5C20 /* Prometheus */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CONFIGURATION_BUILD_DIR = "$(SRCROOT)/usr/local/bin"; + COPY_PHASE_STRIP = NO; + EXCLUDED_SOURCE_FILE_NAMES = ""; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "DEBUG=1", + "USE_CASSANDRA_DRIVER=1", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = ""; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + ., + usr/local/include, + usr/local/include/bsoncxx/v_noabi, + usr/local/include/mongocxx/v_noabi, + ); + LD_RUNPATH_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; + LIBRARY_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; + MACOSX_DEPLOYMENT_TARGET = 10.10; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ( + "$(inherited)", + "-lchaos_common", + "-ljsoncpp", + "-levent", + "-lcassandra", + "-lmongoclient", + "-lmongocxx", + "-lbsoncxx", + "-lboost_timer", + "-lcouchbase", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Prometheus; + }; + 32CDED2022EC8DC2002B5C20 /* Prometheus */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + CONFIGURATION_BUILD_DIR = "$(SRCROOT)/usr/local/bin"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = ZZ5BMKV37Y; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + ., + usr/local/include, + ); + LIBRARY_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; + MACOSX_DEPLOYMENT_TARGET = 10.12; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ( + "-lchaos_common", + "-ljsoncpp", + "-levent", + "-lmongoclient", + "-lcouchbase", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Prometheus; + }; + 32CDED2122EC8DC2002B5C20 /* Prometheus */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CONFIGURATION_BUILD_DIR = "$(SRCROOT)/usr/local/bin"; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + ., + usr/local/include, + ); + LD_RUNPATH_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; + LIBRARY_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ( + "-lchaos_metadata_service_client", + "-lchaos_common", + "-lboost_timer", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Prometheus; + }; + 32CDED2222EC8DC2002B5C20 /* Prometheus */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Automatic; + CONFIGURATION_BUILD_DIR = "$(SRCROOT)/usr/local/lib"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + EXECUTABLE_EXTENSION = chaos_extension; + EXECUTABLE_PREFIX = ""; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_CPP_EXCEPTIONS = YES; + GCC_ENABLE_CPP_RTTI = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = "$(SRCROOT)/usr/local/include"; + LIBRARY_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + OTHER_LDFLAGS = ( + "-lchaos_common", + "-lchaos_cutoolkit", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SKIP_INSTALL = YES; + }; + name = Prometheus; + }; + 32CDED2322EC8DC2002B5C20 /* Prometheus */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Automatic; + CONFIGURATION_BUILD_DIR = "$(SRCROOT)/usr/local/bin"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + ., + usr/local/include, + usr/local/include/bsoncxx/v_noabi, + usr/local/include/mongocxx/v_noabi, + ); + LD_RUNPATH_SEARCH_PATHS = "$(SRCROOT)/usr/local/lib"; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + OTHER_LDFLAGS = ( + "-lchaos_common", + "-lgtest", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Prometheus; + }; + 32CDED2422EC8DC2002B5C20 /* Prometheus */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Automatic; + CONFIGURATION_BUILD_DIR = "$(SRCROOT)/usr/local/bin"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = usr/local/include; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + OTHER_LDFLAGS = ( + "-lchaos_common", + "-lgtest", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Prometheus; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -8630,6 +9218,7 @@ isa = XCConfigurationList; buildConfigurations = ( 322085DE1AC5A0E200F1B71A /* Debug */, + 32CDED2122EC8DC2002B5C20 /* Prometheus */, 322085DF1AC5A0E200F1B71A /* Release */, ); defaultConfigurationIsVisible = 0; @@ -8639,6 +9228,7 @@ isa = XCConfigurationList; buildConfigurations = ( 323236CE164573C60052CE06 /* Debug */, + 32CDED1F22EC8DC2002B5C20 /* Prometheus */, 323236CF164573C60052CE06 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -8648,6 +9238,7 @@ isa = XCConfigurationList; buildConfigurations = ( 3238883121627B9600CC8A2B /* Debug */, + 32CDED2322EC8DC2002B5C20 /* Prometheus */, 3238883321627B9600CC8A2B /* Release */, ); defaultConfigurationIsVisible = 0; @@ -8657,6 +9248,7 @@ isa = XCConfigurationList; buildConfigurations = ( 3238889E21627DB600CC8A2B /* Debug */, + 32CDED2222EC8DC2002B5C20 /* Prometheus */, 323888A021627DB600CC8A2B /* Release */, ); defaultConfigurationIsVisible = 0; @@ -8666,6 +9258,7 @@ isa = XCConfigurationList; buildConfigurations = ( 324D089C1F30CD7A00836E29 /* Debug */, + 32CDED1E22EC8DC2002B5C20 /* Prometheus */, 324D089D1F30CD7A00836E29 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -8675,6 +9268,7 @@ isa = XCConfigurationList; buildConfigurations = ( 3260261214B300FE00C906CE /* Debug */, + 32CDED1A22EC8DC2002B5C20 /* Prometheus */, 3260261314B300FE00C906CE /* Release */, ); defaultConfigurationIsVisible = 0; @@ -8684,6 +9278,7 @@ isa = XCConfigurationList; buildConfigurations = ( 326026EC14B301F600C906CE /* Debug */, + 32CDED1B22EC8DC2002B5C20 /* Prometheus */, 326026ED14B301F600C906CE /* Release */, ); defaultConfigurationIsVisible = 0; @@ -8693,6 +9288,7 @@ isa = XCConfigurationList; buildConfigurations = ( 3260276814B3068100C906CE /* Debug */, + 32CDED1C22EC8DC2002B5C20 /* Prometheus */, 3260276914B3068100C906CE /* Release */, ); defaultConfigurationIsVisible = 0; @@ -8702,6 +9298,7 @@ isa = XCConfigurationList; buildConfigurations = ( 3264139E1E44ACE60035E175 /* Debug */, + 32CDED2022EC8DC2002B5C20 /* Prometheus */, 3264139F1E44ACE60035E175 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -8711,6 +9308,7 @@ isa = XCConfigurationList; buildConfigurations = ( 32661C671AA73D5C00F1A721 /* Debug */, + 32CDED1D22EC8DC2002B5C20 /* Prometheus */, 32661C681AA73D5C00F1A721 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -8720,6 +9318,7 @@ isa = XCConfigurationList; buildConfigurations = ( 326FBA152164C278004B0060 /* Debug */, + 32CDED2422EC8DC2002B5C20 /* Prometheus */, 326FBA172164C278004B0060 /* Release */, ); defaultConfigurationIsVisible = 0; diff --git a/CMakeLists.txt b/CMakeLists.txt index dbfaeed558eb068bc30ef799e6261ab939de330f..2a8876ddac97403d0d115572340da57fa0c2f777 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ option(USE_GPT "Uses Google Performance tool to perform analisys" OFF) option(CLING_VIRTUAL_MACHINE_ENABLE "Enable cling for scripting" OFF) option(CHAOS_ONLY_DEPENDECY "Download all the dependency" OFF) option(CHAOS_ARCHITECTURE_TEST "Architecture tests" OFF) +option(CHAOS_PROMETHEUS "Enable Prometheus metrics support" OFF) if (WIN32) option(CHAOS_MDS "Chaos Data Service" OFF) option(CHAOS_AGENT "Chaos Agent Service" OFF) @@ -102,7 +103,7 @@ ENDIF() IF (USE_GPT) #google performance tools - MESG("Add Google Performance Tools as external project") + MESG("Add Google Performance Tools dependency") ExternalProject_Add( google_pt GIT_REPOSITORY https://github.com/gperftools/gperftools.git @@ -127,6 +128,25 @@ IF (USE_GPT) MESG("${GPT_LIBRARY_DIR}") ENDIF() +IF (CHAOS_PROMETHEUS) + #google performance tools + MESG("Add Prometheus metrics dependency") + ExternalProject_Add( + prometheus + GIT_REPOSITORY https://github.com/jupp0r/prometheus-cpp.git + GIT_TAG master + PREFIX "${CMAKE_BINARY_DIR}/ext_dep/prometheus-prefix" + SOURCE_DIR "${CMAKE_BINARY_DIR}/ext_dep/prometheus-src" + BINARY_DIR "${CMAKE_BINARY_DIR}/ext_dep/prometheus-src" + CMAKE_ARGS -DBUILD_SHARED_LIBS=ON + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON) + # add definition for compilation + add_definitions(-DCHAOS_PROMETHEUS=1) +ENDIF() + SET( ${PROJECT_NAME}_MAJOR_VERSION 0 ) SET( ${PROJECT_NAME}_MINOR_VERSION 1 ) SET( ${PROJECT_NAME}_PATCH_LEVEL 0 ) @@ -147,7 +167,6 @@ if(NOT CHAOS_ONLY_DEPENDECY) MESG("Configure CUToolkit Layer") ADD_SUBDIRECTORY(chaos/cu_toolkit) - MESG("Configure Chaos Metadata Service Client Library") ADD_SUBDIRECTORY(chaos_metadata_service_client) diff --git a/ChaosMetadataService/CMakeLists.txt b/ChaosMetadataService/CMakeLists.txt index 393c0bf00ad800ff0df781fb616313e373831d84..c6a1027f5d5a1e7384b8307eaa54907257e46ca3 100644 --- a/ChaosMetadataService/CMakeLists.txt +++ b/ChaosMetadataService/CMakeLists.txt @@ -11,7 +11,6 @@ IF (DEFINED ENV{CHAOS_BUNDLE} ) include($ENV{CHAOS_BUNDLE}/tools/project_template/CMakeChaos.txt) ENDIF() - IF (COMPILE_HAZELCAST_LIVE_DRIVER) MESG("Install hazelcast c++ client") ExternalProject_Add( @@ -259,9 +258,7 @@ SET(cnd_src ${cnd_src} api/agent/logging/AgentLoggingApiGroup.cpp #Worker SET(cnd_src ${cnd_src} worker/DataWorker.cpp - worker/DeviceSharedDataWorker.cpp - worker/DeviceSharedDataWorkerMetric.cpp - worker/DeviceSharedDataWorkerMetricCollector.cpp) + worker/DeviceSharedDataWorker.cpp) #Persistence SET(cnd_src ${cnd_src} persistence/data_access/UnitServerDataAccess.cpp @@ -284,12 +281,10 @@ SET(cnd_src ${cnd_src} persistence/mongodb/MongoDBPersistenceDriver.cpp persistence/mongodb/MongoDBSnapshotDataAccess.cpp persistence/mongodb/MongoDBTreeGroupDataAccess.cpp persistence/mongodb/MongoDBLoggingDataAccess.cpp - persistence/mongodb/MongoDBScriptDataAccess.cpp + persistence/mongodb/MongoDBScriptDataAccess.cpp persistence/mongodb/MongoDBAgentDataAccess.cpp) #Caching SET(cnd_src ${cnd_src} cache_system/CacheDriver.cpp - cache_system/CacheDriverMetricCollector.cpp - cache_system/CacheDriverSharedMetricIO.cpp cache_system/CouchbaseCacheDriver.cpp) @@ -343,6 +338,12 @@ SET(cnd_src ${cnd_src} batch/script/LoadInstanceOnUnitServer.cpp SET(cnd_src ${cnd_src} batch/general/RestoreSnapshotBatch.cpp batch/general/CreateSnapshotBatch.cpp) +if(CHAOS_PROMETHEUS) +SET(cnd_src ${cnd_src} worker/DeviceSharedDataWorkerMetricCollector.cpp + cache_system/CacheDriverMetricCollector.cpp + cache_system/CacheDriverSharedMetricIO.cpp) +ENDIF(CHAOS_PROMETHEUS) + ADD_EXECUTABLE(${PROJECT_NAME} ${cnd_src}) #add dependency diff --git a/ChaosMetadataService/DriverPoolManager.cpp b/ChaosMetadataService/DriverPoolManager.cpp index ec480be43c4e2b982e1f464a85510ff51cf71ecd..ddf86134ba4dba711374c7ac6aa18551b5f8d26f 100644 --- a/ChaosMetadataService/DriverPoolManager.cpp +++ b/ChaosMetadataService/DriverPoolManager.cpp @@ -22,6 +22,10 @@ #include "DriverPoolManager.h" #include "ChaosMetadataService.h" +#if CHAOS_PROMETHEUS +#include "cache_system/CacheDriverMetricCollector.h" +#endif + #include <limits> #include <chaos/common/global.h> @@ -45,8 +49,13 @@ void DriverPoolManager::init(void *init_data) { //init cache pool //InizializableService::initImplementation(cache_pool, NULL, "CacheDriverPool", __PRETTY_FUNCTION__); const std::string cache_impl_name = ChaosMetadataService::getInstance()->setting.cache_driver_setting.cache_driver_impl+"CacheDriver"; +#if CHAOS_PROMETHEUS + cache_driver.reset(new CacheDriverMetricCollector(ObjectFactoryRegister<chaos::metadata_service::cache_system::CacheDriver>::getInstance()->getNewInstanceByName(cache_impl_name)), cache_impl_name); +#else cache_driver.reset(ObjectFactoryRegister<chaos::metadata_service::cache_system::CacheDriver>::getInstance()->getNewInstanceByName(cache_impl_name), - cache_impl_name); + cache_impl_name); +#endif + if(cache_driver.get() == NULL) throw chaos::CException(-1, CHAOS_FORMAT("No %1% Cache Driver found", %cache_impl_name), __PRETTY_FUNCTION__); cache_driver.init(NULL, __PRETTY_FUNCTION__); @@ -59,7 +68,7 @@ void DriverPoolManager::init(void *init_data) { const std::string storage_impl_name = ChaosMetadataService::getInstance()->setting.object_storage_setting.driver_impl + "ObjectStorageDriver"; storage_driver.reset(ObjectFactoryRegister<service_common::persistence::data_access::AbstractPersistenceDriver>::getInstance()->getNewInstanceByName(storage_impl_name), - storage_impl_name); + storage_impl_name); if(storage_driver.get() == NULL) throw chaos::CException(-1, CHAOS_FORMAT("No %1% Object Storage Driver found", %storage_impl_name), __PRETTY_FUNCTION__); storage_driver.init(NULL, __PRETTY_FUNCTION__); } diff --git a/ChaosMetadataService/QueryDataConsumer.cpp b/ChaosMetadataService/QueryDataConsumer.cpp index aa3fe4dfea5fbc1bd3e4f299d3f01c94dde2b88f..fa97416da9a292e7a0d72b07f5d549a70bffac23 100644 --- a/ChaosMetadataService/QueryDataConsumer.cpp +++ b/ChaosMetadataService/QueryDataConsumer.cpp @@ -22,12 +22,13 @@ #include "QueryDataConsumer.h" #include "DriverPoolManager.h" #include "worker/DeviceSharedDataWorker.h" -#include "worker/DeviceSharedDataWorkerMetric.h" -#include "worker/DeviceSharedDataWorkerMetricCollector.h" #include "persistence/persistence.h" -#include <chaos/common/network/NetworkBroker.h> +#if CHAOS_PROMETHEUS +#include "worker/DeviceSharedDataWorkerMetricCollector.h" +#endif +#include <chaos/common/network/NetworkBroker.h> #include <chaos/common/utility/ObjectFactoryRegister.h> #include <chaos/common/utility/endianess.h> #include <chaos/common/utility/DataBuffer.h> @@ -55,8 +56,6 @@ using namespace chaos::common::direct_io::channel; #define DBG DBG_LOG(QueryDataConsumer) #define ERR ERR_LOG(QueryDataConsumer) -ChaosSharedPtr<worker::DeviceSharedDataWorkerMetric> dsdwm_metric; - //constructor QueryDataConsumer::QueryDataConsumer(): server_endpoint(NULL), @@ -87,16 +86,12 @@ void QueryDataConsumer::init(void *init_data) { idx < ChaosMetadataService::getInstance()->setting.worker_setting.instances; idx++) { DataWorkerSharedPtr tmp; - if(ChaosMetadataService::getInstance()->setting.worker_setting.log_metric) { - INFO << "Enable caching worker log metric"; - INFO << "Init Device shared data worker metric"; - dsdwm_metric.reset(new worker::DeviceSharedDataWorkerMetric("DeviceSharedDataWorkerMetric", - ChaosMetadataService::getInstance()->setting.worker_setting.log_metric_update_interval)); - - tmp = ChaosMakeSharedPtr<worker::DeviceSharedDataWorkerMetricCollector>(dsdwm_metric); - } else { +#if CHAOS_PROMETHEUS + INFO << "Enable dataset processing worker metric"; + tmp = ChaosMakeSharedPtr<worker::DeviceSharedDataWorkerMetricCollector>(); +#else tmp = ChaosMakeSharedPtr<chaos::metadata_service::worker::DeviceSharedDataWorker>(); - } +#endif device_data_worker.push_back(tmp); StartableService::initImplementation(*tmp, NULL, "DeviceSharedDataWorker", __PRETTY_FUNCTION__); StartableService::startImplementation(*tmp, "DeviceSharedDataWorker", __PRETTY_FUNCTION__); @@ -120,9 +115,6 @@ void QueryDataConsumer::deinit() { device_data_worker[idx]->stop(); device_data_worker[idx]->deinit(); } - if(ChaosMetadataService::getInstance()->setting.worker_setting.log_metric) { - dsdwm_metric.reset(); - } } #pragma mark DirectIODeviceServerChannelHandler diff --git a/ChaosMetadataService/cache_system/CacheDriverMetricCollector.cpp b/ChaosMetadataService/cache_system/CacheDriverMetricCollector.cpp index eec2e4fe3a1681098ac5f3456ba5a14bd8db5ea2..2444ad83aebd6bed078c0865ef28398c83491fbe 100644 --- a/ChaosMetadataService/cache_system/CacheDriverMetricCollector.cpp +++ b/ChaosMetadataService/cache_system/CacheDriverMetricCollector.cpp @@ -22,24 +22,21 @@ #include "CacheDriverMetricCollector.h" #include <chaos/common/global.h> +using namespace chaos::common::metric; using namespace chaos::metadata_service::cache_system; -// static initialization -ChaosSharedPtr<CacheDriverSharedMetricIO> CacheDriverMetricCollector::shared_collector; - CacheDriverMetricCollector::CacheDriverMetricCollector(CacheDriver *_wrapped_cache_driver): CacheDriver(_wrapped_cache_driver->getName()), wrapped_cache_driver(_wrapped_cache_driver){ //init the shared collector - //lock mutex - boost::unique_lock<boost::mutex> wr(mutex_shared_collector); - - //check if the static instance needs to be initlized - if(shared_collector.get() == NULL){ - //initliae it - shared_collector.reset(new CacheDriverSharedMetricIO("CacheDriverMetricCollector")); - CHAOS_ASSERT(shared_collector.get()) - } + MetricManager::getInstance()->createCounterFamily("mds_cache_set_dataset_count", "Is the number of dataset that are stored in cache"); + set_pack_count_uptr = MetricManager::getInstance()->getNewCounterFromFamily("mds_cache_set_dataset_count"); + MetricManager::getInstance()->createCounterFamily("mds_cache_set_dataset_bandwith", "Is the bandwidth of dataset that are stored in cache (in kbyte)"); + set_bandwith_uptr = MetricManager::getInstance()->getNewCounterFromFamily("mds_cache_set_dataset_bandwith"); + MetricManager::getInstance()->createCounterFamily("mds_cache_get_dataset_count", "Is the number of dataset that are retrieved from the cache"); + get_pack_count_uptr = MetricManager::getInstance()->getNewCounterFromFamily("mds_cache_get_dataset_count"); + MetricManager::getInstance()->createCounterFamily("mds_cache_get_dataset_bandwith", "Is the bandwidth of dataset that are retrieved from the cache (in kbyte)"); + get_bandwith_uptr = MetricManager::getInstance()->getNewCounterFromFamily("mds_cache_get_dataset_bandwith"); } CacheDriverMetricCollector::~CacheDriverMetricCollector() { @@ -50,7 +47,8 @@ int CacheDriverMetricCollector::putData(const std::string& key, CacheData data) { CHAOS_ASSERT(wrapped_cache_driver) if(data->size()) { - shared_collector->incrementSetBandWidth((uint32_t)data->size()); + (*set_pack_count_uptr)++; + (*set_bandwith_uptr) += data->size(); } int err = wrapped_cache_driver->putData(key, data); @@ -63,7 +61,8 @@ int CacheDriverMetricCollector::getData(const std::string& key, int err = wrapped_cache_driver->getData(key, data); if(data->size()) { - shared_collector->incrementGetBandWidth((uint32_t)data->size()); + (*get_pack_count_uptr)++; + (*get_bandwith_uptr)+=data->size(); } return err; } @@ -73,16 +72,17 @@ int CacheDriverMetricCollector::getData(const ChaosStringVector& keys, int err = wrapped_cache_driver->getData(keys, multi_data); if(multi_data.size()) { - shared_collector->incrementGetBandWidth((uint32_t)multi_data.size()); + (*get_pack_count_uptr)++; + (*get_bandwith_uptr)+=multi_data.size(); } return err; } -int CacheDriverMetricCollector::addServer(std::string server_desc) { +int CacheDriverMetricCollector::addServer(const std::string& server_desc) { CHAOS_ASSERT(wrapped_cache_driver) return wrapped_cache_driver->addServer(server_desc); } -int CacheDriverMetricCollector::removeServer(std::string server_desc) { +int CacheDriverMetricCollector::removeServer(const std::string& server_desc) { CHAOS_ASSERT(wrapped_cache_driver) return wrapped_cache_driver->removeServer(server_desc); } diff --git a/ChaosMetadataService/cache_system/CacheDriverMetricCollector.h b/ChaosMetadataService/cache_system/CacheDriverMetricCollector.h index 8721b90d5a76fbed66641cfc54acd2365be5519b..5394adc33bc7842146370f8e5cd1a19828a31a9a 100644 --- a/ChaosMetadataService/cache_system/CacheDriverMetricCollector.h +++ b/ChaosMetadataService/cache_system/CacheDriverMetricCollector.h @@ -25,6 +25,8 @@ #include "CacheDriverSharedMetricIO.h" #include "CacheDriver.h" +#include <chaos/common/metric/metric.h> + #include <boost/thread.hpp> namespace chaos { @@ -37,9 +39,14 @@ namespace chaos { class CacheDriverMetricCollector: public CacheDriver { CacheDriver *wrapped_cache_driver; - - boost::mutex mutex_shared_collector; - static ChaosSharedPtr<CacheDriverSharedMetricIO> shared_collector; + //! count the pack that are been set to the cache + chaos::common::metric::CounterUniquePtr set_pack_count_uptr; + //! count the total bandwith in set caching operation + chaos::common::metric::CounterUniquePtr set_bandwith_uptr; + //! count the pack that are been get to the cache + chaos::common::metric::CounterUniquePtr get_pack_count_uptr; + //! ount the total bandwith in set caching operation + chaos::common::metric::CounterUniquePtr get_bandwith_uptr; public: //!base constructo rwith the wrapped dariver CacheDriverMetricCollector(CacheDriver *_wrapped_cache_driver); @@ -54,9 +61,9 @@ namespace chaos { int getData(const ChaosStringVector& keys, MultiCacheData& multi_data); //!inherited method - int addServer(std::string server_desc); + int addServer(const std::string& server_desc); //!inherited method - int removeServer(std::string server_desc); + int removeServer(const std::string& server_desc); //!inherited method void init(void *init_data); //!inherited method diff --git a/ChaosMetadataService/cache_system/CacheDriverSharedMetricIO.cpp b/ChaosMetadataService/cache_system/CacheDriverSharedMetricIO.cpp index 991d76569147856a9ad5b65ed1e2a9fef5a91b69..f78e61027b9c2376811d097d3098bd69401965c6 100644 --- a/ChaosMetadataService/cache_system/CacheDriverSharedMetricIO.cpp +++ b/ChaosMetadataService/cache_system/CacheDriverSharedMetricIO.cpp @@ -27,76 +27,70 @@ using namespace chaos::metadata_service; using namespace chaos::metadata_service::cache_system; +using namespace chaos::common::metric; + #define CACHDRVMC_INFO INFO_LOG(CacheDriverSharedMetricIO) #define CACHDRVMC_DBG_ DBG_LOG(CacheDriverSharedMetricIO) #define CACHDRVMC_ERR_ ERR_LOG(CacheDriverSharedMetricIO) -static const char * const METRIC_KEY_SET_PACKET_COUNT = "set_packet_count"; -static const char * const METRIC_KEY_SET_BANDWITH = "set_kb_sec"; -static const char * const METRIC_KEY_GET_PACKET_COUNT = "get_packet_count"; -static const char * const METRIC_KEY_GET_BANDWITH = "get_kb_sec"; CacheDriverSharedMetricIO::CacheDriverSharedMetricIO(const std::string& client_impl): -MetricCollectorIO(client_impl, - ChaosMetadataService::getInstance()->setting.cache_driver_setting.log_metric_update_interval), -set_pack_count(0), -set_bandwith(0), -get_pack_count(0), -get_bandwith(0) { - +MetricCollectorIO(){ CACHDRVMC_DBG_ << "Allocate collector"; //add custom key - addMetric(METRIC_KEY_SET_PACKET_COUNT, chaos::DataType::TYPE_DOUBLE); - addMetric(METRIC_KEY_SET_BANDWITH, chaos::DataType::TYPE_DOUBLE); - addMetric(METRIC_KEY_GET_PACKET_COUNT, chaos::DataType::TYPE_DOUBLE); - addMetric(METRIC_KEY_GET_BANDWITH, chaos::DataType::TYPE_DOUBLE); + MetricManager::getInstance()->createCounterFamily("mds_cache_set_dataset_count", "Is the number of dataset that are stored in cache"); + set_pack_count_uptr = MetricManager::getInstance()->getNewCounterFromFamily("mds_cache_set_dataset_count"); + MetricManager::getInstance()->createCounterFamily("mds_cache_set_dataset_bandwith", "Is the bandwidth of dataset that are stored in cache (in kbyte)"); + set_bandwith_uptr = MetricManager::getInstance()->getNewCounterFromFamily("mds_cache_set_dataset_bandwith"); + MetricManager::getInstance()->createCounterFamily("mds_cache_get_dataset_count", "Is the number of dataset that are retrieved from the cache"); + get_pack_count_uptr = MetricManager::getInstance()->getNewCounterFromFamily("mds_cache_get_dataset_count"); + MetricManager::getInstance()->createCounterFamily("mds_cache_get_dataset_bandwith", "Is the bandwidth of dataset that are retrieved from the cache (in kbyte)"); + get_bandwith_uptr = MetricManager::getInstance()->getNewCounterFromFamily("mds_cache_get_dataset_bandwith"); //start logging - startLogging(); +// startLogging(); } CacheDriverSharedMetricIO::~CacheDriverSharedMetricIO() { //stop logging - stopLogging(); +// stopLogging(); } void CacheDriverSharedMetricIO::incrementSetBandWidth(uint32_t increment) { boost::shared_lock<boost::shared_mutex> rl(metric_mutex); - set_pack_count++; - set_bandwith += increment; + (*set_pack_count_uptr)++; + (*set_bandwith_uptr) += ((double)increment); } void CacheDriverSharedMetricIO::incrementGetBandWidth(uint32_t increment) { boost::shared_lock<boost::shared_mutex> rl(metric_mutex); - get_pack_count++; - get_bandwith+=increment; + (*get_pack_count_uptr)++; + (*get_bandwith_uptr)+=((double)increment/1000); } void CacheDriverSharedMetricIO::fetchMetricForTimeDiff(uint64_t time_diff) { - double sec = time_diff/1000; - boost::unique_lock<boost::shared_mutex> wl(metric_mutex); - //update total - pack_count = set_pack_count+get_pack_count; - bandwith = set_bandwith + get_bandwith; - - - //udpate partial - double set_pc = set_pack_count/sec; set_pack_count = 0; - double set_bw = ((set_bandwith/sec)/1024); set_bandwith = 0; - double get_pc = get_pack_count/sec; get_pack_count = 0; - double get_bw = ((get_bandwith/sec)/1024); get_bandwith = 0; - - //update local variable cache - updateMetricValue(METRIC_KEY_SET_PACKET_COUNT, - &set_pc, - sizeof(double)); - updateMetricValue(METRIC_KEY_SET_BANDWITH, - &set_bw, - sizeof(double)); - updateMetricValue(METRIC_KEY_GET_PACKET_COUNT, - &get_pc, - sizeof(double)); - updateMetricValue(METRIC_KEY_GET_BANDWITH, - &get_bw, - sizeof(double)); - //call sublcass - MetricCollectorIO::fetchMetricForTimeDiff(time_diff); +// double sec = time_diff/1000; +// boost::unique_lock<boost::shared_mutex> wl(metric_mutex); +// //update total +// pack_count = set_pack_count+get_pack_count; +// bandwith = set_bandwith + get_bandwith; +// +// +// //udpate partial +// double set_pc = set_pack_count/sec; set_pack_count = 0; +// double set_bw = ((set_bandwith/sec)/1024); set_bandwith = 0; +// double get_pc = get_pack_count/sec; get_pack_count = 0; +// double get_bw = ((get_bandwith/sec)/1024); get_bandwith = 0; +// +// //update local variable cache +// updateMetricValue(METRIC_KEY_SET_PACKET_COUNT, +// &set_pc, +// sizeof(double)); +// updateMetricValue(METRIC_KEY_SET_BANDWITH, +// &set_bw, +// sizeof(double)); +// updateMetricValue(METRIC_KEY_GET_PACKET_COUNT, +// &get_pc, +// sizeof(double)); +// updateMetricValue(METRIC_KEY_GET_BANDWITH, +// &get_bw, +// sizeof(double)); } diff --git a/ChaosMetadataService/cache_system/CacheDriverSharedMetricIO.h b/ChaosMetadataService/cache_system/CacheDriverSharedMetricIO.h index 6df0c33c20dca69b7c6fc225ee83f0b84c7f2580..44267bb943db004470429a22c1800b537c227fcf 100644 --- a/ChaosMetadataService/cache_system/CacheDriverSharedMetricIO.h +++ b/ChaosMetadataService/cache_system/CacheDriverSharedMetricIO.h @@ -32,15 +32,15 @@ namespace chaos { namespace cache_system { class CacheDriverSharedMetricIO: public chaos::common::metric::MetricCollectorIO { - + //! count the pack that are been set to the cache - boost::atomic<uint32_t> set_pack_count; + chaos::common::metric::CounterUniquePtr set_pack_count_uptr; //! count the total bandwith in set caching operation - boost::atomic<uint32_t> set_bandwith; + chaos::common::metric::CounterUniquePtr set_bandwith_uptr; //! count the pack that are been get to the cache - boost::atomic<uint32_t> get_pack_count; + chaos::common::metric::CounterUniquePtr get_pack_count_uptr; //! ount the total bandwith in set caching operation - boost::atomic<uint32_t> get_bandwith; + chaos::common::metric::CounterUniquePtr get_bandwith_uptr; boost::shared_mutex metric_mutex; protected: diff --git a/ChaosMetadataService/cache_system/cache_system.h b/ChaosMetadataService/cache_system/cache_system.h index 8187db538a9f0f9a3f908d14f9d0449f891bb9c4..ebe354febb6cd627547be86b12fb374a47d389b6 100644 --- a/ChaosMetadataService/cache_system/cache_system.h +++ b/ChaosMetadataService/cache_system/cache_system.h @@ -22,6 +22,5 @@ #define CHAOSFramework_cache_sytem_h //#include "MemcachedCacheDriver.h" #include "CouchbaseCacheDriver.h" -#include "CacheDriverMetricCollector.h" #include "cache_system_types.h" #endif diff --git a/ChaosMetadataService/worker/DeviceSharedDataWorker.cpp b/ChaosMetadataService/worker/DeviceSharedDataWorker.cpp index 37bc70e198f10016441d4d2fab41591bdf5509fb..2eabbb688bf067846d377dc0251cf3b396b1fc6a 100644 --- a/ChaosMetadataService/worker/DeviceSharedDataWorker.cpp +++ b/ChaosMetadataService/worker/DeviceSharedDataWorker.cpp @@ -21,7 +21,6 @@ #include "../ChaosMetadataService.h" #include "DeviceSharedDataWorker.h" -#include "../cache_system/CacheDriverMetricCollector.h" #include "../DriverPoolManager.h" #include <chaos/common/utility/UUIDUtil.h> #include <chaos/common/utility/TimingUtil.h> diff --git a/ChaosMetadataService/worker/DeviceSharedDataWorkerMetric.cpp b/ChaosMetadataService/worker/DeviceSharedDataWorkerMetric.cpp deleted file mode 100644 index 63187a2885106cba0329bdf4f53692d79325130c..0000000000000000000000000000000000000000 --- a/ChaosMetadataService/worker/DeviceSharedDataWorkerMetric.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2012, 2017 INFN - * - * Licensed under the EUPL, Version 1.2 or – as soon they - * will be approved by the European Commission - subsequent - * versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the - * Licence. - * You may obtain a copy of the Licence at: - * - * https://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in - * writing, software distributed under the Licence is - * distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. - * See the Licence for the specific language governing - * permissions and limitations under the Licence. - */ - -#include "DeviceSharedDataWorkerMetric.h" - -using namespace chaos::metadata_service::worker; - -static const char * const METRIC_KEY_INPUT_PACKET_COUNT = "input_packet_count"; -static const char * const METRIC_KEY_INPUT_BANDWITH = "input_badnwith_kb"; -static const char * const METRIC_KEY_OUTPUT_PACKET_COUNT = "output_packet_count"; -static const char * const METRIC_KEY_OUTPUT_BADNWITH = "output_bandwith_kb"; -static const char * const METRIC_KEY_QUEUED_PACKET_COUNT = "queued_packet_count"; -static const char * const METRIC_KEY_QUEUED_PACKET_SIZE = "queued_packet_size_kb"; - -DeviceSharedDataWorkerMetric::DeviceSharedDataWorkerMetric(const std::string& _collector_name, - uint64_t update_time_in_sec): -MetricCollector(_collector_name, - update_time_in_sec), -input_data_pack(0), -input_badnwith(0), -output_data_pack(0), -output_badnwith(0), -queued_data_pack(0), -queued_size(0){ - //received pack and bw in the - addMetric(METRIC_KEY_INPUT_PACKET_COUNT, chaos::DataType::TYPE_DOUBLE); - addMetric(METRIC_KEY_INPUT_BANDWITH, chaos::DataType::TYPE_DOUBLE); - addMetric(METRIC_KEY_OUTPUT_PACKET_COUNT, chaos::DataType::TYPE_DOUBLE); - addMetric(METRIC_KEY_OUTPUT_BADNWITH, chaos::DataType::TYPE_DOUBLE); - addMetric(METRIC_KEY_QUEUED_PACKET_COUNT, chaos::DataType::TYPE_INT64); - addMetric(METRIC_KEY_QUEUED_PACKET_SIZE, chaos::DataType::TYPE_DOUBLE); - - startLogging(); -} - -DeviceSharedDataWorkerMetric::~DeviceSharedDataWorkerMetric() { - stopLogging(); -} - - -void DeviceSharedDataWorkerMetric::incrementInputBandwith(uint32_t pack_size) { - boost::shared_lock<boost::shared_mutex> rl(metric_mutex); - input_data_pack++; - input_badnwith+=pack_size; -} - -void DeviceSharedDataWorkerMetric::incrementOutputBandwith(uint32_t pack_size) { - boost::shared_lock<boost::shared_mutex> rl(metric_mutex); - output_data_pack++; - output_badnwith+=pack_size; -} - -void DeviceSharedDataWorkerMetric::incrementQueueSize(uint32_t pack_size) { - boost::shared_lock<boost::shared_mutex> rl(metric_mutex); - queued_data_pack++; - queued_size += pack_size; -} - -void DeviceSharedDataWorkerMetric::decrementQueueSize(uint32_t pack_size) { - boost::shared_lock<boost::shared_mutex> rl(metric_mutex); - queued_data_pack--; - queued_size -= pack_size; -} - -void DeviceSharedDataWorkerMetric::fetchMetricForTimeDiff(uint64_t time_diff) { - boost::unique_lock<boost::shared_mutex> wl(metric_mutex); - - double sec = time_diff/1000; - //udpate partial - double in_pc = input_data_pack/sec; input_data_pack = 0; - double in_bw = ((input_badnwith/sec)/1024); input_badnwith = 0; - double out_pc = output_data_pack/sec; output_data_pack = 0; - double out_bw = ((output_badnwith/sec)/1024); output_badnwith = 0; - int64_t q_pc = queued_data_pack;queued_data_pack=0; - double q_size = ((queued_size)/1024);queued_size=0; - - //update local variable cache - updateMetricValue(METRIC_KEY_INPUT_PACKET_COUNT, - &in_pc, - sizeof(double)); - updateMetricValue(METRIC_KEY_INPUT_BANDWITH, - &in_bw, - sizeof(double)); - updateMetricValue(METRIC_KEY_OUTPUT_PACKET_COUNT, - &out_pc, - sizeof(double)); - updateMetricValue(METRIC_KEY_OUTPUT_BADNWITH, - &out_bw, - sizeof(double)); - updateMetricValue(METRIC_KEY_QUEUED_PACKET_COUNT, - &q_pc, - sizeof(int64_t)); - updateMetricValue(METRIC_KEY_QUEUED_PACKET_SIZE, - &q_size, - sizeof(double)); -} diff --git a/ChaosMetadataService/worker/DeviceSharedDataWorkerMetric.h b/ChaosMetadataService/worker/DeviceSharedDataWorkerMetric.h deleted file mode 100644 index 36dab5b9d483a6ffebc8c9f0698a431c3af61860..0000000000000000000000000000000000000000 --- a/ChaosMetadataService/worker/DeviceSharedDataWorkerMetric.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2012, 2017 INFN - * - * Licensed under the EUPL, Version 1.2 or – as soon they - * will be approved by the European Commission - subsequent - * versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the - * Licence. - * You may obtain a copy of the Licence at: - * - * https://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in - * writing, software distributed under the Licence is - * distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. - * See the Licence for the specific language governing - * permissions and limitations under the Licence. - */ - -#ifndef __CHAOSFramework__DeviceSharedDataWorkerMetric__ -#define __CHAOSFramework__DeviceSharedDataWorkerMetric__ - -#include <chaos/common/metric/metric.h> - -#include <boost/thread.hpp> -#include <boost/atomic.hpp> - -namespace chaos{ - namespace metadata_service { - namespace worker { - - class DeviceSharedDataWorkerMetric : - public chaos::common::metric::MetricCollector { - - //! count the pack that are been set to the cache - boost::atomic<uint32_t> input_data_pack; - boost::atomic<uint64_t> input_badnwith; - boost::atomic<uint32_t> output_data_pack; - boost::atomic<uint64_t> output_badnwith; - boost::atomic<uint32_t> queued_data_pack; - boost::atomic<uint64_t> queued_size; - - boost::shared_mutex metric_mutex; - protected: - void fetchMetricForTimeDiff(uint64_t time_diff); - public: - DeviceSharedDataWorkerMetric(const std::string& client_impl, - uint64_t update_time_in_sec); - ~DeviceSharedDataWorkerMetric(); - - void incrementInputBandwith(uint32_t pack_size); - void incrementOutputBandwith(uint32_t pack_size); - void incrementQueueSize(uint32_t pack_size); - void decrementQueueSize(uint32_t pack_size); - }; - } - } -} - -#endif /* defined(__CHAOSFramework__DeviceSharedDataWorkerMetric__) */ diff --git a/ChaosMetadataService/worker/DeviceSharedDataWorkerMetricCollector.cpp b/ChaosMetadataService/worker/DeviceSharedDataWorkerMetricCollector.cpp index 54795f1e0e6f65a06c1e79018249215fdf2c4d1b..06d508f111ce2b4785598aa74c1910ee45aab9d3 100644 --- a/ChaosMetadataService/worker/DeviceSharedDataWorkerMetricCollector.cpp +++ b/ChaosMetadataService/worker/DeviceSharedDataWorkerMetricCollector.cpp @@ -25,65 +25,52 @@ #include <chaos/common/global.h> +using namespace chaos::common::metric; using namespace chaos::metadata_service::worker; -DeviceSharedDataWorkerMetricCollector::DeviceSharedDataWorkerMetricCollector(ChaosSharedPtr<DeviceSharedDataWorkerMetric> _data_worker_metric): -DeviceSharedDataWorker(), -data_worker_metric(_data_worker_metric){} +DeviceSharedDataWorkerMetricCollector::DeviceSharedDataWorkerMetricCollector(): +DeviceSharedDataWorker(){ + MetricManager::getInstance()->createGaugeFamily("mds_storage_queue", "Metrics for storage mds queue, element in queue are waiting to be porcessed by object storage driver"); + gauge_queued_dataset_uptr = MetricManager::getInstance()->getNewGaugeFromFamily("mds_storage_queue",{{"type","queued_element"}}); + gauge_queued_memory_uptr = MetricManager::getInstance()->getNewGaugeFromFamily("mds_storage_queue",{{"type","queued_data"}}); +} DeviceSharedDataWorkerMetricCollector::~DeviceSharedDataWorkerMetricCollector() {} void DeviceSharedDataWorkerMetricCollector::executeJob(WorkerJobPtr job_info, void* cookie) { DeviceSharedWorkerJob& job = *reinterpret_cast<DeviceSharedWorkerJob*>(job_info.get()); - int tag = job.key_tag; uint32_t total_data = (uint32_t)job.data_pack->size() + (uint32_t)job.key.size(); DeviceSharedDataWorker::executeJob(job_info, cookie); - switch(tag) { - case 0:// storicize only - case 2:// storicize and live - //increment metric for data stored on vfs - data_worker_metric->incrementOutputBandwith(total_data); + switch(static_cast<DataServiceNodeDefinitionType::DSStorageType>(job.key_tag)) { + case DataServiceNodeDefinitionType::DSStorageTypeHistory:// storicize only + case DataServiceNodeDefinitionType::DSStorageTypeLiveHistory:{// storicize and live + (*gauge_queued_dataset_uptr)--; + (*gauge_queued_memory_uptr)-=total_data; break; - - case 1:{// live only + } + case DataServiceNodeDefinitionType::DSStorageTypeLive: + case DataServiceNodeDefinitionType::DSStorageTypeUndefined:{// live only break; } } - //decrement metric that this packet has been removed from queue - data_worker_metric->decrementQueueSize(total_data); } -int DeviceSharedDataWorkerMetricCollector::submitJobInfo(WorkerJobPtr job_info) { - int err = 0; +int DeviceSharedDataWorkerMetricCollector::submitJobInfo(WorkerJobPtr job_info, int64_t milliseconds_to_wait) { DeviceSharedWorkerJob& job = *reinterpret_cast<DeviceSharedWorkerJob*>(job_info.get()); - int tag = job.key_tag; uint32_t total_data = (uint32_t)job.data_pack->size() + (uint32_t)job.key.size(); - data_worker_metric->incrementInputBandwith(total_data); - switch(tag) { - case 0:// storicize only - case 2:// storicize and live - //write data on stage file - data_worker_metric->incrementQueueSize(total_data); - break; - - case 1:{// live only - + switch(static_cast<DataServiceNodeDefinitionType::DSStorageType>(job.key_tag)) { + case DataServiceNodeDefinitionType::DSStorageTypeHistory:// storicize only + case DataServiceNodeDefinitionType::DSStorageTypeLiveHistory:{// storicize and live + (*gauge_queued_dataset_uptr)++; + (*gauge_queued_memory_uptr)+=total_data; break; } - } - err = DeviceSharedDataWorker::submitJobInfo(job_info); - switch(tag) { - case 0:// storicize only - case 2:// storicize and live - //write data on stage file - - break; - - case 1:{// live only + case DataServiceNodeDefinitionType::DSStorageTypeLive: + case DataServiceNodeDefinitionType::DSStorageTypeUndefined:{// live only break; } } - return err; + return DeviceSharedDataWorker::submitJobInfo(job_info); } diff --git a/ChaosMetadataService/worker/DeviceSharedDataWorkerMetricCollector.h b/ChaosMetadataService/worker/DeviceSharedDataWorkerMetricCollector.h index 5a1c254b3144256bba13fd6b9bc99cd00da40127..2bb35a54ce74ab3f3114256a20c604457c5ab167 100644 --- a/ChaosMetadataService/worker/DeviceSharedDataWorkerMetricCollector.h +++ b/ChaosMetadataService/worker/DeviceSharedDataWorkerMetricCollector.h @@ -23,7 +23,7 @@ #define __CHAOSFramework__DeviceSharedDataWorkerMetricCollector__ #include "DeviceSharedDataWorker.h" -#include "DeviceSharedDataWorkerMetric.h" +#include <chaos/common/metric/metric.h> #include <memory> @@ -35,13 +35,14 @@ namespace chaos{ class DeviceSharedDataWorkerMetricCollector: public DeviceSharedDataWorker { - ChaosSharedPtr<DeviceSharedDataWorkerMetric> data_worker_metric; + chaos::common::metric::GaugeUniquePtr gauge_queued_dataset_uptr; + chaos::common::metric::GaugeUniquePtr gauge_queued_memory_uptr; protected: void executeJob(WorkerJobPtr job_info, void* cookie); public: - DeviceSharedDataWorkerMetricCollector(ChaosSharedPtr<DeviceSharedDataWorkerMetric> _data_worker_metric); + DeviceSharedDataWorkerMetricCollector(); ~DeviceSharedDataWorkerMetricCollector(); - int submitJobInfo(WorkerJobPtr job_info); + int submitJobInfo(WorkerJobPtr job_info, int64_t milliseconds_to_wait = chaos::common::constants::MDSHistoryQueuePushTimeoutinMSec); }; } diff --git a/ChaosMetadataServiceClientTest/NodeMonitorHandlerTest.cpp b/ChaosMetadataServiceClientTest/NodeMonitorHandlerTest.cpp index 28027e1cc06cdeb22783d191ef8e0b2c05ed172a..d04565403c50faf80a167163f0701bb3334e3225 100644 --- a/ChaosMetadataServiceClientTest/NodeMonitorHandlerTest.cpp +++ b/ChaosMetadataServiceClientTest/NodeMonitorHandlerTest.cpp @@ -15,7 +15,6 @@ using namespace chaos::metadata_service_client::node_monitor; std::string getStatusDesc(chaos::metadata_service_client::node_monitor::OnlineState status){ switch(status){ - case chaos::metadata_service_client::node_monitor::OnlineStateON: return "Status ON"; break; @@ -25,6 +24,8 @@ std::string getStatusDesc(chaos::metadata_service_client::node_monitor::OnlineSt case chaos::metadata_service_client::node_monitor::OnlineStateNotFound: return "No status data found"; break; + case chaos::metadata_service_client::node_monitor::OnlineStateUnknown: + break; } return "Unknown"; } diff --git a/changelogs/unreleased/20190826103018250_prometheus.yml b/changelogs/unreleased/20190826103018250_prometheus.yml new file mode 100644 index 0000000000000000000000000000000000000000..344b4db6d5fbd8bd45d70d638073eac2c84c5a72 --- /dev/null +++ b/changelogs/unreleased/20190826103018250_prometheus.yml @@ -0,0 +1,4 @@ +--- +Added: +- Support for prometheus metrics, need to be compiled using cmake -DCHAOS_PROMETHEUS=ON + .... diff --git a/chaos/common/CMakeLists.txt b/chaos/common/CMakeLists.txt index a6997f64339c0a095fd2d41b2436470bca46176f..7f8b3225f1caf7d87cdfa20f32a95a03c4095598 100644 --- a/chaos/common/CMakeLists.txt +++ b/chaos/common/CMakeLists.txt @@ -143,14 +143,6 @@ SET(common_lib_src ${common_lib_src} cronus_manager/CronusManager.cpp cronus_manager/CronJob.cpp) -SET(common_lib_src ${common_lib_src} - metric/MetricCollector.cpp - metric/MetricCollectorIO.cpp - metric/AbstractMetricBackend.cpp - metric/ConsoleMetricBackend.cpp - metric/FileMetricBackend.cpp - metric/CSVFileMetricBackend.cpp) - SET(common_lib_src ${common_lib_src} data/CDataWrapper.cpp data/CDataBuffer.cpp @@ -245,9 +237,6 @@ SET(common_lib_src ${common_lib_src} direct_io/impl/ZMQDirectIOServer.cpp direct_io/impl/ZMQBaseClass.cpp direct_io/impl/ZMQDirectIOClientConnection.cpp - direct_io/DirectIODispatcherMetricCollector.cpp - direct_io/DirectIOClientConnectionMetricCollector.cpp - direct_io/DirectIOClientConnectionSharedMetricIO.cpp direct_io/channel/DirectIOVirtualChannel.cpp direct_io/channel/DirectIOVirtualClientChannel.cpp direct_io/channel/DirectIOVirtualServerChannel.cpp @@ -263,7 +252,7 @@ SET(common_lib_src ${common_lib_src} io/IODirectIODriver.cpp io/ManagedDirectIODataDriver.cpp io/QueryCursor.cpp - io/QueryIndexCursor.cpp + io/QueryIndexCursor.cpp io/SharedManagedDirecIoDataDriver.cpp) SET(common_lib_src ${common_lib_src} @@ -287,11 +276,8 @@ SET(common_lib_src ${common_lib_src} SET(common_lib_src ${common_lib_src} rpc/RpcClient.cpp rpc/RpcServer.cpp - rpc/RpcClientMetricCollector.cpp - rpc/RpcServerMetricCollector.cpp rpc/zmq/ZMQClient.cpp rpc/zmq/ZMQServer.cpp) - SET(common_lib_src ${common_lib_src} utility/NamedService.cpp utility/StartableService.cpp @@ -303,7 +289,7 @@ SET(common_lib_src ${common_lib_src} utility/AbstractListener.cpp utility/AbstractListenerContainer.cpp utility/ProcStat.cpp - utility/ProcessInfo.cpp + utility/ProcessInfo.cpp utility/InetUtility.cpp utility/FSUtility.cpp utility/Base64Util.cpp @@ -345,6 +331,23 @@ SET(common_lib_src ${common_lib_src} trigger/TriggerExecutionEnviroment.cpp trigger/trigger_types.cpp) +IF(CHAOS_PROMETHEUS) +MESG("Add source code for metrics: ${CHAOS_PROMETHEUS}") +SET(common_lib_src ${common_lib_src} + metric/MetricManager.cpp + metric/MetricCollector.cpp + metric/MetricCollectorIO.cpp) + +SET(common_lib_src ${common_lib_src} + direct_io/DirectIODispatcherMetricCollector.cpp + direct_io/DirectIOClientConnectionMetricCollector.cpp) +SET(common_lib_src ${common_lib_src} + rpc/RpcClientMetricCollector.cpp + rpc/RpcServerMetricCollector.cpp) +ELSE(CHAOS_PROMETHEUS) +MESG("Metrics source code is not included") +ENDIF(CHAOS_PROMETHEUS) + SET(common_lib_src ${common_lib_src} ChaosCommonWin.cpp) #compile lua chaos vm and core files @@ -370,9 +373,6 @@ IF (NOT DEFINED BUILD_FORCE_STATIC) ENDIF () -#SET(common_lib_library $ENV{CHAOS_LINK_LIBRARY}) -# separate_arguments(common_lib_library) - IF (BUILD_FORCE_STATIC ) ADD_LIBRARY(${PROJECT_NAME} STATIC ${common_lib_src}) ELSE () @@ -380,9 +380,13 @@ ELSE () set_target_properties(${PROJECT_NAME} PROPERTIES VERSION 1.0.0 SOVERSION 1) ENDIF () +IF (CHAOS_PROMETHEUS) +add_dependencies(${PROJECT_NAME} prometheus) +endif() #IF (NOT WIN32) #add dependency to libzmq + add_dependencies(${PROJECT_NAME} libzmq) #ENDIF(NOT WIN32) @@ -391,18 +395,24 @@ IF (CLING_VIRTUAL_MACHINE) ENDIF() target_compile_definitions(${PROJECT_NAME} PRIVATE CLING_VIRTUAL_MACHINE=${CLING_VIRTUAL_MACHINE}) + +SET(BUILD_LIBRARY ${FrameworkLib}) +SET(BUILD_LIBRARY ${BUILD_LIBRARY} libzmq.a) + IF(CLING_VIRTUAL_MACHINE) MESSAGE(STATUS "LINKING clingIntepreter") - TARGET_LINK_LIBRARIES(${PROJECT_NAME} libzmq.a ${FrameworkLib} clingInterpreter ) + SET(BUILD_LIBRARY ${BUILD_LIBRARY} clingInterpreter) ELSE() IF (WIN32) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${ALL_WINDOWS_LIBPATH}) -ELSE(WIN32) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} libzmq.a ${FrameworkLib}) + SET(BUILD_LIBRARY ${BUILD_LIBRARY} ${ALL_WINDOWS_LIBPATH}) ENDIF(WIN32) ENDIF() +IF(CHAOS_PROMETHEUS) + SET(BUILD_LIBRARY ${BUILD_LIBRARY} prometheus-cpp-core prometheus-cpp-pull) +ENDIF(CHAOS_PROMETHEUS) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${BUILD_LIBRARY}) FILE(GLOB files "external_unit/*.h") INSTALL(FILES ${files} DESTINATION include/chaos/common/external_unit) diff --git a/chaos/common/ChaosCommon.cpp b/chaos/common/ChaosCommon.cpp index 8643c19203c4fa86694c1accc137e7f6ff76114c..a2d6ca5ddd55bffa50f422d6878fa6987fa84169 100644 --- a/chaos/common/ChaosCommon.cpp +++ b/chaos/common/ChaosCommon.cpp @@ -20,6 +20,10 @@ */ #include <chaos/common/ChaosCommon.h> +#if CHAOS_PROMETHEUS +#include <chaos/common/metric/MetricManager.h> +#endif + #include <errno.h> #include <csignal> #include <fstream> @@ -241,7 +245,9 @@ void ChaosAbstractCommon::init(void *init_data) { LERR_ << "error setting signal handler for SIGSEGV"; } #endif - +#if CHAOS_PROMETHEUS + LAPP_ << "Metric HTTP port: " << GlobalConfiguration::getInstance()->getConfiguration()->getStringValue(InitOption::OPT_METRIC_WEB_SERVER_PORT); +#endif err = uname(&u_name); if (err == -1) { LAPP_ << "Platform: " << strerror(errno); @@ -266,6 +272,12 @@ void ChaosAbstractCommon::init(void *init_data) { LAPP_ << "The local address choosen is: " << GlobalConfiguration::getInstance()->getLocalServerAddress(); +#if CHAOS_PROMETEUS + if(GlobalConfiguration::getInstance()-isMetricEnbled()){ + common::utility::InizializableService::initImplementation(chaos::common::metric::MetricManager::getInstance(), init_data, "MetricManager", __PRETTY_FUNCTION__); + } +#endif + //Starting Async central common::utility::InizializableService::initImplementation(AsyncCentralManager::getInstance(), init_data, "AsyncCentralManager", __PRETTY_FUNCTION__); common::utility::StartableService::initImplementation(NetworkBroker::getInstance(), init_data, "NetworkBroker", __PRETTY_FUNCTION__); @@ -291,20 +303,20 @@ void ChaosAbstractCommon::init(void *init_data) { NodeDomainAndActionRPC::RPC_DOMAIN, NodeDomainAndActionRPC::ACTION_GET_BUILD_INFO, "Return the build info of current chaos node instance"); - + AbstActionDescShrPtr action_description2 = addActionDescritionInstance<ChaosAbstractCommon>(this, - &ChaosAbstractCommon::getProcessInfo, - NodeDomainAndActionRPC::RPC_DOMAIN, - NodeDomainAndActionRPC::ACTION_GET_PROCESS_INFO, - "Return the process info of current chaos node instance"); + &ChaosAbstractCommon::getProcessInfo, + NodeDomainAndActionRPC::RPC_DOMAIN, + NodeDomainAndActionRPC::ACTION_GET_PROCESS_INFO, + "Return the process info of current chaos node instance"); AbstActionDescShrPtr actionDescription3 = addActionDescritionInstance<ChaosAbstractCommon>(this, - &ChaosAbstractCommon::_registrationAck, - NodeDomainAndActionRPC::RPC_DOMAIN, - NodeDomainAndActionRPC::ACTION_REGISTRATION_ACK, - "Generic ack to a registration request"); - - + &ChaosAbstractCommon::_registrationAck, + NodeDomainAndActionRPC::RPC_DOMAIN, + NodeDomainAndActionRPC::ACTION_REGISTRATION_ACK, + "Generic ack to a registration request"); + + NetworkBroker::getInstance()->registerAction(this); } catch (...) { @@ -353,6 +365,9 @@ void ChaosAbstractCommon::deinit() { //shutdown logger chaos::common::log::LogManager::getInstance()->deinit(); +#if CHAOS_PROMETHEUS + CHAOS_NOT_THROW(common::utility::InizializableService::deinitImplementation(chaos::common::metric::MetricManager::getInstance(), "MetricManager", __PRETTY_FUNCTION__);) +#endif } void ChaosAbstractCommon::start() {} diff --git a/chaos/common/chaos_constants.h b/chaos/common/chaos_constants.h index d592570b363a6b07c447ca7ddc2c5df5530afc3a..9636029aa3f3c1ae3cf32e75e512fdc272685825 100644 --- a/chaos/common/chaos_constants.h +++ b/chaos/common/chaos_constants.h @@ -60,16 +60,6 @@ namespace chaos { static const char * const OPT_LOG_LEVEL = "log-level"; //! Specify the log max size static const char * const OPT_LOG_MAX_SIZE_MB = "log-max-size"; - //! enable metric loggin on console backend - static const char * const OPT_LOG_METRIC_ON_CONSOLE = "log-metric-on-console"; - //! enable metric loggin on file backend - static const char * const OPT_LOG_METRIC_ON_FILE = "log-metric-on-file"; - //! enable metric loggin on file backend - static const char * const OPT_LOG_METRIC_ON_FILE_PATH = "log-metric-on-file-path"; - //! activate the loggin of metric on rpc system - static const char * const OPT_RPC_LOG_METRIC = "rpc-log-metric"; - //! the time between the update of rpc metric on persistence backend (in seconds) - static const char * const OPT_RPC_LOG_METRIC_UPDATE_INTERVAL = "rpc-log-metric-update-interval"; //! Specify the implementation to use for rp messaging static const char * const OPT_RPC_IMPL_KV_PARAM = "rpc-kv-param"; //! Specify the implementation to use for rp messaging @@ -96,12 +86,6 @@ namespace chaos { static const char * const OPT_DIRECT_IO_SERVER_IMPL_KV_PARAM = "direct-io-server-kv-param"; //! Specify the key/values (string:string) map for direct io client implementation parameters static const char * const OPT_DIRECT_IO_CLIENT_IMPL_KV_PARAM = "direct-io-client-kv-param"; - //! activate the loggin of metric on rpc system - static const char * const OPT_DIRECT_IO_LOG_METRIC = "direct-io-log-metric"; - //! activate the merged or separate metric on target endpoint - static const char * const OPT_DIRECT_IO_CLIENT_LOG_METRIC_MERGED_ENDPOINT = "direct-io-client-log-metric-mep"; - //! the time between the update of rpc metric on persistence backend (in seconds) - static const char * const OPT_DIRECT_IO_LOG_METRIC_UPDATE_INTERVAL = "direct-io-log-metric-update-interval"; //!disable the event system static const char * const OPT_EVENT_DISABLE = "event-disable"; //! Specify the metadata address for the metadataserver @@ -125,7 +109,13 @@ namespace chaos { //!multiple key value parameter that are passed to script virtual machine static const char * const OPT_SCRIPT_VM_KV_PARAM = "script-vm-kvp"; //!rest poll time us - static const char * const OPT_REST_POLL_TIME_US = "rest-poll-us"; + static const char * const OPT_REST_POLL_TIME_US = "rest-poll-us"; +#if CHAOS_PROMETHEUS + //! config file parameter + static const char * const OPT_METRIC_ENABLE = "enable_metric"; + //! config file parameter + static const char * const OPT_METRIC_WEB_SERVER_PORT = "metrics-http-port"; +#endif } /** @} */ // end of ParamOption diff --git a/chaos/common/configuration/GlobalConfiguration.cpp b/chaos/common/configuration/GlobalConfiguration.cpp index 5faad68c6911c3d8baf4a2bb519fbb3c60143f87..abe37d57f0074c2670f44dc5378798721fd864fc 100644 --- a/chaos/common/configuration/GlobalConfiguration.cpp +++ b/chaos/common/configuration/GlobalConfiguration.cpp @@ -63,9 +63,6 @@ void GlobalConfiguration::preParseStartupParameters() { addOption(InitOption::OPT_LOG_FILE, po::value< string >()->default_value("chaos_framework_log_%Y-%m-%d_%H-%M-%S.%N.log"), "Specify when the file path of the log"); addOption(InitOption::OPT_LOG_LEVEL, po::value< string >()->default_value("info"), "Specify the level of the log using the value [debug, info, notice, warning, fatal]"); addOption(InitOption::OPT_LOG_MAX_SIZE_MB, po::value< uint32_t >()->default_value(10), "Specify the max size in megabytes fo the file log"); - addOption(InitOption::OPT_LOG_METRIC_ON_CONSOLE, po::value< bool >()->zero_tokens(), "Enable the logging metric on console"); - addOption(InitOption::OPT_LOG_METRIC_ON_FILE, po::value< bool >()->zero_tokens(), "Enable the logging metric on file"); - addOption(InitOption::OPT_LOG_METRIC_ON_FILE_PATH, po::value< string >()->default_value(boost::filesystem::current_path().string()), "Specify the path of metric logs"); addOption(InitOption::OPT_METADATASERVER_ADDRESS, po::value< std::vector< std::string > >(), "Metadataserver server:port address"); addOption(InitOption::OPT_DATA_IO_IMPL, po::value< string >()->default_value("IODirect"), "Specify the data io implementation"); addOption(InitOption::OPT_DIRECT_IO_IMPLEMENTATION, po::value< string >()->default_value("ZMQ"), "Specify the direct io implementation"); @@ -74,12 +71,7 @@ void GlobalConfiguration::preParseStartupParameters() { addOption(InitOption::OPT_DIRECT_IO_SERVER_THREAD_NUMBER, po::value<uint32_t>()->default_value(1),"DirectIO server thread number"); addOption(InitOption::OPT_DIRECT_IO_SERVER_IMPL_KV_PARAM, po::value< std::vector<std::string> >(),"DirectIO implementation key value parameters[k:v]"); addOption(InitOption::OPT_DIRECT_IO_CLIENT_IMPL_KV_PARAM, po::value< std::vector<std::string> >(),"DirectIO implementation key value parameters[k:v]"); - addOption(InitOption::OPT_DIRECT_IO_LOG_METRIC, po::value< bool >()->zero_tokens(), "Enable the logging of the DirectIO metric"); - addOption(InitOption::OPT_DIRECT_IO_LOG_METRIC_UPDATE_INTERVAL, po::value< uint64_t >()->default_value(5), "The time interval between metric samples"); - addOption(InitOption::OPT_DIRECT_IO_CLIENT_LOG_METRIC_MERGED_ENDPOINT, po::value< bool >()->default_value(true), "Merge the metric values(of all endpoint) together"); addOption(InitOption::OPT_RPC_SYNC_ENABLE, po::value< bool >()->default_value(false), "Enable the sync wrapper to rpc protocol"); - addOption(InitOption::OPT_RPC_LOG_METRIC, po::value< bool >()->zero_tokens(), "Enable the logging of the mrpc metric"); - addOption(InitOption::OPT_RPC_LOG_METRIC_UPDATE_INTERVAL, po::value< uint64_t >()->default_value(5), "The time intervall between metric samples"); addOption(InitOption::OPT_RPC_IMPLEMENTATION, po::value< string >()->default_value("ZMQ"), "Specify the rpc implementation"); addOption(InitOption::OPT_RPC_SERVER_PORT, po::value<uint32_t>()->default_value(_RPC_PORT), "RPC server port"); addOption(InitOption::OPT_RPC_SERVER_THREAD_NUMBER, po::value<uint32_t>()->default_value(2),"RPC server thread number"); @@ -103,6 +95,11 @@ void GlobalConfiguration::preParseStartupParameters() { addOption(ext_unt::InitOption::OPT_UNIT_GATEWAY_ENABLE, po::value< bool >()->zero_tokens(), ext_unt::InitOption::OPT_UNIT_GATEWAY_ENABLE_DESC); addOption(ext_unt::InitOption::OPT_UNIT_GATEWAY_WORKER_THREAD_NUMBER, po::value< uint32_t >()->default_value(ext_unt::InitOption::OPT_UNIT_GATEWAY_WORKER_THREAD_NUMBER_DEFAULT), ext_unt::InitOption::OPT_UNIT_GATEWAY_WORKER_THREAD_NUMBER_DESC); addOption(ext_unt::InitOption::OPT_UNIT_GATEWAY_ADAPTER_KV_PARAM, po::value< std::vector<std::string> >(), ext_unt::InitOption::OPT_UNIT_GATEWAY_ADAPTER_KV_PARAM_DESC); + +#if CHAOS_PROMETHEUS + addOption(InitOption::OPT_METRIC_ENABLE, po::value< bool >()->zero_tokens(), "Enable metric"); + addOption(InitOption::OPT_METRIC_WEB_SERVER_PORT, po::value< std::string >()->default_value("10000"), "Specify the port where publish the prometheus metrics"); +#endif } catch (po::error &e) { throw CException(0, e.what(), "GlobalConfiguration::preParseStartupParameters"); } @@ -241,15 +238,6 @@ void GlobalConfiguration::checkDefaultOption() { CHECK_AND_DEFINE_OPTION(string, logLevel, InitOption::OPT_LOG_LEVEL) configuration->addInt32Value(InitOption::OPT_LOG_LEVEL, filterLogLevel(logLevel)); - CHECK_AND_DEFINE_BOOL_ZERO_TOKEN_OPTION(log_metric_on_console, InitOption::OPT_LOG_METRIC_ON_CONSOLE); - configuration->addBoolValue(InitOption::OPT_LOG_METRIC_ON_CONSOLE, log_metric_on_console); - - CHECK_AND_DEFINE_BOOL_ZERO_TOKEN_OPTION(log_metric_on_file, InitOption::OPT_LOG_METRIC_ON_FILE) - configuration->addBoolValue(InitOption::OPT_LOG_METRIC_ON_FILE, log_metric_on_file); - - CHECK_AND_DEFINE_OPTION(string, log_metric_file_path, InitOption::OPT_LOG_METRIC_ON_FILE_PATH); - configuration->addStringValue(InitOption::OPT_LOG_METRIC_ON_FILE_PATH, log_metric_file_path); - CHECK_AND_DEFINE_OPTION_WITH_DEFAULT(uint32_t, log_max_size_mb, InitOption::OPT_LOG_MAX_SIZE_MB, 10); configuration->addInt32Value(InitOption::OPT_LOG_MAX_SIZE_MB, log_max_size_mb); @@ -276,12 +264,7 @@ void GlobalConfiguration::checkDefaultOption() { OPT_RPC_SYNC_ENABLE = false; } configuration->addBoolValue(InitOption::OPT_RPC_SYNC_ENABLE, OPT_RPC_SYNC_ENABLE); - - CHECK_AND_DEFINE_OPTION_WITH_DEFAULT(bool, rpc_enable_log_metric, InitOption::OPT_RPC_LOG_METRIC, false); - configuration->addBoolValue(InitOption::OPT_RPC_LOG_METRIC, rpc_enable_log_metric);; - - CHECK_AND_DEFINE_OPTION_WITH_DEFAULT(uint64_t, rpc_enable_log_metric_update_sec, InitOption::OPT_RPC_LOG_METRIC_UPDATE_INTERVAL, 5); - configuration->addInt64Value(InitOption::OPT_RPC_LOG_METRIC_UPDATE_INTERVAL, rpc_enable_log_metric_update_sec); + CHECK_AND_DEFINE_OPTION(std::vector<std::string>, rpc_impl_kv_param, InitOption::OPT_RPC_IMPL_KV_PARAM); @@ -322,15 +305,6 @@ void GlobalConfiguration::checkDefaultOption() { freeFoundPort = InetUtility::scanForLocalFreePort(direct_io_service_port); configuration->addInt32Value(common::direct_io::DirectIOConfigurationKey::DIRECT_IO_SERVICE_PORT, (uint32_t)freeFoundPort); - CHECK_AND_DEFINE_OPTION_WITH_DEFAULT(bool, direct_io_enable_log_metric, InitOption::OPT_DIRECT_IO_LOG_METRIC, false); - configuration->addBoolValue(InitOption::OPT_DIRECT_IO_LOG_METRIC, direct_io_enable_log_metric); - - CHECK_AND_DEFINE_OPTION_WITH_DEFAULT(uint64_t, direct_io_enable_log_metric_update_sec, InitOption::OPT_DIRECT_IO_LOG_METRIC_UPDATE_INTERVAL, 5); - configuration->addInt64Value(InitOption::OPT_DIRECT_IO_LOG_METRIC_UPDATE_INTERVAL, direct_io_enable_log_metric_update_sec); - - CHECK_AND_DEFINE_OPTION_WITH_DEFAULT(bool, direct_io_enable_log_metric_merged_endpoint, InitOption::OPT_DIRECT_IO_CLIENT_LOG_METRIC_MERGED_ENDPOINT, true) - configuration->addBoolValue(InitOption::OPT_DIRECT_IO_CLIENT_LOG_METRIC_MERGED_ENDPOINT, direct_io_enable_log_metric_merged_endpoint); - //event CHECK_AND_DEFINE_BOOL_ZERO_TOKEN_OPTION(event_disable, InitOption::OPT_EVENT_DISABLE); configuration->addBoolValue(InitOption::OPT_EVENT_DISABLE, event_disable); @@ -360,10 +334,18 @@ void GlobalConfiguration::checkDefaultOption() { configuration->addStringValue(InitOption::OPT_TIME_CALIBRATION_NTP_SERVER, time_calibration_ntp_server); CHECK_AND_DEFINE_OPTION(std::vector<std::string>, script_vm_kv_param, InitOption::OPT_SCRIPT_VM_KV_PARAM); - //fill the key value list + // fill the key value list if(script_vm_kv_param.size()) { fillKVParameter(map_kv_param_script_vm, script_vm_kv_param, ""); } + +#if CHAOS_PROMETHEUS + // configura http metric port + CHECK_AND_DEFINE_OPTION_WITH_DEFAULT(std::string, httpMetricPort, InitOption::OPT_METRIC_WEB_SERVER_PORT, "10000"); + httpMetricPort = boost::lexical_cast<std::string>(InetUtility::scanForLocalFreePort(boost::lexical_cast<int32_t>(httpMetricPort))); + configuration->addStringValue(InitOption::OPT_METRIC_WEB_SERVER_PORT, httpMetricPort); + +#endif } @@ -526,6 +508,12 @@ int32_t GlobalConfiguration::getLocalServerBasePort() { return configuration->getInt32Value("base_port"); } +#if CHAOS_PROMETHEUS +int32_t GlobalConfiguration::getHttpMetricsPort() { + return configuration->getInt32Value(InitOption::OPT_METRIC_WEB_SERVER_PORT); +} +#endif + string GlobalConfiguration::getLocalServerAddressAnBasePort(){ char buf[128]; string addr = configuration->getStringValue("local_ip"); diff --git a/chaos/common/configuration/GlobalConfiguration.h b/chaos/common/configuration/GlobalConfiguration.h index b8470c2bf84f95da535ec81e56ef9773c98a8ff4..57de7242e4874020f75c862ac013f0b83e3e5713 100644 --- a/chaos/common/configuration/GlobalConfiguration.h +++ b/chaos/common/configuration/GlobalConfiguration.h @@ -319,6 +319,9 @@ x = hasOption(y); int32_t getLocalServerBasePort(); string getLocalServerAddressAnBasePort(); +#if CHAOS_PROMETHEUS + int32_t getHttpMetricsPort(); +#endif /* return the address of metadataserver diff --git a/chaos/common/direct_io/DirectIOClient.cpp b/chaos/common/direct_io/DirectIOClient.cpp index 3d0dca2f454a2077798b67ebde92be60405ab158..b3356af57aa5e05bbc07adfb26714af27225011a 100644 --- a/chaos/common/direct_io/DirectIOClient.cpp +++ b/chaos/common/direct_io/DirectIOClient.cpp @@ -25,9 +25,9 @@ #include <chaos/common/direct_io/DirectIOClient.h> #include <chaos/common/direct_io/channel/DirectIOVirtualClientChannel.h> -#include <chaos/common/direct_io/DirectIOClientConnectionSharedMetricIO.h> +#ifdef CHAOS_PROMETHEUS #include <chaos/common/direct_io/DirectIOClientConnectionMetricCollector.h> - +#endif #include <boost/regex.hpp> #include <boost/format.hpp> #include <boost/algorithm/string.hpp> @@ -75,44 +75,17 @@ DirectIOClientConnection *DirectIOClient::getNewConnection(const std::string& se DirectIOClientConnection *result = NULL; DEBUG_CODE(DIOLDBG_ << "Requested a new connection for a server description " << server_description_with_endpoint;) if(decodeServerDescriptionWithEndpoint(server_description_with_endpoint, server_description, endpoint)) { - DEBUG_CODE(DIOLDBG_ << "scomposed into server description " << server_description << " and endpoint " << endpoint;) + DEBUG_CODE(DIOLDBG_ << "decomposed into server description " << server_description << " and endpoint " << endpoint;) result = _getNewConnectionImpl(server_description, endpoint); - - if(result && - GlobalConfiguration::getInstance()->getConfiguration()->hasKey(InitOption::OPT_DIRECT_IO_LOG_METRIC) && - GlobalConfiguration::getInstance()->getConfiguration()->getBoolValue(InitOption::OPT_DIRECT_IO_LOG_METRIC)) { - //lock the map - boost::unique_lock<boost::mutex> wl(mutex_map_shared_collectors); - - //prepare key in case with need to split themetric for endpoint - std::string server_key = server_description; - if(GlobalConfiguration::getInstance()->getConfiguration()->getBoolValue(InitOption::OPT_DIRECT_IO_CLIENT_LOG_METRIC_MERGED_ENDPOINT)) { - //we need to merge the endpoint - server_key = "merge_together"; - } else { - server_key = server_description_with_endpoint; - } - //create the collector key - SharedCollectorKey key(server_key); - ChaosSharedPtr<DirectIOClientConnectionSharedMetricIO> shared_collector; - - //check if we have already allcoated thecollector - if(map_shared_collectors.count(key)==0) { - shared_collector.reset(new DirectIOClientConnectionSharedMetricIO(getName(), server_description_with_endpoint)); - map_shared_collectors.insert(make_pair(key, shared_collector)); - } else { - shared_collector = map_shared_collectors[key]; - } - - //the metric allocator of direct io is a direct subclass of DirectIODispatcher +#if CHAOS_PROMETHEUS + if(result){ result = new DirectIOClientConnectionMetricCollector(server_description, endpoint, - shared_collector, result); } - +#endif } return result; } @@ -120,19 +93,17 @@ DirectIOClientConnection *DirectIOClient::getNewConnection(const std::string& se //! Release the connection void DirectIOClient::releaseConnection(DirectIOClientConnection *connection_to_release) { if(connection_to_release) { - if(GlobalConfiguration::getInstance()->getConfiguration()->getBoolValue(InitOption::OPT_DIRECT_IO_LOG_METRIC)) { - //the metric allocator of direct io is a direct subclass of DirectIODispatcher - DirectIOClientConnectionMetricCollector *metric_collector = dynamic_cast<DirectIOClientConnectionMetricCollector*>(connection_to_release); - if(metric_collector) { - _releaseConnectionImpl(metric_collector->wrapped_connection); - delete(metric_collector); - } - } else { - _releaseConnectionImpl(connection_to_release); +#ifdef CHAOS_PROMETHEUS + //the metric allocator of direct io is a direct subclass of DirectIODispatcher + DirectIOClientConnectionMetricCollector *metric_collector = dynamic_cast<DirectIOClientConnectionMetricCollector*>(connection_to_release); + if(metric_collector) { + _releaseConnectionImpl(metric_collector->wrapped_connection); + delete(metric_collector); } +#else + _releaseConnectionImpl(connection_to_release); +#endif } } -void DirectIOClient::freeObject(const DCKeyObjectContainer::TKOCElement& element) { - -} +void DirectIOClient::freeObject(const DCKeyObjectContainer::TKOCElement& element) {} diff --git a/chaos/common/direct_io/DirectIOClientConnectionMetricCollector.cpp b/chaos/common/direct_io/DirectIOClientConnectionMetricCollector.cpp index 3460843da6a76eb9a96634e5ebd167dca0d78ed2..b25142873cd62a153d35af698b3d6a6befb38e92 100644 --- a/chaos/common/direct_io/DirectIOClientConnectionMetricCollector.cpp +++ b/chaos/common/direct_io/DirectIOClientConnectionMetricCollector.cpp @@ -23,6 +23,7 @@ #include <chaos/common/configuration/GlobalConfiguration.h> +using namespace chaos::common::metric; using namespace chaos::common::direct_io; #define DIOCCMC_INFO INFO_LOG(DirectIOClientConnectionMetricCollector) @@ -31,38 +32,50 @@ using namespace chaos::common::direct_io; DirectIOClientConnectionMetricCollector::DirectIOClientConnectionMetricCollector(const std::string& _server_description, uint16_t _endpoint, - ChaosSharedPtr<DirectIOClientConnectionSharedMetricIO> _shared_collector, DirectIOClientConnection *_wrapped_connection): DirectIOClientConnection(_server_description, _endpoint), -shared_collector(_shared_collector), -wrapped_connection(_wrapped_connection) { +MetricCollectorIO(), +wrapped_connection(_wrapped_connection), +current_bandwidth(0) { DIOCCMC_DBG_ << "Allocate collector"; + counter_dataseet_sent = MetricManager::getInstance()->getNewTxPacketRateMetricFamily({{"driver","direct_io"}}); + counter_data_sent = MetricManager::getInstance()->getNewTxDataRateMetricFamily({{"driver","direct_io"}}); + + MetricManager::getInstance()->createGaugeFamily("tx_bandwidth_direct_io_dispatcher", "Metric for bandwith measure on data transmitted by direct-io dispatcher"); + gauge_bandwidth_uptr = MetricManager::getInstance()->getNewGaugeFromFamily("tx_bandwidth_direct_io_dispatcher"); + + startLogging(); } DirectIOClientConnectionMetricCollector::~DirectIOClientConnectionMetricCollector() { DIOCCMC_DBG_ << "Deallocate collector"; + stopLogging(); } //! inherited method int DirectIOClientConnectionMetricCollector::sendPriorityData(DirectIODataPackSPtr data_pack) { - CHAOS_ASSERT(wrapped_connection && shared_collector) + CHAOS_ASSERT(wrapped_connection) //inrement packec count - shared_collector->incrementPackCount(); + (*counter_dataseet_sent)++; //increment packet size - shared_collector->incrementBandWidth(data_pack->header.channel_header_size+data_pack->header.channel_data_size + sizeof(DirectIODataPackDispatchHeader)); + int32_t total_data = (data_pack->header.channel_header_size+data_pack->header.channel_data_size + sizeof(DirectIODataPackDispatchHeader)); + total_data += current_bandwidth; + (*counter_data_sent) += current_bandwidth; return wrapped_connection->sendPriorityData(MOVE(data_pack)); } int DirectIOClientConnectionMetricCollector::sendPriorityData(DirectIODataPackSPtr data_pack, DirectIODataPackSPtr& asynchronous_answer) { - CHAOS_ASSERT(wrapped_connection && shared_collector) + CHAOS_ASSERT(wrapped_connection) //inrement packec count - shared_collector->incrementPackCount(); + (*counter_dataseet_sent)++; //increment packet size - shared_collector->incrementBandWidth(data_pack->header.channel_header_size+data_pack->header.channel_data_size + sizeof(DirectIODataPackDispatchHeader)); + int32_t total_data = (data_pack->header.channel_header_size+data_pack->header.channel_data_size + sizeof(DirectIODataPackDispatchHeader)); + total_data += current_bandwidth; + (*counter_data_sent) += current_bandwidth; return wrapped_connection->sendPriorityData(MOVE(data_pack), asynchronous_answer); } @@ -70,22 +83,32 @@ int DirectIOClientConnectionMetricCollector::sendPriorityData(DirectIODataPackSP //! inherited method int DirectIOClientConnectionMetricCollector::sendServiceData(chaos::common::direct_io::DirectIODataPackSPtr data_pack) { - CHAOS_ASSERT(wrapped_connection && shared_collector) + CHAOS_ASSERT(wrapped_connection) //inrement packec count - shared_collector->incrementPackCount(); + (*counter_dataseet_sent)++; //increment packet size - shared_collector->incrementBandWidth(data_pack->header.channel_header_size+data_pack->header.channel_data_size + sizeof(DirectIODataPackDispatchHeader)); + int32_t total_data = (data_pack->header.channel_header_size+data_pack->header.channel_data_size + sizeof(DirectIODataPackDispatchHeader)); + total_data += current_bandwidth; + (*counter_data_sent) += current_bandwidth; return wrapped_connection->sendServiceData(MOVE(data_pack)); } int DirectIOClientConnectionMetricCollector::sendServiceData(chaos::common::direct_io::DirectIODataPackSPtr data_pack, chaos::common::direct_io::DirectIODataPackSPtr& asynchronous_answer) { - CHAOS_ASSERT(wrapped_connection && shared_collector) + CHAOS_ASSERT(wrapped_connection) //inrement packec count - shared_collector->incrementPackCount(); + (*counter_dataseet_sent)++; //increment packet size - shared_collector->incrementBandWidth(data_pack->header.channel_header_size+data_pack->header.channel_data_size + sizeof(DirectIODataPackDispatchHeader)); + int32_t total_data = (data_pack->header.channel_header_size+data_pack->header.channel_data_size + sizeof(DirectIODataPackDispatchHeader)); + total_data += current_bandwidth; + (*counter_data_sent) += current_bandwidth; return wrapped_connection->sendServiceData(MOVE(data_pack), asynchronous_answer); } + +void DirectIOClientConnectionMetricCollector::fetchMetricForTimeDiff(uint64_t time_diff) { + double sec = time_diff/1000; + if(sec == 0) return; + (*gauge_bandwidth_uptr) = ((current_bandwidth / sec)/1024); current_bandwidth = 0; +} diff --git a/chaos/common/direct_io/DirectIOClientConnectionMetricCollector.h b/chaos/common/direct_io/DirectIOClientConnectionMetricCollector.h index de455803634955492efbe5155ce5719530f071c5..74ce8cd657e347f0d4b746963b0b9eb41fb7fc5c 100644 --- a/chaos/common/direct_io/DirectIOClientConnectionMetricCollector.h +++ b/chaos/common/direct_io/DirectIOClientConnectionMetricCollector.h @@ -24,7 +24,6 @@ #include <chaos/common/metric/metric.h> #include <chaos/common/direct_io/DirectIOClientConnection.h> -#include <chaos/common/direct_io/DirectIOClientConnectionSharedMetricIO.h> #include <boost/shared_ptr.hpp> @@ -37,16 +36,19 @@ namespace chaos { the metric collection da data that flow through the DirectIO */ class DirectIOClientConnectionMetricCollector: - public DirectIOClientConnection { + public DirectIOClientConnection, + public chaos::common::metric::MetricCollectorIO { friend class DirectIOClient; - ChaosSharedPtr<DirectIOClientConnectionSharedMetricIO> shared_collector; DirectIOClientConnection *wrapped_connection; + chaos::common::metric::CounterUniquePtr counter_dataseet_sent; + chaos::common::metric::CounterUniquePtr counter_data_sent; + chaos::common::metric::GaugeUniquePtr gauge_bandwidth_uptr; + double current_bandwidth; protected: void fetchMetricForTimeDiff(uint64_t time_diff); public: DirectIOClientConnectionMetricCollector(const std::string& _server_description, uint16_t _endpoint, - ChaosSharedPtr<DirectIOClientConnectionSharedMetricIO> _shared_collector, DirectIOClientConnection *_wrapped_connection); ~DirectIOClientConnectionMetricCollector(); diff --git a/chaos/common/direct_io/DirectIOClientConnectionSharedMetricIO.cpp b/chaos/common/direct_io/DirectIOClientConnectionSharedMetricIO.cpp deleted file mode 100644 index 9d0c8638858ba0ef9a36a5a417704cfb9ef766cc..0000000000000000000000000000000000000000 --- a/chaos/common/direct_io/DirectIOClientConnectionSharedMetricIO.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2012, 2017 INFN - * - * Licensed under the EUPL, Version 1.2 or – as soon they - * will be approved by the European Commission - subsequent - * versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the - * Licence. - * You may obtain a copy of the Licence at: - * - * https://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in - * writing, software distributed under the Licence is - * distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. - * See the Licence for the specific language governing - * permissions and limitations under the Licence. - */ - -#include <chaos/common/direct_io/DirectIOClientConnectionSharedMetricIO.h> - -#include <chaos/common/configuration/GlobalConfiguration.h> - -#include <boost/format.hpp> - -using namespace chaos::common::direct_io; - -#define DIOCCSMC_INFO INFO_LOG(DirectIOClientConnectionSharedMetricIO) -#define DIOCCSMC_DBG_ DBG_LOG(DirectIOClientConnectionSharedMetricIO) -#define DIOCCSMC_ERR_ ERR_LOG(DirectIOClientConnectionSharedMetricIO) - -DirectIOClientConnectionSharedMetricIO::DirectIOClientConnectionSharedMetricIO(const std::string& client_impl, - const std::string& server_endpoint): -MetricCollectorIO(client_impl, - GlobalConfiguration::getInstance()->getConfiguration()->getUInt64Value(InitOption::OPT_DIRECT_IO_LOG_METRIC_UPDATE_INTERVAL)) { - - DIOCCSMC_DBG_ << "Allocate collector"; - - startLogging(); -} - -DirectIOClientConnectionSharedMetricIO::~DirectIOClientConnectionSharedMetricIO() { - //DIOCCSMC_DBG_ << "Deallocate collector"; - stopLogging(); -} - -void DirectIOClientConnectionSharedMetricIO::incrementPackCount() { - pack_count++; -} - -//increment packet size -void DirectIOClientConnectionSharedMetricIO::incrementBandWidth(uint64_t increment) { - bandwith+=increment; -} - -void DirectIOClientConnectionSharedMetricIO::fetchMetricForTimeDiff(uint64_t time_diff) { - MetricCollectorIO::fetchMetricForTimeDiff(time_diff); -} \ No newline at end of file diff --git a/chaos/common/direct_io/DirectIOClientConnectionSharedMetricIO.h b/chaos/common/direct_io/DirectIOClientConnectionSharedMetricIO.h deleted file mode 100644 index 014f4d9078ecfe39858420e177b93823a5f5c56f..0000000000000000000000000000000000000000 --- a/chaos/common/direct_io/DirectIOClientConnectionSharedMetricIO.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2012, 2017 INFN - * - * Licensed under the EUPL, Version 1.2 or – as soon they - * will be approved by the European Commission - subsequent - * versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the - * Licence. - * You may obtain a copy of the Licence at: - * - * https://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in - * writing, software distributed under the Licence is - * distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. - * See the Licence for the specific language governing - * permissions and limitations under the Licence. - */ - -#ifndef __CHAOSFramework__DirectIOClientConnectionSharedMetricIO__ -#define __CHAOSFramework__DirectIOClientConnectionSharedMetricIO__ - -#include <chaos/common/metric/metric.h> -namespace chaos { - namespace common { - namespace direct_io { - class DirectIOClientConnectionSharedMetricIO: - public chaos::common::metric::MetricCollectorIO { - protected: - void fetchMetricForTimeDiff(uint64_t time_diff); - public: - DirectIOClientConnectionSharedMetricIO(const std::string& client_impl, - const std::string& server_endpoint); - ~DirectIOClientConnectionSharedMetricIO(); - - void incrementPackCount(); - void incrementBandWidth(uint64_t increment); - }; - } - } -} - -#endif /* defined(__CHAOSFramework__DirectIOClientConnectionSharedMetricIO__) */ diff --git a/chaos/common/direct_io/DirectIODispatcherMetricCollector.cpp b/chaos/common/direct_io/DirectIODispatcherMetricCollector.cpp index f8773c26e30a9563374223775720e7927cf80eb3..9d7a96b29e96c8e39f68a8c21e861ab7f314d0b5 100644 --- a/chaos/common/direct_io/DirectIODispatcherMetricCollector.cpp +++ b/chaos/common/direct_io/DirectIODispatcherMetricCollector.cpp @@ -23,6 +23,7 @@ #include <chaos/common/configuration/GlobalConfiguration.h> +using namespace chaos::common::metric; using namespace chaos::common::direct_io; static const char * const METRIC_KEY_ENDPOINT_ALIVE = "ndpoint_alive"; @@ -31,13 +32,17 @@ static const char * const METRIC_KEY_ENDPOINT_ALIVE = "ndpoint_alive"; #define DIODMC_DBG_ DBG_LOG(DirectIODispatcherMetricCollector) #define DIODMC_ERR_ ERR_LOG(DirectIODispatcherMetricCollector) -DirectIODispatcherMetricCollector::DirectIODispatcherMetricCollector(const std::string& direct_io_server_impl): -MetricCollectorIO(direct_io_server_impl, - GlobalConfiguration::getInstance()->getConfiguration()->getUInt64Value(InitOption::OPT_DIRECT_IO_LOG_METRIC_UPDATE_INTERVAL)), -endpoint_alive_count(0) { +DirectIODispatcherMetricCollector::DirectIODispatcherMetricCollector(): +MetricCollectorIO(), +endpoint_alive_count(0), +current_bandwidth(0){ DIODMC_DBG_ << "Allcoate collector"; //uppend custom direct io metric - addMetric(METRIC_KEY_ENDPOINT_ALIVE, chaos::DataType::TYPE_INT32); + coutenr_pack_uptr = MetricManager::getInstance()->getNewRxPacketRateMetricFamily({{"driver","direct_io"}}); + counter_data_uptr = MetricManager::getInstance()->getNewRxDataRateMetricFamily({{"driver","direct_io"}}); + + MetricManager::getInstance()->createGaugeFamily("rx_bandwidth_direct_io_dispatcher", "Metric for bandwith measure on data received by direct-io dispatcher"); + gauge_bandwidth_uptr = MetricManager::getInstance()->getNewGaugeFromFamily("rx_bandwidth_direct_io_dispatcher"); } DirectIODispatcherMetricCollector::~DirectIODispatcherMetricCollector() { @@ -62,24 +67,24 @@ void DirectIODispatcherMetricCollector::stop() { //! Allocate a new endpoint DirectIOServerEndpoint *DirectIODispatcherMetricCollector::getNewEndpoint() { - endpoint_alive_count++; return DirectIODispatcher::getNewEndpoint(); } //! Relase the endpoint void DirectIODispatcherMetricCollector::releaseEndpoint(DirectIOServerEndpoint *endpoint_to_release) { DirectIODispatcher::releaseEndpoint(endpoint_to_release); - endpoint_alive_count--; } // Event for a new data received int DirectIODispatcherMetricCollector::priorityDataReceived(chaos::common::direct_io::DirectIODataPackSPtr data_pack, chaos::common::direct_io::DirectIODataPackSPtr& synchronous_answer) { //inrement packet count - pack_count++; + (*coutenr_pack_uptr)++; //increment packet size - bandwith+=data_pack->header.channel_header_size+data_pack->header.channel_data_size + sizeof(DirectIODataPackDispatchHeader); + long total_data = data_pack->header.channel_header_size+data_pack->header.channel_data_size + sizeof(DirectIODataPackDispatchHeader); + current_bandwidth += total_data; + (*counter_data_uptr)+= total_data; //flow back to base class return DirectIODispatcher::priorityDataReceived(MOVE(data_pack), @@ -90,10 +95,12 @@ int DirectIODispatcherMetricCollector::priorityDataReceived(chaos::common::direc int DirectIODispatcherMetricCollector::serviceDataReceived(chaos::common::direct_io::DirectIODataPackSPtr data_pack, chaos::common::direct_io::DirectIODataPackSPtr& synchronous_answer) { //inrement packec count - pack_count++; + (*coutenr_pack_uptr)++; //increment packet size - bandwith+=data_pack->header.channel_header_size+data_pack->header.channel_data_size + sizeof(DirectIODataPackDispatchHeader); + long total_data = data_pack->header.channel_header_size+data_pack->header.channel_data_size + sizeof(DirectIODataPackDispatchHeader); + current_bandwidth += total_data; + (*counter_data_uptr)+= total_data; //flow back to base class return DirectIODispatcher::serviceDataReceived(MOVE(data_pack), @@ -101,8 +108,7 @@ int DirectIODispatcherMetricCollector::serviceDataReceived(chaos::common::direct } void DirectIODispatcherMetricCollector::fetchMetricForTimeDiff(uint64_t time_diff) { - updateMetricValue(METRIC_KEY_ENDPOINT_ALIVE, - &endpoint_alive_count, - sizeof(int32_t)); - MetricCollectorIO::fetchMetricForTimeDiff(time_diff); + double sec = time_diff/1000; + if(sec == 0) return; + (*gauge_bandwidth_uptr) = ((current_bandwidth / sec)/1024); current_bandwidth = 0; } diff --git a/chaos/common/direct_io/DirectIODispatcherMetricCollector.h b/chaos/common/direct_io/DirectIODispatcherMetricCollector.h index 372150fdb7e8b41d10ec81387472190540c4b1a8..a4aa3c683a1cafa14237fbcdea9242954c9162cc 100644 --- a/chaos/common/direct_io/DirectIODispatcherMetricCollector.h +++ b/chaos/common/direct_io/DirectIODispatcherMetricCollector.h @@ -37,10 +37,15 @@ namespace chaos { public DirectIODispatcher, public chaos::common::metric::MetricCollectorIO { int32_t endpoint_alive_count; + chaos::common::metric::CounterUniquePtr coutenr_pack_uptr; + chaos::common::metric::CounterUniquePtr counter_data_uptr; + + double current_bandwidth; + chaos::common::metric::GaugeUniquePtr gauge_bandwidth_uptr; protected: void fetchMetricForTimeDiff(uint64_t time_diff); public: - DirectIODispatcherMetricCollector(const std::string& direct_io_server_impl); + DirectIODispatcherMetricCollector(); ~DirectIODispatcherMetricCollector(); // Start the implementation diff --git a/chaos/common/global.h b/chaos/common/global.h index bd6c6587233a4213c2d80276782b3ee8f01ef0f6..fdc2e2457aecd693504737b23418d2598a7bc2f1 100644 --- a/chaos/common/global.h +++ b/chaos/common/global.h @@ -207,7 +207,7 @@ delete(x); x=NULL; LAPP_ << "-----------------------------------------";\ LAPP_ << CSLIB_VERSION_HEADER;\ LAPP_ << CSLIB_VERSION_MAJOR<<"."<<CSLIB_VERSION_MINOR<<CSLIB_VERSION_NUMBER;\ - LAPP_ << "Build ID:"<<CSLIB_BUILD_ID;\ +LAPP_ << "Build ID:"<<CSLIB_BUILD_ID;\ LAPP_ << "Build Date:"<<__DATE__ <<" " <<__TIME__; \ LAPP_ << "-----------------------------------------"; diff --git a/chaos/common/metric/AbstractMetricBackend.cpp b/chaos/common/metric/AbstractMetricBackend.cpp deleted file mode 100644 index 3cd439c7d12de87720fc4e4da52e29f87e7c99f7..0000000000000000000000000000000000000000 --- a/chaos/common/metric/AbstractMetricBackend.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2012, 2017 INFN - * - * Licensed under the EUPL, Version 1.2 or – as soon they - * will be approved by the European Commission - subsequent - * versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the - * Licence. - * You may obtain a copy of the Licence at: - * - * https://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in - * writing, software distributed under the Licence is - * distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. - * See the Licence for the specific language governing - * permissions and limitations under the Licence. - */ - -#include <chaos/common/metric/AbstractMetricBackend.h> - -using namespace chaos::common::metric; - -AbstractMetricBackend::AbstractMetricBackend(const std::string& _backend_indetity): -backend_indetity(_backend_indetity){ - -} - -AbstractMetricBackend::~AbstractMetricBackend() { - -} - -void AbstractMetricBackend::init(void *init_data) { - -} - -void AbstractMetricBackend::deinit() { - -} - -void AbstractMetricBackend::addConfiguration(const std::string& configuraiton_name, - const std::string& configuraiton_value) { - //append configuration - map_configuration.insert(make_pair(configuraiton_name, configuraiton_value)); -} - -void AbstractMetricBackend::addConfiguration(const MapMetricBackendConfiguration& configuration) { - //apoend configuration for input map - map_configuration.insert(configuration.begin(), configuration.end()); -} diff --git a/chaos/common/metric/AbstractMetricBackend.h b/chaos/common/metric/AbstractMetricBackend.h deleted file mode 100644 index 6a9ce4cec70c718bfcabd74eac735b40826edee8..0000000000000000000000000000000000000000 --- a/chaos/common/metric/AbstractMetricBackend.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2012, 2017 INFN - * - * Licensed under the EUPL, Version 1.2 or – as soon they - * will be approved by the European Commission - subsequent - * versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the - * Licence. - * You may obtain a copy of the Licence at: - * - * https://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in - * writing, software distributed under the Licence is - * distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. - * See the Licence for the specific language governing - * permissions and limitations under the Licence. - */ - -#ifndef __CHAOSFramework__AbstractMetricBackend__ -#define __CHAOSFramework__AbstractMetricBackend__ - -#include <string> -#include <chaos/common/chaos_types.h> -#include <chaos/common/utility/InizializableService.h> - -#include <boost/variant.hpp> - -#include <stdint.h> - -namespace chaos { - namespace common { - namespace metric { - - CHAOS_DEFINE_MAP_FOR_TYPE(std::string, std::string, MapMetricBackendConfiguration) - - //!Abstract class for the metric representation and memorization - /*! - To create a new backnd for visualization or memorization on various backend - */ - class AbstractMetricBackend: - public chaos::common::utility::InizializableService { - protected: - const std::string backend_indetity; - MapMetricBackendConfiguration map_configuration; - public: - AbstractMetricBackend(const std::string& _backend_indetity); - ~AbstractMetricBackend(); - - void init(void *init_data); - void deinit(); - void addConfiguration(const std::string& configuraiton_name, - const std::string& configuraiton_value); - void addConfiguration(const MapMetricBackendConfiguration& configuration); - virtual void preMetric() = 0; - virtual void addMetric(const std::string& metric_name, - const std::string& metric_value) = 0; - virtual void postMetric() = 0; - virtual void prepare(uint64_t metric_acquire_ts) = 0; - virtual void flush() = 0; - }; - } - } -} - -#endif /* defined(__CHAOSFramework__AbstractMetricBackend__) */ diff --git a/chaos/common/metric/CSVFileMetricBackend.cpp b/chaos/common/metric/CSVFileMetricBackend.cpp deleted file mode 100644 index 72ec9a0b07507fde09d07988eea6e6db92b8e2b6..0000000000000000000000000000000000000000 --- a/chaos/common/metric/CSVFileMetricBackend.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2012, 2017 INFN - * - * Licensed under the EUPL, Version 1.2 or – as soon they - * will be approved by the European Commission - subsequent - * versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the - * Licence. - * You may obtain a copy of the Licence at: - * - * https://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in - * writing, software distributed under the Licence is - * distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. - * See the Licence for the specific language governing - * permissions and limitations under the Licence. - */ - -#include <chaos/common/metric/CSVFileMetricBackend.h> - -#include <fstream> - -using namespace chaos::common::metric; - -CVSFileMetricBackend::CVSFileMetricBackend(const std::string& _backend_identity, - const std::string& _file_path, - bool append): -FileMetricBackend(_backend_identity, - _file_path, - ".csv", - (append?std::fstream::app:std::fstream::trunc)| std::fstream::out){ - -} - -CVSFileMetricBackend::~CVSFileMetricBackend() { - -} - -void CVSFileMetricBackend::prepare(uint64_t metric_acquire_ts) { - output_stream << metric_acquire_ts; -} - -void CVSFileMetricBackend::preMetric() { - output_stream << ","; -} - -void CVSFileMetricBackend::addMetric(const std::string& metric_name, - const std::string& metric_value) { - output_stream << metric_value; -} - - -void CVSFileMetricBackend::postMetric() { - -} - - -void CVSFileMetricBackend::flush() { - //write to file - output_stream << std::endl; - output_file_stream << output_stream.str(); - FileMetricBackend::flush(); - output_stream.clear(); - output_stream.str(""); -} diff --git a/chaos/common/metric/CSVFileMetricBackend.h b/chaos/common/metric/CSVFileMetricBackend.h deleted file mode 100644 index a71721842d07ac7f4243f6d6d1f156a32ca47a78..0000000000000000000000000000000000000000 --- a/chaos/common/metric/CSVFileMetricBackend.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2012, 2017 INFN - * - * Licensed under the EUPL, Version 1.2 or – as soon they - * will be approved by the European Commission - subsequent - * versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the - * Licence. - * You may obtain a copy of the Licence at: - * - * https://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in - * writing, software distributed under the Licence is - * distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. - * See the Licence for the specific language governing - * permissions and limitations under the Licence. - */ - -#ifndef __CHAOSFramework__CSVFileMetricBackend__ -#define __CHAOSFramework__CSVFileMetricBackend__ - -#include <chaos/common/metric/FileMetricBackend.h> - -#include <sstream> - -namespace chaos { - namespace common { - namespace metric { - class CVSFileMetricBackend: - public FileMetricBackend { - protected: - const boost::filesystem::path file_path; - std::ostringstream output_stream; - public: - CVSFileMetricBackend(const std::string& _backend_identity, - const std::string& _file_path, - bool append = false); - ~CVSFileMetricBackend(); - void preMetric(); - void addMetric(const std::string& metric_name, - const std::string& metric_value); - void postMetric(); - void prepare(uint64_t metric_acquire_ts); - void flush(); - }; - - } - } -} - -#endif /* defined(__CHAOSFramework__CSVFileMetricBackend__) */ diff --git a/chaos/common/metric/ConsoleMetricBackend.cpp b/chaos/common/metric/ConsoleMetricBackend.cpp deleted file mode 100644 index c9e439555775ac8c9b536bd7c4a5a0bfdb3ba578..0000000000000000000000000000000000000000 --- a/chaos/common/metric/ConsoleMetricBackend.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2012, 2017 INFN - * - * Licensed under the EUPL, Version 1.2 or – as soon they - * will be approved by the European Commission - subsequent - * versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the - * Licence. - * You may obtain a copy of the Licence at: - * - * https://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in - * writing, software distributed under the Licence is - * distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. - * See the Licence for the specific language governing - * permissions and limitations under the Licence. - */ - -#include <chaos/common/global.h> -#include <chaos/common/metric/ConsoleMetricBackend.h> - -using namespace chaos::common::metric; - -#define CONSOLE_MB_INFO INFO_LOG(ConsoleMetricBackend) -#define CONSOLE_MB_LDBG DBG_LOG(ConsoleMetricBackend) -#define CONSOLE_MB_LNOTICE NOTICE_LOG(ConsoleMetricBackend) - -ConsoleMetricBackend::ConsoleMetricBackend(const std::string& _backend_identity): -AbstractMetricBackend(_backend_identity), -first_metric(false){} - -ConsoleMetricBackend::~ConsoleMetricBackend() {} - -void ConsoleMetricBackend::preMetric() { - if(first_metric) return; - output_stream << ","; -} - -void ConsoleMetricBackend::addMetric(const std::string& metric_name, - const std::string& metric_value) { - //! - output_stream << metric_name << ":" << metric_value; - first_metric = false; -} - - -void ConsoleMetricBackend::postMetric() { - -} - -void ConsoleMetricBackend::prepare(uint64_t metric_acquire_ts) { - first_metric = true; - output_stream << backend_indetity << "["; -} - -void ConsoleMetricBackend::flush() { - output_stream <<"]"; - CONSOLE_MB_LNOTICE << output_stream.str(); - output_stream.clear(); - output_stream.str(""); -} diff --git a/chaos/common/metric/ConsoleMetricBackend.h b/chaos/common/metric/ConsoleMetricBackend.h deleted file mode 100644 index 811361c1593e98c3994ded559e6d1440bcbf93ab..0000000000000000000000000000000000000000 --- a/chaos/common/metric/ConsoleMetricBackend.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2012, 2017 INFN - * - * Licensed under the EUPL, Version 1.2 or – as soon they - * will be approved by the European Commission - subsequent - * versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the - * Licence. - * You may obtain a copy of the Licence at: - * - * https://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in - * writing, software distributed under the Licence is - * distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. - * See the Licence for the specific language governing - * permissions and limitations under the Licence. - */ - -#ifndef __CHAOSFramework__ConsoleMetricBackend__ -#define __CHAOSFramework__ConsoleMetricBackend__ - -#include <chaos/common/metric/AbstractMetricBackend.h> - -#include <sstream> - -namespace chaos { - namespace common { - namespace metric { - - class ConsoleMetricBackend: - public AbstractMetricBackend { - bool first_metric; - std::ostringstream output_stream; - public: - ConsoleMetricBackend(const std::string& _backend_identity); - ~ConsoleMetricBackend(); - void preMetric(); - void addMetric(const std::string& metric_name, - const std::string& metric_value); - void postMetric(); - void prepare(uint64_t metric_acquire_ts); - void flush(); - }; - - } - } -} - -#endif /* defined(__CHAOSFramework__ConsoleMetricBackend__) */ diff --git a/chaos/common/metric/FileMetricBackend.cpp b/chaos/common/metric/FileMetricBackend.cpp deleted file mode 100644 index 050af02358f0f3f4b316c4fed37f7254281af0e0..0000000000000000000000000000000000000000 --- a/chaos/common/metric/FileMetricBackend.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2012, 2017 INFN - * - * Licensed under the EUPL, Version 1.2 or – as soon they - * will be approved by the European Commission - subsequent - * versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the - * Licence. - * You may obtain a copy of the Licence at: - * - * https://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in - * writing, software distributed under the Licence is - * distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. - * See the Licence for the specific language governing - * permissions and limitations under the Licence. - */ - -#include <chaos/common/global.h> -#include <chaos/common/metric/FileMetricBackend.h> - -#include <boost/format.hpp> -using namespace chaos::common::metric; - -#define FILE_MB_INFO INFO_LOG(FileMetricBackend) -#define FILE_MB_LDBG DBG_LOG(FileMetricBackend) -#define FILE_MB_LERR ERR_LOG(FileMetricBackend) - -FileMetricBackend::FileMetricBackend(const std::string& _backend_identity, - const std::string& _file_path, - const std::string& _file_extension, - std::ios_base::openmode _open_mode): -AbstractMetricBackend(_backend_identity), -file_path(_file_path){ -//open file - CHAOS_ASSERT(boost::filesystem::create_directories(file_path) || boost::filesystem::exists(file_path)) - boost::filesystem::path file = file_path; - file /= _backend_identity; - file.replace_extension(_file_extension); - - output_file_stream.open(file, _open_mode); -} - -FileMetricBackend::~FileMetricBackend() { - output_file_stream.close(); -} - -void FileMetricBackend::flush() { - output_file_stream.flush(); -} diff --git a/chaos/common/metric/FileMetricBackend.h b/chaos/common/metric/FileMetricBackend.h deleted file mode 100644 index 02581b9f413e92be1176e18b2511222d59cb0fb4..0000000000000000000000000000000000000000 --- a/chaos/common/metric/FileMetricBackend.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2012, 2017 INFN - * - * Licensed under the EUPL, Version 1.2 or – as soon they - * will be approved by the European Commission - subsequent - * versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the - * Licence. - * You may obtain a copy of the Licence at: - * - * https://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in - * writing, software distributed under the Licence is - * distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. - * See the Licence for the specific language governing - * permissions and limitations under the Licence. - */ - -#ifndef __CHAOSFramework__FileMetricBackend__ -#define __CHAOSFramework__FileMetricBackend__ - -#include <chaos/common/metric/AbstractMetricBackend.h> - -#include <boost/filesystem.hpp> -#include <boost/filesystem/fstream.hpp> - -#include <iostream> - -namespace chaos { - namespace common { - namespace metric { - class FileMetricBackend: - public AbstractMetricBackend { - protected: - const boost::filesystem::path file_path; - boost::filesystem::fstream output_file_stream; - public: - FileMetricBackend(const std::string& _backend_identity, - const std::string& _file_path, - const std::string& _file_extension, - std::ios_base::openmode _open_mode); - ~FileMetricBackend(); - void flush(); - }; - - } - } -} - -#endif /* defined(__CHAOSFramework__FileMetricBackend__) */ diff --git a/chaos/common/metric/MetricCollector.cpp b/chaos/common/metric/MetricCollector.cpp index 099a59b1698e70a34c8ec477236426470d838fcb..271836218be3a5ddf5539e2777a8b7fd9c9039a0 100644 --- a/chaos/common/metric/MetricCollector.cpp +++ b/chaos/common/metric/MetricCollector.cpp @@ -20,9 +20,6 @@ */ #include <chaos/common/metric/MetricCollector.h> -#include <chaos/common/metric/ConsoleMetricBackend.h> -#include <chaos/common/metric/CSVFileMetricBackend.h> -#include <chaos/common/utility/TimingUtil.h> #include <chaos/common/configuration/GlobalConfiguration.h> #include <sstream> @@ -31,137 +28,11 @@ #define MC_LERR ERR_LOG(MetricCollector) using namespace chaos::common::metric; -using namespace chaos::common::data::cache; -using namespace chaos::common::async_central; -MetricCollector::MetricCollector(const std::string& _collector_name, - uint64_t update_time_in_sec): -collector_name(_collector_name), -current_slot_index(0), -last_stat_call(0), -stat_intervall(update_time_in_sec*1000){ - bool on_console = GlobalConfiguration::getInstance()->getConfiguration()->hasKey(InitOption::OPT_LOG_METRIC_ON_CONSOLE) && - GlobalConfiguration::getInstance()->getConfiguration()->getVariantValue(InitOption::OPT_LOG_METRIC_ON_CONSOLE).asBool(); - bool on_file = GlobalConfiguration::getInstance()->getConfiguration()->hasKey(InitOption::OPT_LOG_METRIC_ON_FILE) && - GlobalConfiguration::getInstance()->getConfiguration()->getVariantValue(InitOption::OPT_LOG_METRIC_ON_FILE).asBool(); - if(on_console) { - //set the metric manager to print metrics on console - addBackend(metric::MetricBackendPointer(new metric::ConsoleMetricBackend(collector_name))); - } - - if(on_file) { - const std::string file_path = GlobalConfiguration::getInstance()->getConfiguration()->getStringValue(InitOption::OPT_LOG_METRIC_ON_FILE_PATH); - //set the time interval to one second of default - addBackend(metric::MetricBackendPointer(new metric::CVSFileMetricBackend(collector_name, - file_path))); - } - if(!on_console && - !on_file) { - MC_INFO<< "% No metric output selected for collector, redirecting to default. To redirect output use options:'"<<InitOption::OPT_LOG_METRIC_ON_FILE<<"' and '"<<InitOption::OPT_LOG_METRIC_ON_FILE_PATH<<"'" ; - addBackend(metric::MetricBackendPointer(new metric::ConsoleMetricBackend(collector_name))); - // per una cavolata non parte l'MDS - //throw CException(-1, "No metric output selected for collector", __PRETTY_FUNCTION__); - } -} +MetricCollector::MetricCollector() {} +MetricCollector::~MetricCollector() {} -MetricCollector::~MetricCollector() { - stopLogging(); - caching_slot[1].metric_attribute_cache.reset(); - caching_slot[0].metric_attribute_cache.reset(); -} -void MetricCollector::addBackend(MetricBackendPointer backend) { - vector_metric_backend.push_back(backend); -} +void MetricCollector::startLogging() {} -bool MetricCollector::_addMetric(ChachingSlot& cs, - const std::string& metric_name, - chaos::DataType::DataType metric_type, - uint32_t metric_max_size) { - cs.metric_attribute_cache.addAttribute(metric_name, metric_max_size, metric_type); - AttributeValue *cached_metric = cs.metric_attribute_cache.getValueSettingForIndex(cs.metric_attribute_cache.getIndexForName(metric_name)); - if(cached_metric) { - cs.map_name_index.insert(make_pair(metric_name, cs.map_name_index.size())); - cs.vector_attribute_value.push_back(cached_metric); - return true; - } else { - return false; - } - -} - -bool MetricCollector::addMetric(const std::string& metric_name, - chaos::DataType::DataType metric_type, - uint32_t metric_max_size) { - boost::shared_lock<boost::shared_mutex> rl(current_slot_index_mutex); - return _addMetric(caching_slot[0], metric_name, metric_type, metric_max_size) && - _addMetric(caching_slot[1], metric_name, metric_type, metric_max_size); -} - -bool MetricCollector::updateMetricValue(const std::string& metric_name, - const void *value_ptr, - uint32_t value_size) { - boost::shared_lock<boost::shared_mutex> rl(current_slot_index_mutex); - if(caching_slot[current_slot_index].map_name_index.count(metric_name) == 0) return false; - return caching_slot[current_slot_index].vector_attribute_value[caching_slot[current_slot_index].map_name_index[metric_name]]->setValue(value_ptr, - value_size); -} - -void MetricCollector::writeTo(chaos::common::data::CDataWrapper& data_wrapper) { - //switch slot - boost::unique_lock<boost::shared_mutex> rwl(current_slot_index_mutex); - ChachingSlot *slot_to_persist = &caching_slot[(current_slot_index ^= 0x00000001)]; - rwl.unlock(); - - //persiste previous slot - for(VectorMetricIterator it = slot_to_persist->vector_attribute_value.begin(); - it != slot_to_persist->vector_attribute_value.end(); - it++) { - (*it)->writeToCDataWrapper(data_wrapper); - } -} - -void MetricCollector::timeout() { - uint64_t now = chaos::common::utility::TimingUtil::getTimeStamp(); - if(last_stat_call) { - fetchMetricForTimeDiff(now - last_stat_call); - } else { - fetchMetricForTimeDiff(0); - } - last_stat_call = chaos::common::utility::TimingUtil::getTimeStamp(); - //switch slot - boost::unique_lock<boost::shared_mutex> rwl(current_slot_index_mutex); - ChachingSlot *slot_to_persist = &caching_slot[(current_slot_index ^= 0x00000001) ^ 0x00000001]; - rwl.unlock(); - - //write metric to backend - CHAOS_SCAN_VECTOR_ITERATOR(VectorMetricBackendIterator, vector_metric_backend, (*it)->prepare(now);) - for(VectorMetricIterator it_metric = slot_to_persist->vector_attribute_value.begin(); - it_metric != slot_to_persist->vector_attribute_value.end(); - it_metric++) { - CHAOS_SCAN_VECTOR_ITERATOR(VectorMetricBackendIterator, - vector_metric_backend, - (*it)->preMetric(); - (*it)->addMetric((*it_metric)->name, - (*it_metric)->toString(2)); - (*it)->postMetric();) - } - CHAOS_SCAN_VECTOR_ITERATOR(VectorMetricBackendIterator, vector_metric_backend, (*it)->flush();) -} - -void MetricCollector::setStatIntervalInSeconds(uint64_t stat_intervall_in_seconds) { - stat_intervall = stat_intervall_in_seconds*1000; -} - -void MetricCollector::startLogging() { - try{ - last_stat_call = chaos::common::utility::TimingUtil::getTimeStamp(); - AsyncCentralManager::getInstance()->addTimer(this, 1000, stat_intervall); - }catch(...) { - throw CException(-1, "Error adding timer", __PRETTY_FUNCTION__); - } -} - -void MetricCollector::stopLogging() { - AsyncCentralManager::getInstance()->removeTimer(this); -} +void MetricCollector::stopLogging() {} diff --git a/chaos/common/metric/MetricCollector.h b/chaos/common/metric/MetricCollector.h index 42de9628a254f7a17e74ef89d1889feae57c9a6e..84545a4b6a5bc29edaa87126d8f1b8978a682645 100644 --- a/chaos/common/metric/MetricCollector.h +++ b/chaos/common/metric/MetricCollector.h @@ -24,101 +24,26 @@ #include <chaos/common/chaos_types.h> #include <chaos/common/chaos_constants.h> -#include <chaos/common/data/CDataWrapper.h> -#include <chaos/common/data/cache/AttributeCache.h> -#include <chaos/common/async_central/async_central.h> -#include <chaos/common/metric/AbstractMetricBackend.h> #include <string> #include <stdint.h> -#include <boost/thread.hpp> -#include <boost/shared_ptr.hpp> namespace chaos { namespace common { namespace metric { - typedef ChaosSharedPtr<AbstractMetricBackend> MetricBackendPointer; - CHAOS_DEFINE_VECTOR_FOR_TYPE(MetricBackendPointer, VectorMetricBackend) - - CHAOS_DEFINE_MAP_FOR_TYPE(std::string, int, MapMetricNameVecIndex) - CHAOS_DEFINE_VECTOR_FOR_TYPE(chaos::common::data::cache::AttributeValue*, VectorMetric) - - struct ChachingSlot { - MapMetricNameVecIndex map_name_index; - VectorMetric vector_attribute_value; - chaos::common::data::cache::AttributeCache metric_attribute_cache; - }; - //! Class that permit to collect a set of metric - class MetricCollector: - public chaos::common::async_central::TimerHandler { - //is a name for collector - std::string collector_name; - - //! backend used to visualize the metric - VectorMetricBackend vector_metric_backend; - - //! two different slot for optimizing the update of the metric wil old one are snapped to backend - ChachingSlot caching_slot[2]; - - boost::shared_mutex current_slot_index_mutex; - int current_slot_index; - uint64_t last_stat_call; - uint64_t stat_intervall; - - bool _addMetric(ChachingSlot& cs, - const std::string& metric_name, - chaos::DataType::DataType metric_type, - uint32_t metric_max_size = 32); - - void _prepareBackends(); - void _sendToBackends(const std::string& metric_name, - const std::string& metric_value); - void _flushBackends(); - private: - void timeout(); + class MetricCollector { protected: - //! need to be implementad by the subclass for collect metric - /*! - this methdo is called at fixed(almost) delay of time, every time si called - it bring the difference in milliseconds since the last call. Subclass can usi this value - to compute the metric of statistic - \param time_diff time passed(in milliseconds) from last call - */ - virtual void fetchMetricForTimeDiff(uint64_t time_diff) = 0; public: - MetricCollector(const std::string& _collector_name, - uint64_t update_time_in_sec = 10); + MetricCollector(); ~MetricCollector(); - //! add a new backend - void addBackend(MetricBackendPointer backend); - - //add a new metric - bool addMetric(const std::string& metric_name, - chaos::DataType::DataType metric_type, - uint32_t metric_max_size = 32); - - //udpate a single metric value - bool updateMetricValue(const std::string& metric_name, - const void *value_ptr, - uint32_t value_size); - - //! write the mertic to a cdata wrapper - void writeTo(chaos::common::data::CDataWrapper& data_wrapper); - - //!set the stat interval in milliseoconds - /*! - determinate the delay between a fetchMetricForTimeDiff call and the next - */ - void setStatIntervalInSeconds(uint64_t stat_intervall_in_seconds); - - void startLogging(); + virtual void startLogging(); - void stopLogging(); + virtual void stopLogging(); }; } diff --git a/chaos/common/metric/MetricCollectorIO.cpp b/chaos/common/metric/MetricCollectorIO.cpp index 20a4fc632a91a76ca4d849cd00b0c6de836664b6..669b724c06b0d184fd2d7784f3b48d1e9e6d1994 100644 --- a/chaos/common/metric/MetricCollectorIO.cpp +++ b/chaos/common/metric/MetricCollectorIO.cpp @@ -21,40 +21,53 @@ #include <chaos/common/metric/MetricCollectorIO.h> +#include <chaos/common/utility/TimingUtil.h> + using namespace chaos::common::metric; +using namespace chaos::common::async_central; -static const char * const METRIC_KEY_PACKET_COUNT = "packet_count"; -static const char * const METRIC_KEY_BANDWITH = "kb_sec"; -//static const char * const METRIC_KEY_PACKET_UNSENT_COUNT = "packet_waiting"; - -MetricCollectorIO::MetricCollectorIO(const std::string& _collector_name, - uint64_t update_time_in_sec): -MetricCollector(_collector_name, - update_time_in_sec), -pack_count(0), -bandwith(0), -pack_count_for_ut(0.0), -bw_for_ut(0.0){ +MetricCollectorIO::MetricCollectorIO(): +MetricCollector(), +last_sample_ts(0){ //received pack and bw in the - addMetric(METRIC_KEY_PACKET_COUNT, chaos::DataType::TYPE_DOUBLE); - addMetric(METRIC_KEY_BANDWITH, chaos::DataType::TYPE_DOUBLE); +// addMetric(METRIC_KEY_PACKET_COUNT, chaos::DataType::TYPE_DOUBLE); +// addMetric(METRIC_KEY_BANDWITH, chaos::DataType::TYPE_DOUBLE); + last_sample_ts = chaos::common::utility::TimingUtil::getTimeStamp(); } MetricCollectorIO::~MetricCollectorIO() { } -void MetricCollectorIO::fetchMetricForTimeDiff(uint64_t time_diff) { - double sec = time_diff/1000; - if(sec > 0) { - pack_count_for_ut = pack_count / sec; pack_count = 0; - bw_for_ut = ((bandwith / sec)/1024); bandwith = 0; - - updateMetricValue(METRIC_KEY_PACKET_COUNT, - &pack_count_for_ut, - sizeof(double)); - updateMetricValue(METRIC_KEY_BANDWITH, - &bw_for_ut, - sizeof(double)); +void MetricCollectorIO::startLogging() { + AsyncCentralManager::getInstance()->addTimer(this, 1000, 1000); +} + +void MetricCollectorIO::stopLogging() { + AsyncCentralManager::getInstance()->removeTimer(this); +} + +//void MetricCollectorIO::fetchMetricForTimeDiff(uint64_t time_diff) { +// double sec = time_diff/1000; +// if(sec > 0) { +// pack_count_for_ut = pack_count / sec; pack_count = 0; +// bw_for_ut = ((bandwith / sec)/1024); bandwith = 0; +// +// updateMetricValue(METRIC_KEY_PACKET_COUNT, +// &pack_count_for_ut, +// sizeof(double)); +// updateMetricValue(METRIC_KEY_BANDWITH, +// &bw_for_ut, +// sizeof(double)); +// } +//} + +void MetricCollectorIO::timeout() { + uint64_t now = chaos::common::utility::TimingUtil::getTimeStamp(); + if(last_sample_ts) { + fetchMetricForTimeDiff(now - last_sample_ts); + } else { + fetchMetricForTimeDiff(0); } + last_sample_ts = now; } diff --git a/chaos/common/metric/MetricCollectorIO.h b/chaos/common/metric/MetricCollectorIO.h index 198a70c5f613653a40deeb320d2070672320368e..a696e25fa6fbdb1908158261f6842317df76233d 100644 --- a/chaos/common/metric/MetricCollectorIO.h +++ b/chaos/common/metric/MetricCollectorIO.h @@ -24,6 +24,8 @@ #include <chaos/common/metric/MetricCollector.h> +#include <chaos/common/async_central/async_central.h> + #include <boost/atomic.hpp> namespace chaos { namespace common { @@ -31,22 +33,17 @@ namespace chaos { //! class for data io metric collector class MetricCollectorIO: - public MetricCollector { + public MetricCollector, + public chaos::common::async_central::TimerHandler { protected: - //! messagge that hase beens sent since last metric acquisition - boost::atomic<uint64_t> pack_count; - //! toatl bandwith since last metric acquisition - boost::atomic<uint64_t> bandwith; - //variable for calculation - double pack_count_for_ut; - double bw_for_ut; - - void fetchMetricForTimeDiff(uint64_t time_diff); - + uint64_t last_sample_ts; + void timeout(); + virtual void fetchMetricForTimeDiff(uint64_t time_diff) = 0; public: - MetricCollectorIO(const std::string& _collector_name, - uint64_t update_time_in_sec = 0); + MetricCollectorIO(); ~MetricCollectorIO(); + void startLogging(); + void stopLogging(); }; } } diff --git a/chaos/common/metric/MetricManager.cpp b/chaos/common/metric/MetricManager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6377f2186ea97f3b704598ca2caf3f0e3940325c --- /dev/null +++ b/chaos/common/metric/MetricManager.cpp @@ -0,0 +1,198 @@ +/* + * Copyright 2012, 2019 INFN + * + * Licensed under the EUPL, Version 1.2 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * https://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ + +#include <chaos/common/configuration/GlobalConfiguration.h> +#include <chaos/common/metric/MetricManager.h> + +using namespace chaos::common::metric; + +using namespace prometheus; +#pragma mark Counter +chaos::common::metric::CCounter::CCounter(prometheus::Counter& _impl): +impl(_impl){} + +double chaos::common::metric::CCounter::operator()() { + return impl.Value(); +} +prometheus::Counter& chaos::common::metric::CCounter::operator++() { + impl.Increment(); + return impl; +} +prometheus::Counter& chaos::common::metric::CCounter::operator++(int) { + impl.Increment(); + return impl; +} +double chaos::common::metric::CCounter::operator+(const double d) const { + impl.Increment(d); + return impl.Value(); +} +chaos::common::metric::CCounter& chaos::common::metric::CCounter::operator+=(const double d) { + impl.Increment(d); + return *this; +} +#pragma mark Gauge +chaos::common::metric::CGauge::CGauge(prometheus::Gauge& _impl): +impl(_impl){} + +double chaos::common::metric::CGauge::operator()() { + return impl.Value(); +} + +prometheus::Gauge& chaos::common::metric::CGauge::operator--() { + impl.Decrement(); + return impl; +} + +prometheus::Gauge& chaos::common::metric::CGauge::operator++() { + impl.Increment(); + return impl; +} + +prometheus::Gauge& chaos::common::metric::CGauge::operator--(int) { + impl.Decrement(); + return impl; +} + +prometheus::Gauge& chaos::common::metric::CGauge::operator++(int) { + impl.Increment(); + return impl; +} +double chaos::common::metric::CGauge::operator+(const double d) const { + impl.Increment(d); + return impl.Value(); +} +double chaos::common::metric::CGauge::operator-(const double d) const { + impl.Decrement(d); + return impl.Value(); +} +double chaos::common::metric::CGauge::operator=(const double d) const { + impl.Set(d); + return impl.Value(); +} +chaos::common::metric::CGauge& chaos::common::metric::CGauge::operator+=(const double d) { + impl.Increment(d); + return *this; +} + +chaos::common::metric::CGauge& chaos::common::metric::CGauge::operator-=(const double d) { + impl.Decrement(d); + return *this; +} + +#pragma mark Manager +MetricManager::MetricManager(): +http_exposer(new prometheus::Exposer(GlobalConfiguration::getInstance()->getConfiguration()->getStringValue(InitOption::OPT_METRIC_WEB_SERVER_PORT))), +metrics_registry(std::make_shared<Registry>()), +io_send_byte_sec(BuildCounter() + .Name("io_tx_data") + .Help("The data rate of transmitted out of data service") + .Labels({}) + .Register(*metrics_registry)), +io_send_packet_sec(BuildCounter() + .Name("io_tx_packet") + .Help("The data rate of transmitted packet out of data service") + .Labels({}) + .Register(*metrics_registry)), +io_receive_byte_sec(BuildCounter() + .Name("io_rx_data") + .Help("The data rate of received out of data service") + .Labels({}) + .Register(*metrics_registry)), +io_receive_packet_sec(BuildCounter() + .Name("io_rx_packet") + .Help("The data rate of received packet out of data service") + .Labels({}) + .Register(*metrics_registry)) { + http_exposer->RegisterCollectable(metrics_registry); +} + +MetricManager::~MetricManager() {} + +void MetricManager::init(void *data) { + +} + +void MetricManager::deinit() { + metrics_registry.reset(); + http_exposer.reset(); +} + +CounterUniquePtr MetricManager::getNewTxDataRateMetricFamily(const std::map<std::string,std::string>& label) { + return CounterUniquePtr(new chaos::common::metric::CCounter(io_send_byte_sec.Add(label))); +} + +CounterUniquePtr MetricManager::getNewRxDataRateMetricFamily(const std::map<std::string,std::string>& label) { + return CounterUniquePtr(new chaos::common::metric::CCounter(io_receive_byte_sec.Add(label))); +} + +CounterUniquePtr MetricManager::getNewTxPacketRateMetricFamily(const std::map<std::string,std::string>& label) { + return CounterUniquePtr(new chaos::common::metric::CCounter(io_send_packet_sec.Add(label))); +} + +CounterUniquePtr MetricManager::getNewRxPacketRateMetricFamily(const std::map<std::string,std::string>& label) { + return CounterUniquePtr(new chaos::common::metric::CCounter(io_receive_packet_sec.Add(label))); +} + +void MetricManager::createCounterFamily(const std::string& name, + const std::string& desc) { + LMapFamilyCounterWriteLock wl = map_counter.getWriteLockObject(); + + //check if family already exists + if(map_counter().find(name) != map_counter().end()) return; + + map_counter().insert(MapFamilyCounterPair(name, + BuildCounter() + .Name(name) + .Help(desc) + .Labels({}) + .Register(*metrics_registry))); +} + +void MetricManager::createGaugeFamily(const std::string& name, + const std::string& desc) { + LMapFamilyGaugeWriteLock wl = map_gauge.getWriteLockObject(); + + //check if family already exists + if(map_gauge().find(name) != map_gauge().end()) return; + + map_gauge().insert(MapFamilyGaugePair(name, + BuildGauge() + .Name(name) + .Help(desc) + .Labels({}) + .Register(*metrics_registry))); +} + +CounterUniquePtr MetricManager::getNewCounterFromFamily(const std::string& family_name, + const std::map<std::string,std::string>& label) { + LMapFamilyCounterReadLock wl = map_counter.getReadLockObject(); + MapFamilyCounterIterator i = map_counter().find(family_name); + if(i == map_counter().end()) return CounterUniquePtr(); + return CounterUniquePtr(new chaos::common::metric::CCounter(i->second.Add(label))); +} + +GaugeUniquePtr MetricManager::getNewGaugeFromFamily(const std::string& family_name, + const std::map<std::string,std::string>& label) { + LMapFamilyGaugeReadLock wl = map_gauge.getReadLockObject(); + MapFamilyGaugeIterator i = map_gauge().find(family_name); + if(i == map_gauge().end()) return GaugeUniquePtr(); + return GaugeUniquePtr(new chaos::common::metric::CGauge(i->second.Add(label))); +} diff --git a/chaos/common/metric/MetricManager.h b/chaos/common/metric/MetricManager.h new file mode 100644 index 0000000000000000000000000000000000000000..c99f851571c2de6cdcc2162c0ded42d64320e079 --- /dev/null +++ b/chaos/common/metric/MetricManager.h @@ -0,0 +1,135 @@ +/* + * Copyright 2012, 2019 INFN + * + * Licensed under the EUPL, Version 1.2 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * https://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ + + +#ifndef MetricManager_h +#define MetricManager_h + +#include <chaos/common/chaos_types.h> +#include <chaos/common/utility/Singleton.h> +#include <chaos/common/utility/LockableObject.h> +#include <chaos/common/utility/InizializableService.h> + +#include <prometheus/exposer.h> +#include <prometheus/registry.h> +#include <prometheus/counter.h> +#include <prometheus/gauge.h> +namespace chaos { + namespace common { + namespace metric { + class MetricManager; + + /*! + Counter abstraction + */ + class CCounter { + friend class MetricManager; + prometheus::Counter& impl; + CCounter(prometheus::Counter& _impl); + public: + double operator()(); + prometheus::Counter& operator++(); + prometheus::Counter& operator++(int); + double operator+(const double d) const; + CCounter& operator+=(const double d); + }; + + /*! + Gauge abstraction + */ + class CGauge { + friend class MetricManager; + prometheus::Gauge& impl; + + CGauge(prometheus::Gauge& _impl); + public: + double operator()(); + prometheus::Gauge& operator--(); + prometheus::Gauge& operator++(); + prometheus::Gauge& operator--(int); + prometheus::Gauge& operator++(int); + double operator+(const double d) const; + double operator-(const double d) const; + double operator=(const double d) const; + CGauge& operator+=(const double d); + CGauge& operator-=(const double d); + }; + + typedef ChaosUniquePtr<CCounter> CounterUniquePtr; + typedef ChaosUniquePtr<CGauge> GaugeUniquePtr; + + CHAOS_DEFINE_MAP_FOR_TYPE(std::string, prometheus::Family<prometheus::Counter>&, MapFamilyCounter); + CHAOS_DEFINE_LOCKABLE_OBJECT(MapFamilyCounter, LMapFamilyCounter); + + CHAOS_DEFINE_MAP_FOR_TYPE(std::string, prometheus::Family<prometheus::Gauge>&, MapFamilyGauge); + CHAOS_DEFINE_LOCKABLE_OBJECT(MapFamilyGauge, LMapFamilyGauge); + /*! + Central managment for metric exposition to Prometheus + */ + class MetricManager: + public common::utility::InizializableService, + public chaos::common::utility::Singleton<MetricManager> { + friend class chaos::common::utility::Singleton<MetricManager>; + //main structure + ChaosUniquePtr<prometheus::Exposer> http_exposer; + ChaosSharedPtr<prometheus::Registry> metrics_registry; + + LMapFamilyCounter map_counter; + LMapFamilyGauge map_gauge; + + //io base metrics family for data and packet rate + prometheus::Family<prometheus::Counter>& io_send_byte_sec; + prometheus::Family<prometheus::Counter>& io_send_packet_sec; + prometheus::Family<prometheus::Counter>& io_receive_byte_sec; + prometheus::Family<prometheus::Counter>& io_receive_packet_sec; + + + + MetricManager(); + ~MetricManager(); + protected: + void init(void *data); + void deinit(); + public: + + CounterUniquePtr getNewTxDataRateMetricFamily(const std::map<std::string,std::string>& label); + CounterUniquePtr getNewRxDataRateMetricFamily(const std::map<std::string,std::string>& label); + CounterUniquePtr getNewTxPacketRateMetricFamily(const std::map<std::string,std::string>& label); + CounterUniquePtr getNewRxPacketRateMetricFamily(const std::map<std::string,std::string>& label); + + void createCounterFamily(const std::string& name, + const std::string& desc); + + void createGaugeFamily(const std::string& name, + const std::string& desc); + + CounterUniquePtr getNewCounterFromFamily(const std::string& family_name, + const std::map<std::string,std::string>& label = {}); + + GaugeUniquePtr getNewGaugeFromFamily(const std::string& family_name, + const std::map<std::string,std::string>& label = {}); + + }; + } + } +} + +#endif /* MetricManager_hpp */ diff --git a/chaos/common/metric/metric.h b/chaos/common/metric/metric.h index 67873b9ecdd5fcfadcc54471aaf9b83c0feb4efa..e20def68401112a74f970c509b6bd8b15cedbaea 100644 --- a/chaos/common/metric/metric.h +++ b/chaos/common/metric/metric.h @@ -22,11 +22,8 @@ #ifndef CHAOSFramework_metric_h #define CHAOSFramework_metric_h +#include <chaos/common/metric/MetricManager.h> #include <chaos/common/metric/MetricCollector.h> #include <chaos/common/metric/MetricCollectorIO.h> -#include <chaos/common/metric/AbstractMetricBackend.h> -#include <chaos/common/metric/FileMetricBackend.h> -#include <chaos/common/metric/CSVFileMetricBackend.h> -#include <chaos/common/metric/ConsoleMetricBackend.h> #endif diff --git a/chaos/common/network/NetworkBroker.cpp b/chaos/common/network/NetworkBroker.cpp index 42db3d02f90aab90b995a26e92457e0f2f880de4..f349beb151cef94c7485a4c521f1d9cb2a701d8a 100644 --- a/chaos/common/network/NetworkBroker.cpp +++ b/chaos/common/network/NetworkBroker.cpp @@ -32,9 +32,11 @@ #include <chaos/common/message/MultiAddressMessageChannel.h> #include <chaos/common/dispatcher/AbstractCommandDispatcher.h> //-----------for metric collection--------- +#if (CHAOS_PROMETHEUS) #include <chaos/common/rpc/RpcClientMetricCollector.h> #include <chaos/common/rpc/RpcServerMetricCollector.h> #include <chaos/common/direct_io/DirectIODispatcherMetricCollector.h> +#endif #define MB_LAPP LAPP_ << "[NetworkBroker]- " @@ -84,7 +86,7 @@ void NetworkBroker::init(void *initData) { throw CException(-1, "No global configuraiton found", __PRETTY_FUNCTION__); } MB_LAPP << "Configuration:"<<globalConfiguration->getCompliantJSONString(); - + //---------------------------- D I R E C T I/O ---------------------------- if(globalConfiguration->hasKey(common::direct_io::DirectIOConfigurationKey::DIRECT_IO_IMPL_TYPE)) { MB_LAPP << "Setup DirectIO sublayer"; @@ -98,22 +100,19 @@ void NetworkBroker::init(void *initData) { //allocate the dispatcher MB_LAPP << "Allocate DirectIODispatcher"; - if(globalConfiguration->hasKey(InitOption::OPT_DIRECT_IO_LOG_METRIC) && - globalConfiguration->getBoolValue(InitOption::OPT_DIRECT_IO_LOG_METRIC)) { - //the metric allocator of direct io is a direct subclass of DirectIODispatcher - direct_io_dispatcher = new direct_io::DirectIODispatcherMetricCollector(direct_io_server->getName()); - } else { - direct_io_dispatcher = new common::direct_io::DirectIODispatcher(); - } +#if CHAOS_PROMETHEUS + // install metric awahre dispatcher subclass + direct_io_dispatcher = new chaos::common::direct_io::DirectIODispatcherMetricCollector(); +#else + direct_io_dispatcher = new common::direct_io::DirectIODispatcher(); +#endif direct_io_server->setHandler(direct_io_dispatcher); - - //initialize direct io server StartableService::initImplementation(direct_io_server, static_cast<void*>(globalConfiguration), direct_io_server->getName(), __PRETTY_FUNCTION__); //init the my_ip variable for all client -// common::direct_io::DirectIOClientConnection::my_str_ip = GlobalConfiguration::getInstance()->getLocalServerAddress(); -// common::direct_io::DirectIOClientConnection::my_i64_ip = STRIP_TO_UI64(common::direct_io::DirectIOClientConnection::my_str_ip).to_ulong(); + // common::direct_io::DirectIOClientConnection::my_str_ip = GlobalConfiguration::getInstance()->getLocalServerAddress(); + // common::direct_io::DirectIOClientConnection::my_i64_ip = STRIP_TO_UI64(common::direct_io::DirectIOClientConnection::my_str_ip).to_ulong(); direct_io_client = ObjectFactoryRegister<common::direct_io::DirectIOClient>::getInstance()->getNewInstanceByName(direct_io_client_impl); if(!direct_io_client) throw CException(-3, "Error creating direct io client implementation", __PRETTY_FUNCTION__); @@ -187,26 +186,22 @@ void NetworkBroker::init(void *initData) { MB_LAPP << "Trying to initilize RPC Server: " << rpc_server_name; rpc_server = ObjectFactoryRegister<RpcServer>::getInstance()->getNewInstanceByName(rpc_server_name); if(!rpc_server) throw CException(-8, "Error allocating rpc server implementation", __PRETTY_FUNCTION__); - if(globalConfiguration->getBoolValue(InitOption::OPT_RPC_LOG_METRIC)) { - rpc_server = new rpc::RpcServerMetricCollector(rpc_server->getName(), rpc_server); - } - +#if CHAOS_PROMETHEUS + rpc_server = new rpc::RpcServerMetricCollector(rpc_server->getName(), rpc_server); +#endif if(StartableService::initImplementation(rpc_server, static_cast<void*>(globalConfiguration), rpc_server->getName(), __PRETTY_FUNCTION__)) { //set the handler on the rpc server rpc_server->setCommandDispatcher(rpc_dispatcher); } - MB_LAPP << "Trying to initilize RPC Client: " << rpc_client_name; rpc_client = ObjectFactoryRegister<RpcClient>::getInstance()->getNewInstanceByName(rpc_client_name); if(!rpc_client) throw CException(-9, "Error allocating rpc client implementation", __PRETTY_FUNCTION__); - if(globalConfiguration->getBoolValue(InitOption::OPT_RPC_LOG_METRIC)) { - rpc_client = new rpc::RpcClientMetricCollector(rpc_client->getName(), rpc_client); - } - +#if CHAOS_PROMETHEUS + rpc_client = new rpc::RpcClientMetricCollector(rpc_client->getName(), rpc_client); +#endif //! connect dispatch to manage error durign request forwarding rpc_client->setServerHandler(rpc_dispatcher); - if(StartableService::initImplementation(rpc_client, static_cast<void*>(globalConfiguration), rpc_client->getName(), __PRETTY_FUNCTION__)) { //set the forwarder into dispatcher for answere rpc_dispatcher->setRpcForwarder(rpc_client); @@ -251,15 +246,15 @@ void NetworkBroker::deinit() { channnelIter++) { event::channel::EventChannel *eventChannelToDispose = channnelIter->second; - - if(eventChannelToDispose){ - //deinit channel - eventChannelToDispose->deinit(); - - //dispose it - delete(eventChannelToDispose); - } + if(eventChannelToDispose){ + + //deinit channel + eventChannelToDispose->deinit(); + + //dispose it + delete(eventChannelToDispose); + } } MB_LAPP << "Clear event channel map"; active_event_channel.clear(); @@ -399,10 +394,10 @@ channel::EventChannel *NetworkBroker::getNewEventChannelFromType(common::event:: CHAOS_ASSERT(!GlobalConfiguration::getInstance()->getOption<bool>(InitOption::OPT_EVENT_DISABLE)); common::event::channel::EventChannel *new_event_channel = NULL; switch (event_type) { - case common::event::EventTypeAlert: + case common::event::EventTypeAlert: new_event_channel = new event::channel::AlertEventChannel(this); break; - case common::event::EventTypeInstrument: + case common::event::EventTypeInstrument: new_event_channel = new event::channel::InstrumentEventChannel(this); break; default: @@ -423,12 +418,12 @@ channel::EventChannel *NetworkBroker::getNewEventChannelFromType(common::event:: \param deviceNetworkAddress device node address */ AlertEventChannel *NetworkBroker::getNewAlertEventChannel() { - - if(GlobalConfiguration::getInstance()->getOption<bool>(InitOption::OPT_EVENT_DISABLE)){ - MB_LAPP<<"No Event Alert Instanced, EVENTS are DISABLED"; - return NULL; - } - + + if(GlobalConfiguration::getInstance()->getOption<bool>(InitOption::OPT_EVENT_DISABLE)){ + MB_LAPP<<"No Event Alert Instanced, EVENTS are DISABLED"; + return NULL; + } + return static_cast<event::channel::AlertEventChannel*>(NetworkBroker::getNewEventChannelFromType(event::EventTypeAlert)); } @@ -520,7 +515,7 @@ bool NetworkBroker::submitMessage(const string& host, to the registered rpc domain */ chaos::common::data::CDWUniquePtr NetworkBroker::submitInterProcessMessage(chaos::common::data::CDWUniquePtr message, - bool onThisThread) { + bool onThisThread) { CHAOS_ASSERT(rpc_dispatcher) if(onThisThread) { return rpc_dispatcher->executeCommandSync(MOVE(message)); @@ -645,13 +640,13 @@ DeviceMessageChannel *NetworkBroker::getDeviceMessageChannelFromAddress(CDeviceN bool self_managed, bool use_shared_request_domain) { DeviceMessageChannel *channel = (use_shared_request_domain? - new DeviceMessageChannel(this, - node_network_address, - self_managed, - global_request_domain): - new DeviceMessageChannel(this, - node_network_address, - self_managed)); + new DeviceMessageChannel(this, + node_network_address, + self_managed, + global_request_domain): + new DeviceMessageChannel(this, + node_network_address, + self_managed)); if(channel){ @@ -669,12 +664,12 @@ PerformanceNodeChannel *NetworkBroker::getPerformanceChannelFromAddress(CNetwork //! Return a raw message channel MessageChannel *NetworkBroker::getRawMessageChannel() { - return getNewMessageChannelForRemoteHost(NULL, RAW); + return getNewMessageChannelForRemoteHost(NULL, RAW); } //! Return a raw multinode message channel MultiAddressMessageChannel *NetworkBroker::getRawMultiAddressMessageChannel() { - return static_cast<MultiAddressMessageChannel*>(getNewMessageChannelForRemoteHost(NULL, RAW_MULTI_ADDRESS)); + return static_cast<MultiAddressMessageChannel*>(getNewMessageChannelForRemoteHost(NULL, RAW_MULTI_ADDRESS)); } //! Return a raw multinode message channel diff --git a/chaos/common/rpc/RpcClientMetricCollector.cpp b/chaos/common/rpc/RpcClientMetricCollector.cpp index c7b437cc139bb992a843046dbd96179133a30c21..7aa6125a5ef9cce09c1106daefdcd2855540e5a1 100644 --- a/chaos/common/rpc/RpcClientMetricCollector.cpp +++ b/chaos/common/rpc/RpcClientMetricCollector.cpp @@ -21,6 +21,7 @@ #include <chaos/common/configuration/GlobalConfiguration.h> #include <chaos/common/rpc/RpcClientMetricCollector.h> + #include <boost/format.hpp> using namespace chaos::common::rpc; @@ -33,8 +34,7 @@ using namespace chaos::common::metric; RpcClientMetricCollector::RpcClientMetricCollector(const std::string& forwarder_implementation, RpcClient *_wrapped_client, bool _dispose_forwarder_on_exit): -MetricCollectorIO(forwarder_implementation, - GlobalConfiguration::getInstance()->getConfiguration()->getUInt64Value(InitOption::OPT_RPC_LOG_METRIC_UPDATE_INTERVAL)), +MetricCollectorIO(), RpcClient(forwarder_implementation), wrapped_client(_wrapped_client), dispose_forwarder_on_exit(_dispose_forwarder_on_exit) { @@ -52,6 +52,8 @@ RpcClientMetricCollector::~RpcClientMetricCollector() { void RpcClientMetricCollector::init(void *init_data) { CHAOS_ASSERT(wrapped_client) utility::StartableService::initImplementation(wrapped_client, init_data, wrapped_client->getName(), __PRETTY_FUNCTION__); + packet_count_uptr = MetricManager::getInstance()->getNewTxPacketRateMetricFamily({{"driver","rpc"}}); + bw_counter_uptr = MetricManager::getInstance()->getNewTxDataRateMetricFamily({{"driver","rpc"}}); } /* @@ -59,7 +61,7 @@ void RpcClientMetricCollector::init(void *init_data) { */ void RpcClientMetricCollector::start() { CHAOS_ASSERT(wrapped_client) - startLogging(); +// startLogging(); utility::StartableService::startImplementation(wrapped_client, wrapped_client->getName(), __PRETTY_FUNCTION__); } @@ -68,7 +70,7 @@ void RpcClientMetricCollector::start() { */ void RpcClientMetricCollector::stop() { CHAOS_ASSERT(wrapped_client) - stopLogging(); +// stopLogging(); utility::StartableService::stopImplementation(wrapped_client, wrapped_client->getName(), __PRETTY_FUNCTION__); } @@ -87,22 +89,26 @@ void RpcClientMetricCollector::setServerHandler(chaos::RpcServerHandler *_server bool RpcClientMetricCollector::submitMessage(chaos::common::network::NFISharedPtr forward_info, bool on_this_thread) { CHAOS_ASSERT(wrapped_client) - int size = 0; - bool result = true; - - result = wrapped_client->submitMessage(MOVE(forward_info), - on_this_thread); - //inrement packec count - pack_count++; - - //increment packet size - forward_info->message->getBSONRawData(size); - bandwith+=size; - - return result; + (*packet_count_uptr)++; + if(forward_info->hasMessage()) { + (*bw_counter_uptr) += forward_info->message->getBSONRawSize(); + } + return wrapped_client->submitMessage(MOVE(forward_info), + on_this_thread); } void RpcClientMetricCollector::fetchMetricForTimeDiff(uint64_t time_diff) { - MetricCollectorIO::fetchMetricForTimeDiff(time_diff); +// double sec = time_diff/1000; +// if(sec == 0) return; +// pack_count_for_ut = pack_count / sec; pack_count = 0; +// bw_for_ut = ((bandwith / sec)/1024); bandwith = 0; +// +// updateMetricValue(METRIC_KEY_PACKET_COUNT, +// &pack_count_for_ut, +// sizeof(double)); +// updateMetricValue(METRIC_KEY_BANDWITH, +// &bw_for_ut, +// sizeof(double)); + } diff --git a/chaos/common/rpc/RpcClientMetricCollector.h b/chaos/common/rpc/RpcClientMetricCollector.h index 12e2f04eb50758dbe65d52a5266df0d177ec9453..852dcc5cb97e45af013ed4a3ba535135594a3237 100644 --- a/chaos/common/rpc/RpcClientMetricCollector.h +++ b/chaos/common/rpc/RpcClientMetricCollector.h @@ -38,6 +38,8 @@ namespace chaos { public RpcClient { bool dispose_forwarder_on_exit; RpcClient *wrapped_client; + chaos::common::metric::CounterUniquePtr packet_count_uptr; + chaos::common::metric::CounterUniquePtr bw_counter_uptr; private: void fetchMetricForTimeDiff(uint64_t time_diff); public: diff --git a/chaos/common/rpc/RpcServerMetricCollector.cpp b/chaos/common/rpc/RpcServerMetricCollector.cpp index 169302e64d8a7f6fb6ef831991e5be834f6e4686..2441972eecb0b1c7fd4277d47086d13b97a54183 100644 --- a/chaos/common/rpc/RpcServerMetricCollector.cpp +++ b/chaos/common/rpc/RpcServerMetricCollector.cpp @@ -34,8 +34,7 @@ using namespace chaos::common::metric; RpcServerMetricCollector::RpcServerMetricCollector(const std::string& forwarder_implementation, RpcServer *_wrapper_server, bool _dispose_forwarder_on_exit): -MetricCollectorIO(forwarder_implementation, - GlobalConfiguration::getInstance()->getConfiguration()->getUInt64Value(InitOption::OPT_RPC_LOG_METRIC_UPDATE_INTERVAL)), +MetricCollectorIO(), RpcServer(forwarder_implementation), wrapper_server(_wrapper_server), wrapperd_server_handler(NULL), @@ -58,6 +57,10 @@ RpcServerMetricCollector::~RpcServerMetricCollector() { void RpcServerMetricCollector::init(void *init_data) { CHAOS_ASSERT(wrapper_server) utility::StartableService::initImplementation(wrapper_server, init_data, wrapper_server->getName(), __PRETTY_FUNCTION__); + packet_async_count_uptr = MetricManager::getInstance()->getNewRxPacketRateMetricFamily({{"driver","rpc_async"}}); + data_async_count_uptr = MetricManager::getInstance()->getNewRxDataRateMetricFamily({{"driver","rpc_async"}}); + packet_sync_count_uptr = MetricManager::getInstance()->getNewRxPacketRateMetricFamily({{"driver","rpc_sync"}}); + data_sync_count_uptr = MetricManager::getInstance()->getNewRxDataRateMetricFamily({{"driver","rpc_sync"}}); } /* @@ -100,31 +103,23 @@ void RpcServerMetricCollector::setCommandDispatcher(RpcServerHandler *_wrapperd_ // method called when the rpc server receive a new data CDWUniquePtr RpcServerMetricCollector::dispatchCommand(CDWUniquePtr action_pack) { CHAOS_ASSERT(wrapperd_server_handler) - int size = 0; CDWUniquePtr result; //inrement packec count - pack_count++; + (*packet_async_count_uptr)++; + (*data_async_count_uptr) += action_pack->getBSONRawSize(); result = wrapperd_server_handler->dispatchCommand(MOVE(action_pack)); - //increment packet size - action_pack->getBSONRawData(size); - bandwith+=size; return result; } // execute an action in synchronous mode CDWUniquePtr RpcServerMetricCollector::executeCommandSync(CDWUniquePtr action_pack) { CHAOS_ASSERT(wrapperd_server_handler) - int size = 0; CDWUniquePtr result; //inrement packec count - pack_count++; - result = wrapperd_server_handler->dispatchCommand(MOVE(action_pack)); - //increment packet size - action_pack->getBSONRawData(size); - bandwith+=size; - return result; + (*packet_sync_count_uptr)++; + (*data_sync_count_uptr) += action_pack->getBSONRawSize(); + return wrapperd_server_handler->dispatchCommand(MOVE(action_pack)); } void RpcServerMetricCollector::fetchMetricForTimeDiff(uint64_t time_diff) { - MetricCollectorIO::fetchMetricForTimeDiff(time_diff); } diff --git a/chaos/common/rpc/RpcServerMetricCollector.h b/chaos/common/rpc/RpcServerMetricCollector.h index 7c510ea50df55972771c3a924c0f780296cab9ff..1d73f1702eaf2f79e05f1c7d09d564104545ff8b 100644 --- a/chaos/common/rpc/RpcServerMetricCollector.h +++ b/chaos/common/rpc/RpcServerMetricCollector.h @@ -40,7 +40,11 @@ namespace chaos { bool dispose_forwarder_on_exit; RpcServer *wrapper_server; RpcServerHandler *wrapperd_server_handler; - + chaos::common::metric::CounterUniquePtr packet_async_count_uptr; + chaos::common::metric::CounterUniquePtr packet_sync_count_uptr; + + chaos::common::metric::CounterUniquePtr data_async_count_uptr; + chaos::common::metric::CounterUniquePtr data_sync_count_uptr; void fetchMetricForTimeDiff(uint64_t time_diff); public: RpcServerMetricCollector(const std::string& forwarder_implementation, diff --git a/chaos/common/rpc/zmq/ZMQClient.cpp b/chaos/common/rpc/zmq/ZMQClient.cpp index c22320b60d07061bcad53a8d892bd863535b41ab..5f8b45d48839c820ee7cb432d90810f10fd5861f 100644 --- a/chaos/common/rpc/zmq/ZMQClient.cpp +++ b/chaos/common/rpc/zmq/ZMQClient.cpp @@ -18,6 +18,7 @@ * See the Licence for the specific language governing * permissions and limitations under the Licence. */ + #include <chaos/common/global.h> #include <chaos/common/rpc/zmq/ZMQClient.h> #include <chaos/common/rpc/zmq/ZmqMemoryManagement.h> @@ -30,7 +31,9 @@ using namespace chaos; using namespace chaos::common::data; using namespace chaos::common::pool; - +#if CHAOS_PROMETHEUS +using namespace chaos::common::metric; +#endif using namespace std; using namespace boost; using namespace boost::algorithm; @@ -58,6 +61,11 @@ RpcClient(alias), zmq_context(NULL), zmq_timeout(RpcConfigurationKey::GlobalRPCTimeoutinMSec){ seq_id=0; +#if CHAOS_PROMETHEUS + //add custom driver metric + chaos::common::metric::MetricManager::getInstance()->createGaugeFamily("rpc_zmq_client_queue", "Element in queue that need to forwarded by the zmq client"); + counter_queuend_uptr = MetricManager::getInstance()->getNewGaugeFromFamily("rpc_zmq_client_queue"); +#endif } ZMQClient::~ZMQClient(){} @@ -143,6 +151,9 @@ bool ZMQClient::submitMessage(NFISharedPtr forwardInfo, processBufferElement(MOVE(forwardInfo)); } else { CObjectProcessingQueue<NetworkForwardInfo>::push(MOVE(forwardInfo)); +#if CHAOS_PROMETHEUS + (*counter_queuend_uptr)++; +#endif } } catch(CException& ex){ //in this case i need to delete the memory @@ -288,6 +299,10 @@ void ZMQClient::processBufferElement(NFISharedPtr messageInfo) { zmq_msg_t message; zmq_msg_init (&reply); +#if CHAOS_PROMETHEUS + (*counter_queuend_uptr)--; +#endif + //get remote ip //serialize the call packet ZMQSocketPool::ResourceSlot *socket_info = NULL; diff --git a/chaos/common/rpc/zmq/ZMQClient.h b/chaos/common/rpc/zmq/ZMQClient.h index dad330441cc1c81ee21dfe9abd1394403e4d0194..6512228c9f78ad72cbd47da142f3547cd7efba3f 100644 --- a/chaos/common/rpc/zmq/ZMQClient.h +++ b/chaos/common/rpc/zmq/ZMQClient.h @@ -22,6 +22,10 @@ #include <chaos/common/pool/ResourcePool.h> #include <chaos/common/chaos_types.h> +#if CHAOS_PROMETHEUS +#include <chaos/common/metric/metric.h> +#endif + #include <boost/thread.hpp> #include <boost/shared_ptr.hpp> @@ -61,6 +65,10 @@ namespace chaos { boost::shared_mutex map_socket_mutex; SocketMap map_socket; ChaosAtomic<uint64_t> seq_id; +#if CHAOS_PROMETHEUS + //custom driver metrics + chaos::common::metric::GaugeUniquePtr counter_queuend_uptr; +#endif protected: void *zmq_context; virtual void processBufferElement(NFISharedPtr element);