working on memory leak NIHVIVO-2782
This commit is contained in:
parent
025fb1b435
commit
1031455e4c
9 changed files with 98 additions and 37 deletions
|
@ -13,6 +13,7 @@ import org.apache.commons.logging.LogFactory;
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
import com.hp.hpl.jena.ontology.OntModelSpec;
|
import com.hp.hpl.jena.ontology.OntModelSpec;
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
|
import com.hp.hpl.jena.query.QueryExecution;
|
||||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||||
import com.hp.hpl.jena.query.QueryFactory;
|
import com.hp.hpl.jena.query.QueryFactory;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
@ -74,9 +75,12 @@ public class ObjectPropertyStatementDaoSDB extends
|
||||||
DatasetWrapper w = dwf.getDatasetWrapper();
|
DatasetWrapper w = dwf.getDatasetWrapper();
|
||||||
Dataset dataset = w.getDataset();
|
Dataset dataset = w.getDataset();
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
|
QueryExecution qexec = null;
|
||||||
try {
|
try {
|
||||||
m = QueryExecutionFactory.create(QueryFactory.create(query), dataset).execConstruct();
|
qexec = QueryExecutionFactory.create(QueryFactory.create(query), dataset);
|
||||||
|
m = qexec.execConstruct();
|
||||||
} finally {
|
} finally {
|
||||||
|
if(qexec != null) qexec.close();
|
||||||
dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
w.close();
|
w.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,11 @@ public class VitroRequestPrep implements Filter {
|
||||||
//This will replace the WebappDaoFactory with a different version if menu management parameter is found
|
//This will replace the WebappDaoFactory with a different version if menu management parameter is found
|
||||||
wdf = checkForSpecialWDF(vreq, wdf);
|
wdf = checkForSpecialWDF(vreq, wdf);
|
||||||
|
|
||||||
|
// request.setAttribute("aboxModel", setspeicalABoxModel)
|
||||||
|
// request.setAttribute("tboxModel", speicalTboxModel)
|
||||||
|
// request.setAttribute("infModel", speicalInfModel) (maybe?)
|
||||||
|
// request.setAttribute("displayModel", displayModel)
|
||||||
|
|
||||||
VitroFilters filters = null;
|
VitroFilters filters = null;
|
||||||
|
|
||||||
filters = getFiltersFromContextFilterFactory(req, wdf);
|
filters = getFiltersFromContextFilterFactory(req, wdf);
|
||||||
|
|
|
@ -146,6 +146,7 @@ public class IndexBuilder extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
indexer.abortIndexingAndCleanUp();
|
||||||
|
|
||||||
if(log != null )//may be null on shutdown
|
if(log != null )//may be null on shutdown
|
||||||
log.info("Stopping IndexBuilder thread");
|
log.info("Stopping IndexBuilder thread");
|
||||||
|
|
|
@ -36,6 +36,7 @@ import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
||||||
|
|
||||||
public class CalculateParameters implements DocumentModifier {
|
public class CalculateParameters implements DocumentModifier {
|
||||||
|
|
||||||
|
private boolean shutdown = false;
|
||||||
private Dataset dataset;
|
private Dataset dataset;
|
||||||
public static int totalInd=1;
|
public static int totalInd=1;
|
||||||
protected Map<String,Float> betaMap = new Hashtable<String,Float>();
|
protected Map<String,Float> betaMap = new Hashtable<String,Float>();
|
||||||
|
@ -91,10 +92,10 @@ public class CalculateParameters implements DocumentModifier {
|
||||||
Resource uriResource = ResourceFactory.createResource(uri);
|
Resource uriResource = ResourceFactory.createResource(uri);
|
||||||
initialBinding.add("uri", uriResource);
|
initialBinding.add("uri", uriResource);
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
|
QueryExecution qexec=null;
|
||||||
try{
|
try{
|
||||||
query = QueryFactory.create(betaQuery,Syntax.syntaxARQ);
|
query = QueryFactory.create(betaQuery,Syntax.syntaxARQ);
|
||||||
QueryExecution qexec = QueryExecutionFactory.create(query,dataset,initialBinding);
|
qexec = QueryExecutionFactory.create(query,dataset,initialBinding);
|
||||||
ResultSet results = qexec.execSelect();
|
ResultSet results = qexec.execSelect();
|
||||||
List<String> resultVars = results.getResultVars();
|
List<String> resultVars = results.getResultVars();
|
||||||
if(resultVars!=null && resultVars.size()!=0){
|
if(resultVars!=null && resultVars.size()!=0){
|
||||||
|
@ -102,8 +103,11 @@ public class CalculateParameters implements DocumentModifier {
|
||||||
Conn = Integer.parseInt(soln.getLiteral(resultVars.get(0)).getLexicalForm());
|
Conn = Integer.parseInt(soln.getLiteral(resultVars.get(0)).getLexicalForm());
|
||||||
}
|
}
|
||||||
}catch(Throwable t){
|
}catch(Throwable t){
|
||||||
|
if( ! shutdown )
|
||||||
log.error(t,t);
|
log.error(t,t);
|
||||||
}finally{
|
}finally{
|
||||||
|
if( qexec != null )
|
||||||
|
qexec.close();
|
||||||
dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,6 +242,7 @@ public class CalculateParameters implements DocumentModifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
if( ! shutdown )
|
||||||
log.error("Error found in getAdjacentNodes method of SearchQueryHandler");
|
log.error("Error found in getAdjacentNodes method of SearchQueryHandler");
|
||||||
}finally{
|
}finally{
|
||||||
qexec.close();
|
qexec.close();
|
||||||
|
@ -260,6 +265,7 @@ public class CalculateParameters implements DocumentModifier {
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(Throwable t){
|
catch(Throwable t){
|
||||||
|
if( ! shutdown )
|
||||||
log.error(t,t);
|
log.error(t,t);
|
||||||
}finally{
|
}finally{
|
||||||
dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
|
@ -285,16 +291,19 @@ public class CalculateParameters implements DocumentModifier {
|
||||||
|
|
||||||
for(String term: fieldsToAddBetaTo){
|
for(String term: fieldsToAddBetaTo){
|
||||||
SolrInputField f = doc.getField( term );
|
SolrInputField f = doc.getField( term );
|
||||||
f.setBoost( getBeta(uri) + phi + IndividualToSolrDocument.NAME_BOOST);
|
float orgBoost = f.getBoost();
|
||||||
|
f.setBoost( getBeta(uri) + phi + orgBoost );
|
||||||
}
|
}
|
||||||
|
|
||||||
for(String term: fieldsToMultiplyBetaBy){
|
for(String term: fieldsToMultiplyBetaBy){
|
||||||
SolrInputField f = doc.getField( term );
|
SolrInputField f = doc.getField( term );
|
||||||
f.addValue(info.toString(),getBeta(uri)*phi*IndividualToSolrDocument.ALL_TEXT_BOOST);
|
//f.addValue(info.toString(),getBeta(uri)*phi*IndividualToSolrDocument.ALL_TEXT_BOOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
SolrInputField f = doc.getField(VitroSearchTermNames.targetInfo);
|
|
||||||
f.addValue(adjInfo[1],f.getBoost());
|
//SolrInputField f = doc.getField(VitroSearchTermNames.targetInfo);
|
||||||
|
//f.addValue(adjInfo[1],f.getBoost());
|
||||||
|
|
||||||
doc.setDocumentBoost(getBeta(uri)*phi*IndividualToSolrDocument.ALL_TEXT_BOOST);
|
doc.setDocumentBoost(getBeta(uri)*phi*IndividualToSolrDocument.ALL_TEXT_BOOST);
|
||||||
|
|
||||||
log.debug("Parameter calculation is done");
|
log.debug("Parameter calculation is done");
|
||||||
|
@ -304,6 +313,9 @@ public class CalculateParameters implements DocumentModifier {
|
||||||
betaMap.clear();
|
betaMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void shutdown(){
|
||||||
|
shutdown=true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TotalInd implements Runnable{
|
class TotalInd implements Runnable{
|
||||||
|
@ -321,10 +333,11 @@ class TotalInd implements Runnable{
|
||||||
Query query;
|
Query query;
|
||||||
QuerySolution soln = null;
|
QuerySolution soln = null;
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
|
QueryExecution qexec = null;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
query = QueryFactory.create(totalCountQuery,Syntax.syntaxARQ);
|
query = QueryFactory.create(totalCountQuery,Syntax.syntaxARQ);
|
||||||
QueryExecution qexec = QueryExecutionFactory.create(query,dataset);
|
qexec = QueryExecutionFactory.create(query,dataset);
|
||||||
ResultSet results = qexec.execSelect();
|
ResultSet results = qexec.execSelect();
|
||||||
List<String> resultVars = results.getResultVars();
|
List<String> resultVars = results.getResultVars();
|
||||||
|
|
||||||
|
@ -337,8 +350,12 @@ class TotalInd implements Runnable{
|
||||||
}catch(Throwable t){
|
}catch(Throwable t){
|
||||||
log.error(t,t);
|
log.error(t,t);
|
||||||
}finally{
|
}finally{
|
||||||
|
if( qexec != null )
|
||||||
|
qexec.close();
|
||||||
dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
||||||
public class ContextNodeFields implements DocumentModifier{
|
public class ContextNodeFields implements DocumentModifier{
|
||||||
private Model model;
|
private Model model;
|
||||||
|
|
||||||
|
private boolean shutdown = false;
|
||||||
private static ExecutorService threadPool = null;
|
private static ExecutorService threadPool = null;
|
||||||
private static final int THREAD_POOL_SIZE = 10;
|
private static final int THREAD_POOL_SIZE = 10;
|
||||||
|
|
||||||
|
@ -134,6 +135,7 @@ public class ContextNodeFields implements DocumentModifier{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(Throwable t){
|
}catch(Throwable t){
|
||||||
|
if( ! shutdown )
|
||||||
log.error(t,t);
|
log.error(t,t);
|
||||||
} finally{
|
} finally{
|
||||||
qExec.close();
|
qExec.close();
|
||||||
|
@ -437,4 +439,7 @@ public class ContextNodeFields implements DocumentModifier{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void shutdown(){
|
||||||
|
shutdown=true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,4 +12,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
public interface DocumentModifier {
|
public interface DocumentModifier {
|
||||||
public void modifyDocument(Individual individual, SolrInputDocument doc, StringBuffer addUri);
|
public void modifyDocument(Individual individual, SolrInputDocument doc, StringBuffer addUri);
|
||||||
|
|
||||||
|
//called to inform the DocumentModifier that the system is shutting down
|
||||||
|
public void shutdown();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,6 +315,17 @@ public class IndividualToSolrDocument {
|
||||||
return ent;
|
return ent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void shutdown(){
|
||||||
|
for(DocumentModifier dm: documentModifiers){
|
||||||
|
try{
|
||||||
|
dm.shutdown();
|
||||||
|
}catch(Exception e){
|
||||||
|
if( log != null)
|
||||||
|
log.debug(e,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void fillContextNodes(){
|
private void fillContextNodes(){
|
||||||
IndividualToSolrDocument.contextNodeClassNames.add("Role");
|
IndividualToSolrDocument.contextNodeClassNames.add("Role");
|
||||||
IndividualToSolrDocument.contextNodeClassNames.add("AttendeeRole");
|
IndividualToSolrDocument.contextNodeClassNames.add("AttendeeRole");
|
||||||
|
|
|
@ -158,8 +158,25 @@ public class SolrIndexer implements IndexerIface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void abortIndexingAndCleanUp() {
|
public void abortIndexingAndCleanUp() {
|
||||||
endIndexing();
|
try{
|
||||||
|
server.commit();
|
||||||
|
}catch(SolrServerException e){
|
||||||
|
if( log != null)
|
||||||
|
log.debug("could not commit to solr server, " +
|
||||||
|
"this should not be a problem since solr will do autocommit");
|
||||||
|
} catch (IOException e) {
|
||||||
|
if( log != null)
|
||||||
|
log.debug("could not commit to solr server, " +
|
||||||
|
"this should not be a problem since solr will do autocommit");
|
||||||
}
|
}
|
||||||
|
try{
|
||||||
|
individualToSolrDoc.shutdown();
|
||||||
|
}catch(Exception e){
|
||||||
|
if( log != null)
|
||||||
|
log.warn(e,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void endIndexing() {
|
public synchronized void endIndexing() {
|
||||||
|
@ -179,11 +196,13 @@ public class SolrIndexer implements IndexerIface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
server.optimize();
|
server.optimize();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Could not optimize solr server", e);
|
log.error("Could not optimize solr server", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
indexing = false;
|
indexing = false;
|
||||||
notifyAll();
|
notifyAll();
|
||||||
}
|
}
|
||||||
|
@ -215,8 +234,4 @@ public class SolrIndexer implements IndexerIface {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -563,7 +563,7 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
return TYPE;
|
return TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTemplate() {
|
public String Template() {
|
||||||
return config.templateName;
|
return config.templateName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue