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-10-07 11:01:36 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
53945d53f7a0cf240d708b74ee33c20c23bfaf68
53945d53
1 parent
672488d8
Working on intent uninstall during recompilation.
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
13 deletions
cli/src/main/java/org/onlab/onos/cli/net/DevicesListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.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/net/src/main/java/org/onlab/onos/net/intent/impl/ObjectiveTracker.java
cli/src/main/java/org/onlab/onos/cli/net/DevicesListCommand.java
View file @
53945d5
...
...
@@ -35,7 +35,7 @@ public class DevicesListCommand extends AbstractShellCommand {
* @param service device service
* @return sorted device list
*/
protected
List
<
Device
>
getSortedDevices
(
DeviceService
service
)
{
protected
static
List
<
Device
>
getSortedDevices
(
DeviceService
service
)
{
List
<
Device
>
devices
=
newArrayList
(
service
.
getDevices
());
Collections
.
sort
(
devices
,
Comparators
.
ELEMENT_COMPARATOR
);
return
devices
;
...
...
cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
View file @
53945d5
package
org
.
onlab
.
onos
.
cli
.
net
;
import
static
com
.
google
.
common
.
collect
.
Lists
.
newArrayList
;
import
static
org
.
onlab
.
onos
.
cli
.
net
.
DevicesListCommand
.
getSortedDevices
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -64,7 +65,7 @@ public class FlowsListCommand extends AbstractShellCommand {
if
(
state
!=
null
&&
!
state
.
equals
(
"any"
))
{
s
=
FlowEntryState
.
valueOf
(
state
.
toUpperCase
());
}
Iterable
<
Device
>
devices
=
uri
==
null
?
deviceService
.
getDevices
(
)
:
Iterable
<
Device
>
devices
=
uri
==
null
?
getSortedDevices
(
deviceService
)
:
Collections
.
singletonList
(
deviceService
.
getDevice
(
DeviceId
.
deviceId
(
uri
)));
for
(
Device
d
:
devices
)
{
if
(
s
==
null
)
{
...
...
core/api/src/test/java/org/onlab/onos/net/intent/FakeIntentManager.java
View file @
53945d5
...
...
@@ -128,7 +128,7 @@ public class FakeIntentManager implements TestableIntentService {
setState
(
intent
,
IntentState
.
WITHDRAWN
);
dispatch
(
new
IntentEvent
(
IntentEvent
.
Type
.
WITHDRAWN
,
intent
));
}
catch
(
IntentException
e
)
{
// FIXME:
Do we really want to do this?
// FIXME:
Rework this to always go from WITHDRAWING to WITHDRAWN!
setState
(
intent
,
IntentState
.
FAILED
);
dispatch
(
new
IntentEvent
(
IntentEvent
.
Type
.
FAILED
,
intent
));
}
...
...
core/net/src/main/java/org/onlab/onos/net/intent/impl/IntentManager.java
View file @
53945d5
...
...
@@ -36,6 +36,7 @@ import java.util.concurrent.ExecutorService;
import
static
com
.
google
.
common
.
base
.
Preconditions
.
checkNotNull
;
import
static
java
.
util
.
concurrent
.
Executors
.
newSingleThreadExecutor
;
import
static
org
.
onlab
.
onos
.
net
.
intent
.
IntentState
.*;
import
static
org
.
onlab
.
util
.
Tools
.
delay
;
import
static
org
.
onlab
.
util
.
Tools
.
namedThreads
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
...
...
@@ -226,6 +227,8 @@ public class IntentManager
executeInstallingPhase
(
intent
);
}
catch
(
Exception
e
)
{
log
.
warn
(
"Unable to compile intent {} due to: {}"
,
intent
.
id
(),
e
);
// If compilation failed, mark the intent as failed.
store
.
setState
(
intent
,
FAILED
);
}
...
...
@@ -238,8 +241,6 @@ public class IntentManager
for
(
Intent
compiled
:
getCompiler
(
intent
).
compile
(
intent
))
{
InstallableIntent
installableIntent
=
(
InstallableIntent
)
compiled
;
installable
.
add
(
installableIntent
);
trackerService
.
addTrackedResources
(
intent
.
id
(),
installableIntent
.
requiredLinks
());
}
return
installable
;
}
...
...
@@ -259,12 +260,17 @@ public class IntentManager
if
(
installables
!=
null
)
{
for
(
InstallableIntent
installable
:
installables
)
{
registerSubclassInstallerIfNeeded
(
installable
);
trackerService
.
addTrackedResources
(
intent
.
id
(),
installable
.
requiredLinks
());
getInstaller
(
installable
).
install
(
installable
);
}
}
eventDispatcher
.
post
(
store
.
setState
(
intent
,
INSTALLED
));
}
catch
(
Exception
e
)
{
log
.
warn
(
"Unable to install intent {} due to: {}"
,
intent
.
id
(),
e
);
uninstallIntent
(
intent
);
// If compilation failed, kick off the recompiling phase.
executeRecompilingPhase
(
intent
);
}
...
...
@@ -299,6 +305,8 @@ public class IntentManager
executeInstallingPhase
(
intent
);
}
}
catch
(
Exception
e
)
{
log
.
warn
(
"Unable to recompile intent {} due to: {}"
,
intent
.
id
(),
e
);
// If compilation failed, mark the intent as failed.
eventDispatcher
.
post
(
store
.
setState
(
intent
,
FAILED
));
}
...
...
@@ -313,12 +321,7 @@ public class IntentManager
private
void
executeWithdrawingPhase
(
Intent
intent
)
{
// Indicate that the intent is being withdrawn.
store
.
setState
(
intent
,
WITHDRAWING
);
List
<
InstallableIntent
>
installables
=
store
.
getInstallableIntents
(
intent
.
id
());
if
(
installables
!=
null
)
{
for
(
InstallableIntent
installable
:
installables
)
{
getInstaller
(
installable
).
uninstall
(
installable
);
}
}
uninstallIntent
(
intent
);
// If all went well, disassociate the top-level intent with its
// installable derivatives and mark it as withdrawn.
...
...
@@ -327,6 +330,24 @@ public class IntentManager
}
/**
* Uninstalls all installable intents associated with the given intent.
*
* @param intent intent to be uninstalled
*/
private
void
uninstallIntent
(
Intent
intent
)
{
try
{
List
<
InstallableIntent
>
installables
=
store
.
getInstallableIntents
(
intent
.
id
());
if
(
installables
!=
null
)
{
for
(
InstallableIntent
installable
:
installables
)
{
getInstaller
(
installable
).
uninstall
(
installable
);
}
}
}
catch
(
IntentException
e
)
{
log
.
warn
(
"Unable to uninstall intent {} due to: {}"
,
intent
.
id
(),
e
);
}
}
/**
* Registers an intent compiler of the specified intent if an intent compiler
* for the intent is not registered. This method traverses the class hierarchy of
* the intent. Once an intent compiler for a parent type is found, this method
...
...
@@ -394,7 +415,10 @@ public class IntentManager
boolean
compileAllFailed
)
{
// Attempt recompilation of the specified intents first.
for
(
IntentId
intentId
:
intentIds
)
{
executeRecompilingPhase
(
getIntent
(
intentId
));
Intent
intent
=
getIntent
(
intentId
);
uninstallIntent
(
intent
);
delay
(
1000
);
executeRecompilingPhase
(
intent
);
}
if
(
compileAllFailed
)
{
...
...
core/net/src/main/java/org/onlab/onos/net/intent/impl/ObjectiveTracker.java
View file @
53945d5
...
...
@@ -113,7 +113,7 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
@Override
public
void
run
()
{
if
(
event
.
reasons
()
==
null
)
{
delegate
.
triggerCompile
(
null
,
fals
e
);
delegate
.
triggerCompile
(
null
,
tru
e
);
}
else
{
Set
<
IntentId
>
toBeRecompiled
=
new
HashSet
<>();
...
...
Please
register
or
login
to post a comment