Upgrading to Solr 5.1.0, fixing empty javadoc, and cleaning up variable naming

This commit is contained in:
bbende 2015-04-16 22:09:11 -04:00
parent 751d601a92
commit a9ef5ec1bc
4 changed files with 22 additions and 20 deletions

View File

@ -241,7 +241,7 @@ public class GetSolr extends SolrProcessor {
lastEndDatedRef.set(currDate); lastEndDatedRef.set(currDate);
writeLastEndDate(); writeLastEndDate();
} catch (SolrServerException e) { } catch (SolrServerException | IOException e) {
context.yield(); context.yield();
session.rollback(); session.rollback();
logger.error("Failed to execute query {} due to {}", new Object[]{query, e}, e); logger.error("Failed to execute query {} due to {}", new Object[]{query, e}, e);

View File

@ -89,11 +89,11 @@ public abstract class SolrProcessor extends AbstractProcessor {
if (SOLR_TYPE_STANDARD.equals(context.getProperty(SOLR_TYPE).getValue())) { if (SOLR_TYPE_STANDARD.equals(context.getProperty(SOLR_TYPE).getValue())) {
return new HttpSolrClient(context.getProperty(SOLR_LOCATION).getValue()); return new HttpSolrClient(context.getProperty(SOLR_LOCATION).getValue());
} else { } else {
CloudSolrClient cloudSolrServer = new CloudSolrClient( CloudSolrClient cloudSolrClient = new CloudSolrClient(
context.getProperty(SOLR_LOCATION).getValue()); context.getProperty(SOLR_LOCATION).getValue());
cloudSolrServer.setDefaultCollection( cloudSolrClient.setDefaultCollection(
context.getProperty(COLLECTION).evaluateAttributeExpressions().getValue()); context.getProperty(COLLECTION).evaluateAttributeExpressions().getValue());
return cloudSolrServer; return cloudSolrClient;
} }
} }
@ -101,7 +101,7 @@ public abstract class SolrProcessor extends AbstractProcessor {
* Returns the {@link org.apache.solr.client.solrj.SolrClient} that was created by the * Returns the {@link org.apache.solr.client.solrj.SolrClient} that was created by the
* {@link #createSolrClient(org.apache.nifi.processor.ProcessContext)} method * {@link #createSolrClient(org.apache.nifi.processor.ProcessContext)} method
* *
* @return * @return an HttpSolrClient or CloudSolrClient
*/ */
protected final SolrClient getSolrClient() { protected final SolrClient getSolrClient() {
return solrClient; return solrClient;

View File

@ -26,6 +26,7 @@ import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.Mockito; import org.mockito.Mockito;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -95,7 +96,7 @@ public class TestPutSolrContentStream {
verifySolrDocuments(proc.getSolrClient(), Arrays.asList(expectedDoc1, expectedDoc2)); verifySolrDocuments(proc.getSolrClient(), Arrays.asList(expectedDoc1, expectedDoc2));
} finally { } finally {
try { proc.getSolrClient().shutdown(); } catch (Exception e) { } try { proc.getSolrClient().close(); } catch (Exception e) { }
} }
} }
@ -123,7 +124,7 @@ public class TestPutSolrContentStream {
verifySolrDocuments(proc.getSolrClient(), Arrays.asList(expectedDoc1, expectedDoc2)); verifySolrDocuments(proc.getSolrClient(), Arrays.asList(expectedDoc1, expectedDoc2));
} finally { } finally {
try { proc.getSolrClient().shutdown(); } catch (Exception e) { } try { proc.getSolrClient().close(); } catch (Exception e) { }
} }
} }
@ -145,7 +146,7 @@ public class TestPutSolrContentStream {
verifySolrDocuments(proc.getSolrClient(), Arrays.asList(expectedDoc1, expectedDoc2)); verifySolrDocuments(proc.getSolrClient(), Arrays.asList(expectedDoc1, expectedDoc2));
} finally { } finally {
try { proc.getSolrClient().shutdown(); } catch (Exception e) { } try { proc.getSolrClient().close(); } catch (Exception e) { }
} }
} }
@ -167,7 +168,7 @@ public class TestPutSolrContentStream {
verifySolrDocuments(proc.getSolrClient(), Arrays.asList(expectedDoc1, expectedDoc2)); verifySolrDocuments(proc.getSolrClient(), Arrays.asList(expectedDoc1, expectedDoc2));
} finally { } finally {
try { proc.getSolrClient().shutdown(); } catch (Exception e) { } try { proc.getSolrClient().close(); } catch (Exception e) { }
} }
} }
@ -183,7 +184,7 @@ public class TestPutSolrContentStream {
runner.run(); runner.run();
runner.assertAllFlowFilesTransferred(PutSolrContentStream.REL_CONNECTION_FAILURE, 1); runner.assertAllFlowFilesTransferred(PutSolrContentStream.REL_CONNECTION_FAILURE, 1);
verify(proc.getSolrClient(), times(1)).request(any(SolrRequest.class)); verify(proc.getSolrClient(), times(1)).request(any(SolrRequest.class), eq((String)null));
} }
} }
@ -199,7 +200,7 @@ public class TestPutSolrContentStream {
runner.run(); runner.run();
runner.assertAllFlowFilesTransferred(PutSolrContentStream.REL_FAILURE, 1); runner.assertAllFlowFilesTransferred(PutSolrContentStream.REL_FAILURE, 1);
verify(proc.getSolrClient(), times(1)).request(any(SolrRequest.class)); verify(proc.getSolrClient(), times(1)).request(any(SolrRequest.class), eq((String)null));
} }
} }
@ -216,7 +217,7 @@ public class TestPutSolrContentStream {
runner.run(); runner.run();
runner.assertAllFlowFilesTransferred(PutSolrContentStream.REL_FAILURE, 1); runner.assertAllFlowFilesTransferred(PutSolrContentStream.REL_FAILURE, 1);
verify(proc.getSolrClient(), times(1)).request(any(SolrRequest.class)); verify(proc.getSolrClient(), times(1)).request(any(SolrRequest.class), eq((String)null));
} }
} }
@ -244,7 +245,7 @@ public class TestPutSolrContentStream {
*/ */
private class ExceptionThrowingProcessor extends PutSolrContentStream { private class ExceptionThrowingProcessor extends PutSolrContentStream {
private SolrClient mockSolrServer; private SolrClient mockSolrClient;
private Throwable throwable; private Throwable throwable;
public ExceptionThrowingProcessor(Throwable throwable) { public ExceptionThrowingProcessor(Throwable throwable) {
@ -253,15 +254,16 @@ public class TestPutSolrContentStream {
@Override @Override
protected SolrClient createSolrClient(ProcessContext context) { protected SolrClient createSolrClient(ProcessContext context) {
mockSolrServer = Mockito.mock(SolrClient.class); mockSolrClient = Mockito.mock(SolrClient.class);
try { try {
when(mockSolrServer.request(any(SolrRequest.class))).thenThrow(throwable); when(mockSolrClient.request(any(SolrRequest.class),
eq((String)null))).thenThrow(throwable);
} catch (SolrServerException e) { } catch (SolrServerException e) {
Assert.fail(e.getMessage()); Assert.fail(e.getMessage());
} catch (IOException e) { } catch (IOException e) {
Assert.fail(e.getMessage()); Assert.fail(e.getMessage());
} }
return mockSolrServer; return mockSolrClient;
} }
} }
@ -272,7 +274,7 @@ public class TestPutSolrContentStream {
private class EmbeddedSolrServerProcessor extends PutSolrContentStream { private class EmbeddedSolrServerProcessor extends PutSolrContentStream {
private String coreName; private String coreName;
private SolrClient embeddedSolrServer; private SolrClient embeddedSolrClient;
public EmbeddedSolrServerProcessor(String coreName) { public EmbeddedSolrServerProcessor(String coreName) {
this.coreName = coreName; this.coreName = coreName;
@ -285,14 +287,14 @@ public class TestPutSolrContentStream {
.getCodeSource().getLocation().getFile() .getCodeSource().getLocation().getFile()
+ "../../target"; + "../../target";
embeddedSolrServer = EmbeddedSolrServerFactory.create( embeddedSolrClient = EmbeddedSolrServerFactory.create(
EmbeddedSolrServerFactory.DEFAULT_SOLR_HOME, EmbeddedSolrServerFactory.DEFAULT_SOLR_HOME,
EmbeddedSolrServerFactory.DEFAULT_CORE_HOME, EmbeddedSolrServerFactory.DEFAULT_CORE_HOME,
coreName, relPath); coreName, relPath);
} catch (IOException e) { } catch (IOException e) {
Assert.fail(e.getMessage()); Assert.fail(e.getMessage());
} }
return embeddedSolrServer; return embeddedSolrClient;
} }
} }

View File

@ -28,7 +28,7 @@
<description>A bundle of processors that can store and retrieve data from Apache Solr</description> <description>A bundle of processors that can store and retrieve data from Apache Solr</description>
<properties> <properties>
<solr.version>5.0.0</solr.version> <solr.version>5.1.0</solr.version>
</properties> </properties>
<modules> <modules>