本文整理匯總了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);
}
示例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();
}
示例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
}
示例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++;
}
}
}
示例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();
}
}
}
示例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;
}