SOLR-8995: Replace anonymous implementations of SAM interfaces with Lambdas

This commit is contained in:
Noble Paul 2016-04-15 18:58:08 +05:30
parent 6c74669375
commit f82a27aa5c
18 changed files with 25 additions and 93 deletions

View File

@ -19,5 +19,5 @@ package org.apache.solr.cloud.rule;
import java.util.Map; import java.util.Map;
public interface RemoteCallback { public interface RemoteCallback {
public void remoteCallback(SnitchContext ctx, Map<String, Object> returnedVal) ; void remoteCallback(SnitchContext ctx, Map<String, Object> returnedVal);
} }

View File

@ -24,5 +24,5 @@ import org.apache.solr.request.SolrRequestHandler;
public interface NestedRequestHandler { public interface NestedRequestHandler {
/** Return a Requestandler to handle a subpath from the path this handler is registered. /** Return a Requestandler to handle a subpath from the path this handler is registered.
*/ */
public SolrRequestHandler getSubHandler(String subPath); SolrRequestHandler getSubHandler(String subPath);
} }

View File

@ -794,14 +794,9 @@ public class QueryComponent extends SearchComponent
rb.resultIds = new HashMap<>(); rb.resultIds = new HashMap<>();
} }
EndResultTransformer.SolrDocumentSource solrDocumentSource = new EndResultTransformer.SolrDocumentSource() { EndResultTransformer.SolrDocumentSource solrDocumentSource = doc -> {
ShardDoc solrDoc = (ShardDoc) doc;
@Override return rb.retrievedDocuments.get(solrDoc.id);
public SolrDocument retrieve(ScoreDoc doc) {
ShardDoc solrDoc = (ShardDoc) doc;
return rb.retrievedDocuments.get(solrDoc.id);
}
}; };
EndResultTransformer endResultTransformer; EndResultTransformer endResultTransformer;
if (groupSpec.isMain()) { if (groupSpec.isMain()) {

View File

@ -42,7 +42,7 @@ public interface EndResultTransformer {
* Abstracts the source for {@link SolrDocument} instances. * Abstracts the source for {@link SolrDocument} instances.
* The source of documents is different for a distributed search than local search * The source of documents is different for a distributed search than local search
*/ */
public interface SolrDocumentSource { interface SolrDocumentSource {
SolrDocument retrieve(ScoreDoc doc); SolrDocument retrieve(ScoreDoc doc);

View File

@ -140,7 +140,7 @@ public abstract class SolrCoreState {
public interface IndexWriterCloser { public interface IndexWriterCloser {
public void closeWriter(IndexWriter writer) throws IOException; void closeWriter(IndexWriter writer) throws IOException;
} }
public abstract void doRecovery(CoreContainer cc, CoreDescriptor cd); public abstract void doRecovery(CoreContainer cc, CoreDescriptor cd);

View File

@ -46,12 +46,7 @@ public class TestCryptoKeys extends AbstractFullDistribZkTestBase {
private void setupHarnesses() { private void setupHarnesses() {
for (final SolrClient client : clients) { for (final SolrClient client : clients) {
RestTestHarness harness = new RestTestHarness(new RESTfulServerProvider() { RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient) client).getBaseURL());
@Override
public String getBaseURL() {
return ((HttpSolrClient) client).getBaseURL();
}
});
restTestHarnesses.add(harness); restTestHarnesses.add(harness);
} }
} }

View File

@ -45,12 +45,7 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
private void setupHarnesses() { private void setupHarnesses() {
for (final SolrClient client : clients) { for (final SolrClient client : clients) {
RestTestHarness harness = new RestTestHarness(new RESTfulServerProvider() { RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient)client).getBaseURL());
@Override
public String getBaseURL() {
return ((HttpSolrClient)client).getBaseURL();
}
});
restTestHarnesses.add(harness); restTestHarnesses.add(harness);
} }
} }

View File

@ -60,12 +60,7 @@ public class TestConfigReload extends AbstractFullDistribZkTestBase {
private void setupHarnesses() { private void setupHarnesses() {
for (final SolrClient client : clients) { for (final SolrClient client : clients) {
RestTestHarness harness = new RestTestHarness(new RESTfulServerProvider() { RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient)client).getBaseURL());
@Override
public String getBaseURL() {
return ((HttpSolrClient)client).getBaseURL();
}
});
restTestHarnesses.add(harness); restTestHarnesses.add(harness);
} }
} }

