Renamed LimitRead/Write to Read/WriteLimit

This commit is contained in:
Trustin Lee 2009-04-12 06:55:52 +00:00
parent 4d88c5348a
commit 7376367973

View File

@ -52,12 +52,12 @@ public abstract class TrafficCounterFactory {
/** /**
* Limit in B/s to apply to write for all channel TrafficCounter * Limit in B/s to apply to write for all channel TrafficCounter
*/ */
private long channelLimitWrite = 0; private long channelWriteLimit = 0;
/** /**
* Limit in B/s to apply to read for all channel TrafficCounter * Limit in B/s to apply to read for all channel TrafficCounter
*/ */
private long channelLimitRead = 0; private long channelReadLimit = 0;
/** /**
* Delay between two performance snapshots for channel * Delay between two performance snapshots for channel
@ -72,12 +72,12 @@ public abstract class TrafficCounterFactory {
/** /**
* Limit in B/s to apply to write for the global TrafficCounter * Limit in B/s to apply to write for the global TrafficCounter
*/ */
private long globalLimitWrite = 0; private long globalWriteLimit = 0;
/** /**
* Limit in B/s to apply to read for the global TrafficCounter * Limit in B/s to apply to read for the global TrafficCounter
*/ */
private long globalLimitRead = 0; private long globalReadLimit = 0;
/** /**
* Delay between two performance snapshots for global * Delay between two performance snapshots for global
@ -107,28 +107,28 @@ public abstract class TrafficCounterFactory {
* *
* @param newexecutorService * @param newexecutorService
* @param newChannelActive * @param newChannelActive
* @param newChannelLimitWrite * @param newChannelWriteLimit
* @param newChannelLimitRead * @param newChannelReadLimit
* @param newChannelDelay * @param newChannelDelay
* @param newGlobalActive * @param newGlobalActive
* @param newGlobalLimitWrite * @param newGlobalWriteLimit
* @param newGlobalLimitRead * @param newGlobalReadLimit
* @param newGlobalDelay * @param newGlobalDelay
*/ */
private void init(ExecutorService newexecutorService, private void init(ExecutorService newexecutorService,
boolean newChannelActive, long newChannelLimitWrite, boolean newChannelActive, long newChannelWriteLimit,
long newChannelLimitRead, long newChannelDelay, long newChannelReadLimit, long newChannelDelay,
boolean newGlobalActive, long newGlobalLimitWrite, boolean newGlobalActive, long newGlobalWriteLimit,
long newGlobalLimitRead, long newGlobalDelay) { long newGlobalReadLimit, long newGlobalDelay) {
this.executorService = newexecutorService; executorService = newexecutorService;
this.channelActive = newChannelActive; channelActive = newChannelActive;
this.channelLimitWrite = newChannelLimitWrite; channelWriteLimit = newChannelWriteLimit;
this.channelLimitRead = newChannelLimitRead; channelReadLimit = newChannelReadLimit;
this.channelDelay = newChannelDelay; channelDelay = newChannelDelay;
this.globalActive = newGlobalActive; globalActive = newGlobalActive;
this.globalLimitWrite = newGlobalLimitWrite; globalWriteLimit = newGlobalWriteLimit;
this.globalLimitRead = newGlobalLimitRead; globalReadLimit = newGlobalReadLimit;
this.globalDelay = newGlobalDelay; globalDelay = newGlobalDelay;
} }
/** /**
@ -138,30 +138,30 @@ public abstract class TrafficCounterFactory {
* created for instance like Executors.newCachedThreadPool * created for instance like Executors.newCachedThreadPool
* @param channelActive * @param channelActive
* True if each channel will have a TrafficCounter * True if each channel will have a TrafficCounter
* @param channelLimitWrite * @param channelWriteLimit
* NO_LIMIT or a limit in bytes/s * NO_LIMIT or a limit in bytes/s
* @param channelLimitRead * @param channelReadLimit
* NO_LIMIT or a limit in bytes/s * NO_LIMIT or a limit in bytes/s
* @param channelDelay * @param channelDelay
* The delay between two computations of performances for * The delay between two computations of performances for
* channels or NO_STAT if no stats are to be computed * channels or NO_STAT if no stats are to be computed
* @param globalActive * @param globalActive
* True if global context will have one unique TrafficCounter * True if global context will have one unique TrafficCounter
* @param globalLimitWrite * @param globalWriteLimit
* NO_LIMIT or a limit in bytes/s * NO_LIMIT or a limit in bytes/s
* @param globalLimitRead * @param globalReadLimit
* NO_LIMIT or a limit in bytes/s * NO_LIMIT or a limit in bytes/s
* @param globalDelay * @param globalDelay
* The delay between two computations of performances for global * The delay between two computations of performances for global
* context or NO_STAT if no stats are to be computed * context or NO_STAT if no stats are to be computed
*/ */
public TrafficCounterFactory(ExecutorService executorService, public TrafficCounterFactory(ExecutorService executorService,
boolean channelActive, long channelLimitWrite, boolean channelActive, long channelWriteLimit,
long channelLimitRead, long channelDelay, boolean globalActive, long channelReadLimit, long channelDelay, boolean globalActive,
long globalLimitWrite, long globalLimitRead, long globalDelay) { long globalWriteLimit, long globalReadLimit, long globalDelay) {
init(executorService, channelActive, channelLimitWrite, init(executorService, channelActive, channelWriteLimit,
channelLimitRead, channelDelay, globalActive, globalLimitWrite, channelReadLimit, channelDelay, globalActive, globalWriteLimit,
globalLimitRead, globalDelay); globalReadLimit, globalDelay);
} }
/** /**
@ -171,24 +171,24 @@ public abstract class TrafficCounterFactory {
* created for instance like Executors.newCachedThreadPool * created for instance like Executors.newCachedThreadPool
* @param channelActive * @param channelActive
* True if each channel will have a TrafficCounter * True if each channel will have a TrafficCounter
* @param channelLimitWrite * @param channelWriteLimit
* NO_LIMIT or a limit in bytes/s * NO_LIMIT or a limit in bytes/s
* @param channelLimitRead * @param channelReadLimit
* NO_LIMIT or a limit in bytes/s * NO_LIMIT or a limit in bytes/s
* @param globalActive * @param globalActive
* True if global context will have one unique TrafficCounter * True if global context will have one unique TrafficCounter
* @param globalLimitWrite * @param globalWriteLimit
* NO_LIMIT or a limit in bytes/s * NO_LIMIT or a limit in bytes/s
* @param globalLimitRead * @param globalReadLimit
* NO_LIMIT or a limit in bytes/s * NO_LIMIT or a limit in bytes/s
*/ */
public TrafficCounterFactory(ExecutorService executorService, public TrafficCounterFactory(ExecutorService executorService,
boolean channelActive, long channelLimitWrite, boolean channelActive, long channelWriteLimit,
long channelLimitRead, boolean globalActive, long globalLimitWrite, long channelReadLimit, boolean globalActive, long globalWriteLimit,
long globalLimitRead) { long globalReadLimit) {
init(executorService, channelActive, channelLimitWrite, init(executorService, channelActive, channelWriteLimit,
channelLimitRead, DEFAULT_DELAY, globalActive, channelReadLimit, DEFAULT_DELAY, globalActive,
globalLimitWrite, globalLimitRead, DEFAULT_DELAY); globalWriteLimit, globalReadLimit, DEFAULT_DELAY);
} }
/** /**
@ -200,19 +200,19 @@ public abstract class TrafficCounterFactory {
* True if each channel will have a TrafficCounter * True if each channel will have a TrafficCounter
* @param globalActive * @param globalActive
* True if global context will have one unique TrafficCounter * True if global context will have one unique TrafficCounter
* @param globalLimitWrite * @param globalWriteLimit
* NO_LIMIT or a limit in bytes/s * NO_LIMIT or a limit in bytes/s
* @param globalLimitRead * @param globalReadLimit
* NO_LIMIT or a limit in bytes/s * NO_LIMIT or a limit in bytes/s
* @param globalDelay * @param globalDelay
* The delay between two computations of performances for global * The delay between two computations of performances for global
* context or NO_STAT if no stats are to be computed * context or NO_STAT if no stats are to be computed
*/ */
public TrafficCounterFactory(ExecutorService executorService, public TrafficCounterFactory(ExecutorService executorService,
boolean channelActive, boolean globalActive, long globalLimitWrite, boolean channelActive, boolean globalActive, long globalWriteLimit,
long globalLimitRead, long globalDelay) { long globalReadLimit, long globalDelay) {
init(executorService, channelActive, 0, 0, init(executorService, channelActive, 0, 0,
DEFAULT_DELAY, globalActive, globalLimitWrite, globalLimitRead, DEFAULT_DELAY, globalActive, globalWriteLimit, globalReadLimit,
globalDelay); globalDelay);
} }
@ -225,16 +225,16 @@ public abstract class TrafficCounterFactory {
* True if each channel will have a TrafficCounter * True if each channel will have a TrafficCounter
* @param globalActive * @param globalActive
* True if global context will have one unique TrafficCounter * True if global context will have one unique TrafficCounter
* @param globalLimitWrite * @param globalWriteLimit
* NO_LIMIT or a limit in bytes/s * NO_LIMIT or a limit in bytes/s
* @param globalLimitRead * @param globalReadLimit
* NO_LIMIT or a limit in bytes/s * NO_LIMIT or a limit in bytes/s
*/ */
public TrafficCounterFactory(ExecutorService executorService, public TrafficCounterFactory(ExecutorService executorService,
boolean channelActive, boolean globalActive, long globalLimitWrite, boolean channelActive, boolean globalActive, long globalWriteLimit,
long globalLimitRead) { long globalReadLimit) {
init(executorService, channelActive, 0, 0, init(executorService, channelActive, 0, 0,
DEFAULT_DELAY, globalActive, globalLimitWrite, globalLimitRead, DEFAULT_DELAY, globalActive, globalWriteLimit, globalReadLimit,
DEFAULT_DELAY); DEFAULT_DELAY);
} }
@ -261,7 +261,7 @@ public abstract class TrafficCounterFactory {
* @param active * @param active
*/ */
public void setChannelActive(boolean active) { public void setChannelActive(boolean active) {
this.channelActive = active; channelActive = active;
} }
/** /**
@ -271,12 +271,12 @@ public abstract class TrafficCounterFactory {
* @param active * @param active
*/ */
public void setGlobalActive(boolean active) { public void setGlobalActive(boolean active) {
if (this.globalActive) { if (globalActive) {
if (!active) { if (!active) {
stopGlobalTrafficCounter(); stopGlobalTrafficCounter();
} }
} }
this.globalActive = active; globalActive = active;
getGlobalTrafficCounter(); getGlobalTrafficCounter();
} }
@ -285,26 +285,26 @@ public abstract class TrafficCounterFactory {
* any) is dynamically changed, but Channels TrafficCounters are not * any) is dynamically changed, but Channels TrafficCounters are not
* changed, only new created ones. * changed, only new created ones.
* *
* @param newchannelLimitWrite * @param newchannelWriteLimit
* @param newchannelLimitRead * @param newchannelReadLimit
* @param newchanneldelay * @param newchanneldelay
* @param newglobalLimitWrite * @param newglobalWriteLimit
* @param newglobalLimitRead * @param newglobalReadLimit
* @param newglobaldelay * @param newglobaldelay
*/ */
public void configure(long newchannelLimitWrite, public void configure(long newchannelWriteLimit,
long newchannelLimitRead, long newchanneldelay, long newchannelReadLimit, long newchanneldelay,
long newglobalLimitWrite, long newglobalLimitRead, long newglobalWriteLimit, long newglobalReadLimit,
long newglobaldelay) { long newglobaldelay) {
this.channelLimitWrite = newchannelLimitWrite; channelWriteLimit = newchannelWriteLimit;
this.channelLimitRead = newchannelLimitRead; channelReadLimit = newchannelReadLimit;
this.channelDelay = newchanneldelay; channelDelay = newchanneldelay;
this.globalLimitWrite = newglobalLimitWrite; globalWriteLimit = newglobalWriteLimit;
this.globalLimitRead = newglobalLimitRead; globalReadLimit = newglobalReadLimit;
this.globalDelay = newglobaldelay; globalDelay = newglobaldelay;
if (this.globalTrafficMonitor != null) { if (globalTrafficMonitor != null) {
this.globalTrafficMonitor.configure(null, globalTrafficMonitor.configure(null,
newglobalLimitWrite, newglobalLimitRead, newglobaldelay); newglobalWriteLimit, newglobalReadLimit, newglobaldelay);
} }
} }
@ -312,16 +312,16 @@ public abstract class TrafficCounterFactory {
* @return the Global TrafficCounter or null if this support is disabled * @return the Global TrafficCounter or null if this support is disabled
*/ */
public TrafficCounter getGlobalTrafficCounter() { public TrafficCounter getGlobalTrafficCounter() {
if (this.globalActive) { if (globalActive) {
if (this.globalTrafficMonitor == null) { if (globalTrafficMonitor == null) {
this.globalTrafficMonitor = new TrafficCounter(this, globalTrafficMonitor = new TrafficCounter(this,
this.executorService, null, "GlobalPC", executorService, null, "GlobalPC",
this.globalLimitWrite, this.globalLimitRead, globalWriteLimit, globalReadLimit,
this.globalDelay); globalDelay);
this.globalTrafficMonitor.start(); globalTrafficMonitor.start();
} }
} }
return this.globalTrafficMonitor; return globalTrafficMonitor;
} }
/** /**
@ -330,11 +330,11 @@ public abstract class TrafficCounterFactory {
* disabled * disabled
*/ */
public TrafficCounter createChannelTrafficCounter(Channel channel) { public TrafficCounter createChannelTrafficCounter(Channel channel) {
if (this.channelActive && ((this.channelLimitRead > 0) || (this.channelLimitWrite > 0) if (channelActive && (channelReadLimit > 0 || channelWriteLimit > 0
|| (this.channelDelay > 0))) { || channelDelay > 0)) {
return new TrafficCounter(this, this.executorService, channel, return new TrafficCounter(this, executorService, channel,
"ChannelPC" + channel.getId(), this.channelLimitWrite, "ChannelPC" + channel.getId(), channelWriteLimit,
this.channelLimitRead, this.channelDelay); channelReadLimit, channelDelay);
} }
return null; return null;
} }
@ -345,9 +345,9 @@ public abstract class TrafficCounterFactory {
* *
*/ */
public void stopGlobalTrafficCounter() { public void stopGlobalTrafficCounter() {
if (this.globalTrafficMonitor != null) { if (globalTrafficMonitor != null) {
this.globalTrafficMonitor.stop(); globalTrafficMonitor.stop();
this.globalTrafficMonitor = null; globalTrafficMonitor = null;
} }
} }
@ -355,7 +355,7 @@ public abstract class TrafficCounterFactory {
* @return the channelDelay * @return the channelDelay
*/ */
public long getChannelDelay() { public long getChannelDelay() {
return this.channelDelay; return channelDelay;
} }
/** /**
@ -367,40 +367,40 @@ public abstract class TrafficCounterFactory {
} }
/** /**
* @return the channelLimitRead * @return the channelReadLimit
*/ */
public long getChannelLimitRead() { public long getChannelReadLimit() {
return this.channelLimitRead; return channelReadLimit;
} }
/** /**
* @param channelLimitRead * @param channelReadLimit
* the channelLimitRead to set * the channelReadLimit to set
*/ */
public void setChannelLimitRead(long channelLimitRead) { public void setChannelReadLimit(long channelReadLimit) {
this.channelLimitRead = channelLimitRead; this.channelReadLimit = channelReadLimit;
} }
/** /**
* @return the channelLimitWrite * @return the channelWriteLimit
*/ */
public long getChannelLimitWrite() { public long getChannelWriteLimit() {
return this.channelLimitWrite; return channelWriteLimit;
} }
/** /**
* @param channelLimitWrite * @param channelWriteLimit
* the channelLimitWrite to set * the channelWriteLimit to set
*/ */
public void setChannelLimitWrite(long channelLimitWrite) { public void setChannelWriteLimit(long channelWriteLimit) {
this.channelLimitWrite = channelLimitWrite; this.channelWriteLimit = channelWriteLimit;
} }
/** /**
* @return the globalDelay * @return the globalDelay
*/ */
public long getGlobalDelay() { public long getGlobalDelay() {
return this.globalDelay; return globalDelay;
} }
/** /**
@ -409,50 +409,50 @@ public abstract class TrafficCounterFactory {
*/ */
public void setGlobalDelay(long globalDelay) { public void setGlobalDelay(long globalDelay) {
this.globalDelay = globalDelay; this.globalDelay = globalDelay;
if (this.globalTrafficMonitor != null) { if (globalTrafficMonitor != null) {
this.globalTrafficMonitor.configure(null, globalTrafficMonitor.configure(null,
this.globalLimitWrite, this.globalLimitRead, globalWriteLimit, globalReadLimit,
this.globalDelay); this.globalDelay);
} }
} }
/** /**
* @return the globalLimitRead * @return the globalReadLimit
*/ */
public long getGlobalLimitRead() { public long getGlobalReadLimit() {
return this.globalLimitRead; return globalReadLimit;
} }
/** /**
* @param globalLimitRead * @param globalReadLimit
* the globalLimitRead to set * the globalReadLimit to set
*/ */
public void setGlobalLimitRead(long globalLimitRead) { public void setGlobalReadLimit(long globalReadLimit) {
this.globalLimitRead = globalLimitRead; this.globalReadLimit = globalReadLimit;
if (this.globalTrafficMonitor != null) { if (globalTrafficMonitor != null) {
this.globalTrafficMonitor.configure(null, globalTrafficMonitor.configure(null,
this.globalLimitWrite, this.globalLimitRead, globalWriteLimit, this.globalReadLimit,
this.globalDelay); globalDelay);
} }
} }
/** /**
* @return the globalLimitWrite * @return the globalWriteLimit
*/ */
public long getGlobalLimitWrite() { public long getGlobalWriteLimit() {
return this.globalLimitWrite; return globalWriteLimit;
} }
/** /**
* @param globalLimitWrite * @param globalWriteLimit
* the globalLimitWrite to set * the globalWriteLimit to set
*/ */
public void setGlobalLimitWrite(long globalLimitWrite) { public void setGlobalWriteLimit(long globalWriteLimit) {
this.globalLimitWrite = globalLimitWrite; this.globalWriteLimit = globalWriteLimit;
if (this.globalTrafficMonitor != null) { if (globalTrafficMonitor != null) {
this.globalTrafficMonitor.configure(null, globalTrafficMonitor.configure(null,
this.globalLimitWrite, this.globalLimitRead, this.globalWriteLimit, globalReadLimit,
this.globalDelay); globalDelay);
} }
} }
@ -460,14 +460,14 @@ public abstract class TrafficCounterFactory {
* @return the channelActive * @return the channelActive
*/ */
public boolean isChannelActive() { public boolean isChannelActive() {
return this.channelActive; return channelActive;
} }
/** /**
* @return the globalActive * @return the globalActive
*/ */
public boolean isGlobalActive() { public boolean isGlobalActive() {
return this.globalActive; return globalActive;
} }
} }