Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.controller.backend.BackendRecoveryPolicy Class Reference

List of all members.

Public Member Functions

 BackendRecoveryPolicy (String backendName, boolean recoveryPolicy)
String getBackendName ()
boolean getRecoveryPolicy ()
void addController (String controllerName) throws ControllerException
boolean isEligibleForRecovery (String controllerName)
String getXml ()

Detailed Description

Distributed backend policy for distributed virtual databases (horizontal scalability).

Author:
Emmanuel Cecchet
Version:
1.0

Definition at line 40 of file BackendRecoveryPolicy.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.controller.backend.BackendRecoveryPolicy.BackendRecoveryPolicy String  backendName,
boolean  recoveryPolicy
 

Create a new BackendRecoveryPolicy

Parameters:
backendName backend name
recoveryPolicy true if backends must be recovered

Definition at line 52 of file BackendRecoveryPolicy.java.

00053   {
00054     this.backendName = backendName;
00055     this.recoveryPolicy = recoveryPolicy;
00056   }


Member Function Documentation

void org.objectweb.cjdbc.controller.backend.BackendRecoveryPolicy.addController String  controllerName  )  throws ControllerException
 

Add a controller name that can recover this backend in case of the failure of the current controller.

Parameters:
controllerName name of the controller
Exceptions:
ControllerException if the recovery policy is off

Definition at line 85 of file BackendRecoveryPolicy.java.

00086   {
00087     if (recoveryPolicy == false)
00088       throw new ControllerException(
00089           "Cannot define controllers when recovery policy is off.");
00090     if (controllers == null)
00091       controllers = new ArrayList();
00092     controllers.add(controllerName);
00093   }

String org.objectweb.cjdbc.controller.backend.BackendRecoveryPolicy.getBackendName  ) 
 

Get the backend name

Returns:
backend name

Definition at line 63 of file BackendRecoveryPolicy.java.

Referenced by org.objectweb.cjdbc.controller.virtualdatabase.DistributedVirtualDatabase.addBackendRecoveryPolicy().

00064   {
00065     return backendName;
00066   }

boolean org.objectweb.cjdbc.controller.backend.BackendRecoveryPolicy.getRecoveryPolicy  ) 
 

Get the recoveryPolicy

Returns:
true if the recovery policy is on, false otherwise.

Definition at line 73 of file BackendRecoveryPolicy.java.

00074   {
00075     return recoveryPolicy;
00076   }

String org.objectweb.cjdbc.controller.backend.BackendRecoveryPolicy.getXml  ) 
 

Get the XML dump of this BackendRecoveryPolicy element

Returns:
XML dump of this BackendRecoveryPolicy element

Definition at line 117 of file BackendRecoveryPolicy.java.

Referenced by org.objectweb.cjdbc.controller.virtualdatabase.DistributedVirtualDatabase.getDistributionXml().

00118   {
00119     String xml = "<" + DatabasesXmlTags.ELT_BackendRecoveryPolicy + " "
00120         + DatabasesXmlTags.ATT_backendName + "=\"" + backendName + "\" "
00121         + DatabasesXmlTags.ATT_recoveryPolicy + "=\""
00122         + (recoveryPolicy ? DatabasesXmlTags.VAL_on : DatabasesXmlTags.VAL_off);
00123     if (controllers != null)
00124     {
00125       xml += ">";
00126       int size = controllers.size();
00127       for (int i = 0; i < size; i++)
00128         xml += "<" + DatabasesXmlTags.ELT_ControllerName + " "
00129             + DatabasesXmlTags.ATT_name + "=\"" + backendName + "\"/>";
00130       xml += "</" + DatabasesXmlTags.ELT_BackendRecoveryPolicy + ">";
00131     }
00132     else
00133       xml += "\"/>";
00134     return xml;
00135   }

boolean org.objectweb.cjdbc.controller.backend.BackendRecoveryPolicy.isEligibleForRecovery String  controllerName  ) 
 

Returns whether the given controller name is authorized to recover this backend or not.

Parameters:
controllerName controller asking for recovery
Returns:
true if the controller is eligible

Definition at line 102 of file BackendRecoveryPolicy.java.

00103   {
00104     if (recoveryPolicy == false)
00105       return false;
00106     if (controllers == null)
00107       return true;
00108     else
00109       return controllers.contains(controllerName);
00110   }


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:03:24 2005 for C-JDBC by  doxygen 1.3.9.1