mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Updates to repo filesystem to add support for NFS, plus various updates/fixes to NFS.
Removed synchronization from content network file methods, synchronization is done in the protocol layer. Compacted content network file debug output. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4810 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1778,8 +1778,7 @@ public class NFSServer extends RpcNetworkServer implements RpcProcessor {
|
||||
|
||||
// Get the disk interface from the disk driver
|
||||
|
||||
DiskInterface disk = (DiskInterface) conn.getSharedDevice()
|
||||
.getInterface();
|
||||
DiskInterface disk = (DiskInterface) conn.getSharedDevice().getInterface();
|
||||
|
||||
// Get the pre-operation state for the parent directory
|
||||
|
||||
@@ -1846,8 +1845,7 @@ public class NFSServer extends RpcNetworkServer implements RpcProcessor {
|
||||
if (finfo.isDirectory())
|
||||
packDirectoryHandle(shareId, finfo.getFileId(), rpc);
|
||||
else
|
||||
packFileHandle(shareId, getFileIdForHandle(handle),
|
||||
finfo.getFileId(), rpc);
|
||||
packFileHandle(shareId, getFileIdForHandle(handle), finfo.getFileId(), rpc);
|
||||
|
||||
// Pack the file attributes
|
||||
|
||||
@@ -1856,19 +1854,17 @@ public class NFSServer extends RpcNetworkServer implements RpcProcessor {
|
||||
// Add a cache entry for the path
|
||||
|
||||
ShareDetails details = m_shareDetails.findDetails(shareId);
|
||||
details.getFileIdCache().addPath(finfo.getFileId(),
|
||||
filePath);
|
||||
details.getFileIdCache().addPath(finfo.getFileId(), filePath);
|
||||
|
||||
// Add a cache entry for the network file
|
||||
|
||||
sess.getFileCache().addFile(netFile, conn);
|
||||
sess.getFileCache().addFile(netFile, conn, sess);
|
||||
|
||||
// Pack the wcc data structure for the directory
|
||||
|
||||
packPreOpAttr(sess, preInfo, rpc);
|
||||
|
||||
FileInfo postInfo = disk.getFileInformation(sess, conn,
|
||||
path);
|
||||
FileInfo postInfo = disk.getFileInformation(sess, conn, path);
|
||||
packPostOpAttr(sess, postInfo, shareId, rpc);
|
||||
|
||||
// DEBUG
|
||||
@@ -1879,8 +1875,7 @@ public class NFSServer extends RpcNetworkServer implements RpcProcessor {
|
||||
|
||||
// Notify change listeners that a new file has been created
|
||||
|
||||
DiskDeviceContext diskCtx = (DiskDeviceContext) conn
|
||||
.getContext();
|
||||
DiskDeviceContext diskCtx = (DiskDeviceContext) conn.getContext();
|
||||
|
||||
if (diskCtx.hasChangeHandler())
|
||||
diskCtx.getChangeHandler().notifyFileChanged( NotifyChange.ActionAdded, filePath);
|
||||
@@ -2320,14 +2315,13 @@ public class NFSServer extends RpcNetworkServer implements RpcProcessor {
|
||||
|
||||
// Add a cache entry for the network file
|
||||
|
||||
sess.getFileCache().addFile(netFile, conn);
|
||||
sess.getFileCache().addFile(netFile, conn, sess);
|
||||
|
||||
// Pack the wcc data structure for the directory
|
||||
|
||||
packPreOpAttr(sess, preInfo, rpc);
|
||||
|
||||
FileInfo postInfo = disk.getFileInformation(sess, conn,
|
||||
path);
|
||||
FileInfo postInfo = disk.getFileInformation(sess, conn, path);
|
||||
packPostOpAttr(sess, postInfo, shareId, rpc);
|
||||
|
||||
// DEBUG
|
||||
@@ -3036,7 +3030,7 @@ public class NFSServer extends RpcNetworkServer implements RpcProcessor {
|
||||
|
||||
// Generate the search path
|
||||
|
||||
String searchPath = generatePath(path, "*.*");
|
||||
String searchPath = generatePath(path, "*");
|
||||
|
||||
// DEBUG
|
||||
|
||||
@@ -4611,8 +4605,7 @@ public class NFSServer extends RpcNetworkServer implements RpcProcessor {
|
||||
* @exception StaleHandleException
|
||||
* If the file id cannot be converted to a path
|
||||
*/
|
||||
protected final NetworkFile getNetworkFileForHandle(NFSSrvSession sess,
|
||||
byte[] handle, TreeConnection conn, boolean readOnly)
|
||||
protected final NetworkFile getNetworkFileForHandle(NFSSrvSession sess, byte[] handle, TreeConnection conn, boolean readOnly)
|
||||
throws BadHandleException, StaleHandleException {
|
||||
|
||||
// Check if the handle is a file handle
|
||||
@@ -4633,7 +4626,7 @@ public class NFSServer extends RpcNetworkServer implements RpcProcessor {
|
||||
|
||||
// Check the file cache, file may already be open
|
||||
|
||||
file = fileCache.findFile(fileId);
|
||||
file = fileCache.findFile(fileId, sess);
|
||||
if (file == null) {
|
||||
|
||||
// Get the path for the file
|
||||
@@ -4656,7 +4649,7 @@ public class NFSServer extends RpcNetworkServer implements RpcProcessor {
|
||||
// Add the file to the active file cache
|
||||
|
||||
if (file != null)
|
||||
fileCache.addFile(file, conn);
|
||||
fileCache.addFile(file, conn, sess);
|
||||
}
|
||||
catch (AccessDeniedException ex) {
|
||||
if (hasDebug())
|
||||
|
@@ -133,7 +133,7 @@ public class NFSSrvSession extends SrvSession {
|
||||
public final NetworkFileCache getFileCache()
|
||||
{
|
||||
if (m_fileCache == null)
|
||||
m_fileCache = new NetworkFileCache(getUniqueId());
|
||||
m_fileCache = new NetworkFileCache(getUniqueId(), getNFSServer().getRpcAuthenticator());
|
||||
return m_fileCache;
|
||||
}
|
||||
|
||||
|
@@ -17,11 +17,12 @@
|
||||
package org.alfresco.filesys.server.oncrpc.nfs;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
import org.alfresco.filesys.server.SrvSession;
|
||||
import org.alfresco.filesys.server.filesys.DiskInterface;
|
||||
import org.alfresco.filesys.server.filesys.NetworkFile;
|
||||
import org.alfresco.filesys.server.filesys.TreeConnection;
|
||||
import org.alfresco.filesys.server.oncrpc.RpcAuthenticator;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -40,7 +41,7 @@ public class NetworkFileCache {
|
||||
|
||||
// Default file timeout
|
||||
|
||||
public static final long DefaultFileTimeout = 5000L; // 5 seconds
|
||||
public static final long DefaultFileTimeout = 5000L; // 5 seconds
|
||||
|
||||
// Network file cache, key is the file id
|
||||
|
||||
@@ -50,6 +51,10 @@ public class NetworkFileCache {
|
||||
|
||||
private FileExpiry m_expiryThread;
|
||||
|
||||
// RPC authenticator
|
||||
|
||||
private RpcAuthenticator m_rpcAuthenticator;
|
||||
|
||||
// File timeout
|
||||
|
||||
private long m_fileTmo = DefaultFileTimeout;
|
||||
@@ -74,18 +79,23 @@ public class NetworkFileCache {
|
||||
// File timeout
|
||||
|
||||
private long m_timeout;
|
||||
|
||||
// Session that last accessed the file
|
||||
|
||||
private SrvSession m_sess;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param file
|
||||
* NetworkFile
|
||||
* @param conn
|
||||
* TreeConnection
|
||||
* @param file NetworkFile
|
||||
* @param conn TreeConnection
|
||||
* @param sess SrvSession
|
||||
*/
|
||||
public FileEntry(NetworkFile file, TreeConnection conn) {
|
||||
public FileEntry(NetworkFile file, TreeConnection conn, SrvSession sess) {
|
||||
m_file = file;
|
||||
m_conn = conn;
|
||||
setSession(sess);
|
||||
|
||||
updateTimeout();
|
||||
}
|
||||
|
||||
@@ -116,6 +126,16 @@ public class NetworkFileCache {
|
||||
return m_conn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the session that last accessed the file
|
||||
*
|
||||
* @return SrvSession
|
||||
*/
|
||||
public final SrvSession getSession()
|
||||
{
|
||||
return m_sess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the file timeout
|
||||
*/
|
||||
@@ -132,6 +152,16 @@ public class NetworkFileCache {
|
||||
public final void updateTimeout(long tmo) {
|
||||
m_timeout = tmo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the session that last accessed the file
|
||||
*
|
||||
* @param sess SrvSession
|
||||
*/
|
||||
public final void setSession( SrvSession sess)
|
||||
{
|
||||
m_sess = sess;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -242,22 +272,31 @@ public class NetworkFileCache {
|
||||
|
||||
try {
|
||||
|
||||
// Set the current user using the session that last accessed the file
|
||||
|
||||
if ( m_rpcAuthenticator != null)
|
||||
m_rpcAuthenticator.setCurrentUser( fentry.getSession(), fentry.getSession().getClientInformation());
|
||||
|
||||
// Get the disk interface
|
||||
|
||||
DiskInterface disk = (DiskInterface) fentry
|
||||
.getConnection().getInterface();
|
||||
DiskInterface disk = (DiskInterface) fentry.getConnection().getInterface();
|
||||
|
||||
// Close the file
|
||||
|
||||
disk.closeFile(null,
|
||||
fentry.getConnection(), netFile);
|
||||
} catch (IOException ex) {
|
||||
disk.closeFile( fentry.getSession(), fentry.getConnection(), netFile);
|
||||
|
||||
// Commit any transactions
|
||||
|
||||
fentry.getSession().endTransaction();
|
||||
|
||||
// DEBUG
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("NFSFileExpiry: Closed file=" + fentry.getFile().getFullName() + ", fid=" + fileId);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
logger.error( "File expiry exception", ex);
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("NFSFileExpiry: Closed file=" + fentry.getFile().getFullName() + ", fid=" + fileId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -293,10 +332,10 @@ public class NetworkFileCache {
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param name
|
||||
* String
|
||||
* @param name String
|
||||
* @param rpcAuth RpcAuthenticator
|
||||
*/
|
||||
public NetworkFileCache(String name) {
|
||||
public NetworkFileCache(String name, RpcAuthenticator rpcAuth) {
|
||||
|
||||
// Create the file cache
|
||||
|
||||
@@ -305,6 +344,10 @@ public class NetworkFileCache {
|
||||
// Start the file expiry thread
|
||||
|
||||
m_expiryThread = new FileExpiry(DefaultFileTimeout / 4, name);
|
||||
|
||||
// Set the RPC authenticator
|
||||
|
||||
m_rpcAuthenticator = rpcAuth;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,16 +362,22 @@ public class NetworkFileCache {
|
||||
/**
|
||||
* Add a file to the cache
|
||||
*
|
||||
* @param file
|
||||
* NetworkFile
|
||||
* @param conn
|
||||
* TreeConnection
|
||||
* @param file NetworkFile
|
||||
* @param conn TreeConnection
|
||||
* @param sess SrvSession
|
||||
*/
|
||||
public synchronized final void addFile(NetworkFile file, TreeConnection conn) {
|
||||
public synchronized final void addFile(NetworkFile file, TreeConnection conn, SrvSession sess) {
|
||||
|
||||
// Add the file id mapping
|
||||
|
||||
synchronized (m_fileCache) {
|
||||
m_fileCache.put(new Integer(file.getFileId()), new FileEntry(file,
|
||||
conn));
|
||||
m_fileCache.put(new Integer(file.getFileId()), new FileEntry(file, conn, sess));
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
|
||||
if ( logger.isDebugEnabled())
|
||||
logger.debug("Added file " + file.getName() + ", fid=" + file.getFileId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -350,11 +399,11 @@ public class NetworkFileCache {
|
||||
/**
|
||||
* Find a file via the file id
|
||||
*
|
||||
* @param id
|
||||
* int
|
||||
* @param id int
|
||||
* @param sess SrvSession
|
||||
* @return NetworkFile
|
||||
*/
|
||||
public synchronized final NetworkFile findFile(int id) {
|
||||
public synchronized final NetworkFile findFile(int id, SrvSession sess) {
|
||||
|
||||
// Create the search key
|
||||
|
||||
@@ -372,6 +421,8 @@ public class NetworkFileCache {
|
||||
// Update the file timeout and return the file
|
||||
|
||||
fentry.updateTimeout();
|
||||
fentry.setSession(sess);
|
||||
|
||||
return fentry.getFile();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user