20 namespace Lucene.Net.Store
37 public static void Main(System.String[] args)
42 System.Console.Out.WriteLine(
"\nUsage: java Lucene.Net.Store.LockStressTest myID verifierHostOrIP verifierPort lockFactoryClassName lockDirName sleepTime\n" +
"\n" +
" myID = int from 0 .. 255 (should be unique for test process)\n" +
" verifierHostOrIP = host name or IP address where LockVerifyServer is running\n" +
" verifierPort = port that LockVerifyServer is listening on\n" +
" lockFactoryClassName = primary LockFactory class that we will use\n" +
" lockDirName = path to the lock directory (only set for Simple/NativeFSLockFactory\n" +
" sleepTimeMS = milliseconds to pause betweeen each lock obtain/release\n" +
"\n" +
"You should run multiple instances of this process, each with its own\n" +
"unique ID, and each pointing to the same lock directory, to verify\n" +
"that locking is working correctly.\n" +
"\n" +
"Make sure you are first running LockVerifyServer.\n" +
"\n");
43 System.Environment.Exit(1);
46 int myID = System.Int32.Parse(args[0]);
48 if (myID < 0 || myID > 255)
50 System.Console.Out.WriteLine(
"myID must be a unique int 0..255");
51 System.Environment.Exit(1);
54 System.String verifierHost = args[1];
55 int verifierPort = System.Int32.Parse(args[2]);
56 System.String lockFactoryClassName = args[3];
57 System.String lockDirName = args[4];
58 int sleepTimeMS = System.Int32.Parse(args[5]);
63 c = System.Type.GetType(lockFactoryClassName);
65 catch (System.Exception)
67 throw new System.IO.IOException(
"unable to find LockClass " + lockFactoryClassName);
73 lockFactory = (
LockFactory) System.Activator.CreateInstance(c);
75 catch (System.UnauthorizedAccessException)
77 throw new System.IO.IOException(
"IllegalAccessException when instantiating LockClass " + lockFactoryClassName);
79 catch (System.InvalidCastException)
81 throw new System.IO.IOException(
"unable to cast LockClass " + lockFactoryClassName +
" instance to a LockFactory");
83 catch (System.Exception)
85 throw new System.IO.IOException(
"InstantiationException when instantiating LockClass " + lockFactoryClassName);
88 System.IO.DirectoryInfo lockDir =
new System.IO.DirectoryInfo(lockDirName);
92 ((NativeFSLockFactory) lockFactory).LockDir = lockDir;
96 ((SimpleFSLockFactory) lockFactory).LockDir = lockDir;
108 bool obtained =
false;
116 System.Console.Out.Write(
"x");
121 System.Console.Out.Write(
"l");
124 System.Threading.Thread.Sleep(
new System.TimeSpan((System.Int64) 10000 * sleepTimeMS));