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
tom
2014-09-23 01:09:35 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2d7c65f39c87d3701de5eed58baf6d9af2610f05
2d7c65f3
1 parent
e4729875
Added an initial sketch of a distributed cluster store.
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
0 deletions
core/api/src/main/java/org/onlab/onos/cluster/DefaultControllerNode.java
core/store/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java
core/api/src/main/java/org/onlab/onos/cluster/DefaultControllerNode.java
View file @
2d7c65f
...
...
@@ -14,6 +14,12 @@ public class DefaultControllerNode implements ControllerNode {
private
final
NodeId
id
;
private
final
IpPrefix
ip
;
// For serialization
private
DefaultControllerNode
()
{
this
.
id
=
null
;
this
.
ip
=
null
;
}
/**
* Creates a new instance with the specified id and IP address.
*
...
...
core/store/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java
0 → 100644
View file @
2d7c65f
package
org
.
onlab
.
onos
.
store
.
cluster
.
impl
;
import
com.google.common.collect.ImmutableSet
;
import
com.hazelcast.core.HazelcastInstance
;
import
com.hazelcast.core.Member
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Deactivate
;
import
org.apache.felix.scr.annotations.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.apache.felix.scr.annotations.Service
;
import
org.onlab.onos.cluster.ClusterStore
;
import
org.onlab.onos.cluster.ControllerNode
;
import
org.onlab.onos.cluster.DefaultControllerNode
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.store.StoreService
;
import
org.onlab.packet.IpPrefix
;
import
org.slf4j.Logger
;
import
java.util.Set
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
/**
* Distributed implementation of the cluster nodes store.
*/
@Component
(
immediate
=
true
)
@Service
public
class
DistributedClusterStore
implements
ClusterStore
{
private
final
Logger
log
=
getLogger
(
getClass
());
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
StoreService
storeService
;
private
HazelcastInstance
theInstance
;
// FIXME: experimental implementation; enhance to assure persistence and
// visibility to nodes that are not currently in the cluster
@Activate
public
void
activate
()
{
log
.
info
(
"Started"
);
theInstance
=
storeService
.
getHazelcastInstance
();
}
@Deactivate
public
void
deactivate
()
{
log
.
info
(
"Stopped"
);
}
@Override
public
ControllerNode
getLocalNode
()
{
return
node
(
theInstance
.
getCluster
().
getLocalMember
());
}
@Override
public
Set
<
ControllerNode
>
getNodes
()
{
ImmutableSet
.
Builder
<
ControllerNode
>
builder
=
ImmutableSet
.
builder
();
for
(
Member
member
:
theInstance
.
getCluster
().
getMembers
())
{
builder
.
add
(
node
(
member
));
}
return
builder
.
build
();
}
@Override
public
ControllerNode
getNode
(
NodeId
nodeId
)
{
for
(
Member
member
:
theInstance
.
getCluster
().
getMembers
())
{
if
(
member
.
getUuid
().
equals
(
nodeId
.
toString
()))
{
return
node
(
member
);
}
}
return
null
;
}
@Override
public
ControllerNode
.
State
getState
(
NodeId
nodeId
)
{
return
ControllerNode
.
State
.
ACTIVE
;
}
// Creates a controller node descriptor from the Hazelcast member.
private
ControllerNode
node
(
Member
member
)
{
return
new
DefaultControllerNode
(
new
NodeId
(
member
.
getUuid
()),
IpPrefix
.
valueOf
(
member
.
getSocketAddress
().
getAddress
().
getAddress
()));
}
}
Please
register
or
login
to post a comment