Exemplo n.º 1
0
    ///////////////////////////////////////////////////////////////////////////////
    // logical_file functions
    void logical_file_cpi_impl::sync_list_locations(std::vector<saga::url>& locations)
    {

//        SAGA_ADAPTOR_THROW ("Not implemented! ", saga::NotImplemented);
    	SAGA_LOG_DEBUG("file sync_list_locations()");
    	check_state();

    	instance_data   instanceData (this);
        std::string rns_path = instanceData->location_.get_path();

    	std::vector <std::string> results;
    	std::vector <saga::url>   list_tmp;

    	try {
    		results = rns_lfile.list_locations(rns_path);
    		list_tmp.insert(list_tmp.begin(), results.begin(), results.end());
//    		for(unsigned int i=0; i< list_tmp.size(); i++){
//    			list_tmp[i].set_scheme(irods_url_org.get_scheme());
//    		}
    		locations = list_tmp;
    	}
    	catch (boost::system::system_error const& e) {
    		SAGA_ADAPTOR_THROW(e.what(), saga::NoSuccess);
    	}


    }
Exemplo n.º 2
0
    void DebugRenderer::AddWirePyramid(const Matrix& transform, const Color& color, Lifespan lifespan) {
        InstanceData instanceData(transform, color);

        if (lifespan == Temporary) {
            temporaryInstanceData[WirePyramid].push_back(instanceData);
        } else {
            permanentInstanceData[WirePyramid].push_back(instanceData);
        }
    }
Exemplo n.º 3
0
void logical_directory_cpi_impl::sync_get_url(saga::url& url)
{

//    SAGA_ADAPTOR_THROW ("Not implemented! sync_get_url", saga::NotImplemented);
    SAGA_LOG_DEBUG("sync_get_url()");
    check_state();

	adaptor_data_t  adaptorData(this);
	instance_data   instanceData (this);

	saga::url lfn_url(instanceData->location_.get_url());
    url = lfn_url;
}
Exemplo n.º 4
0
void logical_directory_cpi_impl::sync_get_cwd(saga::url& cwd)
{
//    SAGA_ADAPTOR_THROW ("Not implemented! sync_get_cwd", saga::NotImplemented);
	SAGA_LOG_DEBUG("sync_get_cwd()");
	check_state();

	if (path.empty()) {
	  SAGA_ADAPTOR_THROW ("path is empty.", saga::NoSuccess);
	}

	adaptor_data_t  adaptorData(this);
	instance_data   instanceData (this);

	cwd = instanceData->location_;
	cwd.set_path(path.branch_path().string()); // remove last element.
}
Exemplo n.º 5
0
    void DebugRenderer::AddWireGrid(const Matrix& transform, const Color& color, Quality quality, Lifespan lifespan) {
        PrimitiveType type;
        switch(quality) {
            case Low: type = WireGridLow; break;
            case Medium: type = WireGridMedium; break;
            case High: type = WireGridHigh; break;
            default: throw Exception("DebugRenderer: Unrecognized wire grid quality type");
        }

        InstanceData instanceData(transform, color);

        if (lifespan == Temporary) {
            temporaryInstanceData[type].push_back(instanceData);
        } else {
            permanentInstanceData[type].push_back(instanceData);
        }
    }
    void logical_file_cpi_impl::sync_update_location(saga::impl::void_t& ret, 
                                                     saga::url oldlocation, saga::url newlocation)
    {
        adaptor_data_t  adaptorData(this);
        instance_data   instanceData (this);
        saga::url lfn_url(instanceData->location_);
        
        this->check_if_open ("logical_file_cpi_impl::sync_update_location", instanceData->location_);
        
        check_permissions(saga::replica::Write, "update_location", lfn_url.get_url());
        
        bool oldExists = false; // worst case - update will fail
        bool newExists = true;  //
        
        SAGA_OSSTREAM strm;
        strm << "Could not update location for logical file ["
        << instanceData->location_ << "]. ";
        
        try {
            RLSConnection * RLSHandle = 
			adaptorData->getConnectionHandle(instanceData->location_);
            oldExists = RLSHandle->LFNtoPFNMappingExists(lfn_url.get_path(), 
                                                         oldlocation.get_url());
            newExists = RLSHandle->LFNtoPFNMappingExists(lfn_url.get_path(), 
                                                         newlocation.get_url());
        }
        catch(globus_rls_replica_adaptor::exception const & e)
        {
            strm << e.RLSErrorText();
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), e.SAGAError()); 
        }
        
        if(!oldExists) {
            strm << "PFN: [" << oldlocation << "] doesn't exist!";
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::DoesNotExist);
        }
        
        if(newExists) {
            strm << "PFN: [" << newlocation << "] already exist!";
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::AlreadyExists);
        }
        
        // everyting seems to be ok. let's update the LFN
        sync_add_location(ret, newlocation);
        sync_remove_location(ret, oldlocation);
    }
