List of usage examples for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration
public PropertiesConfiguration()
From source file:com.linkedin.pinot.core.segment.index.loader.LoadersTest.java
@BeforeMethod public void setUp() throws Exception { INDEX_DIR = Files.createTempDirectory(LoadersTest.class.getName() + "_segmentDir").toFile(); final String filePath = TestUtils .getFileFromResourceUrl(Loaders.class.getClassLoader().getResource(AVRO_DATA)); final SegmentGeneratorConfig config = SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns( new File(filePath), INDEX_DIR, "daysSinceEpoch", TimeUnit.HOURS, "testTable"); config.setSegmentNamePostfix("1"); config.setTimeColumnName("daysSinceEpoch"); final SegmentIndexCreationDriver driver = SegmentCreationDriverFactory.get(null); driver.init(config);/*from ww w .jav a2 s. c o m*/ driver.build(); segmentDirectory = new File(INDEX_DIR, driver.getSegmentName()); Configuration tableConfig = new PropertiesConfiguration(); tableConfig.addProperty(IndexLoadingConfigMetadata.KEY_OF_SEGMENT_FORMAT_VERSION, "v1"); v1LoadingConfig = new IndexLoadingConfigMetadata(tableConfig); tableConfig.clear(); tableConfig.addProperty(IndexLoadingConfigMetadata.KEY_OF_SEGMENT_FORMAT_VERSION, "v3"); v3LoadingConfig = new IndexLoadingConfigMetadata(tableConfig); }
From source file:com.linkedin.pinot.tools.admin.command.StartBrokerCommand.java
@Override public boolean execute() throws Exception { if (_brokerHost == null) { _brokerHost = NetUtil.getHostAddress(); }//from w w w .ja v a2 s .c o m Configuration configuration = readConfigFromFile(_configFileName); if (configuration == null) { if (_configFileName != null) { LOGGER.error("Error: Unable to find file {}.", _configFileName); return false; } configuration = new PropertiesConfiguration(); configuration.addProperty(CommonConstants.Helix.KEY_OF_BROKER_QUERY_PORT, _brokerPort); configuration.setProperty("pinot.broker.routing.table.builder.class", "random"); } LOGGER.info("Executing command: " + toString()); final HelixBrokerStarter pinotHelixBrokerStarter = new HelixBrokerStarter(_clusterName, _zkAddress, configuration); String pidFile = ".pinotAdminBroker-" + String.valueOf(System.currentTimeMillis()) + ".pid"; savePID(System.getProperty("java.io.tmpdir") + File.separator + pidFile); return true; }
From source file:io.fluo.mapreduce.FluoInputFormat.java
@Override public RecordReader<Bytes, ColumnIterator> createRecordReader(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { return new RecordReader<Bytes, ColumnIterator>() { private Entry<Bytes, ColumnIterator> entry; private RowIterator rowIter; private Environment env = null; private TransactionImpl ti = null; @Override//w w w . j a v a 2 s . c o m public void close() throws IOException { if (env != null) { env.close(); } if (ti != null) { ti.close(); } } @Override public Bytes getCurrentKey() throws IOException, InterruptedException { return entry.getKey(); } @Override public ColumnIterator getCurrentValue() throws IOException, InterruptedException { return entry.getValue(); } @Override public float getProgress() throws IOException, InterruptedException { // TODO Auto-generated method stub return 0; } @Override public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { try { // TODO this uses non public Accumulo API! RangeInputSplit ris = (RangeInputSplit) split; Span span = SpanUtil.toSpan(ris.getRange()); ByteArrayInputStream bais = new ByteArrayInputStream( context.getConfiguration().get(PROPS_CONF_KEY).getBytes("UTF-8")); PropertiesConfiguration props = new PropertiesConfiguration(); props.load(bais); env = new Environment(new FluoConfiguration(props)); ti = new TransactionImpl(env, context.getConfiguration().getLong(TIMESTAMP_CONF_KEY, -1)); ScannerConfiguration sc = new ScannerConfiguration().setSpan(span); for (String fam : context.getConfiguration().getStrings(FAMS_CONF_KEY, new String[0])) sc.fetchColumnFamily(Bytes.wrap(fam)); rowIter = ti.get(sc); } catch (Exception e) { throw new IOException(e); } } @Override public boolean nextKeyValue() throws IOException, InterruptedException { if (rowIter.hasNext()) { entry = rowIter.next(); return true; } return false; } }; }
From source file:maltcms.ui.fileHandles.properties.tools.SceneExporter.java
/** * Layout: NAME/ NAME.properties NAME-general.properties (optional) * fragmentCommands/ 00_CLASSNAME/ CLASSNAME.properties 01_CLASSNAME/ * CLASSNAME.properties//from www . j av a 2 s . com * * @param pipeline * @param general */ private void createConfigFiles(List<PipelineElementWidget> pipeline, PipelineGeneralConfigWidget general) { try { //create base config FileObject baseConfigFo = this.file.getFileObject(this.name + ".mpl"); File f = FileUtil.toFile(baseConfigFo); PropertiesConfiguration baseConfig = new PropertiesConfiguration(); File subDir = new File(f.getParent(), "xml"); FileUtil.createFolder(subDir); //retrieve general configuration Configuration generalConfig = general.getProperties(); //only create and link, if non-empty if (!generalConfig.isEmpty()) { ConfigurationUtils.copy(generalConfig, baseConfig); } //String list for pipeline elements List<String> pipelineElements = new LinkedList<>(); File pipelineXml = new File(subDir, this.name + ".xml"); for (PipelineElementWidget pw : pipeline) { //add full class name to pipeline elements pipelineElements.add(pw.getClassName()); //write configuration to that file PropertiesConfiguration pc = new PropertiesConfiguration(); } //set pipeline property baseConfig.setProperty("pipeline", pipelineElements); //set pipeline.properties property String pipelineXmlString = "file:${config.basedir}/xml/bipace.xml"; baseConfig.setProperty("pipeline.xml", pipelineXmlString); FileObject fo = FileUtil.toFileObject(f); try { baseConfig.save(new PrintStream(fo.getOutputStream())); } catch (ConfigurationException ex) { Exceptions.printStackTrace(ex); } } catch (FileNotFoundException ex) { Exceptions.printStackTrace(ex); } catch (IOException ex) { Exceptions.printStackTrace(ex); } }
From source file:de.ppi.selenium.browser.ClientProperties.java
/** * Constructs a {@code ClientProperties} from the given file. * * @param filePath the file to be loaded *//*from w ww. j av a 2 s . c o m*/ public ClientProperties(String filePath) { URL clientPath = this.getClass().getClassLoader().getResource(filePath); this.config = new PropertiesConfiguration(); this.config.setDelimiterParsingDisabled(true); try { client = clientPath; // Disable delimiting values (default is comma delimited) this.config.load(client); } catch (ConfigurationException e) { String message = "Client configuration could not be loaded from file: \"" + filePath + "\""; LOG.error(message, e); throw new RuntimeException(message, e); } propertiesConfigurationLayout = config.getLayout(); browser = load("browser", "htmlunit", "Browser name. See browsers supported by WebDriver."); browserVersion = load("browser.version", null, "Version of the browser (if applicable)."); proxy = load("proxy", null, null); proxyHttps = load("proxy.https", null, null); String browserInitPositionXStr = load("browser.init.position.x", "0", "Horizontal position for moving browser to. Useful for debugging tests."); try { browserInitPositionX = Integer.parseInt(browserInitPositionXStr); } catch (Exception e) { LOG.error("Error parsing '" + browserInitPositionXStr + "' (value of 'browser.init.position.x' property from client properties file) as integer. Please fix your test configuration."); } String browserInitPositionYStr = load("browser.init.position.y", "0", "Vertical position for moving browser to. Useful for debugging tests."); try { browserInitPositionY = Integer.parseInt(browserInitPositionYStr); } catch (Exception e) { LOG.error("Error parsing '" + browserInitPositionYStr + "' (value of 'browser.init.position.y' property from client properties file) as integer. Please fix your test configuration."); } acceptLanguages = load("browser.accept_languages", null, "Accepted Languages."); os = load("os", null, null); osVersion = load("os.version", null, null); maxPageWaitString = load("maxPageWait", "30000", "Standard maximum page wait timeout throughout your automation project (in milliseconds)"); try { maxPageWait = Integer.parseInt(maxPageWaitString); } catch (Exception e) { LOG.warn("error parsing maxPageWaitString", e); } appearWaitTimeString = load("appearWaitTime", "5000", "Maximum time for waiting of element appear (in milliseconds)"); try { appearWaitTime = Integer.parseInt(appearWaitTimeString); } catch (Exception e) { LOG.warn("error parsing appearWaitTimeString", e); } maxRequestTimeoutString = load("maxRequestTimeout", "30000", "Standard maximum request wait timeout throughout your automation project (in milliseconds)"); try { maxRequestTimeout = Integer.parseInt(maxRequestTimeoutString); } catch (Exception e) { LOG.warn("error parsing maxRequestTimeoutString", e); } maxDownloadWaitTime = Integer.parseInt(load("download.time", "30000", "Maximum download wait timeout")); downloadFolder = load("download.folder", null, "Default download folder"); ffBinaryPath = loadAndCheckFileExists("ffBinaryPath", null, "Path to Firefox executable (if you want to use specific version installed on your machine instead of default FF installation)"); chromeBinaryPath = loadAndCheckFileExists("chromeBinaryPath", null, "Path to Chrome executable (if you want to use specific version installed on your machine instead of default Chrome installation)"); webDriverIEDriver = loadAndCheckFileExists("webdriver.ie.driver", null, "Path to IEDriverServer.exe"); webDriverChromeDriver = loadAndCheckFileExists("webdriver.chrome.driver", null, "Path to chromedriver executable"); webDriverPhantomJsDriver = loadAndCheckFileExists("webdriver.phantomjs.driver", null, "Path to chromedriver executable"); String uploadFolderStr = load("upload.folder", null, "Default folder to grab files from to perform upload"); if (uploadFolderStr != null && !uploadFolderStr.equals("")) { File temp = new File(uploadFolderStr); uploadFolder = temp.getAbsolutePath(); } else { uploadFolder = "."; } firefoxProfileFolder = loadAndCheckFileExists("firefoxProfile.folder", null, "Path to custom Firefox profile (setup Firefox profile)"); firefoxPropertiesFile = loadAndCheckFileExists("firefoxProfile.file", null, "Properties file containing configuration you want to load to current Firefox profile (setup Firefox properties file)"); // Check before 'webdriver.doTaskKill' String useGridStr = load("useGrid", "false", "Setting for running tests against Selenium Grid or Sauce Labs"); if (useGridStr != null && useGridStr.equalsIgnoreCase("true")) { useGrid = true; } else { useGrid = false; } // Check after 'useGrid' String taskCheck = load("webdriver.doTaskKill", "true", "Gracefully kill all the driver server processes at the beginning of execution"); if (taskCheck != null) { if (taskCheck.equalsIgnoreCase("false") || taskCheck.equalsIgnoreCase("0") || taskCheck.equalsIgnoreCase("no") || useGrid) { doTaskKill = false; } else if ((taskCheck.equalsIgnoreCase("true") || taskCheck.equalsIgnoreCase("1") || taskCheck.equalsIgnoreCase("yes"))) { doTaskKill = true; } else { LOG.error( "Property 'doTaskKill' is not within range of accepted values. (Range of accepted values are '1'/'0', 'Yes'/'No' and 'True'/'False')"); doTaskKill = true; } } else { // Default value doTaskKill = true; } String numberOfDaysToKeepTempFoldersStr = load("numberOfDaysToKeepTempFolders", "7", "Specify the period of which you want to keep temporary WebDriver folders created in temp directory"); try { numberOfDaysToKeepTempFolders = Integer.parseInt(numberOfDaysToKeepTempFoldersStr); } catch (Exception e) { LOG.warn("error parsing numberOfDaysToKeepTempFoldersStr", e); } tempFolderNameContainsList = load("tempFolderNameContainsList", null, "Comma separated list of folders to clean with webDriver temp files"); for (int i = 1; config.containsKey("firefoxProfile.extension." + Integer.toString(i)); i++) { String ext = config.getString("firefoxProfile.extension." + Integer.toString(i)); firefoxExtensions.add(ext); } String highlight = load("highlight", "false", "Highlighting web elements during execution"); if (highlight.equalsIgnoreCase("true") || highlight.equalsIgnoreCase("yes") || highlight.equalsIgnoreCase("1")) { isHighlight = true; } else if (highlight.equalsIgnoreCase("false") || highlight.equalsIgnoreCase("no") || highlight.equalsIgnoreCase("0")) { isHighlight = false; } else { LOG.error("Error parsing client property 'highlight' ('" + highlight + "'). It can be one of 'true / false', 'yes / no', '1 / 0'."); } highlightColorMap = new HashMap<String, String>(); loadColorMapRgb(); maxAllowedSessions = load("maxAllowedSessions", null, null); String debug = load("debugMode", "false", "Test debug mode. If it is on, highlight will be turned on by default"); // If debug is on, then turn highlight on if (debug != null && debug.equalsIgnoreCase("true")) { debugMode = true; isHighlight = true; } else { debugMode = false; } String selectLastFrameStr = load("selectLastFrame", "true", "Feature to select last frame automatically"); if (selectLastFrameStr != null && selectLastFrameStr.equalsIgnoreCase("false")) { selectLastFrame = false; } else { selectLastFrame = true; } gridUrl = load("grid.url", "http://username-string:access-key-string@ondemand.saucelabs.com:80/wd/hub", "Sauce labs URL (e.g. 'http://username-string:access-key-string@ondemand.saucelabs.com:80/wd/hub')"); gridPlatform = load("grid.platform", "Windows 7", "Selenium Grid OS Platform name (e.g. 'Windows 7')"); gridProperties = load("grid.properties", "record-screenshots=true", "Space separated Selenium Grid properties (e.g. 'record-screenshots=true')"); }
From source file:com.liferay.ide.project.core.SDKProjectRemoteServerPublisher.java
@Override public IPath publishModuleFull(IProgressMonitor monitor) throws CoreException { final IPath deployPath = LiferayServerCore.getTempLocation("direct-deploy", StringPool.EMPTY); //$NON-NLS-1$ File warFile = deployPath.append(getProject().getName() + ".war").toFile(); //$NON-NLS-1$ warFile.getParentFile().mkdirs();/* ww w . ja v a 2 s . co m*/ final Map<String, String> properties = new HashMap<String, String>(); properties.put(ISDKConstants.PROPERTY_AUTO_DEPLOY_UNPACK_WAR, "false"); //$NON-NLS-1$ final ILiferayRuntime runtime = ServerUtil.getLiferayRuntime(getProject()); final String appServerDeployDirProp = ServerUtil .getAppServerPropertyKey(ISDKConstants.PROPERTY_APP_SERVER_DEPLOY_DIR, runtime); properties.put(appServerDeployDirProp, deployPath.toOSString()); // IDE-1073 LPS-37923 properties.put(ISDKConstants.PROPERTY_PLUGIN_FILE_DEFAULT, warFile.getAbsolutePath()); properties.put(ISDKConstants.PROPERTY_PLUGIN_FILE, warFile.getAbsolutePath()); final String fileTimeStamp = System.currentTimeMillis() + ""; // IDE-1491 properties.put(ISDKConstants.PROPERTY_LP_VERSION, fileTimeStamp); properties.put(ISDKConstants.PROPERTY_LP_VERSION_SUFFIX, ".0"); IStatus status = sdk.validate(); if (!status.isOK()) { throw new CoreException(status); } final IStatus directDeployStatus = sdk.war(getProject(), properties, true, new String[] { "-Duser.timezone=GMT" }, monitor); if (!directDeployStatus.isOK() || (!warFile.exists())) { String pluginVersion = "1"; final IPath pluginPropertiesPath = new Path("WEB-INF/liferay-plugin-package.properties"); final IWebProject webproject = LiferayCore.create(IWebProject.class, getProject()); if (webproject != null) { final IResource propsRes = webproject.findDocrootResource(pluginPropertiesPath); if (propsRes instanceof IFile && propsRes.exists()) { try { final PropertiesConfiguration pluginPackageProperties = new PropertiesConfiguration(); final InputStream is = ((IFile) propsRes).getContents(); pluginPackageProperties.load(is); pluginVersion = pluginPackageProperties.getString("module-incremental-version"); is.close(); } catch (Exception e) { LiferayCore.logError("error reading module-incremtnal-version. ", e); } } warFile = sdk.getLocation().append("dist") .append(getProject().getName() + "-" + fileTimeStamp + "." + pluginVersion + ".0" + ".war") .toFile(); if (!warFile.exists()) { throw new CoreException(directDeployStatus); } } } return new Path(warFile.getAbsolutePath()); }
From source file:edu.berkeley.sparrow.api.SparrowFrontendClient.java
/** * Initialize a connection to a sparrow scheduler. * @param sparrowSchedulerAddr. The socket address of the Sparrow scheduler. * @param app. The application id. Note that this must be consistent across frontends * and backends.//from w w w . j av a 2 s .c om * @param frontendServer. A class which implements the frontend server interface (for * communication from Sparrow). * @param listenPort. The port on which to listen for request from the scheduler. * @throws IOException */ public void initialize(InetSocketAddress sparrowSchedulerAddr, String app, FrontendService.Iface frontendServer, int listenPort) throws TException, IOException { FrontendService.Processor<FrontendService.Iface> processor = new FrontendService.Processor<FrontendService.Iface>( frontendServer); if (!launchedServerAlready) { try { TServers.launchThreadedThriftServer(listenPort, 8, processor); } catch (IOException e) { LOG.fatal("Couldn't launch server side of frontend", e); } launchedServerAlready = true; } for (int i = 0; i < NUM_CLIENTS; i++) { Client client = TClients.createBlockingSchedulerClient( sparrowSchedulerAddr.getAddress().getHostAddress(), sparrowSchedulerAddr.getPort(), 60000); clients.add(client); } clients.peek().registerFrontend(app, Network.getIPAddress(new PropertiesConfiguration()) + ":" + listenPort); }
From source file:com.linkedin.pinot.integration.tests.FileBasedServerBrokerStarters.java
private PropertiesConfiguration serverProperties() { final PropertiesConfiguration serverConfiguration = new PropertiesConfiguration(); serverConfiguration.addProperty(getKey("pinot.server.instance", "id"), "0"); serverConfiguration.addProperty(getKey("pinot.server.instance", "bootstrap.segment.dir"), SERVER_BOOTSTRAP_DIR);//from ww w . j a v a 2 s .c o m serverConfiguration.addProperty(getKey("pinot.server.instance", "dataDir"), SERVER_INDEX_DIR); serverConfiguration.addProperty(getKey("pinot.server.instance", "tableName"), StringUtils.join(TABLE_NAMES, ',').trim()); for (final String table : TABLE_NAMES) { serverConfiguration .addProperty(getKey("pinot.server.instance", table.trim(), "numQueryExecutorThreads"), "50"); serverConfiguration.addProperty(getKey("pinot.server.instance", table.trim(), "dataManagerType"), "offline"); serverConfiguration.addProperty(getKey("pinot.server.instance", table.trim(), "readMode"), SERVER_INDEX_READ_MODE); } serverConfiguration.addProperty("pinot.server.instance.data.manager.class", FileBasedInstanceDataManager.class.getName()); serverConfiguration.addProperty("pinot.server.instance.segment.metadata.loader.class", ColumnarSegmentMetadataLoader.class.getName()); serverConfiguration.addProperty("pinot.server.query.executor.pruner.class", StringUtil.join(",", TimeSegmentPruner.class.getSimpleName(), DataSchemaSegmentPruner.class.getSimpleName(), ValidSegmentPruner.class.getSimpleName())); serverConfiguration.addProperty("pinot.server.query.executor.pruner.TimeSegmentPruner.id", "0"); serverConfiguration.addProperty("pinot.server.query.executor.pruner.DataSchemaSegmentPruner.id", "1"); serverConfiguration.addProperty("pinot.server.query.executor.pruner.ValidSegmentPruner.id", "2"); serverConfiguration.addProperty("pinot.server.query.executor.class", ServerQueryExecutorV1Impl.class.getName()); serverConfiguration.addProperty("pinot.server.requestHandlerFactory.class", SimpleRequestHandlerFactory.class.getName()); serverConfiguration.addProperty("pinot.server.netty.port", SERVER_PORT); serverConfiguration.setDelimiterParsingDisabled(false); return serverConfiguration; }
From source file:ch.epfl.eagle.api.EagleFrontendClient.java
/** * Initialize a connection to an eagle scheduler. * @param eagleSchedulerAddr. The socket address of the Eagle scheduler. * @param app. The application id. Note that this must be consistent across frontends * and backends./*w w w . j a va2s . com*/ * @param frontendServer. A class which implements the frontend server interface (for * communication from Eagle). * @param listenPort. The port on which to listen for request from the scheduler. * @throws IOException */ public void initialize(InetSocketAddress eagleSchedulerAddr, String app, FrontendService.Iface frontendServer, int listenPort) throws TException, IOException { FrontendService.Processor<FrontendService.Iface> processor = new FrontendService.Processor<FrontendService.Iface>( frontendServer); if (!launchedServerAlready) { try { TServers.launchThreadedThriftServer(listenPort, 8, processor); } catch (IOException e) { LOG.fatal("Couldn't launch server side of frontend", e); } launchedServerAlready = true; } for (int i = 0; i < NUM_CLIENTS; i++) { Client client = TClients.createBlockingSchedulerClient(eagleSchedulerAddr.getAddress().getHostAddress(), eagleSchedulerAddr.getPort(), 60000); clients.add(client); } clients.peek().registerFrontend(app, Network.getIPAddress(new PropertiesConfiguration()) + ":" + listenPort); }
From source file:com.linkedin.pinot.query.aggregation.AggregationQueriesOnMultiValueColumnTest.java
@BeforeClass public void setup() throws Exception { _instancePlanMaker = new InstancePlanMakerImplV2(new QueryExecutorConfig(new PropertiesConfiguration())); setupSegment();/*from ww w . j a va 2 s. co m*/ setupQuery(); setupDataSourceMap(); }