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)  

libroundrobin.cpp
Go to the documentation of this file.
1 #include "msParam.h"
2 #include "miscServerFunct.hpp"
4 
6 #include "irods_file_object.hpp"
12 #include "irods_stacktrace.hpp"
15 
16 #include <iostream>
17 #include <sstream>
18 #include <vector>
19 #include <string>
20 
21 #include <boost/lexical_cast.hpp>
22 #include <boost/function.hpp>
23 #include <boost/any.hpp>
24 
25 
26 
27 
30 template< typename DEST_TYPE >
32  irods::plugin_context& _ctx ) {
33  // =-=-=-=-=-=-=-
34  // ask the context if it is valid
35  irods::error ret = _ctx.valid< DEST_TYPE >();
36  if ( !ret.ok() ) {
37  return PASSMSG( "resource context is invalid", ret );
38 
39  }
40 
41  return SUCCESS();
42 
43 } // round_robin_check_params
44 
49  const std::string& _name,
50  const std::string& _hier,
52  irods::resource_ptr& _resc ) {
53 
54  irods::resource_child_map* cmap_ref;
55  _props.get< irods::resource_child_map* >(
57  cmap_ref );
58 
59  // =-=-=-=-=-=-=-
60  // create a parser and parse the string
62  irods::error err = parse.set_string( _hier );
63  if ( !err.ok() ) {
64  std::stringstream msg;
65  msg << "get_next_child_in_hier - failed in set_string for [";
66  msg << _hier << "]";
67  return PASSMSG( msg.str(), err );
68  }
69 
70  // =-=-=-=-=-=-=-
71  // get the next resource in the series
72  std::string next;
73  err = parse.next( _name, next );
74  if ( !err.ok() ) {
75  std::stringstream msg;
76  msg << "get_next_child_in_hier - failed in next for [";
77  msg << _name << "] for hier ["
78  << _hier << "]";
79  return PASSMSG( msg.str(), err );
80  }
81 
82  // =-=-=-=-=-=-=-
83  // get the next resource from the child map
84  if ( !cmap_ref->has_entry( next ) ) {
85  std::stringstream msg;
86  msg << "get_next_child_in_hier - child map missing entry [";
87  msg << next << "]";
88  return ERROR( CHILD_NOT_FOUND, msg.str() );
89  }
90 
91  // =-=-=-=-=-=-=-
92  // assign resource
93  _resc = (*cmap_ref)[ next ].second;
94 
95  return SUCCESS();
96 
97 } // get_next_child_in_hier
98 
103  const std::string& _name,
104  irods::file_object_ptr& _file_obj,
106  irods::resource_ptr& _resc ) {
107  // =-=-=-=-=-=-=-
108  // set up iteration over physical objects
109  std::vector< irods::physical_object > objs = _file_obj->replicas();
110  std::vector< irods::physical_object >::iterator itr = objs.begin();
111 
112  // =-=-=-=-=-=-=-
113  // check to see if the replica is in this resource, if one is requested
114  for ( ; itr != objs.end(); ++itr ) {
115  // =-=-=-=-=-=-=-
116  // run the hier string through the parser
118  parser.set_string( itr->resc_hier() );
119 
120  // =-=-=-=-=-=-=-
121  // find this resource in the hier
122  if ( !parser.resc_in_hier( _name ) ) {
123  continue;
124  }
125 
126  // =-=-=-=-=-=-=-
127  // if we have a hit, get the resc ptr to the next resc
128  return get_next_child_in_hier(
129  _name,
130  itr->resc_hier(),
131  _props,
132  _resc );
133 
134  } // for itr
135 
136  std::string msg( "no hier found for resc [" );
137  msg += _name + "]";
138  return ERROR(
140  msg );
141 
142 } // get_next_child_for_open_or_write
143 
144 // =-=-=-=-=-=-=-
147 template< typename DEST_TYPE >
149  irods::plugin_context& _ctx,
150  irods::resource_ptr& _resc ) {
151  // =-=-=-=-=-=-=-
152  // check incoming parameters
153  irods::error err = round_robin_check_params< DEST_TYPE >( _ctx );
154  if ( !err.ok() ) {
155  return PASSMSG( "round_robin_get_resc_for_call - bad resource context", err );
156  }
157 
158  // =-=-=-=-=-=-=-
159  // get the object's name
160  std::string name;
161  err = _ctx.prop_map().get< std::string >( irods::RESOURCE_NAME, name );
162  if ( !err.ok() ) {
163  return PASSMSG( "round_robin_get_resc_for_call - failed to get property 'name'.", err );
164  }
165 
166  // =-=-=-=-=-=-=-
167  // get the object's hier string
168  boost::shared_ptr< DEST_TYPE > obj = boost::dynamic_pointer_cast< DEST_TYPE >( _ctx.fco() );
169  std::string hier = obj->resc_hier( );
170 
171  // =-=-=-=-=-=-=-
172  // get the next child pointer given our name and the hier string
173  err = get_next_child_in_hier( name, hier, _ctx.prop_map(), _resc );
174  if ( !err.ok() ) {
175  return PASSMSG( "round_robin_get_resc_for_call - get_next_child_in_hier failed.", err );
176  }
177 
178  return SUCCESS();
179 
180 } // round_robin_get_resc_for_call
181 
184 const std::string NEXT_CHILD_PROP( "round_robin_next_child" );
185 
188 const std::string CHILD_VECTOR_PROP( "round_robin_child_vector" );
189 
192 const std::string OPERATION_PROP( "round_robin_operation" );
193 
197 // NOTE :: this assumes the order in the icat dictates the order of the RR.
198 // the user can override that behavior with applying an index to the
199 // child. should the resc id wrap, this should still work as it
200 // should behave like a circular queue.
203  std::vector< std::string >& _child_vector ) {
204 
205  irods::resource_child_map* cmap_ref;
206  _props.get< irods::resource_child_map* >(
208  cmap_ref );
209 
210  // =-=-=-=-=-=-=-
211  // vector holding all of the children
212  size_t list_size = cmap_ref->size();
213  _child_vector.resize( list_size );
214 
215  // =-=-=-=-=-=-=-
216  // iterate over the children and look for indicies on the
217  // childrens context strings. use those to build the initial
218  // list.
220  for ( itr = cmap_ref->begin();
221  itr != cmap_ref->end();
222  ++itr ) {
223 
224  std::string ctx = itr->second.first;
225  irods::resource_ptr& resc = itr->second.second;
226  if ( !ctx.empty() ) {
227  try {
228  // =-=-=-=-=-=-=-
229  // cast std::string to int index
230  size_t idx = boost::lexical_cast<size_t>( ctx );
231  if ( idx >= list_size ) {
232  irods::log( ERROR( -1, "build_sorted_child_vector - index out of bounds" ) );
233  continue;
234  }
235 
236  // =-=-=-=-=-=-=-
237  // make sure the map at this spot is already empty, could have
238  // duplicate indicies on children
239  if ( !_child_vector[ idx ].empty() ) {
240  std::stringstream msg;
241  msg << "build_sorted_child_vector - child map list is not empty ";
242  msg << "for index " << idx << " colliding with [";
243  msg << _child_vector[ idx ] << "]";
244  irods::log( ERROR( -1, msg.str() ) );
245  continue;
246  }
247 
248  // =-=-=-=-=-=-=-
249  // snag child resource name
250  std::string name;
251  irods::error ret = resc->get_property< std::string >( irods::RESOURCE_NAME, name );
252  if ( !ret.ok() ) {
253  irods::log( ERROR( -1, "build_sorted_child_vector - get property for resource name failed." ) );
254  continue;
255  }
256 
257  // =-=-=-=-=-=-=-
258  // finally add child to the list
259  _child_vector[ idx ] = name;
260 
261  }
262  catch ( const boost::bad_lexical_cast& ) {
263  irods::log( ERROR( -1, "build_sorted_child_vector - lexical cast to size_t failed" ) );
264  }
265 
266  } // if ctx != empty
267 
268  } // for itr
269 
270 
271  // =-=-=-=-=-=-=-
272  // iterate over the children again and add in any in the holes
273  // left from the first pass
274  for ( itr = cmap_ref->begin();
275  itr != cmap_ref->end();
276  ++itr ) {
277 
278  std::string ctx = itr->second.first;
279  irods::resource_ptr& resc = itr->second.second;
280 
281  // =-=-=-=-=-=-=-
282  // skip any resource whose context is not empty
283  // as they should have places already
284  if ( !ctx.empty() ) {
285  continue;
286  }
287 
288  // =-=-=-=-=-=-=-
289  // iterate over the _child_vector and find a hole to
290  // fill in with this resource name
291  bool filled_flg = false;
292  size_t idx = 0;
293  std::vector< std::string >::iterator vitr;
294  for ( vitr = _child_vector.begin();
295  vitr != _child_vector.end();
296  ++vitr ) {
297  if ( vitr->empty() ) {
298  // =-=-=-=-=-=-=-
299  // snag child resource name
300  std::string name;
301  irods::error ret = resc->get_property< std::string >( irods::RESOURCE_NAME, name );
302  if ( !ret.ok() ) {
303  irods::log( ERROR( -1, "build_sorted_child_vector - get property for resource name failed." ) );
304  idx++;
305  continue;
306  }
307 
308  ( *vitr ) = name;
309  filled_flg = true;
310  break;
311 
312  }
313  else {
314  idx++;
315  }
316 
317  } // for vitr
318 
319  // =-=-=-=-=-=-=-
320  // check to ensure that the resc found its way into the list
321  if ( false == filled_flg ) {
322  irods::log( ERROR( -1, "build_sorted_child_vector - failed to find an entry in the resc list" ) );
323  }
324 
325  } // for itr
326 
327 
328  return SUCCESS();
329 
330 } // build_sorted_child_vector
331 
336  irods::plugin_property_map& _prop_map ) {
337  // =-=-=-=-=-=-=-
338  // extract next_child, may be empty for new RR node
339  std::string next_child;
340  _prop_map.get< std::string >( NEXT_CHILD_PROP, next_child );
341 
342  // =-=-=-=-=-=-=-
343  // extract child_vector
344  std::vector< std::string > child_vector;
345  irods::error get_err = _prop_map.get( CHILD_VECTOR_PROP, child_vector );
346  if ( !get_err.ok() ) {
347  std::stringstream msg;
348  msg << "update_next_child_resource - failed to get child vector";
349  return ERROR( -1, msg.str() );
350  }
351 
352  // =-=-=-=-=-=-=-
353  // if the next_child string is empty then the next in the round robin
354  // selection is the first non empty resource in the vector
355  if ( next_child.empty() ) {
356  // =-=-=-=-=-=-=-
357  // scan the child vector for the first non empty position
358  for ( size_t i = 0; i < child_vector.size(); ++i ) {
359  if ( child_vector[ i ].empty() ) {
360  std::stringstream msg;
361  msg << "update_next_child_resource - chlid vector at ";
362  msg << " posittion " << i;
363  irods::log( ERROR( -1, msg.str() ) );
364 
365  }
366  else {
367  next_child = child_vector[ i ];
368  break;
369  }
370 
371  } // for i
372 
373  }
374  else {
375  // =-=-=-=-=-=-=-
376  // scan the child vector for the context string
377  // and select the next position in the series
378  for ( size_t i = 0; i < child_vector.size(); ++i ) {
379  if ( next_child == child_vector[ i ] ) {
380  size_t idx = ( ( i + 1 ) >= child_vector.size() ) ? 0 : i + 1;
381  next_child = child_vector[ idx ];
382  break;
383  }
384 
385  } // for i
386 
387  } // else
388 
389  // =-=-=-=-=-=-=-
390  // if next_child is empty, something went terribly awry
391  if ( next_child.empty() ) {
392  std::stringstream msg;
393  msg << "update_next_child_resource - next_child is empty.";
394  return ERROR( -1, msg.str() );
395  }
396 
397  // =-=-=-=-=-=-=-
398  // assign the next_child to the property map
399  _prop_map.set< std::string >( NEXT_CHILD_PROP, next_child );
400 
401  return SUCCESS();
402 
403 } // update_next_child_resource
404 
405 // =-=-=-=-=-=-=-
410  irods::plugin_property_map& _prop_map ) {
411 
412  irods::resource_child_map* cmap_ref;
413  _prop_map.get< irods::resource_child_map* >(
415  cmap_ref );
416 
417  // =-=-=-=-=-=-=-
418  // trap case where no children are available
419  if ( cmap_ref->empty() ) {
420  return ERROR( -1, "round_robin_start_operation - no children specified" );
421  }
422 
423  // =-=-=-=-=-=-=-
424  // build the initial list of children
425  std::vector< std::string > child_vector;
426  irods::error err = build_sorted_child_vector( _prop_map, child_vector );
427  if ( !err.ok() ) {
428  return PASSMSG( "round_robin_start_operation - failed.", err );
429  }
430 
431  // =-=-=-=-=-=-=-
432  // report children to log
433  for ( size_t i = 0; i < child_vector.size(); ++i ) {
434  rodsLog( LOG_DEBUG, "round_robin_start_operation :: RR Child [%s] at [%d]",
435  child_vector[i].c_str(), i );
436  }
437 
438  // =-=-=-=-=-=-=-
439  // add the child list to the property map
440  err = _prop_map.set< std::vector< std::string > >( CHILD_VECTOR_PROP, child_vector );
441  if ( !err.ok() ) {
442  return PASSMSG( "round_robin_start_operation - failed.", err );
443  }
444 
445  // =-=-=-=-=-=-=-
446  // if the next_child property is empty then we need to populate it
447  // to the first resource in the child vector
448  std::string next_child;
449  err = _prop_map.get< std::string >( NEXT_CHILD_PROP, next_child );
450  if ( err.ok() && next_child.empty() && child_vector.size() > 0 ) {
451  _prop_map.set< std::string >( NEXT_CHILD_PROP, child_vector[ 0 ] );
452  }
453 
454  return SUCCESS();
455 
456 } // round_robin_start_operation
457 
461  irods::plugin_context& _ctx ) {
462  // =-=-=-=-=-=-=-
463  // get the child resc to call
464  irods::resource_ptr resc;
465  irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
466  if ( !err.ok() ) {
467  std::stringstream msg;
468  msg << __FUNCTION__;
469  msg << " - failed.";
470  return PASSMSG( msg.str(), err );
471  }
472 
473  // =-=-=-=-=-=-=-
474  // call create on the child
475  return resc->call( _ctx.comm(), irods::RESOURCE_OP_CREATE, _ctx.fco() );
476 
477 } // round_robin_file_create
478 
479 // =-=-=-=-=-=-=-
480 // interface for POSIX Open
482  irods::plugin_context& _ctx ) {
483  // =-=-=-=-=-=-=-
484  // get the child resc to call
485  irods::resource_ptr resc;
486  irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
487  if ( !err.ok() ) {
488  std::stringstream msg;
489  msg << __FUNCTION__;
490  msg << " - failed.";
491  return PASSMSG( msg.str(), err );
492  }
493 
494  // =-=-=-=-=-=-=-
495  // call open operation on the child
496  return resc->call( _ctx.comm(), irods::RESOURCE_OP_OPEN, _ctx.fco() );
497 
498 } // round_robin_file_open
499 
503  irods::plugin_context& _ctx,
504  void* _buf,
505  int _len ) {
506  // =-=-=-=-=-=-=-
507  // get the child resc to call
508  irods::resource_ptr resc;
509  irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
510  if ( !err.ok() ) {
511  std::stringstream msg;
512  msg << __FUNCTION__;
513  msg << " - failed.";
514  return PASSMSG( msg.str(), err );
515  }
516 
517  // =-=-=-=-=-=-=-
518  // call read on the child
519  return resc->call< void*, int >( _ctx.comm(), irods::RESOURCE_OP_READ, _ctx.fco(), _buf, _len );
520 
521 } // round_robin_file_read
522 
526  irods::plugin_context& _ctx,
527  void* _buf,
528  int _len ) {
529  // =-=-=-=-=-=-=-
530  // get the child resc to call
531  irods::resource_ptr resc;
532  irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
533  if ( !err.ok() ) {
534  std::stringstream msg;
535  msg << __FUNCTION__;
536  msg << " - failed.";
537  return PASSMSG( msg.str(), err );
538  }
539 
540  // =-=-=-=-=-=-=-
541  // call write on the child
542  return resc->call< void*, int >( _ctx.comm(), irods::RESOURCE_OP_WRITE, _ctx.fco(), _buf, _len );
543 
544 } // round_robin_file_write
545 
549  irods::plugin_context& _ctx ) {
550  // =-=-=-=-=-=-=-
551  // get the child resc to call
552  irods::resource_ptr resc;
553  irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
554  if ( !err.ok() ) {
555  std::stringstream msg;
556  msg << __FUNCTION__;
557  msg << " - failed.";
558  return PASSMSG( msg.str(), err );
559  }
560 
561  // =-=-=-=-=-=-=-
562  // call close on the child
563  return resc->call( _ctx.comm(), irods::RESOURCE_OP_CLOSE, _ctx.fco() );
564 
565 } // round_robin_file_close
566 
570  irods::plugin_context& _ctx ) {
571  // =-=-=-=-=-=-=-
572  // get the child resc to call
573  irods::resource_ptr resc;
574  irods::error err = round_robin_get_resc_for_call< irods::data_object >( _ctx, resc );
575  if ( !err.ok() ) {
576  std::stringstream msg;
577  msg << __FUNCTION__;
578  msg << " - failed.";
579  return PASSMSG( msg.str(), err );
580  }
581 
582  // =-=-=-=-=-=-=-
583  // call unlink on the child
584  return resc->call( _ctx.comm(), irods::RESOURCE_OP_UNLINK, _ctx.fco() );
585 
586 } // round_robin_file_unlink
587 
591  irods::plugin_context& _ctx,
592  struct stat* _statbuf ) {
593  // =-=-=-=-=-=-=-
594  // get the child resc to call
595  irods::resource_ptr resc;
596  irods::error err = round_robin_get_resc_for_call< irods::data_object >( _ctx, resc );
597  if ( !err.ok() ) {
598  std::stringstream msg;
599  msg << __FUNCTION__;
600  msg << " - failed.";
601  return PASSMSG( msg.str(), err );
602  }
603 
604  // =-=-=-=-=-=-=-
605  // call stat on the child
606  return resc->call< struct stat* >( _ctx.comm(), irods::RESOURCE_OP_STAT, _ctx.fco(), _statbuf );
607 
608 } // round_robin_file_stat
609 
613  irods::plugin_context& _ctx,
614  long long _offset,
615  int _whence ) {
616  // =-=-=-=-=-=-=-
617  // get the child resc to call
618  irods::resource_ptr resc;
619  irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
620  if ( !err.ok() ) {
621  std::stringstream msg;
622  msg << __FUNCTION__;
623  msg << " - failed.";
624  return PASSMSG( msg.str(), err );
625  }
626 
627  // =-=-=-=-=-=-=-
628  // call lseek on the child
629  return resc->call< long long, int >( _ctx.comm(), irods::RESOURCE_OP_LSEEK, _ctx.fco(), _offset, _whence );
630 
631 } // round_robin_file_lseek
632 
636  irods::plugin_context& _ctx ) {
637  // =-=-=-=-=-=-=-
638  // get the child resc to call
639  irods::resource_ptr resc;
640  irods::error err = round_robin_get_resc_for_call< irods::collection_object >( _ctx, resc );
641  if ( !err.ok() ) {
642  std::stringstream msg;
643  msg << __FUNCTION__;
644  msg << " - failed.";
645  return PASSMSG( msg.str(), err );
646  }
647 
648  // =-=-=-=-=-=-=-
649  // call mkdir on the child
650  return resc->call( _ctx.comm(), irods::RESOURCE_OP_MKDIR, _ctx.fco() );
651 
652 } // round_robin_file_mkdir
653 
657  irods::plugin_context& _ctx ) {
658  // =-=-=-=-=-=-=-
659  // get the child resc to call
660  irods::resource_ptr resc;
661  irods::error err = round_robin_get_resc_for_call< irods::collection_object >( _ctx, resc );
662  if ( !err.ok() ) {
663  std::stringstream msg;
664  msg << __FUNCTION__;
665  msg << " - failed.";
666  return PASSMSG( msg.str(), err );
667  }
668 
669  // =-=-=-=-=-=-=-
670  // call rmdir on the child
671  return resc->call( _ctx.comm(), irods::RESOURCE_OP_RMDIR, _ctx.fco() );
672 
673 } // round_robin_file_rmdir
674 
678  irods::plugin_context& _ctx ) {
679  // =-=-=-=-=-=-=-
680  // get the child resc to call
681  irods::resource_ptr resc;
682  irods::error err = round_robin_get_resc_for_call< irods::collection_object >( _ctx, resc );
683  if ( !err.ok() ) {
684  std::stringstream msg;
685  msg << __FUNCTION__;
686  msg << " - failed.";
687  return PASSMSG( msg.str(), err );
688  }
689 
690  // =-=-=-=-=-=-=-
691  // call opendir on the child
692  return resc->call( _ctx.comm(), irods::RESOURCE_OP_OPENDIR, _ctx.fco() );
693 
694 } // round_robin_file_opendir
695 
696 // =-=-=-=-=-=-=-
699  irods::plugin_context& _ctx ) {
700  // =-=-=-=-=-=-=-
701  // get the child resc to call
702  irods::resource_ptr resc;
703  irods::error err = round_robin_get_resc_for_call< irods::collection_object >( _ctx, resc );
704  if ( !err.ok() ) {
705  std::stringstream msg;
706  msg << __FUNCTION__;
707  msg << " - failed.";
708  return PASSMSG( msg.str(), err );
709  }
710 
711  // =-=-=-=-=-=-=-
712  // call closedir on the child
713  return resc->call( _ctx.comm(), irods::RESOURCE_OP_CLOSEDIR, _ctx.fco() );
714 
715 } // round_robin_file_closedir
716 
720  irods::plugin_context& _ctx,
721  struct rodsDirent** _dirent_ptr ) {
722  // =-=-=-=-=-=-=-
723  // get the child resc to call
724  irods::resource_ptr resc;
725  irods::error err = round_robin_get_resc_for_call< irods::collection_object >( _ctx, resc );
726  if ( !err.ok() ) {
727  std::stringstream msg;
728  msg << __FUNCTION__;
729  msg << " - failed.";
730  return PASSMSG( msg.str(), err );
731  }
732 
733  // =-=-=-=-=-=-=-
734  // call readdir on the child
735  return resc->call< struct rodsDirent** >( _ctx.comm(), irods::RESOURCE_OP_READDIR, _ctx.fco(), _dirent_ptr );
736 
737 } // round_robin_file_readdir
738 
742  irods::plugin_context& _ctx,
743  const char* _new_file_name ) {
744  // =-=-=-=-=-=-=-
745  // get the child resc to call
746  irods::resource_ptr resc;
747  irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
748  if ( !err.ok() ) {
749  std::stringstream msg;
750  msg << __FUNCTION__;
751  msg << " - failed.";
752  return PASSMSG( msg.str(), err );
753  }
754 
755  // =-=-=-=-=-=-=-
756  // call rename on the child
757  return resc->call< const char* >( _ctx.comm(), irods::RESOURCE_OP_RENAME, _ctx.fco(), _new_file_name );
758 
759 } // round_robin_file_rename
760 
764  irods::plugin_context& _ctx ) {
765  // =-=-=-=-=-=-=-
766  // get the child resc to call
767  irods::resource_ptr resc;
768  irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
769  if ( !err.ok() ) {
770  return PASS( err );
771  }
772 
773  // =-=-=-=-=-=-=-
774  // call truncate on the child
775  return resc->call( _ctx.comm(), irods::RESOURCE_OP_TRUNCATE, _ctx.fco() );
776 
777 } // round_robin_file_truncate
778 
782  irods::plugin_context& _ctx ) {
783  // =-=-=-=-=-=-=-
784  // get the child resc to call
785  irods::resource_ptr resc;
786  irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
787  if ( !err.ok() ) {
788  std::stringstream msg;
789  msg << __FUNCTION__;
790  msg << " - failed.";
791  return PASSMSG( msg.str(), err );
792  }
793 
794  // =-=-=-=-=-=-=-
795  // call freespace on the child
796  return resc->call( _ctx.comm(), irods::RESOURCE_OP_FREESPACE, _ctx.fco() );
797 
798 } // round_robin_file_getfs_freespace
799 
805  irods::plugin_context& _ctx,
806  const char* _cache_file_name ) {
807  // =-=-=-=-=-=-=-
808  // get the child resc to call
809  irods::resource_ptr resc;
810  irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
811  if ( !err.ok() ) {
812  std::stringstream msg;
813  msg << __FUNCTION__;
814  msg << " - failed.";
815  return PASSMSG( msg.str(), err );
816  }
817 
818  // =-=-=-=-=-=-=-
819  // call stage on the child
820  return resc->call< const char* >( _ctx.comm(), irods::RESOURCE_OP_STAGETOCACHE, _ctx.fco(), _cache_file_name );
821 
822 } // round_robin_file_stage_to_cache
823 
829  irods::plugin_context& _ctx,
830  const char* _cache_file_name ) {
831  // =-=-=-=-=-=-=-
832  // get the child resc to call
833  irods::resource_ptr resc;
834  irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
835  if ( !err.ok() ) {
836  std::stringstream msg;
837  msg << __FUNCTION__;
838  msg << " - failed.";
839  return PASSMSG( msg.str(), err );
840  }
841 
842  // =-=-=-=-=-=-=-
843  // call synctoarch on the child
844  return resc->call< const char* >( _ctx.comm(), irods::RESOURCE_OP_SYNCTOARCH, _ctx.fco(), _cache_file_name );
845 
846 } // round_robin_file_sync_to_arch
847 
851  irods::plugin_context& _ctx ) {
852  // =-=-=-=-=-=-=-
853  // get the child resc to call
854  irods::resource_ptr resc;
855  irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
856  if ( !err.ok() ) {
857  std::stringstream msg;
858  msg << __FUNCTION__;
859  msg << " - failed.";
860  return PASSMSG( msg.str(), err );
861  }
862 
863  // =-=-=-=-=-=-=-
864  // call registered on the child
865  return resc->call( _ctx.comm(), irods::RESOURCE_OP_REGISTERED, _ctx.fco() );
866 
867 } // round_robin_file_registered
868 
872  irods::plugin_context& _ctx ) {
873  // =-=-=-=-=-=-=-
874  // get the child resc to call
875  irods::resource_ptr resc;
876  irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
877  if ( !err.ok() ) {
878  std::stringstream msg;
879  msg << __FUNCTION__;
880  msg << " - failed.";
881  return PASSMSG( msg.str(), err );
882  }
883 
884  // =-=-=-=-=-=-=-
885  // call unregistered on the child
886  return resc->call( _ctx.comm(), irods::RESOURCE_OP_UNREGISTERED, _ctx.fco() );
887 
888 } // round_robin_file_unregistered
889 
893  irods::plugin_context& _ctx ) {
894  // =-=-=-=-=-=-=-
895  // get the child resc to call
896  irods::resource_ptr resc;
897  irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
898  if ( !err.ok() ) {
899  return PASS( err );
900  }
901 
902  // =-=-=-=-=-=-=-
903  // call modified on the child
904  err = resc->call( _ctx.comm(), irods::RESOURCE_OP_MODIFIED, _ctx.fco() );
905  if ( !err.ok() ) {
906  return PASS( err );
907  }
908 
909  // =-=-=-=-=-=-=-
910  // get the operation property, if it is a create op then we need
911  // to update the next child in the context string
912  std::string operation;
913  err = _ctx.prop_map().get< std::string >(
915  operation );
916  if( err.ok() && irods::CREATE_OPERATION == operation ) {
917  // =-=-=-=-=-=-=-
918  // update the next_child appropriately as the above succeeded
919  err = update_next_child_resource( _ctx.prop_map() );
920  if ( !err.ok() ) {
921  return PASSMSG( "update_next_child_resource failed", err );
922  }
923 
924  // =-=-=-=-=-=-=-
925  // if file modified is successful then we will update the next
926  // child in the round robin within the database
927  std::string name;
928  _ctx.prop_map().get< std::string >( irods::RESOURCE_NAME, name );
929 
930  std::string next_child;
931  _ctx.prop_map().get< std::string >( NEXT_CHILD_PROP, next_child );
932 
934  snprintf(
935  inp.resc_name_,
936  sizeof( inp.resc_name_ ),
937  "%s", name.c_str() );
938  snprintf(
939  inp.context_,
940  sizeof( inp.context_ ),
941  "%s", next_child.c_str() );
943  _ctx.comm(),
944  &inp );
945  if ( status < 0 ) {
946  std::stringstream msg;
947  msg << "failed to update round robin context for [";
948  msg << name << "] with context [" << next_child << "]";
949  return ERROR(
950  status,
951  msg.str() );
952  }
953 
954  } // if get prop
955 
956  return SUCCESS();
957 
958 } // round_robin_file_modified
959 
963  irods::plugin_context& _ctx,
964  const std::string* _opr,
965  const std::string* _curr_host,
966  irods::hierarchy_parser* _out_parser,
967  float* _out_vote ) {
968 
969  // =-=-=-=-=-=-=-
970  // counter and flag
971  int child_ctr = 0;
972  bool child_found = false;
973 
974  irods::resource_child_map* cmap_ref;
977  cmap_ref );
978 
979  // =-=-=-=-=-=-=-
980  // while we have not found a child and have not
981  // exhausted all the children in the map
982  while ( !child_found &&
983  child_ctr < cmap_ref->size() ) {
984  // =-=-=-=-=-=-=-
985  // increment child counter
986  child_ctr++;
987 
988  // =-=-=-=-=-=-=-
989  // get the next_child property
990  std::string next_child;
991  irods::error err = _ctx.prop_map().get< std::string >(
993  next_child );
994  if ( !err.ok() ) {
995  return PASSMSG( "get property for 'next_child' failed.", err );
996 
997  }
998 
999  // =-=-=-=-=-=-=-
1000  // get the next_child resource
1001  if ( !cmap_ref->has_entry( next_child ) ) {
1002  std::stringstream msg;
1003  msg << "child map has no child by name [";
1004  msg << next_child << "]";
1005  return PASSMSG( msg.str(), err );
1006 
1007  }
1008 
1009  // =-=-=-=-=-=-=-
1010  // request our child resource to test it
1011  irods::resource_ptr resc = (*cmap_ref)[ next_child ].second;
1012 
1013  // =-=-=-=-=-=-=-
1014  // get the resource's status
1015  int resc_status = 0;
1016  err = resc->get_property<int>( irods::RESOURCE_STATUS, resc_status );
1017  if ( !err.ok() ) {
1018  return PASSMSG( "failed to get property", err );
1019 
1020  }
1021 
1022  // =-=-=-=-=-=-=-
1023  // forward the 'put' redirect to the appropriate child
1024  err = resc->call < const std::string*,
1025  const std::string*,
1027  float* > (
1028  _ctx.comm(),
1030  _ctx.fco(),
1031  _opr,
1032  _curr_host,
1033  _out_parser,
1034  _out_vote );
1035  if ( !err.ok() ) {
1036  rodsLog(
1037  LOG_ERROR,
1038  "forward of put redirect failed" );
1039  continue;
1040 
1041  }
1042 
1043  if( *_out_vote > 0 ) {
1044  // =-=-=-=-=-=-=-
1045  // we found a valid child, set out variable
1046  child_found = true;
1047 
1048  }
1049  else {
1050  // =-=-=-=-=-=-=-
1051  // update the next_child as we do not have a valid child yet
1052  err = update_next_child_resource( _ctx.prop_map() );
1053  if ( !err.ok() ) {
1054  return PASSMSG( "update_next_child_resource failed", err );
1055 
1056  }
1057 
1058  }
1059 
1060  } // while
1061 
1062  // =-=-=-=-=-=-=-
1063  // return appropriately
1064  if ( child_found ) {
1065  return SUCCESS();
1066 
1067  }
1068  else {
1069  return ERROR( NO_NEXT_RESC_FOUND, "no valid child found" );
1070 
1071  }
1072 
1073 } // get_next_valid_child_resource
1074 
1079  irods::plugin_context& _ctx,
1080  const std::string* _opr,
1081  const std::string* _curr_host,
1082  irods::hierarchy_parser* _out_parser,
1083  float* _out_vote ) {
1084  // =-=-=-=-=-=-=-
1085  // check incoming parameters
1086  irods::error err = round_robin_check_params< irods::file_object >( _ctx );
1087  if ( !err.ok() ) {
1088  return PASSMSG(
1089  "round_robin_resolve_hierarchy - bad resource context", err );
1090  }
1091  if ( !_opr ) {
1092  return ERROR(
1094  "round_robin_resolve_hierarchy - null operation" );
1095  }
1096  if ( !_curr_host ) {
1097  return ERROR(
1099  "round_robin_resolve_hierarchy - null host" );
1100  }
1101  if ( !_out_parser ) {
1102  return ERROR(
1104  "round_robin_resolve_hierarchy - null outgoing hier parser" );
1105  }
1106  if ( !_out_vote ) {
1107  return ERROR(
1109  "round_robin_resolve_hierarchy - null outgoing vote" );
1110  }
1111 
1112  // =-=-=-=-=-=-=-
1113  // set operation property for use in file_modified for
1114  // determining and storing the next child when appropriate
1115  err = _ctx.prop_map().set< std::string >(
1117  *_opr );
1118  if( !err.ok() ) {
1119  return PASS( err );
1120  }
1121 
1122  // =-=-=-=-=-=-=-
1123  // get the object's hier string
1124  irods::file_object_ptr file_obj = boost::dynamic_pointer_cast<
1126  _ctx.fco() );
1127  std::string hier = file_obj->resc_hier( );
1128 
1129  // =-=-=-=-=-=-=-
1130  // get the object's hier string
1131  std::string name;
1132  err = _ctx.prop_map().get< std::string >( irods::RESOURCE_NAME, name );
1133  if ( !err.ok() ) {
1134  return PASSMSG( "failed to get property 'name'.", err );
1135  }
1136 
1137  // =-=-=-=-=-=-=-
1138  // add ourselves into the hierarch before calling child resources
1139  _out_parser->add_child( name );
1140 
1141  // =-=-=-=-=-=-=-
1142  // test the operation to determine which choices to make
1143  if ( irods::OPEN_OPERATION == ( *_opr ) ||
1144  irods::WRITE_OPERATION == ( *_opr ) ||
1145  irods::UNLINK_OPERATION == ( *_opr )) {
1146  // =-=-=-=-=-=-=-
1147  // get the next child pointer in the hierarchy, given our name and the hier string
1148  irods::resource_ptr resc;
1150  name,
1151  file_obj,
1152  _ctx.prop_map(),
1153  resc );
1154  if ( !err.ok() ) {
1155  ( *_out_vote ) = 0.0;
1156  return PASS( err );
1157  }
1158 
1159  // =-=-=-=-=-=-=-
1160  // forward the resolve_hierarchy call to the child for assertion of the whole operation,
1161  // there may be more than a leaf beneath us
1162  return resc->call < const std::string*,
1163  const std::string*,
1165  float* > (
1166  _ctx.comm(),
1168  _ctx.fco(),
1169  _opr,
1170  _curr_host,
1171  _out_parser,
1172  _out_vote );
1173  }
1174  else if ( irods::CREATE_OPERATION == ( *_opr ) ) {
1175  // =-=-=-=-=-=-=-
1176  // get the next available child resource
1178  _ctx,
1179  _opr,
1180  _curr_host,
1181  _out_parser,
1182  _out_vote );
1183  if ( !err.ok() ) {
1184  ( *_out_vote ) = 0.0;
1185  return PASS( err );
1186 
1187  }
1188 
1189  std::string hier;
1190  _out_parser->str( hier );
1191  rodsLog(
1192  LOG_DEBUG,
1193  "round robin - create :: resc hier [%s] vote [%f]",
1194  hier.c_str(),
1195  *_out_vote );
1196 
1197  return SUCCESS();
1198  }
1199 
1200  // =-=-=-=-=-=-=-
1201  // must have been passed a bad operation
1202  std::stringstream msg;
1203  msg << "round_robin_resolve_hierarchy - operation not supported [";
1204  msg << ( *_opr ) << "]";
1205  return ERROR( -1, msg.str() );
1206 
1207 } // round_robin_file_resolve_hierarchy
1208 
1209 // =-=-=-=-=-=-=-
1210 // round_robin_file_rebalance - code which would rebalance the subtree
1212  irods::plugin_context& _ctx ) {
1213  irods::resource_child_map* cmap_ref;
1216  cmap_ref );
1217 
1218  // =-=-=-=-=-=-=-
1219  // forward request for rebalance to children
1220  irods::error result = SUCCESS();
1221  irods::resource_child_map::iterator itr = cmap_ref->begin();
1222  for ( ; itr != cmap_ref->end(); ++itr ) {
1223  irods::error ret = itr->second.second->call(
1224  _ctx.comm(),
1226  _ctx.fco() );
1227  if ( !ret.ok() ) {
1228  irods::log( PASS( ret ) );
1229  result = ret;
1230  }
1231  }
1232 
1233  if ( !result.ok() ) {
1234  return PASS( result );
1235  }
1236 
1237  return SUCCESS();
1238 
1239 } // round_robin_file_rebalance
1240 
1241 // =-=-=-=-=-=-=-
1242 // interface for POSIX Open
1244  irods::plugin_context& _ctx,
1245  const std::string* _opr ) {
1246  // =-=-=-=-=-=-=-
1247  // get the child resc to call
1248  irods::resource_ptr resc;
1249  irods::error err = round_robin_get_resc_for_call< irods::file_object >( _ctx, resc );
1250  if ( !err.ok() ) {
1251  std::stringstream msg;
1252  msg << "failed.";
1253  return PASSMSG( msg.str(), err );
1254  }
1255 
1256  // =-=-=-=-=-=-=-
1257  // call open operation on the child
1258  return resc->call< const std::string* >(
1259  _ctx.comm(),
1261  _ctx.fco(),
1262  _opr );
1263 
1264 } // round_robin_file_open
1265 
1266 // =-=-=-=-=-=-=-
1267 // 3. create derived class to handle round_robin file system resources
1268 // necessary to do custom parsing of the context string to place
1269 // any useful values into the property map for reference in later
1270 // operations. semicolon is the preferred delimiter
1272  public:
1273  roundrobin_resource( const std::string& _inst_name,
1274  const std::string& _context ) :
1275  irods::resource( _inst_name, _context ) {
1276  // =-=-=-=-=-=-=-
1277  // assign context string as the next_child string
1278  // in the property map. this is used to keep track
1279  // of the last used child in the vector
1280  properties_.set< std::string >( NEXT_CHILD_PROP, context_ );
1281  rodsLog( LOG_DEBUG, "roundrobin_resource :: next_child [%s]", context_.c_str() );
1282 
1284  }
1285 
1286 }; // class
1287 
1288 // =-=-=-=-=-=-=-
1289 // 4. create the plugin factory function which will return a dynamically
1290 // instantiated object of the previously defined derived resource. use
1291 // the add_operation member to associate a 'call name' to the interfaces
1292 // defined above. for resource plugins these call names are standardized
1293 // as used by the irods facing interface defined in
1294 // server/drivers/src/fileDriver.c
1295 extern "C"
1296 irods::resource* plugin_factory( const std::string& _inst_name,
1297  const std::string& _context ) {
1298  // =-=-=-=-=-=-=-
1299  // 4a. create round_robinfilesystem_resource
1300  roundrobin_resource* resc = new roundrobin_resource( _inst_name, _context );
1301 
1302  // =-=-=-=-=-=-=-
1303  // 4b. map function names to operations. this map will be used to load
1304  // the symbols from the shared object in the delay_load stage of
1305  // plugin loading.
1306  using namespace irods;
1307  using namespace std;
1308  resc->add_operation(
1310  function<error(plugin_context&)>(
1312 
1313  resc->add_operation(
1315  function<error(plugin_context&)>(
1317 
1318  resc->add_operation<void*,int>(
1320  std::function<
1321  error(irods::plugin_context&,void*,int)>(
1323 
1324  resc->add_operation<void*,int>(
1326  function<error(plugin_context&,void*,int)>(
1328 
1329  resc->add_operation(
1331  function<error(plugin_context&)>(
1333 
1334  resc->add_operation(
1336  function<error(plugin_context&)>(
1338 
1339  resc->add_operation<struct stat*>(
1341  function<error(plugin_context&, struct stat*)>(
1343 
1344  resc->add_operation(
1346  function<error(plugin_context&)>(
1348 
1349  resc->add_operation(
1351  function<error(plugin_context&)>(
1353 
1354  resc->add_operation<struct rodsDirent**>(
1356  function<error(plugin_context&,struct rodsDirent**)>(
1358 
1359  resc->add_operation<const char*>(
1361  function<error(plugin_context&, const char*)>(
1363 
1364  resc->add_operation(
1366  function<error(plugin_context&)>(
1368 
1369  resc->add_operation<long long, int>(
1371  function<error(plugin_context&, long long, int)>(
1373 
1374  resc->add_operation(
1376  function<error(plugin_context&)>(
1378 
1379  resc->add_operation(
1381  function<error(plugin_context&)>(
1383 
1384  resc->add_operation<const char*>(
1386  function<error(plugin_context&, const char*)>(
1388 
1389  resc->add_operation<const char*>(
1391  function<error(plugin_context&, const char*)>(
1393 
1394  resc->add_operation(
1396  function<error(plugin_context&)>(
1398 
1399  resc->add_operation(
1401  function<error(plugin_context&)>(
1403 
1404  resc->add_operation(
1406  function<error(plugin_context&)>(
1408 
1409  resc->add_operation<const std::string*>(
1411  function<error(plugin_context&, const std::string*)>(
1413 
1414  resc->add_operation(
1416  function<error(plugin_context&)>(
1418 
1419  resc->add_operation<const std::string*, const std::string*, irods::hierarchy_parser*, float*>(
1421  function<error(plugin_context&,const std::string*, const std::string*, irods::hierarchy_parser*, float*)>(
1423 
1424  resc->add_operation(
1426  function<error(plugin_context&)>(
1428 
1429  // =-=-=-=-=-=-=-
1430  // set some properties necessary for backporting to iRODS legacy code
1431  resc->set_property< int >( irods::RESOURCE_CHECK_PATH_PERM, 2 );//DO_CHK_PATH_PERM );
1432  resc->set_property< int >( irods::RESOURCE_CREATE_PATH, 1 );//CREATE_PATH );
1433 
1434  // =-=-=-=-=-=-=-
1435  // 4c. return the pointer through the generic interface of an
1436  // irods::resource pointer
1437  return dynamic_cast<irods::resource*>( resc );
1438 
1439 } // plugin_factory
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
irods_physical_object.hpp
irods.pyparsing.empty
empty
Definition: pyparsing.py:3430
irods::lookup_table< boost::any >
OPERATION_PROP
const std::string OPERATION_PROP("round_robin_operation")
irods::RESOURCE_NAME
const std::string RESOURCE_NAME("resource_property_name")
irods::RESOURCE_OP_STAT
const std::string RESOURCE_OP_STAT("resource_stat")
roundrobin_resource::roundrobin_resource
roundrobin_resource(const std::string &_inst_name, const std::string &_context)
Definition: libroundrobin.cpp:1273
round_robin_file_create
irods::error round_robin_file_create(irods::plugin_context &_ctx)
Definition: libroundrobin.cpp:460
msParam.h
irods::plugin_context::valid
virtual error valid()
Definition: irods_plugin_context.hpp:77
irods.six.next
next
Definition: six.py:518
round_robin_file_closedir
irods::error round_robin_file_closedir(irods::plugin_context &_ctx)
Definition: libroundrobin.cpp:698
irods::resource
Definition: irods_resource_plugin.hpp:25
irods::RESOURCE_CHECK_PATH_PERM
const std::string RESOURCE_CHECK_PATH_PERM("resource_property_check_path_perm")
irods::RESOURCE_OP_MODIFIED
const std::string RESOURCE_OP_MODIFIED("resource_modified")
round_robin_file_readdir
irods::error round_robin_file_readdir(irods::plugin_context &_ctx, struct rodsDirent **_dirent_ptr)
Definition: libroundrobin.cpp:719
irods_file_object.hpp
irods::RESOURCE_OP_CLOSEDIR
const std::string RESOURCE_OP_CLOSEDIR("resource_closedir")
irods_stacktrace.hpp
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
round_robin_file_notify
irods::error round_robin_file_notify(irods::plugin_context &_ctx, const std::string *_opr)
Definition: libroundrobin.cpp:1243
irods_collection_object.hpp
irods::resource_ptr
boost::shared_ptr< resource > resource_ptr
Definition: irods_resource_types.hpp:11
irods::RESOURCE_OP_RESOLVE_RESC_HIER
const std::string RESOURCE_OP_RESOLVE_RESC_HIER("resource_resolve_hierarchy")
irods::RESOURCE_OP_READDIR
const std::string RESOURCE_OP_READDIR("resource_readdir")
round_robin_check_params
irods::error round_robin_check_params(irods::plugin_context &_ctx)
Definition: libroundrobin.cpp:31
irods::hierarchy_parser
Definition: irods_hierarchy_parser.hpp:14
round_robin_file_mkdir
irods::error round_robin_file_mkdir(irods::plugin_context &_ctx)
Definition: libroundrobin.cpp:635
round_robin_file_rmdir
irods::error round_robin_file_rmdir(irods::plugin_context &_ctx)
Definition: libroundrobin.cpp:656
irods::lookup_table::begin
iterator begin()
Definition: irods_lookup_table.hpp:53
round_robin_file_close
irods::error round_robin_file_close(irods::plugin_context &_ctx)
Definition: libroundrobin.cpp:548
irods::RESOURCE_OP_READ
const std::string RESOURCE_OP_READ("resource_read")
round_robin_file_modified
irods::error round_robin_file_modified(irods::plugin_context &_ctx)
Definition: libroundrobin.cpp:892
irods::RESOURCE_OP_FREESPACE
const std::string RESOURCE_OP_FREESPACE("resource_freespace")
round_robin_file_getfs_freespace
irods::error round_robin_file_getfs_freespace(irods::plugin_context &_ctx)
Definition: libroundrobin.cpp:781
irods::lookup_table< std::pair< std::string, resource_ptr > >::iterator
irods_hash_map::iterator iterator
Definition: irods_lookup_table.hpp:31
round_robin_file_resolve_hierarchy
irods::error round_robin_file_resolve_hierarchy(irods::plugin_context &_ctx, const std::string *_opr, const std::string *_curr_host, irods::hierarchy_parser *_out_parser, float *_out_vote)
Definition: libroundrobin.cpp:1078
irods::RESOURCE_OP_LSEEK
const std::string RESOURCE_OP_LSEEK("resource_lseek")
get_next_child_for_open_or_write
irods::error get_next_child_for_open_or_write(const std::string &_name, irods::file_object_ptr &_file_obj, irods::plugin_property_map &_props, irods::resource_ptr &_resc)
Definition: libroundrobin.cpp:102
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
deploy_schemas_locally.parser
parser
Definition: deploy_schemas_locally.py:59
irods::plugin_context
Definition: irods_plugin_context.hpp:18
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
generate_iadmin_commands_for_41_to_42_upgrade.name
name
Definition: generate_iadmin_commands_for_41_to_42_upgrade.py:23
round_robin_file_stage_to_cache
irods::error round_robin_file_stage_to_cache(irods::plugin_context &_ctx, const char *_cache_file_name)
Definition: libroundrobin.cpp:804
irods::lookup_table::get
error get(const std::string &_key, ValueType &_val)
Definition: irods_lookup_table.hpp:71
irods_resource_redirect.hpp
irods::resource::resource
resource(const std::string &_inst, const std::string &_ctx)
Definition: irods_resource_plugin.hpp:29
irods::RESOURCE_STATUS
const std::string RESOURCE_STATUS("resource_property_status")
irods::plugin_base::set_property
error set_property(const std::string &_key, const T &_val)
Definition: irods_plugin_base.hpp:304
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
round_robin_file_unregistered
irods::error round_robin_file_unregistered(irods::plugin_context &_ctx)
Definition: libroundrobin.cpp:871
round_robin_get_resc_for_call
irods::error round_robin_get_resc_for_call(irods::plugin_context &_ctx, irods::resource_ptr &_resc)
Definition: libroundrobin.cpp:148
round_robin_file_sync_to_arch
irods::error round_robin_file_sync_to_arch(irods::plugin_context &_ctx, const char *_cache_file_name)
Definition: libroundrobin.cpp:828
irods::lookup_table::size
int size() const
Definition: irods_lookup_table.hpp:38
irods_resource_plugin.hpp
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
irods::plugin_context::comm
virtual rsComm_t * comm()
Definition: irods_plugin_context.hpp:95
irods::RESOURCE_OP_TRUNCATE
const std::string RESOURCE_OP_TRUNCATE("resource_truncate")
irods_string_tokenize.hpp
irods::RESOURCE_OP_RENAME
const std::string RESOURCE_OP_RENAME("resource_rename")
irods::OPEN_OPERATION
const std::string OPEN_OPERATION("OPEN")
get_next_valid_child_resource
irods::error get_next_valid_child_resource(irods::plugin_context &_ctx, const std::string *_opr, const std::string *_curr_host, irods::hierarchy_parser *_out_parser, float *_out_vote)
Definition: libroundrobin.cpp:962
irods.pypyodbc.long
long
Definition: pypyodbc.py:43
irods::plugin_context::prop_map
virtual irods::plugin_property_map & prop_map()
Definition: irods_plugin_context.hpp:99
round_robin_file_rebalance
irods::error round_robin_file_rebalance(irods::plugin_context &_ctx)
Definition: libroundrobin.cpp:1211
irods::lookup_table::empty
bool empty() const
Definition: irods_lookup_table.hpp:50
LOG_DEBUG
#define LOG_DEBUG
Definition: rodsLog.h:23
irods::plugin_base::properties_
plugin_property_map properties_
Definition: irods_plugin_base.hpp:332
irods::hierarchy_parser::add_child
error add_child(const std::string &_resc)
Definition: irods_hierarchy_parser.cpp:88
irods::RESOURCE_OP_CREATE
const std::string RESOURCE_OP_CREATE("resource_create")
irods
Definition: apiHandler.hpp:35
round_robin_file_open
irods::error round_robin_file_open(irods::plugin_context &_ctx)
Definition: libroundrobin.cpp:481
round_robin_file_registered
irods::error round_robin_file_registered(irods::plugin_context &_ctx)
Definition: libroundrobin.cpp:850
get_next_child_in_hier
irods::error get_next_child_in_hier(const std::string &_name, const std::string &_hier, irods::plugin_property_map &_props, irods::resource_ptr &_resc)
Definition: libroundrobin.cpp:48
round_robin_file_write
irods::error round_robin_file_write(irods::plugin_context &_ctx, void *_buf, int _len)
Definition: libroundrobin.cpp:525
irods::RESOURCE_OP_NOTIFY
const std::string RESOURCE_OP_NOTIFY("resource_notify")
irods::data_object::resc_hier
virtual std::string resc_hier() const
Definition: irods_data_object.hpp:77
round_robin_file_unlink
irods::error round_robin_file_unlink(irods::plugin_context &_ctx)
Definition: libroundrobin.cpp:569
irods::RESOURCE_CREATE_PATH
const std::string RESOURCE_CREATE_PATH("resource_property_create_path")
irods::RESOURCE_OP_WRITE
const std::string RESOURCE_OP_WRITE("resource_write")
round_robin_start_operation
irods::error round_robin_start_operation(irods::plugin_property_map &_prop_map)
Definition: libroundrobin.cpp:409
build_sorted_child_vector
irods::error build_sorted_child_vector(irods::plugin_property_map &_props, std::vector< std::string > &_child_vector)
Definition: libroundrobin.cpp:201
irods::lookup_table::has_entry
bool has_entry(KeyType _k) const
Definition: irods_lookup_table.hpp:41
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
round_robin_file_stat
irods::error round_robin_file_stat(irods::plugin_context &_ctx, struct stat *_statbuf)
Definition: libroundrobin.cpp:590
irods::RESOURCE_OP_CLOSE
const std::string RESOURCE_OP_CLOSE("resource_close")
setRoundRobinContextInp_t
Definition: set_round_robin_context.h:7
irods::log
void log(const error &)
Definition: irods_log.cpp:13
irods::RESC_CHILD_MAP_PROP
const std::string RESC_CHILD_MAP_PROP("resource_child_map_property")
rodsDirent
Definition: rodsType.h:70
irods::RESOURCE_OP_UNLINK
const std::string RESOURCE_OP_UNLINK("resource_unlink")
irods::RESOURCE_OP_RMDIR
const std::string RESOURCE_OP_RMDIR("resource_rmdir")
irods::lookup_table::end
iterator end()
Definition: irods_lookup_table.hpp:56
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::RESOURCE_OP_UNREGISTERED
const std::string RESOURCE_OP_UNREGISTERED("resource_unregistered")
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
round_robin_file_rename
irods::error round_robin_file_rename(irods::plugin_context &_ctx, const char *_new_file_name)
Definition: libroundrobin.cpp:741
irods::RESOURCE_OP_REGISTERED
const std::string RESOURCE_OP_REGISTERED("resource_registered")
round_robin_file_lseek
irods::error round_robin_file_lseek(irods::plugin_context &_ctx, long long _offset, int _whence)
Definition: libroundrobin.cpp:612
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::plugin_base::set_start_operation
void set_start_operation(maintenance_operation_t _op)
Definition: irods_plugin_base.hpp:309
NEXT_CHILD_PROP
const std::string NEXT_CHILD_PROP("round_robin_next_child")
irods::file_object
Definition: irods_file_object.hpp:19
irods::RESOURCE_OP_MKDIR
const std::string RESOURCE_OP_MKDIR("resource_mkdir")
round_robin_file_truncate
irods::error round_robin_file_truncate(irods::plugin_context &_ctx)
Definition: libroundrobin.cpp:763
irods::RESOURCE_OP_OPENDIR
const std::string RESOURCE_OP_OPENDIR("resource_opendir")
irods::RESOURCE_OP_STAGETOCACHE
const std::string RESOURCE_OP_STAGETOCACHE("resource_stagetocache")
roundrobin_resource
Definition: libroundrobin.cpp:1271
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
irods::WRITE_OPERATION
const std::string WRITE_OPERATION("WRITE")
irods::plugin_base::add_operation
error add_operation(const std::string &_op, std::function< error(plugin_context &)> _f)
Definition: irods_plugin_base.hpp:122
irods::plugin_context::fco
virtual first_class_object_ptr fco()
Definition: irods_plugin_context.hpp:102
irods::RESOURCE_OP_SYNCTOARCH
const std::string RESOURCE_OP_SYNCTOARCH("resource_synctoarch")
irods_server_api_call.hpp
CHILD_NOT_FOUND
@ CHILD_NOT_FOUND
Definition: rodsErrorTable.h:753
round_robin_file_opendir
irods::error round_robin_file_opendir(irods::plugin_context &_ctx)
Definition: libroundrobin.cpp:677
set_round_robin_context.h
irods::plugin_base::context_
std::string context_
Definition: irods_plugin_base.hpp:326
size
long long size
Definition: filesystem.cpp:102
rsSetRoundRobinContext
int rsSetRoundRobinContext(rsComm_t *, setRoundRobinContextInp_t *)
Definition: rsSetRoundRobinContext.cpp:16
irods::RESOURCE_OP_REBALANCE
const std::string RESOURCE_OP_REBALANCE("resource_rebalance")
NO_NEXT_RESC_FOUND
@ NO_NEXT_RESC_FOUND
Definition: rodsErrorTable.h:754
plugin_factory
irods::resource * plugin_factory(const std::string &_inst_name, const std::string &_context)
Definition: libroundrobin.cpp:1296
irods::lookup_table::set
error set(const std::string &_key, const ValueType &_val)
Definition: irods_lookup_table.hpp:83
round_robin_file_read
irods::error round_robin_file_read(irods::plugin_context &_ctx, void *_buf, int _len)
Definition: libroundrobin.cpp:502
CHILD_VECTOR_PROP
const std::string CHILD_VECTOR_PROP("round_robin_child_vector")
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
rsSetRoundRobinContext.hpp
update_next_child_resource
irods::error update_next_child_resource(irods::plugin_property_map &_prop_map)
Definition: libroundrobin.cpp:335
irods::RESOURCE_OP_OPEN
const std::string RESOURCE_OP_OPEN("resource_open")
irods::CREATE_OPERATION
const std::string CREATE_OPERATION("CREATE")
irods::UNLINK_OPERATION
const std::string UNLINK_OPERATION("UNLINK")