Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
1cebd474
Commit
1cebd474
authored
Aug 13, 2020
by
Piotr Gawron
Browse files
concurrency issue fixed
parent
0cd2d041
Pipeline
#31036
passed with stage
in 15 minutes and 29 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
1cebd474
...
...
@@ -8,6 +8,8 @@ minerva (15.0.3) stable; urgency=medium
*
Bug
fix
:
"bqbiol:hasTaxon"
relation
type
is
not
supported
by
CellDedigner
and
is
now
transformed
during
export
into
something
readable
by
CellDesigner
(#
1281
)
*
Bug
fix
:
concurrency
issue
that
could
happen
rarely
on
first
search
of
the
map
and
put
the
project
into
"unsearchable"
state
is
fixed
(#
1333
)
--
Piotr
Gawron
<
piotr
.
gawron
@
uni
.
lu
>
Wed
,
8
Jul
2020
16
:
00
:
00
+
0200
...
...
service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java
View file @
1cebd474
...
...
@@ -111,7 +111,7 @@ public class SearchService implements ISearchService {
addSearchPrefix
(
"unknown"
,
Unknown
.
class
);
}
/**
/**
* Adds search prefix for an element class.
*
* @param prefix
...
...
@@ -158,10 +158,13 @@ public class SearchService implements ISearchService {
List
<
SearchResult
>
sortedResults
=
new
ArrayList
<>();
for
(
Element
alias
:
aliases
)
{
if
(
type
.
isAssignableFrom
(
alias
.
getClass
()))
{
List
<
SearchIndex
>
indexes
=
alias
.
getSearchIndexes
();
if
(
indexes
.
size
()
==
0
)
{
indexes
=
searchIndexer
.
createIndexForAlias
(
alias
);
alias
.
setSearchIndexes
(
indexes
);
List
<
SearchIndex
>
indexes
;
synchronized
(
alias
)
{
indexes
=
alias
.
getSearchIndexes
();
if
(
indexes
.
size
()
==
0
)
{
indexes
=
searchIndexer
.
createIndexForAlias
(
alias
);
alias
.
setSearchIndexes
(
indexes
);
}
}
for
(
SearchIndex
searchIndex
:
indexes
)
{
double
score
=
searchIndexer
.
match
(
query
,
searchIndex
);
...
...
@@ -536,7 +539,7 @@ public class SearchService implements ISearchService {
this
.
searchHistoryService
=
searchHistoryService
;
}
/**
/**
* Private class that defines internal search result element. Contains reference
* to original result and match score of the result.
*
...
...
service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java
View file @
1cebd474
package
lcsb.mapviewer.services.impl
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
patch
;
import
java.awt.geom.Point2D
;
import
java.util.*
;
import
org.apache.commons.lang.mutable.MutableBoolean
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.junit.*
;
import
org.mockito.Mockito
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.web.servlet.RequestBuilder
;
import
lcsb.mapviewer.common.Configuration
;
import
lcsb.mapviewer.model.Project
;
...
...
@@ -77,6 +82,44 @@ public class SearchServiceTest extends ServiceTestFunctions {
assertEquals
(
count
+
1
,
count2
);
}
@Test
public
void
concurrencyIssueWithIndexing
()
throws
Exception
{
Model
model
=
createFullModel
();
Species
species
=
new
GenericProtein
(
"id"
);
species
.
setName
(
"Xxx"
);
species
.
setFullName
(
"xxx yyy"
);
for
(
int
i
=
0
;
i
<
100000
;
i
++)
{
species
.
addSynonym
(
"syn"
+
i
);
species
.
addFormerSymbol
(
"symb"
+
i
);
}
SearchService
service
=
new
SearchService
(
null
,
null
);
List
<
Thread
>
threads
=
new
ArrayList
<>();
MutableBoolean
exceptionHappened
=
new
MutableBoolean
(
false
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
Thread
thread
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
service
.
searchByIndexedQuery
(
model
,
"symbsfdsdg999"
,
100
,
true
,
GenericProtein
.
class
);
}
catch
(
Exception
e
)
{
exceptionHappened
.
setValue
(
true
);
e
.
printStackTrace
();
}
}
});
threads
.
add
(
thread
);
thread
.
start
();
}
for
(
Thread
thread
:
threads
)
{
thread
.
join
();
}
assertFalse
(
exceptionHappened
.
booleanValue
());
}
@Test
public
void
testSearchByName2
()
throws
Exception
{
Model
model
=
createFullModel
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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