@@ -240,30 +240,15 @@ static String[] parseIdentifier(String tableIdentifier, Logger logger)
240
240
}
241
241
242
242
@ VisibleForTesting
243
- public static String randomEndpoint (String feNodes , Logger logger )
244
- throws DorisConnectorException {
245
- logger .trace ("Parse fenodes '{}'." , feNodes );
246
- if (StringUtils .isEmpty (feNodes )) {
247
- String errMsg =
248
- String .format (ErrorMessages .ILLEGAL_ARGUMENT_MESSAGE , "fenodes" , feNodes );
249
- throw new DorisConnectorException (DorisConnectorErrorCode .REST_SERVICE_FAILED , errMsg );
250
- }
251
- List <String > nodes = Arrays .asList (feNodes .split ("," ));
252
- Collections .shuffle (nodes );
253
- return nodes .get (0 ).trim ();
254
- }
255
-
256
- @ VisibleForTesting
257
- static String getUriStr (
258
- DorisSourceConfig dorisSourceConfig , DorisSourceTable dorisSourceTable , Logger logger )
243
+ static String getUriStr (String node , DorisSourceTable dorisSourceTable , Logger logger )
259
244
throws DorisConnectorException {
260
245
String tableIdentifier =
261
246
dorisSourceTable .getTablePath ().getDatabaseName ()
262
247
+ "."
263
248
+ dorisSourceTable .getTablePath ().getTableName ();
264
249
String [] identifier = parseIdentifier (tableIdentifier , logger );
265
250
return "http://"
266
- + randomEndpoint ( dorisSourceConfig . getFrontends (), logger )
251
+ + node . trim ( )
267
252
+ API_PREFIX
268
253
+ "/"
269
254
+ identifier [0 ]
@@ -298,16 +283,37 @@ public static List<PartitionDefinition> findPartitions(
298
283
}
299
284
logger .debug ("Query SQL Sending to Doris FE is: '{}'." , sql );
300
285
301
- HttpPost httpPost =
302
- new HttpPost (getUriStr (dorisSourceConfig , dorisSourceTable , logger ) + QUERY_PLAN );
303
286
String entity = "{\" sql\" : \" " + sql + "\" }" ;
304
287
logger .debug ("Post body Sending to Doris FE is: '{}'." , entity );
305
288
StringEntity stringEntity = new StringEntity (entity , StandardCharsets .UTF_8 );
306
289
stringEntity .setContentEncoding ("UTF-8" );
307
290
stringEntity .setContentType ("application/json" );
308
- httpPost .setEntity (stringEntity );
309
291
310
- String resStr = send (dorisSourceConfig , httpPost , logger );
292
+ List <String > feNodes = Arrays .asList (dorisSourceConfig .getFrontends ().split ("," ));
293
+ Collections .shuffle (feNodes );
294
+ int feNodesNum = feNodes .size ();
295
+ String resStr = null ;
296
+
297
+ for (int i = 0 ; i < feNodesNum ; i ++) {
298
+ try {
299
+ HttpPost httpPost =
300
+ new HttpPost (
301
+ getUriStr (feNodes .get (i ), dorisSourceTable , logger ) + QUERY_PLAN );
302
+ httpPost .setEntity (stringEntity );
303
+ resStr = send (dorisSourceConfig , httpPost , logger );
304
+ break ;
305
+ } catch (Exception e ) {
306
+ if (i == feNodesNum - 1 ) {
307
+ throw new DorisConnectorException (
308
+ DorisConnectorErrorCode .REST_SERVICE_FAILED , e );
309
+ }
310
+ log .error (
311
+ "Find partition error for feNode: {} with exception: {}" ,
312
+ feNodes .get (i ),
313
+ e .getMessage ());
314
+ }
315
+ }
316
+
311
317
logger .debug ("Find partition response is '{}'." , resStr );
312
318
QueryPlan queryPlan = getQueryPlan (resStr , logger );
313
319
Map <String , List <Long >> be2Tablets = selectBeForTablet (queryPlan , logger );
0 commit comments