|
19 | 19 |
|
20 | 20 | package org.apache.iotdb.db.pipe.sink.protocol.opcua.client; |
21 | 21 |
|
| 22 | +import org.apache.iotdb.commons.pipe.config.PipeConfig; |
| 23 | +import org.apache.iotdb.pipe.api.exception.PipeException; |
| 24 | + |
22 | 25 | import org.bouncycastle.jce.provider.BouncyCastleProvider; |
23 | 26 | import org.eclipse.milo.opcua.sdk.client.OpcUaClient; |
24 | 27 | import org.eclipse.milo.opcua.stack.client.security.DefaultClientCertificateValidator; |
@@ -115,35 +118,17 @@ public void run() { |
115 | 118 | Thread.currentThread().interrupt(); |
116 | 119 | logger.warn("Error disconnecting: ", e); |
117 | 120 | } |
118 | | - |
119 | | - try { |
120 | | - Thread.sleep(1000); |
121 | | - System.exit(0); |
122 | | - } catch (final InterruptedException e) { |
123 | | - Thread.currentThread().interrupt(); |
124 | | - e.printStackTrace(); |
125 | | - } |
126 | 121 | }); |
127 | 122 |
|
128 | 123 | try { |
129 | 124 | configurableUaClient.run(client); |
130 | | - future.get(100000, TimeUnit.SECONDS); |
| 125 | + future.get( |
| 126 | + PipeConfig.getInstance().getPipeConnectorHandshakeTimeoutMs(), TimeUnit.MICROSECONDS); |
131 | 127 | } catch (final Exception e) { |
132 | | - logger.warn("Error running client example: ", e); |
133 | | - future.completeExceptionally(e); |
| 128 | + throw new PipeException("Error running client example.", e); |
134 | 129 | } |
135 | 130 | } catch (final Exception e) { |
136 | | - logger.warn("Error getting client: ", e); |
137 | | - |
138 | | - future.completeExceptionally(e); |
139 | | - |
140 | | - try { |
141 | | - Thread.sleep(1000); |
142 | | - System.exit(0); |
143 | | - } catch (InterruptedException interruptedException) { |
144 | | - Thread.currentThread().interrupt(); |
145 | | - logger.warn("Interrupted when running client: ", e); |
146 | | - } |
| 131 | + throw new PipeException("Error getting client.", e); |
147 | 132 | } |
148 | 133 | } |
149 | 134 | } |
0 commit comments