}
}
break;
}
}
<<<<<<< HEAD
if (deleteQueue != null) {
for (Long l : deleteQueue) {
deviceMap.remove(l);
}
=======
synchronized (d) {
/**
* Since the update below is happening on a copy of the device it
* should not impact packetIn processing time due to lock contention
*
* Also make sure the attachmentPoints are in non-blocked state
*/
for (DeviceAttachmentPoint dap: tempAPMap.values()) {
if (log.isDebugEnabled()) {
log.debug("Reset AP {} for device {}", dap, d);
}
//dap.setBlocked(false);
dap.resetConflictState();
}
d.setAttachmentPoints(tempAPMap.values());
for (DeviceAttachmentPoint dap : tempOldAPMap.values()) {
if (log.isDebugEnabled()) {
log.debug("Reset Old AP {} for device {}", dap, d);
}
//dap.setBlocked(false);
dap.resetConflictState();
d.addOldAttachmentPoint(dap);
}
if (log.isDebugEnabled()) {
public void clearAllDeviceStateFromMemory() {
log.debug("After cleanup, device {}", d);
}
devMgrMaps.clearMaps();
}
private Date ageBoundaryDifference(Date currentDate, long expire) {
if (expire == 0) {
return new Date(0);
}
return new Date(currentDate.getTime() - 1000*expire);
}
// *********************
// Storage Write Methods
// *********************
protected void writeDeviceToStorage(Device device, Date currentDate) {
Map rowValues = new HashMap();
String macString = device.getDlAddrString();
rowValues.put(MAC_COLUMN_NAME, macString);
if (device.getVlanId() != null)
rowValues.put(VLAN_COLUMN_NAME, device.getVlanId());
rowValues.put(LAST_SEEN_COLUMN_NAME, currentDate);
storageSource.updateRowAsync(DEVICE_TABLE_NAME, rowValues);
device.lastSeenWrittenToStorage(currentDate);
for (DeviceAttachmentPoint attachmentPoint:
device.getAttachmentPoints()) {
writeAttachmentPointToStorage(device, attachmentPoint, currentDate);
}
for (DeviceNetworkAddress networkAddress:
device.getNetworkAddresses()) {
writeNetworkAddressToStorage(device, networkAddress, currentDate);
}
}
protected void writeAttachmentPointToStorage(Device device,
DeviceAttachmentPoint attachmentPoint, Date currentDate) {
assert(device != null);
assert(attachmentPoint != null);
String deviceId = device.getDlAddrString();
SwitchPortTuple switchPort = attachmentPoint.getSwitchPort();
assert(switchPort != null);
String switchId = switchPort.getSw().getStringId();
Short port = switchPort.getPort();
String attachmentPointId =
deviceId + "|" + switchId + "|" + port.toString();
Map rowValues = new HashMap();
rowValues.put(ID_COLUMN_NAME, attachmentPointId);
rowValues.put(DEVICE_COLUMN_NAME, deviceId);
rowValues.put(SWITCH_COLUMN_NAME, switchId);
rowValues.put(PORT_COLUMN_NAME, port);
rowValues.put(LAST_SEEN_COLUMN_NAME, attachmentPoint.getLastSeen());
String status = null;
if (attachmentPoint.isBlocked())
status = "blocked: duplicate mac";
rowValues.put(AP_STATUS_COLUMN_NAME, status);
storageSource.updateRowAsync(DEVICE_ATTACHMENT_POINT_TABLE_NAME,
rowValues);
attachmentPoint.lastSeenWrittenToStorage(currentDate);
}
// **********************
// Storage Remove Methods
// **********************
protected void removeAttachmentPointFromStorage(String deviceId,
String switchId, String port) {
String attachmentPointId =
deviceId + "|" + switchId + "|" + port;
try {
storageSource.deleteRowAsync(
DEVICE_ATTACHMENT_POINT_TABLE_NAME, attachmentPointId);
} catch (NullPointerException e) {
log.warn("Null ptr exception for device {} on sw {} port {}",
new Object[] {deviceId, switchId, port});
}
}
protected void writeNetworkAddressToStorage(Device device,
DeviceNetworkAddress networkAddress, Date currentDate) {
assert(device != null);
assert(networkAddress != null);
String deviceId = device.getDlAddrString();
String networkAddressString = IPv4.fromIPv4Address(
networkAddress.getNetworkAddress());
String networkAddressId = deviceId + "|" + networkAddressString;
if (networkAddress.getNetworkAddress() == 0) {
log.error("Zero network address for device {}\n {}",
device, Thread.currentThread().getStackTrace());
return;
>>>>>>> e2c095ca47fbba2ca8981bb7cf625af100d7ff39
}
processUpdates(deviceUpdates); |