28
28
import com .alibaba .nacos .api .selector .AbstractSelector ;
29
29
import com .alibaba .nacos .api .selector .ExpressionSelector ;
30
30
import com .alibaba .nacos .api .selector .SelectorType ;
31
- import com .alibaba .nacos .api .utils .NetUtils ;
32
31
import com .alibaba .nacos .client .env .NacosClientProperties ;
33
32
import com .alibaba .nacos .client .monitor .MetricsMonitor ;
34
33
import com .alibaba .nacos .client .naming .core .ServerListManager ;
@@ -93,8 +92,6 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy {
93
92
94
93
private static final String CLUSTERS_PARAM = "clusters" ;
95
94
96
- private static final String UDP_PORT_PARAM = "udpPort" ;
97
-
98
95
private static final String CLIENT_IP_PARAM = "clientIP" ;
99
96
100
97
private static final String HEALTHY_ONLY_PARAM = "healthyOnly" ;
@@ -160,17 +157,15 @@ public void batchRegisterService(String serviceName, String groupName, List<Inst
160
157
}
161
158
162
159
@ Override
163
- public void batchDeregisterService (String serviceName , String groupName , List <Instance > instances )
164
- throws NacosException {
160
+ public void batchDeregisterService (String serviceName , String groupName , List <Instance > instances ) {
165
161
throw new UnsupportedOperationException (
166
162
"Do not support persistent instances to perform batch de registration methods." );
167
163
}
168
164
169
165
@ Override
170
166
public void deregisterService (String serviceName , String groupName , Instance instance ) throws NacosException {
171
- NAMING_LOGGER
172
- .info ("[DEREGISTER-SERVICE] {} deregistering service {} with instance: {}" , namespaceId , serviceName ,
173
- instance );
167
+ NAMING_LOGGER .info ("[DEREGISTER-SERVICE] {} deregistering service {} with instance: {}" , namespaceId ,
168
+ serviceName , instance );
174
169
if (instance .isEphemeral ()) {
175
170
return ;
176
171
}
@@ -187,8 +182,8 @@ public void deregisterService(String serviceName, String groupName, Instance ins
187
182
188
183
@ Override
189
184
public void updateInstance (String serviceName , String groupName , Instance instance ) throws NacosException {
190
- NAMING_LOGGER
191
- . info ( "[UPDATE-SERVICE] {} update service {} with instance: {}" , namespaceId , serviceName , instance );
185
+ NAMING_LOGGER . info ( "[UPDATE-SERVICE] {} update service {} with instance: {}" , namespaceId , serviceName ,
186
+ instance );
192
187
193
188
final Map <String , String > params = new HashMap <>(32 );
194
189
params .put (CommonParams .NAMESPACE_ID , namespaceId );
@@ -206,20 +201,10 @@ public void updateInstance(String serviceName, String groupName, Instance instan
206
201
}
207
202
208
203
@ Override
209
- public ServiceInfo queryInstancesOfService (String serviceName , String groupName , String clusters , int udpPort ,
210
- boolean healthyOnly ) throws NacosException {
211
- final Map <String , String > params = new HashMap <>(16 );
212
- params .put (CommonParams .NAMESPACE_ID , namespaceId );
213
- params .put (CommonParams .SERVICE_NAME , NamingUtils .getGroupedName (serviceName , groupName ));
214
- params .put (CLUSTERS_PARAM , clusters );
215
- params .put (UDP_PORT_PARAM , String .valueOf (udpPort ));
216
- params .put (CLIENT_IP_PARAM , NetUtils .localIP ());
217
- params .put (HEALTHY_ONLY_PARAM , String .valueOf (healthyOnly ));
218
- String result = reqApi (UtilAndComs .nacosUrlBase + "/instance/list" , params , HttpMethod .GET );
219
- if (StringUtils .isNotEmpty (result )) {
220
- return JacksonUtils .toObj (result , ServiceInfo .class );
221
- }
222
- return new ServiceInfo (NamingUtils .getGroupedName (serviceName , groupName ), clusters );
204
+ public ServiceInfo queryInstancesOfService (String serviceName , String groupName , String clusters ,
205
+ boolean healthyOnly ) {
206
+ throw new UnsupportedOperationException (
207
+ "Do not support query instance by http client,please use gRPC replaced." );
223
208
}
224
209
225
210
@ Override
@@ -442,8 +427,8 @@ public String callServer(String api, Map<String, String> params, Map<String, Str
442
427
url = NamingHttpClientManager .getInstance ().getPrefix () + curServer + api ;
443
428
}
444
429
try {
445
- HttpRestResult <String > restResult = nacosRestTemplate
446
- . exchangeForm ( url , header , Query .newInstance ().initParams (params ), body , method , String .class );
430
+ HttpRestResult <String > restResult = nacosRestTemplate . exchangeForm ( url , header ,
431
+ Query .newInstance ().initParams (params ), body , method , String .class );
447
432
end = System .currentTimeMillis ();
448
433
449
434
MetricsMonitor .getNamingRequestMonitor (method , url , String .valueOf (restResult .getCode ()))
0 commit comments