Project
Loading...
Searching...
No Matches
test_CrashingWorkflow.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
14#include "Framework/Logger.h"
16#include "Framework/Signpost.h"
17
19
20using namespace o2::framework;
21
23 Configurable<std::string> crashType{"crash-type", "fatal-init", {"how should this crash? (fatal-init, fatal-run, runtime-init, runtime-fail, abort-init, abort-run)"}};
24};
25
27
28AlgorithmSpec simpleCrashingSource(std::string const& what)
29{
30 return AlgorithmSpec{adaptStateful([what](InitContext& ctx) {
31 O2_SIGNPOST_ID_FROM_POINTER(ii, crash_test, &ctx);
32 O2_SIGNPOST_START(crash_test, ii, "Init", "Starting Init");
33 O2_SIGNPOST_EVENT_EMIT(crash_test, ii, "Init", "%{public}s selected", what.c_str());
34
35 if (what == "fatal-init") {
36 LOG(fatal) << "This should have a fatal";
37 } else if (what == "runtime-init") {
38 throw std::runtime_error("This is a std::runtime_error");
39 } else if (what == "abort-init") {
40 abort();
41 } else if (what == "framework-init") {
42 throw o2::framework::runtime_error("This is a o2::framework::runtime_error");
43 } else if (what == "framework-prerun") {
44 ctx.services().get<CallbackService>().set<CallbackService::Id::PreProcessing>([](ServiceRegistryRef, int) {
45 throw o2::framework::runtime_error("This is o2::framework::runtime_error in PreProcessing");
46 });
47 } else if (what == "runtime-prerun") {
48 ctx.services().get<CallbackService>().set<CallbackService::Id::PreProcessing>([](ServiceRegistryRef, int) {
49 throw std::runtime_error("This is std::runtime_error in PreProcessing");
50 });
51 }
52 O2_SIGNPOST_END(crash_test, ii, "Init", "Init Done");
53 return adaptStateless([what](ProcessingContext& pCtx) {
54 O2_SIGNPOST_ID_FROM_POINTER(ri, crash_test, &pCtx);
55 O2_SIGNPOST_START(crash_test, ri, "Run", "Starting Run");
56 O2_SIGNPOST_EVENT_EMIT(crash_test, ri, "Run", "%{public}s selected", what.c_str());
57 if (what == "fatal-run") {
58 LOG(fatal) << "This should have a fatal";
59 } else if (what == "runtime-run") {
60 throw std::runtime_error("This is a std::runtime_error");
61 } else if (what == "abort-run") {
62 abort();
63 } else if (what == "framework-run") {
64 throw o2::framework::runtime_error("This is a o2::framework::runtime_error");
65 }
66 O2_SIGNPOST_EVENT_EMIT_ERROR(crash_test, ri, "Run", "Unknown option for crash-type: %{public}s.", what.c_str());
67 O2_SIGNPOST_END(crash_test, ri, "Init", "Run Done");
68 exit(1);
69 });
70 })};
71}
72
73// This is how you can define your processing in a declarative way
75{
76 auto crashType = config.options().get<std::string>("crash-type");
78 .name = "deliberately-crashing",
79 .outputs = {OutputSpec{{"a1"}, "TST", "A1"}},
80 .algorithm = AlgorithmSpec{simpleCrashingSource(crashType)}};
82 .name = "B",
83 .inputs = {InputSpec{"x", "TST", "A1", Lifetime::Timeframe}},
84 .algorithm = AlgorithmSpec{adaptStateless([](ProcessingContext&) {})}};
85
87}
88
#define O2_SIGNPOST_EVENT_EMIT_ERROR(log, id, name, format,...)
Definition Signpost.h:515
#define O2_DECLARE_DYNAMIC_LOG(name)
Definition Signpost.h:473
#define O2_SIGNPOST_ID_FROM_POINTER(name, log, pointer)
Definition Signpost.h:489
#define O2_SIGNPOST_END(log, id, name, format,...)
Definition Signpost.h:540
#define O2_SIGNPOST_EVENT_EMIT(log, id, name, format,...)
Definition Signpost.h:495
#define O2_SIGNPOST_START(log, id, name, format,...)
Definition Signpost.h:534
ConfigParamRegistry & options() const
ServiceRegistryRef services()
Definition InitContext.h:34
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
WorkflowSpec concat(T &&t, ARGS &&... args)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
RuntimeErrorRef runtime_error(const char *)
std::vector< DataProcessorSpec > WorkflowSpec
AlgorithmSpec::ProcessCallback adaptStateless(LAMBDA l)
AlgorithmSpec::InitCallback adaptStateful(LAMBDA l)
Configurable< std::string > crashType
AlgorithmSpec simpleCrashingSource(std::string const &what)
WorkflowSpec defineDataProcessing(ConfigContext const &config)
This function hooks up the the workflow specifications into the DPL driver.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"