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");
}
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());
}
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());
}
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());
}
}
Aggregations