当前位置: 首页>>代码示例>>Java>>正文


Java Ini.fetch方法代码示例

本文整理汇总了Java中org.ini4j.Ini.fetch方法的典型用法代码示例。如果您正苦于以下问题:Java Ini.fetch方法的具体用法?Java Ini.fetch怎么用?Java Ini.fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ini4j.Ini的用法示例。


在下文中一共展示了Ini.fetch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reloadDatabase

import org.ini4j.Ini; //导入方法依赖的package包/类
private void reloadDatabase(final Ini config) {
	log.debug("Overwriting current database with saved session");
	final String dbPath = config.fetch("database", "path", String.class);
	ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
		  worker.schedule(new Runnable() {
			@Override
			public void run() {
				PropertiesUtil props = new PropertiesUtil("../bin/nubi.properties");
				try {
					FileUtil.copy(new File(System.getProperty("user.home")+"/.nubisave/nubisavemount/data"+dbPath), new File(props.getProperty("splitter_database_location")+".db"));
					new File(props.getProperty("splitter_database_location")+".lg").delete();
					metaDataStore.reloadDataBase();
					fileStore.reloadDatabase();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, 1, TimeUnit.SECONDS);
}
 
开发者ID:joe42,项目名称:nubisave,代码行数:20,代码来源:ConfigurableFuseBox.java

示例2: configureSplitter

import org.ini4j.Ini; //导入方法依赖的package包/类
private void configureSplitter() throws FuseException {
	Ini config = IniUtil.getIni(vtSplitterConfig.getText());
	//TODO: check and write version
	try {
		if(config.get("splitter").containsKey("save")){ 
			log.debug("save Splitter's configuration");
			if(config.containsKey("database")){ 
				saveDatabase(config);
			}
			String sessionNumber = config.fetch("splitter", "save", String.class);
			config.remove("splitter", "save");
			fileStore.writeMetaData(IniUtil.getString(config), "/.nubisave_database.meta"+sessionNumber);
			storageServiceMgr.getServices().storeServiceNames(".nubisave_service_name.session"+sessionNumber);
		} else if(config.get("splitter").containsKey("load")){
			setServicesMapping(config);
			config = loadDatabaseMetaData(config);
			reloadDatabase(config);
		}
		
	} catch (IOException e) {
		config.getFile().delete();
		throw new FuseException("IO Exception on persisting Splitter's configuration.")
			.initErrno(FuseException.EIO);
	}
	vtSplitterConfig.setText(IniUtil.getString(config));
	setRedundancy(config.fetch("splitter", "redundancy", Integer.class));
	setStorageStrategyName(config.fetch("splitter", "storagestrategy", String.class));
	updateVTSplitterConfigFile();
	config.getFile().delete();
}
 
开发者ID:joe42,项目名称:nubisave,代码行数:31,代码来源:ConfigurableFuseBox.java

示例3: setServicesMapping

import org.ini4j.Ini; //导入方法依赖的package包/类
/**
 * Sets the mapping of current to previous service names in the splitter's configuration file
 * The section name is MapOfCurrentToPreviousServices and the parameter names are the current services' names
 * with the corresponding previous services' names as values. The services need to be renamed in order to access the files
 * from the previous session, after the database has been reloaded.
 */
private void setServicesMapping(Ini config) {String sessionNumber = config.fetch("splitter", "load", String.class);
	Map<String,String> newToPreviousServiceNames =  storageServiceMgr.getServices().getServiceNameMapping(".nubisave_service_name.session"+sessionNumber);
	for(Entry<String, String> newToPreviousServiceName: newToPreviousServiceNames.entrySet()){
		config.put("MapOfCurrentToPreviousServices", newToPreviousServiceName.getKey(), newToPreviousServiceName.getValue());
	}
	vtSplitterConfig.setText(IniUtil.getString(config)); //TODO: synchronize
}
 
开发者ID:joe42,项目名称:nubisave,代码行数:14,代码来源:ConfigurableFuseBox.java

示例4: saveDatabase

import org.ini4j.Ini; //导入方法依赖的package包/类
private void saveDatabase(Ini config) throws IOException {
	String dbPath = config.fetch("database", "path", String.class);
	FilePartFragmentMetaDataStore filePartFragmentDataStore = (FilePartFragmentMetaDataStore)fileStore.fileFragmentMetaDataStore;
	long size = fileStore.getSize(dbPath);
	log.debug("database dbPath: "+dbPath);
	log.debug("database size: "+size);
	config.put("database", "size", size);
	List<String> fragments;
	List<byte[]> checksums;
	String sectionName;
	int databasePartNr = 0;
	for(String dbPartPath:  filePartFragmentDataStore.getFilePartPaths(dbPath)){
		sectionName = "databasePartNr_"+databasePartNr;
		fragments = getFragments(dbPartPath);
		checksums = ((FileFragmentMetaDataStore)fileStore.fileFragmentMetaDataStore).getFragmentsChecksums(dbPartPath);
		config.put(sectionName, "name", dbPartPath);
		config.put(sectionName, "nrOfFileFragmentsRequired", filePartFragmentDataStore.getNrOfRequiredFragments(dbPartPath));
		config.put(sectionName, "nrOfFileFragments", filePartFragmentDataStore.getNrOfFragments(dbPartPath));
		for(int i=0; i<fragments.size();i++){
			log.debug("fragment name "+i+": "+fragments.get(i));
			config.put(sectionName, "fileFragmentName_"+i, fragments.get(i));
			log.debug("checksums.get(i)="+checksums.size());
			config.put(sectionName, "fileFragmentNameChecksum_"+i, new String(Hex.encode(checksums.get(i))) );
			databasePartNr++;
		}
	}
}
 
开发者ID:joe42,项目名称:nubisave,代码行数:28,代码来源:ConfigurableFuseBox.java

示例5: deletePreviousSession

import org.ini4j.Ini; //导入方法依赖的package包/类
private void deletePreviousSession(Ini config) throws IOException{
	String sectionName;
	Ini previousSession;
	int databasePartNr = 0;
	while(true){ // remove previous database parts
		sectionName = "databasePartNr_"+databasePartNr;
		if( ! config.containsKey(sectionName) ){
			break;
		}
		config.remove(sectionName);
		databasePartNr++;
	}
	byte[] splitter_config = fileStore.readMetaData("/.nubisave_database.meta"+config.fetch("splitter", "load", Integer.class));
	previousSession = IniUtil.getIni(new String(splitter_config, "UTF-8"));

	ArrayList<String> fragmentNames = new ArrayList<String>();
	ArrayList<String> absoluteFragmentNames;
	int nr_of_file_fragments;
	databasePartNr = 0;
	while(true){
		sectionName = "databasePartNr_"+databasePartNr;
		if( ! previousSession.containsKey(sectionName) ){
			break;
		}
		databasePartNr++;
		nr_of_file_fragments = previousSession.fetch(sectionName, "nrOfFileFragments", Integer.class);
		fragmentNames = new ArrayList<String>();
		for(int i=0; i<nr_of_file_fragments; i++){
			fragmentNames.add(previousSession.fetch(sectionName, "fileFragmentName_"+i, String.class));
		}
		absoluteFragmentNames = getAbsoluteFragmentPaths(fragmentNames, nr_of_file_fragments);
		for(String previousFragment: absoluteFragmentNames){
			new File(previousFragment).delete();
		}
	}		
}
 
开发者ID:joe42,项目名称:nubisave,代码行数:37,代码来源:ConfigurableFuseBox.java

示例6: loadDatabaseMetaData

import org.ini4j.Ini; //导入方法依赖的package包/类
private Ini loadDatabaseMetaData(Ini config) throws IOException,
		UnsupportedEncodingException {
	log.debug("load Splitter's configuration");
	byte[] splitter_config = fileStore.readMetaData("/.nubisave_database.meta"+config.fetch("splitter", "load", Integer.class));
	log.debug("new String(splitter_config)"+new String(splitter_config));
	vtSplitterConfig.setText(new String(splitter_config, "UTF-8")); 
	config = IniUtil.getIni(new String(splitter_config, "UTF-8"));
	config.remove("splitter", "load");

	String dbPath = config.fetch("database", "path", String.class);
	long dbSize = config.fetch("database", "size", long.class);
	ArrayList<String> fragmentNames = new ArrayList<String>();
	ArrayList<byte[]> checksums;
	ArrayList<String> absoluteFragmentNames;
	int nr_of_file_fragments_required;
	int nr_of_file_fragments;
	String sectionName, dbPartPath;
	int databasePartNr = 0;
	while(true){
		sectionName = "databasePartNr_"+databasePartNr;
		if( ! config.containsKey(sectionName) ){
			break;
		}
		databasePartNr++;
		dbPartPath = config.fetch(sectionName, "name", String.class);
		nr_of_file_fragments_required = config.fetch(sectionName, "nrOfFileFragmentsRequired", Integer.class);
		nr_of_file_fragments = config.fetch(sectionName, "nrOfFileFragments", Integer.class);
		fragmentNames = new ArrayList<String>();
		checksums = new ArrayList<byte[]>();
		for(int i=0; i<nr_of_file_fragments; i++){
			fragmentNames.add(config.fetch(sectionName, "fileFragmentName_"+i, String.class));
			log.debug("fragment name "+i+": "+fragmentNames.get(i));
			checksums.add( Hex.decode(config.fetch(sectionName, "fileFragmentNameChecksum_"+i, String.class)) );
		}
		absoluteFragmentNames = getAbsoluteFragmentPaths(fragmentNames, nr_of_file_fragments);
		fileStore.fileFragmentMetaDataStore.setFragments(dbPartPath, absoluteFragmentNames, nr_of_file_fragments_required, nr_of_file_fragments, checksums, dbSize);
		((FilePartFragmentMetaDataStore)fileStore.fileFragmentMetaDataStore).put(dbPath,dbSize);
	}		
	FileEntry fileEntry;
		//metaDataStore.makeFolderEntry(dbPath);
		fileEntry = metaDataStore.makeFileEntry(dbPath);
		fileEntry.uid = UID;
		fileEntry.gid = GID;
		log.debug("size:"+fileStore.getSize(dbPath));
		metaDataStore.putFileEntry(dbPath, fileEntry);
	log.debug("Metadata of database successfully created");
	return config;
}
 
开发者ID:joe42,项目名称:nubisave,代码行数:49,代码来源:ConfigurableFuseBox.java


注:本文中的org.ini4j.Ini.fetch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。