Skip to content

Commit

Permalink
Check for illegal condition max_bytes < frag_size
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed May 9, 2012
1 parent f5d02e2 commit 17620db
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/org/jgroups/protocols/RATE_LIMITER.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class RATE_LIMITER extends Protocol {

protected long total_block_time=0L; // ns

protected int frag_size=0;

protected volatile boolean running=true;

public long getMaxBytes() {
Expand Down Expand Up @@ -85,6 +87,8 @@ public void init() throws Exception {

public void start() throws Exception {
super.start();
if(max_bytes < frag_size)
throw new IllegalStateException("max_bytes (" + max_bytes + ") need to be bigger than frag_size (" + frag_size + ")");
running=true;
}

Expand Down Expand Up @@ -136,8 +140,10 @@ public Object down(Event evt) {

if(evt.getType() == Event.CONFIG) {
Map<String,Object> map=(Map<String, Object>)evt.getArg();
Integer frag_size=map != null? (Integer)map.get("frag_size") : null;
if(frag_size != null) {
Integer tmp=map != null? (Integer)map.get("frag_size") : null;
if(tmp != null)
frag_size=tmp.intValue();
if(frag_size > 0) {
if(max_bytes % frag_size != 0) {
if(log.isWarnEnabled())
log.warn("For optimal performance, max_bytes (" + max_bytes +
Expand Down

0 comments on commit 17620db

Please sign in to comment.