/** * If allocateSize is large load some sequences in a background thread. * <p> * For example, when inserting a bean with a cascade on a OneToMany with * many beans Ebean can call this to ensure . * </p> */ public void preAllocateIds(int allocateSize) { if (batchSize > 1 && allocateSize > batchSize){ // only bother if allocateSize is bigger than // the normal loading batchSize if (allocateSize > 100){ // max out at 100 for now allocateSize = 100; } loadLargeAllocation(allocateSize); } }
public void run() { 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; } }
String sql = getSql(loadSize); closeResources(null, pstmt, rset); } else { closeResources(c, pstmt, rset);
protected void loadMoreIds(final int numberToLoad, Transaction t) { ArrayList<Long> newIds = getMoreIds(numberToLoad, t); if (logger.isDebugEnabled()) { logger.debug("... seq:" + seqName + " loaded:" + numberToLoad + " ids:" + newIds); } synchronized (monitor) { for (Long newId : newIds) { idList.add(newId); } } }
/** * 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; } }
String sql = getSql(loadSize); closeResources(null, pstmt, rset); } else { closeResources(c, pstmt, rset);
protected void loadMoreIds(final int numberToLoad, Transaction t) { ArrayList<Integer> newIds = getMoreIds(numberToLoad, t); if (logger.isLoggable(Level.FINE)){ logger.log(Level.FINE, "... seq:"+seqName+" loaded:"+numberToLoad+" ids:"+newIds); } synchronized (monitor) { for (int i = 0; i < newIds.size(); i++) { idList.add(newIds.get(i)); } } }
/** * 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; } }
String sql = getSql(loadSize); closeResources(null, pstmt, rset); } else { closeResources(c, pstmt, rset);
public void run() { loadMoreIds(batchSize, null); synchronized (backgroundLoadMonitor) { currentlyBackgroundLoading = 0; } } });
protected void loadMoreIds(final int numberToLoad, Transaction t) { ArrayList<Integer> newIds = getMoreIds(numberToLoad, t); if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "... seq:" + seqName + " loaded:" + numberToLoad + " ids:" + newIds); } synchronized (monitor) { for (int i = 0; i < newIds.size(); i++) { idList.add(newIds.get(i)); } } }
/** * If allocateSize is large load some sequences in a background thread. * <p> * For example, when inserting a bean with a cascade on a OneToMany with many * beans Ebean can call this to ensure . * </p> */ public void preAllocateIds(int allocateSize) { if (batchSize > 1 && allocateSize > batchSize) { // only bother if allocateSize is bigger than // the normal loading batchSize if (allocateSize > 100) { // max out at 100 for now allocateSize = 100; } loadLargeAllocation(allocateSize); } }
public void run() { loadMoreIds(allocateSize, null); } });
/** * If allocateSize is large load some sequences in a background thread. * <p> * For example, when inserting a bean with a cascade on a OneToMany with many * beans Ebean can call this to ensure . * </p> */ public void preAllocateIds(int allocateSize) { if (batchSize > 1 && allocateSize > batchSize) { // only bother if allocateSize is bigger than // the normal loading batchSize if (allocateSize > 100) { // max out at 100 for now allocateSize = 100; } loadLargeAllocation(allocateSize); } }
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; } }); } }