internal bool AnyChanges() { globalBufferLock.@Lock(); try { /* * check if all items in the global slice were applied * and if the global slice is up-to-date * and if globalBufferedUpdates has changes */ return(globalBufferedUpdates.Any() || !globalSlice.IsEmpty || globalSlice.sliceTail != tail || tail.next != null); } finally { globalBufferLock.Unlock(); } }
public bool AnyChanges() { GlobalBufferLock.@Lock(); try { /* * check if all items in the global slice were applied * and if the global slice is up-to-date * and if globalBufferedUpdates has changes */ return(GlobalBufferedUpdates.Any() || !GlobalSlice.Empty || GlobalSlice.SliceTail != Tail || Tail.Next != null); } finally { GlobalBufferLock.Unlock(); } }
public override void Run() { for (int iter = 0; iter < Iters && !Failed.Get(); iter++) { //final int x = Random().nextInt(5); int x = Random.Next(3); try { switch (x) { case 0: RollbackLock.@Lock(); if (VERBOSE) { Console.WriteLine("\nTEST: " + Thread.CurrentThread.Name + ": now rollback"); } try { WriterRef.Value.Rollback(); if (VERBOSE) { Console.WriteLine("TEST: " + Thread.CurrentThread.Name + ": rollback done; now open new writer"); } WriterRef.Value = new IndexWriter(d, OuterInstance.NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random))); } finally { RollbackLock.Unlock(); } break; case 1: CommitLock.@Lock(); if (VERBOSE) { Console.WriteLine("\nTEST: " + Thread.CurrentThread.Name + ": now commit"); } try { if (Random.NextBoolean()) { WriterRef.Value.PrepareCommit(); } WriterRef.Value.Commit(); } catch (ObjectDisposedException) { // ok } catch (NullReferenceException) { // ok } finally { CommitLock.Unlock(); } break; case 2: if (VERBOSE) { Console.WriteLine("\nTEST: " + Thread.CurrentThread.Name + ": now add"); } try { WriterRef.Value.AddDocument(Docs.NextDoc()); } catch (ObjectDisposedException) { // ok } catch (System.NullReferenceException) { // ok } catch (InvalidOperationException) { // ok } break; } } catch (Exception t) { Failed.Set(true); throw new Exception(t.Message, t); } } }
public override void Run() { for (int iter = 0; iter < iters && !failed.Value; iter++) { //final int x = Random().nextInt(5); int x = Random.Next(3); try { switch (x) { case 0: rollbackLock.@Lock(); if (Verbose) { Console.WriteLine("\nTEST: " + Thread.CurrentThread.Name + ": now rollback"); } try { writerRef.Value.Rollback(); if (Verbose) { Console.WriteLine("TEST: " + Thread.CurrentThread.Name + ": rollback done; now open new writer"); } writerRef.Value = new IndexWriter(d, NewIndexWriterConfig( #if FEATURE_INSTANCE_TESTDATA_INITIALIZATION outerInstance, #endif TEST_VERSION_CURRENT, new MockAnalyzer(Random))); } finally { rollbackLock.Unlock(); } break; case 1: commitLock.@Lock(); if (Verbose) { Console.WriteLine("\nTEST: " + Thread.CurrentThread.Name + ": now commit"); } try { if (Random.NextBoolean()) { writerRef.Value.PrepareCommit(); } writerRef.Value.Commit(); } catch (Exception ace) when(ace.IsAlreadyClosedException()) { // ok } catch (NullReferenceException) // LUCENENET TODO: - NullReferenceException must be allowed to propagate so we can defensively avoid it in .NET { // ok } finally { commitLock.Unlock(); } break; case 2: if (Verbose) { Console.WriteLine("\nTEST: " + Thread.CurrentThread.Name + ": now add"); } try { writerRef.Value.AddDocument(docs.NextDoc()); } catch (Exception ace) when(ace.IsAlreadyClosedException()) { // ok } catch (NullReferenceException) // LUCENENET TODO: - NullReferenceException must be allowed to propagate so we can defensively avoid it in .NET { // ok } catch (Exception ae) when(ae.IsAssertionError()) { // ok } break; } } catch (Exception t) when(t.IsThrowable()) { failed.Value = (true); throw RuntimeException.Create(t); } } }
public override void Run() { for (int iter = 0; iter < iters && !failed.Value; iter++) { //final int x = Random().nextInt(5); int x = Random.Next(3); try { switch (x) { case 0: rollbackLock.@Lock(); if (Verbose) { Console.WriteLine("\nTEST: " + Thread.CurrentThread.Name + ": now rollback"); } try { writerRef.Value.Rollback(); if (Verbose) { Console.WriteLine("TEST: " + Thread.CurrentThread.Name + ": rollback done; now open new writer"); } writerRef.Value = new IndexWriter(d, NewIndexWriterConfig( #if FEATURE_INSTANCE_TESTDATA_INITIALIZATION outerInstance, #endif TEST_VERSION_CURRENT, new MockAnalyzer(Random))); } finally { rollbackLock.Unlock(); } break; case 1: commitLock.@Lock(); if (Verbose) { Console.WriteLine("\nTEST: " + Thread.CurrentThread.Name + ": now commit"); } try { if (Random.NextBoolean()) { writerRef.Value.PrepareCommit(); } writerRef.Value.Commit(); } catch (ObjectDisposedException) { // ok } catch (NullReferenceException) { // ok } finally { commitLock.Unlock(); } break; case 2: if (Verbose) { Console.WriteLine("\nTEST: " + Thread.CurrentThread.Name + ": now add"); } try { writerRef.Value.AddDocument(docs.NextDoc()); } catch (ObjectDisposedException) { // ok } catch (NullReferenceException) { // ok } catch (InvalidOperationException) { // ok } catch (AssertionException) { // ok } break; } } catch (Exception t) { failed.Value = (true); throw new Exception(t.Message, t); } } }