/// <summary>Just like {@link #Open(File)}, but allows you to /// also specify a custom {@link LockFactory}. /// </summary> public static FSDirectory Open(System.IO.DirectoryInfo path, LockFactory lockFactory) { /* For testing: MMapDirectory dir=new MMapDirectory(path, lockFactory); dir.setUseUnmap(true); return dir; */ if (Constants.WINDOWS) { return new SimpleFSDirectory(path, lockFactory); } else { //NIOFSDirectory is not implemented in Mono.Lucene.Net //return new NIOFSDirectory(path, lockFactory); return new SimpleFSDirectory(path, lockFactory); } }
/* will move to ctor, when reflection is removed in 3.0 */ private void Init(System.IO.DirectoryInfo path, LockFactory lockFactory) { // Set up lockFactory with cascaded defaults: if an instance was passed in, // use that; else if locks are disabled, use NoLockFactory; else if the // system property Mono.Lucene.Net.Store.FSDirectoryLockFactoryClass is set, // instantiate that; else, use SimpleFSLockFactory: directory = path; // due to differences in how Java & .NET refer to files, the checks are a bit different if (!directory.Exists && System.IO.File.Exists(directory.FullName)) { throw new NoSuchDirectoryException("file '" + directory.FullName + "' exists but is not a directory"); } if (lockFactory == null) { if (disableLocks) { // Locks are disabled: lockFactory = NoLockFactory.GetNoLockFactory(); } else { System.String lockClassName = SupportClass.AppSettings.Get("Mono.Lucene.Net.Store.FSDirectoryLockFactoryClass", ""); if (lockClassName != null && !lockClassName.Equals("")) { System.Type c; try { c = System.Type.GetType(lockClassName); } catch (System.Exception e) { throw new System.IO.IOException("unable to find LockClass " + lockClassName); } try { lockFactory = (LockFactory) System.Activator.CreateInstance(c, true); } catch (System.UnauthorizedAccessException e) { throw new System.IO.IOException("IllegalAccessException when instantiating LockClass " + lockClassName); } catch (System.InvalidCastException e) { throw new System.IO.IOException("unable to cast LockClass " + lockClassName + " instance to a LockFactory"); } catch (System.Exception e) { throw new System.IO.IOException("InstantiationException when instantiating LockClass " + lockClassName); } } else { // Our default lock is SimpleFSLockFactory; // default lockDir is our index directory: lockFactory = new SimpleFSLockFactory(); } } } SetLockFactory(lockFactory); // for filesystem based LockFactory, delete the lockPrefix, if the locks are placed // in index dir. If no index dir is given, set ourselves if (lockFactory is FSLockFactory) { FSLockFactory lf = (FSLockFactory) lockFactory; System.IO.DirectoryInfo dir = lf.GetLockDir(); // if the lock factory has no lockDir set, use the this directory as lockDir if (dir == null) { lf.SetLockDir(this.directory); lf.SetLockPrefix(null); } else if (dir.FullName.Equals(this.directory.FullName)) { lf.SetLockPrefix(null); } } }
public static FSDirectory GetDirectory(System.IO.DirectoryInfo file, LockFactory lockFactory) { FSDirectory dir; lock (DIRECTORIES) { if(!DIRECTORIES.TryGetValue(file.FullName, out dir)) { try { dir = (FSDirectory)System.Activator.CreateInstance(IMPL, true); } catch (System.Exception e) { throw new System.SystemException("cannot load FSDirectory class: " + e.ToString(), e); } dir.Init(file, lockFactory); DIRECTORIES.Add(file.FullName, dir); } else { // Catch the case where a Directory is pulled from the cache, but has a // different LockFactory instance. if (lockFactory != null && lockFactory != dir.GetLockFactory()) { throw new System.IO.IOException("Directory was previously created with a different LockFactory instance; please pass null as the lockFactory instance and use setLockFactory to change it"); } dir.checked_Renamed = false; } } lock (dir) { dir.refCount++; } return dir; }
// permit subclassing /// <summary>Create a new FSDirectory for the named location (ctor for subclasses).</summary> /// <param name="path">the path of the directory /// </param> /// <param name="lockFactory">the lock factory to use, or null for the default /// ({@link NativeFSLockFactory}); /// </param> /// <throws> IOException </throws> protected internal FSDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory) { // new ctors use always NativeFSLockFactory as default: if (lockFactory == null) { lockFactory = new NativeFSLockFactory(); } Init(path, lockFactory); refCount = 1; }
/// <summary>Create a new MMapDirectory for the named location. /// /// </summary> /// <param name="path">the path of the directory /// </param> /// <param name="lockFactory">the lock factory to use, or null for the default. /// </param> /// <throws> IOException </throws> public MMapDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory) : base(path, lockFactory) { InitBlock(); }
/// <summary> Set the LockFactory that this Directory instance should /// use for its locking implementation. Each * instance of /// LockFactory should only be used for one directory (ie, /// do not share a single instance across multiple /// Directories). /// /// </summary> /// <param name="lockFactory">instance of {@link LockFactory}. /// </param> public virtual void SetLockFactory(LockFactory lockFactory) { this.lockFactory = lockFactory; lockFactory.SetLockPrefix(this.GetLockID()); }
public SimpleFSDirectory(System.IO.FileInfo path, LockFactory lockFactory) : base(new System.IO.DirectoryInfo(path.FullName), lockFactory) { }
public NIOFSDirectory(System.IO.DirectoryInfo dir, LockFactory lockFactory) { }
public static FSDirectory GetDirectory(System.IO.FileInfo file, LockFactory lockFactory) { return(GetDirectory(new System.IO.DirectoryInfo(file.FullName), lockFactory)); }
/* will move to ctor, when reflection is removed in 3.0 */ private void Init(System.IO.DirectoryInfo path, LockFactory lockFactory) { // Set up lockFactory with cascaded defaults: if an instance was passed in, // use that; else if locks are disabled, use NoLockFactory; else if the // system property Mono.Lucene.Net.Store.FSDirectoryLockFactoryClass is set, // instantiate that; else, use SimpleFSLockFactory: directory = path; // due to differences in how Java & .NET refer to files, the checks are a bit different if (!directory.Exists && System.IO.File.Exists(directory.FullName)) { throw new NoSuchDirectoryException("file '" + directory.FullName + "' exists but is not a directory"); } if (lockFactory == null) { if (disableLocks) { // Locks are disabled: lockFactory = NoLockFactory.GetNoLockFactory(); } else { System.String lockClassName = SupportClass.AppSettings.Get("Mono.Lucene.Net.Store.FSDirectoryLockFactoryClass", ""); if (lockClassName != null && !lockClassName.Equals("")) { System.Type c; try { c = System.Type.GetType(lockClassName); } catch (System.Exception e) { throw new System.IO.IOException("unable to find LockClass " + lockClassName); } try { lockFactory = (LockFactory)System.Activator.CreateInstance(c, true); } catch (System.UnauthorizedAccessException e) { throw new System.IO.IOException("IllegalAccessException when instantiating LockClass " + lockClassName); } catch (System.InvalidCastException e) { throw new System.IO.IOException("unable to cast LockClass " + lockClassName + " instance to a LockFactory"); } catch (System.Exception e) { throw new System.IO.IOException("InstantiationException when instantiating LockClass " + lockClassName); } } else { // Our default lock is SimpleFSLockFactory; // default lockDir is our index directory: lockFactory = new SimpleFSLockFactory(); } } } SetLockFactory(lockFactory); // for filesystem based LockFactory, delete the lockPrefix, if the locks are placed // in index dir. If no index dir is given, set ourselves if (lockFactory is FSLockFactory) { FSLockFactory lf = (FSLockFactory)lockFactory; System.IO.DirectoryInfo dir = lf.GetLockDir(); // if the lock factory has no lockDir set, use the this directory as lockDir if (dir == null) { lf.SetLockDir(this.directory); lf.SetLockPrefix(null); } else if (dir.FullName.Equals(this.directory.FullName)) { lf.SetLockPrefix(null); } } }
public static FSDirectory GetDirectory(System.String path, LockFactory lockFactory) { return(GetDirectory(new System.IO.DirectoryInfo(path), lockFactory)); }
/// <summary>Create a new SimpleFSDirectory for the named location. /// /// </summary> /// <param name="path">the path of the directory /// </param> /// <param name="lockFactory">the lock factory to use, or null for the default. /// </param> /// <throws> IOException </throws> public SimpleFSDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory) : base(path, lockFactory) { }
public SimpleFSDirectory(System.IO.FileInfo path, LockFactory lockFactory):base(new System.IO.DirectoryInfo(path.FullName), lockFactory) { }
public MMapDirectory(System.IO.FileInfo path, LockFactory lockFactory) : base(new System.IO.DirectoryInfo(path.FullName), lockFactory) { InitBlock(); }
public static FSDirectory GetDirectory(System.String path, LockFactory lockFactory) { return GetDirectory(new System.IO.DirectoryInfo(path), lockFactory); }
public MMapDirectory(System.IO.FileInfo path, LockFactory lockFactory):base(new System.IO.DirectoryInfo(path.FullName), lockFactory) { InitBlock(); }
public static FSDirectory GetDirectory(System.IO.FileInfo file, LockFactory lockFactory) { return GetDirectory(new System.IO.DirectoryInfo(file.FullName), lockFactory); }
/// <param name="id">should be a unique id across all clients /// </param> /// <param name="lf">the LockFactory that we are testing /// </param> /// <param name="host">host or IP where {@link LockVerifyServer} /// is running /// </param> /// <param name="port">the port {@link LockVerifyServer} is /// listening on /// </param> public VerifyingLockFactory(sbyte id, LockFactory lf, System.String host, int port) { this.id = id; this.lf = lf; this.host = host; this.port = port; }
public NIOFSDirectory(System.IO.DirectoryInfo dir,LockFactory lockFactory) { }