Class ProxyCore
java.lang.Object
uk.ac.manchester.spinnaker.alloc.proxy.ProxyCore
- All Implemented Interfaces:
- AutoCloseable
The main proxy class for a particular web socket session. It's bound to a
 job, which should be running at the time that the web socket is opened.
- Author:
- Donal Fellows
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()protected ByteBuffercloseChannel(ByteBuffer message) Close a channel in response to aProxyOp.CLOSEmessage.final voidhandleClientMessage(ByteBuffer message) Handle a message sent to this service on the web socket associated with this object.protected ByteBufferopenConnectedChannel(ByteBuffer message) Open a connected channel in response to aProxyOp.OPENmessage.protected ByteBufferopenUnconnectedChannel(ByteBuffer message) Open an unconnected channel in response to aProxyOp.OPEN_UNCONNECTEDmessage.protected ByteBuffersendMessage(ByteBuffer message) Send a message on a channel in response to aProxyOp.MESSAGEmessage.protected ByteBuffersendMessageTo(ByteBuffer message) Send a message to a particular destination on a channel in response to aProxyOp.MESSAGE_TOmessage.
- 
Method Details- 
handleClientMessageHandle a message sent to this service on the web socket associated with this object.- Parameters:
- message- The content of the message.
- Throws:
- IOException- Not expected; implementations don't actually throw
 
- 
openConnectedChannelOpen a connected channel in response to aProxyOp.OPENmessage. Note that no control over the local (to the service) port number or address is provided, nor is a mechanism given to easily make available what address is used (though it can be obtained from the IPTag).- Parameters:
- message- The message received. The initial 4-byte type code will have been already read out of the buffer.
- Returns:
- The response message to send, in the bytes leading up to the
         position. The caller will flip the
         message. Underlying failures that are not due to outright
         protocol abuse will be reported to users as a
         ProxyOp.ERRORmessage.
- Throws:
- IllegalArgumentException- If insufficient or too many arguments are supplied.
 
- 
openUnconnectedChannelOpen an unconnected channel in response to aProxyOp.OPEN_UNCONNECTEDmessage. Note that no control over the local (to the service) port number or address is provided, but the IP address and port opened are in the return message.- Parameters:
- message- The message received. The initial 4-byte type code will have been already read out of the buffer.
- Returns:
- The response message to send, in the bytes leading up to the
         position. The caller will flip the
         message. Underlying failures that are not due to outright
         protocol abuse will be reported to users as a
         ProxyOp.ERRORmessage.
- Throws:
- IllegalArgumentException- If insufficient or too many arguments are supplied.
 
- 
closeChannelClose a channel in response to aProxyOp.CLOSEmessage. It's not an error to close a channel twice- Parameters:
- message- The message received. The initial 4-byte type code will have been already read out of the buffer.
- Returns:
- The response message to send, in the bytes leading up to the
         position. The caller will flip the
         message. Underlying failures that are not due to outright
         protocol abuse will be reported to users as a
         ProxyOp.ERRORmessage.
- Throws:
- IllegalArgumentException- If insufficient or too many arguments are supplied.
 
- 
sendMessageSend a message on a channel in response to aProxyOp.MESSAGEmessage. It's not an error to send on a non-existant or closed channel.- Parameters:
- message- The message received. The initial 4-byte type code will have been already read out of the buffer.
- Returns:
- The response message to send, in the bytes leading up to the
         position. The caller will flip the
         message. If null, no response will be sent (expected case for this operation!)
- Throws:
- IOException- If the proxy connection can't be used.
 
- 
sendMessageToSend a message to a particular destination on a channel in response to aProxyOp.MESSAGE_TOmessage. It's not an error to send on a non-existent or closed channel. It is an error to use this operation on a channel that has a bound remote host address.- Parameters:
- message- The message received. The initial 4-byte type code will have been already read out of the buffer.
- Returns:
- The response message to send, in the bytes leading up to the
         position. The caller will flip the
         message. If null, no response will be sent (expected case for this operation!)
- Throws:
- IOException- If the proxy connection can't be used.
- IllegalArgumentException- If the target doesn't exist in the job, the port number is out of range, or the channel has a bound address.
 
- 
closepublic void close()- Specified by:
- closein interface- AutoCloseable
 
 
-