亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? nativefslockfactory.cs

?? 介紹有關全文檢索的類庫,以lucene為例,在.net環境下實現多種類型文檔的全文檢索.
?? CS
字號:
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using System;

// using FileChannel = java.nio.channels.FileChannel;
// using FileLock = java.nio.channels.FileLock;

namespace Lucene.Net.Store
{
	
	/// <summary> Implements {@link LockFactory} using native OS file locks
	/// (available through java.nio.*).  Note that for certain
	/// filesystems native locks are possible but must be
	/// explicity configured and enabled (and may be disabled by
	/// default).  For example, for NFS servers there sometimes
	/// must be a separate lockd process running, and other
	/// configuration may be required such as running the server
	/// in kernel mode.  Other filesystems may not even support
	/// native OS locks in which case you must use a different
	/// {@link LockFactory} implementation.
	/// 
	/// <p>The advantage of this lock factory over
	/// {@link SimpleFSLockFactory} is that the locks should be
	/// "correct", whereas {@link SimpleFSLockFactory} uses
	/// java.io.File.createNewFile which
	/// <a target="_top" href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#createNewFile()">has warnings</a> about not
	/// using it for locking.  Furthermore, if the JVM crashes,
	/// the OS will free any held locks, whereas
	/// {@link SimpleFSLockFactory} will keep the locks held, requiring
	/// manual removal before re-running Lucene.</p>
	/// 
	/// <p>Note that, unlike {@link SimpleFSLockFactory}, the existence of
	/// leftover lock files in the filesystem on exiting the JVM
	/// is fine because the OS will free the locks held against
	/// these files even though the files still remain.</p>
	/// 
	/// <p>Native locks file names have the substring "-n-", which
	/// you can use to differentiate them from lock files created
	/// by {@link SimpleFSLockFactory}.</p>
	/// 
	/// </summary>
	/// <seealso cref="LockFactory">
	/// </seealso>
	
	public class NativeFSLockFactory : LockFactory
	{
		
		/// <summary> Directory specified by <code>Lucene.Net.lockDir</code>
		/// system property.  If that is not set, then <code>java.io.tmpdir</code>
		/// system property is used.
		/// </summary>
		
		private System.IO.FileInfo lockDir;
		
		// Simple test to verify locking system is "working".  On
		// NFS, if it's misconfigured, you can hit long (35
		// second) timeouts which cause Lock.obtain to take far
		// too long (it assumes the obtain() call takes zero
		// time).  Since it's a configuration problem, we test up
		// front once on creating the LockFactory:
		private void  AcquireTestLock()
		{
			System.String randomLockName = "lucene-" + System.Convert.ToString(new System.Random().Next(), 16) + "-test.lock";
			
			Lock l = MakeLock(randomLockName);
			try
			{
				l.Obtain();
			}
			catch (System.IO.IOException e)
			{
				System.IO.IOException e2 = new System.IO.IOException("Failed to acquire random test lock; please verify filesystem for lock directory '" + lockDir + "' supports locking", e);
				throw e2;
			}
			
			l.Release();
		}
		
		/// <summary> Create a NativeFSLockFactory instance, storing lock
		/// files into the specified lockDirName:
		/// 
		/// </summary>
		/// <param name="lockDirName">where lock files are created.
		/// </param>
		public NativeFSLockFactory(System.String lockDirName) : this(new System.IO.FileInfo(lockDirName))
		{
		}
		
		/// <summary> Create a NativeFSLockFactory instance, storing lock
		/// files into the specified lockDir:
		/// 
		/// </summary>
		/// <param name="lockDir">where lock files are created.
		/// </param>
		public NativeFSLockFactory(System.IO.FileInfo lockDir)
		{
			
			this.lockDir = lockDir;
			
			// Ensure that lockDir exists and is a directory.
			bool tmpBool;
			if (System.IO.File.Exists(lockDir.FullName))
				tmpBool = true;
			else
				tmpBool = System.IO.Directory.Exists(lockDir.FullName);
			if (!tmpBool)
			{
                try
                {
                    System.IO.Directory.CreateDirectory(lockDir.FullName);
                }
                catch
                {
                    throw new System.IO.IOException("Cannot create directory: " + lockDir.FullName);
                }
			}
			else if (!System.IO.Directory.Exists(lockDir.FullName))
			{
				throw new System.IO.IOException("Found regular file where directory expected: " + lockDir.FullName);
			}
			
			AcquireTestLock();
		}
		
		public override Lock MakeLock(System.String lockName)
		{
			lock (this)
			{
				if (lockPrefix != null)
					lockName = lockPrefix + "-n-" + lockName;
				return new NativeFSLock(lockDir, lockName);
			}
		}
		
