com.caucho.cloud.bam
Class BamTriadSender

java.lang.Object
  extended by com.caucho.cloud.topology.AbstractCloudServerListener
      extended by com.caucho.cloud.bam.BamTriadSender
All Implemented Interfaces:
CloudServerListener

public class BamTriadSender
extends AbstractCloudServerListener

Service for handling the distributed cache


Nested Class Summary
static class BamTriadSender.ActiveEnum
           
static class BamTriadSender.RemoteEnum
           
 
Constructor Summary
BamTriadSender(QuerySender sender, CloudPod pod, java.lang.String uid)
           
 
Method Summary
 java.lang.String getActiveAddress(TriadOwner owner)
          Returns the address of the first active server.
 java.lang.String getActiveAddress(TriadOwner owner, java.lang.String oldAddress)
          Returns the address of the first active backup server.
 java.lang.String getActiveOrSelfAddress(TriadOwner owner)
          Returns the address of the first active server.
 ClusterServer getActiveOrSelfServer(TriadOwner owner)
          Returns the address of the first active server.
 java.lang.String getAddress()
           
 CloudPod getPod()
          Returns the pod for the sender.
 java.lang.String getPrimaryActiveAddress(TriadOwner owner)
          Returns the address of the primary, or null if the server doesn't exist.
 java.lang.String getPrimaryAddress(TriadOwner owner)
          Returns the address of the primary, or null if the server doesn't exist.
 java.lang.String getSecondaryActiveAddress(TriadOwner owner)
          Returns the address of the secondary, or null if the server doesn't exist.
 java.lang.String getSecondaryAddress(TriadOwner owner)
          Returns the address of the secondary, or null if the server doesn't exist.
 java.lang.String getTertiaryActiveAddress(TriadOwner owner)
          Returns the address of the tertiary, or null if the server doesn't exist.
 java.lang.String getTertiaryAddress(TriadOwner owner)
          Returns the address of the tertiary, or null if the server doesn't exist.
 boolean isPrimarySelf(TriadOwner owner)
          Returns the address of the primary, or null if the server doesn't exist.
 java.lang.String messageActiveOrSelf(java.io.Serializable msg, TriadOwner owner)
          Sends a message to one of the triad members, including the server itself.
 void messageAll(java.io.Serializable msg)
          Send a message to all servers in the pod.
 void messageAllTriadRemote(java.io.Serializable msg)
          Send a message to active remove triad servers.
 void messageBackup(java.io.Serializable msg, TriadOwner owner)
           
 java.lang.String messageFirstTriad(java.io.Serializable msg, TriadOwner owner, BamTriadSender.RemoteEnum remote)
          Sends a message to the first active remote triad server.
 java.lang.String messageFirstTriadActive(java.io.Serializable msg, TriadOwner owner)
          Sends a message to the first active remote triad server.
 java.lang.String messageFirstTriadRemote(java.io.Serializable msg, TriadOwner owner)
          Sends a message to the first active remote triad server.
 void messageTriadRemote(java.io.Serializable msg, TriadOwner owner)
           
 void onTriadAdd(TriadServer server)
           
 void onTriadRemove(TriadServer server)
           
 void queryAllTriadRemote(java.io.Serializable msg, QueryCallback cb)
          Send a message to active remove triad servers.
 boolean queryPrimary(TriadOwner owner, java.io.Serializable payload, QueryCallback callback, BamTriadSender.RemoteEnum remote, BamTriadSender.ActiveEnum active)
          Query the primary server, returning true if the query was sent or false if the server doesn't exist or doesn't match the predicates.
 boolean querySecondary(TriadOwner owner, java.io.Serializable payload, QueryCallback callback, BamTriadSender.RemoteEnum remote, BamTriadSender.ActiveEnum active)
          Query the primary server, returning true if the query was sent or false if the server doesn't exist or doesn't match the predicates.
 boolean queryTertiary(TriadOwner owner, java.io.Serializable payload, QueryCallback callback, BamTriadSender.RemoteEnum remote, BamTriadSender.ActiveEnum active)
          Query the primary server, returning true if the query was sent or false if the server doesn't exist or doesn't match the predicates.
 boolean queryTriad(TriadOwner owner, java.io.Serializable payload, QueryCallback callback)
          Sends a query to the first active server in the triad.
 java.lang.Object queryTriadActiveOrSelf(TriadOwner owner, java.io.Serializable payload)
          Load a file from the remote servers.
 void queryTriadActiveOrSelf(TriadOwner owner, java.io.Serializable payload, QueryCallback cb)
          Load a file from the remote servers.
 void queryTriadAll(TriadOwner owner, java.io.Serializable payload, QueryCallback cb, BamTriadSender.RemoteEnum remote, BamTriadSender.ActiveEnum active)
          Load a file from the remote servers.
 void queryTriadFirstActive(TriadOwner owner, java.io.Serializable payload, QueryCallback cb)
          Load a file from the remote servers.
 java.lang.Object queryTriadFirstRemote(TriadOwner owner, java.io.Serializable payload)
          Load a file from the remote servers.
 void queryTriadFirstRemote(TriadOwner owner, java.io.Serializable payload, QueryCallback cb)
          Load a file from the remote servers.
 java.lang.String toString()
           
 