View File

@ -43,12 +43,7 @@ public class TestReqParamsAPI extends AbstractFullDistribZkTestBase {
private void setupHarnesses() { private void setupHarnesses() {
for (final SolrClient client : clients) { for (final SolrClient client : clients) {
RestTestHarness harness = new RestTestHarness(new RESTfulServerProvider() { RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient) client).getBaseURL());
@Override
public String getBaseURL() {
return ((HttpSolrClient) client).getBaseURL();
}
});
restTestHarnesses.add(harness); restTestHarnesses.add(harness);
} }
} }

View File

@ -49,12 +49,7 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
private void setupHarnesses() { private void setupHarnesses() {
for (final SolrClient client : clients) { for (final SolrClient client : clients) {
RestTestHarness harness = new RestTestHarness(new RESTfulServerProvider() { RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient)client).getBaseURL());
@Override
public String getBaseURL() {
return ((HttpSolrClient)client).getBaseURL();
}
});
restTestHarnesses.add(harness); restTestHarnesses.add(harness);
} }
} }

View File

@ -61,12 +61,7 @@ public class TestSolrConfigHandlerConcurrent extends AbstractFullDistribZkTestBa
private void setupHarnesses() { private void setupHarnesses() {
for (final SolrClient client : clients) { for (final SolrClient client : clients) {
RestTestHarness harness = new RestTestHarness(new RESTfulServerProvider() { RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient)client).getBaseURL());
@Override
public String getBaseURL() {
return ((HttpSolrClient)client).getBaseURL();
}
});
restTestHarnesses.add(harness); restTestHarnesses.add(harness);
} }
} }

View File

@ -60,12 +60,7 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
private void setupHarnesses() { private void setupHarnesses() {
for (final SolrClient client : clients) { for (final SolrClient client : clients) {
RestTestHarness harness = new RestTestHarness(new RESTfulServerProvider() { RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient)client).getBaseURL());
@Override
public String getBaseURL() {
return ((HttpSolrClient)client).getBaseURL();
}
});
restTestHarnesses.add(harness); restTestHarnesses.add(harness);
} }
} }

View File

