lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1534003 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/contrib/ solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/ solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/ solr/core/ solr/cor...
Date Sun, 20 Oct 2013 23:00:50 GMT
Author: markrmiller
Date: Sun Oct 20 23:00:49 2013
New Revision: 1534003

URL: http://svn.apache.org/r1534003
Log:
SOLR-5371: Solr should consistently call SolrServer#shutdown

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/contrib/   (props changed)
    lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/SolrEntityProcessor.java
    lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSolrEntityProcessorEndToEnd.java
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.java
    lucene/dev/branches/branch_4x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExceptionTest.java
    lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java
    lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java
    lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java

Modified: lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/SolrEntityProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/SolrEntityProcessor.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/SolrEntityProcessor.java
(original)
+++ lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/SolrEntityProcessor.java
Sun Oct 20 23:00:49 2013
@@ -94,13 +94,16 @@ public class SolrEntityProcessor extends
             "SolrEntityProcessor: parameter 'url' is required");
       }
 
+      // TODO: we should close this client!
       HttpClient client = getHttpClient();
       URL url = new URL(serverPath);
       // (wt="javabin|xml") default is javabin
       if ("xml".equals(context.getResolvedEntityAttribute(CommonParams.WT))) {
+        // TODO: it doesn't matter for this impl when passing a client currently, but we
should shutdown this!
         solrServer = new HttpSolrServer(url.toExternalForm(), client, new XMLResponseParser());
         LOG.info("using XMLResponseParser");
       } else {
+        // TODO: it doesn't matter for this impl when passing a client currently, but we
should shutdown this!
         solrServer = new HttpSolrServer(url.toExternalForm(), client);
         LOG.info("using BinaryResponseParser");
       }

Modified: lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSolrEntityProcessorEndToEnd.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSolrEntityProcessorEndToEnd.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSolrEntityProcessorEndToEnd.java
(original)
+++ lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSolrEntityProcessorEndToEnd.java
Sun Oct 20 23:00:49 2013
@@ -282,10 +282,14 @@ public class TestSolrEntityProcessorEndT
     }
     
     HttpSolrServer solrServer = new HttpSolrServer(getSourceUrl());
-    solrServer.setConnectionTimeout(15000);
-    solrServer.setSoTimeout(30000);
-    solrServer.add(sidl);
-    solrServer.commit(true, true);
+    try {
+      solrServer.setConnectionTimeout(15000);
+      solrServer.setSoTimeout(30000);
+      solrServer.add(sidl);
+      solrServer.commit(true, true);
+    } finally {
+      solrServer.shutdown();
+    }
   }
   
   private static class SolrInstance {

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
Sun Oct 20 23:00:49 2013
@@ -168,35 +168,41 @@ public class RecoveryStrategy extends Th
     
   }
 
-  private void commitOnLeader(String leaderUrl) throws SolrServerException, IOException {
+  private void commitOnLeader(String leaderUrl) throws SolrServerException,
+      IOException {
     HttpSolrServer server = new HttpSolrServer(leaderUrl);
-    server.setConnectionTimeout(30000);
-    server.setSoTimeout(60000);
-    UpdateRequest ureq = new UpdateRequest();
-    ureq.setParams(new ModifiableSolrParams());
-    ureq.getParams().set(DistributedUpdateProcessor.COMMIT_END_POINT, true);
-    ureq.getParams().set(UpdateParams.OPEN_SEARCHER, false);
-    ureq.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, true).process(
-        server);
-    server.shutdown();
+    try {
+      server.setConnectionTimeout(30000);
+      server.setSoTimeout(60000);
+      UpdateRequest ureq = new UpdateRequest();
+      ureq.setParams(new ModifiableSolrParams());
+      ureq.getParams().set(DistributedUpdateProcessor.COMMIT_END_POINT, true);
+      ureq.getParams().set(UpdateParams.OPEN_SEARCHER, false);
+      ureq.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, true).process(
+          server);
+    } finally {
+      server.shutdown();
+    }
   }
 
