public void run() { loadMoreIds(batchSize, null); synchronized (backgroundLoadMonitor) { currentlyBackgroundLoading = 0; } } });
public void run() { loadMoreIds(batchSize, null); synchronized (backgroundLoadMonitor) { currentlyBackgroundLoading = 0; } } });
public void run() { loadMoreIds(allocateSize, null); } });
public void run() { loadMoreIds(allocateSize, null); } });
/** * Called by preAllocateIds when we know that a large number of Id's is going * to be needed shortly. */ protected void loadLargeAllocation(final int allocateSize) { // preAllocateIds was called with a relatively large batchSize // so we will just go ahead and load those anyway in background backgroundExecutor.execute(() -> loadMoreIds(allocateSize, null)); }
/** * Load another batch of Id's using a background thread. */ protected void loadBatchInBackground() { // single threaded processing... synchronized (backgroundLoadMonitor) { if (currentlyBackgroundLoading > 0) { // skip as already background loading logger.debug("... skip background sequence load (another load in progress)"); return; } currentlyBackgroundLoading = batchSize; backgroundExecutor.execute(() -> { loadMoreIds(batchSize, null); synchronized (backgroundLoadMonitor) { currentlyBackgroundLoading = 0; } }); } }
/** * Return the next Id. * <p> * If a Transaction has been passed in use the Connection from it. * </p> */ public Object nextId(Transaction t) { synchronized (monitor) { if (idList.isEmpty()) { loadMoreIds(batchSize, t); } Long nextId = idList.remove(0); if (batchSize > 1) { if (idList.size() <= batchSize / 2) { loadBatchInBackground(); } } return nextId; } }
/** * Return the next Id. * <p> * If a Transaction has been passed in use the Connection from it. * </p> */ public Object nextId(Transaction t) { synchronized (monitor) { if (idList.size() == 0){ loadMoreIds(batchSize, t); } Integer nextId = idList.remove(0); if (batchSize > 1) { if (idList.size() <= batchSize/2){ loadBatchInBackground(); } } return nextId; } }
/** * Return the next Id. * <p> * If a Transaction has been passed in use the Connection from it. * </p> */ public Object nextId(Transaction t) { synchronized (monitor) { if (idList.size() == 0) { loadMoreIds(batchSize, t); } Integer nextId = idList.remove(0); if (batchSize > 1) { if (idList.size() <= batchSize / 2) { loadBatchInBackground(); } } return nextId; } }