List of usage examples for org.apache.commons.configuration Configuration getInt
int getInt(String key, int defaultValue);
From source file:org.apache.whirr.service.accumulo.AccumuloMasterClusterActionHandler.java
@Override protected void configureFirewallRules(FirewallManager firewallManager, Configuration conf) throws IOException { // open port for master (9999 by default) firewallManager.addRule(Rule.create().destination(role(AccumuloMasterClusterActionHandler.ROLE)) .port(conf.getInt(AccumuloConstants.PROP_ACCUMULO_PORT_MASTER, AccumuloConstants.DEFAULT_ACCUMULO_PORT_MASTER))); }
From source file:org.apache.whirr.service.accumulo.AccumuloMonitorClusterActionHandler.java
@Override protected void configureFirewallRules(FirewallManager firewallManager, Configuration conf) throws IOException { firewallManager.addRule(Rule.create().destination(role(AccumuloMonitorClusterActionHandler.ROLE)) .port(conf.getInt(AccumuloConstants.PROP_ACCUMULO_PORT_MONITOR, AccumuloConstants.DEFAULT_ACCUMULO_PORT_MONITOR))); }
From source file:org.apache.whirr.service.accumulo.AccumuloTabletServerClusterActionHandler.java
@Override protected void configureFirewallRules(FirewallManager firewallManager, Configuration conf) throws IOException { firewallManager.addRule(Rule.create().destination(role(AccumuloTabletServerClusterActionHandler.ROLE)) .port(conf.getInt(AccumuloConstants.PROP_ACCUMULO_PORT_TSERVER, AccumuloConstants.DEFAULT_ACCUMULO_PORT_TSERVER))); }
From source file:org.apache.whirr.service.accumulo.AccumuloTracerClusterActionHandler.java
@Override protected void configureFirewallRules(FirewallManager firewallManager, Configuration conf) throws IOException { firewallManager.addRule(Rule.create().destination(role(AccumuloTracerClusterActionHandler.ROLE)) .port(conf.getInt(AccumuloConstants.PROP_ACCUMULO_PORT_TRACER, AccumuloConstants.DEFAULT_ACCUMULO_PORT_TRACER))); }
From source file:org.apache.whirr.service.mongodb.BaseMongoDBClusterActionHandler.java
@Override protected void beforeConfigure(ClusterActionEvent event) throws IOException, InterruptedException { LOG.info("Handling beforeConfigure event"); ClusterSpec clusterSpec = event.getClusterSpec(); Cluster cluster = event.getCluster(); Configuration config = getConfiguration(clusterSpec); if (configKeyPort != null) { this.port = config.getInt(configKeyPort, defaultPort); }//from ww w .j a va 2s . c o m LOG.info("Opening firewall port for MongoDB on '" + port + "'"); // TODO - For sharding, only open mongod ports internal to cluster? event.getFirewallManager().addRule(Rule.create().destination(cluster.getInstances()).ports(port)); addStatement(event, call("install_service")); addStatement(event, call("install_tarball")); if (this.tarUrl != null) { addStatement(event, call(getInstallFunction(config), role, MongoDBConstants.PARAM_PROVIDER, clusterSpec.getProvider(), MongoDBConstants.PARAM_TARBALL, prepareRemoteFileUrl(event, this.tarUrl))); } else { addStatement(event, call(getInstallFunction(config), role, MongoDBConstants.PARAM_PROVIDER, clusterSpec.getProvider())); addStatement(event, call(getStopFunction(config))); } String configFunction = getConfigureFunction(config); ArrayList<String> configArgs = new ArrayList<String>(); configArgs.add(role); configArgs.add(MongoDBConstants.PARAM_PROVIDER); configArgs.add(clusterSpec.getProvider()); configArgs.add(MongoDBConstants.PARAM_PORT); configArgs.add(String.valueOf(port)); if (this.noJournal != null) { configArgs.add(MongoDBConstants.PARAM_NOJOURNAL); } if (this.replicaSetName != null) { configArgs.add(MongoDBConstants.PARAM_REPLSETNAME); configArgs.add(this.replicaSetName.toString()); } if (this.authPassword != null && this.authUsername != null) { configArgs.add(MongoDBConstants.PARAM_PASSWORD); configArgs.add(this.authPassword); configArgs.add(MongoDBConstants.PARAM_USER); configArgs.add(this.authUsername); } if (this.bindIp != null) { configArgs.add(MongoDBConstants.PARAM_BINDIP); configArgs.add(this.bindIp); } if (this.noPreAlloc != null && this.noPreAlloc) { configArgs.add(MongoDBConstants.PARAM_NOPREALLOC); } if (this.smallFiles != null && this.smallFiles) { configArgs.add(MongoDBConstants.PARAM_SMALLFILES); } if (this.noTableScan != null && this.noTableScan) { configArgs.add(MongoDBConstants.PARAM_NOTABLESCAN); } if (this.rest != null && this.rest) { configArgs.add(MongoDBConstants.PARAM_REST); } if (this.noHttpInterface != null && this.noHttpInterface) { configArgs.add(MongoDBConstants.PARAM_NOHTTP); } if (this.noUnixSockets != null && this.noUnixSockets) { configArgs.add(MongoDBConstants.PARAM_NOUNIX); } if (this.objCheck != null && this.objCheck) { configArgs.add(MongoDBConstants.PARAM_OBJCHECK); } if (this.nsSize != null) { configArgs.add(MongoDBConstants.PARAM_NSSIZE); configArgs.add(this.nsSize.toString()); } if (this.slowMs != null) { configArgs.add(MongoDBConstants.PARAM_SLOWMS); configArgs.add(this.slowMs.toString()); } if (this.journalCommitInterval != null) { configArgs.add(MongoDBConstants.PARAM_JOURNALINTERVAL); configArgs.add(this.journalCommitInterval.toString()); } if (this.oplogSize != null) { configArgs.add(MongoDBConstants.PARAM_OPLOGSIZE); configArgs.add(this.oplogSize.toString()); } addStatement(event, call(configFunction, configArgs.toArray(new String[] {}))); LOG.info("Calling start function: " + getStartFunction(config)); addStatement(event, call(getStartFunction(config))); if (this.authPassword != null && this.authUsername != null) { addStatement(event, call(MongoDBConstants.FUNCTION_SETUPAUTH, this.authUsername, this.authPassword)); } }
From source file:org.apache.whirr.service.mongodb.MongoDBReplSetMemberClusterActionHandler.java
@Override protected void afterConfigure(ClusterActionEvent event) { ClusterSpec clusterSpec = event.getClusterSpec(); Cluster cluster = event.getCluster(); LOG.info("Configuring replica set members."); //Get all the instances that are marked as replica set members Set<String> replSetRoles = Sets.newHashSet(ROLE, MongoDBArbiterClusterActionHandler.ROLE); Set<Cluster.Instance> replSetInstances = cluster.getInstancesMatching(anyRoleIn(replSetRoles)); //Just grab the first of these instances, use it to send the rs.initiate() Cluster.Instance setLeader = replSetInstances.iterator().next(); try {// ww w . jav a 2 s.c o m Configuration config = getConfiguration(clusterSpec); this.arbiterPort = config.getInt(MongoDBArbiterClusterActionHandler.CFG_KEY_PORT, MongoDBArbiterClusterActionHandler.PORT); } catch (IOException e) { this.arbiterPort = MongoDBArbiterClusterActionHandler.PORT; } Mongo mongo; DB db; try { // throws IOExc, UnknownHostExc: LOG.info( "Connecting to " + setLeader.getPublicAddress().getHostAddress() + " to initiate replica set."); mongo = new Mongo(setLeader.getPublicAddress().getHostAddress(), PORT); db = mongo.getDB("admin"); if (this.authPassword != null && this.authUsername != null) { db.authenticate(this.authUsername, this.authPassword.toCharArray()); } } catch (Exception e) { LOG.error("Unable to get public host address of replica set leader, " + e.getMessage()); return; } try { BasicDBObject configObject = this.generateReplicaSetConfig(replSetInstances); // throws IOexc LOG.info("config object:" + configObject.toString()); BasicDBObject commandInfo = new BasicDBObject("replSetInitiate", configObject); LOG.info("Sending rs.initiate() command"); CommandResult initiateResult = db.command(commandInfo); LOG.info("Command Result: " + initiateResult.toString()); } catch (IOException e) { LOG.error("Unable to get private host addresses of replica set members, " + e.getMessage()); } finally { //TODO any cleanup? } }
From source file:org.apache.whirr.service.voldemort.VoldemortClusterActionHandler.java
@Override protected void beforeConfigure(ClusterActionEvent event) throws IOException, InterruptedException { Cluster cluster = event.getCluster(); LOG.info("Authorizing firewall"); event.getFirewallManager().addRule(Rule.create().destination(cluster.getInstancesMatching(role(ROLE))) .ports(CLIENT_PORT, ADMIN_PORT, HTTP_PORT)); String servers = Joiner.on(' ').join(getPrivateIps(cluster.getInstances())); Configuration config = event.getClusterSpec().getConfiguration(); int partitionsPerNode = config.getInt(PARAM_PARTITIONS_PER_NODE, 10); addStatement(event,/*from ww w . ja v a2 s. c om*/ call(FUNCTION_CONFIGURE, PARAM_PARTITIONS_PER_NODE, Integer.toString(partitionsPerNode), servers)); }
From source file:org.csource.fastdfs.ClientGlobal.java
/** * load global variables// w w w .j a v a 2 s. c o m * @param conf_filename config filename * @throws ConfigurationException */ public static void init(String conf_filename) throws FileNotFoundException, IOException, MyException, ConfigurationException { Configuration config; config = new PropertiesConfiguration(conf_filename); g_connect_timeout = config.getInt("connect_timeout", DEFAULT_CONNECT_TIMEOUT); if (g_connect_timeout < 0) { g_connect_timeout = DEFAULT_CONNECT_TIMEOUT; } g_connect_timeout *= 1000; //millisecond g_network_timeout = config.getInt("network_timeout", DEFAULT_NETWORK_TIMEOUT); if (g_network_timeout < 0) { g_network_timeout = DEFAULT_NETWORK_TIMEOUT; } g_network_timeout *= 1000; //millisecond g_charset = config.getString("charset"); if (g_charset == null || g_charset.length() == 0) { g_charset = "ISO8859-1"; } List<Object> trackerServers = config.getList("tracker_server"); InetSocketAddress[] tracker_servers = new InetSocketAddress[trackerServers.size()]; String[] parts; for (int i = 0; i < trackerServers.size(); i++) { parts = ((String) trackerServers.get(i)).split("\\:", 2); if (parts.length != 2) { throw new MyException( "the value of item \"tracker_server\" is invalid, the correct format is host:port"); } tracker_servers[i] = new InetSocketAddress(parts[0].trim(), Integer.parseInt(parts[1].trim())); } g_tracker_group = new TrackerGroup(tracker_servers); g_tracker_http_port = config.getInt("http.tracker_http_port", 80); g_anti_steal_token = config.getBoolean("http.anti_steal_token", false); if (g_anti_steal_token) { g_secret_key = config.getString("http.secret_key"); } if (trackerServers.size() == 0) { throw new MyException("item \"tracker_server\" in " + conf_filename + " not found"); } /* IniFileReader iniReader; String[] szTrackerServers; String[] parts; iniReader = new IniFileReader(conf_filename); g_connect_timeout = iniReader.getIntValue("connect_timeout", DEFAULT_CONNECT_TIMEOUT); if (g_connect_timeout < 0) { g_connect_timeout = DEFAULT_CONNECT_TIMEOUT; } g_connect_timeout *= 1000; //millisecond g_network_timeout = iniReader.getIntValue("network_timeout", DEFAULT_NETWORK_TIMEOUT); if (g_network_timeout < 0) { g_network_timeout = DEFAULT_NETWORK_TIMEOUT; } g_network_timeout *= 1000; //millisecond g_charset = iniReader.getStrValue("charset"); if (g_charset == null || g_charset.length() == 0) { g_charset = "ISO8859-1"; } szTrackerServers = iniReader.getValues("tracker_server"); if (szTrackerServers == null) { throw new MyException("item \"tracker_server\" in " + conf_filename + " not found"); } InetSocketAddress[] tracker_servers = new InetSocketAddress[szTrackerServers.length]; for (int i=0; i<szTrackerServers.length; i++) { parts = szTrackerServers[i].split("\\:", 2); if (parts.length != 2) { throw new MyException("the value of item \"tracker_server\" is invalid, the correct format is host:port"); } tracker_servers[i] = new InetSocketAddress(parts[0].trim(), Integer.parseInt(parts[1].trim())); } g_tracker_group = new TrackerGroup(tracker_servers); g_tracker_http_port = iniReader.getIntValue("http.tracker_http_port", 80); g_anti_steal_token = iniReader.getBoolValue("http.anti_steal_token", false); if (g_anti_steal_token) { g_secret_key = iniReader.getStrValue("http.secret_key"); }*/ }
From source file:org.j2free.cache.impl.memory.MemoryFragmentCache.java
/** * * @param config/*w w w . ja v a 2 s . c om*/ */ public MemoryFragmentCache(Configuration config) { this(config.getInt(PROP_SIZE, DEFAULT_SIZE), config.getFloat(PROP_LOAD_FACTOR, DEFAULT_LOAD_FACTOR), config.getInt(PROP_CONCURRENCY, DEFAULT_CONCURRENCY)); scheduleCleaner(config.getInt(PROP_CLEAN_INTERVAL), TimeUnit.SECONDS, false); }
From source file:org.j2free.invoker.InvokerFilter.java
/** * Configures the InvokerFilter, locking to prevent request processing * while configuration is set.// ww w . jav a 2 s .c o m */ private void configure(Configuration config) { try { write.lock(); // In case the user has let us know about paths that are guaranteed static bypassPath = config.getString(Property.BYPASS_PATH, EMPTY); // Can enable benchmarking globally benchmark = config.getBoolean(Property.BENCHMARK_REQS, false); // Set the SSL redirect port int val = config.getInt(Constants.PROP_LOCALPORT_SSL, -1); if (val > 0) sslRedirectPort = val; // Set the SSL redirect port val = config.getInt(Constants.PROP_LOCALPORT, -1); if (val > 0) nonSslRedirectPort = val; // Set the reload threshold for servlets maxServletUses = config.getInt(Property.MAX_SERVLET_USES, 1000); // The default SSL option String defSSLStr = config.getString(Property.DEFAULT_SSL_OPT, null); if (defSSLStr != null) { try { defaultSSLOption = SSLOption.valueOf(defSSLStr); } catch (Exception e) { log.error("Error setting default SSLOption for value: " + defSSLStr); } } } finally { write.unlock(); // ALWAYS unlock } }