private void startSearching() { removeSearchField(false); if (!this.caseFacade.getCaseHistory().getIsCaseIndexed()) { JOptionPane.showMessageDialog( this, "please do the indexing operation first before do any operation", "Case is not indexed", JOptionPane.ERROR_MESSAGE); return; } String queryString = getQueryText(); if (queryString.isEmpty()) { JOptionPane.showMessageDialog( this, "please fill the query string and choose an index location"); return; } this.searchProgressBard.setIndeterminate(true); this.resultSavingButton.setEnabled(false); SearcherThread sThread = new SearcherThread(this); sThread.execute(); }
// Verify: do stress test, by opening IndexReaders and // IndexWriters over & over in 2 threads and making sure // no unexpected exceptions are raised: public void testStressLocks() throws Exception { Path tempPath = createTempDir(); assumeFalse("cannot handle buggy Files.delete", TestUtil.hasWindowsFS(tempPath)); Directory dir = getDirectory(tempPath); // First create a 1 doc index: IndexWriter w = new IndexWriter( dir, new IndexWriterConfig(new MockAnalyzer(random())).setOpenMode(OpenMode.CREATE)); addDoc(w); w.close(); WriterThread writer = new WriterThread(100, dir); SearcherThread searcher = new SearcherThread(100, dir); writer.start(); searcher.start(); while (writer.isAlive() || searcher.isAlive()) { Thread.sleep(1000); } assertTrue("IndexWriter hit unexpected exceptions", !writer.hitException); assertTrue("IndexSearcher hit unexpected exceptions", !searcher.hitException); dir.close(); }
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); _finder = new AppEngineStationFinder(); _searchThread = new SearcherThread(MainActivity.this, _searchRequestQueue); _searchThread.start(); _uiThreadCallback = new Handler(); initViewMembers(); preloadIconBitmaps(); _mapView.getOverlays().add(new TapListenerOverlay(this)); _locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); initMyLocationOverview(); registerLocationListener(); if (!_locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { buildAlertMessageNoGps(); } useLastKnownLocation(_locationManager); Log.v(TAG, "On create finished"); // updateLocation( 53.250721,10.433192 ); }
public void testTransactions() throws Throwable { // we cant use non-ramdir on windows, because this test needs to double-write. MockDirectoryWrapper dir1 = new MockDirectoryWrapper(random(), new RAMDirectory()); MockDirectoryWrapper dir2 = new MockDirectoryWrapper(random(), new RAMDirectory()); dir1.setPreventDoubleWrite(false); dir2.setPreventDoubleWrite(false); dir1.failOn(new RandomFailure()); dir2.failOn(new RandomFailure()); dir1.setFailOnOpenInput(false); dir2.setFailOnOpenInput(false); // We throw exceptions in deleteFile, which creates // leftover files: dir1.setAssertNoUnrefencedFilesOnClose(false); dir2.setAssertNoUnrefencedFilesOnClose(false); initIndex(dir1); initIndex(dir2); TimedThread[] threads = new TimedThread[3]; int numThread = 0; IndexerThread indexerThread = new IndexerThread(this, dir1, dir2, threads); threads[numThread++] = indexerThread; indexerThread.start(); SearcherThread searcherThread1 = new SearcherThread(this, dir1, dir2, threads); threads[numThread++] = searcherThread1; searcherThread1.start(); SearcherThread searcherThread2 = new SearcherThread(this, dir1, dir2, threads); threads[numThread++] = searcherThread2; searcherThread2.start(); for (int i = 0; i < numThread; i++) threads[i].join(); for (int i = 0; i < numThread; i++) assertTrue(!threads[i].failed); dir1.close(); dir2.close(); }
public static void main(String[] args) throws Exception { IndexWriter writer = new IndexWriter("index", ANALYZER, true); Thread indexerThread = new IndexerThread(writer); indexerThread.start(); Thread.sleep(1000); SearcherThread searcherThread1 = new SearcherThread(false); searcherThread1.start(); SEARCHER = new IndexSearcher("index"); SearcherThread searcherThread2 = new SearcherThread(true); searcherThread2.start(); SearcherThread searcherThread3 = new SearcherThread(true); searcherThread3.start(); }