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
Madan Jampani
2014-11-06 20:06:12 -0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2ee20002b0e5a3c29b1e2742a10367e53df546b6
2ee20002
1 parent
d2a38821
Simpler way to construct MapDBLog
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
14 deletions
core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
core/store/dist/src/main/java/org/onlab/onos/store/service/impl/MapDBLog.java
core/store/dist/src/test/java/org/onlab/onos/store/service/impl/MapDBLogTest.java
core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
View file @
2ee2000
...
...
@@ -2,7 +2,6 @@ package org.onlab.onos.store.service.impl;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
...
...
@@ -129,7 +128,7 @@ public class DatabaseManager implements DatabaseService, DatabaseAdminService {
// Chronicle + OSGi issue
//Log consensusLog = new ChronicleLog(LOG_FILE_PREFIX + "_" + thisNode.id());
//Log consensusLog = new KryoRegisteredInMemoryLog();
Log
consensusLog
=
new
MapDBLog
(
new
File
(
LOG_FILE_PREFIX
+
localNode
.
id
()
),
Log
consensusLog
=
new
MapDBLog
(
LOG_FILE_PREFIX
+
localNode
.
id
(
),
ClusterMessagingProtocol
.
SERIALIZER
);
copycat
=
new
Copycat
(
stateMachine
,
consensusLog
,
cluster
,
copycatMessagingProtocol
);
...
...
core/store/dist/src/main/java/org/onlab/onos/store/service/impl/MapDBLog.java
View file @
2ee2000
...
...
@@ -35,8 +35,8 @@ public class MapDBLog implements Log {
private
static
final
String
LOG_NAME
=
"log"
;
private
static
final
String
SIZE_FIELD_NAME
=
"size"
;
public
MapDBLog
(
File
dbFil
e
,
StoreSerializer
serializer
)
{
this
.
dbFile
=
dbFile
;
public
MapDBLog
(
String
dbFileNam
e
,
StoreSerializer
serializer
)
{
this
.
dbFile
=
new
File
(
dbFileName
)
;
this
.
serializer
=
serializer
;
}
...
...
core/store/dist/src/test/java/org/onlab/onos/store/service/impl/MapDBLogTest.java
View file @
2ee2000
...
...
@@ -51,13 +51,13 @@ public class MapDBLogTest {
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
testAssertOpen
()
{
Log
log
=
new
MapDBLog
(
new
File
(
DB_FILE_NAME
)
,
SERIALIZER
);
Log
log
=
new
MapDBLog
(
DB_FILE_NAME
,
SERIALIZER
);
log
.
size
();
}
@Test
public
void
testAppendEntry
()
throws
IOException
{
Log
log
=
new
MapDBLog
(
new
File
(
DB_FILE_NAME
)
,
SERIALIZER
);
Log
log
=
new
MapDBLog
(
DB_FILE_NAME
,
SERIALIZER
);
log
.
open
();
log
.
appendEntry
(
TEST_ENTRY1
);
OperationEntry
first
=
log
.
firstEntry
();
...
...
@@ -72,7 +72,7 @@ public class MapDBLogTest {
@Test
public
void
testAppendEntries
()
throws
IOException
{
Log
log
=
new
MapDBLog
(
new
File
(
DB_FILE_NAME
)
,
SERIALIZER
);
Log
log
=
new
MapDBLog
(
DB_FILE_NAME
,
SERIALIZER
);
log
.
open
();
log
.
appendEntries
(
TEST_ENTRY1
,
TEST_ENTRY2
,
TEST_ENTRY3
);
OperationEntry
first
=
log
.
firstEntry
();
...
...
@@ -90,7 +90,7 @@ public class MapDBLogTest {
@Test
public
void
testDelete
()
throws
IOException
{
Log
log
=
new
MapDBLog
(
new
File
(
DB_FILE_NAME
)
,
SERIALIZER
);
Log
log
=
new
MapDBLog
(
DB_FILE_NAME
,
SERIALIZER
);
log
.
open
();
log
.
appendEntries
(
TEST_ENTRY1
,
TEST_ENTRY2
);
log
.
delete
();
...
...
@@ -104,7 +104,7 @@ public class MapDBLogTest {
@Test
public
void
testGetEntries
()
throws
IOException
{
Log
log
=
new
MapDBLog
(
new
File
(
DB_FILE_NAME
)
,
SERIALIZER
);
Log
log
=
new
MapDBLog
(
DB_FILE_NAME
,
SERIALIZER
);
log
.
open
();
log
.
appendEntries
(
TEST_ENTRY1
,
TEST_ENTRY2
,
TEST_ENTRY3
,
TEST_ENTRY4
);
Assert
.
assertEquals
(
...
...
@@ -123,7 +123,7 @@ public class MapDBLogTest {
@Test
public
void
testRemoveAfter
()
throws
IOException
{
Log
log
=
new
MapDBLog
(
new
File
(
DB_FILE_NAME
)
,
SERIALIZER
);
Log
log
=
new
MapDBLog
(
DB_FILE_NAME
,
SERIALIZER
);
log
.
open
();
log
.
appendEntries
(
TEST_ENTRY1
,
TEST_ENTRY2
,
TEST_ENTRY3
,
TEST_ENTRY4
);
log
.
removeAfter
(
1
);
...
...
@@ -135,7 +135,7 @@ public class MapDBLogTest {
@Test
public
void
testAddAfterRemove
()
throws
IOException
{
Log
log
=
new
MapDBLog
(
new
File
(
DB_FILE_NAME
)
,
SERIALIZER
);
Log
log
=
new
MapDBLog
(
DB_FILE_NAME
,
SERIALIZER
);
log
.
open
();
log
.
appendEntries
(
TEST_ENTRY1
,
TEST_ENTRY2
,
TEST_ENTRY3
,
TEST_ENTRY4
);
log
.
removeAfter
(
1
);
...
...
@@ -150,7 +150,7 @@ public class MapDBLogTest {
@Test
public
void
testClose
()
throws
IOException
{
Log
log
=
new
MapDBLog
(
new
File
(
DB_FILE_NAME
)
,
SERIALIZER
);
Log
log
=
new
MapDBLog
(
DB_FILE_NAME
,
SERIALIZER
);
Assert
.
assertFalse
(
log
.
isOpen
());
log
.
open
();
Assert
.
assertTrue
(
log
.
isOpen
());
...
...
@@ -160,7 +160,7 @@ public class MapDBLogTest {
@Test
public
void
testReopen
()
throws
IOException
{
Log
log
=
new
MapDBLog
(
new
File
(
DB_FILE_NAME
)
,
SERIALIZER
);
Log
log
=
new
MapDBLog
(
DB_FILE_NAME
,
SERIALIZER
);
log
.
open
();
log
.
appendEntries
(
TEST_ENTRY1
,
TEST_ENTRY2
,
TEST_ENTRY3
,
TEST_ENTRY4
);
log
.
close
();
...
...
@@ -180,7 +180,7 @@ public class MapDBLogTest {
@Test
public
void
testCompact
()
throws
IOException
{
Log
log
=
new
MapDBLog
(
new
File
(
DB_FILE_NAME
)
,
SERIALIZER
);
Log
log
=
new
MapDBLog
(
DB_FILE_NAME
,
SERIALIZER
);
log
.
open
();
log
.
appendEntries
(
TEST_ENTRY1
,
TEST_ENTRY2
,
TEST_ENTRY3
,
TEST_ENTRY4
);
log
.
compact
(
3
,
TEST_SNAPSHOT_ENTRY
);
...
...
Please
register
or
login
to post a comment