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


Java Protocol.DEFAULT_PORT属性代码示例

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


在下文中一共展示了Protocol.DEFAULT_PORT属性的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: createPool

private static JedisPool createPool(GenericObjectPoolConfig redisPoolConfig,
                                    String connection,
                                    int timeout) {
  URI redisConnection = URI.create(connection);

  String host = redisConnection.getHost();
  int port = redisConnection.getPort() == -1 ? Protocol.DEFAULT_PORT : redisConnection.getPort();

  String path = redisConnection.getPath();
  if (StringUtils.isEmpty(path)) {
    path = "/" + String.valueOf(Protocol.DEFAULT_DATABASE);
  }
  int database = Integer.parseInt(path.split("/", 2)[1]);

  String password = null;
  if (redisConnection.getUserInfo() != null) {
    password = redisConnection.getUserInfo().split(":", 2)[1];
  }

  if (redisPoolConfig == null) {
    redisPoolConfig = new GenericObjectPoolConfig();
  }

  return new JedisPool(redisPoolConfig, host, port, timeout, password, database, null);
}
 
开发者ID:spinnaker,项目名称:fiat,代码行数:25,代码来源:RedisConfig.java

示例3: newJedisPool

/**
 * Creates a new {@link JedisPool}.
 * 
 * @param hostAndPort
 * @param password
 * @param db
 * @param timeoutMs
 * @return
 */
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 + 1000);
    // 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, (int) timeoutMs, password, db);
    return jedisPool;
}
 
开发者ID:DDTH,项目名称:ddth-cache-adapter,代码行数:28,代码来源:RedisCacheFactory.java

示例4: 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

示例5: init

public void init() throws DBException {
    Properties props = getProperties();
    int port;

    String portString = props.getProperty(PORT_PROPERTY);
    if (portString != null) {
        port = Integer.parseInt(portString);
    }
    else {
        port = Protocol.DEFAULT_PORT;
    }
    String host = props.getProperty(HOST_PROPERTY);

    jedis = new Jedis(host, port);
    jedis.connect();

    String password = props.getProperty(PASSWORD_PROPERTY);
    if (password != null) {
        jedis.auth(password);
    }
}
 
开发者ID:pbailis,项目名称:hat-vldb2014-code,代码行数:21,代码来源:RedisClient.java

示例6: create

@Override
public GelfSender create(GelfSenderConfiguration configuration) throws IOException {

    String graylogHost = configuration.getHost();

    URI hostUri = URI.create(graylogHost);
    int port = hostUri.getPort();
    if (port <= 0) {
        port = configuration.getPort();
    }

    if (port <= 0) {
        port = Protocol.DEFAULT_PORT;
    }

    if (hostUri.getFragment() == null || hostUri.getFragment().trim().equals("")) {
        throw new IllegalArgumentException("Redis URI must specify fragment");
    }

    if (hostUri.getHost() == null) {
        throw new IllegalArgumentException("Redis URI must specify host");
    }

    Pool<Jedis> pool = RedisSenderPoolProvider.getJedisPool(hostUri, port);
    return new GelfREDISSender(pool, hostUri.getFragment(), configuration.getErrorReporter());
}
 
开发者ID:mp911de,项目名称:logstash-gelf,代码行数:26,代码来源:RedisGelfSenderProvider.java

示例7: newShardedJedisPool

/**
 * Create a new {@link ShardedJedisPool}.
 * 
 * @param poolConfig
 *            format {@code host1:port1,host2:port2,...}, default Redis port is used if not
 *            specified
 * @param password
 * @param timeoutMs
 * @return
 */
public static ShardedJedisPool newShardedJedisPool(JedisPoolConfig poolConfig,
        String hostsAndPorts, String password, int timeoutMs) {
    List<JedisShardInfo> shards = new ArrayList<>();
    String[] hapList = hostsAndPorts.split("[,;\\s]+");
    for (String hostAndPort : hapList) {
        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;
        JedisShardInfo shardInfo = new JedisShardInfo(host, port, timeoutMs);
        shardInfo.setPassword(password);
        shards.add(shardInfo);
    }
    ShardedJedisPool jedisPool = new ShardedJedisPool(poolConfig, shards);
    return jedisPool;
}
 
开发者ID:DDTH,项目名称:ddth-commons,代码行数:25,代码来源:JedisUtils.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: connectWithShardInfo