Methods inherited from class com.caucho.cloud.topology.AbstractCloudServerListener
onServerAdd, onServerRemove, onServerStateChange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BamTriadSender

public BamTriadSender(QuerySender sender,
                      CloudPod pod,
                      java.lang.String uid)
Parameters:
linkStream - stream to the broker for sending messages
pod - the owning pod
uid - the uid prefix for the generated message
Method Detail

getPod

public CloudPod getPod()
Returns the pod for the sender.


getAddress

public java.lang.String getAddress()

isPrimarySelf

public boolean isPrimarySelf(TriadOwner owner)
Returns the address of the primary, or null if the server doesn't exist.


getPrimaryAddress

public java.lang.String getPrimaryAddress(TriadOwner owner)
Returns the address of the primary, or null if the server doesn't exist.


getSecondaryAddress

public java.lang.String getSecondaryAddress(TriadOwner owner)
Returns the address of the secondary, or null if the server doesn't exist.


getTertiaryAddress

public java.lang.String getTertiaryAddress(TriadOwner owner)
Returns the address of the tertiary, or null if the server doesn't exist.


getPrimaryActiveAddress

public java.lang.String getPrimaryActiveAddress(TriadOwner owner)
Returns the address of the primary, or null if the server doesn't exist.


getSecondaryActiveAddress

public java.lang.String getSecondaryActiveAddress(TriadOwner owner)
Returns the address of the secondary, or null if the server doesn't exist.


getTertiaryActiveAddress

public java.lang.String getTertiaryActiveAddress(TriadOwner owner)
Returns the address of the tertiary, or null if the server doesn't exist.


getActiveAddress

public java.lang.String getActiveAddress(TriadOwner owner)
Returns the address of the first active server.


getActiveOrSelfAddress

public java.lang.String getActiveOrSelfAddress(TriadOwner owner)
Returns the address of the first active server.


getActiveAddress

public java.lang.String getActiveAddress(TriadOwner owner,
                                         java.lang.String oldAddress)
Returns the address of the first active backup server.


getActiveOrSelfServer

public ClusterServer getActiveOrSelfServer(TriadOwner owner)
Returns the address of the first active server.


messageActiveOrSelf

public java.lang.String messageActiveOrSelf(java.io.Serializable msg,
                                            TriadOwner owner)
Sends a message to one of the triad members, including the server itself.


messageBackup

public void messageBackup(java.io.Serializable msg,
                          TriadOwner owner)

messageTriadRemote

public void messageTriadRemote(java.io.Serializable msg,
                               TriadOwner owner)

messageFirstTriadRemote

public java.lang.String messageFirstTriadRemote(java.io.Serializable msg,
                                                TriadOwner owner)
