You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by io...@apache.org on 2014/05/01 14:21:32 UTC

svn commit: r1591634 - in /manifoldcf/integration/solr-3.x/trunk: ./ src/main/java/org/apache/solr/mcf/ src/test/java/org/apache/solr/mcf/

Author: iorixxx
Date: Thu May  1 12:21:31 2014
New Revision: 1591634

URL: http://svn.apache.org/r1591634
Log:
CONNECTORS-934 : Check if log level is enabled before constructing log message.

Modified:
    manifoldcf/integration/solr-3.x/trunk/CHANGES.txt
    manifoldcf/integration/solr-3.x/trunk/src/main/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
    manifoldcf/integration/solr-3.x/trunk/src/main/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java
    manifoldcf/integration/solr-3.x/trunk/src/test/java/org/apache/solr/mcf/ManifoldCFSCLoadTest.java

Modified: manifoldcf/integration/solr-3.x/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/integration/solr-3.x/trunk/CHANGES.txt?rev=1591634&r1=1591633&r2=1591634&view=diff
==============================================================================
--- manifoldcf/integration/solr-3.x/trunk/CHANGES.txt (original)
+++ manifoldcf/integration/solr-3.x/trunk/CHANGES.txt Thu May  1 12:21:31 2014
@@ -6,6 +6,9 @@ $Id$
 CONNECTORS-914: Go to a Maven build system.
 (Ahmet Arslan)
 
+CONNECTORS-934 : Check if log level is enabled before constructing log message.
+(Ahmet Arslan)
+
 ======================= Release 2.0 =====================
 
 CONNECTORS-886: Provide [allow|deny]_token_parent fields.

