// 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 <see cref="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 /// (<seealso cref="NativeFSLockFactory"/>); </param> /// <exception cref="IOException"> if there is a low-level I/O error </exception> protected internal FSDirectory(DirectoryInfo path, LockFactory lockFactory) { // new ctors use always NativeFSLockFactory as default: if (lockFactory == null) { lockFactory = new NativeFSLockFactory(); } m_directory = new DirectoryInfo(path.GetCanonicalPath()); if (File.Exists(path.FullName)) { throw new DirectoryNotFoundException("file '" + path.FullName + "' exists but is not a directory"); } SetLockFactory(lockFactory); }
/// <summary> /// Create a new <see cref="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 /// (<seealso cref="NativeFSLockFactory"/>); </param> /// <exception cref="IOException"> if there is a low-level I/O error </exception> protected internal FSDirectory(DirectoryInfo path, LockFactory lockFactory) { // new ctors use always NativeFSLockFactory as default: if (lockFactory == null) { lockFactory = new NativeFSLockFactory(); } m_directory = path; // Lucene.NET doesn't need to call GetCanonicalPath since we already have DirectoryInfo handy if (File.Exists(path.FullName)) { throw new DirectoryNotFoundException("file '" + path.FullName + "' exists but is not a directory"); } SetLockFactory(lockFactory); }
/// <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 /// (<seealso cref="NativeFSLockFactory"/>); </param> /// <exception cref="System.IO.IOException"> if there is a low-level I/O error </exception> protected internal FSDirectory(DirectoryInfo path, LockFactory lockFactory) { // new ctors use always NativeFSLockFactory as default: if (lockFactory == null) { lockFactory = new NativeFSLockFactory(); } Directory_Renamed = GetCanonicalPath(path); if (File.Exists(path.FullName)) { throw new NoSuchDirectoryException("file '" + path.FullName + "' exists but is not a directory"); //should be NoSuchDirectoryException } LockFactory = lockFactory; }
/// <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 /// (<see cref="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(); } // 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 Lucene.Net.Store.FSDirectoryLockFactoryClass is set, // instantiate that; else, use SimpleFSLockFactory: internalDirectory = path; // due to differences in how Java & .NET refer to files, the checks are a bit different if (!internalDirectory.Exists && System.IO.File.Exists(internalDirectory.FullName)) { throw new NoSuchDirectoryException("file '" + internalDirectory.FullName + "' exists but is not a directory"); } 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.LockDir; // if the lock factory has no lockDir set, use the this directory as lockDir if (dir == null) { lf.LockDir = this.internalDirectory; lf.LockPrefix = null; } else if (dir.FullName.Equals(this.internalDirectory.FullName)) { lf.LockPrefix = null; } } }
public virtual void TestNativeFSLockFactory() { var f = new NativeFSLockFactory(CreateTempDir("testNativeFsLockFactory")); f.LockPrefix = "test"; var l = f.MakeLock("commit"); var l2 = f.MakeLock("commit"); Assert.IsTrue(l.Obtain(), "failed to obtain lock, got exception: {0}", l.FailureReason); Assert.IsTrue(!l2.Obtain(), "succeeded in obtaining lock twice"); l.Dispose(); Assert.IsTrue(l2.Obtain(), "failed to obtain 2nd lock after first one was freed, got exception: {0}", l2.FailureReason); l2.Dispose(); // Make sure we can obtain first one again, test isLocked(): Assert.IsTrue(l.Obtain(), "failed to obtain lock, got exception: {0}", l.FailureReason); Assert.IsTrue(l.Locked); Assert.IsTrue(l2.Locked); l.Dispose(); Assert.IsFalse(l.Locked); Assert.IsFalse(l2.Locked); }
public virtual void TestNativeFSLockFactory() { NativeFSLockFactory f = new NativeFSLockFactory(SupportClass.AppSettings.Get("tempDir", System.IO.Path.GetTempPath())); f.SetLockPrefix("test"); Lock l = f.MakeLock("commit"); Lock l2 = f.MakeLock("commit"); Assert.IsTrue(l.Obtain(), "failed to obtain lock"); Assert.IsTrue(!l2.Obtain(), "succeeded in obtaining lock twice"); l.Release(); Assert.IsTrue(l2.Obtain(), "failed to obtain 2nd lock after first one was freed"); l2.Release(); // Make sure we can obtain first one again, test isLocked(): Assert.IsTrue(l.Obtain(), "failed to obtain lock"); Assert.IsTrue(l.IsLocked()); Assert.IsTrue(l2.IsLocked()); l.Release(); Assert.IsFalse(l.IsLocked()); Assert.IsFalse(l2.IsLocked()); }
public virtual void TestNativeFSLockFactory() { //NativeFSLockFactory f = new NativeFSLockFactory(CreateTempDir(LuceneTestCase.TestClass.SimpleName)); NativeFSLockFactory f = new NativeFSLockFactory(AppSettings.Get("tempDir", Path.GetTempPath())); f.LockPrefix = "test"; Lock l = f.MakeLock("commit"); Lock l2 = f.MakeLock("commit"); Assert.IsTrue(l.Obtain(), "failed to obtain lock"); Assert.IsTrue(!l2.Obtain(), "succeeded in obtaining lock twice"); l.Dispose(); Assert.IsTrue(l2.Obtain(), "failed to obtain 2nd lock after first one was freed"); l2.Dispose(); // Make sure we can obtain first one again, test isLocked(): Assert.IsTrue(l.Obtain(), "failed to obtain lock"); Assert.IsTrue(l.Locked); Assert.IsTrue(l2.Locked); l.Dispose(); Assert.IsFalse(l.Locked); Assert.IsFalse(l2.Locked); }
public NativeFSLock(NativeFSLockFactory outerInstance, DirectoryInfo lockDir, string lockFileName) { this.outerInstance = outerInstance; this.lockDir = lockDir; path = new DirectoryInfo(System.IO.Path.Combine(lockDir.FullName, lockFileName)); }
public virtual void TestNativeFSLockFactory() { var f = new NativeFSLockFactory(CreateTempDir("testNativeFsLockFactory")); f.LockPrefix = "test"; var l = f.MakeLock("commit"); var l2 = f.MakeLock("commit"); Assert.IsTrue(l.Obtain(), "failed to obtain lock, got exception: {0}", l.FailureReason); Assert.IsTrue(!l2.Obtain(), "succeeded in obtaining lock twice"); l.Dispose(); Assert.IsTrue(l2.Obtain(), "failed to obtain 2nd lock after first one was freed, got exception: {0}", l2.FailureReason); l2.Dispose(); // Make sure we can obtain first one again, test isLocked(): Assert.IsTrue(l.Obtain(), "failed to obtain lock, got exception: {0}", l.FailureReason); Assert.IsTrue(l.Locked); Assert.IsTrue(l2.Locked); l.Dispose(); Assert.IsFalse(l.Locked); Assert.IsFalse(l2.Locked); }
/// <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 /// (<seealso cref="NativeFSLockFactory"/>); </param> /// <exception cref="System.IO.IOException"> if there is a low-level I/O error </exception> protected internal FSDirectory(DirectoryInfo path, LockFactory lockFactory) { // new ctors use always NativeFSLockFactory as default: if (lockFactory == null) { lockFactory = new NativeFSLockFactory(); } directory = path; // Lucene.NET doesn't need to call GetCanonicalPath since we already have DirectoryInfo handy if (File.Exists(path.FullName)) { throw new NoSuchDirectoryException("file '" + path.FullName + "' exists but is not a directory"); //should be NoSuchDirectoryException } LockFactory = lockFactory; }
// 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 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 /// (<see cref="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(); } // 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 Lucene.Net.Store.FSDirectoryLockFactoryClass is set, // instantiate that; else, use SimpleFSLockFactory: internalDirectory = path; // due to differences in how Java & .NET refer to files, the checks are a bit different if (!internalDirectory.Exists && System.IO.File.Exists(internalDirectory.FullName)) { throw new NoSuchDirectoryException("file '" + internalDirectory.FullName + "' exists but is not a directory"); } 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.LockDir; // if the lock factory has no lockDir set, use the this directory as lockDir if (dir == null) { lf.LockDir = this.internalDirectory; lf.LockPrefix = null; } else if (dir.FullName.Equals(this.internalDirectory.FullName)) { lf.LockPrefix = null; } } }
public SharingAwareNativeFSLock(NativeFSLockFactory outerInstance, DirectoryInfo lockDir, string path) { this.outerInstance = outerInstance; this.lockDir = lockDir; this.path = path; }
// 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.FileInfo path, LockFactory lockFactory) { path = GetCanonicalPath(path); // new ctors use always NativeFSLockFactory as default: if (lockFactory == null) { lockFactory = new NativeFSLockFactory(); } Init(path, lockFactory); refCount = 1; }
public virtual void TestNativeFSLockFactory() { //NativeFSLockFactory f = new NativeFSLockFactory(CreateTempDir(LuceneTestCase.TestClass.SimpleName)); NativeFSLockFactory f = new NativeFSLockFactory(AppSettings.Get("tempDir", Path.GetTempPath())); f.LockPrefix = "test"; Lock l = f.MakeLock("commit"); Lock l2 = f.MakeLock("commit"); Assert.IsTrue(l.Obtain(), "failed to obtain lock"); Assert.IsTrue(!l2.Obtain(), "succeeded in obtaining lock twice"); l.Dispose(); Assert.IsTrue(l2.Obtain(), "failed to obtain 2nd lock after first one was freed"); l2.Dispose(); // Make sure we can obtain first one again, test isLocked(): Assert.IsTrue(l.Obtain(), "failed to obtain lock"); Assert.IsTrue(l.Locked); Assert.IsTrue(l2.Locked); l.Dispose(); Assert.IsFalse(l.Locked); Assert.IsFalse(l2.Locked); }
public WindowsNativeFSLock(NativeFSLockFactory outerInstance, DirectoryInfo lockDir, string path) : base(outerInstance, lockDir, path) { }
public virtual void TestNativeFSLockFactory() { NativeFSLockFactory f = new NativeFSLockFactory(SupportClass.AppSettings.Get("tempDir", System.IO.Path.GetTempPath())); f.SetLockPrefix("test"); Lock l = f.MakeLock("commit"); Lock l2 = f.MakeLock("commit"); Assert.IsTrue(l.Obtain(), "failed to obtain lock"); Assert.IsTrue(!l2.Obtain(), "succeeded in obtaining lock twice"); l.Release(); Assert.IsTrue(l2.Obtain(), "failed to obtain 2nd lock after first one was freed"); l2.Release(); // Make sure we can obtain first one again, test isLocked(): Assert.IsTrue(l.Obtain(), "failed to obtain lock"); Assert.IsTrue(l.IsLocked()); Assert.IsTrue(l2.IsLocked()); l.Release(); Assert.IsFalse(l.IsLocked()); Assert.IsFalse(l2.IsLocked()); }
public NativeFSLock(NativeFSLockFactory creatingInstance, DirectoryInfo lockDir, string lockFileName) { _creatingInstance = creatingInstance; this.LockDir = lockDir; Path = new DirectoryInfo(System.IO.Path.Combine(lockDir.FullName, lockFileName)); }
public NativeFSLock(NativeFSLockFactory creatingInstance, DirectoryInfo lockDir, string lockFileName) { _creatingInstance = creatingInstance; this.LockDir = lockDir; Path = new DirectoryInfo(System.IO.Path.Combine(lockDir.FullName, lockFileName)); }
/// <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 /// (<seealso cref="NativeFSLockFactory"/>); </param> /// <exception cref="System.IO.IOException"> if there is a low-level I/O error </exception> protected internal FSDirectory(DirectoryInfo path, LockFactory lockFactory) { // new ctors use always NativeFSLockFactory as default: if (lockFactory == null) { lockFactory = new NativeFSLockFactory(); } directory = GetCanonicalPath(path); if (File.Exists(path.FullName)) { throw new NoSuchDirectoryException("file '" + path.FullName + "' exists but is not a directory"); //should be NoSuchDirectoryException } LockFactory = lockFactory; }