You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by th...@apache.org on 2008/03/14 12:41:52 UTC
svn commit: r637070 - in
/labs/droids/trunk/src/examples/java/org/apache/droids/examples:
IndexerCrawler.java droids-example-context.xml
Author: thorsten
Date: Fri Mar 14 04:41:52 2008
New Revision: 637070
URL: http://svn.apache.org/viewvc?rev=637070&view=rev
Log:
Enhancing the indexer example and fixing its context file
Modified:
labs/droids/trunk/src/examples/java/org/apache/droids/examples/IndexerCrawler.java
labs/droids/trunk/src/examples/java/org/apache/droids/examples/droids-example-context.xml
Modified: labs/droids/trunk/src/examples/java/org/apache/droids/examples/IndexerCrawler.java
URL: http://svn.apache.org/viewvc/labs/droids/trunk/src/examples/java/org/apache/droids/examples/IndexerCrawler.java?rev=637070&r1=637069&r2=637070&view=diff
==============================================================================
--- labs/droids/trunk/src/examples/java/org/apache/droids/examples/IndexerCrawler.java (original)
+++ labs/droids/trunk/src/examples/java/org/apache/droids/examples/IndexerCrawler.java Fri Mar 14 04:41:52 2008
@@ -1,13 +1,56 @@
package org.apache.droids.examples;
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import org.apache.droids.Core;
import org.apache.droids.DefaultCrawler;
import org.apache.droids.api.Worker;
+import org.apache.droids.handle.Solr;
+import org.apache.http.PostFile;
public class IndexerCrawler extends DefaultCrawler{
+
+ private String updateUrl;
+ /**
+ * We want to use the indexerWorker since it limits
+ * the handling to the SolrHandler
+ * @return IndexerWorker
+ */
public synchronized Worker getWorker() {
IndexerWorker worker = new IndexerWorker();
worker.setQueue(getQueue());
worker.setDroid(this);
return worker;
+ }
+ /**
+ * Implementing this method since we want to send the commit
+ * command on the end of the whole queue.
+ */
+ protected synchronized void shutdownAndAwaitTermination() {
+ super.shutdownAndAwaitTermination();
+ ByteArrayOutputStream out;
+ BufferedInputStream stream ;
+ PostFile post;
+ Solr solr = new Solr();
+ solr.setUpdateUrl(updateUrl);
+ try {
+ out = solr.createCommitDocument();
+ stream = new BufferedInputStream(
+ new ByteArrayInputStream(out.toByteArray()));
+ post = new PostFile(updateUrl, stream);
+ } catch (Exception e) {
+ Core.threadMessage(e.getMessage());
+ }
+
+ }
+
+ public String getUpdateUrl() {
+ return updateUrl;
+ }
+
+ public void setUpdateUrl(String updateUrl) {
+ this.updateUrl = updateUrl;
}
}
Modified: labs/droids/trunk/src/examples/java/org/apache/droids/examples/droids-example-context.xml
URL: http://svn.apache.org/viewvc/labs/droids/trunk/src/examples/java/org/apache/droids/examples/droids-example-context.xml?rev=637070&r1=637069&r2=637070&view=diff
==============================================================================
--- labs/droids/trunk/src/examples/java/org/apache/droids/examples/droids-example-context.xml (original)
+++ labs/droids/trunk/src/examples/java/org/apache/droids/examples/droids-example-context.xml Fri Mar 14 04:41:52 2008
@@ -23,19 +23,20 @@
<property name="queue" ref="org.apache.droids.queue.Simple"/>
<property name="maxThreads" value="@droids.maxThreads@"/>
<property name="url" value="@droids.initial.url@"/>
+ <property name="updateUrl" value="http://localhost:8983/solr/update"/>
</bean>
<bean id="org.apache.droids.helper.factories.HandlerFactory"
class="org.apache.droids.helper.factories.HandlerFactory">
<property name="map">
<map>
- <entry key="solr" value-ref="org.apache.droids.handle.Save"/>
+ <entry key="solr" value-ref="org.apache.droids.handle.Solr"/>
</map>
</property>
</bean>
<!-- Handler -->
<bean id="org.apache.droids.handle.Solr" class="org.apache.droids.handle.Solr">
- <property name="urpdateUrl" value="http://localhost:8983/solr/update"/>
+ <property name="updateUrl" value="http://localhost:8983/solr/update"/>
</bean>
</beans>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org