Revision 7687
Added by Jing Tao over 11 years ago
metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/IndexGenerator.java | ||
---|---|---|
59 | 59 |
*/ |
60 | 60 |
public class IndexGenerator implements Runnable { |
61 | 61 |
|
62 |
private static final int WAITTIME = 10000; |
|
63 |
private static final int MAXWAITNUMBER = 180; |
|
62 | 64 |
private static final String HTTP = "http://"; |
63 | 65 |
private static final String MNAPPENDIX = "/d1/mn"; |
64 | 66 |
private SolrIndex solrIndex = null; |
... | ... | |
149 | 151 |
log.info("the solr ids -----------------------------"+solrIds); |
150 | 152 |
metacatIds = getMetadataIds(since, until); |
151 | 153 |
log.info("the metacat ids -----------------------------"+metacatIds); |
152 |
if(metacatIds != null) { |
|
154 |
/*if(metacatIds != null) {
|
|
153 | 155 |
for(String metacatId : metacatIds) { |
154 | 156 |
if(metacatId != null) { |
155 | 157 |
boolean buildIndex = true; |
... | ... | |
167 | 169 |
} |
168 | 170 |
} |
169 | 171 |
} |
170 |
} |
|
172 |
}*/
|
|
171 | 173 |
} |
172 | 174 |
|
173 | 175 |
public void run() { |
... | ... | |
215 | 217 |
InvalidToken, NotAuthorized, NotImplemented, ServiceFailure { |
216 | 218 |
List<String> ids = new ArrayList(); |
217 | 219 |
ObjectList objects = null; |
220 |
int times = 0; |
|
221 |
while (true) { |
|
222 |
try { |
|
223 |
mNode.ping(); |
|
224 |
break; |
|
225 |
} catch (Exception e) { |
|
226 |
if(times <= MAXWAITNUMBER) { |
|
227 |
log.warn("IndexGenerator.getMetadataIds - the mnode "+ mNode.getNodeBaseServiceUrl()+ |
|
228 |
" is not ready :" +e.getMessage()+"\nWe will try to access it 10 seconds later "); |
|
229 |
try { |
|
230 |
Thread.sleep(WAITTIME); |
|
231 |
} catch (Exception ee) { |
|
232 |
log.warn("IndexGenerator.getMetadataIds - the thread can't sleep for 10 seconds to wait the MNode"); |
|
233 |
} |
|
234 |
|
|
235 |
} else { |
|
236 |
throw new ServiceFailure("503", "IndexGenerator.getMetadataIds - the mnode "+ mNode.getNodeBaseServiceUrl()+ |
|
237 |
" is not ready even though Metacat-index wailted for 30 minutes. We can't get the objects list from it and the building index can't happen this time"); |
|
238 |
} |
|
239 |
|
|
240 |
} |
|
241 |
times++; |
|
242 |
} |
|
218 | 243 |
if(since == null && until == null) { |
219 | 244 |
objects = mNode.listObjects(); |
220 | 245 |
} else { |
Also available in: Unified diff
Add code to wait the startup of the MNode.