public static void initialize(ThunderProperties properties) {
RedisClusterFactory.properties = properties;
String clusterValue = null;
try {
clusterValue = properties.getString(ThunderConstant.REDIS_CLUSTER_ATTRIBUTE_NAME);
} catch (Exception e) {
LOG.warn("Redis cluster address is null, redis won't start");
return;
}
if (StringUtils.isEmpty(clusterValue)) {
LOG.warn("Redis cluster address is null, redis won't start");
return;
}
try {
HashSet<HostAndPort> clusterSet = new HashSet<HostAndPort>();
String[] clusterArray = StringUtils.split(clusterValue, ";");
for (String cluster : clusterArray) {
String[] info = StringUtils.split(cluster, ":");
clusterSet.add(new HostAndPort(info[0].trim(), Integer.valueOf(info[1].trim())));
}
cluster = new JedisCluster(clusterSet,
properties.getInteger(ThunderConstant.REDIS_CONNECTION_TIMEOUT_ATTRIBUTE_NAME),
properties.getInteger(ThunderConstant.REDIS_SO_TIMEOUT_ATTRIBUTE_NAME),
properties.getInteger(ThunderConstant.REDIS_MAX_REDIRECTIONS_ATTRIBUTE_NAME),
ObjectPoolFactory.createRedisObjectPoolConfig());
LOG.info("Redis cluster is initialized...");
} catch (Exception e) {
LOG.error("Redis cluster is initialized failed", e);
}
}