Project

General

Profile

« Previous | Next » 

Revision 7562

lookup the hz client connection information from the hazelcast.xml file being used by metacat. https://projects.ecoinformatics.org/ecoinfo/issues/5909

View differences:

metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SystemMetadataEventListener.java
27 27
package edu.ucsb.nceas.metacat.index;
28 28

  
29 29
import java.io.FileInputStream;
30
import java.io.FileNotFoundException;
30 31
import java.io.InputStream;
31 32

  
32 33
import org.apache.commons.logging.Log;
......
37 38

  
38 39
import com.hazelcast.client.ClientConfig;
39 40
import com.hazelcast.client.HazelcastClient;
41
import com.hazelcast.config.Config;
42
import com.hazelcast.config.FileSystemXmlConfig;
40 43
import com.hazelcast.core.EntryEvent;
41 44
import com.hazelcast.core.EntryListener;
42 45
import com.hazelcast.core.IMap;
......
93 96
    	
94 97
    	// get config values
95 98
        String hzSystemMetadata = Settings.getConfiguration().getString(
96
                "dataone.hazelcast.systemMetadata");
99
                "dataone.hazelcast.storageCluster.systemMetadataMap");
97 100
        String hzObjectPath = Settings.getConfiguration().getString(
98
                "dataone.hazelcast.objectPath");
99
        String hzGroupName = Settings.getConfiguration().getString(
100
                "dataone.hazelcast.groupName");
101
        String hzGroupPassword = Settings.getConfiguration().getString(
102
                "dataone.hazelcast.groupPassword");
103
        String hzAddress = Settings.getConfiguration().getString(
104
                "dataone.hazelcast.address");
101
                "dataone.hazelcast.storageCluster.objectPathMap");
102
        
103
        String configFileName = null;
104
    	Config hzConfig = null;
105
		try {
106
    		configFileName = Settings.getConfiguration().getString("dataone.hazelcast.configFilePath");
107
    		hzConfig = new FileSystemXmlConfig(configFileName);
108
    	} catch (Exception e) {
109
    		// use default metacat hazelcast.xml file in metacat deployment
110
    		configFileName = 
111
    				Settings.getConfiguration().getString("application.deployDir") +
112
    				Settings.getConfiguration().getString("application.context") + 
113
    				"/WEB-INF/hazelcast.xml";
114
    		try {
115
				hzConfig = new FileSystemXmlConfig(configFileName);
116
			} catch (FileNotFoundException fnfe) {
117
				// TODO: anything we can do here?
118
				fnfe.printStackTrace();
119
			}
120
    	}
121
		
122
        String hzGroupName = hzConfig.getGroupConfig().getName();
123
        String hzGroupPassword = hzConfig.getGroupConfig().getPassword();
124
        String hzAddress = hzConfig.getNetworkConfig().getInterfaces().getInterfaces().iterator().next() + ":" + hzConfig.getNetworkConfig().getPort();
105 125

  
106 126
    	log.info("starting index entry listener...");
107 127
    	log.info("System Metadata value: " + hzSystemMetadata);
......
114 134
        ClientConfig cc = new ClientConfig();
115 135
		cc.getGroupConfig().setName(hzGroupName);
116 136
		cc.getGroupConfig().setPassword(hzGroupPassword);
117
		cc.addAddress(hzAddress );
137
		cc.addAddress(hzAddress);
118 138
        try {
119 139
        	this.hzClient = HazelcastClient.newHazelcastClient(cc);
120 140
        } catch (Exception e) {

Also available in: Unified diff