当前位置: 首页>>代码示例>>Java>>正文


Java AbstractConfiguration.getInt方法代码示例

本文整理汇总了Java中org.apache.commons.configuration.AbstractConfiguration.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractConfiguration.getInt方法的具体用法?Java AbstractConfiguration.getInt怎么用?Java AbstractConfiguration.getInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.configuration.AbstractConfiguration的用法示例。


在下文中一共展示了AbstractConfiguration.getInt方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("master_slave")) {
        throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with master slave redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
    this.lettuceMasterSlave = RedisClient.create(lettuceURI);
    this.lettuceMasterSlaveConn = MasterSlave.connect(this.lettuceMasterSlave, new Utf8StringCodec(), lettuceURI);
    this.lettuceMasterSlaveConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));

    // params
    initParams(config);
}
 
开发者ID:longkerdandy,项目名称:mithqtt,代码行数:20,代码来源:RedisSyncMasterSlaveStorageImpl.java

示例2: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("single")) {
        throw new IllegalStateException("RedisSyncSingleStorage class can only be used with single redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
    this.lettuce = RedisClient.create(lettuceURI);
    this.lettuceConn = this.lettuce.connect();

    // redisson
    Config redissonConfig = new Config();
    redissonConfig.useSingleServer()
            .setAddress(address.get(0))
            .setDatabase(databaseNumber)
            .setPassword(StringUtils.isNotEmpty(password) ? password : null);
    this.redisson = Redisson.create(redissonConfig);

    // params
    initParams(config);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:27,代码来源:RedisSyncSingleStorage.java

示例3: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("single")) {
        throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with single redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
    this.lettuce = RedisClient.create(lettuceURI);
    this.lettuceConn = this.lettuce.connect();

    // params
    initParams(config);
}
 
开发者ID:longkerdandy,项目名称:mithqtt,代码行数:19,代码来源:RedisSyncSingleStorageImpl.java

示例4: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("sentinel")) {
        throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with sentinel redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 26379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";
    String masterId = config.getString("redis.master");

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis-sentinel://" + password + String.join(",", address) + "/" + databaseNumber + "#" + masterId);
    this.lettuceSentinel = RedisClient.create(lettuceURI);
    this.lettuceSentinelConn = MasterSlave.connect(this.lettuceSentinel, new Utf8StringCodec(), lettuceURI);
    this.lettuceSentinelConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));

    // params
    initParams(config);
}
 
开发者ID:longkerdandy,项目名称:mithqtt,代码行数:21,代码来源:RedisSyncSentinelStorageImpl.java

示例5: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("master_slave")) {
        throw new IllegalStateException("RedisSyncSingleStorage class can only be used with master slave redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
    this.lettuceMasterSlave = RedisClient.create(lettuceURI);
    this.lettuceMasterSlaveConn = MasterSlave.connect(this.lettuceMasterSlave, new Utf8StringCodec(), lettuceURI);
    this.lettuceMasterSlaveConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));

    // redisson
    String masterNode = address.get(0);
    String[] slaveNodes = address.subList(1, address.size()).toArray(new String[address.size() - 1]);
    Config redissonConfig = new Config();
    redissonConfig.useMasterSlaveServers()
            .setMasterAddress(masterNode)
            .setLoadBalancer(new RoundRobinLoadBalancer())
            .addSlaveAddress(slaveNodes)
            .setReadMode(ReadMode.MASTER)
            .setDatabase(databaseNumber)
            .setPassword(StringUtils.isNotEmpty(password) ? password : null);
    this.redisson = Redisson.create(redissonConfig);

    // params
    initParams(config);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:33,代码来源:RedisSyncMasterSlaveStorage.java

示例6: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("cluster")) {
        throw new IllegalStateException("RedisSyncSingleStorage class can only be used with cluster redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
    this.lettuceCluster = RedisClusterClient.create(lettuceURI);
    this.lettuceCluster.setOptions(new ClusterClientOptions.Builder()
            .refreshClusterView(true)
            .refreshPeriod(1, TimeUnit.MINUTES)
            .build());
    this.lettuceClusterConn = this.lettuceCluster.connect();
    this.lettuceClusterConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));

    // redisson
    Config redissonConfig = new Config();
    redissonConfig.useClusterServers()
            .setScanInterval(60000)
            .addNodeAddress(address.toArray(new String[address.size()]))
            .setReadMode(ReadMode.MASTER)
            .setPassword(StringUtils.isNotEmpty(password) ? password : null);
    this.redisson = Redisson.create(redissonConfig);

    // params
    initParams(config);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:33,代码来源:RedisSyncClusterStorage.java

