Adding logging of search index builder progress.

This commit is contained in:
bdc34 2011-01-31 20:45:28 +00:00
parent e058b67072
commit 99daffa6de

View file

@ -161,7 +161,7 @@ public class IndexBuilder {
listOfIterators.add((((ObjectSourceIface) obj) listOfIterators.add((((ObjectSourceIface) obj)
.getAllOfThisTypeIterator())); .getAllOfThisTypeIterator()));
else else
log.debug("\tskipping object of class " log.warn("\tskipping object of class "
+ obj.getClass().getName() + "\n" + obj.getClass().getName() + "\n"
+ "\tIt doesn not implement ObjectSourceIface.\n"); + "\tIt doesn not implement ObjectSourceIface.\n");
} }
@ -169,7 +169,7 @@ public class IndexBuilder {
//clear out changed uris since we are doing a full index rebuild //clear out changed uris since we are doing a full index rebuild
getAndEmptyChangedUris(); getAndEmptyChangedUris();
if( listOfIterators.size() == 0){ log.debug("Warning: no ObjectSources found.");} if( listOfIterators.size() == 0){ log.warn("Warning: no ObjectSources found.");}
setReindexRequested(false); setReindexRequested(false);
doBuild( listOfIterators, Collections.EMPTY_LIST, true, NEW_DOCS ); doBuild( listOfIterators, Collections.EMPTY_LIST, true, NEW_DOCS );
@ -191,7 +191,7 @@ public class IndexBuilder {
listOfIterators.add((((ObjectSourceIface) obj) listOfIterators.add((((ObjectSourceIface) obj)
.getUpdatedSinceIterator(since))); .getUpdatedSinceIterator(since)));
else else
log.debug("\tskipping object of class " log.warn("\tskipping object of class "
+ obj.getClass().getName() + "\n" + obj.getClass().getName() + "\n"
+ "\tIt doesn not implement " + "ObjectSourceIface.\n"); + "\tIt doesn not implement " + "ObjectSourceIface.\n");
} }
@ -299,7 +299,7 @@ public class IndexBuilder {
while (sourceIters.hasNext()) { while (sourceIters.hasNext()) {
obj = sourceIters.next(); obj = sourceIters.next();
if (obj == null || !(obj instanceof Iterator)) { if (obj == null || !(obj instanceof Iterator)) {
log.debug("\tskipping object of class " log.warn("\tskipping object of class "
+ obj.getClass().getName() + "\n" + obj.getClass().getName() + "\n"
+ "\tIt doesn not implement " + "\tIt doesn not implement "
+ "Iterator.\n"); + "Iterator.\n");
@ -323,10 +323,23 @@ public class IndexBuilder {
*/ */
private void indexForSource(Iterator<Individual> individuals , boolean newDocs){ private void indexForSource(Iterator<Individual> individuals , boolean newDocs){
if( individuals == null ) return; if( individuals == null ) return;
long starttime = System.currentTimeMillis();
long count = 0;
while(individuals.hasNext()){ while(individuals.hasNext()){
indexItem(individuals.next(), newDocs); indexItem(individuals.next(), newDocs);
count++;
if( log.isDebugEnabled() ){
if( (count % 100 ) == 0 && count > 0 ){
long dt = (System.currentTimeMillis() - starttime);
log.debug("individuals indexed: " + count + " in " + dt + " msec " +
" time pre individual = " + (dt / count) + " msec");
} }
} }
}
log.info("individuals indexed: " + count + " in " + (System.currentTimeMillis() - starttime) + " msec" +
" time per individual = " + (System.currentTimeMillis() - starttime)/ count + " msec") ;
}
/** /**
* Use the backend indexer to index a single item. * Use the backend indexer to index a single item.
@ -340,24 +353,29 @@ public class IndexBuilder {
if( ind.getVClasses() == null || ind.getVClasses().size() < 1 ) if( ind.getVClasses() == null || ind.getVClasses().size() < 1 )
return; return;
boolean prohibitedClass = false; boolean prohibitedClass = false;
VClass prohClass = null;
if( classesProhibitedFromSearch != null ){ if( classesProhibitedFromSearch != null ){
for( VClass vclass : ind.getVClasses() ){ for( VClass vclass : ind.getVClasses() ){
if( classesProhibitedFromSearch.isClassProhibited(vclass.getURI()) ){ if( classesProhibitedFromSearch.isClassProhibited(vclass.getURI()) ){
prohibitedClass = true; prohibitedClass = true;
log.debug("removing " + ind.getURI() + " from index because class " + vclass.getURI() + " is on prohibited list."); prohClass = vclass;
break; break;
} }
} }
} }
if( !prohibitedClass ){ if( !prohibitedClass ){
log.debug("Indexing '" + ind.getName() + "' URI: " + ind.getURI());
indexer.index(ind, newDoc); indexer.index(ind, newDoc);
}else{ }else{
if( ! newDoc ){
//log.debug("removing " + ind.getURI() + " from index because class " + prohClass.getURI() + " is on prohibited list.");
indexer.removeFromIndex(ind); indexer.removeFromIndex(ind);
}else{
//log.debug("not adding " + ind.getURI() + " to index because class " + prohClass.getURI() + " is on prohibited list.");
}
} }
}catch(Throwable ex){ }catch(Throwable ex){
log.debug("IndexBuilder.indexItem() Error indexing " log.warn("IndexBuilder.indexItem() Error indexing "
+ ind + "\n" +ex); + ind + "\n" +ex);
} }
return ; return ;