Search in sources :

Example 1 with ConfigQueryRequest

use of com.alibaba.nacos.api.config.remote.request.ConfigQueryRequest in project nacos by alibaba.

the class ConfigQueryRequestHandlerTest method testHandle.

@Test
public void testHandle() throws NacosException {
    ConfigQueryRequest configQueryRequest = new ConfigQueryRequest();
    configQueryRequest.setDataId("dataId");
    configQueryRequest.setGroup("group");
    RequestMeta requestMeta = new RequestMeta();
    requestMeta.setClientIp("127.0.0.1");
    ConfigQueryResponse response = configQueryRequestHandler.handle(configQueryRequest, requestMeta);
    Assert.assertEquals(response.getContent(), "content");
}
Also used : RequestMeta(com.alibaba.nacos.api.remote.request.RequestMeta) ConfigQueryResponse(com.alibaba.nacos.api.config.remote.response.ConfigQueryResponse) ConfigQueryRequest(com.alibaba.nacos.api.config.remote.request.ConfigQueryRequest) Test(org.junit.Test)

Example 2 with ConfigQueryRequest

use of com.alibaba.nacos.api.config.remote.request.ConfigQueryRequest in project nacos by alibaba.

the class ConfigQueryGroupKeyParserTest method testParse.

@Test
public void testParse() {
    ConfigQueryRequest configQueryRequest = new ConfigQueryRequest();
    configQueryRequest.setRequestId("requestId");
    configQueryRequest.setGroup("group");
    configQueryRequest.setDataId("dataId");
    configQueryRequest.setTenant("tenant");
    MonitorKey parse = configQueryGroupKeyParser.parse(configQueryRequest);
    Assert.assertEquals("dataId+group+tenant", parse.getKey());
}
Also used : MonitorKey(com.alibaba.nacos.core.remote.control.MonitorKey) ConfigQueryRequest(com.alibaba.nacos.api.config.remote.request.ConfigQueryRequest) Test(org.junit.Test)

Example 3 with ConfigQueryRequest

use of com.alibaba.nacos.api.config.remote.request.ConfigQueryRequest in project nacos by alibaba.

the class ConfigQueryGroupParserTest method testParse.

@Test
public void testParse() {
    ConfigQueryRequest configQueryRequest = new ConfigQueryRequest();
    configQueryRequest.setRequestId("requestId");
    configQueryRequest.setGroup("group");
    configQueryRequest.setDataId("dataId");
    configQueryRequest.setTenant("tenant");
    MonitorKey parse = configQueryGroupParser.parse(configQueryRequest);
    Assert.assertEquals("group", parse.getKey());
}
Also used : MonitorKey(com.alibaba.nacos.core.remote.control.MonitorKey) ConfigQueryRequest(com.alibaba.nacos.api.config.remote.request.ConfigQueryRequest) Test(org.junit.Test)

Example 4 with ConfigQueryRequest

use of com.alibaba.nacos.api.config.remote.request.ConfigQueryRequest in project nacos by alibaba.

the class InternalConfigChangeNotifier method loadLocalConfigLikeClient.

private String loadLocalConfigLikeClient(String dataId, String group) throws NacosException {
    ConfigQueryRequest queryRequest = new ConfigQueryRequest();
    queryRequest.setDataId(dataId);
    queryRequest.setGroup(group);
    RequestMeta meta = new RequestMeta();
    meta.setClientIp(NetUtils.localIP());
    ConfigQueryResponse handle = configQueryRequestHandler.handle(queryRequest, meta);
    if (handle == null) {
        throw new NacosException(NacosException.SERVER_ERROR, "load local config fail,response is null");
    }
    if (handle.isSuccess()) {
        return handle.getContent();
    } else if (handle.getErrorCode() == ConfigQueryResponse.CONFIG_NOT_FOUND) {
        return null;
    } else {
        Loggers.REMOTE.error("connection limit rule load fail,errorCode={}", handle.getErrorCode());
        throw new NacosException(NacosException.SERVER_ERROR, "load local config fail,error code=" + handle.getErrorCode());
    }
}
Also used : RequestMeta(com.alibaba.nacos.api.remote.request.RequestMeta) ConfigQueryResponse(com.alibaba.nacos.api.config.remote.response.ConfigQueryResponse) ConfigQueryRequest(com.alibaba.nacos.api.config.remote.request.ConfigQueryRequest) NacosException(com.alibaba.nacos.api.exception.NacosException)

Aggregations

ConfigQueryRequest (com.alibaba.nacos.api.config.remote.request.ConfigQueryRequest)4 Test (org.junit.Test)3 ConfigQueryResponse (com.alibaba.nacos.api.config.remote.response.ConfigQueryResponse)2 RequestMeta (com.alibaba.nacos.api.remote.request.RequestMeta)2 MonitorKey (com.alibaba.nacos.core.remote.control.MonitorKey)2 NacosException (com.alibaba.nacos.api.exception.NacosException)1