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-13 20:27:14 -0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
841c0b623ad5e780f437215e11877108d2ab6730
841c0b62
1 parent
6b38ee35
Add getAll to DatabaseService
Change-Id: I5fb9d52244b005dfc22e7faaa68341be3c3f3725
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
0 deletions
core/api/src/main/java/org/onlab/onos/store/service/DatabaseService.java
core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseClient.java
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/DatabaseStateMachine.java
core/api/src/main/java/org/onlab/onos/store/service/DatabaseService.java
View file @
841c0b6
package
org
.
onlab
.
onos
.
store
.
service
;
import
java.util.Map
;
/**
* Service interface for a strongly consistent and durable
* key value data store.
...
...
@@ -15,6 +17,14 @@ public interface DatabaseService {
VersionedValue
get
(
String
tableName
,
String
key
);
/**
* Reads the whole table.
*
* @param tableName name of the table associated with this operation.
* @return the whole table
*/
Map
<
String
,
VersionedValue
>
getAll
(
String
tableName
);
/**
* Associate the key with a value.
* @param tableName table name in which this key/value resides.
* @param key key with which the specified value is to be associated
...
...
core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseClient.java
View file @
841c0b6
...
...
@@ -3,6 +3,7 @@ package org.onlab.onos.store.service.impl;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.ExecutionException
;
...
...
@@ -13,6 +14,7 @@ import org.onlab.onos.store.service.BatchReadRequest;
import
org.onlab.onos.store.service.BatchWriteRequest
;
import
org.onlab.onos.store.service.DatabaseException
;
import
org.onlab.onos.store.service.ReadResult
;
import
org.onlab.onos.store.service.VersionedValue
;
import
org.onlab.onos.store.service.WriteResult
;
/**
...
...
@@ -95,4 +97,13 @@ public class DatabaseClient {
throw
new
DatabaseException
(
e
);
}
}
public
Map
<
String
,
VersionedValue
>
getAll
(
String
tableName
)
{
CompletableFuture
<
Map
<
String
,
VersionedValue
>>
future
=
copycat
.
submit
(
"getAll"
,
tableName
);
try
{
return
future
.
get
();
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
throw
new
DatabaseException
(
e
);
}
}
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
View file @
841c0b6
...
...
@@ -226,6 +226,12 @@ public class DatabaseManager implements DatabaseService, DatabaseAdminService {
}
@Override
public
Map
<
String
,
VersionedValue
>
getAll
(
String
tableName
)
{
return
client
.
getAll
(
tableName
);
}
@Override
public
BatchReadResult
batchRead
(
BatchReadRequest
batchRequest
)
{
return
new
BatchReadResult
(
client
.
batchRead
(
batchRequest
));
}
...
...
core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseStateMachine.java
View file @
841c0b6
...
...
@@ -31,6 +31,7 @@ import org.onlab.util.KryoNamespace;
import
org.slf4j.Logger
;
import
com.google.common.base.MoreObjects
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
...
...
@@ -148,6 +149,12 @@ public class DatabaseStateMachine implements StateMachine {
return
results
;
}
@Query
public
Map
<
String
,
VersionedValue
>
getAll
(
String
tableName
)
{
return
ImmutableMap
.
copyOf
(
state
.
getTable
(
tableName
));
}
WriteStatus
checkIfApplicable
(
WriteRequest
request
,
VersionedValue
value
)
{
...
...
Please
register
or
login
to post a comment