Project
Loading...
Searching...
No Matches
test_CompletionPolicies.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.
11
15
16#include <cassert>
17#include <chrono>
18#include <thread>
19#include <vector>
20
21using namespace o2::framework;
22
23void customize(std::vector<CompletionPolicy>& policies)
24{
25 std::vector<CompletionPolicy> result{
26 CompletionPolicyHelpers::defineByName("discard", CompletionPolicy::CompletionOp::Discard),
27 CompletionPolicyHelpers::defineByName("process", CompletionPolicy::CompletionOp::Process),
28 CompletionPolicyHelpers::defineByName("wait", CompletionPolicy::CompletionOp::Wait),
29 CompletionPolicyHelpers::defineByName("consume", CompletionPolicy::CompletionOp::Consume)};
30 policies.swap(result);
31}
32
35#include "Framework/Logger.h"
38#include <vector>
39
40// This is a simple consumer / producer workflow where both are
41// stateful, i.e. they have context which comes from their initialization.
43{
44 return WorkflowSpec{
46 "hearthbeat",
47 {},
48 {OutputSpec{{"out1"}, "TST", "TST", 0},
49 OutputSpec{{"out2"}, "TST", "TST", 1}},
51 [](ProcessingContext& ctx) {
52 // We deliberately make only out1 to test that
53 // the policies for the following dataprocessors are
54 // actually respected.
55 ctx.outputs().make<int>(OutputRef{"out1"}, 1);
56 std::this_thread::sleep_for(std::chrono::seconds(1));
57 }}},
59 "discard",
60 {
61 InputSpec{"in1", "TST", "TST", 0},
62 InputSpec{"in2", "TST", "TST", 1},
63 },
64 {},
66 [](ProcessingContext& ctx) {
67 LOG(error) << "Should have not been invoked";
68 // We deliberately make only out1 to test that
69 // the policies for the following dataprocessors are
70 // actually respected.
71 }}},
73 "does-use",
74 {InputSpec{"in1", "TST", "TST", 0}},
75 {},
77 [](ProcessingContext& ctx) {
78 // Since this shares a dependency with "discard",
79 // it should be forwarded the messages as soon as the former
80 // discards them.
81 }}},
82 };
83}
GLuint64EXT * result
Definition glcorearb.h:5662
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
static CompletionPolicy defineByName(std::string const &name, CompletionPolicy::CompletionOp op)
void customize(std::vector< CompletionPolicy > &policies)
WorkflowSpec defineDataProcessing(ConfigContext const &config)
This function hooks up the the workflow specifications into the DPL driver.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"