120 |
120 |
try {
|
121 |
121 |
indexingMap.wait();
|
122 |
122 |
} catch (InterruptedException ex) {
|
123 |
|
System.err.println("Interrupted");
|
|
123 |
logMetacat.error("Interrupted");
|
124 |
124 |
}
|
125 |
125 |
}
|
126 |
126 |
|
... | ... | |
132 |
132 |
}
|
133 |
133 |
return returnVal;
|
134 |
134 |
}
|
|
135 |
|
|
136 |
/**
|
|
137 |
* Removes the Indexing Task object from the queue
|
|
138 |
* for the given docid. Currently, rev is ignored
|
|
139 |
* This method should be used to cancel scheduled indexing on a document
|
|
140 |
* (typically if it is being deleted but indexing has not completed yet)
|
|
141 |
* see http://bugzilla.ecoinformatics.org/show_bug.cgi?id=5750
|
|
142 |
* @param docid the docid (without revision)
|
|
143 |
* @param rev the docid's rev (ignored)
|
|
144 |
*/
|
|
145 |
public void remove(String docid, String rev) {
|
|
146 |
synchronized (indexingMap) {
|
|
147 |
if (indexingMap.containsKey(docid)) {
|
|
148 |
indexingMap.remove(docid);
|
|
149 |
}
|
|
150 |
}
|
|
151 |
}
|
135 |
152 |
|
136 |
153 |
}
|
137 |
154 |
|
... | ... | |
157 |
174 |
public void run() {
|
158 |
175 |
while (metacatRunning) {
|
159 |
176 |
// blocks until job
|
160 |
|
IndexingQueueObject returnVal =
|
|
177 |
IndexingQueueObject indexQueueObject =
|
161 |
178 |
IndexingQueue.getInstance().getNext();
|
162 |
179 |
|
163 |
|
if(returnVal != null){
|
|
180 |
if(indexQueueObject != null){
|
164 |
181 |
if(!IndexingQueue.getInstance().
|
165 |
|
currentDocidsBeingIndexed.contains(returnVal.getDocid())){
|
|
182 |
currentDocidsBeingIndexed.contains(indexQueueObject.getDocid())){
|
166 |
183 |
try {
|
167 |
184 |
IndexingQueue.getInstance().
|
168 |
|
currentDocidsBeingIndexed.add(returnVal.getDocid());
|
169 |
|
String docid = returnVal.getDocid() + "." + returnVal.getRev();
|
|
185 |
currentDocidsBeingIndexed.add(indexQueueObject.getDocid());
|
|
186 |
String docid = indexQueueObject.getDocid() + "." + indexQueueObject.getRev();
|
170 |
187 |
if(checkDocumentTable(docid, "xml_documents")){
|
171 |
188 |
logMetacat.warn("Calling buildIndex for " + docid);
|
172 |
189 |
DocumentImpl doc = new DocumentImpl(docid, false);
|
... | ... | |
183 |
200 |
logMetacat.warn("Exception: " + e);
|
184 |
201 |
e.printStackTrace();
|
185 |
202 |
|
186 |
|
if(returnVal.getCount() < 25){
|
187 |
|
returnVal.setCount(returnVal.getCount()+1);
|
|
203 |
if(indexQueueObject.getCount() < 25){
|
|
204 |
indexQueueObject.setCount(indexQueueObject.getCount()+1);
|
188 |
205 |
// add the docid back to the list
|
189 |
|
IndexingQueue.getInstance().add(returnVal);
|
|
206 |
IndexingQueue.getInstance().add(indexQueueObject);
|
190 |
207 |
} else {
|
191 |
|
logMetacat.fatal("Docid " + returnVal.getDocid()
|
|
208 |
logMetacat.fatal("Docid " + indexQueueObject.getDocid()
|
192 |
209 |
+ " has been inserted to IndexingQueue "
|
193 |
210 |
+ "more than 25 times. Not adding the docid to"
|
194 |
211 |
+ " the queue again.");
|
195 |
212 |
}
|
196 |
213 |
} finally {
|
197 |
214 |
IndexingQueue.getInstance().currentDocidsBeingIndexed
|
198 |
|
.remove(returnVal.getDocid());
|
|
215 |
.remove(indexQueueObject.getDocid());
|
199 |
216 |
}
|
200 |
217 |
} else {
|
201 |
|
returnVal.setCount(returnVal.getCount()+1);
|
202 |
|
IndexingQueue.getInstance().add(returnVal);
|
|
218 |
indexQueueObject.setCount(indexQueueObject.getCount()+1);
|
|
219 |
IndexingQueue.getInstance().add(indexQueueObject);
|
203 |
220 |
}
|
204 |
221 |
}
|
205 |
222 |
}
|
remove document from the indexing queue when delete is called. http://bugzilla.ecoinformatics.org/show_bug.cgi?id=5750