2020package com .dtstack .flink .sql .side .rdb .async ;
2121
2222import com .dtstack .flink .sql .enums .ECacheContentType ;
23- import com .dtstack .flink .sql .metric .MetricConstant ;
2423import com .dtstack .flink .sql .side .BaseAsyncReqRow ;
2524import com .dtstack .flink .sql .side .BaseSideInfo ;
2625import com .dtstack .flink .sql .side .CacheMissVal ;
3433import io .vertx .core .json .JsonObject ;
3534import io .vertx .ext .sql .SQLClient ;
3635import io .vertx .ext .sql .SQLConnection ;
37- import org .apache .calcite .sql .JoinType ;
3836import org .apache .commons .lang3 .StringUtils ;
39- import org .apache .flink .configuration .Configuration ;
40- import org .apache .flink .metrics .Counter ;
4137import org .apache .flink .streaming .api .functions .async .ResultFuture ;
4238import org .apache .flink .table .runtime .types .CRow ;
4339import org .apache .flink .table .typeutils .TimeIndicatorTypeInfo ;
@@ -88,12 +84,8 @@ public class RdbAsyncReqRow extends BaseAsyncReqRow {
8884
8985 private final static AtomicBoolean CONN_STATUS = new AtomicBoolean (true );
9086
91- private final static AtomicLong FAIL_NUM = new AtomicLong (0 );
92-
9387 private Logger logger = LoggerFactory .getLogger (getClass ());
9488
95- private Counter counter = getRuntimeContext ().getMetricGroup ().counter (MetricConstant .DT_NUM_SIDE_PARSE_ERROR_RECORDS );
96-
9789 public RdbAsyncReqRow (BaseSideInfo sideInfo ) {
9890 super (sideInfo );
9991 init (sideInfo );
@@ -114,7 +106,11 @@ protected void preInvoke(CRow input, ResultFuture<CRow> resultFuture){
114106 @ Override
115107 public void handleAsyncInvoke (Map <String , Object > inputParams , CRow input , ResultFuture <CRow > resultFuture ) throws Exception {
116108
109+ AtomicLong networkLogCounter = new AtomicLong (0L );
117110 while (!CONN_STATUS .get ()){//network is unhealth
111+ if (networkLogCounter .getAndIncrement () % 1000 == 0 ){
112+ LOG .info ("network unhealth to block task" );
113+ }
118114 Thread .sleep (100 );
119115 }
120116 Map <String , Object > params = formatInputParam (inputParams );
@@ -144,12 +140,7 @@ private void connectWithRetry(Map<String, Object> inputParams, CRow input, Resul
144140 logger .error ("getConnection error" , conn .cause ());
145141 }
146142 if (failCounter .get () >= sideInfo .getSideTableInfo ().getAsyncFailMaxNum (3L )){
147- if (FAIL_NUM .incrementAndGet () > sideInfo .getSideTableInfo ().getAsyncFailMaxNum (Long .MAX_VALUE )){
148- counter .inc ();
149- resultFuture .completeExceptionally (conn .cause ());
150- } else {
151- dealMissKey (input , resultFuture );
152- }
143+ dealFillDataError (input , resultFuture , conn .cause ());
153144 finishFlag .set (true );
154145 }
155146 conn .result ().close ();
@@ -161,8 +152,7 @@ private void connectWithRetry(Map<String, Object> inputParams, CRow input, Resul
161152 handleQuery (conn .result (), inputParams , input , resultFuture );
162153 finishFlag .set (true );
163154 } catch (Exception e ) {
164- dealFillDataError (resultFuture , e , null );
165- logger .error ("" , e );
155+ dealFillDataError (input , resultFuture , e );
166156 } finally {
167157 latch .countDown ();
168158 }
@@ -228,13 +218,7 @@ private void handleQuery(SQLConnection connection, Map<String, Object> inputPara
228218 JsonArray params = new JsonArray (Lists .newArrayList (inputParams .values ()));
229219 connection .queryWithParams (sideInfo .getSqlCondition (), params , rs -> {
230220 if (rs .failed ()) {
231- if (FAIL_NUM .incrementAndGet () > sideInfo .getSideTableInfo ().getAsyncFailMaxNum (Long .MAX_VALUE )){
232- LOG .error ("Cannot retrieve the data from the database" , rs .cause ());
233- counter .inc ();
234- resultFuture .completeExceptionally (rs .cause ());
235- } else {
236- dealMissKey (input , resultFuture );
237- }
221+ dealFillDataError (input , resultFuture , rs .cause ());
238222 return ;
239223 }
240224
0 commit comments