|
| 1 | +/* |
| 2 | + * LSST Data Management System |
| 3 | + * |
| 4 | + * This product includes software developed by the |
| 5 | + * LSST Project (http://www.lsst.org/). |
| 6 | + * |
| 7 | + * This program is free software: you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU General Public License as published by |
| 9 | + * the Free Software Foundation, either version 3 of the License, or |
| 10 | + * (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the LSST License Statement and |
| 18 | + * the GNU General Public License along with this program. If not, |
| 19 | + * see <http://www.lsstcorp.org/LegalNotices/>. |
| 20 | + */ |
| 21 | +#ifndef LSST_QSERV_REPLICA_PROTOCOL_H |
| 22 | +#define LSST_QSERV_REPLICA_PROTOCOL_H |
| 23 | + |
| 24 | +// System headers |
| 25 | +#include <string> |
| 26 | + |
| 27 | +// Third party headers |
| 28 | +#include "nlohmann/json.hpp" |
| 29 | + |
| 30 | +// This header declarations |
| 31 | +namespace lsst::qserv::replica::protocol { |
| 32 | + |
| 33 | +/// Subtypes of the SQL requests. |
| 34 | +enum class SqlRequestType : int { |
| 35 | + |
| 36 | + QUERY = 0, |
| 37 | + CREATE_DATABASE = 1, |
| 38 | + DROP_DATABASE = 2, |
| 39 | + ENABLE_DATABASE = 3, ///< in Qserv |
| 40 | + DISABLE_DATABASE = 4, ///< in Qserv |
| 41 | + GRANT_ACCESS = 5, |
| 42 | + CREATE_TABLE = 6, |
| 43 | + DROP_TABLE = 7, |
| 44 | + REMOVE_TABLE_PARTITIONING = 8, |
| 45 | + DROP_TABLE_PARTITION = 9, |
| 46 | + GET_TABLE_INDEX = 10, |
| 47 | + CREATE_TABLE_INDEX = 11, |
| 48 | + DROP_TABLE_INDEX = 12, |
| 49 | + ALTER_TABLE = 13, |
| 50 | + TABLE_ROW_STATS = 14 |
| 51 | +}; |
| 52 | + |
| 53 | +/// @return the string representation of the SQL request type |
| 54 | +std::string toString(SqlRequestType status); |
| 55 | + |
| 56 | +/// Types of the table indexes specified in the index management requests requests. |
| 57 | +enum class SqlIndexSpec : int { DEFAULT = 1, UNIQUE = 2, FULLTEXT = 3, SPATIAL = 4 }; |
| 58 | + |
| 59 | +/// Status values returned by all request related to operations with |
| 60 | +/// replicas. Request management operations always return messages whose types |
| 61 | +/// match the return types of the corresponding (original) replica-related requests. |
| 62 | +/// Service management requests have their own set of status values. |
| 63 | +/// |
| 64 | +enum class Status : int { |
| 65 | + CREATED = 0, |
| 66 | + SUCCESS = 1, |
| 67 | + QUEUED = 2, |
| 68 | + IN_PROGRESS = 3, |
| 69 | + IS_CANCELLING = 4, |
| 70 | + BAD = 5, |
| 71 | + FAILED = 6, |
| 72 | + CANCELLED = 7 |
| 73 | +}; |
| 74 | + |
| 75 | +enum class StatusExt : int { |
| 76 | + NONE = 0, ///< Unspecified problem. |
| 77 | + INVALID_PARAM = 1, ///< Invalid parameter(s) of a request. |
| 78 | + INVALID_ID = 2, ///< An invalid request identifier. |
| 79 | + FOLDER_STAT = 4, ///< Failed to obtain fstat() for a folder. |
| 80 | + FOLDER_CREATE = 5, ///< Failed to create a folder. |
| 81 | + FILE_STAT = 6, ///< Failed to obtain fstat() for a file. |
| 82 | + FILE_SIZE = 7, ///< Failed to obtain a size of a file. |
| 83 | + FOLDER_READ = 8, ///< Failed to read the contents of a folder. |
| 84 | + FILE_READ = 9, ///< Failed to read the contents of a file. |
| 85 | + FILE_ROPEN = 10, ///< Failed to open a remote file. |
| 86 | + FILE_CREATE = 11, ///< Failed to create a file. |
| 87 | + FILE_OPEN = 12, ///< Failed to open a file. |
| 88 | + FILE_RESIZE = 13, ///< Failed to resize a file. |
| 89 | + FILE_WRITE = 14, ///< Failed to write into a file. |
| 90 | + FILE_COPY = 15, ///< Failed to copy a file. |
| 91 | + FILE_DELETE = 16, ///< Failed to delete a file. |
| 92 | + FILE_RENAME = 17, ///< Failed to rename a file. |
| 93 | + FILE_EXISTS = 18, ///< File already exists. |
| 94 | + SPACE_REQ = 19, ///< Space availability check failed. |
| 95 | + NO_FOLDER = 20, ///< Folder doesn't exist. |
| 96 | + NO_FILE = 21, ///< File doesn't exist. |
| 97 | + NO_ACCESS = 22, ///< No access to a file or a folder. |
| 98 | + NO_SPACE = 23, ///< No space left on a device as required by an operation. |
| 99 | + FILE_MTIME = 24, ///< Get/set 'mtime' operation failed. |
| 100 | + MYSQL_ERROR = 25, ///< General MySQL error (other than any specific ones listed here). |
| 101 | + LARGE_RESULT = 26, ///< Result exceeds a limit set in a request. |
| 102 | + NO_SUCH_TABLE = 27, ///< No table found while performing a MySQL operation. |
| 103 | + NOT_PARTITIONED_TABLE = 28, ///< The table is not MySQL partitioned as it was expected. |
| 104 | + NO_SUCH_PARTITION = 29, ///< No MySQL partition found in a table as it was expected. |
| 105 | + MULTIPLE = 30, ///< Multiple unspecified errors encountered when processing a request. |
| 106 | + OTHER_EXCEPTION = 31, ///< Other exception not listed here. |
| 107 | + FOREIGN_INSTANCE = 32, ///< Detected a request from a Controller serving an unrelated Qserv. |
| 108 | + DUPLICATE_KEY = 33, ///< Duplicate key found when creating an index or altering a table schema. |
| 109 | + CANT_DROP_KEY = 34 ///< Can't drop a field or a key which doesn't exist. |
| 110 | +}; |
| 111 | + |
| 112 | +/// @return the string representation of the status |
| 113 | +std::string toString(Status status); |
| 114 | + |
| 115 | +/// @return the string representation of the extended status |
| 116 | +std::string toString(StatusExt extendedStatus); |
| 117 | + |
| 118 | +/// @return the string representation of the full status |
| 119 | +std::string toString(Status status, StatusExt extendedStatus); |
| 120 | + |
| 121 | +/// Status of a service. |
| 122 | +enum class ServiceState : int { SUSPEND_IN_PROGRESS = 0, SUSPENDED = 1, RUNNING = 2 }; |
| 123 | + |
| 124 | +/// @return the string representation of the service state |
| 125 | +std::string toString(ServiceState state); |
| 126 | + |
| 127 | +/// The header to be sent with the requests processed through the worker's queueing system. |
| 128 | +struct QueuedRequestHdr { |
| 129 | + std::string id; |
| 130 | + int priority; |
| 131 | + unsigned int timeout; |
| 132 | + QueuedRequestHdr(std::string const& id_, int priority_, unsigned int timeout_) |
| 133 | + : id(id_), priority(priority_), timeout(timeout_) {} |
| 134 | + nlohmann::json toJson() const { return {{"id", id}, {"priority", priority}, {"timeout", timeout}}; }; |
| 135 | +}; |
| 136 | + |
| 137 | +} // namespace lsst::qserv::replica::protocol |
| 138 | + |
| 139 | +#endif // LSST_QSERV_REPLICA_PROTOCOL_H |
0 commit comments