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


Java Protocol.DEFAULT_TIMEOUT属性代码示例

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


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

示例1: JaRedisPool

public JaRedisPool(final String host) {
    URI uri = URI.create(host);
    if (JedisURIHelper.isValid(uri)) {
        String h = uri.getHost();
        int port = uri.getPort();
        String password = JedisURIHelper.getPassword(uri);
        int database = JedisURIHelper.getDBIndex(uri);
        this.internalPool = new GenericObjectPool<>(new JaRedisFactory(h, port,
                Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, password, database, null),
                new GenericObjectPoolConfig());
    } else {
        this.internalPool = new GenericObjectPool<>(new JaRedisFactory(host,
                Protocol.DEFAULT_PORT, Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, null,
                Protocol.DEFAULT_DATABASE, null), new GenericObjectPoolConfig());
    }
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:16,代码来源:JaRedisPool.java

示例2: createJedisPool

private void createJedisPool() {

        JedisPoolConfig config = new JedisPoolConfig();

        // 设置最大连接数
        config.setMaxTotal(500);

        // 设置最大阻塞时间(毫秒)
        config.setMaxWaitMillis(1000);

        // 设置空闲连接数
        config.setMaxIdle(20);
        config.setMinIdle(10);

        // 创建连接池
        pool = new JedisPool(config, appConfig.get(CONFIG_KEY_REDIS_HOST, DEFAULT_REDIS_HOST), appConfig.getInt(CONFIG_KEY_REDIS_PORT, DEFAULT_REDIS_PORT), Protocol.DEFAULT_TIMEOUT, appConfig.get(CONFIG_KEY_REDIS_PASS, ""));
    }
 
开发者ID:thundernet8,项目名称:Elune,代码行数:17,代码来源:RedisManager.java

示例3: setUpRedis

@Before
public void setUpRedis() throws IOException, SchedulerConfigException {
    port = getPort();
    logger.debug("Attempting to start embedded Redis server on port " + port);
    redisServer = RedisServer.builder()
            .port(port)
            .build();
    redisServer.start();
    final short database = 1;
    JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
    jedisPoolConfig.setTestOnBorrow(true);
    jedisPool = new JedisPool(jedisPoolConfig, host, port, Protocol.DEFAULT_TIMEOUT, null, database);

    jobStore = new RedisJobStore();
    jobStore.setHost(host);
    jobStore.setLockTimeout(2000);
    jobStore.setPort(port);
    jobStore.setInstanceId("testJobStore1");
    jobStore.setDatabase(database);
    mockScheduleSignaler = mock(SchedulerSignaler.class);
    jobStore.initialize(null, mockScheduleSignaler);
    schema = new RedisJobStoreSchema();

    jedis = jedisPool.getResource();
    jedis.flushDB();
}
 
开发者ID:jlinn,项目名称:quartz-redis-jobstore,代码行数:26,代码来源:BaseTest.java

示例4: initialize

@Override
public void initialize(ClassLoadHelper loadHelper,
		SchedulerSignaler signaler) throws SchedulerConfigException {
	
	this.loadHelper = loadHelper;
	this.signaler = signaler;		
   
   	// initializing a connection pool
   	JedisPoolConfig config = new JedisPoolConfig();
   	if (password != null)
   		pool = new JedisPool(config, host, port, Protocol.DEFAULT_TIMEOUT, password);	    		
   	else
   		pool = new JedisPool(config, host, port, Protocol.DEFAULT_TIMEOUT);
   	
   	// initializing a locking connection pool with a longer timeout
   	if (lockTimeout == 0)
   		lockTimeout = 10 * 60 * 1000; // 10 Minutes locking timeout
   	
     lockPool = new JedisLock(pool.getResource(), "JobLock", lockTimeout);

}
 
开发者ID:RedisLabs,项目名称:redis-quartz,代码行数:21,代码来源:RedisJobStore.java

示例5: newJedisPool

/**
 * Creates a new {@link JedisPool}.
 * 
 * @param hostAndPort
 * @param password
 * @param db
 * @param timeoutMs
 * @return
 * @since 0.5.0
 */
public static JedisPool newJedisPool(String hostAndPort, String password, int db,
        long timeoutMs) {
    final int maxTotal = Runtime.getRuntime().availableProcessors();
    final int maxIdle = maxTotal / 2;

    JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxTotal(maxTotal);
    poolConfig.setMinIdle(1);
    poolConfig.setMaxIdle(maxIdle > 0 ? maxIdle : 1);
    poolConfig.setMaxWaitMillis(timeoutMs);
    // poolConfig.setTestOnBorrow(true);
    poolConfig.setTestWhileIdle(true);

    String[] tokens = hostAndPort.split(":");
    String host = tokens.length > 0 ? tokens[0] : Protocol.DEFAULT_HOST;
    int port = tokens.length > 1 ? Integer.parseInt(tokens[1]) : Protocol.DEFAULT_PORT;
    JedisPool jedisPool = new JedisPool(poolConfig, host, port, Protocol.DEFAULT_TIMEOUT,
            password, db);
    return jedisPool;
}
 
开发者ID:DDTH,项目名称:ddth-id,代码行数:30,代码来源:RedisIdGenerator.java

示例6: buildRateLimiter

private RateLimiter buildRateLimiter(double permitsPerSecond) {
    JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
    jedisPoolConfig.setMaxTotal(30);
    JedisPool jedisPool = new JedisPool(jedisPoolConfig, "localhost", 6379, Protocol.DEFAULT_TIMEOUT);

    RDBI rdbi = new RDBI(jedisPool);

    // Verify our loading of the LUA script upon initial start.
    rdbi.withHandle(new Callback<Void>() {
        @Override
        public Void run(Handle handle) {
            handle.jedis().scriptFlush();
            return null;
        }
    });

    return new StrictRateLimiter("d:test:rdbi", rdbi, UUID.randomUUID().toString(), permitsPerSecond);
}
 
开发者ID:lithiumtech,项目名称:rdbi,代码行数:18,代码来源:StrictRateLimiterTest.java

示例7: getRdbi

private RDBI getRdbi() {
    JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
    jedisPoolConfig.setMaxTotal(30);
    JedisPool jedisPool = new JedisPool(jedisPoolConfig, "localhost", 6379, Protocol.DEFAULT_TIMEOUT);

    RDBI rdbi = new RDBI(jedisPool);

    // Verify our loading of the LUA script upon initial start.
    rdbi.withHandle(new Callback<Void>() {
        @Override
        public Void run(Handle handle) {
            handle.jedis().scriptFlush();
            return null;
        }
    });
    return rdbi;
}
 
开发者ID:lithiumtech,项目名称:rdbi,代码行数:17,代码来源:TokenBucketRateLimiterTest.java

示例8: RedisPool

public RedisPool(final String host) {
    URI uri = URI.create(host);
    if (uri.getScheme() != null && uri.getScheme().equals("redis")) {
        String h = uri.getHost();
        int port = uri.getPort();
        String password = JedisURIHelper.getPassword(uri);
        int database = 0;
        Integer dbIndex = JedisURIHelper.getDBIndex(uri);
        if (dbIndex != null) {
            database = dbIndex.intValue();
        }
        this.internalPool = new GenericObjectPool<BinaryJedis>(
                new BinaryJedisFactory(h, port, Protocol.DEFAULT_TIMEOUT,
                        password, database, null),
                new GenericObjectPoolConfig());
    } else {
        this.internalPool = new GenericObjectPool<BinaryJedis>(new BinaryJedisFactory(
                host, Protocol.DEFAULT_PORT, Protocol.DEFAULT_TIMEOUT,
                null, Protocol.DEFAULT_DATABASE, null),
                new GenericObjectPoolConfig());
    }
}
 
开发者ID:yamingd,项目名称:argo,代码行数:22,代码来源:RedisPool.java

示例9: initialize

/**
 * method to initialize the data-cache
 * 
 * @param properties
 * @param filePath
 */
@SuppressWarnings("unchecked")
private void initialize(Properties properties, String filePath) {
	if (dataCache != null) {
		return;
	}
	properties = (properties == null) ? loadProperties(filePath) : properties;

	boolean clusterEnabled = Boolean.valueOf(properties.getProperty(RedisConstants.CLUSTER_ENABLED, RedisConstants.DEFAULT_CLUSTER_ENABLED));

	String hosts = properties.getProperty(RedisConstants.HOSTS, Protocol.DEFAULT_HOST.concat(":").concat(String.valueOf(Protocol.DEFAULT_PORT)));
	Collection<? extends Serializable> nodes = getJedisNodes(hosts, clusterEnabled);

	String password = properties.getProperty(RedisConstants.PASSWORD);
	password = StringUtils.isNotBlank(password) ? password : null;

	int database = Integer.parseInt(properties.getProperty(RedisConstants.DATABASE, String.valueOf(Protocol.DEFAULT_DATABASE)));

	int timeout = Integer.parseInt(properties.getProperty(RedisConstants.TIMEOUT, String.valueOf(Protocol.DEFAULT_TIMEOUT)));
	timeout = (timeout < Protocol.DEFAULT_TIMEOUT) ? Protocol.DEFAULT_TIMEOUT : timeout;

	if (clusterEnabled) {
		dataCache = new RedisClusterCacheUtil((Set<HostAndPort>) nodes, timeout, getPoolConfig(properties));
	} else {
		dataCache = new RedisCacheUtil(((List<String>) nodes).get(0),
				Integer.parseInt(((List<String>) nodes).get(1)), password, database, timeout, getPoolConfig(properties));
	}

	boolean guiEnabled = Boolean.valueOf(properties.getProperty(TaskSchedulerConstants.IS_GUI_ENABLED, RedisConstants.DEFAULT_CLUSTER_ENABLED));
	if (guiEnabled) {
		int port = Integer.parseInt(properties.getProperty(TaskSchedulerConstants.GUI_PORT,
				String.valueOf(TaskSchedulerConstants.DEFAULT_SCHEDULER_GUI_PORT)));
		new TaskTrackerHandler().startServer(port);
	}
}
 
开发者ID:ran-jit,项目名称:distributed-task-scheduler,代码行数:40,代码来源:RedisDataCache.java

示例10: RedisUtil

public RedisUtil(String host, int port, String password, int database) {
    // Jedis连接池
    JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
    jedisPoolConfig.setMaxTotal(64);
    this.jedisPool = new JedisPool(jedisPoolConfig, host, port, Protocol.DEFAULT_TIMEOUT, "".equals(password) ? null : password, database);
    // 支持集群

}
 
开发者ID:ogcs,项目名称:Okra-Ax,代码行数:8,代码来源:RedisUtil.java

示例11: connectDb

/**
 * This method is used to connect this class with the Redis database. 
 *     This information is used only for log purposes. 
 * @return True if the connection has been established with the Redis 
 *     database, false if not. The data description about the connection problem
 *     should be storage inside input Exception object.
 * @since v0.3.1
 */
private boolean connectDb(){
    pool = new JedisPool(new GenericObjectPoolConfig(), 
            serverIp.getHostAddress(), 
            port, 
            Protocol.DEFAULT_TIMEOUT, 
            password);
    // Redis connected.
    dataBaseObj = pool.getResource();
    monitorDbObj = pool.getResource();
    return true;
}
 
开发者ID:mami-project,项目名称:KeyServer,代码行数:19,代码来源:DataBase.java

示例12: DataBaseTest

/**
 * Test class constructor.
 * @author <a href="mailto:[email protected]">Javier Martinez Gusano</a>
 * @since v0.4.3
 */
public DataBaseTest(){
    try {
        dbAddress = InetAddress.getLocalHost();
    } catch (UnknownHostException ex) {
        System.out.println("[ ERROR ] Can't load 'localhost' address.");
        Logger.getLogger(DataBaseTest.class.getName()).log(Level.SEVERE, null, ex);
    }
    dbPort = 6379;
    dbPassword = "foobared";
    dbIndex = 0;
    // Connection DB test.
    JedisPool pool = new JedisPool(new GenericObjectPoolConfig(), 
            this.dbAddress.getHostAddress(), 
            this.dbPort, 
            Protocol.DEFAULT_TIMEOUT, 
            this.dbPassword);
    try{
        // Redis connected.
        dataBaseObj = pool.getResource();
        dataBaseObj.ping();
        dataBaseObj.close();
        this.dbAvailable = true;
    } catch (Exception e){
        this.dbAvailable = false;
        System.out.println("[ WARNING ] Redis Server is not available. JUnit tests will be skipped.");
    }
    
}
 
开发者ID:mami-project,项目名称:KeyServer,代码行数:33,代码来源:DataBaseTest.java

示例13: activateService

@Override
public void activateService()
    throws Exception
{
    configuration.refresh();
    RedisEntityStoreConfiguration config = configuration.get();

    String host = config.host().get() == null ? DEFAULT_HOST : config.host().get();
    int port = config.port().get() == null ? Protocol.DEFAULT_PORT : config.port().get();
    int timeout = config.timeout().get() == null ? Protocol.DEFAULT_TIMEOUT : config.timeout().get();
    String password = config.password().get();
    int database = config.database().get() == null ? Protocol.DEFAULT_DATABASE : config.database().get();

    pool = new JedisPool( new JedisPoolConfig(), host, port, timeout, password, database );
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:15,代码来源:RedisEntityStoreMixin.java

示例14: setUpAll

@BeforeClass
public static void setUpAll() {
    final JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxTotal(1);

    pool = new JedisPool(
        poolConfig,
        System.getProperty("hp.hod.redisHost", "localhost"),
        Integer.parseInt(System.getProperty("hp.hod.redisPort", "6379")),
        Protocol.DEFAULT_TIMEOUT,
        null,
        Integer.parseInt(System.getProperty("hp.hod.redisDb", "0"))
    );
}
 
开发者ID:hpe-idol,项目名称:redis-hod-token-repository,代码行数:14,代码来源:RedisTokenRepositoryITCase.java

示例15: JedisManager

private JedisManager() {
	String host = System.getenv("REDIS_HOST");
	String port = System.getenv("REDIS_PORT");

	factory = new JedisFactory(host == null ? "" : host, port == null ? 6379 : Integer.valueOf(port),
			Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, null, Protocol.DEFAULT_DATABASE, null);
}
 
开发者ID:eleme,项目名称:hackathon-2015,代码行数:7,代码来源:JedisManager.java


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