Exemplo n.º 7
0
void logical_directory_cpi_impl::sync_list_attributes(std::vector<std::string>& keys)
{

//    SAGA_ADAPTOR_THROW ("Not implemented! ", saga::NotImplemented);
	SAGA_LOG_DEBUG("logical dir, sync_list_attributes()");
	check_state();

	instance_data   instanceData (this);
    std::string rns_path = instanceData->location_.get_path();

	try {
		keys = rns_lfile.list_attributes(rns_path);
	}
	catch (boost::system::system_error const& e) {
		SAGA_ADAPTOR_THROW(e.what(), saga::NoSuccess);
	}
}
Exemplo n.º 8
0
void logical_directory_cpi_impl::sync_get_attribute(std::string& ret, std::string key)
{

//    SAGA_ADAPTOR_THROW ("Not implemented! ", saga::NotImplemented);
	SAGA_LOG_DEBUG("logical dir, sync_get_attribute()");
	check_state();

	instance_data   instanceData (this);
	std::string rns_path = instanceData->location_.get_path();

	try {
//		std::cout<< "rns_path : " << rns_path << std::endl;
//		std::cout<< "key  : " << key  << std::endl;
		ret = rns_lfile.get_attribute(rns_path, key);
	}
	catch (boost::system::system_error const& e) {
		SAGA_ADAPTOR_THROW(e.what(), saga::NoSuccess);
	}
}
    ///////////////////////////////////////////////////////////////////////////////
    // logical_file functions
    void logical_file_cpi_impl::sync_list_locations(std::vector<saga::url>& locations)
    {
        adaptor_data_t  adaptorData(this);
        instance_data   instanceData (this);
        saga::url lfn_url(instanceData->location_);
        
        this->check_if_open ("logical_file_cpi_impl::sync_list_locations", instanceData->location_);
        
        try {
            RLSConnection * RLSHandle = 
			adaptorData->getConnectionHandle(instanceData->location_);
            locations = RLSHandle->LFNGetPFNList(lfn_url.get_path());
        }
        catch(globus_rls_replica_adaptor::exception const & e)
        {
            SAGA_OSSTREAM strm;
            strm << "Could not list locations for logical file [" << 
            instanceData->location_ << "]. " << e.RLSErrorText();
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), e.SAGAError()); 
        }
    }