Modified: manifoldcf/integration/solr-3.x/trunk/src/main/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
URL: http://svn.apache.org/viewvc/manifoldcf/integration/solr-3.x/trunk/src/main/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java?rev=1591634&r1=1591633&r2=1591634&view=diff
==============================================================================
--- manifoldcf/integration/solr-3.x/trunk/src/main/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java (original)
+++ manifoldcf/integration/solr-3.x/trunk/src/main/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java Thu May  1 12:21:31 2014
@@ -41,8 +41,6 @@ import java.net.*;
 */
 public class ManifoldCFQParserPlugin extends QParserPlugin
 {
-  /** The component name */
-  static final public String COMPONENT_NAME = "mcf";
   /** The parameter that is supposed to contain the authenticated user name, possibly including the AD domain */
   static final public String AUTHENTICATED_USER_NAME = "AuthenticatedUserName";
   /** The parameter that is supposed to contain the MCF authorization domain, if any */
@@ -59,10 +57,7 @@ public class ManifoldCFQParserPlugin ext
   
   /** Special token for null security fields */
   static final public String NOSECURITY_TOKEN = "__nosecurity__";
-  
-  /** The queries that we will not attempt to interfere with */
-  static final private String[] globalAllowed = { "solrpingquery" };
-  
+
   /** A logger we can use */
   private static final Logger LOG = LoggerFactory.getLogger(ManifoldCFQParserPlugin.class);
 
@@ -197,26 +192,25 @@ public class ManifoldCFQParserPlugin ext
         {
           // Only return 'public' documents (those with no security tokens at all)
           LOG.info("Group tokens received from caller");
-          for (String passedToken : passedTokens)
-          {
-            userAccessTokens.add(passedToken);
-          }
+          userAccessTokens.addAll(Arrays.asList(passedTokens));
         }
       }
       else
       {
-        StringBuilder sb = new StringBuilder("[");
-        boolean first = true;
-        for (String domain : domainMap.keySet())
-        {
-          if (!first)
-            sb.append(",");
-          else
-            first = false;
-          sb.append(domain).append(":").append(domainMap.get(domain));
+        if(LOG.isInfoEnabled()){
+          StringBuilder sb = new StringBuilder("[");
+          boolean first = true;
+          for (String domain : domainMap.keySet())
+          {
+            if (!first)
+              sb.append(",");
+            else
+              first = false;
+            sb.append(domain).append(":").append(domainMap.get(domain));
+          }
+          sb.append("]");
+          LOG.info("Trying to match docs for user '"+sb.toString()+"'");
         }
-        sb.append("]");
-        LOG.info("Trying to match docs for user '"+sb.toString()+"'");
         // Valid authenticated user name.  Look up access tokens for the user.
         // Check the configuration arguments for validity
         if (authorityBaseURL == null)

Modified: manifoldcf/integration/solr-3.x/trunk/src/main/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java
URL: http://svn.apache.org/viewvc/manifoldcf/integration/solr-3.x/trunk/src/main/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java?rev=1591634&r1=1591633&r2=1591634&view=diff
==============================================================================
--- manifoldcf/integration/solr-3.x/trunk/src/main/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java (original)
+++ manifoldcf/integration/solr-3.x/trunk/src/main/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java Thu May  1 12:21:31 2014
@@ -198,26 +198,25 @@ public class ManifoldCFSearchComponent e
       {
         // Only return 'public' documents (those with no security tokens at all)
         LOG.info("Group tokens received from caller");
-        for (String passedToken : passedTokens)
-        {
-          userAccessTokens.add(passedToken);
-        }
+        userAccessTokens.addAll(Arrays.asList(passedTokens));
       }
     }
     else
     {
-      StringBuilder sb = new StringBuilder("[");
-      boolean first = true;
-      for (String domain : domainMap.keySet())
-      {
-        if (!first)
-          sb.append(",");
-        else
-          first = false;
-        sb.append(domain).append(":").append(domainMap.get(domain));
+      if(LOG.isInfoEnabled()){
+        StringBuilder sb = new StringBuilder("[");
+        boolean first = true;
+        for (String domain : domainMap.keySet())
+        {
+          if (!first)
+            sb.append(",");
+          else
+            first = false;
+          sb.append(domain).append(":").append(domainMap.get(domain));
+        }
+        sb.append("]");
+        LOG.info("Trying to match docs for user '"+sb.toString()+"'");
       }
-      sb.append("]");
-      LOG.info("Trying to match docs for user '"+sb.toString()+"'");
       // Valid authenticated user name.  Look up access tokens for the user.
       // Check the configuration arguments for validity
       if (authorityBaseURL == null)

Modified: manifoldcf/integration/solr-3.x/trunk/src/test/java/org/apache/solr/mcf/ManifoldCFSCLoadTest.java
URL: http://svn.apache.org/viewvc/manifoldcf/integration/solr-3.x/trunk/src/test/java/org/apache/solr/mcf/ManifoldCFSCLoadTest.java?rev=1591634&r1=1591633&r2=1591634&view=diff
==============================================================================
--- manifoldcf/integration/solr-3.x/trunk/src/test/java/org/apache/solr/mcf/ManifoldCFSCLoadTest.java (original)
+++ manifoldcf/integration/solr-3.x/trunk/src/test/java/org/apache/solr/mcf/ManifoldCFSCLoadTest.java Thu May  1 12:21:31 2014
@@ -18,6 +18,7 @@
 package org.apache.solr.mcf;
 
 import java.io.IOException;
+import java.util.concurrent.TimeUnit;
 
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
@@ -78,7 +79,7 @@ public class ManifoldCFSCLoadTest extend
   @Test
   public void testTimeQueries() throws Exception {
     int i = 0;
-    long startTime = System.currentTimeMillis();
+    long startTime = System.nanoTime();
     while (i < 1000)
     {
       assertQ(req("qt", "/mcf", "q", "*:*", "fl", "id", "AuthenticatedUserName", "user1"),
@@ -92,7 +93,7 @@ public class ManifoldCFSCLoadTest extend
       
       i++;
     }
-    System.out.println("Query time = "+new Long(System.currentTimeMillis()-startTime));
+    System.out.println("Query time (milliseconds) = " +  TimeUnit.NANOSECONDS.toMillis(System.nanoTime()-startTime));
   }
 
   static class MockMCFAuthorityService {