Verified Commit 6803d913 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Move API type defintions to types.h

parent 282b6262
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ set_property(TARGET api_rpcs PROPERTY POSITION_INDEPENDENT_CODE ON)
add_library(adm_iosched SHARED)

target_sources(adm_iosched
  PUBLIC admire.h admire.hpp
  PUBLIC admire.h types.h admire.hpp
  PRIVATE admire.cpp c_wrapper.cpp detail/impl.hpp detail/impl.cpp errors.c)

target_include_directories(adm_iosched PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
+2 −387
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "types.h"

#ifdef __cplusplus
extern "C" {
@@ -43,393 +44,7 @@ extern "C" {
/* Public type definitions and type-related functions                         */
/******************************************************************************/

/* Error return codes */
typedef enum {
    ADM_SUCCESS = 0,
    ADM_ESNAFU,
    ADM_EBADARGS,
    ADM_ENOMEM,
    ADM_EOTHER,
    ADM_ERR_MAX = 512
} ADM_return_t;

/* A server */
typedef struct adm_server* ADM_server_t;

/**
 * Initialize a server from a user-provided name/address.
 *
 * @remark Servers need to be freed by calling ADM_server_destroy().
 *
 * @param[in] protocol The protocol that will be used to access the server.
 * @param[in] address The address of server.
 * @return A valid ADM_server_t if successful or NULL in case of failure.
 */
ADM_server_t
ADM_server_create(const char* protocol, const char* address);

/**
 * Destroy a server created by ADM_server_create().
 *
 * @param[in] server A pointer to a ADM_server_t
 * @return ADM_SUCCESS or corresponding ADM error code
 */
ADM_return_t
ADM_server_destroy(ADM_server_t server);

/* A node */
typedef struct adm_node* ADM_node_t;

/**
 * Initialize a node from a user-provided hostname/address.
 *
 * @remark Nodes need to be freed by calling ADM_server_destroy().
 *
 * @param[in] hostname The hostname of the node.
 * @return A valid ADM_server_t if successful or NULL in case of failure.
 */
ADM_node_t
ADM_node_create(const char* hostname);

/**
 * Destroy a node created by ADM_node_create().
 *
 * @param[in] node A valid ADM_node_t
 * @return ADM_SUCCESS or corresponding ADM error code
 */
ADM_return_t
ADM_node_destroy(ADM_node_t node);


/** A dataset */
typedef struct adm_dataset* ADM_dataset_t;

/**
 * Create a dataset from a user-provided id (e.g. a path for POSIX-like file
 * systems or key for key-value stores).
 *
 * @remark Datasets need to be freed by calling ADM_dataset_destroy().
 *
 * @param[in] id The id for the dataset.
 * @return A valid ADM_dataset_handle_t if successful or NULL in case of
 * failure.
 */
ADM_dataset_t
ADM_dataset_create(const char* id);

/**
 * Destroy a dataset created by ADM_dataset_create().
 *
 * @param[in] dataset A valid ADM_dataset_t
 * @return ADM_SUCCESS or corresponding ADM error code
 */
ADM_return_t
ADM_dataset_destroy(ADM_dataset_t dataset);

/* A job handle */
typedef struct adm_job* ADM_job_t;

/* The scope affected by a QoS limit */
typedef enum {
    ADM_QOS_SCOPE_DATASET,
    ADM_QOS_SCOPE_NODE,
    ADM_QOS_SCOPE_JOB
} ADM_qos_scope_t;

/** The class of QoS limit applied to a scope */
typedef enum { ADM_QOS_CLASS_BANDWIDTH, ADM_QOS_CLASS_IOPS } ADM_qos_class_t;

/** An ADMIRE entity upon which QoS can be defined */
typedef struct adm_qos_entity* ADM_qos_entity_t;

/**
 * Create a QoS entity given a scope, a node, a dataset, or a job.
 *
 * @remark QoS entities need to be freed by calling ADM_qos_entity_destroy().
 *
 * @param scope The scope of the entity, i.e. ADM_QOS_SCOPE_DATASET,
 * ADM_QOS_SCOPE_NODE, or ADM_QOS_SCOPE_JOB.
 * @param ... A single argument with data from either a ADM_dataset_t,
 * ADM_node_t, or ADM_job_t variable. The argument must correspond properly
 * to the scope provided.
 * @return A valid ADM_qos_entity_t if successful or NULL in case of failure.
 */
ADM_qos_entity_t
ADM_qos_entity_create(ADM_qos_scope_t scope, ...);

/**
 * Destroy a QoS entity created by ADM_qos_entity_create().
 *
 * @param[in] entity A valid ADM_qos_entity_t
 * @return ADM_SUCCESS or corresponding ADM error code
 */
ADM_return_t
ADM_qos_entity_destroy(ADM_qos_entity_t entity);

/** A QoS limit */
typedef struct adm_qos_limit* ADM_qos_limit_t;

/**
 * Create a QoS limit given an entity and a QoS class.
 *
 * @remark QoS limits need to be freed by calling ADM_qos_limit_destroy().
 *
 * @param[in] entity The entity upon which the QoS limit should be enforced.
 * @param[in] cls The QoS restriction class to apply.
 * @param[in] value The limit's value.
 * @return A valid ADM_qos_limit_t if successful or NULL in case of failure.
 */
ADM_qos_limit_t
ADM_qos_limit_create(ADM_qos_entity_t entity, ADM_qos_class_t cls,
                     uint64_t value);

/**
 * Destroy a QoS limit created by ADM_qos_limit_create().
 *
 * @param[in] limit A valid ADM_qos_limit_t
 * @return ADM_SUCCESS or corresponding ADM error code
 */
ADM_return_t
ADM_qos_limit_destroy(ADM_qos_limit_t limit);


/** A transfer mapping */
typedef enum {
    ADM_MAPPING_ONE_TO_ONE,
    ADM_MAPPING_ONE_TO_N,
    ADM_MAPPING_N_TO_N
} ADM_transfer_mapping_t;

/** A handle to a created transfer */
typedef struct adm_transfer* ADM_transfer_t;

/** Information about a dataset */
typedef struct adm_dataset_info* ADM_dataset_info_t;

/**
 * Create a dataset from a user-provided id (e.g. a path for POSIX-like file
 * systems or key for key-value stores).
 *
 * @remark Datasets need to be freed by calling ADM_dataset_info_destroy().
 *
 * @return A valid ADM_DATASET_INFO if successful or NULL in case of
 * failure.
 */
ADM_dataset_info_t
ADM_dataset_info_create();

/**
 * Destroy a dataset created by ADM_dataset_info_create().
 *
 * @param[in] dataset A valid ADM_dataset_info_t
 * @return ADM_SUCCESS or corresponding ADM error code
 */
ADM_return_t
ADM_dataset_info_destroy(ADM_dataset_info_t dataset_info);

typedef enum {
    ADM_STORAGE_GEKKOFS,
    ADM_STORAGE_DATACLAY,
    ADM_STORAGE_EXPAND,
    ADM_STORAGE_HERCULES,
    ADM_STORAGE_LUSTRE,
    ADM_STORAGE_GPFS,
} ADM_storage_type_t;

/** A storage tier */
typedef struct adm_storage* ADM_storage_t;

/**
 * Create a ADM_STORAGE to represent a storage tier.
 *
 * @remark ADM_STORAGEs need to be freed by calling ADM_storage_destroy().
 *
 * @param[in] id An identifier for the storage tier
 * @param[in] type The type for the storage tier being created.
 * @param[in] ctx Some specific context information for the storage tier or
 * NULL if none is required. For instance, an adhoc storage system may find it
 * useful to provide an ADM_adhoc_context_t describing the instance.
 * @return A valid ADM_STORAGE if successful, or NULL in case of failure.
 */
ADM_storage_t
ADM_storage_create(const char* id, ADM_storage_type_t type, void* ctx);

/**
 * Destroy a ADM_STORAGE created by ADM_storage_destroy().
 *
 * @param[in] storage A valid ADM_STORAGE
 * @return ADM_SUCCESS or corresponding ADM error code
 */
ADM_return_t
ADM_storage_destroy(ADM_storage_t storage);

/** Information about resources assigned to a storage tier */
typedef struct adm_storage_resources* ADM_storage_resources_t;

/**
 * Create an ADM_STORAGE_RESOURCES from information about storage resources.
 *
 * @remark ADM_STORAGE_RESOURCES need to be freed by calling
 * ADM_storage_resources_destroy().
 *
 * @return A valid ADM_STORAGE_RESOURCES, or NULL in case of failure
 */
ADM_storage_resources_t
ADM_storage_resources_create();

/**
 * Destroy a ADM_STORAGE_RESOURCES created by ADM_storage_resources_create().
 *
 * @param[in] res A valid ADM_STORAGE
 * @return ADM_SUCCESS or corresponding ADM error code
 */
ADM_return_t
ADM_storage_resources_destroy(ADM_storage_resources_t res);

/** A transfer priority */
typedef int ADM_transfer_priority_t;

/** A data operation */
typedef struct adm_data_operation* ADM_data_operation_t;

/**
 * Create an ADM_DATA_OPERATION from information about storage resources.
 *
 * @remark ADM_DATA_OPERATION need to be freed by calling
 * ADM_storage_resources_destroy().
 *
 * @return A valid ADM_DATA_OPERATION, or NULL in case of failure
 */
ADM_data_operation_t
ADM_data_operation_create();

/**
 * Destroy a ADM_DATA_OPERATION created by ADM_storage_resources_create().
 *
 * @param[in] op A valid ADM_DATA_OPERATION
 * @return ADM_SUCCESS or corresponding ADM error code
 */
ADM_return_t
ADM_data_operation_destroy(ADM_data_operation_t op);

/** A data operation status */
typedef struct {
    // TODO: empty for now
} ADM_data_operation_status_t;

/** I/O stats from a job */
typedef struct {
    // TODO: empty for now
} ADM_job_stats_t;

/** Execution modes for an adhoc storage system */
typedef enum {
    ADM_ADHOC_MODE_IN_JOB_SHARED,
    ADM_ADHOC_MODE_IN_JOB_DEDICATED,
    ADM_ADHOC_MODE_SEPARATE_NEW,
    ADM_ADHOC_MODE_SEPARATE_EXISTING
} ADM_adhoc_mode_t;

/** Access modes for an adhoc storage system */
typedef enum {
    ADM_ADHOC_ACCESS_RDONLY,
    ADM_ADHOC_ACCESS_WRONLY,
    ADM_ADHOC_ACCESS_RDWR,
} ADM_adhoc_access_t;

/** Abstract type to represent data distributions for adhoc storage systems */
typedef struct adm_adhoc_data_distribution* ADM_adhoc_data_distribution_t;

/** The context for an  adhoc storage instance */
typedef struct adm_adhoc_context* ADM_adhoc_context_t;

/**
 * Create an ADM_ADHOC_CONTEXT from information about how an adhoc storage
 * instance should be executed.
 *
 * @remark ADM_ADHOC_CONTEXTs need to be freed by calling
 * ADM_adhoc_context_destroy().
 *
 * @param[in] exec_mode The adhoc storage system execution mode
 * @param[in] access_type The adhoc storage system execution type
 * @param[in] nodes The number of nodes for the adhoc storage system
 * @param[in] walltime The adhoc storage system walltime
 * @param[in] should_flush Whether the adhoc storage system should flush data in
 * the background
 * @return A valid ADM_ADHOC_CONTEXT if successful. NULL otherwise.
 */
ADM_adhoc_context_t
ADM_adhoc_context_create(ADM_adhoc_mode_t exec_mode,
                         ADM_adhoc_access_t access_type, uint32_t nodes,
                         uint32_t walltime, bool should_flush);

/**
 * Destroy an ADM_ADHOC_CONTEXT created by ADM_adhoc_context_create().
 *
 * @param[in] ctx A valid ADM_ADHOC_CONTEXT
 * @return ADM_SUCCESS or corresponding ADM error code
 */
ADM_return_t
ADM_adhoc_context_destroy(ADM_adhoc_context_t ctx);

/** The context for a parallel file system storage */
typedef struct adm_pfs_context* ADM_pfs_context_t;

/**
 * Create an ADM_PFS_CONTEXT from information about how a PFS is configured.
 *
 * @remark ADM_PFS_CONTEXTs need to be freed by calling
 * ADM_pfs_context_destroy().
 *
 * @param[in] mountpoint The PFS mount point
 * @return A valid ADM_PFS_CONTEXT if successful. NULL otherwise.
 */
ADM_pfs_context_t
ADM_pfs_context_create(const char* mountpoint);

/**
 * Destroy an ADM_PFS_CONTEXT created by ADM_pfs_context_create().
 *
 * @param[in] ctx A valid ADM_PFS_CONTEXT
 * @return ADM_SUCCESS or corresponding ADM error code
 */
ADM_return_t
ADM_pfs_context_destroy(ADM_pfs_context_t ctx);

/** The I/O requirements for a job */
typedef struct adm_job_requirements* ADM_job_requirements_t;

/**
 * Create a JOB_REQUIREMENTS from user-provided information.
 *
 * @remark JOB_REQUIREMENTS created by this function need to be freed by calling
 * ADM_job_requirements_destroy().
 *
 * @param[in] inputs An array of DATASET_DESCRIPTORS describing the input
 * information required by the job.
 * @param[in] inputs_len The number of DATASET_DESCRIPTORS stored in inputs.
 * @param[in] outputs An array of DATASET_DESCRIPTORS describing the output
 * information generated by the job.
 * @param[in] outputs_len The number of DATASET_DESCRIPTORS stored in outputs.
 * @param[in] storage An optional ADHOC_DESCRIPTOR describing the adhoc
 * storage system required by the job (can be set to NULL if no adhoc storage
 * system is required).
 * @return A valid ADM_job_requirements_t if sucessfull or NULL in case of
 * failure.
 */
ADM_job_requirements_t
ADM_job_requirements_create(ADM_dataset_t inputs[], size_t inputs_len,
                            ADM_dataset_t outputs[], size_t outputs_len,
                            ADM_storage_t storage);

/**
 * Destroy a ADM_job_requirements_t created by ADM_job_requirements_create().
 *
 * @param[in] reqs The ADM_job_requirements_t to destroy.
 * @return ADM_SUCCESS or corresponding error code.
 */
ADM_return_t
ADM_job_requirements_destroy(ADM_job_requirements_t reqs);
// See types.h


/******************************************************************************/

src/lib/types.h

0 → 100644
+498 −0

File added.

Preview size limit exceeded, changes collapsed.