Exemplo n.º 10
0
    void logical_file_cpi_impl::sync_add_location(saga::impl::void_t&, saga::url location)
    {

//        SAGA_ADAPTOR_THROW ("Not implemented! ", saga::NotImplemented);
    	SAGA_LOG_DEBUG("file, sync_add_location()");
    	check_state();

    	instance_data   instanceData (this);
        std::string rns_path = instanceData->location_.get_path();
        std::string loc_url = location.get_string();

//    	bool exists = false;
//    	try {
//    		exists  = rns_ldir.exists(rns_path);
//    	}
//    	catch (boost::system::system_error const& e) {
//    		SAGA_ADAPTOR_THROW(e.what(), saga::NoSuccess);
//    	}
//
//    	if (exists){
////    		SAGA_ADAPTOR_THROW ("The specified target already exists. ", saga::AlreadyExists);
//    		std::cout<< "The specified target already exists." << rns_path << std::endl;
//    		std::cout<< "Adding the location : " << location << std::endl;
//    		// rns_lfile.add_location??
//    	}


    	try {
//    		std::cout<< "rns_path : " << rns_path << std::endl;
//    		std::cout<< "loc_url  : " << loc_url  << std::endl;
    		rns_lfile.add_location(rns_path, loc_url);
    	}
    	catch (boost::system::system_error const& e) {
    		SAGA_ADAPTOR_THROW(e.what(), saga::NoSuccess);
    	}


    }
    void logical_file_cpi_impl::sync_remove_location(saga::impl::void_t&, saga::url location)
    {
        adaptor_data_t  adaptorData(this);
        instance_data   instanceData (this);
        saga::url lfn_url(instanceData->location_);
        
        this->check_if_open ("logical_file_cpi_impl::sync_remove_location", instanceData->location_);
        
        check_permissions(saga::replica::Write, "remove_location", lfn_url.get_url());
        
        try {
            RLSConnection * RLSHandle = 
			adaptorData->getConnectionHandle(instanceData->location_);
            RLSHandle->LFNRemovePFN(lfn_url.get_path(), location.get_url());
        }
        catch(globus_rls_replica_adaptor::exception const & e)
        {
            SAGA_OSSTREAM strm;
            strm << "Could not remove location from logical file [" << 
            instanceData->location_ << "]. " << e.RLSErrorText();
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), e.SAGAError()); 
        }
    }
    logical_file_cpi_impl::logical_file_cpi_impl (proxy* p, cpi_info const& info,
                                                  saga::ini::ini const& glob_ini, saga::ini::ini const& adap_ini,
                                                  TR1::shared_ptr<saga::adaptor> adaptor)
    :   base_cpi (p, info, adaptor, cpi::Noflags)
    {
        adaptor_data_t  adaptorData(this);
        instance_data   instanceData (this);
        saga::url lfn_url(instanceData->location_);
        
        // we support only any:// and lfn:// schemes FIXME: what about LRC/RLI ?!?
        std::string scheme(instanceData->location_.get_scheme());
        std::string host(instanceData->location_.get_host());
        
        if (scheme != "any" && scheme != "lfn" && 
            scheme != GLOBUS_RLS_URL_SCHEME && scheme != GLOBUS_RLS_URL_SCHEME_NOAUTH)
        {
            SAGA_OSSTREAM strm;
            strm << "Could not open logical file [" << instanceData->location_ << "]. " 
            << "Supported URL schemes are: any:// and lfn://";
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::adaptors::AdaptorDeclined);
        }
        
        // and we always fall back to 'localhost' if the hostname is empty
        if( host.empty() )
        {
            instanceData->location_.set_host("localhost"); 
        }
        
        // If we've made it here, it should be safe to load
        // the GRAM modules now. The loader employs a sigleton mechanism,
        // so ut doesn't matter if we call this method multiple times.
        globus_module_loader::globus_init ();
        
        // try to create/retreive a connection handle for the given host 
        bool exists = false;
        try {
            RLSConnection * RLSHandle = 
			adaptorData->getConnectionHandle(instanceData->location_);
            exists = RLSHandle->LFNExists(lfn_url.get_path());
        }
        catch(globus_rls_replica_adaptor::exception const & e)
        {
            SAGA_OSSTREAM strm;
            strm << "Could not open logical file [" << instanceData->location_ << "]. " 
            << e.RLSErrorText();
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), e.SAGAError()); 
        }
        
        saga::replica::flags mode = 
		(saga::replica::flags)instanceData->mode_;
		
        if (((mode & saga::replica::Create) || 
             (mode & saga::replica::CreateParents)) && 
            (mode & saga::replica::Exclusive)) 
        {
            // FIXME: handle modes...
        }
        
        if ((mode & saga::replica::Create) || 
            (mode & saga::replica::CreateParents))
        {
            // FIXME: Create replica entry if the create flag is given...
        }
        
        
        if(!exists) 
        {
            SAGA_OSSTREAM strm;
            strm << "Could not open logical file [" << instanceData->location_ << "]. " 
            << "The file doesn't exist and the 'Create' flag is not set!";
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::DoesNotExist);
        } 
        
        is_open_ = true;
    }
