Project

General

Profile

« Previous | Next » 

Revision 8292

Added by Jing Tao about 11 years ago

Clean up the code.

View differences:

metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/ApplicationController.java
202 202
     * It will create a timer to run this task periodically. 
203 203
     * If the property of "index.regenerate.interval" is less than 0, the thread would NOT run.
204 204
     */
205
    private void startIndex() {
205
    private void startIndexGenerator() {
206 206
        if(period > 0) {
207 207
            SolrIndex index = solrIndexes.get(FIRST);
208 208
            //SystemMetadataEventListener listener = sysmetaListeners.get(FIRST);
......
222 222
     * @throws ServiceFailure 
223 223
     * @throws FileNotFoundException 
224 224
     */
225
    public void startSysmetaListener() throws FileNotFoundException, ServiceFailure {
225
    private void startSysmetaListener() throws FileNotFoundException, ServiceFailure {
226 226
        if(sysmetaListeners != null) {
227 227
            //only expects one listener.
228 228
            for(SystemMetadataEventListener listener : sysmetaListeners) {
......
254 254
            }
255 255
            initialize();
256 256
            startSysmetaListener();
257
            startIndex();//it will create another thread.
257
            startIndexGenerator();//it will create another thread.
258 258
        } catch (Exception e) {
259 259
            log.error("Application.run "+e.getMessage());
260 260
        }
metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/IndexGenerator.java
85 85
    public static final String WAITIMEPOPERTYNAME = "index.regenerate.start.waitingtime";
86 86
    public static final String MAXATTEMPTSPROPERTYNAME = "index.regenerate.start.maxattempts";
87 87
    
88
    private static int waitingTime = WAITTIME;
89
    private static int maxAttempts = MAXWAITNUMBER;
90 88
    
91 89
    private SolrIndex solrIndex = null;
92 90
    //private SystemMetadataEventListener systemMetadataListener = null;
......
106 104
        resourceMapNamespaces = Settings.getConfiguration().getList(RESOURCEMAPPROPERYNAME);
107 105
        //this.systemMetadataListener = systemMetadataListener;
108 106
        //this.mNode = new MNode(buildMNBaseURL());
109
        try {
110
            waitingTime = Settings.getConfiguration().getInt(WAITIMEPOPERTYNAME);
111
            maxAttempts = Settings.getConfiguration().getInt(MAXATTEMPTSPROPERTYNAME);
112
        } catch (Exception e) {
113
            log.warn("IndexGenerator.constructor - couldn't read the waiting time or maxattempts from the metacat.properties file since : "+e.getMessage()+". Default values will be used");
114
            waitingTime = WAITTIME;
115
            maxAttempts = MAXWAITNUMBER;
116
        }
107
      
117 108
    }
118 109
    
119 110
    /**
......
720 711
        int times = 0;
721 712
        if(systemMetadataMap == null) {
722 713
            systemMetadataMap = DistributedMapsFactory.getSystemMetadataMap();
723
            /*while(true) {
724
                try {
725
                    systemMetadataMap = DistributedMapsFactory.getSystemMetadataMap();
726
                    break;
727
                } catch (FileNotFoundException e) {
728
                    throw e;
729
                } catch (ServiceFailure e) {
730
                    if(times <= maxAttempts) {
731
                        log.warn("IndexGenerator.initSystemMetadataMap - the hazelcast service is not ready : "
732
                                         +e.getMessage()+"\nWe will try to access it "+waitingTime/1000+" seconds later ");
733
                        try {
734
                            Thread.sleep(waitingTime);
735
                        } catch (Exception ee) {
736
                            log.warn("IndexGenerator.initSystemMetadataMap - the thread can't sleep for "+waitingTime/1000+" seconds to wait the hazelcast service");
737
                        }
738
                       
739
                    } else {
740
                        throw new ServiceFailure("0000", "IndexGenerator.initSystemMetadataMap - the hazelcast service is not ready even though Metacat-index wailted for "+maxAttempts*waitingTime/1000+" seconds. We can't get the system metadata from it and the building index can't happen this time");
741
                    }
742
                }
743
                times++;
744
            }*/
745 714
        }
746 715
    }
747 716
    

Also available in: Unified diff