public boolean isFull(int highWaterMark) { if (parent != null && parent.isFull(highWaterMark)) { return true; } usageLock.writeLock().lock(); try { percentUsage = caclPercentUsage(); return percentUsage >= highWaterMark; } finally { usageLock.writeLock().unlock(); } }
/** * Sets the minimum number of percentage points the usage has to change before a UsageListener event is fired by the * manager. * * @param percentUsageMinDelta * @org.apache.xbean.Property propertyEditor="org.apache.activemq.util.MemoryPropertyEditor" */ public void setPercentUsageMinDelta(int percentUsageMinDelta) { if (percentUsageMinDelta < 1) { throw new IllegalArgumentException("percentUsageMinDelta must be greater than 0"); } usageLock.writeLock().lock(); try { this.percentUsageMinDelta = percentUsageMinDelta; setPercentUsage(caclPercentUsage()); } finally { usageLock.writeLock().unlock(); } }
percentUsage = caclPercentUsage(); if (percentUsage >= highWaterMark) { long deadline = timeout > 0 ? System.currentTimeMillis() + timeout : Long.MAX_VALUE; long timeleft = deadline; while (timeleft > 0) { percentUsage = caclPercentUsage(); if (percentUsage >= highWaterMark) { waitForSpaceCondition.await(pollingTime, TimeUnit.MILLISECONDS);
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(); } }
public boolean isFull(int highWaterMark) { if (parent != null && parent.isFull(highWaterMark)) { return true; } usageLock.writeLock().lock(); try { percentUsage = caclPercentUsage(); return percentUsage >= highWaterMark; } finally { usageLock.writeLock().unlock(); } }
public boolean isFull(int highWaterMark) { if (parent != null && parent.isFull(highWaterMark)) { return true; } usageLock.writeLock().lock(); try { percentUsage = caclPercentUsage(); return percentUsage >= highWaterMark; } finally { usageLock.writeLock().unlock(); } }
public boolean isFull(int highWaterMark) { if (parent != null && parent.isFull(highWaterMark)) { return true; } synchronized (usageMutex) { percentUsage=caclPercentUsage(); return percentUsage >= highWaterMark; } }
public boolean isFull(int highWaterMark) { if (parent != null && parent.isFull(highWaterMark)) { return true; } usageLock.writeLock().lock(); try { percentUsage = caclPercentUsage(); return percentUsage >= highWaterMark; } finally { usageLock.writeLock().unlock(); } }
/** * Sets the minimum number of percentage points the usage has to change before a UsageListener event is fired by the * manager. * * @param percentUsageMinDelta * @org.apache.xbean.Property propertyEditor="org.apache.activemq.util.MemoryPropertyEditor" */ public void setPercentUsageMinDelta(int percentUsageMinDelta) { if (percentUsageMinDelta < 1) { throw new IllegalArgumentException("percentUsageMinDelta must be greater than 0"); } usageLock.writeLock().lock(); try { this.percentUsageMinDelta = percentUsageMinDelta; setPercentUsage(caclPercentUsage()); } finally { usageLock.writeLock().unlock(); } }
/** * Sets the minimum number of percentage points the usage has to change * before a UsageListener event is fired by the manager. * * @param percentUsageMinDelta * @org.apache.xbean.Property propertyEditor="org.apache.activemq.util.MemoryPropertyEditor" */ public void setPercentUsageMinDelta(int percentUsageMinDelta) { if (percentUsageMinDelta < 1) { throw new IllegalArgumentException("percentUsageMinDelta must be greater than 0"); } int percentUsage; synchronized (usageMutex) { this.percentUsageMinDelta = percentUsageMinDelta; percentUsage = caclPercentUsage(); } setPercentUsage(percentUsage); }
/** * @param timeout * @throws InterruptedException * @return true if space */ public boolean waitForSpace(long timeout, int highWaterMark) throws InterruptedException { if (parent != null) { if (!parent.waitForSpace(timeout, highWaterMark)) { return false; } } synchronized (usageMutex) { percentUsage=caclPercentUsage(); if (percentUsage >= highWaterMark) { long deadline = timeout > 0 ? System.currentTimeMillis() + timeout : Long.MAX_VALUE; long timeleft = deadline; while (timeleft > 0) { percentUsage=caclPercentUsage(); if (percentUsage >= highWaterMark) { usageMutex.wait(pollingTime); timeleft = deadline - System.currentTimeMillis(); } else { break; } } } return percentUsage < highWaterMark; } }
/** * Sets the minimum number of percentage points the usage has to change before a UsageListener event is fired by the * manager. * * @param percentUsageMinDelta * @org.apache.xbean.Property propertyEditor="org.apache.activemq.util.MemoryPropertyEditor" */ public void setPercentUsageMinDelta(int percentUsageMinDelta) { if (percentUsageMinDelta < 1) { throw new IllegalArgumentException("percentUsageMinDelta must be greater than 0"); } usageLock.writeLock().lock(); try { this.percentUsageMinDelta = percentUsageMinDelta; setPercentUsage(caclPercentUsage()); } finally { usageLock.writeLock().unlock(); } }
/** * Sets the minimum number of percentage points the usage has to change before a UsageListener event is fired by the * manager. * * @param percentUsageMinDelta * @org.apache.xbean.Property propertyEditor="org.apache.activemq.util.MemoryPropertyEditor" */ public void setPercentUsageMinDelta(int percentUsageMinDelta) { if (percentUsageMinDelta < 1) { throw new IllegalArgumentException("percentUsageMinDelta must be greater than 0"); } usageLock.writeLock().lock(); try { this.percentUsageMinDelta = percentUsageMinDelta; setPercentUsage(caclPercentUsage()); } finally { usageLock.writeLock().unlock(); } }
percentUsage = caclPercentUsage(); if (percentUsage >= highWaterMark) { long deadline = timeout > 0 ? System.currentTimeMillis() + timeout : Long.MAX_VALUE; long timeleft = deadline; while (timeleft > 0) { percentUsage = caclPercentUsage(); if (percentUsage >= highWaterMark) { waitForSpaceCondition.await(pollingTime, TimeUnit.MILLISECONDS);
percentUsage = caclPercentUsage(); if (percentUsage >= highWaterMark) { long deadline = timeout > 0 ? System.currentTimeMillis() + timeout : Long.MAX_VALUE; long timeleft = deadline; while (timeleft > 0) { percentUsage = caclPercentUsage(); if (percentUsage >= highWaterMark) { waitForSpaceCondition.await(pollingTime, TimeUnit.MILLISECONDS);
percentUsage = caclPercentUsage(); if (percentUsage >= highWaterMark) { long deadline = timeout > 0 ? System.currentTimeMillis() + timeout : Long.MAX_VALUE; long timeleft = deadline; while (timeleft > 0) { percentUsage = caclPercentUsage(); if (percentUsage >= highWaterMark) { waitForSpaceCondition.await(pollingTime, TimeUnit.MILLISECONDS);
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(); } }