mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Minor fixes:
- ContentStore directory creation does a few retries if it fails - A little less Session clearing during content store cleaning git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5941 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -167,7 +167,7 @@ public class FileContentStore extends AbstractContentStore
|
||||
*
|
||||
* @see #setReadOnly(boolean)
|
||||
*/
|
||||
public File createNewFile(String newContentUrl) throws IOException
|
||||
private File createNewFile(String newContentUrl) throws IOException
|
||||
{
|
||||
if (readOnly)
|
||||
{
|
||||
@@ -180,7 +180,7 @@ public class FileContentStore extends AbstractContentStore
|
||||
File dir = file.getParentFile();
|
||||
if (!dir.exists())
|
||||
{
|
||||
dir.mkdirs();
|
||||
makeDirectory(dir);
|
||||
}
|
||||
|
||||
// create a new, empty file
|
||||
@@ -197,6 +197,46 @@ public class FileContentStore extends AbstractContentStore
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronized and retrying directory creation. Repeated attempts will be made to create the
|
||||
* directory, subject to a limit on the number of retries.
|
||||
*
|
||||
* @param dir the directory to create
|
||||
* @throws IOException if an IO error occurs
|
||||
*/
|
||||
private synchronized void makeDirectory(File dir) throws IOException
|
||||
{
|
||||
/*
|
||||
* Once in this method, the only contention will be from other file stores or processes.
|
||||
* This is OK as we have retrying to sort it out.
|
||||
*/
|
||||
if (dir.exists())
|
||||
{
|
||||
// Beaten to it during synchronization
|
||||
return;
|
||||
}
|
||||
// 20 attempts with 20 ms wait each time
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
boolean created = dir.mkdirs();
|
||||
if (created)
|
||||
{
|
||||
// Successfully created
|
||||
return;
|
||||
}
|
||||
// Wait
|
||||
try { this.wait(20L); } catch (InterruptedException e) {}
|
||||
// Did it get created in the meantime
|
||||
if (dir.exists())
|
||||
{
|
||||
// Beaten to it while asleep
|
||||
return;
|
||||
}
|
||||
}
|
||||
// It still didn't succeed
|
||||
throw new ContentIOException("Failed to create directory for file storage: " + dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the file absolute path, strips off the root path of the store
|
||||
* and appends the store URL prefix.
|
||||
|
@@ -1166,6 +1166,7 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
||||
// Loop through, extracting content URLs
|
||||
List<Serializable> convertedValues = new ArrayList<Serializable>(1000);
|
||||
TypeConverter converter = DefaultTypeConverter.INSTANCE;
|
||||
int unflushedCount = 0;
|
||||
while(results.next())
|
||||
{
|
||||
Node node = (Node) results.get()[0];
|
||||
@@ -1200,8 +1201,13 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
||||
}
|
||||
}
|
||||
}
|
||||
// evict all data from the session
|
||||
getSession().clear();
|
||||
unflushedCount++;
|
||||
if (unflushedCount >= 1000)
|
||||
{
|
||||
// evict all data from the session
|
||||
getSession().clear();
|
||||
unflushedCount = 0;
|
||||
}
|
||||
}
|
||||
return convertedValues;
|
||||
}
|
||||
|
Reference in New Issue
Block a user