lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1565184 [3/3] - in /lucene/dev/branches/lucene5376: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/codecs/lucene45/ lucene/core/src/java/org/apache/lucene/search/ lucene/core/src/java/org/apache/lucene/store/ lucene/core/sr...
Date Thu, 06 Feb 2014 11:38:32 GMT
Modified: lucene/dev/branches/lucene5376/solr/core/src/test/org/apache/solr/handler/admin/InfoHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/solr/core/src/test/org/apache/solr/handler/admin/InfoHandlerTest.java?rev=1565184&r1=1565183&r2=1565184&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/solr/core/src/test/org/apache/solr/handler/admin/InfoHandlerTest.java
(original)
+++ lucene/dev/branches/lucene5376/solr/core/src/test/org/apache/solr/handler/admin/InfoHandlerTest.java
Thu Feb  6 11:38:30 2014
@@ -17,9 +17,9 @@
 
 package org.apache.solr.handler.admin;
 
+import java.io.IOException;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrException;
-import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
@@ -68,6 +68,98 @@ public class InfoHandlerTest extends Sol
     
   }
 
+  @Test
+  public void testOverriddenHandlers() throws Exception {
+    final CoreContainer cores = h.getCoreContainer();
+    final InfoHandler infoHandler = new InfoHandler(cores);
+    infoHandler.init(null);
+
+    CountPropertiesRequestHandler propHandler = new CountPropertiesRequestHandler();
+    CountThreadDumpHandler threadHandler = new CountThreadDumpHandler();
+    CountLoggingHandler loggingHandler = new CountLoggingHandler(cores);
+    CountSystemInfoHandler systemInfoHandler = new CountSystemInfoHandler(cores);
+
+    // set the request handlers
+    infoHandler.setPropertiesHandler(propHandler);
+    infoHandler.setThreadDumpHandler(threadHandler);
+    infoHandler.setLoggingHandler(loggingHandler);
+    infoHandler.setSystemInfoHandler(systemInfoHandler);
+
+    // verify that the sets are reflected in the gets
+    assertEquals(propHandler, infoHandler.getPropertiesHandler());
+    assertEquals(threadHandler, infoHandler.getThreadDumpHandler());
+    assertEquals(loggingHandler, infoHandler.getLoggingHandler());
+    assertEquals(systemInfoHandler, infoHandler.getSystemInfoHandler());
+
+    // call each handler and verify it was actually called
+    handleRequest(infoHandler, "properties");
+    handleRequest(infoHandler, "threads");
+    handleRequest(infoHandler, "logging");
+    handleRequest(infoHandler, "system");
+
+    assertEquals(1, propHandler.getRequestCount());
+    assertEquals(1, threadHandler.getRequestCount());
+    assertEquals(1, loggingHandler.getRequestCount());
+    assertEquals(1, systemInfoHandler.getRequestCount());
+  }
+
+  // derived request handlers that count the number of request body counts made
+  public static class CountPropertiesRequestHandler extends PropertiesRequestHandler {
+    private int requestCount = 0;
+
+    @Override
+    public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp)
+    throws IOException {
+      ++requestCount;
+      super.handleRequestBody(req, rsp);
+    }
+
+    public int getRequestCount() { return requestCount; }
+  }
+
+  public static class CountThreadDumpHandler extends ThreadDumpHandler {
+    private int requestCount = 0;
+
+    @Override
+    public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp)
+    throws IOException {
+      ++requestCount;
+      super.handleRequestBody(req, rsp);
+    }
+
+    public int getRequestCount() { return requestCount; }
+  }
+
+  public static class CountLoggingHandler extends LoggingHandler {
+    private int requestCount = 0;
+
+    CountLoggingHandler(CoreContainer cores) { super(cores); }
+
+    @Override
+    public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp)
+    throws Exception {
+      ++requestCount;
+      super.handleRequestBody(req, rsp);
+    }
+
+    public int getRequestCount() { return requestCount; }
+  }
+
+  public static class CountSystemInfoHandler extends SystemInfoHandler {
+    private int requestCount = 0;
+
+    CountSystemInfoHandler(CoreContainer cores) { super(cores); }
+
+    @Override
+    public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp)
+    throws Exception {
+      ++requestCount;
+      super.handleRequestBody(req, rsp);
+    }
+
+    public int getRequestCount() { return requestCount; }
+  }
+
   private SolrQueryResponse handleRequest(InfoHandler infoHandler, String path)
       throws Exception {
     SolrQueryResponse rsp = new SolrQueryResponse();

Modified: lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/client/solrj/request/RequestWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/client/solrj/request/RequestWriter.java?rev=1565184&r1=1565183&r2=1565184&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/client/solrj/request/RequestWriter.java
(original)
+++ lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/client/solrj/request/RequestWriter.java
Thu Feb  6 11:38:30 2014
@@ -69,7 +69,7 @@ public class RequestWriter {
   public void write(SolrRequest request, OutputStream os) throws IOException {
     if (request instanceof UpdateRequest) {
       UpdateRequest updateRequest = (UpdateRequest) request;
-      OutputStreamWriter writer = new OutputStreamWriter(os, UTF_8);
+      BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, UTF_8));
       updateRequest.writeXML(writer);
       writer.flush();
     }

Modified: lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/client/solrj/response/QueryResponse.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/client/solrj/response/QueryResponse.java?rev=1565184&r1=1565183&r2=1565184&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/client/solrj/response/QueryResponse.java
(original)
+++ lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/client/solrj/response/QueryResponse.java
Thu Feb  6 11:38:30 2014
@@ -223,7 +223,13 @@ public class QueryResponse extends SolrR
           _groupResponse.add(groupedCommand);
         } else if (queryCommand != null) {
           Integer iMatches = (Integer) oMatches;
-          GroupCommand groupCommand = new GroupCommand(fieldName, iMatches);
+          GroupCommand groupCommand;
+          if (oNGroups != null) {
+            Integer iNGroups = (Integer) oNGroups;
+            groupCommand = new GroupCommand(fieldName, iMatches, iNGroups);
+          } else {
+            groupCommand = new GroupCommand(fieldName, iMatches);
+          }
           SolrDocumentList docList = (SolrDocumentList) queryCommand;
           groupCommand.add(new Group(fieldName, docList));
           _groupResponse.add(groupCommand);

Modified: lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java?rev=1565184&r1=1565183&r2=1565184&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java
(original)
+++ lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java
Thu Feb  6 11:38:30 2014
@@ -229,7 +229,7 @@ public class ConnectionManager implement
         wait(500);
       } catch (InterruptedException e) {
         Thread.currentThread().interrupt();
-        throw new RuntimeException(e);
+        break;
       }
       left = expire - System.currentTimeMillis();
     }

