String[] cols = {CONTROLLER_ID,
CONTROLLER_SYNC_ID,
CONTROLLER_SYNC_DOMAIN_ID,
CONTROLLER_SYNC_PORT};
IResultSet res = null;
try {
res = storageSource.executeQuery(CONTROLLER_TABLE_NAME,
cols, null, null);
while (res.next()) {
String controllerId = res.getString(CONTROLLER_ID);
if (!res.containsColumn(CONTROLLER_SYNC_ID) ||
!res.containsColumn(CONTROLLER_SYNC_DOMAIN_ID) ||
!res.containsColumn(CONTROLLER_SYNC_PORT)) {
logger.debug("No sync data found for {}", controllerId);
continue;
}
short nodeId = res.getShort(CONTROLLER_SYNC_ID);
short domainId = res.getShort(CONTROLLER_SYNC_DOMAIN_ID);
int port = res.getInt(CONTROLLER_SYNC_PORT);
String syncIp = getNodeIP(controllerId);
if (syncIp == null) {
logger.debug("No sync IP found for {}", controllerId);
continue;
}
Node node = new Node(syncIp, port, nodeId, domainId);
nodes.add(node);
if (thisControllerID.equals(controllerId))
thisNodeId = nodeId;
}
} finally {
if (res != null) res.close();
}
if (nodes.size() == 0)
throw new SyncException("No valid nodes found");
if (thisNodeId < 0)