List of usage examples for org.apache.commons.configuration Configuration getKeys
Iterator getKeys();
From source file:org.apache.qpid.server.configuration.plugins.AbstractConfiguration.java
/** Helper method to print out list of keys in a {@link Configuration}. */ public static final void showKeys(Configuration config) { if (config.isEmpty()) { _logger.info("Configuration is empty"); } else {// www . j av a2 s . com Iterator<?> keys = config.getKeys(); while (keys.hasNext()) { String key = (String) keys.next(); _logger.info("Configuration key: " + key); } } }
From source file:org.apache.qpid.server.configuration.XmlConfigurationUtilities.java
public static Configuration parseConfig(File file) throws ConfigurationException { ConfigurationFactory factory = new ConfigurationFactory(); factory.setConfigurationFileName(file.getAbsolutePath()); Configuration conf = factory.getConfiguration(); Iterator<?> keys = conf.getKeys(); if (!keys.hasNext()) { keys = null;//from w ww. ja va2s .c o m conf = flatConfig(file); } return conf; }
From source file:org.apache.qpid.server.store.SlowMessageStore.java
private void configureDelays(Configuration config) { @SuppressWarnings("unchecked") Iterator<String> delays = config.getKeys(); while (delays.hasNext()) { String key = (String) delays.next(); if (key.endsWith(PRE)) { _preDelays.put(key.substring(0, key.length() - PRE.length() - 1), config.getLong(key)); } else if (key.endsWith(POST)) { _postDelays.put(key.substring(0, key.length() - POST.length() - 1), config.getLong(key)); }/* w ww. java2 s. c om*/ } }
From source file:org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection.java
public DriverRemoteConnection(final Configuration conf) { final boolean hasClusterConf = IteratorUtils.anyMatch(conf.getKeys(), k -> k.startsWith("clusterConfiguration")); if (conf.containsKey(GREMLIN_REMOTE_DRIVER_CLUSTERFILE) && hasClusterConf) throw new IllegalStateException( String.format("A configuration should not contain both '%s' and 'clusterConfiguration'", GREMLIN_REMOTE_DRIVER_CLUSTERFILE)); remoteTraversalSourceName = conf.getString(GREMLIN_REMOTE_DRIVER_SOURCENAME, DEFAULT_TRAVERSAL_SOURCE); try {/* w w w. j a va 2 s . c o m*/ final Cluster cluster; if (!conf.containsKey(GREMLIN_REMOTE_DRIVER_CLUSTERFILE) && !hasClusterConf) cluster = Cluster.open(); else cluster = conf.containsKey(GREMLIN_REMOTE_DRIVER_CLUSTERFILE) ? Cluster.open(conf.getString(GREMLIN_REMOTE_DRIVER_CLUSTERFILE)) : Cluster.open(conf.subset("clusterConfiguration")); client = cluster.connect(Client.Settings.build().create()).alias(remoteTraversalSourceName); } catch (Exception ex) { throw new IllegalStateException(ex); } tryCloseCluster = true; this.conf = Optional.of(conf); }
From source file:org.apache.tinkerpop.gremlin.driver.Settings.java
/** * Read configuration from a file into a new {@link Settings} object. *//*w ww . j ava2s .c o m*/ public static Settings from(final Configuration conf) { final Settings settings = new Settings(); if (conf.containsKey("port")) settings.port = conf.getInt("port"); if (conf.containsKey("nioPoolSize")) settings.nioPoolSize = conf.getInt("nioPoolSize"); if (conf.containsKey("workerPoolSize")) settings.workerPoolSize = conf.getInt("workerPoolSize"); if (conf.containsKey("username")) settings.username = conf.getString("username"); if (conf.containsKey("password")) settings.password = conf.getString("password"); if (conf.containsKey("jaasEntry")) settings.jaasEntry = conf.getString("jaasEntry"); if (conf.containsKey("protocol")) settings.protocol = conf.getString("protocol"); if (conf.containsKey("hosts")) settings.hosts = conf.getList("hosts").stream().map(Object::toString).collect(Collectors.toList()); if (conf.containsKey("serializer.className")) { final SerializerSettings serializerSettings = new SerializerSettings(); final Configuration serializerConf = conf.subset("serializer"); if (serializerConf.containsKey("className")) serializerSettings.className = serializerConf.getString("className"); final Configuration serializerConfigConf = conf.subset("serializer.config"); if (IteratorUtils.count(serializerConfigConf.getKeys()) > 0) { final Map<String, Object> m = new HashMap<>(); serializerConfigConf.getKeys().forEachRemaining(name -> { m.put(name, serializerConfigConf.getProperty(name)); }); serializerSettings.config = m; } settings.serializer = serializerSettings; } final Configuration connectionPoolConf = conf.subset("connectionPool"); if (IteratorUtils.count(connectionPoolConf.getKeys()) > 0) { final ConnectionPoolSettings cpSettings = new ConnectionPoolSettings(); if (connectionPoolConf.containsKey("channelizer")) cpSettings.channelizer = connectionPoolConf.getString("channelizer"); if (connectionPoolConf.containsKey("enableSsl")) cpSettings.enableSsl = connectionPoolConf.getBoolean("enableSsl"); if (connectionPoolConf.containsKey("trustCertChainFile")) cpSettings.trustCertChainFile = connectionPoolConf.getString("trustCertChainFile"); if (connectionPoolConf.containsKey("minSize")) cpSettings.minSize = connectionPoolConf.getInt("minSize"); if (connectionPoolConf.containsKey("maxSize")) cpSettings.maxSize = connectionPoolConf.getInt("maxSize"); if (connectionPoolConf.containsKey("minSimultaneousUsagePerConnection")) cpSettings.minSimultaneousUsagePerConnection = connectionPoolConf .getInt("minSimultaneousUsagePerConnection"); if (connectionPoolConf.containsKey("maxSimultaneousUsagePerConnection")) cpSettings.maxSimultaneousUsagePerConnection = connectionPoolConf .getInt("maxSimultaneousUsagePerConnection"); if (connectionPoolConf.containsKey("maxInProcessPerConnection")) cpSettings.maxInProcessPerConnection = connectionPoolConf.getInt("maxInProcessPerConnection"); if (connectionPoolConf.containsKey("minInProcessPerConnection")) cpSettings.minInProcessPerConnection = connectionPoolConf.getInt("minInProcessPerConnection"); if (connectionPoolConf.containsKey("maxWaitForConnection")) cpSettings.maxWaitForConnection = connectionPoolConf.getInt("maxWaitForConnection"); if (connectionPoolConf.containsKey("maxContentLength")) cpSettings.maxContentLength = connectionPoolConf.getInt("maxContentLength"); if (connectionPoolConf.containsKey("reconnectInterval")) cpSettings.reconnectInterval = connectionPoolConf.getInt("reconnectInterval"); if (connectionPoolConf.containsKey("reconnectInitialDelay")) cpSettings.reconnectInitialDelay = connectionPoolConf.getInt("reconnectInitialDelay"); if (connectionPoolConf.containsKey("resultIterationBatchSize")) cpSettings.resultIterationBatchSize = connectionPoolConf.getInt("resultIterationBatchSize"); if (connectionPoolConf.containsKey("keepAliveInterval")) cpSettings.keepAliveInterval = connectionPoolConf.getLong("keepAliveInterval"); settings.connectionPool = cpSettings; } return settings; }
From source file:org.apache.tinkerpop.gremlin.giraph.process.computer.GiraphGraphComputer.java
public GiraphGraphComputer(final HadoopGraph hadoopGraph) { super(hadoopGraph); final Configuration configuration = hadoopGraph.configuration(); configuration.getKeys().forEachRemaining( key -> this.giraphConfiguration.set(key, configuration.getProperty(key).toString())); this.giraphConfiguration.setMasterComputeClass(GiraphMemory.class); this.giraphConfiguration.setVertexClass(GiraphVertex.class); this.giraphConfiguration.setComputationClass(GiraphComputation.class); this.giraphConfiguration.setWorkerContextClass(GiraphWorkerContext.class); this.giraphConfiguration.setOutEdgesClass(EmptyOutEdges.class); this.giraphConfiguration.setClass(GiraphConstants.VERTEX_ID_CLASS.getKey(), ObjectWritable.class, ObjectWritable.class); this.giraphConfiguration.setClass(GiraphConstants.VERTEX_VALUE_CLASS.getKey(), VertexWritable.class, VertexWritable.class); this.giraphConfiguration.setBoolean(GiraphConstants.STATIC_GRAPH.getKey(), true); this.giraphConfiguration.setVertexInputFormatClass(GiraphVertexInputFormat.class); this.giraphConfiguration.setVertexOutputFormatClass(GiraphVertexOutputFormat.class); this.useWorkerThreadsInConfiguration = this.giraphConfiguration.getInt(GiraphConstants.MAX_WORKERS, -666) != -666// w w w . j a va 2 s . co m || this.giraphConfiguration.getInt(GiraphConstants.NUM_COMPUTE_THREADS.getKey(), -666) != -666; }
From source file:org.apache.tinkerpop.gremlin.groovy.engine.GroovyTraversalScript.java
@Override public GroovyTraversalScript<S, E> over(final Graph graph) { final Configuration configuration = graph.configuration(); final StringBuilder configurationMap = new StringBuilder("g = GraphFactory.open(["); configuration.getKeys().forEachRemaining(key -> configurationMap.append("'").append(key).append("':'") .append(configuration.getProperty(key)).append("',")); configurationMap.deleteCharAt(configurationMap.length() - 1).append("])\n"); this.openGraphScript = configurationMap.toString(); this.openGraphScript = this.openGraphScript + "g.engine(ComputerTraversalEngine.computer)\n"; return this; }
From source file:org.apache.tinkerpop.gremlin.hadoop.process.computer.giraph.GiraphGraphComputer.java
public GiraphGraphComputer(final HadoopGraph hadoopGraph) { super(hadoopGraph); final Configuration configuration = hadoopGraph.configuration(); configuration.getKeys().forEachRemaining( key -> this.giraphConfiguration.set(key, configuration.getProperty(key).toString())); this.giraphConfiguration.setMasterComputeClass(GiraphMemory.class); this.giraphConfiguration.setVertexClass(GiraphComputeVertex.class); this.giraphConfiguration.setWorkerContextClass(GiraphWorkerContext.class); this.giraphConfiguration.setOutEdgesClass(EmptyOutEdges.class); this.giraphConfiguration.setClass(GiraphConstants.VERTEX_ID_CLASS.getKey(), ObjectWritable.class, ObjectWritable.class); this.giraphConfiguration.setClass(GiraphConstants.VERTEX_VALUE_CLASS.getKey(), VertexWritable.class, VertexWritable.class); this.giraphConfiguration.setBoolean(GiraphConstants.STATIC_GRAPH.getKey(), true); this.giraphConfiguration.setVertexInputFormatClass(GiraphVertexInputFormat.class); this.giraphConfiguration.setVertexOutputFormatClass(GiraphVertexOutputFormat.class); }
From source file:org.apache.tinkerpop.gremlin.jsr223.JavaTranslator.java
private Object translateObject(final Object object) { if (object instanceof Bytecode.Binding) return translateObject(((Bytecode.Binding) object).value()); else if (object instanceof Bytecode) { try {/*from w w w . j a v a 2 s .com*/ final Traversal.Admin<?, ?> traversal = (Traversal.Admin) this.anonymousTraversal.getMethod("start") .invoke(null); for (final Bytecode.Instruction instruction : ((Bytecode) object).getStepInstructions()) { invokeMethod(traversal, Traversal.class, instruction.getOperator(), instruction.getArguments()); } return traversal; } catch (final Throwable e) { throw new IllegalStateException(e.getMessage()); } } else if (object instanceof TraversalStrategyProxy) { final Map<String, Object> map = new HashMap<>(); final Configuration configuration = ((TraversalStrategyProxy) object).getConfiguration(); configuration.getKeys() .forEachRemaining(key -> map.put(key, translateObject(configuration.getProperty(key)))); try { return map.isEmpty() ? ((TraversalStrategyProxy) object).getStrategyClass().getMethod("instance").invoke(null) : ((TraversalStrategyProxy) object).getStrategyClass() .getMethod("create", Configuration.class).invoke(null, new MapConfiguration(map)); } catch (final NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { throw new IllegalStateException(e.getMessage(), e); } } else if (object instanceof Map) { final Map<Object, Object> map = new LinkedHashMap<>(((Map) object).size()); for (final Map.Entry<?, ?> entry : ((Map<?, ?>) object).entrySet()) { map.put(translateObject(entry.getKey()), translateObject(entry.getValue())); } return map; } else if (object instanceof List) { final List<Object> list = new ArrayList<>(((List) object).size()); for (final Object o : (List) object) { list.add(translateObject(o)); } return list; } else if (object instanceof Set) { final Set<Object> set = new HashSet<>(((Set) object).size()); for (final Object o : (Set) object) { set.add(translateObject(o)); } return set; } else return object; }
From source file:org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy.java
public static VertexProgramStrategy create(final Configuration configuration) { try {//from ww w .j av a2 s .co m final VertexProgramStrategy.Builder builder = VertexProgramStrategy.build(); for (final String key : (List<String>) IteratorUtils.asList(configuration.getKeys())) { if (key.equals(GRAPH_COMPUTER)) builder.graphComputer((Class) Class.forName(configuration.getString(key))); else if (key.equals(WORKERS)) builder.workers(configuration.getInt(key)); else if (key.equals(PERSIST)) builder.persist(GraphComputer.Persist.valueOf(configuration.getString(key))); else if (key.equals(RESULT)) builder.result(GraphComputer.ResultGraph.valueOf(configuration.getString(key))); else if (key.equals(VERTICES)) builder.vertices((Traversal) configuration.getProperty(key)); else if (key.equals(EDGES)) builder.edges((Traversal) configuration.getProperty(key)); else builder.configure(key, configuration.getProperty(key)); } return builder.create(); } catch (final ClassNotFoundException e) { throw new IllegalArgumentException(e.getMessage(), e); } }