Modified: lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java?rev=1565184&r1=1565183&r2=1565184&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
(original)
+++ lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
Thu Feb  6 11:38:30 2014
@@ -24,6 +24,7 @@ import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.List;
+import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicLong;
 
 import javax.xml.transform.OutputKeys;
@@ -132,7 +133,7 @@ public class SolrZkClient {
           Thread.currentThread().interrupt();
         }
       }
-      throw new RuntimeException(e);
+      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
     }
     
     try {
@@ -144,7 +145,7 @@ public class SolrZkClient {
       } catch (InterruptedException e1) {
         Thread.currentThread().interrupt();
       }
-      throw new RuntimeException(e);
+      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
     }
     numOpens.incrementAndGet();
   }

Modified: lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java?rev=1565184&r1=1565183&r2=1565184&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
(original)
+++ lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
Thu Feb  6 11:38:30 2014
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -68,6 +69,9 @@ public class ZkStateReader {
   public static final String LIVE_NODES_ZKNODE = "/live_nodes";
   public static final String ALIASES = "/aliases.json";
   public static final String CLUSTER_STATE = "/clusterstate.json";
+  public static final String CLUSTER_PROPS = "/clusterprops.json";
+
+
   public static final String ROLES = "/roles.json";
 
   public static final String RECOVERING = "recovering";
@@ -595,5 +599,18 @@ public class ZkStateReader {
 
     ZkStateReader.this.aliases = aliases;
   }
+  public Map getClusterProps(){
+    Map result = null;
+    try {
+      if(getZkClient().exists(ZkStateReader.CLUSTER_PROPS,true)){
+        result = (Map) ZkStateReader.fromJSON(getZkClient().getData(ZkStateReader.CLUSTER_PROPS,
null, new Stat(), true)) ;
+      } else {
+        result= new LinkedHashMap();
+      }
+      return result;
+    } catch (Exception e) {
+      throw new SolrException(ErrorCode.SERVER_ERROR,"Error reading cluster properties",e)
;
+    }
+  }
   
 }

