public class RouterStub extends ReceiverAdapter implements java.lang.Comparable<RouterStub>, ConnectionListener
Modifier and Type | Class and Description |
---|---|
static interface |
RouterStub.CloseListener |
static interface |
RouterStub.MembersNotification |
static interface |
RouterStub.StubReceiver |
Modifier and Type | Field and Description |
---|---|
protected BaseServer |
client |
protected RouterStub.CloseListener |
close_listener |
protected java.util.Map<java.lang.String,java.util.List<RouterStub.MembersNotification>> |
get_members_map |
protected IpAddress |
local |
protected static Log |
log |
protected RouterStub.StubReceiver |
receiver |
protected IpAddress |
remote |
protected int |
sock_conn_timeout |
protected boolean |
tcp_nodelay |
protected boolean |
use_nio |
Constructor and Description |
---|
RouterStub(java.net.InetAddress bind_addr,
int bind_port,
java.net.InetAddress router_host,
int router_port,
boolean use_nio,
RouterStub.CloseListener l)
Creates a stub to a remote GossipRouter
|
RouterStub(IpAddress local,
IpAddress remote,
boolean use_nio,
RouterStub.CloseListener l) |
Modifier and Type | Method and Description |
---|---|
protected void |
_doConnect() |
int |
compareTo(RouterStub o) |
void |
connect() |
void |
connect(java.lang.String group,
Address addr,
java.lang.String logical_name,
PhysicalAddress phys_addr)
Registers mbr with the GossipRouter under the given group, with the given logical name and physical address.
|
void |
connectionClosed(Connection conn,
java.lang.String reason) |
void |
connectionEstablished(Connection conn) |
RouterStub.CloseListener |
connectionListener() |
RouterStub |
connectionListener(RouterStub.CloseListener l) |
void |
destroy() |
void |
disconnect(java.lang.String group,
Address addr) |
boolean |
equals(java.lang.Object obj) |
void |
getMembers(java.lang.String group,
RouterStub.MembersNotification callback)
Fetches a list of
PingData from the GossipRouter, one for each member in the given group. |
IpAddress |
gossipRouterAddress() |
int |
hashCode() |
boolean |
isConnected() |
IpAddress |
local() |
protected void |
notifyResponse(java.lang.String group,
java.util.List<PingData> list) |
void |
receive(Address sender,
byte[] buf,
int offset,
int length)
Delivers a message from a given sender to the application
|
void |
receive(Address sender,
java.nio.ByteBuffer buf)
The default implementation assumes that
Buffer.flip() or Buffer.rewind() was called on
buf before invoking this callback |
RouterStub.StubReceiver |
receiver() |
RouterStub |
receiver(RouterStub.StubReceiver r) |
IpAddress |
remote() |
protected void |
removeResponse(java.lang.String group,
RouterStub.MembersNotification notif) |
void |
sendToAllMembers(java.lang.String group,
byte[] data,
int offset,
int length) |
void |
sendToMember(java.lang.String group,
Address dest,
byte[] data,
int offset,
int length) |
RouterStub |
set(java.lang.String attr,
java.lang.Object val) |
int |
socketConnectionTimeout() |
RouterStub |
socketConnectionTimeout(int timeout) |
boolean |
tcpNoDelay() |
RouterStub |
tcpNoDelay(boolean tcp_nodelay) |
java.lang.String |
toString() |
boolean |
useNio() |
protected void |
writeRequest(GossipData req) |
protected BaseServer client
protected final IpAddress local
protected final IpAddress remote
protected final boolean use_nio
protected RouterStub.StubReceiver receiver
protected RouterStub.CloseListener close_listener
protected static final Log log
protected int sock_conn_timeout
protected boolean tcp_nodelay
protected final java.util.Map<java.lang.String,java.util.List<RouterStub.MembersNotification>> get_members_map
public RouterStub(java.net.InetAddress bind_addr, int bind_port, java.net.InetAddress router_host, int router_port, boolean use_nio, RouterStub.CloseListener l)
bind_addr
- The local address to bind to. If null, one will be pickedbind_port
- The local port. If 0, a random port will be usedrouter_host
- The address of the remote GossipRouter
router_port
- The port on which the remote GossipRouter is listeninguse_nio
- Whether to use blocking or non-blocking IOl
- The RouterStub.CloseListener
public RouterStub(IpAddress local, IpAddress remote, boolean use_nio, RouterStub.CloseListener l)
public IpAddress local()
public IpAddress remote()
public RouterStub receiver(RouterStub.StubReceiver r)
public RouterStub.StubReceiver receiver()
public boolean tcpNoDelay()
public RouterStub tcpNoDelay(boolean tcp_nodelay)
public RouterStub.CloseListener connectionListener()
public RouterStub connectionListener(RouterStub.CloseListener l)
public int socketConnectionTimeout()
public RouterStub socketConnectionTimeout(int timeout)
public boolean useNio()
public IpAddress gossipRouterAddress()
public boolean isConnected()
public RouterStub set(java.lang.String attr, java.lang.Object val)
public void connect(java.lang.String group, Address addr, java.lang.String logical_name, PhysicalAddress phys_addr) throws java.lang.Exception
group
- The group cluster) name under which to register the memberaddr
- The address of the memberlogical_name
- The logical name of the memberphys_addr
- The physical address of the memberjava.lang.Exception
- Thrown when the registration failedpublic void connect() throws java.lang.Exception
java.lang.Exception
protected void _doConnect() throws java.lang.Exception
java.lang.Exception
public void disconnect(java.lang.String group, Address addr) throws java.lang.Exception
java.lang.Exception
public void destroy()
public void getMembers(java.lang.String group, RouterStub.MembersNotification callback) throws java.lang.Exception
PingData
from the GossipRouter, one for each member in the given group. This call
returns immediately and when the results are available, the
RouterStub.MembersNotification.members(List)
callback will be invoked.group
- The group for which we need members informationcallback
- The callback to be invoked.java.lang.Exception
public void sendToAllMembers(java.lang.String group, byte[] data, int offset, int length) throws java.lang.Exception
java.lang.Exception
public void sendToMember(java.lang.String group, Address dest, byte[] data, int offset, int length) throws java.lang.Exception
java.lang.Exception
public void receive(Address sender, byte[] buf, int offset, int length)
Receiver
receive
in interface Receiver
receive
in class ReceiverAdapter
sender
- The sender of the messagebuf
- The buffer. An application typically de-serializes data from the buffer into objects used by the
application. Note that when receive() returns, it is not safe to use the buffer any longer;
if an application needs to use a buffer after this callback returns, it must make a copy.offset
- The offset at which the received data startslength
- The length of the received datapublic void receive(Address sender, java.nio.ByteBuffer buf)
ReceiverAdapter
Buffer.flip()
or Buffer.rewind()
was called on
buf before invoking this callbackreceive
in interface Receiver
receive
in class ReceiverAdapter
sender
- The sender of the messagebuf
- The buffer. An application typically de-serializes data from the buffer into objects used by the
application. Note that when receive() returns, it is not safe to use the buffer any longer;
if an application needs to use a buffer after this callback returns, it must make a copy.
Note that buf could be a direct ByteBuffer.public void connectionClosed(Connection conn, java.lang.String reason)
connectionClosed
in interface ConnectionListener
public void connectionEstablished(Connection conn)
connectionEstablished
in interface ConnectionListener
public int compareTo(RouterStub o)
compareTo
in interface java.lang.Comparable<RouterStub>
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
protected void writeRequest(GossipData req) throws java.lang.Exception
java.lang.Exception
protected void removeResponse(java.lang.String group, RouterStub.MembersNotification notif)
protected void notifyResponse(java.lang.String group, java.util.List<PingData> list)
Copyright © 1998-2020 Red Hat. All Rights Reserved.