1 24 25 package org.objectweb.cjdbc.controller.loadbalancer.policies; 26 27 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags; 28 34 public class WaitForCompletionPolicy 35 { 36 37 public static final int FIRST = 0; 38 39 42 public static final int MAJORITY = 1; 43 44 45 public static final int ALL = 2; 46 47 48 private int policy = FIRST; 49 50 55 public int getPolicy() 56 { 57 return policy; 58 } 59 60 65 public void setPolicy(int policy) 66 { 67 this.policy = policy; 68 } 69 70 75 public String getInformation() 76 { 77 switch (policy) 78 { 79 case FIRST : 80 return "return when first node completes"; 81 case MAJORITY : 82 return "return when a majority of nodes completes"; 83 case ALL : 84 return "return when all nodes have completed"; 85 default : 86 return "unknown policy"; 87 } 88 } 89 90 95 public String getXml() 96 { 97 StringBuffer info = new StringBuffer (); 98 info.append( 99 "<" 100 + DatabasesXmlTags.ELT_WaitForCompletion 101 + " " 102 + DatabasesXmlTags.ATT_policy 103 + "=\""); 104 switch (policy) 105 { 106 case FIRST : 107 info.append(DatabasesXmlTags.VAL_first); 108 break; 109 case ALL : 110 info.append(DatabasesXmlTags.VAL_all); 111 break; 112 case MAJORITY : 113 info.append(DatabasesXmlTags.VAL_majority); 114 break; 115 default : 116 } 117 info.append("\"/>"); 118 return info.toString(); 119 } 120 } 121 | Popular Tags |