Modified: lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/CollectionParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/CollectionParams.java?rev=1565184&r1=1565183&r2=1565184&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/CollectionParams.java
(original)
+++ lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/CollectionParams.java
Thu Feb  6 11:38:30 2014
@@ -28,7 +28,20 @@ public interface CollectionParams 
 
 
   public enum CollectionAction {
-    CREATE, DELETE, RELOAD, SYNCSHARD, CREATEALIAS, DELETEALIAS, SPLITSHARD, DELETESHARD,
CREATESHARD, DELETEREPLICA, MIGRATE, ADDROLE,REMOVEROLE ;
+    CREATE,
+    DELETE,
+    RELOAD,
+    SYNCSHARD,
+    CREATEALIAS,
+    DELETEALIAS,
+    SPLITSHARD,
+    DELETESHARD,
+    CREATESHARD,
+    DELETEREPLICA,
+    MIGRATE,
+    ADDROLE,
+    REMOVEROLE,
+    CLUSTERPROP;
     
     public static CollectionAction get( String p )
     {

Modified: lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java?rev=1565184&r1=1565183&r2=1565184&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java
(original)
+++ lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java
Thu Feb  6 11:38:30 2014
@@ -181,6 +181,9 @@ public interface CommonParams {
     }
   };
 
+  /** which parameters to log (if not supplied all parameters will be logged) **/
+  public static final String LOG_PARAMS_LIST = "logParamsList";
+
   public static final String EXCLUDE = "ex";
   public static final String TAG = "tag";
   public static final String TERMS = "terms";

Modified: lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/SimpleParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/SimpleParams.java?rev=1565184&r1=1565183&r2=1565184&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/SimpleParams.java
(original)
+++ lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/SimpleParams.java
Thu Feb  6 11:38:30 2014
@@ -26,4 +26,25 @@ public interface SimpleParams {
 
   /** Override the currently enabled/disabled query operators. */
   public static String QO = "q.operators";
+  
+  /** Enables {@code AND} operator (+) */
+  public static final String AND_OPERATOR         = "AND";
+  /** Enables {@code NOT} operator (-) */
+  public static final String NOT_OPERATOR         = "NOT";
+  /** Enables {@code OR} operator (|) */
+  public static final String OR_OPERATOR          = "OR";
+  /** Enables {@code PREFIX} operator (*) */
+  public static final String PREFIX_OPERATOR      = "PREFIX";
+  /** Enables {@code PHRASE} operator (") */
+  public static final String PHRASE_OPERATOR      = "PHRASE";
+  /** Enables {@code PRECEDENCE} operators: {@code (} and {@code )} */
+  public static final String PRECEDENCE_OPERATORS = "PRECEDENCE";
+  /** Enables {@code ESCAPE} operator (\) */
+  public static final String ESCAPE_OPERATOR      = "ESCAPE";
+  /** Enables {@code WHITESPACE} operators: ' ' '\n' '\r' '\t' */
+  public static final String WHITESPACE_OPERATOR  = "WHITESPACE";
+  /** Enables {@code FUZZY} operator (~) */
+  public static final String FUZZY_OPERATOR       = "FUZZY";
+  /** Enables {@code NEAR} operator (~) */
+  public static final String NEAR_OPERATOR        = "NEAR";
 }

Modified: lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/SolrParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/SolrParams.java?rev=1565184&r1=1565183&r2=1565184&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/SolrParams.java
(original)
+++ lucene/dev/branches/lucene5376/solr/solrj/src/java/org/apache/solr/common/params/SolrParams.java
Thu Feb  6 11:38:30 2014
@@ -20,6 +20,7 @@ package org.apache.solr.common.params;
 import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.solr.common.SolrException;
@@ -298,6 +299,21 @@ public abstract class SolrParams impleme
     return new MapSolrParams(map);
   }
   
