use of com.sohu.cache.entity.InstanceConfig in project cachecloud by sohutv.
the class RedisConfigTemplateServiceImpl method handleClusterConfig.
@Override
public List<String> handleClusterConfig(int port) {
List<InstanceConfig> instanceConfigList = getByType(ConstUtils.CACHE_TYPE_REDIS_CLUSTER);
if (CollectionUtils.isEmpty(instanceConfigList)) {
return Collections.emptyList();
}
List<String> configs = new ArrayList<String>();
for (InstanceConfig instanceConfig : instanceConfigList) {
if (!instanceConfig.isEffective()) {
continue;
}
String configKey = instanceConfig.getConfigKey();
String configValue = instanceConfig.getConfigValue();
if (StringUtils.isBlank(configValue)) {
configValue = SPECIAL_EMPTY_STR;
}
if (RedisClusterConfigEnum.CLUSTER_CONFIG_FILE.getKey().equals(configKey)) {
configValue = String.format(configValue, port);
}
configs.add(combineConfigKeyValue(configKey, configValue));
}
return configs;
}
use of com.sohu.cache.entity.InstanceConfig in project cachecloud by sohutv.
the class RedisConfigTemplateServiceImpl method handleCommonConfig.
@Override
public List<String> handleCommonConfig(int port, int maxMemory) {
List<InstanceConfig> instanceConfigList = getByType(ConstUtils.CACHE_REDIS_STANDALONE);
if (CollectionUtils.isEmpty(instanceConfigList)) {
return Collections.emptyList();
}
List<String> configs = new ArrayList<String>();
for (InstanceConfig instanceConfig : instanceConfigList) {
// 无效配置过滤
if (!instanceConfig.isEffective()) {
continue;
}
String configKey = instanceConfig.getConfigKey();
String configValue = instanceConfig.getConfigValue();
if (StringUtils.isBlank(configValue)) {
configValue = SPECIAL_EMPTY_STR;
}
if (RedisConfigEnum.MAXMEMORY.getKey().equals(configKey)) {
configValue = String.format(configValue, maxMemory);
} else if (RedisConfigEnum.DBFILENAME.getKey().equals(configKey) || RedisConfigEnum.APPENDFILENAME.getKey().equals(configKey) || RedisConfigEnum.PORT.getKey().equals(configKey)) {
configValue = String.format(configValue, port);
} else if (RedisConfigEnum.DIR.getKey().equals(configKey)) {
configValue = MachineProtocol.DATA_DIR;
} else if (RedisConfigEnum.AUTO_AOF_REWRITE_PERCENTAGE.getKey().equals(configKey)) {
//随机比例 auto-aof-rewrite-percentage
int percent = 69 + new Random().nextInt(30);
configValue = String.format(configValue, percent);
}
configs.add(combineConfigKeyValue(configKey, configValue));
}
return configs;
}
use of com.sohu.cache.entity.InstanceConfig in project cachecloud by sohutv.
the class InstanceConfigDaoTest method testById.
@Test
public void testById() {
long id = 1;
InstanceConfig instanceConfig = instanceConfigDao.getById(id);
logger.info("===========testById start==============");
logger.info(instanceConfig.toString());
logger.info("===========testById end==============");
}
use of com.sohu.cache.entity.InstanceConfig in project cachecloud by sohutv.
the class InstanceConfigDaoTest method testSaveOrUpdate.
@Test
public void testSaveOrUpdate() {
InstanceConfig instanceConfig = new InstanceConfig();
instanceConfig.setConfigKey("hello");
instanceConfig.setConfigValue("world");
instanceConfig.setInfo("info");
instanceConfig.setStatus(1);
instanceConfig.setType(ConstUtils.CACHE_TYPE_REDIS_CLUSTER);
instanceConfig.setUpdateTime(new Date());
logger.info("===========testSaveOrUpdate start==============");
instanceConfigDao.saveOrUpdate(instanceConfig);
logger.info("===========testSaveOrUpdate end==============");
}
use of com.sohu.cache.entity.InstanceConfig in project cachecloud by sohutv.
the class InstanceConfigDaoTest method testByConfigKeyAndType.
@Test
public void testByConfigKeyAndType() {
String configKey = "port";
int type = ConstUtils.CACHE_REDIS_STANDALONE;
InstanceConfig instanceConfig = instanceConfigDao.getByConfigKeyAndType(configKey, type);
logger.info("===========testById start==============");
logger.info(instanceConfig.toString());
logger.info("===========testById end==============");
}
Aggregations