You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2012/08/13 16:18:32 UTC
svn commit: r1372438 [5/5] - in /lucene/dev/branches/lucene3312: ./
dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/libraries/
dev-tools/maven/ dev-tools/maven/solr/
dev-tools/maven/solr/contrib/analysis-extras/
dev-tools/maven/solr/contrib/clusteri...
Modified: lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/handler/component/TermVectorComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/handler/component/TermVectorComponent.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/handler/component/TermVectorComponent.java (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/handler/component/TermVectorComponent.java Mon Aug 13 14:18:26 2012
@@ -16,7 +16,6 @@ import java.util.Map.Entry;
import org.apache.lucene.index.DocsAndPositionsEnum;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.Fields;
-import org.apache.lucene.index.FieldsEnum;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.StoredFieldVisitor;
import org.apache.lucene.index.Terms;
@@ -318,10 +317,8 @@ public class TermVectorComponent extends
} else {
// extract all fields
final Fields vectors = reader.getTermVectors(docId);
- final FieldsEnum fieldsEnum = vectors.iterator();
- String field;
- while((field = fieldsEnum.next()) != null) {
- Terms terms = fieldsEnum.terms();
+ for (String field : vectors) {
+ Terms terms = vectors.terms(field);
if (terms != null) {
termsEnum = terms.iterator(termsEnum);
mapOneVector(docNL, allFields, reader, docId, termsEnum, field);
Modified: lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java Mon Aug 13 14:18:26 2012
@@ -122,8 +122,8 @@ public class JavabinLoader extends Conte
for (String s : update.getDeleteById()) {
delcmd.id = s;
processor.processDelete(delcmd);
+ delcmd.clear();
}
- delcmd.id = null;
}
if(update.getDeleteQuery() != null) {
Modified: lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/internal/csv/ExtendedBufferedReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/internal/csv/ExtendedBufferedReader.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/internal/csv/ExtendedBufferedReader.java (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/internal/csv/ExtendedBufferedReader.java Mon Aug 13 14:18:26 2012
@@ -254,7 +254,7 @@ class ExtendedBufferedReader extends Buf
* Skips all chars in the input until (but excluding) the given char
*
* @param c
- * @return
+ * @return counter
* @throws IllegalArgumentException
* @throws IOException
*/
Modified: lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/request/SimpleFacets.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/request/SimpleFacets.java (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/request/SimpleFacets.java Mon Aug 13 14:18:26 2012
@@ -397,7 +397,7 @@ public class SimpleFacets {
Integer.MAX_VALUE,
10, TimeUnit.SECONDS, // terminate idle threads after 10 sec
new SynchronousQueue<Runnable>() // directly hand off tasks
- , new DefaultSolrThreadFactory("facetExectutor")
+ , new DefaultSolrThreadFactory("facetExecutor")
);
/**
Modified: lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java Mon Aug 13 14:18:26 2012
@@ -958,7 +958,7 @@ class ExtendedDismaxQParser extends QPar
* Returns the aliases found for a field.
* Returns null if there are no aliases for the field
* @param field
- * @return
+ * @return Alias
*/
public Alias getAlias(String field) {
return aliases.get(field);
Modified: lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/update/CommitTracker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/update/CommitTracker.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/update/CommitTracker.java (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/update/CommitTracker.java Mon Aug 13 14:18:26 2012
@@ -29,6 +29,7 @@ import org.apache.solr.common.params.Mod
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.util.DefaultSolrThreadFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,8 +53,8 @@ public final class CommitTracker impleme
private int docsUpperBound;
private long timeUpperBound;
- private final ScheduledExecutorService scheduler = Executors
- .newScheduledThreadPool(1);
+ private final ScheduledExecutorService scheduler =
+ Executors.newScheduledThreadPool(1, new DefaultSolrThreadFactory("commitScheduler"));
private ScheduledFuture pending;
// state
Modified: lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/update/TransactionLog.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/update/TransactionLog.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/update/TransactionLog.java (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/update/TransactionLog.java Mon Aug 13 14:18:26 2012
@@ -34,9 +34,11 @@ import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
@@ -149,7 +151,8 @@ public class TransactionLog {
long start = raf.length();
channel = raf.getChannel();
os = Channels.newOutputStream(channel);
- fos = FastOutputStream.wrap(os);
+ fos = new FastOutputStream(os, new byte[65536], 0);
+ // fos = FastOutputStream.wrap(os);
if (openExisting) {
if (start > 0) {
@@ -300,93 +303,119 @@ public class TransactionLog {
numRecords++;
}
+ private void checkWriteHeader(LogCodec codec, SolrInputDocument optional) throws IOException {
+
+ // Unsynchronized access. We can get away with an unsynchronized access here
+ // since we will never get a false non-zero when the position is in fact 0.
+ // rollback() is the only function that can reset to zero, and it blocks updates.
+ if (fos.size() != 0) return;
+
+ synchronized (this) {
+ if (fos.size() != 0) return; // check again while synchronized
+ if (optional != null) {
+ addGlobalStrings(optional.getFieldNames());
+ }
+ writeLogHeader(codec);
+ }
+ }
+
+ int lastAddSize;
public long write(AddUpdateCommand cmd, int flags) {
LogCodec codec = new LogCodec();
- long pos = 0;
- synchronized (this) {
- try {
- pos = fos.size(); // if we had flushed, this should be equal to channel.position()
- SolrInputDocument sdoc = cmd.getSolrInputDocument();
+ SolrInputDocument sdoc = cmd.getSolrInputDocument();
- if (pos == 0) { // TODO: needs to be changed if we start writing a header first
- addGlobalStrings(sdoc.getFieldNames());
- writeLogHeader(codec);
- pos = fos.size();
- }
+ try {
+ checkWriteHeader(codec, sdoc);
+
+ // adaptive buffer sizing
+ int bufSize = lastAddSize; // unsynchronized access of lastAddSize should be fine
+ bufSize = Math.min(1024*1024, bufSize+(bufSize>>3)+256);
+
+ MemOutputStream out = new MemOutputStream(new byte[bufSize]);
+ codec.init(out);
+ codec.writeTag(JavaBinCodec.ARR, 3);
+ codec.writeInt(UpdateLog.ADD | flags); // should just take one byte
+ codec.writeLong(cmd.getVersion());
+ codec.writeSolrInputDocument(cmd.getSolrInputDocument());
+ lastAddSize = (int)out.size();
+
+ synchronized (this) {
+ long pos = fos.size(); // if we had flushed, this should be equal to channel.position()
+ assert pos != 0;
/***
- System.out.println("###writing at " + pos + " fos.size()=" + fos.size() + " raf.length()=" + raf.length());
+ System.out.println("###writing at " + pos + " fos.size()=" + fos.size() + " raf.length()=" + raf.length());
if (pos != fos.size()) {
- throw new RuntimeException("ERROR" + "###writing at " + pos + " fos.size()=" + fos.size() + " raf.length()=" + raf.length());
- }
+ throw new RuntimeException("ERROR" + "###writing at " + pos + " fos.size()=" + fos.size() + " raf.length()=" + raf.length());
+ }
***/
- codec.init(fos);
- codec.writeTag(JavaBinCodec.ARR, 3);
- codec.writeInt(UpdateLog.ADD | flags); // should just take one byte
- codec.writeLong(cmd.getVersion());
- codec.writeSolrInputDocument(cmd.getSolrInputDocument());
-
+ out.writeAll(fos);
endRecord(pos);
// fos.flushBuffer(); // flush later
return pos;
- } catch (IOException e) {
- // TODO: reset our file pointer back to "pos", the start of this record.
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error logging add", e);
}
+
+ } catch (IOException e) {
+ // TODO: reset our file pointer back to "pos", the start of this record.
+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error logging add", e);
}
}
public long writeDelete(DeleteUpdateCommand cmd, int flags) {
LogCodec codec = new LogCodec();
- synchronized (this) {
- try {
- long pos = fos.size(); // if we had flushed, this should be equal to channel.position()
- if (pos == 0) {
- writeLogHeader(codec);
- pos = fos.size();
- }
- codec.init(fos);
- codec.writeTag(JavaBinCodec.ARR, 3);
- codec.writeInt(UpdateLog.DELETE | flags); // should just take one byte
- codec.writeLong(cmd.getVersion());
- BytesRef br = cmd.getIndexedId();
- codec.writeByteArray(br.bytes, br.offset, br.length);
+ try {
+ checkWriteHeader(codec, null);
+
+ BytesRef br = cmd.getIndexedId();
+
+ MemOutputStream out = new MemOutputStream(new byte[20 + br.length]);
+ codec.init(out);
+ codec.writeTag(JavaBinCodec.ARR, 3);
+ codec.writeInt(UpdateLog.DELETE | flags); // should just take one byte
+ codec.writeLong(cmd.getVersion());
+ codec.writeByteArray(br.bytes, br.offset, br.length);
+
+ synchronized (this) {
+ long pos = fos.size(); // if we had flushed, this should be equal to channel.position()
+ assert pos != 0;
+ out.writeAll(fos);
endRecord(pos);
// fos.flushBuffer(); // flush later
-
return pos;
- } catch (IOException e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
}
+
+ } catch (IOException e) {
+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
}
+
}
public long writeDeleteByQuery(DeleteUpdateCommand cmd, int flags) {
LogCodec codec = new LogCodec();
- synchronized (this) {
- try {
- long pos = fos.size(); // if we had flushed, this should be equal to channel.position()
- if (pos == 0) {
- writeLogHeader(codec);
- pos = fos.size();
- }
- codec.init(fos);
- codec.writeTag(JavaBinCodec.ARR, 3);
- codec.writeInt(UpdateLog.DELETE_BY_QUERY | flags); // should just take one byte
- codec.writeLong(cmd.getVersion());
- codec.writeStr(cmd.query);
+ try {
+ checkWriteHeader(codec, null);
+ MemOutputStream out = new MemOutputStream(new byte[20 + (cmd.query.length())]);
+ codec.init(out);
+ codec.writeTag(JavaBinCodec.ARR, 3);
+ codec.writeInt(UpdateLog.DELETE_BY_QUERY | flags); // should just take one byte
+ codec.writeLong(cmd.getVersion());
+ codec.writeStr(cmd.query);
+
+ synchronized (this) {
+ long pos = fos.size(); // if we had flushed, this should be equal to channel.position()
+ out.writeAll(fos);
endRecord(pos);
// fos.flushBuffer(); // flush later
-
return pos;
+ }
} catch (IOException e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
}
- }
+
}
@@ -745,3 +774,32 @@ class ChannelFastInputStream extends Fas
}
}
+
+class MemOutputStream extends FastOutputStream {
+ public List<byte[]> buffers = new LinkedList<byte[]>();
+ public MemOutputStream(byte[] tempBuffer) {
+ super(null, tempBuffer, 0);
+ }
+
+ @Override
+ public void flush(byte[] arr, int offset, int len) throws IOException {
+ if (arr == buf && offset==0 && len==buf.length) {
+ buffers.add(buf); // steal the buffer
+ buf = new byte[8192];
+ } else if (len > 0) {
+ byte[] newBuf = new byte[len];
+ System.arraycopy(arr, offset, newBuf, 0, len);
+ buffers.add(newBuf);
+ }
+ }
+
+ public void writeAll(FastOutputStream fos) throws IOException {
+ for (byte[] buffer : buffers) {
+ fos.write(buffer);
+ }
+ if (pos > 0) {
+ fos.write(buf, 0, pos);
+ }
+ }
+}
+
Modified: lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/util/FastWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/util/FastWriter.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/util/FastWriter.java (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/java/org/apache/solr/util/FastWriter.java Mon Aug 13 14:18:26 2012
@@ -52,7 +52,7 @@ public class FastWriter extends Writer {
public void write(char c) throws IOException {
if (pos >= buf.length) {
- sink.write(buf,0,pos);
+ flush(buf,0,pos);
pos=0;
}
buf[pos++] = c;
@@ -61,7 +61,7 @@ public class FastWriter extends Writer {
@Override
public FastWriter append(char c) throws IOException {
if (pos >= buf.length) {
- sink.write(buf,0,pos);
+ flush(buf,0,pos);
pos=0;
}
buf[pos++] = c;
@@ -77,14 +77,14 @@ public class FastWriter extends Writer {
} else if (len<BUFSIZE) {
// if the data to write is small enough, buffer it.
System.arraycopy(cbuf, off, buf, pos, space);
- sink.write(buf, 0, buf.length);
+ flush(buf, 0, buf.length);
pos = len-space;
System.arraycopy(cbuf, off+space, buf, 0, pos);
} else {
- sink.write(buf,0,pos); // flush
+ flush(buf,0,pos); // flush
pos=0;
// don't buffer, just write to sink
- sink.write(cbuf, off, len);
+ flush(cbuf, off, len);
}
}
@@ -97,32 +97,40 @@ public class FastWriter extends Writer {
} else if (len<BUFSIZE) {
// if the data to write is small enough, buffer it.
str.getChars(off, off+space, buf, pos);
- sink.write(buf, 0, buf.length);
+ flush(buf, 0, buf.length);
str.getChars(off+space, off+len, buf, 0);
pos = len-space;
} else {
- sink.write(buf,0,pos); // flush
+ flush(buf,0,pos); // flush
pos=0;
// don't buffer, just write to sink
- sink.write(str, off, len);
+ flush(str, off, len);
}
}
@Override
public void flush() throws IOException {
- sink.write(buf,0,pos);
+ flush(buf, 0, pos);
pos=0;
- sink.flush();
+ if (sink != null) sink.flush();
+ }
+
+ public void flush(char[] buf, int offset, int len) throws IOException {
+ sink.write(buf, offset, len);
+ }
+
+ public void flush(String str, int offset, int len) throws IOException {
+ sink.write(str, offset, len);
}
@Override
public void close() throws IOException {
flush();
- sink.close();
+ if (sink != null) sink.close();
}
public void flushBuffer() throws IOException {
- sink.write(buf, 0, pos);
+ flush(buf, 0, pos);
pos=0;
}
}
Modified: lucene/dev/branches/lucene3312/solr/core/src/test-files/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/test-files/solr/collection1/conf/schema.xml?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/test-files/solr/collection1/conf/schema.xml (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/test-files/solr/collection1/conf/schema.xml Mon Aug 13 14:18:26 2012
@@ -559,7 +559,7 @@
<field name="inStock" type="boolean" indexed="true" stored="true" />
<field name="subword" type="subword" indexed="true" stored="true"/>
- <field name="subword_offsets" type="subword" indexed="true" stored="true" termOffsets="true"/>
+ <field name="subword_offsets" type="subword" indexed="true" stored="true" termVectors="true" termOffsets="true"/>
<field name="numericsubword" type="numericsubword" indexed="true" stored="true"/>
<field name="protectedsubword" type="protectedsubword" indexed="true" stored="true"/>
Modified: lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/SolrInfoMBeanTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/SolrInfoMBeanTest.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/SolrInfoMBeanTest.java (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/SolrInfoMBeanTest.java Mon Aug 13 14:18:26 2012
@@ -25,6 +25,7 @@ import org.apache.solr.highlight.Default
import org.apache.solr.search.LRUCache;
import org.junit.BeforeClass;
import java.io.File;
+import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
@@ -94,7 +95,10 @@ public class SolrInfoMBeanTest extends S
String path = pckgname.replace('.', '/');
Enumeration<URL> resources = cld.getResources(path);
while (resources.hasMoreElements()) {
- final File f = new File(resources.nextElement().toURI());
+ final URI uri = resources.nextElement().toURI();
+ if (!"file".equalsIgnoreCase(uri.getScheme()))
+ continue;
+ final File f = new File(uri);
directories.add(f);
}
@@ -114,6 +118,7 @@ public class SolrInfoMBeanTest extends S
}
}
}
+ assertFalse("No classes found in package '"+pckgname+"'; maybe your test classes are packaged as JAR file?", classes.isEmpty());
return classes;
}
}
Modified: lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java Mon Aug 13 14:18:26 2012
@@ -35,10 +35,12 @@ import org.apache.solr.common.cloud.Solr
import org.apache.solr.common.cloud.ZkCoreNodeProps;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.util.DefaultSolrThreadFactory;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.NoNodeException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
@Slow
@@ -315,7 +317,7 @@ public class LeaderElectionTest extends
@Test
public void testStressElection() throws Exception {
final ScheduledExecutorService scheduler = Executors
- .newScheduledThreadPool(15);
+ .newScheduledThreadPool(15, new DefaultSolrThreadFactory("stressElection"));
final List<ClientThread> threads = Collections
.synchronizedList(new ArrayList<ClientThread>());
@@ -369,9 +371,7 @@ public class LeaderElectionTest extends
}
Thread.sleep(10);
-
} catch (Exception e) {
-
}
}
}
@@ -382,7 +382,6 @@ public class LeaderElectionTest extends
public void run() {
while (!stopStress) {
-
try {
Thread.sleep(50);
int j;
@@ -426,6 +425,7 @@ public class LeaderElectionTest extends
// cleanup any threads still running
for (ClientThread thread : threads) {
+ thread.zkClient.getSolrZooKeeper().close();
thread.close();
}
Modified: lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java Mon Aug 13 14:18:26 2012
@@ -43,6 +43,7 @@ import org.apache.solr.common.cloud.ZkNo
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.handler.component.HttpShardHandlerFactory;
+import org.apache.solr.util.DefaultSolrThreadFactory;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.NodeExistsException;
@@ -298,7 +299,7 @@ public class OverseerTest extends SolrTe
for (int i = 0; i < nodeCount; i++) {
- nodeExecutors[i] = Executors.newFixedThreadPool(1);
+ nodeExecutors[i] = Executors.newFixedThreadPool(1, new DefaultSolrThreadFactory("testShardAssignment"));
}
final String[] ids = new String[coreCount];
Modified: lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java Mon Aug 13 14:18:26 2012
@@ -24,8 +24,6 @@ import org.apache.solr.client.solrj.Solr
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.common.SolrInputDocument;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,16 +34,7 @@ public class RecoveryZkTest extends Abst
private static Logger log = LoggerFactory.getLogger(RecoveryZkTest.class);
private StopableIndexingThread indexThread;
private StopableIndexingThread indexThread2;
- @BeforeClass
- public static void beforeSuperClass() {
- }
-
- @AfterClass
- public static void afterSuperClass() {
-
- }
-
public RecoveryZkTest() {
super();
sliceCount = 1;
Modified: lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java Mon Aug 13 14:18:26 2012
@@ -37,7 +37,6 @@ public class TestMultiCoreConfBootstrap
protected CoreContainer cores = null;
private String home;
-
protected static ZkTestServer zkServer;
protected static String zkDir;
@@ -101,7 +100,6 @@ public class TestMultiCoreConfBootstrap
super.tearDown();
}
-
@Test
public void testMultiCoreConfBootstrap() throws Exception {
System.setProperty("bootstrap_conf", "true");
@@ -113,6 +111,7 @@ public class TestMultiCoreConfBootstrap
assertTrue(zkclient.exists("/configs/core1/schema.xml", true));
assertTrue(zkclient.exists("/configs/core0/solrconfig.xml", true));
assertTrue(zkclient.exists("/configs/core1/schema.xml", true));
+
+ zkclient.close();
}
-
}
Modified: lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java Mon Aug 13 14:18:26 2012
@@ -25,6 +25,7 @@ import org.apache.solr.request.SolrQuery
import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.util.DefaultSolrThreadFactory;
import org.apache.solr.util.plugin.SolrCoreAware;
import org.junit.Test;
@@ -163,7 +164,7 @@ public class SolrCoreTest extends SolrTe
final int LOOP = 100;
final int MT = 16;
- ExecutorService service = Executors.newFixedThreadPool(MT);
+ ExecutorService service = Executors.newFixedThreadPool(MT, new DefaultSolrThreadFactory("refCountMT"));
List<Callable<Integer>> callees = new ArrayList<Callable<Integer>>(MT);
final CoreContainer cores = h.getCoreContainer();
for (int i = 0; i < MT; ++i) {
Modified: lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/search/TestSolrJ.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/search/TestSolrJ.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/search/TestSolrJ.java (original)
+++ lucene/dev/branches/lucene3312/solr/core/src/test/org/apache/solr/search/TestSolrJ.java Mon Aug 13 14:18:26 2012
@@ -18,24 +18,149 @@
package org.apache.solr.search;
-import org.apache.lucene.util.OpenBitSet;
import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrServer;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
-import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
-import org.apache.solr.request.SolrQueryRequest;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import java.io.IOException;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
+import java.util.Random;
+
public class TestSolrJ extends SolrTestCaseJ4 {
- public void testSolrJ() {
+ public void testSolrJ() throws Exception {
+ // docs, producers, connections, sleep_time
+ // main(new String[] {"1000000","4", "1", "0"});
+
// doCommitPerf();
}
+ public static SolrServer server;
+ public static String idField = "id";
+ public static Exception ex;
+
+ public static void main(String[] args) throws Exception {
+ // String addr = "http://odin.local:80/solr";
+ // String addr = "http://odin.local:8983/solr";
+ String addr = "http://localhost:8983/solr";
+
+ int i = 0;
+ final int nDocs = Integer.parseInt(args[i++]);
+ final int nProducers = Integer.parseInt(args[i++]);
+ final int nConnections = Integer.parseInt(args[i++]);
+ final int maxSleep = Integer.parseInt(args[i++]);
+
+ ConcurrentUpdateSolrServer sserver = null;
+
+ // server = sserver = new ConcurrentUpdateSolrServer(addr,32,8);
+ server = sserver = new ConcurrentUpdateSolrServer(addr,64,nConnections);
+
+ server.deleteByQuery("*:*");
+ server.commit();
+
+ long start = System.currentTimeMillis();
+
+ final int docsPerThread = nDocs / nProducers;
+
+ Thread[] threads = new Thread[nProducers];
+
+ for (int threadNum = 0; threadNum<nProducers; threadNum++) {
+ final int base = threadNum * docsPerThread;
+
+ threads[threadNum] = new Thread("add-thread"+i) {
+ public void run(){
+ try {
+ indexDocs(base, docsPerThread, maxSleep);
+ } catch (Exception e) {
+ System.out.println("###############################CAUGHT EXCEPTION");
+ e.printStackTrace();
+ ex = e;
+ }
+ }
+ };
+ threads[threadNum].start();
+ }
+
+ // optional: wait for commit?
+
+ for (int threadNum = 0; threadNum<nProducers; threadNum++) {
+ threads[threadNum].join();
+ }
+
+ if (sserver != null) {
+ sserver.blockUntilFinished();
+ }
+
+ long end = System.currentTimeMillis();
+ System.out.println("time="+(end-start) + " throughput="+(nDocs*1000/(end-start)) + " Exception="+ex);
+
+ // should server threads be marked as daemon?
+ // need a server.close()!!!
+ }
+
+ public static SolrInputDocument getDocument(int docnum) {
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.setField(idField, docnum );
+ doc.setField("cat", Integer.toString(docnum&0x0f) );
+ doc.setField("name", "my name is " + Integer.toString(docnum&0xff) );
+ doc.setField("foo_t", "now is the time for all good men to come to the aid of their country" );
+ doc.setField("foo_i", Integer.toString(docnum&0x0f) );
+ doc.setField("foo_s", Integer.toString(docnum&0xff) );
+ doc.setField("foo_b", Boolean.toString( (docnum&0x01) == 1) );
+ doc.setField("parent_s", Integer.toString(docnum-1) );
+ doc.setField("price", Integer.toString(docnum >> 4));
+
+ int golden = (int)2654435761L;
+ int h = docnum * golden;
+ int n = (h & 0xff) + 1;
+ List lst = new ArrayList(n);
+ for (int i=0; i<n; i++) {
+ h = (h+i) * golden;
+ lst.add(h & 0xfff);
+ }
+
+ doc.setField("num_is", lst);
+ return doc;
+ }
+
+ public static void indexDocs(int base, int count, int maxSleep) throws IOException, SolrServerException {
+ Random r = new Random(base);
+
+ for (int i=base; i<count+base; i++) {
+ if ((i & 0xfffff) == 0) {
+ System.out.print("\n% " + new Date()+ "\t" + i + "\t");
+ System.out.flush();
+ }
+
+ if ((i & 0xffff) == 0) {
+ System.out.print(".");
+ System.out.flush();
+ }
+
+ SolrInputDocument doc = getDocument(i);
+ server.add(doc);
+
+ if (maxSleep > 0) {
+ int sleep = r.nextInt(maxSleep);
+ try {
+ Thread.sleep(sleep);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ }
+ }
+
+
public void doCommitPerf() throws Exception {
HttpSolrServer client = new HttpSolrServer("http://localhost:8983/solr");
@@ -55,4 +180,7 @@ public class TestSolrJ extends SolrTestC
System.out.println("TIME: " + (end-start));
}
+
+
+
}
Modified: lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java (original)
+++ lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java Mon Aug 13 14:18:26 2012
@@ -49,6 +49,7 @@ import org.apache.solr.common.params.Mod
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.UpdateParams;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SolrjNamedThreadFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -71,7 +72,8 @@ public class ConcurrentUpdateSolrServer
.getLogger(ConcurrentUpdateSolrServer.class);
private HttpSolrServer server;
final BlockingQueue<UpdateRequest> queue;
- final ExecutorService scheduler = Executors.newCachedThreadPool();
+ final ExecutorService scheduler = Executors.newCachedThreadPool(
+ new SolrjNamedThreadFactory("concurrentUpdateScheduler"));
final Queue<Runner> runners;
volatile CountDownLatch lock = null; // used to block everything
final int threadCount;
Modified: lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java (original)
+++ lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java Mon Aug 13 14:18:26 2012
@@ -21,6 +21,7 @@ import org.apache.solr.client.solrj.*;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SolrjNamedThreadFactory;
import org.apache.solr.common.SolrException;
import java.io.IOException;
@@ -397,7 +398,7 @@ public class LBHttpSolrServer extends So
public void setSoTimeout(int timeout) {
HttpClientUtil.setSoTimeout(httpClient, timeout);
}
-
+
@Override
public void shutdown() {
if (aliveCheckExecutor != null) {
@@ -555,7 +556,8 @@ public class LBHttpSolrServer extends So
if (aliveCheckExecutor == null) {
synchronized (this) {
if (aliveCheckExecutor == null) {
- aliveCheckExecutor = Executors.newSingleThreadScheduledExecutor();
+ aliveCheckExecutor = Executors.newSingleThreadScheduledExecutor(
+ new SolrjNamedThreadFactory("aliveCheckExecutor"));
aliveCheckExecutor.scheduleAtFixedRate(
getAliveCheckRunner(new WeakReference<LBHttpSolrServer>(this)),
this.interval, this.interval, TimeUnit.MILLISECONDS);
Modified: lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/solr/common/util/FastOutputStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/solr/common/util/FastOutputStream.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/solr/common/util/FastOutputStream.java (original)
+++ lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/solr/common/util/FastOutputStream.java Mon Aug 13 14:18:26 2012
@@ -23,10 +23,10 @@ import java.io.*;
* Internal Solr use only, subject to change.
*/
public class FastOutputStream extends OutputStream implements DataOutput {
- private final OutputStream out;
- private final byte[] buf;
- private long written; // how many bytes written to the underlying stream
- private int pos;
+ protected final OutputStream out;
+ protected byte[] buf;
+ protected long written; // how many bytes written to the underlying stream
+ protected int pos;
public FastOutputStream(OutputStream w) {
// use default BUFSIZE of BufferedOutputStream so if we wrap that
@@ -57,7 +57,7 @@ public class FastOutputStream extends Ou
public void write(byte b) throws IOException {
if (pos >= buf.length) {
- out.write(buf);
+ flush(buf, 0, buf.length);
written += pos;
pos=0;
}
@@ -73,18 +73,18 @@ public class FastOutputStream extends Ou
} else if (len<buf.length) {
// if the data to write is small enough, buffer it.
System.arraycopy(arr, off, buf, pos, space);
- out.write(buf);
+ flush(buf, 0, buf.length);
written += buf.length;
pos = len-space;
System.arraycopy(arr, off+space, buf, 0, pos);
} else {
if (pos>0) {
- out.write(buf,0,pos); // flush
+ flush(buf,0,pos); // flush
written += pos;
pos=0;
}
// don't buffer, just write to sink
- out.write(arr, off, len);
+ flush(arr, off, len);
written += len;
}
}
@@ -168,13 +168,13 @@ public class FastOutputStream extends Ou
@Override
public void flush() throws IOException {
flushBuffer();
- out.flush();
+ if (out != null) out.flush();
}
@Override
public void close() throws IOException {
flushBuffer();
- out.close();
+ if (out != null) out.close();
}
/** Only flushes the buffer of the FastOutputStream, not that of the
@@ -182,12 +182,17 @@ public class FastOutputStream extends Ou
*/
public void flushBuffer() throws IOException {
if (pos > 0) {
- out.write(buf, 0, pos);
+ flush(buf, 0, pos);
written += pos;
pos=0;
}
}
+ /** All writes to the sink will go through this method */
+ public void flush(byte[] buf, int offset, int len) throws IOException {
+ out.write(buf, offset, len);
+ }
+
public long size() {
return written + pos;
}
Modified: lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/zookeeper/SolrZooKeeper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/zookeeper/SolrZooKeeper.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/zookeeper/SolrZooKeeper.java (original)
+++ lucene/dev/branches/lucene3312/solr/solrj/src/java/org/apache/zookeeper/SolrZooKeeper.java Mon Aug 13 14:18:26 2012
@@ -19,9 +19,12 @@ package org.apache.zookeeper;
import java.io.IOException;
import java.nio.channels.SocketChannel;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
// we use this class to expose nasty stuff for tests
public class SolrZooKeeper extends ZooKeeper {
+ List<Thread> spawnedThreads = new CopyOnWriteArrayList<Thread>();
public SolrZooKeeper(String connectString, int sessionTimeout,
Watcher watcher) throws IOException {
@@ -38,21 +41,32 @@ public class SolrZooKeeper extends ZooKe
* @param ms the number of milliseconds to pause.
*/
public void pauseCnxn(final long ms) {
- new Thread() {
+ Thread t = new Thread() {
public void run() {
- synchronized (cnxn) {
- try {
+ try {
+ synchronized (cnxn) {
try {
((SocketChannel) cnxn.sendThread.sockKey.channel()).socket()
.close();
} catch (Exception e) {
-
}
Thread.sleep(ms);
- } catch (InterruptedException e) {}
- }
+ }
+
+ // Wait a long while to make sure we properly clean up these threads.
+ Thread.sleep(500000);
+ } catch (InterruptedException e) {}
}
- }.start();
+ };
+ t.start();
+ spawnedThreads.add(t);
}
+ @Override
+ public synchronized void close() throws InterruptedException {
+ for (Thread t : spawnedThreads) {
+ t.interrupt();
+ }
+ super.close();
+ }
}
Modified: lucene/dev/branches/lucene3312/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java (original)
+++ lucene/dev/branches/lucene3312/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java Mon Aug 13 14:18:26 2012
@@ -711,16 +711,11 @@ abstract public class SolrExampleTests e
assertNumFound( "*:*", 3 ); // make sure it got in
// should be able to handle multiple delete commands in a single go
- StringWriter xml = new StringWriter();
- xml.append( "<delete>" );
+ List<String> ids = new ArrayList<String>();
for( SolrInputDocument d : doc ) {
- xml.append( "<id>" );
- XML.escapeCharData( (String)d.getField( "id" ).getFirstValue(), xml );
- xml.append( "</id>" );
+ ids.add(d.getFieldValue("id").toString());
}
- xml.append( "</delete>" );
- DirectXmlRequest up = new DirectXmlRequest( "/update", xml.toString() );
- server.request( up );
+ server.deleteById(ids);
server.commit();
assertNumFound( "*:*", 0 ); // make sure it got out
}
Modified: lucene/dev/branches/lucene3312/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java (original)
+++ lucene/dev/branches/lucene3312/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java Mon Aug 13 14:18:26 2012
@@ -21,7 +21,9 @@ import junit.framework.Assert;
import org.apache.commons.io.FileUtils;
import org.apache.http.client.HttpClient;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.QuickPatchThreadsFilter;
import org.apache.lucene.util.LuceneTestCase.Slow;
+import org.apache.solr.SolrIgnoredThreadsFilter;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
@@ -35,6 +37,8 @@ import org.apache.solr.util.AbstractSolr
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -48,6 +52,10 @@ import java.util.Set;
* @since solr 1.4
*/
@Slow
+@ThreadLeakFilters(defaultFilters = true, filters = {
+ SolrIgnoredThreadsFilter.class,
+ QuickPatchThreadsFilter.class
+})
public class TestLBHttpSolrServer extends LuceneTestCase {
SolrInstance[] solr = new SolrInstance[3];
HttpClient httpClient;
Modified: lucene/dev/branches/lucene3312/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/branches/lucene3312/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java Mon Aug 13 14:18:26 2012
@@ -24,6 +24,7 @@ import java.util.logging.*;
import javax.xml.xpath.XPathExpressionException;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.QuickPatchThreadsFilter;
import org.apache.noggit.*;
import org.apache.solr.common.*;
import org.apache.solr.common.cloud.SolrZkClient;
@@ -38,6 +39,7 @@ import org.apache.solr.schema.SchemaFiel
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.servlet.DirectSolrConnection;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.apache.solr.util.RevertDefaultThreadHandlerRule;
import org.apache.solr.util.TestHarness;
import org.junit.*;
import org.junit.rules.RuleChain;
@@ -46,20 +48,25 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
-import com.carrotsearch.randomizedtesting.annotations.ThreadLeaks;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
/**
* A junit4 Solr test harness that extends LuceneTestCaseJ4.
* Unlike {@link AbstractSolrTestCase}, a new core is not created for each test method.
*/
+@ThreadLeakFilters(defaultFilters = true, filters = {
+ SolrIgnoredThreadsFilter.class,
+ QuickPatchThreadsFilter.class
+})
public abstract class SolrTestCaseJ4 extends LuceneTestCase {
public static int DEFAULT_CONNECTION_TIMEOUT = 1000; // default socket connection timeout in ms
@ClassRule
public static TestRule solrClassRules =
- RuleChain.outerRule(new SystemPropertiesRestoreRule());
+ RuleChain.outerRule(new SystemPropertiesRestoreRule())
+ .around(new RevertDefaultThreadHandlerRule());
@Rule
public TestRule solrTestRules =
Modified: lucene/dev/branches/lucene3312/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java (original)
+++ lucene/dev/branches/lucene3312/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java Mon Aug 13 14:18:26 2012
@@ -31,7 +31,9 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.http.params.CoreConnectionPNames;
+import org.apache.lucene.util.LuceneTestCase.BadApple;
import org.apache.lucene.util.LuceneTestCase.Slow;
+import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
@@ -59,12 +61,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
* TODO: we should still test this works as a custom update chain as well as
* what we test now - the default update chain
- *
*/
@Slow
+@BadApple
+@AwaitsFix(bugUrl = "SOLR-3727 (leak threads)")
public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTestBase {
static Logger log = LoggerFactory.getLogger(AbstractFullDistribZkTestBase.class);
@@ -757,7 +759,7 @@ public abstract class AbstractFullDistri
zkStateReader.getClusterState().getSlice(DEFAULT_COLLECTION, shard)
.getShards().size(), solrJetties.size());
- SolrServer lastClient = null;
+ CloudJettyRunner lastJetty = null;
for (CloudJettyRunner cjetty : solrJetties) {
ZkNodeProps props = cjetty.info;
if (verbose) System.err.println("client" + cnt++);
@@ -790,7 +792,7 @@ public abstract class AbstractFullDistri
ZkStateReader.ACTIVE);
if (active && live) {
if (lastNum > -1 && lastNum != num && failMessage == null) {
- failMessage = shard + " is not consistent. Got " + lastNum + " from " + lastClient + "lastClient"
+ failMessage = shard + " is not consistent. Got " + lastNum + " from " + lastJetty.url + "lastClient"
+ " and got " + num + " from " + cjetty.url;
if (verbose || true) {
@@ -801,15 +803,15 @@ public abstract class AbstractFullDistri
query.set("rows","1000");
query.set("sort","id asc");
- SolrDocumentList lst1 = lastClient.query(query).getResults();
+ SolrDocumentList lst1 = lastJetty.client.solrClient.query(query).getResults();
SolrDocumentList lst2 = cjetty.client.solrClient.query(query).getResults();
- showDiff(lst1, lst2, lastClient.toString(), cjetty.client.solrClient.toString());
+ showDiff(lst1, lst2, lastJetty.toString(), cjetty.client.solrClient.toString());
}
}
lastNum = num;
- lastClient = cjetty.client.solrClient;
+ lastJetty = cjetty;
}
}
return failMessage;
Modified: lucene/dev/branches/lucene3312/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java (original)
+++ lucene/dev/branches/lucene3312/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java Mon Aug 13 14:18:26 2012
@@ -25,6 +25,8 @@ import java.util.*;
import javax.xml.xpath.XPathExpressionException;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.QuickPatchThreadsFilter;
+import org.apache.solr.SolrIgnoredThreadsFilter;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.*;
import org.apache.solr.common.params.CommonParams;
@@ -38,7 +40,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
-import com.carrotsearch.randomizedtesting.annotations.ThreadLeaks;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
/**
@@ -54,6 +56,10 @@ import com.carrotsearch.randomizedtestin
* @see #setUp
* @see #tearDown
*/
+@ThreadLeakFilters(defaultFilters = true, filters = {
+ SolrIgnoredThreadsFilter.class,
+ QuickPatchThreadsFilter.class
+})
public abstract class AbstractSolrTestCase extends LuceneTestCase {
protected SolrConfig solrConfig;
@@ -98,7 +104,8 @@ public abstract class AbstractSolrTestCa
@ClassRule
public static TestRule solrClassRules =
- RuleChain.outerRule(new SystemPropertiesRestoreRule());
+ RuleChain.outerRule(new SystemPropertiesRestoreRule())
+ .around(new RevertDefaultThreadHandlerRule());
@Rule
public TestRule solrTestRules =
Modified: lucene/dev/branches/lucene3312/solr/testlogging.properties
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/solr/testlogging.properties?rev=1372438&r1=1372437&r2=1372438&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/solr/testlogging.properties (original)
+++ lucene/dev/branches/lucene3312/solr/testlogging.properties Mon Aug 13 14:18:26 2012
@@ -10,6 +10,7 @@ java.util.logging.ConsoleHandler.formatt
#org.apache.solr.update.processor.LogUpdateProcessor=FINEST
#org.apache.solr.update.processor.DistributedUpdateProcessor=FINEST
#org.apache.solr.update.PeerSync.level=FINEST
+#org.apache.solr.cloud.RecoveryStrategy.level=FINEST
#org.apache.solr.update.UpdateLog.level=FINE
#org.apache.solr.update.TransactionLog.level=FINEST