Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixes.

  • Loading branch information...
commit 05631204bda573cb0960e66eb24ddc6269d0214e 1 parent 8116d82
@rnewson authored
View
3  README.md
@@ -21,6 +21,9 @@ You are advised to delete indexes created prior to this update.
<h1>Configure CouchDB</h1>
<pre>
+[couchdb]
+os_process_timeout=60000 ; increase the timeout from 5 seconds.
+
[external]
searcher=/usr/bin/java -jar /path/to/couchdb-lucene*-jar-with-dependencies.jar -search
View
8 TODO
@@ -1,8 +1,6 @@
-* indexer as updater process
-* searcher as external
* sort cache can take too long to build, respond with keep-alive messages.
-* revisit numeric handling (it's too surprising)
-* document rhino integration
-* code tidy in general.
* add a _status uri that lets you see index state/progress.
* add an _optimize option.
+* handle "create" and "delete" notifications explicitly.
+* batch updates (no hair trigger).
+
View
19 src/main/java/org/apache/couchdb/lucene/Index.java
@@ -53,13 +53,13 @@ public void run() {
waitForUpdateNotification();
}
} catch (final IOException e) {
- Log.log(e);
+ Log.errlog(e);
}
}
private void updateIndex() throws IOException {
if (IndexWriter.isLocked(dir)) {
- Log.log("Forcibly unlocking locked index at startup.");
+ Log.errlog("Forcibly unlocking locked index at startup.");
IndexWriter.unlock(dir);
}
@@ -87,7 +87,7 @@ private void updateIndex() throws IOException {
commit |= updateDatabase(writer, dbname, progress, rhino);
}
} catch (final IOException e) {
- Log.log(e);
+ Log.errlog(e);
commit = false;
} finally {
if (commit) {
@@ -107,6 +107,7 @@ private void waitForUpdateNotification() {
} catch (final InterruptedException e) {
running = false;
}
+ Log.errlog("Update detected.");
}
}
@@ -129,7 +130,7 @@ private boolean updateDatabase(final IndexWriter writer, final String dbname, fi
}
if (from == -1) {
- Log.log("index is missing or inconsistent, reindexing all documents for %s.", dbname);
+ Log.errlog("index is missing or inconsistent, reindexing all documents for %s.", dbname);
writer.deleteDocuments(new Term(Config.DB, dbname));
}
@@ -137,7 +138,7 @@ private boolean updateDatabase(final IndexWriter writer, final String dbname, fi
while (from < info.getUpdateSeq()) {
final JSONObject obj = DB.getAllDocsBySeq(dbname, from, Config.BATCH_SIZE);
if (!obj.has("rows")) {
- Log.log("no rows found (%s).", obj);
+ Log.errlog("no rows found (%s).", obj);
return false;
}
final JSONArray rows = obj.getJSONArray("rows");
@@ -160,7 +161,7 @@ private boolean updateDatabase(final IndexWriter writer, final String dbname, fi
progress.setProgress(dbname, info.getUpdateSeq());
if (changed) {
- Log.log("%s: index caught up from %,d to %,d.", dbname, start, info.getUpdateSeq());
+ Log.errlog("%s: index caught up from %,d to %,d.", dbname, start, info.getUpdateSeq());
}
return changed;
@@ -207,7 +208,7 @@ private void updateDocument(final IndexWriter writer, final String dbname, final
if (sc == 200) {
TIKA.parse(get.getResponseBodyAsStream(), att.getString("content_type"), doc);
} else {
- Log.log("Failed to retrieve attachment: %d", sc);
+ Log.errlog("Failed to retrieve attachment: %d", sc);
}
} finally {
get.releaseConnection();
@@ -242,9 +243,9 @@ private void add(final Document out, final String key, final Object value, final
add(out, key, arr.get(i), store);
}
} else if (value == null) {
- Log.log("%s was null.", key);
+ Log.errlog("%s was null.", key);
} else {
- Log.log("Unsupported data type: %s.", value.getClass());
+ Log.errlog("Unsupported data type: %s.", value.getClass());
}
}
View
19 src/main/java/org/apache/couchdb/lucene/Log.java
@@ -2,14 +2,23 @@
public final class Log {
- public static void log(final String fmt, final Object... args) {
- System.out.print("log,");
+ public static void outlog(final String fmt, final Object... args) {
+ System.out.print("{\"log\":\"");
System.out.printf(fmt, args);
- System.out.println();
+ System.out.println("\"}");
}
- public static void log(final Exception e) {
- log("%s", e.getMessage());
+ public static void errlog(final String fmt, final Object... args) {
+ System.err.printf(fmt, args);
+ System.err.println();
+ }
+
+ public static void outlog(final Exception e) {
+ outlog("%s", e.getMessage());
+ }
+
+ public static void errlog(final Exception e) {
+ errlog("%s", e.getMessage());
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.