Thx for the reply. I tried those lock-methods already but still cant it get to work. Heres what i did in my RequestHandler at least.
Type "Directory" and all Lock stuff comes from org.apache.lucene.store.* and the copyFiles method is the same as for the replication-RequestHandler. I still never see a lucene-xxxxxxxxxxx-write.lock file inside the index-dir as i see one when the index gets optimzed... have a good WE, regards Alex /** * @param req * @param rsp */ private void createBackup(SolrQueryRequest req, SolrQueryResponse rsp){ String message = new String(); String snapDir; if (backupLocation != null){ snapDir = backupLocation + "/" + solrCore.getName(); } else { snapDir = solrCore.getDataDir(); } try{ // backup dir SimpleDateFormat fmt = new SimpleDateFormat(FFBackupConfigDefaults.DATE_FMT); String directoryName = "snapshot." + fmt.format(new Date()); // name darf nicht geändert werden message += "directoryName: " + directoryName + "; \n"; // indexdir open DirectoryFactory dirFac = solrCore.getDirectoryFactory(); String indexDirPath = solrCore.getIndexDir(); Directory indexDir = dirFac.open(indexDirPath); // solr-core verzeichnis in der backup-location erstmal checken und erstellen falls nötig: if (!new File(snapDir).exists()){ new File(snapDir).mkdir(); } File snapShotDir = new File(snapDir, directoryName); if (snapShotDir.mkdir()) { // LOCK String rawLockType = (null == idxConfig) ? null : idxConfig.lockType; if (null == rawLockType) { // we default to "simple" for backwards compatibility LOG.warn("No lockType configured for " + indexDirPath + " assuming 'simple'"); rawLockType = "simple"; } final String lockType = rawLockType.toLowerCase().trim(); if (lockType.equals("simple")) { // multiple SimpleFSLockFactory instances should be OK indexDir.setLockFactory(new SimpleFSLockFactory(indexDirPath)); } else if (lockType.equals("native")) { indexDir.setLockFactory(new NativeFSLockFactory(indexDirPath)); } else if (lockType.equals("single")) { if (!(indexDir.getLockFactory() instanceof SingleInstanceLockFactory)){ indexDir.setLockFactory(new SingleInstanceLockFactory()); } } else if (lockType.equals("none")) { // Recipe for disaster LOG.error("CONFIGURATION WARNING: locks are disabled on " + indexDirPath); indexDir.setLockFactory(new NoLockFactory()); } else { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unrecognized lockType: " + rawLockType); } indexDir.makeLock(org.apache.lucene.index.IndexWriter.WRITE_LOCK_NAME); List<String> files2copy = Arrays.asList(indexDir.listAll()); message += "files2copy: " + files2copy + "; \n"; copyFiles(files2copy, snapShotDir); indexDir.clearLock(org.apache.lucene.index.IndexWriter.WRITE_LOCK_NAME); message += "done\n"; rsp.add("result", message); } else { message += "Kann Snapshotverzeichnis nicht erstellen: " + snapShotDir.getAbsolutePath() + "\n"; LOG.error(message); } LOG.info(message); } catch (IOException e) { message += "Error on creating backup: " + e + "\n"; LOG.error(message, e); } rsp.add("message", message); } On Friday 18 June 2010 14:54:35 Otis Gospodnetic wrote: > Alex, > > For something like that you may just want to directly use one of the Lucene > lock classes to create a lock: > > http://search-lucene.com/?q=lock&fc_project=Lucene&fc_type=source+code > > e.g. > http://search-lucene.com/c/Lucene:/src/java/org/apache/lucene/store/SingleI >nstanceLockFactory.java||makeLock -- Alexander Rothenberg Fotofinder GmbH USt-IdNr. DE812854514 Software Entwicklung Web: http://www.fotofinder.net/ Potsdamer Str. 96 Tel: +49 30 25792890 10785 Berlin Fax: +49 30 257928999 Geschäftsführer: Ali Paczensky Amtsgericht: Berlin Charlottenburg (HRB 73099) Sitz: Berlin