Short term fixes to repo/AVM filesystems and a few other bits affected by the Alfresco JLAN cluster changes.

Hard code a standalone state cache into the repo/AVM filesystems.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28775 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gary Spencer
2011-07-04 10:55:51 +00:00
parent 8ae8c29a76
commit f8f02a9f95
8 changed files with 110 additions and 13 deletions

View File

@@ -24,12 +24,21 @@ import java.util.StringTokenizer;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.filesys.config.GlobalDesktopActionConfigBean; import org.alfresco.filesys.config.GlobalDesktopActionConfigBean;
import org.alfresco.filesys.config.ServerConfigurationBean;
import org.alfresco.jlan.server.config.CoreServerConfigSection;
import org.alfresco.jlan.server.config.InvalidConfigurationException;
import org.alfresco.jlan.server.core.DeviceContextException;
import org.alfresco.jlan.server.filesys.DiskDeviceContext; import org.alfresco.jlan.server.filesys.DiskDeviceContext;
import org.alfresco.jlan.server.filesys.DiskInterface; import org.alfresco.jlan.server.filesys.DiskInterface;
import org.alfresco.jlan.server.filesys.DiskSharedDevice;
import org.alfresco.jlan.server.filesys.FileSystem; import org.alfresco.jlan.server.filesys.FileSystem;
import org.alfresco.jlan.server.filesys.FilesystemsConfigSection;
import org.alfresco.jlan.server.filesys.SrvDiskInfo; import org.alfresco.jlan.server.filesys.SrvDiskInfo;
import org.alfresco.jlan.server.filesys.cache.FileStateCache;
import org.alfresco.jlan.server.filesys.cache.StandaloneFileStateCache;
import org.alfresco.jlan.server.filesys.pseudo.PseudoFileInterface; import org.alfresco.jlan.server.filesys.pseudo.PseudoFileInterface;
import org.alfresco.repo.admin.SysAdminParams; import org.alfresco.repo.admin.SysAdminParams;
import org.springframework.extensions.config.element.GenericConfigElement;
/** /**
* Alfresco Filesystem Context Class * Alfresco Filesystem Context Class
@@ -74,6 +83,10 @@ public abstract class AlfrescoContext extends DiskDeviceContext
private IOControlHandler m_ioHandler; private IOControlHandler m_ioHandler;
// Server configuration
private ServerConfigurationBean m_serverConfig;
// Debug flags // Debug flags
// //
// Requires the logger to be enabled for debug output // Requires the logger to be enabled for debug output
@@ -107,6 +120,15 @@ public abstract class AlfrescoContext extends DiskDeviceContext
enableChangeHandler(!disableChangeNotification); enableChangeHandler(!disableChangeNotification);
} }
/**
* Set the server configuration
*
* @param srvConfig ServerConfigurationBean
*/
public void setServerConfigurationBean( ServerConfigurationBean srvConfig) {
m_serverConfig = srvConfig;
}
/** /**
* Complete initialization by registering with a disk driver * Complete initialization by registering with a disk driver
*/ */
@@ -424,4 +446,57 @@ public abstract class AlfrescoContext extends DiskDeviceContext
{ {
return (m_debug & flg) != 0 ? true : false; return (m_debug & flg) != 0 ? true : false;
} }
/**
* Start the filesystem
*
* @param share DiskSharedDevice
* @exception DeviceContextException
*/
public void startFilesystem(DiskSharedDevice share)
throws DeviceContextException {
// Call the base class
super.startFilesystem(share);
}
/**
* Enable the state cache
*
* @param ena boolean
*/
public void enableStateCache( boolean ena) {
// Check if the server configuration has been set
if ( m_serverConfig == null)
throw new AlfrescoRuntimeException( "Failed to set standalone file state cache for share " + getShareName());
// Check if we are enabling the state cache
if ( ena == true && getStateCache() == null) {
// Set the state cache, use a hard coded standalone cache for now
FilesystemsConfigSection filesysConfig = (FilesystemsConfigSection) m_serverConfig.getConfigSection( FilesystemsConfigSection.SectionName);
if ( filesysConfig != null) {
try {
// Create a standalone state cache
StandaloneFileStateCache standaloneCache = new StandaloneFileStateCache();
standaloneCache.initializeCache( new GenericConfigElement( ""), m_serverConfig);
filesysConfig.addFileStateCache( getDeviceName(), standaloneCache);
setStateCache( standaloneCache);
}
catch ( InvalidConfigurationException ex) {
throw new AlfrescoRuntimeException( "Failed to initialize standalone state cache for " + getDeviceName());
}
}
}
}
} }

