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-22 14:09:17 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1fb982fe9373a3efd2781b0a8bd7f21ce79d58d3
1fb982fe
1 parent
68ae665e
Adding intent operations batch abstraction.
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
196 additions
and
6 deletions
core/api/src/main/java/org/onlab/onos/net/intent/BatchOperation.java
core/api/src/main/java/org/onlab/onos/net/intent/BatchOperationEntry.java
core/api/src/main/java/org/onlab/onos/net/intent/BatchOperationTarget.java
core/api/src/main/java/org/onlab/onos/net/intent/IntentBatchOperation.java
core/api/src/main/java/org/onlab/onos/net/intent/IntentOperation.java
core/api/src/main/java/org/onlab/onos/net/intent/IntentOperations.java
core/api/src/main/java/org/onlab/onos/net/intent/IntentService.java
core/api/src/test/java/org/onlab/onos/net/intent/FakeIntentManager.java
core/net/src/main/java/org/onlab/onos/net/intent/impl/IntentManager.java
core/api/src/main/java/org/onlab/onos/net/intent/BatchOperation.java
View file @
1fb982f
...
...
@@ -14,6 +14,7 @@ import java.util.List;
* @param <T> the enum of operators <br>
* This enum must be defined in each sub-classes.
*/
@Deprecated
public
abstract
class
BatchOperation
<
T
extends
BatchOperationEntry
<?,
?>>
{
private
final
List
<
T
>
ops
;
...
...
core/api/src/main/java/org/onlab/onos/net/intent/BatchOperationEntry.java
View file @
1fb982f
...
...
@@ -11,6 +11,7 @@ import com.google.common.base.MoreObjects;
* This is the interface to classes which are maintained by BatchOperation as
* its entries.
*/
@Deprecated
public
class
BatchOperationEntry
<
T
extends
Enum
<?>,
U
extends
BatchOperationTarget
>
{
private
final
T
operator
;
private
final
U
target
;
...
...
core/api/src/main/java/org/onlab/onos/net/intent/BatchOperationTarget.java
View file @
1fb982f
...
...
@@ -4,6 +4,7 @@ package org.onlab.onos.net.intent;
/**
* An interface of the class which is assigned to BatchOperation.
*/
@Deprecated
public
interface
BatchOperationTarget
{
}
...
...
core/api/src/main/java/org/onlab/onos/net/intent/IntentBatchOperation.java
View file @
1fb982f
...
...
@@ -3,6 +3,7 @@ package org.onlab.onos.net.intent;
/**
* A list of intent operations.
*/
@Deprecated
public
class
IntentBatchOperation
extends
BatchOperation
<
BatchOperationEntry
<
IntentBatchOperation
.
Operator
,
?>>
{
/**
...
...
core/api/src/main/java/org/onlab/onos/net/intent/IntentOperation.java
0 → 100644
View file @
1fb982f
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package
org
.
onlab
.
onos
.
net
.
intent
;
/**
* Abstraction of an intent-related operation, e.g. add, remove, replace.
*/
public
class
IntentOperation
{
private
final
Type
type
;
private
final
IntentId
intentId
;
private
final
Intent
intent
;
/**
* Operation type.
*/
enum
Type
{
/**
* Indicates that an intent should be added.
*/
SUBMIT
,
/**
* Indicates that an intent should be removed.
*/
WITHDRAW
,
/**
* Indicates that an intent should be replaced with another.
*/
REPLACE
}
/**
* Creates an intent operation.
*
* @param type operation type
* @param intentId identifier of the intent subject to the operation
* @param intent intent subject
*/
IntentOperation
(
Type
type
,
IntentId
intentId
,
Intent
intent
)
{
this
.
type
=
type
;
this
.
intentId
=
intentId
;
this
.
intent
=
intent
;
}
/**
* Returns the type of the operation.
*
* @return operation type
*/
public
Type
type
()
{
return
type
;
}
/**
* Returns the identifier of the intent to which this operation applies.
*
* @return intent identifier
*/
public
IntentId
intentId
()
{
return
intentId
;
}
/**
* Returns the intent to which this operation applied. For remove,
* this can be null.
*
* @return intent that is the subject of the operation; null for remove
*/
public
Intent
intent
()
{
return
intent
;
}
}
core/api/src/main/java/org/onlab/onos/net/intent/IntentOperations.java
View file @
1fb982f
package
org
.
onlab
.
onos
.
net
.
intent
;
import
com.google.common.collect.ImmutableList
;
import
java.util.List
;
import
static
org
.
onlab
.
onos
.
net
.
intent
.
IntentOperation
.
Type
.
REPLACE
;
import
static
org
.
onlab
.
onos
.
net
.
intent
.
IntentOperation
.
Type
.
SUBMIT
;
import
static
org
.
onlab
.
onos
.
net
.
intent
.
IntentOperation
.
Type
.
WITHDRAW
;
/**
* Abstraction of a batch of intent submit/withdraw operations.
* Batch of intent submit/withdraw/replace operations.
*/
public
final
class
IntentOperations
{
private
final
List
<
IntentOperation
>
operations
;
/**
* Creates a batch of intent operations using the supplied list.
*
* @param operations list of intent operations
*/
public
interface
IntentOperations
{
private
IntentOperations
(
List
<
IntentOperation
>
operations
)
{
this
.
operations
=
operations
;
}
// TODO: elaborate once the revised BatchOperation scheme is in place
/**
* List of operations that need to be executed as a unit.
*
* @return list of intent operations
*/
public
List
<
IntentOperation
>
operations
()
{
return
operations
;
}
/**
* Returns a builder for intent operation batches.
*
* @return intent operations builder
*/
public
static
Builder
builder
()
{
return
new
Builder
();
}
/**
* Builder for batches of intent operations.
*/
public
static
final
class
Builder
{
ImmutableList
.
Builder
<
IntentOperation
>
builder
=
ImmutableList
.
builder
();
// Public construction is forbidden.
private
Builder
()
{
}
/**
* Adds an intent submit operation.
*
* @param intent intent to be submitted
* @return self
*/
public
Builder
addSubmitOperation
(
Intent
intent
)
{
builder
.
add
(
new
IntentOperation
(
SUBMIT
,
intent
.
id
(),
intent
));
return
this
;
}
/**
* Adds an intent submit operation.
*
* @param oldIntentId intent to be replaced
* @param newIntent replacement intent
* @return self
*/
public
Builder
addReplaceOperation
(
IntentId
oldIntentId
,
Intent
newIntent
)
{
builder
.
add
(
new
IntentOperation
(
REPLACE
,
oldIntentId
,
newIntent
));
return
this
;
}
/**
* Adds an intent submit operation.
*
* @param intentId identifier of the intent to be withdrawn
* @return self
*/
public
Builder
addWithdrawOperation
(
IntentId
intentId
)
{
builder
.
add
(
new
IntentOperation
(
WITHDRAW
,
intentId
,
null
));
return
this
;
}
/**
* Builds a batch of intent operations.
*
* @return immutable batch of intent operations
*/
public
IntentOperations
build
()
{
return
new
IntentOperations
(
builder
.
build
());
}
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/intent/IntentService.java
View file @
1fb982f
...
...
@@ -2,6 +2,7 @@ package org.onlab.onos.net.intent;
import
java.util.List
;
import
java.util.concurrent.Future
;
/**
* Service for application submitting or withdrawing their intents.
...
...
@@ -27,6 +28,8 @@ public interface IntentService {
*/
void
withdraw
(
Intent
intent
);
// void replace(IntentId oldIntentId, Intent newIntent);
/**
* Submits a batch of submit & withdraw operations. Such a batch is
* assumed to be processed together.
...
...
@@ -36,7 +39,7 @@ public interface IntentService {
*
* @param operations batch of intent operations
*/
void
execute
(
IntentOperations
operations
);
Future
<
IntentOperations
>
execute
(
IntentOperations
operations
);
/**
* Returns an iterable of intents currently in the system.
...
...
core/api/src/test/java/org/onlab/onos/net/intent/FakeIntentManager.java
View file @
1fb982f
...
...
@@ -9,6 +9,7 @@ import java.util.Map;
import
java.util.Set
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
/**
* Fake implementation of the intent service to assist in developing tests of
...
...
@@ -171,8 +172,9 @@ public class FakeIntentManager implements TestableIntentService {
}
@Override
public
void
execute
(
IntentOperations
operations
)
{
public
Future
<
IntentOperations
>
execute
(
IntentOperations
operations
)
{
// TODO: implement later
return
null
;
}
@Override
...
...
core/net/src/main/java/org/onlab/onos/net/intent/impl/IntentManager.java
View file @
1fb982f
...
...
@@ -126,7 +126,7 @@ public class IntentManager
// FIXME: implement this method
@Override
public
void
execute
(
IntentOperations
operations
)
{
public
Future
<
IntentOperations
>
execute
(
IntentOperations
operations
)
{
throw
new
UnsupportedOperationException
(
"execute() is not implemented yet"
);
}
...
...
Please
register
or
login
to post a comment