41 |
41 |
* @author tao
|
42 |
42 |
*
|
43 |
43 |
*/
|
44 |
|
public class ApplicationController {
|
|
44 |
public class ApplicationController implements Runnable {
|
45 |
45 |
|
46 |
46 |
private static String SOLRINDEXES = "solrIndexes";
|
47 |
47 |
private static short FIRST = 0;
|
48 |
48 |
|
49 |
49 |
private List<SolrIndex> solrIndexes = null;
|
50 |
|
//private List<SystemMetadataEventListener> sysmetaListeners = new ArrayList<SystemMetadataEventListener>();
|
|
50 |
private List<SystemMetadataEventListener> sysmetaListeners = new ArrayList<SystemMetadataEventListener>();
|
51 |
51 |
private static ApplicationContext context = null;
|
52 |
52 |
private String springConfigFile = "src/main/resources/index-processor-context.xml";
|
53 |
53 |
Log log = LogFactory.getLog(ApplicationController.class);
|
... | ... | |
95 |
95 |
// start listening for events
|
96 |
96 |
SystemMetadataEventListener smel = new SystemMetadataEventListener();
|
97 |
97 |
smel.setSolrIndex(solrIndex);
|
98 |
|
smel.start();
|
99 |
|
//sysmetaListeners.add(smel);
|
|
98 |
sysmetaListeners.add(smel);
|
|
99 |
//smel.start();
|
100 |
100 |
}
|
101 |
101 |
|
102 |
102 |
}
|
... | ... | |
131 |
131 |
/**
|
132 |
132 |
* Start to generate indexes for those haven't been indexed in another thread.
|
133 |
133 |
*/
|
134 |
|
public void startIndex() {
|
|
134 |
private void startIndex() {
|
135 |
135 |
SolrIndex index = solrIndexes.get(FIRST);
|
136 |
136 |
//SystemMetadataEventListener listener = sysmetaListeners.get(FIRST);
|
137 |
137 |
IndexGenerator generator = new IndexGenerator(index);
|
138 |
138 |
Thread indexThread = new Thread(generator);
|
139 |
139 |
indexThread.start();
|
140 |
140 |
}
|
|
141 |
|
|
142 |
/**
|
|
143 |
* Start the system metadata listener
|
|
144 |
*/
|
|
145 |
public void startSysmetaListener() {
|
|
146 |
if(sysmetaListeners != null) {
|
|
147 |
//only expects one listener.
|
|
148 |
for(SystemMetadataEventListener listener : sysmetaListeners) {
|
|
149 |
if(listener != null) {
|
|
150 |
listener.start();
|
|
151 |
}
|
|
152 |
}
|
|
153 |
}
|
|
154 |
}
|
|
155 |
|
|
156 |
/**
|
|
157 |
* It will start system metadata event listener first. Then to generate indexes for those haven't been indexed in another thread.
|
|
158 |
*/
|
|
159 |
public void run() {
|
|
160 |
startSysmetaListener();
|
|
161 |
startIndex();//it will create another thread.
|
|
162 |
}
|
141 |
163 |
}
|
Use another thread in the Servlet init method to wait hazelcast.