View File

@@ -25,6 +25,7 @@ import javax.transaction.Status;
import javax.transaction.UserTransaction; import javax.transaction.UserTransaction;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.filesys.config.ServerConfigurationBean;
import org.alfresco.jlan.server.SrvSession; import org.alfresco.jlan.server.SrvSession;
import org.alfresco.jlan.server.core.DeviceContext; import org.alfresco.jlan.server.core.DeviceContext;
import org.alfresco.jlan.server.core.DeviceContextException; import org.alfresco.jlan.server.core.DeviceContextException;
@@ -399,13 +400,25 @@ public abstract class AlfrescoDiskDriver implements IOCtlInterface, Transactiona
* shares. In this base class, we initialize all desktop actions. * shares. In this base class, we initialize all desktop actions.
* *
* @param ctx the context * @param ctx the context
* @param serverConfig ServerConfigurationBean
* @exception DeviceContextException * @exception DeviceContextException
*/ */
public void registerContext(DeviceContext ctx) throws DeviceContextException public void registerContext(DeviceContext ctx, ServerConfigurationBean serverConfig) throws DeviceContextException
{ {
if (ctx instanceof AlfrescoContext) if (ctx instanceof AlfrescoContext)
{ {
((AlfrescoContext) ctx).initialize(this); // Enable a standalone state cache on the filesystem
AlfrescoContext alfCtx = (AlfrescoContext) ctx;
if ( serverConfig != null) {
alfCtx.setServerConfigurationBean( serverConfig);
alfCtx.enableStateCache( true);
}
// Initialize the filesystem
alfCtx.initialize(this);
} }
} }

View File

@@ -18,6 +18,7 @@
*/ */
package org.alfresco.filesys.alfresco; package org.alfresco.filesys.alfresco;
import org.alfresco.filesys.config.ServerConfigurationBean;
import org.alfresco.jlan.server.core.DeviceContext; import org.alfresco.jlan.server.core.DeviceContext;
import org.alfresco.jlan.server.core.DeviceContextException; import org.alfresco.jlan.server.core.DeviceContextException;
import org.alfresco.jlan.server.filesys.DiskInterface; import org.alfresco.jlan.server.filesys.DiskInterface;
@@ -33,7 +34,8 @@ public interface ExtendedDiskInterface extends DiskInterface
* *
* @param context * @param context
* the device context * the device context
* @param serverConfig ServerConfigurationBean
* @exception DeviceContextException * @exception DeviceContextException
*/ */
public void registerContext(DeviceContext ctx) throws DeviceContextException; public void registerContext(DeviceContext ctx, ServerConfigurationBean serverConfig) throws DeviceContextException;
} }

View File

