I have one shapefile , multiple threads are running the following code:

        FileDataStore store = new IndexedShapefileDataStore(tzUrl, false,
true);  <======
        ustzFeatureSource = store.getFeatureSource();
        collection = ustzFeatureSource.getFeatures(query);


problem is with the first line. since I gave createSpatialIndex=true, each
thread actually tries to create its own index,
and ran into issues with locks:

SEVERE: Unable to delete the file: /mnt/shapes/biggeo.gml_POSTAL_CODE.qix
when attempting to replace with temporary copy.
 Feb 3, 2012 3:35:25 AM org.geotools.data.shapefile.StorageFile
replaceOriginals
 SEVERE: The problem is almost certainly caused by the fact that there are
still locks being held on the shapefiles.  Probably a r
 Feb 3, 2012 3:35:25 AM org.geotools.data.shapefile.ShpFiles
logCurrentLockers
 SEVERE: The following locker still has a lock: write on
file:/mnt/shapes/biggeo.gml_POSTAL_CODE.shp by StorageFile: biggeo3034272
 Feb 3, 2012 3:35:25 AM org.geotools.data.shapefile.ShpFiles
logCurrentLockers
 SEVERE: The following locker still has a lock: write on
file:/mnt/shapes/biggeo.gml_POSTAL_CODE.qix by StorageFile: biggeo3034272
 Feb 3, 2012 3:35:25 AM
org.geotools.data.shapefile.indexed.IndexedShapefileDataStore
createSpatialIndex
 SEVERE: null
 Feb 3, 2012 3:35:26 AM org.geotools.data.shapefile.StorageFile
replaceOriginals
 SEVERE: Unable to delete the file: /mnt/shapes/biggeo.gml_COUNTY.qix when
attempting to replace with temporary copy.
 Feb 3, 2012 3:35:26 AM org.geotools.data.shapefile.StorageFile
replaceOriginals
 SEVERE: The problem is almost certainly caused by the fact that there are
still locks being held on the shapefiles.  Probably a r
 Feb 3, 2012 3:35:26 AM org.geotools.data.shapefile.ShpFiles
logCurrentLockers
 SEVERE: The following locker still has a lock: write on
file:/mnt/shapes/biggeo.gml_COUNTY.shp by StorageFile: biggeo304623062369
 Feb 3, 2012 3:35:26 AM org.geotools.data.shapefile.ShpFiles
logCurrentLockers

 Task Logs: 'attempt_201201252018_0018_m_000000_0' (2/30)
 SEVERE: The following locker still has a lock: write on
file:/mnt/shapes/biggeo.gml_COUNTY.qix by StorageFile: biggeo304623062369
 Feb 3, 2012 3:35:26 AM
org.geotools.data.shapefile.indexed.IndexedShapefileDataStore
createSpatialIndex
 SEVERE: null
 Feb 3, 2012 3:35:47 AM org.geotools.data.shapefile.StorageFile
replaceOriginals
 SEVERE: Unable to delete the file: /mnt/shapes/biggeo.gml_POSTAL_CODE.qix
when attempting to replace with temporary copy.
 Feb 3, 2012 3:35:47 AM org.geotools.data.shapefile.StorageFile
replaceOriginals
 SEVERE: The problem is almost certainly caused by the fact that there are
still locks being held on the shapefiles.  Probably a r
 Feb 3, 2012 3:35:47 AM org.geotools.data.shapefile.ShpFiles
logCurrentLockers
 SEVERE: The following locker still has a lock: write on
file:/mnt/shapes/biggeo.gml_POSTAL_CODE.shp by StorageFile: biggeo5047038
 Feb 3, 2012 3:35:47 AM org.geotools.data.shapefile.ShpFiles
logCurrentLockers
 SEVERE: The following locker still has a lock: write on
file:/mnt/shapes/biggeo.gml_POSTAL_CODE.qix by StorageFile: biggeo5047038
 Feb 3, 2012 3:35:47 AM
org.geotools.data.shapefile.indexed.IndexedShapefileDataStore
createSpatialIndex
 SEVERE: null
 Feb 3, 2012 3:35:49 AM org.geotools.data.shapefile.StorageFile
replaceOriginals
 SEVERE: Unable to delete the file: /mnt/shapes/biggeo.gml_COUNTY.qix when
attempting to replace with temporary copy.
 Feb 3, 2012 3:35:49 AM org.geotools.data.shapefile.StorageFile
replaceOriginals
 SEVERE: The problem is almost certainly caused by the fact that there are
still locks being held on the shapefiles.  Probably a r
 Feb 3, 2012 3:35:49 AM org.geotools.data.shapefile.ShpFiles
logCurrentLockers
 Feb 3, 2012 3:35:49 AM org.geotools.data.shapefile.StorageFile
replaceOriginals
 SEVERE: Unable to delete the file: /mnt/shapes/biggeo.gml_COUNTY.qix when
attempting to replace with temporary copy.
 Feb 3, 2012 3:35:49 AM org.geotools.data.shapefile.StorageFile
replaceOriginals
 SEVERE: The problem is almost certainly caused by the fact that there are
still locks being held on the shapefiles.  Probably a r
 Feb 3, 2012 3:35:49 AM org.geotools.data.shapefile.ShpFiles
logCurrentLockers
 SEVERE: The following locker still has a lock: write on
file:/mnt/shapes/biggeo.gml_COUNTY.shp by StorageFile: biggeo834418033700
 Feb 3, 2012 3:35:49 AM org.geotools.data.shapefile.ShpFiles
logCurrentLockers
 SEVERE: The following locker still has a lock: write on
file:/mnt/shapes/biggeo.gml_COUNTY.qix by StorageFile: biggeo834418033700
 Feb 3, 2012 3:35:49 AM
org.geotools.data.shapefile.indexed.IndexedShapefileDataStore
createSpatialIndex
 SEVERE: null
 java.util.NoSuchElementException: Could not aquire
feature:org.geotools.data.DataSourceException: Error querying QuadTree
         at
org.geotools.data.store.NoContentIterator.next(NoContentIterator.java:58)
         at
org.geotools.data.store.NoContentIterator.next(NoContentIterator.java:43)
         at
org.geotools.feature.collection.DelegateFeatureIterator.next(DelegateFeatureIterator.java:58)
         at
citygridmedia.geography.pig.GeoFinder.searchSingleGeo(GeoFinder.java:162)
         at
citygridmedia.geography.pig.GeoFinder._searchPrimaryGeo(GeoFinder.java:126)
         at
citygridmedia.geography.pig.GeoFinder.searchPrimaryGeo(GeoFinde         at
citygridmedia.geography.pig.PrimaryGeocoder.exec(PrimaryGeocoder.java:49)
         at
citygridmedia.geography.pig.PrimaryGeocoder.exec(PrimaryGeocoder.java:11)




so it looks I can have only one ShapefileDataStore obj for one file, that's
fine, then  I can let the multiple threads share one datastore obj, but
then the question is, is the ShapefileDataStore obj thread-safe? and also
the FeatureSource obj returned by the DataStore?


thanks a lot
Yang
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to