예제 #1
0
 void verify_source(const std::string& cmd_source, container& backup_dir) {
   fs::path source_dir(fs::initial_path());
   source_dir = fs::system_complete(fs::path(cmd_source, fs::native));
   backup_dir.source(source_dir.native_file_string());
   if (not fs::exists(source_dir)) throw Backup::Error::Directory_Error("Source directory does not exist!");      
   if (not fs::is_directory(source_dir)) throw Backup::Error::Directory_Error("Source specified is not a directory!");
   if (fs::is_empty(source_dir)) throw Backup::Error::Directory_Error("Source directory is empty!");
 }
void
FileSystemTestSetup::make_dirs_(const fs::path& pfx) const
{
    fs::create_directories(source_dir());
    fs::create_directories(mount_dir(pfx));
    fs::create_directories(clustercache_dir(pfx));
    fs::create_directories(scocache_mountpoint(pfx));
    fs::create_directories(tlog_dir(pfx));
    fs::create_directories(mdstore_dir(pfx));
    fs::create_directories(dump_on_halt_dir(pfx));
    fs::create_directories(failovercache_dir(topdir_));
    fs::create_directories(fdriver_cache_dir(pfx));
}
bpt::ptree&
FileSystemTestSetup::make_config_(bpt::ptree& pt,
                                  const fs::path& topdir,
                                  const vfs::NodeId& vrouter_id) const
{
    be::BackendTestSetup::backend_config().persist_internal(pt, ReportDefault::T);

    // scocache
    {
        vd::MountPointConfigs mp_configs;

        mp_configs.push_back(vd::MountPointConfig(scocache_mountpoint(topdir).string(),
                             scache_size_));

        ip::PARAMETER_TYPE(scocache_mount_points)(mp_configs).persist(pt);
        ip::PARAMETER_TYPE(trigger_gap)(yt::DimensionedValue(scache_trigger_gap_)).persist(pt);
        ip::PARAMETER_TYPE(backoff_gap)(yt::DimensionedValue(scache_backoff_gap_)).persist(pt);
    }

    // clustercache
    {
        std::vector<vd::MountPointConfig> kfgs;

        yt::DimensionedValue csize("20MiB");

        const fs::path kdev(clustercache_mountpoint(topdir));
        maybe_setup_clustercache_device(kdev, csize.getBytes());
        vd::MountPointConfig mp(kdev, csize.getBytes());
        kfgs.push_back(mp);

        ip::PARAMETER_TYPE(clustercache_mount_points)(kfgs).persist(pt);
        ip::PARAMETER_TYPE(read_cache_serialization_path)(clustercache_serialization_path(topdir).string()).persist(pt);
    }

    // volmanager
    {
        ip::PARAMETER_TYPE(tlog_path)(tlog_dir(topdir).string()).persist(pt);
        ip::PARAMETER_TYPE(metadata_path)(mdstore_dir(topdir).string()).persist(pt);
        ip::PARAMETER_TYPE(open_scos_per_volume)(open_scos_per_volume_).persist(pt);
        ip::PARAMETER_TYPE(datastore_throttle_usecs)(dstore_throttle_usecs_).persist(pt);
        ip::PARAMETER_TYPE(clean_interval)(scache_clean_interval_).persist(pt);
        ip::PARAMETER_TYPE(number_of_scos_in_tlog)(num_scos_in_tlog_).persist(pt);
        ip::PARAMETER_TYPE(debug_metadata_path)(dump_on_halt_dir(topdir).string()).persist(pt);

        // (backend)threadpool
        ip::PARAMETER_TYPE(num_threads)(num_threads_).persist(pt);
    }

    // metadata_server - we run it outside volmanager, hence empty ServerConfigs here.
    {
        // not 'const' as clang analyzer 3.8 does not like using the defaulted default ctor:
        //         error: default initialization of an object of const type 'const mds::ServerConfigs' (aka 'const vector<metadata_server::ServerConfig>') without a user-provided default constructor
        //         const mds::ServerConfigs scfgs;
        //                                  ^
        //                                       {}
        // 1 error generated.
        mds::ServerConfigs scfgs;
        mds_test_setup_->make_manager_config(pt,
                                             scfgs);
    }

    // distributed_lock_store
    {
        ip::PARAMETER_TYPE(dls_type)(vd::LockStoreType::Arakoon).persist(pt);
        ip::PARAMETER_TYPE(dls_arakoon_cluster_id)(arakoon_test_setup_->clusterID().str()).persist(pt);
        const auto node_configs(arakoon_test_setup_->node_configs());
        const ip::PARAMETER_TYPE(dls_arakoon_cluster_nodes)::ValueType
        node_configv(node_configs.begin(),
                     node_configs.end());

        ip::PARAMETER_TYPE(dls_arakoon_cluster_nodes)(node_configv).persist(pt);
    }
    // filedriver
    {
        ip::PARAMETER_TYPE(fd_cache_path)(fdriver_cache_dir(topdir).string()).persist(pt);
        ip::PARAMETER_TYPE(fd_namespace)(fdriver_namespace_.str()).persist(pt);
    }

    // filesystem
    {
        ip::PARAMETER_TYPE(fs_ignore_sync)(false).persist(pt);

        const std::string backend_dir(source_dir().string());
        ip::PARAMETER_TYPE(fs_virtual_disk_format)(vdisk_format_->name()).persist(pt);

        ip::PARAMETER_TYPE(fs_cache_dentries)(true).persist(pt);
        ip::PARAMETER_TYPE(fs_enable_shm_interface)(true).persist(pt);
        ip::PARAMETER_TYPE(fs_enable_network_interface)(true).persist(pt);

        make_mdstore_config_(pt);
        make_dtl_config_(vrouter_id,
                         pt);
    }

    // volume_router
    {
        ip::PARAMETER_TYPE(vrouter_backend_sync_timeout_ms)(backend_sync_timeout_ms_).persist(pt);
        ip::PARAMETER_TYPE(vrouter_migrate_timeout_ms)(migrate_timeout_ms_).persist(pt);
        ip::PARAMETER_TYPE(vrouter_redirect_timeout_ms)(redirect_timeout_ms_).persist(pt);
        ip::PARAMETER_TYPE(vrouter_redirect_retries)(redirect_retries_).persist(pt);
        ip::PARAMETER_TYPE(vrouter_id)(vrouter_id).persist(pt);
        ip::PARAMETER_TYPE(scrub_manager_interval)(scrub_manager_interval_secs_).persist(pt);
        ip::PARAMETER_TYPE(vrouter_use_fencing)(use_fencing_).persist(pt);
        ip::PARAMETER_TYPE(vrouter_send_sync_response)(send_sync_response_).persist(pt);
    }

    // volume_router_cluster
    {
        ip::PARAMETER_TYPE(vrouter_cluster_id)(vrouter_cluster_id()).persist(pt);
    }

    //failovercache
    {
        ip::PARAMETER_TYPE(dtl_path)(failovercache_dir(topdir).string()).persist(pt);
        ip::PARAMETER_TYPE(dtl_transport)(failovercache_transport()).persist(pt);
    }

    // volume_registry
    make_registry_config_(pt);

    // event_publisher is not configured for now as it's entirely optional.

    // stats_collector
    {
        ip::PARAMETER_TYPE(stats_collector_interval_secs)(30).persist(pt);
    }

    return pt;
}
예제 #4
0
void
FolderShaper::MoveCopyTemplate	(entry_ref * a_template_ref, bool a_move)
{
	BEntry		template_entry;
	
	template_entry.SetTo	(a_template_ref, true);			// traverse, if link (future proof)
	template_entry.GetRef	(a_template_ref);
	BString template_name =	a_template_ref->name;				// name of dropped template
	BPath	template_path	(& template_entry);
	
	BString template_path_string = template_path.Path();		// path of dropped template
	NameSafe(& template_path_string);

	BPath	templates_folder_path	(m_tmpl_dir, NULL);			// path of template folder
	BString	templates_folder_string	=	templates_folder_path.Path();
	//NameSafe(& templates_folder_string);	// not yet, we want the new name in first

	// create a new name that is unique in the Template folder
	BString new_target_name	=	a_template_ref->name;			

	int32	counter	=	2;
	m_tmpl_dir->Rewind();
	
	while(m_tmpl_dir->Contains(new_target_name.String()))
	{
		new_target_name = a_template_ref->name;
		new_target_name.Append(" ");
		new_target_name << counter;
		counter	++;
	}

	BString	target_template_path_string	=	templates_folder_string;
	target_template_path_string.	Append("/");
	target_template_path_string.	Append(new_target_name);
	NameSafe(& target_template_path_string);
	
	//	 DEBUG
	PRINT(("template_name: %s\n", template_name.String()));
	PRINT(("new_target_name: %s\n", new_target_name.String()));	
	
	PRINT(("template_path_string: %s\n", template_path_string.String()));	
	PRINT(("templates_folder_string: %s\n", templates_folder_string.String()));	
	PRINT(("target_template_path_string: %s\n", target_template_path_string.String()));	

	if (a_move)	// Move
	{
		// find a temp name that's in neither of the source/target folders
		BString unique_name = a_template_ref->name;	 
		BDirectory	source_dir(templates_folder_string.String());
		
		counter = 2;
		while(	source_dir.Contains(unique_name.String())
				||
				m_tmpl_dir->Contains(unique_name.String())	)
		{
			unique_name = a_template_ref->name;
			unique_name.Append(" ");
			unique_name << counter;
			counter	++;
		}
		
		PRINT(("unique_name: %s\n", unique_name.String()));
		
		template_entry.Rename(unique_name.String());
		template_entry.MoveTo(m_tmpl_dir);
		
	}
	else		// Copy
	{
		BString command = "copyattr -d -r ";
		command.Append(template_path_string);
		command.Append(" ");
		command.Append(target_template_path_string);
		system(command.String());
	}
}