Exemplo n.º 13
0
    logical_file_cpi_impl::logical_file_cpi_impl (proxy* p, cpi_info const& info,
                                                  saga::ini::ini const& glob_ini, saga::ini::ini const& adap_ini,
                                                  TR1::shared_ptr<saga::adaptor> adaptor)
    :   base_cpi (p, info, adaptor, cpi::Noflags)
    {

        instance_data instanceData(this);
        set_path_str(instanceData->location_);

        saga::replica::flags flags = static_cast<saga::replica::flags>(instanceData->mode_);
        saga::url rns_url_org(instanceData->location_);
        std::string rns_path = rns_url_org.get_path();

    	//Check the entry existence
    	bool is_entry = false;
    	try {
    		is_entry = rns_ldir.is_entry(rns_path);
    	}
    	catch (boost::system::system_error const& e) {
    		SAGA_ADAPTOR_THROW(e.what(), saga::NoSuccess);
    	}

//    	std::cout<< "is_entry =" << is_entry << std::endl;
    	std::string str_buf;

    	if(is_entry){
//    		std::cout<< "is_entry" << std::endl;
    		if((flags & saga::filesystem::Create) && (flags & saga::filesystem::Exclusive)){
    			SAGA_ADAPTOR_THROW ("Create and Exclusive flags are given, but the entry already exists.",
    					saga::AlreadyExists);
    		}
    		else{
    			str_buf = "entry open OK: " + rns_url_org.get_string();
    			SAGA_LOG_CRITICAL(str_buf.c_str());
    		    is_opened = true;
    		}
    	}
    	else{
    		// Check the existence
    		bool exists = false;
    		exists = rns_ldir.exists(rns_path);
    		try {
    			exists = rns_ldir.exists(rns_path);
    		}
    		catch (boost::system::system_error const& e) {
    			SAGA_ADAPTOR_THROW(e.what(), saga::NoSuccess);
    		}

    		if(exists){
    			SAGA_ADAPTOR_THROW("invalid entry name", saga::BadParameter);
    		}
    		else{
    			if(flags & saga::filesystem::Create){

    				// Check parent directory
    				bool is_p_dir = false;
    				boost::filesystem::path check_url_org(rns_path);
    				std::string check_url_bpath = check_url_org.branch_path().string();

    				try {
    					is_p_dir = rns_ldir.is_dir(check_url_bpath);
    				}
    				catch (boost::system::system_error const& e) {
    					SAGA_ADAPTOR_THROW(e.what(), saga::NoSuccess);
    				}

    				if(is_p_dir){
    					str_buf = "call rns_ldir open. : " + rns_url_org.get_string();
    	    			SAGA_LOG_CRITICAL(str_buf.c_str());
    	    			SAGA_LOG_CRITICAL("But NOT created until adding a location");
//    					rns_ldir.open(rns_path, flags);
    					is_opened = true;
    				}
    				else {
    					SAGA_ADAPTOR_THROW("parent directory does not exist:" + check_url_bpath,
    							saga::BadParameter);
    				}
    			}
    			else{
    		        SAGA_ADAPTOR_THROW ("the entry does not exist.", saga::DoesNotExist);
    			}
    		}

    	}
    }