forked from nathanmarz/storm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use ControlMessage instead of previous TaskMessage hack
- Loading branch information
Showing
12 changed files
with
130 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
storm-netty/src/jvm/backtype/storm/messaging/netty/ControlMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package backtype.storm.messaging.netty; | ||
|
||
class ControlMessage { | ||
static final short BASE_CODE = -100; | ||
static final short OK = -200; //HTTP status: 200 | ||
static final short EOB = -201; //end of a batch | ||
static final short FAILURE = -400; //HTTP status: 400 BAD REQUEST | ||
static final short CLOSE = -410; //HTTP status: 410 GONE | ||
|
||
static final ControlMessage CLOSE_MESSAGE = new ControlMessage(CLOSE); | ||
static final ControlMessage EOB_MESSAGE = new ControlMessage(EOB); | ||
static final ControlMessage OK_RESPONSE = new ControlMessage(OK); | ||
static final ControlMessage FAILURE_RESPONSE = new ControlMessage(FAILURE); | ||
|
||
private short code; | ||
|
||
ControlMessage() { | ||
code = OK; | ||
} | ||
|
||
ControlMessage(short code) { | ||
assert(code<BASE_CODE); | ||
this.code = code; | ||
} | ||
|
||
short code() { | ||
return code; | ||
} | ||
|
||
public String toString() { | ||
switch (code) { | ||
case OK: return "OK"; | ||
case EOB: return "END_OF_BATCH"; | ||
case FAILURE: return "FAILURE"; | ||
case CLOSE: return "CLOSE"; | ||
default: return "control message w/ code " + code; | ||
} | ||
} | ||
|
||
public boolean equals(Object obj) { | ||
if (obj == null) return false; | ||
if (obj instanceof ControlMessage) | ||
return ((ControlMessage)obj).code == code; | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.