Changeset 4097
- Timestamp:
- 2003-04-07T16:52:08+12:00 (21 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3/collection
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/collection/Collection.java
r4086 r4097 44 44 extends ServiceCluster { 45 45 46 protected XMLTransformer transformer _= null;46 protected XMLTransformer transformer = null; 47 47 /** same as setClusterName */ 48 48 public void setCollectionName(String name) { … … 51 51 52 52 public Collection() { 53 service_map_ = new HashMap(); 54 converter_ = new XMLConverter(); 55 transformer_ = new XMLTransformer(); 56 doc_ = converter_.newDOM(); 57 description_ = doc_.createElement(GSXML.COLLECTION_ELEM); 58 service_info_ = doc_.createElement(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER); 59 meta_info_ = doc_.createElement(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 60 description_.appendChild(meta_info_); 61 description_.appendChild(service_info_); 53 this.service_map = new HashMap(); 54 this.converter = new XMLConverter(); 55 this.transformer = new XMLTransformer(); 56 this.doc = this.converter.newDOM(); 57 this.description = this.doc.createElement(GSXML.COLLECTION_ELEM); 62 58 63 59 } … … 75 71 public boolean configure() { 76 72 77 if ( site_home_ == null || cluster_name_== null) {73 if (this.site_home == null || this.cluster_name== null) { 78 74 System.err.println("site_home and collection_name must be set before configure called!"); 79 75 return false; 80 76 } 81 // read the collection build configuration file 82 File build_config_file = new File(GSFile.collectionBuildConfigFile(site_home_, cluster_name_)); 83 File coll_config_file = new File(GSFile.collectionConfigFile(site_home_, cluster_name_)); 84 77 78 Element coll_config_xml = loadCollConfigFile(); 79 Element build_config_xml = loadBuildConfigFile(); 80 81 if (coll_config_xml==null||build_config_xml==null) { 82 return false; 83 } 84 // process the metadata 85 findAndLoadMetadata(coll_config_xml, build_config_xml); 86 87 // now do the services 88 Element service_list = (Element)GSXML.getChildByTagName(build_config_xml, GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER); 89 configureServiceRack(service_list, coll_config_xml); 90 91 return true; 92 93 } 94 95 /** 96 * overwrite the serviceCluster one cos we use diff config files 97 */ 98 protected Element processSystemRequest(Element request) { 99 Element response = this.doc.createElement(GSXML.RESPONSE_ELEM); 100 response.setAttribute(GSXML.FROM_ATT, this.cluster_name); 101 response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_SYSTEM); 102 103 // a list of system requests - should put any error messages 104 // or success messages into response 105 NodeList commands = request.getElementsByTagName(GSXML.SYSTEM_ELEM); 106 Element coll_config_elem = null; 107 Element build_config_elem = null; 108 for (int i=0; i<commands.getLength(); i++) { 109 // all the commands should be Elements 110 Element elem = (Element)commands.item(i); 111 String action = elem.getAttribute(GSXML.TYPE_ATT); 112 if (action.equals("configure")) { 113 String subset = elem.getAttribute("subset"); 114 if (subset.equals("")) { 115 // need to reconfigure the collection 116 if (this.configure()) { 117 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " collection reconfigured"); 118 response.appendChild(s); 119 continue; 120 } 121 122 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " collection could not be reconfigured"); 123 response.appendChild(s); 124 return response; // wont be able to process any more if we cant do this one 125 126 } 127 // else its a specific request 128 129 // need the coll config files 130 if (coll_config_elem==null) { 131 coll_config_elem = loadCollConfigFile(); 132 build_config_elem = loadBuildConfigFile(); 133 if (coll_config_elem == null||build_config_elem == null) { 134 // wont be able to do any of teh requests 135 return response; 136 } 137 } 138 139 boolean success = false; 140 if (subset.equals(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER)) { 141 Element service_rack_list = (Element)GSXML.getChildByTagName(build_config_elem, GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER); 142 143 success = configureServiceRack(service_rack_list, coll_config_elem); 144 } else if (subset.equals(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER)) { 145 success = findAndLoadMetadata(coll_config_elem, build_config_elem); 146 147 } else { 148 System.err.println("ServiceCluster: cant process system request, configure "+subset); 149 } 150 151 String message=null; 152 if (success) { 153 message = "ServiceCluster: "+ subset + " reconfigured successfully"; 154 } else { 155 message = "ServiceCluster: Error in reconfiguring "+subset; 156 } 157 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, message); 158 response.appendChild(s); 159 } else { 160 String module_name = elem.getAttribute(GSXML.SYSTEM_MODULE_NAME_ATT); 161 String module_type = elem.getAttribute(GSXML.SYSTEM_MODULE_TYPE_ATT); 162 if (action.equals("activate")) { 163 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, module_type+": "+module_name+" activated -- not yet implemented"); 164 response.appendChild(s); 165 } else if (action.equals("deactivate")) { 166 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, module_type+": "+module_name+" deactivated -- not yet implemented"); 167 response.appendChild(s); 168 } else { 169 System.err.println("Collection: cant process system request, action "+action); 170 continue; 171 } 172 173 } 174 } // for each command 175 return response; 176 } 177 178 protected Element loadCollConfigFile() { 179 180 File coll_config_file = new File(GSFile.collectionConfigFile(this.site_home, this.cluster_name)); 181 85 182 if (!coll_config_file.exists()) { 86 183 System.err.println(coll_config_file+" does not exist"); 87 System.err.println("couldn't configure collection: "+cluster_name_); 88 return false; 89 } 90 184 System.err.println("couldn't configure collection: "+this.cluster_name); 185 return null; 186 } 187 // get the xml for both files 188 Element coll_config_elem = this.converter.getDOM(coll_config_file, CONFIG_ENCODING).getDocumentElement(); 189 return coll_config_elem; 190 191 } 192 193 194 protected Element loadBuildConfigFile() { 195 196 File build_config_file = new File(GSFile.collectionBuildConfigFile(this.site_home, this.cluster_name)); 91 197 if (!build_config_file.exists()) { 92 198 System.err.println(build_config_file+" does not exist"); 93 System.err.println("couldn't configure collection: "+cluster_name_); 94 return false; 95 } 96 97 // get the xml for both files 98 Element coll_config_xml = converter_.getDOM(coll_config_file, CONFIG_ENCODING).getDocumentElement(); 99 Element build_config_xml = converter_.getDOM(build_config_file, CONFIG_ENCODING).getDocumentElement(); 100 101 // process the metadata 199 System.err.println("couldn't configure collection: "+this.cluster_name); 200 return null; 201 } 202 Element build_config_elem = this.converter.getDOM(build_config_file, CONFIG_ENCODING).getDocumentElement(); 203 204 return build_config_elem; 205 } 206 207 208 protected boolean findAndLoadMetadata(Element coll_config_xml, 209 Element build_config_xml){ 210 211 this.metadata_list = this.doc.createElement(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 102 212 Element meta_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 103 configureMetadata(meta_list);213 addMetadata(meta_list); 104 214 meta_list = (Element)GSXML.getChildByTagName(build_config_xml, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 105 configureMetadata(meta_list); 106 107 meta_list = doc_.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 108 GSXML.addMetadata(doc_, meta_list, "httpPath", site_http_address_+"/collect/"+cluster_name_); 109 configureMetadata(meta_list); 110 111 // now do the services 112 113 Element service_list = (Element)GSXML.getChildByTagName(build_config_xml, GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER); 114 configureServiceRack(service_list, coll_config_xml); 115 215 addMetadata(meta_list); 216 217 meta_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 218 GSXML.addMetadata(this.doc, meta_list, "httpPath", this.site_http_address+"/collect/"+this.cluster_name); 219 addMetadata(meta_list); 116 220 return true; 117 221 118 222 } 119 223 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java
r4086 r4097 48 48 49 49 /** base directory for the site that this cluster belongs to*/ 50 protected String site_home _= null;50 protected String site_home = null; 51 51 /** http address of the site that this cluster belongs to */ 52 protected String site_http_address _= null;52 protected String site_http_address = null; 53 53 /** The name of the cluster - for a collection, this is the collection name*/ 54 protected String cluster_name _= null;54 protected String cluster_name = null; 55 55 56 56 /** a reference to the message router */ 57 protected MessageRouter router _= null;57 protected MessageRouter router = null; 58 58 /** The map of services. 59 59 * … … 62 62 * 63 63 */ 64 protected HashMap service_map _=null;64 protected HashMap service_map=null; 65 65 66 66 /** XML converter for String to DOM and vice versa */ 67 protected XMLConverter converter _=null;67 protected XMLConverter converter=null; 68 68 69 69 /** container doc for description elements */ 70 protected Document doc _= null;70 protected Document doc = null; 71 71 /** list of services */ 72 protected Element service_ info_= null;72 protected Element service_list = null; 73 73 /** list of Metadata */ 74 protected Element meta _info_= null;75 /** full description */76 protected Element description _= null;74 protected Element metadata_list = null; 75 /** the element that will have any descriptions passed back in */ 76 protected Element description = null; 77 77 78 78 public void setSiteHome(String home) { 79 site_home_= home;79 this.site_home = home; 80 80 } 81 81 82 82 public void setSiteAddress(String address) { 83 site_http_address_= address;83 this.site_http_address = address; 84 84 } 85 85 86 86 public void setClusterName(String name) { 87 cluster_name_= name;88 description_.setAttribute(GSXML.NAME_ATT, name);87 this.cluster_name = name; 88 this.description.setAttribute(GSXML.NAME_ATT, name); 89 89 } 90 90 91 91 public void setMessageRouter(MessageRouter m) { 92 router_= m;92 this.router = m; 93 93 } 94 94 95 95 public ServiceCluster() { 96 service_map_ = new HashMap(); 97 converter_ = new XMLConverter(); 98 doc_ = converter_.newDOM(); 99 description_ = doc_.createElement(GSXML.CLUSTER_ELEM); 100 service_info_ = doc_.createElement(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER); 101 meta_info_ = doc_.createElement(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 102 description_.appendChild(meta_info_); 103 description_.appendChild(service_info_); 96 this.service_map = new HashMap(); 97 this.converter = new XMLConverter(); 98 this.doc = this.converter.newDOM(); 99 this.description = this.doc.createElement(GSXML.CLUSTER_ELEM); 104 100 105 101 } … … 120 116 public boolean configure() { 121 117 122 if ( site_home_ == null || cluster_name_== null) {123 System.err.println(" site_home_and cluster_name_ must be set before configure called!");118 if (this.site_home == null || this.cluster_name== null) { 119 System.err.println("this.site_home and cluster_name_ must be set before configure called!"); 124 120 return false; 125 121 } 126 122 System.out.println("configuring service cluster"); 127 123 // read the site configuration file 128 File config_file _ = new File(GSFile.siteConfigFile(site_home_));129 130 if (!config_file _.exists()) {131 System.err.println(config_file _+" does not exist");132 System.err.println("couldn't configure cluster: "+ cluster_name_);124 File config_file = new File(GSFile.siteConfigFile(this.site_home)); 125 126 if (!config_file.exists()) { 127 System.err.println(config_file+" does not exist"); 128 System.err.println("couldn't configure cluster: "+this.cluster_name); 133 129 return false; 134 130 } 135 131 136 Document doc = converter_.getDOM(config_file_, CONFIG_ENCODING);132 Document doc = this.converter.getDOM(config_file, CONFIG_ENCODING); 137 133 138 134 // get the appropriate service cluster element 139 135 Element cluster_list = (Element)GSXML.getChildByTagName(doc.getDocumentElement(), GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER); 140 136 Element sc = GSXML.getNamedElement(cluster_list, GSXML.CLUSTER_ELEM, 141 GSXML.NAME_ATT, cluster_name_);137 GSXML.NAME_ATT, this.cluster_name); 142 138 143 139 return this.configure(sc); … … 148 144 149 145 // do the metadata 150 146 this.metadata_list = this.doc.createElement(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 151 147 // get the metadata - for now just add it to the list 152 148 Element meta_list = (Element) GSXML.getChildByTagName(service_cluster_info, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 153 149 if (meta_list !=null) { 154 if (! configureMetadata(meta_list)) {150 if (!addMetadata(meta_list)) { 155 151 156 152 System.err.println("couldn't configure the metadata"); … … 176 172 } 177 173 178 /** adds metadata from a metadataList into the meta _info_xml */179 protected boolean configureMetadata(Element metadata_list) {174 /** adds metadata from a metadataList into the metadata_list xml */ 175 protected boolean addMetadata(Element metadata_list) { 180 176 NodeList metanodes = metadata_list.getElementsByTagName(GSXML.METADATA_ELEM); 181 177 if (metanodes.getLength()>0) { 182 178 for(int k=0; k<metanodes.getLength(); k++) { 183 meta_info_.appendChild(doc_.importNode(metanodes.item(k),true));179 this.metadata_list.appendChild(this.doc.importNode(metanodes.item(k),true)); 184 180 } 185 181 } … … 192 188 protected boolean configureServiceRack(Element service_rack_list, 193 189 Element extra_info) { 194 190 191 // empty the service map in case this is a reconfigure 192 service_map.clear(); 193 this.service_list = this.doc.createElement(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER); 194 195 195 // create all the services 196 196 NodeList nodes = service_rack_list.getElementsByTagName(GSXML.SERVICE_CLASS_ELEM); 197 197 if (nodes.getLength()==0) { 198 System.err.println("Cluster configuration error: cluster "+ cluster_name_+" has no service modules!");198 System.err.println("Cluster configuration error: cluster "+this.cluster_name+" has no service modules!"); 199 199 return false; 200 200 } … … 204 204 // the xml request to send to the serviceRack to query what 205 205 // services it provides 206 Element message = doc_.createElement(GSXML.MESSAGE_ELEM);207 Element request = GSXML.createBasicRequest( doc_, GSXML.REQUEST_TYPE_DESCRIBE, "", "");206 Element message = this.doc.createElement(GSXML.MESSAGE_ELEM); 207 Element request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", ""); 208 208 message.appendChild(request); 209 209 request.setAttribute(GSXML.INFO_ATT, GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER); … … 216 216 ServiceRack s = (ServiceRack)Class.forName("org.greenstone.gsdl3.service."+servicetype).newInstance(); 217 217 218 s.setSiteHome( site_home_);219 s.setSiteAddress( site_http_address_);220 s.setClusterName( cluster_name_);221 s.setMessageRouter( router_);218 s.setSiteHome(this.site_home); 219 s.setSiteAddress(this.site_http_address); 220 s.setClusterName(this.cluster_name); 221 s.setMessageRouter(this.router); 222 222 // pass the xml node to the service for configuration 223 223 s.configure(n, extra_info); … … 229 229 for (int j=0; j<typenodes.getLength();j++) { 230 230 String service = ((Element) typenodes.item(j)).getAttribute(GSXML.NAME_ATT); 231 service_map_.put(service, s);231 this.service_map.put(service, s); 232 232 233 233 // also add info to the ServiceInfo XML element 234 service_info_.appendChild(doc_.importNode(typenodes.item(j), true));234 this.service_list.appendChild(this.doc.importNode(typenodes.item(j), true)); 235 235 } 236 236 } catch (Exception e) { … … 241 241 242 242 } 243 // add elements to description244 description_.appendChild(service_info_);245 243 return true; 246 244 … … 259 257 public String process(String in) { 260 258 261 Document doc = converter_.getDOM(in);259 Document doc = this.converter.getDOM(in); 262 260 Element e = doc.getDocumentElement(); 263 261 264 262 Element res = process(e); 265 return converter_.getString(res);263 return this.converter.getString(res); 266 264 267 265 } … … 274 272 NodeList requests = message.getElementsByTagName(GSXML.REQUEST_ELEM); 275 273 Document mess_doc = message.getOwnerDocument(); 276 Element mainResult = doc_.createElement(GSXML.MESSAGE_ELEM);274 Element mainResult = this.doc.createElement(GSXML.MESSAGE_ELEM); 277 275 if (requests.getLength()==0) { 278 System.err.println("ServiceCluster.process: no requests for cluster:"+ cluster_name_);276 System.err.println("ServiceCluster.process: no requests for cluster:"+this.cluster_name); 279 277 // no requests 280 278 return mainResult; // for now … … 286 284 // the cluster name should be first, check, then remove 287 285 String clustername = GSPath.getFirstLink(to); 288 if (!clustername.equals( cluster_name_)){289 System.err.println("ServiceCluster Error: cluster name wrong! was "+clustername+" should have been "+ cluster_name_);286 if (!clustername.equals(this.cluster_name)){ 287 System.err.println("ServiceCluster Error: cluster name wrong! was "+clustername+" should have been "+this.cluster_name); 290 288 continue; // ignore this request 291 289 } … … 294 292 295 293 if (to.equals("")) { // this command is for me 296 String type = request.getAttribute(GSXML.TYPE_ATT); 297 if (type.equals(GSXML.REQUEST_TYPE_DESCRIBE)) { 298 // create a response with the description inside it 299 Element response = doc_.createElement(GSXML.RESPONSE_ELEM); 300 response.setAttribute(GSXML.FROM_ATT, cluster_name_); 301 response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_DESCRIBE); 302 response.appendChild(description_); 303 mainResult.appendChild(response); 304 305 } else { 306 System.err.println("ServiceCluster Error: cant handle request of type "+ type); 307 308 } 309 294 Element response = processMessage(request); 295 mainResult.appendChild(response); 296 310 297 } else { // the request is for one of my services 311 298 String service = GSPath.getFirstLink(to); 312 299 313 if (! service_map_.containsKey(service)) {300 if (!this.service_map.containsKey(service)) { 314 301 System.err.println("ServiceCluster Error: non-existant service, "+service+", specified!"); 315 302 continue; … … 318 305 Element single_message = mess_doc.createElement(GSXML.MESSAGE_ELEM); 319 306 single_message.appendChild(request); 320 Element response_message = ((ModuleInterface) service_map_.get(service)).process(single_message);307 Element response_message = ((ModuleInterface)this.service_map.get(service)).process(single_message); 321 308 if (response_message != null) { 322 309 Element response = (Element) GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM); 323 310 String from = response.getAttribute(GSXML.FROM_ATT); 324 from = GSPath.prependLink(from, cluster_name_);311 from = GSPath.prependLink(from, this.cluster_name); 325 312 response.setAttribute(GSXML.FROM_ATT, from); 326 mainResult.appendChild( doc_.importNode(response, true));313 mainResult.appendChild(this.doc.importNode(response, true)); 327 314 } 328 315 … … 333 320 return mainResult; 334 321 } 335 322 323 /** handles requests made to the ServiceCluster itself 324 * 325 * @param req - the request Element- <request> 326 * @return the result Element - should be <response> 327 */ 328 protected Element processMessage(Element request) { 329 330 Element response = this.doc.createElement(GSXML.RESPONSE_ELEM); 331 response.setAttribute(GSXML.FROM_ATT, this.cluster_name); 332 String type = request.getAttribute(GSXML.TYPE_ATT); 333 response.setAttribute(GSXML.TYPE_ATT, type); 334 335 if (type.equals(GSXML.REQUEST_TYPE_DESCRIBE)) { 336 // create the collection element 337 Element description = (Element)this.description.cloneNode(false); 338 response.appendChild(description); 339 // check the param list 340 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 341 if (param_list == null) { 342 description.appendChild(this.service_list); 343 description.appendChild(this.metadata_list); 344 return response; 345 } 346 347 // go through the param list and see what components are wanted 348 NodeList params = param_list.getElementsByTagName(GSXML.PARAM_ELEM); 349 for (int i=0; i<params.getLength(); i++) { 350 351 Element param = (Element)params.item(i); 352 // Identify the structure information desired 353 if (param.getAttribute(GSXML.NAME_ATT) == GSXML.INFO_PARAM ) { 354 String info = param.getAttribute(GSXML.VALUE_ATT); 355 if (info.equals(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER)) { 356 description.appendChild(this.service_list); 357 } else if (info.equals(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER)) { 358 description.appendChild(this.metadata_list); 359 } 360 } 361 } 362 return response; 363 } 364 365 if (type.equals(GSXML.REQUEST_TYPE_SYSTEM)) { 366 response = processSystemRequest(request); 367 } else { // unknown type 368 System.err.println("ServiceCluster Error: cant handle request of type "+ type); 369 370 } 371 return response; 372 } 373 374 protected Element processSystemRequest(Element request) { 375 376 Element response = this.doc.createElement(GSXML.RESPONSE_ELEM); 377 response.setAttribute(GSXML.FROM_ATT, this.cluster_name); 378 response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_SYSTEM); 379 380 // a list of system requests - should put any error messages 381 // or success messages into response 382 NodeList commands = request.getElementsByTagName(GSXML.SYSTEM_ELEM); 383 Element cluster_config_elem = null; 384 for (int i=0; i<commands.getLength(); i++) { 385 // all the commands should be Elements 386 Element elem = (Element)commands.item(i); 387 String action = elem.getAttribute(GSXML.TYPE_ATT); 388 if (action.equals("configure")) { 389 String subset = elem.getAttribute(GSXML.SYSTEM_SUBSET_ATT); 390 if (subset.equals("")) { 391 // need to reconfigure the service cluster 392 393 if (this.configure()) { 394 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " cluster reconfigured"); 395 response.appendChild(s); 396 continue; 397 } 398 399 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " cluster could not be reconfigured"); 400 response.appendChild(s); 401 return response; // wont be able to process any more if we cant do this one 402 403 } 404 // else its a specific request 405 406 // need the site config file 407 if (cluster_config_elem==null) { 408 409 File configFile = new File(GSFile.siteConfigFile(this.site_home)); 410 if (!configFile.exists() ) { 411 System.err.println("ServiceCluster: site config file: "+configFile.getPath()+" not found!"); 412 // wont be able to do any of teh requests 413 return response; 414 415 } 416 Element site_config_elem = this.converter.getDOM(configFile).getDocumentElement(); 417 cluster_config_elem = GSXML.getNamedElement((Element)GSXML.getChildByTagName(site_config_elem, GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER), GSXML.CLUSTER_ELEM, GSXML.NAME_ATT, this.cluster_name); 418 if (cluster_config_elem == null) { 419 System.err.println("ServiceCluster: site config file: "+configFile.getPath()+" has no element for cluster "+this.cluster_name); 420 // wont be able to do any of teh requests 421 return response; 422 423 } 424 } 425 426 boolean success = false; 427 if (subset.equals(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER)) { 428 Element service_rack_list = (Element)GSXML.getChildByTagName(cluster_config_elem, GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER); 429 430 success = configureServiceRack(service_rack_list, null); 431 } else if (subset.equals(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER)) { 432 this.metadata_list = this.doc.createElement(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 433 Element metadata_list = (Element)GSXML.getChildByTagName(cluster_config_elem, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 434 success = addMetadata(metadata_list); 435 } else { 436 System.err.println("ServiceCluster: cant process system request, configure "+subset); 437 } 438 439 String message=null; 440 if (success) { 441 message = "ServiceCluster: "+ subset + "reconfigured successfully"; 442 } else { 443 message = "ServiceCluster: Error in reconfiguring "+subset; 444 } 445 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, message); 446 response.appendChild(s); 447 } else { 448 String module_name = elem.getAttribute(GSXML.SYSTEM_MODULE_NAME_ATT); 449 String module_type = elem.getAttribute(GSXML.SYSTEM_MODULE_TYPE_ATT); 450 if (action.equals("activate")) { 451 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, module_type+": "+module_name+" activated -- not yet implemented"); 452 response.appendChild(s); 453 } else if (action.equals("deactivate")) { 454 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, module_type+": "+module_name+" deactivated -- not yet implemented"); 455 response.appendChild(s); 456 } else { 457 System.err.println("ServiceCluster: cant process system request, action "+action); 458 continue; 459 } 460 461 } 462 463 } // for each command 464 return response; 465 } 466 336 467 } 337 468
Note:
See TracChangeset
for help on using the changeset viewer.