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 long getLimit() { usageLock.readLock().lock(); try { return limiter.getLimit(); } finally { usageLock.readLock().unlock(); } }
/** * Sets the memory limit in bytes. Setting the limit in bytes will set the usagePortion to 0 since the UsageManager * is not going to be portion based off the parent. When set using Xbean, values of the form "20 Mb", "1024kb", and * "1g" can be used * * @org.apache.xbean.Property propertyEditor="org.apache.activemq.util.MemoryPropertyEditor" */ public void setLimit(long limit) { if (percentUsageMinDelta < 0) { throw new IllegalArgumentException("percentUsageMinDelta must be greater or equal to 0"); } usageLock.writeLock().lock(); try { this.limiter.setLimit(limit); this.usagePortion = 0; } finally { usageLock.writeLock().unlock(); } onLimitChange(); }
@Override public String toString() { return "Usage(" + getName() + ") percentUsage=" + percentUsage + "%, usage=" + retrieveUsage() + ", limit=" + limiter.getLimit() + ", percentUsageMinDelta=" + percentUsageMinDelta + "%" + (parent != null ? ";Parent:" + parent.toString() : ""); }
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 long getLimit() { synchronized (usageMutex) { return limiter.getLimit(); } }
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() * (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; }
/** * Sets the memory limit in bytes. Setting the limit in bytes will set the * usagePortion to 0 since the UsageManager is not going to be portion based * off the parent. * When set using Xbean, values of the form "20 Mb", "1024kb", and "1g" can be used * * @org.apache.xbean.Property propertyEditor="org.apache.activemq.util.MemoryPropertyEditor" */ public void setLimit(long limit) { if (percentUsageMinDelta < 0) { throw new IllegalArgumentException("percentUsageMinDelta must be greater or equal to 0"); } synchronized (usageMutex) { this.limiter.setLimit(limit); this.usagePortion = 0; } onLimitChange(); }