private void handleDataNotAvailable(DataNotAvailableException e) throws BlockedException { if (e.getWaitUntil() != null) { long timeDiff = e.getWaitUntil().getTime() - System.currentTimeMillis(); if (timeDiff <= 0) { //already met the time return; } if (e.isStrict()) { this.waitUntil = e.getWaitUntil().getTime(); } scheduleMoreWork(timeDiff); } else if (e.getRetryDelay() >= 0) { if (e.isStrict()) { this.waitUntil = System.currentTimeMillis() + e.getRetryDelay(); } scheduleMoreWork(e.getRetryDelay()); } else if (this.cwi.isDataAvailable()) { return; //no polling, but data is already available } else if (e.isStrict()) { //no polling, wait indefinitely this.waitUntil = Long.MAX_VALUE; } throw BlockedException.block(aqr.getAtomicRequestID(), "Blocking on DataNotAvailableException", aqr.getAtomicRequestID()); //$NON-NLS-1$ }
@Override public AtomicResultsMessage more() throws TranslatorException { if (dataNotAvailable != null) { int delay = dataNotAvailable; dataNotAvailable = null; DataNotAvailableException dnae = new DataNotAvailableException(delay); dnae.setStrict(strict); throw dnae; } if (addWarning) { msg.setWarnings(Arrays.asList(new Exception())); } if (!returnedInitial) { returnedInitial = true; return msg; } throw new RuntimeException("Should not be called"); //$NON-NLS-1$ }
private List<List> readResultsFromExecution(Execution execution) throws TranslatorException { List<List> results = new ArrayList<List>(); while (true) { try { if (execution instanceof ResultSetExecution) { ResultSetExecution rs = (ResultSetExecution)execution; List result = null; while ((result = rs.next()) != null) { results.add(result); } break; } UpdateExecution rs = (UpdateExecution)execution; int[] result = rs.getUpdateCounts(); for (int i = 0; i < result.length; i++) { results.add(Arrays.asList(result[i])); } break; } catch (DataNotAvailableException e) { if (e.getRetryDelay() > 0) { try { Thread.sleep(e.getRetryDelay()); } catch (InterruptedException e1) { throw new TranslatorException(e1); } } } } return results; }
throw e; if (e.getWaitUntil() != null) {
private void throwDataNotAvailable(BatchResultInfo info) { int waitCount = info.incrementAndGetWaitCount(); LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Waiting on queued/inprogress, wait number", waitCount); //$NON-NLS-1$ throw new DataNotAvailableException(pollingInterval * Math.min(8, waitCount)); }
throw e; if (e.getWaitUntil() != null) {
@Override public BatchResult[] getBulkResults(JobInfo job, List<String> ids) throws ResourceException { try { JobInfo info = this.bulkConnection.getJobStatus(job.getId()); if (info.getNumberBatchesTotal() != info.getNumberBatchesFailed() + info.getNumberBatchesCompleted()) { throw new DataNotAvailableException(pollingInterval); } BatchResult[] results = new BatchResult[ids.size()]; for (int i = 0; i < ids.size(); i++) { results[i] = this.bulkConnection.getBatchResult(job.getId(), ids.get(i)); } return results; } catch (AsyncApiException e) { throw new ResourceException(e); } }
private void handleDataNotAvailable(DataNotAvailableException e) throws BlockedException { if (e.getWaitUntil() != null) { long timeDiff = e.getWaitUntil().getTime() - System.currentTimeMillis(); if (timeDiff <= 0) { //already met the time return; } if (e.isStrict()) { this.waitUntil = e.getWaitUntil().getTime(); } scheduleMoreWork(timeDiff); } else if (e.getRetryDelay() >= 0) { if (e.isStrict()) { this.waitUntil = System.currentTimeMillis() + e.getRetryDelay(); } scheduleMoreWork(e.getRetryDelay()); } else if (this.cwi.isDataAvailable()) { return; //no polling, but data is already available } else if (e.isStrict()) { //no polling, wait indefinitely this.waitUntil = Long.MAX_VALUE; } throw BlockedException.block(aqr.getAtomicRequestID(), "Blocking on DataNotAvailableException", aqr.getAtomicRequestID()); //$NON-NLS-1$ }
throw e; if (e.getWaitUntil() != null) {
private void handleDataNotAvailable(DataNotAvailableException e) throws BlockedException { if (e.getWaitUntil() != null) { long timeDiff = e.getWaitUntil().getTime() - System.currentTimeMillis(); if (timeDiff <= 0) { //already met the time return; } if (e.isStrict()) { this.waitUntil = e.getWaitUntil().getTime(); } scheduleMoreWork(timeDiff); } else if (e.getRetryDelay() >= 0) { if (e.isStrict()) { this.waitUntil = System.currentTimeMillis() + e.getRetryDelay(); } scheduleMoreWork(e.getRetryDelay()); } else if (this.cwi.isDataAvailable()) { return; //no polling, but data is already available } else if (e.isStrict()) { //no polling, wait indefinitely this.waitUntil = Long.MAX_VALUE; } throw BlockedException.block(aqr.getAtomicRequestID(), "Blocking on DataNotAvailableException", aqr.getAtomicRequestID()); //$NON-NLS-1$ }