irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

irods_repl_rebalance.cpp
Go to the documentation of this file.
3 #include "irods_file_object.hpp"
5 #include "irods_virtual_path.hpp"
6 #include "irods_repl_retry.hpp"
7 #include "irods_repl_types.hpp"
9 #include "dataObjRepl.h"
10 #include "genQuery.h"
11 #include "rsGenQuery.hpp"
12 #include "boost/format.hpp"
13 #include "boost/lexical_cast.hpp"
14 #include "rodsError.h"
15 
16 
17 namespace {
18  irods::error repl_for_rebalance(
20  const std::string& _obj_path,
21  const std::string& _current_resc,
22  const std::string& _src_hier,
23  const std::string& _dst_hier,
24  const std::string& _src_resc,
25  const std::string& _dst_resc,
26  const int _mode ) {
27  // =-=-=-=-=-=-=-
28  // generate a resource hierarchy that ends at this resource for pdmo
30  parser.set_string( _src_hier );
31  std::string sub_hier;
32  parser.str( sub_hier, _current_resc );
33 
34  // =-=-=-=-=-=-=-
35  // create a data obj input struct to call rsDataObjRepl which given
36  // the _stage_sync_kw will either stage or sync the data object
37  dataObjInp_t data_obj_inp{};
38  rstrcpy( data_obj_inp.objPath, _obj_path.c_str(), MAX_NAME_LEN );
39  data_obj_inp.createMode = _mode;
40  addKeyVal( &data_obj_inp.condInput, RESC_HIER_STR_KW, _src_hier.c_str() );
41  addKeyVal( &data_obj_inp.condInput, DEST_RESC_HIER_STR_KW, _dst_hier.c_str() );
42  addKeyVal( &data_obj_inp.condInput, RESC_NAME_KW, _src_resc.c_str() );
43  addKeyVal( &data_obj_inp.condInput, DEST_RESC_NAME_KW, _dst_resc.c_str() );
44  addKeyVal( &data_obj_inp.condInput, IN_PDMO_KW, sub_hier.c_str() );
45  addKeyVal( &data_obj_inp.condInput, ADMIN_KW, "" );
46 
47  try {
48  // =-=-=-=-=-=-=-
49  // process the actual call for replication
50  const auto status = data_obj_repl_with_retry( _ctx, data_obj_inp );
51  if ( status < 0 ) {
52  return ERROR( status,
53  boost::format( "Failed to replicate the data object [%s]" ) %
54  _obj_path );
55  }
56  }
57  catch( const irods::exception& e ) {
58  return irods::error( e );
59  }
60 
61  return SUCCESS();
62  }
63 
64  // throws irods::exception
65  sqlResult_t* extract_sql_result(const genQueryInp_t& genquery_inp, genQueryOut_t* genquery_out_ptr, const int column_number) {
66  if (sqlResult_t *sql_result = getSqlResultByInx(genquery_out_ptr, column_number)) {
67  return sql_result;
68  }
69  THROW(
71  boost::format("getSqlResultByInx failed. column [%d] genquery_inp contents:\n%s\n\n possible iquest [%s]") %
72  column_number %
73  genquery_inp_to_diagnostic_string(&genquery_inp) %
74  genquery_inp_to_iquest_string(&genquery_inp));
75  };
76 
77  struct ReplicationSourceInfo {
78  std::string object_path;
79  std::string resource_hierarchy;
80  int data_mode;
81  };
82 
83  // throws irods::exception
84  ReplicationSourceInfo get_source_data_object_attributes(
85  rsComm_t* _comm,
86  const rodsLong_t _data_id,
87  const std::vector<leaf_bundle_t>& _leaf_bundles) {
88 
89  if (!_comm) {
90  THROW(SYS_INTERNAL_NULL_INPUT_ERR, "null comm ptr");
91  }
92 
93  irods::GenQueryInpWrapper genquery_inp_wrapped;
94  genquery_inp_wrapped.get().maxRows = MAX_SQL_ROWS;
95  addInxVal(&genquery_inp_wrapped.get().sqlCondInp, COL_D_DATA_ID, (boost::format("= '%lld'") % _data_id).str().c_str());
96 
97  std::stringstream cond_ss;
98  for (auto& bun : _leaf_bundles) {
99  for (auto id : bun) {
100  cond_ss << "= '" << id << "' || ";
101  }
102  }
103  std::string cond_str = cond_ss.str().substr(0, cond_ss.str().size()-4);
104  addInxVal(&genquery_inp_wrapped.get().sqlCondInp, COL_D_RESC_ID, cond_str.c_str());
105 
106  addInxVal(&genquery_inp_wrapped.get().sqlCondInp, COL_D_REPL_STATUS, "= '1'");
107 
108  addInxIval(&genquery_inp_wrapped.get().selectInp, COL_DATA_NAME, 1);
109  addInxIval(&genquery_inp_wrapped.get().selectInp, COL_COLL_NAME, 1);
110  addInxIval(&genquery_inp_wrapped.get().selectInp, COL_DATA_MODE, 1);
111  addInxIval(&genquery_inp_wrapped.get().selectInp, COL_D_RESC_ID, 1);
112 
113  irods::GenQueryOutPtrWrapper genquery_out_ptr_wrapped;
114  const int status_rsGenQuery = rsGenQuery(_comm, &genquery_inp_wrapped.get(), &genquery_out_ptr_wrapped.get());
115  if (status_rsGenQuery < 0) {
116  THROW(
117  status_rsGenQuery,
118  boost::format("rsGenQuery failed. genquery_inp contents:\n%s\n\n possible iquest [%s]") %
119  genquery_inp_to_diagnostic_string(&genquery_inp_wrapped.get()) %
120  genquery_inp_to_iquest_string(&genquery_inp_wrapped.get()));
121  }
122 
123  if (!genquery_out_ptr_wrapped.get()) {
124  THROW(
126  boost::format("rsGenQuery failed. genquery_inp contents:\n%s\n\n possible iquest [%s]") %
127  genquery_inp_to_diagnostic_string(&genquery_inp_wrapped.get()) %
128  genquery_inp_to_iquest_string(&genquery_inp_wrapped.get()));
129  }
130 
131 
132  sqlResult_t *data_name_result = extract_sql_result(genquery_inp_wrapped.get(), genquery_out_ptr_wrapped.get(), COL_DATA_NAME);
133  char *data_name = &data_name_result->value[0];
134 
135  sqlResult_t *coll_name_result = extract_sql_result(genquery_inp_wrapped.get(), genquery_out_ptr_wrapped.get(), COL_COLL_NAME);
136  char *coll_name = &coll_name_result->value[0];
137 
138  auto cast_genquery_result = [&genquery_inp_wrapped](char *s) -> rodsLong_t {
139  try {
140  return boost::lexical_cast<rodsLong_t>(s);
141  } catch (const boost::bad_lexical_cast&) {
142  THROW(
144  boost::format("boost::lexical_cast failed. tried to cast [%s]. genquery_inp contents:\n%s\n\n possible iquest [%s]") %
145  s %
146  genquery_inp_to_diagnostic_string(&genquery_inp_wrapped.get()) %
147  genquery_inp_to_iquest_string(&genquery_inp_wrapped.get()));
148  }
149  };
150 
151  sqlResult_t *resc_id_result = extract_sql_result(genquery_inp_wrapped.get(), genquery_out_ptr_wrapped.get(), COL_D_RESC_ID);
152  const rodsLong_t resc_id = cast_genquery_result(&resc_id_result->value[0]);
153 
154  sqlResult_t *data_mode_result = extract_sql_result(genquery_inp_wrapped.get(), genquery_out_ptr_wrapped.get(), COL_DATA_MODE);
155  const int data_mode = cast_genquery_result(&data_mode_result->value[0]);
156 
157  ReplicationSourceInfo ret;
158  ret.object_path = (boost::format("%s%s%s") % coll_name % irods::get_virtual_path_separator() % data_name).str();
159  irods::error err = resc_mgr.leaf_id_to_hier(resc_id, ret.resource_hierarchy);
160  if (!err.ok()) {
161  THROW(err.code(),
162  boost::format("leaf_id_to_hier failed. resc id [%lld] genquery inp:\n%s") %
163  resc_id %
164  genquery_inp_to_diagnostic_string(&genquery_inp_wrapped.get()));
165  }
166  ret.data_mode = data_mode;
167  return ret;
168  }
169 
170  struct ReplicaAndRescId {
171  rodsLong_t data_id;
173  rodsLong_t resource_id;
174  };
175 
176  // throws irods::exception
177  std::vector<ReplicaAndRescId> get_out_of_date_replicas_batch(
178  rsComm_t* _comm,
179  const std::vector<leaf_bundle_t>& _bundles,
180  const std::string& _invocation_timestamp,
181  const int _batch_size) {
182  if (!_comm) {
183  THROW(SYS_INTERNAL_NULL_INPUT_ERR, "null rsComm");
184  }
185  if (_bundles.empty()) {
186  THROW(SYS_INVALID_INPUT_PARAM, "empty bundles");
187  }
188  if (_batch_size <= 0) {
189  THROW(SYS_INVALID_INPUT_PARAM, boost::format("invalid batch size [%d]") % _batch_size);
190  }
191  if (_invocation_timestamp.empty()) {
192  THROW(SYS_INVALID_INPUT_PARAM, "empty invocation timestamp");
193  }
194 
195  irods::GenQueryInpWrapper genquery_inp_wrapped;
196  genquery_inp_wrapped.get().maxRows = _batch_size;
197 
198  std::stringstream cond_ss;
199  for (auto& bun : _bundles) {
200  for (auto id : bun) {
201  cond_ss << "= '" << id << "' || ";
202  }
203  }
204  const std::string cond_str = cond_ss.str().substr(0, cond_ss.str().size()-4);
205  addInxVal(&genquery_inp_wrapped.get().sqlCondInp, COL_D_RESC_ID, cond_str.c_str());
206  addInxVal(&genquery_inp_wrapped.get().sqlCondInp, COL_D_REPL_STATUS, "= '0'");
207  const std::string timestamp_str = "<= '" + _invocation_timestamp + "'";
208  addInxVal(&genquery_inp_wrapped.get().sqlCondInp, COL_D_MODIFY_TIME, timestamp_str.c_str());
209  addInxIval(&genquery_inp_wrapped.get().selectInp, COL_D_DATA_ID, 1);
210  addInxIval(&genquery_inp_wrapped.get().selectInp, COL_DATA_REPL_NUM, 1);
211  addInxIval(&genquery_inp_wrapped.get().selectInp, COL_D_RESC_ID, 1);
212 
213  irods::GenQueryOutPtrWrapper genquery_out_ptr_wrapped;
214  const int status_rsGenQuery = rsGenQuery(_comm, &genquery_inp_wrapped.get(), &genquery_out_ptr_wrapped.get());
215 
216  std::vector<ReplicaAndRescId> ret;
217  if (CAT_NO_ROWS_FOUND == status_rsGenQuery) {
218  return ret;
219  } else if (status_rsGenQuery < 0) {
220  THROW(
221  status_rsGenQuery,
222  boost::format("rsGenQuery failed. genquery_inp contents:\n%s\npossible iquest [%s]") %
223  genquery_inp_to_diagnostic_string(&genquery_inp_wrapped.get()) %
224  genquery_inp_to_iquest_string(&genquery_inp_wrapped.get()));
225  } else if (nullptr == genquery_out_ptr_wrapped.get()) {
226  THROW(
228  boost::format("rsGenQuery failed. genquery_inp contents:\n%s\npossible iquest [%s]") %
229  genquery_inp_to_diagnostic_string(&genquery_inp_wrapped.get()) %
230  genquery_inp_to_iquest_string(&genquery_inp_wrapped.get()));
231  }
232 
233  sqlResult_t *data_id_results = extract_sql_result(genquery_inp_wrapped.get(), genquery_out_ptr_wrapped.get(), COL_D_DATA_ID);
234  sqlResult_t *data_repl_num_results = extract_sql_result(genquery_inp_wrapped.get(), genquery_out_ptr_wrapped.get(), COL_DATA_REPL_NUM);
235  sqlResult_t *data_resc_id_results = extract_sql_result(genquery_inp_wrapped.get(), genquery_out_ptr_wrapped.get(), COL_D_RESC_ID);
236 
237  ret.reserve(genquery_out_ptr_wrapped.get()->rowCnt);
238  for (int i=0; i<genquery_out_ptr_wrapped.get()->rowCnt; ++i) {
239  ReplicaAndRescId repl_and_resc;
240  auto cast_genquery_result = [&genquery_inp_wrapped](int i, char *s) {
241  try {
242  return boost::lexical_cast<rodsLong_t>(s);
243  } catch (const boost::bad_lexical_cast&) {
244  THROW(
246  boost::format("boost::lexical_cast failed. index [%d]. tried to cast [%s]. genquery_inp contents:\n%s\npossible iquest [%s]") %
247  i %
248  s %
249  genquery_inp_to_diagnostic_string(&genquery_inp_wrapped.get()) %
250  genquery_inp_to_iquest_string(&genquery_inp_wrapped.get()));
251  }
252  };
253  repl_and_resc.data_id = cast_genquery_result(i, &data_id_results ->value[data_id_results ->len * i]);
254  repl_and_resc.replica_number = cast_genquery_result(i, &data_repl_num_results->value[data_repl_num_results->len * i]);
255  repl_and_resc.resource_id = cast_genquery_result(i, &data_resc_id_results ->value[data_resc_id_results ->len * i]);
256  ret.push_back(repl_and_resc);
257  }
258  return ret;
259  }
260 
261  // throws irods::exception
262  std::string get_child_name_that_is_ancestor_of_bundle(
263  const std::string& _resc_name,
264  const leaf_bundle_t& _bundle) {
265  std::string hier;
266  irods::error err = resc_mgr.leaf_id_to_hier(_bundle[0], hier);
267  if (!err.ok()) {
268  THROW(err.code(), err.result());
269  }
270 
272  err = parse.set_string(hier);
273  if (!err.ok()) {
274  THROW(err.code(), err.result());
275  }
276 
277  std::string ret;
278  err = parse.next(_resc_name, ret);
279  if (!err.ok()) {
280  THROW(err.code(), err.result());
281  }
282  return ret;
283  }
284 
285  std::string leaf_bundles_to_string(
286  const std::vector<leaf_bundle_t>& _leaf_bundles) {
287  std::stringstream ss;
288  for (auto& b : _leaf_bundles) {
289  ss << '[';
290  for (auto d : b) {
291  ss << d << ", ";
292  }
293  ss << "], ";
294  }
295  return ss.str();
296  }
297 
298  // throws irods::exception
299  void proc_results_for_rebalance(
300  irods::plugin_context& _ctx,
301  const std::string& _parent_resc_name,
302  const std::string& _child_resc_name,
303  const size_t _bun_idx,
304  const std::vector<leaf_bundle_t> _bundles,
305  const dist_child_result_t& _data_ids_to_replicate) {
306  if (!_ctx.comm()) {
308  boost::format("null comm pointer. resource [%s]. child resource [%s]. bundle index [%d]. bundles [%s]") %
309  _parent_resc_name %
310  _child_resc_name %
311  _bun_idx %
312  leaf_bundles_to_string(_bundles));
313  }
314 
315  if (_data_ids_to_replicate.empty()) {
317  boost::format("empty data id list. resource [%s]. child resource [%s]. bundle index [%d]. bundles [%s]") %
318  _parent_resc_name %
319  _child_resc_name %
320  _bun_idx %
321  leaf_bundles_to_string(_bundles));
322  }
323 
324  irods::error first_rebalance_error = SUCCESS();
325  for (auto data_id_to_replicate : _data_ids_to_replicate) {
326  const ReplicationSourceInfo source_info = get_source_data_object_attributes(_ctx.comm(), data_id_to_replicate, _bundles);
327 
328  // create a file object so we can resolve a valid hierarchy to which to replicate
329  irods::file_object_ptr f_ptr(new irods::file_object(_ctx.comm(), source_info.object_path, "", "", 0, source_info.data_mode, 0));
330  // short circuit the magic re-repl
331  {
332  irods::hierarchy_parser sub_parser;
333  sub_parser.set_string(source_info.resource_hierarchy);
334  std::string sub_hier;
335  sub_parser.str(sub_hier, _parent_resc_name);
336  f_ptr->in_pdmo(sub_hier);
337  }
338 
339  // init the parser with the fragment of the upstream hierarchy not including the repl node as it should add itself
341  const size_t pos = source_info.resource_hierarchy.find(_parent_resc_name);
342  if (std::string::npos == pos) {
343  THROW(SYS_INVALID_INPUT_PARAM, boost::format("missing repl name [%s] in source hier string [%s]") % _parent_resc_name % source_info.resource_hierarchy);
344  }
345 
346  // substring hier from the root to the parent resc
347  std::string src_frag = source_info.resource_hierarchy.substr(0, pos + _parent_resc_name.size() + 1);
348  parser.set_string(src_frag);
349 
350  // handy reference to root resc name
351  std::string root_resc;
352  parser.first_resc(root_resc);
353 
354  // resolve the target child resource plugin
355  irods::resource_ptr dst_resc;
356  const irods::error err_resolve = resc_mgr.resolve(_child_resc_name, dst_resc);
357  if (!err_resolve.ok()) {
358  THROW(err_resolve.code(), boost::format("failed to resolve resource plugin. child resc [%s] parent resc [%s] bundle index [%d] bundles [%s] data id [%lld]. resolve message [%s]") %
359  _child_resc_name %
360  _parent_resc_name %
361  _bun_idx %
362  leaf_bundles_to_string(_bundles) %
363  data_id_to_replicate %
364  err_resolve.result());
365  }
366 
367  // then we need to query the target resource and ask it to determine a dest resc hier for the repl
368  std::string host_name;
369  float vote = 0.0;
370  const irods::error err_vote = dst_resc->call<const std::string*, const std::string*, irods::hierarchy_parser*, float*>(
371  _ctx.comm(),
373  f_ptr,
375  &host_name,
376  &parser,
377  &vote );
378  if (!err_vote.ok()) {
379  THROW(err_resolve.code(), boost::format("failed to get dest hierarchy. child resc [%s] parent resc [%s] bundle index [%d] bundles [%s] data id [%lld]. vote message [%s]") %
380  _child_resc_name %
381  _parent_resc_name %
382  _bun_idx %
383  leaf_bundles_to_string(_bundles) %
384  data_id_to_replicate %
385  err_vote.result());
386  }
387 
388  // extract the hier from the parser
389  std::string dst_hier;
390  parser.str(dst_hier);
391  rodsLog(LOG_NOTICE, "proc_results_for_rebalance: creating new replica for data id [%lld] from [%s] on [%s]", data_id_to_replicate, source_info.resource_hierarchy.c_str(), dst_hier.c_str());
392  const irods::error err_rebalance = repl_for_rebalance(
393  _ctx,
394  source_info.object_path,
395  _parent_resc_name,
396  source_info.resource_hierarchy,
397  dst_hier,
398  root_resc,
399  root_resc,
400  source_info.data_mode);
401  if (!err_rebalance.ok()) {
402  if (first_rebalance_error.ok()) {
403  first_rebalance_error = err_rebalance;
404  }
405  rodsLog(LOG_ERROR, "proc_results_for_rebalance: repl_for_rebalance failed. object path [%s] parent resc [%s] source hier [%s] dest hier [%s] root resc [%s] data mode [%d]",
406  source_info.object_path.c_str(), _parent_resc_name.c_str(), source_info.resource_hierarchy.c_str(), dst_hier.c_str(), root_resc.c_str(), source_info.data_mode);
407  irods::log(PASS(err_rebalance));
408  if (_ctx.comm()->rError.len < MAX_ERROR_MESSAGES) {
409  addRErrorMsg(&_ctx.comm()->rError, err_rebalance.code(), err_rebalance.result().c_str());
410  }
411  }
412  }
413 
414  if (!first_rebalance_error.ok()) {
415  THROW(first_rebalance_error.code(),
416  boost::format("proc_results_for_rebalance: repl_for_rebalance failed. child_resc [%s] parent resc [%s]. rebalance message [%s]") %
417  _child_resc_name %
418  _parent_resc_name %
419  first_rebalance_error.result());
420  }
421  }
422 }
423 
424 namespace irods {
425  // throws irods::exception
427  irods::plugin_context& _ctx,
428  const std::vector<leaf_bundle_t>& _leaf_bundles,
429  const int _batch_size,
430  const std::string& _invocation_timestamp,
431  const std::string& _resource_name) {
432 
433  while (true) {
434  const std::vector<ReplicaAndRescId> replicas_to_update = get_out_of_date_replicas_batch(_ctx.comm(), _leaf_bundles, _invocation_timestamp, _batch_size);
435  if (replicas_to_update.empty()) {
436  break;
437  }
438 
439  error first_error = SUCCESS();
440  for (const auto& replica_to_update : replicas_to_update) {
441  std::string destination_hierarchy;
442  const error err_dst_hier = resc_mgr.leaf_id_to_hier(replica_to_update.resource_id, destination_hierarchy);
443  if (!err_dst_hier.ok()) {
444  THROW(err_dst_hier.code(),
445  boost::format("leaf_id_to_hier failed. data id [%lld]. replica number [%d] resource id [%lld]") %
446  replica_to_update.data_id %
447  replica_to_update.replica_number %
448  replica_to_update.resource_id);
449  }
450 
451  ReplicationSourceInfo source_info = get_source_data_object_attributes(_ctx.comm(), replica_to_update.data_id, _leaf_bundles);
453  const error err_parser = hierarchy_parser.set_string(source_info.resource_hierarchy);
454  if (!err_parser.ok()) {
455  THROW(
456  err_parser.code(),
457  boost::format("set_string failed. resource hierarchy [%s]. object path [%s]") %
458  source_info.resource_hierarchy %
459  source_info.object_path);
460  }
461  std::string root_resc;
462  const error err_first_resc = hierarchy_parser.first_resc(root_resc);
463  if (!err_first_resc.ok()) {
464  THROW(
465  err_first_resc.code(),
466  boost::format("first_resc failed. resource hierarchy [%s]. object path [%s]") %
467  source_info.resource_hierarchy %
468  source_info.object_path);
469  }
470 
471  rodsLog(LOG_NOTICE, "update_out_of_date_replicas: updating out-of-date replica for data id [%ji] from [%s] to [%s]",
472  static_cast<intmax_t>(replica_to_update.data_id),
473  source_info.resource_hierarchy.c_str(),
474  destination_hierarchy.c_str());
475  const error err_repl = repl_for_rebalance(
476  _ctx,
477  source_info.object_path,
478  _resource_name,
479  source_info.resource_hierarchy,
480  destination_hierarchy,
481  root_resc,
482  root_resc,
483  source_info.data_mode);
484 
485  if (!err_repl.ok()) {
486  if (first_error.ok()) {
487  first_error = err_repl;
488  }
489  const error error_to_log = PASS(err_repl);
490  if (_ctx.comm()->rError.len < MAX_ERROR_MESSAGES) {
491  addRErrorMsg(&_ctx.comm()->rError, error_to_log.code(), error_to_log.result().c_str());
492  }
494  "update_out_of_date_replicas: repl_for_rebalance failed with code [%ji] and message [%s]. object [%s] source hierarchy [%s] data id [%ji] destination repl num [%ji] destination hierarchy [%s]",
495  static_cast<intmax_t>(err_repl.code()), err_repl.result().c_str(), source_info.object_path.c_str(), source_info.resource_hierarchy.c_str(),
496  static_cast<intmax_t>(replica_to_update.data_id), static_cast<intmax_t>(replica_to_update.replica_number), destination_hierarchy.c_str());
497  }
498  }
499  if (!first_error.ok()) {
500  THROW(first_error.code(), first_error.result());
501  }
502  }
503  }
504 
505  // throws irods::exception
507  irods::plugin_context& _ctx,
508  const std::vector<leaf_bundle_t>& _leaf_bundles,
509  const int _batch_size,
510  const std::string& _invocation_timestamp,
511  const std::string& _resource_name) {
512  for (size_t i=0; i<_leaf_bundles.size(); ++i) {
513  const std::string child_name = get_child_name_that_is_ancestor_of_bundle(_resource_name, _leaf_bundles[i]);
514  while (true) {
515  dist_child_result_t data_ids_needing_new_replicas;
516  const int status_chlGetReplListForLeafBundles = chlGetReplListForLeafBundles(_batch_size, i, &_leaf_bundles, &_invocation_timestamp, &data_ids_needing_new_replicas);
517  if (status_chlGetReplListForLeafBundles != 0) {
518  THROW(status_chlGetReplListForLeafBundles,
519  boost::format("failed to get data objects needing new replicas for resource [%s] bundle index [%d] bundles [%s]")
520  % _resource_name
521  % i
522  % leaf_bundles_to_string(_leaf_bundles));
523  }
524  if (data_ids_needing_new_replicas.empty()) {
525  break;
526  }
527 
528  proc_results_for_rebalance(_ctx, _resource_name, child_name, i, _leaf_bundles, data_ids_needing_new_replicas);
529  }
530  }
531  }
532 } // namespace irods
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
MAX_SQL_ROWS
#define MAX_SQL_ROWS
Definition: rodsGenQuery.h:16
RESC_NAME_KW
#define RESC_NAME_KW
Definition: rodsKeyWdDef.h:19
rsComm_t
Definition: rcConnect.h:145
leaf_bundle_t
irods::resource_manager::leaf_bundle_t leaf_bundle_t
Definition: db_plugin.cpp:54
COL_DATA_REPL_NUM
#define COL_DATA_REPL_NUM
Definition: rodsGenQuery.h:166
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
COL_D_REPL_STATUS
#define COL_D_REPL_STATUS
Definition: rodsGenQuery.h:175
rError_t::len
int len
Definition: rodsError.h:25
SYS_INTERNAL_NULL_INPUT_ERR
@ SYS_INTERNAL_NULL_INPUT_ERR
Definition: rodsErrorTable.h:92
THROW
#define THROW(_code, _msg)
Definition: irods_exception.hpp:68
irods_file_object.hpp
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
resc_mgr
irods::resource_manager resc_mgr
Definition: irods_resource_manager.cpp:31
irods::GenQueryInpWrapper
Definition: rsGenQuery.hpp:9
irods::resource_ptr
boost::shared_ptr< resource > resource_ptr
Definition: irods_resource_types.hpp:11
chlGetReplListForLeafBundles
int chlGetReplListForLeafBundles(rodsLong_t _count, size_t _child_idx, const std::vector< leaf_bundle_t > *_bundles, const std::string *_invocation_timestamp, dist_child_result_t *_results)
Definition: icatHighLevelRoutines.cpp:4665
irods::RESOURCE_OP_RESOLVE_RESC_HIER
const std::string RESOURCE_OP_RESOLVE_RESC_HIER("resource_resolve_hierarchy")
GenQueryInp
Definition: rodsGenQuery.h:24
irods::hierarchy_parser
Definition: irods_hierarchy_parser.hpp:14
irods::experimental::filesystem::replica_number
replica_number
Definition: filesystem.hpp:51
INVALID_LEXICAL_CAST
@ INVALID_LEXICAL_CAST
Definition: rodsErrorTable.h:768
irods::GenQueryInpWrapper::get
genQueryInp_t & get(void)
Definition: rsGenQuery.cpp:179
deploy_schemas_locally.parser
parser
Definition: deploy_schemas_locally.py:59
addInxVal
int addInxVal(inxValPair_t *inxValPair, int inx, const char *value)
Definition: rcMisc.cpp:921
irods::plugin_context
Definition: irods_plugin_context.hpp:18
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
GenQueryInp::selectInp
inxIvalPair_t selectInp
Definition: rodsGenQuery.h:53
GenQueryInp::maxRows
int maxRows
Definition: rodsGenQuery.h:25
irods::GenQueryOutPtrWrapper
Definition: rsGenQuery.hpp:17
rodsError.h
COL_DATA_NAME
#define COL_DATA_NAME
Definition: rodsGenQuery.h:165
irods_resource_plugin.hpp
DEST_RESC_NAME_KW
#define DEST_RESC_NAME_KW
Definition: rodsKeyWdDef.h:20
genquery_inp_to_iquest_string
std::string genquery_inp_to_iquest_string(const genQueryInp_t *q)
Definition: rsGenQuery.cpp:140
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
irods::plugin_context::comm
virtual rsComm_t * comm()
Definition: irods_plugin_context.hpp:95
MAX_ERROR_MESSAGES
#define MAX_ERROR_MESSAGES
Definition: rodsError.h:17
irods::create_missing_replicas
void create_missing_replicas(irods::plugin_context &_ctx, const std::vector< leaf_bundle_t > &_leaf_bundles, const int _batch_size, const std::string &_invocation_timestamp, const std::string &_resource_name)
Definition: irods_repl_rebalance.cpp:506
rsComm_t::rError
rError_t rError
Definition: rcConnect.h:158
irods::error::code
long long code() const
Definition: irods_error.cpp:194
RESC_HIER_STR_KW
#define RESC_HIER_STR_KW
Definition: rodsKeyWdDef.h:225
getSqlResultByInx
sqlResult_t * getSqlResultByInx(genQueryOut_t *genQueryOut, int attriInx)
Definition: rcMisc.cpp:1387
irods::hierarchy_parser::first_resc
error first_resc(std::string &_ret_resc) const
Definition: irods_hierarchy_parser.cpp:96
COL_D_MODIFY_TIME
#define COL_D_MODIFY_TIME
Definition: rodsGenQuery.h:182
irods
Definition: apiHandler.hpp:35
irods::get_virtual_path_separator
std::string get_virtual_path_separator()
Definition: irods_virtual_path.cpp:11
GenQueryInp::sqlCondInp
inxValPair_t sqlCondInp
Definition: rodsGenQuery.h:56
DataObjInp
Definition: dataObjInpOut.h:65
genQuery.h
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
terminate_irods_processes.e
e
Definition: terminate_irods_processes.py:19
irods::resource_manager::resolve
error resolve(std::string, resource_ptr &)
Definition: irods_resource_manager.cpp:51
NULL_VALUE_ERR
@ NULL_VALUE_ERR
Definition: rodsErrorTable.h:669
irods::data_obj_repl_with_retry
int data_obj_repl_with_retry(irods::plugin_context &_ctx, dataObjInp_t &dataObjInp)
Definition: irods_repl_retry.cpp:12
addInxIval
int addInxIval(inxIvalPair_t *inxIvalPair, int inx, int value)
Definition: rcMisc.cpp:883
ADMIN_KW
#define ADMIN_KW
Definition: rodsKeyWdDef.h:62
GenQueryOut
Definition: rodsGenQuery.h:67
addRErrorMsg
int addRErrorMsg(rError_t *myError, int status, const char *msg)
Definition: rcMisc.cpp:121
irods::update_out_of_date_replicas
void update_out_of_date_replicas(irods::plugin_context &_ctx, const std::vector< leaf_bundle_t > &_leaf_bundles, const int _batch_size, const std::string &_invocation_timestamp, const std::string &_resource_name)
Definition: irods_repl_rebalance.cpp:426
irods::hierarchy_parser::set_string
error set_string(const std::string &_resc_hier)
Definition: irods_hierarchy_parser.cpp:36
dist_child_result_t
std::vector< rodsLong_t > dist_child_result_t
Definition: icatHighLevelRoutines.hpp:192
get_irods_version.value
dictionary value
Definition: get_irods_version.py:27
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
GenQueryOut::rowCnt
int rowCnt
Definition: rodsGenQuery.h:68
irods::log
void log(const error &)
Definition: irods_log.cpp:13
DEST_RESC_HIER_STR_KW
#define DEST_RESC_HIER_STR_KW
Definition: rodsKeyWdDef.h:226
irods_repl_rebalance.hpp
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::error
Definition: irods_error.hpp:23
dataObjRepl.h
irods::resource_manager::leaf_id_to_hier
error leaf_id_to_hier(const rodsLong_t &, std::string &)
Definition: irods_resource_manager.cpp:1119
irods::GenQueryOutPtrWrapper::get
genQueryOut_t *& get(void)
Definition: rsGenQuery.cpp:188
SqlResult::value
char * value
Definition: rodsGenQuery.h:64
IN_PDMO_KW
#define IN_PDMO_KW
Definition: rodsKeyWdDef.h:227
irods_hierarchy_parser.hpp
irods::hierarchy_parser::str
error str(std::string &_ret_string, const std::string &_term_resc="") const
Definition: irods_hierarchy_parser.cpp:46
irods::hierarchy_parser::next
error next(const std::string &_current, std::string &_ret_resc) const
Definition: irods_hierarchy_parser.cpp:136
irods::file_object
Definition: irods_file_object.hpp:19
irods_repl_types.hpp
irods_virtual_path.hpp
CAT_NO_ROWS_FOUND
@ CAT_NO_ROWS_FOUND
Definition: rodsErrorTable.h:423
SqlResult
Definition: rodsGenQuery.h:61
irods.six.b
def b(s)
Definition: six.py:606
error
int error
Definition: filesystem.cpp:101
irods::file_object_ptr
boost::shared_ptr< file_object > file_object_ptr
Definition: irods_file_object.hpp:145
COL_COLL_NAME
#define COL_COLL_NAME
Definition: rodsGenQuery.h:189
irods::exception
Definition: irods_exception.hpp:15
SqlResult::len
int len
Definition: rodsGenQuery.h:63
icatHighLevelRoutines.hpp
rsGenQuery.hpp
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
irods_repl_retry.hpp
irods::CREATE_OPERATION
const std::string CREATE_OPERATION("CREATE")
rsGenQuery
int rsGenQuery(rsComm_t *rsComm, genQueryInp_t *genQueryInp, genQueryOut_t **genQueryOut)
Definition: rsGenQuery.cpp:604
genquery_inp_to_diagnostic_string
std::string genquery_inp_to_diagnostic_string(const genQueryInp_t *q)
Definition: rsGenQuery.cpp:133
irods::error::result
std::string result() const
Definition: irods_error.cpp:201
rodsLong_t
long long rodsLong_t
Definition: rodsType.h:32
COL_D_RESC_ID
#define COL_D_RESC_ID
Definition: rodsGenQuery.h:185
COL_D_DATA_ID
#define COL_D_DATA_ID
Definition: rodsGenQuery.h:163
COL_DATA_MODE
#define COL_DATA_MODE
Definition: rodsGenQuery.h:183