|
45 | 45 | import java.net.SocketException; |
46 | 46 | import java.util.ArrayList; |
47 | 47 | import java.util.Arrays; |
| 48 | +import java.util.HashMap; |
48 | 49 | import java.util.List; |
| 50 | +import java.util.Map; |
49 | 51 | import java.util.zip.CRC32; |
50 | 52 |
|
51 | 53 | import static org.apache.iotdb.commons.pipe.config.constant.PipeConnectorConstant.CONNECTOR_AIR_GAP_E_LANGUAGE_ENABLE_DEFAULT_VALUE; |
@@ -98,6 +100,8 @@ public String toString() { |
98 | 100 | // The air gap connector does not use clientManager thus we put handshake type here |
99 | 101 | protected boolean supportModsIfIsDataNodeReceiver = true; |
100 | 102 |
|
| 103 | + private final Map<TEndPoint, Long> failLogTimes = new HashMap<>(); |
| 104 | + |
101 | 105 | @Override |
102 | 106 | public void customize( |
103 | 107 | final PipeParameters parameters, final PipeConnectorRuntimeConfiguration configuration) |
@@ -180,12 +184,19 @@ public void handshake() throws Exception { |
180 | 184 | socket.setKeepAlive(true); |
181 | 185 | sockets.set(i, socket); |
182 | 186 | LOGGER.info("Successfully connected to target server ip: {}, port: {}.", ip, port); |
| 187 | + failLogTimes.remove(nodeUrls.get(i)); |
183 | 188 | } catch (final Exception e) { |
184 | | - LOGGER.warn( |
185 | | - "Failed to connect to target server ip: {}, port: {}, because: {}. Ignore it.", |
186 | | - ip, |
187 | | - port, |
188 | | - e.getMessage()); |
| 189 | + final TEndPoint endPoint = nodeUrls.get(i); |
| 190 | + final long currentTimeMillis = System.currentTimeMillis(); |
| 191 | + final Long lastFailLogTime = failLogTimes.get(endPoint); |
| 192 | + if (lastFailLogTime == null || currentTimeMillis - lastFailLogTime > 60000) { |
| 193 | + failLogTimes.put(endPoint, currentTimeMillis); |
| 194 | + LOGGER.warn( |
| 195 | + "Failed to connect to target server ip: {}, port: {}, because: {}. Ignore it.", |
| 196 | + ip, |
| 197 | + port, |
| 198 | + e.getMessage()); |
| 199 | + } |
189 | 200 | continue; |
190 | 201 | } |
191 | 202 |
|
|
0 commit comments