32 |
32 |
import java.io.File;
|
33 |
33 |
import java.util.ArrayList;
|
34 |
34 |
import java.util.List;
|
|
35 |
import java.util.Timer;
|
35 |
36 |
|
36 |
37 |
import javax.servlet.ServletConfig;
|
37 |
38 |
import javax.servlet.ServletException;
|
... | ... | |
46 |
47 |
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
47 |
48 |
|
48 |
49 |
import com.hazelcast.client.HazelcastClient;
|
|
50 |
import com.ibm.icu.util.Calendar;
|
49 |
51 |
|
50 |
52 |
/**
|
51 |
53 |
* The start class of the index.
|
... | ... | |
54 |
56 |
*/
|
55 |
57 |
public class ApplicationController implements Runnable {
|
56 |
58 |
|
|
59 |
private static long DEFAULTINTERVAL = 7200000;
|
57 |
60 |
private static String SOLRINDEXES = "solrIndexes";
|
58 |
61 |
private static short FIRST = 0;
|
59 |
62 |
|
... | ... | |
64 |
67 |
private String metacatPropertiesFile = null;
|
65 |
68 |
private static int waitingTime = IndexGenerator.WAITTIME;
|
66 |
69 |
private static int maxAttempts = IndexGenerator.MAXWAITNUMBER;
|
|
70 |
private static long period = DEFAULTINTERVAL;
|
67 |
71 |
Log log = LogFactory.getLog(ApplicationController.class);
|
68 |
72 |
|
69 |
73 |
|
... | ... | |
95 |
99 |
*/
|
96 |
100 |
private void initializeSharedConfiguration() {
|
97 |
101 |
int times = 0;
|
|
102 |
boolean foundProperty = false;
|
98 |
103 |
while(true) {
|
99 |
104 |
File metacatProperties = new File(metacatPropertiesFile);
|
100 |
105 |
if(metacatProperties.exists()) {
|
|
106 |
foundProperty = true;
|
101 |
107 |
break;
|
102 |
108 |
} else {
|
103 |
109 |
try {
|
... | ... | |
137 |
143 |
//if we don't set this property, d1_cn_index_processor will use the default location /etc/dataone/storage.
|
138 |
144 |
Settings.getConfiguration().setProperty("dataone.hazelcast.location.clientconfig", hzConfigFileName);
|
139 |
145 |
}
|
|
146 |
if(foundProperty) {
|
|
147 |
period = Settings.getConfiguration().getLong("index.regenerate.interval");
|
|
148 |
}
|
|
149 |
|
140 |
150 |
}
|
141 |
151 |
|
142 |
152 |
/**
|
... | ... | |
199 |
209 |
|
200 |
210 |
/**
|
201 |
211 |
* Start to generate indexes for those haven't been indexed in another thread.
|
|
212 |
* It will create a timer to run this task periodically.
|
|
213 |
* If the property of "index.regenerate.interval" is less than 0, the thread would NOT run.
|
202 |
214 |
*/
|
203 |
215 |
private void startIndex() {
|
204 |
|
SolrIndex index = solrIndexes.get(FIRST);
|
205 |
|
//SystemMetadataEventListener listener = sysmetaListeners.get(FIRST);
|
206 |
|
IndexGenerator generator = new IndexGenerator(index);
|
207 |
|
Thread indexThread = new Thread(generator);
|
208 |
|
indexThread.start();
|
|
216 |
if(period > 0) {
|
|
217 |
SolrIndex index = solrIndexes.get(FIRST);
|
|
218 |
//SystemMetadataEventListener listener = sysmetaListeners.get(FIRST);
|
|
219 |
IndexGenerator generator = new IndexGenerator(index);
|
|
220 |
//Thread indexThread = new Thread(generator);
|
|
221 |
//indexThread.start();
|
|
222 |
Timer indexTimer = new Timer();
|
|
223 |
indexTimer.scheduleAtFixedRate(generator, Calendar.getInstance().getTime(), period);
|
|
224 |
}
|
|
225 |
|
209 |
226 |
}
|
210 |
227 |
|
211 |
228 |
/**
|
Set up a Timer to run the regenerating solr index task periodically.