IceFlow NDN-based stream processing library written in C++
Loading...
Searching...
No Matches
dag-parser.hpp
1/*
2 * Copyright 2024 The IceFlow Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 */
18
19#ifndef DAGPARSER_HPP
20#define DAGPARSER_HPP
21
22#include <fstream>
23#include <iostream>
24#include <nlohmann/json.hpp>
25#include <optional>
26#include <stdexcept>
27#include <string>
28#include <vector>
29
30using json = nlohmann::json;
31
32namespace iceflow {
33
34// Structs for resources, container, scaling parameters, and communication task
35struct Resources {
36 uint32_t cpu;
37 uint32_t memory;
38};
39
40struct Container {
41 std::string image;
42 std::string tag;
43 Resources resources;
44};
45
47 uint32_t taskComplexity;
48};
49
50struct Edge {
51 std::string id;
52 std::string target;
53 uint32_t maxPartitions;
54 nlohmann::json::object_t applicationConfiguration;
55};
56
60struct Node {
61 std::string task;
62 std::string name;
63 std::string description;
64 std::string executor;
65 Container container;
66 ScalingParameters scalingParameters;
67 std::vector<Edge> downstream;
68 nlohmann::json::object_t applicationConfiguration;
69};
70
74class DAGParser {
75public:
76 DAGParser(const std::string &appName, const std::vector<Node> &nodes);
77
78 static DAGParser parseFromFile(const std::string &filename);
79
80 const std::vector<Node> &getNodes();
81
82 const std::string &getApplicationName();
83
84 const Node &findNodeByName(const std::string &nodeName);
85
86 const Edge &findEdgeByName(const std::string &edgeId);
87
88 std::vector<std::pair<const Node &, const Edge &>>
89 findUpstreamEdges(const std::string &taskId);
90
91 std::vector<std::pair<const Node &, const Edge &>>
92 findUpstreamEdges(const Node &node);
93
94private:
95 std::string m_applicationName;
96 std::vector<Node> nodes;
97};
98
99} // namespace iceflow
100
101#endif // DAGPARSER_HPP
Definition dag-parser.hpp:74
Definition dag-parser.hpp:40
Definition dag-parser.hpp:50
Definition dag-parser.hpp:60
Definition dag-parser.hpp:35
Definition dag-parser.hpp:46