Project

General

Profile

« Previous | Next » 

Revision 8184

change hazelcast group name to match the current context. https://projects.ecoinformatics.org/ecoinfo/issues/5624

View differences:

src/edu/ucsb/nceas/metacat/admin/PropertiesAdmin.java
292 292
						validationErrors.add(errorString);
293 293
					}
294 294
				}
295
				
295 296
				//modify some params of the index context
296
				 modifyIndexContextParams(indexContext);
297
				this.modifyIndexContextParams(indexContext);
297 298
				
299
				// make sure hazelcast.xml uses a unique group name
300
				this.modifyHazelcastConfig();
301
				
298 302
				// write the backup properties to a location outside the 
299 303
				// application directories so they will be available after
300 304
				// the next upgrade
......
346 350
		}
347 351
	}
348 352
	
349
	/*
353
	/**
350 354
	 * In the web.xml of the Metacat-index context, there is a parameter:
351 355
	 * <context-param>
352 356
     * <param-name>metacat.properties.path</param-name>
......
382 386
            }
383 387
	    }
384 388
	}
389
	
390
	/**
391
	 * Changes the Hazelcast group name to match the current context
392
	 * This ensures we do not share the same group if multiple Metacat 
393
	 * instances are running in the same Tomcat container.
394
	 */
395
	private void modifyHazelcastConfig() {
396
        try {
397
            String metacatContext = PropertyService.getProperty("application.context");
398
            //System.out.println("the metacat context is ========================="+metacatContext);
399
            if (metacatContext != null) {
400
                String hzConfigFile = 
401
                                PropertyService.getProperty("application.deployDir")
402
                                + FileUtil.getFS()
403
                                + metacatContext
404
                                + FileUtil.getFS() 
405
                                + "WEB-INF"
406
                                + FileUtil.getFS()
407
                                + "hazelcast.xml";
408
                //System.out.println("============================== the web.xml file is "+indexConfigFile);
409
                String configContents = FileUtil.readFileToString(hzConfigFile, "UTF-8");
410
                //System.out.println("============================== the content of web.xml file is "+configContents);
411
                configContents = configContents.replace("<name>DataONE</name>", "<name>" + metacatContext + "</name>");
412
                FileUtil.writeFile(hzConfigFile, new StringReader(configContents), "UTF-8");
413
            }
414
            
415
        } catch (Exception e) {
416
            String errorMessage = "PropertiesAdmin.configureProperties - Problem setting groupName in hazelcast.xml: " + e.getMessage();
417
            logMetacat.error(errorMessage);
418
        }
419
	}
385 420

  
386 421
	/**
387 422
	 * Validate the most important configuration options submitted by the user.

Also available in: Unified diff