Skip to content

Commit

Permalink
forgot to add the task
Browse files Browse the repository at this point in the history
  • Loading branch information
JaimeCernuda committed Oct 18, 2023
1 parent f86c32b commit f1b9913
Show file tree
Hide file tree
Showing 8 changed files with 544 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tasks/coeus_mdm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#------------------------------------------------------------------------------
# Build Hrun Admin Task Library
#------------------------------------------------------------------------------
include_directories(include)
add_subdirectory(src)

#-----------------------------------------------------------------------------
# Install HRUN Admin Task Library Headers
#-----------------------------------------------------------------------------
install(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX})
83 changes: 83 additions & 0 deletions tasks/coeus_mdm/include/coeus_mdm/coeus_mdm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Distributed under BSD 3-Clause license. *
* Copyright by The HDF Group. *
* Copyright by the Illinois Institute of Technology. *
* All rights reserved. *
* *
* This file is part of Hermes. The full Hermes copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the top directory. If you do not *
* have access to the file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef HRUN_coeus_mdm_H_
#define HRUN_coeus_mdm_H_

#include "coeus_mdm_tasks.h"

namespace hrun::coeus_mdm {

/** Create coeus_mdm requests */
class Client : public TaskLibClient {

public:
/** Default constructor */
Client() = default;

/** Destructor */
~Client() = default;

/** Async create a task state */
HSHM_ALWAYS_INLINE
LPointer<ConstructTask> AsyncCreate(const TaskNode &task_node,
const DomainId &domain_id,
const std::string &state_name,
const std::string &db_path) {
id_ = TaskStateId::GetNull();
QueueManagerInfo &qm = HRUN_CLIENT->server_config_.queue_manager_;
std::vector<PriorityInfo> queue_info = {
{1, 1, qm.queue_depth_, 0},
{1, 1, qm.queue_depth_, QUEUE_LONG_RUNNING},
{qm.max_lanes_, qm.max_lanes_, qm.queue_depth_, QUEUE_LOW_LATENCY}
};
return HRUN_ADMIN->AsyncCreateTaskState<ConstructTask>(
task_node, domain_id, state_name, id_, queue_info, db_path);
}
HRUN_TASK_NODE_ROOT(AsyncCreate)
template<typename ...Args>
HSHM_ALWAYS_INLINE
void CreateRoot(Args&& ...args) {
LPointer<ConstructTask> task =
AsyncCreateRoot(std::forward<Args>(args)...);
task->Wait();
id_ = task->id_;
queue_id_ = QueueId(id_);
HRUN_CLIENT->DelTask(task);
}

/** Destroy task state + queue */
HSHM_ALWAYS_INLINE
void DestroyRoot(const DomainId &domain_id) {
HRUN_ADMIN->DestroyTaskStateRoot(domain_id, id_);
}

/** Call a custom method */
HSHM_ALWAYS_INLINE
void AsyncMdm_insertConstruct(Mdm_insertTask *task,
const TaskNode &task_node,
const DomainId &domain_id,
DbOperation db_op) {
HRUN_CLIENT->ConstructTask<Mdm_insertTask>(
task, task_node, domain_id, id_, db_op);
}
HSHM_ALWAYS_INLINE
void Mdm_insertRoot(const DomainId &domain_id, DbOperation db_op) {
LPointer<hrunpq::TypedPushTask<Mdm_insertTask>> task = AsyncMdm_insertRoot(domain_id, db_op);
// task.ptr_->Wait();
}
HRUN_TASK_NODE_PUSH_ROOT(Mdm_insert);
};

} // namespace hrun

#endif // HRUN_coeus_mdm_H_
197 changes: 197 additions & 0 deletions tasks/coeus_mdm/include/coeus_mdm/coeus_mdm_lib_exec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
#ifndef HRUN_COEUS_MDM_LIB_EXEC_H_
#define HRUN_COEUS_MDM_LIB_EXEC_H_

