You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2012/08/13 13:17:06 UTC
svn commit: r1372366 [8/8] - in /lucene/dev/branches/pforcodec_3892: ./
dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/libraries/
dev-tools/maven/ dev-tools/maven/lucene/
dev-tools/maven/lucene/analysis/common/
dev-tools/maven/lucene/analysis/icu/ ...
Modified: lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/client/solrj/request/AbstractUpdateRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/client/solrj/request/AbstractUpdateRequest.java?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/client/solrj/request/AbstractUpdateRequest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/client/solrj/request/AbstractUpdateRequest.java Mon Aug 13 11:16:57 2012
@@ -30,7 +30,7 @@ import java.io.IOException;
*
*
**/
-public abstract class AbstractUpdateRequest extends SolrRequest {
+public abstract class AbstractUpdateRequest extends SolrRequest implements IsUpdateRequest {
protected ModifiableSolrParams params;
protected int commitWithin = -1;
Modified: lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/client/solrj/request/DirectXmlRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/client/solrj/request/DirectXmlRequest.java?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/client/solrj/request/DirectXmlRequest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/client/solrj/request/DirectXmlRequest.java Mon Aug 13 11:16:57 2012
@@ -34,7 +34,7 @@ import org.apache.solr.common.util.Conte
*
* @since solr 1.3
*/
-public class DirectXmlRequest extends SolrRequest
+public class DirectXmlRequest extends SolrRequest implements IsUpdateRequest
{
final String xml;
private SolrParams params;
Modified: lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java Mon Aug 13 11:16:57 2012
@@ -32,6 +32,7 @@ import org.apache.solr.common.SolrExcept
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.cloud.HashPartitioner.Range;
import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.data.Stat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,25 +43,49 @@ import org.slf4j.LoggerFactory;
public class ClusterState implements JSONWriter.Writable {
private static Logger log = LoggerFactory.getLogger(ClusterState.class);
- private final Map<String, Map<String,Slice>> collectionStates; // Map<collectionName, Map<sliceName,Slice>>
- private final Set<String> liveNodes;
+ private Integer zkClusterStateVersion;
+
+ private final Map<String, Map<String,Slice>> collectionStates; // Map<collectionName, Map<sliceName,Slice>>
+ private final Set<String> liveNodes;
private final HashPartitioner hp = new HashPartitioner();
private final Map<String,RangeInfo> rangeInfos = new HashMap<String,RangeInfo>();
private final Map<String,Map<String,ZkNodeProps>> leaders = new HashMap<String,Map<String,ZkNodeProps>>();
- public ClusterState(Set<String> liveNodes,
- Map<String, Map<String,Slice>> collectionStates) {
- this.liveNodes = new HashSet<String>(liveNodes.size());
- this.liveNodes.addAll(liveNodes);
- this.collectionStates = new HashMap<String, Map<String,Slice>>(collectionStates.size());
- this.collectionStates.putAll(collectionStates);
- addRangeInfos(collectionStates.keySet());
- getShardLeaders();
- }
- private void getShardLeaders() {
+
+ /**
+ * Use this constr when ClusterState is meant for publication.
+ *
+ * hashCode and equals will only depend on liveNodes and not clusterStateVersion.
+ *
+ * @param liveNodes
+ * @param collectionStates
+ */
+ public ClusterState(Set<String> liveNodes,
+ Map<String, Map<String,Slice>> collectionStates) {
+ this(null, liveNodes, collectionStates);
+ }
+
+ /**
+ * Use this constr when ClusterState is meant for consumption.
+ *
+ * @param zkClusterStateVersion
+ * @param liveNodes
+ * @param collectionStates
+ */
+ public ClusterState(Integer zkClusterStateVersion, Set<String> liveNodes,
+ Map<String, Map<String,Slice>> collectionStates) {
+ this.liveNodes = new HashSet<String>(liveNodes.size());
+ this.liveNodes.addAll(liveNodes);
+ this.collectionStates = new HashMap<String, Map<String,Slice>>(collectionStates.size());
+ this.collectionStates.putAll(collectionStates);
+ addRangeInfos(collectionStates.keySet());
+ getShardLeaders();
+ }
+
+ private void getShardLeaders() {
Set<Entry<String,Map<String,Slice>>> collections = collectionStates.entrySet();
for (Entry<String,Map<String,Slice>> collection : collections) {
Map<String,Slice> state = collection.getValue();
@@ -85,27 +110,27 @@ public class ClusterState implements JSO
}
}
- /**
- * Get properties of a shard leader for specific collection.
- */
- public ZkNodeProps getLeader(String collection, String shard) {
- Map<String,ZkNodeProps> collectionLeaders = leaders.get(collection);
- if (collectionLeaders == null) return null;
- return collectionLeaders.get(shard);
- }
-
- /**
- * Get shard properties or null if shard is not found.
- */
- public ZkNodeProps getShardProps(final String collection, final String coreNodeName) {
- Map<String, Slice> slices = getSlices(collection);
- for(Slice slice: slices.values()) {
- if(slice.getShards().get(coreNodeName)!=null) {
- return slice.getShards().get(coreNodeName);
- }
- }
- return null;
- }
+ /**
+ * Get properties of a shard leader for specific collection.
+ */
+ public ZkNodeProps getLeader(String collection, String shard) {
+ Map<String,ZkNodeProps> collectionLeaders = leaders.get(collection);
+ if (collectionLeaders == null) return null;
+ return collectionLeaders.get(shard);
+ }
+
+ /**
+ * Get shard properties or null if shard is not found.
+ */
+ public ZkNodeProps getShardProps(final String collection, final String coreNodeName) {
+ Map<String, Slice> slices = getSlices(collection);
+ for(Slice slice: slices.values()) {
+ if(slice.getShards().get(coreNodeName)!=null) {
+ return slice.getShards().get(coreNodeName);
+ }
+ }
+ return null;
+ }
private void addRangeInfos(Set<String> collections) {
for (String collection : collections) {
@@ -117,72 +142,72 @@ public class ClusterState implements JSO
* Get the index Slice for collection.
*/
public Slice getSlice(String collection, String slice) {
- if (collectionStates.containsKey(collection)
- && collectionStates.get(collection).containsKey(slice))
- return collectionStates.get(collection).get(slice);
- return null;
- }
+ if (collectionStates.containsKey(collection)
+ && collectionStates.get(collection).containsKey(slice))
+ return collectionStates.get(collection).get(slice);
+ return null;
+ }
/**
* Get all slices for collection.
*/
- public Map<String, Slice> getSlices(String collection) {
- if(!collectionStates.containsKey(collection))
- return null;
- return Collections.unmodifiableMap(collectionStates.get(collection));
- }
-
- /**
- * Get collection names.
- */
- public Set<String> getCollections() {
- return Collections.unmodifiableSet(collectionStates.keySet());
- }
-
- /**
- * @return Map<collectionName, Map<sliceName,Slice>>
- */
- public Map<String, Map<String, Slice>> getCollectionStates() {
- return Collections.unmodifiableMap(collectionStates);
- }
-
- /**
- * Get names of the currently live nodes.
- */
- public Set<String> getLiveNodes() {
- return Collections.unmodifiableSet(liveNodes);
- }
-
- /**
- * Get shardId for core.
- * @param coreNodeName in the form of nodeName_coreName
- */
- public String getShardId(String coreNodeName) {
- for (Entry<String, Map<String, Slice>> states: collectionStates.entrySet()){
- for(Entry<String, Slice> slices: states.getValue().entrySet()) {
- for(Entry<String, ZkNodeProps> shards: slices.getValue().getShards().entrySet()){
- if(coreNodeName.equals(shards.getKey())) {
- return slices.getKey();
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Check if node is alive.
- */
- public boolean liveNodesContain(String name) {
- return liveNodes.contains(name);
- }
-
- public RangeInfo getRanges(String collection) {
+ public Map<String, Slice> getSlices(String collection) {
+ if(!collectionStates.containsKey(collection))
+ return null;
+ return Collections.unmodifiableMap(collectionStates.get(collection));
+ }
+
+ /**
+ * Get collection names.
+ */
+ public Set<String> getCollections() {
+ return Collections.unmodifiableSet(collectionStates.keySet());
+ }
+
+ /**
+ * @return Map<collectionName, Map<sliceName,Slice>>
+ */
+ public Map<String, Map<String, Slice>> getCollectionStates() {
+ return Collections.unmodifiableMap(collectionStates);
+ }
+
+ /**
+ * Get names of the currently live nodes.
+ */
+ public Set<String> getLiveNodes() {
+ return Collections.unmodifiableSet(liveNodes);
+ }
+
+ /**
+ * Get shardId for core.
+ * @param coreNodeName in the form of nodeName_coreName
+ */
+ public String getShardId(String coreNodeName) {
+ for (Entry<String, Map<String, Slice>> states: collectionStates.entrySet()){
+ for(Entry<String, Slice> slices: states.getValue().entrySet()) {
+ for(Entry<String, ZkNodeProps> shards: slices.getValue().getShards().entrySet()){
+ if(coreNodeName.equals(shards.getKey())) {
+ return slices.getKey();
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Check if node is alive.
+ */
+ public boolean liveNodesContain(String name) {
+ return liveNodes.contains(name);
+ }
+
+ public RangeInfo getRanges(String collection) {
// TODO: store this in zk
RangeInfo rangeInfo = rangeInfos.get(collection);
- return rangeInfo;
- }
+ return rangeInfo;
+ }
private RangeInfo addRangeInfo(String collection) {
List<Range> ranges;
@@ -227,29 +252,39 @@ public class ClusterState implements JSO
throw new IllegalStateException("The HashPartitioner failed");
}
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("live nodes:" + liveNodes);
- sb.append(" collections:" + collectionStates);
- return sb.toString();
- }
-
- /**
- * Create ClusterState by reading the current state from zookeeper.
- */
- public static ClusterState load(SolrZkClient zkClient, Set<String> liveNodes) throws KeeperException, InterruptedException {
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("live nodes:" + liveNodes);
+ sb.append(" collections:" + collectionStates);
+ return sb.toString();
+ }
+
+ /**
+ * Create ClusterState by reading the current state from zookeeper.
+ */
+ public static ClusterState load(SolrZkClient zkClient, Set<String> liveNodes) throws KeeperException, InterruptedException {
+ Stat stat = new Stat();
byte[] state = zkClient.getData(ZkStateReader.CLUSTER_STATE,
- null, null, true);
- return load(state, liveNodes);
- }
-
- /**
- * Create ClusterState from json string that is typically stored in zookeeper.
- */
- public static ClusterState load(byte[] bytes, Set<String> liveNodes) {
+ null, stat, true);
+ return load(stat.getVersion(), state, liveNodes);
+ }
+
+
+ /**
+ * Create ClusterState from json string that is typically stored in zookeeper.
+ *
+ * Use {@link ClusterState#load(SolrZkClient, Set)} instead, unless you want to
+ * do something more when getting the data - such as get the stat, set watch, etc.
+ *
+ * @param version zk version of the clusterstate.json file (bytes)
+ * @param bytes clusterstate.json as a byte array
+ * @param liveNodes list of live nodes
+ * @return the ClusterState
+ */
+ public static ClusterState load(Integer version, byte[] bytes, Set<String> liveNodes) {
if (bytes == null || bytes.length == 0) {
- return new ClusterState(liveNodes, Collections.<String, Map<String,Slice>>emptyMap());
+ return new ClusterState(version, liveNodes, Collections.<String, Map<String,Slice>>emptyMap());
}
LinkedHashMap<String, Object> stateMap = (LinkedHashMap<String, Object>) ZkStateReader.fromJSON(bytes);
@@ -269,8 +304,8 @@ public class ClusterState implements JSO
}
state.put(collectionName, slices);
}
- return new ClusterState(liveNodes, state);
- }
+ return new ClusterState(version, liveNodes, state);
+ }
@Override
public void write(JSONWriter jsonWriter) {
@@ -282,5 +317,41 @@ public class ClusterState implements JSO
private ArrayList<String> shardList;
}
+ /**
+ * The version of clusterstate.json in ZooKeeper.
+ *
+ * @return null if ClusterState was created for publication, not consumption
+ */
+ public Integer getZkClusterStateVersion() {
+ return zkClusterStateVersion;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((zkClusterStateVersion == null) ? 0 : zkClusterStateVersion.hashCode());
+ result = prime * result + ((liveNodes == null) ? 0 : liveNodes.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (getClass() != obj.getClass()) return false;
+ ClusterState other = (ClusterState) obj;
+ if (zkClusterStateVersion == null) {
+ if (other.zkClusterStateVersion != null) return false;
+ } else if (!zkClusterStateVersion.equals(other.zkClusterStateVersion)) return false;
+ if (liveNodes == null) {
+ if (other.liveNodes != null) return false;
+ } else if (!liveNodes.equals(other.liveNodes)) return false;
+ return true;
+ }
+
+
+
}
Modified: lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/cloud/ZkCoreNodeProps.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/cloud/ZkCoreNodeProps.java?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/cloud/ZkCoreNodeProps.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/cloud/ZkCoreNodeProps.java Mon Aug 13 11:16:57 2012
@@ -74,5 +74,9 @@ public class ZkCoreNodeProps {
return nodeProps;
}
+ public boolean isLeader() {
+ return nodeProps.containsKey(ZkStateReader.LEADER_PROP);
+ }
+
}
Modified: lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java Mon Aug 13 11:16:57 2012
@@ -42,6 +42,7 @@ import org.apache.zookeeper.KeeperExcept
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;
+import org.apache.zookeeper.data.Stat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -193,10 +194,11 @@ public class ZkStateReader {
synchronized (ZkStateReader.this.getUpdateLock()) {
// remake watch
final Watcher thisWatch = this;
- byte[] data = zkClient.getData(CLUSTER_STATE, thisWatch, null,
+ Stat stat = new Stat();
+ byte[] data = zkClient.getData(CLUSTER_STATE, thisWatch, stat ,
true);
- ClusterState clusterState = ClusterState.load(data,
+ ClusterState clusterState = ClusterState.load(stat.getVersion(), data,
ZkStateReader.this.clusterState.getLiveNodes());
// update volatile
ZkStateReader.this.clusterState = clusterState;
@@ -242,8 +244,10 @@ public class ZkStateReader {
LIVE_NODES_ZKNODE, this, true);
Set<String> liveNodesSet = new HashSet<String>();
liveNodesSet.addAll(liveNodes);
- ClusterState clusterState = new ClusterState(liveNodesSet,
- ZkStateReader.this.clusterState.getCollectionStates());
+ ClusterState clusterState = new ClusterState(
+ ZkStateReader.this.clusterState.getZkClusterStateVersion(),
+ liveNodesSet, ZkStateReader.this.clusterState
+ .getCollectionStates());
ZkStateReader.this.clusterState = clusterState;
}
} catch (KeeperException e) {
@@ -293,7 +297,8 @@ public class ZkStateReader {
clusterState = ClusterState.load(zkClient, liveNodesSet);
} else {
log.info("Updating live nodes from ZooKeeper... ");
- clusterState = new ClusterState(liveNodesSet,
+ clusterState = new ClusterState(
+ ZkStateReader.this.clusterState.getZkClusterStateVersion(), liveNodesSet,
ZkStateReader.this.clusterState.getCollectionStates());
}
}
@@ -325,7 +330,7 @@ public class ZkStateReader {
clusterState = ClusterState.load(zkClient, liveNodesSet);
} else {
log.info("Updating live nodes from ZooKeeper... ");
- clusterState = new ClusterState(liveNodesSet, ZkStateReader.this.clusterState.getCollectionStates());
+ clusterState = new ClusterState(ZkStateReader.this.clusterState .getZkClusterStateVersion(), liveNodesSet, ZkStateReader.this.clusterState.getCollectionStates());
}
ZkStateReader.this.clusterState = clusterState;
Modified: lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/util/FastOutputStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/util/FastOutputStream.java?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/util/FastOutputStream.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/solr/common/util/FastOutputStream.java Mon Aug 13 11:16:57 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/pforcodec_3892/solr/solrj/src/java/org/apache/zookeeper/SolrZooKeeper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/zookeeper/SolrZooKeeper.java?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/zookeeper/SolrZooKeeper.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/solrj/src/java/org/apache/zookeeper/SolrZooKeeper.java Mon Aug 13 11:16:57 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/pforcodec_3892/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java Mon Aug 13 11:16:57 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/pforcodec_3892/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java Mon Aug 13 11:16:57 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;
@@ -237,7 +245,7 @@ public class TestLBHttpSolrServer extend
}
public String getSchemaFile() {
- return "solrj/solr/conf/schema-replication1.xml";
+ return "solrj/solr/collection1/conf/schema-replication1.xml";
}
public String getConfDir() {
@@ -249,7 +257,7 @@ public class TestLBHttpSolrServer extend
}
public String getSolrConfigFile() {
- return "solrj/solr/conf/solrconfig-slave1.xml";
+ return "solrj/solr/collection1/conf/solrconfig-slave1.xml";
}
public void setUp() throws Exception {
Modified: lucene/dev/branches/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java Mon Aug 13 11:16:57 2012
@@ -450,11 +450,25 @@ public abstract class BaseDistributedSea
// System.out.println("resp b:" + b);
boolean ordered = (flags & UNORDERED) == 0;
+ if (!ordered) {
+ Map mapA = new HashMap(a.size());
+ for (int i=0; i<a.size(); i++) {
+ Object prev = mapA.put(a.getName(i), a.getVal(i));
+ }
+
+ Map mapB = new HashMap(b.size());
+ for (int i=0; i<b.size(); i++) {
+ Object prev = mapB.put(b.getName(i), b.getVal(i));
+ }
+
+ return compare(mapA, mapB, flags, handle);
+ }
+
int posa = 0, posb = 0;
int aSkipped = 0, bSkipped = 0;
for (; ;) {
- if (posa >= a.size() || posb >= b.size()) {
+ if (posa >= a.size() && posb >= b.size()) {
break;
}
@@ -468,29 +482,27 @@ public abstract class BaseDistributedSea
posa++;
flagsa = flags(handle, namea);
if ((flagsa & SKIP) != 0) {
+ namea = null; vala = null;
aSkipped++;
continue;
}
break;
}
- if (!ordered) posb = 0; // reset if not ordered
-
while (posb < b.size()) {
nameb = b.getName(posb);
valb = b.getVal(posb);
posb++;
flagsb = flags(handle, nameb);
if ((flagsb & SKIP) != 0) {
+ nameb = null; valb = null;
bSkipped++;
continue;
}
if (eq(namea, nameb)) {
break;
}
- if (ordered) {
- return "." + namea + "!=" + nameb + " (unordered or missing)";
- }
+ return "." + namea + "!=" + nameb + " (unordered or missing)";
// if unordered, continue until we find the right field.
}
@@ -503,7 +515,7 @@ public abstract class BaseDistributedSea
if (a.size() - aSkipped != b.size() - bSkipped) {
- return ".size()==" + a.size() + "," + b.size() + "skipped=" + aSkipped + "," + bSkipped;
+ return ".size()==" + a.size() + "," + b.size() + " skipped=" + aSkipped + "," + bSkipped;
}
return null;
Modified: lucene/dev/branches/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java Mon Aug 13 11:16:57 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 =
@@ -1388,11 +1395,10 @@ public abstract class SolrTestCaseJ4 ext
return file;
} catch (Exception e) {
/* more friendly than NPE */
- throw new RuntimeException("Cannot find resource: " + name);
+ throw new RuntimeException("Cannot find resource: " + new File(name).getAbsolutePath());
}
}
- // TODO: use solr rather than solr/collection1
public static String TEST_HOME() {
return getFile("solr/collection1").getParent();
}
Modified: lucene/dev/branches/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/util/AbstractSolrTestCase.java Mon Aug 13 11:16:57 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/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java Mon Aug 13 11:16:57 2012
@@ -25,7 +25,7 @@ import java.io.File;
* @lucene.internal
*/
public class ExternalPaths {
- private static final String SOURCE_HOME = determineSourceHome();
+ public static final String SOURCE_HOME = determineSourceHome();
public static String WEBAPP_HOME = new File(SOURCE_HOME, "webapp/web").getAbsolutePath();
public static String EXAMPLE_HOME = new File(SOURCE_HOME, "example/solr").getAbsolutePath();
public static String EXAMPLE_MULTICORE_HOME = new File(SOURCE_HOME, "example/multicore").getAbsolutePath();
Modified: lucene/dev/branches/pforcodec_3892/solr/testlogging.properties
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/testlogging.properties?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/testlogging.properties (original)
+++ lucene/dev/branches/pforcodec_3892/solr/testlogging.properties Mon Aug 13 11:16:57 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
Modified: lucene/dev/branches/pforcodec_3892/solr/webapp/web/admin.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/webapp/web/admin.html?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/webapp/web/admin.html (original)
+++ lucene/dev/branches/pforcodec_3892/solr/webapp/web/admin.html Mon Aug 13 11:16:57 2012
@@ -95,8 +95,8 @@ limitations under the License.
<li id="cloud" class="global optional"><p><a href="#/~cloud">Cloud</a></p>
<ul>
- <li class="tree"><a href="#/~cloud">Tree</a></li>
- <li class="graph"><a href="#/~cloud?view=graph">Graph</a></li>
+ <li class="tree"><a href="#/~cloud?view=tree">Tree</a></li>
+ <li class="graph"><a href="#/~cloud">Graph</a></li>
<li class="rgraph"><a href="#/~cloud?view=rgraph">Graph (Radial)</a></li>
<li class="dump"><a href="#/~cloud">Dump</a></li>
</ul>
Modified: lucene/dev/branches/pforcodec_3892/solr/webapp/web/js/scripts/app.js
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/webapp/web/js/scripts/app.js?rev=1372366&r1=1372365&r2=1372366&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/webapp/web/js/scripts/app.js (original)
+++ lucene/dev/branches/pforcodec_3892/solr/webapp/web/js/scripts/app.js Mon Aug 13 11:16:57 2012
@@ -258,7 +258,7 @@ var solr_admin = function( app_config )
{
show_global_error
(
- '<div class="message">There are no SolrCores running â for the currenct functionality ' +
+ '<div class="message">There are no SolrCores running â for the current functionality ' +
'we require at least one SolrCore, sorry :)</div>'
);
return;