Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Partition
Commits
f35758fa
Commit
f35758fa
authored
Jan 07, 2021
by
Alok Joshi
Browse files
update the cache list instead of dropping it
parent
18760615
Pipeline
#20999
failed with stages
in 36 minutes and 45 seconds
Changes
2
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
partition-core/src/main/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImpl.java
View file @
f35758fa
...
...
@@ -50,7 +50,7 @@ public class CachedPartitionServiceImpl implements IPartitionService {
if
(
pi
!=
null
)
{
partitionServiceCache
.
put
(
partitionId
,
partitionInfo
);
partitionListCache
.
clearAll
(
);
partitionListCache
.
get
(
PARTITION_LIST_KEY
).
add
(
partitionId
);
}
return
pi
;
...
...
@@ -87,7 +87,7 @@ public class CachedPartitionServiceImpl implements IPartitionService {
if
(
partitionService
.
deletePartition
(
partitionId
))
{
if
(
partitionServiceCache
.
get
(
partitionId
)
!=
null
)
{
partitionServiceCache
.
delete
(
partitionId
);
partitionListCache
.
clearAll
(
);
partitionListCache
.
get
(
PARTITION_LIST_KEY
).
remove
(
partitionId
);
}
return
true
;
...
...
partition-core/src/test/java/org/opengroup/osdu/partition/service/CachedPartitionServiceImplTest.java
View file @
f35758fa
...
...
@@ -44,20 +44,25 @@ public class CachedPartitionServiceImplTest {
@InjectMocks
private
CachedPartitionServiceImpl
cachedPartitionServiceImpl
;
private
static
final
String
PARTITION_LIST_KEY
=
"getAllPartitions"
;
@Test
public
void
createPartitionSucceed
()
{
String
partId
=
"key"
;
List
<
String
>
partitions
=
new
ArrayList
<>();
PartitionInfo
newPi
=
PartitionInfo
.
builder
().
build
();
PartitionInfo
retPi
=
PartitionInfo
.
builder
().
build
();
when
(
partitionServiceImpl
.
createPartition
(
partId
,
newPi
)).
thenReturn
(
retPi
);
when
(
partitionListCache
.
get
(
PARTITION_LIST_KEY
)).
thenReturn
(
partitions
);
cachedPartitionServiceImpl
.
createPartition
(
partId
,
newPi
);
verify
(
partitionServiceImpl
,
times
(
1
)).
createPartition
(
partId
,
newPi
);
verify
(
partitionServiceCache
,
times
(
1
)).
put
(
partId
,
retPi
);
verify
(
partitionListCache
,
times
(
1
)).
clearAll
(
);
verify
(
partitionListCache
,
times
(
1
)).
get
(
PARTITION_LIST_KEY
);
}
@Test
...
...
@@ -72,7 +77,7 @@ public class CachedPartitionServiceImplTest {
verify
(
partitionServiceImpl
,
times
(
1
)).
createPartition
(
partId
,
newPi
);
verify
(
partitionServiceCache
,
times
(
0
)).
put
(
any
(),
any
());
verify
(
partitionListCache
,
times
(
0
)).
clearAll
(
);
verify
(
partitionListCache
,
times
(
0
)).
get
(
PARTITION_LIST_KEY
);
verify
(
partitionServiceCache
,
times
(
1
)).
get
(
any
());
}
...
...
@@ -125,15 +130,18 @@ public class CachedPartitionServiceImplTest {
String
partId
=
"key"
;
PartitionInfo
retPi
=
PartitionInfo
.
builder
().
build
();
List
<
String
>
partitions
=
new
ArrayList
<>();
when
(
partitionServiceImpl
.
deletePartition
(
partId
)).
thenReturn
(
true
);
when
(
partitionServiceCache
.
get
(
partId
)).
thenReturn
(
retPi
);
when
(
partitionListCache
.
get
(
PARTITION_LIST_KEY
)).
thenReturn
(
partitions
);
cachedPartitionServiceImpl
.
deletePartition
(
partId
);
verify
(
partitionServiceImpl
,
times
(
1
)).
deletePartition
(
partId
);
verify
(
partitionServiceCache
,
times
(
1
)).
delete
(
partId
);
verify
(
partitionServiceCache
,
times
(
1
)).
get
(
partId
);
verify
(
partitionListCache
,
times
(
1
)).
clearAll
(
);
verify
(
partitionListCache
,
times
(
1
)).
get
(
PARTITION_LIST_KEY
);
}
@Test
...
...
@@ -142,10 +150,9 @@ public class CachedPartitionServiceImplTest {
when
(
partitionServiceImpl
.
getAllPartitions
()).
thenReturn
(
partitions
);
cachedPartitionServiceImpl
.
getAllPartitions
();
String
partKey
=
"getAllPartitions"
;
verify
(
partitionListCache
,
times
(
1
)).
get
(
partKey
);
verify
(
partitionListCache
,
times
(
1
)).
get
(
PARTITION_LIST_KEY
);
verify
(
partitionServiceImpl
,
times
(
1
)).
getAllPartitions
();
verify
(
partitionListCache
,
times
(
1
)).
put
(
partKey
,
partitions
);
verify
(
partitionListCache
,
times
(
1
)).
put
(
PARTITION_LIST_KEY
,
partitions
);
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
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