Commit c1055fc6 authored by Stanislav Bohm's avatar Stanislav Bohm

RF: Basic tasks moved from worker to libloom

parent f30ccb59
......@@ -8,6 +8,16 @@ add_library(libloom
data/array.cpp
data/index.h
data/index.cpp
tasks/basetasks.cpp
tasks/basetasks.h
tasks/rawdatatasks.cpp
tasks/rawdatatasks.h
tasks/arraytasks.cpp
tasks/arraytasks.h
tasks/runtask.cpp
tasks/runtask.h
tasks/loomrun.pb.cc
tasks/loomrun.pb.h
connection.cpp
connection.h
worker.cpp
......
#ifndef LOOM_WORKER_ARRAYTASKS_H
#define LOOM_WORKER_ARRAYTASKS_H
#ifndef LIBLOOM_TASKS_ARRAYTASKS_H
#define LIBLOOM_TASKS_ARRAYTASKS_H
#include "libloom/taskinstance.h"
......@@ -10,4 +10,4 @@ public:
void start(loom::DataVector &inputs);
};
#endif // LOOM_WORKER_ARRAYTASKS_H
#endif // LIBLOOM_TASKS_ARRAYTASKS_H
#include "basictasks.h"
#include "basetasks.h"
//#include "libloom/log.h"
......
#ifndef LOOM_WORKER_BASICTASKS_H
#define LOOM_WORKER_BASICTASKS_H
#ifndef LIBLOOM_TASKS_BASICTASKS_H
#define LIBLOOM_TASKS_BASICTASKS_H
#include "libloom/taskinstance.h"
......@@ -18,4 +18,4 @@ public:
void start(loom::DataVector &inputs);
};
#endif // LOOM_WORKER_BASICTASKS_H
#endif // LIBLOOM_TASKS_BASICTASKS_H
#ifndef LOOM_WORKER_RAWDATATASKS_H
#define LOOM_WORKER_RAWDATATASKS_H
#ifndef LIBLOOM_TASKS_RAWDATATASKS_H
#define LIBLOOM_TASKS_RAWDATATASKS_H
#include "libloom/taskinstance.h"
......@@ -35,4 +35,4 @@ public:
};
#endif // LOOM_WORKER_RAWDATATASKS_H
#endif // LIBLOOM_TASKS_RAWDATATASKS_H
#ifndef LOOM_WORKER_RUNTASK_H
#define LOOM_WORKER_RUNTASK_H
#ifndef LIBLOOM_TASKS_RUNTASK_H
#define LIBLOOM_TASKS_RUNTASK_H
#include "libloom/taskinstance.h"
......@@ -29,4 +29,4 @@ private:
};
#endif // LOOM_WORKER_RUNTASK_H
#endif // LIBLOOM_TASKS_RUNTASK_H
......@@ -3,10 +3,16 @@
#include "utils.h"
#include "log.h"
#include "types.h"
#include "data/rawdata.h"
#include "data/array.h"
#include "data/index.h"
#include "tasks/basetasks.h"
#include "tasks/rawdatatasks.h"
#include "tasks/arraytasks.h"
#include "tasks/runtask.h"
#include <stdlib.h>
#include <sstream>
#include <unistd.h>
......@@ -78,6 +84,25 @@ Worker::Worker(uv_loop_t *loop,
resource_cpus = 1;
}
void Worker::register_basic_tasks()
{
// Base
add_task_factory<GetTask>("base/get");
add_task_factory<SliceTask>("base/slice");
// RawData
add_task_factory<ConstTask>("data/const");
add_task_factory<MergeTask>("data/merge");
add_task_factory<OpenTask>("data/open");
add_task_factory<SplitTask>("data/split");
// Arrays
add_task_factory<ArrayMakeTask>("array/make");
// Run
add_task_factory<RunTask>("run/run");
}
void Worker::_on_getaddrinfo(uv_getaddrinfo_t* handle, int status,
struct addrinfo* response) {
......
......@@ -50,6 +50,8 @@ public:
uv_loop_t *get_loop() {
return loop;
}
void register_basic_tasks();
void new_task(std::unique_ptr<Task> task);
void send_data(const std::string &address, Id id, std::shared_ptr<Data> &data, bool with_size);
......
......@@ -9,9 +9,7 @@ CLIENT_DIR=${BASE_DIR}/../client
# LIBLOOM
protoc loomcomm.proto --cpp_out=${LIBLOOM_DIR}
protoc loomplan.proto --cpp_out=${LIBLOOM_DIR}
# WORKER
protoc loomrun.proto --cpp_out=${WORKER_DIR}
protoc loomrun.proto --cpp_out=${LIBLOOM_DIR}/tasks
# CLIENT (Python)
protoc loomcomm.proto --python_out=${CLIENT_DIR}
......
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -Wall")
add_executable(loom-worker
loomrun.pb.cc
loomrun.pb.h
runtask.cpp
runtask.h
basictasks.cpp
basictasks.h
rawdatatasks.cpp
rawdatatasks.h
arraytasks.cpp
arraytasks.h
main.cpp)
target_include_directories(loom-worker PUBLIC ${PROJECT_SOURCE_DIR})
target_link_libraries(loom-worker libloom ${LIBUV_LIBRARY} pthread)
......
#include "runtask.h"
#include "basictasks.h"
#include "rawdatatasks.h"
#include "arraytasks.h"
#include "libloom/worker.h"
#include "libloom/log.h"
......@@ -111,24 +106,9 @@ int main(int argc, char **argv)
config.server_address,
config.port,
config.work_dir);
worker.register_basic_tasks();
loom::llog->info("Worker started; listening on port {}", worker.get_listen_port());
// Base
worker.add_task_factory<GetTask>("base/get");
worker.add_task_factory<SliceTask>("base/slice");
// RawData
worker.add_task_factory<ConstTask>("data/const");
worker.add_task_factory<MergeTask>("data/merge");
worker.add_task_factory<OpenTask>("data/open");
worker.add_task_factory<SplitTask>("data/split");
// Arrays
worker.add_task_factory<ArrayMakeTask>("array/make");
// Run
worker.add_task_factory<RunTask>("run/run");
worker.set_cpus(config.cpus);
uv_run(&loop, UV_RUN_DEFAULT);
uv_loop_close(&loop);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment