-
Notifications
You must be signed in to change notification settings - Fork 11
[#124] Allow indexing rules to be invoked manually (main) #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
korydraughn
wants to merge
9
commits into
irods:main
Choose a base branch
from
korydraughn:124.m
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1939a44
[124] Allow indexing rules to be invoked manually.
korydraughn 06155c7
squash. clang-format
korydraughn 1a5db05
squash. admin mode for full text indexing via irule
korydraughn f5ab547
squash. clang-format
korydraughn 75675fe
squash. bytes_read < 0 explanation.
korydraughn 10ea1ab
Should we do something different if the read op fails for full text i…
korydraughn e9383bf
(WIP) investigating why the data is not getting indexed when invoked …
korydraughn eaab095
squash. wip - tests
korydraughn 2f8619e
tests
korydraughn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,19 +3,29 @@ | |
| #include "utilities.hpp" | ||
|
|
||
| #include <irods/MD5Strategy.hpp> | ||
| #include <irods/dataObjInpOut.h> | ||
| #include <irods/irods_hasher_factory.hpp> | ||
| #include <irods/irods_log.hpp> | ||
| #include <irods/irods_re_plugin.hpp> | ||
| #include <irods/irods_re_ruleexistshelper.hpp> | ||
| #include <irods/irods_rs_comm_query.hpp> | ||
| #include <irods/rodsErrorTable.h> | ||
| #include <irods/rsModAVUMetadata.hpp> | ||
| #include <irods/library_features.h> | ||
| #include <irods/irods_at_scope_exit.hpp> | ||
|
|
||
| #define IRODS_QUERY_ENABLE_SERVER_SIDE_API | ||
| #include <irods/irods_query.hpp> | ||
|
|
||
| #define IRODS_IO_TRANSPORT_ENABLE_SERVER_SIDE_API | ||
| #include <irods/dstream.hpp> | ||
| #include <irods/transport/default_transport.hpp> | ||
| #ifdef IRODS_HAS_FEATURE_ADMIN_MODE_FOR_DSTREAM_LIBRARIES | ||
| # define IRODS_IO_TRANSPORT_ENABLE_SERVER_SIDE_API | ||
| # include <irods/dstream.hpp> | ||
| # include <irods/transport/default_transport.hpp> | ||
| #else | ||
| # include <irods/rs_replica_open.hpp> | ||
| # include <irods/rs_replica_close.hpp> | ||
| # include <irods/rsDataObjRead.hpp> | ||
| #endif // IRODS_HAS_FEATURE_ADMIN_MODE_FOR_DSTREAM_LIBRARIES | ||
|
|
||
| #define IRODS_FILESYSTEM_ENABLE_SERVER_SIDE_API | ||
| #include <irods/filesystem.hpp> | ||
|
|
@@ -340,16 +350,58 @@ namespace | |
| { | ||
| try { | ||
| const std::string object_id = get_object_index_id(_rei, _object_path); | ||
| std::vector<char> buffer(config->read_size); | ||
| irods::experimental::io::server::basic_transport<char> xport(*_rei->rsComm); | ||
| irods::experimental::io::idstream in{xport, _object_path}; | ||
|
|
||
| std::vector<char> buffer(config->read_size); | ||
| int chunk_counter{0}; | ||
| bool need_final_perform{false}; | ||
| std::stringstream ss; | ||
|
|
||
| #ifdef IRODS_HAS_FEATURE_ADMIN_MODE_FOR_DSTREAM_LIBRARIES | ||
| irods::experimental::io::server::basic_transport<char> xport(*_rei->rsComm); | ||
| irods::experimental::io::idstream in{xport, _object_path}; // TODO Add admin mode option when available. | ||
|
|
||
| while (in) { | ||
| in.read(buffer.data(), buffer.size()); | ||
| #else | ||
| DataObjInp obj_input{}; | ||
| irods::at_scope_exit free_obj_input{[&obj_input] { clearKeyVal(&obj_input.condInput); }}; | ||
|
|
||
| obj_input.dataSize = -1; | ||
| obj_input.openFlags = O_RDONLY; | ||
|
|
||
| _object_path.copy(obj_input.objPath, sizeof(obj_input.objPath) - 1); | ||
|
|
||
| // Add the admin keyword if the user invoking this is a rodsadmin. | ||
| // This primarily applies when the rule is invoked via irule by a rodsadmin and | ||
| // the rodsadmin does not have read permissions on the data object. | ||
| if (irods::is_privileged_client(*_rei->rsComm)) { | ||
| addKeyVal(&obj_input.condInput, ADMIN_KW, ""); | ||
| } | ||
|
|
||
| char* json_output{}; | ||
| irods::at_scope_exit free_json_output{[&json_output] { std::free(json_output); }}; | ||
|
|
||
| // We use rs_replica_open to ease policy management for admins. | ||
| // If we chose to use rsDataObjOpen, that means the admin has to worry about | ||
| // the PEP changing after dstream grows support for admin mode. | ||
| const auto fd = rs_replica_open(_rei->rsComm, &obj_input, &json_output); | ||
| if (fd < 3) { | ||
| THROW(fd, fmt::format("Could not open data object [{}] for reading", _object_path)); | ||
| } | ||
|
|
||
| OpenedDataObjInp read_input{}; | ||
| read_input.l1descInx = fd; | ||
| read_input.len = buffer.size(); | ||
|
|
||
| BytesBuf bbuf_output{}; | ||
| bbuf_output.len = read_input.len; | ||
| bbuf_output.buf = buffer.data(); | ||
|
|
||
| int bytes_read = 0; | ||
|
|
||
| while (true) { | ||
| bytes_read = rsDataObjRead(_rei->rsComm, &read_input, &bbuf_output); | ||
| #endif // IRODS_HAS_FEATURE_ADMIN_MODE_FOR_DSTREAM_LIBRARIES | ||
|
|
||
| // The indexing instruction. | ||
| // clang-format off | ||
|
|
@@ -369,7 +421,13 @@ namespace | |
| // clang-format off | ||
| ss << json{ | ||
| {"absolutePath", _object_path}, | ||
| #ifdef IRODS_HAS_FEATURE_ADMIN_MODE_FOR_DSTREAM_LIBRARIES | ||
| {"data", std::string_view(buffer.data(), in.gcount())} | ||
| #else | ||
| // Take the max to avoid passing an integer that's less than zero to the | ||
| // the string_view constructor. | ||
| {"data", std::string_view(buffer.data(), std::max(0, bytes_read))} | ||
|
Comment on lines
+427
to
+433
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a statement explaining how |
||
| #endif // IRODS_HAS_FEATURE_ADMIN_MODE_FOR_DSTREAM_LIBRARIES | ||
| }.dump(indent, indent_char, ensure_ascii, json::error_handler_t::ignore) << '\n'; | ||
| // clang-format on | ||
|
|
||
|
|
@@ -391,6 +449,16 @@ namespace | |
|
|
||
| ss.str(""); | ||
| } | ||
|
|
||
| #ifndef IRODS_HAS_FEATURE_ADMIN_MODE_FOR_DSTREAM_LIBRARIES | ||
| if (0 == bytes_read) { | ||
| break; | ||
| } | ||
| else if (bytes_read < 0) { | ||
| rodsLog(LOG_ERROR, "%s: Read error on data object [%s]", __func__, _object_path.c_str()); | ||
| break; | ||
| } | ||
| #endif // IRODS_HAS_FEATURE_ADMIN_MODE_FOR_DSTREAM_LIBRARIES | ||
| } | ||
|
|
||
| if (chunk_counter > 0) { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature test macro name is just a placeholder until irods/irods#7530 is resolved.
This PR isn't blocked by that work. Once the irods/irods issue is resolved, these preprocessor macros can be updated to match the real feature test macro.