@@ 189-210 (lines=22) @@ | ||
186 | return rowMeta; |
|
187 | } |
|
188 | ||
189 | private void handleError(Throwable e, int attempts) { |
|
190 | ||
191 | try { |
|
192 | String msg = String.format("Falha ao executar consulta (tentativa %d de %d): ", attempts, MAX_ATTEMPTS); |
|
193 | ||
194 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
|
195 | baos.write(msg.getBytes()); |
|
196 | ||
197 | e.printStackTrace(new PrintWriter(baos, true)); |
|
198 | ||
199 | long sleepTime = (long) (500 * Math.pow(2, attempts)); |
|
200 | msg = String.format("Tentando novamente em %d milissegundos...", sleepTime); |
|
201 | baos.write(msg.getBytes()); |
|
202 | ||
203 | log.logBasic(baos.toString()); |
|
204 | ||
205 | Thread.sleep(sleepTime); |
|
206 | ||
207 | } catch (IOException e1) { |
|
208 | e1.printStackTrace(); |
|
209 | } catch (InterruptedException e2) { |
|
210 | e2.printStackTrace(); |
|
211 | } |
|
212 | } |
|
213 |
@@ 160-181 (lines=22) @@ | ||
157 | return rowMeta; |
|
158 | } |
|
159 | ||
160 | private void handleError(Throwable e, int attempts) { |
|
161 | ||
162 | try { |
|
163 | String msg = String.format("Falha ao executar consulta (tentativa %d de %d): ", attempts, MAX_ATTEMPTS); |
|
164 | ||
165 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
|
166 | baos.write(msg.getBytes()); |
|
167 | ||
168 | e.printStackTrace(new PrintWriter(baos, true)); |
|
169 | ||
170 | long sleepTime = (long) (500 * Math.pow(2, attempts)); |
|
171 | msg = String.format("Tentando novamente em %d milissegundos...", sleepTime); |
|
172 | baos.write(msg.getBytes()); |
|
173 | ||
174 | log.logBasic(baos.toString()); |
|
175 | ||
176 | Thread.sleep(sleepTime); |
|
177 | ||
178 | } catch (IOException e1) { |
|
179 | e1.printStackTrace(); |
|
180 | } catch (InterruptedException e2) { |
|
181 | e2.printStackTrace(); |
|
182 | } |
|
183 | } |
|
184 |