		public override void  ClearLock(System.String lockName)
		{
			// Note that this isn't strictly required anymore
			// because the existence of these files does not mean
			// they are locked, but, still do this in case people
			// really want to see the files go away:
			bool tmpBool;
			if (System.IO.File.Exists(lockDir.FullName))
				tmpBool = true;
			else
				tmpBool = System.IO.Directory.Exists(lockDir.FullName);
			if (tmpBool)
			{
				if (lockPrefix != null)
				{
					lockName = lockPrefix + "-n-" + lockName;
				}
				System.IO.FileInfo lockFile = new System.IO.FileInfo(System.IO.Path.Combine(lockDir.FullName, lockName));
				bool tmpBool2;
				if (System.IO.File.Exists(lockFile.FullName))
					tmpBool2 = true;
				else
					tmpBool2 = System.IO.Directory.Exists(lockFile.FullName);
				bool tmpBool3;
				if (System.IO.File.Exists(lockFile.FullName))
				{
					System.IO.File.Delete(lockFile.FullName);
					tmpBool3 = true;
				}
				else if (System.IO.Directory.Exists(lockFile.FullName))
				{
					System.IO.Directory.Delete(lockFile.FullName);
					tmpBool3 = true;
				}
				else
					tmpBool3 = false;
				if (tmpBool2 && !tmpBool3)
				{
					throw new System.IO.IOException("Cannot delete " + lockFile);
				}
			}
		}
	}
	
	
	class NativeFSLock : Lock
	{
		
		private System.IO.FileStream f;
		private System.IO.FileStream channel;   // private FileChannel B; // {{Aroush-2.1}}
		private bool lock_Renamed;              // FileLock lock_Renamed;   // {{Aroush-2.1}}
		private System.IO.FileInfo path;
		private System.IO.FileInfo lockDir;
		
		/*
		* The javadocs for FileChannel state that you should have
		* a single instance of a FileChannel (per JVM) for all
		* locking against a given file.  To ensure this, we have
		* a single (static) HashSet that contains the file paths
		* of all currently locked locks.  This protects against
		* possible cases where different Directory instances in
		* one JVM (each with their own NativeFSLockFactory
		* instance) have set the same lock dir and lock prefix.
		*/
		private static System.Collections.Hashtable LOCK_HELD = new System.Collections.Hashtable();
		
		public NativeFSLock(System.IO.FileInfo lockDir, System.String lockFileName)
		{
			this.lockDir = lockDir;
			path = new System.IO.FileInfo(System.IO.Path.Combine(lockDir.FullName, lockFileName));
		}
		
		public override bool Obtain()
		{
			lock (this)
			{
				
				if (IsLocked())
				{
					// Our instance is already locked:
					return false;
				}
				
				// Ensure that lockDir exists and is a directory.
				bool tmpBool;
				if (System.IO.File.Exists(lockDir.FullName))
					tmpBool = true;
				else
					tmpBool = System.IO.Directory.Exists(lockDir.FullName);
				if (!tmpBool)
				{
                    try
                    {
                        System.IO.Directory.CreateDirectory(lockDir.FullName);
                    }
                    catch
                    {
                        throw new System.IO.IOException("Cannot create directory: " + lockDir.FullName);
                    }
				}
				else
				{
                    try
                    {
                         System.IO.Directory.Exists(lockDir.FullName);
                    }
                    catch
                    {
                        throw new System.IO.IOException("Found regular file where directory expected: " + lockDir.FullName);
                    }
				}
				
				System.String canonicalPath = path.FullName;
				
				bool markedHeld = false;
				
				try
				{
					
					// Make sure nobody else in-process has this lock held
					// already, and, mark it held if not:
					
					lock (LOCK_HELD)
					{
						if (LOCK_HELD.Contains(canonicalPath))
						{
							// Someone else in this JVM already has the lock:
							return false;
						}
						else
						{
							// This "reserves" the fact that we are the one
							// thread trying to obtain this lock, so we own
							// the only instance of a channel against this
							// file:
							LOCK_HELD.Add(canonicalPath, canonicalPath);
							markedHeld = true;
						}
					}
					
					try
					{
						f = new System.IO.FileStream(path.FullName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite); 
					}
					catch (System.IO.IOException e)
					{
						// On Windows, we can get intermittant "Access
						// Denied" here.  So, we treat this as failure to
						// acquire the lock, but, store the reason in case
						// there is in fact a real error case.
						failureReason = e;
						f = null;
					}
					
					if (f != null)
					{
						try
						{
							channel = f; // f.getChannel();     // {{Aroush-2.1}}
                            lock_Renamed = false;
							try
							{
								channel.Lock(0, channel.Length);
                                lock_Renamed = true;
							}
							catch (System.IO.IOException e)
							{
								// At least on OS X, we will sometimes get an
								// intermittant "Permission Denied" IOException,
								// which seems to simply mean "you failed to get
								// the lock".  But other IOExceptions could be
								// "permanent" (eg, locking is not supported via
								// the filesystem).  So, we record the failure
								// reason here; the timeout obtain (usually the
								// one calling us) will use this as "root cause"
								// if it fails to get the lock.
								failureReason = e;
							}
							finally
							{
								if (lock_Renamed == false)
								{
									try
									{
										channel.Close();
									}
									finally
									{
										channel = null;
									}
								}
							}
						}
						finally
						{
							if (channel == null)
							{
								try
								{
									f.Close();
								}
								finally
								{
									f = null;
								}
							}
						}
					}
				}
				finally
				{
					if (markedHeld && !IsLocked())
					{
						lock (LOCK_HELD)
						{
							if (LOCK_HELD.Contains(canonicalPath))
							{
								LOCK_HELD.Remove(canonicalPath);
							}
						}
					}
				}
				return IsLocked();
			}
		}
		
