private void saveMetadata() throws Exception { if (_minMaxValueAdded) { _segmentProperties.save(); } } }
private void createMetadataFile(File currentDir, File v3Dir) throws ConfigurationException { File v2MetadataFile = new File(currentDir, V1Constants.MetadataKeys.METADATA_FILE_NAME); File v3MetadataFile = new File(v3Dir, V1Constants.MetadataKeys.METADATA_FILE_NAME); final PropertiesConfiguration properties = new PropertiesConfiguration(v2MetadataFile); // update the segment version properties.setProperty(V1Constants.MetadataKeys.Segment.SEGMENT_VERSION, SegmentVersion.v3.toString()); properties.save(v3MetadataFile); }
public static void saveConfig() { try { config.save(getConfigFilePath()); LOGGER.info("Saved configuration to " + getConfigFilePath()); } catch (ConfigurationException e) { LOGGER.error("Error while saving configuration: ", e); } }
/** * Stores the index maps for multiple star-trees into a file. */ public static void storeToFile(List<Map<IndexKey, IndexValue>> indexMaps, File indexMapFile) throws ConfigurationException { Preconditions.checkState(!indexMapFile.exists(), "Star-tree index map file already exists"); PropertiesConfiguration configuration = new PropertiesConfiguration(indexMapFile); int numStarTrees = indexMaps.size(); for (int i = 0; i < numStarTrees; i++) { Map<IndexKey, IndexValue> indexMap = indexMaps.get(i); for (Map.Entry<IndexKey, IndexValue> entry : indexMap.entrySet()) { IndexKey key = entry.getKey(); IndexValue value = entry.getValue(); configuration.addProperty(key.getPropertyName(i, OFFSET_SUFFIX), value._offset); configuration.addProperty(key.getPropertyName(i, SIZE_SUFFIX), value._size); } } configuration.save(); }
/** * Get Java Env info as string */ @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN) public String getEnv() throws ConfigurationException, UnsupportedEncodingException { PropertiesConfiguration tempConfig = new PropertiesConfiguration(); OrderedProperties orderedProperties = new OrderedProperties(new TreeMap<String, String>()); // Add Java Env String content = ""; ByteArrayOutputStream baos = new ByteArrayOutputStream(); // env Map<String, String> env = System.getenv(); for (Map.Entry<String, String> entry : env.entrySet()) { orderedProperties.setProperty(entry.getKey(), entry.getValue()); } // properties Properties properties = System.getProperties(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { orderedProperties.setProperty((String) entry.getKey(), (String) entry.getValue()); } for (Map.Entry<String, String> entry : orderedProperties.entrySet()) { tempConfig.addProperty(entry.getKey(), entry.getValue()); } // do save tempConfig.save(baos); content = baos.toString("UTF-8"); return content; }
_metadataProperties.save(); StarTreeIndexMapUtils.storeToFile(indexMaps, new File(_segmentDirectory, INDEX_MAP_FILE_NAME)); FileUtils.forceDelete(starTreeIndexDir);
_segmentProperties.save();
/** * Helper method to update the metadata.properties for the converted segment. * * @param segmentDir Segment directory * @param columns Converted columns * @param tableName New table name to be written in the meta-data. Skipped if null. * @throws IOException * @throws ConfigurationException */ private void updateMetadata(File segmentDir, String[] columns, String tableName) throws IOException, ConfigurationException { File metadataFile = new File(segmentDir, V1Constants.MetadataKeys.METADATA_FILE_NAME); PropertiesConfiguration properties = new PropertiesConfiguration(metadataFile); if (tableName != null) { properties.setProperty(V1Constants.MetadataKeys.Segment.TABLE_NAME, tableName); } for (String column : columns) { properties.setProperty( V1Constants.MetadataKeys.Column.getKeyFor(column, V1Constants.MetadataKeys.Column.HAS_DICTIONARY), false); properties.setProperty( V1Constants.MetadataKeys.Column.getKeyFor(column, V1Constants.MetadataKeys.Column.BITS_PER_ELEMENT), -1); } properties.save(); }
convertColumn(columnToConvert); _convertedProperties.save();
properties.save();
public void printProperties() throws IOException { try { kylinConfig.save(System.out); } catch (ConfigurationException ex) { throw new IOException("Error printing KylinConfig", ex); } }
public void writeProperties(File file) throws IOException { try { kylinConfig.save(file); } catch (ConfigurationException ex) { throw new IOException("Error writing KylinConfig to " + file, ex); } }
public String getConfigAsString() throws IOException { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); kylinConfig.save(baos); String content = baos.toString(); return content; } catch (ConfigurationException ex) { throw new IOException("Error writing KylinConfig to String", ex); } }
public String serialize() { PropertiesConfiguration propConfig = new PropertiesConfiguration(); propConfig.copy(compositeConfig); StringWriter writer = new StringWriter(); try { propConfig.save(writer); } catch (ConfigurationException e) { // this should never happen throw new IllegalStateException(e); } return writer.toString(); }
private boolean migrateProperties(File dbPropsFile, Properties dbProps, String newMSKey, String newDBKey) { System.out.println("Migrating db.properties.."); StandardPBEStringEncryptor msEncryptor = new StandardPBEStringEncryptor(); ; initEncryptor(msEncryptor, newMSKey); try { PropertiesConfiguration newDBProps = new PropertiesConfiguration(dbPropsFile); if (newDBKey != null && !newDBKey.isEmpty()) { newDBProps.setProperty("db.cloud.encrypt.secret", "ENC(" + msEncryptor.encrypt(newDBKey) + ")"); } String prop = dbProps.getProperty("db.cloud.password"); if (prop != null && !prop.isEmpty()) { newDBProps.setProperty("db.cloud.password", "ENC(" + msEncryptor.encrypt(prop) + ")"); } prop = dbProps.getProperty("db.usage.password"); if (prop != null && !prop.isEmpty()) { newDBProps.setProperty("db.usage.password", "ENC(" + msEncryptor.encrypt(prop) + ")"); } newDBProps.save(dbPropsFile.getAbsolutePath()); } catch (Exception e) { e.printStackTrace(); return false; } System.out.println("Migrating db.properties Done."); return true; }
public static void storeConfiguration(final String fileName) throws IOException { try { PropertiesConfiguration.setDefaultListDelimiter('\0'); final PropertiesConfiguration config = new PropertiesConfiguration(); // store settings for (final Setting setting : settings.values()) { // story only modified settings and the super user password if (setting.isModified() || "superuser.password".equals(setting.getKey())) { config.setProperty(setting.getKey(), setting.getValue()); } } config.save(fileName); } catch (ConfigurationException ex) { System.err.println("Unable to store configuration: " + ex.getMessage()); } }
backupDBProps.save(); } catch (ConfigurationException e) { e.printStackTrace();
/** Saves the configuration to the specified file. * * @param filename a file name. */ public void save( final CharSequence filename ) throws ConfigurationException, IOException { final Writer w = new OutputStreamWriter( new FileOutputStream( filename.toString() ), "UTF-8" ); super.save( w ); w.close(); }
public void save(OutputStream out) { PropertiesConfiguration pconf = new PropertiesConfiguration(); pconf.setDelimiterParsingDisabled(true); pconf.append(internalConfig); try { pconf.save(out); } catch (ConfigurationException e) { throw new FluoException(e); } }