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

irods_structured_object.cpp
Go to the documentation of this file.
1 // =-=-=-=-=-=-=-
4 #include "irods_stacktrace.hpp"
5 
7 
8 namespace irods {
9 
10 // =-=-=-=-=-=-=-
11 // public - ctor
13  addr_(),
14  sub_file_path_( "" ),
15  offset_( 0 ),
16  spec_coll_( 0 ),
17  data_type_( "" ),
18  opr_type_( 0 ),
19  spec_coll_type_( HAAW_STRUCT_FILE_T ) {
20  } // structured_object
21 
22 // =-=-=-=-=-=-=-
23 // public - ctor
25  sub_file_path_( "" ),
26  offset_( 0 ),
27  spec_coll_( 0 ),
28  data_type_( "" ),
29  opr_type_( 0 ) {
30  // =-=-=-=-=-=-=-
31  // pull out subFile attributes
32  addr_ = _sub.addr;
34  offset_ = _sub.offset;
35  spec_coll_ = _sub.specColl;
40  mode( _sub.mode );
41  flags( _sub.flags );
42 
43  // =-=-=-=-=-=-=-
44  // file* functions will fail with an empty physical_path_
46  if ( spec_coll_ ) {
49  }
50 
51  } // structured_object
52 
53 // =-=-=-=-=-=-=-
54 // public - ctor
56  subStructFileFdOprInp_t& _fd_inp ) :
57  file_object(),
58  sub_file_path_( "" ),
59  offset_( 0 ),
60  spec_coll_( 0 ),
61  data_type_( "" ),
62  opr_type_( 0 ) {
63 
64  addr_ = _fd_inp.addr;
65  file_descriptor_ = _fd_inp.fd;
66  spec_coll_type_ = _fd_inp.type;
67  resc_hier_ = _fd_inp.resc_hier;
68 
69  } // structured_object
70 
71 // =-=-=-=-=-=-=-
72 // public - cctor
74  file_object( _rhs ) {
75  addr_ = _rhs.addr_;
77  offset_ = _rhs.offset_;
78  spec_coll_ = _rhs.spec_coll_;
79  data_type_ = _rhs.data_type_;
80  opr_type_ = _rhs.opr_type_;
82  } // cctor
83 
84 // =-=-=-=-=-=-=-
85 // public - dtor
87  } // dtor
88 
89 // =-=-=-=-=-=-=-
90 // public - assignment operator
92  // =-=-=-=-=-=-=-
93  // call base class assignment first
94  file_object::operator=( _rhs );
95 
96  addr_ = _rhs.addr_;
98  offset_ = _rhs.offset_;
99  spec_coll_ = _rhs.spec_coll_;
100  data_type_ = _rhs.data_type_;
101  opr_type_ = _rhs.opr_type_;
102 
103  return *this;
104 
105  } // operator=
106 
107 // =-=-=-=-=-=-=-
108 // plugin - resolve resource plugin for this object
110  const std::string& _interface,
111  plugin_ptr& _ptr ) {
112  // =-=-=-=-=-=-=-
113  // check to see if this is for a resource plugin
114  // resolution, otherwise it is an error
115  if ( RESOURCE_INTERFACE != _interface ) {
116  std::stringstream msg;
117  msg << "structured_object does not support a [";
118  msg << _interface;
119  msg << "] for plugin resolution";
120  return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
121  }
122 
123  // =-=-=-=-=-=-=-
124  // we now support tar file ( structfile ) and
125  // msso file types. this needs to be moved out
126  std::string plugin_type;
128  plugin_type = "structfile";
129 
130  }
131  else if ( MSSO_STRUCT_FILE_T == spec_coll_type_ ) {
132  plugin_type = "mssofile";
133 
134  }
135  else {
136  std::stringstream msg;
137  msg << "unsupported structured type: "
138  << spec_coll_type_;
139  return ERROR(
141  msg.str() );
142  }
143 
144  // =-=-=-=-=-=-=-
145  // try to find the resource based on the type
146  resource_ptr resc_ptr;
148  plugin_type,
149  resc_ptr );
150  if ( err.ok() ) {
151  _ptr = boost::dynamic_pointer_cast< resource >( resc_ptr );
152  return SUCCESS();
153 
154  }
155  else {
156  // =-=-=-=-=-=-=-
157  // otherwise create a resource and add properties from this object
158  error init_err = resc_mgr.init_from_type(
159  plugin_type, // type
160  plugin_type, // key
161  "struct_file_inst", // inst name
162  "empty context", // context
163  resc_ptr );
164  if ( !init_err.ok() ) {
165  return PASSMSG( "failed to load resource plugin", init_err );
166 
167  }
168 
169  } // if !ok
170 
171  // =-=-=-=-=-=-=-
172  // found ourselves a plugin, fill in the properties
173  rodsServerHost_t* tmpRodsServerHost = 0;
174  int status = resolveHost( &addr_, &tmpRodsServerHost );
175  if ( status < 0 ) {
176  std::stringstream msg;
177  msg << "resolveHost error for [";
178  msg << addr_.hostAddr;
179  return ERROR( status, msg.str() );
180  }
181 
182  resc_ptr->set_property< rodsServerHost_t* >( RESOURCE_HOST, tmpRodsServerHost );
183 
184  resc_ptr->set_property<rodsLong_t>( RESOURCE_ID, -1 );
185  resc_ptr->set_property<long>( RESOURCE_QUOTA, -1 );
186 
187  resc_ptr->set_property<int>( RESOURCE_STATUS, INT_RESC_STATUS_UP );
188 
189  resc_ptr->set_property<std::string>( RESOURCE_FREESPACE, "-1" );
190  resc_ptr->set_property<std::string>( RESOURCE_ZONE, addr_.zoneName );
191  resc_ptr->set_property<std::string>( RESOURCE_NAME, plugin_type );
192  resc_ptr->set_property<std::string>( RESOURCE_LOCATION, addr_.hostAddr );
193  resc_ptr->set_property<std::string>( RESOURCE_TYPE, plugin_type );
194  resc_ptr->set_property<std::string>( RESOURCE_CLASS, "cache" );
195  resc_ptr->set_property<std::string>( RESOURCE_PATH, physical_path_ );
196  resc_ptr->set_property<std::string>( RESOURCE_INFO, "blank info" );
197  resc_ptr->set_property<std::string>( RESOURCE_COMMENTS, "blank comments" );
198  resc_ptr->set_property<std::string>( RESOURCE_CREATE_TS, "create?" );
199  resc_ptr->set_property<std::string>( RESOURCE_MODIFY_TS, "modify?" );
200 
201  _ptr = boost::dynamic_pointer_cast< resource >( resc_ptr );
202  return SUCCESS();
203 
204  } // resolve
205 
206 // =-=-=-=-=-=-=-
207 // public - get vars from object for rule engine
209  rule_engine_vars_t& _kvp ) {
210  file_object::get_re_vars( _kvp );
211  // =-=-=-=-=-=-=-
212  // host addr
213  _kvp[HOST_ADDR_KW] = addr_.hostAddr;
214  _kvp[ZONE_NAME_KW] = addr_.zoneName;
215 
216  std::stringstream pn;
217  pn << addr_.portNum;
218  _kvp[PORT_NUM_KW] = pn.str().c_str();
219 
220  // =-=-=-=-=-=-=-
221  // misc attributes
222  _kvp[SUB_FILE_PATH_KW] = sub_file_path_.c_str();
223 
224  std::stringstream off;
225  off << offset_;
226  _kvp[OFFSET_KW] = off.str().c_str();
227 
228  _kvp[DATA_TYPE_KW] = data_type_.c_str();
229 
230  std::stringstream opr;
231  opr << opr_type_;
232  _kvp[OPR_TYPE_KW] = opr.str().c_str();
233 
234  // =-=-=-=-=-=-=-
235  // spec coll
236  if ( spec_coll_ ) {
237  std::stringstream coll_class;
238  coll_class << spec_coll_->collClass;
239  _kvp[SPEC_COLL_CLASS_KW] = coll_class.str().c_str();
240 
241  std::stringstream type;
242  type << spec_coll_->type;
243  _kvp[SPEC_COLL_TYPE_KW] = type.str().c_str();
244 
250 
251  std::stringstream dirty;
252  dirty << spec_coll_->cacheDirty;
253  _kvp[SPEC_COLL_CACHE_DIRTY] = dirty.str().c_str();
254 
255  std::stringstream repl;
256  repl << spec_coll_->replNum;
257  _kvp[SPEC_COLL_REPL_NUM] = repl.str().c_str();
258 
259  }
260 
261  return SUCCESS();
262 
263  } // get_re_vars
264 
265 }; // namespace irods
irods::plugin_ptr
boost::shared_ptr< plugin_base > plugin_ptr
Definition: irods_first_class_object.hpp:18
irods::structured_object::addr_
rodsHostAddr_t addr_
Definition: irods_structured_object.hpp:94
irods::RESOURCE_CLASS
const std::string RESOURCE_CLASS("resource_property_class")
irods::RESOURCE_LOCATION
const std::string RESOURCE_LOCATION("resource_property_location")
SubStructFileFdOpr::addr
rodsHostAddr_t addr
Definition: subStructFileRead.h:9
irods::RESOURCE_COMMENTS
const std::string RESOURCE_COMMENTS("resource_property_comments")
SPEC_COLL_OBJ_PATH_KW
#define SPEC_COLL_OBJ_PATH_KW
Definition: rodsKeyWdDef.h:276
irods::resource_manager::init_from_type
error init_from_type(std::string, std::string, std::string, std::string, resource_ptr &)
Definition: irods_resource_manager.cpp:718
Subfile::offset
rodsLong_t offset
Definition: objInfo.h:321
irods::RESOURCE_NAME
const std::string RESOURCE_NAME("resource_property_name")
irods::data_object::mode
virtual int mode() const
Definition: irods_data_object.hpp:83
SpecColl::resource
char resource[64]
Definition: objInfo.h:83
irods::file_object::operator=
virtual file_object & operator=(const file_object &)
Definition: irods_file_object.cpp:139
SPEC_COLL_TYPE_KW
#define SPEC_COLL_TYPE_KW
Definition: rodsKeyWdDef.h:275
Subfile
Definition: objInfo.h:316
irods_stacktrace.hpp
Subfile::subFilePath
char subFilePath[(1024+64)]
Definition: objInfo.h:318
irods::resource_ptr
boost::shared_ptr< resource > resource_ptr
Definition: irods_resource_types.hpp:11
SPEC_COLL_PHY_PATH_KW
#define SPEC_COLL_PHY_PATH_KW
Definition: rodsKeyWdDef.h:279
SpecColl::cacheDirty
int cacheDirty
Definition: objInfo.h:92
SpecColl::phyPath
char phyPath[(1024+64)]
Definition: objInfo.h:85
SpecColl::cacheDir
char cacheDir[(1024+64)]
Definition: objInfo.h:89
SpecColl::type
structFileType_t type
Definition: objInfo.h:78
irods::structured_object::spec_coll_
specColl_t * spec_coll_
Definition: irods_structured_object.hpp:97
SpecColl::replNum
int replNum
Definition: objInfo.h:93
HAAW_STRUCT_FILE_T
@ HAAW_STRUCT_FILE_T
Definition: objInfo.h:54
irods::RESOURCE_PATH
const std::string RESOURCE_PATH("resource_property_path")
Subfile::specColl
specColl_t * specColl
Definition: objInfo.h:322
irods::data_object::physical_path_
std::string physical_path_
Definition: irods_data_object.hpp:135
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
SPEC_COLL_CACHE_DIRTY
#define SPEC_COLL_CACHE_DIRTY
Definition: rodsKeyWdDef.h:281
irods::RESOURCE_STATUS
const std::string RESOURCE_STATUS("resource_property_status")
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
DATA_TYPE_KW
#define DATA_TYPE_KW
Definition: rodsKeyWdDef.h:23
irods::file_object::logical_path_
std::string logical_path_
Definition: irods_file_object.hpp:128
irods::structured_object::structured_object
structured_object()
Definition: irods_structured_object.cpp:12
SubStructFileFdOpr
Definition: subStructFileRead.h:8
INT_RESC_STATUS_UP
#define INT_RESC_STATUS_UP
Definition: rodsDef.h:281
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
irods
Definition: apiHandler.hpp:35
irods::RESOURCE_TYPE
const std::string RESOURCE_TYPE("resource_property_type")
irods::RESOURCE_INTERFACE
const std::string RESOURCE_INTERFACE("irods_resource_interface")
irods::structured_object::spec_coll_type_
structFileType_t spec_coll_type_
Definition: irods_structured_object.hpp:101
irods::data_object::resc_hier
virtual std::string resc_hier() const
Definition: irods_data_object.hpp:77
irods::file_object::file_descriptor_
int file_descriptor_
Definition: irods_file_object.hpp:130
OFFSET_KW
#define OFFSET_KW
Definition: rodsKeyWdDef.h:91
irods::structured_object
Definition: irods_structured_object.hpp:15
irods::resource_manager::resolve
error resolve(std::string, resource_ptr &)
Definition: irods_resource_manager.cpp:51
Subfile::addr
rodsHostAddr_t addr
Definition: objInfo.h:317
irods::structured_object::data_type_
std::string data_type_
Definition: irods_structured_object.hpp:98
OPR_TYPE_KW
#define OPR_TYPE_KW
Definition: rodsKeyWdDef.h:94
irods::file_object::get_re_vars
virtual error get_re_vars(rule_engine_vars_t &)
Definition: irods_file_object.cpp:237
irods::RESOURCE_ZONE
const std::string RESOURCE_ZONE("resource_property_zone")
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
irods::RESOURCE_FREESPACE
const std::string RESOURCE_FREESPACE("resource_property_freespace")
SpecColl::rescHier
char rescHier[(1024+64)]
Definition: objInfo.h:84
SUB_FILE_PATH_KW
#define SUB_FILE_PATH_KW
Definition: rodsKeyWdDef.h:267
resc_mgr
irods::resource_manager resc_mgr
Definition: irods_resource_manager.cpp:31
irods::file_object::logical_path
virtual std::string logical_path() const
Definition: irods_file_object.hpp:72
SPEC_COLL_RESOURCE_KW
#define SPEC_COLL_RESOURCE_KW
Definition: rodsKeyWdDef.h:277
irods::RESOURCE_CREATE_TS
const std::string RESOURCE_CREATE_TS("resource_property_create_ts")
irods::RESOURCE_QUOTA
const std::string RESOURCE_QUOTA("resource_property_quota")
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::error
Definition: irods_error.hpp:23
irods::structured_object::get_re_vars
virtual error get_re_vars(rule_engine_vars_t &)
Definition: irods_structured_object.cpp:208
SubStructFileFdOpr::resc_hier
char resc_hier[(1024+64)]
Definition: subStructFileRead.h:13
irods::data_object::flags
virtual int flags() const
Definition: irods_data_object.hpp:86
SubStructFileFdOpr::fd
int fd
Definition: subStructFileRead.h:11
TAR_STRUCT_FILE_T
@ TAR_STRUCT_FILE_T
Definition: objInfo.h:55
irods::RESOURCE_MODIFY_TS
const std::string RESOURCE_MODIFY_TS("resource_property_modify_ts")
SubStructFileFdOpr::type
structFileType_t type
Definition: subStructFileRead.h:10
irods::file_object
Definition: irods_file_object.hpp:19
rodsServerHost
Definition: rodsConnect.h:62
rodsHostAddr_t::hostAddr
char hostAddr[256]
Definition: rodsDef.h:297
irods::structured_object::resolve
virtual error resolve(const std::string &, plugin_ptr &)
Definition: irods_structured_object.cpp:109
irods_resource_manager.hpp
irods::resource_manager
Definition: irods_resource_manager.hpp:30
SPEC_COLL_CACHE_DIR_KW
#define SPEC_COLL_CACHE_DIR_KW
Definition: rodsKeyWdDef.h:280
irods::structured_object::opr_type_
int opr_type_
Definition: irods_structured_object.hpp:99
irods::structured_object::~structured_object
virtual ~structured_object()
Definition: irods_structured_object.cpp:86
irods::data_object::resc_hier_
std::string resc_hier_
Definition: irods_data_object.hpp:136
SPEC_COLL_RESC_HIER_KW
#define SPEC_COLL_RESC_HIER_KW
Definition: rodsKeyWdDef.h:278
irods::structured_object::sub_file_path_
std::string sub_file_path_
Definition: irods_structured_object.hpp:95
SPEC_COLL_CLASS_KW
#define SPEC_COLL_CLASS_KW
Definition: rodsKeyWdDef.h:274
Subfile::mode
int mode
Definition: objInfo.h:319
irods::RESOURCE_INFO
const std::string RESOURCE_INFO("resource_property_info")
irods_structured_object.hpp
rodsHostAddr_t::portNum
int portNum
Definition: rodsDef.h:299
HOST_ADDR_KW
#define HOST_ADDR_KW
Definition: rodsKeyWdDef.h:264
irods::structured_object::offset_
rodsLong_t offset_
Definition: irods_structured_object.hpp:96
ZONE_NAME_KW
#define ZONE_NAME_KW
Definition: rodsKeyWdDef.h:265
Subfile::flags
int flags
Definition: objInfo.h:320
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
SpecColl::objPath
char objPath[(1024+64)]
Definition: objInfo.h:80
type
int type
Definition: filesystem.cpp:103
irods::RESOURCE_HOST
const std::string RESOURCE_HOST("resource_property_host")
MSSO_STRUCT_FILE_T
@ MSSO_STRUCT_FILE_T
Definition: objInfo.h:56
PORT_NUM_KW
#define PORT_NUM_KW
Definition: rodsKeyWdDef.h:266
irods::structured_object::operator=
virtual structured_object & operator=(const structured_object &)
Definition: irods_structured_object.cpp:91
rodsHostAddr_t::zoneName
char zoneName[64]
Definition: rodsDef.h:298
irods::rule_engine_vars_t
std::map< std::string, std::string > rule_engine_vars_t
Definition: irods_first_class_object.hpp:20
rodsLong_t
long long rodsLong_t
Definition: rodsType.h:32
SpecColl::collClass
specCollClass_t collClass
Definition: objInfo.h:77
resolveHost
int resolveHost(rodsHostAddr_t *addr, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:375
SPEC_COLL_REPL_NUM
#define SPEC_COLL_REPL_NUM
Definition: rodsKeyWdDef.h:282
irods::RESOURCE_ID
const std::string RESOURCE_ID("resource_property_id")