Skip to content
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

Support for reporting replicates #131

Merged
merged 5 commits into from
Oct 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@ Options

Prints command line help.

.. program:: baton-list
.. option:: --replicate

Print data object replicate information, in the format described in
:ref:`representing_replicates`.

.. program:: baton-list
.. option:: --silent

Expand Down Expand Up @@ -644,17 +650,6 @@ object checksums are given under the ``checksum`` property.

{"collection:" "/unit/home/user", "data_object": "README.txt", "size": 123456}

In cases where data objects have replicates, the full details of
replication may be displayed, including replicate identity numbers,
status (valid or invalid) and checksum.

.. code-block:: json

{"collection": "/unit/home/user", "data_object": "README.txt",
"replicate": [{"checksum": "2ebec02316ddc3ee64a67c89b5e3140c",
"number": 0,
"valid": true}]}

The above JSON representations of collections and data objects are
sufficient to be passed to baton's ``baton-list`` program, which
fulfils a similar role to the iRODS ``ils`` program, listing data
Expand All @@ -663,6 +658,24 @@ objects and collection contents.
``baton`` ignores JSON properties that it does not recognise, therefore it
is harmless to include extra properties in program input.

.. _representing_replicates:

Representing replicates
=======================

In cases where data objects have replicates, the full details of
replication may be displayed, including replicate identity numbers,
status (valid or invalid), resource name, location and checksum.

.. code-block:: json

{"collection": "/unit/home/user", "data_object": "README.txt",
"replicates": [{"checksum": "2ebec02316ddc3ee64a67c89b5e3140c",
"location": "unit-a-1",
"resource": "test_resource",
"number": 0,
"valid": true}]}

.. _representing_local_paths:

Representing Local Paths
Expand Down Expand Up @@ -914,7 +927,6 @@ modified in 2014-03, the syntax would be:
{"modified": "2014-03-01T00:00:00", "operator": "n>="},
{"modified": "2014-03-31T00:00:00", "operator": "n<"}]}


.. _representing_permissions:

Representing Access Control Lists
Expand Down
16 changes: 9 additions & 7 deletions src/baton.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,10 @@ int set_rods_path(rcComm_t *conn, rodsPath_t *rods_path, char *path) {

int resolve_collection(json_t *object, rcComm_t *conn, rodsEnv *env,
option_flags flags, baton_error_t *error) {
char *collection = NULL;

init_baton_error(error);

char *collection = NULL;
if (!json_is_object(object)) {
set_baton_error(error, -1, "Failed to resolve the iRODS collection: "
"target not a JSON object");
Expand Down Expand Up @@ -986,13 +987,14 @@ json_t *list_replicates(rcComm_t *conn, rodsPath_t *rods_path,
results = do_query(conn, query_in, obj_format.labels, error);
if (error->code != 0) goto error;

results = revmap_replicate_results(results, error);
json_t *mapped = revmap_replicate_results(results, error);
if (error->code != 0) goto error;

logmsg(DEBUG, "Obtained replicates of '%s'", rods_path->outPath);
free_query_input(query_in);
json_decref(results);

return results;
return mapped;

error:
logmsg(ERROR, "Failed to list replicates of '%s': error %d %s",
Expand All @@ -1012,6 +1014,8 @@ int modify_permissions(rcComm_t *conn, rodsPath_t *rods_path,
modAccessControlInp_t mod_perms_in;
int status;

init_baton_error(error);

check_str_arg("owner specifier", owner_specifier, MAX_STR_LEN, error);
if (error->code != 0) goto error;

Expand Down Expand Up @@ -1297,8 +1301,6 @@ static json_t *list_data_object(rcComm_t *conn, rodsPath_t *rods_path,
.labels = { JSON_COLLECTION_KEY, JSON_DATA_OBJECT_KEY } };
}

init_baton_error(error);

query_in = make_query_input(SEARCH_MAX_ROWS, obj_format->num_columns,
obj_format->columns);
query_in = prepare_obj_list(query_in, rods_path, NULL);
Expand Down Expand Up @@ -1336,12 +1338,12 @@ static json_t *list_data_object(rcComm_t *conn, rodsPath_t *rods_path,

static json_t *list_collection(rcComm_t *conn, rodsPath_t *rods_path,
option_flags flags, baton_error_t *error) {
json_t *results = NULL;

int query_flags = DATA_QUERY_FIRST_FG;
collHandle_t coll_handle;
collEnt_t coll_entry;

json_t *results = NULL;

int status = rclOpenCollection(conn, rods_path->outPath, query_flags,
&coll_handle);
if (status < 0) {
Expand Down
Loading