@Test
public void connectWithShardInfo() {
  JedisShardInfo shardInfo = new JedisShardInfo("localhost", Protocol.DEFAULT_PORT);
  shardInfo.setPassword("foobared");
  Jedis jedis = new Jedis(shardInfo);
  jedis.get("foo");
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:7,代码来源:JedisTest.java

示例10: 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

示例11: setupPool

@BeforeClass
public static void setupPool() {
    POOL = new JedisPool(new GenericObjectPoolConfig(), 
            Protocol.DEFAULT_HOST, 
            Protocol.DEFAULT_PORT, 
            Protocol.DEFAULT_TIMEOUT, 
            null, 
            5);
}
 
开发者ID:andrepnh,项目名称:jedis-utils,代码行数:9,代码来源:CommandBlockTest.java

示例12: buildHostAndPort

@Nonnull
public static HostAndPort buildHostAndPort(@Nonnull String host) {
	checkNotNull(host);
	int index = host.indexOf(":");
	return index == -1 ? new HostAndPort(host, Protocol.DEFAULT_PORT) :
			new HostAndPort(host.substring(0, index), Integer.parseInt(host.substring(index + 1)));
}
 
开发者ID:lithiumtech,项目名称:flow,代码行数:7,代码来源:JedisUtils.java

示例13: createPool

private static void createPool(String prop, String charset){
	if(pool == null){
		LOG.debug("Jedis pool is not exist, lock and create pool.");
		
		lock.lock();
		
		if(pool!=null){
			lock.unlock();
		}
		
		try {
			
			Map<String, String> conf = PropertiesUtil.read(prop, charset);
			String host = conf.get("redis.server");
			String confPort = conf.get("redis.server.port");
			
			int port = (confPort==null || "".equals(confPort))?Protocol.DEFAULT_PORT:Integer.valueOf(confPort);
			
			JedisPoolConfig config  =new JedisPoolConfig();
			//TODO config by properties
			pool = new JedisPool(config, host, port);
			
		} catch (IOException e) {
			LOG.error("Error occurred when create jedis pool.", e);
		}finally{
			lock.unlock();
		}
	}
	
}
 
开发者ID:yysoft,项目名称:yy-utils,代码行数:30,代码来源:JedisUtil.java

示例14: newJedisCluster

/**
 * Creates a new {@link JedisCluster}.
 * 
 * @param hostsAndPorts
 *            format {@code host1:port1,host2:port2...}
 * @param password
 * @param timeoutMs
 * @return
 */
public static JedisCluster newJedisCluster(String hostsAndPorts, String password,
        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 + 1000);
    // poolConfig.setTestOnBorrow(true);
    poolConfig.setTestWhileIdle(true);

    Set<HostAndPort> clusterNodes = new HashSet<>();
    String[] hapList = hostsAndPorts.split("[,;\\s]+");
    for (String hostAndPort : hapList) {
        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;
        clusterNodes.add(new HostAndPort(host, port));
    }

    JedisCluster jedisCluster = new JedisCluster(clusterNodes, (int) timeoutMs, (int) timeoutMs,
            DEFAULT_MAX_ATTEMPTS, password, poolConfig);
    return jedisCluster;
}
 
开发者ID:DDTH,项目名称:ddth-cache-adapter,代码行数:35,代码来源:ClusteredRedisCacheFactory.java

示例15: newJedisPool

/**
 * Creates a new {@link ShardedJedisPool}.
 * 
 * @param hostsAndPorts
 *            format {@code host1:port1,host2:port2...}
 * @param password
 * @param timeoutMs
 * @return
 */
public static ShardedJedisPool newJedisPool(String hostsAndPorts, String password,
        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 + 1000);
    // poolConfig.setTestOnBorrow(true);
    poolConfig.setTestWhileIdle(true);

    List<JedisShardInfo> shards = new ArrayList<>();
    String[] hapList = hostsAndPorts.split("[,;\\s]+");
    for (String hostAndPort : hapList) {
        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;
        JedisShardInfo shardInfo = new JedisShardInfo(host, port, (int) timeoutMs);
        shardInfo.setPassword(password);
        shards.add(shardInfo);
    }
    ShardedJedisPool jedisPool = new ShardedJedisPool(poolConfig, shards);
    return jedisPool;
}
 
开发者ID:DDTH,项目名称:ddth-cache-adapter,代码行数:35,代码来源:ShardedRedisCacheFactory.java


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