		public override void  Release()
		{
			lock (this)
			{
				try
				{
					if (IsLocked())
					{
						try
						{
                            channel.Unlock(0, channel.Length);
						}
						finally
						{
							lock_Renamed = false;
							try
							{
								channel.Close();
							}
							finally
							{
								channel = null;
								try
								{
									f.Close();
								}
								finally
								{
									f = null;
									lock (LOCK_HELD)
									{
										LOCK_HELD.Remove(path.FullName);
									}
								}
							}
						}
						bool tmpBool;
						if (System.IO.File.Exists(path.FullName))
						{
							System.IO.File.Delete(path.FullName);
							tmpBool = true;
						}
						else if (System.IO.Directory.Exists(path.FullName))
						{
							System.IO.Directory.Delete(path.FullName);
							tmpBool = true;
						}
						else
							tmpBool = false;
						bool generatedAux = tmpBool;
					}
				}
				catch (System.IO.IOException e)
				{
					// Not sure how to better message/handle this without
					// changing API?
					throw new System.SystemException("", e);
				}
			}
		}
		
		public override bool IsLocked()
		{
			return lock_Renamed;
		}
		
		public override System.String ToString()
		{
			return "NativeFSLock@" + path;
		}
		
		~NativeFSLock()
		{
			try
			{
				if (IsLocked())
				{
					Release();
				}
			}
			finally
			{
			}
		}
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
51精品久久久久久久蜜臀| 色婷婷精品久久二区二区蜜臀av | 色综合久久九月婷婷色综合| 极品少妇xxxx精品少妇| 久久av资源网| 国产精品一区二区久久不卡| 国产一区激情在线| 成人a级免费电影| 丰满少妇在线播放bd日韩电影| 久久97超碰国产精品超碰| 久久超碰97人人做人人爱| 精品亚洲国内自在自线福利| 精品一二线国产| 夫妻av一区二区| 99久精品国产| 欧美日韩一级二级| 久久久久久亚洲综合| 国产午夜亚洲精品不卡| 亚洲欧洲成人精品av97| 亚洲国产中文字幕| 久久精品国产免费| 99久久久无码国产精品| 欧美日韩久久一区二区| 精品免费视频.| 专区另类欧美日韩| 奇米精品一区二区三区在线观看 | 成人免费观看av| 在线观看国产91| 日韩精品中文字幕在线不卡尤物| 国产女同性恋一区二区| 亚洲成a人在线观看| 久久国产精品99久久人人澡| 99视频一区二区| 欧美一二三区在线观看| 国产人成亚洲第一网站在线播放| 亚洲精品成a人| 九一九一国产精品| 欧美午夜不卡在线观看免费| 337p粉嫩大胆噜噜噜噜噜91av| 国产精品久久久久aaaa| 日本欧美大码aⅴ在线播放| 欧美午夜精品理论片a级按摩| 欧美一级一级性生活免费录像| 中文av字幕一区| 日韩精品国产欧美| 成人av影视在线观看| 678五月天丁香亚洲综合网| 中文字幕欧美区| 青青草成人在线观看| 91热门视频在线观看| 久久蜜桃av一区精品变态类天堂| 一区二区三区日韩精品视频| 丁香一区二区三区| 日韩欧美精品三级| 亚洲国产视频a| 99久久777色| 国产精品久久久久永久免费观看| 久久精品999| 欧美日韩黄色影视| 亚洲一区免费在线观看| av中文字幕一区| 国产精品每日更新在线播放网址| 久久国产精品无码网站| 日韩一区二区三区四区五区六区| 樱桃视频在线观看一区| 97超碰欧美中文字幕| 国产亚洲人成网站| 国产麻豆视频一区| 国产欧美中文在线| 国产精品一区二区久久不卡| 日韩精品专区在线| 黄色日韩网站视频| 精品第一国产综合精品aⅴ| 青青青伊人色综合久久| 91麻豆精品国产91久久久久久 | 3d成人动漫网站| 亚洲欧美日韩国产另类专区 | 偷窥少妇高潮呻吟av久久免费| 99精品国产91久久久久久| 国产精品国产三级国产aⅴ无密码| 国产mv日韩mv欧美| 国产精品久久久久久久久免费桃花| 风间由美一区二区三区在线观看 | 国产成人免费在线观看不卡| 久久免费午夜影院| 国产成人免费视频精品含羞草妖精 | 97久久精品人人做人人爽50路| 国产调教视频一区| 一本在线高清不卡dvd| 亚洲国产综合人成综合网站| 欧美丰满嫩嫩电影| 国产一区二区不卡老阿姨| 欧美激情中文不卡| 在线观看日韩一区| 卡一卡二国产精品| 国产精品欧美一区二区三区| 91污片在线观看| 亚洲国产日韩综合久久精品| 6080午夜不卡| 成人高清视频在线| 亚洲一区二区黄色| 日韩欧美国产三级电影视频| 国产在线精品视频| 一二三区精品视频| 精品国产欧美一区二区| 一本到一区二区三区| 水蜜桃久久夜色精品一区的特点| 精品88久久久久88久久久| 99精品视频在线观看免费| 亚洲6080在线| 欧美经典一区二区| 91成人在线精品| 国产精品1024久久| 亚洲福利视频导航| 国产日韩欧美制服另类| 欧美亚洲一区二区三区四区| 久久超级碰视频| 亚洲一区二区在线视频| 久久久蜜桃精品| 69堂成人精品免费视频| 91免费看视频| 国产精品538一区二区在线| 午夜天堂影视香蕉久久| 国产精品乱人伦| 久久先锋影音av| 在线不卡中文字幕| 欧美丝袜丝交足nylons| 成人禁用看黄a在线| 精久久久久久久久久久| 亚洲一级二级三级| 日韩理论片中文av| 国产拍揄自揄精品视频麻豆| 日韩一区二区三区视频在线观看| 色视频欧美一区二区三区| 成人动漫一区二区在线| 国产精品亚洲视频| 青椒成人免费视频| 一区二区欧美精品| 亚洲精品免费看| 中文字幕在线不卡视频| 久久精品人人做人人爽人人| 日韩精品综合一本久道在线视频| 欧美图片一区二区三区| 欧美中文一区二区三区| 91麻豆精东视频| 色猫猫国产区一区二在线视频| 国产91在线观看| 粉嫩av亚洲一区二区图片| 国产伦精品一区二区三区视频青涩 | 日韩小视频在线观看专区| 欧美日韩日日摸| 欧美日韩一区视频| 欧美酷刑日本凌虐凌虐| 欧美美女黄视频| 欧美军同video69gay| 日韩一区二区三区四区五区六区| 欧美一级生活片| 欧美电视剧在线看免费| 精品入口麻豆88视频| 久久综合久久久久88| 久久日韩粉嫩一区二区三区| 国产亚洲制服色| 亚洲欧洲日韩综合一区二区| 日韩一区在线播放| 一区二区三区四区中文字幕| 亚洲九九爱视频| 午夜精品久久久久久久| 美女国产一区二区| 国产盗摄一区二区| 成人成人成人在线视频| 欧美日韩免费视频| 日韩欧美亚洲国产另类| 中文字幕欧美三区| 亚洲国产中文字幕| 精品无码三级在线观看视频| 成人免费视频app| 欧洲日韩一区二区三区| 精品国产一区二区三区久久久蜜月| 久久久久久日产精品| 亚洲精品国产品国语在线app| 日韩精品亚洲一区二区三区免费| 久久99精品久久久| 95精品视频在线| 欧美mv日韩mv亚洲| 1000精品久久久久久久久| 日韩福利视频网| av在线播放一区二区三区| 欧美精品色综合| 国产精品久久久久一区二区三区| 亚洲午夜精品网| 国产a精品视频| 91精品国产免费| 中文字幕日本不卡| 精品在线一区二区| 欧美性高清videossexo| 久久中文字幕电影| 日韩黄色免费电影| 色呦呦一区二区三区| 久久综合一区二区| 亚洲成a人v欧美综合天堂下载|