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)  

libcompound.cpp
Go to the documentation of this file.
1 // =-=-=-=-=-=-=-
2 // irods includes
3 #include "msParam.h"
4 #include "generalAdmin.h"
5 #include "physPath.hpp"
6 #include "reIn2p3SysRule.hpp"
7 #include "miscServerFunct.hpp"
8 #include "dataObjRepl.h"
9 #include "rsDataObjRepl.hpp"
10 
11 // =-=-=-=-=-=-=-
13 #include "irods_file_object.hpp"
19 #include "irods_stacktrace.hpp"
21 #include "irods_lexical_cast.hpp"
22 
23 // =-=-=-=-=-=-=-
24 // stl includes
25 #include <iostream>
26 #include <sstream>
27 #include <vector>
28 #include <string>
29 
30 // =-=-=-=-=-=-=-
31 // boost includes
32 #include <boost/lexical_cast.hpp>
33 #include <boost/function.hpp>
34 #include <boost/any.hpp>
35 
39 const std::string OPERATION_TYPE( "operation_type" );
40 
43 const std::string CACHE_CONTEXT_TYPE( "cache" );
44 
47 const std::string ARCHIVE_CONTEXT_TYPE( "archive" );
48 
50 const std::string AUTO_REPL_POLICY( "auto_repl" );
51 
53 const std::string AUTO_REPL_POLICY_ENABLED( "on" );
54 
57 template< typename DEST_TYPE >
59  irods::plugin_context& _ctx ) {
60  // =-=-=-=-=-=-=-
61  // ask the context if it is valid
62  irods::error ret = _ctx.valid< DEST_TYPE >();
63  if ( !ret.ok() ) {
64  return PASSMSG( "resource context is invalid", ret );
65 
66  }
67 
68  return SUCCESS();
69 
70 } // compound_check_param
71 
72 // =-=-=-=-=-=-=-
75 template< typename DEST_TYPE >
78  irods::resource_ptr& _resc ) {
79  // =-=-=-=-=-=-=-
80  // check the context for validity
81  irods::error ret = compound_check_param< DEST_TYPE >( _ctx );
82  if ( !ret.ok() ) {
83  return PASSMSG( "invalid resource context", ret );
84  }
85  // =-=-=-=-=-=-=-
86  // get the resource name
87  std::string name;
88  ret = _ctx.prop_map().get< std::string >( irods::RESOURCE_NAME, name );
89  if ( !ret.ok() ) {
90  PASS( ret );
91  }
92 
93  // =-=-=-=-=-=-=-
94  // get the resource after this resource
96  boost::shared_ptr< DEST_TYPE > dst_obj = boost::dynamic_pointer_cast< DEST_TYPE >( _ctx.fco() );
97  parser.set_string( dst_obj->resc_hier() );
98  std::string child;
99  ret = parser.next( name, child );
100  if ( !ret.ok() ) {
101  PASS( ret );
102  }
103 
104  irods::resource_child_map* cmap_ref;
107  cmap_ref );
108 
109  // =-=-=-=-=-=-=-
110  // extract the next resource from the child map
111  if ( cmap_ref->has_entry( child ) ) {
112  std::pair< std::string, irods::resource_ptr > resc_pair;
113  ret = cmap_ref->get( child, resc_pair );
114  if ( !ret.ok() ) {
115  return PASS( ret );
116  }
117  else {
118  _resc = resc_pair.second;
119  return SUCCESS();
120  }
121 
122  }
123  else {
124  std::stringstream msg;
125  msg << "child not found [" << child << "]";
126  return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
127 
128  }
129 
130 } // get_next_child
131 
135  irods::plugin_context& _ctx,
136  irods::resource_ptr& _resc ) {
137  // =-=-=-=-=-=-=-
138  // check the context for validity
139  irods::error ret = compound_check_param< irods::file_object >( _ctx );
140  if ( !ret.ok() ) {
141  return PASSMSG( "invalid resource context", ret );
142  }
143 
144  // =-=-=-=-=-=-=-
145  // get the cache name
146  std::string resc_name;
147  ret = _ctx.prop_map().get< std::string >( CACHE_CONTEXT_TYPE, resc_name );
148  if ( !ret.ok() ) {
149  return PASS( ret );
150  }
151 
152  // =-=-=-=-=-=-=-
153  // extract the resource from the child map
154  irods::resource_child_map* cmap_ref;
157  cmap_ref );
158 
159  std::pair< std::string, irods::resource_ptr > resc_pair;
160  ret = cmap_ref->get( resc_name, resc_pair );
161  if ( !ret.ok() ) {
162  std::stringstream msg;
163  msg << "failed to get child resource [" << resc_name << "]";
164  return PASSMSG( msg.str(), ret );
165  }
166 
167  // =-=-=-=-=-=-=-
168  // assign the resource to the out variable
169  _resc = resc_pair.second;
170 
171  return SUCCESS();
172 
173 } // get_cache
174 
178  irods::plugin_context& _ctx,
179  irods::resource_ptr& _resc ) {
180  // =-=-=-=-=-=-=-
181  // check the context for validity
182  irods::error ret = compound_check_param< irods::file_object >( _ctx );
183  if ( !ret.ok() ) {
184  return PASSMSG( "invalid resource context", ret );
185  }
186 
187  // =-=-=-=-=-=-=-
188  // get the archive name
189  std::string resc_name;
190  ret = _ctx.prop_map().get< std::string >( ARCHIVE_CONTEXT_TYPE, resc_name );
191  if ( !ret.ok() ) {
192  return PASS( ret );
193  }
194 
195  // =-=-=-=-=-=-=-
196  // extract the resource from the child map
197  irods::resource_child_map* cmap_ref;
200  cmap_ref );
201  std::pair< std::string, irods::resource_ptr > resc_pair;
202  ret = cmap_ref->get( resc_name, resc_pair );
203  if ( !ret.ok() ) {
204  std::stringstream msg;
205  msg << "failed to get child resource [" << resc_name << "]";
206  return PASSMSG( msg.str(), ret );
207  }
208 
209  // =-=-=-=-=-=-=-
210  // assign the resource to the out variable
211  _resc = resc_pair.second;
212  return SUCCESS();
213 
214 } // get_archive
215 
218 template< typename DEST_TYPE >
220  irods::plugin_context& _ctx,
221  irods::resource_ptr& _resc ) {
222  irods::error result = SUCCESS();
223  irods::error ret;
224  irods::resource_ptr next_resc;
225 
226  // =-=-=-=-=-=-=-
227  // get the cache resource
228  if ( !( ret = get_cache( _ctx, _resc ) ).ok() ) {
229  std::stringstream msg;
230  msg << "Failed to get cache resource.";
231  result = PASSMSG( msg.str(), ret );
232  }
233 
234  // get the next child resource in the hierarchy
235  else if ( !( ret = get_next_child< DEST_TYPE >( _ctx, next_resc ) ).ok() ) {
236  std::stringstream msg;
237  msg << "Failed to get next child resource.";
238  result = PASSMSG( msg.str(), ret );
239  }
240 
241  // Make sure the file object came from the cache resource
242  else if ( _resc != next_resc ) {
243  boost::shared_ptr< DEST_TYPE > obj = boost::dynamic_pointer_cast< DEST_TYPE >( _ctx.fco() );
244  std::stringstream msg;
245  msg << "Cannot open data object: \"";
246  msg << obj->physical_path();
247  msg << "\" It is stored in an archive resource which is not directly accessible.";
248  result = ERROR( DIRECT_ARCHIVE_ACCESS, msg.str() );
249  }
250 
251  return result;
252 
253 } // get_cache_resc
254 
255 // =-=-=-=-=-=-=-
259  const std::string& _results,
260  std::string& _policy ) {
261  // =-=-=-=-=-=-=-
262  // get a map of the key value pairs
263  irods::kvp_map_t kvp;
265  _results,
266  kvp );
267  if ( !kvp_err.ok() ) {
268  return PASS( kvp_err );
269  }
270 
271  std::string value = kvp[ irods::RESOURCE_STAGE_TO_CACHE_POLICY ];
272  if ( value.empty() ) {
273  return ERROR(
275  "stage policy value not found" );
276  }
277  _policy = value;
278 
279  return SUCCESS();
280 
281 } // get_stage_policy
282 
283 // =-=-=-=-=-=-=-
288  irods::plugin_property_map& _prop_map ) {
289 
290  irods::resource_child_map* cmap_ref;
291  _prop_map.get< irods::resource_child_map* >(
293  cmap_ref );
294 
295  // =-=-=-=-=-=-=-
296  // trap invalid number of children
297  if ( cmap_ref->size() == 0 || cmap_ref->size() > 2 ) {
298  std::stringstream msg;
299  msg << "compound resource: invalid number of children [";
300  msg << cmap_ref->size() << "]";
301  return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
302  }
303 
304  // =-=-=-=-=-=-=-
305  // child map is indexed by name, get first name
306  std::string first_child_name;
307  irods::resource_child_map::iterator itr = cmap_ref->begin();
308  if ( itr == cmap_ref->end() ) {
309  return ERROR( -1, "child map is empty" );
310  }
311 
312  std::string first_child_ctx = itr->second.first;
313  irods::resource_ptr& first_child_resc = itr->second.second;
314  irods::error get_err = first_child_resc->get_property<std::string>( irods::RESOURCE_NAME, first_child_name );
315  if ( !get_err.ok() ) {
316  return PASS( get_err );
317  }
318 
319  // =-=-=-=-=-=-=-
320  // get second name
321  std::string second_child_name;
322  itr++;
323  if ( itr == cmap_ref->end() ) {
324  return ERROR( SYS_INVALID_INPUT_PARAM, "child map has only one entry" );
325  }
326 
327  std::string second_child_ctx = itr->second.first;
328  irods::resource_ptr second_child_resc = itr->second.second;
329  get_err = second_child_resc->get_property<std::string>( irods::RESOURCE_NAME, second_child_name );
330  if ( !get_err.ok() ) {
331  return PASS( get_err );
332  }
333 
334  // =-=-=-=-=-=-=-
335  // now if first name is a cache, store that name as such
336  // otherwise it is the archive
337  // cmap is a hash map whose payload is a pair< string, resource_ptr >
338  // the first of which is the parent-child context string denoting
339  // that either the child is a cache or archive
340  if ( first_child_ctx == CACHE_CONTEXT_TYPE ) {
341  _prop_map[ CACHE_CONTEXT_TYPE ] = first_child_name;
342 
343  }
344  else if ( first_child_ctx == ARCHIVE_CONTEXT_TYPE ) {
345  _prop_map[ ARCHIVE_CONTEXT_TYPE ] = first_child_name;
346 
347  }
348  else {
349  return ERROR( INVALID_RESC_CHILD_CONTEXT, first_child_ctx );
350 
351  }
352 
353  // =-=-=-=-=-=-=-
354  // do the same for the second resource
355  if ( second_child_ctx == CACHE_CONTEXT_TYPE ) {
356  _prop_map[ CACHE_CONTEXT_TYPE ] = second_child_name;
357 
358  }
359  else if ( second_child_ctx == ARCHIVE_CONTEXT_TYPE ) {
360  _prop_map[ ARCHIVE_CONTEXT_TYPE ] = second_child_name;
361 
362  }
363  else {
364  return ERROR( INVALID_RESC_CHILD_CONTEXT, second_child_ctx );
365 
366  }
367 
368  // =-=-=-=-=-=-=-
369  // if both context strings match, this is also an error
370  if ( first_child_ctx == second_child_ctx ) {
371  std::stringstream msg;
372  msg << "matching child context strings :: ";
373  msg << "[" << first_child_ctx << "] vs ";
374  msg << "[" << second_child_ctx << "]";
375  return ERROR( INVALID_RESC_CHILD_CONTEXT, msg.str() );
376 
377  }
378 
379  // =-=-=-=-=-=-=-
380  // and... were done.
381  return SUCCESS();
382 
383 } // compound_start_operation
384 
388  irods::plugin_context& _ctx,
389  const char* _stage_sync_kw ) {
390  irods::error result = SUCCESS();
391 
392  // =-=-=-=-=-=-=-
393  // error check incoming params
394  if ( ( result = ASSERT_ERROR( _stage_sync_kw || strlen( _stage_sync_kw ) != 0, SYS_INVALID_INPUT_PARAM, "Null or empty _stage_sync_kw." ) ).ok() ) {
395 
396  // =-=-=-=-=-=-=-
397  // get the file object from the fco
398  irods::file_object_ptr obj = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
399 
400  // =-=-=-=-=-=-=-
401  // get the root resource to pass to the cond input
403  parser.set_string( obj->resc_hier() );
404 
405  std::string resource;
406  parser.first_resc( resource );
407  // =-=-=-=-=-=-=-
408  // get the parent name
409  std::string parent_id_str;
410  irods::error ret = _ctx.prop_map().get< std::string >( irods::RESOURCE_PARENT, parent_id_str );
411  if ( ( result = ASSERT_PASS( ret, "Failed to get the parent name." ) ).ok() ) {
412 
413  std::string parent_name;
415  parent_id_str,
416  parent_name );
417  if(!ret.ok()) {
418  return PASS(ret);
419  }
420 
421  // =-=-=-=-=-=-=-
422  // get the cache name
423  std::string cache_name;
424  irods::error ret = _ctx.prop_map().get< std::string >( CACHE_CONTEXT_TYPE, cache_name );
425  if ( ( result = ASSERT_PASS( ret, "Failed to get the cache name." ) ).ok() ) {
426 
427  // =-=-=-=-=-=-=-
428  // get the archive name
429  std::string arch_name;
430  ret = _ctx.prop_map().get< std::string >( ARCHIVE_CONTEXT_TYPE, arch_name );
431  if ( ( result = ASSERT_PASS( ret, "Failed to get the archive name." ) ).ok() ) {
432 
433  // =-=-=-=-=-=-=-
434  // manufacture a resc hier to either the archive or the cache resc
435  std::string keyword = _stage_sync_kw;
436  std::string inp_hier = obj->resc_hier();
437 
438  std::string tgt_name, src_name;
439  if ( keyword == STAGE_OBJ_KW ) {
440  tgt_name = cache_name;
441  src_name = arch_name;
442  }
443  else if ( keyword == SYNC_OBJ_KW ) {
444  tgt_name = arch_name;
445  src_name = cache_name;
446  }
447  else {
448  std::stringstream msg;
449  msg << "stage_sync_kw value is unexpected [" << _stage_sync_kw << "]";
450  return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
451  }
452 
453  std::string current_name;
454  ret = _ctx.prop_map().get<std::string>( irods::RESOURCE_NAME, current_name );
455  if ( ( result = ASSERT_PASS( ret, "Failed to get the resource name." ) ).ok() ) {
456  size_t pos = inp_hier.find( parent_name );
457  if ( std::string::npos == pos ) {
458  std::stringstream msg;
459  msg << "parent resc ["
460  << parent_name
461  << "] not in fco resc hier ["
462  << inp_hier
463  << "]";
464  return ERROR(
466  msg.str() );
467  }
468 
469  // =-=-=-=-=-=-=-
470  // Generate src and tgt hiers
471  std::string dst_hier = inp_hier.substr( 0, pos + parent_name.size() );
472  if ( !dst_hier.empty() ) {
474  }
475  dst_hier += current_name +
477  tgt_name;
478 
479  std::string src_hier = inp_hier.substr( 0, pos + parent_name.size() );
480  if ( !src_hier.empty() ) {
482  }
483  src_hier += current_name +
485  src_name;
486 
487  // =-=-=-=-=-=-=-
488  // Generate sub hier to use for pdmo
489  parser.set_string( src_hier );
490  std::string sub_hier;
491  parser.str( sub_hier, current_name );
492 
493  // =-=-=-=-=-=-=-
494  // create a data obj input struct to call rsDataObjRepl which given
495  // the _stage_sync_kw will either stage or sync the data object
496  dataObjInp_t data_obj_inp;
497  bzero( &data_obj_inp, sizeof( data_obj_inp ) );
498  rstrcpy( data_obj_inp.objPath, obj->logical_path().c_str(), MAX_NAME_LEN );
499  data_obj_inp.createMode = obj->mode();
500 
501  copyKeyVal( ( keyValPair_t* )&obj->cond_input(), &data_obj_inp.condInput );
502  rmKeyVal( &data_obj_inp.condInput, PURGE_CACHE_KW ); // do not want to accidentally purge
503 
504  char* no_chk = getValByKey( ( keyValPair_t* )&obj->cond_input(), NO_CHK_COPY_LEN_KW );
505  if ( no_chk ) {
506  addKeyVal( &data_obj_inp.condInput, NO_CHK_COPY_LEN_KW, no_chk );
507  }
508 
509  addKeyVal( &data_obj_inp.condInput, RESC_HIER_STR_KW, src_hier.c_str() );
510  addKeyVal( &data_obj_inp.condInput, DEST_RESC_HIER_STR_KW, dst_hier.c_str() );
511  addKeyVal( &data_obj_inp.condInput, RESC_NAME_KW, resource.c_str() );
512  addKeyVal( &data_obj_inp.condInput, DEST_RESC_NAME_KW, resource.c_str() );
513  addKeyVal( &data_obj_inp.condInput, IN_PDMO_KW, sub_hier.c_str() );
514  addKeyVal( &data_obj_inp.condInput, _stage_sync_kw, "1" );
515 
516  transferStat_t* trans_stat = NULL;
517  int status = rsDataObjRepl( _ctx.comm(), &data_obj_inp, &trans_stat );
518  free( trans_stat );
519  clearKeyVal( &data_obj_inp.condInput );
520  if ( status < 0 ) {
521  std::stringstream msg;
522  msg << "Failed to replicate the data object [" << obj->logical_path() << "] ";
523  msg << "for operation [" << _stage_sync_kw << "]";
524  return ERROR( status, msg.str() );
525  }
526 
527  } // if current_name
528 
529  } // if arch_name
530 
531  } // if cache_name
532 
533  } // if parent name
534 
535  } // if stage_sync_kw
536 
537  return result;
538 
539 } // repl_object
540 
544  irods::plugin_context& _ctx ) {
545  // =-=-=-=-=-=-=-
546  // check the context for validity
547  irods::error ret = compound_check_param< irods::file_object >( _ctx );
548  if ( !ret.ok() ) {
549  return PASSMSG( "invalid resource context", ret );
550  }
551 
552  // =-=-=-=-=-=-=-
553  // get the next child resource
554  irods::resource_ptr resc;
555  ret = get_next_child< irods::file_object >( _ctx, resc );
556  if ( !ret.ok() ) {
557  return PASS( ret );
558  }
559 
560  // =-=-=-=-=-=-=-
561  // forward the call
562  return resc->call( _ctx.comm(), irods::RESOURCE_OP_CREATE, _ctx.fco() );
563 
564 } // compound_file_create
565 
569  irods::plugin_context& _ctx ) {
570  // =-=-=-=-=-=-=-
571  // check the context for validity
572  irods::error ret = compound_check_param< irods::file_object >( _ctx );
573  if ( !ret.ok() ) {
574  return PASSMSG( "invalid resource context", ret );
575  }
576 
577  // =-=-=-=-=-=-=-
578  // get the cache resource
579  irods::resource_ptr cache_resc;
580  if ( !( ret = get_cache_resc< irods::file_object >( _ctx, cache_resc ) ).ok() ) {
581  std::stringstream msg;
582  msg << "Failed to get cache resource.";
583  return PASSMSG( msg.str(), ret );
584  }
585 
586  // =-=-=-=-=-=-=-
587  // forward the call
588  return cache_resc->call( _ctx.comm(), irods::RESOURCE_OP_OPEN, _ctx.fco() );
589 
590 } // compound_file_open
591 
595  irods::plugin_context& _ctx,
596  void* _buf,
597  int _len ) {
598  // =-=-=-=-=-=-=-
599  // check the context for validity
600  irods::error ret = compound_check_param< irods::file_object >( _ctx );
601  if ( !ret.ok() ) {
602  return PASSMSG( "invalid resource context", ret );
603  }
604 
605  // =-=-=-=-=-=-=-
606  // get the cache resource
607  irods::resource_ptr resc;
608  ret = get_cache( _ctx, resc );
609  if ( !ret.ok() ) {
610  return PASSMSG( "Unable to get cache resource.", ret );
611  }
612 
613  // =-=-=-=-=-=-=-
614  // forward the call
615  return resc->call< void*, int >( _ctx.comm(), irods::RESOURCE_OP_READ, _ctx.fco(), _buf, _len );
616 
617 } // compound_file_read
618 
622  irods::plugin_context& _ctx,
623  void* _buf,
624  int _len ) {
625  // =-=-=-=-=-=-=-
626  // check the context for validity
627  irods::error ret = compound_check_param< irods::file_object >( _ctx );
628  if ( !ret.ok() ) {
629  return PASSMSG( "invalid resource context", ret );
630  }
631 
632  // =-=-=-=-=-=-=-
633  // get the cache resource
634  irods::resource_ptr resc;
635  ret = get_cache( _ctx, resc );
636  if ( !ret.ok() ) {
637  return PASS( ret );
638  }
639 
640  // =-=-=-=-=-=-=-
641  // forward the call
642  return resc->call< void*, int >( _ctx.comm(), irods::RESOURCE_OP_WRITE, _ctx.fco(), _buf, _len );
643 
644 } // compound_file_write
645 
649  irods::plugin_context& _ctx ) {
650  // =-=-=-=-=-=-=-
651  // check the context for validity
652  irods::error ret = compound_check_param< irods::file_object >( _ctx );
653  if ( !ret.ok() ) {
654  return PASSMSG( "invalid resource context", ret );
655  }
656 
657  // =-=-=-=-=-=-=-
658  // get the cache resource
659  irods::resource_ptr resc;
660  ret = get_cache( _ctx, resc );
661  if ( !ret.ok() ) {
662  return PASS( ret );
663  }
664 
665  // =-=-=-=-=-=-=-
666  // forward the call
667  ret = resc->call( _ctx.comm(), irods::RESOURCE_OP_CLOSE, _ctx.fco() );
668  if ( !ret.ok() ) {
669  return PASS( ret );
670 
671  }
672 
673  return SUCCESS();
674 
675 } // compound_file_close
676 
680  irods::plugin_context& _ctx ) {
681  // =-=-=-=-=-=-=-
682  // check the context for validity
683  irods::error ret = compound_check_param< irods::data_object >( _ctx );
684  if ( !ret.ok() ) {
685  return PASSMSG( "invalid resource context", ret );
686  }
687 
688  // =-=-=-=-=-=-=-
689  // get the next child resource
690  irods::resource_ptr resc;
691  ret = get_next_child< irods::data_object >( _ctx, resc );
692  if ( !ret.ok() ) {
693  return PASS( ret );
694  }
695 
696  // =-=-=-=-=-=-=-
697  // forward the call
698  return resc->call( _ctx.comm(), irods::RESOURCE_OP_UNLINK, _ctx.fco() );
699 
700 } // compound_file_unlink
701 
705  irods::plugin_context& _ctx,
706  struct stat* _statbuf ) {
707  // =-=-=-=-=-=-=-
708  // check the context for validity
709  irods::error ret = compound_check_param< irods::data_object >( _ctx );
710  if ( !ret.ok() ) {
711  return PASSMSG( "invalid resource context", ret );
712  }
713 
714  // =-=-=-=-=-=-=-
715  // get the next child resource
716  irods::resource_ptr resc;
717  ret = get_next_child< irods::data_object >( _ctx, resc );
718  if ( !ret.ok() ) {
719  return PASS( ret );
720  }
721 
722  // =-=-=-=-=-=-=-
723  // forward the call
724  return resc->call< struct stat* >( _ctx.comm(), irods::RESOURCE_OP_STAT, _ctx.fco(), _statbuf );
725 
726 } // compound_file_stat
727 
731  irods::plugin_context& _ctx,
732  long long _offset,
733  int _whence ) {
734  // =-=-=-=-=-=-=-
735  // check the context for validity
736  irods::error ret = compound_check_param< irods::file_object >( _ctx );
737  if ( !ret.ok() ) {
738  return PASSMSG( "invalid resource context", ret );
739  }
740 
741  // =-=-=-=-=-=-=-
742  // get the next child resource
743  irods::resource_ptr resc;
744  ret = get_next_child< irods::file_object >( _ctx, resc );
745  if ( !ret.ok() ) {
746  return PASS( ret );
747  }
748 
749  // =-=-=-=-=-=-=-
750  // forward the call
751  return resc->call< long long, int >( _ctx.comm(), irods::RESOURCE_OP_LSEEK, _ctx.fco(), _offset, _whence );
752 
753 } // compound_file_lseek
754 
758  irods::plugin_context& _ctx ) {
759  // =-=-=-=-=-=-=-
760  // check the context for validity
761  irods::error ret = compound_check_param< irods::collection_object >( _ctx );
762  if ( !ret.ok() ) {
763  return PASSMSG( "invalid resource context", ret );
764  }
765 
766  // =-=-=-=-=-=-=-
767  // get the next child resource
768  irods::resource_ptr resc;
769  ret = get_next_child< irods::collection_object >( _ctx, resc );
770  if ( !ret.ok() ) {
771  return PASS( ret );
772  }
773 
774  // =-=-=-=-=-=-=-
775  // forward the call
776  return resc->call( _ctx.comm(), irods::RESOURCE_OP_MKDIR, _ctx.fco() );
777 
778 } // compound_file_mkdir
779 
783  irods::plugin_context& _ctx ) {
784  // =-=-=-=-=-=-=-
785  // check the context for validity
786  irods::error ret = compound_check_param< irods::collection_object >( _ctx );
787  if ( !ret.ok() ) {
788  return PASSMSG( "invalid resource context", ret );
789  }
790 
791  // =-=-=-=-=-=-=-
792  // get the next child resource
793  irods::resource_ptr resc;
794  ret = get_next_child< irods::collection_object >( _ctx, resc );
795  if ( !ret.ok() ) {
796  return PASS( ret );
797  }
798 
799  // =-=-=-=-=-=-=-
800  // forward the call
801  return resc->call( _ctx.comm(), irods::RESOURCE_OP_RMDIR, _ctx.fco() );
802 
803 } // compound_file_rmdir
804 
808  irods::plugin_context& _ctx ) {
809  // =-=-=-=-=-=-=-
810  // check the context for validity
811  irods::error ret = compound_check_param< irods::collection_object >( _ctx );
812  if ( !ret.ok() ) {
813  return PASSMSG( "invalid resource context", ret );
814  }
815 
816  // =-=-=-=-=-=-=-
817  // get the next child resource
818  irods::resource_ptr resc;
819  ret = get_next_child< irods::collection_object >( _ctx, resc );
820  if ( !ret.ok() ) {
821  return PASS( ret );
822  }
823 
824  // =-=-=-=-=-=-=-
825  // forward the call
826  return resc->call( _ctx.comm(), irods::RESOURCE_OP_OPENDIR, _ctx.fco() );
827 
828 } // compound_file_opendir
829 
830 // =-=-=-=-=-=-=-
833  irods::plugin_context& _ctx ) {
834  // =-=-=-=-=-=-=-
835  // check the context for validity
836  irods::error ret = compound_check_param< irods::collection_object >( _ctx );
837  if ( !ret.ok() ) {
838  return PASSMSG( "invalid resource context", ret );
839  }
840 
841  // =-=-=-=-=-=-=-
842  // get the next child resource
843  irods::resource_ptr resc;
844  ret = get_next_child< irods::collection_object >( _ctx, resc );
845  if ( !ret.ok() ) {
846  return PASS( ret );
847  }
848 
849  // =-=-=-=-=-=-=-
850  // forward the call
851  return resc->call( _ctx.comm(), irods::RESOURCE_OP_CLOSEDIR, _ctx.fco() );
852 
853 } // compound_file_closedir
854 
858  irods::plugin_context& _ctx,
859  struct rodsDirent** _dirent_ptr ) {
860  // =-=-=-=-=-=-=-
861  // check the context for validity
862  irods::error ret = compound_check_param< irods::collection_object >( _ctx );
863  if ( !ret.ok() ) {
864  return PASSMSG( "invalid resource context", ret );
865  }
866 
867  // =-=-=-=-=-=-=-
868  // get the next child resource
869  irods::resource_ptr resc;
870  ret = get_next_child< irods::collection_object >( _ctx, resc );
871  if ( !ret.ok() ) {
872  return PASS( ret );
873  }
874 
875  // =-=-=-=-=-=-=-
876  // forward the call
877  return resc->call< struct rodsDirent** >( _ctx.comm(), irods::RESOURCE_OP_READDIR, _ctx.fco(), _dirent_ptr );
878 
879 } // compound_file_readdir
880 
884  irods::plugin_context& _ctx,
885  const char* _new_file_name ) {
886  // =-=-=-=-=-=-=-
887  // check the context for validity
888  irods::error ret = compound_check_param< irods::data_object >( _ctx );
889  if ( !ret.ok() ) {
890  return PASSMSG( "invalid resource context", ret );
891  }
892 
893  // =-=-=-=-=-=-=-
894  // get the next child resource
895  irods::resource_ptr resc;
896  ret = get_next_child< irods::data_object >( _ctx, resc );
897  if ( !ret.ok() ) {
898  return PASS( ret );
899  }
900 
901  // =-=-=-=-=-=-=-
902  // forward the call
903  return resc->call<const char*>( _ctx.comm(), irods::RESOURCE_OP_RENAME, _ctx.fco(), _new_file_name );
904 
905 } // compound_file_rename
906 
910  irods::plugin_context& _ctx ) {
911  // =-=-=-=-=-=-=-
912  // check the context for validity
913  irods::error ret = compound_check_param< irods::data_object >( _ctx );
914  if ( !ret.ok() ) {
915  return PASSMSG( "invalid resource context", ret );
916  }
917 
918  // =-=-=-=-=-=-=-
919  // get the next child resource
920  irods::resource_ptr resc;
921  ret = get_next_child< irods::data_object >( _ctx, resc );
922  if ( !ret.ok() ) {
923  return PASS( ret );
924  }
925 
926  // =-=-=-=-=-=-=-
927  // forward the call
928  return resc->call( _ctx.comm(), irods::RESOURCE_OP_TRUNCATE, _ctx.fco() );
929 
930 } // compound_file_truncate
931 
935  irods::plugin_context& _ctx ) {
936  // =-=-=-=-=-=-=-
937  // check the context for validity
938  irods::error ret = compound_check_param< irods::data_object >( _ctx );
939  if ( !ret.ok() ) {
940  return PASSMSG( "invalid resource context", ret );
941  }
942 
943  // =-=-=-=-=-=-=-
944  // get the next child resource
945  irods::resource_ptr resc;
946  ret = get_next_child< irods::data_object >( _ctx, resc );
947  if ( !ret.ok() ) {
948  return PASS( ret );
949  }
950 
951  // =-=-=-=-=-=-=-
952  // forward the call
953  return resc->call(
954  _ctx.comm(),
956  _ctx.fco() );
957 
958 } // compound_file_getfs_freespace
959 
960 
966  irods::plugin_context& _ctx,
967  const char* _cache_file_name ) {
968  // =-=-=-=-=-=-=-
969  // Check the operation parameters and update the physical path
970  irods::error ret = compound_check_param< irods::file_object >( _ctx );
971  if ( !ret.ok() ) {
972  std::stringstream msg;
973  msg << "Invalid resource context";
974  return PASSMSG( msg.str(), ret );
975  }
976 
977  // =-=-=-=-=-=-=-
978  // get the archive resource
979  irods::resource_ptr resc;
980  ret = get_archive( _ctx, resc );
981  if ( !ret.ok() ) {
982  return PASS( ret );
983  }
984 
985  // =-=-=-=-=-=-=-
986  // forward the call to the archive
987  return resc->call< const char* >( _ctx.comm(), irods::RESOURCE_OP_STAGETOCACHE, _ctx.fco(), _cache_file_name );
988 
989 } // compound_file_stage_to_cache
990 
996  irods::plugin_context& _ctx,
997  const char* _cache_file_name ) {
998  // =-=-=-=-=-=-=-
999  // Check the operation parameters and update the physical path
1000  irods::error ret = compound_check_param< irods::file_object >( _ctx );
1001  if ( !ret.ok() ) {
1002  std::stringstream msg;
1003  msg << "Invalid resource context";
1004  return PASSMSG( msg.str(), ret );
1005  }
1006 
1007  // =-=-=-=-=-=-=-
1008  // get the archive resource
1009  irods::resource_ptr resc;
1010  get_archive( _ctx, resc );
1011  if ( !ret.ok() ) {
1012  return PASS( ret );
1013  }
1014 
1015  // =-=-=-=-=-=-=-
1016  // forward the call to the archive
1017  return resc->call< const char* >( _ctx.comm(), irods::RESOURCE_OP_SYNCTOARCH, _ctx.fco(), _cache_file_name );
1018 
1019 } // compound_file_sync_to_arch
1020 
1024  irods::plugin_context& _ctx ) {
1025  // =-=-=-=-=-=-=-
1026  // Check the operation parameters and update the physical path
1027  irods::error ret = compound_check_param< irods::file_object >( _ctx );
1028  if ( !ret.ok() ) {
1029  std::stringstream msg;
1030  msg << "Invalid resource context";
1031  return PASSMSG( msg.str(), ret );
1032  }
1033 
1034  return SUCCESS();
1035 
1036 } // compound_file_registered
1037 
1041  irods::plugin_context& _ctx ) {
1042  // Check the operation parameters and update the physical path
1043  irods::error ret = compound_check_param< irods::file_object >( _ctx );
1044  if ( !ret.ok() ) {
1045  std::stringstream msg;
1046  msg << "Invalid resource context";
1047  return PASSMSG( msg.str(), ret );
1048  }
1049  // NOOP
1050  return SUCCESS();
1051 
1052 } // compound_file_unregistered
1053 
1055  irods::plugin_context& _ctx ) {
1056  std::string auto_repl;
1057  irods::error ret = _ctx.prop_map().get<std::string>(
1059  auto_repl );
1060  if( ret.ok() ) {
1061  if( AUTO_REPL_POLICY_ENABLED != auto_repl ) {
1062  return false;
1063  }
1064  }
1065  return true;
1066 } // auto_replication_is_enabled
1067 
1073  irods::plugin_context& _ctx ) {
1074  irods::error result = SUCCESS();
1075 
1076  // =-=-=-=-=-=-=-
1077  // Check the operation parameters and update the physical path
1078  if( auto_replication_is_enabled( _ctx ) ) {
1079  irods::error ret = compound_check_param< irods::file_object >( _ctx );
1080  if ( ( result = ASSERT_PASS( ret, "Invalid resource context." ) ).ok() ) {
1081  std::string operation;
1082  ret = _ctx.prop_map().get< std::string >( OPERATION_TYPE, operation );
1083  if ( ret.ok() ) {
1084  std::string name;
1085  ret = _ctx.prop_map().get<std::string>( irods::RESOURCE_NAME, name );
1086  if ( ( result = ASSERT_PASS( ret, "Failed to get the resource name." ) ).ok() ) {
1087  irods::file_object_ptr file_obj = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
1088  irods::hierarchy_parser sub_parser;
1089  sub_parser.set_string( file_obj->in_pdmo() );
1090  if ( !sub_parser.resc_in_hier( name ) ) {
1091  result = repl_object( _ctx, SYNC_OBJ_KW );
1092  }
1093  }
1094  }
1095  }
1096  }
1097  return result;
1098 
1099 } // compound_file_modified
1100 
1104  irods::plugin_context& _ctx,
1105  const std::string* _opr ) {
1106  irods::error result = SUCCESS();
1107 
1108  // =-=-=-=-=-=-=-
1109  // Check the operation parameters and update the physical path
1110  irods::error ret = compound_check_param< irods::file_object >( _ctx );
1111  if ( ( result = ASSERT_PASS( ret, "Invalid resource context." ) ).ok() ) {
1112  std::string operation;
1113  ret = _ctx.prop_map().get< std::string >( OPERATION_TYPE, operation );
1114  if ( ret.ok() ) {
1115  rodsLog(
1116  LOG_DEBUG,
1117  "compound_file_notify - oper [%s] changed to [%s]",
1118  _opr->c_str(),
1119  operation.c_str() );
1120  } // if ret ok
1121  if ( irods::WRITE_OPERATION == ( *_opr ) ||
1122  irods::CREATE_OPERATION == ( *_opr ) ) {
1123  _ctx.prop_map().set< std::string >( OPERATION_TYPE, ( *_opr ) );
1124  }
1125  else {
1126  rodsLog(
1127  LOG_DEBUG,
1128  "compound_file_notify - skipping [%s]",
1129  _opr->c_str() );
1130  }
1131 
1132  } // if valid
1133 
1134  return result;
1135 
1136 } // compound_file_notify
1137 
1138 // =-=-=-=-=-=-=-
1141  irods::plugin_context& _ctx,
1142  const std::string& _operation,
1143  const std::string* _curr_host,
1144  irods::hierarchy_parser* _out_parser,
1145  float* _out_vote ) {
1146  // =-=-=-=-=-=-=-
1147  // determine if the resource is down
1148  int resc_status = 0;
1149  irods::error ret = _ctx.prop_map().get< int >( irods::RESOURCE_STATUS, resc_status );
1150  if ( !ret.ok() ) {
1151  return PASSMSG( "failed to get 'status' property", ret );
1152  }
1153 
1154  // =-=-=-=-=-=-=-
1155  // if the status is down, vote no.
1156  if ( INT_RESC_STATUS_DOWN == resc_status ) {
1157  ( *_out_vote ) = 0.0;
1158  return SUCCESS();
1159  }
1160 
1161  // =-=-=-=-=-=-=-
1162  // get the cache resource
1163  irods::resource_ptr resc;
1164  ret = get_cache( _ctx, resc );
1165  if ( !ret.ok() ) {
1166  return PASS( ret );
1167  }
1168 
1169  // =-=-=-=-=-=-=-
1170  // ask the cache if it is willing to accept a new file, politely
1171  ret = resc->call < const std::string*, const std::string*,
1172  irods::hierarchy_parser*, float* > (
1174  &_operation, _curr_host,
1175  _out_parser, _out_vote );
1176 
1177  // =-=-=-=-=-=-=-
1178  // set the operation type to signal that we need to do some work
1179  // in file modified
1180  _ctx.prop_map().set< std::string >( OPERATION_TYPE, _operation );
1181 
1182  return ret;
1183 
1184 } // compound_file_redirect_create
1185 
1186 // =-=-=-=-=-=-=-
1189  irods::plugin_context& _ctx,
1190  const std::string& _operation,
1191  const std::string* _curr_host,
1192  irods::hierarchy_parser* _out_parser,
1193  float* _out_vote ) {
1194  // =-=-=-=-=-=-=-
1195  // determine if the resource is down
1196  int resc_status = 0;
1197  irods::error ret = _ctx.prop_map().get< int >( irods::RESOURCE_STATUS, resc_status );
1198  if ( !ret.ok() ) {
1199  return PASSMSG( "failed to get 'status' property", ret );
1200  }
1201 
1202  // =-=-=-=-=-=-=-
1203  // if the status is down, vote no.
1204  if ( INT_RESC_STATUS_DOWN == resc_status ) {
1205  ( *_out_vote ) = 0.0;
1206  return SUCCESS();
1207  }
1208 
1209  // =-=-=-=-=-=-=-
1210  // get the cache resource
1211  irods::resource_ptr resc;
1212  ret = get_cache( _ctx, resc );
1213  if ( !ret.ok() ) {
1214  return PASS( ret );
1215  }
1216 
1217  // =-=-=-=-=-=-=-
1218  // ask the cache if it is willing to accept a new file, politely
1219  ret = resc->call < const std::string*, const std::string*,
1220  irods::hierarchy_parser*, float* > (
1222  &_operation, _curr_host,
1223  _out_parser, _out_vote );
1224 
1225  // =-=-=-=-=-=-=-
1226  // if cache votes non zero we're done
1227  if (*_out_vote > 0.0) {
1228  return SUCCESS();
1229  }
1230 
1231  // =-=-=-=-=-=-=-
1232  // otherwise try the archive
1233  ret = get_archive( _ctx, resc );
1234  if ( !ret.ok() ) {
1235  return PASS( ret );
1236  }
1237 
1238  // =-=-=-=-=-=-=-
1239  // ask the archive if it is willing to accept a new file, politely
1240  ret = resc->call < const std::string*, const std::string*,
1241  irods::hierarchy_parser*, float* > (
1243  &_operation, _curr_host,
1244  _out_parser, _out_vote );
1245 
1246  return ret;
1247 
1248 } // compound_file_redirect_unlink
1249 
1250 // =-=-=-=-=-=-=-
1253  irods::plugin_context& _ctx,
1254  const std::string* _curr_host,
1255  irods::hierarchy_parser* _out_parser,
1256  float* _out_vote ) {
1257  // =-=-=-=-=-=-=-
1258  // check incoming parameters
1259  if ( !_curr_host ) {
1260  return ERROR( SYS_INVALID_INPUT_PARAM, "null operation" );
1261  }
1262  if ( !_out_parser ) {
1263  return ERROR( SYS_INVALID_INPUT_PARAM, "null outgoing hier parser" );
1264  }
1265  if ( !_out_vote ) {
1266  return ERROR( SYS_INVALID_INPUT_PARAM, "null outgoing vote" );
1267  }
1268 
1269  // =-=-=-=-=-=-=-
1270  // get the archive resource
1271  irods::resource_ptr arch_resc;
1272  irods::error ret = get_archive( _ctx, arch_resc );
1273  if ( !ret.ok() ) {
1274  return PASS( ret );
1275  }
1276 
1277  // =-=-=-=-=-=-=-
1278  // get the archive resource
1279  irods::resource_ptr cache_resc;
1280  ret = get_cache( _ctx, cache_resc );
1281  if ( !ret.ok() ) {
1282  return PASS( ret );
1283  }
1284 
1285  // =-=-=-=-=-=-=-
1286  // repave the repl requested temporarily
1287  irods::file_object_ptr f_ptr = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
1288  int repl_requested = f_ptr->repl_requested();
1289  f_ptr->repl_requested( -1 );
1290 
1291  // =-=-=-=-=-=-=-
1292  // ask the archive if it has the data object in question, politely
1293  float arch_check_vote = 0.0;
1294  irods::hierarchy_parser arch_check_parser = ( *_out_parser );
1295  ret = arch_resc->call < const std::string*, const std::string*,
1296  irods::hierarchy_parser*, float* > (
1298  &irods::OPEN_OPERATION, _curr_host,
1299  &arch_check_parser, &arch_check_vote );
1300  if ( !ret.ok() || 0.0 == arch_check_vote ) {
1301  rodsLog(
1302  LOG_NOTICE,
1303  "replica not found in archive for [%s]",
1304  f_ptr->logical_path().c_str() );
1305  // =-=-=-=-=-=-=-
1306  // the archive query redirect failed, something terrible happened
1307  // or mounted collection hijinks are afoot. ask the cache if it
1308  // has the data object in question, politely as a fallback
1309  float cache_check_vote = 0.0;
1310  irods::hierarchy_parser cache_check_parser = ( *_out_parser );
1311  ret = cache_resc->call < const std::string*, const std::string*,
1312  irods::hierarchy_parser*, float* > (
1314  &irods::OPEN_OPERATION, _curr_host,
1315  &cache_check_parser, &cache_check_vote );
1316  if ( !ret.ok() ) {
1317  return PASS( ret );
1318  }
1319 
1320  if( 0.0 == cache_check_vote ) {
1321  *_out_vote = 0.0;
1322  return SUCCESS();
1323  }
1324 
1325  // =-=-=-=-=-=-=-
1326  // set the vote and hier parser
1327  ( *_out_parser ) = cache_check_parser;
1328  ( *_out_vote ) = cache_check_vote;
1329 
1330  return SUCCESS();
1331 
1332  }
1333 
1334  // =-=-=-=-=-=-=-
1335  // repave the resc hier with the archive hier which guarantees that
1336  // we are in the hier for the repl to do its magic. this is a hack,
1337  // and will need refactored later with an improved object model
1338  std::string arch_hier;
1339  arch_check_parser.str( arch_hier );
1340  f_ptr->resc_hier( arch_hier );
1341 
1342  // repave the resc id with the new leaf id
1343  rodsLong_t resc_id = 0;
1344  ret = resc_mgr.hier_to_leaf_id(arch_hier,resc_id);
1345  if(!ret.ok()) {
1346  return PASS(ret);
1347  }
1348  f_ptr->resc_id(resc_id);
1349 
1350  irods::data_object_ptr d_ptr = boost::dynamic_pointer_cast <
1351  irods::data_object > ( f_ptr );
1352  add_key_val(
1353  d_ptr,
1355  "prefer_archive_policy" );
1356 
1357  // =-=-=-=-=-=-=-
1358  // if the vote is 0 then we do a wholesale stage, not an update
1359  // otherwise it is an update operation for the stage to cache
1360  ret = repl_object( _ctx, STAGE_OBJ_KW );
1361  if ( !ret.ok() ) {
1362  return PASS( ret );
1363  }
1364 
1365  // =-=-=-=-=-=-=-
1366  // restore repl requested
1367  f_ptr->repl_requested( repl_requested );
1369  d_ptr,
1371 
1372  // =-=-=-=-=-=-=-
1373  // get the parent name
1374  std::string parent_id_str;
1375  ret = _ctx.prop_map().get< std::string >( irods::RESOURCE_PARENT, parent_id_str );
1376  if ( !ret.ok() ) {
1377  return PASS( ret );
1378  }
1379 
1380  std::string parent_name;
1381  ret = resc_mgr.resc_id_to_name(
1382  parent_id_str,
1383  parent_name );
1384  if(!ret.ok()) {
1385  return PASS(ret);
1386  }
1387 
1388  // =-=-=-=-=-=-=-
1389  // get this resc name
1390  std::string current_name;
1391  ret = _ctx.prop_map().get<std::string>( irods::RESOURCE_NAME, current_name );
1392  if ( !ret.ok() ) {
1393  return PASS( ret );
1394  }
1395 
1396  // =-=-=-=-=-=-=-
1397  // get the cache name
1398  std::string cache_name;
1399  ret = _ctx.prop_map().get< std::string >( CACHE_CONTEXT_TYPE, cache_name );
1400  if ( !ret.ok() ) {
1401  return PASS( ret );
1402  }
1403 
1404 
1405  // =-=-=-=-=-=-=-
1406  // get the current hier
1407  irods::file_object_ptr obj = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
1408  std::string inp_hier = obj->resc_hier();
1409 
1410  // =-=-=-=-=-=-=-
1411  // find the parent in the hier
1412  size_t pos = inp_hier.find( parent_name );
1413  if ( std::string::npos == pos ) {
1414  return ERROR(
1416  "parent resc not in fco resc hier" );
1417  }
1418 
1419  // =-=-=-=-=-=-=-
1420  // create the new resc hier
1421  std::string dst_hier = inp_hier.substr( 0, pos + parent_name.size() );
1422  if ( !dst_hier.empty() ) {
1423  dst_hier += irods::hierarchy_parser::delimiter();
1424  }
1425  dst_hier += current_name +
1427  cache_name;
1428 
1429  // =-=-=-=-=-=-=-
1430  // set the vote and hier parser
1431  _out_parser->set_string( dst_hier );
1432  ( *_out_vote ) = arch_check_vote;
1433 
1434  return SUCCESS();
1435 
1436 } // open_for_prefer_archive_policy
1437 
1438 // =-=-=-=-=-=-=-
1441  irods::plugin_context& _ctx,
1442  const std::string* _opr,
1443  const std::string* _curr_host,
1444  irods::hierarchy_parser* _out_parser,
1445  float* _out_vote ) {
1446  // =-=-=-=-=-=-=-
1447  // check incoming parameters
1448  if ( !_curr_host ) {
1449  return ERROR( SYS_INVALID_INPUT_PARAM, "null operation" );
1450  }
1451  if ( !_out_parser ) {
1452  return ERROR( SYS_INVALID_INPUT_PARAM, "null outgoing hier parser" );
1453  }
1454  if ( !_out_vote ) {
1455  return ERROR( SYS_INVALID_INPUT_PARAM, "null outgoing vote" );
1456  }
1457 
1458  // =-=-=-=-=-=-=-
1459  // get the cache resource
1460  irods::resource_ptr cache_resc;
1461  irods::error ret = get_cache( _ctx, cache_resc );
1462  if ( !ret.ok() ) {
1463  return PASS( ret );
1464  }
1465 
1466  std::string cache_resc_name;
1467  ret = cache_resc->get_property<std::string>(
1469  cache_resc_name );
1470  if ( !ret.ok() ) {
1471  return PASS( ret );
1472  }
1473 
1474  // =-=-=-=-=-=-=-
1475  // get the archive resource
1476  irods::resource_ptr arch_resc;
1477  ret = get_archive( _ctx, arch_resc );
1478  if ( !ret.ok() ) {
1479  return PASS( ret );
1480  }
1481 
1482  // =-=-=-=-=-=-=-
1483  // ask the cache if it has the data object in question, politely
1484  float cache_check_vote = 0.0;
1485  irods::hierarchy_parser cache_check_parser = ( *_out_parser );
1486  ret = cache_resc->call < const std::string*, const std::string*,
1487  irods::hierarchy_parser*, float* > (
1489  &irods::OPEN_OPERATION, _curr_host,
1490  &cache_check_parser, &cache_check_vote );
1491 
1492  // =-=-=-=-=-=-=-
1493  // if the vote is 0 then the cache doesnt have it so it will need be staged
1494  if ( 0.0 == cache_check_vote ) {
1495  // =-=-=-=-=-=-=-
1496  // repave the repl requested temporarily
1497  irods::file_object_ptr f_ptr = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
1498  int repl_requested = f_ptr->repl_requested();
1499  f_ptr->repl_requested( -1 );
1500 
1501  // =-=-=-=-=-=-=-
1502  // ask the archive if it has the data object in question, politely
1503  float arch_check_vote = 0.0;
1504  irods::hierarchy_parser arch_check_parser = ( *_out_parser );
1505  ret = arch_resc->call < const std::string*, const std::string*,
1506  irods::hierarchy_parser*, float* > (
1508  &irods::OPEN_OPERATION, _curr_host,
1509  &arch_check_parser, &arch_check_vote );
1510  if ( !ret.ok() ) {
1511  return PASS( ret );
1512  }
1513 
1514  if( 0.0 == arch_check_vote ) {
1515  *_out_vote = 0.0;
1516  return SUCCESS();
1517  }
1518 
1519  if( irods::UNLINK_OPERATION == ( *_opr ) ) {
1520  ( *_out_parser ) = arch_check_parser;
1521  ( *_out_vote ) = arch_check_vote;
1522  return SUCCESS();
1523  }
1524 
1525  // =-=-=-=-=-=-=-
1526  // repave the resc hier with the archive hier which guarantees that
1527  // we are in the hier for the repl to do its magic. this is a hack,
1528  // and will need refactored later with an improved object model
1529  std::string arch_hier;
1530  arch_check_parser.str( arch_hier );
1531  f_ptr->resc_hier( arch_hier );
1532 
1533  // =-=-=-=-=-=-=-
1534  // if the archive has it, then replicate
1535  ret = repl_object( _ctx, STAGE_OBJ_KW );
1536  if ( !ret.ok() ) {
1537  return PASS( ret );
1538  }
1539 
1540  // =-=-=-=-=-=-=-
1541  // restore repl requested
1542  f_ptr->repl_requested( repl_requested );
1543 
1544  // =-=-=-=-=-=-=-
1545  // now that the repl happened, we will assume that the
1546  // object is in the cache as to not hit the DB again
1547  // the first vote was zero so we must add the name to
1548  // the resource hierarchy
1549  cache_check_parser.add_child( cache_resc_name );
1550  ( *_out_parser ) = cache_check_parser;
1551  ( *_out_vote ) = arch_check_vote;
1552 
1553  }
1554  else {
1555  // =-=-=-=-=-=-=-
1556  // else it is in the cache so assign the parser
1557  ( *_out_vote ) = cache_check_vote;
1558  ( *_out_parser ) = cache_check_parser;
1559  }
1560 
1561  return SUCCESS();
1562 
1563 } // open_for_prefer_cache_policy
1564 
1565 // =-=-=-=-=-=-=-
1570  irods::plugin_context& _ctx,
1571  const std::string* _opr,
1572  const std::string* _curr_host,
1573  irods::hierarchy_parser* _out_parser,
1574  float* _out_vote ) {
1575  // =-=-=-=-=-=-=-
1576  // check incoming parameters
1577  if ( !_curr_host ) {
1578  return ERROR( SYS_INVALID_INPUT_PARAM, "null operation" );
1579  }
1580  if ( !_out_parser ) {
1581  return ERROR( SYS_INVALID_INPUT_PARAM, "null outgoing hier parser" );
1582  }
1583  if ( !_out_vote ) {
1584  return ERROR( SYS_INVALID_INPUT_PARAM, "null outgoing vote" );
1585  }
1586 
1587  // =-=-=-=-=-=-=-
1588  // determine if the resource is down
1589  int resc_status = 0;
1590  irods::error ret = _ctx.prop_map().get< int >( irods::RESOURCE_STATUS, resc_status );
1591  if ( !ret.ok() ) {
1592  return PASS( ret );
1593  }
1594 
1595  // =-=-=-=-=-=-=-
1596  // if the status is down, vote no.
1597  if ( INT_RESC_STATUS_DOWN == resc_status ) {
1598  ( *_out_vote ) = 0.0;
1599  return SUCCESS();
1600  }
1601 
1602  // =-=-=-=-=-=-=-
1603  // acquire the value of the stage policy from the results string
1604  std::string policy;
1605  ret = get_stage_policy( _ctx.rule_results(), policy );
1606 
1607  // =-=-=-=-=-=-=-
1608  // if the policy is prefer cache then if the cache has the object
1609  // return an upvote
1610  if ( policy.empty() || irods::RESOURCE_STAGE_PREFER_CACHE == policy ) {
1611  return open_for_prefer_cache_policy( _ctx, _opr, _curr_host, _out_parser, _out_vote );
1612  }
1613 
1614  // =-=-=-=-=-=-=-
1615  // if the policy is always, then if the archive has it
1616  // stage from archive to cache and return an upvote
1617  else if ( irods::RESOURCE_STAGE_PREFER_ARCHIVE == policy ) {
1618  return open_for_prefer_archive_policy( _ctx, _curr_host, _out_parser, _out_vote );
1619  }
1620  else {
1621  std::stringstream msg;
1622  msg << "invalid stage policy [" << policy << "]";
1623  return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
1624  }
1625 
1626  return SUCCESS();
1627 
1628 } // compound_file_redirect_open
1629 
1634  irods::plugin_context& _ctx,
1635  const std::string* _opr,
1636  const std::string* _curr_host,
1637  irods::hierarchy_parser* _out_parser,
1638  float* _out_vote ) {
1639  // =-=-=-=-=-=-=-
1640  // check the context validity
1641 
1642  irods::error ret = _ctx.valid< irods::file_object >();
1643  if ( !ret.ok() ) {
1644  std::stringstream msg;
1645  msg << "resource context is invalid";
1646  return PASSMSG( msg.str(), ret );
1647  }
1648 
1649  // =-=-=-=-=-=-=-
1650  // check incoming parameters
1651  if ( !_opr ) {
1652  return ERROR( SYS_INVALID_INPUT_PARAM, "null operation" );
1653  }
1654  if ( !_curr_host ) {
1655  return ERROR( SYS_INVALID_INPUT_PARAM, "null operation" );
1656  }
1657  if ( !_out_parser ) {
1658  return ERROR( SYS_INVALID_INPUT_PARAM, "null outgoing hier parser" );
1659  }
1660  if ( !_out_vote ) {
1661  return ERROR( SYS_INVALID_INPUT_PARAM, "null outgoing vote" );
1662  }
1663 
1664  ( *_out_vote ) = 0.0f;
1665 
1666  // =-=-=-=-=-=-=-
1667  // get the name of this resource
1668  std::string resc_name;
1669  ret = _ctx.prop_map().get< std::string >( irods::RESOURCE_NAME, resc_name );
1670  if ( !ret.ok() ) {
1671  std::stringstream msg;
1672  msg << "failed in get property for name";
1673  return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
1674  }
1675 
1676  // =-=-=-=-=-=-=-
1677  // add ourselves to the hierarchy parser by default
1678  _out_parser->add_child( resc_name );
1679 
1680  // =-=-=-=-=-=-=-
1681  // test the operation to determine which choices to make
1682  if ( irods::OPEN_OPERATION == ( *_opr ) ||
1683  irods::WRITE_OPERATION == ( *_opr ) ) {
1684 
1685  if ( irods::WRITE_OPERATION == ( *_opr ) ) {
1686  _ctx.prop_map().set< std::string >( OPERATION_TYPE, ( *_opr ) );
1687  }
1688 
1689  // =-=-=-=-=-=-=-
1690  // call redirect determination for 'get' operation
1691  return compound_file_redirect_open( _ctx, _opr, _curr_host, _out_parser, _out_vote );
1692 
1693  }
1694  else if ( irods::CREATE_OPERATION == ( *_opr )
1695  ) {
1696  // =-=-=-=-=-=-=-
1697  // call redirect determination for 'create' operation
1698  return compound_file_redirect_create( _ctx, ( *_opr ), _curr_host, _out_parser, _out_vote );
1699  }
1700  else if ( irods::UNLINK_OPERATION == ( *_opr )
1701  ) {
1702  // =-=-=-=-=-=-=-
1703  // call redirect determination for 'unlink' operation
1704  return compound_file_redirect_unlink( _ctx, ( *_opr ), _curr_host, _out_parser, _out_vote );
1705  }
1706 
1707  // =-=-=-=-=-=-=-
1708  // must have been passed a bad operation
1709  std::stringstream msg;
1710  msg << "operation not supported [";
1711  msg << ( *_opr ) << "]";
1712  return ERROR( -1, msg.str() );
1713 
1714 } // compound_file_resolve_hierarchy
1715 
1719  irods::plugin_context& _ctx ) {
1720  irods::resource_child_map* cmap_ref;
1723  cmap_ref );
1724  // =-=-=-=-=-=-=-
1725  // forward request for rebalance to children
1726  irods::error result = SUCCESS();
1727  irods::resource_child_map::iterator itr = cmap_ref->begin();
1728  for ( ; itr != cmap_ref->end(); ++itr ) {
1729  irods::error ret = itr->second.second->call(
1730  _ctx.comm(),
1732  _ctx.fco() );
1733  if ( !ret.ok() ) {
1734  irods::log( PASS( ret ) );
1735  result = ret;
1736  }
1737  }
1738 
1739  if ( !result.ok() ) {
1740  return PASS( result );
1741  }
1742 
1743  return SUCCESS();
1744 
1745 } // compound_file_rebalance
1746 
1747 
1748 // =-=-=-=-=-=-=-
1749 // 3. create derived class to handle universal mss resources
1750 // context string will hold the script to be called.
1752  public:
1753  compound_resource( const std::string& _inst_name,
1754  const std::string& _context ) :
1755  irods::resource( _inst_name, _context ) {
1756  // =-=-=-=-=-=-=-
1757  // set the start operation to identify the cache and archive children
1759 
1760  // =-=-=-=-=-=-=-
1761  // parse context string into property pairs assuming a ; as a separator
1762  std::vector< std::string > props;
1763  irods::kvp_map_t kvp;
1765  _context,
1766  kvp );
1767  if(!ret.ok()) {
1768  rodsLog(
1769  LOG_ERROR,
1770  "libcompound: invalid context [%s]",
1771  _context.c_str() );
1772  }
1773 
1774  // =-=-=-=-=-=-=-
1775  // copy the properties from the context to the prop map
1776  irods::kvp_map_t::iterator itr = kvp.begin();
1777  for( ; itr != kvp.end(); ++itr ) {
1778  properties_.set< std::string >(
1779  itr->first,
1780  itr->second );
1781  } // for itr
1782 
1783  std::string parent_id_str;
1784  ret = properties_.get< std::string >( irods::RESOURCE_PARENT, parent_id_str );
1785 
1786  }
1787 
1788  // =-=-=-=-=-=-
1789  // override from plugin_base
1791  _flg = false;
1792  return SUCCESS();
1793  }
1794 
1795  // =-=-=-=-=-=-
1796  // override from plugin_base
1798  return ERROR( -1, "nop" );
1799  }
1800 
1801 }; // class compound_resource
1802 
1803 // =-=-=-=-=-=-=-
1804 // 4. create the plugin factory function which will return a dynamically
1805 // instantiated object of the previously defined derived resource. use
1806 // the add_operation member to associate a 'call name' to the interfaces
1807 // defined above. for resource plugins these call names are standardized
1808 // as used by the irods facing interface defined in
1809 // server/drivers/src/fileDriver.cpp
1810 extern "C"
1811 irods::resource* plugin_factory( const std::string& _inst_name,
1812  const std::string& _context ) {
1813  // =-=-=-=-=-=-=-
1814  // 4a. create compound_resource object
1815  compound_resource* resc = new compound_resource( _inst_name, _context );
1816 
1817  // =-=-=-=-=-=-=-
1818  // 4b. map function names to operations. this map will be used to load
1819  // the symbols from the shared object in the delay_load stage of
1820  // plugin loading.
1821 
1822  using namespace irods;
1823  using namespace std;
1824  resc->add_operation(
1826  function<error(plugin_context&)>(
1828 
1829  resc->add_operation(
1831  function<error(plugin_context&)>(
1832  compound_file_open ) );
1833 
1834  resc->add_operation<void*,int>(
1836  std::function<
1837  error(irods::plugin_context&,void*,int)>(
1838  compound_file_read ) );
1839 
1840  resc->add_operation<void*,int>(
1842  function<error(plugin_context&,void*,int)>(
1843  compound_file_write ) );
1844 
1845  resc->add_operation(
1847  function<error(plugin_context&)>(
1848  compound_file_close ) );
1849 
1850  resc->add_operation(
1852  function<error(plugin_context&)>(
1854 
1855  resc->add_operation<struct stat*>(
1857  function<error(plugin_context&, struct stat*)>(
1858  compound_file_stat ) );
1859 
1860  resc->add_operation(
1862  function<error(plugin_context&)>(
1863  compound_file_mkdir ) );
1864 
1865  resc->add_operation(
1867  function<error(plugin_context&)>(
1869 
1870  resc->add_operation<struct rodsDirent**>(
1872  function<error(plugin_context&,struct rodsDirent**)>(
1874 
1875  resc->add_operation<const char*>(
1877  function<error(plugin_context&, const char*)>(
1879 
1880  resc->add_operation(
1882  function<error(plugin_context&)>(
1884 
1885  resc->add_operation<long long, int>(
1887  function<error(plugin_context&, long long, int)>(
1888  compound_file_lseek ) );
1889 
1890  resc->add_operation(
1892  function<error(plugin_context&)>(
1893  compound_file_rmdir ) );
1894 
1895  resc->add_operation(
1897  function<error(plugin_context&)>(
1899 
1900  resc->add_operation<const char*>(
1902  function<error(plugin_context&, const char*)>(
1904 
1905  resc->add_operation<const char*>(
1907  function<error(plugin_context&, const char*)>(
1909 
1910  resc->add_operation(
1912  function<error(plugin_context&)>(
1914 
1915  resc->add_operation(
1917  function<error(plugin_context&)>(
1919 
1920  resc->add_operation(
1922  function<error(plugin_context&)>(
1924 
1925  resc->add_operation<const std::string*>(
1927  function<error(plugin_context&, const std::string*)>(
1929 
1930  resc->add_operation(
1932  function<error(plugin_context&)>(
1934 
1935  resc->add_operation<const std::string*, const std::string*, irods::hierarchy_parser*, float*>(
1937  function<error(plugin_context&,const std::string*, const std::string*, irods::hierarchy_parser*, float*)>(
1939 
1940  resc->add_operation(
1942  function<error(plugin_context&)>(
1944 
1945  // =-=-=-=-=-=-=-
1946  // set some properties necessary for backporting to iRODS legacy code
1947  resc->set_property< int >( irods::RESOURCE_CHECK_PATH_PERM, 2 );//DO_CHK_PATH_PERM );
1948  resc->set_property< int >( irods::RESOURCE_CREATE_PATH, 1 );//CREATE_PATH );
1949 
1950  // =-=-=-=-=-=-=-
1951  // 4c. return the pointer through the generic interface of an
1952  // irods::resource pointer
1953  return dynamic_cast<irods::resource*>( resc );
1954 
1955 } // plugin_factory
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
getValByKey
char * getValByKey(const keyValPair_t *condInput, const char *keyWord)
Definition: rcMisc.cpp:675
DataObjInp::objPath
char objPath[(1024+64)]
Definition: dataObjInpOut.h:66
compound_file_notify
irods::error compound_file_notify(irods::plugin_context &_ctx, const std::string *_opr)
Definition: libcompound.cpp:1103
RESC_NAME_KW
#define RESC_NAME_KW
Definition: rodsKeyWdDef.h:19
NULL
#define NULL
Definition: rodsDef.h:70
irods_physical_object.hpp
transferStat_t
Definition: objInfo.h:291
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
compound_file_unregistered
irods::error compound_file_unregistered(irods::plugin_context &_ctx)
Definition: libcompound.cpp:1040
AUTO_REPL_POLICY_ENABLED
const std::string AUTO_REPL_POLICY_ENABLED("on")
STAGE_OBJ_KW
#define STAGE_OBJ_KW
Definition: rodsKeyWdDef.h:228
compound_check_param
irods::error compound_check_param(irods::plugin_context &_ctx)
Definition: libcompound.cpp:58
irods::lookup_table< std::pair< std::string, resource_ptr > >
open_for_prefer_cache_policy
irods::error open_for_prefer_cache_policy(irods::plugin_context &_ctx, const std::string *_opr, const std::string *_curr_host, irods::hierarchy_parser *_out_parser, float *_out_vote)
Definition: libcompound.cpp:1440
compound_file_rebalance
irods::error compound_file_rebalance(irods::plugin_context &_ctx)
Definition: libcompound.cpp:1718
irods::RESOURCE_NAME
const std::string RESOURCE_NAME("resource_property_name")
OPERATION_TYPE
const std::string OPERATION_TYPE("operation_type")
irods::RESOURCE_OP_STAT
const std::string RESOURCE_OP_STAT("resource_stat")
compound_file_write
irods::error compound_file_write(irods::plugin_context &_ctx, void *_buf, int _len)
Definition: libcompound.cpp:621
compound_file_redirect_create
irods::error compound_file_redirect_create(irods::plugin_context &_ctx, const std::string &_operation, const std::string *_curr_host, irods::hierarchy_parser *_out_parser, float *_out_vote)
Definition: libcompound.cpp:1140
msParam.h
irods::plugin_context::valid
virtual error valid()
Definition: irods_plugin_context.hpp:77
compound_file_mkdir
irods::error compound_file_mkdir(irods::plugin_context &_ctx)
Definition: libcompound.cpp:757
irods::resource
Definition: irods_resource_plugin.hpp:25
compound_file_rename
irods::error compound_file_rename(irods::plugin_context &_ctx, const char *_new_file_name)
Definition: libcompound.cpp:883
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")
irods_file_object.hpp
irods::RESOURCE_OP_CLOSEDIR
const std::string RESOURCE_OP_CLOSEDIR("resource_closedir")
irods_stacktrace.hpp
irods::pdmo_type
std::function< irods::error(rcComm_t *) > pdmo_type
Definition: irods_plugin_base.hpp:29
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
resc_mgr
irods::resource_manager resc_mgr
Definition: irods_resource_manager.cpp:31
compound_file_redirect_open
irods::error compound_file_redirect_open(irods::plugin_context &_ctx, const std::string *_opr, const std::string *_curr_host, irods::hierarchy_parser *_out_parser, float *_out_vote)
Definition: libcompound.cpp:1569
irods::RESOURCE_STAGE_PREFER_CACHE
const std::string RESOURCE_STAGE_PREFER_CACHE("when_necessary")
irods::data_object_ptr
boost::shared_ptr< data_object > data_object_ptr
Definition: irods_data_object.hpp:17
irods_collection_object.hpp
irods::resource_ptr
boost::shared_ptr< resource > resource_ptr
Definition: irods_resource_types.hpp:11
get_cache_resc
irods::error get_cache_resc(irods::plugin_context &_ctx, irods::resource_ptr &_resc)
Definition: libcompound.cpp:219
AUTO_REPL_POLICY
const std::string AUTO_REPL_POLICY("auto_repl")
irods::RESOURCE_OP_RESOLVE_RESC_HIER
const std::string RESOURCE_OP_RESOLVE_RESC_HIER("resource_resolve_hierarchy")
compound_file_resolve_hierarchy
irods::error compound_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: libcompound.cpp:1633
generalAdmin.h
irods::RESOURCE_OP_READDIR
const std::string RESOURCE_OP_READDIR("resource_readdir")
irods::hierarchy_parser
Definition: irods_hierarchy_parser.hpp:14
reIn2p3SysRule.hpp
irods::lookup_table::begin
iterator begin()
Definition: irods_lookup_table.hpp:53
irods::RESOURCE_OP_READ
const std::string RESOURCE_OP_READ("resource_read")
compound_resource::post_disconnect_maintenance_operation
irods::error post_disconnect_maintenance_operation(irods::pdmo_type &)
Definition: libcompound.cpp:1797
irods::RESOURCE_OP_FREESPACE
const std::string RESOURCE_OP_FREESPACE("resource_freespace")
irods::lookup_table< std::pair< std::string, resource_ptr > >::iterator
irods_hash_map::iterator iterator
Definition: irods_lookup_table.hpp:31
compound_start_operation
irods::error compound_start_operation(irods::plugin_property_map &_prop_map)
Definition: libcompound.cpp:287
compound_file_getfs_freespace
irods::error compound_file_getfs_freespace(irods::plugin_context &_ctx)
Definition: libcompound.cpp:934
irods::RESOURCE_OP_LSEEK
const std::string RESOURCE_OP_LSEEK("resource_lseek")
irods::data_object
Definition: irods_data_object.hpp:22
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
deploy_schemas_locally.parser
parser
Definition: deploy_schemas_locally.py:59
INVALID_RESC_CHILD_CONTEXT
@ INVALID_RESC_CHILD_CONTEXT
Definition: rodsErrorTable.h:758
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
open_for_prefer_archive_policy
irods::error open_for_prefer_archive_policy(irods::plugin_context &_ctx, const std::string *_curr_host, irods::hierarchy_parser *_out_parser, float *_out_vote)
Definition: libcompound.cpp:1252
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
compound_file_stat
irods::error compound_file_stat(irods::plugin_context &_ctx, struct stat *_statbuf)
Definition: libcompound.cpp:704
PURGE_CACHE_KW
#define PURGE_CACHE_KW
Definition: rodsKeyWdDef.h:110
compound_file_rmdir
irods::error compound_file_rmdir(irods::plugin_context &_ctx)
Definition: libcompound.cpp:782
ASSERT_ERROR
#define ASSERT_ERROR(expr_, code_, format_,...)
Definition: irods_error.hpp:123
compound_file_opendir
irods::error compound_file_opendir(irods::plugin_context &_ctx)
Definition: libcompound.cpp:807
irods::lookup_table::size
int size() const
Definition: irods_lookup_table.hpp:38
compound_file_closedir
irods::error compound_file_closedir(irods::plugin_context &_ctx)
Definition: libcompound.cpp:832
get_stage_policy
irods::error get_stage_policy(const std::string &_results, std::string &_policy)
Definition: libcompound.cpp:258
irods_resource_plugin.hpp
ARCHIVE_CONTEXT_TYPE
const std::string ARCHIVE_CONTEXT_TYPE("archive")
DEST_RESC_NAME_KW
#define DEST_RESC_NAME_KW
Definition: rodsKeyWdDef.h:20
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")
compound_file_sync_to_arch
irods::error compound_file_sync_to_arch(irods::plugin_context &_ctx, const char *_cache_file_name)
Definition: libcompound.cpp:995
irods::OPEN_OPERATION
const std::string OPEN_OPERATION("OPEN")
RESC_HIER_STR_KW
#define RESC_HIER_STR_KW
Definition: rodsKeyWdDef.h:225
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
SYNC_OBJ_KW
#define SYNC_OBJ_KW
Definition: rodsKeyWdDef.h:229
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::hierarchy_parser::resc_in_hier
bool resc_in_hier(const std::string &_resc) const
Definition: irods_hierarchy_parser.cpp:214
compound_resource::need_post_disconnect_maintenance_operation
irods::error need_post_disconnect_maintenance_operation(bool &_flg)
Definition: libcompound.cpp:1790
irods::RESOURCE_OP_CREATE
const std::string RESOURCE_OP_CREATE("resource_create")
CACHE_CONTEXT_TYPE
const std::string CACHE_CONTEXT_TYPE("cache")
irods
Definition: apiHandler.hpp:35
irods::RESOURCE_OP_NOTIFY
const std::string RESOURCE_OP_NOTIFY("resource_notify")
compound_file_read
irods::error compound_file_read(irods::plugin_context &_ctx, void *_buf, int _len)
Definition: libcompound.cpp:594
irods::RESOURCE_STAGE_TO_CACHE_POLICY
const std::string RESOURCE_STAGE_TO_CACHE_POLICY("compound_resource_cache_refresh_policy")
compound_file_create
irods::error compound_file_create(irods::plugin_context &_ctx)
Definition: libcompound.cpp:543
DataObjInp
Definition: dataObjInpOut.h:65
irods::RESOURCE_CREATE_PATH
const std::string RESOURCE_CREATE_PATH("resource_property_create_path")
compound_resource::compound_resource
compound_resource(const std::string &_inst_name, const std::string &_context)
Definition: libcompound.cpp:1753
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
irods::RESOURCE_OP_WRITE
const std::string RESOURCE_OP_WRITE("resource_write")
compound_file_truncate
irods::error compound_file_truncate(irods::plugin_context &_ctx)
Definition: libcompound.cpp:909
rmKeyVal
int rmKeyVal(keyValPair_t *condInput, const char *keyWord)
Definition: rcMisc.cpp:710
ASSERT_PASS
#define ASSERT_PASS(prev_error_, format_,...)
Definition: irods_error.hpp:124
compound_file_unlink
irods::error compound_file_unlink(irods::plugin_context &_ctx)
Definition: libcompound.cpp:679
irods::hierarchy_parser::set_string
error set_string(const std::string &_resc_hier)
Definition: irods_hierarchy_parser.cpp:36
get_irods_version.value
dictionary value
Definition: get_irods_version.py:27
compound_file_stage_to_cache
irods::error compound_file_stage_to_cache(irods::plugin_context &_ctx, const char *_cache_file_name)
Definition: libcompound.cpp:965
irods::lookup_table::has_entry
bool has_entry(KeyType _k) const
Definition: irods_lookup_table.hpp:41
repl_object
irods::error repl_object(irods::plugin_context &_ctx, const char *_stage_sync_kw)
Definition: libcompound.cpp:387
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
get_next_child
irods::error get_next_child(irods::plugin_context &_ctx, irods::resource_ptr &_resc)
Definition: libcompound.cpp:76
irods::RESOURCE_OP_CLOSE
const std::string RESOURCE_OP_CLOSE("resource_close")
compound_file_registered
irods::error compound_file_registered(irods::plugin_context &_ctx)
Definition: libcompound.cpp:1023
physPath.hpp
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
DEST_RESC_HIER_STR_KW
#define DEST_RESC_HIER_STR_KW
Definition: rodsKeyWdDef.h:226
irods::hierarchy_parser::delimiter
static const std::string & delimiter(void)
Definition: irods_hierarchy_parser.cpp:210
irods::RESOURCE_OP_UNLINK
const std::string RESOURCE_OP_UNLINK("resource_unlink")
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
irods::RESOURCE_OP_RMDIR
const std::string RESOURCE_OP_RMDIR("resource_rmdir")
compound_resource
Definition: libcompound.cpp:1751
compound_file_readdir
irods::error compound_file_readdir(irods::plugin_context &_ctx, struct rodsDirent **_dirent_ptr)
Definition: libcompound.cpp:857
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
INT_RESC_STATUS_DOWN
#define INT_RESC_STATUS_DOWN
Definition: rodsDef.h:282
irods::add_key_val
void add_key_val(data_object_ptr &_do, const std::string &_k, const std::string &_v)
Definition: irods_data_object.cpp:172
DataObjInp::createMode
int createMode
Definition: dataObjInpOut.h:67
dataObjRepl.h
irods_lexical_cast.hpp
NO_CHK_COPY_LEN_KW
#define NO_CHK_COPY_LEN_KW
Definition: rodsKeyWdDef.h:108
compound_file_open
irods::error compound_file_open(irods::plugin_context &_ctx)
Definition: libcompound.cpp:568
irods::RESOURCE_OP_REGISTERED
const std::string RESOURCE_OP_REGISTERED("resource_registered")
compound_file_close
irods::error compound_file_close(irods::plugin_context &_ctx)
Definition: libcompound.cpp:648
IN_PDMO_KW
#define IN_PDMO_KW
Definition: rodsKeyWdDef.h:227
irods_hierarchy_parser.hpp
irods::parse_kvp_string
error parse_kvp_string(const std::string &_str, kvp_map_t &_kvp, const std::string &_association=KVP_DEF_ASSOCIATION, const std::string &_delimeter=KVP_DEF_DELIMITER)
Definition: irods_kvp_string_parser.cpp:69
irods::plugin_base::set_start_operation
void set_start_operation(maintenance_operation_t _op)
Definition: irods_plugin_base.hpp:309
irods::resource_manager::hier_to_leaf_id
error hier_to_leaf_id(const std::string &, rodsLong_t &)
Definition: irods_resource_manager.cpp:1082
irods::file_object
Definition: irods_file_object.hpp:19
irods::RESOURCE_OP_MKDIR
const std::string RESOURCE_OP_MKDIR("resource_mkdir")
irods::plugin_context::rule_results
virtual const std::string rule_results()
Definition: irods_plugin_context.hpp:105
auto_replication_is_enabled
static bool auto_replication_is_enabled(irods::plugin_context &_ctx)
Definition: libcompound.cpp:1054
irods::RESOURCE_OP_OPENDIR
const std::string RESOURCE_OP_OPENDIR("resource_opendir")
irods::RESOURCE_OP_STAGETOCACHE
const std::string RESOURCE_OP_STAGETOCACHE("resource_stagetocache")
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
rsDataObjRepl
int rsDataObjRepl(rsComm_t *rsComm, dataObjInp_t *dataObjInp, transferStat_t **transferStat)
Definition: rsDataObjRepl.cpp:65
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_kvp_string_parser.hpp
get_archive
irods::error get_archive(irods::plugin_context &_ctx, irods::resource_ptr &_resc)
Definition: libcompound.cpp:177
irods::RESOURCE_PARENT
const std::string RESOURCE_PARENT("resource_property_parent")
irods::RESOURCE_OP_REBALANCE
const std::string RESOURCE_OP_REBALANCE("resource_rebalance")
irods::remove_key_val
void remove_key_val(data_object_ptr &_do, const std::string &_k)
Definition: irods_data_object.cpp:182
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
irods::lookup_table::set
error set(const std::string &_key, const ValueType &_val)
Definition: irods_lookup_table.hpp:83
DataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:74
KeyValPair
Definition: objInfo.h:120
irods::kvp_map_t
std::map< std::string, std::string > kvp_map_t
Definition: irods_kvp_string_parser.hpp:30
get_cache
irods::error get_cache(irods::plugin_context &_ctx, irods::resource_ptr &_resc)
Definition: libcompound.cpp:134
irods::RESOURCE_STAGE_PREFER_ARCHIVE
const std::string RESOURCE_STAGE_PREFER_ARCHIVE("always")
plugin_factory
irods::resource * plugin_factory(const std::string &_inst_name, const std::string &_context)
Definition: libcompound.cpp:1811
clearKeyVal
int clearKeyVal(keyValPair_t *condInput)
Definition: rcMisc.cpp:1047
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
irods::RESOURCE_OP_OPEN
const std::string RESOURCE_OP_OPEN("resource_open")
compound_file_modified
irods::error compound_file_modified(irods::plugin_context &_ctx)
Definition: libcompound.cpp:1072
irods::CREATE_OPERATION
const std::string CREATE_OPERATION("CREATE")
DIRECT_ARCHIVE_ACCESS
@ DIRECT_ARCHIVE_ACCESS
Definition: rodsErrorTable.h:763
irods::UNLINK_OPERATION
const std::string UNLINK_OPERATION("UNLINK")
irods::resource_manager::resc_id_to_name
error resc_id_to_name(const rodsLong_t &, std::string &)
Definition: irods_resource_manager.cpp:1162
rsDataObjRepl.hpp
compound_file_redirect_unlink
irods::error compound_file_redirect_unlink(irods::plugin_context &_ctx, const std::string &_operation, const std::string *_curr_host, irods::hierarchy_parser *_out_parser, float *_out_vote)
Definition: libcompound.cpp:1188
rodsLong_t
long long rodsLong_t
Definition: rodsType.h:32
compound_file_lseek
irods::error compound_file_lseek(irods::plugin_context &_ctx, long long _offset, int _whence)
Definition: libcompound.cpp:730
copyKeyVal
int copyKeyVal(const keyValPair_t *srcCondInput, keyValPair_t *destCondInput)
Definition: rcMisc.cpp:751