List of usage examples for org.apache.commons.configuration BaseConfiguration setProperty
public void setProperty(String key, Object value)
From source file:backup.store.BackupUtil.java
public static org.apache.commons.configuration.Configuration convert(Configuration conf) { BaseConfiguration baseConfiguration = new BaseConfiguration(); for (Entry<String, String> e : conf) { baseConfiguration.setProperty(e.getKey(), e.getValue()); }// w w w. j av a2s . c o m return baseConfiguration; }
From source file:com.dattack.naming.standalone.StandaloneContextFactory.java
private static CompositeConfiguration getConfiguration(final Map<?, ?> environment) { final BaseConfiguration baseConf = new BaseConfiguration(); for (final Entry<?, ?> entry : environment.entrySet()) { baseConf.setProperty(ObjectUtils.toString(entry.getKey()), entry.getValue()); }// w ww . ja v a 2 s . co m final CompositeConfiguration configuration = new CompositeConfiguration(); configuration.addConfiguration(new SystemConfiguration()); configuration.addConfiguration(new EnvironmentConfiguration()); configuration.addConfiguration(baseConf); return configuration; }
From source file:com.feedzai.fos.server.remote.impl.RemoteClassifierFactoryTest.java
@Test public void testCreation() throws Exception { BaseConfiguration configuration = new BaseConfiguration(); configuration.setProperty(FosConfig.FACTORY_NAME, DummyManagerFactory.class.getName()); configuration.setProperty(FosConfig.EMBEDDED_REGISTRY, true); configuration.setProperty(FosConfig.REGISTRY_PORT, 5959); final FosConfig fosConfig = new FosConfig(configuration); RemoteManagerFactory remoteClassifierFactory = new RemoteManagerFactory(); Assert.assertTrue(Whitebox.getInternalState(remoteClassifierFactory.createManager(fosConfig), "manager") instanceof DummyManager); Assert.assertTrue(Whitebox.getInternalState(remoteClassifierFactory.createManager(fosConfig).getScorer(), "scorer") instanceof DummyScorer); }
From source file:com.feedzai.fos.impl.weka.utils.WekaThreadSafeScorerPoolTest.java
@Test public void testScoring() throws Exception { BaseConfiguration configuration = new BaseConfiguration(); configuration.setProperty(GenericObjectPoolConfig.class.getName() + ".minIdle", 10); configuration.setProperty(GenericObjectPoolConfig.class.getName() + ".maxActive", 10); configuration.setProperty(FosConfig.HEADER_LOCATION, "target/test-classes/models/threadsafe"); configuration.setProperty(FosConfig.FACTORY_NAME, WekaManagerFactory.class.getName()); FileInputStream fis = new FileInputStream("target/test-classes/models/threadsafe/test.header"); String modelConfigJson = IOUtils.toString(fis); ObjectMapper mapper = new ObjectMapper(); ModelConfig modelConfig = mapper.readValue(modelConfigJson, ModelConfig.class); WekaManagerConfig wekaManagerConfig = new WekaManagerConfig(new FosConfig(configuration)); WekaThreadSafeScorer wekaThreadSafeScorer = new WekaThreadSafeScorerPool( new WekaModelConfig(modelConfig, wekaManagerConfig), wekaManagerConfig); double[] score = wekaThreadSafeScorer.score(new Object[] { 1.5, 0, "gray", "positive" }); assertEquals(2, score.length);/*from w w w .ja v a 2 s . c om*/ assertEquals(1.0, score[0] + score[1], 0.001); }
From source file:com.feedzai.fos.impl.weka.WekaScorerTest.java
public void poolCreationTest() throws FOSException { BaseConfiguration configuration = new BaseConfiguration(); configuration.setProperty(GenericObjectPoolConfig.class.getName() + ".minIdle", 10); configuration.setProperty(GenericObjectPoolConfig.class.getName() + ".maxActive", 10); configuration.setProperty(FosConfig.HEADER_LOCATION, "target/test-classes/models/threadsafe"); configuration.setProperty(FosConfig.FACTORY_NAME, WekaManagerFactory.class.getName()); WekaManagerConfig wekaManagerConfig = new WekaManagerConfig(new FosConfig(configuration)); WekaManager wekaManager = new WekaManager(wekaManagerConfig); WekaScorer wekaScorer = wekaManager.getScorer(); double[] score = wekaScorer.score(Lists.newArrayList(testUUID), new Object[] { 1.5, 0, "gray", "positive" }) .get(0);/* w w w . j a v a 2 s .c o m*/ assertEquals(2, score.length); assertEquals(1.0, score[0] + score[1], 0.001); Assert.assertTrue(((Map<Integer, WekaThreadSafeScorer>) Whitebox.getInternalState(wekaScorer, "wekaThreadSafeScorers")).get(testUUID) instanceof WekaThreadSafeScorerPool); }
From source file:com.feedzai.fos.impl.weka.WekaScorerTest.java
@Test public void passthroughCreationTest() throws FOSException { BaseConfiguration configuration = new BaseConfiguration(); configuration.setProperty(GenericObjectPoolConfig.class.getName() + ".minIdle", 10); configuration.setProperty(GenericObjectPoolConfig.class.getName() + ".maxActive", 10); configuration.setProperty(FosConfig.HEADER_LOCATION, "target/test-classes/models/threadunsafe"); configuration.setProperty(FosConfig.FACTORY_NAME, WekaManagerFactory.class.getName()); WekaManagerConfig wekaManagerConfig = new WekaManagerConfig(new FosConfig(configuration)); WekaManager wekaManager = new WekaManager(wekaManagerConfig); WekaScorer wekaScorer = wekaManager.getScorer(); double[] score = wekaScorer.score(Lists.newArrayList(testUUID), new Object[] { 1.5, 0, "gray", "positive" }) .get(0);//from ww w. j a v a2 s. co m assertEquals(2, score.length); assertEquals(1.0, score[0] + score[1], 0.001); Assert.assertTrue(((Map<Integer, WekaThreadSafeScorer>) Whitebox.getInternalState(wekaScorer, "wekaThreadSafeScorers")).get(testUUID) instanceof WekaThreadSafeScorerPassthrough); }
From source file:com.feedzai.fos.impl.r.RandomForestPMMLProducerConsumerTest.java
private RManager setupManager() throws FOSException { BaseConfiguration configuration = new BaseConfiguration(); configuration.setProperty(FosConfig.FACTORY_NAME, RManagerFactory.class.getName()); FosConfig config = new FosConfig(configuration); RManagerConfig rManagerConfig = new RManagerConfig(config); return new RManager(rManagerConfig); }
From source file:fr.inria.corese.rdftograph.driver.OrientDbDriver.java
@Override public Graph createDatabase(String databasePath) throws IOException { String path = databasePath.replaceFirst("plocal:", ""); super.createDatabase(path); graph = new OrientGraphFactory(databasePath); BaseConfiguration nodeConfig = new BaseConfiguration(); nodeConfig.setProperty("type", "NOTUNIQUE"); nodeConfig.setProperty("keytype", OType.STRING); graph.getTx().createVertexIndex(VERTEX_VALUE, RDF_VERTEX_LABEL, nodeConfig); nodeConfig = new BaseConfiguration(); nodeConfig.setProperty("type", "NOTUNIQUE"); nodeConfig.setProperty("keytype", OType.STRING); graph.getTx().createVertexIndex(KIND, RDF_VERTEX_LABEL, nodeConfig); nodeConfig = new BaseConfiguration(); nodeConfig.setProperty("type", "NOTUNIQUE"); nodeConfig.setProperty("keytype", OType.STRING); graph.getTx().createEdgeIndex(EDGE_P, RDF_EDGE_LABEL, nodeConfig); g = graph.getTx();/*from w w w . j a va 2s .c om*/ return g; }
From source file:ai.grakn.factory.OrientDBInternalFactory.java
private OrientGraph createIndicesVertex(OrientGraph graph) { ResourceBundle keys = ResourceBundle.getBundle("indices-vertices"); Set<String> labels = keys.keySet(); for (String label : labels) { String[] configs = keys.getString(label).split(","); for (String propertyConfig : configs) { String[] propertyConfigs = propertyConfig.split(":"); Schema.VertexProperty property = Schema.VertexProperty.valueOf(propertyConfigs[0]); boolean isUnique = Boolean.parseBoolean(propertyConfigs[1]); OType orientDataType = getOrientDataType(property); BaseConfiguration indexConfig = new BaseConfiguration(); indexConfig.setProperty("keytype", orientDataType); //TODO: Figure out why this is not working when the Orient Guys say it should //indexConfig.setProperty("metadata.ignoreNullValues", true); if (isUnique) { indexConfig.setProperty("type", "UNIQUE"); }/*from ww w. j a v a2 s . c om*/ if (!graph.getVertexIndexedKeys(label).contains(property.name())) { graph.createVertexIndex(property.name(), label, indexConfig); } } } return graph; }
From source file:com.dattack.dbcopy.engine.DbCopyJob.java
public void execute() { LOGGER.info("Running job '{}' at thread '{}'", dbcopyJobBean.getId(), Thread.currentThread().getName()); final List<Future<?>> futureList = new ArrayList<>(); final DbCopyJobResult jobResult = new DbCopyJobResult(dbcopyJobBean); MBeanHelper.registerMBean("com.dattack.dbcopy:type=JobResult,name=" + dbcopyJobBean.getId(), jobResult); final RangeVisitor rangeVisitor = new RangeVisitor() { @Override/*from w ww . j av a2 s .c o m*/ public void visite(final IntegerRangeBean bean) { for (int i = bean.getLowValue(); i < bean.getHighValue(); i += bean.getBlockSize()) { final int lowValue = i; final int highValue = i + bean.getBlockSize(); final BaseConfiguration baseConfiguration = new BaseConfiguration(); baseConfiguration.setProperty(bean.getId() + ".low", lowValue); baseConfiguration.setProperty(bean.getId() + ".high", highValue); final CompositeConfiguration configuration = new CompositeConfiguration(); configuration.addConfiguration(externalConfiguration); configuration.addConfiguration(ConfigurationUtil.createEnvSystemConfiguration()); configuration.addConfiguration(baseConfiguration); final String taskName = String.format("Task_%d_%d", lowValue, highValue); final DbCopyTask dbcopyTask = new DbCopyTask(dbcopyJobBean, configuration, jobResult.createTaskResult(taskName)); futureList.add(executionController.submit(dbcopyTask)); } } @Override public void visite(final NullRangeBean bean) { final String taskName = "SingleTask"; final CompositeConfiguration configuration = new CompositeConfiguration(); configuration.addConfiguration(externalConfiguration); configuration.addConfiguration(ConfigurationUtil.createEnvSystemConfiguration()); final DbCopyTask dbcopyTask = new DbCopyTask(dbcopyJobBean, configuration, jobResult.createTaskResult(taskName)); futureList.add(executionController.submit(dbcopyTask)); } }; if (dbcopyJobBean.getRangeBean() == null || dbcopyJobBean.getRangeBean().isEmpty()) { new NullRangeBean().accept(rangeVisitor); } else { for (final AbstractRangeBean item : dbcopyJobBean.getRangeBean()) { item.accept(rangeVisitor); } } executionController.shutdown(); showFutures(futureList); show(jobResult); LOGGER.info("Job finished (job-name: '{}', thread: '{}')", dbcopyJobBean.getId(), Thread.currentThread().getName()); }