-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/service/SolrServiceImpl.java # Conflicts: # shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/service/SolrServiceImpl.java
- Loading branch information
1 parent
b8887ad
commit 748fd64
Showing
7 changed files
with
118 additions
and
5 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
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
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
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,20 @@ | ||
#!/bin/bash | ||
|
||
WAIT_TIME=300 | ||
|
||
echo "Waiting for the solr container to be reachable..." | ||
|
||
# Try pinging the solr container | ||
while ! ping -c 1 -W 1 "solr" > /dev/null 2>&1; do | ||
echo "Container solr is not reachable, retrying..." | ||
sleep 5 | ||
|
||
# Decrement wait time and exit if it reaches zero | ||
WAIT_TIME=$((WAIT_TIME - 1)) | ||
if [ "$WAIT_TIME" -le 0 ]; then | ||
echo "Error : Timeout waiting for container solr to become reachable." | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "Container solr reached, launching container datasets." |
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,18 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
( | ||
# Compare old and new solr scheme.xml | ||
set -e | ||
cd /etc/shanoir-core-template | ||
for file in $(find . -maxdepth 1 -type f); do | ||
cmp -- "$file" "/var/solr/data/shanoir/$file" | ||
done | ||
echo "Solr index is up-to-date, no rebuild needed" | ||
) || ( | ||
# If different, remove last index | ||
echo 'Deleting /var/solr/data (not up-to-date with the template), the index has to be rebuilt' | ||
rm -rf /var/solr/data | ||
) | ||
|
||
$@ |
41 changes: 41 additions & 0 deletions
41
shanoir-ng-datasets/src/main/java/org/shanoir/ng/ShanoirDatasetIndexation.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 @@ | ||
package org.shanoir.ng; | ||
|
||
import org.apache.solr.client.solrj.SolrClient; | ||
import org.apache.solr.client.solrj.SolrQuery; | ||
import org.shanoir.ng.solr.service.SolrServiceImpl; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.ApplicationArguments; | ||
import org.springframework.boot.ApplicationRunner; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Objects; | ||
|
||
|
||
@Component | ||
@Profile("!test") | ||
public class ShanoirDatasetIndexation implements ApplicationRunner { | ||
|
||
@Autowired | ||
private SolrClient solrClient; | ||
|
||
@Autowired | ||
private SolrServiceImpl solrServiceImpl; | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(ShanoirDatasetIndexation.class); | ||
|
||
@Override | ||
public void run(ApplicationArguments args) throws Exception { | ||
SolrQuery q = new SolrQuery("*:*"); | ||
q.setRows(0); // don't actually request any data | ||
if(Objects.nonNull(solrClient.query(q)) && Objects.equals(0L, solrClient.query(q).getResults().getNumFound())){ | ||
LOG.info("Solr index empty. Re-indexing..."); | ||
solrServiceImpl.indexAllNoAuth(); | ||
LOG.info("Solr indexation complete."); | ||
} else { | ||
LOG.info("Solr index already complete, no re-indexation required."); | ||
} | ||
} | ||
} |
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