mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Use real free/total disk space values for the repository filesystem, if the content store supports them. ALF-1530.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22893 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -44,8 +44,10 @@ import org.alfresco.jlan.server.core.DeviceContextException;
|
||||
import org.alfresco.jlan.server.filesys.AccessDeniedException;
|
||||
import org.alfresco.jlan.server.filesys.AccessMode;
|
||||
import org.alfresco.jlan.server.filesys.DirectoryNotEmptyException;
|
||||
import org.alfresco.jlan.server.filesys.DiskDeviceContext;
|
||||
import org.alfresco.jlan.server.filesys.DiskFullException;
|
||||
import org.alfresco.jlan.server.filesys.DiskInterface;
|
||||
import org.alfresco.jlan.server.filesys.DiskSizeInterface;
|
||||
import org.alfresco.jlan.server.filesys.FileAttribute;
|
||||
import org.alfresco.jlan.server.filesys.FileInfo;
|
||||
import org.alfresco.jlan.server.filesys.FileName;
|
||||
@@ -54,6 +56,7 @@ import org.alfresco.jlan.server.filesys.FileSharingException;
|
||||
import org.alfresco.jlan.server.filesys.FileStatus;
|
||||
import org.alfresco.jlan.server.filesys.NetworkFile;
|
||||
import org.alfresco.jlan.server.filesys.SearchContext;
|
||||
import org.alfresco.jlan.server.filesys.SrvDiskInfo;
|
||||
import org.alfresco.jlan.server.filesys.TreeConnection;
|
||||
import org.alfresco.jlan.server.filesys.cache.FileState;
|
||||
import org.alfresco.jlan.server.filesys.cache.FileStateLockManager;
|
||||
@@ -72,6 +75,7 @@ import org.alfresco.jlan.smb.SharingMode;
|
||||
import org.alfresco.jlan.smb.WinNT;
|
||||
import org.alfresco.jlan.smb.server.SMBServer;
|
||||
import org.alfresco.jlan.smb.server.SMBSrvSession;
|
||||
import org.alfresco.jlan.util.MemorySize;
|
||||
import org.alfresco.jlan.util.WildCard;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.admin.SysAdminParams;
|
||||
@@ -110,7 +114,7 @@ import org.springframework.extensions.config.ConfigElement;
|
||||
*
|
||||
* @author gkspencer
|
||||
*/
|
||||
public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterface, FileLockingInterface, OpLockInterface
|
||||
public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterface, FileLockingInterface, OpLockInterface, DiskSizeInterface
|
||||
{
|
||||
// Logging
|
||||
|
||||
@@ -148,6 +152,17 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
||||
NamespaceService.CONTENT_MODEL_1_0_URI, NamespaceService.SYSTEM_MODEL_1_0_URI
|
||||
}));
|
||||
|
||||
// Disk sizing contants
|
||||
|
||||
private static final int DiskBlockSize = 512; // bytes per block
|
||||
private static final long DiskAllocationUnit = 32 * MemorySize.KILOBYTE;
|
||||
private static final long DiskBlocksPerUnit = DiskAllocationUnit / DiskBlockSize;
|
||||
|
||||
// Disk size returned in the content store does not support free/total size
|
||||
|
||||
protected static final long DiskSizeDefault = 1 * MemorySize.TERABYTE;
|
||||
protected static final long DiskFreeDefault = DiskSizeDefault / 2;
|
||||
|
||||
// Services and helpers
|
||||
|
||||
private CifsHelper cifsHelper;
|
||||
@@ -3936,4 +3951,38 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
||||
|
||||
return fstatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the disk information for this shared disk device.
|
||||
*
|
||||
* @param ctx DiskDeviceContext
|
||||
* @param diskDev SrvDiskInfo
|
||||
* @exception IOException
|
||||
*/
|
||||
public void getDiskInformation(DiskDeviceContext ctx, SrvDiskInfo diskDev)
|
||||
throws IOException {
|
||||
|
||||
// Set the block size and blocks per allocation unit
|
||||
|
||||
diskDev.setBlockSize( DiskBlockSize);
|
||||
diskDev.setBlocksPerAllocationUnit( DiskBlocksPerUnit);
|
||||
|
||||
// Get the free and total disk size in bytes from the content store
|
||||
|
||||
long freeSpace = contentService.getStoreFreeSpace();
|
||||
long totalSpace= contentService.getStoreTotalSpace();
|
||||
|
||||
if ( totalSpace == -1L) {
|
||||
|
||||
// Use a fixed value for the total space, content store does not support size information
|
||||
|
||||
totalSpace = DiskSizeDefault;
|
||||
freeSpace = DiskFreeDefault;
|
||||
}
|
||||
|
||||
// Convert the total/free space values to allocation units
|
||||
|
||||
diskDev.setTotalUnits( totalSpace / DiskAllocationUnit);
|
||||
diskDev.setFreeUnits( freeSpace / DiskAllocationUnit);
|
||||
}
|
||||
}
|
||||
|
@@ -99,11 +99,17 @@ public class ContentQuotaManager implements QuotaManager, Runnable {
|
||||
*/
|
||||
public long getAvailableFreeSpace() {
|
||||
|
||||
// Return a dummy value for now
|
||||
//
|
||||
// Need to find the content store size and return the live available space value if possible
|
||||
// Get the live free space value from the content store, if supported
|
||||
|
||||
return 100 * MemorySize.GIGABYTE;
|
||||
long freeSpace = m_filesys.getContentService().getStoreFreeSpace();
|
||||
if ( freeSpace == -1L) {
|
||||
|
||||
// Content store does not support sizing, return a large dummy value
|
||||
|
||||
freeSpace = ContentDiskDriver.DiskFreeDefault;
|
||||
}
|
||||
|
||||
return freeSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user