-  private void sendPrepRecoveryCmd(String leaderBaseUrl,
-      String leaderCoreName) throws SolrServerException,
-      IOException {
+  private void sendPrepRecoveryCmd(String leaderBaseUrl, String leaderCoreName)
+      throws SolrServerException, IOException {
     HttpSolrServer server = new HttpSolrServer(leaderBaseUrl);
-    server.setConnectionTimeout(45000);
-    server.setSoTimeout(120000);
-    WaitForState prepCmd = new WaitForState();
-    prepCmd.setCoreName(leaderCoreName);
-    prepCmd.setNodeName(zkController.getNodeName());
-    prepCmd.setCoreNodeName(coreZkNodeName);
-    prepCmd.setState(ZkStateReader.RECOVERING);
-    prepCmd.setCheckLive(true);
-    prepCmd.setOnlyIfLeader(true);
-    
-    server.request(prepCmd);
-    server.shutdown();
+    try {
+      server.setConnectionTimeout(45000);
+      server.setSoTimeout(120000);
+      WaitForState prepCmd = new WaitForState();
+      prepCmd.setCoreName(leaderCoreName);
+      prepCmd.setNodeName(zkController.getNodeName());
+      prepCmd.setCoreNodeName(coreZkNodeName);
+      prepCmd.setState(ZkStateReader.RECOVERING);
+      prepCmd.setCheckLive(true);
+      prepCmd.setOnlyIfLeader(true);
+      
+      server.request(prepCmd);
+    } finally {
+      server.shutdown();
+    }
   }
 
   @Override

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java
Sun Oct 20 23:00:49 2013
@@ -285,12 +285,14 @@ public class SyncStrategy {
         recoverRequestCmd.setCoreName(coreName);
         
         HttpSolrServer server = new HttpSolrServer(baseUrl, client);
-        server.setConnectionTimeout(15000);
-        server.setSoTimeout(60000);
         try {
+          server.setConnectionTimeout(15000);
+          server.setSoTimeout(60000);
           server.request(recoverRequestCmd);
         } catch (Throwable t) {
           SolrException.log(log, ZkCoreNodeProps.getCoreUrl(leaderProps) + ": Could not tell
a replica to recover", t);
+        } finally {
+          server.shutdown();
         }
       }
     };

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/SnapPuller.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
Sun Oct 20 23:00:49 2013
@@ -75,12 +75,15 @@ import org.apache.lucene.index.IndexWrit
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.store.IndexOutput;
+
 import static org.apache.lucene.util.IOUtils.CHARSET_UTF_8;
+
 import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.impl.HttpClientUtil;
 import org.apache.solr.client.solrj.impl.HttpSolrServer;
 import org.apache.solr.client.solrj.request.QueryRequest;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.params.SolrParams;
@@ -247,13 +250,18 @@ public class SnapPuller {
     params.set(CommonParams.QT, "/replication");
     QueryRequest req = new QueryRequest(params);
     HttpSolrServer server = new HttpSolrServer(masterUrl, myHttpClient); //XXX modify to
use shardhandler
-    server.setSoTimeout(60000);
-    server.setConnectionTimeout(15000);
+    NamedList rsp;
     try {
-      return server.request(req);
+      server.setSoTimeout(60000);
+      server.setConnectionTimeout(15000);
+      
+      rsp = server.request(req);
     } catch (SolrServerException e) {
-      throw new IOException(e);
+      throw new SolrException(ErrorCode.SERVER_ERROR, e.getMessage());
+    } finally {
+      server.shutdown();
     }
+    return rsp;
   }
 
   /**
@@ -267,10 +275,9 @@ public class SnapPuller {
     params.set(CommonParams.QT, "/replication");
     QueryRequest req = new QueryRequest(params);
     HttpSolrServer server = new HttpSolrServer(masterUrl, myHttpClient);  //XXX modify to
use shardhandler
-    server.setSoTimeout(60000);
-    server.setConnectionTimeout(15000);
-
     try {
+      server.setSoTimeout(60000);
+      server.setConnectionTimeout(15000);
       NamedList response = server.request(req);
 
       List<Map<String, Object>> files = (List<Map<String,Object>>)
response.get(CMD_GET_FILE_LIST);
@@ -287,6 +294,8 @@ public class SnapPuller {
 
     } catch (SolrServerException e) {
       throw new IOException(e);
+    } finally {
+      server.shutdown();
     }
   }
 
@@ -1273,9 +1282,7 @@ public class SnapPuller {
      * Open a new stream using HttpClient
      */
     FastInputStream getStream() throws IOException {
-      HttpSolrServer s = new HttpSolrServer(masterUrl, myHttpClient, null);  //XXX use shardhandler
-      s.setSoTimeout(60000);
-      s.setConnectionTimeout(15000);
+
       ModifiableSolrParams params = new ModifiableSolrParams();
 
 //    //the method is command=filecontent
@@ -1307,7 +1314,11 @@ public class SnapPuller {
 
       NamedList response;
       InputStream is = null;
+      
+      HttpSolrServer s = new HttpSolrServer(masterUrl, myHttpClient, null);  //XXX use shardhandler
       try {
+        s.setSoTimeout(60000);
+        s.setConnectionTimeout(15000);
         QueryRequest req = new QueryRequest(params);
         response = s.request(req);
         is = (InputStream) response.get("stream");
@@ -1319,6 +1330,8 @@ public class SnapPuller {
         //close stream on error
         IOUtils.closeQuietly(is);
         throw new IOException("Could not download file '" + fileName + "'", t);
+      } finally {
+        s.shutdown();
       }
     }
   }
@@ -1534,9 +1547,7 @@ public class SnapPuller {
      * Open a new stream using HttpClient
      */
     FastInputStream getStream() throws IOException {
-      HttpSolrServer s = new HttpSolrServer(masterUrl, myHttpClient, null);  //XXX use shardhandler
-      s.setSoTimeout(60000);
-      s.setConnectionTimeout(15000);
+
       ModifiableSolrParams params = new ModifiableSolrParams();
 
 //    //the method is command=filecontent
@@ -1568,7 +1579,10 @@ public class SnapPuller {
 
       NamedList response;
       InputStream is = null;
+      HttpSolrServer s = new HttpSolrServer(masterUrl, myHttpClient, null);  //XXX use shardhandler
       try {
+        s.setSoTimeout(60000);
+        s.setConnectionTimeout(15000);
         QueryRequest req = new QueryRequest(params);
         response = s.request(req);
         is = (InputStream) response.get("stream");
@@ -1580,6 +1594,8 @@ public class SnapPuller {
         //close stream on error
         IOUtils.closeQuietly(is);
         throw new IOException("Could not download file '" + fileName + "'", t);
+      } finally {
+        s.shutdown();
       }
     }
   }
@@ -1590,10 +1606,16 @@ public class SnapPuller {
     params.set("slave", false);
     params.set(CommonParams.QT, "/replication");
     HttpSolrServer server = new HttpSolrServer(masterUrl, myHttpClient); //XXX use shardhandler
-    server.setSoTimeout(60000);
-    server.setConnectionTimeout(15000);
-    QueryRequest request = new QueryRequest(params);
-    return server.request(request);
+    NamedList rsp;
+    try {
+      server.setSoTimeout(60000);
+      server.setConnectionTimeout(15000);
+      QueryRequest request = new QueryRequest(params);
+      rsp = server.request(request);
+    } finally {
+      server.shutdown();
+    }
+    return rsp;
   }
 
   static Integer readInterval(String interval) {

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
Sun Oct 20 23:00:49 2013
@@ -232,13 +232,17 @@ public class CollectionsHandler extends 
     ZkCoreNodeProps nodeProps = new ZkCoreNodeProps(leaderProps);
     
     HttpSolrServer server = new HttpSolrServer(nodeProps.getBaseUrl());
-    server.setConnectionTimeout(15000);
-    server.setSoTimeout(60000);
-    RequestSyncShard reqSyncShard = new CoreAdminRequest.RequestSyncShard();
-    reqSyncShard.setCollection(collection);
-    reqSyncShard.setShard(shard);
-    reqSyncShard.setCoreName(nodeProps.getCoreName());
-    server.request(reqSyncShard);
+    try {
+      server.setConnectionTimeout(15000);
+      server.setSoTimeout(60000);
+      RequestSyncShard reqSyncShard = new CoreAdminRequest.RequestSyncShard();
+      reqSyncShard.setCollection(collection);
+      reqSyncShard.setShard(shard);
+      reqSyncShard.setCoreName(nodeProps.getCoreName());
+      server.request(reqSyncShard);
+    } finally {
+      server.shutdown();
+    }
   }
   
   private void handleCreateAliasAction(SolrQueryRequest req,

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
Sun Oct 20 23:00:49 2013
@@ -152,7 +152,11 @@ public class HttpShardHandler extends Sh
             String url = urls.get(0);
             srsp.setShardAddress(url);
             SolrServer server = new HttpSolrServer(url, httpClient);
-            ssr.nl = server.request(req);
+            try {
+              ssr.nl = server.request(req);
+            } finally {
+              server.shutdown();
+            }
           } else {
             LBHttpSolrServer.Rsp rsp = httpShardHandlerFactory.makeLoadBalancedRequest(req,
urls);
             ssr.nl = rsp.getResponse();

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
Sun Oct 20 23:00:49 2013
@@ -56,10 +56,12 @@ public class SolrCmdDistributor {
   }
   
   public void finish() {
-    servers.blockUntilFinished();
-    doRetriesIfNeeded();
-  
-    servers.shutdown();
+    try {
+      servers.blockUntilFinished();
+      doRetriesIfNeeded();
+    } finally {
+      servers.shutdown();
+    }
   }
 
   private void doRetriesIfNeeded() {
@@ -189,12 +191,14 @@ public class SolrCmdDistributor {
       
       HttpSolrServer server = new HttpSolrServer(req.node.getUrl(),
           servers.getHttpClient());
-
       try {
         server.request(req.uReq);
       } catch (Exception e) {
         throw new SolrException(ErrorCode.SERVER_ERROR, "Failed synchronous update on shard
" + req.node + " update: " + req.uReq , e);
+      } finally {
+        server.shutdown();
       }
+      
       return;
     }
     

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
Sun Oct 20 23:00:49 2013
@@ -553,16 +553,21 @@ public class DistributedUpdateProcessor 
         public void run() {
           log.info("try and ask " + recoveryUrl + " to recover");
           HttpSolrServer server = new HttpSolrServer(recoveryUrl);
-          server.setSoTimeout(60000);
-          server.setConnectionTimeout(15000);
-          
-          RequestRecovery recoverRequestCmd = new RequestRecovery();
-          recoverRequestCmd.setAction(CoreAdminAction.REQUESTRECOVERY);
-          recoverRequestCmd.setCoreName(error.req.node.getCoreName());
           try {
-            server.request(recoverRequestCmd);
-          } catch (Throwable t) {
-            SolrException.log(log, recoveryUrl + ": Could not tell a replica to recover",
t);
+            server.setSoTimeout(60000);
+            server.setConnectionTimeout(15000);
+            
+            RequestRecovery recoverRequestCmd = new RequestRecovery();
+            recoverRequestCmd.setAction(CoreAdminAction.REQUESTRECOVERY);
+            recoverRequestCmd.setCoreName(error.req.node.getCoreName());
+            try {
+              server.request(recoverRequestCmd);
+            } catch (Throwable t) {
+              SolrException.log(log, recoveryUrl
+                  + ": Could not tell a replica to recover", t);
+            }
+          } finally {
+            server.shutdown();
           }
         }
       };

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
Sun Oct 20 23:00:49 2013
@@ -923,7 +923,7 @@ public class BasicDistributedZkTest exte
     Callable call = new Callable() {
       @Override
       public Object call() {
-        HttpSolrServer server;
+        HttpSolrServer server = null;
         try {
           server = new HttpSolrServer(baseUrl);
           server.setConnectionTimeout(15000);
@@ -944,6 +944,10 @@ public class BasicDistributedZkTest exte
         } catch (Exception e) {
           e.printStackTrace();
           //fail
+        } finally {
+          if (server != null) {
+            server.shutdown();
+          }
         }
         return null;
       }
@@ -1052,7 +1056,7 @@ public class BasicDistributedZkTest exte
       Callable call = new Callable() {
         @Override
         public Object call() {
-          HttpSolrServer server;
+          HttpSolrServer server = null;
           try {
             server = new HttpSolrServer(baseUrl);
             server.setConnectionTimeout(15000);
@@ -1067,6 +1071,10 @@ public class BasicDistributedZkTest exte
           } catch (Exception e) {
             e.printStackTrace();
             //fails
+          } finally {
+            if (server != null) {
+              server.shutdown();
+            }
           }
           return null;
         }

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
Sun Oct 20 23:00:49 2013
@@ -865,9 +865,13 @@ public class CollectionsAPIDistributedZk
         while (shardIt.hasNext()) {
           Entry<String,Replica> shardEntry = shardIt.next();
           ZkCoreNodeProps coreProps = new ZkCoreNodeProps(shardEntry.getValue());
-          CoreAdminResponse mcr = CoreAdminRequest.getStatus(
-              coreProps.getCoreName(),
-              new HttpSolrServer(coreProps.getBaseUrl()));
+          HttpSolrServer server = new HttpSolrServer(coreProps.getBaseUrl());
+          CoreAdminResponse mcr;
+          try {
+            mcr = CoreAdminRequest.getStatus(coreProps.getCoreName(), server);
+          } finally {
+            server.shutdown();
+          }
           long before = mcr.getStartTime(coreProps.getCoreName()).getTime();
           urlToTime.put(coreProps.getCoreUrl(), before);
         }

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
Sun Oct 20 23:00:49 2013
@@ -310,16 +310,20 @@ public class FullSolrCloudDistribCmdsTes
   private void testIndexingWithSuss() throws Exception {
     ConcurrentUpdateSolrServer suss = new ConcurrentUpdateSolrServer(
         ((HttpSolrServer) clients.get(0)).getBaseURL(), 3, 1);
-    suss.setConnectionTimeout(15000);
-    suss.setSoTimeout(30000);
-    for (int i=100; i<150; i++) {
-      index_specific(suss, id, i);      
+    try {
+      suss.setConnectionTimeout(15000);
+      suss.setSoTimeout(30000);
+      for (int i = 100; i < 150; i++) {
+        index_specific(suss, id, i);
+      }
+      suss.blockUntilFinished();
+      
+      commit();
+      
+      checkShardConsistency();
+    } finally {
+      suss.shutdown();
     }
-    suss.blockUntilFinished();
-    
-    commit();
-    
-    checkShardConsistency();
   }
   
   private void testOptimisticUpdate(QueryResponse results) throws Exception {

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java
Sun Oct 20 23:00:49 2013
@@ -408,12 +408,23 @@ public class ShardSplitTest extends Basi
 
     ZkCoreNodeProps shard1_0 = getLeaderUrlFromZk(AbstractDistribZkTestBase.DEFAULT_COLLECTION,
SHARD1_0);
     HttpSolrServer shard1_0Server = new HttpSolrServer(shard1_0.getCoreUrl());
-    QueryResponse response = shard1_0Server.query(query);
+    QueryResponse response;
+    try {
+      response = shard1_0Server.query(query);
+    } finally {
+      shard1_0Server.shutdown();
+    }
     long shard10Count = response.getResults().getNumFound();
 
-    ZkCoreNodeProps shard1_1 = getLeaderUrlFromZk(AbstractDistribZkTestBase.DEFAULT_COLLECTION,
SHARD1_1);
+    ZkCoreNodeProps shard1_1 = getLeaderUrlFromZk(
+        AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1_1);
     HttpSolrServer shard1_1Server = new HttpSolrServer(shard1_1.getCoreUrl());
-    QueryResponse response2 = shard1_1Server.query(query);
+    QueryResponse response2;
+    try {
+      response2 = shard1_1Server.query(query);
+    } finally {
+      shard1_1Server.shutdown();
+    }
     long shard11Count = response2.getResults().getNumFound();
 
     logDebugHelp(docCounts, response, shard10Count, response2, shard11Count);
@@ -433,7 +444,12 @@ public class ShardSplitTest extends Basi
     for (Replica replica : slice.getReplicas()) {
       String coreUrl = new ZkCoreNodeProps(replica).getCoreUrl();
       HttpSolrServer server = new HttpSolrServer(coreUrl);
-      QueryResponse response = server.query(query);
+      QueryResponse response;
+      try {
+        response = server.query(query);
+      } finally {
+        server.shutdown();
+      }
       numFound[c++] = response.getResults().getNumFound();
       log.info("Shard: " + shard + " Replica: {} has {} docs", coreUrl, String.valueOf(response.getResults().getNumFound()));
       assertTrue("Shard: " + shard + " Replica: " + coreUrl + " has 0 docs", response.getResults().getNumFound()
> 0);

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.java
Sun Oct 20 23:00:49 2013
@@ -115,26 +115,30 @@ public class StressHdfsTest extends Basi
     
     int i = 0;
     for (SolrServer client : clients) {
-      HttpSolrServer c = new HttpSolrServer(getBaseUrl(client) + "/delete_data_dir");
-      c.add(getDoc("id", i++));
-      if (random().nextBoolean()) c.add(getDoc("id", i++));
-      if (random().nextBoolean()) c.add(getDoc("id", i++));
-      if (random().nextBoolean()) {
-        c.commit();
-      } else {
-        c.commit(true, true, true);
+      HttpSolrServer c = new HttpSolrServer(getBaseUrl(client)
+          + "/delete_data_dir");
+      try {
+        c.add(getDoc("id", i++));
+        if (random().nextBoolean()) c.add(getDoc("id", i++));
+        if (random().nextBoolean()) c.add(getDoc("id", i++));
+        if (random().nextBoolean()) {
+          c.commit();
+        } else {
+          c.commit(true, true, true);
+        }
+        
+        c.query(new SolrQuery("id:" + i));
+        c.setSoTimeout(60000);
+        c.setConnectionTimeout(30000);
+        NamedList<Object> response = c.query(
+            new SolrQuery().setRequestHandler("/admin/system")).getResponse();
+        NamedList<Object> coreInfo = (NamedList<Object>) response.get("core");
+        String dataDir = (String) ((NamedList<Object>) coreInfo
+            .get("directory")).get("data");
+        dataDirs.add(dataDir);
+      } finally {
+        c.shutdown();
       }
-      
-      c.query(new SolrQuery("id:" + i));
-      c.setSoTimeout(60000);
-      c.setConnectionTimeout(30000);
-      NamedList<Object> response = c.query(
-          new SolrQuery().setRequestHandler("/admin/system")).getResponse();
-      NamedList<Object> coreInfo = (NamedList<Object>) response.get("core");
-      String dataDir = (String) ((NamedList<Object>) coreInfo.get("directory"))
-          .get("data");
-      dataDirs.add(dataDir);
-      c.shutdown();
     }
     
     if (random().nextBoolean()) {

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExceptionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExceptionTest.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExceptionTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExceptionTest.java
Sun Oct 20 23:00:49 2013
@@ -42,6 +42,7 @@ public class SolrExceptionTest extends L
       SolrServer client = new HttpSolrServer("http://[ff01::114]:11235/solr/", httpClient);
       SolrQuery query = new SolrQuery("test123");
       client.query(query);
+      client.shutdown();
     } catch (SolrServerException sse) {
       gotExpectedError = true;
       /***

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java
(original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java
Sun Oct 20 23:00:49 2013
@@ -38,6 +38,7 @@ import org.apache.solr.client.solrj.impl
 import org.apache.solr.client.solrj.impl.HttpSolrServer;
 import org.apache.solr.client.solrj.impl.LBHttpSolrServer;
 import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.client.solrj.response.SolrResponseBase;
 import org.apache.solr.client.solrj.response.UpdateResponse;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.params.ModifiableSolrParams;
@@ -107,9 +108,14 @@ public class TestLBHttpSolrServer extend
       docs.add(doc);
     }
     HttpSolrServer solrServer = new HttpSolrServer(solrInstance.getUrl(), httpClient);
-    UpdateResponse resp = solrServer.add(docs);
-    assertEquals(0, resp.getStatus());
-    resp = solrServer.commit();
+    SolrResponseBase resp;
+    try {
+      resp = solrServer.add(docs);
+      assertEquals(0, resp.getStatus());
+      resp = solrServer.commit();
+    } finally {
+      solrServer.shutdown();
+    }
     assertEquals(0, resp.getStatus());
   }
 

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java
Sun Oct 20 23:00:49 2013
@@ -479,6 +479,7 @@ public class BasicHttpSolrServerTest ext
       server.setDefaultMaxConnectionsPerHost(1);
       fail("Operation should not succeed.");
     } catch (UnsupportedOperationException e) {}
+    server.shutdown();
     client.getConnectionManager().shutdown();
   }
 

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java?rev=1534003&r1=1534002&r2=1534003&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java
Sun Oct 20 23:00:49 2013
@@ -204,14 +204,15 @@ public class CloudSolrServerTest extends
   
   public void testShutdown() throws MalformedURLException {
     CloudSolrServer server = new CloudSolrServer("[ff01::114]:33332");
-    server.setZkConnectTimeout(100);
     try {
+      server.setZkConnectTimeout(100);
       server.connect();
       fail("Expected exception");
-    } catch(RuntimeException e) {
+    } catch (RuntimeException e) {
       assertTrue(e.getCause() instanceof TimeoutException);
+    } finally {
+      server.shutdown();
     }
-    server.shutdown();
   }
 
 }



Mime
View raw message