getDocIfPn(String partition, BytesRef tmp) {
+ final String text = tmp.utf8ToString();
+ if (log.isTraceEnabled())
+ log.trace("getDoc if p={}", partition);
+
+ final String[] vals = text.split(" ");
+
+ final String docPartition = vals[1];
+
+ /*
+ If the partition matches the one we are looking for,
+ parse the version, bkey, and object hash from the
+ entropy data field (term).
+ */
+ if (partition.equals(docPartition)) {
+ if (log.isDebugEnabled())
+ log.debug(" getDoc 「{}」", text);
+
+ final String vsn = vals[0];
+ final String[] decoded = decodeForVersion(vsn,
+ vals[2],
+ vals[3],
+ vals[4]);
+
+ final String hash = vals[5];
+
+ final SolrDocument tmpDoc = new SolrDocument();
+ tmpDoc.addField("vsn", vsn);
+ tmpDoc.addField("riak_bucket_type", decoded[0]);
+ tmpDoc.addField("riak_bucket_name", decoded[1]);
+ tmpDoc.addField("riak_key", decoded[2]);
+ tmpDoc.addField("base64_hash", hash);
+ return Optional.of(tmpDoc);
+ }
+ return Optional.empty();
}
- static BytesRef decodeCont(final String cont) {
+ private static BytesRef decodeCont(final String cont) {
final byte[] bytes = org.apache.commons.codec.binary.Base64.decodeBase64(cont);
return new BytesRef(bytes);
}
- static boolean endOfItr(final BytesRef returnValue) {
- return returnValue == null;
- }
+ // private static boolean endOfItr(final BytesRef returnValue) {
+ // return returnValue == null;
+ // }
- static boolean isContinue(final BytesRef cont) {
+ private static boolean isContinue(final BytesRef cont) {
return DEFAULT_CONT != cont;
}
@@ -201,48 +276,45 @@ public String getDescription() {
return "vector clock data iterator";
}
- @Override
- public String getVersion() {
- return "0.0.1";
- }
-
- @Override
- public String getSource() {
- return "TODO: implement getSource";
- }
+ // @Override
+ // public String getVersion() {
+ // return "0.0.1";
+ // }
/**
- @param vsn a String vsn number referring to the item's ed handler version
- @param riakBType riak bucket-type
- @param riakBName riak bucket-name
- @param riakKey riak key
- @return a String array consisting of a Bucket Type, Bucket Name, and Riak Key
- */
- private String [] decodeForVersion(String vsn, String riakBType, String riakBName, String riakKey) {
- final String [] bKeyInfo;
- switch(Integer.parseInt(vsn)) {
- case 1:
- bKeyInfo = new String [] {riakBType, riakBName, riakKey};
- break;
- default:
- bKeyInfo = new String []
- {
- decodeBase64DocPart(riakBType),
- decodeBase64DocPart(riakBName),
- decodeBase64DocPart(riakKey)
- };
- break;
+ * @param vsn a String vsn number referring to the item's ed handler version
+ * @param riakBType riak bucket-type
+ * @param riakBName riak bucket-name
+ * @param riakKey riak key
+ * @return a String array consisting of a Bucket Type, Bucket Name, and Riak Key
+ */
+ private String[] decodeForVersion(String vsn, String riakBType, String riakBName, String riakKey) {
+ final String[] bKeyInfo;
+ switch (Integer.parseInt(vsn)) {
+ case 1:
+ bKeyInfo = new String[]{riakBType, riakBName, riakKey};
+ break;
+ default:
+ bKeyInfo = new String[]
+ {
+ decodeBase64DocPart(riakBType),
+ decodeBase64DocPart(riakBName),
+ decodeBase64DocPart(riakKey)
+ };
+ break;
}
return bKeyInfo;
}
/**
- @param base64EncodedVal base64 encoded string
- @return a string of decoded base64 bytes
- */
- private String decodeBase64DocPart(String base64EncodedVal) {
- return new String(DatatypeConverter.parseBase64Binary(
- base64EncodedVal));
+ * @param base64EncodedVal base64 encoded string
+ * @return a string of decoded base64 bytes
+ */
+
+ public static String decodeBase64DocPart(String base64EncodedVal) {
+ //return new String(DatatypeConverter.parseBase64Binary(
+ // base64EncodedVal));
+ return new String(Base64.decodeBase64(base64EncodedVal));
}
}
diff --git a/java_src/com/basho/yokozuna/handler/component/FQShardTranslator.java b/java_src/com/basho/yokozuna/handler/component/FQShardTranslator.java
index 1e1a02d5..8fafe79e 100644
--- a/java_src/com/basho/yokozuna/handler/component/FQShardTranslator.java
+++ b/java_src/com/basho/yokozuna/handler/component/FQShardTranslator.java
@@ -8,10 +8,8 @@
import org.apache.solr.handler.component.ShardRequest;
import org.apache.solr.request.SolrQueryRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.slf4j.*;
-import java.io.IOException;
/**
* Translate custom Yokozuna filter query shard params to normal
@@ -33,20 +31,23 @@
* each shard by passing a query param with the name `$host:$port` and
* a value of the filter query to run. For example:
*
- * ?10.0.1.100:10014=_yz_pn:1 OR _yz_pn:7 OR ...\
- * &10.0.1.101:10014=_yz_pn:4 OR _yz_pn:10 OR ...
- *
+ *
+ * {@code
+ * ?10.0.1.100:10014=_yz_pn:1 OR _yz_pn:7 OR ...\
+ * &10.0.1.101:10014=_yz_pn:4 OR _yz_pn:10 OR ...
+ * }
+ *
*/
public class FQShardTranslator extends SearchComponent {
protected static final Logger log = LoggerFactory.getLogger(FQShardTranslator.class);
public static final String COMPONENT_NAME = "fq_shard_translator";
@Override
- public void prepare(ResponseBuilder rb) throws IOException {
+ public void prepare(ResponseBuilder rb) {
SolrQueryRequest req = rb.req;
SolrParams params = req.getParams();
- if (!isDistrib(params)) {
+ if (! rb.isDistributed()) {
String shardUrl = params.get(ShardParams.SHARD_URL);
if (shardUrl != null) {
String hostPort = shardUrl.substring(0, shardUrl.indexOf('/'));
@@ -58,32 +59,21 @@ public void prepare(ResponseBuilder rb) throws IOException {
}
@Override
- public void process(ResponseBuilder rb) throws IOException {
- return;
+ public void process(ResponseBuilder rb) {
}
@Override
- public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) {
- return;
- }
+ public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) {}
+
@Override
public String getDescription() {
return "Yokozuna's FQ Shard Translator";
}
- @Override
+ // @Override
public String getSource() {
return "https://github.com/basho/yokozuna";
}
- private boolean isDistrib(SolrParams params) {
- // Based on HttpShardHandler because rb.isDistrib is not public.
- boolean distrib = params.getBool("distrib", false);
- String shards = params.get(ShardParams.SHARDS);
- boolean hasShardURL = shards != null;
-
- return hasShardURL || distrib;
- }
-
}
diff --git a/java_src/com/basho/yokozuna/handler/package-info.java b/java_src/com/basho/yokozuna/handler/package-info.java
new file mode 100644
index 00000000..4e2208b5
--- /dev/null
+++ b/java_src/com/basho/yokozuna/handler/package-info.java
@@ -0,0 +1,2 @@
+package com.basho.yokozuna.handler;
+
diff --git a/java_src/com/basho/yokozuna/monitor/Monitor.java b/java_src/com/basho/yokozuna/monitor/Monitor.java
index 51c028e4..e1ca4c96 100644
--- a/java_src/com/basho/yokozuna/monitor/Monitor.java
+++ b/java_src/com/basho/yokozuna/monitor/Monitor.java
@@ -15,10 +15,11 @@
*/
package com.basho.yokozuna.monitor;
+import org.slf4j.*;
+
import java.io.IOException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
/**
* Kill Solr when stdin closes, as it will when the Erlang VM shuts
@@ -37,28 +38,31 @@ public void run() {
log.debug("Monitor attempting read on stdin");
}
if (System.in.read() < 0) {
- if (log.isInfoEnabled()) {
- log.info("Yokozuna has exited - shutting down Solr");
- }
- System.exit(0);
+ die();
}
if (log.isDebugEnabled()) {
log.debug("Monitoring succeeded reading stdin");
}
}
catch (final IOException ioe) {
- if (log.isInfoEnabled()) {
- log.info("Yokozuna has exited - shutting down Solr");
- }
- System.exit(0);
+ die();
}
}
+ // for dtrace’s sake
+ private void die() {
+ if (log.isInfoEnabled()) {
+ log.info("Yokozuna has exited - shutting down Solr");
+ }
+ System.exit(0);
+ }
+
/**
* Start monitoring stdin in a background thread
*/
public static Monitor monitor() {
final Monitor m = new Monitor();
+ m.setName("riak superviser thread");
m.start();
return m;
}
@@ -72,7 +76,7 @@ public static void main(String[] args) {
try {
while(true) {
// hang out until thread sees stdin close
- Thread.sleep(1000);
+ Thread.sleep(1000L);
}
}
catch (final InterruptedException ie) {
diff --git a/java_src/com/basho/yokozuna/monitor/package-info.java b/java_src/com/basho/yokozuna/monitor/package-info.java
new file mode 100644
index 00000000..6fde928f
--- /dev/null
+++ b/java_src/com/basho/yokozuna/monitor/package-info.java
@@ -0,0 +1 @@
+package com.basho.yokozuna.monitor;
diff --git a/java_src/com/basho/yokozuna/query/EntropyClient.java b/java_src/com/basho/yokozuna/query/EntropyClient.java
new file mode 100644
index 00000000..78c93956
--- /dev/null
+++ b/java_src/com/basho/yokozuna/query/EntropyClient.java
@@ -0,0 +1,39 @@
+/**
+ * Lucene index walker client.
+ *
+ */
+
+
+
+
+package com.basho.yokozuna.query;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Path;
+
+
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.MMapDirectory;
+
+public class EntropyClient {
+ public static void main(String... args) throws IOException {
+
+ String dirS = args[0];
+ Path pa = FileSystems.getDefault().getPath(dirS);
+ Directory dir = new MMapDirectory(pa);
+
+ try (DirectoryReader reader = DirectoryReader.open(dir)) {
+ reader.leaves().stream().forEachOrdered((LeafReaderContext x) -> {
+ System.out.printf("\u001b[4m=== %s\u001b[m\nbase=%d\n", x, x.docBase);
+ });
+ }
+
+ System.err.println("Done.");
+
+ }
+}
diff --git a/java_src/com/basho/yokozuna/query/SimpleQueryExample.java b/java_src/com/basho/yokozuna/query/SimpleQueryExample.java
index 38c22936..288a214d 100644
--- a/java_src/com/basho/yokozuna/query/SimpleQueryExample.java
+++ b/java_src/com/basho/yokozuna/query/SimpleQueryExample.java
@@ -4,38 +4,49 @@
*
* Usage:
*
- * java -cp priv/java_lib/yokozuna.jar:priv/solr-jars/WEB-INF/lib/* com.basho.yokozuna.query.SimpleQueryExample BASE_URL INDEX FIELD TERM
+ * java -cp priv/solr-jars/WEB-INF/lib/* com.basho.yokozuna.query.SimpleQueryExample BASE_URL INDEX FIELD TERM
*
* Example:
*
- * java -cp priv/java_lib/yokozuna.jar:priv/solr-jars/WEB-INF/lib/* com.basho.yokozuna.query.SimpleQueryExample http://localhost:8098/search fruit text apple
+ * java -cp priv/solr-jars/WEB-INF/lib/* com.basho.yokozuna.query.SimpleQueryExample http://localhost:8098/search fruit text apple
*/
package com.basho.yokozuna.query;
-import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServer;
+import java.io.IOException;
+
+import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+//import org.apache.solr.client.solrj.request.QueryRequest;
+import org.apache.solr.client.solrj.impl.HttpSolrClient.Builder;
import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.common.params.ModifiableSolrParams;
+//@SuppressWarnings("UseOfSystemOutOrSystemErr")
public class SimpleQueryExample {
- public static void main(String[] args) throws SolrServerException {
+
+
+
+ public static void main(final String[] args)
+ throws SolrServerException, IOException {
final String baseURL = args[0];
final String index = args[1];
final String field = args[2];
final String term = args[3];
- final SolrServer solr = new HttpSolrServer(baseURL + "/" + index);
- final ModifiableSolrParams params = new ModifiableSolrParams();
+ String prefix = baseURL + "/" + index;
+ SolrClient solr = new Builder(prefix).build();
+
+
+ ModifiableSolrParams params = new ModifiableSolrParams();
params.set("qt", "/");
params.set("q", field + ":" + term);
- final SolrRequest req = new QueryRequest(params);
+ //SolrRequest req = new QueryRequest(params);
+
+ QueryResponse resp = solr.query(params);
- final QueryResponse resp = solr.query(params);
System.out.println("resp: " + resp);
}
}
diff --git a/priv/conf/solrconfig.xml b/priv/conf/solrconfig.xml
index 521f75df..3a598976 100644
--- a/priv/conf/solrconfig.xml
+++ b/priv/conf/solrconfig.xml
@@ -633,8 +633,8 @@
Admin Handlers - This will register all the standard admin
RequestHandlers.
-->
-
+
+
-
-
-
- _yz_id:ping_query
-
-
+
+
+
+
+
+
diff --git a/priv/default_schema.xml b/priv/default_schema.xml
index 32058ca6..8543a9b4 100644
--- a/priv/default_schema.xml
+++ b/priv/default_schema.xml
@@ -20,7 +20,7 @@
-
+
@@ -48,7 +48,6 @@
-
@@ -141,6 +140,8 @@
+
+
@@ -456,18 +457,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/priv/solr/contexts/solr-jetty-context.xml b/priv/solr/contexts/solr-jetty-context.xml
index 6a811851..21be01ce 100644
--- a/priv/solr/contexts/solr-jetty-context.xml
+++ b/priv/solr/contexts/solr-jetty-context.xml
@@ -1,8 +1,20 @@
-
-
+
+
-
- /webapps/solr.war
- /etc/webdefault.xml
- /solr-webapp
+
+
+
+ /solr-webapp/webapp
+ /etc/webdefault.xml
+ false
+
+
+
+
+
+
+
+
+
+
diff --git a/priv/solr/etc/jetty-http.xml b/priv/solr/etc/jetty-http.xml
new file mode 100644
index 00000000..2bac8e98
--- /dev/null
+++ b/priv/solr/etc/jetty-http.xml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/priv/solr/etc/jetty.xml b/priv/solr/etc/jetty.xml
index a6898712..c2fd61bc 100644
--- a/priv/solr/etc/jetty.xml
+++ b/priv/solr/etc/jetty.xml
@@ -1,5 +1,5 @@
-
+
@@ -12,126 +12,153 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ solr.jetty
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ https
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
- 10
- 10000
- false
-
-
-
-
-
+
+
+ true
+ false
+ requestedPath
-
-
-
-
-
-
- log4j.configuration etc/log4j.properties
-
-
- 60000
-
- 5000
-
-
- false
+
+
+
+ ^/$
+ /solr/
-
-
-
-
-
+
+
+
+
+
+ /v2/*
+ /solr/____v2
+
+
+
+
+
+
+ /api/*
+ /solr/____v2
+
+
+
+
+
+
+
+
+ /solr/*
+ /internal_solr
+
+
+
+
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
-
+
-
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
+
-
true
- false
- false
- 1000
false
false
-
-
-
-
+
org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern
.*/servlet-api-[^/]*\.jar$
-
+
+
+
+
+ /contexts
+ 0
+
+
+