@ -90,12 +90,7 @@ public class TestCloudManagedSchemaConcurrent extends AbstractFullDistribZkTestB
private void setupHarnesses() { private void setupHarnesses() {
for (final SolrClient client : clients) { for (final SolrClient client : clients) {
RestTestHarness harness = new RestTestHarness(new RESTfulServerProvider() { RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient)client).getBaseURL());
@Override
public String getBaseURL() {
return ((HttpSolrClient)client).getBaseURL();
}
});
restTestHarnesses.add(harness); restTestHarnesses.add(harness);
} }
} }
@ -352,11 +347,7 @@ public class TestCloudManagedSchemaConcurrent extends AbstractFullDistribZkTestB
final String coreUrl = (new ZkCoreNodeProps(shard1Leader)).getCoreUrl(); final String coreUrl = (new ZkCoreNodeProps(shard1Leader)).getCoreUrl();
assertNotNull(coreUrl); assertNotNull(coreUrl);
RestTestHarness harness = new RestTestHarness(new RESTfulServerProvider() { RestTestHarness harness = new RestTestHarness(() -> coreUrl.endsWith("/") ? coreUrl.substring(0, coreUrl.length()-1) : coreUrl);
public String getBaseURL() {
return coreUrl.endsWith("/") ? coreUrl.substring(0, coreUrl.length()-1) : coreUrl;
}
});
try { try {
addFieldTypePut(harness, "fooInt", 15); addFieldTypePut(harness, "fooInt", 15);
} finally { } finally {
@ -413,11 +404,7 @@ public class TestCloudManagedSchemaConcurrent extends AbstractFullDistribZkTestB
*/ */
protected void validateZkVersion(Replica replica, int schemaZkVersion, int waitSecs, boolean retry) throws Exception { protected void validateZkVersion(Replica replica, int schemaZkVersion, int waitSecs, boolean retry) throws Exception {
final String replicaUrl = (new ZkCoreNodeProps(replica)).getCoreUrl(); final String replicaUrl = (new ZkCoreNodeProps(replica)).getCoreUrl();
RestTestHarness testHarness = new RestTestHarness(new RESTfulServerProvider() { RestTestHarness testHarness = new RestTestHarness(() -> replicaUrl.endsWith("/") ? replicaUrl.substring(0, replicaUrl.length()-1) : replicaUrl);
public String getBaseURL() {
return replicaUrl.endsWith("/") ? replicaUrl.substring(0, replicaUrl.length()-1) : replicaUrl;
}
});
try { try {
long waitMs = waitSecs * 1000L; long waitMs = waitSecs * 1000L;
if (waitMs > 0) Thread.sleep(waitMs); // wait a moment for the zk watcher to fire if (waitMs > 0) Thread.sleep(waitMs); // wait a moment for the zk watcher to fire

View File

@ -81,12 +81,7 @@ public class TestCloudSchemaless extends AbstractFullDistribZkTestBase {
private void setupHarnesses() { private void setupHarnesses() {
for (final SolrClient client : clients) { for (final SolrClient client : clients) {
RestTestHarness harness = new RestTestHarness(new RESTfulServerProvider() { RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient)client).getBaseURL());
@Override
public String getBaseURL() {
return ((HttpSolrClient)client).getBaseURL();
}
});
restTestHarnesses.add(harness); restTestHarnesses.add(harness);
} }
} }

View File

@ -49,12 +49,7 @@ public class TestNamedUpdateProcessors extends AbstractFullDistribZkTestBase {
private void setupHarnesses() { private void setupHarnesses() {
for (final SolrClient client : clients) { for (final SolrClient client : clients) {
RestTestHarness harness = new RestTestHarness(new RESTfulServerProvider() { RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient) client).getBaseURL());
@Override
public String getBaseURL() {
return ((HttpSolrClient) client).getBaseURL();
}
});
restTestHarnesses.add(harness); restTestHarnesses.add(harness);
} }
} }

View File

@ -898,7 +898,7 @@ public class JavaBinCodec {
* <p> * <p>
* Implementors of this interface write a method to serialize a given object using an existing {@link JavaBinCodec} * Implementors of this interface write a method to serialize a given object using an existing {@link JavaBinCodec}
*/ */
public static interface ObjectResolver { public interface ObjectResolver {
/** /**
* Examine and attempt to serialize the given object, using a {@link JavaBinCodec} to write it to a stream. * Examine and attempt to serialize the given object, using a {@link JavaBinCodec} to write it to a stream.
* *
@ -907,12 +907,12 @@ public class JavaBinCodec {
* @return the object {@code o} itself if it could not be serialized, or {@code null} if the whole object was successfully serialized. * @return the object {@code o} itself if it could not be serialized, or {@code null} if the whole object was successfully serialized.
* @see JavaBinCodec * @see JavaBinCodec
*/ */
public Object resolve(Object o, JavaBinCodec codec) throws IOException; Object resolve(Object o, JavaBinCodec codec) throws IOException;
} }
public interface WritableDocFields { public interface WritableDocFields {
public boolean isWritable(String name); boolean isWritable(String name);
public boolean wantsAllFields(); boolean wantsAllFields();
} }

View File

@ -16,5 +16,5 @@
*/ */
package org.apache.solr.util; package org.apache.solr.util;
public interface RESTfulServerProvider { public interface RESTfulServerProvider {
public String getBaseURL(); String getBaseURL();
} }

View File

@ -51,12 +51,7 @@ abstract public class RestTestBase extends SolrJettyTestBase {
createJetty(solrHome, configFile, schemaFile, context, stopAtShutdown, extraServlets); createJetty(solrHome, configFile, schemaFile, context, stopAtShutdown, extraServlets);
restTestHarness = new RestTestHarness(new RESTfulServerProvider() { restTestHarness = new RestTestHarness(() -> jetty.getBaseUrl().toString() + "/" + DEFAULT_TEST_CORENAME);
@Override
public String getBaseURL() {
return jetty.getBaseUrl().toString() + "/" + DEFAULT_TEST_CORENAME;
}
});
} }
/** Validates an update XML String is successful /** Validates an update XML String is successful