+  /** Create filtered SolrParams. */
+  public SolrParams toFilteredSolrParams(List<String> names) {
+    NamedList<String> nl = new NamedList<String>();
+    for (Iterator<String> it = getParameterNamesIterator(); it.hasNext();) {
+      final String name = it.next();
+      if (names.contains(name)) {
+        final String[] values = getParams(name);
+        for (String value : values) {
+          nl.add(name, value);
+        }
+      }
+    }
+    return toSolrParams(nl);
+  }
+  
   /** Convert this to a NamedList */
   public NamedList<Object> toNamedList() {
     final SimpleOrderedMap<Object> result = new SimpleOrderedMap<Object>();
@@ -315,11 +331,3 @@ public abstract class SolrParams impleme
     return result;
   }
 }
-
-
-
-
-
-
-
-

Modified: lucene/dev/branches/lucene5376/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.java?rev=1565184&r1=1565183&r2=1565184&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.java
(original)
+++ lucene/dev/branches/lucene5376/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.java
Thu Feb  6 11:38:30 2014
@@ -20,6 +20,7 @@ package org.apache.solr.client.solrj.res
 import junit.framework.Assert;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.solr.client.solrj.impl.XMLResponseParser;
+import org.apache.solr.common.SolrDocumentList;
 import org.apache.solr.common.util.DateUtil;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrResourceLoader;
@@ -219,4 +220,45 @@ public class QueryResponseTest extends L
     assertEquals(57074, queryCommandGroups.get(0).getResult().getNumFound());
   }
 
+  @Test
+  public void testSimpleGroupResponse() throws Exception {
+    XMLResponseParser parser = new XMLResponseParser();
+    InputStream is = new SolrResourceLoader(null, null).openResource("solrj/sampleSimpleGroupResponse.xml");
+    assertNotNull(is);
+    Reader in = new InputStreamReader(is, "UTF-8");
+    NamedList<Object> response = parser.processResponse(in);
+    in.close();
+
+    QueryResponse qr = new QueryResponse(response, null);
+    assertNotNull(qr);
+    GroupResponse groupResponse = qr.getGroupResponse();
+    assertNotNull(groupResponse);
+    List<GroupCommand> commands = groupResponse.getValues();
+    assertNotNull(commands);
+    assertEquals(1, commands.size());
+
+    GroupCommand fieldCommand = commands.get(0);
+    assertEquals("acco_id", fieldCommand.getName());
+    assertEquals(30000000, fieldCommand.getMatches());
+    assertEquals(5687, fieldCommand.getNGroups().intValue());
+    List<Group> fieldCommandGroups = fieldCommand.getValues();
+    assertEquals(1, fieldCommandGroups.size());
+    
+    assertEquals("acco_id", fieldCommandGroups.get(0).getGroupValue());
+    SolrDocumentList documents = fieldCommandGroups.get(0).getResult();
+    assertNotNull(documents);
+    
+    assertEquals(10, documents.size());
+    assertEquals("116_AR", documents.get(0).getFieldValue("acco_id"));
+    assertEquals("116_HI", documents.get(1).getFieldValue("acco_id"));
+    assertEquals("953_AR", documents.get(2).getFieldValue("acco_id"));
+    assertEquals("953_HI", documents.get(3).getFieldValue("acco_id"));
+    assertEquals("954_AR", documents.get(4).getFieldValue("acco_id"));
+    assertEquals("954_HI", documents.get(5).getFieldValue("acco_id"));
+    assertEquals("546_AR", documents.get(6).getFieldValue("acco_id"));
+    assertEquals("546_HI", documents.get(7).getFieldValue("acco_id"));
+    assertEquals("708_AR", documents.get(8).getFieldValue("acco_id"));
+    assertEquals("708_HI", documents.get(9).getFieldValue("acco_id"));
+  }
+
 }



Mime
View raw message