Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Yuta HIGUCHI
2014-11-10 09:46:36 -0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a38d995126b5023b9fa7cc2a342c7d13501e8123
a38d9951
1 parent
413573d5
MapDBLog: add sanity check
Change-Id: If364a073b2d80c301eed236f80c6884f34bee6be
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
core/store/dist/src/main/java/org/onlab/onos/store/service/impl/MapDBLog.java
core/store/dist/src/main/java/org/onlab/onos/store/service/impl/MapDBLog.java
View file @
a38d995
...
...
@@ -99,7 +99,8 @@ public class MapDBLog implements Log {
long
nextIndex
=
log
.
isEmpty
()
?
1
:
log
.
lastKey
()
+
1
;
long
addedBytes
=
0
;
for
(
Entry
entry
:
entries
)
{
byte
[]
entryBytes
=
serializer
.
encode
(
entry
);
byte
[]
entryBytes
=
verifyNotNull
(
serializer
.
encode
(
entry
),
"Writing LogEntry %s failed"
,
nextIndex
);
log
.
put
(
nextIndex
,
entryBytes
);
addedBytes
+=
entryBytes
.
length
;
indices
.
add
(
nextIndex
);
...
...
@@ -144,7 +145,7 @@ public class MapDBLog implements Log {
DB
db
=
txMaker
.
makeTx
();
try
{
BTreeMap
<
Long
,
byte
[]>
log
=
getLogMap
(
db
);
return
log
.
isEmpty
()
?
null
:
serializer
.
decode
(
log
.
firstEntry
().
getValue
(
));
return
log
.
isEmpty
()
?
null
:
verifyNotNull
(
serializer
.
decode
(
log
.
firstEntry
().
getValue
()
));
}
finally
{
db
.
close
();
}
...
...
@@ -177,7 +178,7 @@ public class MapDBLog implements Log {
}
List
<
T
>
entries
=
new
ArrayList
<>((
int
)
(
to
-
from
+
1
));
for
(
long
i
=
from
;
i
<=
to
;
i
++)
{
T
entry
=
serializer
.
decode
(
log
.
get
(
i
)
);
T
entry
=
verifyNotNull
(
serializer
.
decode
(
log
.
get
(
i
)),
"LogEntry %s was null"
,
i
);
entries
.
add
(
entry
);
}
return
entries
;
...
...
@@ -193,7 +194,8 @@ public class MapDBLog implements Log {
try
{
BTreeMap
<
Long
,
byte
[]>
log
=
getLogMap
(
db
);
byte
[]
entryBytes
=
log
.
get
(
index
);
return
entryBytes
==
null
?
null
:
serializer
.
decode
(
entryBytes
);
return
entryBytes
==
null
?
null
:
verifyNotNull
(
serializer
.
decode
(
entryBytes
),
"LogEntry %s was null"
,
index
);
}
finally
{
db
.
close
();
}
...
...
@@ -217,7 +219,7 @@ public class MapDBLog implements Log {
DB
db
=
txMaker
.
makeTx
();
try
{
BTreeMap
<
Long
,
byte
[]>
log
=
getLogMap
(
db
);
return
log
.
isEmpty
()
?
null
:
serializer
.
decode
(
log
.
lastEntry
().
getValue
(
));
return
log
.
isEmpty
()
?
null
:
verifyNotNull
(
serializer
.
decode
(
log
.
lastEntry
().
getValue
()
));
}
finally
{
db
.
close
();
}
...
...
Please
register
or
login
to post a comment