diff --git a/CHAOSFramework.xcodeproj/project.pbxproj b/CHAOSFramework.xcodeproj/project.pbxproj index 79cecbc8c2871f2fb754763956dbce11f789107c..7df219ddc8784eea87193f294dcceaa80e7f99bb 100644 --- a/CHAOSFramework.xcodeproj/project.pbxproj +++ b/CHAOSFramework.xcodeproj/project.pbxproj @@ -15,7 +15,6 @@ dependencies = ( 3211C6781C146252003B38BF /* PBXTargetDependency */, 3211C67A1C146252003B38BF /* PBXTargetDependency */, - 3211C67C1C146252003B38BF /* PBXTargetDependency */, 3211C67E1C146252003B38BF /* PBXTargetDependency */, 3211C6801C146252003B38BF /* PBXTargetDependency */, 3211C6821C146252003B38BF /* PBXTargetDependency */, @@ -99,8 +98,6 @@ 320CA9511C29D16D00894AAA /* DeleteUS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 320CA94F1C29D16D00894AAA /* DeleteUS.cpp */; }; 320CA9541C29D71A00894AAA /* DeleteUS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 320CA9521C29D71A00894AAA /* DeleteUS.cpp */; }; 320CA9551C29D71A00894AAA /* DeleteUS.h in Headers */ = {isa = PBXBuildFile; fileRef = 320CA9531C29D71A00894AAA /* DeleteUS.h */; }; - 320DF98D14E17E2700251621 /* DeviceController.h in Headers */ = {isa = PBXBuildFile; fileRef = 320DF98C14E17E2700251621 /* DeviceController.h */; }; - 320DF99114E190BB00251621 /* DeviceController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 320DF98F14E17E3D00251621 /* DeviceController.cpp */; }; 320E2FBF1D7EB9CB0077E8FE /* QueryCursor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 320E2FBD1D7EB9CB0077E8FE /* QueryCursor.cpp */; }; 320E2FC01D7EB9CB0077E8FE /* QueryCursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 320E2FBE1D7EB9CB0077E8FE /* QueryCursor.h */; }; 320E773E1A7FBD84001FB8BC /* UnitServerAckBatchCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 320E773C1A7FBD84001FB8BC /* UnitServerAckBatchCommand.cpp */; }; @@ -117,8 +114,6 @@ 3211CCDA1B021B8D00F9B80E /* GetBestEndpoints.h in Headers */ = {isa = PBXBuildFile; fileRef = 3211CCD81B021B8D00F9B80E /* GetBestEndpoints.h */; }; 3211CCDD1B03402800F9B80E /* QuantumKeyConsumer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3211CCDB1B03402800F9B80E /* QuantumKeyConsumer.cpp */; }; 3211CCDE1B03402800F9B80E /* QuantumKeyConsumer.h in Headers */ = {isa = PBXBuildFile; fileRef = 3211CCDC1B03402800F9B80E /* QuantumKeyConsumer.h */; }; - 3211FD1D1698699D00424A3C /* LiveDataFetcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3211FD1B1698699D00424A3C /* LiveDataFetcher.cpp */; }; - 3211FD1E1698699D00424A3C /* LiveDataFetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 3211FD1C1698699D00424A3C /* LiveDataFetcher.h */; }; 3214E7401DC1081100A67414 /* AlarmDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3214E73E1DC1081100A67414 /* AlarmDescription.cpp */; }; 3214E7411DC1081100A67414 /* AlarmDescription.h in Headers */ = {isa = PBXBuildFile; fileRef = 3214E73F1DC1081100A67414 /* AlarmDescription.h */; }; 3214E7441DC10B9500A67414 /* MultiSeverityAlarm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3214E7421DC10B9500A67414 /* MultiSeverityAlarm.cpp */; }; @@ -421,8 +416,6 @@ 32655AD71E9CE0FA00829266 /* RemoveScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32655AD51E9CE0FA00829266 /* RemoveScript.cpp */; }; 32655ADA1E9CE1E700829266 /* RemoveScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32655AD81E9CE1E700829266 /* RemoveScript.cpp */; }; 32655ADB1E9CE1E700829266 /* RemoveScript.h in Headers */ = {isa = PBXBuildFile; fileRef = 32655AD91E9CE1E700829266 /* RemoveScript.h */; }; - 3265BF4615D1A9CA00C3CAC6 /* ChaosUIToolkitCWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 3265BF4515D1A9CA00C3CAC6 /* ChaosUIToolkitCWrapper.h */; }; - 3265BF4915D1AA9F00C3CAC6 /* ChaosUIToolkitCWrapper.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3265BF4815D1AA9F00C3CAC6 /* ChaosUIToolkitCWrapper.cc */; }; 3265F332197E626900F22FBC /* WorkUnitManagement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32D72CA8197D196D00512B89 /* WorkUnitManagement.cpp */; }; 3265F94B1FB899D400FEA246 /* DataPack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3265F9491FB899D300FEA246 /* DataPack.cpp */; }; 3265F94C1FB89F6B00FEA246 /* bson-context.c in Sources */ = {isa = PBXBuildFile; fileRef = 3265F9111FB8997300FEA246 /* bson-context.c */; }; @@ -536,16 +529,6 @@ 326DB4CA14B3A3E50018A8D0 /* DataManagerException.h in Headers */ = {isa = PBXBuildFile; fileRef = 326DB4B214B3A3E50018A8D0 /* DataManagerException.h */; }; 326DB4CB14B3A3E50018A8D0 /* KeyDataStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 326DB4B314B3A3E50018A8D0 /* KeyDataStorage.cpp */; }; 326DB4CC14B3A3E50018A8D0 /* KeyDataStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 326DB4B414B3A3E50018A8D0 /* KeyDataStorage.h */; }; - 326DB4EB14B3B0070018A8D0 /* ChaosUIToolkit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 326DB4D714B3B0070018A8D0 /* ChaosUIToolkit.cpp */; }; - 326DB4EC14B3B0070018A8D0 /* ChaosUIToolkit.h in Headers */ = {isa = PBXBuildFile; fileRef = 326DB4D814B3B0070018A8D0 /* ChaosUIToolkit.h */; }; - 326DB4ED14B3B0070018A8D0 /* HLDataApi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 326DB4DA14B3B0070018A8D0 /* HLDataApi.cpp */; }; - 326DB4EE14B3B0070018A8D0 /* HLDataApi.h in Headers */ = {isa = PBXBuildFile; fileRef = 326DB4DB14B3B0070018A8D0 /* HLDataApi.h */; }; - 326DB4EF14B3B0070018A8D0 /* HLInfrastructureApi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 326DB4DC14B3B0070018A8D0 /* HLInfrastructureApi.cpp */; }; - 326DB4F014B3B0070018A8D0 /* HLInfrastructureApi.h in Headers */ = {isa = PBXBuildFile; fileRef = 326DB4DD14B3B0070018A8D0 /* HLInfrastructureApi.h */; }; - 326DB4F314B3B0070018A8D0 /* LLDataApi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 326DB4E114B3B0070018A8D0 /* LLDataApi.cpp */; }; - 326DB4F414B3B0070018A8D0 /* LLDataApi.h in Headers */ = {isa = PBXBuildFile; fileRef = 326DB4E214B3B0070018A8D0 /* LLDataApi.h */; }; - 326DB4F514B3B0070018A8D0 /* LLRpcApi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 326DB4E314B3B0070018A8D0 /* LLRpcApi.cpp */; }; - 326DB4F614B3B0070018A8D0 /* LLRpcApi.h in Headers */ = {isa = PBXBuildFile; fileRef = 326DB4E414B3B0070018A8D0 /* LLRpcApi.h */; }; 326EA57814D2D8EE00D4962A /* MultiKeyObjectWaitSemaphore.h in Headers */ = {isa = PBXBuildFile; fileRef = 326EA57714D2D8EE00D4962A /* MultiKeyObjectWaitSemaphore.h */; }; 3270D5E81CCFAC4F0072017B /* AbstractExecutionUnit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3270D5E61CCFAC4F0072017B /* AbstractExecutionUnit.cpp */; }; 3270D5E91CCFAC4F0072017B /* AbstractExecutionUnit.h in Headers */ = {isa = PBXBuildFile; fileRef = 3270D5E71CCFAC4F0072017B /* AbstractExecutionUnit.h */; }; @@ -579,6 +562,9 @@ 3277A22F20973A0100FD7307 /* CPPScriptVM.h in Headers */ = {isa = PBXBuildFile; fileRef = 3277A22D20973A0100FD7307 /* CPPScriptVM.h */; }; 3277A235209C4AFD00FD7307 /* ClingRootInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3277A233209C4AFD00FD7307 /* ClingRootInterpreter.cpp */; }; 3277A236209C4AFD00FD7307 /* ClingRootInterpreter.h in Headers */ = {isa = PBXBuildFile; fileRef = 3277A234209C4AFD00FD7307 /* ClingRootInterpreter.h */; }; + 3278855620EB91CE004D1A34 /* SendStorageBurst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3278855520EB91CE004D1A34 /* SendStorageBurst.cpp */; }; + 3278855920EB97BC004D1A34 /* SendStorageBurst.h in Headers */ = {isa = PBXBuildFile; fileRef = 3278855720EB97BC004D1A34 /* SendStorageBurst.h */; }; + 3278855A20EB97BC004D1A34 /* SendStorageBurst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3278855820EB97BC004D1A34 /* SendStorageBurst.cpp */; }; 32788D7F1F277207009BBB1E /* OpcodeDriverWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 32788D7D1F277207009BBB1E /* OpcodeDriverWrapper.h */; }; 32788D831F27766A009BBB1E /* OpcodeExternalCommandMapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 32788D811F27766A009BBB1E /* OpcodeExternalCommandMapper.h */; }; 327967B515DF99FB0003C6DA /* RpcClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 327967B415DF99FB0003C6DA /* RpcClient.cpp */; }; @@ -1213,13 +1199,6 @@ remoteGlobalIDString = 3260276514B3068100C906CE; remoteInfo = chaos_cutoolkit; }; - 3211C67B1C146252003B38BF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 3260260D14B300FE00C906CE /* Project object */; - proxyType = 1; - remoteGlobalIDString = 3260278614B307DA00C906CE; - remoteInfo = chaos_uitoolkit; - }; 3211C67D1C146252003B38BF /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 3260260D14B300FE00C906CE /* Project object */; @@ -1345,8 +1324,6 @@ 320CA9521C29D71A00894AAA /* DeleteUS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeleteUS.cpp; sourceTree = "<group>"; }; 320CA9531C29D71A00894AAA /* DeleteUS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeleteUS.h; sourceTree = "<group>"; }; 320DEA6319CC77F200ED66AB /* ThreadSemaphore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ThreadSemaphore.h; sourceTree = "<group>"; }; - 320DF98C14E17E2700251621 /* DeviceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceController.h; sourceTree = "<group>"; }; - 320DF98F14E17E3D00251621 /* DeviceController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceController.cpp; sourceTree = "<group>"; }; 320E2FBD1D7EB9CB0077E8FE /* QueryCursor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QueryCursor.cpp; sourceTree = "<group>"; }; 320E2FBE1D7EB9CB0077E8FE /* QueryCursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QueryCursor.h; sourceTree = "<group>"; }; 320E773C1A7FBD84001FB8BC /* UnitServerAckBatchCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnitServerAckBatchCommand.cpp; sourceTree = "<group>"; }; @@ -1371,8 +1348,6 @@ 3211CCD81B021B8D00F9B80E /* GetBestEndpoints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetBestEndpoints.h; sourceTree = "<group>"; }; 3211CCDB1B03402800F9B80E /* QuantumKeyConsumer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QuantumKeyConsumer.cpp; sourceTree = "<group>"; }; 3211CCDC1B03402800F9B80E /* QuantumKeyConsumer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuantumKeyConsumer.h; sourceTree = "<group>"; }; - 3211FD1B1698699D00424A3C /* LiveDataFetcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LiveDataFetcher.cpp; sourceTree = "<group>"; }; - 3211FD1C1698699D00424A3C /* LiveDataFetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LiveDataFetcher.h; sourceTree = "<group>"; }; 3214E73E1DC1081100A67414 /* AlarmDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = AlarmDescription.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 3214E73F1DC1081100A67414 /* AlarmDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = AlarmDescription.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 3214E7421DC10B9500A67414 /* MultiSeverityAlarm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = MultiSeverityAlarm.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; @@ -1393,6 +1368,7 @@ 3215860C178756B40090E7E6 /* AbstractDriverPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AbstractDriverPlugin.cpp; sourceTree = "<group>"; }; 3215860E17875FDB0090E7E6 /* DriverPluginLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DriverPluginLoader.cpp; sourceTree = "<group>"; }; 3215860F17875FDB0090E7E6 /* DriverPluginLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DriverPluginLoader.h; sourceTree = "<group>"; }; + 32161D1B20E29E9E00C4F750 /* ZmqMemoryManagement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZmqMemoryManagement.h; sourceTree = "<group>"; }; 3216601014D49D0F008DADD2 /* ObjectWaitSemaphore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ObjectWaitSemaphore.h; sourceTree = "<group>"; }; 3219E69D18CC7AE600C2F795 /* DirectIOClientConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DirectIOClientConnection.cpp; sourceTree = "<group>"; }; 3219E69E18CC7AE600C2F795 /* DirectIOClientConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectIOClientConnection.h; sourceTree = "<group>"; }; @@ -1442,7 +1418,6 @@ 322EC1BA1D34F2E10012467C /* StateFlagCatalog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StateFlagCatalog.h; sourceTree = "<group>"; }; 3230BEBB1817A9E100EA5793 /* libchaos_common.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libchaos_common.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; 3230BEBC1817A9E100EA5793 /* libchaos_cutoolkit.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libchaos_cutoolkit.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; - 3230BEBD1817A9E100EA5793 /* libchaos_uitoolkit.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libchaos_uitoolkit.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; 3230BEBE1817A9E100EA5793 /* ChaosMetadataService */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ChaosMetadataService; sourceTree = BUILT_PRODUCTS_DIR; }; 3230BEC0181A6ADB00EA5793 /* DatasetDB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatasetDB.cpp; sourceTree = "<group>"; }; 3230BEC1181A6ADB00EA5793 /* DatasetDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatasetDB.h; sourceTree = "<group>"; }; @@ -1738,8 +1713,6 @@ 32655AD81E9CE1E700829266 /* RemoveScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoveScript.cpp; sourceTree = "<group>"; }; 32655AD91E9CE1E700829266 /* RemoveScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoveScript.h; sourceTree = "<group>"; }; 326573F218CCD365009E9B6B /* TemplatedKeyObjectContainer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TemplatedKeyObjectContainer.h; sourceTree = "<group>"; }; - 3265BF4515D1A9CA00C3CAC6 /* ChaosUIToolkitCWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChaosUIToolkitCWrapper.h; sourceTree = "<group>"; }; - 3265BF4815D1AA9F00C3CAC6 /* ChaosUIToolkitCWrapper.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ChaosUIToolkitCWrapper.cc; sourceTree = "<group>"; }; 3265F9101FB8997300FEA246 /* b64_ntop.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b64_ntop.h; sourceTree = "<group>"; }; 3265F9111FB8997300FEA246 /* bson-context.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "bson-context.c"; sourceTree = "<group>"; }; 3265F9121FB8997300FEA246 /* bson-oid.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "bson-oid.c"; sourceTree = "<group>"; }; @@ -1912,16 +1885,6 @@ 326DB4B214B3A3E50018A8D0 /* DataManagerException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = DataManagerException.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 326DB4B314B3A3E50018A8D0 /* KeyDataStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = KeyDataStorage.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 326DB4B414B3A3E50018A8D0 /* KeyDataStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = KeyDataStorage.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; - 326DB4D714B3B0070018A8D0 /* ChaosUIToolkit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ChaosUIToolkit.cpp; sourceTree = "<group>"; }; - 326DB4D814B3B0070018A8D0 /* ChaosUIToolkit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChaosUIToolkit.h; sourceTree = "<group>"; }; - 326DB4DA14B3B0070018A8D0 /* HLDataApi.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = HLDataApi.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; - 326DB4DB14B3B0070018A8D0 /* HLDataApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = HLDataApi.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; - 326DB4DC14B3B0070018A8D0 /* HLInfrastructureApi.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = HLInfrastructureApi.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; - 326DB4DD14B3B0070018A8D0 /* HLInfrastructureApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = HLInfrastructureApi.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; - 326DB4E114B3B0070018A8D0 /* LLDataApi.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LLDataApi.cpp; sourceTree = "<group>"; }; - 326DB4E214B3B0070018A8D0 /* LLDataApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LLDataApi.h; sourceTree = "<group>"; }; - 326DB4E314B3B0070018A8D0 /* LLRpcApi.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = LLRpcApi.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; - 326DB4E414B3B0070018A8D0 /* LLRpcApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = LLRpcApi.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 326EA57714D2D8EE00D4962A /* MultiKeyObjectWaitSemaphore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MultiKeyObjectWaitSemaphore.h; sourceTree = "<group>"; }; 3270D5E61CCFAC4F0072017B /* AbstractExecutionUnit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AbstractExecutionUnit.cpp; sourceTree = "<group>"; }; 3270D5E71CCFAC4F0072017B /* AbstractExecutionUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractExecutionUnit.h; sourceTree = "<group>"; }; @@ -1963,6 +1926,10 @@ 3277A22D20973A0100FD7307 /* CPPScriptVM.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPScriptVM.h; sourceTree = "<group>"; }; 3277A233209C4AFD00FD7307 /* ClingRootInterpreter.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ClingRootInterpreter.cpp; sourceTree = "<group>"; }; 3277A234209C4AFD00FD7307 /* ClingRootInterpreter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ClingRootInterpreter.h; sourceTree = "<group>"; }; + 3278855420EB91CE004D1A34 /* SendStorageBurst.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SendStorageBurst.h; sourceTree = "<group>"; }; + 3278855520EB91CE004D1A34 /* SendStorageBurst.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SendStorageBurst.cpp; sourceTree = "<group>"; }; + 3278855720EB97BC004D1A34 /* SendStorageBurst.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SendStorageBurst.h; sourceTree = "<group>"; }; + 3278855820EB97BC004D1A34 /* SendStorageBurst.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SendStorageBurst.cpp; sourceTree = "<group>"; }; 32788D7D1F277207009BBB1E /* OpcodeDriverWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpcodeDriverWrapper.h; sourceTree = "<group>"; }; 32788D811F27766A009BBB1E /* OpcodeExternalCommandMapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpcodeExternalCommandMapper.h; sourceTree = "<group>"; }; 327967B415DF99FB0003C6DA /* RpcClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = RpcClient.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; @@ -2092,7 +2059,6 @@ 32936C661D9280BA00485F71 /* GetSnapshotForNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetSnapshotForNode.h; sourceTree = "<group>"; }; 3294905A159AF4BF00E86BD1 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; lineEnding = 0; path = CMakeLists.txt; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = "<none>"; }; 3294905B159AF4D700E86BD1 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; }; - 3294905C159AF4E600E86BD1 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; }; 3296030F1876B45000CDCADA /* AttributeValueSharedCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AttributeValueSharedCache.cpp; sourceTree = "<group>"; }; 329603101876B45000CDCADA /* AttributeValueSharedCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttributeValueSharedCache.h; sourceTree = "<group>"; }; 329603141876B45000CDCADA /* BatchCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BatchCommand.cpp; sourceTree = "<group>"; }; @@ -2801,13 +2767,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 3260278414B307DA00C906CE /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; 326413961E44ACE60035E175 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -2994,15 +2953,6 @@ path = serialization; sourceTree = "<group>"; }; - 3211FD061698666700424A3C /* caching */ = { - isa = PBXGroup; - children = ( - 3211FD1B1698699D00424A3C /* LiveDataFetcher.cpp */, - 3211FD1C1698699D00424A3C /* LiveDataFetcher.h */, - ); - path = caching; - sourceTree = "<group>"; - }; 3214EF0C1D466F41004DB689 /* manipulation */ = { isa = PBXGroup; children = ( @@ -3293,6 +3243,8 @@ 32B299A31BE25ABE000D3716 /* RecoverError.h */, 32A13EBA1C2016C60010F3FC /* Delete.cpp */, 32A13EBB1C2016C60010F3FC /* Delete.h */, + 3278855520EB91CE004D1A34 /* SendStorageBurst.cpp */, + 3278855420EB91CE004D1A34 /* SendStorageBurst.h */, ); path = control_unit; sourceTree = "<group>"; @@ -3322,6 +3274,8 @@ 32B299A91BE27945000D3716 /* RecoverError.h */, 32A13EB61C2014170010F3FC /* Delete.cpp */, 32A13EB71C2014170010F3FC /* Delete.h */, + 3278855820EB97BC004D1A34 /* SendStorageBurst.cpp */, + 3278855720EB97BC004D1A34 /* SendStorageBurst.h */, 3221D73A1CF5F31F001BE971 /* control_unit.h */, ); path = control_unit; @@ -3601,7 +3555,6 @@ 32F9C79A1E81943F00D4B250 /* CouchTest */, 3230BEBB1817A9E100EA5793 /* libchaos_common.dylib */, 3230BEBC1817A9E100EA5793 /* libchaos_cutoolkit.dylib */, - 3230BEBD1817A9E100EA5793 /* libchaos_uitoolkit.dylib */, 3230BEBE1817A9E100EA5793 /* ChaosMetadataService */, 32661C661AA73D5B00F1A721 /* libchaos_metadata_service_client.dylib */, 322085DA1AC5A0E100F1B71A /* ChaosMetadataServiceClientTest */, @@ -3882,6 +3835,7 @@ 3268CE32161608D100FCDB10 /* ZMQClient.h */, 3268CE33161608D100FCDB10 /* ZMQServer.cpp */, 3268CE34161608D100FCDB10 /* ZMQServer.h */, + 32161D1B20E29E9E00C4F750 /* ZmqMemoryManagement.h */, ); path = zmq; sourceTree = "<group>"; @@ -3964,7 +3918,6 @@ isa = PBXGroup; children = ( 326DB3B314B38BC00018A8D0 /* common */, - 326DB4CF14B3B0040018A8D0 /* ui_toolkit */, 326DB49914B3A3E20018A8D0 /* cu_toolkit */, ); path = chaos; @@ -4350,45 +4303,6 @@ path = data_manager; sourceTree = "<group>"; }; - 326DB4CF14B3B0040018A8D0 /* ui_toolkit */ = { - isa = PBXGroup; - children = ( - 3294905C159AF4E600E86BD1 /* CMakeLists.txt */, - 326DB4D714B3B0070018A8D0 /* ChaosUIToolkit.cpp */, - 326DB4D814B3B0070018A8D0 /* ChaosUIToolkit.h */, - 3265BF4815D1AA9F00C3CAC6 /* ChaosUIToolkitCWrapper.cc */, - 3265BF4515D1A9CA00C3CAC6 /* ChaosUIToolkitCWrapper.h */, - 326DB4D914B3B0070018A8D0 /* HighLevelApi */, - 326DB4E014B3B0070018A8D0 /* LowLevelApi */, - 3211FD061698666700424A3C /* caching */, - ); - path = ui_toolkit; - sourceTree = "<group>"; - }; - 326DB4D914B3B0070018A8D0 /* HighLevelApi */ = { - isa = PBXGroup; - children = ( - 326DB4DA14B3B0070018A8D0 /* HLDataApi.cpp */, - 326DB4DB14B3B0070018A8D0 /* HLDataApi.h */, - 326DB4DC14B3B0070018A8D0 /* HLInfrastructureApi.cpp */, - 326DB4DD14B3B0070018A8D0 /* HLInfrastructureApi.h */, - 320DF98F14E17E3D00251621 /* DeviceController.cpp */, - 320DF98C14E17E2700251621 /* DeviceController.h */, - ); - path = HighLevelApi; - sourceTree = "<group>"; - }; - 326DB4E014B3B0070018A8D0 /* LowLevelApi */ = { - isa = PBXGroup; - children = ( - 326DB4E114B3B0070018A8D0 /* LLDataApi.cpp */, - 326DB4E214B3B0070018A8D0 /* LLDataApi.h */, - 326DB4E314B3B0070018A8D0 /* LLRpcApi.cpp */, - 326DB4E414B3B0070018A8D0 /* LLRpcApi.h */, - ); - path = LowLevelApi; - sourceTree = "<group>"; - }; 3270E06A1C6CBA7D00105726 /* logging */ = { isa = PBXGroup; children = ( @@ -6078,21 +5992,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 3260278514B307DA00C906CE /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 326DB4EC14B3B0070018A8D0 /* ChaosUIToolkit.h in Headers */, - 326DB4EE14B3B0070018A8D0 /* HLDataApi.h in Headers */, - 326DB4F014B3B0070018A8D0 /* HLInfrastructureApi.h in Headers */, - 326DB4F414B3B0070018A8D0 /* LLDataApi.h in Headers */, - 326DB4F614B3B0070018A8D0 /* LLRpcApi.h in Headers */, - 320DF98D14E17E2700251621 /* DeviceController.h in Headers */, - 3265BF4615D1A9CA00C3CAC6 /* ChaosUIToolkitCWrapper.h in Headers */, - 3211FD1E1698699D00424A3C /* LiveDataFetcher.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 32661C641AA73D5B00F1A721 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -6204,6 +6103,7 @@ 3211CCDA1B021B8D00F9B80E /* GetBestEndpoints.h in Headers */, 32661C6E1AA741D000F1A721 /* ChaosMetadataServiceClient.h in Headers */, 32B299AB1BE27945000D3716 /* RecoverError.h in Headers */, + 3278855920EB97BC004D1A34 /* SendStorageBurst.h in Headers */, 326413941E40C72C0035E175 /* CUController.h in Headers */, 3243608C20288BB500B03037 /* ForwardNodeRpcMessage.h in Headers */, 32FC49B01E080FB80087D82C /* GetVariable.h in Headers */, @@ -6300,23 +6200,6 @@ productReference = 3230BEBC1817A9E100EA5793 /* libchaos_cutoolkit.dylib */; productType = "com.apple.product-type.library.dynamic"; }; - 3260278614B307DA00C906CE /* chaos_uitoolkit */ = { - isa = PBXNativeTarget; - buildConfigurationList = 3260278814B307DA00C906CE /* Build configuration list for PBXNativeTarget "chaos_uitoolkit" */; - buildPhases = ( - 3260278314B307DA00C906CE /* Sources */, - 3260278414B307DA00C906CE /* Frameworks */, - 3260278514B307DA00C906CE /* Headers */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = chaos_uitoolkit; - productName = chaos_uitoolkit; - productReference = 3230BEBD1817A9E100EA5793 /* libchaos_uitoolkit.dylib */; - productType = "com.apple.product-type.library.dynamic"; - }; 326413981E44ACE60035E175 /* ChaosAgent */ = { isa = PBXNativeTarget; buildConfigurationList = 3264139D1E44ACE60035E175 /* Build configuration list for PBXNativeTarget "ChaosAgent" */; @@ -6395,7 +6278,6 @@ targets = ( 326026E814B301F600C906CE /* chaos_common */, 3260276514B3068100C906CE /* chaos_cutoolkit */, - 3260278614B307DA00C906CE /* chaos_uitoolkit */, 32661C651AA73D5B00F1A721 /* chaos_metadata_service_client */, 324D08921F30CD7A00836E29 /* chaos_micro_unit_toolkit */, 323236C6164573C60052CE06 /* ChaosMetadataService */, @@ -6491,6 +6373,7 @@ 326ACF9C1E01594C00AD011E /* QueryDataConsumer.cpp in Sources */, 326ACF9B1E01594C00AD011E /* DriverPoolManager.cpp in Sources */, 32610F961AE671AF00779B84 /* StartStop.cpp in Sources */, + 3278855620EB91CE004D1A34 /* SendStorageBurst.cpp in Sources */, 32B9F3F41AC3E74C00380FE9 /* AbstractPersistenceDriver.cpp in Sources */, 324360802024A29800B03037 /* KillCurrentCommand.cpp in Sources */, 32E09CF71C0DED340069752F /* RestoreSnapshot.cpp in Sources */, @@ -6962,21 +6845,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 3260278314B307DA00C906CE /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 326DB4EB14B3B0070018A8D0 /* ChaosUIToolkit.cpp in Sources */, - 326DB4ED14B3B0070018A8D0 /* HLDataApi.cpp in Sources */, - 326DB4EF14B3B0070018A8D0 /* HLInfrastructureApi.cpp in Sources */, - 326DB4F314B3B0070018A8D0 /* LLDataApi.cpp in Sources */, - 326DB4F514B3B0070018A8D0 /* LLRpcApi.cpp in Sources */, - 320DF99114E190BB00251621 /* DeviceController.cpp in Sources */, - 3265BF4915D1AA9F00C3CAC6 /* ChaosUIToolkitCWrapper.cc in Sources */, - 3211FD1D1698699D00424A3C /* LiveDataFetcher.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 326413951E44ACE60035E175 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -7004,6 +6872,7 @@ files = ( 3252F35C1C298755004436A8 /* GetNodeChilds.cpp in Sources */, 32661C6D1AA741D000F1A721 /* ChaosMetadataServiceClient.cpp in Sources */, + 3278855A20EB97BC004D1A34 /* SendStorageBurst.cpp in Sources */, 32FFA3EC1B00D43900C57E07 /* QuantumSlot.cpp in Sources */, 32B1E7F61B2AD1CC00221E49 /* CommandTemplateGet.cpp in Sources */, 32B1E7E91B297C7F00221E49 /* CommandTemplateSet.cpp in Sources */, @@ -7122,11 +6991,6 @@ target = 3260276514B3068100C906CE /* chaos_cutoolkit */; targetProxy = 3211C6791C146252003B38BF /* PBXContainerItemProxy */; }; - 3211C67C1C146252003B38BF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 3260278614B307DA00C906CE /* chaos_uitoolkit */; - targetProxy = 3211C67B1C146252003B38BF /* PBXContainerItemProxy */; - }; 3211C67E1C146252003B38BF /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 323236C6164573C60052CE06 /* ChaosMetadataService */; @@ -7268,42 +7132,6 @@ }; name = "[GPERF]Debug"; }; - 3217816520C559AA00C079C9 /* [GPERF]Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - 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_LDFLAGS = "-lchaos_common"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - }; - name = "[GPERF]Debug"; - }; 3217816620C559AA00C079C9 /* [GPERF]Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -7345,6 +7173,7 @@ ., 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; @@ -7405,6 +7234,7 @@ ., 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; @@ -7807,6 +7637,7 @@ ., 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; @@ -7861,6 +7692,7 @@ ., 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 = NO; @@ -8064,71 +7896,6 @@ }; name = Release; }; - 3260278914B307DA00C906CE /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - 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_LDFLAGS = "-lchaos_common"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - }; - name = Debug; - }; - 3260278A14B307DA00C906CE /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CONFIGURATION_BUILD_DIR = "$(SRCROOT)/usr/local/lib"; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DSTROOT = /; - EXECUTABLE_PREFIX = lib; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - 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; - OTHER_LDFLAGS = "-lchaos_common"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - }; - name = Release; - }; 3264139E1E44ACE60035E175 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -8284,6 +8051,7 @@ ., 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; @@ -8329,6 +8097,7 @@ ., 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 = NO; @@ -8411,16 +8180,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 3260278814B307DA00C906CE /* Build configuration list for PBXNativeTarget "chaos_uitoolkit" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 3260278914B307DA00C906CE /* Debug */, - 3217816520C559AA00C079C9 /* [GPERF]Debug */, - 3260278A14B307DA00C906CE /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; 3264139D1E44ACE60035E175 /* Build configuration list for PBXNativeTarget "ChaosAgent" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/CHAOSFrameworkTests/CHAOSFrameworkTests.xcodeproj/project.pbxproj b/CHAOSFrameworkTests/CHAOSFrameworkTests.xcodeproj/project.pbxproj index b4d7c91864def5ee86cc7aa1b774115fd5f6eaf1..709e302817fa5b2ffd5616d4fcd874a8ec316d91 100644 --- a/CHAOSFrameworkTests/CHAOSFrameworkTests.xcodeproj/project.pbxproj +++ b/CHAOSFrameworkTests/CHAOSFrameworkTests.xcodeproj/project.pbxproj @@ -684,7 +684,6 @@ OTHER_LDFLAGS = ( $inherited, "-lgtest", - "-ltcmalloc", ); PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -711,7 +710,6 @@ OTHER_LDFLAGS = ( $inherited, "-lgtest", - "-ltcmalloc", ); PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/CHAOSFrameworkTests/FrameworkTest/cache/EmbeddedLFCacheTest.cpp b/CHAOSFrameworkTests/FrameworkTest/cache/EmbeddedLFCacheTest.cpp index 57143bc0b88be157fc268d1a78e4cd48c5430dea..33658149ecc6a9fb432d1465f9a17f9c1f7d8e49 100644 --- a/CHAOSFrameworkTests/FrameworkTest/cache/EmbeddedLFCacheTest.cpp +++ b/CHAOSFrameworkTests/FrameworkTest/cache/EmbeddedLFCacheTest.cpp @@ -68,7 +68,7 @@ void EmbeddedLFCacheTest::cacheGarbage(chaos::common::data::cache::KeyGroupCache } while (threadWriteExecution); } -TEST_F(EmbeddedLFCacheTest, EmbeddedLFCacheTest) { +//TEST_F(EmbeddedLFCacheTest, EmbeddedLFCacheTest) { // boost::thread_group tWriterGroup; // boost::thread_group tGarbageGroup; // boost::thread_group tReadersGroup; @@ -98,6 +98,6 @@ TEST_F(EmbeddedLFCacheTest, EmbeddedLFCacheTest) { // //deinit all cache // ASSERT_NO_THROW(dsCache->stop();); // ASSERT_NO_THROW(dsCache->deinit();); -} +//} diff --git a/CHAOSFrameworkTests/FrameworkTest/data/TestCDataWrapper.cpp b/CHAOSFrameworkTests/FrameworkTest/data/TestCDataWrapper.cpp index 5bae3ca6c565272a9df937259629a98506d75b95..b765d0b9d63588b6383e11b17d94b9ce13606a17 100644 --- a/CHAOSFrameworkTests/FrameworkTest/data/TestCDataWrapper.cpp +++ b/CHAOSFrameworkTests/FrameworkTest/data/TestCDataWrapper.cpp @@ -60,7 +60,7 @@ TEST(CDataWrapperTest, MemoryLeaks) { data_pack.appendStringToArray("array_lement"); data_pack.finalizeArrayForKey("array"); const std::string json_serialization = data_pack.getJSONString(); - for (; idx < 1000000; idx++) { + for (; idx < 1000; idx++) { bson_deserialized = CDWUniquePtr(new CDataWrapper(data_pack.getBSONRawData(), data_pack.getBSONRawSize())); ASSERT_TRUE(bson_deserialized.get()); json_deserialized = CDataWrapper::instanceFromJson(json_serialization); @@ -77,13 +77,14 @@ TEST(CDataWrapperTest, MemoryLeaks) { ASSERT_EQ(array_ptr->getInt64ElementAtIndex(1), 2); ASSERT_EQ(array_ptr->getDoubleElementAtIndex(2), 3.0); ASSERT_STREQ(array_ptr->getStringElementAtIndex(3).c_str(), "array_lement"); + array_ptr.reset(); } } TEST(CDataWrapperTest, Performance) { int idx = 0; CDataWrapper data_pack; CDWUniquePtr cloned; - for (; idx < 1000000; idx++) { + for (; idx < 1000; idx++) { data_pack.addBoolValue("bv", (int32_t)0); data_pack.addInt32Value("i32v", (int32_t)0); data_pack.addInt64Value("i64v", (int64_t)0); @@ -107,6 +108,7 @@ TEST(CDataWrapperTest, TestJsonDouble) { for(int cnt=0;cnt<p->size();cnt++){ ASSERT_EQ( test_var[cnt], p->getDoubleElementAtIndex(cnt)); } + p.reset(); } TEST(CDataWrapperTest, TestEmptyBSONToJSON) { CDataWrapper bson_a((const char*)NULL, 0); @@ -176,6 +178,7 @@ TEST(CDataWrapperTest, TestConcatenation) { ASSERT_EQ( test_var[cnt], p->getDoubleElementAtIndex(cnt)); } ASSERT_STREQ("{ \"empty\" : { }, \"notempty\" : { \"double_key\" : [ 1.0, 2.1000000000000000888, -1.0, -0.9000000000000000222 ], \"string_vector\" : [ \"ciao\", \"come stai\" ] }, \"empty2\" : { }, \"pieno\" : { \"ts1\" : 1, \"ts2\" : 2, \"ts3\" : 3, \"ts4\" : 4, \"double_key\" : -2.0, \"ts5\" : 5, \"ts6\" : 6, \"string_empty\" : \"\", \"int_key\" : 3, \"string_key\" : \"this is a long text that try to do some space on bson\", \"bool_key\" : true, \"bool_key1\" : false } }", dconcat.getCompliantJSONString().c_str()); + p.reset(); } TEST(CDataWrapperTest, DateToLong) { const char * json = "{ \"ndk_heartbeat\" : { \"$date\" : { \"$numberLong\" : \"1511968737899\" } } }"; diff --git a/CHAOSFrameworkTests/FrameworkTest/direct_io/DirectIODeviceServerChannelTest.cpp b/CHAOSFrameworkTests/FrameworkTest/direct_io/DirectIODeviceServerChannelTest.cpp index 313123237426e381c21a7c7577e9ca611d5ae1af..c08dc620d3e89ebaf39c28240cb27403028df6a4 100644 --- a/CHAOSFrameworkTests/FrameworkTest/direct_io/DirectIODeviceServerChannelTest.cpp +++ b/CHAOSFrameworkTests/FrameworkTest/direct_io/DirectIODeviceServerChannelTest.cpp @@ -49,9 +49,10 @@ class DeviceServerHandler: public DirectIODeviceServerChannel::DirectIODeviceServerChannelHandler { public: ~DeviceServerHandler(){} - int consumePutEvent(opcode_headers::DirectIODeviceChannelHeaderPutOpcode& header, - BufferSPtr channel_data, - uint32_t channel_data_len) { + int consumePutEvent(const std::string& key, + const uint8_t hst_tag, + const ChaosStringSetConstSPtr meta_tag_set, + chaos::common::data::BufferSPtr channel_data) { int err = 0; if((++consumePutEvent_counter % 2) == 0) { //right result the data need to be savet @@ -59,7 +60,7 @@ public: if(!push_data->hasKey("key") || !push_data->isInt32Value("key")) { err = -1; - } else if(header.tag != push_data->getInt32Value("key")) { + } else if(hst_tag != push_data->getInt32Value("key")) { err = -1; } } else { @@ -69,9 +70,10 @@ public: return err; }; - int consumeHealthDataEvent(opcode_headers::DirectIODeviceChannelHeaderPutOpcode& header, - BufferSPtr channel_data, - uint32_t channel_data_len) { + int consumeHealthDataEvent(const std::string& key, + const uint8_t hst_tag, + const ChaosStringSetConstSPtr meta_tag_set, + chaos::common::data::BufferSPtr channel_data) { int err = 0; if((++consumeHealthDataEvent_counter % 2) == 0) { //right result the data need to be savet @@ -79,7 +81,7 @@ public: if(!push_data->hasKey("key") || !push_data->isInt32Value("key")) { err = -1; - } else if(header.tag != push_data->getInt32Value("key")) { + } else if(hst_tag != push_data->getInt32Value("key")) { err = -1; } } else { @@ -147,8 +149,9 @@ public: int consumeDataCloudQuery(opcode_headers::DirectIODeviceChannelHeaderOpcodeQueryDataCloud& query_header, const std::string& search_key, - uint64_t search_start_ts, - uint64_t search_end_ts, + const ChaosStringSet& meta_tags, + const uint64_t search_start_ts, + const uint64_t search_end_ts, opcode_headers::SearchSequence& last_element_found_seq, opcode_headers::QueryResultPage& result_page) { int err = 0; @@ -346,8 +349,8 @@ TEST_F(DirectIOChannelTest, DeviceChannelTest) { QueryResultPage results; SearchSequence sseq = {1,2}; int page_dimension = 100; - ASSERT_TRUE(client_channel->queryDataCloud("search", std::numeric_limits<uint32_t>::min(), std::numeric_limits<uint32_t>::max(), page_dimension, sseq, results)); - ASSERT_FALSE(client_channel->queryDataCloud("search", std::numeric_limits<uint32_t>::min(), std::numeric_limits<uint32_t>::max(), page_dimension, sseq, results)); + ASSERT_TRUE(client_channel->queryDataCloud("search", ChaosStringSet(), std::numeric_limits<uint32_t>::min(), std::numeric_limits<uint32_t>::max(), page_dimension, sseq, results)); + ASSERT_FALSE(client_channel->queryDataCloud("search", ChaosStringSet(), std::numeric_limits<uint32_t>::min(), std::numeric_limits<uint32_t>::max(), page_dimension, sseq, results)); ASSERT_EQ(page_dimension, results.size()); ASSERT_EQ(sseq.run_id, 2); ASSERT_EQ(sseq.datapack_counter, 3); diff --git a/CHAOSWorkspace.xcworkspace/contents.xcworkspacedata b/CHAOSWorkspace.xcworkspace/contents.xcworkspacedata index fb811328e66b62f6f75c24e62fe2a0430906351f..4a83261c8a216e1eef2908111ff691ad8525c313 100644 --- a/CHAOSWorkspace.xcworkspace/contents.xcworkspacedata +++ b/CHAOSWorkspace.xcworkspace/contents.xcworkspacedata @@ -10,13 +10,7 @@ <FileRef location = "group:CHAOSFrameworkTests/CHAOSFrameworkTests.xcodeproj"> </FileRef> - <FileRef - location = "group:example/ChaosCLI/ChaosCLI.xcodeproj"> - </FileRef> <FileRef location = "group:ChaosDataExport/ChaosDataExport.xcodeproj"> </FileRef> - <FileRef - location = "group:example/ChaosPerformanceTester/ChaosPerformanceTester.xcodeproj"> - </FileRef> </Workspace> diff --git a/CMakeLists.txt b/CMakeLists.txt index abdecb1336db0d0fc9195adba07a8f3c6187cbc5..6741eedac9089d8e2303169c7aa1a730c055b041 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,9 +128,6 @@ if(NOT CHAOS_ONLY_DEPENDECY) MESG("Configure CUToolkit Layer") ADD_SUBDIRECTORY(chaos/cu_toolkit) - MESG("Configure UIToolkit Layer") - ADD_SUBDIRECTORY(chaos/ui_toolkit) - MESG("Configure Chaos Metadata Service Client Library") ADD_SUBDIRECTORY(chaos_metadata_service_client) @@ -143,30 +140,28 @@ MESG("Configure Chaos Agent Service") ADD_SUBDIRECTORY(ChaosAgent) ENDIF() -IF (CHAOS_MDS AND NOT CHAOS_ONLY_DEPENDECY) - MESG("Configure Chaos Metadata Service") - ADD_SUBDIRECTORY(ChaosMetadataService) +IF (CHAOS_MDS AND + NOT CHAOS_ONLY_DEPENDECY) + IF("${CMAKE_CXX_COMPILE_FEATURES}" MATCHES "cxx_std_11") + MESG("Configure Chaos Data Service") + ADD_SUBDIRECTORY(ChaosMetadataService) + ELSE() + WARN("Chaos Data Service require a c11 compliant compiler") + ENDIF() ENDIF() IF(NOT CHAOS_ONLY_DEPENDECY) MESG("Configure Chaos Metadata Service Client Library Test Application") ADD_SUBDIRECTORY(ChaosMetadataServiceClientTest) - IF (CHAOS_DATA_EXPORT) MESG("Configure Chaos Data Export ") ADD_SUBDIRECTORY(ChaosDataExport) ENDIF() IF(CHAOS_EXAMPLES) - MESG("Configure Chaos CLI") - ADD_SUBDIRECTORY(example/ChaosCLI) - MESG("Configure Chaos ChaosMDSCmd") ADD_SUBDIRECTORY(example/ChaosMDSCmd) - - MESG("Configure Chaos Performance Tester") - ADD_SUBDIRECTORY(example/ChaosPerformanceTester) ENDIF() ENDIF() diff --git a/ChaosDataExport/CMakeLists.txt b/ChaosDataExport/CMakeLists.txt index c9dd776244ad3fb51888ffbad6d4584a686c3fc9..4468a5e6ebed341a3b62a91f959b8b2aa377de6f 100644 --- a/ChaosDataExport/CMakeLists.txt +++ b/ChaosDataExport/CMakeLists.txt @@ -12,6 +12,6 @@ ENDIF() ADD_EXECUTABLE(ChaosDataExport ${chaos_cde_src}) -TARGET_LINK_LIBRARIES(ChaosDataExport chaos_uitoolkit chaos_common ${FrameworkLib}) +TARGET_LINK_LIBRARIES(ChaosDataExport chaos_metadata_service_client chaos_common ${FrameworkLib}) INSTALL_TARGETS(/bin ChaosDataExport) diff --git a/ChaosDataExport/ChaosDataExport.xcodeproj/project.pbxproj b/ChaosDataExport/ChaosDataExport.xcodeproj/project.pbxproj index 7c8c379e461c7e045192c4859af83d36c3ed1270..82b8c912354d44928d3e1f8730eea53db9901989 100644 --- a/ChaosDataExport/ChaosDataExport.xcodeproj/project.pbxproj +++ b/ChaosDataExport/ChaosDataExport.xcodeproj/project.pbxproj @@ -353,12 +353,9 @@ CLANG_CXX_LIBRARY = "libc++"; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../usr/local/bin"; HEADER_SEARCH_PATHS = ../../usr/local/include; - LIBRARY_SEARCH_PATHS = ( - /usr/local/lib, - "$(SRCROOT)/../../usr/local/lib", - ); + LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../../usr/local/lib"; OTHER_LDFLAGS = ( - "-lchaos_uitoolkit", + "-lchaos_metadata_service_client", "-lchaos_common", ); PRODUCT_NAME = "$(TARGET_NAME)"; @@ -372,12 +369,9 @@ CLANG_CXX_LIBRARY = "libc++"; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../usr/local/bin"; HEADER_SEARCH_PATHS = ../../usr/local/include; - LIBRARY_SEARCH_PATHS = ( - /usr/local/lib, - "$(SRCROOT)/../../usr/local/lib", - ); + LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../../usr/local/lib"; OTHER_LDFLAGS = ( - "-lchaos_uitoolkit", + "-lchaos_metadata_service_client", "-lchaos_common", ); PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/ChaosDataExport/TestDatasetIO/ChaosDatasetIO.cpp b/ChaosDataExport/TestDatasetIO/ChaosDatasetIO.cpp index dca76d998748141f288ec73b0754bc21cd25d583..68bac98dc62972e3a2a3e0a05bb2097bb2ef6ff6 100644 --- a/ChaosDataExport/TestDatasetIO/ChaosDatasetIO.cpp +++ b/ChaosDataExport/TestDatasetIO/ChaosDatasetIO.cpp @@ -66,6 +66,21 @@ namespace driver{ } uid=groupName+"/"+datasetName; +// ChaosUniquePtr<char[]> buff(new char [10024]); +// CDWUniquePtr result_uptr; +// CDWUniquePtr data_uptr(new CDataWrapper()); +// data_uptr->addStringValue("echo_key", "echo value"); +// data_uptr->addBinaryValue("bin_value", buff.get(), 1024); +// for(int idx = 0; +// idx < 100000000; +// idx++) { +// int err = mds_message_channel->sendEchoMessage(*data_uptr, result_uptr); +// if(!err && +// result_uptr) { +// DPD_LAPP << result_uptr->getCompliantJSONString(); +// } +// } +// DPD_LAPP << "end"; } int ChaosDatasetIO::setAgeing(uint64_t secs){ageing=secs;return 0;} @@ -109,7 +124,7 @@ namespace driver{ int ChaosDatasetIO::pushDataset(int type) { int err = 0; //ad producer key - CDataWrapper*new_dataset=datasets[type].get(); + CDWShrdPtr new_dataset = datasets[type]; uint64_t ts = chaos::common::utility::TimingUtil::getTimeStamp(); uint64_t tsh = chaos::common::utility::TimingUtil::getTimeStampInMicroseconds(); @@ -145,7 +160,7 @@ namespace driver{ // DPD_LDBG <<" PUSHING:"<<new_dataset->getJSONString(); // DirectIOChannelsInfo *next_client = static_cast<DirectIOChannelsInfo*>(connection_feeder.getService()); // serialization->disposeOnDelete = !next_client; - ioLiveDataDriver->storeData(uid+chaos::datasetTypeToPostfix(type),new_dataset,(chaos::DataServiceNodeDefinitionType::DSStorageType)storageType,false); + ioLiveDataDriver->storeData(uid+chaos::datasetTypeToPostfix(type),new_dataset,(chaos::DataServiceNodeDefinitionType::DSStorageType)storageType); return err; @@ -430,7 +445,7 @@ namespace driver{ query_cursor_map.erase(i++); } - + DEBUG_CODE(DPD_LDBG << "Shared Manager deinitialized"); DEBUG_CODE(DPD_LDBG << "Deinitialized"); diff --git a/ChaosDataExport/cde.cpp b/ChaosDataExport/cde.cpp index 654bf1d7ef43d885ade38ecea743edf82744f874..926f00e35503c4f187a3e39f9b1de92c5d28e4b9 100644 --- a/ChaosDataExport/cde.cpp +++ b/ChaosDataExport/cde.cpp @@ -27,9 +27,8 @@ #include <chaos/common/additional_lib/base64.h> #include <chaos/common/utility/TimingUtil.h> #include <chaos/common/network/CNodeNetworkAddress.h> -#include <chaos/ui_toolkit/ChaosUIToolkit.h> -#include <chaos/ui_toolkit/LowLevelApi/LLRpcApi.h> -#include <chaos/ui_toolkit/HighLevelApi/HLDataApi.h> +#include <chaos_metadata_service_client/ChaosMetadataServiceClient.h> + #include <chaos/common/bson/bson.h> @@ -42,7 +41,9 @@ using namespace std; using namespace chaos; using namespace chaos::common::data; using namespace chaos::common::utility; -using namespace chaos::ui; + +using namespace chaos::metadata_service_client; +using namespace chaos::metadata_service_client::node_controller; using namespace boost; #define OPT_CU_ID "device-id" @@ -53,6 +54,7 @@ using namespace boost; #define OPT_PAGE_LENGHT "page-lenght" #define OPT_START_TIME "start-time" #define OPT_END_TIME "end-time" +#define OPT_TAGS "tags" void sendBackOnRow() { @@ -79,7 +81,9 @@ int computePercent(uint64_t done, uint64_t all) { return result; } -chaos::common::data::SerializationBuffer *getCSVDecoding( DeviceController& controller, const std::vector<std::string>& output_element_name, CDataWrapper& data_pack) { +chaos::common::data::SerializationBuffer *getCSVDecoding(CUController& controller, + const std::vector<std::string>& output_element_name, + CDataWrapper& data_pack) { chaos::common::data::SerializationBuffer *result = NULL; std::stringstream csv_lin; chaos::common::data::RangeValueInfo attribute_info; @@ -166,6 +170,7 @@ int main(int argc, const char* argv[]) { uint32_t page_len; string start_time; string end_time; + ChaosStringVector meta_tags; std::string err_str; std::ostream *destination_stream = NULL; std::ofstream destination_file; @@ -175,7 +180,6 @@ int main(int argc, const char* argv[]) { int rett=0; int retry = 0; - uint32_t cicle_number = 0; //clear buffer memset(buf, 0, 255); @@ -186,24 +190,25 @@ int main(int argc, const char* argv[]) { try{ //std::cout << "\x1B[?25l"; //! [UIToolkit Attribute Init] - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_CU_ID, "The identification string of the device", &device_id); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<uint32_t>(OPT_TIMEOUT, "Timeout for wait the answer in milliseconds", 2000, &timeout); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<uint32_t>(OPT_DST_TYPE, "Destination date type [binary(0), JSON(1), CSV(2)]", 0, &dest_type); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_DST_FILE, "Destination file for save found datapack", &dst_file); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_START_TIME, "Time for first datapack to find [format from %Y-%m-%dT%H:%M:%S.%f to %Y]", &start_time); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_END_TIME, "Time for last datapack to find [format from %Y-%m-%dT%H:%M:%S.%f to %Y]", &end_time); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<uint32_t>(OPT_PAGE_LENGHT, "query page lenght", 30, &page_len); + ChaosMetadataServiceClient::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_CU_ID, "The identification string of the device", &device_id); + ChaosMetadataServiceClient::getInstance()->getGlobalConfigurationInstance()->addOption<uint32_t>(OPT_TIMEOUT, "Timeout for wait the answer in milliseconds", 2000, &timeout); + ChaosMetadataServiceClient::getInstance()->getGlobalConfigurationInstance()->addOption<uint32_t>(OPT_DST_TYPE, "Destination date type [binary(0), JSON(1), CSV(2)]", 0, &dest_type); + ChaosMetadataServiceClient::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_DST_FILE, "Destination file for save found datapack", &dst_file); + ChaosMetadataServiceClient::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_START_TIME, "Time for first datapack to find [format from %Y-%m-%dT%H:%M:%S.%f to %Y]", &start_time); + ChaosMetadataServiceClient::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_END_TIME, "Time for last datapack to find [format from %Y-%m-%dT%H:%M:%S.%f to %Y]", &end_time); + ChaosMetadataServiceClient::getInstance()->getGlobalConfigurationInstance()->addOption<uint32_t>(OPT_PAGE_LENGHT, "query page lenght", 30, &page_len); + ChaosMetadataServiceClient::getInstance()->getGlobalConfigurationInstance()->addOption<ChaosStringVector>(OPT_TAGS, "Meta tags list", &meta_tags); //! [UIToolkit Attribute Init] //! [UIToolkit Init] - ChaosUIToolkit::getInstance()->init(argc, argv); + ChaosMetadataServiceClient::getInstance()->init(argc, argv); //! [UIToolkit Init] - if(!ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_CU_ID)){ + if(!ChaosMetadataServiceClient::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_CU_ID)){ throw CException(-1, "invalid device identification string", "check param"); } //get the timestamp for query boundary - if(ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_START_TIME)){ + if(ChaosMetadataServiceClient::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_START_TIME)){ //try to check if the string is a number try { start_ts = lexical_cast<uint64_t>(start_time); @@ -216,7 +221,7 @@ int main(int argc, const char* argv[]) { std::cout << "Set start data to:"<< start_time << std::endl; } - if(ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_END_TIME)){ + if(ChaosMetadataServiceClient::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_END_TIME)){ //try to check if the string is a number try { end_ts = lexical_cast<uint64_t>(end_time); @@ -256,14 +261,22 @@ int main(int argc, const char* argv[]) { //we can allocate the channel std::cout << "Acquiring controller" << std::endl; - DeviceController *controller = HLDataApi::getInstance()->getControllerForDeviceID(device_id, timeout); + CUController *controller = NULL; + ChaosMetadataServiceClient::getInstance()->getNewCUController(device_id, &controller); if(!controller) throw CException(4, "Error allocating decive controller", "device controller creation"); - + ChaosStringSet search_tags; chaos::common::io::QueryCursor *query_cursor = NULL; - controller->executeTimeIntervallQuery(DatasetDomainOutput, + for(ChaosStringVectorIterator it = meta_tags.begin(), + end = meta_tags.end(); + it != end; + it++) { + search_tags.insert(*it); + } + controller->executeTimeIntervallQuery(chaos::cu::data_manager::KeyDataStorageDomainOutput, start_ts, end_ts, + search_tags, &query_cursor, page_len); @@ -298,18 +311,18 @@ int main(int argc, const char* argv[]) { ChaosSharedPtr<CDataWrapper> q_result(query_cursor->next()); if(q_result.get()) { retry = 0; - ChaosUniquePtr<chaos::common::data::SerializationBuffer> ser; + SerializationBufferUPtr ser; //get serialization buffer by type switch (dest_type) { //BSON case 0:{ - ser.reset(q_result->getBSONData()); + ser = q_result->getBSONData(); break; } //JSON case 1:{ std::string ser_str = q_result->getJSONString(); - ser.reset(new SerializationBuffer(ser_str.c_str(), ser_str.size())); + //ser = ChaosMakeSharedPtr<SerializationBuffer>(ser_str.c_str(), ser_str.size())); break; } //CSV @@ -333,7 +346,7 @@ int main(int argc, const char* argv[]) { } destination_stream->flush(); std::cout << "Releasing controller" << std::endl; - HLDataApi::getInstance()->disposeDeviceControllerPtr(controller); + ChaosMetadataServiceClient::getInstance()->deleteCUController(controller); } catch (CException& e) { std::cout << "\x1B[?25h"; std::cerr << e.errorCode << " - "<< e.errorDomain << " - " << e.errorMessage << std::endl; @@ -346,7 +359,7 @@ int main(int argc, const char* argv[]) { try { //! [UIToolkit Deinit] - ChaosUIToolkit::getInstance()->deinit(); + ChaosMetadataServiceClient::getInstance()->deinit(); //! [UIToolkit Deinit] } catch (CException& e) { std::cout << "\x1B[?25h"; diff --git a/ChaosMetadataService/CMakeLists.txt b/ChaosMetadataService/CMakeLists.txt index 00b904ae02d5c81f64ab818c84997eaae5a9cb13..6b219ff1a74c7dc2e747cbd8e15fbfed6c5fde01 100644 --- a/ChaosMetadataService/CMakeLists.txt +++ b/ChaosMetadataService/CMakeLists.txt @@ -119,7 +119,8 @@ SET(cnd_src ${cnd_src} api/control_unit/SetInputDatasetAttributeValues.cpp api/control_unit/CopyInstance.cpp api/control_unit/RecoverError.cpp api/control_unit/GetCurrentDataset.cpp - api/control_unit/GetFullDescription.cpp) + api/control_unit/GetFullDescription.cpp + api/control_unit/SendStorageBurst.cpp) SET(cnd_src ${cnd_src} api/node/NodeGroup.cpp api/node/NodeCreateUnitServer.cpp diff --git a/ChaosMetadataService/QueryDataConsumer.cpp b/ChaosMetadataService/QueryDataConsumer.cpp index ddec5c4d9272b20be07885ead107524b512b1352..e44f224bd7e2053e57f9ac8665bea27bc99edb15 100644 --- a/ChaosMetadataService/QueryDataConsumer.cpp +++ b/ChaosMetadataService/QueryDataConsumer.cpp @@ -149,52 +149,38 @@ void QueryDataConsumer::deinit() throw (chaos::CException) { } #pragma mark DirectIODeviceServerChannelHandler -int QueryDataConsumer::consumePutEvent(DirectIODeviceChannelHeaderPutOpcode& header, - BufferSPtr channel_data, - uint32_t channel_data_len) { +int QueryDataConsumer::consumePutEvent(const std::string& key, + const uint8_t hst_tag, + const ChaosStringSetConstSPtr meta_tag_set, + BufferSPtr channel_data) { CHAOS_ASSERT(channel_data) int err = 0; - const int8_t key_tag = header.tag; - const std::string key_to_store = std::string((const char *)GET_PUT_OPCODE_KEY_PTR(&header), - header.key_len); - DataServiceNodeDefinitionType::DSStorageType storage_type = static_cast<DataServiceNodeDefinitionType::DSStorageType>(key_tag); + + DataServiceNodeDefinitionType::DSStorageType storage_type = static_cast<DataServiceNodeDefinitionType::DSStorageType>(hst_tag); //! if tag is == 1 the datapack is in liveonly - bool send_to_storage_layer = (storage_type != DataServiceNodeDefinitionType::DSStorageTypeLive && - storage_type != DataServiceNodeDefinitionType::DSStorageTypeUndefined); - switch(storage_type) { - case DataServiceNodeDefinitionType::DSStorageTypeLiveHistory: - case DataServiceNodeDefinitionType::DSStorageTypeLive:{ - //protected access to cached driver - CachePoolSlot *cache_slot = DriverPoolManager::getInstance()->getCacheDriverInstance(); - if(cache_slot) { - err = cache_slot->resource_pooled->putData(key_to_store, - channel_data); - DriverPoolManager::getInstance()->releaseCacheDriverInstance(cache_slot); - } else { - ERR << "Error allocating cache slot"; - } - break; - } - case DataServiceNodeDefinitionType::DSStorageTypeHistory: - case DataServiceNodeDefinitionType::DSStorageTypeUndefined: - break; - - default: { - ERR << "Bad storage tag: " << key_tag; - break; + + if(storage_type & DataServiceNodeDefinitionType::DSStorageTypeLive) { + //protected access to cached driver + CachePoolSlot *cache_slot = DriverPoolManager::getInstance()->getCacheDriverInstance(); + if(cache_slot) { + err = cache_slot->resource_pooled->putData(key, + channel_data); + DriverPoolManager::getInstance()->releaseCacheDriverInstance(cache_slot); + } else { + ERR << "Error allocating cache slot"; } } - if(send_to_storage_layer) { + if(storage_type & DataServiceNodeDefinitionType::DSStorageTypeHistory) { //compute the index to use for the data worker uint32_t index_to_use = device_data_worker_index++ % ChaosMetadataService::getInstance()->setting.worker_setting.instances; CHAOS_ASSERT(device_data_worker[index_to_use]) //create storage job information auto job = ChaosMakeSharedPtr<DeviceSharedWorkerJob>(); - job->key = key_to_store; - job->key_tag = key_tag; + job->key = key; + job->key_tag = hst_tag; job->data_pack = channel_data; - job->data_pack_len = channel_data_len; + job->meta_tag = ChaosMoveOperator(meta_tag_set); if((err = device_data_worker[index_to_use]->submitJobInfo(job))) { DEBUG_CODE(DBG << "Error pushing data into worker queue"); } @@ -202,9 +188,10 @@ int QueryDataConsumer::consumePutEvent(DirectIODeviceChannelHeaderPutOpcode& hea return err; } -int QueryDataConsumer::consumeHealthDataEvent(DirectIODeviceChannelHeaderPutOpcode& header, - BufferSPtr channel_data, - uint32_t channel_data_len) { +int QueryDataConsumer::consumeHealthDataEvent(const std::string& key, + const uint8_t hst_tag, + const ChaosStringSetConstSPtr meta_tag_set, + BufferSPtr channel_data) { int err = 0; CDataWrapper health_data_pack((char *)channel_data->data()); @@ -217,15 +204,17 @@ int QueryDataConsumer::consumeHealthDataEvent(DirectIODeviceChannelHeaderPutOpco attribute_reference_wrapper()))) { ERR << "error storing health data into database for key " << attribute_reference_wrapper().node_uid; } - return consumePutEvent(header, - channel_data, - channel_data_len); + return consumePutEvent(key, + hst_tag, + ChaosMoveOperator(meta_tag_set), + channel_data); } int QueryDataConsumer::consumeDataCloudQuery(DirectIODeviceChannelHeaderOpcodeQueryDataCloud& query_header, const std::string& search_key, - uint64_t search_start_ts, - uint64_t search_end_ts, + const ChaosStringSet& meta_tags, + const uint64_t search_start_ts, + const uint64_t search_end_ts, SearchSequence& last_element_found_seq, QueryResultPage& page_element_found) { @@ -233,6 +222,7 @@ int QueryDataConsumer::consumeDataCloudQuery(DirectIODeviceChannelHeaderOpcodeQu //execute the query ObjectStorageDataAccess *obj_storage_da = object_storage_driver->getDataAccess<object_storage::abstraction::ObjectStorageDataAccess>(); if((err = obj_storage_da->findObject(search_key, + meta_tags, search_start_ts, search_end_ts, query_header.field.record_for_page, diff --git a/ChaosMetadataService/QueryDataConsumer.h b/ChaosMetadataService/QueryDataConsumer.h index df82d615ff3f67a6c4fb3408de1a71c0a9931580..19065b7c78c7ce97a212a22367537ec6d7d6caf3 100644 --- a/ChaosMetadataService/QueryDataConsumer.h +++ b/ChaosMetadataService/QueryDataConsumer.h @@ -67,13 +67,15 @@ namespace chaos{ chaos::data_service::worker::DataWorker **device_data_worker; //---------------- DirectIODeviceServerChannelHandler ----------------------- - int consumePutEvent(DirectIODeviceChannelHeaderPutOpcode& header, - chaos::common::data::BufferSPtr channel_data, - uint32_t channel_data_len); + int consumePutEvent(const std::string& key, + const uint8_t hst_tag, + const ChaosStringSetConstSPtr meta_tag_set, + chaos::common::data::BufferSPtr channel_data); - int consumeHealthDataEvent(DirectIODeviceChannelHeaderPutOpcode& header, - chaos::common::data::BufferSPtr channel_data, - uint32_t channel_data_len); + int consumeHealthDataEvent(const std::string& key, + const uint8_t hst_tag, + const ChaosStringSetConstSPtr meta_tag_set, + chaos::common::data::BufferSPtr channel_data); int consumeGetEvent(chaos::common::data::BufferSPtr key_data, uint32_t key_len, @@ -88,8 +90,9 @@ namespace chaos{ int consumeDataCloudQuery(opcode_headers::DirectIODeviceChannelHeaderOpcodeQueryDataCloud& query_header, const std::string& search_key, - uint64_t search_start_ts, - uint64_t search_end_ts, + const ChaosStringSet& meta_tags, + const uint64_t search_start_ts, + const uint64_t search_end_ts, opcode_headers::SearchSequence& last_element_found_seq, opcode_headers::QueryResultPage& page_element_found); diff --git a/ChaosMetadataService/api/control_unit/ControlUnitGroup.cpp b/ChaosMetadataService/api/control_unit/ControlUnitGroup.cpp index 8ef574028e242fecc9e138c676fda36b55dddbf5..71a44ebd024eed751a4e3fc447a90bac70a3a355 100644 --- a/ChaosMetadataService/api/control_unit/ControlUnitGroup.cpp +++ b/ChaosMetadataService/api/control_unit/ControlUnitGroup.cpp @@ -31,6 +31,7 @@ #include "CopyInstance.h" #include "RecoverError.h" #include "Delete.h" +#include "SendStorageBurst.h" using namespace chaos::metadata_service::api::control_unit; DEFINE_CLASS_FACTORY_NO_ALIAS(ControlUnitGroup, chaos::metadata_service::api::AbstractApiGroup); @@ -49,8 +50,9 @@ AbstractApiGroup("control_unit"){ addApi<CopyInstance>(); addApi<RecoverError>(); addApi<Delete>(); + addApi<SendStorageBurst>(); } ControlUnitGroup::~ControlUnitGroup() { -} \ No newline at end of file +} diff --git a/ChaosMetadataService/api/control_unit/SendStorageBurst.cpp b/ChaosMetadataService/api/control_unit/SendStorageBurst.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cfec2f654c9f005168582fead4ff734527f3a02d --- /dev/null +++ b/ChaosMetadataService/api/control_unit/SendStorageBurst.cpp @@ -0,0 +1,102 @@ +/* + * Copyright 2012, 03/07/2018 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 "SendStorageBurst.h" +#include "../../batch/node/SendRpcCommand.h" + +#include <chaos/common/chaos_constants.h> +#include <chaos/common/data/structured/Dataset.h> + +using namespace chaos::common::data; +using namespace chaos::common::data::structured; +using namespace chaos::metadata_service::api::control_unit; +using namespace chaos::metadata_service::persistence::data_access; + +#define CU_RNU_INFO INFO_LOG(RecoverError) +#define CU_RNU_DBG DBG_LOG(RecoverError) +#define CU_RNU_ERR ERR_LOG(RecoverError) + +SendStorageBurst::SendStorageBurst(): +AbstractApi("sendStorageBurst"){} + +SendStorageBurst::~SendStorageBurst() {} + +CDataWrapper *SendStorageBurst::execute(CDataWrapper *api_data, + bool& detach_data) throw(chaos::CException) { + CHECK_CDW_THROW_AND_LOG(api_data, CU_RNU_ERR, -1, "No parameter found") + CHECK_KEY_THROW_AND_LOG(api_data, chaos::NodeDefinitionKey::NODE_UNIQUE_ID , CU_RNU_ERR, -2, "The ndk_uid key is mandatory") + CHECK_ASSERTION_THROW_AND_LOG((!api_data->isVectorValue(chaos::NodeDefinitionKey::NODE_UNIQUE_ID) || + !api_data->isStringValue(chaos::NodeDefinitionKey::NODE_UNIQUE_ID)), CU_RNU_ERR, -3, "ndk_uid key need to be a vector of string"); + + //check burst information + DatasetBurstSDWrapper db_sdw; + db_sdw.deserialize(api_data); + CHECK_ASSERTION_THROW_AND_LOG(db_sdw().type != chaos::ControlUnitNodeDefinitionType::DSStorageBurstTypeUndefined, CU_RNU_ERR, -4, "The type of burst is mandatory"); + CHECK_ASSERTION_THROW_AND_LOG(db_sdw().value.isValid(), CU_RNU_ERR, -5, "The value ofburst is mandatory"); + + GET_DATA_ACCESS(ControlUnitDataAccess, cu_da, -4) + + int err = 0; + uint64_t command_id = 0; + bool presence = false; + std::string temp_node_uid; + ChaosStringVector control_unit_to_recover; + + if(api_data->isVector(chaos::NodeDefinitionKey::NODE_UNIQUE_ID)) { + CMultiTypeDataArrayWrapperSPtr control_unit_ids = api_data->getVectorValue(chaos::NodeDefinitionKey::NODE_UNIQUE_ID); + for(int idx = 0; idx < control_unit_ids->size(); idx++) { + temp_node_uid = control_unit_ids->getStringElementAtIndex(idx); + if((err = cu_da->checkPresence(temp_node_uid, presence))) { + CU_RNU_ERR << "Error checking the presence of control unit" << temp_node_uid << "with code:"<<err; + } else if(presence){ + control_unit_to_recover.push_back(temp_node_uid); + } else { + CU_RNU_ERR << "The control unit" << temp_node_uid << "is not present"; + } + } + } else { + const std::string node_uid = api_data->getStringValue(chaos::NodeDefinitionKey::NODE_UNIQUE_ID); + if((err = cu_da->checkPresence(node_uid, presence))) { + CU_RNU_ERR << "Error checking the presence of control unit" << temp_node_uid << "with code:"<<err; + } else if(presence){ + control_unit_to_recover.push_back(node_uid); + } else { + CU_RNU_ERR << "The control unit" << temp_node_uid << "is not present"; + } + } + + CDWUniquePtr burst_ser = db_sdw.serialize(); + for(ChaosStringVectorIterator it = control_unit_to_recover.begin(), + end = control_unit_to_recover.end(); + it!= end; + it++){ + ChaosUniquePtr<chaos::common::data::CDataWrapper> batch_data(new CDataWrapper()); + + batch_data->addStringValue(chaos::NodeDefinitionKey::NODE_UNIQUE_ID, *it); + batch_data->addStringValue(chaos::RpcActionDefinitionKey::CS_CMDM_ACTION_NAME, chaos::ControlUnitNodeDomainAndActionRPC::ACTION_STORAGE_BURST); + batch_data->addCSDataValue(chaos::RpcActionDefinitionKey::CS_CMDM_ACTION_MESSAGE, *burst_ser); + //launch the batch command + command_id = getBatchExecutor()->submitCommand(std::string(GET_MDS_COMMAND_ALIAS(batch::node::SendRpcCommand)), + batch_data.release()); + } + + return NULL; +} diff --git a/ChaosMetadataService/api/control_unit/SendStorageBurst.h b/ChaosMetadataService/api/control_unit/SendStorageBurst.h new file mode 100644 index 0000000000000000000000000000000000000000..0df0fede9ba4ed1f8b5384ef8e0160a273d7b40a --- /dev/null +++ b/ChaosMetadataService/api/control_unit/SendStorageBurst.h @@ -0,0 +1,45 @@ +/* + * Copyright 2012, 03/07/2018 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__SendStorageBurst_h +#define __CHAOSFramework__SendStorageBurst_h + +#include "../AbstractApi.h" + +namespace chaos { + namespace metadata_service { + namespace api { + namespace control_unit { + class SendStorageBurst: + public AbstractApi { + + public: + SendStorageBurst(); + ~SendStorageBurst(); + chaos::common::data::CDataWrapper *execute(chaos::common::data::CDataWrapper *api_data, + bool& detach_data) throw(chaos::CException); + }; + } + } + } +} + +#endif /* __CHAOSFramework__SendStorageBurst_h */ diff --git a/ChaosMetadataService/object_storage/abstraction/ObjectStorageDataAccess.h b/ChaosMetadataService/object_storage/abstraction/ObjectStorageDataAccess.h index 3662925e29eb338965072468a7912aae68b7900a..23dfce9ec4d1f55c5f1c8d15f7ed0bce34047c30 100644 --- a/ChaosMetadataService/object_storage/abstraction/ObjectStorageDataAccess.h +++ b/ChaosMetadataService/object_storage/abstraction/ObjectStorageDataAccess.h @@ -50,6 +50,7 @@ namespace chaos { //!Put an object within the object persistence layer virtual int pushObject(const std::string& key, + const ChaosStringSetConstSPtr meta_tags, const chaos::common::data::CDataWrapper& stored_object) = 0; //!Retrieve an object from the object persistence layer @@ -68,6 +69,7 @@ namespace chaos { //!search object into object persistence layer virtual int findObject(const std::string& key, + const ChaosStringSet& meta_tags, const uint64_t timestamp_from, const uint64_t timestamp_to, const uint32_t page_len, diff --git a/ChaosMetadataService/object_storage/mongodb/MongoDBObjectStorageDataAccess.cpp b/ChaosMetadataService/object_storage/mongodb/MongoDBObjectStorageDataAccess.cpp index fff176ffb2cbbcb325cc81c4e3fd4f11b676cd48..f18b97089533f1dfe17efcf9bcf099ab6f32dc7a 100644 --- a/ChaosMetadataService/object_storage/mongodb/MongoDBObjectStorageDataAccess.cpp +++ b/ChaosMetadataService/object_storage/mongodb/MongoDBObjectStorageDataAccess.cpp @@ -75,15 +75,27 @@ storage_write_concern(&mongo::WriteConcern::unacknowledged) { MongoDBObjectStorageDataAccess::~MongoDBObjectStorageDataAccess() {} int MongoDBObjectStorageDataAccess::pushObject(const std::string& key, + const ChaosStringSetConstSPtr meta_tags, const CDataWrapper& stored_object) { int err = 0; try { int buffer_size = 0; const int64_t now_in_ms = TimingUtil::getTimeStamp() & 0xFFFFFFFFFFFFFF00; const char *buffer = stored_object.getBSONRawData(buffer_size); + //add tags + mongo::BSONArrayBuilder tag_array_builder; mongo::BSONObjBuilder insert_builder; insert_builder << chaos::DataPackCommonKey::DPCK_DEVICE_ID << key << chaos::DataPackCommonKey::DPCK_TIMESTAMP << mongo::Date_t(now_in_ms); + if(meta_tags && meta_tags->size()) { + for(ChaosStringSetConstIterator it = meta_tags->begin(), + end = meta_tags->end(); + it != end; + it++){ + tag_array_builder << *it; + } + } + insert_builder << chaos::DataPackCommonKey::DPCK_DATASET_TAGS << tag_array_builder.arr(); //add zone sharding information mongo::BSONObj zone_pack = shrd_key_manager.getNewDataPack(key, now_in_ms, @@ -197,7 +209,7 @@ int MongoDBObjectStorageDataAccess::deleteObject(const std::string& key, end_timestamp) { builder << chaos::DataPackCommonKey::DPCK_TIMESTAMP << time_query_builder.obj(); } - + builder << "$or" << BSON_ARRAY(BSON(chaos::DataPackCommonKey::DPCK_DATASET_TAGS << BSON("$exists" << false)) << BSON(chaos::DataPackCommonKey::DPCK_DATASET_TAGS << BSON("$eq" << mongo::BSONArrayBuilder().arr()))); mongo::BSONObj q = builder.obj(); DEBUG_CODE(DBG<<log_message("deleteObject", @@ -219,8 +231,9 @@ int MongoDBObjectStorageDataAccess::deleteObject(const std::string& key, } int MongoDBObjectStorageDataAccess::findObject(const std::string& key, - uint64_t timestamp_from, - uint64_t timestamp_to, + const ChaosStringSet& meta_tags, + const uint64_t timestamp_from, + const uint64_t timestamp_to, const uint32_t page_len, object_storage::abstraction::VectorObject& found_object_page, SearchSequence& last_record_found_seq) { @@ -228,6 +241,7 @@ int MongoDBObjectStorageDataAccess::findObject(const std::string& key, std::vector<mongo::BSONObj> object_found; try { mongo::Query q; + mongo::BSONObjBuilder q_builder; bool reverse_order = false; const std::string run_key = CHAOS_FORMAT("%1%.%2%",%MONGODB_DAQ_DATA_FIELD%chaos::ControlUnitDatapackCommonKey::RUN_ID); const std::string counter_key = CHAOS_FORMAT("%1%.%2%",%MONGODB_DAQ_DATA_FIELD%chaos::DataPackCommonKey::DPCK_SEQ_ID); @@ -235,19 +249,29 @@ int MongoDBObjectStorageDataAccess::findObject(const std::string& key, reverse_order = timestamp_from>timestamp_to; if(reverse_order == false) { - q = BSON(chaos::DataPackCommonKey::DPCK_DEVICE_ID << key << + q_builder << chaos::DataPackCommonKey::DPCK_DEVICE_ID << key << chaos::DataPackCommonKey::DPCK_TIMESTAMP << BSON("$gte" << mongo::Date_t(timestamp_from) << "$lte" << mongo::Date_t(timestamp_to)) << run_key << BSON("$gte" << (long long)last_record_found_seq.run_id) << - counter_key << BSON("$gte" << (long long)last_record_found_seq.datapack_counter)); + counter_key << BSON("$gte" << (long long)last_record_found_seq.datapack_counter); } else { - BSON(chaos::DataPackCommonKey::DPCK_DEVICE_ID << key << + q_builder << chaos::DataPackCommonKey::DPCK_DEVICE_ID << key << chaos::DataPackCommonKey::DPCK_TIMESTAMP << BSON("$lte" << mongo::Date_t(timestamp_from) << "$gte" << mongo::Date_t(timestamp_to)) << run_key << BSON("$lte" << (long long)last_record_found_seq.run_id) << - counter_key << BSON("$lte" << (long long)last_record_found_seq.datapack_counter)); + counter_key << BSON("$lte" << (long long)last_record_found_seq.datapack_counter); + } + + //add tags + if(meta_tags.size()) { + mongo::BSONArrayBuilder tags_arr_b; + for(auto& it: meta_tags) { + tags_arr_b << it; + } + q_builder << chaos::DataPackCommonKey::DPCK_DATASET_TAGS << BSON("$all" << tags_arr_b.arr()); } + q = q_builder.obj(); if(reverse_order) { q = q.sort(BSON(run_key<<-1<<counter_key<<-1<<chaos::DataPackCommonKey::DPCK_TIMESTAMP<<-1)); } else { @@ -276,12 +300,10 @@ int MongoDBObjectStorageDataAccess::findObject(const std::string& key, } if( object_found[object_found.size()-1].getFieldDotted(run_key).type()==mongo::NumberInt){ last_record_found_seq.run_id = object_found[object_found.size()-1].getFieldDotted(run_key).Number(); - } else { last_record_found_seq.run_id = object_found[object_found.size()-1].getFieldDotted(run_key).Long(); } - if( object_found[object_found.size()-1].getFieldDotted(counter_key).type()==mongo::NumberInt){ last_record_found_seq.datapack_counter = object_found[object_found.size()-1].getFieldDotted(counter_key).Number(); diff --git a/ChaosMetadataService/object_storage/mongodb/MongoDBObjectStorageDataAccess.h b/ChaosMetadataService/object_storage/mongodb/MongoDBObjectStorageDataAccess.h index cb5b6fc30891a55f0f9bf55eebfc3237830b223c..320aef162b460054e4f5506fd799caeed8c25be0 100644 --- a/ChaosMetadataService/object_storage/mongodb/MongoDBObjectStorageDataAccess.h +++ b/ChaosMetadataService/object_storage/mongodb/MongoDBObjectStorageDataAccess.h @@ -56,6 +56,7 @@ namespace chaos { public: //inhertied method int pushObject(const std::string& key, + const ChaosStringSetConstSPtr meta_tags, const chaos::common::data::CDataWrapper& stored_object); //inhertied method @@ -72,8 +73,9 @@ namespace chaos { uint64_t end_timestamp); //inhertied method int findObject(const std::string& key, - uint64_t timestamp_from, - uint64_t timestamp_to, + const ChaosStringSet& meta_tags, + const uint64_t timestamp_from, + const uint64_t timestamp_to, const uint32_t page_len, object_storage::abstraction::VectorObject& found_object_page, common::direct_io::channel::opcode_headers::SearchSequence& last_record_found_seq); diff --git a/ChaosMetadataService/persistence/mongodb/MongoDBControlUnitDataAccess.cpp b/ChaosMetadataService/persistence/mongodb/MongoDBControlUnitDataAccess.cpp index 056724795edf521a2098e7142cb06a812c8f30e5..87f60c4c8d9c28e0a31121cc3955269373d30eb4 100644 --- a/ChaosMetadataService/persistence/mongodb/MongoDBControlUnitDataAccess.cpp +++ b/ChaosMetadataService/persistence/mongodb/MongoDBControlUnitDataAccess.cpp @@ -1175,8 +1175,8 @@ int MongoDBControlUnitDataAccess::eraseControlUnitDataBeforeTS(const std::string int err = 0; try { mongo::BSONObj q = BSON(chaos::DataPackCommonKey::DPCK_DEVICE_ID << control_unit_id << - DataPackCommonKey::DPCK_TIMESTAMP << BSON( "$lte" << mongo::Date_t(unit_ts))); - + DataPackCommonKey::DPCK_TIMESTAMP << BSON( "$lte" << mongo::Date_t(unit_ts)) << + "$or" << BSON_ARRAY(BSON(chaos::DataPackCommonKey::DPCK_DATASET_TAGS << BSON("$exists" << false)) << BSON(chaos::DataPackCommonKey::DPCK_DATASET_TAGS << BSON("$eq" << mongo::BSONArrayBuilder().arr())))); DEBUG_CODE(MDBCUDA_DBG<<log_message("eraseControlUnitDataBeforeTS", "delete", DATA_ACCESS_LOG_1_ENTRY("Query", diff --git a/ChaosMetadataService/worker/DeviceSharedDataWorker.cpp b/ChaosMetadataService/worker/DeviceSharedDataWorker.cpp index 13f6c69b2bab7f7651c66132bc0867b28eca79df..1ab5bcad64f72ec2690f878ea11974de0595e358 100644 --- a/ChaosMetadataService/worker/DeviceSharedDataWorker.cpp +++ b/ChaosMetadataService/worker/DeviceSharedDataWorker.cpp @@ -84,6 +84,7 @@ void DeviceSharedDataWorker::executeJob(WorkerJobPtr job_info, void* cookie) { CDataWrapper data_pack((char *)job.data_pack->data()); //push received datapack into object storage if((err = obj_storage_da->pushObject(job.key, + ChaosMoveOperator(job.meta_tag), data_pack))) { ERR << "Error pushing datapack into object storage driver"; } diff --git a/ChaosMetadataService/worker/DeviceSharedDataWorker.h b/ChaosMetadataService/worker/DeviceSharedDataWorker.h index b0cfa358c5cb200914bd2f314ef4c9e6cc83dd7a..f2c4e0b9a606872c1b4b95781c8b9ce61f173d20 100644 --- a/ChaosMetadataService/worker/DeviceSharedDataWorker.h +++ b/ChaosMetadataService/worker/DeviceSharedDataWorker.h @@ -47,8 +47,8 @@ namespace chaos{ public WorkerJob { uint8_t key_tag; std::string key; - int put_operation; //0 -storicize only, 1-live only, 2-storicize and live - uint32_t data_pack_len; + int put_operation; //0 -storicize only, 1-live only, 2-storicize and liveb + ChaosStringSetConstSPtr meta_tag; chaos::common::data::BufferSPtr data_pack; }; diff --git a/ChaosMetadataService/worker/DeviceSharedDataWorkerMetricCollector.cpp b/ChaosMetadataService/worker/DeviceSharedDataWorkerMetricCollector.cpp index ee3d2a553cb475cdc3982a6f84c566d41124022d..732aa76290c89f87d5c7c41f72120feb87d971d8 100644 --- a/ChaosMetadataService/worker/DeviceSharedDataWorkerMetricCollector.cpp +++ b/ChaosMetadataService/worker/DeviceSharedDataWorkerMetricCollector.cpp @@ -37,7 +37,7 @@ 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 = job.data_pack_len + (uint32_t)job.key.size(); + 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 @@ -58,7 +58,7 @@ int DeviceSharedDataWorkerMetricCollector::submitJobInfo(WorkerJobPtr job_info) int err = 0; DeviceSharedWorkerJob& job = *reinterpret_cast<DeviceSharedWorkerJob*>(job_info.get()); int tag = job.key_tag; - uint32_t total_data = job.data_pack_len + (uint32_t)job.key.size(); + uint32_t total_data = (uint32_t)job.data_pack->size() + (uint32_t)job.key.size(); data_worker_metric->incrementInputBandwith(total_data); switch(tag) { diff --git a/ccs/ccs.pro b/ccs/ccs.pro index 33834b655e97d32b8a05fcaff424df76229dbeeb..1a5419e348bb932de5b50528216d746b4f86e3be 100644 --- a/ccs/ccs.pro +++ b/ccs/ccs.pro @@ -188,7 +188,8 @@ SOURCES += main.cpp\ node/connection_manager/ConnectionEditor.cpp \ node/connection_manager/model/ControlUnitNodeDataModel.cpp \ language_editor/LuaLanguageSupport.cpp \ - language_editor/CLINGLanguageSupport.cpp + language_editor/CLINGLanguageSupport.cpp \ + widget/StorageBurst.cpp HEADERS += \ search/SearchNodeResult.h \ @@ -365,7 +366,8 @@ HEADERS += \ node/connection_manager/model/ControlUnitNodeDataModel.h \ language_editor/LanguageEditorSupport.h \ language_editor/LuaLanguageSupport.h \ - language_editor/CLINGLanguageSupport.h + language_editor/CLINGLanguageSupport.h \ + widget/StorageBurst.h FORMS += \ search/searchnoderesult.ui \ @@ -408,7 +410,8 @@ FORMS += \ widget/CPopupWidgetContainer.ui \ widget/ChaosStorageTypeWidget.ui \ preference/SelectNetworkDomain.ui \ - node/connection_manager/ConnectionEditor.ui + node/connection_manager/ConnectionEditor.ui \ + widget/StorageBurst.ui DISTFILES += \ dark_orange.stylesheet \ diff --git a/ccs/node/control_unit/ControUnitInstanceEditor.ui b/ccs/node/control_unit/ControUnitInstanceEditor.ui index 520dda13238b36b983db93c49d0298bbb77fdc4c..464b3da5556a409d9468597795399d4c55d94fd0 100644 --- a/ccs/node/control_unit/ControUnitInstanceEditor.ui +++ b/ccs/node/control_unit/ControUnitInstanceEditor.ui @@ -158,7 +158,7 @@ <enum>QTabWidget::North</enum> </property> <property name="currentIndex"> - <number>0</number> + <number>2</number> </property> <property name="usesScrollButtons"> <bool>true</bool> @@ -613,26 +613,26 @@ </size> </property> <property name="currentIndex"> - <number>3</number> + <number>0</number> </property> <item> <property name="text"> - <string>History</string> + <string>Not Set</string> </property> </item> <item> <property name="text"> - <string>Live</string> + <string>History</string> </property> </item> <item> <property name="text"> - <string>History & Live</string> + <string>Live</string> </property> </item> <item> <property name="text"> - <string>Not Set</string> + <string>History & Live</string> </property> </item> </widget> diff --git a/ccs/node/control_unit/ControlUnitEditor.ui b/ccs/node/control_unit/ControlUnitEditor.ui index 0225b5bb87a9ae814f23612f9e8f4226c52a01b4..3b41c3ad9d1317ecb56015a76630505400b18a06 100644 --- a/ccs/node/control_unit/ControlUnitEditor.ui +++ b/ccs/node/control_unit/ControlUnitEditor.ui @@ -1031,13 +1031,13 @@ <widget class="ChaosStorageTypeWidget" name="widgetStorageType" native="true"> <property name="minimumSize"> <size> - <width>110</width> + <width>130</width> <height>20</height> </size> </property> <property name="maximumSize"> <size> - <width>110</width> + <width>130</width> <height>20</height> </size> </property> diff --git a/ccs/widget/ChaosStorageTypeWidget.cpp b/ccs/widget/ChaosStorageTypeWidget.cpp index de58ae12fbbcefe9aa772e1f4a29aecd20eec0ef..fd26896488bbdd9156fbd177b0869fa6fae5bdd7 100644 --- a/ccs/widget/ChaosStorageTypeWidget.cpp +++ b/ccs/widget/ChaosStorageTypeWidget.cpp @@ -1,6 +1,7 @@ #include "ChaosStorageTypeWidget.h" #include "CPropertyTextEdit.h" #include "CPopupWidgetContainer.h" +#include "StorageBurst.h" #include "ui_ChaosStorageTypeWidget.h" #include <QDebug> @@ -210,3 +211,14 @@ void ChaosStorageTypeWidget::on_pushButtonEdit_clicked() { wc->setWindowModality(Qt::WindowModal); wc->show(); } + +void ChaosStorageTypeWidget::on_pushButton_clicked() { + CPopupWidgetContainer *wc = new CPopupWidgetContainer(this); + StorageBurst *sb = new StorageBurst(wc); + sb->setNodeUID(nodeUID()); + wc->addWidget(sb); + QRect rect = QRect(0,0,parentWidget()->width(),0); + wc->setGeometry(rect); + wc->setWindowModality(Qt::WindowModal); + wc->show(); +} diff --git a/ccs/widget/ChaosStorageTypeWidget.h b/ccs/widget/ChaosStorageTypeWidget.h index a40d043f9828ca4891017d65557e88b6fe737bdf..5b86660b245f074890ec84d02c7f13d8ddb80b24 100644 --- a/ccs/widget/ChaosStorageTypeWidget.h +++ b/ccs/widget/ChaosStorageTypeWidget.h @@ -38,6 +38,8 @@ private slots: void on_pushButtonEdit_clicked(); + void on_pushButton_clicked(); + private: bool data_found; QString last_pushbutton_in_error; diff --git a/ccs/widget/ChaosStorageTypeWidget.ui b/ccs/widget/ChaosStorageTypeWidget.ui index 694b90bf3474cee7f4dbd466537bf23120f922cd..419778dbe18a1f62f9180022d2caaa7b9932d2d4 100644 --- a/ccs/widget/ChaosStorageTypeWidget.ui +++ b/ccs/widget/ChaosStorageTypeWidget.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>166</width> + <width>130</width> <height>22</height> </rect> </property> @@ -18,7 +18,7 @@ </property> <property name="minimumSize"> <size> - <width>110</width> + <width>130</width> <height>22</height> </size> </property> @@ -203,6 +203,24 @@ </property> </widget> </item> + <item> + <widget class="QPushButton" name="pushButton"> + <property name="maximumSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>11</pointsize> + </font> + </property> + <property name="text"> + <string>B</string> + </property> + </widget> + </item> </layout> </widget> <customwidgets> diff --git a/ccs/widget/StorageBurst.cpp b/ccs/widget/StorageBurst.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cb02e62fe454c26a56ced9088a0412a6f0ca119e --- /dev/null +++ b/ccs/widget/StorageBurst.cpp @@ -0,0 +1,53 @@ +#include "StorageBurst.h" +#include "ui_StorageBurst.h" +#include <chaos/common/data/CDataVariant.h> +#include <chaos/common/data/structured/Dataset.h> + +using namespace chaos::common::data; +using namespace chaos::common::data::structured; + +StorageBurst::StorageBurst(QWidget *parent) : + QWidget(parent), + ui(new Ui::StorageBurst) { + ui->setupUi(this); + ui->comboBoxType->clear(); + ui->comboBoxType->addItem("Push", QVariant(chaos::ControlUnitNodeDefinitionType::DSStorageBurstTypeNPush)); + ui->comboBoxType->addItem("Millliseconds", QVariant(chaos::ControlUnitNodeDefinitionType::DSStorageBurstTypeMSec)); +} + +StorageBurst::~StorageBurst() { + delete ui; +} + +void StorageBurst::on_comboBox_currentIndexChanged(const QString &selected_item) { + if(selected_item.compare("Push") == 0) { + ui->lineEditValue->setPlaceholderText("Number of pushes[up to 10000]"); + ui->lineEditValue->setValidator(new QIntValidator(1, 10000, ui->lineEditValue)); + } else if(selected_item.compare("Timed")) { + ui->lineEditValue->setPlaceholderText("Number of milliseconds[up to 1h]"); + ui->lineEditValue->setValidator(new QIntValidator(1, 1000*60*60, ui->lineEditValue)); + } +} + +void StorageBurst::apiHasStarted(const QString& api_tag) { + setEnabled(false); +} + +void StorageBurst::apiHasEnded(const QString& api_tag) { + setEnabled(true); +} + +void StorageBurst::apiHasEndedWithError(const QString& api_tag, + QSharedPointer<chaos::CException> api_exception) { + setEnabled(true); +} + +void StorageBurst::on_pushButtonSubmit_clicked() { + chaos::common::data::structured::DatasetBurst ds_burst; + ds_burst.type = static_cast<chaos::ControlUnitNodeDefinitionType::DSStorageBurstType>(ui->comboBoxType->currentData().toInt()); + ds_burst.value = CDataVariant(ui->lineEditValue->text().toInt()); + ds_burst.tag = ui->lineEditTagName->text().toStdString(); + submitApiResult("submit_burst", + GET_CHAOS_API_PTR(chaos::metadata_service_client::api_proxy::control_unit::SendStorageBurst)->execute(nodeUID().toStdString(), + ds_burst)); +} diff --git a/ccs/widget/StorageBurst.h b/ccs/widget/StorageBurst.h new file mode 100644 index 0000000000000000000000000000000000000000..87ba324e8d90e389b463f4e681d8a73f42104b63 --- /dev/null +++ b/ccs/widget/StorageBurst.h @@ -0,0 +1,32 @@ +#ifndef STORAGEBURST_H +#define STORAGEBURST_H + +#include <QWidget> +#include "ChaosWidgetCompanion.h" +namespace Ui { +class StorageBurst; +} + +class StorageBurst : + public QWidget, + public ChaosWidgetCompanion { + Q_OBJECT + +public: + explicit StorageBurst(QWidget *parent = 0); + ~StorageBurst(); + +private slots: + void on_comboBox_currentIndexChanged(const QString &selected_item); + + void on_pushButtonSubmit_clicked(); + +private: + void apiHasStarted(const QString& api_tag); + void apiHasEnded(const QString& api_tag); + void apiHasEndedWithError(const QString& api_tag, + QSharedPointer<chaos::CException> api_exception); + Ui::StorageBurst *ui; +}; + +#endif // STORAGEBURST_H diff --git a/ccs/widget/StorageBurst.ui b/ccs/widget/StorageBurst.ui new file mode 100644 index 0000000000000000000000000000000000000000..10ae57e97c9c93bc462ebc806773410396c5337f --- /dev/null +++ b/ccs/widget/StorageBurst.ui @@ -0,0 +1,168 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>StorageBurst</class> + <widget class="QWidget" name="StorageBurst"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>320</width> + <height>108</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>320</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>108</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>11</pointsize> + </font> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QFormLayout" name="formLayout"> + <property name="sizeConstraint"> + <enum>QLayout::SetDefaultConstraint</enum> + </property> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::AllNonFixedFieldsGrow</enum> + </property> + <property name="labelAlignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="horizontalSpacing"> + <number>4</number> + </property> + <property name="verticalSpacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>4</number> + </property> + <property name="topMargin"> + <number>4</number> + </property> + <property name="rightMargin"> + <number>4</number> + </property> + <property name="bottomMargin"> + <number>4</number> + </property> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="font"> + <font> + <pointsize>11</pointsize> + </font> + </property> + <property name="text"> + <string>Type:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="comboBoxType"> + <item> + <property name="text"> + <string extracomment="Execute the burst for a number of determinated pushes">Push</string> + </property> + </item> + <item> + <property name="text"> + <string extracomment="Execute the burst for a determinated number of milliseconds">Timed</string> + </property> + </item> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label"> + <property name="font"> + <font> + <pointsize>11</pointsize> + </font> + </property> + <property name="text"> + <string>Tag:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="lineEditTagName"> + <property name="placeholderText"> + <string>tag name</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_3"> + <property name="font"> + <font> + <pointsize>11</pointsize> + </font> + </property> + <property name="text"> + <string>Value:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLineEdit" name="lineEditValue"> + <property name="placeholderText"> + <string>value</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pushButtonSubmit"> + <property name="text"> + <string>Submit</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/chaos/common/chaos_constants.h b/chaos/common/chaos_constants.h index 3501140973750f258b94828931a6db9a6a8b9e51..28f62a6f72afc7bcf19f8480c3ee05b58e60c194 100644 --- a/chaos/common/chaos_constants.h +++ b/chaos/common/chaos_constants.h @@ -623,6 +623,7 @@ namespace chaos { store another datapack into the live system[uint64] */ static const char * const DS_STORAGE_LIVE_TIME = "dsndk_storage_live_time"; + } /** @} */ // end of DataServiceNodeDefinitionKey @@ -637,14 +638,14 @@ namespace chaos { so every datapack can be considere with different store behaviour */ typedef enum DSStorageType { + //!no storage behaviour defined + DSStorageTypeUndefined = 0, //!the datapack is store into the storage system and not in live - DSStorageTypeHistory, + DSStorageTypeHistory = 1, //!the datapack is publish in live shared memory - DSStorageTypeLive, + DSStorageTypeLive = 2, //!datapack is published and stored in live and history - DSStorageTypeLiveHistory, - //!no storage behaviour defined - DSStorageTypeUndefined + DSStorageTypeLiveHistory = 3 } DSStorageType; } /** @} */ // end of DataServiceNodeDefinitionType @@ -744,12 +745,41 @@ namespace chaos { //!The key represent an array with the object taht represent, each one, the command description array[object...] static const char * const CONTROL_UNIT_DATASET_COMMAND_DESCRIPTION = "cudk_ds_command_description"; + /*! + Whatever storage type is actually in use, the set of this property will send data to + the history engine with the type and value specified by the cdata wrapper seriled in it + */ + static const char * const CONTROL_UNIT_DATASET_HISTORY_BURST = "dsndk_history_burst"; + //! Is the key used for specify the type f burts function + static const char * const CONTROL_UNIT_DATASET_HISTORY_BURST_TYPE = "dsndk_history_burst_type"; + //! is the value related to the type + static const char * const CONTROL_UNIT_DATASET_HISTORY_BURST_VALUE = "dsndk_history_burst_value"; + //! is the tag associated to the burst + static const char * const CONTROL_UNIT_DATASET_HISTORY_BURST_TAG = "dsndk_history_burst_tag"; } /** @} */ // end of ControlUnitNodeDefinitionKey + /** @defgroup ControlUnitNodeDefinitionKey List of control unit node type attribute key + * @{ + */ + //! Name space for grupping key for the control unit node type + namespace ControlUnitNodeDefinitionType { + //! define the tipe of hisoty burst function + typedef enum DSStorageBurstType { + //!no storage behaviour defined + DSStorageBurstTypeUndefined = 0, + DSStorageBurstTypeNPush, + DSStorageBurstTypeMSec + } DSStorageBurstType; + } + /** @} */ // end of ControlUnitNodeDefinitionKey namespace ControlUnitNodeDomainAndActionRPC { //!Alias associated to thefunction that apply the value changes set to the input dataset attribute static const char * const CONTROL_UNIT_APPLY_INPUT_DATASET_ATTRIBUTE_CHANGE_SET = "cunrpc_ida_cs"; + + //! Deinitialization of a control unit, if it is in run, the stop phase + //! is started befor deinitialization one + static const char * const ACTION_STORAGE_BURST = "cunrpc_start_storage_burst"; } /** @defgroup ExecutionUnitNodeDefinitionKey List of execution unit node type attribute key @@ -1201,6 +1231,8 @@ namespace chaos { static const char * const DPCK_HIGH_RESOLUTION_TIMESTAMP = "dpck_hr_ats";//chaos::NodeDefinitionKey::NODE_TIMESTAMP; //!define the type of the dataset uint32_t [output(0) - input(1) - custom(2) - system(3) - ....others int32_t] static const char * const DPCK_DATASET_TYPE = "dpck_ds_type"; + //!define the list of tags associated to the datapack + static const char * const DPCK_DATASET_TAGS = "dpck_ds_tag"; //! the constant that represent the output dataset type static const unsigned int DPCK_DATASET_TYPE_OUTPUT = 0; //! the constant that represent the input dataset type @@ -1215,6 +1247,8 @@ namespace chaos { static const unsigned int DPCK_DATASET_TYPE_DEV_ALARM = 5; //! the constant that represent the alarm dataset type static const unsigned int DPCK_DATASET_TYPE_CU_ALARM = 6; + //!define tags associated to the dataset[array of string] + static const char * const DPCK_DATASET_TAG = "dpck_ds_tag"; } diff --git a/chaos/common/chaos_types.h b/chaos/common/chaos_types.h index 40a9217a487bd119c934d1abdaa4ee54ef3039b1..42397c9d4eb7be473c8b44c61343c7d498c8bc97 100644 --- a/chaos/common/chaos_types.h +++ b/chaos/common/chaos_types.h @@ -133,8 +133,8 @@ typedef typename std::vector< t >::iterator n ## Iterator;\ typedef typename std::vector< t >::const_iterator n ## ConstIterator; #define CHAOS_DEFINE_QUEUE_FOR_TYPE(t, n)\ -typedef std::queue< t > n;\ -typedef std::queue< t >::iterator n ## Iterator; +typedef std::queue< t > n; +//typedef std::queue< t >::iterator n ## Iterator; //typedef std::queue< t >::const_iterator n ## ConstIterator; #define CHAOS_DEFINE_DEQUE_FOR_TYPE(t, n)\ @@ -173,7 +173,16 @@ typedef boost::ptr_map< t1, t2 >::const_iterator n ## ConstIterator; dynamic_cast<element_type*>(&map.at(element_key)); CHAOS_DEFINE_VECTOR_FOR_TYPE(std::string, ChaosStringVector) +typedef ChaosUniquePtr<ChaosStringVector> ChaosStringVectorUPtr; +typedef ChaosSharedPtr<ChaosStringVector> ChaosStringVectorSPtr; +typedef ChaosUniquePtr<const ChaosStringVector> ChaosStringVectorConstUPtr; +typedef ChaosSharedPtr<const ChaosStringVector> ChaosStringVectorConstSPtr; + CHAOS_DEFINE_SET_FOR_TYPE(std::string, ChaosStringSet) +typedef ChaosUniquePtr<ChaosStringSet> ChaosStringSetUPtr; +typedef ChaosSharedPtr<ChaosStringSet> ChaosStringSetSPtr; +typedef ChaosUniquePtr<const ChaosStringSet> ChaosStringSetConstUPtr; +typedef ChaosSharedPtr<const ChaosStringSet> ChaosStringSetConstSPtr; #define CHAOS_SCAN_VECTOR_ITERATOR(iter, vec, to_execute)\ for(iter it = vec.begin();\ diff --git a/chaos/common/data/CDataBuffer.cpp b/chaos/common/data/CDataBuffer.cpp index 4340fea2fe704f67bb181de810c16b4d6c300a7d..1b39ec3920f79cb34b64465828b2e17bbff97e8f 100644 --- a/chaos/common/data/CDataBuffer.cpp +++ b/chaos/common/data/CDataBuffer.cpp @@ -26,45 +26,35 @@ using namespace chaos::common::data; CDataBuffer::CDataBuffer(): - own_buffer(false), - buffer_size(0), - buffer(NULL) { } + internal_buffer(){} CDataBuffer::CDataBuffer(const char *_buffer, - uint32_t _buffer_size, - bool copy): -own_buffer(copy) { - buffer_size = _buffer_size; - if(copy) { - buffer = new char[_buffer_size]; - memcpy(buffer, _buffer, buffer_size); - } else { - buffer = (char*)_buffer; - } -} + uint32_t _buffer_size): +internal_buffer(_buffer, + _buffer_size){} + +CDataBuffer::CDataBuffer(char *buffer, + uint32_t buffer_size, + bool own): +internal_buffer(buffer, + buffer_size, + buffer_size, + true){} CDataBuffer::CDataBuffer(const CDataBuffer& cdata_buffer): -own_buffer(cdata_buffer.own_buffer), -buffer(cdata_buffer.buffer), -buffer_size(cdata_buffer.buffer_size){} +internal_buffer(cdata_buffer.internal_buffer){} -CDataBuffer::~CDataBuffer() { - if(own_buffer) delete(buffer); -} +CDataBuffer::~CDataBuffer() {} const char *CDataBuffer::getBuffer() const { - return buffer; + return internal_buffer.data(); } -uint32_t CDataBuffer::getBufferSize() const { - return buffer_size; +std::size_t CDataBuffer::getBufferSize() const { + return internal_buffer.size(); } -CDataBuffer *CDataBuffer::newOwnBufferFromBuffer(char * buffer, - uint32_t _buffer_size) { - CDataBuffer *result = new CDataBuffer(); - result->own_buffer = true; - result->buffer = buffer; - result->buffer_size = _buffer_size; - return result; +CDBufferUniquePtr CDataBuffer::newOwnBufferFromBuffer(char * buffer, + uint32_t _buffer_size) { + return CDBufferUniquePtr(new CDataBuffer(buffer, _buffer_size, true)); } diff --git a/chaos/common/data/CDataBuffer.h b/chaos/common/data/CDataBuffer.h index 0ed8126a4813ef93ab7d558fb241e18a4206a978..4f04751dc890edbd99ee84d33d89e3c75f844de8 100644 --- a/chaos/common/data/CDataBuffer.h +++ b/chaos/common/data/CDataBuffer.h @@ -23,37 +23,39 @@ #define __CHAOSFramework__CDataBuffer_h #include <chaos/common/chaos_types.h> - +#include <chaos/common/data/Buffer.hpp> #include <stdint.h> namespace chaos { namespace common { namespace data { + class CDataBuffer; + + typedef ChaosUniquePtr<chaos::common::data::CDataBuffer> CDBufferUniquePtr; + typedef ChaosSharedPtr<chaos::common::data::CDataBuffer> CDBufferShrdPtr; class CDataBuffer { - bool own_buffer; - char * buffer; - uint32_t buffer_size; - + Buffer internal_buffer; + CDataBuffer(char *buffer, + uint32_t buffer_size, + bool own); public: CDataBuffer(); CDataBuffer(const char *buffer, - uint32_t buffer_size, - bool copy = false); + uint32_t buffer_size); CDataBuffer(const CDataBuffer& cdata_buffer); ~CDataBuffer(); const char *getBuffer() const; - uint32_t getBufferSize() const; + std::size_t getBufferSize() const; - static CDataBuffer *newOwnBufferFromBuffer(char * buffer, - uint32_t _buffer_size); + static CDBufferUniquePtr newOwnBufferFromBuffer(char * buffer, + uint32_t _buffer_size); }; - typedef ChaosUniquePtr<chaos::common::data::CDataBuffer> CDBufferUniquePtr; - typedef ChaosSharedPtr<chaos::common::data::CDataBuffer> CDBufferShrdPtr; + } } } diff --git a/chaos/common/data/CDataVariant.cpp b/chaos/common/data/CDataVariant.cpp index 34d95666eb7a57a930add7630448b5f9039aebab..38c4f0f06001183040bbd8e9b0efdc061a648604 100644 --- a/chaos/common/data/CDataVariant.cpp +++ b/chaos/common/data/CDataVariant.cpp @@ -122,15 +122,15 @@ std::string string_visitor::operator()(const ChaosSharedPtr<CDataWrapper>& buffe #pragma mark CDataBuffervisitor -ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const bool bv) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer((const char*)&bv,sizeof(bool),true));} -ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const int32_t i32v) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer((const char*)&i32v,sizeof(int32_t),true));} -ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const uint32_t ui32v) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer((const char*)&ui32v,sizeof(uint32_t),true));} -ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const int64_t i64v) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer((const char*)&i64v,sizeof(int64_t),true));} -ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const uint64_t ui64v) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer((const char*)&ui64v,sizeof(uint64_t),true));} -ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const double dv) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer((const char*)&dv,sizeof(double),true));} -ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const std::string& str) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer(str.c_str(), (uint32_t)str.size(), true));} +ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const bool bv) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer((const char*)&bv,sizeof(bool)));} +ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const int32_t i32v) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer((const char*)&i32v,sizeof(int32_t)));} +ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const uint32_t ui32v) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer((const char*)&ui32v,sizeof(uint32_t)));} +ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const int64_t i64v) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer((const char*)&i64v,sizeof(int64_t)));} +ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const uint64_t ui64v) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer((const char*)&ui64v,sizeof(uint64_t)));} +ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const double dv) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer((const char*)&dv,sizeof(double)));} +ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const std::string& str) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer(str.c_str(), (uint32_t)str.size()));} ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const ChaosSharedPtr<CDataBuffer>& buffer) const {return buffer;} -ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const ChaosSharedPtr<CDataWrapper>& buffer) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer(buffer->getJSONString().c_str(), (uint32_t)buffer->getJSONString().size(), true));;} +ChaosSharedPtr<CDataBuffer> CDataBuffer_visitor::operator()(const ChaosSharedPtr<CDataWrapper>& buffer) const {return ChaosSharedPtr<CDataBuffer>(new CDataBuffer(buffer->getJSONString().c_str(), (uint32_t)buffer->getJSONString().size()));} #pragma mark CDataWrappervisitor ChaosSharedPtr<CDataWrapper> CDataWrapper_visitor::operator()(const bool bv) const {throw CFatalException(-1,"invalid conversion to CDataWrapper from bool",__PRETTY_FUNCTION__);return ChaosSharedPtr<CDataWrapper>(new CDataWrapper());} @@ -187,9 +187,9 @@ CDataVariant::CDataVariant(const char * string_value):_internal_variant(std::str } } -CDataVariant::CDataVariant(CDataBuffer *buffer_value): +CDataVariant::CDataVariant(CDBufferUniquePtr buffer_value): type(DataType::TYPE_BYTEARRAY), -_internal_variant(ChaosSharedPtr<CDataBuffer>(buffer_value)) { } +_internal_variant(ChaosSharedPtr<CDataBuffer>(buffer_value.release())) { } CDataVariant::CDataVariant(CDataWrapper *buffer_value): type(DataType::TYPE_CLUSTER), @@ -237,8 +237,7 @@ type(_type){ } case DataType::TYPE_BYTEARRAY:{ _internal_variant = ChaosSharedPtr<CDataBuffer>(new CDataBuffer(static_cast<const char*>(_value_pointer), - _value_size, - true)); + _value_size)); break; } default: diff --git a/chaos/common/data/CDataVariant.h b/chaos/common/data/CDataVariant.h index 37d35c8221a169b2abbbc2aee2a568a7878d49b3..717d0a0298d95470848870412f4606e2cf8552a3 100644 --- a/chaos/common/data/CDataVariant.h +++ b/chaos/common/data/CDataVariant.h @@ -110,7 +110,7 @@ namespace chaos { explicit CDataVariant(const std::string& string_value); explicit CDataVariant(const char * string_value); //! take the ownership of the object - explicit CDataVariant(CDataBuffer *buffer_value); + explicit CDataVariant(CDBufferUniquePtr buffer_value); explicit CDataVariant(CDataWrapper *buffer_value); CDataVariant(const CDataVariant& to_copy); diff --git a/chaos/common/data/CDataWrapper.cpp b/chaos/common/data/CDataWrapper.cpp index 4ead91d841cf50c920bb2ad9971c17c953512c56..334dc45d723f048f10ba314c957d602efffcefc6 100644 --- a/chaos/common/data/CDataWrapper.cpp +++ b/chaos/common/data/CDataWrapper.cpp @@ -32,10 +32,8 @@ using namespace chaos::common::data; #pragma mark Utility #define ADD_VECTOR(v,ctype,bsontype){\ - for( std::vector<ctype>::const_iterator i=v.begin();i!=v.end();i++){\ - append ##bsontype ##ToArray(*i);}} - - +for( std::vector<ctype>::const_iterator i=v.begin();i!=v.end();i++){\ +append ##bsontype ##ToArray(*i);}} #define ITER_TYPE(i) ((bson_type_t) * ((i)->raw + (i)->type)) @@ -43,38 +41,40 @@ using namespace chaos::common::data; #define ACCESS_BSON(x) static_cast<bson_t*>(x.get()) #define CW_CAST_EXCEPTION(type){\ - std::stringstream ss;\ - ss<<"cannot get or cast to '" #type "' "<<key<<"' ds:" << getJSONString();\ - throw CException(1, ss.str(), __PRETTY_FUNCTION__);} +std::stringstream ss;\ +ss<<"cannot get or cast to '" #type "' "<<key<<"' ds:" << getJSONString();\ +throw CException(1, ss.str(), __PRETTY_FUNCTION__);} #define ENSURE_ARRAY(x) \ - if(x.get() == NULL) {array_index = 0; x = ALLOCATE_BSONT(bson_new());} +if(x.get() == NULL) {array_index = 0; x = ALLOCATE_BSONT(bson_new());} #define FIND_AND_CHECK(k,c)\ - bson_iter_t element_found;\ - bson_iter_init(&element_found, ACCESS_BSON(bson));\ - if(bson_iter_find_case(&element_found, key.c_str()) && c(&element_found)) +bson_iter_t element_found;\ +bson_iter_init(&element_found, ACCESS_BSON(bson));\ +if(bson_iter_find_case(&element_found, key.c_str()) && c(&element_found)) #define INIT_ITERATOR(key) \ - bool keyfound;\ - bson_iter_t element_found;\ - bson_iter_init(&element_found, ACCESS_BSON(bson));\ - keyfound=bson_iter_find_case(&element_found, key.c_str()); +bool keyfound;\ +bson_iter_t element_found;\ +bson_iter_init(&element_found, ACCESS_BSON(bson));\ +keyfound=bson_iter_find_case(&element_found, key.c_str()); #define GET_VALUE(t,c) \ - if(keyfound&& (c(&element_found))){return bson_iter_##t (&element_found);} +if(keyfound&& (c(&element_found))){return bson_iter_##t (&element_found);} static void bsonDeallocator(bson_t* bson) {if(bson){bson_destroy(bson);}} +static void bsonValueDestroy(bson_value_t* bson_values) {if(bson_values){bson_value_destroy(bson_values);}} + #pragma mark CDataWrapper CDataWrapper::CDataWrapper(): - bson(ALLOCATE_BSONT(bson_new())), - array_index(0){ +bson(ALLOCATE_BSONT(bson_new())), +array_index(0){ CHAOS_ASSERT(bson); } CDataWrapper::CDataWrapper(const bson_t *copy_bson): - array_index(0){ +array_index(0){ if(copy_bson != NULL) { bson = ALLOCATE_BSONT(bson_copy(copy_bson)); } else { @@ -85,7 +85,7 @@ CDataWrapper::CDataWrapper(const bson_t *copy_bson): CDataWrapper::CDataWrapper(const char* mem_ser, uint32_t mem_size): - array_index(0){ +array_index(0){ if(mem_ser != NULL || mem_size) { bson = ALLOCATE_BSONT(bson_new_from_data((const uint8_t*)mem_ser, mem_size)); @@ -96,7 +96,7 @@ CDataWrapper::CDataWrapper(const char* mem_ser, } CDataWrapper::CDataWrapper(const char* mem_ser): - array_index(0) { +array_index(0) { if(mem_ser) { uint32_t size = BSON_UINT32_FROM_LE(*reinterpret_cast<const uint32_t *>(mem_ser)); bson = ALLOCATE_BSONT(bson_new_from_data((const uint8_t*)mem_ser, @@ -108,7 +108,7 @@ CDataWrapper::CDataWrapper(const char* mem_ser): } CDataWrapper::CDataWrapper(const std::string& json_document): - array_index(0) { +array_index(0) { bson_error_t err; bson = ALLOCATE_BSONT(bson_new_from_json((const uint8_t*)json_document.c_str(), json_document.size(), @@ -159,9 +159,9 @@ void CDataWrapper::appendStringToArray(const string& value) { void CDataWrapper::appendBooleanToArray(bool value){ ENSURE_ARRAY(bson_tmp_array); bson_append_bool(ACCESS_BSON(bson_tmp_array), - boost::lexical_cast<std::string>(array_index++).c_str(), - -1, - value); + boost::lexical_cast<std::string>(array_index++).c_str(), + -1, + value); } //append a strin gto an open array @@ -442,30 +442,30 @@ void CDataWrapper::addVariantValue(const std::string& key, const CDataVariant& variant_value) { //create variant using the typed data switch (variant_value.getType()) { - case DataType::TYPE_BOOLEAN: - addBoolValue(key, variant_value.asBool()); - break; - case DataType::TYPE_INT32: - addInt32Value(key, variant_value.asInt32()); - break; - case DataType::TYPE_INT64: - addInt64Value(key, variant_value.asInt64()); - break; - case DataType::TYPE_DOUBLE: - addDoubleValue(key, variant_value.asDouble()); - break; - case DataType::TYPE_CLUSTER:{ - addJsonValue(key,variant_value.asString()); - break; - } - case DataType::TYPE_STRING: - addStringValue(key, variant_value.asString()); - break; - case DataType::TYPE_BYTEARRAY: - addBinaryValue(key, - variant_value.asCDataBuffer()->getBuffer(), - variant_value.asCDataBuffer()->getBufferSize()); - break; + case DataType::TYPE_BOOLEAN: + addBoolValue(key, variant_value.asBool()); + break; + case DataType::TYPE_INT32: + addInt32Value(key, variant_value.asInt32()); + break; + case DataType::TYPE_INT64: + addInt64Value(key, variant_value.asInt64()); + break; + case DataType::TYPE_DOUBLE: + addDoubleValue(key, variant_value.asDouble()); + break; + case DataType::TYPE_CLUSTER:{ + addJsonValue(key,variant_value.asString()); + break; + } + case DataType::TYPE_STRING: + addStringValue(key, variant_value.asString()); + break; + case DataType::TYPE_BYTEARRAY: + addBinaryValue(key, + variant_value.asCDataBuffer()->getBuffer(), + (uint32_t)variant_value.asCDataBuffer()->getBufferSize()); + break; } } @@ -486,8 +486,7 @@ ChaosUniquePtr<CDataBuffer> CDataWrapper::getBinaryValueAsCDataBuffer(const std: uint32_t buf_len = 0; const char* buffer = getBinaryValue(key, buf_len); return ChaosUniquePtr<CDataBuffer>(new CDataBuffer(buffer, - buf_len, - true)); + buf_len)); } //check if the key is present in data wrapper @@ -528,30 +527,30 @@ uint32_t CDataWrapper::getValueSize(const std::string& key) const{ if(bson_iter_find_case(&it, key.c_str()) == false) return 0; const bson_value_t *v = bson_iter_value(&it); switch(v->value_type) { - case BSON_TYPE_INT64: - return sizeof(int64_t); - case BSON_TYPE_INT32: - return sizeof(int32_t); - case BSON_TYPE_BOOL: - return sizeof(bool); - case BSON_TYPE_DOUBLE: - return sizeof(double); - case BSON_TYPE_UTF8: - return v->value.v_utf8.len; - case BSON_TYPE_BINARY: - return v->value.v_binary.data_len; - case BSON_TYPE_ARRAY:{ - uint32_t array_len = 0; - const uint8_t *array = NULL; - bson_iter_array(&it, &array_len, &array); - return array_len; - } - case BSON_TYPE_DOCUMENT:{ - return v->value.v_doc.data_len; - } - default: - return 0; - break; + case BSON_TYPE_INT64: + return sizeof(int64_t); + case BSON_TYPE_INT32: + return sizeof(int32_t); + case BSON_TYPE_BOOL: + return sizeof(bool); + case BSON_TYPE_DOUBLE: + return sizeof(double); + case BSON_TYPE_UTF8: + return v->value.v_utf8.len; + case BSON_TYPE_BINARY: + return v->value.v_binary.data_len; + case BSON_TYPE_ARRAY:{ + uint32_t array_len = 0; + const uint8_t *array = NULL; + bson_iter_array(&it, &array_len, &array); + return array_len; + } + case BSON_TYPE_DOCUMENT:{ + return v->value.v_doc.data_len; + } + default: + return 0; + break; } return 0; } @@ -563,30 +562,30 @@ const char * CDataWrapper::getRawValuePtr(const std::string& key) const{ if(bson_iter_find_case(&it, key.c_str()) == false) return 0; const bson_value_t *v = bson_iter_value(&it); switch(v->value_type) { - case BSON_TYPE_INT64: - return reinterpret_cast<const char*>(&v->value.v_int64); - case BSON_TYPE_INT32: - return reinterpret_cast<const char*>(&v->value.v_int32); - case BSON_TYPE_BOOL: - return reinterpret_cast<const char*>(&v->value.v_bool); - case BSON_TYPE_DOUBLE: - return reinterpret_cast<const char*>(&v->value.v_double); - case BSON_TYPE_UTF8: - return static_cast<const char*>(v->value.v_utf8.str); - case BSON_TYPE_BINARY: - return reinterpret_cast<const char*>(v->value.v_binary.data); - case BSON_TYPE_ARRAY:{ - uint32_t array_len = 0; - const uint8_t *array = NULL; - bson_iter_array(&it, &array_len, &array); - return reinterpret_cast<const char*>(array); - } - case BSON_TYPE_DOCUMENT:{ - return reinterpret_cast<const char*>(v->value.v_doc.data); - } - default: - return NULL; - break; + case BSON_TYPE_INT64: + return reinterpret_cast<const char*>(&v->value.v_int64); + case BSON_TYPE_INT32: + return reinterpret_cast<const char*>(&v->value.v_int32); + case BSON_TYPE_BOOL: + return reinterpret_cast<const char*>(&v->value.v_bool); + case BSON_TYPE_DOUBLE: + return reinterpret_cast<const char*>(&v->value.v_double); + case BSON_TYPE_UTF8: + return static_cast<const char*>(v->value.v_utf8.str); + case BSON_TYPE_BINARY: + return reinterpret_cast<const char*>(v->value.v_binary.data); + case BSON_TYPE_ARRAY:{ + uint32_t array_len = 0; + const uint8_t *array = NULL; + bson_iter_array(&it, &array_len, &array); + return reinterpret_cast<const char*>(array); + } + case BSON_TYPE_DOCUMENT:{ + return reinterpret_cast<const char*>(v->value.v_doc.data); + } + default: + return NULL; + break; } } @@ -602,10 +601,11 @@ void CDataWrapper::addBoolValue(const std::string& key, bool value) { Return the Serialized buffer object taht contain the memory, the requester of this method shuld be deallocate the object */ -SerializationBuffer* CDataWrapper::getBSONData() const{ +__attribute__((__deprecated__)) +SerializationBufferUPtr CDataWrapper::getBSONData() const{ const char * buff = reinterpret_cast<const char*>(bson_get_data(ACCESS_BSON(bson))); - if(!buff) return NULL; - return new SerializationBuffer(buff, bson->len); + if(!buff) return SerializationBufferUPtr(); + return SerializationBufferUPtr(new SerializationBuffer(buff, bson->len)); } /* @@ -756,27 +756,27 @@ CDataVariant CDataWrapper::getVariantValue(const std::string& key) const{ if(!hasKey(key)) return CDataVariant(); //create variant using the typed data switch (getValueType(key)) { - case chaos::DataType::TYPE_BOOLEAN: - return CDataVariant(getBoolValue(key)); - break; - case chaos::DataType::TYPE_INT32: - return CDataVariant(getInt32Value(key)); - break; - case chaos::DataType::TYPE_INT64: - return CDataVariant(getInt64Value(key)); - break; - case chaos::DataType::TYPE_DOUBLE: - return CDataVariant(getDoubleValue(key)); - break; - case chaos::DataType::TYPE_STRING: - return CDataVariant(getStringValue(key)); - break; - case chaos::DataType::TYPE_BYTEARRAY: - return CDataVariant(getBinaryValueAsCDataBuffer(key).release()); - break; - default: - return CDataVariant(); - break; + case chaos::DataType::TYPE_BOOLEAN: + return CDataVariant(getBoolValue(key)); + break; + case chaos::DataType::TYPE_INT32: + return CDataVariant(getInt32Value(key)); + break; + case chaos::DataType::TYPE_INT64: + return CDataVariant(getInt64Value(key)); + break; + case chaos::DataType::TYPE_DOUBLE: + return CDataVariant(getDoubleValue(key)); + break; + case chaos::DataType::TYPE_STRING: + return CDataVariant(getStringValue(key)); + break; + case chaos::DataType::TYPE_BYTEARRAY: + return CDataVariant(getBinaryValueAsCDataBuffer(key).release()); + break; + default: + return CDataVariant(); + break; } } @@ -863,41 +863,41 @@ bool CDataWrapper::isVectorValue(const std::string& key) const{ return false; } - chaos::DataType::DataType CDataWrapper::getValueType(const std::string& key) const{ +chaos::DataType::DataType CDataWrapper::getValueType(const std::string& key) const{ chaos::DataType::DataType result = chaos::DataType::TYPE_UNDEFINED; bson_iter_t it; bson_iter_init(&it, ACCESS_BSON(bson)); if(bson_iter_find_case(&it, key.c_str()) == false) return result; switch(bson_iter_type(&it)) { - case BSON_TYPE_ARRAY: - result = chaos::DataType::TYPE_ACCESS_ARRAY; - break; - case BSON_TYPE_DOCUMENT: - result = chaos::DataType::TYPE_CLUSTER; - break; - case BSON_TYPE_BINARY: - result = chaos::DataType::TYPE_BYTEARRAY; - break; - case BSON_TYPE_UTF8: - result = chaos::DataType::TYPE_STRING; - break; - case BSON_TYPE_DOUBLE: - result = chaos::DataType::TYPE_DOUBLE; - break; - case BSON_TYPE_INT32: - result = chaos::DataType::TYPE_INT32; - break; - case BSON_TYPE_INT64: - result = chaos::DataType::TYPE_INT64; - break; - case BSON_TYPE_BOOL: - result = chaos::DataType::TYPE_BOOLEAN; - break; - case BSON_TYPE_NULL: - result = chaos::DataType::TYPE_UNDEFINED; - break; - default: - break; + case BSON_TYPE_ARRAY: + result = chaos::DataType::TYPE_ACCESS_ARRAY; + break; + case BSON_TYPE_DOCUMENT: + result = chaos::DataType::TYPE_CLUSTER; + break; + case BSON_TYPE_BINARY: + result = chaos::DataType::TYPE_BYTEARRAY; + break; + case BSON_TYPE_UTF8: + result = chaos::DataType::TYPE_STRING; + break; + case BSON_TYPE_DOUBLE: + result = chaos::DataType::TYPE_DOUBLE; + break; + case BSON_TYPE_INT32: + result = chaos::DataType::TYPE_INT32; + break; + case BSON_TYPE_INT64: + result = chaos::DataType::TYPE_INT64; + break; + case BSON_TYPE_BOOL: + result = chaos::DataType::TYPE_BOOLEAN; + break; + case BSON_TYPE_NULL: + result = chaos::DataType::TYPE_UNDEFINED; + break; + default: + break; } return result; @@ -933,8 +933,8 @@ int CDataWrapper::setBson(const bson_iter_t *v ,const double& val){ if(ITER_TYPE(v)==BSON_TYPE_DOUBLE){ memcpy((void*)(v->raw + v->d1), (void*)&val,sizeof(double)); return sizeof(double); - } - return -1; + } + return -1; } int CDataWrapper::setBson(const bson_iter_t *v ,const bool& val){ @@ -966,22 +966,25 @@ int CDataWrapper::setBson(const bson_iter_t *v ,const void* val){ #pragma mark CMultiTypeDataArrayWrapper CMultiTypeDataArrayWrapper::CMultiTypeDataArrayWrapper(const ChaosBsonShrdPtr& _document_shrd_ptr, const std::string& key): - document_shrd_ptr(_document_shrd_ptr) { +document_shrd_ptr(_document_shrd_ptr), +array_doc(new bson_t()) { bson_iter_t element_found; bson_iter_init(&element_found, ACCESS_BSON(_document_shrd_ptr)); if(bson_iter_find_case(&element_found, key.c_str())&& - BSON_ITER_HOLDS_ARRAY(&element_found)) { + BSON_ITER_HOLDS_ARRAY(&element_found)) { uint32_t array_len; const uint8_t *array; bson_iter_array(&element_found, &array_len, &array); - if (bson_init_static(&array_doc, array, array_len)) { + if (bson_init_static(array_doc, array, array_len)) { bson_iter_t iter; - if(bson_iter_init(&iter, &array_doc)) { + if(bson_iter_init(&iter, array_doc)) { while(bson_iter_next(&iter)) { - bson_value_t copy; - bson_value_copy(bson_iter_value(&iter), ©); + //ChaosBsonValuesShrdPtr copy = ChaosBsonValuesShrdPtr(new bson_value_t(), &bsonValueDestroy); + //bson_value_t copy; + bson_value_t*copy = new bson_value_t(); + bson_value_copy(bson_iter_value(&iter), copy); values.push_back(copy); } } @@ -990,120 +993,125 @@ CMultiTypeDataArrayWrapper::CMultiTypeDataArrayWrapper(const ChaosBsonShrdPtr& _ } CMultiTypeDataArrayWrapper::~CMultiTypeDataArrayWrapper() { - for(VectorBsonValuesIterator it = values.begin(), - end = values.end(); - it != end; - it++) { - bson_value_destroy(&(*it)); + for(VectorBsonValuesIterator it = values.begin(), + end = values.end(); + it != end; + it++) { + bson_value_destroy(*it); + delete(*it); } + values.clear(); + delete(array_doc); } std::string CMultiTypeDataArrayWrapper::getJSONString() { size_t str_size; - char * str_c = bson_as_canonical_extended_json(static_cast<const bson_t*>(&array_doc),&str_size); + char * str_c = bson_as_canonical_extended_json(static_cast<const bson_t*>(array_doc),&str_size); return std::string(str_c,str_size); } std::string CMultiTypeDataArrayWrapper::getCanonicalJSONString() { size_t str_size; - char * str_c = bson_as_relaxed_extended_json(static_cast<const bson_t*>(&array_doc),&str_size); + char * str_c = bson_as_relaxed_extended_json(static_cast<const bson_t*>(array_doc),&str_size); return std::string(str_c,str_size); } string CMultiTypeDataArrayWrapper::getStringElementAtIndex(const int pos) const{ - // CHAOS_ASSERT(values[pos].value_type == BSON_TYPE_UTF8); - if(values[pos].value_type != BSON_TYPE_UTF8){ + // CHAOS_ASSERT(values[pos]->value_type == BSON_TYPE_UTF8); + if(values[pos]->value_type != BSON_TYPE_UTF8){ std::stringstream ss; - ss<<"type at index ["<<pos<<"] is not String, typeid:"<<values[pos].value_type; + ss<<"type at index ["<<pos<<"] is not String, typeid:"<<values[pos]->value_type; throw CException(1, ss.str(), __PRETTY_FUNCTION__); - } - return std::string(values[pos].value.v_utf8.str, values[pos].value.v_utf8.len); + } + return std::string(values[pos]->value.v_utf8.str, values[pos]->value.v_utf8.len); } double CMultiTypeDataArrayWrapper::getDoubleElementAtIndex(const int pos) const{ - if(values[pos].value_type != BSON_TYPE_DOUBLE){ + if(values[pos]->value_type != BSON_TYPE_DOUBLE){ std::stringstream ss; - ss<<"type at index ["<<pos<<"] is not double, typeid:"<<values[pos].value_type; + ss<<"type at index ["<<pos<<"] is not double, typeid:"<<values[pos]->value_type; throw CException(1, ss.str(), __PRETTY_FUNCTION__); - } - return values[pos].value.v_double; + } + return values[pos]->value.v_double; } + int32_t CMultiTypeDataArrayWrapper::getInt32ElementAtIndex(const int pos) const{ - return values[pos].value.v_int32; + return values[pos]->value.v_int32; } + bool CMultiTypeDataArrayWrapper::getBoolElementAtIndex(const int pos) const{ - return values[pos].value.v_bool; + return values[pos]->value.v_bool; } int64_t CMultiTypeDataArrayWrapper::getInt64ElementAtIndex(const int pos) const{ - //CHAOS_ASSERT(values[pos].value_type == BSON_TYPE_INT64); - if(values[pos].value_type != BSON_TYPE_INT64){ + //CHAOS_ASSERT(values[pos]->value_type == BSON_TYPE_INT64); + if(values[pos]->value_type != BSON_TYPE_INT64){ std::stringstream ss; - ss<<"type at index ["<<pos<<"] is not int64, typeid:"<<values[pos].value_type; + ss<<"type at index ["<<pos<<"] is not int64, typeid:"<<values[pos]->value_type; throw CException(1, ss.str(), __PRETTY_FUNCTION__); - } - return values[pos].value.v_int64; + } + return values[pos]->value.v_int64; } bool CMultiTypeDataArrayWrapper::isStringElementAtIndex(const int pos) const{ - return values[pos].value_type == BSON_TYPE_UTF8; + return values[pos]->value_type == BSON_TYPE_UTF8; } bool CMultiTypeDataArrayWrapper::isDoubleElementAtIndex(const int pos) const{ - return values[pos].value_type == BSON_TYPE_DOUBLE; + return values[pos]->value_type == BSON_TYPE_DOUBLE; } bool CMultiTypeDataArrayWrapper::isInt32ElementAtIndex(const int pos) const{ - return values[pos].value_type == BSON_TYPE_INT32; + return values[pos]->value_type == BSON_TYPE_INT32; } bool CMultiTypeDataArrayWrapper::isBoolElementAtIndex(const int pos) const{ - return values[pos].value_type == BSON_TYPE_BOOL; + return values[pos]->value_type == BSON_TYPE_BOOL; } bool CMultiTypeDataArrayWrapper::isInt64ElementAtIndex(const int pos) const{ - return values[pos].value_type == BSON_TYPE_INT64; + return values[pos]->value_type == BSON_TYPE_INT64; } bool CMultiTypeDataArrayWrapper::isCDataWrapperElementAtIndex(const int pos) const{ - return values[pos].value_type == BSON_TYPE_DOCUMENT; + return values[pos]->value_type == BSON_TYPE_DOCUMENT; } + const char * CMultiTypeDataArrayWrapper::getRawValueAtIndex(const int pos,uint32_t& size) const{ - switch(values[pos].value_type ) { - case BSON_TYPE_INT64: - size=sizeof(int64_t); - return reinterpret_cast<const char*>(&values[pos].value.v_int64); - case BSON_TYPE_INT32: - size=sizeof(int32_t); - - return reinterpret_cast<const char*>(&values[pos].value.v_int32); - case BSON_TYPE_BOOL: - size=sizeof(bool); - - return reinterpret_cast<const char*>(&values[pos].value.v_bool); - case BSON_TYPE_DOUBLE: - size=sizeof(double); - - return reinterpret_cast<const char*>(&values[pos].value.v_double); - case BSON_TYPE_UTF8: - size = values[pos].value.v_utf8.len; - return static_cast<const char*>(values[pos].value.v_utf8.str); - case BSON_TYPE_BINARY: - size = values[pos].value.v_binary.data_len; - return reinterpret_cast<const char*>(values[pos].value.v_binary.data); + switch(values[pos]->value_type ) { + case BSON_TYPE_INT64: + size=sizeof(int64_t); + return reinterpret_cast<const char*>(&values[pos]->value.v_int64); + case BSON_TYPE_INT32: + size=sizeof(int32_t); + return reinterpret_cast<const char*>(&values[pos]->value.v_int32); + case BSON_TYPE_BOOL: + size=sizeof(bool); + return reinterpret_cast<const char*>(&values[pos]->value.v_bool); + case BSON_TYPE_DOUBLE: + size=sizeof(double); + return reinterpret_cast<const char*>(&values[pos]->value.v_double); + case BSON_TYPE_UTF8: + size = values[pos]->value.v_utf8.len; + return static_cast<const char*>(values[pos]->value.v_utf8.str); + case BSON_TYPE_BINARY: + size = values[pos]->value.v_binary.data_len; + return reinterpret_cast<const char*>(values[pos]->value.v_binary.data); + default: + break; } return NULL; } CDataWrapper* CMultiTypeDataArrayWrapper::getCDataWrapperElementAtIndex(const int pos) const{ - // CHAOS_ASSERT(values[pos].value_type == BSON_TYPE_DOCUMENT); - if(values[pos].value_type != BSON_TYPE_DOCUMENT){ + // CHAOS_ASSERT(values[pos]->value_type == BSON_TYPE_DOCUMENT); + if(values[pos]->value_type != BSON_TYPE_DOCUMENT){ std::stringstream ss; - ss<<"type at index ["<<pos<<"] is not CDataWrapper, typeid:"<<values[pos].value_type; + ss<<"type at index ["<<pos<<"] is not CDataWrapper, typeid:"<<values[pos]->value_type; throw CException(1, ss.str(), __PRETTY_FUNCTION__); - } - return new CDataWrapper((const char *)values[pos].value.v_doc.data, values[pos].value.v_doc.data_len); + } + return new CDataWrapper((const char *)values[pos]->value.v_doc.data, values[pos]->value.v_doc.data_len); } size_t CMultiTypeDataArrayWrapper::size() const{ diff --git a/chaos/common/data/CDataWrapper.h b/chaos/common/data/CDataWrapper.h index b7c0866f5494fd967320f195599c9150c6e9fce8..de1280a87cacada44b350a2c6286840be71ddce9 100644 --- a/chaos/common/data/CDataWrapper.h +++ b/chaos/common/data/CDataWrapper.h @@ -44,7 +44,7 @@ namespace chaos { class CMultiTypeDataArrayWrapper; typedef ChaosUniquePtr<CMultiTypeDataArrayWrapper> CMultiTypeDataArrayWrapperUPtr; typedef ChaosSharedPtr<CMultiTypeDataArrayWrapper> CMultiTypeDataArrayWrapperSPtr; - + /*! Class for contain the serialization buffer the class deallocation will dealloc all the @@ -70,7 +70,11 @@ namespace chaos { size_t getBufferLen(){return bSize;}; const char *getBufferPtr(){return buffer;}; }; + typedef ChaosUniquePtr<SerializationBuffer> SerializationBufferUPtr; typedef ChaosSharedPtr<struct _bson_t> ChaosBsonShrdPtr; + typedef ChaosSharedPtr<struct _bson_value_t> ChaosBsonValuesShrdPtr; + + /*! Class that wrap the serializaiton system for data storage */ @@ -165,12 +169,12 @@ namespace chaos { bool getBoolValue(const std::string&) const; //get a json value std::string getJsonValue(const std::string&) const; - + #define THROW_TYPE_EXC(type)\ std::stringstream ss;\ ss<<"cannot get or cast to '" << #type;\ throw chaos::CException(-2, ss.str(), __PRETTY_FUNCTION__); - + template<typename T> int setValue(const std::string& key,const T& val){ bson_iter_t it; @@ -252,7 +256,7 @@ throw chaos::CException(-2, ss.str(), __PRETTY_FUNCTION__); int bufLen); ChaosUniquePtr<CDataBuffer> getBinaryValueAsCDataBuffer(const std::string &key) const; //return the bson data - SerializationBuffer* getBSONData() const; + SerializationBufferUPtr getBSONData() const; const char* getBSONRawData(int& size) const; const char* getBSONRawData() const; const int getBSONRawSize() const; @@ -307,14 +311,14 @@ throw chaos::CException(-2, ss.str(), __PRETTY_FUNCTION__); chaos::DataType::DataType getValueType(const std::string& key) const; bool isEmpty() const; }; - CHAOS_DEFINE_VECTOR_FOR_TYPE(bson_value_t, VectorBsonValues); + CHAOS_DEFINE_VECTOR_FOR_TYPE(bson_value_t*, VectorBsonValues); /*! Class to read the and arry of multivalue */ class CMultiTypeDataArrayWrapper { friend class CDataWrapper; const ChaosBsonShrdPtr document_shrd_ptr; - bson_t array_doc; + bson_t *array_doc; VectorBsonValues values; CMultiTypeDataArrayWrapper(const ChaosBsonShrdPtr& _document_shrd_ptr, const std::string& key); @@ -325,7 +329,7 @@ throw chaos::CException(-2, ss.str(), __PRETTY_FUNCTION__); int32_t getInt32ElementAtIndex(const int) const; int64_t getInt64ElementAtIndex(const int) const; bool getBoolElementAtIndex(const int) const; - + CDataWrapper* getCDataWrapperElementAtIndex(const int) const; std::string getJSONString(); std::string getCanonicalJSONString(); @@ -334,31 +338,31 @@ throw chaos::CException(-2, ss.str(), __PRETTY_FUNCTION__); bool isInt32ElementAtIndex(const int) const; bool isInt64ElementAtIndex(const int) const; bool isBoolElementAtIndex(const int) const; - + bool isCDataWrapperElementAtIndex(const int) const; template<class T> T getElementAtIndex(const int pos) const{ - if(values[pos].value_type == BSON_TYPE_DOUBLE){ - return static_cast<T>(values[pos].value.v_double); + if(values[pos]->value_type == BSON_TYPE_DOUBLE){ + return static_cast<T>(values[pos]->value.v_double); } - if(values[pos].value_type == BSON_TYPE_INT32){ - return static_cast<T>(values[pos].value.v_int32); + if(values[pos]->value_type == BSON_TYPE_INT32){ + return static_cast<T>(values[pos]->value.v_int32); } - if(values[pos].value_type == BSON_TYPE_INT64){ - return static_cast<T>(values[pos].value.v_int64); + if(values[pos]->value_type == BSON_TYPE_INT64){ + return static_cast<T>(values[pos]->value.v_int64); } - if(values[pos].value_type == BSON_TYPE_BOOL){ - return static_cast<T>(values[pos].value.v_bool); + if(values[pos]->value_type == BSON_TYPE_BOOL){ + return static_cast<T>(values[pos]->value.v_bool); } std::stringstream ss; - ss<<"type at index ["<<pos<<"] cannot convert, typeid:"<<values[pos].value_type; + ss<<"type at index ["<<pos<<"] cannot convert, typeid:"<<values[pos]->value_type; throw CException(1, ss.str(), __PRETTY_FUNCTION__); return 0; } const char * getRawValueAtIndex(const int key,uint32_t& size) const; size_t size() const; }; - + #define CDW_GET_SRT_WITH_DEFAULT(c, k, d) ((c)->hasKey(k)?(c)->getStringValue(k):d) #define CDW_GET_BOOL_WITH_DEFAULT(c, k, d) ((c)->hasKey(k)?(c)->getBoolValue(k):d) #define CDW_GET_INT32_WITH_DEFAULT(c, k, d) ((c)->hasKey(k)?(c)->getInt32Value(k):d) @@ -366,11 +370,11 @@ throw chaos::CException(-2, ss.str(), __PRETTY_FUNCTION__); #define CDW_GET_DOUBLE_WITH_DEFAULT(c, k, d) ((c)->hasKey(k)?(c)->getDoubleValue(k):d) #define CDW_CHECK_AND_SET(chk, cdw, t, k, v) if(chk){cdw->t(k,v);} #define CDW_GET_VALUE_WITH_DEFAULT(c, k, t, d) ((c)->hasKey(k)?(c)->t(k):d) - + typedef ChaosUniquePtr<chaos::common::data::CDataWrapper> CDWUniquePtr; typedef ChaosSharedPtr<chaos::common::data::CDataWrapper> CDWShrdPtr; CHAOS_DEFINE_VECTOR_FOR_TYPE(CDWShrdPtr, VectorCDWShrdPtr); - + typedef std::pair<std::string, CDWShrdPtr> PairStrCDWShrdPtr; CHAOS_DEFINE_VECTOR_FOR_TYPE(PairStrCDWShrdPtr, VectorStrCDWShrdPtr); } diff --git a/chaos/common/data/structured/Dataset.cpp b/chaos/common/data/structured/Dataset.cpp index 3c3439d26c3c2a69c2cee35fb8827549526b1e74..da1f4c98025a25be062e2772485bdc87ca568618 100644 --- a/chaos/common/data/structured/Dataset.cpp +++ b/chaos/common/data/structured/Dataset.cpp @@ -122,4 +122,20 @@ void Dataset::setDatasetKey(const std::string& ds_key) { const std::string& Dataset::getDatasetKey() const { return dataset_key; } +#pragma mark DatasetBurst +DatasetBurst::DatasetBurst(): +tag(), +value(), +type(chaos::ControlUnitNodeDefinitionType::DSStorageBurstTypeUndefined){} + +DatasetBurst::DatasetBurst(const DatasetBurst& copy_src): +tag(copy_src.tag), +value(copy_src.value), +type(copy_src.type){} +DatasetBurst& DatasetBurst::operator=(DatasetBurst const &rhs) { + tag = rhs.tag; + value = rhs.value; + type = rhs.type; + return *this; +} diff --git a/chaos/common/data/structured/Dataset.h b/chaos/common/data/structured/Dataset.h index fb9920f2d7807627331755c5fd7a865524179408..9c3e81c3d651b5ce9885bf867e3631adf739043c 100644 --- a/chaos/common/data/structured/Dataset.h +++ b/chaos/common/data/structured/Dataset.h @@ -25,6 +25,7 @@ #include <chaos/common/chaos_constants.h> #include <chaos/common/chaos_types.h> +#include <chaos/common/data/CDataVariant.h> #include <chaos/common/data/TemplatedDataSDWrapper.h> #include <chaos/common/data/structured/DatasetAttribute.h> @@ -185,6 +186,38 @@ namespace chaos { return result; } CHAOS_CLOSE_SDWRAPPER() + + //!define the information for store dataset in burst mode + typedef struct DatasetBurst { + //!is the tag associated to the burst + std::string tag; + //!is the valued asscoiated to the burst type + chaos::common::data::CDataVariant value; + //!is the type the specified the burst function + chaos::ControlUnitNodeDefinitionType::DSStorageBurstType type; + + DatasetBurst(); + DatasetBurst(const DatasetBurst& copy_src); + DatasetBurst& operator=(DatasetBurst const &rhs); + } DatasetBurst; + + typedef ChaosSharedPtr<DatasetBurst> DatasetBurstShrdPtr; + + CHAOS_OPEN_SDWRAPPER(DatasetBurst) + void deserialize(chaos::common::data::CDataWrapper *serialized_data) { + Subclass::dataWrapped().tag = CDW_GET_SRT_WITH_DEFAULT(serialized_data, ControlUnitNodeDefinitionKey::CONTROL_UNIT_DATASET_HISTORY_BURST_TAG, ""); + Subclass::dataWrapped().type = static_cast<chaos::ControlUnitNodeDefinitionType::DSStorageBurstType>(CDW_GET_INT32_WITH_DEFAULT(serialized_data, ControlUnitNodeDefinitionKey::CONTROL_UNIT_DATASET_HISTORY_BURST_TYPE, chaos::ControlUnitNodeDefinitionType::DSStorageBurstTypeUndefined)); + Subclass::dataWrapped().value = CDW_GET_VALUE_WITH_DEFAULT(serialized_data, ControlUnitNodeDefinitionKey::CONTROL_UNIT_DATASET_HISTORY_BURST_VALUE, getVariantValue, CDataVariant()); + } + + CDWUniquePtr serialize() { + CDWUniquePtr result(new CDataWrapper()); + result->addStringValue(ControlUnitNodeDefinitionKey::CONTROL_UNIT_DATASET_HISTORY_BURST_TAG, Subclass::dataWrapped().tag); + result->addInt32Value(ControlUnitNodeDefinitionKey::CONTROL_UNIT_DATASET_HISTORY_BURST_TYPE, Subclass::dataWrapped().type); + result->addVariantValue(ControlUnitNodeDefinitionKey::CONTROL_UNIT_DATASET_HISTORY_BURST_VALUE, Subclass::dataWrapped().value); + return result; + } + CHAOS_CLOSE_SDWRAPPER() } } } diff --git a/chaos/common/direct_io/DirectIODispatcher.cpp b/chaos/common/direct_io/DirectIODispatcher.cpp index 893f3cd1c24d97ff902d02e1a81605feea164239..5b5711c7691437fdd23b7b26301801adeba168b5 100644 --- a/chaos/common/direct_io/DirectIODispatcher.cpp +++ b/chaos/common/direct_io/DirectIODispatcher.cpp @@ -85,7 +85,6 @@ void DirectIODispatcher::stop() throw(chaos::CException) { // Deinit the implementation void DirectIODispatcher::deinit() throw(chaos::CException) { - if(endpoint_slot_array) { DIOD_LDBG_ << "Deallocating all endpoint slot"; //allocate all endpoint slot @@ -102,6 +101,8 @@ void DirectIODispatcher::deinit() throw(chaos::CException) { free(endpoint_slot_array); endpoint_slot_array=NULL; } + unsigned int tmp; + while(!available_endpoint_slot.empty()){available_endpoint_slot.pop(tmp);} } //allocate new endpoint diff --git a/chaos/common/direct_io/channel/DirectIODeviceChannelGlobal.h b/chaos/common/direct_io/channel/DirectIODeviceChannelGlobal.h index dc5c2d3e29628a2f2988bd5ec9685075db0a07cd..14e6849ae69276abcb7759cd61a2c656130820a1 100644 --- a/chaos/common/direct_io/channel/DirectIODeviceChannelGlobal.h +++ b/chaos/common/direct_io/channel/DirectIODeviceChannelGlobal.h @@ -61,6 +61,8 @@ namespace chaos { Parameter for the query used in CDataWrapper structure */ namespace DeviceChannelOpcodeQueryDataCloudParam { + //!is the timestamp for wich we want to search our key + static const char * const QUERY_PARAM_META_TAGS = "qp_data_cloud_meta_tags"; //!is the timestamp for wich we want to search our key static const char * const QUERY_PARAM_STAR_TS_I64 = "qp_data_cloud_start_ts"; //!is the timestamp that close the time offset of the search [packet that are <= are included into the result] @@ -90,12 +92,14 @@ namespace chaos { //! Header for the DeviceChannelOpcodePutOutput[WithCache] opcodes typedef struct DirectIODeviceChannelHeaderPutOpcode { - //! The 8 bit tag field + //! The tag associated to the uint8_t tag; - //! The 8 bit key length field + //! The lenght of the key uint8_t key_len; - //the pointer to key data - void* key_data; + //! Thenumber of tags for this dataset, every tag is terminated by '\0' + uint16_t tag_num; + //the pointer to hedaer payload + void* data; } DirectIODeviceChannelHeaderData, *DirectIODeviceChannelHeaderDataPtr; diff --git a/chaos/common/direct_io/channel/DirectIODeviceClientChannel.cpp b/chaos/common/direct_io/channel/DirectIODeviceClientChannel.cpp index ea0ab9070bea6fb30ea0d76bd0841ee9da43fa35..3b7e3807469949f34d4e7f840e9272677c91a3c4 100644 --- a/chaos/common/direct_io/channel/DirectIODeviceClientChannel.cpp +++ b/chaos/common/direct_io/channel/DirectIODeviceClientChannel.cpp @@ -61,24 +61,38 @@ int DirectIODeviceClientChannel::storeAndCacheDataOutputChannel(const std::strin void *buffer, uint32_t buffer_len, DataServiceNodeDefinitionType::DSStorageType _put_mode, + const ChaosStringSet& tag_set, bool wait_result) { int err = 0; if(key.size() > 250) return -1; + + DataBuffer data_buffer; DirectIODataPackSPtr answer; + + //write mode and tags number + data_buffer.writeInt8((int8_t) _put_mode); + data_buffer.writeInt16(tag_set.size()); + //write key + data_buffer.writeByte(key.c_str(), (int32_t)key.size()); + data_buffer.writeByte('\0'); + //write tags + for(ChaosStringSetConstIterator it = tag_set.begin(), + end = tag_set.end(); + it!=end; + it++) { + data_buffer.writeByte(it->c_str(), (int32_t)it->size()); + data_buffer.writeByte('\0'); + } + DirectIODataPackSPtr data_pack = ChaosMakeSharedPtr<DirectIODataPack>(); - BufferSPtr put_opcode_header = ChaosMakeSharedPtr<Buffer>(sizeof(DirectIODeviceChannelHeaderPutOpcode)+key.size()); + BufferSPtr put_opcode_header = data_buffer.detachBuffer(); BufferSPtr channel_data = ChaosMakeSharedPtr<Buffer>(buffer, buffer_len, buffer_len, true); - put_opcode_header->data<DirectIODeviceChannelHeaderPutOpcode>()->tag = (uint8_t) _put_mode; - put_opcode_header->data<DirectIODeviceChannelHeaderPutOpcode>()->key_len = key.size(); - //put_opcode_header->key_data - std::memcpy(GET_PUT_OPCODE_KEY_PTR(put_opcode_header->data<DirectIODeviceChannelHeaderPutOpcode>()), key.c_str(), put_opcode_header->data<DirectIODeviceChannelHeaderPutOpcode>()->key_len); - //set opcode data_pack->header.dispatcher_header.fields.channel_opcode = static_cast<uint8_t>(opcode::DeviceChannelOpcodePutOutput); //set the header - DIRECT_IO_SET_CHANNEL_HEADER(data_pack, put_opcode_header, (uint32_t)PUT_HEADER_LEN(key)) + DIRECT_IO_SET_CHANNEL_HEADER(data_pack, put_opcode_header, (uint32_t)put_opcode_header->size()) //set data if the have some if(buffer_len){DIRECT_IO_SET_CHANNEL_DATA(data_pack, channel_data, (uint32_t)channel_data->size());} if(wait_result) { @@ -96,24 +110,37 @@ int DirectIODeviceClientChannel::storeAndCacheHealthData(const std::string& key, void *buffer, uint32_t buffer_len, DataServiceNodeDefinitionType::DSStorageType _put_mode, + const ChaosStringSet& tag_set, bool wait_result) { int err = 0; if(key.size() > 250) return -1; + DataBuffer data_buffer; DirectIODataPackSPtr answer; + + //write mode and tags number + data_buffer.writeInt8((int8_t) _put_mode); + data_buffer.writeInt16(tag_set.size()); + //write key + data_buffer.writeByte(key.c_str(), (int32_t)key.size()); + data_buffer.writeByte('\0'); + //write tags + for(ChaosStringSetConstIterator it = tag_set.begin(), + end = tag_set.end(); + it!=end; + it++) { + data_buffer.writeByte(it->c_str(), (int32_t)it->size()); + data_buffer.writeByte('\0'); + } + DirectIODataPackSPtr data_pack = ChaosMakeSharedPtr<DirectIODataPack>(); - BufferSPtr put_opcode_header = ChaosMakeSharedPtr<Buffer>((PUT_HEADER_LEN(key)+key.size())); + BufferSPtr put_opcode_header = data_buffer.detachBuffer(); BufferSPtr channel_data = ChaosMakeSharedPtr<Buffer>(buffer, buffer_len, buffer_len, true); - put_opcode_header->data<DirectIODeviceChannelHeaderPutOpcode>()->tag = (uint8_t) _put_mode; - put_opcode_header->data<DirectIODeviceChannelHeaderPutOpcode>()->key_len = key.size(); - //put_opcode_header->key_data - std::memcpy(GET_PUT_OPCODE_KEY_PTR(put_opcode_header->data()), key.c_str(), put_opcode_header->data<DirectIODeviceChannelHeaderPutOpcode>()->key_len); - //set opcode data_pack->header.dispatcher_header.fields.channel_opcode = static_cast<uint8_t>(opcode::DeviceChannelOpcodePutHeathData); //set the header - DIRECT_IO_SET_CHANNEL_HEADER(data_pack, put_opcode_header, (uint32_t)PUT_HEADER_LEN(key)) + DIRECT_IO_SET_CHANNEL_HEADER(data_pack, put_opcode_header, (uint32_t)put_opcode_header->size()) //set data if the have some if(buffer_len){DIRECT_IO_SET_CHANNEL_DATA(data_pack, channel_data, (uint32_t)channel_data->size());} if(wait_result) { @@ -218,9 +245,10 @@ int DirectIODeviceClientChannel::requestLastOutputData(const ChaosStringVector& } int DirectIODeviceClientChannel::queryDataCloud(const std::string& key, - uint64_t start_ts, - uint64_t end_ts, - uint32_t page_dimension, + const ChaosStringSet& meta_tags, + const uint64_t start_ts, + const uint64_t end_ts, + const uint32_t page_dimension, SearchSequence& last_sequence_id, QueryResultPage& found_element_page) { int err = 0; @@ -236,7 +264,13 @@ int DirectIODeviceClientChannel::queryDataCloud(const std::string& key, query_description.addInt64Value(DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_END_TS_I64, (int64_t)end_ts); query_description.addInt64Value(DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_SEARCH_LAST_RUN_ID, last_sequence_id.run_id); query_description.addInt64Value(DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_SEARCH_LAST_DP_COUNTER, last_sequence_id.datapack_counter); - + for(ChaosStringSetConstIterator it = meta_tags.begin(), + end = meta_tags.end(); + it != end; + it++) { + query_description.appendStringToArray(*it); + } + query_description.finalizeArrayForKey(DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_META_TAGS); //copy the query id on header query_data_cloud_header->data<DirectIODeviceChannelHeaderOpcodeQueryDataCloud>()->field.record_for_page = TO_LITTEL_ENDNS_NUM(uint32_t, page_dimension); //set opcode diff --git a/chaos/common/direct_io/channel/DirectIODeviceClientChannel.h b/chaos/common/direct_io/channel/DirectIODeviceClientChannel.h index 8da06640a12a2decc6fb76c4c43d412778efae25..46d77c644316ec4690263895438fdbf83c188c53 100644 --- a/chaos/common/direct_io/channel/DirectIODeviceClientChannel.h +++ b/chaos/common/direct_io/channel/DirectIODeviceClientChannel.h @@ -56,6 +56,7 @@ namespace chaos { void *buffer, uint32_t buffer_len, DataServiceNodeDefinitionType::DSStorageType _put_mode, + const ChaosStringSet& tag_set = ChaosStringSet(), bool wait_result = true); //! Send device serialization with priority @@ -63,6 +64,7 @@ namespace chaos { void *buffer, uint32_t buffer_len, DataServiceNodeDefinitionType::DSStorageType _put_mode, + const ChaosStringSet& tag_set = ChaosStringSet(), bool wait_result = true); //! Send a request for the last output data @@ -85,9 +87,10 @@ namespace chaos { \return error */ int queryDataCloud(const std::string& key, - uint64_t start_ts, - uint64_t end_ts, - uint32_t page_dimension, + const ChaosStringSet& meta_tags, + const uint64_t start_ts, + const uint64_t end_ts, + const uint32_t page_dimension, opcode_headers::SearchSequence& last_sequence, opcode_headers::QueryResultPage& found_element_page); diff --git a/chaos/common/direct_io/channel/DirectIODeviceServerChannel.cpp b/chaos/common/direct_io/channel/DirectIODeviceServerChannel.cpp index 6509fec0e73b913db4a534c8b2b22454f89395c8..fa3712abe748e6b82fd9b37875e086d6f493bcd4 100644 --- a/chaos/common/direct_io/channel/DirectIODeviceServerChannel.cpp +++ b/chaos/common/direct_io/channel/DirectIODeviceServerChannel.cpp @@ -48,22 +48,54 @@ int DirectIODeviceServerChannel::consumeDataPack(chaos::common::direct_io::Direc opcode::DeviceChannelOpcode channel_opcode = static_cast<opcode::DeviceChannelOpcode>(data_pack->header.dispatcher_header.fields.channel_opcode); switch (channel_opcode) { case opcode::DeviceChannelOpcodePutOutput: { - DirectIODeviceChannelHeaderPutOpcode *header = data_pack->channel_header_data->data<DirectIODeviceChannelHeaderPutOpcode>(); - //reallign the pointer to the start of the key - header->tag = FROM_LITTLE_ENDNS_NUM(uint32_t, header->tag); - err = handler->consumePutEvent(*header, - data_pack->channel_data, - data_pack->header.channel_data_size); + DataBuffer data_buffer(data_pack->channel_header_data->data(), + (uint32_t)data_pack->channel_header_data->size(), + false); + //write mode and tags number + int8_t hst_tag; + std::string key; + int16_t meta_tag_num; + ChaosStringSetSPtr meta_tag_set = ChaosMakeSharedPtr<ChaosStringSet>(); + + hst_tag = data_buffer.readInt8(); + meta_tag_num = data_buffer.readInt16(); + //write key + key = data_buffer.readStringUntilNull(); + //write tags + while(meta_tag_num--){ + meta_tag_set->insert(data_buffer.readStringUntilNull()); + } + + err = handler->consumePutEvent(key, + hst_tag, + ChaosMoveOperator(meta_tag_set), + data_pack->channel_data); break; } case opcode::DeviceChannelOpcodePutHeathData: { - DirectIODeviceChannelHeaderPutOpcode *header = data_pack->channel_header_data->data<DirectIODeviceChannelHeaderPutOpcode>(); //reallign the pointer to the start of the key - header->tag = FROM_LITTLE_ENDNS_NUM(uint32_t, header->tag); - err = handler->consumeHealthDataEvent(*header, - data_pack->channel_data, - data_pack->header.channel_data_size); + DataBuffer data_buffer(data_pack->channel_header_data->data(), + (uint32_t)data_pack->channel_header_data->size(), + false); + //write mode and tags number + int8_t hst_tag; + std::string key; + int16_t meta_tag_num; + ChaosStringSetSPtr meta_tag_set = ChaosMakeSharedPtr<ChaosStringSet>(); + + hst_tag = data_buffer.readInt8(); + meta_tag_num = data_buffer.readInt16(); + //write key + key = data_buffer.readStringUntilNull(); + //write tags + while(meta_tag_num--){ + meta_tag_set->insert(data_buffer.readStringUntilNull()); + } + err = handler->consumeHealthDataEvent(key, + hst_tag, + ChaosMoveOperator(meta_tag_set), + data_pack->channel_data); break; } @@ -126,8 +158,9 @@ int DirectIODeviceServerChannel::consumeDataPack(chaos::common::direct_io::Direc if (data_pack && data_pack->channel_data) { BufferSPtr result_data; + ChaosStringSet meta_tags; QueryResultPage result_page; - chaos_data::CDataWrapper query(data_pack->channel_data->data()); + CDWUniquePtr query(new CDataWrapper(data_pack->channel_data->data())); BufferSPtr result_header = ChaosMakeSharedPtr<Buffer>(sizeof(DirectIODeviceChannelHeaderOpcodeQueryDataCloudResult)); DirectIODeviceChannelHeaderOpcodeQueryDataCloudResult *result_header_t = result_header->data<DirectIODeviceChannelHeaderOpcodeQueryDataCloudResult>(); @@ -135,19 +168,29 @@ int DirectIODeviceServerChannel::consumeDataPack(chaos::common::direct_io::Direc header->field.record_for_page = FROM_LITTLE_ENDNS_NUM(uint32_t, header->field.record_for_page); //decode the endianes off the data - std::string key = CDW_GET_SRT_WITH_DEFAULT(&query, DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_SEARCH_KEY_STRING, ""); - uint64_t start_ts = CDW_GET_VALUE_WITH_DEFAULT(&query, DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_STAR_TS_I64, getUInt64Value, 0); - uint64_t end_ts = CDW_GET_VALUE_WITH_DEFAULT(&query, DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_END_TS_I64, getUInt64Value, 0); - SearchSequence last_sequence_info = {CDW_GET_VALUE_WITH_DEFAULT(&query, DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_SEARCH_LAST_RUN_ID, getInt64Value, 0), - CDW_GET_VALUE_WITH_DEFAULT(&query, DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_SEARCH_LAST_DP_COUNTER, getInt64Value, 0)}; + std::string key = CDW_GET_SRT_WITH_DEFAULT(query, DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_SEARCH_KEY_STRING, ""); + uint64_t start_ts = CDW_GET_VALUE_WITH_DEFAULT(query, DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_STAR_TS_I64, getUInt64Value, 0); + uint64_t end_ts = CDW_GET_VALUE_WITH_DEFAULT(query, DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_END_TS_I64, getUInt64Value, 0); + SearchSequence last_sequence_info = {CDW_GET_VALUE_WITH_DEFAULT(query, DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_SEARCH_LAST_RUN_ID, getInt64Value, 0), + CDW_GET_VALUE_WITH_DEFAULT(query, DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_SEARCH_LAST_DP_COUNTER, getInt64Value, 0)}; + if(query->hasKey(DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_META_TAGS) && + query->isVectorValue(DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_META_TAGS)) { + CMultiTypeDataArrayWrapperSPtr meta_tags_vec = query->getVectorValue(DeviceChannelOpcodeQueryDataCloudParam::QUERY_PARAM_META_TAGS); + for(int idx = 0; + idx < meta_tags_vec->size(); + idx++) { + meta_tags.insert(meta_tags_vec->getStringElementAtIndex(idx)); + } + } //call server api if we have at least the key if((key.compare("") != 0)) {err = handler->consumeDataCloudQuery(*header, key, + meta_tags, start_ts, end_ts, last_sequence_info,//in-out result_page);} - if(err == 0){ + if(err == 0) { //manage emory for retur data if((result_header_t->numer_of_record_found = (uint32_t)result_page.size())){ result_data = ChaosMakeSharedPtr<Buffer>(); diff --git a/chaos/common/direct_io/channel/DirectIODeviceServerChannel.h b/chaos/common/direct_io/channel/DirectIODeviceServerChannel.h index b167668c56914a13664cd71655ff7bcbf33371f1..57dd22616f1baf92a9792ed3dd5b5b09e0b287ee 100644 --- a/chaos/common/direct_io/channel/DirectIODeviceServerChannel.h +++ b/chaos/common/direct_io/channel/DirectIODeviceServerChannel.h @@ -51,9 +51,10 @@ namespace chaos { \param channel_data the data sent by the device \synchronous_answer possible async answer (not used for now) */ - virtual int consumePutEvent(opcode_headers::DirectIODeviceChannelHeaderPutOpcode& header, - data::BufferSPtr channel_data, - uint32_t channel_data_len) + virtual int consumePutEvent(const std::string& key, + const uint8_t hst_tag, + const ChaosStringSetConstSPtr meta_tag_set, + data::BufferSPtr channel_data) {return -1;}; //! Receive the CDataWrapper forwarded by the channel that contains the helath data @@ -62,9 +63,10 @@ namespace chaos { \param header the header of the channel api \param channel_data contains the health data */ - virtual int consumeHealthDataEvent(opcode_headers::DirectIODeviceChannelHeaderPutOpcode& header, - data::BufferSPtr channel_data, - uint32_t channel_data_len) + virtual int consumeHealthDataEvent(const std::string& key, + const uint8_t hst_tag, + const ChaosStringSetConstSPtr meta_tag_set, + data::BufferSPtr channel_data) {return -1;}; //! Receive the key of the live data channel to read @@ -73,8 +75,8 @@ namespace chaos { in synchronous way the ansert to the client \param key_data the data of the key \param key_len the size of the key data - \param result_header - \param result_value + \param result_header the ehader that specify information of the result + \param result_value the values of the result */ virtual int consumeGetEvent(chaos::common::data::BufferSPtr key_data, uint32_t key_len, @@ -87,11 +89,11 @@ namespace chaos { Receive the keys set to fetch from the live cache and fill the synchronous_answer to return in synchronous way the result of the answre \param header header containing the information where send the answer - \param key_data the data of the key - \param key_len the size of the key data + \param keys the set of key to retrieve \param result_header - \param result_value is the merory that contains the bson document answer for each key in sequence, - \param result_value_size is the size of memory allocated into result_value pointer + \param result_header is the merory that contains the bson document answer for each key in sequence, + \param result_value is the size of memory allocated into result_value pointer + \param result_value if a key is not found in live an empy bson document is add. */ virtual int consumeGetEvent(opcode_headers::DirectIODeviceChannelHeaderMultiGetOpcode& header, @@ -104,17 +106,17 @@ namespace chaos { //! Execute a paged query into a time intervall /*! Execute a paged query in sinchronous way - \param header of the request containing the naswer information + \param query_header of the request containing the naswer information \param search_key the key that we need to query \param search_start_ts the start of the time that delimit the lower time stamp of result \param search_end_ts the end of the time stamp that delimit the upper time stamp of result - \param last_sequence_id is an in-out parameter, at in it specific the last found element, in output it need to be filled with the sequence information of the last item found \param */ virtual int consumeDataCloudQuery(opcode_headers::DirectIODeviceChannelHeaderOpcodeQueryDataCloud& query_header, const std::string& search_key, - uint64_t search_start_ts, - uint64_t search_end_ts, + const ChaosStringSet& meta_tags, + const uint64_t search_start_ts, + const uint64_t search_end_ts, opcode_headers::SearchSequence& last_element_found_seq, opcode_headers::QueryResultPage& result_page) {return -1;}; diff --git a/chaos/common/direct_io/impl/ZMQDirectIOClient.cpp b/chaos/common/direct_io/impl/ZMQDirectIOClient.cpp index 0cf7f0f580b184051e90a75459e110f21d743123..5b5feff3b8d6108a198d9bf30b5306cd034fc18e 100644 --- a/chaos/common/direct_io/impl/ZMQDirectIOClient.cpp +++ b/chaos/common/direct_io/impl/ZMQDirectIOClient.cpp @@ -130,10 +130,8 @@ void ZMQDirectIOClient::_releaseConnectionImpl(DirectIOClientConnection *connect DEBUG_CODE(ZMQDIOLDBG_ << "Release the connection for: " << connection_to_release->getServerDescription() <<" ptr:"<<std::hex<<(uint64_t)connection_to_release;) map_connections.deregisterElementKey(conn->getUniqueUUID()); delete(connection_to_release); - } - void ZMQDirectIOClient::freeObject(const DCKeyObjectContainer::TKOCElement& element) { if(!element.element) return; DirectIOClientConnection *connection = element.element; diff --git a/chaos/common/external_unit/http_adapter/HTTPBaseAdapter.h b/chaos/common/external_unit/http_adapter/HTTPBaseAdapter.h index 4900d03854019ffe59dfd7636b9fbc6939d6c17a..e93f9884d5999494ef03b47909bc8c7c5ba4768f 100644 --- a/chaos/common/external_unit/http_adapter/HTTPBaseAdapter.h +++ b/chaos/common/external_unit/http_adapter/HTTPBaseAdapter.h @@ -59,7 +59,7 @@ namespace chaos { nc(NULL), uri(), s_type(), - buffer(new chaos::common::data::CDataBuffer(ptr, size, true)){} + buffer(new chaos::common::data::CDataBuffer(ptr, size)){} }; typedef ChaosSharedPtr<ServerWorkRequest> ServerWorkRequestShrdPtr; diff --git a/chaos/common/external_unit/http_adapter/HTTPClientAdapter.cpp b/chaos/common/external_unit/http_adapter/HTTPClientAdapter.cpp index 6ac0bf4176dc2852690ef8d8e9a6a865062ad4ad..dc239a375ffc4215b01f50e848115f44d4e00dac 100644 --- a/chaos/common/external_unit/http_adapter/HTTPClientAdapter.cpp +++ b/chaos/common/external_unit/http_adapter/HTTPClientAdapter.cpp @@ -246,8 +246,7 @@ void HTTPClientAdapter::ev_handler(struct mg_connection *conn, } else { //accepted connection ca received data ChaosUniquePtr<CDataBuffer> buffer(new CDataBuffer((const char *)wm->data, - (uint32_t)wm->size, - true)); + (uint32_t)wm->size)); if((err = ci->class_instance->sendDataToEndpoint(*ci->ext_unit_conn, ChaosMoveOperator(buffer)))) { //weh don't have found the sriealizer diff --git a/chaos/common/external_unit/serialization/ExternalBSONExtJsonSerialization.cpp b/chaos/common/external_unit/serialization/ExternalBSONExtJsonSerialization.cpp index e54f0c5f9a2d89520519505a3b032ec12baab77e..d0f132db17fd8ea3eb9406ec3c66d63593692cfc 100644 --- a/chaos/common/external_unit/serialization/ExternalBSONExtJsonSerialization.cpp +++ b/chaos/common/external_unit/serialization/ExternalBSONExtJsonSerialization.cpp @@ -33,7 +33,7 @@ ExternalBSONExtJsonSerialization::~ExternalBSONExtJsonSerialization(){} ChaosUniquePtr<CDataBuffer> ExternalBSONExtJsonSerialization::serialize(const CDataWrapper& cdw_in) { const std::string json_result = cdw_in.getJSONString(); - return ChaosUniquePtr<CDataBuffer>(new CDataBuffer(json_result.c_str(), (uint32_t)json_result.size(), true)); + return ChaosUniquePtr<CDataBuffer>(new CDataBuffer(json_result.c_str(), (uint32_t)json_result.size())); } ChaosUniquePtr<CDataWrapper> ExternalBSONExtJsonSerialization::deserialize(const CDataBuffer& cdb_in) { diff --git a/chaos/common/external_unit/serialization/ExternalBSONJsonSerialization.cpp b/chaos/common/external_unit/serialization/ExternalBSONJsonSerialization.cpp index 774535b4d71529b7eb11e99480e6b718853685e2..bf6daa047a288c365b426ad205bef2a76e43d4ba 100644 --- a/chaos/common/external_unit/serialization/ExternalBSONJsonSerialization.cpp +++ b/chaos/common/external_unit/serialization/ExternalBSONJsonSerialization.cpp @@ -32,7 +32,7 @@ ExternalBSONJsonSerialization::~ExternalBSONJsonSerialization(){} ChaosUniquePtr<CDataBuffer> ExternalBSONJsonSerialization::serialize(const CDataWrapper& cdw_in) { const std::string json_result = cdw_in.getCompliantJSONString(); - return ChaosUniquePtr<CDataBuffer>(new CDataBuffer(json_result.c_str(), (uint32_t)json_result.size(), true)); + return ChaosUniquePtr<CDataBuffer>(new CDataBuffer(json_result.c_str(), (uint32_t)json_result.size())); } ChaosUniquePtr<CDataWrapper> ExternalBSONJsonSerialization::deserialize(const CDataBuffer& cdb_in) { diff --git a/chaos/common/healt_system/HealtManager.cpp b/chaos/common/healt_system/HealtManager.cpp index 78a21ba7a692f53e71a13b2711e3b2c466a2d4b6..3c35d599115b908892368cbecfb45a251c648a74 100644 --- a/chaos/common/healt_system/HealtManager.cpp +++ b/chaos/common/healt_system/HealtManager.cpp @@ -178,21 +178,21 @@ int HealtManager::sayHello() throw (chaos::CException) { void HealtManager::start() throw (chaos::CException) { AsyncCentralManager::getInstance()->addTimer(this, 0, (HEALT_FIRE_TIMEOUT / HEALT_FIRE_SLOTS)*1000); //say hello to mds -// int32_t retry =HELLO_PHASE_RETRY; -// while(retry--){ -// try{ -// if(sayHello()==0){ -// HM_INFO << "Found ("<<retry<<")"; -// //add timer to publish all node healt very 5 second -// -// return; -// } -// } catch(chaos::CException& ex) { -// DECODE_CHAOS_EXCEPTION(ex); -// } -// HM_INFO << "Retry hello again ("<<retry<<")"; -// } -// throw CException(-4, "Cannot find a valid MDS node" , __PRETTY_FUNCTION__); + // int32_t retry =HELLO_PHASE_RETRY; + // while(retry--){ + // try{ + // if(sayHello()==0){ + // HM_INFO << "Found ("<<retry<<")"; + // //add timer to publish all node healt very 5 second + // + // return; + // } + // } catch(chaos::CException& ex) { + // DECODE_CHAOS_EXCEPTION(ex); + // } + // HM_INFO << "Retry hello again ("<<retry<<")"; + // } + // throw CException(-4, "Cannot find a valid MDS node" , __PRETTY_FUNCTION__); } void HealtManager::stop() throw (chaos::CException) { @@ -201,10 +201,10 @@ void HealtManager::stop() throw (chaos::CException) { } void HealtManager::deinit() throw (chaos::CException) { -// if(mds_message_channel) { -// NetworkBroker::getInstance()->disposeMessageChannel(mds_message_channel); -// mds_message_channel = NULL; -// } + // if(mds_message_channel) { + // NetworkBroker::getInstance()->disposeMessageChannel(mds_message_channel); + // mds_message_channel = NULL; + // } } const ProcInfo& HealtManager::getLastProcInfo() { @@ -410,9 +410,9 @@ void HealtManager::addNodeMetricValue(const std::string& node_uid, }CHAOS_BOOST_LOCK_EXCEPTION_CACTH(lock_exception,) } -CDataWrapper* HealtManager::prepareNodeDataPack(NodeHealtSet& node_health_set, - uint64_t push_timestamp) { - CDataWrapper *node_data_pack = new CDataWrapper(); +CDWShrdPtr HealtManager::prepareNodeDataPack(NodeHealtSet& node_health_set, + uint64_t push_timestamp) { + CDWShrdPtr node_data_pack = ChaosMakeSharedPtr<CDataWrapper>(); int64_t cur_ts_usec = TimingUtil::getTimeStampInMicroseconds(); if(node_data_pack) { //add device unique id @@ -441,7 +441,7 @@ CDataWrapper* HealtManager::prepareNodeDataPack(NodeHealtSet& node_health_set, //scan all metrics BOOST_FOREACH(HealtNodeElementMap::value_type map_metric_element, node_health_set.map_metric) { //add metric to cdata wrapper - map_metric_element.second->addMetricToCD(node_data_pack); + map_metric_element.second->addMetricToCD(node_data_pack.get()); } } return node_data_pack; @@ -480,15 +480,15 @@ void HealtManager::_publish(const ChaosSharedPtr<NodeHealtSet>& heath_set, boost::unique_lock<boost::mutex> wl_io(mutex_publishing); //update infromation abour process updateProcInfo(); - + //send datapack - ChaosUniquePtr<chaos::common::data::CDataWrapper> data_pack(prepareNodeDataPack(*heath_set, - publish_ts)); + CDWShrdPtr data_pack = prepareNodeDataPack(*heath_set, + publish_ts); if(data_pack.get()) { //store data on cache SharedManagedDirecIoDataDriver::getInstance()->getSharedDriver()->storeHealthData(heath_set->node_publish_key, - *data_pack, - DataServiceNodeDefinitionType::DSStorageTypeLiveHistory); + ChaosMoveOperator(data_pack), + DataServiceNodeDefinitionType::DSStorageTypeLiveHistory); } else { HM_ERR << "Error allocating health datapack for node:" << heath_set->node_uid; } diff --git a/chaos/common/healt_system/HealtManager.h b/chaos/common/healt_system/HealtManager.h index a801a649dfada8b0c1e696bed87d885f31ff5016..c8d9709efe2e9c3215a5ac694629671b6d757fa5 100644 --- a/chaos/common/healt_system/HealtManager.h +++ b/chaos/common/healt_system/HealtManager.h @@ -42,7 +42,7 @@ namespace chaos { class SendHealthStatAsyncJob: public chaos::common::async_central::AsyncRunnable { - + protected: void run(); public: @@ -50,7 +50,7 @@ namespace chaos { ~SendHealthStatAsyncJob(); }; - //retry for 12h + //retry for 12h #define HELLO_PHASE_RETRY 12*3600 struct ProcInfo { double usr_time; @@ -164,8 +164,8 @@ namespace chaos { //! timer handler for check what slot needs to be fired void timeout(); - chaos::common::data::CDataWrapper* prepareNodeDataPack(NodeHealtSet& node_health_set, - uint64_t push_timestamp); + chaos::common::data::CDWShrdPtr prepareNodeDataPack(NodeHealtSet& node_health_set, + uint64_t push_timestamp); //!protected mehoto to talk with mds to receive the cds server where publish the data int sayHello() throw (chaos::CException); @@ -272,7 +272,7 @@ namespace chaos { //!publish health information for a node /*! \param node_uid the node identification id for which we need to - publish the healt data. + publish the healt data. */ void publishNodeHealt(const std::string& node_uid); }; diff --git a/chaos/common/healt_system/HealtMetric.cpp b/chaos/common/healt_system/HealtMetric.cpp index 5c7d77120bcfd76a5725af9aa18b200ff7876bd4..9dd6b0fed2f7bc833c92128b729d2b6a4651e92d 100644 --- a/chaos/common/healt_system/HealtMetric.cpp +++ b/chaos/common/healt_system/HealtMetric.cpp @@ -58,4 +58,4 @@ HealtMetric(_name, value(""){} void StringHealtMetric::addMetricToCD(CDataWrapper& data) { data.addStringValue(name, value); -} \ No newline at end of file +} diff --git a/chaos/common/io/IODataDriver.cpp b/chaos/common/io/IODataDriver.cpp index 8c7c61f12fad40316a1b1986a57005ec484cc5d5..2d77e01eb63424c5c5774f7dca49b5a0458bded3 100644 --- a/chaos/common/io/IODataDriver.cpp +++ b/chaos/common/io/IODataDriver.cpp @@ -35,23 +35,6 @@ void IODataDriver::deinit() throw(CException) { } -/*--------------------------------------------------------------------------------- - - ---------------------------------------------------------------------------------*/ -void IODataDriver::storeData(const std::string& key, - CDataWrapper *dataToStore, - DataServiceNodeDefinitionType::DSStorageType storage_type, - bool delete_data_to_store) throw(CException){ - CHAOS_ASSERT(dataToStore) -// boost::mutex::scoped_lock l(iomutex); - - SerializationBuffer* serialization = dataToStore->getBSONData(); - - storeRawData(key, serialization, storage_type); - - if(delete_data_to_store){delete(dataToStore);} -} - int IODataDriver::removeData(const std::string& key, uint64_t start_ts, uint64_t end_ts) throw(CException) { diff --git a/chaos/common/io/IODataDriver.h b/chaos/common/io/IODataDriver.h index d7a2679a0811efdd106b14c4b807560f4baa00ce..7fee824b620f324cff5eb44652ea7a4b5eb1f92c 100644 --- a/chaos/common/io/IODataDriver.h +++ b/chaos/common/io/IODataDriver.h @@ -69,14 +69,15 @@ namespace chaos{ * This method cache all object passed to driver * \param storage_type one of values as @DataServiceNodeDefinitionType::DSStorageType */ - void storeData(const std::string& key, - chaos_data::CDataWrapper *dataToStore, - DataServiceNodeDefinitionType::DSStorageType storage_type, - bool delete_data_to_store = true) throw(CException); + virtual void storeData(const std::string& key, + chaos_data::CDWShrdPtr dataToStore, + DataServiceNodeDefinitionType::DSStorageType storage_type, + const ChaosStringSet& tag_set = ChaosStringSet()) throw(CException) = 0; virtual void storeHealthData(const std::string& key, - chaos_data::CDataWrapper& dataToStore, - DataServiceNodeDefinitionType::DSStorageType storage_type) throw(CException) = 0; + chaos_data::CDWShrdPtr dataToStore, + DataServiceNodeDefinitionType::DSStorageType storage_type, + const ChaosStringSet& tag_set = ChaosStringSet()) throw(CException) = 0; //!remove data between the time intervall (extreme included) operation is not undoable virtual int removeData(const std::string& key, @@ -97,13 +98,6 @@ namespace chaos{ virtual utility::ArrayPointer<chaos_data::CDataWrapper>* retriveData(const std::string& key) throw(CException); - /*! - * This method store a buffer into live cached - */ - virtual void storeRawData(const std::string& key, - chaos_data::SerializationBuffer *serialization, - DataServiceNodeDefinitionType::DSStorageType storage_type) throw(CException) = 0; - /*! * This method retrive the cached object by CSDawrapperUsed as query key and * return a pointer to the class ArrayPointer of CDataWrapper type @@ -135,12 +129,18 @@ namespace chaos{ //! perform a query since and virtual QueryCursor *performQuery(const std::string& key, - uint64_t start_ts, - uint64_t end_ts,uint32_t page_len=DEFAULT_PAGE_LEN) = 0; - + const uint64_t start_ts, + const uint64_t end_ts, + const ChaosStringSet& meta_tags, + const uint32_t page_len=DEFAULT_PAGE_LEN) = 0; + virtual QueryCursor *performQuery(const std::string& key, - uint64_t start_ts, - uint64_t end_ts,uint64_t sequid,uint64_t runid,uint32_t page=DEFAULT_PAGE_LEN)=0; + const uint64_t start_ts, + const uint64_t end_ts, + const uint64_t sequid, + const uint64_t runid, + const ChaosStringSet& meta_tags, + const uint32_t page=DEFAULT_PAGE_LEN)=0; virtual void releaseQuery(QueryCursor *query) = 0; }; diff --git a/chaos/common/io/IODirectIODriver.cpp b/chaos/common/io/IODirectIODriver.cpp index 8b71cd8dfca804a60610b9cdf559e4ad3eec9654..7b0fe88b67a5cae84255b7ef872cc1d1283b8c04 100644 --- a/chaos/common/io/IODirectIODriver.cpp +++ b/chaos/common/io/IODirectIODriver.cpp @@ -41,6 +41,7 @@ using namespace chaos; using namespace chaos::common::io; +using namespace chaos::common::data; using namespace chaos::common::utility; using namespace std; @@ -136,49 +137,47 @@ void IODirectIODriver::deinit() throw(CException) { IODataDriver::deinit(); } -void IODirectIODriver::storeRawData(const std::string& key, - chaos::common::data::SerializationBuffer *serialization, - DataServiceNodeDefinitionType::DSStorageType storage_type) throw(CException) { - CHAOS_ASSERT(serialization) +void IODirectIODriver::storeData(const std::string& key, + CDWShrdPtr data_to_store, + DataServiceNodeDefinitionType::DSStorageType storage_type, + const ChaosStringSet& tag_set) throw(CException) { int err = 0; + CHAOS_ASSERT(data_to_store) ChaosReadLock rl(mutext_feeder); - //if(next_client->connection->getState() == chaos_direct_io::DirectIOClientConnectionStateType::DirectIOClientConnectionEventConnected) IODirectIODriverClientChannels *next_client = static_cast<IODirectIODriverClientChannels*>(connectionFeeder.getService()); - serialization->disposeOnDelete = !next_client; + SerializationBufferUPtr serialization = data_to_store->getBSONData(); if(next_client) { - //free the packet serialization->disposeOnDelete = false; if((err = (int)next_client->device_client_channel->storeAndCacheDataOutputChannel(key, (void*)serialization->getBufferPtr(), (uint32_t)serialization->getBufferLen(), - storage_type))) { - IODirectIODriver_LERR_ << "Error storing data into data service "<<next_client->connection->getServerDescription()<<" with code:" << err; + storage_type, + tag_set))) { + IODirectIODriver_LERR_ << CHAOS_FORMAT("Error storing data into data service %1% with code %2%",%next_client->connection->getServerDescription()%err); } } else { DEBUG_CODE(IODirectIODriver_DLDBG_ << "No available socket->loose packet, key '"<<key<<"' storage_type:"<<storage_type<<" buffer len:"<<serialization->getBufferLen()); } - delete(serialization); } - void IODirectIODriver::storeHealthData(const std::string& key, - chaos_data::CDataWrapper& dataToStore, - DataServiceNodeDefinitionType::DSStorageType storage_type) throw(CException) { + CDWShrdPtr data_to_store, + DataServiceNodeDefinitionType::DSStorageType storage_type, + const ChaosStringSet& tag_set) throw(CException) { int err = 0; + CHAOS_ASSERT(data_to_store) try{ ChaosReadLock rl(mutext_feeder); IODirectIODriverClientChannels *next_client = static_cast<IODirectIODriverClientChannels*>(connectionFeeder.getService()); - - ChaosUniquePtr<chaos::common::data::SerializationBuffer> serialization(dataToStore.getBSONData()); - - if(next_client && - serialization.get()) { + SerializationBufferUPtr serialization = data_to_store->getBSONData(); + if(next_client) { serialization->disposeOnDelete = false; if((err = (int)next_client->device_client_channel->storeAndCacheHealthData(key, (void*)serialization->getBufferPtr(), (uint32_t)serialization->getBufferLen(), - storage_type))) { - IODirectIODriver_LERR_ << "Error storing health data into data service "<<next_client->connection->getServerDescription()<<" with code:" << err; + storage_type, + tag_set))) { + IODirectIODriver_LERR_ << CHAOS_FORMAT("Error storing data into data service %1% with code %2%",%next_client->connection->getServerDescription()%err); } } else { DEBUG_CODE(IODirectIODriver_DLDBG_ << "No available socket->loose packet, key '"<<key<<"' storage_type:"<<storage_type<<" buffer len:"<<serialization->getBufferLen()); @@ -395,14 +394,16 @@ void IODirectIODriver::handleEvent(chaos_direct_io::DirectIOClientConnection *cl } QueryCursor *IODirectIODriver::performQuery(const std::string& key, - uint64_t start_ts, - uint64_t end_ts, - uint32_t page_len) { + const uint64_t start_ts, + const uint64_t end_ts, + const ChaosStringSet& meta_tags, + const uint32_t page_len) { QueryCursor *q = new QueryCursor(UUIDUtil::generateUUID(), connectionFeeder, key, start_ts, end_ts, + meta_tags, page_len); if(q) { //add query to map @@ -414,11 +415,11 @@ QueryCursor *IODirectIODriver::performQuery(const std::string& key, return q; } QueryCursor *IODirectIODriver::performQuery(const std::string& key, - uint64_t start_ts, - uint64_t end_ts, - uint64_t sequid, - uint64_t runid, - + const uint64_t start_ts, + const uint64_t end_ts, + const uint64_t sequid, + const uint64_t runid, + const ChaosStringSet& meta_tags, uint32_t page_len) { QueryCursor *q = new QueryCursor(UUIDUtil::generateUUID(), connectionFeeder, @@ -427,6 +428,7 @@ QueryCursor *IODirectIODriver::performQuery(const std::string& key, end_ts, sequid, runid, + meta_tags, page_len); if(q) { //add query to map diff --git a/chaos/common/io/IODirectIODriver.h b/chaos/common/io/IODirectIODriver.h index 05316058d3178355a419fee4160213843976e53b..aef452cdc388a354ca726e8805594fe468b40948 100644 --- a/chaos/common/io/IODirectIODriver.h +++ b/chaos/common/io/IODirectIODriver.h @@ -126,15 +126,17 @@ namespace chaos{ void deinit() throw(CException); void storeHealthData(const std::string& key, - chaos_data::CDataWrapper & dataToStore, - DataServiceNodeDefinitionType::DSStorageType storage_type) throw(CException); + chaos_data::CDWShrdPtr data_to_store, + DataServiceNodeDefinitionType::DSStorageType storage_type, + const ChaosStringSet& tag_set = ChaosStringSet()) throw(CException); /* * storeRawData */ - void storeRawData(const std::string& key, - chaos_data::SerializationBuffer *serialization, - DataServiceNodeDefinitionType::DSStorageType storage_type) throw(CException); + void storeData(const std::string& key, + chaos_data::CDWShrdPtr data_to_store, + DataServiceNodeDefinitionType::DSStorageType storage_type, + const ChaosStringSet& tag_set = ChaosStringSet()) throw(CException); int removeData(const std::string& key, uint64_t start_ts, @@ -160,11 +162,17 @@ namespace chaos{ QueryCursor *performQuery(const std::string& key, uint64_t start_ts, - uint64_t end_ts,uint32_t page=DEFAULT_PAGE_LEN); - + uint64_t end_ts, + const ChaosStringSet& meta_tags = ChaosStringSet(), + uint32_t page=DEFAULT_PAGE_LEN); + QueryCursor *performQuery(const std::string& key, uint64_t start_ts, - uint64_t end_ts,uint64_t sequid,uint64_t runid,uint32_t page=DEFAULT_PAGE_LEN); + uint64_t end_ts, + uint64_t sequid, + uint64_t runid, + const ChaosStringSet& meta_tags = ChaosStringSet(), + uint32_t page=DEFAULT_PAGE_LEN); void releaseQuery(QueryCursor *query_cursor); }; diff --git a/chaos/common/io/QueryCursor.cpp b/chaos/common/io/QueryCursor.cpp index 8d8877baec5bfc7a394fe2b7d9c613a585df8b9f..1985ad57918182562872813ec927e412158e5eb9 100644 --- a/chaos/common/io/QueryCursor.cpp +++ b/chaos/common/io/QueryCursor.cpp @@ -59,6 +59,7 @@ QueryCursor::QueryCursor(const std::string& _query_id, const std::string& _node_id, uint64_t _start_ts, uint64_t _end_ts, + const ChaosStringSet& _meta_tags, uint32_t default_page_len): query_id(_query_id), connection_feeder(_connection_feeder), @@ -69,7 +70,9 @@ page_len(default_page_len), phase(QueryPhaseNotStarted), start_seq(0), runid_seq(0), +meta_tags(_meta_tags), api_error(0){} + QueryCursor::QueryCursor(const std::string& _query_id, URLServiceFeeder& _connection_feeder, const std::string& _node_id, @@ -77,7 +80,7 @@ QueryCursor::QueryCursor(const std::string& _query_id, uint64_t _end_ts, uint64_t _sequid, uint64_t _runid, - + const ChaosStringSet& _meta_tags, uint32_t default_page_len): query_id(_query_id), connection_feeder(_connection_feeder), @@ -88,6 +91,7 @@ page_len(default_page_len), phase(QueryPhaseNotStarted), start_seq(_sequid), runid_seq(_runid), +meta_tags(_meta_tags), api_error(0){ if(_sequid>0){ phase = QueryPhaseStarted; @@ -153,6 +157,7 @@ int64_t QueryCursor::fetchNewPage() { return 0; } if((api_error = next_client->device_client_channel->queryDataCloud(node_id, + meta_tags, start_ts, end_ts, page_len, diff --git a/chaos/common/io/QueryCursor.h b/chaos/common/io/QueryCursor.h index dda9a871f3a7cd2dd2c38435782ae454e25ddf3e..60308990e8122934bf4e80919452c2fe03c5518f 100644 --- a/chaos/common/io/QueryCursor.h +++ b/chaos/common/io/QueryCursor.h @@ -64,7 +64,7 @@ namespace chaos { uint64_t end_ts; uint64_t start_seq; uint64_t runid_seq; - + const ChaosStringSet meta_tags; //!is the reuslt page dimension uint32_t page_len; QueryPhase phase; @@ -77,6 +77,7 @@ namespace chaos { const std::string& _node_id, uint64_t _start_ts, uint64_t _end_ts, + const ChaosStringSet& _meta_tags, uint32_t page_len=DEFAULT_PAGE_LEN); QueryCursor(const std::string& _query_id, @@ -86,7 +87,7 @@ namespace chaos { uint64_t _end_ts, uint64_t _sequid, uint64_t _runid, - + const ChaosStringSet& _meta_tags, uint32_t page_len=DEFAULT_PAGE_LEN); ~QueryCursor(); diff --git a/chaos/common/message/MDSMessageChannel.cpp b/chaos/common/message/MDSMessageChannel.cpp index b57a0461ba31b664be09dc2bf36e3cc297844438..fe994021e78a26ae0bd2416639c4bbb0e6637c9e 100644 --- a/chaos/common/message/MDSMessageChannel.cpp +++ b/chaos/common/message/MDSMessageChannel.cpp @@ -77,6 +77,21 @@ void MDSMessageChannel::sendHeartBeatForDeviceID(const std::string& identificati hb_message.get()); } +int MDSMessageChannel::sendEchoMessage(CDataWrapper& data, CDWUniquePtr& result) { + int err = 0; + CDWUniquePtr message(new CDataWrapper()); + data.copyAllTo(*message); + ChaosUniquePtr<MultiAddressMessageRequestFuture> request_future = sendRequestWithFuture(NodeDomainAndActionRPC::RPC_DOMAIN, + NodeDomainAndActionRPC::ACTION_ECHO_TEST, + message.release()); + if(request_future->wait()) { + result.reset(request_future->detachResult()); + } else { + result.reset(); + err = request_future->getError(); + } + return err; +} //! Send unit server CU states to MDS int MDSMessageChannel::sendUnitServerCUStates(CDataWrapper& deviceDataset, @@ -295,18 +310,12 @@ int MDSMessageChannel::loadSnapshotNodeDataset(const std::string& snapname, std::string ret=datasetTypeToHuman(val->getUInt32Value(chaos::DataPackCommonKey::DPCK_DATASET_TYPE)); data_set.addCSDataValue(ret,*val); } - } } - - } else { err = -1; } - - } - return err; } int MDSMessageChannel::getFullNodeDescription(const std::string& identification_id, diff --git a/chaos/common/message/MDSMessageChannel.h b/chaos/common/message/MDSMessageChannel.h index dacae95de30d3eb49843e2964cf4d6a538ac453d..eb8f8267b2129b3253422d7f2a8e0318e7018ce7 100644 --- a/chaos/common/message/MDSMessageChannel.h +++ b/chaos/common/message/MDSMessageChannel.h @@ -67,6 +67,9 @@ namespace chaos { */ void sendHeartBeatForDeviceID(const std::string& identification_id); + //!Send echo message to one of mds + int sendEchoMessage(CDataWrapper& data, chaos::common::data::CDWUniquePtr& result); + //! Send Unit server registration to MDS /*! Perform the registration of the unit server diff --git a/chaos/common/rpc/zmq/ZMQClient.cpp b/chaos/common/rpc/zmq/ZMQClient.cpp index 53e7fdcdfe1bcb56da4de984579b9993926b8439..fb297893cbfc83167b0a7dd062f82588b1bb6915 100644 --- a/chaos/common/rpc/zmq/ZMQClient.cpp +++ b/chaos/common/rpc/zmq/ZMQClient.cpp @@ -20,6 +20,7 @@ */ #include <chaos/common/global.h> #include <chaos/common/rpc/zmq/ZMQClient.h> +#include <chaos/common/rpc/zmq/ZmqMemoryManagement.h> #include <chaos/common/chaos_constants.h> #include <chaos/common/configuration/GlobalConfiguration.h> #include <string> @@ -45,7 +46,10 @@ using namespace boost::algorithm; DEFINE_CLASS_FACTORY(ZMQClient, RpcClient); static void my_free (void *data, void *hint) { - free(data); + if(hint) { + MemoryManagement *tmp = static_cast<MemoryManagement*>(hint); + delete(tmp); + } else {free(data);}; } @@ -251,7 +255,7 @@ void ZMQClient::processBufferElement(NetworkForwardInfo *messageInfo, ElementMan ZMQSocketPool::ResourceSlot *socket_info = NULL; messageInfo->message->addBoolValue("syncrhonous_call", RpcClient::syncrhonous_call); - ChaosUniquePtr<chaos::common::data::SerializationBuffer> callSerialization(messageInfo->message->getBSONData()); + CDWShrdPtr message_data = CDWShrdPtr(messageInfo->message.release()); try{ socket_info = getSocketForNFI(messageInfo); if(socket_info == NULL){ @@ -273,9 +277,7 @@ void ZMQClient::processBufferElement(NetworkForwardInfo *messageInfo, ElementMan return; } - //detach buffer from carrier object so we don't need to copy anymore the data - callSerialization->disposeOnDelete = false; - if((err = zmq_msg_init_data(&message, (void*)callSerialization->getBufferPtr(), callSerialization->getBufferLen(), my_free, NULL)) == -1) { + if((err = zmq_msg_init_data(&message, (void*)message_data->getBSONRawData(), message_data->getBSONRawSize(), my_free, new MemoryManagement(message_data))) == -1) { int32_t sent_error = zmq_errno(); std::string error_message =zmq_strerror(sent_error); ZMQC_LERR << "Error allocating zmq messagecode:" << sent_error << " message:" <<error_message; diff --git a/chaos/common/rpc/zmq/ZMQServer.cpp b/chaos/common/rpc/zmq/ZMQServer.cpp index c78a8a204df82f9a5e7a582e122d8da07fe26c97..43eaa2d2a37ad0ed44ecfa8d1f84b27e01f6d5dc 100644 --- a/chaos/common/rpc/zmq/ZMQServer.cpp +++ b/chaos/common/rpc/zmq/ZMQServer.cpp @@ -21,6 +21,7 @@ #include <chaos/common/global.h> #include <chaos/common/rpc/zmq/ZMQServer.h> +#include <chaos/common/rpc/zmq/ZmqMemoryManagement.h> #include <chaos/common/chaos_constants.h> #include <chaos/common/exception/exception.h> @@ -36,7 +37,10 @@ using namespace boost; using namespace chaos::common::data; static void my_free (void *data, void *hint) { - free (data); + if(hint) { + MemoryManagement *tmp = static_cast<MemoryManagement*>(hint); + delete(tmp); + } else {free(data);}; } DEFINE_CLASS_FACTORY(ZMQServer, RpcServer); @@ -218,7 +222,7 @@ void ZMQServer::worker() { } else { if(zmq_msg_size(&request)>0) { ZMQS_LDBG << "Message Received"; - ChaosUniquePtr<chaos::common::data::CDataWrapper> result_data_pack; + CDWShrdPtr result_data_pack; message_data.reset(new CDataWrapper((const char*)zmq_msg_data(&request))); //dispatch the command if(message_data->hasKey("syncrhonous_call") && @@ -227,10 +231,8 @@ void ZMQServer::worker() { } else { result_data_pack.reset(command_handler->dispatchCommand(message_data.release())); } - //get serailizaiton - ChaosUniquePtr<SerializationBuffer> result(result_data_pack->getBSONData()); //create zmq message - err = zmq_msg_init_data(&response, (void*)result->getBufferPtr(), result->getBufferLen(), my_free, NULL); + err = zmq_msg_init_data(&response, (void*)result_data_pack->getBSONRawData(), result_data_pack->getBSONRawSize(), my_free, new MemoryManagement(ChaosMoveOperator(result_data_pack))); if(err == -1) { //there was an error int32_t sent_error = zmq_errno(); @@ -238,10 +240,6 @@ void ZMQServer::worker() { ZMQS_LERR << "Error initializing the response message with code:" << sent_error << " message:" <<error_message; } else { //no error on create message - //at this time memory is managed by zmq - result->disposeOnDelete = false; - //ChaosUniquePtr<SerializationBuffer> result(result_data_pack->getBSONData()); - //result->disposeOnDelete = false; ZMQS_LDBG << "Send ack"; err = zmq_sendmsg(receiver, &response, ZMQ_NOBLOCK); if(err == -1) { @@ -252,14 +250,13 @@ void ZMQServer::worker() { ZMQS_LDBG << "ACK Sent"; } } - }else { + } else { ZMQS_LDBG << "Empty message received"; } } err = zmq_msg_close(&request); err = zmq_msg_close(&response); - } catch (CException& ex) { DECODE_CHAOS_EXCEPTION(ex) } diff --git a/chaos/ui_toolkit/LowLevelApi/LLDataApi.cpp b/chaos/common/rpc/zmq/ZmqMemoryManagement.h similarity index 61% rename from chaos/ui_toolkit/LowLevelApi/LLDataApi.cpp rename to chaos/common/rpc/zmq/ZmqMemoryManagement.h index 03a154bce952e7de9038d7b3116139f4074db786..2cd8e70abb3c66387e0b5dfe35784be4638c4f39 100644 --- a/chaos/ui_toolkit/LowLevelApi/LLDataApi.cpp +++ b/chaos/common/rpc/zmq/ZmqMemoryManagement.h @@ -18,16 +18,19 @@ * See the Licence for the specific language governing * permissions and limitations under the Licence. */ -#include "LLDataApi.h" -#include "../../common/global.h" +#ifndef CHAOSFramework_ZmqMemoryManagement_h +#define CHAOSFramework_ZmqMemoryManagement_h -using namespace chaos; -using namespace chaos::ui; - -LLDataApi::LLDataApi() { +#include <chaos/common/data/CDataWrapper.h> +namespace chaos { + //!keep memory alive untile zmw require to dispose it + struct MemoryManagement { + chaos::common::data::CDWShrdPtr data; + MemoryManagement(chaos::common::data::CDWShrdPtr _data): + data(ChaosMoveOperator(_data)){} + }; } -LLDataApi::~LLDataApi() { -} +#endif /* CHAOSFramework_ZmqMemoryManagement_h */ diff --git a/chaos/common/state_flag/StateFlagCatalog.cpp b/chaos/common/state_flag/StateFlagCatalog.cpp index 4d82582855ae2d482a555b7d234456e9e3e345d0..dadb7209191bc93db0fa128be1de4517b8e589fb 100644 --- a/chaos/common/state_flag/StateFlagCatalog.cpp +++ b/chaos/common/state_flag/StateFlagCatalog.cpp @@ -203,11 +203,11 @@ void StateFlagCatalog::getFlagsForSeverity(StateFlagServerity severity, } #pragma mark Serialization Method -ChaosUniquePtr<chaos::common::data::CDataBuffer> StateFlagCatalog::getRawFlagsLevel() { +CDBufferUniquePtr StateFlagCatalog::getRawFlagsLevel() { //read lock on owned catalog LockableObjectReadLock_t rl; catalog_container.getReadLock(rl); - ChaosUniquePtr<CDataBuffer> result; + CDBufferUniquePtr result; char * raw_description = (char*)malloc(catalog_container().size()); if(raw_description) { //retrieve the ordered index @@ -218,16 +218,16 @@ ChaosUniquePtr<chaos::common::data::CDataBuffer> StateFlagCatalog::getRawFlagsLe it++){ raw_description[(*it)->seq_id] = static_cast<char>((*it)->status_flag->getCurrentLevel()); } - result.reset(CDataBuffer::newOwnBufferFromBuffer(raw_description, - (uint32_t)catalog_container().size())); + result = CDataBuffer::newOwnBufferFromBuffer(raw_description, + (uint32_t)catalog_container().size()); } return result; } -void StateFlagCatalog::setApplyRawFlagsValue(ChaosUniquePtr<chaos::common::data::CDataBuffer>& raw_level) { +void StateFlagCatalog::setApplyRawFlagsValue(CDBufferUniquePtr& raw_level) { if(raw_level.get() == NULL) return; const char * buffer = raw_level->getBuffer(); - uint32_t buffer_size = raw_level->getBufferSize(); + uint32_t buffer_size = (uint32_t)raw_level->getBufferSize(); if(buffer_size != catalog_container().size()) return; LockableObjectWriteLock_t wl; diff --git a/chaos/common/state_flag/StateFlagCatalog.h b/chaos/common/state_flag/StateFlagCatalog.h index d4a1885e461d4a0e43385a00b722b8d8c5e015df..9392093d4e4365cc6619ea5c9963672180296412 100644 --- a/chaos/common/state_flag/StateFlagCatalog.h +++ b/chaos/common/state_flag/StateFlagCatalog.h @@ -182,10 +182,10 @@ namespace chaos { VectorStateFlag& found_flag); //!get data buffer describing all flag with own level - ChaosUniquePtr<chaos::common::data::CDataBuffer> getRawFlagsLevel(); + chaos::common::data::CDBufferUniquePtr getRawFlagsLevel(); //!set the falg value base on array description - void setApplyRawFlagsValue(ChaosUniquePtr<chaos::common::data::CDataBuffer>& raw_level); + void setApplyRawFlagsValue(chaos::common::data::CDBufferUniquePtr& raw_level); //!return the number of status flag in the catalog const size_t size() const; diff --git a/chaos/common/utility/DataBuffer.h b/chaos/common/utility/DataBuffer.h index 0080691446943168abcf7d9d4345f8959ccc0aae..e561a1bc15e14ee2ef62db0edd5221849cb8c85d 100644 --- a/chaos/common/utility/DataBuffer.h +++ b/chaos/common/utility/DataBuffer.h @@ -34,8 +34,6 @@ namespace chaos { namespace common { namespace utility { -#define CHECK_AND_GROW(m) if(cursor+m>=ChaosBuffer<Allocator>::size) {ChaosBuffer<Allocator>::grow(m);} - //! class DataBuffer { data::Buffer buffer; @@ -76,6 +74,28 @@ namespace chaos { cursor += 1; } + void writeInt8(const int8_t& number) { + buffer.append(&number, sizeof(int8_t)); + cursor+=sizeof(int8_t); + } + + int8_t readInt8() { + int8_t result = *(int8_t*)(buffer.data() + cursor); + cursor+=sizeof(int8_t); + return result; + } + + void writeInt16(const int16_t& number) { + buffer.append(&number, sizeof(int16_t)); + cursor+=sizeof(int16_t); + } + + int16_t readInt16() { + int16_t result = *(int16_t*)(buffer.data() + cursor); + cursor+=sizeof(int16_t); + return result; + } + void writeInt32(const int32_t& number) { buffer.append(&number, sizeof(int32_t)); cursor+=sizeof(int32_t); @@ -124,6 +144,12 @@ namespace chaos { uint32_t getCursorLocation() { return cursor; } + + chaos::common::data::BufferSPtr detachBuffer() { + chaos::common::data::BufferSPtr result = ChaosMakeSharedPtr<chaos::common::data::Buffer>(); + buffer.swap(*result); + return result; + } }; } } diff --git a/chaos/cu_toolkit/control_manager/AbstractControlUnit.cpp b/chaos/cu_toolkit/control_manager/AbstractControlUnit.cpp index 05e44c2f27d1564517f53eb567fe47fe1a52677d..c71149b7e6aed9dd86988b3565a63b97d225f6fc 100644 --- a/chaos/cu_toolkit/control_manager/AbstractControlUnit.cpp +++ b/chaos/cu_toolkit/control_manager/AbstractControlUnit.cpp @@ -38,6 +38,7 @@ using namespace boost::uuids; using namespace chaos::common::data; +using namespace chaos::common::data::structured; using namespace chaos::common::alarm; using namespace chaos::common::utility; using namespace chaos::common::property; @@ -191,6 +192,10 @@ void AbstractControlUnit::_initPropertyGroup() { pg_abstract_cu.addProperty(DataServiceNodeDefinitionKey::DS_STORAGE_TYPE, "Set the control unit storage type", DataType::TYPE_INT32, 0, CDataVariant((int32_t)0)); pg_abstract_cu.addProperty(DataServiceNodeDefinitionKey::DS_STORAGE_LIVE_TIME, "Set the control unit storage type", DataType::TYPE_INT64, 0, CDataVariant((int64_t)0)); pg_abstract_cu.addProperty(DataServiceNodeDefinitionKey::DS_STORAGE_HISTORY_TIME, "Set the control unit storage type", DataType::TYPE_INT64, 0, CDataVariant((int64_t)0)); + // CDWUniquePtr burst_type_desc(new CDataWrapper()); + // burst_type_desc->addInt32Value(DataServiceNodeDefinitionKey::DS_HISTORY_BURST_TYPE, DataServiceNodeDefinitionType::DSStorageBurstTypeUndefined); + // pg_abstract_cu.addProperty(DataServiceNodeDefinitionKey::DS_HISTORY_BURST, "Specify if the restore operation need to be done as real operation or not", DataType::TYPE_CLUSTER,0, CDataVariant(burst_type_desc.release())); + pg_abstract_cu.addProperty(ControlUnitDatapackSystemKey::THREAD_SCHEDULE_DELAY, "Set the control unit step repeat time in microseconds", DataType::TYPE_INT64, 0, CDataVariant((int64_t)1000000));//set to one seconds pg_abstract_cu.addProperty(ControlUnitPropertyKey::INIT_RESTORE_OPTION, "Specify the restore type operatio to do durint initialization phase", DataType::TYPE_INT32, 0, CDataVariant((int32_t)0)); pg_abstract_cu.addProperty(ControlUnitPropertyKey::INIT_RESTORE_APPLY, "Specify if the restore operation need to be done as real operation or not", DataType::TYPE_BOOLEAN,0, CDataVariant((bool)false)); @@ -280,56 +285,63 @@ void AbstractControlUnit::_defineActionAndDataset(CDataWrapper& setup_configurat //for now we need only to add custom action for expose to rpc //input element of the dataset AbstActionDescShrPtr - actionDescription = addActionDescritionInstance<AbstractControlUnit>(this, - &AbstractControlUnit::_setDatasetAttribute, - ControlUnitNodeDomainAndActionRPC::CONTROL_UNIT_APPLY_INPUT_DATASET_ATTRIBUTE_CHANGE_SET, - "method for set the input element for the dataset"); + action_description = addActionDescritionInstance<AbstractControlUnit>(this, + &AbstractControlUnit::_setDatasetAttribute, + ControlUnitNodeDomainAndActionRPC::CONTROL_UNIT_APPLY_INPUT_DATASET_ATTRIBUTE_CHANGE_SET, + "method for set the input element for the dataset"); //expose updateConfiguration Methdo to rpc - actionDescription = addActionDescritionInstance<AbstractControlUnit>(this, - &AbstractControlUnit::updateConfiguration, - NodeDomainAndActionRPC::ACTION_UPDATE_PROPERTY, - "Update control unit property"); - - actionDescription = addActionDescritionInstance<AbstractControlUnit>(this, - &AbstractControlUnit::_init, - NodeDomainAndActionRPC::ACTION_NODE_INIT, - "Perform the control unit initialization"); - - actionDescription = addActionDescritionInstance<AbstractControlUnit>(this, - &AbstractControlUnit::_deinit, - NodeDomainAndActionRPC::ACTION_NODE_DEINIT - , - "Perform the control unit deinitialization"); - actionDescription = addActionDescritionInstance<AbstractControlUnit>(this, - &AbstractControlUnit::_start, - NodeDomainAndActionRPC::ACTION_NODE_START, - "Start the control unit scheduling"); - - actionDescription = addActionDescritionInstance<AbstractControlUnit>(this, - &AbstractControlUnit::_stop, - NodeDomainAndActionRPC::ACTION_NODE_STOP, - "Stop the control unit scheduling"); - - actionDescription = addActionDescritionInstance<AbstractControlUnit>(this, - &AbstractControlUnit::_recover, - NodeDomainAndActionRPC::ACTION_NODE_RECOVER, - "Recovery a recoverable state, going to the last state"); - - actionDescription = addActionDescritionInstance<AbstractControlUnit>(this, - &AbstractControlUnit::_unitRestoreToSnapshot, - NodeDomainAndActionRPC::ACTION_NODE_RESTORE, - "Restore contorl unit to a snapshot tag"); - - actionDescription = addActionDescritionInstance<AbstractControlUnit>(this, - &AbstractControlUnit::_getState, - NodeDomainAndActionRPC::ACTION_NODE_GET_STATE, - "Get the state of the running control unit"); - - actionDescription = addActionDescritionInstance<AbstractControlUnit>(this, - &AbstractControlUnit::_getInfo, - NodeDomainAndActionRPC::ACTION_CU_GET_INFO, - "Get the information about running control unit"); + action_description = addActionDescritionInstance<AbstractControlUnit>(this, + &AbstractControlUnit::updateConfiguration, + NodeDomainAndActionRPC::ACTION_UPDATE_PROPERTY, + "Update control unit property"); + + action_description = addActionDescritionInstance<AbstractControlUnit>(this, + &AbstractControlUnit::_init, + NodeDomainAndActionRPC::ACTION_NODE_INIT, + "Perform the control unit initialization"); + + action_description = addActionDescritionInstance<AbstractControlUnit>(this, + &AbstractControlUnit::_deinit, + NodeDomainAndActionRPC::ACTION_NODE_DEINIT + , + "Perform the control unit deinitialization"); + action_description = addActionDescritionInstance<AbstractControlUnit>(this, + &AbstractControlUnit::_start, + NodeDomainAndActionRPC::ACTION_NODE_START, + "Start the control unit scheduling"); + + action_description = addActionDescritionInstance<AbstractControlUnit>(this, + &AbstractControlUnit::_stop, + NodeDomainAndActionRPC::ACTION_NODE_STOP, + "Stop the control unit scheduling"); + + action_description = addActionDescritionInstance<AbstractControlUnit>(this, + &AbstractControlUnit::_recover, + NodeDomainAndActionRPC::ACTION_NODE_RECOVER, + "Recovery a recoverable state, going to the last state"); + + action_description = addActionDescritionInstance<AbstractControlUnit>(this, + &AbstractControlUnit::_unitRestoreToSnapshot, + NodeDomainAndActionRPC::ACTION_NODE_RESTORE, + "Restore contorl unit to a snapshot tag"); + + action_description = addActionDescritionInstance<AbstractControlUnit>(this, + &AbstractControlUnit::_getState, + NodeDomainAndActionRPC::ACTION_NODE_GET_STATE, + "Get the state of the running control unit"); + + action_description = addActionDescritionInstance<AbstractControlUnit>(this, + &AbstractControlUnit::_getInfo, + NodeDomainAndActionRPC::ACTION_CU_GET_INFO, + "Get the information about running control unit"); + action_description = addActionDescritionInstance<AbstractControlUnit>(this, + &AbstractControlUnit::_startStorageBurst, + ControlUnitNodeDomainAndActionRPC::ACTION_STORAGE_BURST, + "Execute a storage burst on control unit"); + action_description->addParam(ControlUnitNodeDefinitionKey::CONTROL_UNIT_DATASET_HISTORY_BURST_TAG, DataType::TYPE_STRING, "Tag asosciated to the stored data during burst"); + action_description->addParam(ControlUnitNodeDefinitionKey::CONTROL_UNIT_DATASET_HISTORY_BURST_TYPE, DataType::TYPE_INT32, "The type of burst"); + action_description->addParam(ControlUnitNodeDefinitionKey::CONTROL_UNIT_DATASET_HISTORY_BURST_VALUE, DataType::TYPE_UNDEFINED, "The value of the burst is defined by the type"); //grab dataset description DatasetDB::fillDataWrapperWithDataSetDescription(setup_configuration); @@ -1383,6 +1395,20 @@ CDataWrapper* AbstractControlUnit::_getState(CDataWrapper* getStatedParam, return stateResult; } + +chaos::common::data::CDataWrapper* AbstractControlUnit::_startStorageBurst(CDataWrapper* data, + bool& detachParam) throw (CException) { + common::data::structured::DatasetBurstSDWrapper db_sdw; + db_sdw.deserialize(data); + DatasetBurstShrdPtr burst = ChaosMakeSharedPtr<DatasetBurst>(db_sdw()); + if(!key_data_storage->addStorageBurst(ChaosMoveOperator(burst))) { + ACULERR_ << CHAOS_FORMAT("Error adding new burst execution -> %1%",%data->getJSONString()); + } else { + ACULAPP_ << CHAOS_FORMAT("Succesfull add new burst execution -> %1%",%data->getJSONString()); + } + return NULL; +} + /* Get the current control unit state */ @@ -1662,12 +1688,6 @@ void AbstractControlUnit::propertyUpdatedHandler(const std::string& group_name, if(group_name.compare("property_abstract_control_unit") == 0) { //update property on driver key_data_storage->updateConfiguration(property_name, new_value); - - //TODO - // if(attribute_value_shared_cache->hasAttribute(DOMAIN_SYSTEM, property_name)){ - // attribute_value_shared_cache->getAttributeValue(DOMAIN_SYSTEM, property_name)->setValue(new_value); - // } - //reflect modification on dataset if(property_name.compare(ControlUnitDatapackSystemKey::BYPASS_STATE) == 0) { _setBypassState(new_value.asBool()); @@ -1700,7 +1720,7 @@ void AbstractControlUnit::pushOutputDataset() { //check if something as changed if(!output_attribute_cache.hasChanged()) return; - CDataWrapper *output_attribute_dataset = key_data_storage->getNewDataPackForDomain(KeyDataStorageDomainOutput); + CDWShrdPtr output_attribute_dataset = key_data_storage->getNewDataPackForDomain(KeyDataStorageDomainOutput); if(!output_attribute_dataset) return; output_attribute_dataset->addInt64Value(ControlUnitDatapackCommonKey::RUN_ID, run_id); output_attribute_dataset->addInt64Value(DataPackCommonKey::DPCK_TIMESTAMP, *timestamp_acq_cached_value->getValuePtr<uint64_t>()); @@ -1755,7 +1775,7 @@ void AbstractControlUnit::pushOutputDataset() { } } //now we nede to push the outputdataset - key_data_storage->pushDataSet(data_manager::KeyDataStorageDomainOutput, output_attribute_dataset); + key_data_storage->pushDataSet(data_manager::KeyDataStorageDomainOutput, ChaosMoveOperator(output_attribute_dataset)); //update counter push_dataset_counter++; @@ -1770,7 +1790,7 @@ void AbstractControlUnit::pushInputDataset() { if(!input_attribute_cache.hasChanged()) return; //get the cdatawrapper for the pack int64_t cur_us = TimingUtil::getTimeStampInMicroseconds(); - CDataWrapper *input_attribute_dataset = key_data_storage->getNewDataPackForDomain(KeyDataStorageDomainInput); + CDWShrdPtr input_attribute_dataset = key_data_storage->getNewDataPackForDomain(KeyDataStorageDomainInput); if(input_attribute_dataset) { input_attribute_dataset->addInt64Value(ControlUnitDatapackCommonKey::RUN_ID, run_id); //input dataset timestamp is added only when pushed on cache @@ -1780,7 +1800,7 @@ void AbstractControlUnit::pushInputDataset() { fillCDatawrapperWithCachedValue(cache_input_attribute_vector, *input_attribute_dataset); //push out the system dataset - key_data_storage->pushDataSet(data_manager::KeyDataStorageDomainInput, input_attribute_dataset); + key_data_storage->pushDataSet(data_manager::KeyDataStorageDomainInput, ChaosMoveOperator(input_attribute_dataset)); } input_attribute_cache.resetChangedIndex(); } @@ -1791,21 +1811,18 @@ void AbstractControlUnit::pushCustomDataset() { if(!custom_attribute_cache.hasChanged()) return; //get the cdatawrapper for the pack int64_t cur_us = TimingUtil::getTimeStampInMicroseconds(); - CDataWrapper *custom_attribute_dataset = key_data_storage->getNewDataPackForDomain(KeyDataStorageDomainCustom); + CDWShrdPtr custom_attribute_dataset = key_data_storage->getNewDataPackForDomain(KeyDataStorageDomainCustom); if(custom_attribute_dataset) { custom_attribute_dataset->addInt64Value(ControlUnitDatapackCommonKey::RUN_ID, run_id); //input dataset timestamp is added only when pushed on cache custom_attribute_dataset->addInt64Value(DataPackCommonKey::DPCK_TIMESTAMP, cur_us/1000); custom_attribute_dataset->addInt64Value(DataPackCommonKey::DPCK_HIGH_RESOLUTION_TIMESTAMP, cur_us); - //add dataset type - // custom_attribute_dataset->addInt32Value(DataPackCommonKey::DPCK_DATASET_TYPE, DataPackCommonKey::DPCK_DATASET_TYPE_CUSTOM); - //fill the dataset fillCDatawrapperWithCachedValue(cache_custom_attribute_vector, *custom_attribute_dataset); //push out the system dataset - key_data_storage->pushDataSet(data_manager::KeyDataStorageDomainCustom, custom_attribute_dataset); + key_data_storage->pushDataSet(data_manager::KeyDataStorageDomainCustom, ChaosMoveOperator(custom_attribute_dataset)); } } @@ -1814,35 +1831,29 @@ void AbstractControlUnit::pushSystemDataset() { if(!systemm_attribute_cache.hasChanged()) return; //get the cdatawrapper for the pack int64_t cur_us = TimingUtil::getTimeStampInMicroseconds(); - CDataWrapper *system_attribute_dataset = key_data_storage->getNewDataPackForDomain(KeyDataStorageDomainSystem); + CDWShrdPtr system_attribute_dataset = key_data_storage->getNewDataPackForDomain(KeyDataStorageDomainSystem); if(system_attribute_dataset) { system_attribute_dataset->addInt64Value(ControlUnitDatapackCommonKey::RUN_ID, run_id); //input dataset timestamp is added only when pushed on cache system_attribute_dataset->addInt64Value(DataPackCommonKey::DPCK_TIMESTAMP, cur_us/1000); system_attribute_dataset->addInt64Value(DataPackCommonKey::DPCK_HIGH_RESOLUTION_TIMESTAMP, cur_us); - //add dataset type - // system_attribute_dataset->addInt32Value(DataPackCommonKey::DPCK_DATASET_TYPE, DataPackCommonKey::DPCK_DATASET_TYPE_SYSTEM); //fill the dataset fillCDatawrapperWithCachedValue(cache_system_attribute_vector, *system_attribute_dataset); - //push out the system dataset - key_data_storage->pushDataSet(data_manager::KeyDataStorageDomainSystem, system_attribute_dataset); + key_data_storage->pushDataSet(data_manager::KeyDataStorageDomainSystem, ChaosMoveOperator(system_attribute_dataset)); } //reset changed index systemm_attribute_cache.resetChangedIndex(); } -CDataWrapper *AbstractControlUnit::writeCatalogOnCDataWrapper(AlarmCatalog& catalog, - int32_t dataset_type) { - CDataWrapper *attribute_dataset = key_data_storage->getNewDataPackForDomain((KeyDataStorageDomain)dataset_type); +CDWShrdPtr AbstractControlUnit::writeCatalogOnCDataWrapper(AlarmCatalog& catalog, + int32_t dataset_type) { + CDWShrdPtr attribute_dataset = key_data_storage->getNewDataPackForDomain((KeyDataStorageDomain)dataset_type); if(attribute_dataset) { //fill datapack with //! the dataaset can be pushed also in other moment attribute_dataset->addInt64Value(DataPackCommonKey::DPCK_TIMESTAMP, TimingUtil::getTimeStamp()); - //add dataset type - // attribute_dataset->addInt32Value(DataPackCommonKey::DPCK_DATASET_TYPE, dataset_type); - //scan all alarm ad create the datapack size_t alarm_size = catalog.size(); for(unsigned int idx = 0; @@ -1858,23 +1869,21 @@ CDataWrapper *AbstractControlUnit::writeCatalogOnCDataWrapper(AlarmCatalog& cata void AbstractControlUnit::pushDevAlarmDataset() { GET_CAT_OR_EXIT(StateVariableTypeAlarmDEV, ); - //get the cdatawrapper for the pack - CDataWrapper *attribute_dataset = writeCatalogOnCDataWrapper(catalog, - DataPackCommonKey::DPCK_DATASET_TYPE_DEV_ALARM); + CDWShrdPtr attribute_dataset = writeCatalogOnCDataWrapper(catalog, + DataPackCommonKey::DPCK_DATASET_TYPE_DEV_ALARM); if(attribute_dataset) { //push out the system dataset - key_data_storage->pushDataSet(KeyDataStorageDomainDevAlarm, attribute_dataset); + key_data_storage->pushDataSet(KeyDataStorageDomainDevAlarm, ChaosMoveOperator(attribute_dataset)); } } void AbstractControlUnit::pushCUAlarmDataset() { GET_CAT_OR_EXIT(StateVariableTypeAlarmCU, ); - //get the cdatawrapper for the pack - CDataWrapper *attribute_dataset = writeCatalogOnCDataWrapper(catalog, - DataPackCommonKey::DPCK_DATASET_TYPE_CU_ALARM); + CDWShrdPtr attribute_dataset = writeCatalogOnCDataWrapper(catalog, + DataPackCommonKey::DPCK_DATASET_TYPE_CU_ALARM); if(attribute_dataset) { //push out the system dataset - key_data_storage->pushDataSet(KeyDataStorageDomainCUAlarm, attribute_dataset); + key_data_storage->pushDataSet(KeyDataStorageDomainCUAlarm, ChaosMoveOperator(attribute_dataset)); } } diff --git a/chaos/cu_toolkit/control_manager/AbstractControlUnit.h b/chaos/cu_toolkit/control_manager/AbstractControlUnit.h index 0919819d8482d25a83ece0d9d74de6ef8bf92add..732b86f9a848f37fdd416c9d74cb219a9961628f 100644 --- a/chaos/cu_toolkit/control_manager/AbstractControlUnit.h +++ b/chaos/cu_toolkit/control_manager/AbstractControlUnit.h @@ -206,8 +206,8 @@ namespace chaos{ return -1; } - chaos::common::data::CDataWrapper *writeCatalogOnCDataWrapper(chaos::common::alarm::AlarmCatalog& catalog, - int32_t dataset_type); + chaos::common::data::CDWShrdPtr writeCatalogOnCDataWrapper(chaos::common::alarm::AlarmCatalog& catalog, + int32_t dataset_type); //check at initilization time ifr need to to a restore or only an apply void checkForRestoreOnInit() throw(CException); private: @@ -426,21 +426,28 @@ namespace chaos{ This method is called when the input attribute of the dataset need to be valorized, subclass need to perform all the appropiate action to set these attribute */ - chaos::common::data::CDataWrapper* _setDatasetAttribute(chaos::common::data::CDataWrapper*, bool&) throw (CException); + chaos::common::data::CDataWrapper* _setDatasetAttribute(chaos::common::data::CDataWrapper* data, + bool& detachParam) throw (CException); //! Return the state of the control unit /*! Return the current control unit state identifyed by ControlUnitState types fitted into the CDatawrapper with the key CUStateKey::CONTROL_UNIT_STATE */ - chaos::common::data::CDataWrapper* _getState(chaos::common::data::CDataWrapper*, bool& detachParam) throw(CException); + chaos::common::data::CDataWrapper* _getState(chaos::common::data::CDataWrapper* data, + bool& detachParam) throw(CException); //! Return the information about the type of the current instace of control unit /*! Return unit fitted into cdata wrapper: CU type: string type associated with the key @CUDefinitionKey::CS_CM_CU_TYPE */ - chaos::common::data::CDataWrapper* _getInfo(chaos::common::data::CDataWrapper*, bool& detachParam) throw(CException); + chaos::common::data::CDataWrapper* _getInfo(chaos::common::data::CDataWrapper* data, + bool& detachParam) throw(CException); + + //!start a new storicization burst execution + chaos::common::data::CDataWrapper* _startStorageBurst(chaos::common::data::CDataWrapper* data, + bool& detachParam) throw (CException); //! update the timestamp attribute of the output datapack void _updateAcquistionTimestamp(uint64_t alternative_ts); diff --git a/chaos/cu_toolkit/control_manager/AbstractExecutionUnit.cpp b/chaos/cu_toolkit/control_manager/AbstractExecutionUnit.cpp index b540da16150a0571b5f3131a92d89054d77ba86d..3d242debc3617e6cd6c2a9d5b917f3aa14d0d190 100644 --- a/chaos/cu_toolkit/control_manager/AbstractExecutionUnit.cpp +++ b/chaos/cu_toolkit/control_manager/AbstractExecutionUnit.cpp @@ -212,13 +212,15 @@ int AbstractExecutionUnit::performQuery(chaos::common::io::QueryCursor **cursor, KeyDataStorageDomain dataset_domain, const uint64_t start_ts, const uint64_t end_ts, + const ChaosStringSet& meta_tags, const uint32_t page_len) { CHAOS_ASSERT(key_data_storage.get()); int err = key_data_storage->performGeneralQuery(cursor, node_id, dataset_domain, start_ts, - end_ts); + end_ts, + meta_tags); if(!err || *cursor) { (*cursor)->setPageDimension(page_len); } diff --git a/chaos/cu_toolkit/control_manager/AbstractExecutionUnit.h b/chaos/cu_toolkit/control_manager/AbstractExecutionUnit.h index e4c162370f5f360f2fef09ffdc9fd1b4e9565b03..3763019b31699e20fb7a79a1cb8e3718e91ad2ec 100644 --- a/chaos/cu_toolkit/control_manager/AbstractExecutionUnit.h +++ b/chaos/cu_toolkit/control_manager/AbstractExecutionUnit.h @@ -168,6 +168,7 @@ namespace chaos{ chaos::cu::data_manager::KeyDataStorageDomain dataset_domain, const uint64_t start_ts, const uint64_t end_ts, + const ChaosStringSet& meta_tags, const uint32_t page_len); //! release a cursor diff --git a/chaos/cu_toolkit/control_manager/script/api/EUSearch.cpp b/chaos/cu_toolkit/control_manager/script/api/EUSearch.cpp index 694fb70c08c8965e395ca1efe3af23517be08d4a..df0c21383bc949ec7938ff9921d9b71b053ec2e6 100644 --- a/chaos/cu_toolkit/control_manager/script/api/EUSearch.cpp +++ b/chaos/cu_toolkit/control_manager/script/api/EUSearch.cpp @@ -113,6 +113,7 @@ int EUSearch::newSearch(const common::script::ScriptInParam& input_parameter, static_cast<KeyDataStorageDomain>(input_parameter[1].asInt32()), input_parameter[2].asInt64(),//start_ts input_parameter[3].asInt64(),//end_ts; + ChaosStringSet(), DEFAULT_PAGE_LEN); CHAOS_ASSERT(!err && cursor != NULL); @@ -145,6 +146,7 @@ int EUSearch::newSearchSinceSeconds(const common::script::ScriptInParam& input_p static_cast<KeyDataStorageDomain>(input_parameter[1].asInt32()), start_ts,//start_ts end_ts,//end_ts; + ChaosStringSet(), DEFAULT_PAGE_LEN); CHAOS_ASSERT(!err && cursor != NULL); @@ -271,6 +273,7 @@ int EUSearch::runAlgoSearchSinceSeconds(const common::script::ScriptInParam& inp search_domain, start_ts, end_ts, + ChaosStringSet(), DEFAULT_PAGE_LEN); CHAOS_ASSERT(!err && cursor != NULL); diff --git a/chaos/cu_toolkit/control_manager/script/api/plugin/EUPluginApiWrapper.cpp b/chaos/cu_toolkit/control_manager/script/api/plugin/EUPluginApiWrapper.cpp index ee407f0f93d4a810a6a6eb3094f0cb65ded88f07..7cdfbe6b844954c497f6fbf4617a5eb8d8caa7e6 100644 --- a/chaos/cu_toolkit/control_manager/script/api/plugin/EUPluginApiWrapper.cpp +++ b/chaos/cu_toolkit/control_manager/script/api/plugin/EUPluginApiWrapper.cpp @@ -63,7 +63,7 @@ int EUPluginApiWrapper::execPlugin(const ScriptInParam& input_parameter, if((err = api_plugin->execute(input_json.c_str(), (uint32_t)input_json.size(), &output_data, &output_size)) == 0) { //we have data const std::string output_json((output_data?output_data:""), output_size); - output_parameter.push_back(CDataVariant(CDataBuffer::newOwnBufferFromBuffer(output_data, output_size))); + output_parameter.push_back(CDataVariant(ChaosMoveOperator(CDataBuffer::newOwnBufferFromBuffer(output_data, output_size)))); output_parameter.push_back(CDataVariant(output_size)); EUSW_DBG << CHAOS_FORMAT("Result EU plugin with ---->%1%", %output_json); } diff --git a/chaos/cu_toolkit/data_manager/DataManager.cpp b/chaos/cu_toolkit/data_manager/DataManager.cpp index ea57c07afad1e18ede4d26bf38218e4e08ae9625..e977ef37531a0a08f6f45678d78f925258dd2795 100644 --- a/chaos/cu_toolkit/data_manager/DataManager.cpp +++ b/chaos/cu_toolkit/data_manager/DataManager.cpp @@ -176,14 +176,14 @@ void DataManager::updateConfigurationForDeviceIdKey(const string& device_id, CDa /* Submit a CDataWrapper on device id KeyDataStorage */ -void DataManager::pushDeviceDataByIdKey(const string& device_id, CDataWrapper* deviceCDataWrapper) throw(CException) { - deviceIDKeyDataStorageMap[device_id]->pushDataSet(data_manager::KeyDataStorageDomainOutput, deviceCDataWrapper); +void DataManager::pushDeviceDataByIdKey(const string& device_id, CDWShrdPtr dataset) throw(CException) { + deviceIDKeyDataStorageMap[device_id]->pushDataSet(data_manager::KeyDataStorageDomainOutput, ChaosMoveOperator(dataset)); } /* return a new instance of CDataWrapper filled with a mandatory data according to key */ -CDataWrapper *DataManager::getNewDataWrapperForDeviceIdKey(const string& device_id) { +CDWShrdPtr DataManager::getNewDataWrapperForDeviceIdKey(const string& device_id) { return deviceIDKeyDataStorageMap[device_id]->getNewDataPackForDomain(KeyDataStorageDomainOutput); } diff --git a/chaos/cu_toolkit/data_manager/DataManager.h b/chaos/cu_toolkit/data_manager/DataManager.h index b0b8579b736054458182807a7a841d89caa2ddec..ae8ecbb74a39bfaf5d45501cdb00bdd81b75c911 100644 --- a/chaos/cu_toolkit/data_manager/DataManager.h +++ b/chaos/cu_toolkit/data_manager/DataManager.h @@ -106,13 +106,13 @@ namespace chaos{ /* Submit a CDataWrapper on device id KeyDataStorage */ - void pushDeviceDataByIdKey(const std::string &device_id, chaos_data::CDataWrapper*) throw(CException); + void pushDeviceDataByIdKey(const std::string& device_id, chaos_data::CDWShrdPtr dataset) throw(CException); /* return a new instance of CDataWrapper filled with a mandatory data according to key */ - chaos_data::CDataWrapper *getNewDataWrapperForDeviceIdKey(const std::string &device_id); + chaos_data::CDWShrdPtr getNewDataWrapperForDeviceIdKey(const std::string &device_id); /* Configure the datamanager diff --git a/chaos/cu_toolkit/data_manager/KeyDataStorage.cpp b/chaos/cu_toolkit/data_manager/KeyDataStorage.cpp index 5ad1385b4140e335706309e2fb66068f303af43f..0493ac8647b5090e21185e882f1adc7198439ff0 100644 --- a/chaos/cu_toolkit/data_manager/KeyDataStorage.cpp +++ b/chaos/cu_toolkit/data_manager/KeyDataStorage.cpp @@ -27,6 +27,7 @@ using namespace std; using namespace chaos; using namespace chaos::common::data; +using namespace chaos::common::data::structured; using namespace chaos::common::utility; using namespace chaos::cu::data_manager; @@ -34,6 +35,36 @@ using namespace chaos::cu::data_manager; #define KeyDataStorageLDBG DBG_LOG(KeyDataStorage) #define KeyDataStorageLERR ERR_LOG(KeyDataStorage) +#pragma mark StorageBurst +StorageBurst::StorageBurst(DatasetBurstShrdPtr _dataset_burst): +dataset_burst(_dataset_burst){} + +StorageBurst::~StorageBurst(){} + +#pragma mark PushStorageBurst +PushStorageBurst::PushStorageBurst(DatasetBurstShrdPtr _dataset_burst): +StorageBurst(ChaosMoveOperator(_dataset_burst)), +current_pushes(0){} + +PushStorageBurst::~PushStorageBurst(){} + +bool PushStorageBurst::active(void *data __attribute__((unused))) { + return current_pushes++<StorageBurst::dataset_burst->value.asUInt32(); +} + +#pragma mark MSecStorageBurst +MSecStorageBurst::MSecStorageBurst(DatasetBurstShrdPtr _dataset_burst): +StorageBurst(ChaosMoveOperator(_dataset_burst)), +timeout_msec(TimingUtil::getTimestampWithDelay(StorageBurst::dataset_burst->value.asInt32(), true)){} + +MSecStorageBurst::~MSecStorageBurst(){} + +bool MSecStorageBurst::active(void *data) { + int64_t *now = static_cast<int64_t*>(data); + return timeout_msec>*now; +} + +#pragma mark KeyDataStorage KeyDataStorage::KeyDataStorage(const std::string& _key, chaos_io::IODataDriver *_io_data_driver): key(_key), @@ -43,33 +74,27 @@ storage_history_time(0), storage_history_time_last_push(0), storage_live_time(0), storage_live_time_last_push(0), -sequence_id(0 /*std::numeric_limits<int64_t>::min()*/){ - output_key = _key + DataPackPrefixID::OUTPUT_DATASET_POSTFIX; - input_key = _key + DataPackPrefixID::INPUT_DATASET_POSTFIX; - system_key = _key + DataPackPrefixID::SYSTEM_DATASET_POSTFIX; - custom_key = _key + DataPackPrefixID::CUSTOM_DATASET_POSTFIX; - health_key = _key + DataPackPrefixID::HEALTH_DATASET_POSTFIX; - cu_alarm_key = _key + DataPackPrefixID::CU_ALARM_DATASET_POSTFIX; - dev_alarm_key = _key + DataPackPrefixID::DEV_ALARM_DATASET_POSTFIX; -} +sequence_id(0), +output_key(key + DataPackPrefixID::OUTPUT_DATASET_POSTFIX), +input_key(key + DataPackPrefixID::INPUT_DATASET_POSTFIX), +system_key(key + DataPackPrefixID::SYSTEM_DATASET_POSTFIX), +custom_key(key + DataPackPrefixID::CUSTOM_DATASET_POSTFIX), +health_key(key + DataPackPrefixID::HEALTH_DATASET_POSTFIX), +cu_alarm_key(key + DataPackPrefixID::CU_ALARM_DATASET_POSTFIX), +dev_alarm_key(key + DataPackPrefixID::DEV_ALARM_DATASET_POSTFIX){} KeyDataStorage::~KeyDataStorage() { restore_point_map.clear(); - if(io_data_driver) { - delete(io_data_driver); - io_data_driver = NULL; - } - } void KeyDataStorage::init(void *init_parameter) throw (chaos::CException) { - if(!io_data_driver) throw chaos::CException(-1, "IO data driver not set", __PRETTY_FUNCTION__); + if(!io_data_driver.get()) throw chaos::CException(-1, "IO data driver not set", __PRETTY_FUNCTION__); io_data_driver->init(init_parameter); } void KeyDataStorage::deinit() throw (chaos::CException) { - if(io_data_driver) io_data_driver->deinit(); + if(io_data_driver.get()) {io_data_driver->deinit();} restore_point_map.clear(); } @@ -133,8 +158,8 @@ std::string KeyDataStorage::getDomainString(const std::string& node_uid, Return a new instace for the CSDatawrapped filled with default madatory data */ -CDataWrapper* KeyDataStorage::getNewDataPackForDomain(const KeyDataStorageDomain domain) { - CDataWrapper *result = new CDataWrapper(); +CDWShrdPtr KeyDataStorage::getNewDataPackForDomain(const KeyDataStorageDomain domain) { + CDWShrdPtr result = ChaosMakeSharedPtr<CDataWrapper>(); int32_t node_type; switch(domain) { case KeyDataStorageDomainOutput: @@ -167,94 +192,111 @@ CDataWrapper* KeyDataStorage::getNewDataPackForDomain(const KeyDataStorageDomain } void KeyDataStorage::pushDataWithControlOnHistoryTime(const std::string& key, - CDataWrapper *dataToStore, + CDWShrdPtr dataset, DataServiceNodeDefinitionType::DSStorageType storage_type) { - uint64_t now = TimingUtil::getTimeStampInMicroseconds(); - switch(storage_type) { - case DataServiceNodeDefinitionType::DSStorageTypeLive: { - if((now - storage_live_time_last_push) >= storage_live_time) { - io_data_driver->storeData(key, - dataToStore, - DataServiceNodeDefinitionType::DSStorageTypeLive); - storage_live_time_last_push = now; + ChaosStringSet tags; + //check for burt information + if(!current_burst.get()) { + LQueueBurstReadLock wl = burst_queue.getReadLockObject(); + if(!burst_queue().empty()){ + switch(burst_queue().front()->type) { + case chaos::ControlUnitNodeDefinitionType::DSStorageBurstTypeNPush: + current_burst.reset(new PushStorageBurst(ChaosMoveOperator(burst_queue().front()))); + break; + case chaos::ControlUnitNodeDefinitionType::DSStorageBurstTypeMSec: + current_burst.reset(new MSecStorageBurst(ChaosMoveOperator(burst_queue().front()))); + break; + default: + break; } - - break; + burst_queue().pop(); } - case DataServiceNodeDefinitionType::DSStorageTypeHistory: { - + } + + uint64_t now = TimingUtil::getTimeStampInMicroseconds(); + int effective_storage_type = DataServiceNodeDefinitionType::DSStorageTypeUndefined; + + if(storage_type & DataServiceNodeDefinitionType::DSStorageTypeLive) { + //live is enbaled + if((now - storage_live_time_last_push) >= storage_live_time) { + effective_storage_type |= DataServiceNodeDefinitionType::DSStorageTypeLive; + storage_live_time_last_push = now; + } + } + + if(!current_burst.get()) { + if(storage_type & DataServiceNodeDefinitionType::DSStorageTypeHistory) { + //history is enabled if((now - storage_history_time_last_push) >= storage_history_time) { - io_data_driver->storeData(key, - dataToStore, - DataServiceNodeDefinitionType::DSStorageTypeHistory); + effective_storage_type |= DataServiceNodeDefinitionType::DSStorageTypeHistory; storage_history_time_last_push = now; } - break; } - case DataServiceNodeDefinitionType::DSStorageTypeLiveHistory: { - - DataServiceNodeDefinitionType::DSStorageType effective_storage_type = DataServiceNodeDefinitionType::DSStorageTypeLiveHistory; - bool push_history = (now - storage_history_time_last_push) >= storage_history_time; - bool push_live = (now - storage_live_time_last_push) >= storage_live_time; - if(push_live || push_history) { - if(push_history && push_live) { - storage_history_time_last_push = storage_live_time_last_push = now; - } else if(push_history) { - effective_storage_type = DataServiceNodeDefinitionType::DSStorageTypeHistory; - storage_history_time_last_push = now; - } else if(push_live) { - effective_storage_type = DataServiceNodeDefinitionType::DSStorageTypeLive; - storage_live_time_last_push = now; - } - io_data_driver->storeData(key, - dataToStore, - effective_storage_type); - } - break; + } else { + storage_history_time_last_push = now; + effective_storage_type |= DataServiceNodeDefinitionType::DSStorageTypeHistory; + if(current_burst->dataset_burst->tag.size()) { + tags.insert(current_burst->dataset_burst->tag); } - case DataServiceNodeDefinitionType::DSStorageTypeUndefined: - break; + //check for storage information + if(!current_burst->active(&now)) { + //we need to remove it + current_burst.reset(); + } + } + + if(effective_storage_type) { + io_data_driver->storeData(key, + ChaosMoveOperator(dataset), + static_cast<DataServiceNodeDefinitionType::DSStorageType>(effective_storage_type), + tags); } } void KeyDataStorage::pushDataSet(KeyDataStorageDomain domain, - chaos_data::CDataWrapper *dataset) { - CHAOS_ASSERT(io_data_driver); + CDWShrdPtr dataset) { + CHAOS_ASSERT(io_data_driver.get()); //lock for protect the access boost::unique_lock<boost::mutex> l(mutex_push_data); switch(domain) { case KeyDataStorageDomainOutput: pushDataWithControlOnHistoryTime(output_key, - dataset, + ChaosMoveOperator(dataset), storage_type); break; case KeyDataStorageDomainInput: //input channel need to be push ever either in live and in history io_data_driver->storeData(input_key, - dataset, + ChaosMoveOperator(dataset), DataServiceNodeDefinitionType::DSStorageTypeLiveHistory); break; case KeyDataStorageDomainSystem: //system channel need to be push ever either in live and in history io_data_driver->storeData(system_key, - dataset, + ChaosMoveOperator(dataset), DataServiceNodeDefinitionType::DSStorageTypeLiveHistory); break; case KeyDataStorageDomainCUAlarm: //system channel need to be push ever either in live and in history io_data_driver->storeData(cu_alarm_key, - dataset, + ChaosMoveOperator(dataset), DataServiceNodeDefinitionType::DSStorageTypeLiveHistory); break; case KeyDataStorageDomainDevAlarm: //system channel need to be push ever either in live and in history io_data_driver->storeData(dev_alarm_key, - dataset, + ChaosMoveOperator(dataset), DataServiceNodeDefinitionType::DSStorageTypeLiveHistory); break; + case KeyDataStorageDomainHealth: + //system channel need to be push ever either in live and in history + io_data_driver->storeHealthData(health_key, + ChaosMoveOperator(dataset), + DataServiceNodeDefinitionType::DSStorageTypeLiveHistory); + break; case KeyDataStorageDomainCustom: pushDataWithControlOnHistoryTime(custom_key, - dataset, + ChaosMoveOperator(dataset), storage_type); break; } @@ -292,7 +334,7 @@ int KeyDataStorage::loadRestorePoint(const std::string& restore_point_tag) { } else { if(dataset){ restore_point_map[restore_point_tag].insert(make_pair(input_key, ChaosMoveOperator(dataset)));dataset.reset(); - + } } @@ -357,8 +399,8 @@ ChaosSharedPtr<chaos_data::CDataWrapper> KeyDataStorage::getDatasetFromRestorePo void KeyDataStorage::updateConfiguration(CDataWrapper *configuration) { //update the driver configration - if(io_data_driver) io_data_driver->updateConfiguration(configuration); - + if(io_data_driver.get()) io_data_driver->updateConfiguration(configuration); + } void KeyDataStorage::updateConfiguration(const std::string& conf_name, @@ -373,6 +415,22 @@ void KeyDataStorage::updateConfiguration(const std::string& conf_name, KeyDataStorageLAPP << CHAOS_FORMAT("Set value %1% to property %2%", %conf_value.asString()%conf_name); } +//!add into the queue a noew storage burst mode +bool KeyDataStorage::addStorageBurst(chaos::common::data::structured::DatasetBurstShrdPtr burst_mode) { + if(burst_mode->type == chaos::ControlUnitNodeDefinitionType::DSStorageBurstTypeUndefined) { + KeyDataStorageLERR << "The type is mandatory"; + return false; + } + if(!burst_mode->value.isValid()) { + KeyDataStorageLERR << "The value is mandatory"; + return false; + } + + LQueueBurstWriteLock wl = burst_queue.getWriteLockObject(); + burst_queue().push(burst_mode); + return true; +} + DataServiceNodeDefinitionType::DSStorageType KeyDataStorage::getStorageType() { return storage_type; } @@ -413,12 +471,14 @@ int KeyDataStorage::performLiveFetch(const ChaosStringVector& node_uid, } int KeyDataStorage::performSelfQuery(chaos::common::io::QueryCursor **cursor, - KeyDataStorageDomain dataset_domain, + const KeyDataStorageDomain dataset_domain, const uint64_t start_ts, - const uint64_t end_ts) { + const uint64_t end_ts, + const ChaosStringSet& meta_tags) { *cursor = io_data_driver->performQuery(getDomainString(dataset_domain), start_ts, - end_ts); + end_ts, + meta_tags); return ((*cursor == NULL)?-1:0); } @@ -426,11 +486,13 @@ int KeyDataStorage::performGeneralQuery(chaos::common::io::QueryCursor **cursor, const std::string& node_id, KeyDataStorageDomain dataset_domain, const uint64_t start_ts, - const uint64_t end_ts) { + const uint64_t end_ts, + const ChaosStringSet& meta_tags) { *cursor = io_data_driver->performQuery(getDomainString(node_id, dataset_domain), start_ts, - end_ts); + end_ts, + meta_tags); return ((*cursor == NULL)?-1:0); } diff --git a/chaos/cu_toolkit/data_manager/KeyDataStorage.h b/chaos/cu_toolkit/data_manager/KeyDataStorage.h index b2529b22dfc6e126aa86eedac74da58ada110c6d..b73eace7938a3402aa5b92a0b9ee4aca2366bad9 100644 --- a/chaos/cu_toolkit/data_manager/KeyDataStorage.h +++ b/chaos/cu_toolkit/data_manager/KeyDataStorage.h @@ -25,8 +25,12 @@ #include <map> #include <string> +#include <chaos/common/chaos_types.h> +#include <chaos/common/chaos_constants.h> #include <chaos/common/io/IODataDriver.h> +#include <chaos/common/data/structured/Dataset.h> #include <chaos/common/utility/ArrayPointer.h> +#include <chaos/common/utility/LockableObject.h> #include <boost/thread.hpp> #include <boost/atomic.hpp> @@ -37,7 +41,7 @@ namespace chaos_utility = chaos::common::utility; namespace chaos{ namespace cu { namespace data_manager { - + //!data domain managed by the driver typedef enum KeyDataStorageDomain { KeyDataStorageDomainOutput = DataPackCommonKey::DPCK_DATASET_TYPE_OUTPUT, KeyDataStorageDomainInput = DataPackCommonKey::DPCK_DATASET_TYPE_INPUT, @@ -48,26 +52,66 @@ namespace chaos{ KeyDataStorageDomainCUAlarm =DataPackCommonKey::DPCK_DATASET_TYPE_CU_ALARM } KeyDataStorageDomain; + //!define the hasmap for the dataset tags + CHAOS_DEFINE_MAP_FOR_TYPE(KeyDataStorageDomain, chaos::common::data::structured::DatasetBurstShrdPtr, MapDatasetBurst); + CHAOS_DEFINE_LOCKABLE_OBJECT(MapDatasetBurst, LMapDatasetBurst); + + CHAOS_DEFINE_QUEUE_FOR_TYPE(chaos::common::data::structured::DatasetBurstShrdPtr, QueueBurst); + CHAOS_DEFINE_LOCKABLE_OBJECT(QueueBurst, LQueueBurst); + + class StorageBurst { + public: + chaos::common::data::structured::DatasetBurstShrdPtr dataset_burst; + StorageBurst(chaos::common::data::structured::DatasetBurstShrdPtr _dataset_burst); + virtual ~StorageBurst(); + virtual bool active(void *data) = 0; + }; + + class PushStorageBurst: + public StorageBurst { + uint32_t current_pushes; + public: + PushStorageBurst(chaos::common::data::structured::DatasetBurstShrdPtr _dataset_burst); + virtual ~PushStorageBurst(); + bool active(void *data); + }; + + class MSecStorageBurst: + public StorageBurst { + int64_t timeout_msec; + public: + MSecStorageBurst(chaos::common::data::structured::DatasetBurstShrdPtr _dataset_burst); + virtual ~MSecStorageBurst(); + bool active(void *data); + }; + + //!High level driver for manage the push and query of data sets class KeyDataStorage { - std::string key; - std::string output_key; - std::string input_key; - std::string system_key; - std::string custom_key; - std::string health_key; - std::string cu_alarm_key; - std::string dev_alarm_key; - //is the sequence if + const std::string key; + const std::string output_key; + const std::string input_key; + const std::string system_key; + const std::string custom_key; + const std::string health_key; + const std::string cu_alarm_key; + const std::string dev_alarm_key; + + //!is the sequence if boost::atomic<int64_t> sequence_id; - //restore poitn map + //!restore poitn map std::map<std::string, std::map<std::string, chaos_data::CDWShrdPtr > > restore_point_map; - chaos_io::IODataDriver *io_data_driver; + //!instance driver for push data + ChaosUniquePtr<chaos_io::IODataDriver> io_data_driver; - //storage type + //!storage type DataServiceNodeDefinitionType::DSStorageType storage_type; + //!define the queur for burst information + LQueueBurst burst_queue; + ChaosUniquePtr<StorageBurst> current_burst; + //history time uint64_t storage_history_time; uint64_t storage_history_time_last_push; @@ -77,7 +121,7 @@ namespace chaos{ boost::mutex mutex_push_data; void pushDataWithControlOnHistoryTime(const std::string& key, - chaos::common::data::CDataWrapper *dataToStore, + chaos::common::data::CDWShrdPtr dataset, chaos::DataServiceNodeDefinitionType::DSStorageType storage_type); inline std::string getDomainString(const KeyDataStorageDomain dataset_domain); @@ -95,7 +139,7 @@ namespace chaos{ /* Return a new instace for the CSDatawrapped */ - chaos_data::CDataWrapper* getNewDataPackForDomain(const KeyDataStorageDomain domain); + chaos::common::data::CDWShrdPtr getNewDataPackForDomain(const KeyDataStorageDomain domain); /* Retrive the data from Live Storage @@ -103,7 +147,7 @@ namespace chaos{ //chaos_utility::ArrayPointer<chaos_data::CDataWrapper>* getLastDataSet(KeyDataStorageDomain domain); //! push a dataset associated to a domain - void pushDataSet(KeyDataStorageDomain domain, chaos_data::CDataWrapper *dataset); + void pushDataSet(KeyDataStorageDomain domain, chaos::common::data::CDWShrdPtr dataset); //! load all dataseet for a restore point int loadRestorePoint(const std::string& restore_point_tag); @@ -118,6 +162,9 @@ namespace chaos{ void updateConfiguration(chaos::common::data::CDataWrapper *configuration); void updateConfiguration(const std::string& conf_name, const chaos::common::data::CDataVariant& conf_value); + //!add into the queue a noew storage burst mode + bool addStorageBurst(chaos::common::data::structured::DatasetBurstShrdPtr burst_mode); + //!return the current storage type [live, history or both] setting DataServiceNodeDefinitionType::DSStorageType getStorageType(); @@ -139,13 +186,15 @@ namespace chaos{ int performSelfQuery(chaos::common::io::QueryCursor **cursor, KeyDataStorageDomain dataset_domain, const uint64_t start_ts, - const uint64_t end_ts); + const uint64_t end_ts, + const ChaosStringSet& meta_tags); int performGeneralQuery(chaos::common::io::QueryCursor **cursor, const std::string& node_id, KeyDataStorageDomain dataset_domain, const uint64_t start_ts, - const uint64_t end_ts); + const uint64_t end_ts, + const ChaosStringSet& meta_tags); void releseQuery(chaos::common::io::QueryCursor *cursor); }; diff --git a/chaos/ui_toolkit/CMakeLists.txt b/chaos/ui_toolkit/CMakeLists.txt deleted file mode 100644 index afaee5c28574f118d0ed4012f3209d24a412f8ee..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -project(chaos_uitoolkit) -INCLUDE_DIRECTORIES(chaos/ui_toolkit ../../) -SET(ui_lib_src ChaosUIToolkit.cpp ChaosUIToolkitCWrapper.cc - HighLevelApi/DeviceController.cpp HighLevelApi/HLDataApi.cpp - HighLevelApi/HLInfrastructureApi.cpp LowLevelApi/LLDataApi.cpp LowLevelApi/LLRpcApi.cpp) - -IF(BUILD_FORCE_STATIC) - ADD_LIBRARY(${PROJECT_NAME} STATIC ${ui_lib_src}) - ELSE() - ADD_LIBRARY(${PROJECT_NAME} SHARED ${ui_lib_src}) - set_target_properties(${PROJECT_NAME} PROPERTIES VERSION 1.0.0 SOVERSION 1) - ENDIF() - -# ADD_LIBRARY(${PROJECT_NAME} ${ui_lib_src}) -#Set_target_properties(${PROJECT_NAME}_static PROPERTIES output_name chaos_uitoolkit) - - -SET(chaos_uitoolkit_lib $ENV{CHAOS_LINK_LIBRARY}) -separate_arguments(chaos_uitoolkit_lib) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} chaos_common ${chaos_uitoolkit_lib}) - - - -FILE(GLOB files "*.h") -INSTALL(FILES ${files} DESTINATION include/chaos/ui_toolkit) - -FILE(GLOB files "Common/*.h") -INSTALL(FILES ${files} DESTINATION include/chaos/ui_toolkit/Common) - -FILE(GLOB files "HighLevelApi/*.h") -INSTALL(FILES ${files} DESTINATION include/chaos/ui_toolkit/HighLevelApi) - -FILE(GLOB files "LowLevelApi/*.h") -INSTALL(FILES ${files} DESTINATION include/chaos/ui_toolkit/LowLevelApi) - -INSTALL(TARGETS ${PROJECT_NAME} - DESTINATION "lib" - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) -# INSTALL(TARGETS ${PROJECT_NAME}_static -# DESTINATION "lib" -# PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) diff --git a/chaos/ui_toolkit/ChaosUIToolkit.cpp b/chaos/ui_toolkit/ChaosUIToolkit.cpp deleted file mode 100644 index bb2b1d3b3bcff3abb5902fd83d8a12329a160b00..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/ChaosUIToolkit.cpp +++ /dev/null @@ -1,101 +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/ui_toolkit/LowLevelApi/LLDataApi.h> -#include <chaos/ui_toolkit/LowLevelApi/LLRpcApi.h> -#include <chaos/ui_toolkit/ChaosUIToolkit.h> - -using namespace std; -using namespace chaos; -using namespace chaos::ui; - -#define UI_LAPP_ LAPP_ << "[UIToolkit] -" -/* - - */ -ChaosUIToolkit::ChaosUIToolkit(){ - clientInstanceUUID = common::utility::UUIDUtil::generateUUIDLite(); -} - -/* - - */ -ChaosUIToolkit::~ChaosUIToolkit(){ - deinit(); -} - - //! C and C++ attribute parser -/*! - Specialized option for startup c and cpp program main options parameter - */ -void ChaosUIToolkit::init(int argc, const char* argv[]) throw (CException) { - ChaosCommon<ChaosUIToolkit>::init(argc, argv); -} - //!stringbuffer parser -/* - specialized option for string stream buffer with boost semantics - */ -void ChaosUIToolkit::init(istringstream &initStringStream) throw (CException) { - ChaosCommon<ChaosUIToolkit>::init(initStringStream); -} - -/* - - */ -void ChaosUIToolkit::init(void *init_data) throw(CException) { - try{ - ChaosCommon<ChaosUIToolkit>::init(init_data); - - UI_LAPP_ << "Init LLRpcApi"; - LLRpcApi::getInstance()->init(); - UI_LAPP_ << "LLRpcApi Initilized"; - UI_LAPP_ << "Initialization terminated"; - } catch (CException& ex) { - DECODE_CHAOS_EXCEPTION(ex) - exit(1); - } -} - -/* - - */ -void ChaosUIToolkit::deinit() throw(CException) { - try{ - UI_LAPP_ << "Deinit HLDataApi"; - HLDataApi::getInstance()->deinit(); - UI_LAPP_ << "HLDataApi deinitilized"; - }catch(...) {} - - try{ - UI_LAPP_ << "Deinit LLRpcApi"; - LLRpcApi::getInstance()->deinit(); - UI_LAPP_ << "LLRpcApi Deinitialized"; - UI_LAPP_ << "Deinitialization terminated"; - }catch(...) {} - - try{ - //forward the deinitialization to the common sublayer - ChaosCommon<ChaosUIToolkit>::deinit(); - }catch(...) {} - -} - - diff --git a/chaos/ui_toolkit/ChaosUIToolkit.h b/chaos/ui_toolkit/ChaosUIToolkit.h deleted file mode 100644 index 9468e66683b112efb79ba0e27d483b072a9f1d4d..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/ChaosUIToolkit.h +++ /dev/null @@ -1,88 +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_ChaosUIToolkit_h -#define ChaosFramework_ChaosUIToolkit_h - -#include <chaos/common/global.h> -#include <chaos/common/exception/exception.h> -#include <chaos/common/utility/Singleton.h> -#include <chaos/common/data/CDataWrapper.h> -#include <chaos/common/ChaosCommon.h> -#include <chaos/common/utility/Atomic.h> -#include <chaos/ui_toolkit/HighLevelApi/HLDataApi.h> -#include <chaos/ui_toolkit/HighLevelApi/HLInfrastructureApi.h> - -namespace chaos{ - //! Default chaos namespace used to group all ui api - namespace ui{ - - /*! \page page_cuit The Chaos User Interface Toolkit - * \section page_cuit_sec Why an User Interface Toolkit - * - */ - - //! ChaosUIToolkit class is the main singleton needed to use UI chaos API - /*! - Every developer that need to access chaos resource must use this pachecke to - allocate and instantiate other api pachage - */ - class ChaosUIToolkit : public ChaosCommon<ChaosUIToolkit> { - friend class common::utility::Singleton<ChaosUIToolkit>; - /** \brief Client unique id */ - string clientInstanceUUID; - /** \brief point to the class the need to be allert when this UIToolkit must exit*/ - ServerDelegator *serverDelegator; - - //!Constructor - ChaosUIToolkit(); - //!Destructor - ~ChaosUIToolkit(); - public: - //! C and C++ attribute parser - /*! - Specialized option for startup c and cpp program main options parameter - */ - void init(int argc, const char* argv[]) throw (CException); - //!stringbuffer parser - /* - specialized option for string stream buffer with boost semantics - */ - void init(istringstream &initStringStream) throw (CException); - - //!Initializaiton Method - /*! - This method provide at the all API package initialization it must be called only at applciaiton startup - \param argc the argc of main cpp program function - \param argv the argv of main cpp program function - \exception CException instance is created when something goes wrong - */ - void init(void *init_data) throw(CException); - - //!Deinitializaiton Method - /*! - this method provide all the resource deallocation - \exception CException instance is created when something goes wrong - */ - void deinit() throw(CException); - }; - } -} -#endif diff --git a/chaos/ui_toolkit/ChaosUIToolkitCWrapper.cc b/chaos/ui_toolkit/ChaosUIToolkitCWrapper.cc deleted file mode 100644 index 26f0ef616db90129469d2f8ae0f5ae1c9080fb61..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/ChaosUIToolkitCWrapper.cc +++ /dev/null @@ -1,512 +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 <map> -#include <string.h> -#include <memory.h> - -#include <chaos/ui_toolkit/ChaosUIToolkit.h> -#include <chaos/ui_toolkit/LowLevelApi/LLRpcApi.h> -#include <chaos/ui_toolkit/ChaosUIToolkitCWrapper.h> -#include <chaos/ui_toolkit/HighLevelApi/HLDataApi.h> - -#include <chaos/common/additional_lib/base64.h> -#include <chaos/common/data/CDataWrapper.h> - -#include <boost/lexical_cast.hpp> - -using namespace std; -using namespace chaos; -using namespace chaos::ui; - - - -uint32_t sequenceNumber = 0; -std::map<uint32_t, DeviceController *> chanelMap; - -//--------------------------------------------------------------- -inline DeviceController *getDeviceControllerFromID(uint32_t did) { - if(chanelMap.count(did)==0) return NULL; - return chanelMap[did]; -} - -//--------------------------------------------------------------- -inline char * convertStringToCharPtr(const string& orgString) { - char *result = NULL; - if(!orgString.length()) return NULL; - - const char *tmpCStr = orgString.c_str(); - result = (char*)malloc(strlen(tmpCStr)+1); - strcpy(result, tmpCStr); - return result; -} - -extern "C" { - //--------------------------------------------------------------- - int initToolkit(const char* startupParameter) { - int err = 0; - istringstream optionStream; - optionStream.str(startupParameter); - try { - ChaosUIToolkit::getInstance()->init(optionStream); - } catch (CException& e) { - err = e.errorCode; - } - return err; - } - - //--------------------------------------------------------------- - int getNewControllerForDeviceID(const char * const deviceID, uint32_t *devIDPtr) { - int err = 0; - DeviceController *controller = NULL; - try{ - string dID = deviceID; - controller = HLDataApi::getInstance()->getControllerForDeviceID(dID); - if(controller) { - chanelMap.insert(make_pair((*devIDPtr = ++sequenceNumber), controller)); - - //activate the traking - controller->setupTracking(); - } - } catch (CException& e) { - printf("eccezione %s\n",e.what()); - err = e.errorCode; - } - return err; - } - //--------------------------------------------------------------- - int setControllerTimeout(uint32_t devID, uint32_t timeout) { - int err = 0; - DeviceController *controller = NULL; - try{ - controller = getDeviceControllerFromID(devID); - if(controller) { - controller->setRequestTimeWaith(timeout); - } - } catch (CException& e) { - err = e.errorCode; - } - return err; - } - - //--------------------------------------------------------------- - int getDeviceDatasetAttributeNameForDirection(uint32_t devID, int16_t attributeDirection, char***attributeNameArrayHandle, uint32_t *attributeNumberPtr) { - int err = 0; - char **arrayPtr; - uint32_t attributeFound = 0; - vector<string> attributesName; - DataType::DataSetAttributeIOAttribute _attributeDirection = static_cast<DataType::DataSetAttributeIOAttribute>(attributeDirection); - try{ - if(devID) { - DeviceController * ctrl = getDeviceControllerFromID(devID); - if(ctrl){ - //get the name - ctrl->getDeviceDatasetAttributesName(attributesName, _attributeDirection); - - //copy yhe array dimension on function param - *attributeNumberPtr = attributeFound = static_cast<uint32_t>(attributesName.size()); - - //allcoate the memory for the array - *attributeNameArrayHandle = arrayPtr = (char**)malloc(attributeFound * sizeof(char*)); - - //scann all name and allocate the string - for (int idx = 0 ; idx < attributeFound; idx++) { - string curName = attributesName[idx]; - - //create and copy the attribute name into appropiate index - arrayPtr[idx] = (char*)malloc(strlen(curName.c_str()) * sizeof(char) + 1); - - //copy the string - strcpy(arrayPtr[idx], curName.c_str()); - } - }else{ - err = -1001; - } - } else { - err = -1000; - } - } catch (CException& e) { - err = e.errorCode; - } - return err; - - } - - //--------------------------------------------------------------- - int initDevice(uint32_t devID) { - int err = 0; - try{ - if(devID) { - DeviceController * ctrl = getDeviceControllerFromID(devID); - if(ctrl){ - err = ctrl->initDevice(); - }else{ - err = -1001; - } - } else { - err = -1000; - } - } catch (CException& e) { - err = e.errorCode; - } - return err; - } - - //--------------------------------------------------------------- - int startDevice(uint32_t devID) { - int err = 0; - try{ - if(devID) { - DeviceController * ctrl = getDeviceControllerFromID(devID); - if(ctrl){ - err = ctrl->startDevice(); - }else{ - err = -1001; - } - } else { - err = -1000; - } - } catch (CException& e) { - err = e.errorCode; - } - return err; - } - - //--------------------------------------------------------------- - int setDeviceRunScheduleDelay(uint32_t devID, int32_t delayTimeInMilliseconds) { - int err = 0; - try{ - if(devID) { - DeviceController * ctrl = getDeviceControllerFromID(devID); - if(ctrl){ - err = ctrl->setScheduleDelay(delayTimeInMilliseconds); - }else{ - err = -1001; - } - } else { - err = -1000; - } - } catch (CException& e) { - err = e.errorCode; - } - return err; - } - - //--------------------------------------------------------------- - int stopDevice(uint32_t devID) { - int err = 0; - try{ - if(devID) { - DeviceController * ctrl = getDeviceControllerFromID(devID); - if(ctrl){ - err = ctrl->stopDevice(); - }else{ - err = -1001; - } - } else { - err = -1000; - } - } catch (CException& e) { - err = e.errorCode; - } - return err; - } - - //--------------------------------------------------------------- - int deinitDevice(uint32_t devID) { - int err = 0; - try{ - if(devID) { - DeviceController * ctrl = getDeviceControllerFromID(devID); - if(ctrl){ - err = ctrl->deinitDevice(); - }else{ - err = -1001; - } - } else { - err = -1000; - } - } catch (CException& e) { - err = e.errorCode; - } - return err; - } - - //--------------------------------------------------------------- - int fetchLiveData(uint32_t devID) { - int err = 0; - try{ - if(devID) { - DeviceController * ctrl = getDeviceControllerFromID(devID); - if(ctrl){ - ctrl->fetchCurrentDeviceValue(); - }else{ - err = -1001; - } - } else { - err = -1000; - } - } catch (CException& e) { - err = e.errorCode; - } - return err; - } - - - //--------------------------------------------------------------- - int fetchLiveDatasetByDomain(uint32_t devID, - int16_t domain_type) { - int err = 0; - try{ - if(devID) { - DeviceController * ctrl = getDeviceControllerFromID(devID); - if(ctrl){ - if(domain_type >= 0 && - domain_type <= DatasetDomainSystem) { - ctrl->fetchCurrentDatatasetFromDomain((DatasetDomain)domain_type); - }else { - err = -1002; - } - }else{ - err = -1001; - } - } else { - err = -1000; - } - } catch (CException& e) { - err = e.errorCode; - } - return err; - } - - //--------------------------------------------------------------- - int getJSONDescriptionForDataset(uint32_t devID, - int16_t domain_type, - char ** json_dataset_handler) { - int err = 0; - try{ - if(devID) { - DeviceController * ctrl = getDeviceControllerFromID(devID); - if(ctrl){ - if(domain_type >= 0 && - domain_type <= DatasetDomainSystem) { - chaos::common::data::CDataWrapper *dataset = ctrl->getCurrentDatasetForDomain((DatasetDomain)domain_type); - if(dataset) { - //aloocate and copy cstring - *json_dataset_handler = convertStringToCharPtr(dataset->getJSONString()); - } else { - *json_dataset_handler = NULL; - err = -1003; - } - - }else { - err = -1002; - } - }else{ - err = -1001; - } - } else { - err = -1000; - } - } catch (CException& e) { - err = e.errorCode; - } - return err; - - } - - //--------------------------------------------------------------- - int getTimeStamp(uint32_t devID,uint64_t*ts){ - DeviceController *dCtrl = getDeviceControllerFromID(devID); - if(dCtrl){ - return dCtrl->getTimeStamp(*ts); - } - return -1; - } - - //--------------------------------------------------------------- - int getStrValueForAttribute(uint32_t devID, const char * const dsAttrName, char ** dsAttrValueHandle) { - int err = 0; - string tmpString; - try{ - DeviceController *dCtrl = getDeviceControllerFromID(devID); - if(dCtrl && dsAttrName && dsAttrValueHandle) { - chaos::common::data::CDataWrapper * dataWrapper = ((DeviceController*)dCtrl)->getCurrentDatasetForDomain(DatasetDomainOutput); - if(dataWrapper) { - if(dataWrapper->hasKey(dsAttrName)){ - DataType::DataType attributeType; - string attributesName = dsAttrName; - err = ((DeviceController*)dCtrl)->getDeviceAttributeType(attributesName, attributeType); - if(err == 0){ - switch (attributeType) { - case DataType::TYPE_INT64: - tmpString = boost::lexical_cast<string>(dataWrapper->getInt64Value(dsAttrName)); - *dsAttrValueHandle = convertStringToCharPtr(tmpString); - break; - - case DataType::TYPE_INT32: - tmpString = boost::lexical_cast<string>(dataWrapper->getInt64Value(dsAttrName)); - *dsAttrValueHandle = convertStringToCharPtr(tmpString); - break; - - case DataType::TYPE_DOUBLE: - tmpString = boost::lexical_cast<string>(dataWrapper->getDoubleValue(dsAttrName)); - *dsAttrValueHandle = convertStringToCharPtr(tmpString); - break; - - case DataType::TYPE_STRING: - tmpString = boost::lexical_cast<string>(dataWrapper->getStringValue(dsAttrName)); - *dsAttrValueHandle = convertStringToCharPtr(tmpString); - break; - - case DataType::TYPE_BOOLEAN: - tmpString = dataWrapper->getBoolValue(dsAttrName)?"true":"false"; - *dsAttrValueHandle = convertStringToCharPtr(tmpString); - break; - - case DataType::TYPE_BYTEARRAY: - uint32_t len; - std::string binary_field; - const char * base_addr = dataWrapper->getBinaryValue(dsAttrName, len); - binary_field = base64_encode((unsigned char const*)base_addr , len ); - *dsAttrValueHandle = convertStringToCharPtr(binary_field.c_str()); - break; - } - } else { - err = -1003; - } - } else { - err = -1002; - } - } else { - err = -1001; - } - } else { - err = -1000; - } - } catch (CException& e) { - err = e.errorCode; - } - return err; - } - - //--------------------------------------------------------------- - int getStrValueForAttr(uint32_t devID, const char * const dsAttrName, char * dsAttrValueHandle){ - char *pntS=0; - int ret; - ret=getStrValueForAttribute( devID, dsAttrName, &pntS); - if(dsAttrValueHandle && pntS){ - strcpy(dsAttrValueHandle,pntS); - free(pntS); - } else { - ret =-1; - } - return ret; - } - - - //--------------------------------------------------------------- - int setStrValueForAttribute(uint32_t devID, const char * const dsAttrName, const char * const dsAttrValueCStr) { - int err = 0; - string attributeName = dsAttrName; - DeviceController *dCtrl = getDeviceControllerFromID(devID); - if(dCtrl && dsAttrName && dsAttrValueCStr) { - //changed to use the new api - err = dCtrl->setAttributeToValue(dsAttrName, dsAttrValueCStr, false); - } else { - err = -1001; - } - return err; - } - - //--------------------------------------------------------------- - int submitSlowControlCommand(uint32_t dev_id, - const char * const command_alias, - uint16_t submissione_rule, - uint32_t priority, - uint64_t *command_id, - uint32_t scheduler_steps_delay, - uint32_t submission_checker_steps_delay, - const char * const slow_command_data) { - int err = 0; - uint64_t cmd_id_tmp; - DeviceController *dCtrl = getDeviceControllerFromID(dev_id); - if(dCtrl && command_alias) { - //changed to use the new api - ChaosUniquePtr<chaos::common::data::CDataWrapper> data_wrapper; - - std::string cmd_alias_str = command_alias; - if(slow_command_data) { - data_wrapper.reset(new chaos::common::data::CDataWrapper()); - if(data_wrapper.get()) - data_wrapper->setSerializedJsonData(slow_command_data); - else - return -1001; - } - - err = dCtrl->submitSlowControlCommand(cmd_alias_str, - static_cast<chaos::common::batch_command::SubmissionRuleType::SubmissionRule>(submissione_rule), - priority, - cmd_id_tmp, - 0, - scheduler_steps_delay, - submission_checker_steps_delay, - data_wrapper.get()); - if(!err && command_id) { - *command_id = cmd_id_tmp; - } - } else { - err = -1002; - } - return err; - } - - //--------------------------------------------------------------- - int deinitController(uint32_t devID) { - int err = 0; - try{ - if(devID) { - DeviceController * ctrl = getDeviceControllerFromID(devID); - if(ctrl){ - HLDataApi::getInstance()->disposeDeviceControllerPtr(ctrl); - }else{ - err = -1001; - } - } else { - err = -1000; - } - } catch (CException& e) { - err = e.errorCode; - } - return err; - } - - //--------------------------------------------------------------- - int deinitToolkit() { - int err = 0; - try{ - ChaosUIToolkit::getInstance()->deinit(); - } catch (CException& e) { - err = e.errorCode; - } - return err; - } -} diff --git a/chaos/ui_toolkit/ChaosUIToolkitCWrapper.h b/chaos/ui_toolkit/ChaosUIToolkitCWrapper.h deleted file mode 100644 index bcf6bbbfc97d85d917012b648162220acbb92399..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/ChaosUIToolkitCWrapper.h +++ /dev/null @@ -1,244 +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. - */ - -/*! \file ChaosUIToolkitCWrapper*/ - -/*! \page page_uicwrapper The Chaos "C Wrapper" for User Interface Toolkit - * \section page_cuit_sec Why an a "C" language wrapper? - * Some applications used in scentific experiment (as for example LabView) can be - * can be customized with the use of shared library written in "C" language. At this - * scope, !CHAOS give a simple interface to a DeviceController managed by user interface - * toolkit \link UIToolkitCWrapper wrapped with few simple "C" function\endlink. - */ - -/** @defgroup UIToolkitCWrapper "C" language interface to user interface toolkit - * These are the funciton to be used with the "C" language to use cpp UIToolkit library. - * The library to be linked is the same as the cpp language, libchoas_uitoolkit - * @{ - */ - -#ifndef CHAOSFramework_UIToolkitCWrapper_h -#define CHAOSFramework_UIToolkitCWrapper_h - -#include <stdint.h> -#ifdef LABVIEW -// labview unable to parse stdint -typedef unsigned long uint32_t; -typedef int int32_t; - -typedef unsigned short uint16_t; -typedef short int16_t; -typedef unsigned long long uint64_t; -#endif -#ifdef __cplusplus -extern "C" { -#endif - - - //! User interface toolkit initialization - /*! - Perform the user interface toolkit initialization, the startup parameter are the same of the complied - !CHAOS application. For example: --log-on-console is setupped with the string - "log-on-console=true" and for example "--metadata-server=host:5000" is "metadata-server=host:5000" - \param startupParameter the startup initialization string queal to the norma launch program - \return the error of operation, if all goes well the result is 0 - */ - int initToolkit(const char* startupParameter); - - //! Device Controller creation - /*! - Create an instance of the controller for a device. The function return the DeviceControl ID that - need to be used in other funtion. - \param deviceID is the unique string identification for a device. - \param devIDPtr is ap ointer toan unsigned int32 used for return the id for the create channel - \return the error of operation, if all goes well the result is 0 - */ - int getNewControllerForDeviceID(const char * const deviceID, uint32_t *devIDPtr); - - int setControllerTimeout(uint32_t devID, uint32_t timeout); - - //! Get device attribute names - /*! - Retrive the device attributes name giving a device identification string and a a direction. - \param deviceID is the unique string identification for a device. - \param attributeDirection can be one of these value: - - 0 -> input - - 1 -> output - - 2 -> bidirectional - \param attributeNameArrayPtr isthe handle to an array of "c" string - \param attributeNumber a pointer to an interger that will be filled - with the number for attribute names found - \return the error of operation, if all goes well the result is 0 - */ - int getDeviceDatasetAttributeNameForDirection(uint32_t devID, int16_t attributeDirection, char***attributeNameArrayHandle, uint32_t *attributeNumberPtr); - - //! Device initialization - /*! - Perform the initialization of the device, using the setup specified in the metadataserver - \param devID is the identification number got from \link getNewControllerForDeviceID \endlink function - \return the error of operation, if all goes well the result is 0 - */ - int initDevice(uint32_t devID); - - //! Startup the device - /*! - Perform the startup of the device - \param devID is the identification number got from \link getNewControllerForDeviceID \endlink function - \return the error of operation, if all goes well the result is 0 - */ - int startDevice(uint32_t devID); - - //! Setup of the run method delay - /*! - Setup of the delay of the run method schedule - \param devID is the identification number got from \link getNewControllerForDeviceID \endlink function - \param delayTimeInMilliseconds the number of millisecond between lat run method execution - \return the error of operation, if all goes well the result is 0 - */ - int setDeviceRunScheduleDelay(uint32_t devID, int32_t delayTimeInMilliseconds); - - //! Stop the device - /*! - Perform the interruption of the run method scehduling without deinitlize the control unit - \param devID is the identification number got from \link getNewControllerForDeviceID \endlink function - \return the error of operation, if all goes well the result is 0 - */ - int stopDevice(uint32_t devID); - - //! Deinit the device - /*! - Perform the deinitialization of the control unit - \param devID is the identification number got from \link getNewControllerForDeviceID \endlink function - \return the error of operation, if all goes well the result is 0 - */ - int deinitDevice(uint32_t devID); - - //! Fetch the device live data - /*! - Perform the update of device control internal live data cache - \param devID is the identification number got from \link getNewControllerForDeviceID \endlink function - \return the error of operation, if all goes well the result is 0 - */ - int fetchLiveData(uint32_t devID); - - //! fetch the live data for the required dataset - /*! - \param domain_type is the the domain the need to be fetched from the chaos - data chache: 0=DatasetDomainOutput, 1=DatasetDomainInput, 2=DatasetDomainCustom, 3=DatasetDomainSystem - */ - int fetchLiveDatasetByDomain(uint32_t devID, - int16_t domain_type); - - //! return the json representation of the dataset of the needed domain - /*! - the json representation is got form the latest live dataaset for the domain updated by the - last call to the fetchLiveDatasetByDomain api. - */ - int getJSONDescriptionForDataset(uint32_t devID, - int16_t domain_type, - char ** json_dataset_handler); - - //! Return a string represetnation of an attribute value - /*! - Return the stirng representation of an attribute value. The current attribute value is keept from the - device control interna cache, that is filled with \link fetchLiveData \endlink - \param devID is the identification number got from \link getNewControllerForDeviceID \endlink function - \param dsAttrName the name of the attribute - \param dsAttrValueHandle the handle to c string that will contain the attribute value - \return the error of operation, if all goes well the result is 0 - */ - int getStrValueForAttribute(uint32_t devID, const char * const dsAttrName, char ** dsAttrValueHandle); - - /*! - Return the stirng representation of an attribute value. The current attribute value is keept from the - device control interna cache, that is filled with \link fetchLiveData \endlink - \param devID is the identification number got from \link getNewControllerForDeviceID \endlink function - \param dsAttrName the name of the attribute - \param dsAttrValue a pointer to preallocated c string that will contain the attribute value - \return the error of operation, if all goes well the result is 0 - */ - int getStrValueForAttr(uint32_t devID, const char * const dsAttrName, char * dsAttrValue); - - //! Set the value for an attribute - /*! - Set an attribute value using a string reprpesentation for the new value to use. - \param devID is the identification number got from \link getNewControllerForDeviceID \endlink function - \param dsAttrName the name of the attribute - \param dsAttrValueCStr the "c" string representing the attribute value - \return the error of operation, if all goes well the result is 0 - */ - int setStrValueForAttribute(uint32_t devID, const char * const dsAttrName, const char * const dsAttrValueCStr); - - int getTimeStamp(uint32_t devID,uint64_t*ts); - //! Submit a new slow command - /*! - \ingroup API_Slow_Control - The submition of slow command is made collection all the information that permit to submit it - \param dev_id is the identification number got from \link getNewControllerForDeviceID \endlink function - \param command_alias represent the alias of the command the the control unit expost from RPC subsystem - \param submissione_rule determinate the rule with which the command is submitted. @SubmissionRuleType::SubmissionRule - \param command_id is the assigned command id to the submitted one - the execution of the current execution command in the control unit, according with his running state - \param scheduler_steps_delay rapresent the intervall beetween the step of the scehduler [...acquisition -> correlation -> scheduleInterval...] - \param submission_checker_steps_delay is the delay between two steps of the submission checker - \param slow_command_data is the abstraction of the command data that is passed to the set handler befor the scheduler loop of the new command - take palce. The memory of that parameter is not free - */ -/*#ifdef __cplusplus - int submitSlowControlCommand(uint32_t dev_id, - const char * const command_alias, - uint16_t submissione_rule, - uint32_t priority, - uint64_t *command_id, - uint32_t scheduler_steps_delay = 0, - uint32_t submission_checker_steps_delay = 0, - const char * const slow_command_data = NULL); -#else*/ - int submitSlowControlCommand(uint32_t dev_id, - const char * const command_alias, - uint16_t submissione_rule, - uint32_t priority, - uint64_t *command_id, - uint32_t scheduler_steps_delay , - uint32_t submission_checker_steps_delay , - const char * const slow_command_data ); - -//#endif - //! Device Control deinitialization - /*! - Perform deinitialization of a device control associated to an id - \param devID is the identification number got from \link getNewControllerForDeviceID \endlink function - \return the error of operation, if all goes well the result is 0 - */ - int deinitController(uint32_t devID); - - //! UiToolkit deinitialization - /*! - Perform the deinitialization of UIToolkit - \return the error of operation, if all goes well the result is 0 - */ - int deinitToolkit(); -#ifdef __cplusplus -} -#endif - - /** @} */ // end of UIToolkitCWrapper -#endif diff --git a/chaos/ui_toolkit/HighLevelApi/DeviceController.cpp b/chaos/ui_toolkit/HighLevelApi/DeviceController.cpp deleted file mode 100644 index 4d2cbb4aa8afe7acf8e3f76a154891138afc35df..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/HighLevelApi/DeviceController.cpp +++ /dev/null @@ -1,1065 +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 "DeviceController.h" -#include <chaos/common/chaos_constants.h> -#include <chaos/common/data/CDataWrapper.h> -#include <chaos/ui_toolkit/LowLevelApi/LLRpcApi.h> -#include <boost/lexical_cast.hpp> - -using namespace std; -using namespace chaos; -using namespace chaos::ui; -using namespace chaos::common::io; -using namespace chaos::common::data; -using namespace chaos::common::utility; -using namespace chaos::common::message; -using namespace chaos::common::batch_command; - - - -//--------------------------------------------------------------------------------------------------- -DeviceController::DeviceController(string& _deviceID): -device_id(_deviceID), -datasetDB(true) { - - const ChaosUniquePtr<chaos::common::data::CDataWrapper> d; - mdsChannel = NULL; - deviceChannel = NULL; - ioLiveDataDriver = NULL; - millisecToWait = RpcConfigurationKey::GlobalRPCTimeoutinMSec; - channel_keys.push_back(device_id + DataPackPrefixID::OUTPUT_DATASET_POSTFIX); - channel_keys.push_back(device_id + DataPackPrefixID::INPUT_DATASET_POSTFIX); - channel_keys.push_back(device_id + DataPackPrefixID::CUSTOM_DATASET_POSTFIX); - channel_keys.push_back(device_id + DataPackPrefixID::SYSTEM_DATASET_POSTFIX); - channel_keys.push_back(device_id + DataPackPrefixID::DEV_ALARM_DATASET_POSTFIX); - channel_keys.push_back(device_id + DataPackPrefixID::CU_ALARM_DATASET_POSTFIX); - channel_keys.push_back(device_id + DataPackPrefixID::HEALTH_DATASET_POSTFIX); - - // current_dataset.push_back(d); - for(int cnt=0;cnt<channel_keys.size();cnt++) - current_dataset.push_back(ChaosSharedPtr<chaos::common::data::CDataWrapper>()); - - - //allocate device channel the memory of the CDeviceNetworkAddress * is managed by channel - CDeviceNetworkAddress *address = new CDeviceNetworkAddress(_deviceID); - //get a new message channel in a self manage way - deviceChannel = LLRpcApi::getInstance()->getNewDeviceMessageChannel(address, - true); - if(!deviceChannel) throw CException(-4, "Invalid device channel created", "DeviceController::init"); -} - -//--------------------------------------------------------------------------------------------------- -DeviceController::~DeviceController() { - LDBG_<<"["<<__PRETTY_FUNCTION__<<"] remove Device Controller:"<<device_id; - stopTracking(); - - if(mdsChannel){ - LLRpcApi::getInstance()->deleteMessageChannel(mdsChannel); - } - - - if(deviceChannel){ - LLRpcApi::getInstance()->deleteMessageChannel(deviceChannel); - - } - - if(ioLiveDataDriver){ - ioLiveDataDriver->deinit(); - delete(ioLiveDataDriver); - } -} - -//--------------------------------------------------------------------------------------------------- -void DeviceController::setRequestTimeWaith(uint32_t newMillisecToWait){ - millisecToWait = newMillisecToWait; -} - -//--------------------------------------------------------------------------------------------------- -uint32_t DeviceController::getRequestTimeWaith(){ - return millisecToWait; -} - -//--------------------------------------------------------------------------------------------------- -void DeviceController::getDeviceId(string& dId) { - dId = device_id; -} - -//--------------------------------------------------------------------------------------------------- -void DeviceController::updateChannel() throw(CException) { - int err = ErrorCode::EC_NO_ERROR; - CDataWrapper *tmp_data_handler = NULL; - CDeviceNetworkAddress *devAddress = NULL; - //make the live driver - if(!mdsChannel){ - mdsChannel = LLRpcApi::getInstance()->getNewMetadataServerChannel(); - if(!mdsChannel) throw CException(-1, "No MDS Channel created", "DeviceController::init"); - } - - err = mdsChannel->getLastDatasetForDevice(device_id, &tmp_data_handler, millisecToWait); - if(err!=ErrorCode::EC_NO_ERROR || !tmp_data_handler) throw CException(-2, "No device dataset received", "DeviceController::updateChannel"); - - ChaosUniquePtr<chaos::common::data::CDataWrapper> lastDeviceDefinition(tmp_data_handler); - - datasetDB.addAttributeToDataSetFromDataWrapper(*lastDeviceDefinition.get()); - - err = mdsChannel->getNetworkAddressForDevice(device_id, &devAddress, millisecToWait); - if(err!=ErrorCode::EC_NO_ERROR || !devAddress) throw CException(-3, "No Address found for device", "DeviceController::init"); - - //update live data driver - if(!ioLiveDataDriver) { - ioLiveDataDriver = LLRpcApi::getInstance()->getDataProxyChannelNewInstance(); - if(ioLiveDataDriver) { - ioLiveDataDriver->init(NULL); - if(!mdsChannel->getDataDriverBestConfiguration(&tmp_data_handler, millisecToWait)){ - ChaosUniquePtr<chaos::common::data::CDataWrapper> best_available_da_ptr(tmp_data_handler); - ioLiveDataDriver->updateConfiguration(best_available_da_ptr.get()); - } - } - } -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::setScheduleDelay(uint64_t microseconds) { - CHAOS_ASSERT(deviceChannel) - return deviceChannel->setScheduleDelay(microseconds, millisecToWait); -} - -//--------------------------------------------------------------------------------------------------- -void DeviceController::getDeviceDatasetAttributesName(vector<string>& attributesName) { - datasetDB.getDatasetAttributesName(attributesName); -} - -//--------------------------------------------------------------------------------------------------- -void DeviceController::getAttributeDescription(const string& attributesName, string& attributeDescription) { - datasetDB.getAttributeDescription(attributesName, attributeDescription); -} - -//--------------------------------------------------------------------------------------------------- -void DeviceController::getDeviceDatasetAttributesName(vector<string>& attributesName, DataType::DataSetAttributeIOAttribute directionType) { - datasetDB.getDatasetAttributesName(directionType, attributesName); -} - -//--------------------------------------------------------------------------------------------------- -void DeviceController::getDeviceAttributeRangeValueInfo(const string& attributesName, chaos::common::data::RangeValueInfo& rangeInfo) { - datasetDB.getAttributeRangeValueInfo(attributesName, rangeInfo); -} -//--------------------------------------------------------------------------------------------------- -int DeviceController::getDeviceAttributeDirection(const string& attributesName, DataType::DataSetAttributeIOAttribute& directionType) { - return datasetDB.getAttributeDirection(attributesName, directionType); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::getAttributeStrValue(string attribute_name, string& attribute_value) { - int err = 0; - CDataWrapper * dataWrapper = getLiveCDataWrapperPtr(); - if(dataWrapper) { - DataType::DataType attributeType; - err = getDeviceAttributeType(attribute_name, attributeType); - if(err == 0){ - switch (attributeType) { - case DataType::TYPE_INT64: - attribute_value = boost::lexical_cast<string>(dataWrapper->getInt64Value(attribute_name.c_str())); - break; - - case DataType::TYPE_INT32: - attribute_value = boost::lexical_cast<string>(dataWrapper->getInt64Value(attribute_name.c_str())); - break; - - case DataType::TYPE_DOUBLE: - attribute_value = boost::lexical_cast<string>(dataWrapper->getDoubleValue(attribute_name.c_str())); - break; - - case DataType::TYPE_CLUSTER: - case DataType::TYPE_STRING: - attribute_value = boost::lexical_cast<string>(dataWrapper->getStringValue(attribute_name.c_str())); - break; - - case DataType::TYPE_BOOLEAN: - attribute_value = boost::lexical_cast<string>(dataWrapper->getBoolValue(attribute_name.c_str())); - break; - - case DataType::TYPE_BYTEARRAY: { - const char *buffer = NULL; - uint32_t size; - buffer = dataWrapper->getBinaryValue(attribute_name.c_str(), size); - if(buffer) attribute_value.assign(buffer, size); - break; - } - - default: - err = -1; - break; - } - } - - } - return err; -} -//--------------------------------------------------------------------------------------------------- -int DeviceController::getDeviceAttributeType(const string& attr, DataType::DataType& type) { - int err = 0; - if(attributeValueMap.count(attr)){ - type = attributeValueMap[attr].valueType; - } else { - err = -1; - } - return err; -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::getType(std::string& control_unit_type) { - int err = 0; - if(cu_type.empty()) { - CDataWrapper*tmp=fetchCurrentDatatasetFromDomain(DatasetDomainSystem); - if(tmp && tmp->hasKey(DataPackSystemKey::DP_SYS_UNIT_TYPE)){ - std::string t=tmp->getCStringValue(DataPackSystemKey::DP_SYS_UNIT_TYPE); - cu_type = t; - } else { - return -1; - } - - } - control_unit_type = cu_type; - - return err; -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::initDevice() { - CHAOS_ASSERT(mdsChannel && deviceChannel) - int err = 0; - CDataWrapper initConf; - datasetDB.fillDataWrapperWithDataSetDescription(initConf); - - //initialize the devica with the metadataserver data - err = deviceChannel->initDevice(&initConf, millisecToWait); - //configure the live data with the same server where the device write - return err; -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::startDevice() { - CHAOS_ASSERT(deviceChannel) - return deviceChannel->startDevice(millisecToWait); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::stopDevice() { - CHAOS_ASSERT(deviceChannel) - return deviceChannel->stopDevice(millisecToWait); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::deinitDevice() { - CHAOS_ASSERT(deviceChannel) - return deviceChannel->deinitDevice(millisecToWait); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::restoreDeviceToTag(const std::string& restore_tag) { - CHAOS_ASSERT(deviceChannel) - return deviceChannel->restoreDeviceToTag(restore_tag, - millisecToWait); -} -int DeviceController::recoverDeviceFromError() { - CHAOS_ASSERT(deviceChannel) - return deviceChannel->recoverDeviceFromError(millisecToWait); -} -//--------------------------------------------------------------------------------------------------- -uint64_t DeviceController::getState(CUStateKey::ControlUnitState& deviceState) { - uint64_t ret=0; - CDataWrapper*tmp=fetchCurrentDatatasetFromDomain(DatasetDomainHealth); - deviceState=CUStateKey::UNDEFINED; - if(tmp && tmp->hasKey(NodeHealtDefinitionKey::NODE_HEALT_STATUS)){ - std::string state=tmp->getCStringValue(NodeHealtDefinitionKey::NODE_HEALT_STATUS); - if((state== NodeHealtDefinitionValue::NODE_HEALT_STATUS_START) || (state== NodeHealtDefinitionValue::NODE_HEALT_STATUS_STARTING)) - deviceState=CUStateKey::START; - else if((state== NodeHealtDefinitionValue::NODE_HEALT_STATUS_STOP) || (state== NodeHealtDefinitionValue::NODE_HEALT_STATUS_STOPING)) - deviceState= CUStateKey::STOP; - else if((state== NodeHealtDefinitionValue::NODE_HEALT_STATUS_INIT) || (state== NodeHealtDefinitionValue::NODE_HEALT_STATUS_INITING)) - deviceState= CUStateKey::INIT; - else if((state== NodeHealtDefinitionValue::NODE_HEALT_STATUS_DEINIT) || (state== NodeHealtDefinitionValue::NODE_HEALT_STATUS_DEINITING)|| (state== NodeHealtDefinitionValue::NODE_HEALT_STATUS_LOAD)) - deviceState= CUStateKey::DEINIT; - else if((state== NodeHealtDefinitionValue::NODE_HEALT_STATUS_RERROR)) - deviceState= CUStateKey::RECOVERABLE_ERROR; - else if((state== NodeHealtDefinitionValue::NODE_HEALT_STATUS_FERROR)) - deviceState= CUStateKey::FATAL_ERROR; - - if(tmp->hasKey(NodeHealtDefinitionKey::NODE_HEALT_TIMESTAMP)){ - ret = tmp->getInt64Value(NodeHealtDefinitionKey::NODE_HEALT_TIMESTAMP); - } - } - return ret; -} - -int DeviceController::getChannelsNum(){ - return channel_keys.size(); -} -//--------------------------------------------------------------------------------------------------- -int DeviceController::setAttributeValue(string& attributeName, int32_t attributeValue) { - return setAttributeValue(attributeName.c_str(), attributeValue); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::setAttributeValue(const char *attributeName, int32_t attributeValue) { - CDataWrapper attributeValuePack; - attributeValuePack.addInt32Value(attributeName, attributeValue); - return deviceChannel->setAttributeValue(attributeValuePack, millisecToWait); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::setAttributeValue(string& attributeName, double attributeValue) { - return setAttributeValue(attributeName.c_str(), attributeValue); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::setAttributeValue(const char *attributeName, double attributeValue) { - CDataWrapper attributeValuePack; - attributeValuePack.addDoubleValue(attributeName, attributeValue); - return deviceChannel->setAttributeValue(attributeValuePack, millisecToWait); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::setAttributeToValue(const char *attributeName, const char *attributeValue, bool noWait) { - int err = ErrorCode::EC_NO_ERROR; - CDataWrapper attributeValuePack; - RangeValueInfo range_info; - - //get type for the value - if((err = datasetDB.getAttributeRangeValueInfo(attributeName, range_info))) - return err; - - switch (range_info.valueType) { - case DataType::TYPE_BOOLEAN: { - bool boolValuePtr = lexical_cast<bool>(attributeValue); - attributeValuePack.addBoolValue(attributeName, boolValuePtr); - break; - } - case DataType::TYPE_CLUSTER: - attributeValuePack.addJsonValue(attributeName, attributeValue); - break; - - - case DataType::TYPE_STRING:{ - attributeValuePack.addStringValue(attributeName, attributeValue); - break; - } - case DataType::TYPE_DOUBLE:{ - double doubleValuePtr = lexical_cast<double>(attributeValue); - attributeValuePack.addDoubleValue(attributeName, doubleValuePtr); - break; - } - case DataType::TYPE_INT32:{ - int32_t i32ValuePtr = lexical_cast<int32_t>(attributeValue); - attributeValuePack.addInt32Value(attributeName, i32ValuePtr); - break; - } - case DataType::TYPE_INT64:{ - int64_t i64ValuePtr = lexical_cast<int64_t>(attributeValue); - attributeValuePack.addInt64Value(attributeName, i64ValuePtr); - break; - } - case DataType::TYPE_BYTEARRAY:{ - //const char *byteArrayValuePtr = static_cast<const char*>(attributeValue); - //attributeValuePack.addBinaryValue(attributeName, byteArrayValuePtr, bufferValuedDim); - throw CException(1, "The byte array set is not managed", "DeviceController::setAttributeToValue"); - break; - } - } - return deviceChannel->setAttributeValue(attributeValuePack, noWait, millisecToWait); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::setAttributeToValue(const char *attributeName, void *attributeValue, bool noWait, int32_t bufferValuedDim) { - RangeValueInfo range_info; - - //get type for the value - datasetDB.getAttributeRangeValueInfo(attributeName, range_info); - - //call default API - return setAttributeToValue(attributeName, range_info.valueType, attributeValue, noWait, bufferValuedDim); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::setAttributeToValue(const char *attributeName, DataType::DataType attributeType, void *attributeValue, bool noWait, int32_t bufferValuedDim) { - CDataWrapper attributeValuePack; - switch (attributeType) { - case DataType::TYPE_BOOLEAN: { - bool *boolValuePtr = static_cast<bool *>(attributeValue); - attributeValuePack.addBoolValue(attributeName, *boolValuePtr); - break; - } - case DataType::TYPE_CLUSTER:{ - - attributeValuePack.addJsonValue(attributeName,static_cast<const char *>(attributeValue)); - break; - } - case DataType::TYPE_STRING:{ - const char *strValuePtr = static_cast<const char *>(attributeValue); - attributeValuePack.addStringValue(attributeName, strValuePtr); - break; - } - case DataType::TYPE_DOUBLE:{ - double *doubleValuePtr = static_cast<double*>(attributeValue); - attributeValuePack.addDoubleValue(attributeName, *doubleValuePtr); - break; - } - case DataType::TYPE_INT32:{ - int32_t *i32ValuePtr = static_cast<int32_t*>(attributeValue); - attributeValuePack.addInt32Value(attributeName, *i32ValuePtr); - break; - } - case DataType::TYPE_INT64:{ - int64_t *i64ValuePtr = static_cast<int64_t*>(attributeValue); - attributeValuePack.addInt64Value(attributeName, *i64ValuePtr); - break; - } - case DataType::TYPE_BYTEARRAY:{ - const char *byteArrayValuePtr = static_cast<const char*>(attributeValue); - attributeValuePack.addBinaryValue(attributeName, byteArrayValuePtr, bufferValuedDim); - break; - } - } - return deviceChannel->setAttributeValue(attributeValuePack, noWait, millisecToWait); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::submitSlowControlCommand(string commandAlias, - SubmissionRuleType::SubmissionRule submissionRule, - uint32_t priority, - uint64_t& command_id, - uint32_t execution_channel, - uint64_t scheduler_steps_delay, - uint32_t submission_checker_steps_delay, - CDataWrapper *slow_command_data) { - CDataWrapper local_command_pack; - CDataWrapper *result_data = NULL; - int err = ErrorCode::EC_NO_ERROR; - - if(slow_command_data) { - local_command_pack.appendAllElement(*slow_command_data); - } - - // set the default slow command information - local_command_pack.addStringValue(BatchCommandAndParameterDescriptionkey::BC_ALIAS, commandAlias); - local_command_pack.addInt32Value(BatchCommandSubmissionKey::SUBMISSION_RULE_UI32, (uint32_t) submissionRule); - local_command_pack.addInt32Value(BatchCommandSubmissionKey::SUBMISSION_PRIORITY_UI32, (uint32_t) priority); - - if(execution_channel) local_command_pack.addInt32Value(BatchCommandSubmissionKey::COMMAND_EXECUTION_CHANNEL, (uint32_t) execution_channel); - if(scheduler_steps_delay) local_command_pack.addInt64Value(BatchCommandSubmissionKey::SCHEDULER_STEP_TIME_INTERVALL_UI64, scheduler_steps_delay); - if(submission_checker_steps_delay) local_command_pack.addInt32Value(BatchCommandSubmissionKey::SUBMISSION_RETRY_DELAY_UI32, submission_checker_steps_delay); - - //err = deviceChannel->setAttributeValue(local_command_pack, false, millisecToWait); - local_command_pack.addStringValue(NodeDefinitionKey::NODE_UNIQUE_ID, device_id); - err = deviceChannel->sendCustomRequest(ControlUnitNodeDomainAndActionRPC::CONTROL_UNIT_APPLY_INPUT_DATASET_ATTRIBUTE_CHANGE_SET, &local_command_pack, &result_data, millisecToWait); - if(err == ErrorCode::EC_NO_ERROR && - result_data && - result_data->hasKey(BatchCommandExecutorRpcActionKey::RPC_GET_COMMAND_STATE_CMD_ID_UI64)) { - //fill the command id - command_id = result_data->getUInt64Value(BatchCommandExecutorRpcActionKey::RPC_GET_COMMAND_STATE_CMD_ID_UI64); - } else { - if(result_data) - LERR_<<"missing key:"<<BatchCommandExecutorRpcActionKey::RPC_GET_COMMAND_STATE_CMD_ID_UI64<<" :"<<result_data->getJSONString(); - } - //forward the request - if(result_data) delete(result_data); - return err; -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::submitSlowControlCommand(string commandAlias, - SubmissionRuleType::SubmissionRule submissionRule, - uint64_t& command_id, - uint32_t execution_channel, - uint64_t scheduler_steps_delay, - uint32_t submission_checker_steps_delay, - CDataWrapper *slow_command_data) { - CDataWrapper local_command_pack; - CDataWrapper *result_data = NULL; - int err = ErrorCode::EC_NO_ERROR; - - if(slow_command_data) { - local_command_pack.appendAllElement(*slow_command_data); - } - // set the default slow command information - local_command_pack.addStringValue(BatchCommandAndParameterDescriptionkey::BC_ALIAS, commandAlias); - local_command_pack.addInt32Value(BatchCommandSubmissionKey::SUBMISSION_RULE_UI32, (uint32_t) submissionRule); - - if(execution_channel) local_command_pack.addInt32Value(BatchCommandSubmissionKey::COMMAND_EXECUTION_CHANNEL, (uint32_t) execution_channel); - if(scheduler_steps_delay) local_command_pack.addInt64Value(BatchCommandSubmissionKey::SCHEDULER_STEP_TIME_INTERVALL_UI64, scheduler_steps_delay); - if(submission_checker_steps_delay) local_command_pack.addInt32Value(BatchCommandSubmissionKey::SUBMISSION_RETRY_DELAY_UI32, (uint32_t) submission_checker_steps_delay); - - //forward the request - local_command_pack.addStringValue(NodeDefinitionKey::NODE_UNIQUE_ID, device_id); - err = deviceChannel->sendCustomRequest(ControlUnitNodeDomainAndActionRPC::CONTROL_UNIT_APPLY_INPUT_DATASET_ATTRIBUTE_CHANGE_SET, - &local_command_pack, - &result_data, - millisecToWait); - if(err == ErrorCode::EC_NO_ERROR - && result_data - && result_data->hasKey(BatchCommandExecutorRpcActionKey::RPC_GET_COMMAND_STATE_CMD_ID_UI64)) { - //fill the command id - command_id = result_data->getUInt64Value(BatchCommandExecutorRpcActionKey::RPC_GET_COMMAND_STATE_CMD_ID_UI64); - } - //delete result data - if(result_data)delete(result_data); - return err; -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::setSlowCommandFeatures(features::Features& features, bool lock_features, uint32_t execution_channel) { - CDataWrapper local_command_pack; - if(features.featuresFlag & features::FeaturesFlagTypes::FF_LOCK_USER_MOD) { - local_command_pack.addBoolValue(BatchCommandExecutorRpcActionKey::RPC_SET_COMMAND_FEATURES_LOCK_BOOL, lock_features); - } - - if(features.featuresFlag & features::FeaturesFlagTypes::FF_SET_SCHEDULER_DELAY) { - local_command_pack.addInt64Value(BatchCommandExecutorRpcActionKey::RPC_SET_COMMAND_FEATURES_SCHEDULER_STEP_WAITH_UI64, features.featureSchedulerStepsDelay); - } - - if(execution_channel) local_command_pack.addInt32Value(BatchCommandSubmissionKey::COMMAND_EXECUTION_CHANNEL, (uint32_t) execution_channel); - - return deviceChannel->sendCustomRequest(BatchCommandExecutorRpcActionKey::RPC_SET_COMMAND_FEATURES, &local_command_pack, NULL, millisecToWait); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::setSlowCommandLockOnFeatures(bool lock_features) { - CDataWrapper local_command_pack; - local_command_pack.addBoolValue(BatchCommandExecutorRpcActionKey::RPC_SET_COMMAND_FEATURES_LOCK_BOOL, lock_features); - return deviceChannel->sendCustomRequest(BatchCommandExecutorRpcActionKey::RPC_SET_COMMAND_FEATURES, &local_command_pack, NULL, millisecToWait); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::getCommandState(CommandState& command_state) { - CDataWrapper local_command_pack; - CDataWrapper *result_data = NULL; - int err = ErrorCode::EC_NO_ERROR; - local_command_pack.addInt64Value(BatchCommandExecutorRpcActionKey::RPC_GET_COMMAND_STATE_CMD_ID_UI64, command_state.command_id); - err = deviceChannel->sendCustomRequest(BatchCommandExecutorRpcActionKey::RPC_GET_COMMAND_STATE, &local_command_pack, &result_data, millisecToWait); - if(err == ErrorCode::EC_NO_ERROR && - result_data) { - //fill the command state - command_state.last_event = static_cast<BatchCommandEventType::BatchCommandEventType>(result_data->getUInt32Value(BatchCommandExecutorRpcActionKey::RPC_GET_COMMAND_STATE_LAST_EVENT_UI32)); - if(command_state.last_event == BatchCommandEventType::EVT_FAULT) { - command_state.fault_description.code = result_data->getUInt32Value(BatchCommandExecutorRpcActionKey::RPC_GET_COMMAND_STATE_ERROR_CODE_UI32); - command_state.fault_description.description = result_data->getStringValue(BatchCommandExecutorRpcActionKey::RPC_GET_COMMAND_STATE_ERROR_DESC_STR); - command_state.fault_description.domain = BatchCommandExecutorRpcActionKey::RPC_GET_COMMAND_STATE_ERROR_DOMAIN_STR; - } else { - command_state.fault_description.code = 0; - command_state.fault_description.description.clear(); - command_state.fault_description.domain.clear(); - } - } - if(result_data) delete(result_data); - return err; -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::killCurrentCommand() { - return deviceChannel->sendCustomRequest(BatchCommandExecutorRpcActionKey::RPC_KILL_CURRENT_COMMAND, NULL, NULL, millisecToWait); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::flushCommandStateHistory() { - return 0;//deviceChannel->sendCustomRequest(BatchCommandExecutorRpcActionKey::RPC_FLUSH_COMMAND_HISTORY, NULL, NULL, millisecToWait); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::sendCustomRequest(const std::string& action, - common::data::CDataWrapper * const param, - common::data::CDataWrapper**const result) { - return deviceChannel->sendCustomRequest(action, param, result, millisecToWait); -} - -//--------------------------------------------------------------------------------------------------- -void DeviceController::sendCustomMessage(const std::string& action, - common::data::CDataWrapper * const param) { - deviceChannel->sendCustomMessage(action, - param); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::checkRPCInformation(CDataWrapper **result_information, - uint32_t timeout) { - int err = -1; - ChaosUniquePtr<MessageRequestFuture> result = deviceChannel->checkRPCInformation(); - if(result.get() == NULL) return -1; - if(result->wait(timeout)) { - err = result->getError(); - if(err == 0) { - *result_information = result->detachResult(); - } - }else{ - err = -2; - } - return err; -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::echoTest(CDataWrapper * const echo_data, - CDataWrapper **echo_data_result, - uint32_t timeout) { - int err = -1; - ChaosUniquePtr<MessageRequestFuture> result = deviceChannel->echoTest(echo_data); - if(result.get() == NULL) return err; - if(result->wait(timeout)) { - err = result->getError(); - if(err == 0) { - *echo_data_result = result->detachResult(); - } - }else{ - err = -2; - } - return err; -} - -//--------------------------------------------------------------------------------------------------- -ChaosUniquePtr<MessageRequestFuture> DeviceController::sendCustomRequestWithFuture(const std::string& action_name, - common::data::CDataWrapper *request_date) { - return deviceChannel->sendCustomRequestWithFuture(action_name, - request_date); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::setAttributeValue(string& attributeName, string& attributeValue) { - return setAttributeValue(attributeName, attributeValue.c_str(),(uint32_t)attributeValue.size()); -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::setAttributeValue(string& attributeName, const char* attributeValue) { - return setAttributeValue(attributeName, attributeValue,(uint32_t)strlen(attributeValue)); -} - -std::vector<chaos::common::data::RangeValueInfo> DeviceController::getDeviceValuesInfo(){ - std::vector<chaos::common::data::RangeValueInfo> ret; - for(std::map<std::string,chaos::common::data::RangeValueInfo>::iterator i= attributeValueMap.begin();i!=attributeValueMap.end();i++) - ret.push_back(i->second); - - return ret; -} -//--------------------------------------------------------------------------------------------------- -int DeviceController::setAttributeValue(string& attributeName, const char* attributeValue, uint32_t size) { - CDataWrapper attributeValuePack; - const char *attrname=attributeName.c_str(); - - if(attributeValueMap.find(attributeName) == attributeValueMap.end() ) - return ErrorCode::EC_ATTRIBUTE_NOT_FOUND; - - if(attributeValueMap[attributeName].dir==DataType::Output) - return ErrorCode::EC_ATTRIBUTE_BAD_DIR; - - switch (attributeValueMap[attributeName].valueType) { - - case DataType::TYPE_INT64: - attributeValuePack.addInt64Value(attrname, boost::lexical_cast<int64_t>(attributeValue)); - return deviceChannel->setAttributeValue(attributeValuePack,millisecToWait); - - case DataType::TYPE_INT32: - attributeValuePack.addInt32Value(attrname, boost::lexical_cast<int32_t>(attributeValue)); - return deviceChannel->setAttributeValue(attributeValuePack,millisecToWait); - - case DataType::TYPE_DOUBLE: - attributeValuePack.addDoubleValue(attrname, boost::lexical_cast<double>(attributeValue)); - return deviceChannel->setAttributeValue(attributeValuePack,millisecToWait); - - case DataType::TYPE_BYTEARRAY: - attributeValuePack.addBinaryValue(attrname,attributeValue,size); - return deviceChannel->setAttributeValue(attributeValuePack,millisecToWait); - case DataType::TYPE_CLUSTER:{ - - attributeValuePack.addJsonValue(attrname,attributeValue); - - return deviceChannel->setAttributeValue(attributeValuePack,millisecToWait); - } - case DataType::TYPE_STRING: - attributeValuePack.addStringValue(attrname,attributeValue); - return deviceChannel->setAttributeValue(attributeValuePack,millisecToWait); - default: - break; - }; - return ErrorCode::EC_ATTRIBUTE_TYPE_NOT_SUPPORTED; -} - -//--------------------------------------------------------------------------------------------------- -void DeviceController::initializeAttributeIndexMap() { - // boost::mutex::scoped_lock lock(trackMutext); - vector<string> attributeNames; - RangeValueInfo attributerangeInfo; - - attributeValueMap.clear(); - - - //get all attribute name from db - datasetDB.getDatasetAttributesName(DataType::Input, attributeNames); - for (vector<string>::iterator iter = attributeNames.begin(); - iter != attributeNames.end(); - iter++) { - - if(datasetDB.getAttributeRangeValueInfo(*iter, attributerangeInfo)!=0){ - LERR_<<"CANNOT RETRIVE attr range info of:"<<*iter; - } - LDBG_<<"IN attr:"<<attributerangeInfo.name<<" type:"<<attributerangeInfo.valueType; - attributeValueMap.insert(make_pair(*iter, attributerangeInfo)); - - } - - attributeNames.clear(); - datasetDB.getDatasetAttributesName(DataType::Output, attributeNames); - for (vector<string>::iterator iter = attributeNames.begin(); - iter != attributeNames.end(); - iter++) { - - - if(datasetDB.getAttributeRangeValueInfo(*iter, attributerangeInfo)!=0){ - LERR_<<"CANNOT RETRIVE attr range info of:"<<*iter; - - } - LDBG_<<"OUT attr:"<<attributerangeInfo.name<<" type:"<<attributerangeInfo.valueType; - attributeValueMap.insert(make_pair(*iter, attributerangeInfo)); - - } - -} - -//--------------------------------------------------------------------------------------------------- -void DeviceController::allocateNewLiveBufferForAttributeAndType(string& attributeName, - DataType::DataSetAttributeIOAttribute attributeDirection, - DataType::DataType attrbiuteType) { - //boost::mutex::scoped_lock lock(trackMutext); - if(attributeDirection == DataType::Output || - attributeDirection == DataType::Bidirectional ){ - - switch (attributeValueMap[attributeName].valueType) { - - - case DataType::TYPE_INT32:{ - SingleBufferCircularBuffer<int32_t> *newBuffer = new SingleBufferCircularBuffer<int32_t>(30); - int32AttributeLiveBuffer.insert(make_pair(attributeName, newBuffer)); - } - break; - - case DataType::TYPE_INT64:{ - SingleBufferCircularBuffer<int64_t> *newBuffer = new SingleBufferCircularBuffer<int64_t>(30); - int64AttributeLiveBuffer.insert(make_pair(attributeName, newBuffer)); - } - break; - - case DataType::TYPE_DOUBLE:{ - SingleBufferCircularBuffer<double_t> *newBuffer = new SingleBufferCircularBuffer<double_t>(30); - doubleAttributeLiveBuffer.insert(make_pair(attributeName, newBuffer)); - } - break; - case DataType::TYPE_BYTEARRAY:{ - PointerBuffer *newBuffer = new PointerBuffer(); - pointerAttributeLiveBuffer.insert(make_pair(attributeName, newBuffer)); - } - break; - } - } else if(attributeDirection == DataType::Input || - attributeDirection == DataType::Bidirectional ){ - - } - -} - -//--------------------------------------------------------------------------------------------------- -UIDataBuffer *DeviceController::getBufferForAttribute(string& attributeName) { - boost::mutex::scoped_lock lock(trackMutext); - UIDataBuffer * result = NULL; - //allocate attribute traccking - - if(attributeValueMap.count(attributeName) == 0 ) return result; - - switch (attributeValueMap[attributeName].valueType) { - - case DataType::TYPE_INT32: - result = int32AttributeLiveBuffer[attributeName]; - break; - - case DataType::TYPE_INT64: - result = int64AttributeLiveBuffer[attributeName]; - break; - - case DataType::TYPE_DOUBLE: - result = doubleAttributeLiveBuffer[attributeName]; - break; - } - return result; -} - -//--------------------------------------------------------------------------------------------------- -PointerBuffer *DeviceController::getPtrBufferForAttribute(string& attributeName) { - boost::mutex::scoped_lock lock(trackMutext); - PointerBuffer * result = NULL; - //allocate attribute traccking - if(attributeValueMap.count(attributeName) == 0 ) return result; - - switch (attributeValueMap[attributeName].valueType) { - - case DataType::TYPE_BYTEARRAY: - result = pointerAttributeLiveBuffer[attributeName]; - break; - default: - break; - } - return result; -} - -//--------------------------------------------------------------------------------------------------- -UIDataBuffer *DeviceController::getPtrBufferForTimestamp(const int initialDimension) { - return int64AttributeLiveBuffer.count(DataPackCommonKey::DPCK_TIMESTAMP)>0? int64AttributeLiveBuffer[DataPackCommonKey::DPCK_TIMESTAMP]:NULL; -} - -//--------------------------------------------------------------------------------------------------- -void DeviceController::deinitializeAttributeIndexMap() { - // boost::mutex::scoped_lock lock(trackMutext); - //dispose circula buffer - for (std::map<string, SingleBufferCircularBuffer<int32_t> *>::iterator iter = int32AttributeLiveBuffer.begin(); - iter != int32AttributeLiveBuffer.end(); - iter++) { - delete(iter->second); - } - int32AttributeLiveBuffer.clear(); - - for (std::map<string, SingleBufferCircularBuffer<int64_t> *>::iterator iter = int64AttributeLiveBuffer.begin(); - iter != int64AttributeLiveBuffer.end(); - iter++) { - delete(iter->second); - } - int64AttributeLiveBuffer.clear(); - - for (std::map<string, SingleBufferCircularBuffer<double_t> *>::iterator iter = doubleAttributeLiveBuffer.begin(); - iter != doubleAttributeLiveBuffer.end(); - iter++) { - delete(iter->second); - } - doubleAttributeLiveBuffer.clear(); - - for (std::map<string, PointerBuffer*>::iterator iter = pointerAttributeLiveBuffer.begin(); - iter != pointerAttributeLiveBuffer.end(); - iter++) { - delete(iter->second); - } - pointerAttributeLiveBuffer.clear(); -} - -//--------------------------------------------------------------------------------------------------- -void DeviceController::addAttributeToTrack(string& attr) { - boost::mutex::scoped_lock lock(trackMutext); - - //add attribute name to list of tracking attribute - trackingAttribute.push_back(attr); - - //allocate attribute traccking - if(attributeValueMap.count(attr) == 0 ) return; - - //allcoate the buffer for the new attribute to track - allocateNewLiveBufferForAttributeAndType(attr, attributeValueMap[attr].dir, attributeValueMap[attr].valueType); -} - -//--------------------------------------------------------------------------------------------------- -CDataWrapper * DeviceController::getLiveCDataWrapperPtr() { - return current_dataset[DatasetDomainOutput].get(); -} - - -//--------------------------------------------------------------------------------------------------- -CDataWrapper * DeviceController::getCurrentDatasetForDomain(DatasetDomain domain) { - if(domain<current_dataset.size()){ - return current_dataset[domain].get(); - } - return NULL; -} - -//--------------------------------------------------------------------------------------------------- -chaos::common::data::CDataWrapper * DeviceController::fetchCurrentDatatasetFromDomain(DatasetDomain domain) { - CHAOS_ASSERT(ioLiveDataDriver) - char *value = NULL; - size_t value_len = 0; - if(domain<current_dataset.size()){ - value = ioLiveDataDriver->retriveRawData(channel_keys[domain],(size_t*)&value_len); - if(value){ - chaos::common::data::CDataWrapper *tmp = new CDataWrapper(value); - current_dataset[domain].reset(tmp); - free(value); - return tmp; - } - } - return NULL; -} - -//--------------------------------------------------------------------------------------------------- -int DeviceController::getTimeStamp(uint64_t& live){ - CDataWrapper * d = current_dataset[DatasetDomainOutput].get(); - live =0; - if(d){ - live = d->getInt64Value(DataPackCommonKey::DPCK_TIMESTAMP); - return 0; - } - return -1; -} -//--------------------------------------------------------------------------------------------------- -void DeviceController::setupTracking() { - boost::mutex::scoped_lock lock(trackMutext); - - //init live buffer - initializeAttributeIndexMap(); - - //initialize timestamp buffer - SingleBufferCircularBuffer<int64_t> *newBuffer = new SingleBufferCircularBuffer<int64_t>(10); - int64AttributeLiveBuffer.insert(make_pair(DataPackCommonKey::DPCK_TIMESTAMP, newBuffer)); -} - -//--------------------------------------------------------------------------------------------------- -void DeviceController::stopTracking() { - boost::mutex::scoped_lock lock(trackMutext); - deinitializeAttributeIndexMap(); -} - -//--------------------------------------------------------------------------------------------------- -void DeviceController::fetchCurrentDeviceValue() { - boost::mutex::scoped_lock lock(trackMutext); - - //! fetch the output odmain - fetchCurrentDatatasetFromDomain(DatasetDomainOutput); - - if(trackingAttribute.size() == 0) return; - CDataWrapper *tmpPtr = current_dataset[DatasetDomainOutput].get(); - - //add timestamp value - int64_t got_ts = tmpPtr->getInt64Value(DataPackCommonKey::DPCK_TIMESTAMP); - if(int64AttributeLiveBuffer[DataPackCommonKey::DPCK_TIMESTAMP]->getLastValue() == got_ts) return; - - int64AttributeLiveBuffer[DataPackCommonKey::DPCK_TIMESTAMP]->addValue(got_ts); - - //update buffer for tracked attribute - for (std::vector<string>::iterator iter = trackingAttribute.begin(); - iter != trackingAttribute.end(); - iter++) { - const char *key = (*iter).c_str(); - if(!tmpPtr->hasKey(key)) continue; - - switch (attributeValueMap[*iter].valueType) { - - case DataType::TYPE_INT32: - int32AttributeLiveBuffer[*iter]->addValue(tmpPtr->getInt32Value(key)); - break; - - case DataType::TYPE_INT64: - int64AttributeLiveBuffer[*iter]->addValue(tmpPtr->getInt64Value(key)); - break; - - case DataType::TYPE_DOUBLE: - doubleAttributeLiveBuffer[*iter]->addValue(tmpPtr->getDoubleValue(key)); - break; - - case DataType::TYPE_BYTEARRAY: - uint32_t ptrLen = 0; - const char * tmpPtrAttribute = tmpPtr->getBinaryValue(key, ptrLen); - pointerAttributeLiveBuffer[*iter]->updateData(tmpPtrAttribute, ptrLen); - break; - } - } -} - -CDataWrapper *DeviceController::getCurrentData(){ - return current_dataset[DatasetDomainOutput].get(); -} - -//! get profile info -cu_prof_t DeviceController::getProfileInfo(){ - chaos::common::data::CDataWrapper *prof= fetchCurrentDatatasetFromDomain(DatasetDomainHealth); - cu_prof_t p; - bzero(&p,sizeof(cu_prof_t)); - if(prof){ - p.push_rate=prof->getDoubleValue(ControlUnitHealtDefinitionValue::CU_HEALT_OUTPUT_DATASET_PUSH_RATE); - p.sys_time =prof->getDoubleValue(NodeHealtDefinitionKey::NODE_HEALT_SYSTEM_TIME); - p.usr_time = prof->getDoubleValue(NodeHealtDefinitionKey::NODE_HEALT_USER_TIME); - p.upt_time = prof->getInt64Value(NodeHealtDefinitionKey::NODE_HEALT_PROCESS_UPTIME); - p.metric_time = prof->getInt64Value(NodeHealtDefinitionKey::NODE_HEALT_TIMESTAMP_LAST_METRIC); - } - return p; -} - -//! get datapack between time itervall -void DeviceController::executeTimeIntervallQuery(DatasetDomain domain, - uint64_t start_ts, - uint64_t end_ts, - QueryCursor **query_cursor, - uint32_t page) { - *query_cursor = ioLiveDataDriver->performQuery(channel_keys[domain], - start_ts, - end_ts, - page); -} - -//! release a query -void DeviceController::releaseQuery(QueryCursor *query_cursor) { - ioLiveDataDriver->releaseQuery(query_cursor); -} - -int DeviceController::loadDatasetTypeFromSnapshotTag(const std::string& snapshot_tag, - DatasetDomain dataset_type, - chaos_data::CDWShrdPtr& cdatawrapper_handler) { - return ioLiveDataDriver->loadDatasetTypeFromSnapshotTag(snapshot_tag, - device_id, - dataset_type, - cdatawrapper_handler); -} - -int DeviceController::createNewSnapshot(const std::string& snapshot_tag, - const std::vector<std::string>& other_snapped_device) { - CHAOS_ASSERT(ioLiveDataDriver) - std::vector<std::string> device_id_in_snap = other_snapped_device; - device_id_in_snap.push_back(device_id); - return mdsChannel->createNewSnapshot(snapshot_tag, - device_id_in_snap); -} - -int DeviceController::deleteSnapshot(const std::string& snapshot_tag) { - CHAOS_ASSERT(ioLiveDataDriver) - return mdsChannel->deleteSnapshot(snapshot_tag); -} - -int DeviceController::getSnapshotList(ChaosStringVector& snapshot_list) { - CHAOS_ASSERT(mdsChannel) - return mdsChannel->searchSnapshotForNode(device_id, - snapshot_list, - millisecToWait); -} - -int DeviceController::searchNode(const std::string& unique_id_filter, - unsigned int node_type_filter, - bool alive_only, - unsigned int last_node_sequence_id, - unsigned int page_length, - ChaosStringVector& node_found) { - - return mdsChannel->searchNode(unique_id_filter, - node_type_filter, - alive_only, - last_node_sequence_id, - page_length, - node_found, - millisecToWait); -} - diff --git a/chaos/ui_toolkit/HighLevelApi/DeviceController.h b/chaos/ui_toolkit/HighLevelApi/DeviceController.h deleted file mode 100644 index 01e42c40cba409fa716c10b712ad080e828652a2..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/HighLevelApi/DeviceController.h +++ /dev/null @@ -1,470 +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_DeviceLiveDataFetcher_h -#define CHAOSFramework_DeviceLiveDataFetcher_h - -#include <chaos/common/chaos_types.h> -#include <chaos/common/data/DatasetDB.h> -#include <chaos/common/io/IODataDriver.h> -#include <chaos/common/exception/exception.h> -#include <chaos/common/message/MDSMessageChannel.h> -#include <chaos/common/network/CNodeNetworkAddress.h> -#include <chaos/common/message/DeviceMessageChannel.h> -#include <chaos/common/utility/SingleBufferCircularBuffer.h> - -#include <boost/thread/mutex.hpp> -#include <boost/shared_ptr.hpp> - -#include <map> - -namespace chaos { - namespace ui { - - //! identify the domain qhere fetch the data - typedef enum DatasetDomain { - DatasetDomainOutput = 0, - DatasetDomainInput, - DatasetDomainCustom, - DatasetDomainSystem, - DatasetDomainDevAlarm, - DatasetDomainCUAlarm, - DatasetDomainHealth, - } DatasetDomain; - - //! Controller for a single device instance - /*! - This represent a global controller for a single device, identified by DEVICE_ID. The contorlle rpermit to - contorl the initialization and operation phase for a device. Allow to send value for input dataset and read the last - freshenest value form the live data - */ - class DeviceController { - friend class HLDataApi; - //!time to waith for the answer to an request; - uint32_t millisecToWait; - //! represent the device id controlled by this instance - std::string device_id; - - std::vector<std::string> channel_keys; - - //!cached cu type - std::string cu_type; - - //! Metadata Server channel for get device information - chaos::common::message::MDSMessageChannel *mdsChannel; - //! Device MEssage channel to control via chaos rpc the device - chaos::common::message::DeviceMessageChannel *deviceChannel; - //! The io driver for accessing live data of the device - chaos::common::io::IODataDriver *ioLiveDataDriver; - //!Dataset database - chaos::common::data::DatasetDB datasetDB; - //!point to the freashest live value for this device dataset - //ChaosUniquePtr<chaos::common::data::CDataWrapper> lastDeviceDefinition; - - //!point to the freashest live value for this device dataset - std::vector< ChaosSharedPtr<chaos::common::data::CDataWrapper> >current_dataset; - - - //mutext for multi threading track operation - boost::mutex trackMutext; - - //!store the type of the attribute for fast retrieve - std::map<std::string, common::data::RangeValueInfo> attributeValueMap; - std::vector<std::string> trackingAttribute; - - //!map for live data circular buffer - std::map<std::string, common::utility::SingleBufferCircularBuffer<int32_t> *> int32AttributeLiveBuffer; - std::map<std::string, common::utility::SingleBufferCircularBuffer<int64_t> *> int64AttributeLiveBuffer; - std::map<std::string, common::utility::SingleBufferCircularBuffer<double_t> *> doubleAttributeLiveBuffer; - std::map<std::string, common::utility::PointerBuffer*> pointerAttributeLiveBuffer; - - //! Defautl Constructor - /*! - The visibility of the constructor is private becase it's is isntantiable only via HLDataApi singleton - */ - DeviceController(string& _deviceID); - - - //! update inromation for talking with device - /*! - Perform oall the orpeation to find the rigth chaos address of the device - */ - void updateChannel() throw(CException); - - /*! - Initialize the map for the devices - \param initiDevicedescription the reference to CDataWrapper that contain device initialization information - */ - void initializeAttributeIndexMap(); - - //!DeInitialize the map for the devices - /*! - Dispose all memory used for live data buffer - */ - void deinitializeAttributeIndexMap(); - - //! allocata new circular buffer for attribute and type - /* - - */ - void allocateNewLiveBufferForAttributeAndType(std::string& attributeName, DataType::DataSetAttributeIOAttribute type, DataType::DataType attrbiuteType); - protected: - //! the fetcher thread method - void executeOnThread(const std::string&) throw(CException); - public: - - //!Public destructor - /*! - All can destruct an isntance of the device controller - */ - ~DeviceController(); - - /** - * return the number of output channels - * @return return the nyumber of predefined output channels - */ - int getChannelsNum(); - - //!Return the deviceID of the device - /*! - Return the deviceID that identify the device managed by this controller - \param dID the string that will be filled with the device id - */ - void getDeviceId(std::string& dId); - - //!Set the request wait time - /*! - Set the controller globally wait time, used when a request is forwarded to an device. after that time - the method return with some information. - \param newMillisecToWait the time that the answer is waited - */ - void setRequestTimeWaith(uint32_t newMillisecToWait); - - //!Return the controller globally wait time - /*! - Return the controller globally wait time - \return the wait time - */ - uint32_t getRequestTimeWaith(); - - //! update the scudiling of device run method - /*! - Set the control unit run method scheduling delay - */ - int setScheduleDelay(uint64_t microsecondsDelay); - /*! - Get attribute name filtered by direction type - */ - void getDeviceDatasetAttributesName(vector<std::string>& attributesName); - - /*! - Get time stamp of last packet - * @param [out] live output timestamp, set 0 on error - * @return 0 on success, negative otherwise - */ - int getTimeStamp(uint64_t& live); - /*! - Get description for attribute name - */ - void getAttributeDescription(const std::string& attributesName, - std::string& attributeDescription); - /*! - Get all attribute name - */ - void getDeviceDatasetAttributesName(std::vector<std::string>& attributesName, - DataType::DataSetAttributeIOAttribute directionType); - /*! - Get range valu einfo for attrbiute name - */ - void getDeviceAttributeRangeValueInfo(const std::string& attributesName, - chaos::common::data::RangeValueInfo& rangeInfo); - /*! - Get the direction of the attribute - */ - int getDeviceAttributeDirection(const std::string& attributesName, - DataType::DataSetAttributeIOAttribute& directionType); - /*! - Get the direction of the attribute - */ - int getDeviceAttributeType(const std::string& attributesName, - DataType::DataType& type); - - /** - * - * @return a vector with the information of the dataset - */ - std::vector<chaos::common::data::RangeValueInfo> getDeviceValuesInfo(); - //! - int getAttributeStrValue(const std::string attributesName, - std::string& attribute_value); - - //! Get the type of the control unit - /*! - Get the type of the contro unit - \control_unit_type string that will be filled with the type of the control unit - */ - int getType(std::string& control_unit_type); - - //!Device initialization - /*! - Perform the device initialization phase - */ - int initDevice(); - - //!Start the device chaos driver acquisition data scheduler - /*! - Perform the device start pahse. Thsi phase represent the run methdo called at certain delay in athread - */ - int startDevice(); - - //!Stop(pause) the device driver acquisition data scheduler - /*! - Perform the device initialization phase - */ - int stopDevice(); - - //!Device deinitialization phase - /*! - Perform, if it's not be done the stop operation and afther the hardware deinitialization - */ - int deinitDevice(); - - /** - * recover the device from an error (recoverable) - * @return 0 on success - */ - int recoverDeviceFromError(); - //! restore the device to a saved tag - int restoreDeviceToTag(const std::string& restore_tag); - int setAttributeValue(std::string& attributeName, int32_t attributeValue); - int setAttributeValue(const char *attributeName, int32_t attributeValue); - - int setAttributeValue(std::string& attributeName, double attributeValue); - int setAttributeValue(const char *attributeName, double attributeValue); - - int setAttributeValue(std::string& attributeName, std::string& attributeValue); - int setAttributeValue(std::string& attributeName, const char* attributeValue); - // buffer - int setAttributeValue(std::string& attributeName, const char* attributeValue, uint32_t size); - - int setAttributeToValue(const char *attributeName, const char *attributeValue, bool noWait); - int setAttributeToValue(const char *attributeName, void *attributeValue, bool noWait, int32_t bufferValuedDim); - int setAttributeToValue(const char *attributeName, DataType::DataType attributeType, void *attributeValue, bool noWait = false, int32_t bufferValuedDim = 0); - - //! Submit a new slow command - /*! - \ingroup API_Slow_Control - The submition of slow command is made collection all the information that permit to submit it - \param commandAlias represent the alias of the command the the control unit expost from RPC subsystem - \param submissionRule determinate the rule with which the command is submitted. This can determinate the - the execution of the current execution command in the control unit, according with his running state - \param priority represent the priority beetwen the submitted command and all command in the queue that are - waiting to be submitted in the scheduler - \param command_id is the assigned command id to the submitted one - \param execution_channel (optional) choose the excution channel where execute the command [1 based] - \param scheduler_steps_delay (optional) rapresent the intervall beetween the step of the scehduler [...acquisition -> correlation -> scheduleInterval...] - \param submission_checker_steps_delay (optional) is the delay between two steps of the submission checker - \param slow_command_data (optional) is the abstraction of the command data that is passed to the set handler befor the scheduler loop of the new command - take palce. The memory of that parameter is not free - * @return 0 on success - */ - int submitSlowControlCommand(string commandAlias, - chaos::common::batch_command::SubmissionRuleType::SubmissionRule submissionRule, - uint32_t priority, - uint64_t& command_id, - uint32_t execution_channel = 0, - uint64_t scheduler_steps_delay = 0, - uint32_t submission_checker_steps_delay = 0, - chaos::common::data::CDataWrapper *slow_command_data = NULL); - - //! Submit a new slow command - /*! - \ingroup API_Slow_Control - The submition of slow command is made collection all the information that permit to submit it - \param commandAlias represent the alias of the command the the control unit expost from RPC subsystem - \param submissionRule determinate the rule with which the command is submitted. This can determinate the - \param command_id is the assigned command id to the submitted one - the execution of the current execution command in the control unit, according with his running state - \param execution_channel (optional) choose the excution channel where execute the command [1 based] - \param scheduler_steps_delay (optional) rapresent the intervall beetween the step of the scehduler [...acquisition -> correlation -> scheduleInterval...] - \param submission_checker_steps_delay (optional) is the delay between two steps of the submission checker - \param slow_command_data (optional) is the abstraction of the command data that is passed to the set handler befor the scheduler loop of the new command - take palce. The memory of that parameter is not free - * @return 0 on success - */ - int submitSlowControlCommand(string commandAlias, - chaos::common::batch_command::SubmissionRuleType::SubmissionRule submissionRule, - uint64_t& command_id, - uint32_t execution_channel = 0, - uint64_t scheduler_steps_delay = 0, - uint32_t submission_checker_steps_delay = 0, - chaos::common::data::CDataWrapper *slow_command_data = NULL); - - //! Set the current slow command features - /*! - \ingroup API_Slow_Control - Permit to set the features of the current running command. During execution the chaos::cu::control_manager::slow_command::features::Features::featuresFlag - field is checked to see what feature need to be set. The enumeration chaos::cu::control_manager::slow_command::features::FeaturesFlagTypes::FeatureFlag need to - bee used to set the featuresFlag property. - \param features valorization of the features - \param lock_features set the lock on all features - \param execution_channel set the execution channel where set the features - */ - int setSlowCommandFeatures(chaos::common::batch_command::features::Features& features, bool lock_features, uint32_t execution_channel = 0); - - //! Set the lock on slow command features - /*! - \ingroup API_Slow_Control - Lock the features modification by the slow command api on the current - \param lock_features set the lock on all features - */ - int setSlowCommandLockOnFeatures(bool lock_features); - - //! Get the statistick for a command - /*! - \ingroup API_Slow_Control - Permit to obtain the state of a command by it's unique id using the filed command_id of the command_state parameter - \param command_state will be filled with the state of the command on success - \return result of the execution - */ - int getCommandState(chaos::common::batch_command::CommandState& command_state); - - //! Kill the current executing command - /*! - \ingroup API_Slow_Control - Kill the current executing command in without respetting the running state. - */ - int killCurrentCommand(); - - //! Flush command states history - /*! - \ingroup API_Slow_Control - Flush all the slow control command state history for non active command. - */ - int flushCommandStateHistory(); - - //!Get device state - /*! - Return the current device state - * @param [out] deviceState returned state, if error UNDEFINED state set - * @return the timestamp of the hearthbeat, 0 if error - */ - uint64_t getState(CUStateKey::ControlUnitState& deviceState); - - /*! - Setup the structure to accelerate the tracking of the live data - */ - void setupTracking(); - - //!Stop the live data tracking - /*! - Interrupt the live data tracking operation - */ - void stopTracking(); - - //add attrbiute to track - /*! - Add attribute to tracking - */ - void addAttributeToTrack(std::string& attributeName); - - //get the CDatawrapper for the live value - /*! - the returned object is not own by requester but only by DeviceController isntance - \deprecated use new api getCurrentDatasetForDomain - */ - __attribute__((__deprecated__)) - chaos::common::data::CDataWrapper * getLiveCDataWrapperPtr(); - - //!return the last fetched dataset for the domain - chaos::common::data::CDataWrapper * getCurrentDatasetForDomain(DatasetDomain domain); - - //! fetch from the chaso central cache the dataset associated to the domain - chaos::common::data::CDataWrapper * fetchCurrentDatatasetFromDomain(DatasetDomain domain); - - /*! - Fetch the current live value form live storage - */ - void fetchCurrentDeviceValue(); - - common::utility::UIDataBuffer *getBufferForAttribute(string& attributeName); - common::utility::PointerBuffer *getPtrBufferForAttribute(string& attributeName); - common::utility::UIDataBuffer *getPtrBufferForTimestamp(const int initialDimension = 10); - - chaos::common::data::CDataWrapper *getCurrentData(); - - //! send custom request to device - int sendCustomRequest(const std::string& action, - common::data::CDataWrapper * const param, - common::data::CDataWrapper**const result); - - //! send custom request to device and return a future - ChaosUniquePtr<chaos::common::message::MessageRequestFuture> sendCustomRequestWithFuture(const std::string& action_name, - common::data::CDataWrapper *request_date); - - //! send custom message to device - void sendCustomMessage(const std::string& action, - common::data::CDataWrapper * const param); - - //! Send a request for receive RPC information - int checkRPCInformation(chaos::common::data::CDataWrapper **result_information, - uint32_t timeout = 1000); - - //! Send a request for an echo test - int echoTest(chaos::common::data::CDataWrapper * const echo_data, - chaos::common::data::CDataWrapper **echo_data_result, - uint32_t timeout = 1000); - - //! get datapack between time itervall - void executeTimeIntervallQuery(DatasetDomain domain, - uint64_t start_ts, - uint64_t end_ts, - chaos::common::io::QueryCursor **query_cursor,uint32_t page_len=DEFAULT_PAGE_LEN); - - //! release a query - void releaseQuery(chaos::common::io::QueryCursor *query_cursor); - - //! get profile info - cu_prof_t getProfileInfo(); - - //! restore from a tag a dataset associated to a key - int loadDatasetTypeFromSnapshotTag(const std::string& snapshot_tag, - DatasetDomain dataset_type, - chaos_data::CDWShrdPtr& cdatawrapper_handler); - //! restore from a tag a dataset associated to a key - int createNewSnapshot(const std::string& snapshot_tag, - const std::vector<std::string>& other_snapped_device); - //!delete the snapshot - int deleteSnapshot(const std::string& snapshot_tag); - - //!return the snapshot list for device controlled by this isntance - int getSnapshotList(ChaosStringVector& snapshot_list); - - int searchNode(const std::string& unique_id_filter, - unsigned int node_type_filter, - bool alive_only, - unsigned int last_node_sequence_id, - unsigned int page_length, - ChaosStringVector& node_found); - }; - } -} -#endif diff --git a/chaos/ui_toolkit/HighLevelApi/HLDataApi.cpp b/chaos/ui_toolkit/HighLevelApi/HLDataApi.cpp deleted file mode 100644 index 0a645c3bc17d55374cfb405c4b49ee25a743ec67..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/HighLevelApi/HLDataApi.cpp +++ /dev/null @@ -1,97 +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 "HLDataApi.h" -using namespace std; -using namespace chaos; -using namespace chaos::ui; -using namespace chaos::common::message; - -/* - * Constructor - */ -HLDataApi::HLDataApi() { - -} - -/* - * Distructor - */ -HLDataApi::~HLDataApi() { -} - -/* - LL Rpc Api static initialization it should be called once for application - */ -void HLDataApi::init() throw (CException) { - -} -/* - Deinitialization of LL rpc api - */ -void HLDataApi::deinit() throw (CException) { - LDBG_<<"["<<__PRETTY_FUNCTION__<<"] deleting device controllers"; - - for (map<string, DeviceController*>::iterator controllerIterator = controllerMap.begin(); - controllerIterator != controllerMap.end(); - controllerIterator++) { - LDBG_<<"["<<__PRETTY_FUNCTION__<<"] deleting device controller:"<<controllerIterator->first<<" ptr:"<<(uintptr_t)std::hex<<controllerIterator->second; - - DeviceController *ctrl = controllerIterator->second; - //dispose it - delete(ctrl); - } - -} - - -DeviceController *HLDataApi::getControllerForDeviceID(string deviceID, - uint32_t controller_timeout) throw (CException) { - - DeviceController *deviceController = new DeviceController(deviceID); - deviceController->setRequestTimeWaith(controller_timeout); - deviceController->updateChannel(); - LDBG_<<"["<<__PRETTY_FUNCTION__<<"] inserting new device controller:"<<deviceID<<" ptr:"<<(uintptr_t)std::hex<<deviceController; - controllerMap.insert(make_pair(deviceID, - deviceController)); - - return deviceController; -} - -void HLDataApi::disposeDeviceControllerPtr(DeviceController *ctrl) throw (CException) { - if(!ctrl) return; - string deviceID; - ctrl->getDeviceId(deviceID); - - //remove device from the map of all active device - controllerMap.erase(deviceID); - - //dispose the devie - delete ctrl; - ctrl = NULL; -} - -void HLDataApi::createNewSnapshot(const std::string& snapshot_name) { - -} - -void HLDataApi::deleteSnapshot(const std::string& snapshot_name) { - -} diff --git a/chaos/ui_toolkit/HighLevelApi/HLDataApi.h b/chaos/ui_toolkit/HighLevelApi/HLDataApi.h deleted file mode 100644 index 5638c0abc278eaea062899f4eb56d96f1809099e..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/HighLevelApi/HLDataApi.h +++ /dev/null @@ -1,69 +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_HLDataApi_h -#define ChaosFramework_HLDataApi_h -#include <map> -#include <string> -#include <chaos/ui_toolkit/HighLevelApi/DeviceController.h> -#include <chaos/common/message/PerformanceNodeChannel.h> -#include <chaos/common/utility/Singleton.h> - -namespace chaos { - namespace ui { - /* - High level api for maning device datasert - */ - class HLDataApi: - public common::utility::Singleton<HLDataApi> { - friend class ChaosUIToolkit; - friend class common::utility::Singleton<HLDataApi>; - - std::map<std::string, DeviceController* > controllerMap; - /* - LL Rpc Api static initialization it should be called once for application - */ - void init() throw (CException); - /* - Deinitialization of LL rpc api - */ - void deinit() throw (CException); - - /* - * Constructor - */ - HLDataApi(); - - /* - * Distructor - */ - ~HLDataApi(); - - public: - DeviceController *getControllerForDeviceID(string deviceID, uint32_t controller_timeout=1000) throw (CException); - void disposeDeviceControllerPtr(DeviceController *) throw (CException); - - void createNewSnapshot(const std::string& snapshot_name); - - void deleteSnapshot(const std::string& snapshot_name); - }; - } -} -#endif diff --git a/chaos/ui_toolkit/HighLevelApi/HLInfrastructureApi.cpp b/chaos/ui_toolkit/HighLevelApi/HLInfrastructureApi.cpp deleted file mode 100644 index 5ca10dca6d27ae5b27548f64edc65c31e4bf4fcc..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/HighLevelApi/HLInfrastructureApi.cpp +++ /dev/null @@ -1,38 +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 "HLInfrastructureApi.h" - - -using namespace chaos::ui; - -/* - * Constructor - */ -HLInfrastructureApi::HLInfrastructureApi() { - -} - -/* - * Distructor - */ -HLInfrastructureApi::~HLInfrastructureApi() { - -} diff --git a/chaos/ui_toolkit/HighLevelApi/HLInfrastructureApi.h b/chaos/ui_toolkit/HighLevelApi/HLInfrastructureApi.h deleted file mode 100644 index cf8452aa7349966a4be78b00a5f5de9f1c358eda..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/HighLevelApi/HLInfrastructureApi.h +++ /dev/null @@ -1,43 +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_HLInfrastructureApi_h -#define ChaosFramework_HLInfrastructureApi_h - -namespace chaos{ - namespace ui{ - class HLInfrastructureApi { - friend class ChaosUIToolkit; - - /* - * Constructor - */ - HLInfrastructureApi(); - - /* - * Distructor - */ - ~HLInfrastructureApi(); - - public: - }; - } -} -#endif diff --git a/chaos/ui_toolkit/Labview/LV12/CUinfo.ctl b/chaos/ui_toolkit/Labview/LV12/CUinfo.ctl deleted file mode 100644 index 61ac6a3fed0d7b43355b4bb7db31e79ed32cabfc..0000000000000000000000000000000000000000 Binary files a/chaos/ui_toolkit/Labview/LV12/CUinfo.ctl and /dev/null differ diff --git a/chaos/ui_toolkit/Labview/LV12/ChaosPowerSupply.vi b/chaos/ui_toolkit/Labview/LV12/ChaosPowerSupply.vi deleted file mode 100644 index 5917c6ac2e5d61b89e71202c251f8e6cbc706e70..0000000000000000000000000000000000000000 Binary files a/chaos/ui_toolkit/Labview/LV12/ChaosPowerSupply.vi and /dev/null differ diff --git a/chaos/ui_toolkit/Labview/LV12/InitialiseChaosCUs.vi b/chaos/ui_toolkit/Labview/LV12/InitialiseChaosCUs.vi deleted file mode 100644 index fb8e3e09b3272219f43496cbf0ea805cb0c68088..0000000000000000000000000000000000000000 Binary files a/chaos/ui_toolkit/Labview/LV12/InitialiseChaosCUs.vi and /dev/null differ diff --git a/chaos/ui_toolkit/LowLevelApi/LLDataApi.h b/chaos/ui_toolkit/LowLevelApi/LLDataApi.h deleted file mode 100644 index a7f795ab4e3943f8672a746bc6cf317c4ddc9fdb..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/LowLevelApi/LLDataApi.h +++ /dev/null @@ -1,47 +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_LLDataApi_h -#define ChaosFramework_LLDataApi_h - -#include <string> -#include <chaos/common/utility/Singleton.h> -#include <chaos/common/data/CDataWrapper.h> -#include <chaos/common/io/IODataDriver.h> -using namespace chaos::common::io; -using namespace std; -namespace chaos { - namespace ui { - /* - Low level api for data access api - */ - class LLDataApi: - public common::utility::Singleton<LLDataApi> { - friend class ChaosUIToolkit; - friend class Singleton<LLDataApi>; - LLDataApi(); - ~LLDataApi(); - - public: - - }; - } -} -#endif diff --git a/chaos/ui_toolkit/LowLevelApi/LLRpcApi.cpp b/chaos/ui_toolkit/LowLevelApi/LLRpcApi.cpp deleted file mode 100644 index cd345a6906d81e6c7ae8064299d714c329f41e04..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/LowLevelApi/LLRpcApi.cpp +++ /dev/null @@ -1,172 +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 "LLRpcApi.h" -#include <boost/format.hpp> -#include <chaos/common/global.h> -#include <chaos/common/data/CDataWrapper.h> - -using namespace boost; - -using namespace chaos; -using namespace chaos::ui; -using namespace chaos::common::io; -using namespace chaos::common::event; -using namespace chaos::common::message; -using namespace chaos::common::utility; -using namespace chaos::common::direct_io; -#define LLRA_LAPP_ LAPP_ << "[LLRpcApi] - " - -uint32_t DIOConn::garbage_counter = 0; - -/* - */ -LLRpcApi::LLRpcApi() { - direct_io_client = NULL; -} - -/* - */ -LLRpcApi::~LLRpcApi() { -} -void LLRpcApi::init(chaos::common::network::NetworkBroker *nb){ - LLRA_LAPP_ << "Using a specified NetworkBroker:"<<nb; - - direct_io_client = NetworkBroker::getInstance()->getSharedDirectIOClientInstance(); -} - -/* - LL Rpc Api static initialization it should be called once for application - */ -void LLRpcApi::init() throw (CException) { - - //get new direct io client - direct_io_client = NetworkBroker::getInstance()->getSharedDirectIOClientInstance(); -} - -/* - Deinitialization of LL rpc api - */ -void LLRpcApi::deinit() throw (CException) { - LLRA_LAPP_ << "Deinit LLRpcApi"; -} - -/* - * Return an instance for the configured data live driver - */ -IODataDriver *LLRpcApi::getDataProxyChannelNewInstance() throw(CException) { - IODataDriver *result = NULL; - std::string impl_name = boost::str( boost::format("%1%IODriver") % GlobalConfiguration::getInstance()->getOption<std::string>(InitOption::OPT_DATA_IO_IMPL)); - - result = ObjectFactoryRegister<IODataDriver>::getInstance()->getNewInstanceByName(impl_name); - if(result) { - if(impl_name.compare("IODirectIODriver") == 0) { - //set the information - IODirectIODriverInitParam init_param; - std::memset(&init_param, 0, sizeof(IODirectIODriverInitParam)); - init_param.client_instance = NULL; - init_param.endpoint_instance = NULL; - ((IODirectIODriver*)result)->setDirectIOParam(init_param); - } - } - return result; -} - -/* - */ -MDSMessageChannel *LLRpcApi::getNewMetadataServerChannel() { - return NetworkBroker::getInstance()->getMetadataserverMessageChannel(); -} - -/*! - Return a new device channel - */ -DeviceMessageChannel *LLRpcApi::getNewDeviceMessageChannel(CDeviceNetworkAddress *deviceNetworkAddress, - bool self_managed) { - return NetworkBroker::getInstance()->getDeviceMessageChannelFromAddress(deviceNetworkAddress, - self_managed); -} - -/*! - Return a new device channel - */ -chaos::common::message::PerformanceNodeChannel *LLRpcApi::getNewPerformanceChannel(CNetworkAddress *note_network_address) { - return NetworkBroker::getInstance()->getPerformanceChannelFromAddress(note_network_address); -} - -void LLRpcApi::deleteMessageChannel(MessageChannel *channelToDispose) { - NetworkBroker::getInstance()->disposeMessageChannel(channelToDispose); -} -/*! - Delete a previously instantiatedchannel - */ -void LLRpcApi::deleteMessageChannel(NodeMessageChannel *channelToDispose) { - NetworkBroker::getInstance()->disposeMessageChannel(channelToDispose); -} - -void LLRpcApi::deleteMessageChannel(chaos::common::message::MDSMessageChannel *channelToDispose) { - NetworkBroker::getInstance()->disposeMessageChannel(channelToDispose); -} - -chaos::common::event::channel::AlertEventChannel *LLRpcApi::getNewAlertEventChannel() throw (CException) { - return NetworkBroker::getInstance()->getNewAlertEventChannel(); -} - -chaos::common::event::channel::InstrumentEventChannel *LLRpcApi::getNewInstrumentEventChannel() throw (CException) { - return NetworkBroker::getInstance()->getNewInstrumentEventChannel(); -} - -void LLRpcApi::disposeEventChannel(chaos::common::event::channel::EventChannel *eventChannel) throw (CException) { - NetworkBroker::getInstance()->disposeEventChannel(eventChannel); -} - -SystemApiChannel *LLRpcApi::getSystemApiClientChannel(const std::string& direct_io_address) { - DIOConn *conn = NULL; - boost::unique_lock<boost::mutex> l(mutex_map_dio_addr_conn); - if(map_dio_addr_conn.count(direct_io_address)) { - conn = map_dio_addr_conn[direct_io_address]; - } else { - conn = new DIOConn(direct_io_client->getNewConnection(direct_io_address)); - } - conn->garbage_counter++; - return new SystemApiChannel(conn, (chaos::common::direct_io::channel::DirectIOSystemAPIClientChannel*)conn->connection->getNewChannelInstance("DirectIOSystemAPIClientChannel")); -} - -void LLRpcApi::releaseSystemApyChannel(SystemApiChannel *system_api_channel) { - boost::unique_lock<boost::mutex> l(mutex_map_dio_addr_conn); - if(!system_api_channel) return; - - DIOConn *conn = system_api_channel->connection; - if(conn) { - conn->garbage_counter--; - if(system_api_channel->system_api_channel) { - conn->connection->releaseChannelInstance(system_api_channel->system_api_channel); - } - - if(!conn->garbage_counter) { - //need to be deleted the connection from the map - map_dio_addr_conn.erase(conn->connection->getURL()); - - //and form the root client - direct_io_client->releaseConnection(conn->connection); - } - } - -} diff --git a/chaos/ui_toolkit/LowLevelApi/LLRpcApi.h b/chaos/ui_toolkit/LowLevelApi/LLRpcApi.h deleted file mode 100644 index 20af19f7b0daab38cafa3056863a6ebb7753bc09..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/LowLevelApi/LLRpcApi.h +++ /dev/null @@ -1,152 +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_LLRpcApi_h -#define ChaosFramework_LLRpcApi_h - -#include <map> -#include <boost/shared_ptr.hpp> - -#include <chaos/common/utility/Singleton.h> -#include <chaos/common/exception/exception.h> -#include <chaos/common/network/NetworkBroker.h> -#include <chaos/common/message/MDSMessageChannel.h> -#include <chaos/common/message/DeviceMessageChannel.h> - -#include <chaos/common/event/channel/AlertEventChannel.h> -#include <chaos/common/event/channel/InstrumentEventChannel.h> -#include <chaos/common/io/IODirectIODriver.h> -#include <chaos/common/direct_io/DirectIOClient.h> -#include <chaos/common/direct_io/DirectIOClientConnection.h> -#include <chaos/common/direct_io/channel/DirectIOSystemAPIClientChannel.h> - -#include <boost/thread.hpp> -#include <boost/atomic.hpp> - -namespace chaos { - namespace ui{ - - class LLRpcApi; - - struct DIOConn { - friend class LLRpcApi; - private: - static uint32_t garbage_counter; - chaos::common::direct_io::DirectIOClientConnection *connection; - DIOConn(chaos::common::direct_io::DirectIOClientConnection *_connection):connection(_connection){}; - ~DIOConn(){}; - }; - - struct SystemApiChannel { - friend class LLRpcApi; - chaos::common::direct_io::channel::DirectIOSystemAPIClientChannel *system_api_channel; - private: - DIOConn *connection; - SystemApiChannel(DIOConn *_connection, - chaos::common::direct_io::channel::DirectIOSystemAPIClientChannel *_system_api_channel): - connection(_connection), - system_api_channel(_system_api_channel){}; - ~SystemApiChannel(){}; - }; - - /* - LLRpcApi Class api for rpc system - */ - class LLRpcApi: - public common::utility::Singleton<LLRpcApi> { - friend class ChaosUIToolkit; - friend class common::utility::Singleton<LLRpcApi>; - //!chaos network router - chaos::common::network::NetworkBroker *network_broker; - - //! root direct io client - chaos::common::direct_io::DirectIOClient *direct_io_client; - - //! hasmap for direct io address and connection struct - boost::mutex mutex_map_dio_addr_conn; - std::map<std::string, DIOConn*> map_dio_addr_conn; - - - - /* - */ - LLRpcApi(); - - /* - */ - ~LLRpcApi(); - - public: - - /* - LL Rpc Api static initialization it should be called once for application - */ - void init() throw (CException); - - /* - * use a specified network broker - */ - void init(chaos::common::network::NetworkBroker *network_broker); - /* - Deinitialization of LL rpc api - */ - void deinit() throw (CException); - chaos::common::io::IODataDriver *getDataProxyChannelNewInstance() throw(CException); - - /*! - Return a new channel for talk with metadata server - */ - chaos::common::message::MDSMessageChannel *getNewMetadataServerChannel(); - - /*! - Return a new device channel - */ - chaos::common::message::DeviceMessageChannel *getNewDeviceMessageChannel(chaos::common::network::CDeviceNetworkAddress *device_network_address, - bool self_managed = false); - - chaos::common::message::PerformanceNodeChannel *getNewPerformanceChannel(chaos::common::network::CNetworkAddress *note_network_address); - - /*! - Delete a previously instantiatedchannel - */ - void deleteMessageChannel(chaos::common::message::MessageChannel*); - - /*! - Delete a previously instantiatedchannel - */ - void deleteMessageChannel(chaos::common::message::NodeMessageChannel*); - - /*! - Delete a previously instantiatedchannel - */ - void deleteMessageChannel(chaos::common::message::MDSMessageChannel*); - - chaos::common::event::channel::AlertEventChannel *getNewAlertEventChannel() throw (CException); - chaos::common::event::channel::InstrumentEventChannel *getNewInstrumentEventChannel() throw (CException); - void disposeEventChannel(chaos::common::event::channel::EventChannel *) throw (CException); - - SystemApiChannel *getSystemApiClientChannel(const std::string& direct_io_address); - void releaseSystemApyChannel(SystemApiChannel *system_api_channel); - - }; - } -} -#endif diff --git a/chaos/ui_toolkit/caching/LiveDataFetcher.cpp b/chaos/ui_toolkit/caching/LiveDataFetcher.cpp deleted file mode 100644 index acc7d7536682ac042cbeddaad54fcd120b07c6d7..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/caching/LiveDataFetcher.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// -// LiveDataFetcher.cpp -// CHAOSFramework -// -// Created by Claudio Bisegni on 1/5/13. -// Copyright (c) 2013 INFN. All rights reserved. -// - -#include <chaos/common/chaos_constants.h> -#include <chaos/common/io/IODataDriver.h> -#include <chaos/ui_toolkit/caching/LiveDataFetcher.h> - -using namespace chaos; -using namespace chaos::common::io; -using namespace chaos::common::data; -using namespace chaos::ui::chaching; - -LiveDataFetcher::LiveDataFetcher(IODataDriver *_dataDriver):dataDriver(_dataDriver) { - -} - -LiveDataFetcher::~LiveDataFetcher() { - if(dataDriver){ - dataDriver->deinit(); - delete(dataDriver); - } -} - -/* - Update the driver configuration - */ -CDataWrapper* LiveDataFetcher::updateConfiguration(CDataWrapper *configuration) { - if(dataDriver) dataDriver->updateConfiguration(configuration); - return NULL; -} - -// Initialize instance -void LiveDataFetcher::init(void *configuration) throw(chaos::CException) { - if(dataDriver) { - dataDriver->init(NULL); - } - updateConfiguration(static_cast<CDataWrapper*>(configuration)); -} - -// Start the implementation -void LiveDataFetcher::start() throw(chaos::CException) { - -} - -// Deinit the implementation -void LiveDataFetcher::deinit() throw(chaos::CException) { - if(dataDriver) { - dataDriver->deinit(); - } -} - -void LiveDataFetcher::getData(const std::string& key, CDataWrapper& newData, uint64_t& ts) { - currentRawDataPtr.reset(dataDriver->retriveRawData(key)); - - //create key/value chaos object - newData.setSerializedData(currentRawDataPtr.get()); - - //extras the timestamp of the pack - ts = newData.getInt64Value(DataPackCommonKey::DPCK_TIMESTAMP); -} \ No newline at end of file diff --git a/chaos/ui_toolkit/caching/LiveDataFetcher.h b/chaos/ui_toolkit/caching/LiveDataFetcher.h deleted file mode 100644 index cd48618b40a595ac2c255fa0ad67086e3e855d92..0000000000000000000000000000000000000000 --- a/chaos/ui_toolkit/caching/LiveDataFetcher.h +++ /dev/null @@ -1,74 +0,0 @@ -// -// LiveDataFetcher.h -// CHAOSFramework -// -// Created by Claudio Bisegni on 1/5/13. -// Copyright (c) 2013 INFN. All rights reserved. -// - -#ifndef __CHAOSFramework__LiveDataFetcher__ -#define __CHAOSFramework__LiveDataFetcher__ - -#include <chaos/common/data/CDataWrapper.h> -#include <chaos/common/general/Configurable.h> -#include <chaos/common/utility/StartableService.h> -#include <chaos/common/caching_system/caching_thread/tracker_interface/DataFetcherInterface.h> - -namespace chaos_io = chaos::common::io; -namespace chaos_data = chaos::common::data; - -namespace chaos { - namespace common{ - namespace io { - class IODataDriver; - } - } - - namespace ui { - namespace chaching { - - /*! - Class that implemnt the CDatawrapper fetcher from !CHAOS live data. - */ - class LiveDataFetcher : - public chaos::caching_system::DataFetcherInterface<chaos_data::CDataWrapper>, - public chaos::Configurable, - public common::utility::StartableService { - ChaosUniquePtr<char> currentRawDataPtr; - - chaos_io::IODataDriver *dataDriver; - - void getData(const std::string& key, chaos_data::CDataWrapper& newData, uint64_t& ts); - - public: - - /*! - Default Constructor - \param _dataDriver the isntance ofthe driver to use with this fetcer - */ - LiveDataFetcher(chaos_io::IODataDriver *_dataDriver); - - /*! - Defaut Destructor - */ - virtual ~LiveDataFetcher(); - - /* - Update the driver configuration - */ - chaos_data::CDataWrapper* updateConfiguration(chaos_data::CDataWrapper*); - - // Initialize instance - void init(void*) throw(chaos::CException); - - // Start the implementation - void start() throw(chaos::CException); - - // Deinit the implementation - void deinit() throw(chaos::CException); - }; - } - } -} - -#endif /* defined(__CHAOSFramework__LiveDataFetcher__) */ diff --git a/chaos_metadata_service_client/CMakeLists.txt b/chaos_metadata_service_client/CMakeLists.txt index ad34a7209e42e4339ec69d5ff8acf2870efa5410..ee8dee18e43e78d689c9b15ac5a39cd7983c6cdf 100644 --- a/chaos_metadata_service_client/CMakeLists.txt +++ b/chaos_metadata_service_client/CMakeLists.txt @@ -73,13 +73,11 @@ SET(mcl_src ${mcl_src} api_proxy/node/GetNodeDescription.cpp api_proxy/node/CommandTemplateSubmit.cpp api_proxy/node/CommandInstanceSubmit.cpp api_proxy/node/UpdateProperty.cpp - api_proxy/node/GetPropertyDefaultValues.cpp - api_proxy/node/UpdatePropertyDefaultValues.cpp + api_proxy/node/GetPropertyDefaultValues.cpp + api_proxy/node/UpdatePropertyDefaultValues.cpp api_proxy/node/GetCommandAndTemplateDescription.cpp - api_proxy/node/KillCurrentCommand.cpp - api_proxy/node/ClearCommandQueue.cpp - - ) + api_proxy/node/KillCurrentCommand.cpp + api_proxy/node/ClearCommandQueue.cpp) SET(mcl_src ${mcl_src} api_proxy/data_service/NewDS.cpp api_proxy/data_service/UpdateDS.cpp @@ -99,7 +97,8 @@ SET(mcl_src ${mcl_src} api_proxy/control_unit/SetInputDatasetAttributeValue api_proxy/control_unit/InitDeinit.cpp api_proxy/control_unit/StartStop.cpp api_proxy/control_unit/CopyInstance.cpp - api_proxy/control_unit/RecoverError.cpp) + api_proxy/control_unit/RecoverError.cpp + api_proxy/control_unit/SendStorageBurst.cpp) SET(mcl_src ${mcl_src} api_proxy/unit_server/GetDescription.cpp api_proxy/unit_server/NewUS.cpp diff --git a/chaos_metadata_service_client/api_proxy/control_unit/Delete.h b/chaos_metadata_service_client/api_proxy/control_unit/Delete.h index 50fcb585beafb1edc7dfdfe02c5f1a16b69988ac..7e35a89f30d59ab27cc9b052f6f1a4d46c62301d 100644 --- a/chaos_metadata_service_client/api_proxy/control_unit/Delete.h +++ b/chaos_metadata_service_client/api_proxy/control_unit/Delete.h @@ -22,7 +22,6 @@ #ifndef __CHAOSFramework__Delete_h #define __CHAOSFramework__Delete_h - #include <chaos_metadata_service_client/api_proxy/ApiProxy.h> #include <boost/shared_ptr.hpp> @@ -53,5 +52,4 @@ namespace chaos { } } - #endif /* Delete_h */ diff --git a/chaos_metadata_service_client/api_proxy/control_unit/SendStorageBurst.cpp b/chaos_metadata_service_client/api_proxy/control_unit/SendStorageBurst.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8ef6d3839f6ad85136f7f16db6510bc4859af596 --- /dev/null +++ b/chaos_metadata_service_client/api_proxy/control_unit/SendStorageBurst.cpp @@ -0,0 +1,54 @@ +/* + * Copyright 2012, 03/07/2018 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_metadata_service_client/api_proxy/control_unit/SendStorageBurst.h> + +using namespace chaos::common::data; +using namespace chaos::common::data::structured; +using namespace chaos::metadata_service_client::api_proxy; +using namespace chaos::metadata_service_client::api_proxy::control_unit; + + +API_PROXY_CD_DEFINITION(SendStorageBurst, + "control_unit", + "sendStorageBurst") + +ApiProxyResult SendStorageBurst::execute(const std::string& cu_uid, + chaos::common::data::structured::DatasetBurst& dataset_burst) { + ChaosStringSet cu_set; + cu_set.insert(cu_uid); + return execute(cu_set, dataset_burst); +} + +ApiProxyResult SendStorageBurst::execute(const ChaosStringSet& cu_set, + chaos::common::data::structured::DatasetBurst& dataset_burst) { + DatasetBurstSDWrapper db_sdw(CHAOS_DATA_WRAPPER_REFERENCE_AUTO_PTR(DatasetBurst, dataset_burst)); + ChaosUniquePtr<chaos::common::data::CDataWrapper> message(new chaos::common::data::CDataWrapper()); + for(ChaosStringSetIterator it = cu_set.begin(), + end = cu_set.end(); + it != end; + it++) { + message->appendStringToArray(*it); + } + message->finalizeArrayForKey(chaos::NodeDefinitionKey::NODE_UNIQUE_ID); + db_sdw.serialize()->copyAllTo(*message); + return callApi(message.release()); +} diff --git a/chaos_metadata_service_client/api_proxy/control_unit/SendStorageBurst.h b/chaos_metadata_service_client/api_proxy/control_unit/SendStorageBurst.h new file mode 100644 index 0000000000000000000000000000000000000000..86851266fad7c53dd0e7e8b5b7a349309454bd56 --- /dev/null +++ b/chaos_metadata_service_client/api_proxy/control_unit/SendStorageBurst.h @@ -0,0 +1,64 @@ +/* + * Copyright 2012, 03/07/2018 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__SendStorageBurst_h +#define __CHAOSFramework__SendStorageBurst_h + +#include <chaos_metadata_service_client/api_proxy/ApiProxy.h> + +#include <chaos/common/data/structured/Dataset.h> + +namespace chaos { + namespace metadata_service_client { + namespace api_proxy { + namespace control_unit { + + //! Start a stoarge burst on a determinated constor unit + /*! + The stoarge burst a funciton taht permit to momentary enable the istoricization of + consotrlnit output dataset on determinate rule + */ + class SendStorageBurst: + public chaos::metadata_service_client::api_proxy::ApiProxy { + API_PROXY_CLASS(SendStorageBurst) + protected: + //! default constructor + API_PROXY_CD_DECLARATION(SendStorageBurst) + public: + /*! + \param cu_uid the uid of the control unit + \param dataset_burst is the information of burst + */ + ApiProxyResult execute(const std::string& cu_uid, + chaos::common::data::structured::DatasetBurst& dataset_burst); + /*! + \param cu_uid the set of uid of one or more control unit + \param dataset_burst is the information of burst + */ + ApiProxyResult execute(const ChaosStringSet& cu_set, + chaos::common::data::structured::DatasetBurst& dataset_burst); + }; + } + } + } +} + +#endif /* Delete_h */ diff --git a/chaos_metadata_service_client/api_proxy/control_unit/control_unit.h b/chaos_metadata_service_client/api_proxy/control_unit/control_unit.h index ad0dbe9522cbe98e0947cb2a3368b3c2d45d9cac..91ccefbaef562f67f93277b4dc2f112b0bcc4081 100644 --- a/chaos_metadata_service_client/api_proxy/control_unit/control_unit.h +++ b/chaos_metadata_service_client/api_proxy/control_unit/control_unit.h @@ -21,7 +21,6 @@ #ifndef __CHAOSFramework__21F26AF_8477_485A_A08A_39F56D3644AE_control_unit_h #define __CHAOSFramework__21F26AF_8477_485A_A08A_39F56D3644AE_control_unit_h - #include <chaos_metadata_service_client/api_proxy/control_unit/Delete.h> #include <chaos_metadata_service_client/api_proxy/control_unit/StartStop.h> #include <chaos_metadata_service_client/api_proxy/control_unit/InitDeinit.h> @@ -29,6 +28,7 @@ #include <chaos_metadata_service_client/api_proxy/control_unit/CopyInstance.h> #include <chaos_metadata_service_client/api_proxy/control_unit/RecoverError.h> #include <chaos_metadata_service_client/api_proxy/control_unit/DeleteInstance.h> +#include <chaos_metadata_service_client/api_proxy/control_unit/SendStorageBurst.h> #include <chaos_metadata_service_client/api_proxy/control_unit/GetCurrentDataset.h> #include <chaos_metadata_service_client/api_proxy/control_unit/SearchInstancesByUS.h> #include <chaos_metadata_service_client/api_proxy/control_unit/SetInstanceDescription.h> diff --git a/chaos_metadata_service_client/node_controller/CUController.cpp b/chaos_metadata_service_client/node_controller/CUController.cpp index 26dca92a623bae5ef97c5f4ab85ab415a3e0e502..5d8b315fc5494ddc27357b2dcffc13303b7e0a4b 100644 --- a/chaos_metadata_service_client/node_controller/CUController.cpp +++ b/chaos_metadata_service_client/node_controller/CUController.cpp @@ -54,14 +54,14 @@ using namespace chaos::metadata_service_client; #define MDS_TIMEOUT 5000 #define DBGET LDBG_<<"["<<__PRETTY_FUNCTION__<<"]" #define EXECUTE_CHAOS_API(api_name,time_out,...) \ - DBGET<<" " <<" Executing Api:\""<< # api_name<<"\"" ;\ - chaos::metadata_service_client::api_proxy::ApiProxyResult apires= GET_CHAOS_API_PTR(api_name)->execute( __VA_ARGS__ );\ - apires->setTimeout(time_out);\ - apires->wait();\ - if(apires->getError()){\ - std::stringstream ss;\ - ss<<" error in :"<<__FUNCTION__<<"|"<<__LINE__<<"|"<< # api_name <<" " <<apires->getErrorMessage();\ - throw CException(-2,ss.str(),__PRETTY_FUNCTION__);} +DBGET<<" " <<" Executing Api:\""<< # api_name<<"\"" ;\ +chaos::metadata_service_client::api_proxy::ApiProxyResult apires= GET_CHAOS_API_PTR(api_name)->execute( __VA_ARGS__ );\ +apires->setTimeout(time_out);\ +apires->wait();\ +if(apires->getError()){\ +std::stringstream ss;\ +ss<<" error in :"<<__FUNCTION__<<"|"<<__LINE__<<"|"<< # api_name <<" " <<apires->getErrorMessage();\ +throw CException(-2,ss.str(),__PRETTY_FUNCTION__);} CUController::CUController(const std::string& _deviceID, chaos::common::io::IODataDriverShrdPtr _ioLiveDataDriver): @@ -127,6 +127,7 @@ CUController::~CUController() { } if(ioLiveDataDriver.get()){ + ioLiveDataDriver->deinit(); ioLiveDataDriver.reset(); } } @@ -156,7 +157,7 @@ void CUController::updateChannel() throw(CException) { CDataWrapper *tmp_data_handler = NULL; CHAOS_ASSERT(deviceChannel) LDBG_<<"UPDATING \""<<devId<<"\""; - /* + /* * if(deviceChannel==NULL){ LDBG_<<"["<<__PRETTY_FUNCTION__<<"] Device Channel not still ready..."; return; @@ -169,11 +170,11 @@ void CUController::updateChannel() throw(CException) { ChaosUniquePtr<chaos::common::data::CDataWrapper> lastDeviceDefinition(tmp_data_handler); datasetDB.addAttributeToDataSetFromDataWrapper(*lastDeviceDefinition.get()); - + } int CUController::setScheduleDelay(uint64_t microseconds) { - + chaos::common::property::PropertyGroup pg(chaos::ControlUnitPropertyKey::GROUP_NAME); pg.addProperty(chaos::ControlUnitDatapackSystemKey::THREAD_SCHEDULE_DELAY, CDataVariant(static_cast<uint64_t>(microseconds))); DBGET<<chaos::ControlUnitDatapackSystemKey::THREAD_SCHEDULE_DELAY<<":"<<microseconds; @@ -184,7 +185,7 @@ int CUController::setScheduleDelay(uint64_t microseconds) { int CUController::setBypass(bool onoff){ chaos::common::property::PropertyGroup pg(chaos::ControlUnitPropertyKey::GROUP_NAME); pg.addProperty(chaos::ControlUnitDatapackSystemKey::BYPASS_STATE, CDataVariant(static_cast<bool>(onoff))); - + EXECUTE_CHAOS_API(chaos::metadata_service_client::api_proxy::node::UpdateProperty,millisecToWait,devId,pg); return 0; } @@ -413,7 +414,7 @@ int CUController::setAttributeToValue(const char *attributeName, const char *att } } LDBG_<<"["<<__PRETTY_FUNCTION__<<"] Sending attribute '"<<attributeName<<"'='"<<attributeValuePack.getJSONString()<<"'"; - + return deviceChannel->setAttributeValue(attributeValuePack, noWait, millisecToWait); } @@ -927,10 +928,10 @@ int CUController::fetchAllDataset() { end = current_dataset.end(); (it != end) && (counter<results.size()); it++) { - - (*it) = results[counter++]; - - + + (*it) = results[counter++]; + + } } return err; @@ -951,31 +952,31 @@ ChaosSharedPtr<chaos::common::data::CDataWrapper> CUController::fetchCurrentDat } int CUController::getPackSeq(uint64_t& seq){ - CDataWrapper * d = current_dataset[KeyDataStorageDomainOutput].get(); - if(d){ - seq =d->getInt64Value(DataPackCommonKey::DPCK_SEQ_ID); - return 0; - } - seq=-1; - return -1; + CDataWrapper * d = current_dataset[KeyDataStorageDomainOutput].get(); + if(d){ + seq =d->getInt64Value(DataPackCommonKey::DPCK_SEQ_ID); + return 0; + } + seq=-1; + return -1; } int CUController::getTimeStamp(uint64_t& live,bool hr){ CDataWrapper * d = current_dataset[KeyDataStorageDomainOutput].get(); live =0; if(d){ - if(hr){ - if(d->hasKey(DataPackCommonKey::DPCK_HIGH_RESOLUTION_TIMESTAMP)) { - live = d->getInt64Value(DataPackCommonKey::DPCK_HIGH_RESOLUTION_TIMESTAMP); - } else if(d->hasKey(DataPackCommonKey::DPCK_TIMESTAMP)){ - live= d->getInt64Value(DataPackCommonKey::DPCK_TIMESTAMP)*1000; - } - } else { - if(d->hasKey(DataPackCommonKey::DPCK_TIMESTAMP)){ - live = d->getInt64Value(DataPackCommonKey::DPCK_TIMESTAMP); - } else if(d->hasKey(DataPackCommonKey::DPCK_HIGH_RESOLUTION_TIMESTAMP)){ - live= d->getInt64Value(DataPackCommonKey::DPCK_HIGH_RESOLUTION_TIMESTAMP)*1000; - } - } + if(hr){ + if(d->hasKey(DataPackCommonKey::DPCK_HIGH_RESOLUTION_TIMESTAMP)) { + live = d->getInt64Value(DataPackCommonKey::DPCK_HIGH_RESOLUTION_TIMESTAMP); + } else if(d->hasKey(DataPackCommonKey::DPCK_TIMESTAMP)){ + live= d->getInt64Value(DataPackCommonKey::DPCK_TIMESTAMP)*1000; + } + } else { + if(d->hasKey(DataPackCommonKey::DPCK_TIMESTAMP)){ + live = d->getInt64Value(DataPackCommonKey::DPCK_TIMESTAMP); + } else if(d->hasKey(DataPackCommonKey::DPCK_HIGH_RESOLUTION_TIMESTAMP)){ + live= d->getInt64Value(DataPackCommonKey::DPCK_HIGH_RESOLUTION_TIMESTAMP)*1000; + } + } return 0; } return -1; @@ -1064,32 +1065,36 @@ cu_prof_t CUController::getProfileInfo(){ void CUController::executeTimeIntervallQuery(DatasetDomain domain, uint64_t start_ts, uint64_t end_ts, + const ChaosStringSet& meta_tags, QueryCursor **query_cursor, uint32_t page) { if((domain>=0) && (domain<=DPCK_LAST_DATASET_INDEX)){ *query_cursor = ioLiveDataDriver->performQuery(channel_keys[domain], start_ts, end_ts, + meta_tags, page); } } -void CUController::executeTimeIntervalQuery(DatasetDomain domain, - uint64_t start_ts, - uint64_t end_ts, - uint64_t seqid, - uint64_t runid, - chaos::common::io::QueryCursor **query_cursor, - uint32_t page_len){ +void CUController::executeTimeIntervalQuery(const DatasetDomain domain, + const uint64_t start_ts, + const uint64_t end_ts, + const uint64_t seqid, + const uint64_t runid, + const ChaosStringSet& meta_tags, + chaos::common::io::QueryCursor **query_cursor, + const uint32_t page_len){ if((domain>=0) && (domain<=DPCK_LAST_DATASET_INDEX)){ *query_cursor = ioLiveDataDriver->performQuery(channel_keys[domain], start_ts, end_ts, seqid, runid, + meta_tags, page_len); } - + } //! release a query void CUController::releaseQuery(QueryCursor *query_cursor) { diff --git a/chaos_metadata_service_client/node_controller/CUController.h b/chaos_metadata_service_client/node_controller/CUController.h index 854d90f6d4ddb1d5a5467e1ea120a3dfcd9c6e14..d63ea56438d24cf06a00969572df25c0966defa3 100644 --- a/chaos_metadata_service_client/node_controller/CUController.h +++ b/chaos_metadata_service_client/node_controller/CUController.h @@ -47,9 +47,9 @@ namespace chaos { namespace node_controller { //! identify the domain qhere fetch the data - - typedef chaos::cu::data_manager::KeyDataStorageDomain DatasetDomain; - + + typedef chaos::cu::data_manager::KeyDataStorageDomain DatasetDomain; + //! Controller for a single device instance /*! This represent a global controller for a single device, identified by DEVICE_ID. The contorlle rpermit to @@ -169,7 +169,7 @@ namespace chaos { Set the control unit run method scheduling delay */ int setScheduleDelay(uint64_t microsecondsDelay); - + //! update the scudiling of device run method /*! Set the control unit bypass @@ -193,7 +193,7 @@ namespace chaos { * @return 0 on success, negative otherwise */ int getPackSeq(uint64_t& seq); - + /*! Get description for attribute name */ @@ -260,7 +260,7 @@ namespace chaos { */ int deinitDevice(); - + /** * recover the device from an error (recoverable) * @return 0 on success @@ -410,7 +410,7 @@ namespace chaos { //!return the last fetched dataset for the domain ChaosSharedPtr<chaos::common::data::CDataWrapper> getCurrentDatasetForDomain(DatasetDomain domain); - + //!return the last fetched dataset for the domain int getCurrentDatasetForDomain(DatasetDomain domain,chaos::common::data::CDataWrapper* ret); @@ -439,7 +439,7 @@ namespace chaos { //! send custom request to device and return a future ChaosUniquePtr<chaos::common::message::MessageRequestFuture> sendCustomRequestWithFuture(const std::string& action_name, - common::data::CDataWrapper *request_date); + common::data::CDataWrapper *request_date); //! send custom message to device void sendCustomMessage(const std::string& action, @@ -448,7 +448,7 @@ namespace chaos { //! Send a request for receive RPC information int checkRPCInformation(chaos::common::data::CDataWrapper **result_information, uint32_t timeout = RpcConfigurationKey::GlobalRPCTimeoutinMSec -); + ); //! Send a request for an echo test int echoTest(chaos::common::data::CDataWrapper * const echo_data, @@ -456,18 +456,22 @@ namespace chaos { uint32_t timeout = RpcConfigurationKey::GlobalRPCTimeoutinMSec); //! get datapack between time itervall - void executeTimeIntervallQuery(DatasetDomain domain, - uint64_t start_ts, - uint64_t end_ts, - chaos::common::io::QueryCursor **query_cursor,uint32_t page_len=DEFAULT_PAGE_LEN); - - void executeTimeIntervalQuery(DatasetDomain domain, - uint64_t start_ts, - uint64_t end_ts, - uint64_t seqid, - uint64_t runid, - chaos::common::io::QueryCursor **query_cursor,uint32_t page_len=DEFAULT_PAGE_LEN); - + void executeTimeIntervallQuery(const DatasetDomain domain, + const uint64_t start_ts, + const uint64_t end_ts, + const ChaosStringSet& meta_tags, + chaos::common::io::QueryCursor **query_cursor, + const uint32_t page_len=DEFAULT_PAGE_LEN); + + void executeTimeIntervalQuery(const DatasetDomain domain, + const uint64_t start_ts, + const uint64_t end_ts, + const uint64_t seqid, + const uint64_t runid, + const ChaosStringSet& meta_tags, + chaos::common::io::QueryCursor **query_cursor, + const uint32_t page_len=DEFAULT_PAGE_LEN); + //! release a query void releaseQuery(chaos::common::io::QueryCursor *query_cursor); diff --git a/config/CMakeMacroUtils.txt b/config/CMakeMacroUtils.txt index 79f10b04c812d59c86bded00117edc7dfcb89e88..b6e339f2e79a3ff0ae95c3d2e4c3bd087ab3cfd2 100644 --- a/config/CMakeMacroUtils.txt +++ b/config/CMakeMacroUtils.txt @@ -5,6 +5,12 @@ macro (MESG parm) MESSAGE(STATUS "[${WHERE}] ${parm}") endmacro() +macro (WARN parm) +# get_filename_component(WHERE ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) + SET(WHERE ${CMAKE_CURRENT_LIST_DIR}) + MESSAGE(WARNING "[${WHERE}] ${parm}") +endmacro() + macro (ERROR parm) # get_filename_component(WHERE ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) SET(WHERE ${CMAKE_CURRENT_LIST_DIR}) diff --git a/example/ChaosCLI/CMakeLists.txt b/example/ChaosCLI/CMakeLists.txt deleted file mode 100644 index cc942ae0dee4003c7509136af56bb3980c226306..0000000000000000000000000000000000000000 --- a/example/ChaosCLI/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 2.6) -# IF (DEFINED ENV{CHAOS_BUNDLE} ) -# include($ENV{CHAOS_BUNDLE}/tools/project_template/CMakeChaos.txt) -# ENDIF() - -SET(chaos_cli_src main.cpp) - -ADD_EXECUTABLE(ChaosCLI ${chaos_cli_src}) - - -IF(BUILD_FORCE_STATIC) - SET(CMAKE_EXE_LINKER_FLAGS "-static -Wl,--whole-archive -lchaos_common -Wl,--no-whole-archive") -ENDIF() - -TARGET_LINK_LIBRARIES(ChaosCLI chaos_uitoolkit chaos_common ${FrameworkLib}) -INSTALL_TARGETS(/bin ChaosCLI) diff --git a/example/ChaosCLI/ChaosCLI b/example/ChaosCLI/ChaosCLI deleted file mode 100755 index c9548cd86d05ac0fdd045525a472bd015f7f1ed7..0000000000000000000000000000000000000000 Binary files a/example/ChaosCLI/ChaosCLI and /dev/null differ diff --git a/example/ChaosCLI/ChaosCLI.xcodeproj/project.pbxproj b/example/ChaosCLI/ChaosCLI.xcodeproj/project.pbxproj deleted file mode 100644 index f520c354b98db4fab6aed57d5335add72add77ef..0000000000000000000000000000000000000000 --- a/example/ChaosCLI/ChaosCLI.xcodeproj/project.pbxproj +++ /dev/null @@ -1,261 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 32DC4AE317903EB5005F1696 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32DC4AE217903EB5005F1696 /* main.cpp */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 32DC4AD317903E87005F1696 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 32DC4AD517903E87005F1696 /* ChaosCLI */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ChaosCLI; sourceTree = BUILT_PRODUCTS_DIR; }; - 32DC4AE117903EB5005F1696 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = SOURCE_ROOT; }; - 32DC4AE217903EB5005F1696 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = main.cpp; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 32DC4AD217903E87005F1696 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 32DC4ACC17903E87005F1696 = { - isa = PBXGroup; - children = ( - 32DC4AD717903E87005F1696 /* ChaosCLI */, - 32DC4AD617903E87005F1696 /* Products */, - ); - sourceTree = "<group>"; - }; - 32DC4AD617903E87005F1696 /* Products */ = { - isa = PBXGroup; - children = ( - 32DC4AD517903E87005F1696 /* ChaosCLI */, - ); - name = Products; - sourceTree = "<group>"; - }; - 32DC4AD717903E87005F1696 /* ChaosCLI */ = { - isa = PBXGroup; - children = ( - 32DC4AE117903EB5005F1696 /* CMakeLists.txt */, - 32DC4AE217903EB5005F1696 /* main.cpp */, - ); - path = ChaosCLI; - sourceTree = "<group>"; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 32DC4AD417903E87005F1696 /* ChaosCLI */ = { - isa = PBXNativeTarget; - buildConfigurationList = 32DC4ADE17903E87005F1696 /* Build configuration list for PBXNativeTarget "ChaosCLI" */; - buildPhases = ( - 32DC4AD117903E87005F1696 /* Sources */, - 32DC4AD217903E87005F1696 /* Frameworks */, - 32DC4AD317903E87005F1696 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = ChaosCLI; - productName = ChaosCLI; - productReference = 32DC4AD517903E87005F1696 /* ChaosCLI */; - productType = "com.apple.product-type.tool"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 32DC4ACD17903E87005F1696 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0500; - ORGANIZATIONNAME = infn; - }; - buildConfigurationList = 32DC4AD017903E87005F1696 /* Build configuration list for PBXProject "ChaosCLI" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 32DC4ACC17903E87005F1696; - productRefGroup = 32DC4AD617903E87005F1696 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 32DC4AD417903E87005F1696 /* ChaosCLI */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 32DC4AD117903E87005F1696 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 32DC4AE317903EB5005F1696 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 32DC4ADC17903E87005F1696 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++98"; - 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__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - 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_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.8; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - }; - name = Debug; - }; - 32DC4ADD17903E87005F1696 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++98"; - 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__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_ENABLE_OBJC_EXCEPTIONS = 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; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.8; - SDKROOT = macosx; - }; - name = Release; - }; - 32DC4ADF17903E87005F1696 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_CXX_LANGUAGE_STANDARD = "gnu++98"; - CLANG_CXX_LIBRARY = "libc++"; - CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../usr/local/bin"; - GCC_C_LANGUAGE_STANDARD = gnu99; - HEADER_SEARCH_PATHS = ( - ../../, - ../../usr/local/include, - ); - LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../../usr/local/lib"; - OTHER_LDFLAGS = ( - "-lchaos_uitoolkit", - "-lchaos_common", - ); - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 32DC4AE017903E87005F1696 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_CXX_LANGUAGE_STANDARD = "gnu++98"; - CLANG_CXX_LIBRARY = "libc++"; - CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../usr/local/bin"; - GCC_C_LANGUAGE_STANDARD = gnu99; - HEADER_SEARCH_PATHS = ( - ../../, - ../../usr/local/include, - ); - LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../../usr/local/lib"; - OTHER_LDFLAGS = ( - "-lchaos_uitoolkit", - "-lchaos_common", - ); - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 32DC4AD017903E87005F1696 /* Build configuration list for PBXProject "ChaosCLI" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 32DC4ADC17903E87005F1696 /* Debug */, - 32DC4ADD17903E87005F1696 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 32DC4ADE17903E87005F1696 /* Build configuration list for PBXNativeTarget "ChaosCLI" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 32DC4ADF17903E87005F1696 /* Debug */, - 32DC4AE017903E87005F1696 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 32DC4ACD17903E87005F1696 /* Project object */; -} diff --git a/example/ChaosCLI/ChaosCLI.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ChaosCLI/ChaosCLI.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a6254f0e9651f402737811be6634a03e9c..0000000000000000000000000000000000000000 --- a/example/ChaosCLI/ChaosCLI.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<Workspace - version = "1.0"> - <FileRef - location = "self:"> - </FileRef> -</Workspace> diff --git a/example/ChaosCLI/main.cpp b/example/ChaosCLI/main.cpp deleted file mode 100644 index 6c99d62930483c2979ca5f2405a759fa48085e20..0000000000000000000000000000000000000000 --- a/example/ChaosCLI/main.cpp +++ /dev/null @@ -1,518 +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 <iostream> -#include <string> -#include <vector> -#include <chaos/common/global.h> -#include <chaos/common/utility/TimingUtil.h> -#include <chaos/common/chaos_constants.h> -#include <chaos/common/network/CNodeNetworkAddress.h> -#include <chaos/ui_toolkit/ChaosUIToolkit.h> -#include <chaos/ui_toolkit/LowLevelApi/LLRpcApi.h> -#include <chaos/ui_toolkit/HighLevelApi/HLDataApi.h> -#include <stdio.h> -#include <boost/date_time/posix_time/posix_time.hpp> -#include <boost/date_time/c_local_time_adjustor.hpp> -#include <boost/random/random_device.hpp> -#include <boost/random/uniform_int_distribution.hpp> - -using namespace std; -using namespace chaos; -using namespace chaos::common::data; -using namespace chaos::ui; -using namespace boost; -using namespace boost::posix_time; -using namespace boost::date_time; -namespace chaos_batch = chaos::common::batch_command; - -#define OPT_STATE "op" -#define OPT_TIMEOUT "timeout" -#define OPT_CU_ID "device-id" -#define OPT_SCHEDULE_TIME "stime" -#define OPT_PRINT_STATE "print-state" -#define OPT_PRINT_TYPE "print-type" -#define OPT_PRINT_DATASET "print-dataset" -#define OPT_GET_DS_VALUE "get_ds_value" -//--------------slow contorol option---------------------------------------------------- -#define OPT_SL_ALIAS "sc-alias" -#define OPT_SL_EXEC_CHANNEL "sc-exec-channel" -#define OPT_SL_PRIORITY "sc-priority" -#define OPT_SL_SUBMISSION_RULE "sc-sub-rule" -#define OPT_SL_COMMAND_DATA "sc-cmd-data" -#define OPT_SL_COMMAND_ID "sc-cmd-id" -#define OPT_SL_COMMAND_SCHEDULE_DELAY "sc-cmd-sched-wait" -#define OPT_SL_COMMAND_SUBMISSION_RETRY_DELAY "sc-cmd-submission-retry-delay" -#define OPT_SL_COMMAND_SET_FEATURES_LOCK "sc-cmd-features-lock" -#define OPT_SL_COMMAND_SET_FEATURES_SCHEDULER_WAIT "sc-cmd-features-sched-wait" -//--------------rt control unit option-------------------------------------------------- -#define OPT_RT_ATTRIBUTE_VALUE "rt-attr-val" - -const std::string rand_chars("abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "1234567890" - "!@#$%^&*()" - "`~-_=+[{]{\\|;:'\",<.>/? " - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "1234567890" - "!@#$%^&*()" - "`~-_=+[{]{\\|;:'\",<.>/? " - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "1234567890" - "!@#$%^&*()" - "`~-_=+[{]{\\|;:'\",<.>/? " - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "1234567890" - "!@#$%^&*()" - "`~-_=+[{]{\\|;:'\",<.>/? "); - -inline ptime utcToLocalPTime(ptime utcPTime){ - c_local_adjustor<ptime> utcToLocalAdjustor; - ptime t11 = utcToLocalAdjustor.utc_to_local(utcPTime); - return t11; -} - -void print_state(CUStateKey::ControlUnitState state) { - switch (state) { - case CUStateKey::INIT: - std::cout << "Initialized:"<<state; - break; - case CUStateKey::START: - std::cout << "Started:"<<state; - break; - case CUStateKey::STOP: - std::cout << "Stopped:"<<state; - break; - case CUStateKey::DEINIT: - std::cout << "Deinitilized:"<<state; - break; - - case CUStateKey::RECOVERABLE_ERROR: - std::cout << "Recovable Error:"<<state; - break; - case CUStateKey::FATAL_ERROR: - std::cout << "Fatal Error:"<<state; - break; - default: - std::cout << "Uknown:"<<state; - - } - std::cout<<std::endl; -} - -int checkSubmissionRule(std::string scSubmissionRule) { - if( scSubmissionRule.compare("normal") == 0) { - return chaos_batch::SubmissionRuleType::SUBMIT_NORMAL; - } else if( scSubmissionRule.compare("stack") == 0) { - return chaos_batch::SubmissionRuleType::SUBMIT_AND_STACK; - } else if( scSubmissionRule.compare("kill") == 0) { - return chaos_batch::SubmissionRuleType::SUBMIT_AND_KILL; - } else return -1; -} - -int main (int argc, const char* argv[] ) -{ - try { - int err = 0; - int op =-1; - bool printState = false; - bool printType = false; - int32_t print_domain_current_value = -1; - long scheduleTime; - uint32_t timeout; - - string deviceID; - string scAlias; - string scSubmissionRule; - string scUserData; - uint64_t scCmdID; - uint32_t scSubmissionPriority; - uint32_t scSubmissionSchedulerDelay; - uint32_t scSubmissionSubmissionRetryDelay; - uint32_t scExecutionChannel; - string rtAttributeValue; - vector<string> key_to_show; - - - bool scFeaturesLock; - uint32_t scFeaturesSchedWait; - std::string control_unit_type; - CDeviceNetworkAddress deviceNetworkAddress; - CUStateKey::ControlUnitState deviceState; - - //! [UIToolkit Attribute Init] - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_CU_ID, "The identification string of the device"); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<uint32_t>(OPT_TIMEOUT, "Timeout rpc in milliseconds", 2000, &timeout); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<int>(OPT_STATE, "The state to set on the device{1=init, 2=start, 3=stop, 4=deinit, 5=set schedule time, 6=submite slow command(slcu), 7=kill current command(slcu), 8=get command state by id, 9=set input channel(rtcu)}, 10=flush history state(slcu), 11=get dataset value for keys", 0); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<long>(OPT_SCHEDULE_TIME, "the time in microseconds for devide schedule time"); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<bool>(OPT_PRINT_STATE, "Print the state of the device", false, &printState); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<bool>(OPT_PRINT_TYPE, "Print the type of the control unit of the device", false, &printType); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<int32_t>(OPT_PRINT_DATASET, "print the dataset for the domain -1=no-print, 0=output, 1=input, 2=custom, 3=system 4=health 5=alarm", -1, &print_domain_current_value); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption< vector<string> >(OPT_GET_DS_VALUE, "Print last value of the dataset keys[to use with opcode 11]", &key_to_show, true); - - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_SL_ALIAS, "The alias associted to the command for the slow control cu", "", &scAlias); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<uint32_t>(OPT_SL_EXEC_CHANNEL, "TThe alias used to execute the command [it's 1 based, 0 let choice the channel to the engine]", 0, &scExecutionChannel); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_SL_SUBMISSION_RULE, "The rule used for submit the command for the slow control cu [normal, stack, kill]","stack", &scSubmissionRule); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<uint32_t>(OPT_SL_PRIORITY, "The priority used for submit the command for the slow control cu", 50,&scSubmissionPriority); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_SL_COMMAND_DATA, "The bson pack (in text format) sent to the set handler of the command for the slow", &scUserData); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<uint64_t>(OPT_SL_COMMAND_ID, "The command identification number(cidn)", &scCmdID); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<uint32_t>(OPT_SL_COMMAND_SCHEDULE_DELAY, "The millisecond beetwen a step an the next of the scheduler[in milliseconds]", 1000000, &scSubmissionSchedulerDelay); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<uint32_t>(OPT_SL_COMMAND_SUBMISSION_RETRY_DELAY, "The millisecond beetwen submission checker run", 1000, &scSubmissionSubmissionRetryDelay); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<bool>(OPT_SL_COMMAND_SET_FEATURES_LOCK, "if true will lock the feature to the command modification", &scFeaturesLock); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<uint32_t>(OPT_SL_COMMAND_SET_FEATURES_SCHEDULER_WAIT, "The millisecond beetwen two step of the scheduler", &scFeaturesSchedWait); - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->addOption<string>(OPT_RT_ATTRIBUTE_VALUE, "The attribute and value for the input attribute in rt control unit [attribute:value]", &rtAttributeValue); - - //! [UIToolkit Attribute Init] - - //! [UIToolkit Init] - ChaosUIToolkit::getInstance()->init(argc, argv); - //! [UIToolkit Init] - - if(ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_STATE)){ - op = ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->getOption<int>(OPT_STATE); - } - - if(ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_CU_ID)){ - deviceID = ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->getOption<string>(OPT_CU_ID); - } - - if(deviceID.size()==0) throw CException(1, "invalid device identification string", "check param"); - - - if(op == 5 && !ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_SCHEDULE_TIME)) - throw CException(3, "The set schedule time code need the param \"stime\"", "device controller creation"); - else{ - if(op == 5){ - scheduleTime = ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->getOption<long>(OPT_SCHEDULE_TIME); - } - } - - DeviceController *controller = HLDataApi::getInstance()->getControllerForDeviceID(deviceID, timeout); - if(!controller) throw CException(4, "Error allcoating decive controller", "device controller creation"); - - for(int idx = 0; idx < 8000000; idx++) { - CDataWrapper message_echo; - message_echo.addStringValue("echo_message", CHAOS_FORMAT("echo_test_message %1%/n%2%",%idx%rand_chars)); - - CDataWrapper *result = NULL; - try{ - if(controller->echoTest(&message_echo, &result) == 0) { - - } - }catch(...) { - - } - if(result) { - std::cout << idx << " - " <<result->getJSONString() << std::endl; - delete(result); - } - usleep(100); - } - - controller->fetchCurrentDeviceValue(); - - // use the RPC version for the moment - err = controller->getType(control_unit_type); - if(err == ErrorCode::EC_TIMEOUT) { - control_unit_type="unknown"; - } - // std::cout << "type:"<<control_unit_type<<std::endl; - if((control_unit_type =="rtcu") || (control_unit_type =="sccu")){ - err = controller->getState(deviceState); - if(err == ErrorCode::EC_TIMEOUT && op!=11) throw CException(5, "Time out on connection", "Get state for device"); - //std::cout << control_unit_type<<" device, state:"; - //print_state(deviceState); - } else { - std::cout << "State-less device, type:"<<control_unit_type<<std::endl; - // deviceState = CUStateKey::START; - } - - if(printState) { - uint64_t err; - //err = controller->getState(deviceState); - err = controller->getState(deviceState); - - if(err == 0) throw CException(5, "Error retrving the state", "Get state for device"); - std::cout << "Current state ["<<err<<"]:"; - print_state(deviceState); - std::cout << std::endl; - } - - if(printType) { - std::string control_unit_type; - err = controller->getState(deviceState); - if(err == ErrorCode::EC_TIMEOUT && op!=11) throw CException(5, "Time out on connection", "Get state for device"); - std::cout << "Control unit type:"; - - std::cout << control_unit_type << std::endl; - } - - if(print_domain_current_value >= 0) { - controller->fetchCurrentDatatasetFromDomain((DatasetDomain)print_domain_current_value); - if(controller->getCurrentDatasetForDomain((DatasetDomain)print_domain_current_value) != NULL) { - std::cout << controller->getCurrentDatasetForDomain((DatasetDomain)print_domain_current_value)->getJSONString() <<std::endl; - } - - } - - switch (op) { - case 1: - /* - Init the control unit - */ - - err = controller->initDevice(); - if(err == ErrorCode::EC_TIMEOUT) throw CException(6, "Time out on connection", "Set device to init state"); - - - /* if((deviceState == CUStateKey::START)||(deviceState == CUStateKey::STOP)) { - print_state(deviceState); - throw CException(deviceState, "%% The device is in start or stop state.", "Setting device to init state"); - - }*/ - break; - case 2: - /* - Start the control unit - */ - - err = controller->startDevice(); - if(err == ErrorCode::EC_TIMEOUT) throw CException(2, "Time out on connection", "Set device to start state"); - /*if(deviceState == CUStateKey::DEINIT ) { - print_state(deviceState); - throw CException(deviceState, "%% The device is in deinit state, cannot change state", "Set device to start state"); - }*/ - break; - case 3: - /* - Stop the control unit - */ - - - err = controller->stopDevice(); - if(err == ErrorCode::EC_TIMEOUT) throw CException(2, "Time out on connection", "Set device to stop state"); - /* if((deviceState == CUStateKey::INIT)||(deviceState == CUStateKey::DEINIT)) { - print_state(deviceState); - throw CException(deviceState, "%% The device is not in the start/stop", "Set device to stop state"); - }*/ - break; - case 4: - /* - deinit the control unit - */ - - err = controller->deinitDevice(); - if(err == ErrorCode::EC_TIMEOUT){ - throw CException(2, "Time out on connection", "Set device to deinit state"); - } - /* if(deviceState == CUStateKey::START){ - print_state(deviceState); - throw CException(deviceState, "%% Device is in start cannot change state", "Set device to deinit"); - }*/ - - break; - case 5: - /* - change schedule - */ - - err = controller->setScheduleDelay(scheduleTime); - if(err == ErrorCode::EC_TIMEOUT) throw CException(2, "Time out on connection", "Set device to deinit state"); - /* if(deviceState == CUStateKey::DEINIT) { - print_state(deviceState); - throw CException(29, "%% Device can't be in deinit state", "Set device schedule time"); - }*/ - break; - case 6: { - //check sc - uint64_t command_id = 0; - ChaosUniquePtr<chaos::common::data::CDataWrapper> userData; - bool canBeExecuted = scAlias.size() > 0; - canBeExecuted = canBeExecuted && (checkSubmissionRule(scSubmissionRule) != -1); - if(canBeExecuted) { - if(ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_SL_COMMAND_SUBMISSION_RETRY_DELAY)) { - std::cout << "Custom checker delay submitted -> " << scSubmissionSubmissionRetryDelay << std::endl; - } - - if(ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_SL_COMMAND_DATA)) { - userData.reset(new CDataWrapper()); - if(userData.get())userData->setSerializedJsonData(scUserData.c_str()); - std::cout << "User data submitted" << std::endl; - std::cout << "-----------------------------------------" << std::endl; - std::cout << userData->getJSONString() << std::endl; - std::cout << "-----------------------------------------" << std::endl; - } - err = controller->submitSlowControlCommand(scAlias, - static_cast<chaos_batch::SubmissionRuleType::SubmissionRule>(checkSubmissionRule(scSubmissionRule)), - scSubmissionPriority, - command_id, - scExecutionChannel, - scSubmissionSchedulerDelay, - scSubmissionSubmissionRetryDelay, - userData.get()); - if(err == ErrorCode::EC_TIMEOUT) throw CException(2, "Time out on connection", "Set device to deinit state"); - std::cout << "Command submitted successfully his command idedentification number(cidn) is= " << command_id << std::endl; - } else { - throw CException(29, "Device can't be in deinit state", "Send slow command"); - } - } - break; - case 7:{ - err = controller->killCurrentCommand(); - break; - } - case 8:{ - //chec if has been porvided a command ID - if(!ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_SL_COMMAND_ID)) { - throw CException(1, "No command id provided", "OPCODE 8"); - } - chaos_batch::CommandState command_state; - command_state.command_id = scCmdID; - err = controller->getCommandState(command_state); - std::cout << "Device state start -------------------------------------------------------" << std::endl; - std::cout << "Command"; - switch (command_state.last_event) { - case chaos_batch::BatchCommandEventType::EVT_COMPLETED: - std::cout << " has completed"<< std::endl;; - break; - case chaos_batch::BatchCommandEventType::EVT_FAULT: - std::cout << " has fault"; - std::cout << "Error code :"<<command_state.fault_description.code<< std::endl; - std::cout << "Error domain :"<<command_state.fault_description.domain<< std::endl; - std::cout << "Error description :"<<command_state.fault_description.description<< std::endl; - break; - case chaos_batch::BatchCommandEventType::EVT_KILLED: - std::cout << " has been killed"<< std::endl; - break; - case chaos_batch::BatchCommandEventType::EVT_PAUSED: - std::cout << " has been paused"<< std::endl; - break; - case chaos_batch::BatchCommandEventType::EVT_QUEUED: - std::cout << " has been queued"<< std::endl; - break; - case chaos_batch::BatchCommandEventType::EVT_RUNNING: - std::cout << " is running"<< std::endl; - break; - case chaos_batch::BatchCommandEventType::EVT_WAITING: - std::cout << " is waiting"<< std::endl; - break; - } - std::cout << "Device state end ---------------------------------------------------------" << std::endl; - break; - } - case 9: { - //set an input attribute of the dataset(rtcu) - if(!ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_RT_ATTRIBUTE_VALUE)) { - throw CException(1, "No attribute and value setupped", "OPCODE 9"); - } - if(rtAttributeValue.find(":")== string::npos) { - throw CException(2, "Attribute param not well formet, lak of ':' character (param_name:param_value)", "OPCODE 9"); - - } - std::string param_name = rtAttributeValue.substr(0, rtAttributeValue.find(":")); - std::string param_value = rtAttributeValue.substr(rtAttributeValue.find(":")+1); - //get name and value of the attribute - err = controller->setAttributeToValue(param_name.c_str(), param_value.c_str(), false); - if(err == ErrorCode::EC_TIMEOUT) - throw CException(3, "Time out on connection", "OPCODE 9"); - else if(err != ErrorCode::EC_NO_ERROR) - throw CException(3, "Time out on connection", "OPCODE 9"); - - break; - } - - case 10:{ - err = controller->flushCommandStateHistory(); - if(err == ErrorCode::EC_TIMEOUT) throw CException(3, "Time out on connection", "OPCODE 10"); - break; - } - - case 11:{ - controller->fetchCurrentDeviceValue(); - CDataWrapper * dataWrapper = controller->getLiveCDataWrapperPtr(); - if(dataWrapper) { - std::cout << dataWrapper->getJSONString() << std::endl; - } - std::string str_value; - for (int idx = 0; idx < key_to_show.size(); idx++) { - if(!controller->getAttributeStrValue(key_to_show[idx], str_value)) { - std::cout << key_to_show[idx] << " = " << str_value << std::endl; - } - } - - break; - } - - } - - if(ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_SL_COMMAND_SET_FEATURES_LOCK) || - ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_SL_COMMAND_SET_FEATURES_SCHEDULER_WAIT)){ - - chaos_batch::features::Features features; - - //we can set the features - if(ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_SL_COMMAND_SET_FEATURES_LOCK)) { - features.featuresFlag |= chaos_batch::features::FeaturesFlagTypes::FF_LOCK_USER_MOD; - std::cout << "Set the lock feature to -> " << scFeaturesLock << std::endl; - //set the lock - err = controller->setSlowCommandLockOnFeatures(scFeaturesLock); - if(err == ErrorCode::EC_TIMEOUT) throw CException(5, "Time out on connection", "setSlowCommandLockOnFeatures"); - } - - if(ChaosUIToolkit::getInstance()->getGlobalConfigurationInstance()->hasOption(OPT_SL_COMMAND_SET_FEATURES_SCHEDULER_WAIT)) { - features.featuresFlag |= chaos_batch::features::FeaturesFlagTypes::FF_SET_SCHEDULER_DELAY; - features.featureSchedulerStepsDelay = scFeaturesSchedWait; - std::cout << "Set the sched wait feature to -> " << scFeaturesSchedWait << " on execution channel " << scExecutionChannel << std::endl; - //se the features - err = controller->setSlowCommandFeatures(features, scFeaturesLock, scExecutionChannel); - if(err == ErrorCode::EC_TIMEOUT) throw CException(5, "Time out on connection", "setSlowCommandFeatures"); - } - - } - - if( printState && (op>=1 && op<=4)){ - //get the actual state of device - err = controller->getState(deviceState); - if(err == ErrorCode::EC_TIMEOUT) throw CException(5, "Time out on connection", "Get state for device"); - std::cout << "State after operation:"; - print_state(deviceState); - std::cout << std::endl; - } - - if(controller) - HLDataApi::getInstance()->disposeDeviceControllerPtr(controller); - - } catch (CException& e) { - std::cerr << e.errorCode << " - "<< e.errorDomain << " - " << e.errorMessage << std::endl; - return -4; - } - try { - //! [UIToolkit Deinit] - ChaosUIToolkit::getInstance()->deinit(); - //! [UIToolkit Deinit] - } catch (CException& e) { - std::cerr << e.errorCode << " - "<< e.errorDomain << " - " << e.errorMessage << std::endl; - return -3; - } - return 0; -} diff --git a/example/ChaosPerformanceTester/main.cpp b/example/ChaosPerformanceTester/main.cpp index 9ad087528e07dfad3f66bca1379cf07db170f218..3a6d16094d17d619823702dd51b5f7a8d95e959a 100644 --- a/example/ChaosPerformanceTester/main.cpp +++ b/example/ChaosPerformanceTester/main.cpp @@ -24,9 +24,6 @@ #include <chaos/common/global.h> #include <chaos/common/chaos_constants.h> #include <chaos/common/network/CNodeNetworkAddress.h> -#include <chaos/ui_toolkit/ChaosUIToolkit.h> -#include <chaos/ui_toolkit/LowLevelApi/LLRpcApi.h> -#include <chaos/ui_toolkit/HighLevelApi/HLDataApi.h> #include <stdio.h> #include <chaos/common/bson/bson.h> @@ -38,7 +35,6 @@ using namespace std; using namespace chaos; using namespace chaos::common::network; -using namespace chaos::ui; using namespace boost; using namespace boost::posix_time; using namespace boost::date_time;