Minor refactoring
git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_dev_next@1007 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-net/src/main/java/edu/uci/ics/hyracks/net/protocols/muxdemux/MultiplexedConnection.java b/hyracks-net/src/main/java/edu/uci/ics/hyracks/net/protocols/muxdemux/MultiplexedConnection.java
index be81ab2..5615525 100644
--- a/hyracks-net/src/main/java/edu/uci/ics/hyracks/net/protocols/muxdemux/MultiplexedConnection.java
+++ b/hyracks-net/src/main/java/edu/uci/ics/hyracks/net/protocols/muxdemux/MultiplexedConnection.java
@@ -263,6 +263,12 @@
pendingReadSize = 0;
ccb = null;
}
+
+ private ChannelControlBlock getCCBInCommand() {
+ synchronized (MultiplexedConnection.this) {
+ return cSet.getCCB(command.getChannelId());
+ }
+ }
}
void driveReaderStateMachine() throws IOException, NetException {
@@ -286,16 +292,12 @@
ChannelControlBlock ccb = null;
switch (readerState.command.getCommandType()) {
case ADD_CREDITS: {
- synchronized (MultiplexedConnection.this) {
- ccb = cSet.getCCB(readerState.command.getChannelId());
- }
+ ccb = readerState.getCCBInCommand();
ccb.addWriteCredits(readerState.command.getData());
break;
}
case CLOSE_CHANNEL: {
- synchronized (MultiplexedConnection.this) {
- ccb = cSet.getCCB(readerState.command.getChannelId());
- }
+ ccb = readerState.getCCBInCommand();
ccb.reportRemoteEOS();
int channelId = ccb.getChannelId();
cSet.markEOSAck(channelId);
@@ -303,24 +305,18 @@
break;
}
case CLOSE_CHANNEL_ACK: {
- synchronized (MultiplexedConnection.this) {
- ccb = cSet.getCCB(readerState.command.getChannelId());
- }
+ ccb = readerState.getCCBInCommand();
ccb.reportLocalEOSAck();
break;
}
case DATA: {
- synchronized (MultiplexedConnection.this) {
- ccb = cSet.getCCB(readerState.command.getChannelId());
- }
+ ccb = readerState.getCCBInCommand();
readerState.pendingReadSize = readerState.command.getData();
readerState.ccb = ccb;
break;
}
case ERROR: {
- synchronized (MultiplexedConnection.this) {
- ccb = cSet.getCCB(readerState.command.getChannelId());
- }
+ ccb = readerState.getCCBInCommand();
ccb.reportRemoteError(readerState.command.getData());
int channelId = ccb.getChannelId();
cSet.markEOSAck(channelId);