@Override @SuppressWarnings("unchecked") public void start() { if (started.compareAndSet(false, true)) { if (parent != null) { parent.addChild(this); if (getLimit() > parent.getLimit()) { LOG.info("Usage({}) limit={} should be smaller than its parent limit={}", new Object[] { getName(), getLimit(), parent.getLimit() }); } } for (T t : children) { t.start(); } } }
public Usage(T parent, String name, float portion) { this.parent = parent; this.usagePortion = portion; if (parent != null) { this.limiter.setLimit((long) (parent.getLimit() * (double)portion)); name = parent.name + ":" + name; } this.name = name; }
protected void onLimitChange() { // We may need to calculate the limit if (usagePortion > 0 && parent != null) { usageLock.writeLock().lock(); try { this.limiter.setLimit((long) (parent.getLimit() * (double) usagePortion)); } finally { usageLock.writeLock().unlock(); } } // Reset the percent currently being used. usageLock.writeLock().lock(); try { setPercentUsage(caclPercentUsage()); } finally { usageLock.writeLock().unlock(); } // Let the children know that the limit has changed. They may need to // set their limits based on ours. for (T child : children) { child.onLimitChange(); } }
@Override @SuppressWarnings("unchecked") public void start() { if (started.compareAndSet(false, true)) { if (parent != null) { parent.addChild(this); if (getLimit() > parent.getLimit()) { LOG.info("Usage({}) limit={} should be smaller than its parent limit={}", new Object[] { getName(), getLimit(), parent.getLimit() }); } } for (T t : children) { t.start(); } } }
@Override @SuppressWarnings("unchecked") public void start() { if (started.compareAndSet(false, true)) { if (parent != null) { parent.addChild(this); if (getLimit() > parent.getLimit()) { LOG.info("Usage({}) limit={} should be smaller than its parent limit={}", new Object[] { getName(), getLimit(), parent.getLimit() }); } } for (T t : children) { t.start(); } } }
public Usage(T parent, String name, float portion) { this.parent = parent; this.usagePortion = portion; if (parent != null) { this.limiter.setLimit((long) (parent.getLimit() * (double)portion)); name = parent.name + ":" + name; } this.name = name; }
@Override @SuppressWarnings("unchecked") public void start() { if (started.compareAndSet(false, true)) { if (parent != null) { parent.addChild(this); if (getLimit() > parent.getLimit()) { LOG.info("Usage({}) limit={} should be smaller than its parent limit={}", new Object[] { getName(), getLimit(), parent.getLimit() }); } } for (T t : children) { t.start(); } } }
public Usage(T parent, String name, float portion) { this.parent = parent; this.usagePortion = portion; if (parent != null) { this.limiter.setLimit((long) (parent.getLimit() * (double)portion)); name = parent.name + ":" + name; } this.name = name; }
public Usage(T parent, String name, float portion) { this.parent = parent; this.usagePortion = portion; if (parent != null) { this.limiter.setLimit((long) (parent.getLimit() * (double)portion)); name = parent.name + ":" + name; } this.name = name; }
public Usage(T parent, String name, float portion) { this.parent = parent; this.usagePortion = portion; if (parent != null) { this.limiter.setLimit((long)(parent.getLimit() * portion)); name = parent.name + ":" + name; } this.name = name; }
protected void onLimitChange() { // We may need to calculate the limit if (usagePortion > 0 && parent != null) { usageLock.writeLock().lock(); try { this.limiter.setLimit((long) (parent.getLimit() * (double) usagePortion)); } finally { usageLock.writeLock().unlock(); } } // Reset the percent currently being used. usageLock.writeLock().lock(); try { setPercentUsage(caclPercentUsage()); } finally { usageLock.writeLock().unlock(); } // Let the children know that the limit has changed. They may need to // set their limits based on ours. for (T child : children) { child.onLimitChange(); } }
protected void onLimitChange() { // We may need to calculate the limit if (usagePortion > 0 && parent != null) { usageLock.writeLock().lock(); try { this.limiter.setLimit((long) (parent.getLimit() * (double) usagePortion)); } finally { usageLock.writeLock().unlock(); } } // Reset the percent currently being used. usageLock.writeLock().lock(); try { setPercentUsage(caclPercentUsage()); } finally { usageLock.writeLock().unlock(); } // Let the children know that the limit has changed. They may need to // set their limits based on ours. for (T child : children) { child.onLimitChange(); } }
protected void onLimitChange() { // We may need to calculate the limit if (usagePortion > 0 && parent != null) { usageLock.writeLock().lock(); try { this.limiter.setLimit((long) (parent.getLimit() * (double) usagePortion)); } finally { usageLock.writeLock().unlock(); } } // Reset the percent currently being used. usageLock.writeLock().lock(); try { setPercentUsage(caclPercentUsage()); } finally { usageLock.writeLock().unlock(); } // Let the children know that the limit has changed. They may need to // set their limits based on ours. for (T child : children) { child.onLimitChange(); } }
protected void onLimitChange() { // We may need to calculate the limit if (usagePortion > 0 && parent != null) { synchronized (usageMutex) { this.limiter.setLimit((long)(parent.getLimit() * usagePortion)); } } // Reset the percent currently being used. int percentUsage; synchronized (usageMutex) { percentUsage = caclPercentUsage(); } setPercentUsage(percentUsage); // Let the children know that the limit has changed. They may need to // set // their limits based on ours. for (T child : children) { child.onLimitChange(); } }