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
Thomas Vachuska
2014-10-20 23:03:42 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
1c184f1df9af99c0c710857a7406dcc6821248c2
1c184f1d
2 parents
c96058ae
2809bf37
Merge remote-tracking branch 'origin/master'
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
123 additions
and
5 deletions
core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficSelector.java
core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficTreatment.java
core/store/dist/src/main/java/org/onlab/onos/store/intent/impl/DistributedIntentStore.java
core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoNamespaces.java
utils/misc/src/main/java/org/onlab/util/KryoNamespace.java
core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficSelector.java
View file @
1c184f1
...
...
@@ -8,7 +8,6 @@ import org.onlab.packet.IpPrefix;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
...
...
@@ -27,7 +26,7 @@ public final class DefaultTrafficSelector implements TrafficSelector {
* @param criteria criteria
*/
private
DefaultTrafficSelector
(
Set
<
Criterion
>
criteria
)
{
this
.
criteria
=
Collections
.
unmodifiableSet
(
criteria
);
this
.
criteria
=
ImmutableSet
.
copyOf
(
criteria
);
}
@Override
...
...
core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficTreatment.java
View file @
1c184f1
...
...
@@ -7,7 +7,8 @@ import org.onlab.packet.IpPrefix;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
import
java.util.Collections
;
import
com.google.common.collect.ImmutableList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Objects
;
...
...
@@ -25,7 +26,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
* @param instructions treatment instructions
*/
private
DefaultTrafficTreatment
(
List
<
Instruction
>
instructions
)
{
this
.
instructions
=
Collections
.
unmodifiableList
(
instructions
);
this
.
instructions
=
ImmutableList
.
copyOf
(
instructions
);
}
@Override
...
...
core/store/dist/src/main/java/org/onlab/onos/store/intent/impl/DistributedIntentStore.java
0 → 100644
View file @
1c184f1
package
org
.
onlab
.
onos
.
store
.
intent
.
impl
;
import
static
org
.
onlab
.
onos
.
net
.
intent
.
IntentState
.
FAILED
;
import
static
org
.
onlab
.
onos
.
net
.
intent
.
IntentState
.
INSTALLED
;
import
static
org
.
onlab
.
onos
.
net
.
intent
.
IntentState
.
SUBMITTED
;
import
static
org
.
onlab
.
onos
.
net
.
intent
.
IntentState
.
WITHDRAWN
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
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.Service
;
import
org.onlab.onos.net.intent.InstallableIntent
;
import
org.onlab.onos.net.intent.Intent
;
import
org.onlab.onos.net.intent.IntentEvent
;
import
org.onlab.onos.net.intent.IntentId
;
import
org.onlab.onos.net.intent.IntentState
;
import
org.onlab.onos.net.intent.IntentStore
;
import
org.onlab.onos.net.intent.IntentStoreDelegate
;
import
org.onlab.onos.store.AbstractStore
;
import
org.slf4j.Logger
;
import
com.google.common.collect.ImmutableSet
;
//FIXME: I LIE I AM NOT DISTRIBUTED
@Component
(
immediate
=
true
)
@Service
public
class
DistributedIntentStore
extends
AbstractStore
<
IntentEvent
,
IntentStoreDelegate
>
implements
IntentStore
{
private
final
Logger
log
=
getLogger
(
getClass
());
private
final
Map
<
IntentId
,
Intent
>
intents
=
new
ConcurrentHashMap
<>();
private
final
Map
<
IntentId
,
IntentState
>
states
=
new
ConcurrentHashMap
<>();
private
final
Map
<
IntentId
,
List
<
InstallableIntent
>>
installable
=
new
ConcurrentHashMap
<>();
@Activate
public
void
activate
()
{
log
.
info
(
"Started"
);
}
@Deactivate
public
void
deactivate
()
{
log
.
info
(
"Stopped"
);
}
@Override
public
IntentEvent
createIntent
(
Intent
intent
)
{
intents
.
put
(
intent
.
id
(),
intent
);
return
this
.
setState
(
intent
,
IntentState
.
SUBMITTED
);
}
@Override
public
IntentEvent
removeIntent
(
IntentId
intentId
)
{
Intent
intent
=
intents
.
remove
(
intentId
);
installable
.
remove
(
intentId
);
IntentEvent
event
=
this
.
setState
(
intent
,
WITHDRAWN
);
states
.
remove
(
intentId
);
return
event
;
}
@Override
public
long
getIntentCount
()
{
return
intents
.
size
();
}
@Override
public
Iterable
<
Intent
>
getIntents
()
{
return
ImmutableSet
.
copyOf
(
intents
.
values
());
}
@Override
public
Intent
getIntent
(
IntentId
intentId
)
{
return
intents
.
get
(
intentId
);
}
@Override
public
IntentState
getIntentState
(
IntentId
id
)
{
return
states
.
get
(
id
);
}
@Override
public
IntentEvent
setState
(
Intent
intent
,
IntentState
state
)
{
IntentId
id
=
intent
.
id
();
states
.
put
(
id
,
state
);
IntentEvent
.
Type
type
=
(
state
==
SUBMITTED
?
IntentEvent
.
Type
.
SUBMITTED
:
(
state
==
INSTALLED
?
IntentEvent
.
Type
.
INSTALLED
:
(
state
==
FAILED
?
IntentEvent
.
Type
.
FAILED
:
state
==
WITHDRAWN
?
IntentEvent
.
Type
.
WITHDRAWN
:
null
)));
return
type
==
null
?
null
:
new
IntentEvent
(
type
,
intent
);
}
@Override
public
void
addInstallableIntents
(
IntentId
intentId
,
List
<
InstallableIntent
>
result
)
{
installable
.
put
(
intentId
,
result
);
}
@Override
public
List
<
InstallableIntent
>
getInstallableIntents
(
IntentId
intentId
)
{
return
installable
.
get
(
intentId
);
}
@Override
public
void
removeInstalledIntents
(
IntentId
intentId
)
{
installable
.
remove
(
intentId
);
}
}
core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoNamespaces.java
View file @
1c184f1
...
...
@@ -26,6 +26,7 @@ import org.onlab.onos.net.PortNumber;
import
org.onlab.onos.net.device.DefaultDeviceDescription
;
import
org.onlab.onos.net.device.DefaultPortDescription
;
import
org.onlab.onos.net.flow.DefaultFlowRule
;
import
org.onlab.onos.net.flow.DefaultTrafficSelector
;
import
org.onlab.onos.net.flow.FlowId
;
import
org.onlab.onos.net.host.DefaultHostDescription
;
import
org.onlab.onos.net.host.HostDescription
;
...
...
@@ -88,7 +89,8 @@ public final class KryoNamespaces {
HostDescription
.
class
,
DefaultHostDescription
.
class
,
DefaultFlowRule
.
class
,
FlowId
.
class
FlowId
.
class
,
DefaultTrafficSelector
.
class
)
.
register
(
URI
.
class
,
new
URISerializer
())
.
register
(
NodeId
.
class
,
new
NodeIdSerializer
())
...
...
utils/misc/src/main/java/org/onlab/util/KryoNamespace.java
View file @
1c184f1
...
...
@@ -171,6 +171,7 @@ public final class KryoNamespace implements KryoFactory {
Kryo
kryo
=
getKryo
();
try
{
kryo
.
writeClassAndObject
(
out
,
obj
);
out
.
flush
();
return
out
.
toBytes
();
}
finally
{
putKryo
(
kryo
);
...
...
@@ -188,6 +189,7 @@ public final class KryoNamespace implements KryoFactory {
Kryo
kryo
=
getKryo
();
try
{
kryo
.
writeClassAndObject
(
out
,
obj
);
out
.
flush
();
}
finally
{
putKryo
(
kryo
);
}
...
...
Please
register
or
login
to post a comment