@@ -28,6 +28,7 @@ import java.util.StringTokenizer;
import javax.transaction.UserTransaction; import javax.transaction.UserTransaction;
import org.alfresco.filesys.alfresco.AlfrescoDiskDriver; import org.alfresco.filesys.alfresco.AlfrescoDiskDriver;
import org.alfresco.filesys.config.ServerConfigurationBean;
import org.alfresco.jlan.server.SrvSession; import org.alfresco.jlan.server.SrvSession;
import org.alfresco.jlan.server.auth.ClientInfo; import org.alfresco.jlan.server.auth.ClientInfo;
import org.alfresco.jlan.server.core.DeviceContext; import org.alfresco.jlan.server.core.DeviceContext;
@@ -417,7 +418,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface
} }
// Register the context bean // Register the context bean
registerContext(context); registerContext(context, null);
// Return the context for this shared filesystem // Return the context for this shared filesystem
return context; return context;
@@ -428,13 +429,14 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface
* device. * device.
* *
* @param context the device context * @param context the device context
* @param serverConfig ServerConfigurationBean
* @exception DeviceContextException * @exception DeviceContextException
*/ */
@Override @Override
public void registerContext(DeviceContext ctx) public void registerContext(DeviceContext ctx, ServerConfigurationBean serverConfig)
throws DeviceContextException throws DeviceContextException
{ {
super.registerContext(ctx); super.registerContext(ctx, serverConfig);
AVMContext context = (AVMContext)ctx; AVMContext context = (AVMContext)ctx;
// Use the system user as the authenticated context for the filesystem initialization // Use the system user as the authenticated context for the filesystem initialization

View File

@@ -1627,7 +1627,7 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean
// the new filesystem // the new filesystem
ExtendedDiskInterface filesysDriver = getAvmDiskInterface(); ExtendedDiskInterface filesysDriver = getAvmDiskInterface();
filesysDriver.registerContext(filesystem); filesysDriver.registerContext(filesystem, this);
// Create the shared filesystem // Create the shared filesystem
@@ -1656,7 +1656,7 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean
ExtendedDiskInterface filesysDriver = getRepoDiskInterface(); ExtendedDiskInterface filesysDriver = getRepoDiskInterface();
ContentContext filesysContext = (ContentContext) filesystem; ContentContext filesysContext = (ContentContext) filesystem;
filesysDriver.registerContext(filesystem); filesysDriver.registerContext(filesystem, this);
// Check if an access control list has been specified // Check if an access control list has been specified

View File

@@ -375,6 +375,9 @@ public class ContentContext extends AlfrescoContext
super.startFilesystem(share); super.startFilesystem(share);
if ( getStateCache() != null)
getStateCache().setCaseSensitive( false);
// Find the thread pool via the configuration // Find the thread pool via the configuration
CoreServerConfigSection coreConfig = (CoreServerConfigSection) share.getConfiguration().getConfigSection( CoreServerConfigSection.SectionName); CoreServerConfigSection coreConfig = (CoreServerConfigSection) share.getConfiguration().getConfigSection( CoreServerConfigSection.SectionName);

View File

@@ -39,6 +39,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.filesys.alfresco.AlfrescoContext; import org.alfresco.filesys.alfresco.AlfrescoContext;
import org.alfresco.filesys.alfresco.AlfrescoDiskDriver; import org.alfresco.filesys.alfresco.AlfrescoDiskDriver;
import org.alfresco.filesys.alfresco.AlfrescoNetworkFile; import org.alfresco.filesys.alfresco.AlfrescoNetworkFile;
import org.alfresco.filesys.config.ServerConfigurationBean;
import org.alfresco.jlan.server.SrvSession; import org.alfresco.jlan.server.SrvSession;
import org.alfresco.jlan.server.core.DeviceContext; import org.alfresco.jlan.server.core.DeviceContext;
import org.alfresco.jlan.server.core.DeviceContextException; import org.alfresco.jlan.server.core.DeviceContextException;
@@ -590,7 +591,7 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
// Register the device context // Register the device context
registerContext(context); registerContext(context, null);
// Return the context for this shared filesystem // Return the context for this shared filesystem
@@ -606,13 +607,14 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
* WARNING: side effect, will commit or roll back current user transaction context. * WARNING: side effect, will commit or roll back current user transaction context.
* *
* @param ctx the context * @param ctx the context
* @param serverConfig ServerConfigurationBean
* @exception DeviceContextException * @exception DeviceContextException
*/ */
// MER TODO - transaction handling in registerContext needs changing // MER TODO - transaction handling in registerContext needs changing
@Override @Override
public void registerContext(DeviceContext ctx) throws DeviceContextException public void registerContext(DeviceContext ctx, ServerConfigurationBean serverConfig) throws DeviceContextException
{ {
super.registerContext(ctx); super.registerContext(ctx, serverConfig);
ContentContext context = (ContentContext)ctx; ContentContext context = (ContentContext)ctx;
@@ -750,7 +752,6 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
// Enable file state caching // Enable file state caching
context.enableStateCache( true); context.enableStateCache( true);
context.getStateCache().setCaseSensitive( false);
// Initialize the I/O control handler // Initialize the I/O control handler

View File

@@ -23,6 +23,7 @@ import java.io.IOException;
import org.alfresco.jlan.server.filesys.FileInfo; import org.alfresco.jlan.server.filesys.FileInfo;
import org.alfresco.jlan.server.filesys.cache.FileState; import org.alfresco.jlan.server.filesys.cache.FileState;
import org.alfresco.jlan.server.filesys.cache.LocalFileState;
import org.alfresco.jlan.smb.SeekType; import org.alfresco.jlan.smb.SeekType;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
@@ -261,7 +262,7 @@ public class LinkMemoryNetworkFile extends NodeRefNetworkFile
// Create a dummy file state // Create a dummy file state
if ( super.getFileState() == null) if ( super.getFileState() == null)
setFileState(new FileState(getFullName(), false)); setFileState(new LocalFileState(getFullName(), false));
return super.getFileState(); return super.getFileState();
} }
} }