incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r991374 - in /incubator/lcf/trunk/modules/connectors/solr/connector/src/main/java/org/apache/acf/agents/output/solr: SolrConfig.java SolrConnector.java
Date Tue, 31 Aug 2010 22:32:09 GMT
Author: kwright
Date: Tue Aug 31 22:32:08 2010
New Revision: 991374

URL: http://svn.apache.org/viewvc?rev=991374&view=rev
Log:
Fix for CONNECTORS-57.  Add a checkbox that allows you to turn off end-of-job commits.

Modified:
    incubator/lcf/trunk/modules/connectors/solr/connector/src/main/java/org/apache/acf/agents/output/solr/SolrConfig.java
    incubator/lcf/trunk/modules/connectors/solr/connector/src/main/java/org/apache/acf/agents/output/solr/SolrConnector.java

Modified: incubator/lcf/trunk/modules/connectors/solr/connector/src/main/java/org/apache/acf/agents/output/solr/SolrConfig.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/connectors/solr/connector/src/main/java/org/apache/acf/agents/output/solr/SolrConfig.java?rev=991374&r1=991373&r2=991374&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/connectors/solr/connector/src/main/java/org/apache/acf/agents/output/solr/SolrConfig.java
(original)
+++ incubator/lcf/trunk/modules/connectors/solr/connector/src/main/java/org/apache/acf/agents/output/solr/SolrConfig.java
Tue Aug 31 22:32:08 2010
@@ -51,6 +51,8 @@ public class SolrConfig
   public static final String PARAM_USERID = "User ID";
   /** Optional user password */
   public static final String PARAM_PASSWORD = "Password";
+  /** Enable commits */
+  public static final String PARAM_COMMITS = "Commits";
   /** Node describing an argument */
   public static final String NODE_ARGUMENT = "argument";
   /** Attribute with the argument name */

Modified: incubator/lcf/trunk/modules/connectors/solr/connector/src/main/java/org/apache/acf/agents/output/solr/SolrConnector.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/connectors/solr/connector/src/main/java/org/apache/acf/agents/output/solr/SolrConnector.java?rev=991374&r1=991373&r2=991374&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/connectors/solr/connector/src/main/java/org/apache/acf/agents/output/solr/SolrConnector.java
(original)
+++ incubator/lcf/trunk/modules/connectors/solr/connector/src/main/java/org/apache/acf/agents/output/solr/SolrConnector.java
Tue Aug 31 22:32:08 2010
@@ -44,6 +44,9 @@ public class SolrConnector extends org.a
   /** The deny attribute name */
   protected String denyAttributeName = "deny_token_";
   
+  /** Whether or not to commit */
+  protected boolean doCommits = false;
+  
   /** Constructor.
   */
   public SolrConnector()
@@ -129,6 +132,12 @@ public class SolrConnector extends org.a
       if (idAttributeName == null || idAttributeName.length() == 0)
         idAttributeName = "id";
       
+      String commits = params.getParameter(org.apache.acf.agents.output.solr.SolrConfig.PARAM_COMMITS);
+      if (commits == null || commits.length() == 0)
+        commits = "true";
+      
+      doCommits = commits.equals("true");
+      
       String userID = params.getParameter(SolrConfig.PARAM_USERID);
       String password = params.getObfuscatedParameter(SolrConfig.PARAM_PASSWORD);
       String realm = params.getParameter(SolrConfig.PARAM_REALM);
@@ -369,7 +378,8 @@ public class SolrConnector extends org.a
     getSession();
     
     // Do a commit post
-    poster.commitPost();
+    if (doCommits)
+      poster.commitPost();
   }
 
   // UI support methods.
@@ -394,6 +404,7 @@ public class SolrConnector extends org.a
     tabsArray.add("Server");
     tabsArray.add("Schema");
     tabsArray.add("Arguments");
+    tabsArray.add("Commits");
 
     out.print(
 "<script type=\"text/javascript\">\n"+
@@ -602,7 +613,11 @@ public class SolrConnector extends org.a
     String password = parameters.getObfuscatedParameter(org.apache.acf.agents.output.solr.SolrConfig.PARAM_PASSWORD);
     if (password == null)
       password = "";
-		
+    
+    String commits = parameters.getParameter(org.apache.acf.agents.output.solr.SolrConfig.PARAM_COMMITS);
+    if (commits == null)
+      commits = "true";
+    
     // "Server" tab
     if (tabName.equals("Server"))
     {
@@ -740,6 +755,30 @@ public class SolrConnector extends org.a
         values.add(value);
       }
     }
+    
+    // "Commits" tab
+    if (tabName.equals("Commits"))
+    {
+      out.print(
+"<table class=\"displaytable\">\n"+
+"  <tr>\n"+
+"    <td class=\"description\"><nobr>Commit at end of every job:</nobr></td>\n"+
+"    <td class=\"value\">\n"+
+"      <input name=\"commits_present\" type=\"hidden\" value=\"true\"/>\n"+
+"      <input name=\"commits\" type=\"checkbox\" value=\"true\""+(commits.equals("true")?"
checked=\"yes\"":"")+"/>\n"+
+"    </td>\n"+
+"  </tr>\n"+
+"</table>\n"
+      );
+    }
+    else
+    {
+      out.print(
+"<input type=\"hidden\" name=\"commits_present\" value=\"true\"/>\n"+
+"<input name=\"commits\" type=\"hidden\" value=\""+commits+"\"/>\n"
+      );
+    }
+    
     // "Arguments" tab
     if (tabName.equals("Arguments"))
     {
@@ -911,6 +950,15 @@ public class SolrConnector extends org.a
     if (password != null)
       parameters.setObfuscatedParameter(org.apache.acf.agents.output.solr.SolrConfig.PARAM_PASSWORD,password);
     
+    String commitsPresent = variableContext.getParameter("commits_present");
+    if (commitsPresent != null)
+    {
+      String commits = variableContext.getParameter("commits");
+      if (commits == null)
+        commits = "false";
+      parameters.setParameter(org.apache.acf.agents.output.solr.SolrConfig.PARAM_COMMITS,commits);
+    }
+    
     String x = variableContext.getParameter("argument_count");
     if (x != null && x.length() > 0)
     {



Mime
View raw message