Sends a message to the first active remote triad server. For a triad server, this will not send a message to itself. Used by triad servers to send backup data or for services that send a copy to the triad.


messageFirstTriadActive

public java.lang.String messageFirstTriadActive(java.io.Serializable msg,
                                                TriadOwner owner)
Sends a message to the first active remote triad server. For a triad server, this will not send a message to itself. Used by triad servers to send backup data or for services that send a copy to the triad.


messageFirstTriad

public java.lang.String messageFirstTriad(java.io.Serializable msg,
                                          TriadOwner owner,
                                          BamTriadSender.RemoteEnum remote)
Sends a message to the first active remote triad server. For a triad server, this will not send a message to itself. Used by triad servers to send backup data or for services that send a copy to the triad.


messageAllTriadRemote

public void messageAllTriadRemote(java.io.Serializable msg)
Send a message to active remove triad servers.


queryAllTriadRemote

public void queryAllTriadRemote(java.io.Serializable msg,
                                QueryCallback cb)
Send a message to active remove triad servers.


messageAll

public void messageAll(java.io.Serializable msg)
Send a message to all servers in the pod.


queryTriad

public boolean queryTriad(TriadOwner owner,
                          java.io.Serializable payload,
                          QueryCallback callback)
Sends a query to the first active server in the triad.


queryTriadFirstRemote

public java.lang.Object queryTriadFirstRemote(TriadOwner owner,
                                              java.io.Serializable payload)
Load a file from the remote servers.


queryTriadFirstRemote

public void queryTriadFirstRemote(TriadOwner owner,
                                  java.io.Serializable payload,
                                  QueryCallback cb)
Load a file from the remote servers.


queryTriadFirstActive

public void queryTriadFirstActive(TriadOwner owner,
                                  java.io.Serializable payload,
                                  QueryCallback cb)
Load a file from the remote servers.


queryTriadAll

public void queryTriadAll(TriadOwner owner,
                          java.io.Serializable payload,
                          QueryCallback cb,
                          BamTriadSender.RemoteEnum remote,
                          BamTriadSender.ActiveEnum active)
Load a file from the remote servers.


queryPrimary

public boolean queryPrimary(TriadOwner owner,
                            java.io.Serializable payload,
                            QueryCallback callback,
                            BamTriadSender.RemoteEnum remote,
                            BamTriadSender.ActiveEnum active)
Query the primary server, returning true if the query was sent or false if the server doesn't exist or doesn't match the predicates.


querySecondary

public boolean querySecondary(TriadOwner owner,
                              java.io.Serializable payload,
                              QueryCallback callback,
                              BamTriadSender.RemoteEnum remote,
                              BamTriadSender.ActiveEnum active)
Query the primary server, returning true if the query was sent or false if the server doesn't exist or doesn't match the predicates.


queryTertiary

public boolean queryTertiary(TriadOwner owner,
                             java.io.Serializable payload,
                             QueryCallback callback,
                             BamTriadSender.RemoteEnum remote,
                             BamTriadSender.ActiveEnum active)
Query the primary server, returning true if the query was sent or false if the server doesn't exist or doesn't match the predicates.


queryTriadActiveOrSelf

public java.lang.Object queryTriadActiveOrSelf(TriadOwner owner,
                                               java.io.Serializable payload)
Load a file from the remote servers.


queryTriadActiveOrSelf

public void queryTriadActiveOrSelf(TriadOwner owner,
                                   java.io.Serializable payload,
                                   QueryCallback cb)
Load a file from the remote servers.


onTriadAdd

public void onTriadAdd(TriadServer server)
Specified by:
onTriadAdd in interface CloudServerListener
Overrides:
onTriadAdd in class AbstractCloudServerListener

onTriadRemove

public void onTriadRemove(TriadServer server)
Specified by:
onTriadRemove in interface CloudServerListener
Overrides:
onTriadRemove in class AbstractCloudServerListener

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object