try{
newNodeToStateMap = getNodeIdToStatusMap();
}catch (Exception e) {
release();
throw new CloudControllerException(e.getMessage(), e);
}
// compare it with old map and populate data to be published with ones newly added
// and once whose state got changed
populateNewlyAddedOrStateChangedNodes(newNodeToStateMap);
// issue events for the ones obtained from above
for (CartridgeInstanceData dataObj : dataToBePublished) {
StringBuffer temp = new StringBuffer("");
String privateIpAddresses="";
// Concatenate private IP addresses
for (String ip : dataObj.getMetaData().getPrivateAddresses()) {
temp.append(ip+",");
}
if(!"".equals(temp.toString())){
// remove comma at the end of the string
privateIpAddresses = temp.toString().substring(0, temp.toString().length()-1);
}
temp = new StringBuffer("");
String publicIpAddresses="";
// Concatenate public IP addresses
for (String ip : dataObj.getMetaData().getPublicAddresses()) {
temp.append(ip+",");
}
if(!"".equals(temp.toString())){
// remove comma at the end of the string
publicIpAddresses = temp.toString().substring(0, temp.toString().length()-1);
}
try {
Event cloudControllerEvent = new Event(streamId, System.currentTimeMillis(), new Object[]{}, null,
new Object[]{dataObj.getNodeId(),
dataObj.getType(),
dataObj.getDomain(),
dataObj.getSubDomain(),
dataObj.getAlias(),
dataObj.getTenantRange(),
String.valueOf(dataObj.isMultiTenant()),
dataObj.getIaas(),
dataObj.getStatus(),
dataObj.getMetaData().getHostname(),
dataObj.getMetaData().getHardware().getHypervisor(),
String.valueOf(dataObj.getMetaData().getHardware().getRam()),
dataObj.getMetaData().getImageId(),
String.valueOf(dataObj.getMetaData().getLoginPort()),
dataObj.getMetaData().getOperatingSystem().getName(),
dataObj.getMetaData().getOperatingSystem().getVersion(),
dataObj.getMetaData().getOperatingSystem().getArch(),
String.valueOf(dataObj.getMetaData().getOperatingSystem().is64Bit()),
privateIpAddresses,
publicIpAddresses});
dataPublisher.publish(cloudControllerEvent);
log.debug("Data published : "+cloudControllerEvent.toString());
} catch (Exception e) {
String msg = "Error occurred while publishing Cartridge instance event to BAM. ";
log.error(msg, e);
release();
throw new CloudControllerException(msg, e);
}
}
// replace old map with new one only if data is published