@Override protected void openConnection(URL url) throws IOException { if (null == connection || renewConnection) { super.openConnection(url); } // already 'opened' the mocked connection return; } }
private void openConnectionWithRetry(MapHost host, Set<TaskAttemptID> remaining, URL url) throws IOException { long startTime = Time.monotonicNow(); boolean shouldWait = true; while (shouldWait) { try { openConnection(url); shouldWait = false; } catch (IOException e) { if (!fetchRetryEnabled) { // throw exception directly if fetch's retry is not enabled throw e; } if ((Time.monotonicNow() - startTime) >= this.fetchRetryTimeout) { LOG.warn("Failed to connect to host: " + url + "after " + fetchRetryTimeout + " milliseconds."); throw e; } try { Thread.sleep(this.fetchRetryInterval); } catch (InterruptedException e1) { if (stopped) { return; } } } } }
private void openConnectionWithRetry(MapHost host, Set<TaskAttemptID> remaining, URL url) throws IOException { long startTime = Time.monotonicNow(); boolean shouldWait = true; while (shouldWait) { try { openConnection(url); shouldWait = false; } catch (IOException e) { if (!fetchRetryEnabled) { // throw exception directly if fetch's retry is not enabled throw e; } if ((Time.monotonicNow() - startTime) >= this.fetchRetryTimeout) { LOG.warn("Failed to connect to host: " + url + "after " + fetchRetryTimeout + " milliseconds."); throw e; } try { Thread.sleep(this.fetchRetryInterval); } catch (InterruptedException e1) { if (stopped) { return; } } } } }
private void openConnectionWithRetry(URL url) throws IOException { long startTime = Time.monotonicNow(); boolean shouldWait = true; while (shouldWait) { try { openConnection(url); shouldWait = false; } catch (IOException e) { if (!fetchRetryEnabled) { // throw exception directly if fetch's retry is not enabled throw e; } if ((Time.monotonicNow() - startTime) >= this.fetchRetryTimeout) { LOG.warn("Failed to connect to host: " + url + "after " + fetchRetryTimeout + " milliseconds."); throw e; } try { Thread.sleep(this.fetchRetryInterval); } catch (InterruptedException e1) { if (stopped) { return; } } } } }
private void openConnectionWithRetry(MapHost host, Set<TaskAttemptID> remaining, URL url) throws IOException { long startTime = Time.monotonicNow(); boolean shouldWait = true; while (shouldWait) { try { openConnection(url); shouldWait = false; } catch (IOException e) { if (!fetchRetryEnabled) { // throw exception directly if fetch's retry is not enabled throw e; } if ((Time.monotonicNow() - startTime) >= this.fetchRetryTimeout) { LOG.warn("Failed to connect to host: " + url + "after " + fetchRetryTimeout + " milliseconds."); throw e; } try { Thread.sleep(this.fetchRetryInterval); } catch (InterruptedException e1) { if (stopped) { return; } } } } }