This repository has been archived by the owner on Jan 3, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable an external index (Solr) to receive a minimal index-update
document (Solr document) based on messaging emitted from an F4 repository Implement customizable search index design (https://wiki.duraspace.org/display/FF/Design+-+Customizable+Search+Index) Also, allow asynchronous or synchronous indexing patterns for both Solr and SPARQL indexing.
- Loading branch information
Showing
43 changed files
with
1,808 additions
and
568 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ FedoraRepository/ | |
indexes/ | ||
ObjectStore/ | ||
*/.cache | ||
**/data | ||
.cache | ||
.DS_Store | ||
*~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...o-jms-indexer-core/src/main/java/org/fcrepo/indexer/AbsentTransformPropertyException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright 2013 DuraSpace, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.fcrepo.indexer; | ||
|
||
/** | ||
* Indicates that a resource was not designated for named-field indexing. | ||
* Typically this would be because there has been assigned no appropriate | ||
* transformation. | ||
* | ||
* @author ajs6f | ||
* @date Dec 4, 2013 | ||
*/ | ||
public class AbsentTransformPropertyException extends Exception { | ||
|
||
/** | ||
* | ||
*/ | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* @param msg | ||
*/ | ||
public AbsentTransformPropertyException(final String msg) { | ||
super(msg); | ||
} | ||
|
||
} |
95 changes: 95 additions & 0 deletions
95
fcrepo-jms-indexer-core/src/main/java/org/fcrepo/indexer/AsynchIndexer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/** | ||
* Copyright 2013 DuraSpace, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.fcrepo.indexer; | ||
|
||
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
import java.io.IOException; | ||
import java.io.Reader; | ||
|
||
import org.slf4j.Logger; | ||
|
||
import com.google.common.util.concurrent.ListenableFuture; | ||
import com.google.common.util.concurrent.ListenableFutureTask; | ||
import com.google.common.util.concurrent.ListeningExecutorService; | ||
|
||
/** | ||
* An {@link Indexer} that executes its operation asynchronously. | ||
* | ||
* @author ajs6f | ||
* @date Dec 8, 2013 | ||
* @param <T> the type of response to expect from an operation | ||
*/ | ||
public abstract class AsynchIndexer<T> implements Indexer { | ||
|
||
private static final Logger LOGGER = getLogger(AsynchIndexer.class); | ||
|
||
/** | ||
* @return The {@link ListeningExecutorService} to use for operation. | ||
*/ | ||
public abstract ListeningExecutorService executorService(); | ||
|
||
@Override | ||
public ListenableFuture<T> update(final String identifier, | ||
final Reader content) throws IOException { | ||
LOGGER.debug("Received update for identifier: {}", identifier); | ||
|
||
final ListenableFutureTask<T> task = updateSynch(identifier, content); | ||
task.addListener(new Runnable() { | ||
@Override | ||
public void run() { | ||
synchronized (this) { | ||
notifyAll(); | ||
} | ||
} | ||
}, executorService()); | ||
executorService().submit(task); | ||
return task; | ||
} | ||
|
||
@Override | ||
public ListenableFuture<T> remove(final String identifier) | ||
throws IOException { | ||
LOGGER.debug("Received remove for identifier: {}", identifier); | ||
final ListenableFutureTask<T> task = removeSynch(identifier); | ||
task.addListener(new Runnable() { | ||
@Override | ||
public void run() { | ||
synchronized (this) { | ||
notifyAll(); | ||
} | ||
} | ||
}, executorService()); | ||
executorService().submit(task); | ||
return task; | ||
} | ||
|
||
/** | ||
* @param identifier | ||
* @return | ||
*/ | ||
public abstract ListenableFutureTask<T> removeSynch(final String identifier); | ||
|
||
/** | ||
* @param identifier | ||
* @param content | ||
* @return | ||
*/ | ||
public abstract ListenableFutureTask<T> updateSynch(final String identifier, | ||
final Reader content); | ||
|
||
} |
73 changes: 73 additions & 0 deletions
73
fcrepo-jms-indexer-core/src/main/java/org/fcrepo/indexer/CachingRetriever.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* Copyright 2013 DuraSpace, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/** | ||
* | ||
*/ | ||
package org.fcrepo.indexer; | ||
|
||
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import org.apache.http.HttpException; | ||
import org.apache.http.HttpResponse; | ||
import org.apache.http.client.ClientProtocolException; | ||
import org.slf4j.Logger; | ||
|
||
|
||
/** | ||
* {@link IndexableContentRetriever} that caches its results. | ||
* | ||
* @author ajs6f | ||
* @date Dec 7, 2013 | ||
*/ | ||
public abstract class CachingRetriever implements IndexableContentRetriever { | ||
|
||
private Boolean cached = false; | ||
|
||
private byte[] cache; | ||
|
||
private static final Logger LOGGER = getLogger(CachingRetriever.class); | ||
|
||
|
||
/* (non-Javadoc) | ||
* @see java.util.concurrent.Callable#call() | ||
*/ | ||
@Override | ||
public InputStream call() throws ClientProtocolException, IOException, | ||
AbsentTransformPropertyException, HttpException { | ||
if (cached) { | ||
LOGGER.debug("Returning cached content..."); | ||
return new ByteArrayInputStream(cache); | ||
} | ||
LOGGER.debug("Retrieving uncached content..."); | ||
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { | ||
retrieveHttpResponse().getEntity().writeTo(out); | ||
cache = out.toByteArray(); | ||
} | ||
cached = true; | ||
LOGGER.debug("Retrieved cache-able content:\n{}", new String(cache)); | ||
return new ByteArrayInputStream(cache); | ||
} | ||
|
||
protected abstract HttpResponse retrieveHttpResponse() | ||
throws AbsentTransformPropertyException, | ||
ClientProtocolException, IOException, HttpException; | ||
|
||
} |
Oops, something went wrong.