Package org.gearman.common
Class GearmanNIOJobServerConnection
- java.lang.Object
-
- org.gearman.common.GearmanNIOJobServerConnection
-
- All Implemented Interfaces:
GearmanJobServerConnection
,GearmanJobServerIpConnection
public class GearmanNIOJobServerConnection extends Object implements GearmanJobServerIpConnection
-
-
Constructor Summary
Constructors Constructor Description GearmanNIOJobServerConnection(String hostname)
GearmanNIOJobServerConnection(String hostname, int port)
GearmanNIOJobServerConnection(InetSocketAddress remote)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canRead()
Can a read operation be executed at this time.boolean
canWrite()
Can a write operation be executed at this time.void
close()
Closes a connection to the Gearman Job Server.boolean
equals(Object that)
String
getHost()
int
getPort()
Selector
getSelector()
boolean
hasBufferedWriteData()
int
hashCode()
boolean
isOpen()
Is the connection open.void
open()
Open the connection to the Gearman Job Server.GearmanPacket
read()
Reads aGearmanPacket
from the connection with the Gearman Job Server.SelectionKey
registerSelector(Selector s, int mask)
String
toString()
void
write(GearmanPacket request)
Writes aGearmanPacket
into the connection with the Gearman Job Server.
-
-
-
Constructor Detail
-
GearmanNIOJobServerConnection
public GearmanNIOJobServerConnection(String hostname) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
GearmanNIOJobServerConnection
public GearmanNIOJobServerConnection(String hostname, int port) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
GearmanNIOJobServerConnection
public GearmanNIOJobServerConnection(InetSocketAddress remote) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
-
Method Detail
-
open
public void open() throws IOException
Description copied from interface:GearmanJobServerConnection
Open the connection to the Gearman Job Server.- Specified by:
open
in interfaceGearmanJobServerConnection
- Throws:
IOException
- if an I/O exception was encountered.
-
close
public void close()
Description copied from interface:GearmanJobServerConnection
Closes a connection to the Gearman Job Server.- Specified by:
close
in interfaceGearmanJobServerConnection
-
write
public void write(GearmanPacket request) throws IOException
Description copied from interface:GearmanJobServerConnection
Writes aGearmanPacket
into the connection with the Gearman Job Server.- Specified by:
write
in interfaceGearmanJobServerConnection
- Parameters:
request
- The request to be written.- Throws:
IOException
- if an I/O exception was encountered.
-
read
public GearmanPacket read() throws IOException
Description copied from interface:GearmanJobServerConnection
Reads aGearmanPacket
from the connection with the Gearman Job Server.- Specified by:
read
in interfaceGearmanJobServerConnection
- Returns:
- the GearmanPacket read from the connection.
- Throws:
IOException
- if an I/O exception was encountered.
-
registerSelector
public SelectionKey registerSelector(Selector s, int mask) throws IOException
- Throws:
IOException
-
canRead
public boolean canRead()
Description copied from interface:GearmanJobServerConnection
Can a read operation be executed at this time.- Specified by:
canRead
in interfaceGearmanJobServerConnection
- Returns:
- true if a read can be executed, else returns false.
-
canWrite
public boolean canWrite()
Description copied from interface:GearmanJobServerConnection
Can a write operation be executed at this time.- Specified by:
canWrite
in interfaceGearmanJobServerConnection
- Returns:
- true if a write can be executed, else returns false.
-
hasBufferedWriteData
public boolean hasBufferedWriteData()
-
getSelector
public Selector getSelector()
-
isOpen
public boolean isOpen()
Description copied from interface:GearmanJobServerConnection
Is the connection open.- Specified by:
isOpen
in interfaceGearmanJobServerConnection
- Returns:
- true if the connection is open, else false.
-
getHost
public String getHost()
- Specified by:
getHost
in interfaceGearmanJobServerIpConnection
- Returns:
- The host-name or address of the Gearman Job Server
-
getPort
public int getPort()
- Specified by:
getPort
in interfaceGearmanJobServerIpConnection
- Returns:
- The port used to connect to the Gearman Job Server
-
-