Search in sources :

Example 6 with ConfigModel

use of com.ctrip.xpipe.redis.console.model.ConfigModel in project x-pipe by ctripcorp.

the class ConfigServiceImpl method getConfig.

@Override
public ConfigModel getConfig(String key) {
    try {
        ConfigTbl configTbl = configDao.getByKey(key);
        ConfigModel config = new ConfigModel();
        config.setKey(key);
        config.setVal(configTbl.getValue());
        config.setUpdateIP(configTbl.getLatestUpdateIp());
        config.setUpdateUser(configTbl.getLatestUpdateUser());
        return config;
    } catch (DalException e) {
        logger.error("[getConfig] {}", e);
        return null;
    }
}
Also used : ConfigTbl(com.ctrip.xpipe.redis.console.model.ConfigTbl) ConfigModel(com.ctrip.xpipe.redis.console.model.ConfigModel) DalException(org.unidal.dal.jdbc.DalException)

Example 7 with ConfigModel

use of com.ctrip.xpipe.redis.console.model.ConfigModel in project x-pipe by ctripcorp.

the class SentinelAutoProcessChecker method alert.

@Override
void alert() {
    ConfigModel config = configService.getConfig(DefaultConsoleDbConfig.KEY_SENTINEL_AUTO_PROCESS);
    String user = config.getUpdateUser() == null ? "unkown" : config.getUpdateUser();
    String ip = config.getUpdateIP() == null ? "unkown" : config.getUpdateIP();
    String message = String.format("Sentinel Auto Process will be online %s, </br> " + "Recent update by: %s <br/> and from IP: %s", configService.getAlertSystemRecoverTime().toString(), user, ip);
    alertManager.alert("", "", null, ALERT_TYPE.SENTINEL_AUTO_PROCESS_OFF, message);
}
Also used : ConfigModel(com.ctrip.xpipe.redis.console.model.ConfigModel)

Example 8 with ConfigModel

use of com.ctrip.xpipe.redis.console.model.ConfigModel in project x-pipe by ctripcorp.

the class ConfigControllerTest method testChangeConfig1.

@Test
public void testChangeConfig1() throws Exception {
    ConfigModel model = new ConfigModel();
    model.setKey(DefaultConsoleDbConfig.KEY_ALERT_SYSTEM_ON);
    model.setVal(String.valueOf(false));
    RetMessage ret = controller.changeConfig(request, model);
    Assert.assertEquals(RetMessage.SUCCESS_STATE, ret.getState());
}
Also used : ConfigModel(com.ctrip.xpipe.redis.console.model.ConfigModel) RetMessage(com.ctrip.xpipe.redis.console.controller.api.RetMessage) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 9 with ConfigModel

use of com.ctrip.xpipe.redis.console.model.ConfigModel in project x-pipe by ctripcorp.

the class ConfigControllerTest method testChangeConfig2.

@Test
public void testChangeConfig2() throws Exception {
    ConfigModel model = new ConfigModel();
    model.setKey("Key Unknown");
    model.setVal(String.valueOf(false));
    RetMessage ret = controller.changeConfig(request, model);
    Assert.assertEquals(RetMessage.FAIL_STATE, ret.getState());
    Assert.assertEquals("Unknown config key: Key Unknown", ret.getMessage());
}
Also used : ConfigModel(com.ctrip.xpipe.redis.console.model.ConfigModel) RetMessage(com.ctrip.xpipe.redis.console.controller.api.RetMessage) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 10 with ConfigModel

use of com.ctrip.xpipe.redis.console.model.ConfigModel in project x-pipe by ctripcorp.

the class AlertSystemOffChecker method alert.

@Override
void alert() {
    logger.info("[alert] Alert System Off");
    ConfigModel config = configService.getConfig(DefaultConsoleDbConfig.KEY_ALERT_SYSTEM_ON);
    String user = config.getUpdateUser() == null ? "unkown" : config.getUpdateUser();
    String ip = config.getUpdateIP() == null ? "unkown" : config.getUpdateIP();
    String message = String.format("Alert System will be online %s, </br> Recent update by: %s <br/> and from IP: %s", configService.getAlertSystemRecoverTime().toString(), user, ip);
    logger.info("[alert] sending alert: {}", message);
    alertManager.alert("", "", null, ALERT_TYPE.ALERT_SYSTEM_OFF, message);
}
Also used : ConfigModel(com.ctrip.xpipe.redis.console.model.ConfigModel)

Aggregations

ConfigModel (com.ctrip.xpipe.redis.console.model.ConfigModel)17 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)5 Test (org.junit.Test)5 ConfigTbl (com.ctrip.xpipe.redis.console.model.ConfigTbl)4 Date (java.util.Date)3 RetMessage (com.ctrip.xpipe.redis.console.controller.api.RetMessage)2 DalException (org.unidal.dal.jdbc.DalException)2 UserInfo (com.ctrip.xpipe.api.sso.UserInfo)1