34 #include <sys/types.h>
35 #include <sys/socket.h>
36 #include <netinet/in.h>
37 #include <netinet/tcp.h>
59 using namespace std::placeholders;
122 bool need_progress_report) :
123 m_Handler(
handler), m_CommonArgs(common_args), m_Object(object),
124 m_NeedProgressReport(need_progress_report)
168 m_JSONWriter(m_UTTPWriter),
169 m_ObjectBeingWritten(
eVoid),
174 m_ByeReceived(
false),
175 m_FirstMessage(
true),
176 m_WriteCreateNeedMetaDBUpdate(
false)
245 <<
"(" <<
static_cast<int>(status) <<
")");
251 <<
"(" <<
static_cast<int>(status) <<
")");
259 <<
"(" <<
static_cast<int>(status) <<
")");
299 ERR_POST(
"Incoming message parsing error. " << e <<
300 " The connection will be closed.");
307 catch (
const exception & ex) {
308 ERR_POST(
"STL exception while processing incoming message: " <<
314 ERR_POST(
"Unknown exception while processing incoming message");
402 (read_count > 0 || write_count > 0)) {
411 "The socket may have data not delivered to the client. "
412 "Error code: " << status <<
": " <<
IO_StatusStr(status));
442 ERR_POST(
"eCommunicationError:Connection pool full");
445 ERR_POST(
"eCommunicationError:Unpollable connection");
448 ERR_POST(
"eCommunicationError:Request queue full");
451 ERR_POST(
"eCommunicationError:Unknown overflow error");
464 switch (uttp_event) {
477 ERR_POST(
"Data stream parsing error. The connection will be closed.");
498 ERR_POST(
"Error extracting mandatory fields: " << ex <<
". "
499 "The connection will be closed.");
504 "Error extracting mandatory fields",
518 "The connection will be closed.");
524 "Server is shutting down",
540 "The connection will be closed.");
546 "No messages are allowed after BYE",
560 NetStorageServer_ErrorCode);
561 string error_client_message;
562 unsigned int error_sub_code;
575 (this->*processor)(message, common_args);
580 if (error_sub_code !=
588 error_client_message = ex.
what();
597 error_client_message = ex.
what();
600 &error_sub_code) ==
false) {
606 catch (
const std::exception & ex) {
609 error_client_message = ex.
what();
615 error_client_message =
"Unknown exception";
626 error_client_message,
627 error_scope, error_sub_code);
639 ERR_POST(
"Received " << data_size <<
" bytes after "
640 "an error has been reported to the client");
658 catch (
const exception & ex) {
662 " bytes to write)", start);
682 unsigned int error_sub_code;
685 &error_code, &error_sub_code) ==
false) {
702 " bytes to write)", start);
704 string message =
"Unknown exception while writing " +
753 }
catch (
const exception & ex) {
759 string message =
"Error while finalizing " +
766 unsigned int error_sub_code;
769 &error_sub_code) ==
false) {
774 AppendError(reply, error_code, message, error_scope, error_sub_code);
787 string locator = object_loc_struct.
GetLocator();
791 bool size_was_null =
false;
798 }
catch (
const exception & ex) {
800 string message =
"Error while updating meta info DB for " +
801 locator +
" upon creation: " + ex.what();
806 unsigned int error_sub_code;
809 &error_sub_code) ==
false) {
814 AppendError(reply, error_code, message, error_scope,
815 error_sub_code,
false);
817 string message =
"Unknown error while updating meta info DB "
818 "for " + locator +
" upon creation";
831 bool size_was_null =
false;
844 object_key, object_expiration,
845 individual_object_ttl);
853 individual_object_ttl),
854 object_expiration, size_was_null);
855 }
catch (
const exception & ex) {
856 string message =
"Error while updating meta info DB for " +
857 locator +
" upon writing: " + ex.what();
862 unsigned int error_sub_code;
865 &error_sub_code) ==
false) {
870 AppendError(reply, error_code, message, error_scope,
871 error_sub_code,
false);
873 string message =
"Unknown error while updating meta info DB "
874 "for " + locator +
" upon writing";
930 const char * output_buffer,
size_t output_buffer_size)
933 "Error writing message to the client. "
935 "Socket write error status: " +
IO_StatusStr(status) +
". "
937 ". Message begins with: ";
939 if (output_buffer_size > 32) {
944 CTempString buffer_head(output_buffer, output_buffer_size);
962 if (status != eIO_Closed) {
971 const char * output_buffer;
972 size_t output_buffer_size;
973 size_t bytes_written;
977 while (output_buffer_size > 0) {
1000 output_buffer, output_buffer_size);
1004 output_buffer += bytes_written;
1005 output_buffer_size -= bytes_written;
1020 setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &
val,
sizeof(
val));
1045 .Print(
"_type",
"conn")
1054 unsigned int peer_addr;
1078 "' is not supported");
1099 .Print(
"_type",
"message")
1103 string key = it.GetKey();
1106 if (
key ==
"ncbi_phid")
1110 if (
key ==
"ncbi_context")
1112 if (
key ==
"SessionID" ||
key ==
"ClientIP")
1138 if (!timing.empty())
1166 string protocol_version;
1168 if (!message.
HasKey(
"Client")) {
1170 "Mandatory field 'Client' is missed");
1176 "Mandatory field 'Client' is empty");
1180 SNetStorage::SLimits::Check<SNetStorage::SLimits::SClientName>(
client);
1184 if (message.
HasKey(
"Application"))
1185 application = message.
GetString(
"Application");
1186 if (message.
HasKey(
"Ticket"))
1188 if (message.
HasKey(
"ProtocolVersion")) {
1200 "Invalid type of the 'ProtocolVersion'. "
1201 "String is expected.");
1203 if (message.
HasKey(
"Service"))
1261 reply.
SetString(
"Configuration",
string(converter));
1262 reply.
SetString(
"ConfigurationFilePath",
1299 db_stat_node.
SetBoolean(
"connected", connected);
1303 ExecSP_GetGeneralDBInfo();
1305 k != db_stat.
end(); ++k)
1306 db_stat_node.
SetString(k->first, k->second);
1310 k != db_stat.
end(); ++k)
1311 db_stat_node.
SetString(k->first, k->second);
1312 }
catch (
const exception & ex) {
1319 "Unknown metainfo DB access error",
1323 reply.
SetByKey(
"MetainfoDB", db_stat_node);
1338 string msg =
"Only administrators can acknowledge alerts";
1343 if (!message.
HasKey(
"Name"))
1345 "Mandatory argument Name is not supplied "
1346 "in ACKALERT command");
1347 if (!message.
HasKey(
"User"))
1349 "Mandatory argument User is not supplied "
1350 "in ACKALERT command");
1359 switch (ack_result) {
1370 "Alert has already been acknowledged",
kScopeLogic,
1392 string msg =
"Only administrators can reconfigure server "
1415 vector<string> config_warnings;
1423 if (!config_warnings.empty()) {
1426 for (vector<string>::const_iterator k = config_warnings.begin();
1427 k != config_warnings.end(); ++k) {
1438 "Configuration file is not well formed; " +
msg);
1443 string decrypt_warning;
1444 params.
Read(candidate_reg,
"server", decrypt_warning);
1446 if (!decrypt_warning.empty()) {
1462 "Configuration file has not been changed, "
1471 vector<string> config_checksum_warnings;
1474 if (config_checksum_warnings.empty()) {
1478 for (vector<string>::const_iterator
1479 k = config_checksum_warnings.begin();
1480 k != config_checksum_warnings.end(); ++k)
1503 if (server_diff.
IsNull() &&
1504 metadata_diff.
IsNull() &&
1510 "No changeable parameters were identified "
1511 "in the new configuration file",
1520 if (!server_diff.
IsNull())
1521 total_changes.
SetByKey(
"server", server_diff);
1522 if (!metadata_diff.
IsNull())
1523 total_changes.
SetByKey(
"metadata_conf", metadata_diff);
1524 if (!backend_diff.
IsNull())
1525 total_changes.
SetByKey(
"backend_conf", backend_diff);
1527 total_changes.
SetByKey(
"db_conf", db_diff);
1529 reply.
SetByKey(
"What", total_changes);
1543 string msg =
"Only administrators can shutdown server";
1548 if (!message.
HasKey(
"Mode")) {
1550 "Mandatory field 'Mode' is missed");
1555 if (
mode !=
"hard" &&
mode !=
"soft") {
1557 "Allowed 'Mode' values are 'soft' and 'hard'");
1589 vector<string> client_names;
1592 reply.
SetString(
"DBClients",
"MetadataAccessWarning");
1594 "Stored procedure return code is non zero",
1598 for (vector<string>::const_iterator
1599 k = client_names.begin(); k != client_names.end(); ++k) {
1602 reply.
SetByKey(
"DBClients", db_clients_node);
1604 }
catch (
const exception & ex) {
1605 reply.
SetString(
"DBClients",
"MetadataAccessWarning");
1608 unsigned int error_sub_code;
1611 &error_sub_code) ==
false)
1615 "Error while getting a list of clients "
1616 "in the metainfo DB: " +
string(ex.what()),
1617 error_scope, error_sub_code);
1619 reply.
SetString(
"DBClients",
"MetadataAccessWarning");
1621 "Unknown error while getting a list of clients "
1622 "in the metainfo DB",
1626 reply.
SetString(
"DBClients",
"NoMetadataAccess");
1645 vector< pair<string, string> > users;
1649 "Error executing stored procedure - return code is "
1653 for (vector< pair<string, string> >::const_iterator
1654 k = users.begin(); k != users.end(); ++k) {
1657 a_user.
SetString(
"Namespace", (*k).second);
1662 }
catch (
const exception & ex) {
1667 "Unknown error while getting a list of users "
1668 "in the metainfo DB",
1704 bool need_db_access =
true;
1708 service_properties);
1713 if (need_db_access) {
1731 ExecSP_GetObjectFixedAttributes(
1733 expiration, creation,
1734 obj_read, obj_write,
1735 attr_read, attr_write,
1736 read_count, write_count,
1738 user_namespace, user_name,
1747 reply.
SetString(
"ExpirationTime",
"NotSet");
1751 expiration.
m_Value.AsString());
1772 reply.
SetString(
"TTL", service_properties.
1785 }
catch (
const exception & ex) {
1789 unsigned int error_sub_code;
1792 &error_sub_code) ==
false)
1796 "Error while gettingobject fixed attributes: " +
1797 string(ex.
what()), error_scope, error_sub_code);
1801 "Unknown error while getting object fixed attributes",
1811 bool remote_info_error =
true;
1819 string key = it.GetKey();
1820 if (
key !=
"CreationTime")
1821 reply.
SetByKey(it.GetKey(), it.GetNode());
1823 remote_info_error =
false;
1824 }
catch (
const exception & ex) {
1832 unsigned int error_sub_code;
1835 &error_sub_code) ==
false)
1839 "Error while getting remote object info: " +
1840 string(ex.what()), error_scope, error_sub_code);
1845 string msg =
"Unknown error while getting remote object info";
1852 bool need_client_update =
false;
1854 if (need_db_access && user_name.
m_IsNull && remote_info_error ==
false) {
1859 pair<string, string> ns_and_name = direct_object.
GetUserInfo();
1861 remote_client.
SetName(ns_and_name.second);
1863 reply.
SetString(
"UserNamespace", ns_and_name.first);
1864 reply.
SetString(
"UserName", ns_and_name.second);
1866 need_client_update =
true;
1867 }
catch (
const exception & ex) {
1868 ERR_POST(
"Error retrieving user name and "
1869 "user namespace from a remote storage: " << ex);
1871 ERR_POST(
"Unknown error retrieving user name and "
1872 "user namespace from a remote storage");
1878 if (need_client_update) {
1884 }
catch (
const exception & ex) {
1885 ERR_POST(
"Error updating the user ID "
1886 "after getting the object info: " << ex);
1888 ERR_POST(
"Unknown error updating the user ID "
1889 "after getting the object info");
1918 const string & name,
1930 const string & name,
1942 const string & name,
1961 if (!message.
HasKey(
"ObjectLoc") && !message.
HasKey(
"UserKey"))
1963 "GETATTRLIST message must have ObjectLoc or UserKey. "
1964 "None of them was found.");
1968 "DB access is restricted in HELLO");
1983 vector<string> attr_names;
1985 object_key, attr_names);
1990 for (vector<string>::const_iterator k = attr_names.begin();
1991 k != attr_names.end(); ++k)
1992 names.AppendString(*k);
1998 "Unknown GetAttributeNames status");
2015 if (!message.
HasKey(
"ClientName"))
2017 "GETCLIENTOBJECTS message must have ClientName.");
2023 if (message.
HasKey(
"Limit")) {
2029 "GETCLIENTOBJECTS message Limit argument "
2030 "must be an integer.");
2034 "GETCLIENTOBJECTS message Limit argument "
2040 "DB access is restricted in HELLO");
2053 vector<string> locators;
2054 Int8 total_client_objects;
2057 total_client_objects, locators);
2062 for (vector<string>::const_iterator k = locators.begin();
2063 k != locators.end(); ++k)
2065 reply.
SetByKey(
"ObjectLocators", locators_node);
2066 reply.
SetInteger(
"TotalClientObjects", total_client_objects);
2071 "NetStorage client '" + client_name +
"' is not found");
2075 "Unknown GetClientObjects status");
2093 if (!message.
HasKey(
"UserName"))
2095 "GETUSEROBJECTS message must have UserName.");
2099 if (!message.
HasKey(
"UserNamespace"))
2101 "GETUSEROBJECTS message must have UserNamespace.");
2109 if (message.
HasKey(
"Limit")) {
2115 "GETUSEROBJECTS message Limit argument "
2116 "must be an integer.");
2120 "GETUSEROBJECTS message Limit argument "
2126 "DB access is restricted in HELLO");
2139 vector<string> locators;
2140 Int8 total_client_objects;
2142 user_name, user_namespace, limit,
2143 total_client_objects, locators);
2148 for (vector<string>::const_iterator k = locators.begin();
2149 k != locators.end(); ++k)
2151 reply.
SetByKey(
"ObjectLocators", locators_node);
2152 reply.
SetInteger(
"TotalUserObjects", total_client_objects);
2157 "NetStorage user is not found");
2161 "Unknown GetUserObjects status");
2179 if (!message.
HasKey(
"AttrName"))
2181 "Mandatory field 'AttrName' is missed");
2183 string attr_name = message.
GetString(
"AttrName");
2184 if (attr_name.empty())
2186 "Attribute name must not be empty");
2191 if (!message.
HasKey(
"ObjectLoc") && !message.
HasKey(
"UserKey"))
2193 "GETATTR message must have ObjectLoc or UserKey. "
2194 "None of them was found.");
2198 "DB access is restricted in HELLO");
2215 object_key, attr_name,
2228 "NetStorage attribute is not found");
2233 eNetStorageAttributeValueNotFound,
2234 "NetStorage attribute value is not found");
2238 "Unknown GetAttributeValue status");
2255 if (!message.
HasKey(
"AttrName"))
2257 "Mandatory field 'AttrName' is missed");
2259 string attr_name = message.
GetString(
"AttrName");
2260 SNetStorage::SLimits::Check<SNetStorage::SLimits::SAttrName>(attr_name);
2265 if (!message.
HasKey(
"AttrValue"))
2267 "Mandatory field 'AttrValue' is missed");
2270 SNetStorage::SLimits::Check<SNetStorage::SLimits::SAttrValue>(
value);
2272 if (!message.
HasKey(
"ObjectLoc") && !message.
HasKey(
"UserKey"))
2274 "SETATTR message must have ObjectLoc or UserKey. "
2275 "None of them was found.");
2280 "State changing operations are restricted in HELLO");
2282 bool create_if_not_found =
true;
2283 if (message.
HasKey(
"CreateIfNotFound"))
2284 create_if_not_found = message.
GetBoolean(
"CreateIfNotFound");
2304 object_key, object_loc,
2313 "Unknown AddAttribute status");
2330 if (!message.
HasKey(
"AttrName"))
2332 "Mandatory field 'AttrName' is missed");
2334 string attr_name = message.
GetString(
"AttrName");
2335 if (attr_name.empty())
2337 "Attribute name must not be empty");
2339 if (!message.
HasKey(
"ObjectLoc") && !message.
HasKey(
"UserKey"))
2341 "DELATTR message must have ObjectLoc or UserKey. "
2342 "None of them was found.");
2347 "State changing operations are restricted in HELLO");
2360 object_key, attr_name);
2368 }
else if (status == -2) {
2371 "NetStorage attribute is not found",
2373 }
else if (status == -3) {
2376 "NetStorage attribute value is not found",
2381 "Unknown DelAttributeValue status");
2400 "State changing operations are restricted in HELLO");
2431 .
Print(
"ObjectLoc", locator)
2453 if (!message.
HasKey(
"ObjectLoc") && !message.
HasKey(
"UserKey"))
2455 "WRITE message must have ObjectLoc or UserKey. "
2456 "None of them was found.");
2460 "State changing operations are restricted in HELLO");
2484 string locator = object_locator.
GetLocator();
2487 bool create_if_not_found =
true;
2488 if (message.
HasKey(
"CreateIfNotFound")) {
2489 create_if_not_found = message.
GetBoolean(
"CreateIfNotFound");
2492 if (create_if_not_found ==
false) {
2524 if (!message.
HasKey(
"ObjectLoc") && !message.
HasKey(
"UserKey"))
2526 "READ message must have ObjectLoc or UserKey. "
2527 "None of them was found.");
2531 bool need_meta_db_update =
false;
2536 service_properties);
2544 string locator = object_locator.
GetLocator();
2546 bool allow_backend_fallback =
true;
2547 if (message.
HasKey(
"AllowBackendFallback")) {
2548 allow_backend_fallback = message.
GetBoolean(
"AllowBackendFallback");
2551 if (need_meta_db_update) {
2562 if (allow_backend_fallback ==
false) {
2575 Int8 total_bytes = 0;
2579 while (!direct_object.
Eof()) {
2592 total_bytes += bytes_read;
2599 direct_object.
Close();
2605 }
catch (
const exception & ex) {
2611 unsigned int error_sub_code;
2612 string message =
"Object read error: " +
string(ex.what());
2615 &error_sub_code) ==
false)
2619 error_code, message, error_scope, error_sub_code);
2622 if (need_meta_db_update)
2627 need_meta_db_update =
false;
2630 m_Timing.
Append(
"NetStorageAPI read (unknown exception)", start);
2633 if (need_meta_db_update)
2643 if (need_meta_db_update) {
2645 bool size_was_null =
false;
2656 individual_object_ttl);
2660 service_properties.
GetTTL(),
2662 object_expiration, size_was_null);
2663 }
catch (
const exception & ex) {
2668 unsigned int error_sub_code;
2671 &error_sub_code) ==
false)
2674 AppendError(reply, error_code, ex.what(), error_scope,
2675 error_sub_code,
false);
2678 string msg =
"Unknown metainfo DB update error on object read";
2698 const string & object_key,
2707 ERR_POST(
"Internal error: unknown operation in "
2708 "x_ProlongObjectOnFailure: " << op);
2717 individual_object_ttl);
2732 ERR_POST(
"Internal error: unknown operation in "
2733 "x_ProlongObjectOnFailure: " << op);
2738 object_key, service_props.
GetTTL(),
2739 prolong, object_expiration);
2741 }
catch (
const std::exception & ex) {
2743 " failure. Ignore and continue. " << ex);
2745 ERR_POST(
"Unknown error updating object expiration on " <<
2746 operation <<
" failure. Ignore and continue.");
2760 if (!message.
HasKey(
"ObjectLoc") && !message.
HasKey(
"UserKey"))
2762 "DELETE message must have ObjectLoc or UserKey. "
2763 "None of them was found.");
2767 "State changing operations are restricted in HELLO");
2772 bool need_meta_db_update =
false;
2776 service_properties);
2781 bool allow_backend_fallback =
true;
2782 if (message.
HasKey(
"AllowBackendFallback")) {
2783 allow_backend_fallback = message.
GetBoolean(
"AllowBackendFallback");
2788 if (need_meta_db_update) {
2797 if (allow_backend_fallback ==
false) {
2843 if (!message.
HasKey(
"NewLocation")) {
2845 "NewLocation argument is not found");
2850 "State changing operations are restricted in HELLO");
2855 bool need_meta_db_update =
false;
2859 service_properties);
2875 bool create_if_not_found =
true;
2876 if (message.
HasKey(
"CreateIfNotFound")) {
2877 create_if_not_found = message.
GetBoolean(
"CreateIfNotFound");
2880 bool need_progress_report =
false;
2881 if (message.
HasKey(
"NeedProgressReport")) {
2882 need_progress_report = message.
GetBoolean(
"NeedProgressReport");
2885 if (need_meta_db_update) {
2894 if (create_if_not_found ==
false) {
2902 string new_object_loc;
2904 need_progress_report);
2909 new_object_loc = direct_object.
Relocate(new_location_flags, cb);
2920 ERR_POST(
"NetStorageAPI Relocate interrupt: " << ex);
2921 if (need_meta_db_update)
2923 service_properties);
2931 if (need_meta_db_update)
2933 service_properties);
2938 if (need_meta_db_update)
2940 service_properties);
2944 if (need_meta_db_update) {
2955 individual_object_ttl);
2959 object_key, new_object_loc,
2962 individual_object_ttl),
2964 }
catch (
const exception & ex) {
2970 unsigned int error_sub_code;
2973 &error_sub_code) ==
false)
2975 AppendError(reply, error_code, ex.what(), error_scope,
2976 error_sub_code,
false);
2980 string msg =
"Unknown metainfo DB update error "
2981 "on object relocation";
2991 reply.
SetString(
"ObjectLoc", new_object_loc);
2996 .
Print(
"NewObjectLoc", new_object_loc);
3016 bool need_db_access =
3018 service_properties);
3019 string locator_from_db;
3022 if (need_db_access) {
3024 bool db_error =
true;
3031 object_size, object_locator);
3041 locator_from_db = object_locator.
m_Value;
3042 }
catch (
const exception & ex) {
3047 ERR_POST(
"Unknown exception while getting an object "
3048 "size and a locator from the DB");
3058 bool exists =
false;
3062 if (message.
HasKey(
"ObjectLoc")) {
3066 exists = storage.
Exists(locator_from_db,
3082 exists = storage.
Exists(locator_from_db,
3109 bool consult_backend_if_no_db_record =
true;
3111 if (message.
HasKey(
"ConsultBackendIfNoDBRecord")) {
3112 consult_backend_if_no_db_record =
3113 message.
GetBoolean(
"ConsultBackendIfNoDBRecord");
3121 bool object_size_is_null =
false;
3123 bool need_db_access =
3125 service_properties);
3127 if (need_db_access) {
3130 object_key, db_object_size);
3135 object_size_is_null =
true;
3149 Uint8 object_size = 0;
3150 if (object_size_is_null || consult_backend_if_no_db_record) {
3153 object_size = direct_object.
GetSize();
3161 if (object_size_is_null) {
3169 }
catch (
const exception & ex) {
3172 ERR_POST(
"Unknown error updating the backend expiration time "
3173 "while processing the GETSIZE message");
3179 db_object_size.
m_Value = object_size;
3182 object_key, db_object_size);
3184 object_size = db_object_size.
m_Value;
3190 }
catch (
const exception & ex) {
3193 ERR_POST(
"Unknown error updating the object size while "
3194 "processing the GETSIZE message");
3214 if (!message.
HasKey(
"TTL"))
3216 "Mandatory field 'TTL' is missed");
3218 string arg_val = message.
GetString(
"TTL");
3227 }
catch (
const exception & ex) {
3229 "TTL format is not recognized: " +
string(ex.what()));
3232 "TTL format is not recognized");
3240 if (!message.
HasKey(
"ObjectLoc") && !message.
HasKey(
"UserKey"))
3242 "SETEXPTIME message must have ObjectLoc or UserKey. "
3243 "None of them was found.");
3251 "SETEXPTIME could not be used when the HELLO metadata "
3252 "option is set to Monitoring");
3255 bool db_update =
true;
3266 bool db_error =
false;
3271 bool create_if_not_found =
true;
3272 if (message.
HasKey(
"CreateIfNotFound"))
3273 create_if_not_found = message.
GetBoolean(
"CreateIfNotFound");
3282 create_if_not_found,
3286 }
catch (
const exception & ex) {
3289 unsigned int error_sub_code;
3292 &error_sub_code) ==
false)
3294 AppendError(reply, error_code, ex.what(), error_scope,
3299 "Unknown metainfo DB update error",
3307 if (db_error ==
false)
3314 if (ttl.
m_IsNull || (db_update && !db_error))
3348 }
catch (
const exception & ex) {
3351 unsigned int error_sub_code;
3354 &error_sub_code) ==
false) {
3361 const string msg =
"Unknown remote storage SetExpiration error";
3381 if (!message.
HasKey(
"ObjectLoc") && !message.
HasKey(
"UserKey"))
3383 "LOCKFTPATH message must have ObjectLoc or UserKey. "
3384 "None of them was found.");
3388 "LOCKFTPATH could not be used when the HELLO metadata "
3389 "option is set to Monitoring");
3403 individual_object_ttl);
3413 service_properties.
GetTTL(),
3415 individual_object_ttl),
3417 }
catch (
const std::exception & ex) {
3418 ERR_POST(
"Error updating object expiration on LOCKFTPATH. "
3419 "Ignore and continue. " << ex);
3421 ERR_POST(
"Unknown error updating object "
3422 "expiration on LOCKFTPATH.");
3444 m_Timing.
Append(
"NetStorageAPI FileTrack_Path exception", start);
3450 size_t warn_count = warnings_listener.
Count();
3451 for (
size_t k = 0; k < warn_count; ++k) {
3469 bool need_fake_write)
3473 if (message.
HasKey(
"ObjectLoc")) {
3474 string object_loc = message.
GetString(
"ObjectLoc");
3488 if (need_fake_write) {
3492 object.Write(
"", 0);
3497 .
Print(
"ObjectKey",
object.Locator().GetUniqueKey());
3501 string new_loc =
object.Locator().GetLocator();
3502 if (new_loc != object_loc)
3504 .
Print(
"ObjectLoc",
object.Locator().GetLocator());
3532 if (need_fake_write) {
3536 object.Write(
"", 0);
3542 .
Print(
"ObjectKey",
object.Locator().GetUniqueKey())
3543 .
Print(
"ObjectLoc",
object.Locator().GetLocator());
3558 if (object_loc.empty()) {
3560 "Object locator must not be an empty string");
3573 "CacheName is required if ServiceName is provided");
3586 "AppDomain is required if UniqueKey is provided");
3636 const char * output_buffer;
3637 size_t output_buffer_size;
3642 if (output_buffer_size > 0) {
3655 output_buffer, output_buffer_size);
3669 if (!message.
HasKey(
"Metadata"))
3679 string message =
"Optional field 'Metadata' value is not "
3680 "recognized. Supported values are: ";
3681 for (vector<string>::const_iterator k = valid.begin();
3682 k != valid.end(); ++k) {
3683 if (k != valid.begin())
3697 "Invalid metadata option. It cannot be required "
3698 "for not configured service");
3701 "Invalid metadata option. It cannot be required "
3702 "for a service which has metadata explicitly "
3706 "Invalid metadata option. It cannot be required "
3707 "for a service which has metadata "
3708 "switched off (by default)");
3718 bool expect_object)
const
3720 if (expect_object && message.
HasKey(
"ObjectLoc")) {
3722 string object_loc = message.
GetString(
"ObjectLoc");
3732 "DB access requested for an object which was created "
3733 "with no metadata flag");
3736 if (service.empty())
3745 "Effective object service (" + service +
3746 ") is not configured. Metainfo DB access declined.");
3749 "Effective object service (" + service +
3750 ") has metadata explicitly switched off. "
3751 "Metainfo DB access declined.");
3754 "Effective object service (" + service +
3755 ") has metadata switched off (by default). "
3756 "Metainfo DB access declined.");
3762 if (expect_object) {
3767 "Storage flags forbid access to the metainfo DB. "
3768 "Metainfo DB access declined.");
3780 "Service provided in HELLO (" +
m_Service +
3781 ") is not configured. Metainfo DB access declined.");
3784 "Service provided in HELLO (" +
m_Service +
3785 ") has metadata explicitly switched off. "
3786 "Metainfo DB access declined.");
3789 "Service provided in HELLO (" +
m_Service +
3790 ") has metadata switched off (by default). "
3791 "Metainfo DB access declined.");
3805 if (message.
HasKey(
"ObjectLoc")) {
3807 string object_loc = message.
GetString(
"ObjectLoc");
3819 if (service.empty())
3825 return service_configured;
3829 if (!service_configured)
3831 "Effective object service (" + service +
3832 ") is not in the list of "
3833 "configured services. Metainfo DB access declined.");
3848 if (!service_configured)
3850 "Service provided in HELLO (" +
m_Service +
3851 ") is not in the list of "
3852 "configured services. Metainfo DB access declined.");
3854 return service_configured;
3871 if (!service_configured)
3873 "Service provided in HELLO (" +
m_Service +
3874 ") is not in the list of "
3875 "configured services. Metainfo DB access declined.");
3877 return service_configured;
3890 if (message.
HasKey(
"ObjectLoc")) {
3892 string object_loc = message.
GetString(
"ObjectLoc");
3904 if (service.empty())
3909 return service_configured;
3921 return service_configured;
3961 if (!user_name.empty()) {
3993 const string & user_message
4003 }
catch (
const exception & ex) {
4010 if (to_test_setexp_support != 0)
4022 unsigned int error_sub_code;
4025 &error_sub_code) ==
false)
4029 AppendError(reply, error_code, ex.what(), error_scope,
4030 error_sub_code,
false);
4033 string msg =
"Unknown error updating the backend expiration "
4034 " time while processing the " + user_message +
" message";
4066 "Anonymous client cannot perform " + op);
CDirectNetStorageObject Open(const string &unique_key, TNetStorageFlags flags=0)
bool Exists(const string &db_loc, const string &key, TNetStorageFlags flags)
ENetStorageRemoveResult Remove()
const CNetStorageObjectLoc & Locator()
string Relocate(TNetStorageFlags flags, TNetStorageProgressCb cb=TNetStorageProgressCb())
pair< string, string > GetUserInfo()
CDirectNetStorageObject Open(const string &object_loc)
CDirectNetStorageObject Create(const string &service_name, TNetStorageFlags flags)
bool Exists(const string &db_loc, const string &client_loc)
Iterator for JSON arrays and objects.
Int8 AsInteger() const
Provided that this is a numeric node (that is, either an integer or a floating point node),...
bool IsNull() const
Return true for a null node. Return false otherwise.
static CJsonNode NewArrayNode()
Create a new JSON array node.
void SetDouble(const string &key, double value)
Set a JSON object element to the specified floating point value.
bool HasKey(const string &key) const
Check if an object node has an element accessible by the specified key.
SJsonIteratorImpl * Iterate(EIterationMode mode=eNatural) const
For a container node (that is, either an array or an object), begin iteration over its elements.
void SetString(const string &key, const string &value)
Set a JSON object element to the specified string value.
Int8 GetInteger(const string &key) const
For a JSON object node, return the integer referred to by the specified key.
void AppendString(const string &value)
For an array node, add a string node at the end of the array.
const string AsString() const
Provided that this is a string node, return the string value of this node.
string GetString(const string &key) const
For a JSON object node, return the string referred to by the specified key.
void SetBoolean(const string &key, bool value)
Set a JSON object element to the specified boolean value.
ENodeType GetNodeType() const
Return a ENodeType constant identifying the node type.
void SetInteger(const string &key, Int8 value)
Set a JSON object element to the specified integer value.
void SetByKey(const string &key, CJsonNode::TInstance value)
For a JSON object node, insert a new element or update an existing element.
bool GetBoolean(const string &key) const
For a JSON object node, return the boolean referred to by the specified key.
bool IsObject() const
Return true for a JSON object. Return false otherwise.
static CJsonNode NewObjectNode()
Create a new JSON object node.
void Append(CJsonNode::TInstance value)
For an array node, add a new element at the end of the array.
CJsonNode GetByKey(const string &key) const
For a JSON object node, return the value associated with the specified key.
Exception class for use by CJsonNode.
const CJsonNode GetMessage() const
bool ReadMessage(CUTTPReader &reader)
bool WriteMessage(const CJsonNode &root_node)
void GetOutputBuffer(const char **output_buffer, size_t *output_buffer_size)
~CMessageListenerResetter()
CMessageListenerResetter()
Default implementation of IMessageListener: collects all messages posted.
void AddBytesRead(const string &client, size_t count)
void AddObjectsWritten(const string &client, size_t count)
void AddObjectsRead(const string &client, size_t count)
void Touch(const string &client, const string &applications, const string &ticket, const string &service, const string &protocol_version, EMetadataOption metadataOption, unsigned int peer_address)
void AddObjectsDeleted(const string &client, size_t count)
void SetDBClientID(const string &client, Int8 id)
void AddBytesWritten(const string &client, size_t count)
CJsonNode Serialize(void) const
void RegisterSocketWriteError(const string &client)
void AppendType(const string &client, unsigned int type_to_append)
void AddObjectsRelocated(const string &client, size_t count)
int ExecSP_GetAttribute(const string &object_key, const string &attr_name, bool need_update, string &value)
int ExecSP_GetObjectExpiration(const string &object_key, TNSTDBValue< CTime > &expiration, TNSTDBValue< Int8 > &individual_object_ttl)
int ExecSP_GetClientObjects(const string &client_name, TNSTDBValue< Int8 > limit, Int8 &total, vector< string > &locators)
bool IsConnected(void) const
int ExecSP_UpdateObjectOnRead(const string &object_key, const string &object_loc, Int8 size, Int8 client_id, const TNSTDBValue< CTimeSpan > &ttl, const TNSTDBValue< CTimeSpan > &prolong_on_read, const TNSTDBValue< CTime > &object_expiration, bool &size_was_null)
int ExecSP_SetExpiration(const string &object_key, const TNSTDBValue< CTimeSpan > &ttl, bool create_if_not_found, const string &object_loc, Int8 client_id, TNSTDBValue< Int8 > &object_size)
int ExecSP_GetUsers(vector< pair< string, string > > &users)
int ExecSP_UpdateUserIDForObject(const string &object_key, Int8 user_id)
int ExecSP_GetClients(vector< string > &names)
int ExecSP_UpdateObjectOnRelocate(const string &object_key, const string &object_loc, Int8 client_id, const TNSTDBValue< CTimeSpan > &ttl, const TNSTDBValue< CTimeSpan > &prolong_on_relocate, const TNSTDBValue< CTime > &object_expiration)
int ExecSP_CreateClient(const string &client, Int8 &client_id)
map< string, string > ExecSP_GetStatDBInfo(void)
int ExecSP_GetUserObjects(const string &user_name, const string &user_name_space, TNSTDBValue< Int8 > limit, Int8 &total, vector< string > &locators)
int ExecSP_UpdateObjectOnWrite(const string &object_key, const string &object_loc, Int8 size, Int8 client_id, Int8 user_id, const TNSTDBValue< CTimeSpan > &ttl, const TNSTDBValue< CTimeSpan > &prolong_on_write, const TNSTDBValue< CTime > &object_expiration, bool &size_was_null)
int ExecSP_AddAttribute(const string &object_key, const string &object_loc, const string &attr_name, const string &attr_value, Int8 client_id, bool create_if_not_found, const TNSTDBValue< CTimeSpan > &ttl)
int UpdateExpirationIfExists(const string &object_key, const TNSTDBValue< CTimeSpan > &ttl, const TNSTDBValue< CTimeSpan > &prolong_on_read, const TNSTDBValue< CTime > &object_expiration)
int ExecSP_CreateObjectWithClientID(const string &object_key, const string &object_loc, Int8 size, Int8 client_id, Int8 user_id, const TNSTDBValue< CTimeSpan > ttl, bool &size_was_null)
int ExecSP_DoesObjectExist(const string &object_key)
int ExecSP_GetObjectSize(const string &object_key, TNSTDBValue< Int8 > &object_size)
CTimeout GetExecuteSPTimeout(void)
int ExecSP_GetObjectSizeAndLocator(const string &object_key, TNSTDBValue< Int8 > &object_size, TNSTDBValue< string > &object_locator)
int ExecSP_RemoveObject(const string &object_key)
int ExecSP_GetAttributeNames(const string &object_key, vector< string > &attr_names)
int ExecSP_DelAttribute(const string &object_key, const string &attr_name)
CJsonNode SetParameters(const IRegistry ®)
int ExecSP_UpdateObjectSizeIfNULL(const string &object_key, TNSTDBValue< Int8 > &object_size)
int ExecSP_CreateUser(const CNSTUserID &user, Int8 &user_id)
static CNSTPreciseTime Current(void)
TNSTDBValue< CTimeSpan > GetProlongOnWrite(const TNSTDBValue< Int8 > &individual_obj_ttl) const
TNSTDBValue< CTimeSpan > GetTTL(void) const
TNSTDBValue< CTimeSpan > GetProlongOnRead(const TNSTDBValue< Int8 > &individual_obj_ttl) const
TNSTDBValue< CTimeSpan > GetProlongOnRelocate(const TNSTDBValue< Int8 > &individual_obj_ttl) const
string Serialize(CDiagContext_Extra extra)
void Append(const string &what, const CNSTPreciseTime &how_long)
Int8 GetDBUserID(const CNSTUserID &user) const
void SetDBUserID(const CNSTUserID &user, Int8 id)
void SetNamespace(const string &name_space_)
void SetName(const string &name_)
static CNcbiApplication * Instance(void)
Singleton method.
static void Reload(void)
Re-read key file locations and domain paths, reload encryption keys.
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Exception class for use by CNetStorage, CNetStorageByKey, and CNetStorageObject.
EIO_Status x_SendSyncMessage(const CJsonNode &message, ESocketTimeoutTreat timeout_treat=eTimeoutIsError)
string x_GetConnRef(void)
virtual void OnRead(void)
The client has just sent data.
void x_SetObjectInfoReply(CJsonNode &reply, const string &name, const TNSTDBValue< CTime > &value)
void x_ProcessHello(const CJsonNode &message, const SCommonRequestArguments &common_args)
void x_CheckExistanceStatus(int status)
void x_SendAsyncMessage(const CJsonNode &message)
virtual void OnOpen(void)
Runs in response to an external event [asynchronous].
void x_CheckNonAnonymousClient(const string &op) const
void x_ProcessConfiguration(const CJsonNode &message, const SCommonRequestArguments &common_args)
void x_ProcessSetExpTime(const CJsonNode &message, const SCommonRequestArguments &common_args)
bool x_DetectMetaDBNeedOnGetObjectInfo(const CJsonNode &message, CNSTServiceProperties &props) const
void x_PrintMessageRequestStart(const CJsonNode &message)
unsigned int x_GetPeerAddress(void)
void x_ProcessWrite(const CJsonNode &message, const SCommonRequestArguments &common_args)
void x_ProcessSetAttr(const CJsonNode &message, const SCommonRequestArguments &common_args)
void x_CheckUserKey(const SUserKey &user_key)
TNSTDBValue< CTimeSpan > m_CreateTTL
virtual EIO_Event GetEventsToPollFor(const CTime **alarm_time) const
Following three methods are guaranteed to be called NOT at the same time as On*, so if you implement ...
CDirectNetStorageObject x_CreateObjectStream(const SICacheSettings &icache_settings, TNetStorageFlags flags)
void x_ProcessGetSize(const CJsonNode &message, const SCommonRequestArguments &common_args)
EIO_Status x_SendOutputBuffer(ESocketTimeoutTreat timeout_treat)
void x_ProcessAckAlert(const CJsonNode &message, const SCommonRequestArguments &common_args)
void(CNetStorageHandler::* FProcessor)(const CJsonNode &, const SCommonRequestArguments &)
CRef< CRequestContext > m_ConnContext
void x_ProcessRead(const CJsonNode &message, const SCommonRequestArguments &common_args)
void x_CreateConnContext(void)
void x_ProcessGetClientObjects(const CJsonNode &message, const SCommonRequestArguments &comm_args)
void x_ProcessGetObjectInfo(const CJsonNode &message, const SCommonRequestArguments &common_args)
virtual void OnWrite(void)
The client is ready to receive data.
void x_ProcessShutdown(const CJsonNode &message, const SCommonRequestArguments &common_args)
void x_ProcessReconfigure(const CJsonNode &message, const SCommonRequestArguments &common_args)
CNetStorageHandler(CNetStorageServer *server)
void x_ProcessGetClientsInfo(const CJsonNode &message, const SCommonRequestArguments &common_args)
void x_SetConnRequestStatus(unsigned int status)
void x_SetQuickAcknowledge(void)
void x_CreateClient(void)
CNSTServiceProperties m_WriteServiceProps
void x_PrintMessageRequestStop(void)
void x_FillObjectInfo(CJsonNode &reply, const string &val)
void x_ProcessGetUsersInfo(const CJsonNode &message, const SCommonRequestArguments &common_args)
char m_WriteBuffer[kWriteBufferSize]
virtual void OnOverflow(EOverflowReason reason)
Runs when there are insufficient resources to queue a connection, prior to closing it.
void x_ProcessGetMetadataInfo(const CJsonNode &message, const SCommonRequestArguments &common_args)
virtual void OnTimeout(void)
Runs when a client has been idle for too long, prior to closing the connection [synchronous].
void x_ProcessDelAttr(const CJsonNode &message, const SCommonRequestArguments &common_args)
void x_OnSocketWriteError(EIO_Status status, size_t bytes_written, const char *output_buffer, size_t output_buffer_size)
void x_ProcessGetAttrList(const CJsonNode &message, const SCommonRequestArguments &common_args)
CFastMutex m_OutputQueueMutex
void x_CheckExpirationStatus(int status)
EMetadataOption x_ConvertMetadataArgument(const CJsonNode &message) const
CDirectNetStorageObject m_ObjectBeingWritten
void x_ProcessRelocate(const CJsonNode &message, const SCommonRequestArguments &common_args)
virtual void OnClose(IServer_ConnectionHandler::EClosePeer peer)
The connection has closed (with information on type of closing)
CNetStorageServer * m_Server
void x_ProcessBye(const CJsonNode &message, const SCommonRequestArguments &common_args)
void x_ProcessGetAttr(const CJsonNode &message, const SCommonRequestArguments &common_args)
EIO_Status x_SendOverUTTP()
CRef< CRequestContext > m_CmdContext
CDirectNetStorageObject x_GetObject(const CJsonNode &message, bool need_fake_write=false)
bool x_DetectMetaDBNeedUpdate(const CJsonNode &message, CNSTServiceProperties &props) const
void x_ProcessInfo(const CJsonNode &message, const SCommonRequestArguments &common_args)
bool m_WriteCreateNeedMetaDBUpdate
CJsonOverUTTPWriter m_JSONWriter
Int8 x_GetUserID(const CNSTUserID &user)
void x_ProcessLockFTPath(const CJsonNode &message, const SCommonRequestArguments &common_args)
void x_CheckICacheSettings(const SICacheSettings &icache_settings)
void x_OptionalExpirationUpdate(CDirectNetStorageObject &object, CJsonNode &reply, const string &user_message)
static SProcessorMap sm_Processors[]
bool x_DetectMetaDBNeedOnCreate(TNetStorageFlags flags)
EMetadataOption m_MetadataOption
void x_ProcessGetUserObjects(const CJsonNode &message, const SCommonRequestArguments &comm_args)
char m_ReadBuffer[kReadBufferSize]
Int8 x_GetClientID(const string &client)
void x_GetStorageParams(const CJsonNode &message, SICacheSettings *icache_settings, SUserKey *user_key, TNetStorageFlags *flags)
void x_SendWriteConfirmation()
vector< CJsonNode > m_OutputQueue
void x_ProlongObjectOnFailure(EOp operation, const string &object_key, const CNSTServiceProperties &service_props)
void x_ProcessCreate(const CJsonNode &message, const SCommonRequestArguments &common_args)
void x_ProcessDelete(const CJsonNode &message, const SCommonRequestArguments &common_args)
FProcessor x_FindProcessor(const SCommonRequestArguments &common_args)
void x_CheckObjectLoc(const string &object_loc) const
CJsonOverUTTPReader m_JSONReader
void x_OnData(const void *data, size_t data_size)
void x_ValidateWriteMetaDBAccess(const CJsonNode &message, bool expect_object=true) const
void x_OnMessage(const CJsonNode &message)
void x_ProcessHealth(const CJsonNode &message, const SCommonRequestArguments &common_args)
void x_ProcessExists(const CJsonNode &message, const SCommonRequestArguments &common_args)
void x_SetCmdRequestStatus(unsigned int status)
string GetLocator() const
bool IsMetaDataDisabled() const
string GetServiceName() const
string GetUniqueKey() const
@ eNetStorageAttributeValueNotFound
@ eNetStorageAttributeNotFound
unsigned int ErrCodeToHTTPStatusCode(void) const
CJsonNode SetParameters(const SNetStorageServerParameters &new_params, bool reconfigure)
CJsonNode GetBackendConfDiff(const CJsonNode &conf) const
void SetRAMConfigFileChecksum(const string &checksum)
CNSTDatabase & GetDb(void)
bool AnybodyCanReconfigure(void) const
void ResetDecryptCacheIfNeed(void)
enum EAlertAckResult AcknowledgeAlert(const string &id, const string &user)
string GetSessionID(void) const
unsigned int GetNetworkTimeout(void) const
void RegisterNetStorageAPIDecryptError(const string &message)
void SetAnybodyCanReconfigure(bool val)
CJsonNode SerializeAlerts(void) const
void ReportNetStorageAPIDecryptSuccess(void)
void RegisterAlert(EAlertType alert_type, const string &messge)
CNSTClientRegistry & GetClientRegistry(void)
bool IsAdminClientName(const string &name) const
CJsonNode GetBackendConfiguration(void) const
virtual bool ShutdownRequested(void)
Runs synchronously between iterations.
const CNSTPreciseTime & GetStartTime(void) const
void SetBackendConfiguration(const CJsonNode &conf)
EServiceMetadataPresence InMetadataServices(const string &service) const
bool GetServiceProperties(const string &service, CNSTServiceProperties &service_props) const
bool GetServiceTTL(const string &service, TNSTDBValue< CTimeSpan > &ttl) const
string GetCommandLine(void) const
CJsonNode ReadMetadataConfiguration(const IRegistry ®)
CCompoundIDPool GetCompoundIDPool(void) const
void SetDiskConfigFileChecksum(const string &checksum)
bool IsLogTimingClientSocket() const
const bool & IsLog() const
bool IsLogTimingNSTAPI() const
CJsonNode SerializeMetadataInfo(void) const
CNSTUserCache & GetUserCache(void)
void SetShutdownFlag(int signum=0)
unsigned int GetHostNetAddr() const
const SCommonRequestArguments & m_CommonArgs
CNetStorageHandler & m_Handler
CRelocateCallback(CNetStorageHandler &handler, const SCommonRequestArguments &common_args, CDirectNetStorageObject &object, bool need_progress_report)
void Callback(CJsonNode info)
CDirectNetStorageObject & m_Object
bool m_NeedProgressReport
~CRequestContextResetter()
CRequestContextResetter()
Request context properties passed between tasks.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
CTimeout – Timeout interval.
EStreamParsingEvent GetNextEvent()
Parse the input buffer until a parsing event occurs.
char GetControlSymbol() const
Return the control symbol that has been just read.
EStreamParsingEvent
Enumeration of the input stream parsing events.
@ eChunk
Notify that the last part of the chunk has been read.
@ eEndOfBuffer
Notify that the end of the input buffer has been reached.
@ eChunkPart
Notify that a part of a chunk has been read and can be fetched by a call to the GetChunkPart() method...
@ eControlSymbol
Notify that a control symbol has been read.
const char * GetChunkPart() const
Return a pointer to the buffer that contains a part of the chunk currently being read.
void SetNewBuffer(const char *buffer, size_t buffer_size)
Start processing of the next chunk of data.
size_t GetChunkPartSize() const
Return the size of the buffer returned by the GetChunkPart() method.
bool SendControlSymbol(char symbol)
Send a control symbol over the output buffer.
void GetOutputBuffer(const char **output_buffer, size_t *output_buffer_size)
Return data to be sent over the output stream and extend internal pointers to the next buffer.
bool NextOutputBuffer()
Proceed to the next output buffer.
bool SendChunk(const char *chunk, size_t chunk_length, bool to_be_continued)
Send a chunk of data to the output buffer.
void Reset(char *buffer, size_t buffer_size)
Initialize or reinitialize this object.
const_iterator begin() const
const_iterator end() const
void(*)(CSeq_entry_Handle seh, IWorkbench *wb, const CSerialObject &obj) handler
static const struct name_t names[]
bool ReloadConfig(CMetaRegistry::TFlags flags=CMetaRegistry::fReloadIfChanged, IRegistry::TFlags reg_flags=IRegistry::fWithNcbirc)
Reload the configuration file.
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
const string & GetConfigPath(void) const
Get the full path to the configuration file (if any) we ended up using.
@ eNegative
Value is negative.
void PrintRequestStop(void)
Print request stop message (for request-driven applications)
CDiagContext_Extra & Print(const string &name, const string &value)
The method does not print the argument, but adds it to the string.
void SetBytesWr(Int8 bytes)
int GetRequestStatus(void) const
Request exit status.
string GetStringUID(TUID uid=0) const
Return string representation of UID.
CDiagContext & GetDiagContext(void)
Get diag context instance.
static void SetRequestContext(CRequestContext *ctx)
Shortcut to CDiagContextThreadData::GetThreadData().SetRequestContext()
void PrintRequestStart(const string &message)
Print request start message (for request-driven applications)
void SetRequestID(TCount rid)
Set request ID.
CDiagContext_Extra Extra(void) const
Create a temporary CDiagContext_Extra object.
void SetClientIP(const string &client)
const string & Get(CTempString name) const
Get current property value or empty string if it's not set;.
#define NCBI_ERRCODE_X_NAME(name)
Returns value of error code by its name defined by NCBI_DEFINE_ERRCODE_X.
TCount GetRequestID(void) const
Get request ID (or zero if not set).
static TPID GetPID(void)
Get cached PID (read real PID if not cached yet).
void SetRequestStatus(int status)
void SetHitID(const string &hit)
Set explicit hit id. The id is reset on request end.
void Flush(void)
Print the message and reset object.
void SetBytesRd(Int8 bytes)
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
virtual const char * GetType(void) const
Get class name as a string.
TErrCode GetErrCode(void) const
Get error code.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Warning(CExceptionArgs_Base &args)
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
virtual int GetSubCode(void) const =0
Get error subcode. Zero = not set.
virtual size_t Count(void) const
Get total number of collected messages.
virtual string GetText(void) const =0
Get text message.
virtual const IMessage & GetMessage(size_t index) const
Get a previously collected message.
virtual int GetCode(void) const =0
Get error code. Zero = not set.
static size_t PushListener(IMessageListener &listener, EListenFlag flag=eListen_Unhandled)
Push a new listener to the stack in the current thread.
static void PopListener(size_t depth=0)
Remove listener(s) from the current thread's stack.
bool Eof(void)
Check if the last Read() has hit EOF.
string GetLoc(void) const
Return object locator.
unsigned TNetStorageFlags
Bitwise OR of ENetStorageFlags.
void Write(const void *buffer, size_t buf_size)
Write data to the object (starting at the current position)
size_t Read(void *buffer, size_t buf_size)
Read no more than 'buf_size' bytes of the object contents (starting at the current position)
void SetExpiration(const CTimeout &ttl)
Updates expiration on the object.
void Close(void)
Finalize and close the current object stream.
Uint8 GetSize(void)
Return size of the object.
CNetStorageObjectInfo GetInfo(void)
Return detailed information about the object.
CJsonNode ToJSON()
Pack the whole structure in a single JSON object.
function< void(CJsonNode)> TNetStorageProgressCb
Progress callback.
ENetStorageRemoveResult
Result returned by Remove() methods.
@ fNST_NoMetaData
Do not use NetStorage relational database to track ownership & changes.
@ eNotSupported
Feature is not supported.
@ eNotExists
Illegal op applied to non-existent object.
@ eInterrupted
Operation has been interrupted.
@ eNSTRR_NotFound
Removing failed due to object not found.
bool NotNull(void) const THROWS_NONE
Check if pointer is not null – same effect as NotEmpty().
void Reset(void)
Reset reference object.
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
int64_t Int8
8-byte (64-bit) signed integer
uint64_t Uint8
8-byte (64-bit) unsigned integer
bool Write(CNcbiOstream &os, TFlags flags=0) const
Write the registry content to output stream.
@ eDecryptionFailed
Value looked encrypted, but decryption failed.
EIO_Status Shutdown(EIO_Event how)
Shutdown socket I/O in the specified direction.
static unsigned int GetLoopbackAddress(void)
Loopback address gets returned in network byte order.
virtual EIO_Status GetOSHandle(void *handle_buf, size_t handle_size, EOwnership ownership=eNoOwnership) const
Access to the system-specific socket handle.
EIO_Status SetTimeout(EIO_Event event, const STimeout *timeout)
Set timeout for I/O in the specified direction.
void DisableOSSendDelay(bool on_off=true)
EIO_Status GetStatus(EIO_Event direction) const
Return status of *last* I/O operation without making any actual I/O.
TNCBI_BigCount GetCount(EIO_Event direction) const
void GetPeerAddress(unsigned int *host, unsigned short *port, ENH_ByteOrder byte_order) const
Get peer address.
EIO_Status Write(const void *buf, size_t size, size_t *n_written=0, EIO_WriteMethod how=eIO_WritePersist)
Write to socket.
EIO_Status Read(void *buf, size_t size, size_t *n_read=0, EIO_ReadMethod how=eIO_ReadPlain)
Read from socket.
@ eSAF_IP
only numeric IP if INET socket, empty otherwise
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
static string PrintableString(const CTempString str, TPrintableMode mode=fNewLine_Quote|fNonAscii_Passthru)
Get a printable version of the specified string.
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
TErrCode GetErrCode(void) const
Get error code.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
static string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string.
static string & ToLower(string &str)
Convert string to lower case – string& version.
EClosePeer
Type of connection closing.
void WakeUpPollCycle(void)
Force poll cycle to make another iteration.
EOverflowReason
Error codes for OnOverflow method in IServer_ConnectionHandler.
void CloseConnection(CSocket *sock)
Close connection.
CSocket & GetSocket(void)
Get underlying socket.
@ eClientClose
Connection closed by other peer.
@ eOurClose
Connection closed by ourselves.
bool IsEmpty(void) const
Return TRUE is an object keep zero time span.
double GetAsDouble(void) const
Get as number of seconds (fractional value).
ESign GetSign(void) const
Get sign of time span.
CTime CurrentTime(CTime::ETimeZone tz=CTime::eLocal, CTime::ETimeZonePrecision tzp=CTime::eTZPrecisionDefault)
string AsSmartString(ESmartStringPrecision precision, ERound rounding, ESmartStringZeroMode zero_mode=eSSZ_SkipZero) const
Transform time span to "smart" string.
void Set(EType type)
Set special value.
@ eInfinite
Infinite timeout.
const char * IO_StatusStr(EIO_Status status)
Get the text form of an enum status value.
EIO_Event
I/O event (or direction).
uint64_t TNCBI_BigCount
Big unsigned integer for file size and position.
@ eIO_Timeout
timeout expired before any I/O succeeded
@ eIO_Interrupt
signal arrival prevented any I/O to succeed
@ eIO_NotSupported
operation is not supported or is not available
@ eIO_Success
everything is fine, no error occurred
@ eIO_ReadWrite
eIO_Read | eIO_Write (also, eCONN_OnFlush)
@ eIO_Open
also serves as no-event indicator in SOCK_Poll
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
IMessage/IMessageListener interfaces and basic implementations.