public void clear() { chunkCount = 0; firstChunk = lastChunk = null; budgetCtrl.reserve(this, 0); }
private CuboidResult buildCuboid(CuboidResult parent, long cuboidId) throws IOException { final String consumerName = "AggrCache@Cuboid " + cuboidId; MemoryBudgetController.MemoryConsumer consumer = new MemoryBudgetController.MemoryConsumer() { @Override public int freeUp(int mb) { return 0; // cannot free up on demand } @Override public String toString() { return consumerName; } }; // reserve memory for aggregation cache, can't be larger than the parent memBudget.reserveInsist(consumer, parent.aggrCacheMB); try { return aggregateCuboid(parent, cuboidId); } finally { memBudget.reserve(consumer, 0); } }
private CuboidResult buildCuboid(CuboidResult parent, long cuboidId) throws IOException { final String consumerName = "AggrCache@Cuboid " + cuboidId; MemoryBudgetController.MemoryConsumer consumer = new MemoryBudgetController.MemoryConsumer() { @Override public int freeUp(int mb) { return 0; // cannot free up on demand } @Override public String toString() { return consumerName; } }; // reserve memory for aggregation cache, can't be larger than the parent memBudget.reserveInsist(consumer, parent.aggrCacheMB); try { return aggregateCuboid(parent, cuboidId); } finally { memBudget.reserve(consumer, 0); } }
Consumer(MemoryBudgetController mbc) { mbc.reserve(this, 1); data = new byte[MemoryBudgetController.ONE_MB - 24]; // 24 is object shell of this + object shell of data + reference of data }
@Override public void run() { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } mbc.reserve(a, 0); } }.start();
private CuboidResult buildCuboid(CuboidResult parent, long cuboidId) throws IOException { final String consumerName = "AggrCache@Cuboid " + cuboidId; MemoryBudgetController.MemoryConsumer consumer = new MemoryBudgetController.MemoryConsumer() { @Override public int freeUp(int mb) { return 0; // cannot free up on demand } @Override public String toString() { return consumerName; } }; // reserve memory for aggregation cache, can't be larger than the parent memBudget.reserveInsist(consumer, parent.aggrCacheMB); try { return aggregateCuboid(parent, cuboidId); } finally { memBudget.reserve(consumer, 0); } }
public void reserveInsist(MemoryConsumer consumer, int requestMB) { if (requestMB > totalBudgetMB) throw new NotEnoughBudgetException(); long waitStart = 0; while (true) { try { reserve(consumer, requestMB); if (debug && waitStart > 0) logger.debug(consumer + " waited " + (System.currentTimeMillis() - waitStart) + " ms on the " + requestMB + " MB request"); return; } catch (NotEnoughBudgetException ex) { // retry } if (waitStart == 0) waitStart = System.currentTimeMillis(); synchronized (lock) { try { lock.wait(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new NotEnoughBudgetException(e); } } } }
private CuboidResult buildCuboid(CuboidResult parent, long cuboidId) throws IOException { final String consumerName = "AggrCache@Cuboid " + cuboidId; MemoryBudgetController.MemoryConsumer consumer = new MemoryBudgetController.MemoryConsumer() { @Override public int freeUp(int mb) { return 0; // cannot free up on demand } @Override public String toString() { return consumerName; } }; // reserve memory for aggregation cache, can't be larger than the parent memBudget.reserveInsist(consumer, parent.aggrCacheMB); try { return aggregateCuboid(parent, cuboidId); } finally { memBudget.reserve(consumer, 0); } }
budgetCtrl.reserve(this, needMoreMem); } catch (NotEnoughBudgetException ex) { deactivateMemWrite();
public void clear() { chunkCount = 0; firstChunk = lastChunk = null; budgetCtrl.reserve(this, 0); }
public void reserveInsist(MemoryConsumer consumer, int requestMB) { if (requestMB > totalBudgetMB) throw new NotEnoughBudgetException(); long waitStart = 0; while (true) { try { reserve(consumer, requestMB); if (debug && waitStart > 0) logger.debug(consumer + " waited " + (System.currentTimeMillis() - waitStart) + " ms on the " + requestMB + " MB request"); return; } catch (NotEnoughBudgetException ex) { // retry } if (waitStart == 0) waitStart = System.currentTimeMillis(); synchronized (lock) { try { lock.wait(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new NotEnoughBudgetException(e); } } } }
budgetCtrl.reserve(this, needMoreMem); } catch (NotEnoughBudgetException ex) { deactivateMemWrite();