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-21 02:52:38 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e291c8445e48b8a03d5fcec52c29ebf817248791
e291c844
1 parent
3a78be6c
Enhanced toString for intents for consistency.
Removed ID block allocator stuff.
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
30 additions
and
256 deletions
cli/src/main/java/org/onlab/onos/cli/net/IntentsListCommand.java
core/api/src/main/java/org/onlab/onos/net/intent/ConnectivityIntent.java
core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java
core/api/src/main/java/org/onlab/onos/net/intent/IdGenerator.java
core/api/src/main/java/org/onlab/onos/net/intent/LinkCollectionIntent.java
core/api/src/main/java/org/onlab/onos/net/intent/MultiPointToSinglePointIntent.java
core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java
core/api/src/main/java/org/onlab/onos/net/intent/PointToPointIntent.java
core/api/src/main/java/org/onlab/onos/net/intent/SinglePointToMultiPointIntent.java
core/api/src/test/java/org/onlab/onos/net/intent/IntentIdGenerator.java
core/net/src/main/java/org/onlab/onos/net/intent/impl/AbstractBlockAllocatorBasedIdGenerator.java
core/net/src/main/java/org/onlab/onos/net/intent/impl/DummyIdBlockAllocator.java
core/net/src/main/java/org/onlab/onos/net/intent/impl/IdBlock.java
core/net/src/main/java/org/onlab/onos/net/intent/impl/IdBlockAllocator.java
cli/src/main/java/org/onlab/onos/cli/net/IntentsListCommand.java
View file @
e291c84
...
...
@@ -18,7 +18,8 @@ public class IntentsListCommand extends AbstractShellCommand {
IntentService
service
=
get
(
IntentService
.
class
);
for
(
Intent
intent
:
service
.
getIntents
())
{
IntentState
state
=
service
.
getIntentState
(
intent
.
id
());
print
(
"%s %s %s"
,
intent
.
id
(),
state
,
intent
);
print
(
"id=%s, state=%s, appId=%s, %s"
,
intent
.
id
(),
state
,
intent
.
appId
().
name
(),
intent
);
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/intent/ConnectivityIntent.java
View file @
e291c84
...
...
@@ -73,7 +73,12 @@ public abstract class ConnectivityIntent extends Intent {
return
treatment
;
}
/**
* Produces a collection of network resources from the given links.
*
* @param links collection of links
* @return collection of link resources
*/
protected
static
Collection
<
NetworkResource
>
resources
(
Collection
<
Link
>
links
)
{
return
ImmutableSet
.<
NetworkResource
>
copyOf
(
links
);
}
...
...
core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java
View file @
e291c84
...
...
@@ -66,6 +66,7 @@ public final class HostToHostIntent extends ConnectivityIntent {
public
String
toString
()
{
return
MoreObjects
.
toStringHelper
(
getClass
())
.
add
(
"id"
,
id
())
.
add
(
"appId"
,
appId
())
.
add
(
"selector"
,
selector
())
.
add
(
"treatment"
,
treatment
())
.
add
(
"one"
,
one
)
...
...
core/api/src/main/java/org/onlab/onos/net/intent/IdGenerator.java
deleted
100644 → 0
View file @
3a78be6
package
org
.
onlab
.
onos
.
net
.
intent
;
/**
* A generalized interface for ID generation
* <p/>
* {@link #getNewId()} generates a globally unique ID instance on
* each invocation.
*
* @param <T> the type of ID
*/
@Deprecated
public
interface
IdGenerator
<
T
>
{
/**
* Returns a globally unique ID instance.
*
* @return globally unique ID instance
*/
T
getNewId
();
}
core/api/src/main/java/org/onlab/onos/net/intent/LinkCollectionIntent.java
View file @
e291c84
...
...
@@ -78,8 +78,9 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
public
String
toString
()
{
return
MoreObjects
.
toStringHelper
(
getClass
())
.
add
(
"id"
,
id
())
.
add
(
"match"
,
selector
())
.
add
(
"action"
,
treatment
())
.
add
(
"appId"
,
appId
())
.
add
(
"selector"
,
selector
())
.
add
(
"treatment"
,
treatment
())
.
add
(
"links"
,
links
())
.
add
(
"egress"
,
egressPoint
())
.
toString
();
...
...
core/api/src/main/java/org/onlab/onos/net/intent/MultiPointToSinglePointIntent.java
View file @
e291c84
...
...
@@ -81,10 +81,11 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
public
String
toString
()
{
return
MoreObjects
.
toStringHelper
(
getClass
())
.
add
(
"id"
,
id
())
.
add
(
"match"
,
selector
())
.
add
(
"action"
,
treatment
())
.
add
(
"ingressPoints"
,
ingressPoints
())
.
add
(
"egressPoint"
,
egressPoint
())
.
add
(
"appId"
,
appId
())
.
add
(
"selector"
,
selector
())
.
add
(
"treatment"
,
treatment
())
.
add
(
"ingress"
,
ingressPoints
())
.
add
(
"egress"
,
egressPoint
())
.
toString
();
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java
View file @
e291c84
...
...
@@ -56,8 +56,9 @@ public class PathIntent extends ConnectivityIntent {
public
String
toString
()
{
return
MoreObjects
.
toStringHelper
(
getClass
())
.
add
(
"id"
,
id
())
.
add
(
"match"
,
selector
())
.
add
(
"action"
,
treatment
())
.
add
(
"appId"
,
appId
())
.
add
(
"selector"
,
selector
())
.
add
(
"treatment"
,
treatment
())
.
add
(
"path"
,
path
)
.
toString
();
}
...
...
core/api/src/main/java/org/onlab/onos/net/intent/PointToPointIntent.java
View file @
e291c84
...
...
@@ -69,10 +69,11 @@ public class PointToPointIntent extends ConnectivityIntent {
public
String
toString
()
{
return
MoreObjects
.
toStringHelper
(
getClass
())
.
add
(
"id"
,
id
())
.
add
(
"match"
,
selector
())
.
add
(
"action"
,
treatment
())
.
add
(
"ingressPoint"
,
ingressPoint
)
.
add
(
"egressPoints"
,
egressPoint
)
.
add
(
"appId"
,
appId
())
.
add
(
"selector"
,
selector
())
.
add
(
"treatment"
,
treatment
())
.
add
(
"ingress"
,
ingressPoint
)
.
add
(
"egress"
,
egressPoint
)
.
toString
();
}
...
...
core/api/src/main/java/org/onlab/onos/net/intent/SinglePointToMultiPointIntent.java
View file @
e291c84
...
...
@@ -77,10 +77,11 @@ public class SinglePointToMultiPointIntent extends ConnectivityIntent {
public
String
toString
()
{
return
MoreObjects
.
toStringHelper
(
getClass
())
.
add
(
"id"
,
id
())
.
add
(
"match"
,
selector
())
.
add
(
"action"
,
treatment
())
.
add
(
"ingressPoint"
,
ingressPoint
)
.
add
(
"egressPort"
,
egressPoints
)
.
add
(
"appId"
,
appId
())
.
add
(
"selector"
,
selector
())
.
add
(
"treatment"
,
treatment
())
.
add
(
"ingress"
,
ingressPoint
)
.
add
(
"egress"
,
egressPoints
)
.
toString
();
}
...
...
core/api/src/test/java/org/onlab/onos/net/intent/IntentIdGenerator.java
deleted
100644 → 0
View file @
3a78be6
package
org
.
onlab
.
onos
.
net
.
intent
;
/**
* This interface is for generator of IntentId. It is defined only for
* testing purpose to keep type safety on mock creation.
*
* <p>
* {@link #getNewId()} generates a globally unique {@link IntentId} instance
* on each invocation. Application developers should not generate IntentId
* by themselves. Instead use an implementation of this interface.
* </p>
*/
public
interface
IntentIdGenerator
extends
IdGenerator
<
IntentId
>
{
}
core/net/src/main/java/org/onlab/onos/net/intent/impl/AbstractBlockAllocatorBasedIdGenerator.java
deleted
100644 → 0
View file @
3a78be6
package
org
.
onlab
.
onos
.
net
.
intent
.
impl
;
import
org.onlab.onos.net.intent.IdGenerator
;
/**
* Base class of {@link IdGenerator} implementations which use {@link IdBlockAllocator} as
* backend.
*
* @param <T> the type of ID
*/
public
abstract
class
AbstractBlockAllocatorBasedIdGenerator
<
T
>
implements
IdGenerator
<
T
>
{
protected
final
IdBlockAllocator
allocator
;
protected
IdBlock
idBlock
;
/**
* Constructs an ID generator which use {@link IdBlockAllocator} as backend.
*
* @param allocator
*/
protected
AbstractBlockAllocatorBasedIdGenerator
(
IdBlockAllocator
allocator
)
{
this
.
allocator
=
allocator
;
this
.
idBlock
=
allocator
.
allocateUniqueIdBlock
();
}
@Override
public
synchronized
T
getNewId
()
{
try
{
return
convertFrom
(
idBlock
.
getNextId
());
}
catch
(
UnavailableIdException
e
)
{
idBlock
=
allocator
.
allocateUniqueIdBlock
();
return
convertFrom
(
idBlock
.
getNextId
());
}
}
/**
* Returns an ID instance of {@code T} type from the long value.
*
* @param value original long value
* @return ID instance
*/
protected
abstract
T
convertFrom
(
long
value
);
}
core/net/src/main/java/org/onlab/onos/net/intent/impl/DummyIdBlockAllocator.java
deleted
100644 → 0
View file @
3a78be6
package
org
.
onlab
.
onos
.
net
.
intent
.
impl
;
public
class
DummyIdBlockAllocator
implements
IdBlockAllocator
{
private
long
blockTop
;
private
static
final
long
BLOCK_SIZE
=
0x1000000
L
;
/**
* Returns a block of IDs which are unique and unused.
* Range of IDs is fixed size and is assigned incrementally as this method
* called.
*
* @return an IdBlock containing a set of unique IDs
*/
@Override
public
IdBlock
allocateUniqueIdBlock
()
{
synchronized
(
this
)
{
long
blockHead
=
blockTop
;
long
blockTail
=
blockTop
+
BLOCK_SIZE
;
IdBlock
block
=
new
IdBlock
(
blockHead
,
BLOCK_SIZE
);
blockTop
=
blockTail
;
return
block
;
}
}
@Override
public
IdBlock
allocateUniqueIdBlock
(
long
range
)
{
throw
new
UnsupportedOperationException
(
"Not supported yet"
);
}
}
core/net/src/main/java/org/onlab/onos/net/intent/impl/IdBlock.java
deleted
100644 → 0
View file @
3a78be6
package
org
.
onlab
.
onos
.
net
.
intent
.
impl
;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkArgument
;
import
java.util.Objects
;
import
java.util.concurrent.atomic.AtomicLong
;
import
com.google.common.base.MoreObjects
;
/**
* A class representing an ID space.
*/
public
final
class
IdBlock
{
private
final
long
start
;
private
final
long
size
;
private
final
AtomicLong
currentId
;
/**
* Constructs a new ID block with the specified size and initial value.
*
* @param start initial value of the block
* @param size size of the block
* @throws IllegalArgumentException if the size is less than or equal to 0
*/
public
IdBlock
(
long
start
,
long
size
)
{
checkArgument
(
size
>
0
,
"size should be more than 0, but %s"
,
size
);
this
.
start
=
start
;
this
.
size
=
size
;
this
.
currentId
=
new
AtomicLong
(
start
);
}
// TODO: consider if this method is needed or not
/**
* Returns the initial value.
*
* @return initial value
*/
public
long
getStart
()
{
return
start
;
}
// TODO: consider if this method is needed or not
/**
* Returns the last value.
*
* @return last value
*/
public
long
getEnd
()
{
return
start
+
size
-
1
;
}
/**
* Returns the block size.
*
* @return block size
*/
public
long
getSize
()
{
return
size
;
}
/**
* Returns the next ID in the block.
*
* @return next ID
* @throws UnavailableIdException if there is no available ID in the block.
*/
public
long
getNextId
()
{
final
long
id
=
currentId
.
getAndIncrement
();
if
(
id
>
getEnd
())
{
throw
new
UnavailableIdException
(
String
.
format
(
"used all IDs in allocated space (size: %d, end: %d, current: %d)"
,
size
,
getEnd
(),
id
));
}
return
id
;
}
// TODO: Do we really need equals and hashCode? Should it contain currentId?
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
}
IdBlock
that
=
(
IdBlock
)
o
;
return
Objects
.
equals
(
this
.
start
,
that
.
start
)
&&
Objects
.
equals
(
this
.
size
,
that
.
size
)
&&
Objects
.
equals
(
this
.
currentId
.
get
(),
that
.
currentId
.
get
());
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
start
,
size
,
currentId
);
}
@Override
public
String
toString
()
{
return
MoreObjects
.
toStringHelper
(
getClass
())
.
add
(
"start"
,
start
)
.
add
(
"size"
,
size
)
.
add
(
"currentId"
,
currentId
)
.
toString
();
}
}
core/net/src/main/java/org/onlab/onos/net/intent/impl/IdBlockAllocator.java
deleted
100644 → 0
View file @
3a78be6
package
org
.
onlab
.
onos
.
net
.
intent
.
impl
;
/**
* An interface that gives unique ID spaces.
*/
public
interface
IdBlockAllocator
{
/**
* Allocates a unique Id Block.
*
* @return Id Block.
*/
IdBlock
allocateUniqueIdBlock
();
/**
* Allocates next unique id and retrieve a new range of ids if needed.
*
* @param range range to use for the identifier
* @return Id Block.
*/
IdBlock
allocateUniqueIdBlock
(
long
range
);
}
Please
register
or
login
to post a comment