use of com.alibaba.nacos.api.naming.remote.request.AbstractNamingRequest in project nacos by alibaba.
the class GrpcRequestFilter method filter.
@Override
protected Response filter(Request request, RequestMeta meta, Class handlerClazz) throws NacosException {
if (request instanceof AbstractNamingRequest && !upgradeJudgement.isUseGrpcFeatures()) {
Response response = getDefaultResponseInstance(handlerClazz);
response.setErrorInfo(NacosException.SERVER_ERROR, "Nacos cluster is running with 1.X mode, can't accept gRPC request temporarily. Please check the server status or close Double write to force open 2.0 mode. Detail https://nacos.io/en-us/docs/2.0.0-upgrading.html.");
return response;
}
return null;
}
use of com.alibaba.nacos.api.naming.remote.request.AbstractNamingRequest in project nacos by alibaba.
the class NamingResourceParser method parseName.
@Override
public String parseName(Object requestObj) {
String namespaceId = null;
String serviceName = null;
String groupName = null;
if (requestObj instanceof HttpServletRequest) {
HttpServletRequest req = (HttpServletRequest) requestObj;
namespaceId = NamespaceUtil.processNamespaceParameter(req.getParameter(CommonParams.NAMESPACE_ID));
serviceName = req.getParameter(CommonParams.SERVICE_NAME);
groupName = req.getParameter(CommonParams.GROUP_NAME);
} else if (requestObj instanceof AbstractNamingRequest) {
AbstractNamingRequest request = (AbstractNamingRequest) requestObj;
namespaceId = request.getNamespace();
groupName = request.getGroupName();
serviceName = request.getServiceName();
} else if (requestObj instanceof Request) {
Request request = (Request) requestObj;
namespaceId = (String) ReflectUtils.getFieldValue(request, FieldsConstants.NAME_SPACE, "");
groupName = (String) ReflectUtils.getFieldValue(request, FieldsConstants.GROUP_NAME, "");
serviceName = (String) ReflectUtils.getFieldValue(request, FieldsConstants.SERVICE_NAME, "");
}
if (StringUtils.isBlank(groupName)) {
groupName = NamingUtils.getGroupName(serviceName);
}
serviceName = NamingUtils.getServiceName(serviceName);
StringBuilder sb = new StringBuilder();
if (StringUtils.isNotBlank(namespaceId)) {
sb.append(namespaceId);
}
if (StringUtils.isBlank(groupName)) {
sb.append(Resource.SPLITTER).append('*');
} else {
sb.append(Resource.SPLITTER).append(groupName);
}
if (StringUtils.isBlank(serviceName)) {
sb.append(Resource.SPLITTER).append(AUTH_NAMING_PREFIX).append('*');
} else {
sb.append(Resource.SPLITTER).append(AUTH_NAMING_PREFIX).append(serviceName);
}
return sb.toString();
}
Aggregations