Project

General

Profile

« Previous | Next » 

Revision 7690

Added by Jing Tao over 11 years ago

Use the DistributedMapsFactory to get maps.

View differences:

metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SystemMetadataEventListener.java
52 52
	
53 53
	private SolrIndex solrIndex = null;
54 54
	
55
	private HazelcastClient hzClient;
55
	//private HazelcastClient hzClient;
56 56

  
57 57
    private IMap<Identifier, SystemMetadata> systemMetadataMap;
58 58
    
......
96 96
     */
97 97
    public void start() {
98 98
    	
99
    	// get config values
100
        String hzSystemMetadata = Settings.getConfiguration().getString(
101
                "dataone.hazelcast.storageCluster.systemMetadataMap");
102
        String hzObjectPath = Settings.getConfiguration().getString(
103
                "dataone.hazelcast.storageCluster.objectPathMap");
104
        String configFileName = Settings.getConfiguration().getString(
105
        		"dataone.hazelcast.configFilePath");;
106
    	Config hzConfig = null;
107
		try {
108
    		hzConfig = new FileSystemXmlConfig(configFileName);
109
    	} catch (FileNotFoundException e) {
110
    		log.error("could not load hazelcast configuration file from: " + configFileName, e);
111
			//e.printStackTrace();
112
    	}
113
		
114
        String hzGroupName = hzConfig.getGroupConfig().getName();
115
        String hzGroupPassword = hzConfig.getGroupConfig().getPassword();
116
        String hzAddress = hzConfig.getNetworkConfig().getInterfaces().getInterfaces().iterator().next() + ":" + hzConfig.getNetworkConfig().getPort();
99
        try {
100
            // get shared structures and add listener
101
            this.systemMetadataMap =  DistributedMapsFactory.getSystemMetadataMap();
102
            this.objectPathMap = DistributedMapsFactory.getObjectPathMap();
117 103

  
118
    	log.info("starting index entry listener...");
119
    	log.info("System Metadata value: " + hzSystemMetadata);
120
    	log.info("Object path value: " + hzObjectPath);
121
    	log.info("Group Name: " + hzGroupName);
122
    	log.info("Group Password: " + "*****"); // don't show value
123
    	log.info("HZ Address: " + hzAddress);
124

  
125
    	// connect to the HZ cluster
126
        ClientConfig cc = new ClientConfig();
127
		cc.getGroupConfig().setName(hzGroupName);
128
		cc.getGroupConfig().setPassword(hzGroupPassword);
129
		cc.addAddress(hzAddress);
130
        try {
131
        	this.hzClient = HazelcastClient.newHazelcastClient(cc);
132 104
        } catch (Exception e) {
133 105
            log.error("Unable to create hazelcast client: ", e);
134 106
            e.printStackTrace();
135 107
        }
136 108
        
137
        // get shared structures and add listener
138
        this.systemMetadataMap = this.hzClient.getMap(hzSystemMetadata);
139
        this.objectPathMap = this.hzClient.getMap(hzObjectPath);
140 109
        this.systemMetadataMap.addEntryListener(this, true);
141

  
142 110
        log.info("System Metadata size: " + this.systemMetadataMap.size());
143 111
        log.info("Object path size:" + this.objectPathMap.size());
144 112
    }

Also available in: Unified diff