/** Execute a task */
void Run(u32 method, Task *task, RunContext &rctx) override {
switch (method) {
case Method::kConstruct: {
Construct(reinterpret_cast<ConstructTask *>(task), rctx);
break;
}
case Method::kDestruct: {
Destruct(reinterpret_cast<DestructTask *>(task), rctx);
break;
}
case Method::kMdm_insert: {
Mdm_insert(reinterpret_cast<Mdm_insertTask *>(task), rctx);
break;
}
}
}
/** Delete a task */
void Del(u32 method, Task *task) override {
switch (method) {
case Method::kConstruct: {
HRUN_CLIENT->DelTask(reinterpret_cast<ConstructTask *>(task));
break;
}
case Method::kDestruct: {
HRUN_CLIENT->DelTask(reinterpret_cast<DestructTask *>(task));
break;
}
case Method::kMdm_insert: {
HRUN_CLIENT->DelTask(reinterpret_cast<Mdm_insertTask *>(task));
break;
}
}
}
/** Duplicate a task */
void Dup(u32 method, Task *orig_task, std::vector<LPointer<Task>> &dups) override {
switch (method) {
case Method::kConstruct: {
hrun::CALL_DUPLICATE(reinterpret_cast<ConstructTask*>(orig_task), dups);
break;
}
case Method::kDestruct: {
hrun::CALL_DUPLICATE(reinterpret_cast<DestructTask*>(orig_task), dups);
break;
}
case Method::kMdm_insert: {
hrun::CALL_DUPLICATE(reinterpret_cast<Mdm_insertTask*>(orig_task), dups);
break;
}
}
}
/** Register the duplicate output with the origin task */
void DupEnd(u32 method, u32 replica, Task *orig_task, Task *dup_task) override {
switch (method) {
case Method::kConstruct: {
hrun::CALL_DUPLICATE_END(replica, reinterpret_cast<ConstructTask*>(orig_task), reinterpret_cast<ConstructTask*>(dup_task));
break;
}
case Method::kDestruct: {
hrun::CALL_DUPLICATE_END(replica, reinterpret_cast<DestructTask*>(orig_task), reinterpret_cast<DestructTask*>(dup_task));
break;
}
case Method::kMdm_insert: {
hrun::CALL_DUPLICATE_END(replica, reinterpret_cast<Mdm_insertTask*>(orig_task), reinterpret_cast<Mdm_insertTask*>(dup_task));
break;
}
}
}
/** Ensure there is space to store replicated outputs */
void ReplicateStart(u32 method, u32 count, Task *task) override {
switch (method) {
case Method::kConstruct: {
hrun::CALL_REPLICA_START(count, reinterpret_cast<ConstructTask*>(task));
break;
}
case Method::kDestruct: {
hrun::CALL_REPLICA_START(count, reinterpret_cast<DestructTask*>(task));
break;
}
case Method::kMdm_insert: {
hrun::CALL_REPLICA_START(count, reinterpret_cast<Mdm_insertTask*>(task));
break;
}
}
}
/** Determine success and handle failures */
void ReplicateEnd(u32 method, Task *task) override {
switch (method) {
case Method::kConstruct: {
hrun::CALL_REPLICA_END(reinterpret_cast<ConstructTask*>(task));
break;
}
case Method::kDestruct: {
hrun::CALL_REPLICA_END(reinterpret_cast<DestructTask*>(task));
break;
}
case Method::kMdm_insert: {
hrun::CALL_REPLICA_END(reinterpret_cast<Mdm_insertTask*>(task));
break;
}
}
}
/** Serialize a task when initially pushing into remote */
std::vector<DataTransfer> SaveStart(u32 method, BinaryOutputArchive<true> &ar, Task *task) override {
switch (method) {
case Method::kConstruct: {
ar << *reinterpret_cast<ConstructTask*>(task);
break;
}
case Method::kDestruct: {
ar << *reinterpret_cast<DestructTask*>(task);
break;
}
case Method::kMdm_insert: {
ar << *reinterpret_cast<Mdm_insertTask*>(task);
break;
}
}
return ar.Get();
}
/** Deserialize a task when popping from remote queue */
TaskPointer LoadStart(u32 method, BinaryInputArchive<true> &ar) override {
TaskPointer task_ptr;
switch (method) {
case Method::kConstruct: {
task_ptr.ptr_ = HRUN_CLIENT->NewEmptyTask<ConstructTask>(task_ptr.shm_);
ar >> *reinterpret_cast<ConstructTask*>(task_ptr.ptr_);
break;
}
case Method::kDestruct: {
task_ptr.ptr_ = HRUN_CLIENT->NewEmptyTask<DestructTask>(task_ptr.shm_);
ar >> *reinterpret_cast<DestructTask*>(task_ptr.ptr_);
break;
}
case Method::kMdm_insert: {
task_ptr.ptr_ = HRUN_CLIENT->NewEmptyTask<Mdm_insertTask>(task_ptr.shm_);
ar >> *reinterpret_cast<Mdm_insertTask*>(task_ptr.ptr_);
break;
}
}
return task_ptr;
}
/** Serialize a task when returning from remote queue */
std::vector<DataTransfer> SaveEnd(u32 method, BinaryOutputArchive<false> &ar, Task *task) override {
switch (method) {
case Method::kConstruct: {
ar << *reinterpret_cast<ConstructTask*>(task);
break;
}
case Method::kDestruct: {
ar << *reinterpret_cast<DestructTask*>(task);
break;
}
case Method::kMdm_insert: {
ar << *reinterpret_cast<Mdm_insertTask*>(task);
break;
}
}
return ar.Get();
}
/** Deserialize a task when returning from remote queue */
void LoadEnd(u32 replica, u32 method, BinaryInputArchive<false> &ar, Task *task) override {
switch (method) {
case Method::kConstruct: {
ar.Deserialize(replica, *reinterpret_cast<ConstructTask*>(task));
break;
}
case Method::kDestruct: {
ar.Deserialize(replica, *reinterpret_cast<DestructTask*>(task));
break;
}
case Method::kMdm_insert: {
ar.Deserialize(replica, *reinterpret_cast<Mdm_insertTask*>(task));
break;
}
}
}
/** Get the grouping of the task */
u32 GetGroup(u32 method, Task *task, hshm::charbuf &group) override {
switch (method) {
case Method::kConstruct: {
return reinterpret_cast<ConstructTask*>(task)->GetGroup(group);
}
case Method::kDestruct: {
return reinterpret_cast<DestructTask*>(task)->GetGroup(group);
}
case Method::kMdm_insert: {
return reinterpret_cast<Mdm_insertTask*>(task)->GetGroup(group);
}
}
return -1;
}

#endif // HRUN_COEUS_MDM_METHODS_H_
9 changes: 9 additions & 0 deletions tasks/coeus_mdm/include/coeus_mdm/coeus_mdm_methods.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef HRUN_COEUS_MDM_METHODS_H_
#define HRUN_COEUS_MDM_METHODS_H_

/** The set of methods in the admin task */
struct Method : public TaskMethod {
TASK_METHOD_T kMdm_insert = kLast + 0;
};

#endif // HRUN_COEUS_MDM_METHODS_H_
1 change: 1 addition & 0 deletions tasks/coeus_mdm/include/coeus_mdm/coeus_mdm_methods.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kMdm_insert: 0
Loading

0 comments on commit f1b9913

Please sign in to comment.