示例7: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("sentinel")) {
        throw new IllegalStateException("RedisSyncSingleStorage class can only be used with sentinel redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 26379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";
    String masterId = config.getString("redis.master");

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis-sentinel://" + password + String.join(",", address) + "/" + databaseNumber + "#" + masterId);
    this.lettuceSentinel = RedisClient.create(lettuceURI);
    this.lettuceSentinelConn = MasterSlave.connect(this.lettuceSentinel, new Utf8StringCodec(), lettuceURI);
    this.lettuceSentinelConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));

    // redisson
    Config redissonConfig = new Config();
    redissonConfig.useSentinelServers()
            .setMasterName(masterId)
            .addSentinelAddress(address.toArray(new String[address.size()]))
            .setReadMode(ReadMode.MASTER)
            .setDatabase(databaseNumber)
            .setPassword(StringUtils.isNotEmpty(password) ? password : null);
    this.redisson = Redisson.create(redissonConfig);

    // params
    initParams(config);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:31,代码来源:RedisSyncSentinelStorage.java

示例8: getConfiguration

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
protected AbstractConfiguration getConfiguration() {

  AbstractConfiguration config = ConfigurationManager.getConfigInstance();
  boolean dynamic = config.getBoolean(DYNAMIC_CONFIG, true);
  if (!dynamic) {
    return new DynamicConfiguration();
  } else {
    String appId = null;
    DeploymentContext context = ConfigurationManager.getDeploymentContext();
    appId = context.getApplicationId();
    
    if (appId == null) {
      throw new RuntimeException(
          "Archaius deployment context's applicationId not set (archaius.deployment.applicationId)");
    }

    String consulHost = config.getString(CONSUL_HOST, CONSUL_DEFAULT_HOST);
    int consulPort = config.getInt(CONSUL_PORT, 8500);
    String consulAclToken = config.getString(CONSUL_TOKEN);

    ConsulWatchedConfigurationSource configSource = new ConsulWatchedConfigurationSource(appId,
        new ConsulClient(consulHost, consulPort), 30, TimeUnit.SECONDS, consulAclToken);

    // do the first update synchronously
    try {
      configSource.runOnce();
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }

    configSource.startAsync();

    return new DynamicWatchedConfiguration(configSource);
  }
}
 
开发者ID:irenical,项目名称:jindy,代码行数:37,代码来源:ArchaiusConsulFactory.java

示例9: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("cluster")) {
        throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with cluster redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
    this.lettuceCluster = RedisClusterClient.create(lettuceURI);
    this.lettuceCluster.setOptions(ClusterClientOptions.builder()
            .topologyRefreshOptions(ClusterTopologyRefreshOptions.builder()
                    .enablePeriodicRefresh(config.getBoolean("redis.cluster.periodicRefreshEnabled", ClusterTopologyRefreshOptions.DEFAULT_PERIODIC_REFRESH_ENABLED))
                    .refreshPeriod(config.getLong("redis.cluster.refreshPeriod", ClusterTopologyRefreshOptions.DEFAULT_REFRESH_PERIOD), TimeUnit.SECONDS)
                    .closeStaleConnections(config.getBoolean("redis.cluster.closeStaleConnections", ClusterTopologyRefreshOptions.DEFAULT_CLOSE_STALE_CONNECTIONS))
                    .build())
            .validateClusterNodeMembership(config.getBoolean("redis.cluster.validateClusterNodeMembership", ClusterClientOptions.DEFAULT_VALIDATE_CLUSTER_MEMBERSHIP))
            .maxRedirects(config.getInt("redis.cluster.refreshPeriod", ClusterClientOptions.DEFAULT_MAX_REDIRECTS))
            .build());
    this.lettuceClusterConn = this.lettuceCluster.connect();
    this.lettuceClusterConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));

    // params
    initParams(config);
}
 
开发者ID:longkerdandy,项目名称:mithqtt,代码行数:29,代码来源:RedisSyncClusterStorageImpl.java

示例10: initParams

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
/**
 * Initialize MQTT parameters
 *
 * @param config Redis Configuration
 */
protected void initParams(AbstractConfiguration config) {
    this.inFlightQueueSize = config.getInt("mqtt.inflight.queue.size", 0);
    this.qos2QueueSize = config.getInt("mqtt.qos2.queue.size", 0);
    this.retainQueueSize = config.getInt("mqtt.retain.queue.size", 0);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:11,代码来源:RedisSyncSingleStorage.java

示例11: initParams

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
/**
 * Initialize MQTT parameters
 *
 * @param config Redis Configuration
 */
void initParams(AbstractConfiguration config) {
    this.inFlightQueueSize = config.getInt("mqtt.inflight.queue.size", 0);
    this.qos2QueueSize = config.getInt("mqtt.qos2.queue.size", 0);
    this.retainQueueSize = config.getInt("mqtt.retain.queue.size", 0);
}
 
开发者ID:longkerdandy,项目名称:mithqtt,代码行数:11,代码来源:RedisSyncSingleStorageImpl.java


注:本文中的org.apache.commons.configuration.AbstractConfiguration.getInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。