public class GridHadoopExternalCommunication extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
GridHadoopExternalCommunication.ProcessHandshakeMessage
Process ID message.
|
| Modifier and Type | Field and Description |
|---|---|
static long |
DFLT_CONN_TIMEOUT
Default connection timeout (value is 1000ms).
|
static long |
DFLT_MAX_CONN_TIMEOUT
Default Maximum connection timeout (value is 600,000ms).
|
static int |
DFLT_MSG_QUEUE_LIMIT
Default message queue limit per connection (for incoming and outgoing .
|
static int |
DFLT_PORT
Default port which node sets listener to (value is 47100).
|
static int |
DFLT_PORT_RANGE
Default local port range (value is 100).
|
static int |
DFLT_RECONNECT_CNT
Default reconnect attempts count (value is 10).
|
static int |
DFLT_SELECTORS_CNT
Default count of selectors for TCP server equals to
"Math.min(4, Runtime.getRuntime().availableProcessors())". |
static boolean |
DFLT_TCP_NODELAY
Default value for
TCP_NODELAY socket option (value is true). |
static String |
OUT_OF_RESOURCES_TCP_MSG
IPC error message.
|
| Constructor and Description |
|---|
GridHadoopExternalCommunication(UUID parentNodeId,
UUID procId,
org.gridgain.grid.marshaller.GridMarshaller marsh,
org.gridgain.grid.logger.GridLogger log,
ExecutorService execSvc,
String gridName) |
| Modifier and Type | Method and Description |
|---|---|
protected GridHadoopCommunicationClient |
createNioClient(GridHadoopProcessDescriptor desc) |
protected GridHadoopCommunicationClient |
createShmemClient(GridHadoopProcessDescriptor desc,
int port) |
protected GridHadoopCommunicationClient |
createTcpClient(GridHadoopProcessDescriptor desc)
Establish TCP connection to remote hadoop process and returns client.
|
long |
getConnectTimeout() |
int |
getLocalPort()
Gets local port for socket binding.
|
int |
getLocalPortRange() |
long |
getMaxConnectTimeout()
Gets maximum connection timeout.
|
int |
getMessageQueueLimit() |
int |
getOutboundMessagesQueueSize() |
int |
getReconnectCount() |
int |
getSelectorsCount() |
int |
getSharedMemoryPort()
Gets shared memory port to accept incoming connections.
|
int |
getSocketReceiveBuffer() |
int |
getSocketSendBuffer() |
boolean |
isDirectBuffer() |
boolean |
isTcpNoDelay() |
GridHadoopProcessDescriptor |
localProcessDescriptor()
Gets local process descriptor.
|
protected void |
notifyListener(GridHadoopProcessDescriptor desc,
GridHadoopMessage msg) |
void |
sendMessage(GridHadoopProcessDescriptor desc,
GridHadoopMessage msg) |
void |
setConnectTimeout(long connTimeout)
Sets connect timeout used when establishing connection
with remote nodes.
|
void |
setDirectBuffer(boolean directBuf)
Sets flag to allocate direct or heap buffer in SPI.
|
void |
setListener(GridHadoopMessageListener lsnr)
Sets Hadoop communication message listener.
|
void |
setLocalPort(int locPort)
Sets local port for socket binding.
|
void |
setLocalPortRange(int locPortRange)
Sets local port range for local host ports (value must greater than or equal to 0).
|
void |
setMaxConnectTimeout(long maxConnTimeout)
Sets maximum connect timeout.
|
void |
setMessageQueueLimit(int msgQueueLimit)
Sets message queue limit for incoming and outgoing messages.
|
void |
setReconnectCount(int reconCnt)
Sets maximum number of reconnect attempts used when establishing connection
with remote nodes.
|
void |
setSelectorsCount(int selectorsCnt)
Sets the count of selectors te be used in TCP server.
|
void |
setSharedMemoryPort(int shmemPort)
Sets local port to accept shared memory connections.
|
void |
setSocketReceiveBuffer(int sockRcvBuf)
Sets receive buffer size for sockets created or accepted by this SPI.
|
void |
setSocketSendBuffer(int sockSndBuf)
Sets send buffer size for sockets created or accepted by this SPI.
|
void |
setTcpNoDelay(boolean tcpNoDelay)
Sets value for
TCP_NODELAY socket option. |
void |
start()
Starts communication.
|
void |
stop() |
String |
toString() |
public static final String OUT_OF_RESOURCES_TCP_MSG
public static final int DFLT_PORT
public static final long DFLT_CONN_TIMEOUT
public static final long DFLT_MAX_CONN_TIMEOUT
public static final int DFLT_RECONNECT_CNT
public static final int DFLT_MSG_QUEUE_LIMIT
public static final int DFLT_SELECTORS_CNT
"Math.min(4, Runtime.getRuntime().availableProcessors())".public static final int DFLT_PORT_RANGE
setLocalPortRange(int) for details.public static final boolean DFLT_TCP_NODELAY
TCP_NODELAY socket option (value is true).public GridHadoopExternalCommunication(UUID parentNodeId, UUID procId, org.gridgain.grid.marshaller.GridMarshaller marsh, org.gridgain.grid.logger.GridLogger log, ExecutorService execSvc, String gridName)
parentNodeId - Parent node ID.procId - Process ID.marsh - Marshaller to use.log - Logger.execSvc - Executor service for message notification.gridName - Grid name.public void setLocalPort(int locPort)
If not provided, default value is DFLT_PORT.
locPort - Port number.public int getLocalPort()
public void setLocalPortRange(int locPortRange)
setLocalPort(int)} is occupied,
implementation will try to increment the port number for as long as it is less than
initial value plus this range.
If port range value is 0, then implementation will try bind only to the port provided by
setLocalPort(int) method and fail if binding to this port did not succeed.
Local port range is very useful during development when more than one grid nodes need to run on the same physical machine.
If not provided, default value is DFLT_PORT_RANGE.
locPortRange - New local port range.public int getLocalPortRange()
public void setSharedMemoryPort(int shmemPort)
If set to -1 shared memory communication will be disabled.
If not provided, shared memory is disabled.
shmemPort - Port number.public int getSharedMemoryPort()
public void setConnectTimeout(long connTimeout)
0 is interpreted as infinite timeout.
If not provided, default value is DFLT_CONN_TIMEOUT.
connTimeout - Connect timeout.public long getConnectTimeout()
public void setMaxConnectTimeout(long maxConnTimeout)
0 is interpreted as infinite timeout.
If not provided, default value is DFLT_MAX_CONN_TIMEOUT.
maxConnTimeout - Maximum connect timeout.public long getMaxConnectTimeout()
public void setReconnectCount(int reconCnt)
If not provided, default value is DFLT_RECONNECT_CNT.
reconCnt - Maximum number of reconnection attempts.public int getReconnectCount()
public void setDirectBuffer(boolean directBuf)
true, then SPI will use ByteBuffer.allocateDirect(int) call.
Otherwise, SPI will use ByteBuffer.allocate(int) call.
If not provided, default value is true.
directBuf - Flag indicates to allocate direct or heap buffer in SPI.public boolean isDirectBuffer()
public void setSelectorsCount(int selectorsCnt)
DFLT_SELECTORS_CNT.selectorsCnt - Selectors count.public int getSelectorsCount()
public void setTcpNoDelay(boolean tcpNoDelay)
TCP_NODELAY socket option. Each
socket will be opened using provided value.
Setting this option to true disables Nagle's algorithm
for socket decreasing latency and delivery time for small messages.
For systems that work under heavy network load it is advisable to
set this value to false.
If not provided, default value is DFLT_TCP_NODELAY.
tcpNoDelay - True to disable TCP delay.public boolean isTcpNoDelay()
TCP_NO_DELAY flag.public void setSocketReceiveBuffer(int sockRcvBuf)
If not provided, default is 0 which leaves buffer unchanged after
socket creation (OS defaults).
sockRcvBuf - Socket receive buffer size.public int getSocketReceiveBuffer()
public void setSocketSendBuffer(int sockSndBuf)
If not provided, default is 0 which leaves the buffer unchanged
after socket creation (OS defaults).
sockSndBuf - Socket send buffer size.public int getSocketSendBuffer()
public void setMessageQueueLimit(int msgQueueLimit)
When set to positive number send queue is limited to the configured value.
0 disables the size limitations.
If not provided, default is DFLT_MSG_QUEUE_LIMIT.
msgQueueLimit - Send queue size limit.public int getMessageQueueLimit()
public void setListener(GridHadoopMessageListener lsnr)
lsnr - Message listener.public int getOutboundMessagesQueueSize()
public void start()
throws org.gridgain.grid.GridException
org.gridgain.grid.GridException - If failed.public GridHadoopProcessDescriptor localProcessDescriptor()
public void stop()
throws org.gridgain.grid.GridException
org.gridgain.grid.GridExceptionpublic void sendMessage(GridHadoopProcessDescriptor desc, GridHadoopMessage msg) throws org.gridgain.grid.GridException
org.gridgain.grid.GridException@Nullable protected GridHadoopCommunicationClient createNioClient(GridHadoopProcessDescriptor desc) throws org.gridgain.grid.GridException
desc - Process descriptor.org.gridgain.grid.GridException - If failed.@Nullable protected GridHadoopCommunicationClient createShmemClient(GridHadoopProcessDescriptor desc, int port) throws org.gridgain.grid.GridException
desc - Process descriptor.port - Port.org.gridgain.grid.GridException - If failed.protected GridHadoopCommunicationClient createTcpClient(GridHadoopProcessDescriptor desc) throws org.gridgain.grid.GridException
desc - Process descriptor.org.gridgain.grid.GridException - If failed.protected void notifyListener(GridHadoopProcessDescriptor desc, GridHadoopMessage msg)
desc - Sender process descriptor.msg - Communication message.Copyright © 2014. All rights reserved.