//create cluster state entities if not present
executeInTransaction(new Runnable() {
@Override
public void run() {
ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
ClusterStateDAO clusterStateDAO = injector.getInstance(ClusterStateDAO.class);
List<ClusterEntity> clusterEntities = clusterDAO.findAll();
for (ClusterEntity clusterEntity : clusterEntities) {
if (clusterStateDAO.findByPK(clusterEntity.getClusterId()) == null) {
ClusterStateEntity clusterStateEntity = new ClusterStateEntity();
clusterStateEntity.setClusterEntity(clusterEntity);
clusterStateEntity.setCurrentStackVersion(clusterEntity.getDesiredStackVersion());
clusterStateDAO.create(clusterStateEntity);
clusterEntity.setClusterStateEntity(clusterStateEntity);
clusterDAO.merge(clusterEntity);
}