I have been working on code that will harvest a thumbnail from ArcSDE
and store it with the harvested metadata. I had this working a couple
of months ago (prior to the shift over to github), but now it is
causing the database within Geonetwork to lock up - it would appear
that it is not releasing the lock for the database for some weird
reason. I was wondering if anyone had any idea as to why this might be
happening?
This version of the code is working on the 2.8.0 RC0 branch of
Geonetwork, up to date as of last week. Deployment is being done on a
Windows Server 2008 box.
I am definitely pulling out the image correctly and storing it in the
upload (tmp) directory for later use. I then call the following method
if a thumbnail was harvested to store it with the metadata entry being
harvested. This call is made at the end of the loop for adding /
updating metadata for a harvested entry (right above
idsForHarvestingResult.add(id);).
public void AddThumbnail(ServiceContext context, Dbms dbms,
DataManager dataMan, String id) {
try {
Set s = new org.fao.geonet.services.thumbnail.Set();
Element par = new Element("request");
par.addContent(new Element("id").setText(id));
par.addContent(new Element("version").setText("10"));
par.addContent(new Element("type").setText("large"));
par.addContent(new Element("scalingDir").setText("both"));
par.addContent(new Element("scalingFactor").setText("2"));
//where thumbFile is the name of the harvested thumbnail
Element fname = new Element("fname").setText(thumbFile);
fname.setAttribute("content-type", "image/bmp");
fname.setAttribute("type", "file");
fname.setAttribute("size", "");
par.addContent(fname);
par.addContent(new Element("add").setText("Add"));
par.addContent(new Element("createSmall").setText("on"));
par.addContent(new Element("smallScalingFactor").setText("1"));
par.addContent(new Element("smallScalingDir").setText("both"));
s.execOnHarvest(par, context, dbms, dataMan);
dbms.commit();
} catch(Exception ex) { e.printStackTrace(); }
}
When the call to this method is made the thumbnail is copied to
WEB-INF/data/data/metadata_data/approriate_folder. However, the next
call to add metadata causes the following error:
org.h2.jdbc.JdbcSQLException: Timout trying to lock table "METADATA";
SQL statement:
SELECT id FROM Metadata WHERE uuid=? [50500-152]
If I remove the call to this method then the thumbnails are still
added to the upload (tmp) directory but not added to the metadata and
the rest of the harvesting works correctly. I cannot see any reason
for the database to lock like this. Is there something I am missing?
Elgar Storm
It is not easy to say for sure but so long as the DBMS object is not freed there is likely locks on the tables. If the process is a long process then I think you need to release the dbms object each loop. Or perhaps the Harvester doesn’t correctly release the dbms when done or in the case of an exception.
It is critical to open and close dbms objects only when used to prevent resource leaks as well and release database locks.
Jesse
On Thu, Sep 13, 2012 at 2:31 AM, Elgar Storm <elgarstorm@anonymised.com> wrote:
I have been working on code that will harvest a thumbnail from ArcSDE
and store it with the harvested metadata. I had this working a couple
of months ago (prior to the shift over to github), but now it is
causing the database within Geonetwork to lock up - it would appear
that it is not releasing the lock for the database for some weird
reason. I was wondering if anyone had any idea as to why this might be
happening?
This version of the code is working on the 2.8.0 RC0 branch of
Geonetwork, up to date as of last week. Deployment is being done on a
Windows Server 2008 box.
I am definitely pulling out the image correctly and storing it in the
upload (tmp) directory for later use. I then call the following method
if a thumbnail was harvested to store it with the metadata entry being
harvested. This call is made at the end of the loop for adding /
updating metadata for a harvested entry (right above
idsForHarvestingResult.add(id);).
public void AddThumbnail(ServiceContext context, Dbms dbms,
DataManager dataMan, String id) {
try {
Set s = new org.fao.geonet.services.thumbnail.Set();
Element par = new Element(“request”);
par.addContent(new Element(“id”).setText(id));
par.addContent(new Element(“version”).setText(“10”));
par.addContent(new Element(“type”).setText(“large”));
par.addContent(new Element(“scalingDir”).setText(“both”));
par.addContent(new Element(“scalingFactor”).setText(“2”));
//where thumbFile is the name of the harvested thumbnail
Element fname = new Element(“fname”).setText(thumbFile);
fname.setAttribute(“content-type”, “image/bmp”);
fname.setAttribute(“type”, “file”);
fname.setAttribute(“size”, “”);
par.addContent(fname);
par.addContent(new Element(“add”).setText(“Add”));
par.addContent(new Element(“createSmall”).setText(“on”));
par.addContent(new Element(“smallScalingFactor”).setText(“1”));
par.addContent(new Element(“smallScalingDir”).setText(“both”));
s.execOnHarvest(par, context, dbms, dataMan);
dbms.commit();
} catch(Exception ex) { e.printStackTrace(); }
}
When the call to this method is made the thumbnail is copied to
WEB-INF/data/data/metadata_data/approriate_folder. However, the next
call to add metadata causes the following error:
org.h2.jdbc.JdbcSQLException: Timout trying to lock table “METADATA”;
SQL statement:
SELECT id FROM Metadata WHERE uuid=? [50500-152]
If I remove the call to this method then the thumbnails are still
added to the upload (tmp) directory but not added to the metadata and
the rest of the harvesting works correctly. I cannot see any reason
for the database to lock like this. Is there something I am missing?
Elgar Storm
Live Security Virtual Conference
Exclusive live event will cover all the ways today’s security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork