Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
floodlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
croft1
floodlight
Commits
be2f6ead
Commit
be2f6ead
authored
13 years ago
by
Kanzhe Jiang
Browse files
Options
Downloads
Patches
Plain Diff
remove unnecessary daily deviceStorage, some cleanup in deviceAging
parent
8a912034
Branches
release.asplus
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
+12
-125
12 additions, 125 deletions
...tcontroller/devicemanager/internal/DeviceManagerImpl.java
with
12 additions
and
125 deletions
src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
+
12
−
125
View file @
be2f6ead
...
@@ -435,6 +435,7 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
...
@@ -435,6 +435,7 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
delFromIpv4AddressDeviceMap
(
nwAddr
,
d
);
delFromIpv4AddressDeviceMap
(
nwAddr
,
d
);
dCopy
.
removeNetworkAddress
(
na
);
dCopy
.
removeNetworkAddress
(
na
);
updateMaps
(
dCopy
);
updateMaps
(
dCopy
);
removeNetworkAddressFromStorage
(
d
,
na
);
}
}
d
=
null
;
// to catch if anyone is using this reference
d
=
null
;
// to catch if anyone is using this reference
}
}
...
@@ -527,8 +528,9 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
...
@@ -527,8 +528,9 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
// Now add this updated device to the maps, which will replace
// Now add this updated device to the maps, which will replace
// the old copy
// the old copy
updateMaps
(
dCopy
);
updateMaps
(
dCopy
);
log
.
debug
(
"Device 1 {}"
,
d
);
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"Device 2 {}"
,
dCopy
);
log
.
debug
(
"Remove AP {} for Device {}"
,
dap
,
d
);
}
removeAttachmentPointFromStorage
(
d
,
dap
);
removeAttachmentPointFromStorage
(
d
,
dap
);
d
=
null
;
// to catch if anyone is using this reference
d
=
null
;
// to catch if anyone is using this reference
}
}
...
@@ -703,15 +705,15 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
...
@@ -703,15 +705,15 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
floodlightProvider
.
addOFMessageListener
(
OFType
.
PORT_STATUS
,
this
);
floodlightProvider
.
addOFMessageListener
(
OFType
.
PORT_STATUS
,
this
);
floodlightProvider
.
addOFSwitchListener
(
this
);
floodlightProvider
.
addOFSwitchListener
(
this
);
storageSource
.
addListener
(
PORT_CHANNEL_TABLE_NAME
,
this
);
storageSource
.
addListener
(
PORT_CHANNEL_TABLE_NAME
,
this
);
// Read all our device state (MACs, IPs, attachment points) from storage
readAllDeviceStateFromStorage
();
readPortChannelConfigFromStorage
();
/*
/*
* Device and storage aging.
* Device and storage aging.
*/
*/
enableDeviceAgingTimer
();
enableDeviceAgingTimer
();
// Read all our device state (MACs, IPs, attachment points) from storage
readAllDeviceStateFromStorage
();
readPortChannelConfigFromStorage
();
}
}
public
void
shutDown
()
{
public
void
shutDown
()
{
...
@@ -1500,7 +1502,7 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
...
@@ -1500,7 +1502,7 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
storageSource
.
deleteRowAsync
(
storageSource
.
deleteRowAsync
(
DEVICE_ATTACHMENT_POINT_TABLE_NAME
,
attachmentPointId
);
DEVICE_ATTACHMENT_POINT_TABLE_NAME
,
attachmentPointId
);
}
catch
(
NullPointerException
e
)
{
}
catch
(
NullPointerException
e
)
{
log
.
debug
(
"Null ptr exception for device {} attach-point {}"
,
log
.
warn
(
"Null ptr exception for device {} attach-point {}"
,
device
,
attachmentPoint
);
device
,
attachmentPoint
);
}
}
}
}
...
@@ -1732,7 +1734,6 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
...
@@ -1732,7 +1734,6 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
if
(
address
.
getLastSeen
().
before
(
agedBoundary
))
{
if
(
address
.
getLastSeen
().
before
(
agedBoundary
))
{
devMgrMaps
.
delNwAddrByDataLayerAddr
(
device
.
getDataLayerAddressAsLong
(),
devMgrMaps
.
delNwAddrByDataLayerAddr
(
device
.
getDataLayerAddressAsLong
(),
address
.
getNetworkAddress
().
intValue
());
address
.
getNetworkAddress
().
intValue
());
removeNetworkAddressFromStorage
(
device
,
address
);
}
}
}
}
...
@@ -1758,7 +1759,6 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
...
@@ -1758,7 +1759,6 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
Date
agedBoundary
=
ageBoundaryDifference
(
currentDate
,
expire
);
Date
agedBoundary
=
ageBoundaryDifference
(
currentDate
,
expire
);
if
(
ap
.
getLastSeen
().
before
(
agedBoundary
))
{
if
(
ap
.
getLastSeen
().
before
(
agedBoundary
))
{
devMgrMaps
.
delDevAttachmentPoint
(
device
,
ap
.
getSwitchPort
());
devMgrMaps
.
delDevAttachmentPoint
(
device
,
ap
.
getSwitchPort
());
removeAttachmentPointFromStorage
(
device
,
ap
);
}
}
}
}
...
@@ -1785,121 +1785,6 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
...
@@ -1785,121 +1785,6 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
}
}
}
}
/**
* Removes aged rows in a table, based on the tables LAST_SEEN_COLUMN_NAME,
* requiring 'last_seen' to exist in the table.
*
* @param tableName
* @param aging
* @param currentDate
*/
private
void
removeAgedRowsFromStorage
(
String
tableName
,
String
hostIdFieldName
,
int
aging
,
Date
currentDate
)
{
if
(
aging
==
0
)
{
return
;
}
Date
ageBoundary
=
ageBoundaryDifference
(
currentDate
,
DEVICE_MAX_AGE
);
IResultSet
resultSet
=
null
;
try
{
/**
* The reason this storage call is asynchronous even though it's
* immediately followed by a synchronous get is that there may be
* other queued up asynchronous storage operations that would affect
* the results of executing this query. So we make this call
* asynchronous as well so that we see the affects of the previous
* asynchronous calls.
*/
Future
<
IResultSet
>
future
=
storageSource
.
executeQueryAsync
(
tableName
,
null
,
new
OperatorPredicate
(
LAST_SEEN_COLUMN_NAME
,
OperatorPredicate
.
Operator
.
LT
,
ageBoundary
),
null
);
// FIXME: What timeout should we use here?
resultSet
=
future
.
get
(
30
,
TimeUnit
.
SECONDS
);
while
(
resultSet
.
next
())
{
String
dlAddrStr
=
resultSet
.
getString
(
hostIdFieldName
);
if
(
dlAddrStr
==
null
)
{
continue
;
}
long
dlAddr
=
HexString
.
toLong
(
dlAddrStr
);
log
.
debug
(
"removeRowsFromTable:"
+
hostIdFieldName
+
" "
+
resultSet
.
getString
(
hostIdFieldName
)
+
" "
+
dlAddr
+
" "
+
resultSet
.
getDate
(
LAST_SEEN_COLUMN_NAME
).
toString
()
+
" "
+
currentDate
.
toString
());
lock
.
writeLock
().
lock
();
try
{
devMgrMaps
.
delFromMaps
(
dlAddr
);
}
finally
{
lock
.
writeLock
().
unlock
();
}
resultSet
.
deleteRow
();
}
resultSet
.
save
();
resultSet
.
close
();
resultSet
=
null
;
}
catch
(
ExecutionException
exc
)
{
log
.
error
(
"Error accessing storage to remove old devices"
,
exc
);
}
catch
(
InterruptedException
exc
)
{
log
.
error
(
"Interruption accessing storage to remove old devices"
,
exc
);
}
catch
(
TimeoutException
exc
)
{
log
.
warn
(
"Timeout accessing storage to remove old devices"
,
exc
);
}
finally
{
if
(
resultSet
!=
null
)
{
resultSet
.
close
();
}
}
}
/**
* Expire all age-out managed state. Not intended to be called
* frequently since storage is queried.
*/
private
void
removeAgedDeviceStorageState
(
Date
currentDate
)
{
removeAgedRowsFromStorage
(
DEVICE_TABLE_NAME
,
MAC_COLUMN_NAME
,
DEVICE_MAX_AGE
,
currentDate
);
removeAgedRowsFromStorage
(
DEVICE_ATTACHMENT_POINT_TABLE_NAME
,
DEVICE_COLUMN_NAME
,
DEVICE_AP_MAX_AGE
,
currentDate
);
removeAgedRowsFromStorage
(
DEVICE_NETWORK_ADDRESS_TABLE_NAME
,
DEVICE_COLUMN_NAME
,
DEVICE_NA_MAX_AGE
,
currentDate
);
}
private
void
removeAgedDeviceState
()
{
Date
currentDate
=
new
Date
();
long
dayInMsec
=
TimeUnit
.
MILLISECONDS
.
convert
(
1
,
TimeUnit
.
DAYS
);
removeAgedDevices
(
currentDate
);
/*
* Once a day review the storage state to expire very
* old entries.
*/
Date
yesterday
=
new
Date
(
currentDate
.
getTime
()
-
dayInMsec
);
if
((
previousStorageAudit
==
null
)
||
(
previousStorageAudit
.
before
(
yesterday
)))
{
previousStorageAudit
=
currentDate
;
removeAgedDeviceStorageState
(
currentDate
);
}
}
private
static
final
int
DEVICE_AGING_TIMER
=
15
;
// in minutes
private
static
final
int
DEVICE_AGING_TIMER
=
15
;
// in minutes
private
static
final
int
DEVICE_AGING_TIMER_INTERVAL
=
1
;
// in seconds
private
static
final
int
DEVICE_AGING_TIMER_INTERVAL
=
1
;
// in seconds
...
@@ -1917,7 +1802,9 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
...
@@ -1917,7 +1802,9 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
public
void
run
()
{
public
void
run
()
{
log
.
debug
(
"Running device aging timer {} minutes"
,
log
.
debug
(
"Running device aging timer {} minutes"
,
DEVICE_AGING_TIMER
);
DEVICE_AGING_TIMER
);
removeAgedDeviceState
();
Date
currentDate
=
new
Date
();
removeAgedDevices
(
currentDate
);
if
(
deviceAgingTimer
!=
null
)
{
if
(
deviceAgingTimer
!=
null
)
{
ScheduledExecutorService
ses
=
ScheduledExecutorService
ses
=
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment