Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Backend
Commits
5627ea21
Commit
5627ea21
authored
Jan 02, 2015
by
Matija Obreza
Browse files
Use scrollable result to reindex ES instead of paginated queries
parent
2d846a15
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/servlet/controller/AdminController.java
View file @
5627ea21
...
...
@@ -46,9 +46,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.cache.Cache
;
import
org.springframework.cache.CacheManager
;
import
org.springframework.core.task.TaskExecutor
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.elasticsearch.core.query.IndexQuery
;
import
org.springframework.jdbc.core.RowCallbackHandler
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
...
...
@@ -151,34 +148,14 @@ public class AdminController {
AppliedFilters
filters
=
mapper
.
readValue
(
jsonFilter
,
AppliedFilters
.
class
);
int
page
=
0
,
size
=
100
;
List
<
IndexQuery
>
queries
=
new
ArrayList
<
IndexQuery
>();
do
{
LOG
.
info
(
"Reindexing progress "
+
(
page
*
size
));
queries
.
clear
();
Page
<
Accession
>
accessions
=
filterService
.
listAccessions
(
filters
,
new
PageRequest
(
page
,
size
));
if
(!
accessions
.
hasContent
())
{
LOG
.
info
(
"No more content"
);
break
;
}
page
++;
for
(
Accession
a
:
accessions
)
{
elasticUpdater
.
update
(
Accession
.
class
,
a
.
getId
());
}
genesysLowlevelRepository
.
listAccessionIds
(
filters
,
null
,
new
RowCallbackHandler
()
{
@Override
public
void
processRow
(
ResultSet
rs
)
throws
SQLException
{
long
accessionId
=
rs
.
getLong
(
1
);
if
(
slow
)
{
try
{
Thread
.
sleep
(
50
);
}
catch
(
InterruptedException
e
)
{
break
;
}
elasticUpdater
.
update
(
Accession
.
class
,
accessionId
);
}
}
while
(
true
);
});
LOG
.
info
(
"Done."
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment