mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-16 10:32:34 +01:00
removed import of componentlocator and inject from all files
This commit is contained in:
parent
395de6f2b3
commit
56e5fbdee2
@ -141,7 +141,7 @@ public abstract class BaseCmd {
|
|||||||
|
|
||||||
public static QueryService _queryService;
|
public static QueryService _queryService;
|
||||||
|
|
||||||
static void setComponents(ResponseGenerator generator) {
|
public static void setComponents(ResponseGenerator generator) {
|
||||||
_mgr = ComponentContext.getComponent(ManagementService.class);
|
_mgr = ComponentContext.getComponent(ManagementService.class);
|
||||||
_accountService = ComponentContext.getComponent(AccountService.class);
|
_accountService = ComponentContext.getComponent(AccountService.class);
|
||||||
_configService = ComponentContext.getComponent(ConfigurationService.class);
|
_configService = ComponentContext.getComponent(ConfigurationService.class);
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import java.net.URI;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@ -46,15 +47,13 @@ import com.cloud.storage.resource.SecondaryStorageResource;
|
|||||||
import com.cloud.storage.template.TemplateUploader.Status;
|
import com.cloud.storage.template.TemplateUploader.Status;
|
||||||
import com.cloud.storage.template.TemplateUploader.UploadCompleteCallback;
|
import com.cloud.storage.template.TemplateUploader.UploadCompleteCallback;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.component.Adapters;
|
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.utils.script.Script;
|
import com.cloud.utils.script.Script;
|
||||||
|
|
||||||
public class UploadManagerImpl implements UploadManager {
|
public class UploadManagerImpl implements UploadManager {
|
||||||
|
|
||||||
|
|
||||||
public class Completion implements UploadCompleteCallback {
|
public class Completion implements UploadCompleteCallback {
|
||||||
private final String jobId;
|
private final String jobId;
|
||||||
|
|
||||||
public Completion(String jobId) {
|
public Completion(String jobId) {
|
||||||
@ -67,125 +66,125 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class UploadJob {
|
private static class UploadJob {
|
||||||
private final TemplateUploader tu;
|
private final TemplateUploader tu;
|
||||||
private final String jobId;
|
private final String jobId;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final ImageFormat format;
|
private final ImageFormat format;
|
||||||
private String tmpltPath;
|
private String tmpltPath;
|
||||||
private String description;
|
private String description;
|
||||||
private String checksum;
|
private String checksum;
|
||||||
private Long accountId;
|
private Long accountId;
|
||||||
private String installPathPrefix;
|
private String installPathPrefix;
|
||||||
private long templatesize;
|
private long templatesize;
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
public UploadJob(TemplateUploader tu, String jobId, long id, String name, ImageFormat format, boolean hvm, Long accountId, String descr, String cksum, String installPathPrefix) {
|
public UploadJob(TemplateUploader tu, String jobId, long id, String name, ImageFormat format, boolean hvm, Long accountId, String descr, String cksum, String installPathPrefix) {
|
||||||
super();
|
super();
|
||||||
this.tu = tu;
|
this.tu = tu;
|
||||||
this.jobId = jobId;
|
this.jobId = jobId;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.format = format;
|
this.format = format;
|
||||||
this.accountId = accountId;
|
this.accountId = accountId;
|
||||||
this.description = descr;
|
this.description = descr;
|
||||||
this.checksum = cksum;
|
this.checksum = cksum;
|
||||||
this.installPathPrefix = installPathPrefix;
|
this.installPathPrefix = installPathPrefix;
|
||||||
this.templatesize = 0;
|
this.templatesize = 0;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TemplateUploader getTd() {
|
public TemplateUploader getTd() {
|
||||||
return tu;
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getChecksum() {
|
public String getChecksum() {
|
||||||
return checksum;
|
return checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UploadJob(TemplateUploader td, String jobId, UploadCommand cmd) {
|
public UploadJob(TemplateUploader td, String jobId, UploadCommand cmd) {
|
||||||
this.tu = td;
|
this.tu = td;
|
||||||
this.jobId = jobId;
|
this.jobId = jobId;
|
||||||
this.name = cmd.getName();
|
this.name = cmd.getName();
|
||||||
this.format = cmd.getFormat();
|
this.format = cmd.getFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TemplateUploader getTemplateUploader() {
|
public TemplateUploader getTemplateUploader() {
|
||||||
return tu;
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getJobId() {
|
public String getJobId() {
|
||||||
return jobId;
|
return jobId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTmpltName() {
|
public String getTmpltName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageFormat getFormat() {
|
public ImageFormat getFormat() {
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getAccountId() {
|
public Long getAccountId() {
|
||||||
return accountId;
|
return accountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTmpltPath(String tmpltPath) {
|
public void setTmpltPath(String tmpltPath) {
|
||||||
this.tmpltPath = tmpltPath;
|
this.tmpltPath = tmpltPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTmpltPath() {
|
public String getTmpltPath() {
|
||||||
return tmpltPath;
|
return tmpltPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInstallPathPrefix() {
|
public String getInstallPathPrefix() {
|
||||||
return installPathPrefix;
|
return installPathPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
if (tu != null) {
|
if (tu != null) {
|
||||||
String upldPath = tu.getUploadLocalPath();
|
String upldPath = tu.getUploadLocalPath();
|
||||||
if (upldPath != null) {
|
if (upldPath != null) {
|
||||||
File f = new File(upldPath);
|
File f = new File(upldPath);
|
||||||
f.delete();
|
f.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTemplatesize(long templatesize) {
|
public void setTemplatesize(long templatesize) {
|
||||||
this.templatesize = templatesize;
|
this.templatesize = templatesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTemplatesize() {
|
public long getTemplatesize() {
|
||||||
return templatesize;
|
return templatesize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static final Logger s_logger = Logger.getLogger(UploadManagerImpl.class);
|
public static final Logger s_logger = Logger.getLogger(UploadManagerImpl.class);
|
||||||
private ExecutorService threadPool;
|
private ExecutorService threadPool;
|
||||||
private final Map<String, UploadJob> jobs = new ConcurrentHashMap<String, UploadJob>();
|
private final Map<String, UploadJob> jobs = new ConcurrentHashMap<String, UploadJob>();
|
||||||
private String parentDir;
|
private String parentDir;
|
||||||
private Adapters<Processor> _processors;
|
private List<Processor> _processors;
|
||||||
private String publicTemplateRepo;
|
private String publicTemplateRepo;
|
||||||
private String extractMountPoint = "/mnt/SecStorage/extractmnt";
|
private final String extractMountPoint = "/mnt/SecStorage/extractmnt";
|
||||||
private StorageLayer _storage;
|
private StorageLayer _storage;
|
||||||
private int installTimeoutPerGig;
|
private int installTimeoutPerGig;
|
||||||
private boolean _sslCopy;
|
private boolean _sslCopy;
|
||||||
private String _name;
|
private String _name;
|
||||||
private boolean hvm;
|
private boolean hvm;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String uploadPublicTemplate(long id, String url, String name,
|
public String uploadPublicTemplate(long id, String url, String name,
|
||||||
ImageFormat format, Long accountId, String descr,
|
ImageFormat format, Long accountId, String descr,
|
||||||
String cksum, String installPathPrefix, String userName,
|
String cksum, String installPathPrefix, String userName,
|
||||||
String passwd, long templateSizeInBytes) {
|
String passwd, long templateSizeInBytes) {
|
||||||
|
|
||||||
UUID uuid = UUID.randomUUID();
|
UUID uuid = UUID.randomUUID();
|
||||||
String jobId = uuid.toString();
|
String jobId = uuid.toString();
|
||||||
@ -194,52 +193,52 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
s_logger.debug("Starting upload from " + completePath);
|
s_logger.debug("Starting upload from " + completePath);
|
||||||
|
|
||||||
URI uri;
|
URI uri;
|
||||||
try {
|
try {
|
||||||
uri = new URI(url);
|
uri = new URI(url);
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
s_logger.error("URI is incorrect: " + url);
|
s_logger.error("URI is incorrect: " + url);
|
||||||
throw new CloudRuntimeException("URI is incorrect: " + url);
|
throw new CloudRuntimeException("URI is incorrect: " + url);
|
||||||
}
|
}
|
||||||
TemplateUploader tu;
|
TemplateUploader tu;
|
||||||
if ((uri != null) && (uri.getScheme() != null)) {
|
if ((uri != null) && (uri.getScheme() != null)) {
|
||||||
if (uri.getScheme().equalsIgnoreCase("ftp")) {
|
if (uri.getScheme().equalsIgnoreCase("ftp")) {
|
||||||
tu = new FtpTemplateUploader(completePath, url, new Completion(jobId), templateSizeInBytes);
|
tu = new FtpTemplateUploader(completePath, url, new Completion(jobId), templateSizeInBytes);
|
||||||
} else {
|
} else {
|
||||||
s_logger.error("Scheme is not supported " + url);
|
s_logger.error("Scheme is not supported " + url);
|
||||||
throw new CloudRuntimeException("Scheme is not supported " + url);
|
throw new CloudRuntimeException("Scheme is not supported " + url);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s_logger.error("Unable to download from URL: " + url);
|
s_logger.error("Unable to download from URL: " + url);
|
||||||
throw new CloudRuntimeException("Unable to download from URL: " + url);
|
throw new CloudRuntimeException("Unable to download from URL: " + url);
|
||||||
}
|
}
|
||||||
UploadJob uj = new UploadJob(tu, jobId, id, name, format, hvm, accountId, descr, cksum, installPathPrefix);
|
UploadJob uj = new UploadJob(tu, jobId, id, name, format, hvm, accountId, descr, cksum, installPathPrefix);
|
||||||
jobs.put(jobId, uj);
|
jobs.put(jobId, uj);
|
||||||
threadPool.execute(tu);
|
threadPool.execute(tu);
|
||||||
|
|
||||||
return jobId;
|
return jobId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUploadError(String jobId) {
|
public String getUploadError(String jobId) {
|
||||||
UploadJob uj = jobs.get(jobId);
|
UploadJob uj = jobs.get(jobId);
|
||||||
if (uj != null) {
|
if (uj != null) {
|
||||||
return uj.getTemplateUploader().getUploadError();
|
return uj.getTemplateUploader().getUploadError();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getUploadPct(String jobId) {
|
public int getUploadPct(String jobId) {
|
||||||
UploadJob uj = jobs.get(jobId);
|
UploadJob uj = jobs.get(jobId);
|
||||||
if (uj != null) {
|
if (uj != null) {
|
||||||
return uj.getTemplateUploader().getUploadPercent();
|
return uj.getTemplateUploader().getUploadPercent();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Status getUploadStatus(String jobId) {
|
public Status getUploadStatus(String jobId) {
|
||||||
UploadJob job = jobs.get(jobId);
|
UploadJob job = jobs.get(jobId);
|
||||||
if (job != null) {
|
if (job != null) {
|
||||||
TemplateUploader tu = job.getTemplateUploader();
|
TemplateUploader tu = job.getTemplateUploader();
|
||||||
@ -248,7 +247,7 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Status.UNKNOWN;
|
return Status.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UploadVO.Status convertStatus(Status tds) {
|
public static UploadVO.Status convertStatus(Status tds) {
|
||||||
switch (tds) {
|
switch (tds) {
|
||||||
@ -277,11 +276,11 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
public com.cloud.storage.UploadVO.Status getUploadStatus2(String jobId) {
|
public com.cloud.storage.UploadVO.Status getUploadStatus2(String jobId) {
|
||||||
return convertStatus(getUploadStatus(jobId));
|
return convertStatus(getUploadStatus(jobId));
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String getPublicTemplateRepo() {
|
public String getPublicTemplateRepo() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UploadAnswer handleUploadProgressCmd(UploadProgressCommand cmd) {
|
private UploadAnswer handleUploadProgressCmd(UploadProgressCommand cmd) {
|
||||||
String jobId = cmd.getJobId();
|
String jobId = cmd.getJobId();
|
||||||
@ -290,7 +289,7 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
if (jobId != null)
|
if (jobId != null)
|
||||||
uj = jobs.get(jobId);
|
uj = jobs.get(jobId);
|
||||||
if (uj == null) {
|
if (uj == null) {
|
||||||
return new UploadAnswer(null, 0, "Cannot find job", com.cloud.storage.UploadVO.Status.UNKNOWN, "", "", 0);
|
return new UploadAnswer(null, 0, "Cannot find job", com.cloud.storage.UploadVO.Status.UNKNOWN, "", "", 0);
|
||||||
}
|
}
|
||||||
TemplateUploader td = uj.getTemplateUploader();
|
TemplateUploader td = uj.getTemplateUploader();
|
||||||
switch (cmd.getRequest()) {
|
switch (cmd.getRequest()) {
|
||||||
@ -300,7 +299,7 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
td.stopUpload();
|
td.stopUpload();
|
||||||
sleep();
|
sleep();
|
||||||
break;
|
break;
|
||||||
/*case RESTART:
|
/*case RESTART:
|
||||||
td.stopUpload();
|
td.stopUpload();
|
||||||
sleep();
|
sleep();
|
||||||
threadPool.execute(td);
|
threadPool.execute(td);
|
||||||
@ -319,7 +318,7 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UploadAnswer handleUploadCommand(SecondaryStorageResource resource, UploadCommand cmd) {
|
public UploadAnswer handleUploadCommand(SecondaryStorageResource resource, UploadCommand cmd) {
|
||||||
s_logger.warn("Handling the upload " +cmd.getInstallPath() + " " + cmd.getId());
|
s_logger.warn("Handling the upload " +cmd.getInstallPath() + " " + cmd.getId());
|
||||||
if (cmd instanceof UploadProgressCommand) {
|
if (cmd instanceof UploadProgressCommand) {
|
||||||
return handleUploadProgressCmd((UploadProgressCommand) cmd);
|
return handleUploadProgressCmd((UploadProgressCommand) cmd);
|
||||||
}
|
}
|
||||||
@ -327,9 +326,9 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
String user = null;
|
String user = null;
|
||||||
String password = null;
|
String password = null;
|
||||||
String jobId = uploadPublicTemplate(cmd.getId(), cmd.getUrl(), cmd.getName(),
|
String jobId = uploadPublicTemplate(cmd.getId(), cmd.getUrl(), cmd.getName(),
|
||||||
cmd.getFormat(), cmd.getAccountId(), cmd.getDescription(),
|
cmd.getFormat(), cmd.getAccountId(), cmd.getDescription(),
|
||||||
cmd.getChecksum(), cmd.getInstallPath(), user, password,
|
cmd.getChecksum(), cmd.getInstallPath(), user, password,
|
||||||
cmd.getTemplateSizeInBytes());
|
cmd.getTemplateSizeInBytes());
|
||||||
sleep();
|
sleep();
|
||||||
if (jobId == null) {
|
if (jobId == null) {
|
||||||
return new UploadAnswer(null, 0, "Internal Error", com.cloud.storage.UploadVO.Status.UPLOAD_ERROR, "", "", 0);
|
return new UploadAnswer(null, 0, "Internal Error", com.cloud.storage.UploadVO.Status.UPLOAD_ERROR, "", "", 0);
|
||||||
@ -341,14 +340,14 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
@Override
|
@Override
|
||||||
public CreateEntityDownloadURLAnswer handleCreateEntityURLCommand(CreateEntityDownloadURLCommand cmd){
|
public CreateEntityDownloadURLAnswer handleCreateEntityURLCommand(CreateEntityDownloadURLCommand cmd){
|
||||||
|
|
||||||
boolean isApacheUp = checkAndStartApache();
|
boolean isApacheUp = checkAndStartApache();
|
||||||
if (!isApacheUp){
|
if (!isApacheUp){
|
||||||
String errorString = "Error in starting Apache server ";
|
String errorString = "Error in starting Apache server ";
|
||||||
s_logger.error(errorString);
|
s_logger.error(errorString);
|
||||||
return new CreateEntityDownloadURLAnswer(errorString, CreateEntityDownloadURLAnswer.RESULT_FAILURE);
|
return new CreateEntityDownloadURLAnswer(errorString, CreateEntityDownloadURLAnswer.RESULT_FAILURE);
|
||||||
}
|
}
|
||||||
// Create the directory structure so that its visible under apache server root
|
// Create the directory structure so that its visible under apache server root
|
||||||
String extractDir = "/var/www/html/userdata/";
|
String extractDir = "/var/www/html/userdata/";
|
||||||
Script command = new Script("mkdir", s_logger);
|
Script command = new Script("mkdir", s_logger);
|
||||||
command.add("-p");
|
command.add("-p");
|
||||||
command.add(extractDir);
|
command.add(extractDir);
|
||||||
@ -361,14 +360,14 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
|
|
||||||
// Create a random file under the directory for security reasons.
|
// Create a random file under the directory for security reasons.
|
||||||
String uuid = cmd.getExtractLinkUUID();
|
String uuid = cmd.getExtractLinkUUID();
|
||||||
command = new Script("touch", s_logger);
|
command = new Script("touch", s_logger);
|
||||||
command.add(extractDir + uuid);
|
command.add(extractDir + uuid);
|
||||||
result = command.execute();
|
result = command.execute();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
String errorString = "Error in creating file " +uuid+ " ,error: " + result;
|
String errorString = "Error in creating file " +uuid+ " ,error: " + result;
|
||||||
s_logger.warn(errorString);
|
s_logger.warn(errorString);
|
||||||
return new CreateEntityDownloadURLAnswer(errorString, CreateEntityDownloadURLAnswer.RESULT_FAILURE);
|
return new CreateEntityDownloadURLAnswer(errorString, CreateEntityDownloadURLAnswer.RESULT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create a symbolic link from the actual directory to the template location. The entity would be directly visible under /var/www/html/userdata/cmd.getInstallPath();
|
// Create a symbolic link from the actual directory to the template location. The entity would be directly visible under /var/www/html/userdata/cmd.getInstallPath();
|
||||||
@ -395,7 +394,7 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
Script command = new Script("/bin/bash", s_logger);
|
Script command = new Script("/bin/bash", s_logger);
|
||||||
command.add("-c");
|
command.add("-c");
|
||||||
|
|
||||||
//We just need to remove the UUID.vhd
|
//We just need to remove the UUID.vhd
|
||||||
String extractUrl = cmd.getExtractUrl();
|
String extractUrl = cmd.getExtractUrl();
|
||||||
command.add("unlink /var/www/html/userdata/" +extractUrl.substring(extractUrl.lastIndexOf(File.separator) + 1));
|
command.add("unlink /var/www/html/userdata/" +extractUrl.substring(extractUrl.lastIndexOf(File.separator) + 1));
|
||||||
String result = command.execute();
|
String result = command.execute();
|
||||||
@ -422,27 +421,27 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
return new DeleteEntityDownloadURLAnswer("", CreateEntityDownloadURLAnswer.RESULT_SUCCESS);
|
return new DeleteEntityDownloadURLAnswer("", CreateEntityDownloadURLAnswer.RESULT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getInstallPath(String jobId) {
|
private String getInstallPath(String jobId) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getUploadLocalPath(String jobId) {
|
private String getUploadLocalPath(String jobId) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getUploadTemplateSize(String jobId){
|
private long getUploadTemplateSize(String jobId){
|
||||||
UploadJob uj = jobs.get(jobId);
|
UploadJob uj = jobs.get(jobId);
|
||||||
if (uj != null) {
|
if (uj != null) {
|
||||||
return uj.getTemplatesize();
|
return uj.getTemplatesize();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params)
|
public boolean configure(String name, Map<String, Object> params)
|
||||||
throws ConfigurationException {
|
throws ConfigurationException {
|
||||||
_name = name;
|
_name = name;
|
||||||
|
|
||||||
String value = null;
|
String value = null;
|
||||||
@ -457,21 +456,25 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
Class<StorageLayer> clazz;
|
Class<StorageLayer> clazz;
|
||||||
try {
|
try {
|
||||||
clazz = (Class<StorageLayer>) Class.forName(value);
|
clazz = (Class<StorageLayer>) Class.forName(value);
|
||||||
|
_storage = clazz.newInstance();
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new ConfigurationException("Unable to instantiate " + value);
|
throw new ConfigurationException("Unable to instantiate " + value);
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
throw new ConfigurationException("Unable to instantiate " + value);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new ConfigurationException("Unable to instantiate " + value);
|
||||||
}
|
}
|
||||||
_storage = ComponentLocator.inject(clazz);
|
|
||||||
}
|
}
|
||||||
String useSsl = (String)params.get("sslcopy");
|
String useSsl = (String)params.get("sslcopy");
|
||||||
if (useSsl != null) {
|
if (useSsl != null) {
|
||||||
_sslCopy = Boolean.parseBoolean(useSsl);
|
_sslCopy = Boolean.parseBoolean(useSsl);
|
||||||
|
|
||||||
}
|
}
|
||||||
String inSystemVM = (String)params.get("secondary.storage.vm");
|
String inSystemVM = (String)params.get("secondary.storage.vm");
|
||||||
if (inSystemVM != null && "true".equalsIgnoreCase(inSystemVM)) {
|
if (inSystemVM != null && "true".equalsIgnoreCase(inSystemVM)) {
|
||||||
s_logger.info("UploadManager: starting additional services since we are inside system vm");
|
s_logger.info("UploadManager: starting additional services since we are inside system vm");
|
||||||
startAdditionalServices();
|
startAdditionalServices();
|
||||||
//blockOutgoingOnPrivate();
|
//blockOutgoingOnPrivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
value = (String) params.get("install.timeout.pergig");
|
value = (String) params.get("install.timeout.pergig");
|
||||||
@ -489,53 +492,53 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
threadPool = Executors.newFixedThreadPool(numInstallThreads);
|
threadPool = Executors.newFixedThreadPool(numInstallThreads);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startAdditionalServices() {
|
private void startAdditionalServices() {
|
||||||
|
|
||||||
|
|
||||||
Script command = new Script("rm", s_logger);
|
Script command = new Script("rm", s_logger);
|
||||||
command.add("-rf");
|
command.add("-rf");
|
||||||
command.add(extractMountPoint);
|
command.add(extractMountPoint);
|
||||||
String result = command.execute();
|
String result = command.execute();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
s_logger.warn("Error in creating file " +extractMountPoint+ " ,error: " + result );
|
s_logger.warn("Error in creating file " +extractMountPoint+ " ,error: " + result );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
command = new Script("touch", s_logger);
|
command = new Script("touch", s_logger);
|
||||||
command.add(extractMountPoint);
|
command.add(extractMountPoint);
|
||||||
result = command.execute();
|
result = command.execute();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
s_logger.warn("Error in creating file " +extractMountPoint+ " ,error: " + result );
|
s_logger.warn("Error in creating file " +extractMountPoint+ " ,error: " + result );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
command = new Script("/bin/bash", s_logger);
|
command = new Script("/bin/bash", s_logger);
|
||||||
command.add("-c");
|
command.add("-c");
|
||||||
command.add("ln -sf " + parentDir + " " +extractMountPoint);
|
command.add("ln -sf " + parentDir + " " +extractMountPoint);
|
||||||
result = command.execute();
|
result = command.execute();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
s_logger.warn("Error in linking err=" + result );
|
s_logger.warn("Error in linking err=" + result );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean start() {
|
public boolean start() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stop() {
|
public boolean stop() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get notified of change of job status. Executed in context of uploader thread
|
* Get notified of change of job status. Executed in context of uploader thread
|
||||||
@ -582,7 +585,7 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
tu.setStatus(Status.UNRECOVERABLE_ERROR);
|
tu.setStatus(Status.UNRECOVERABLE_ERROR);
|
||||||
tu.setUploadError("Failed post upload script: " + result);
|
tu.setUploadError("Failed post upload script: " + result);
|
||||||
} else {
|
} else {
|
||||||
s_logger.warn("Upload completed successfully at " + new SimpleDateFormat().format(new Date()));
|
s_logger.warn("Upload completed successfully at " + new SimpleDateFormat().format(new Date()));
|
||||||
tu.setStatus(Status.POST_UPLOAD_FINISHED);
|
tu.setStatus(Status.POST_UPLOAD_FINISHED);
|
||||||
tu.setUploadError("Upload completed successfully at " + new SimpleDateFormat().format(new Date()));
|
tu.setUploadError("Upload completed successfully at " + new SimpleDateFormat().format(new Date()));
|
||||||
}
|
}
|
||||||
@ -596,9 +599,9 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String postUpload(String jobId) {
|
private String postUpload(String jobId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sleep() {
|
private void sleep() {
|
||||||
try {
|
try {
|
||||||
@ -608,18 +611,18 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkAndStartApache() {
|
private boolean checkAndStartApache() {
|
||||||
|
|
||||||
//Check whether the Apache server is running
|
//Check whether the Apache server is running
|
||||||
Script command = new Script("/bin/bash", s_logger);
|
Script command = new Script("/bin/bash", s_logger);
|
||||||
command.add("-c");
|
command.add("-c");
|
||||||
command.add("if [ -d /etc/apache2 ] ; then service apache2 status | grep pid; else service httpd status | grep pid; fi ");
|
command.add("if [ -d /etc/apache2 ] ; then service apache2 status | grep pid; else service httpd status | grep pid; fi ");
|
||||||
String result = command.execute();
|
String result = command.execute();
|
||||||
|
|
||||||
//Apache Server is not running. Try to start it.
|
//Apache Server is not running. Try to start it.
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
|
|
||||||
/*s_logger.warn("Apache server not running, trying to start it");
|
/*s_logger.warn("Apache server not running, trying to start it");
|
||||||
String port = Integer.toString(TemplateConstants.DEFAULT_TMPLT_COPY_PORT);
|
String port = Integer.toString(TemplateConstants.DEFAULT_TMPLT_COPY_PORT);
|
||||||
String intf = TemplateConstants.DEFAULT_TMPLT_COPY_INTF;
|
String intf = TemplateConstants.DEFAULT_TMPLT_COPY_INTF;
|
||||||
|
|
||||||
@ -643,16 +646,16 @@ public class UploadManagerImpl implements UploadManager {
|
|||||||
return false;
|
return false;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
command = new Script("/bin/bash", s_logger);
|
command = new Script("/bin/bash", s_logger);
|
||||||
command.add("-c");
|
command.add("-c");
|
||||||
command.add("if [ -d /etc/apache2 ] ; then service apache2 start; else service httpd start; fi ");
|
command.add("if [ -d /etc/apache2 ] ; then service apache2 start; else service httpd start; fi ");
|
||||||
result = command.execute();
|
result = command.execute();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
s_logger.warn("Error in starting httpd service err=" + result );
|
s_logger.warn("Error in starting httpd service err=" + result );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
|
|||||||
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
|
import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
|
public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
|
||||||
|
|||||||
@ -38,7 +38,7 @@ import com.cloud.storage.Storage.ImageFormat;
|
|||||||
import com.cloud.storage.Volume;
|
import com.cloud.storage.Volume;
|
||||||
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.GenericSearchBuilder;
|
import com.cloud.utils.db.GenericSearchBuilder;
|
||||||
|
|||||||
@ -29,7 +29,7 @@ import com.cloud.exception.InvalidParameterValueException;
|
|||||||
import com.cloud.netapp.NetappManager;
|
import com.cloud.netapp.NetappManager;
|
||||||
import com.cloud.server.ManagementService;
|
import com.cloud.server.ManagementService;
|
||||||
import com.cloud.server.api.response.netapp.AssociateLunCmdResponse;
|
import com.cloud.server.api.response.netapp.AssociateLunCmdResponse;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@APICommand(name = "associateLun", description="Associate a LUN with a guest IQN", responseObject = AssociateLunCmdResponse.class)
|
@APICommand(name = "associateLun", description="Associate a LUN with a guest IQN", responseObject = AssociateLunCmdResponse.class)
|
||||||
public class AssociateLunCmd extends BaseCmd {
|
public class AssociateLunCmd extends BaseCmd {
|
||||||
|
|||||||
@ -33,7 +33,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||||||
import com.cloud.netapp.NetappManager;
|
import com.cloud.netapp.NetappManager;
|
||||||
import com.cloud.server.ManagementService;
|
import com.cloud.server.ManagementService;
|
||||||
import com.cloud.server.api.response.netapp.CreateLunCmdResponse;
|
import com.cloud.server.api.response.netapp.CreateLunCmdResponse;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@APICommand(name = "createLunOnFiler", description="Create a LUN from a pool", responseObject = CreateLunCmdResponse.class)
|
@APICommand(name = "createLunOnFiler", description="Create a LUN from a pool", responseObject = CreateLunCmdResponse.class)
|
||||||
public class CreateLunCmd extends BaseCmd {
|
public class CreateLunCmd extends BaseCmd {
|
||||||
|
|||||||
@ -32,7 +32,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||||||
import com.cloud.netapp.NetappManager;
|
import com.cloud.netapp.NetappManager;
|
||||||
import com.cloud.server.ManagementService;
|
import com.cloud.server.ManagementService;
|
||||||
import com.cloud.server.api.response.netapp.CreateVolumeOnFilerCmdResponse;
|
import com.cloud.server.api.response.netapp.CreateVolumeOnFilerCmdResponse;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@APICommand(name = "createVolumeOnFiler", description="Create a volume", responseObject = CreateVolumeOnFilerCmdResponse.class)
|
@APICommand(name = "createVolumeOnFiler", description="Create a volume", responseObject = CreateVolumeOnFilerCmdResponse.class)
|
||||||
public class CreateVolumeOnFilerCmd extends BaseCmd {
|
public class CreateVolumeOnFilerCmd extends BaseCmd {
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||||||
import com.cloud.netapp.NetappManager;
|
import com.cloud.netapp.NetappManager;
|
||||||
import com.cloud.server.ManagementService;
|
import com.cloud.server.ManagementService;
|
||||||
import com.cloud.server.api.response.netapp.CreateVolumePoolCmdResponse;
|
import com.cloud.server.api.response.netapp.CreateVolumePoolCmdResponse;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@APICommand(name = "createPool", description="Create a pool", responseObject = CreateVolumePoolCmdResponse.class)
|
@APICommand(name = "createPool", description="Create a pool", responseObject = CreateVolumePoolCmdResponse.class)
|
||||||
public class CreateVolumePoolCmd extends BaseCmd {
|
public class CreateVolumePoolCmd extends BaseCmd {
|
||||||
|
|||||||
@ -33,7 +33,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||||||
import com.cloud.netapp.NetappManager;
|
import com.cloud.netapp.NetappManager;
|
||||||
import com.cloud.server.ManagementService;
|
import com.cloud.server.ManagementService;
|
||||||
import com.cloud.server.api.response.netapp.DeleteVolumePoolCmdResponse;
|
import com.cloud.server.api.response.netapp.DeleteVolumePoolCmdResponse;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@APICommand(name = "deletePool", description="Delete a pool", responseObject = DeleteVolumePoolCmdResponse.class)
|
@APICommand(name = "deletePool", description="Delete a pool", responseObject = DeleteVolumePoolCmdResponse.class)
|
||||||
public class DeleteVolumePoolCmd extends BaseCmd {
|
public class DeleteVolumePoolCmd extends BaseCmd {
|
||||||
|
|||||||
@ -33,7 +33,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||||||
import com.cloud.netapp.NetappManager;
|
import com.cloud.netapp.NetappManager;
|
||||||
import com.cloud.server.ManagementService;
|
import com.cloud.server.ManagementService;
|
||||||
import com.cloud.server.api.response.netapp.DeleteLUNCmdResponse;
|
import com.cloud.server.api.response.netapp.DeleteLUNCmdResponse;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@APICommand(name = "destroyLunOnFiler", description="Destroy a LUN", responseObject = DeleteLUNCmdResponse.class)
|
@APICommand(name = "destroyLunOnFiler", description="Destroy a LUN", responseObject = DeleteLUNCmdResponse.class)
|
||||||
public class DestroyLunCmd extends BaseCmd {
|
public class DestroyLunCmd extends BaseCmd {
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||||||
import com.cloud.netapp.NetappManager;
|
import com.cloud.netapp.NetappManager;
|
||||||
import com.cloud.server.ManagementService;
|
import com.cloud.server.ManagementService;
|
||||||
import com.cloud.server.api.response.netapp.DeleteVolumeOnFilerCmdResponse;
|
import com.cloud.server.api.response.netapp.DeleteVolumeOnFilerCmdResponse;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@APICommand(name = "destroyVolumeOnFiler", description="Destroy a Volume", responseObject = DeleteVolumeOnFilerCmdResponse.class)
|
@APICommand(name = "destroyVolumeOnFiler", description="Destroy a Volume", responseObject = DeleteVolumeOnFilerCmdResponse.class)
|
||||||
public class DestroyVolumeOnFilerCmd extends BaseCmd {
|
public class DestroyVolumeOnFilerCmd extends BaseCmd {
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||||||
import com.cloud.netapp.NetappManager;
|
import com.cloud.netapp.NetappManager;
|
||||||
import com.cloud.server.ManagementService;
|
import com.cloud.server.ManagementService;
|
||||||
import com.cloud.server.api.response.netapp.DissociateLunCmdResponse;
|
import com.cloud.server.api.response.netapp.DissociateLunCmdResponse;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@APICommand(name = "dissociateLun", description="Dissociate a LUN", responseObject = DissociateLunCmdResponse.class)
|
@APICommand(name = "dissociateLun", description="Dissociate a LUN", responseObject = DissociateLunCmdResponse.class)
|
||||||
public class DissociateLunCmd extends BaseCmd {
|
public class DissociateLunCmd extends BaseCmd {
|
||||||
|
|||||||
@ -36,7 +36,7 @@ import com.cloud.netapp.LunVO;
|
|||||||
import com.cloud.netapp.NetappManager;
|
import com.cloud.netapp.NetappManager;
|
||||||
import com.cloud.server.ManagementService;
|
import com.cloud.server.ManagementService;
|
||||||
import com.cloud.server.api.response.netapp.ListLunsCmdResponse;
|
import com.cloud.server.api.response.netapp.ListLunsCmdResponse;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@APICommand(name = "listLunsOnFiler", description="List LUN", responseObject = ListLunsCmdResponse.class)
|
@APICommand(name = "listLunsOnFiler", description="List LUN", responseObject = ListLunsCmdResponse.class)
|
||||||
public class ListLunsCmd extends BaseCmd
|
public class ListLunsCmd extends BaseCmd
|
||||||
|
|||||||
@ -34,7 +34,7 @@ import com.cloud.netapp.NetappManager;
|
|||||||
import com.cloud.netapp.PoolVO;
|
import com.cloud.netapp.PoolVO;
|
||||||
import com.cloud.server.ManagementService;
|
import com.cloud.server.ManagementService;
|
||||||
import com.cloud.server.api.response.netapp.ListVolumePoolsCmdResponse;
|
import com.cloud.server.api.response.netapp.ListVolumePoolsCmdResponse;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@APICommand(name = "listPools", description="List Pool", responseObject = ListVolumePoolsCmdResponse.class)
|
@APICommand(name = "listPools", description="List Pool", responseObject = ListVolumePoolsCmdResponse.class)
|
||||||
public class ListVolumePoolsCmd extends BaseCmd {
|
public class ListVolumePoolsCmd extends BaseCmd {
|
||||||
|
|||||||
@ -33,7 +33,7 @@ import com.cloud.netapp.NetappManager;
|
|||||||
import com.cloud.netapp.NetappVolumeVO;
|
import com.cloud.netapp.NetappVolumeVO;
|
||||||
import com.cloud.server.ManagementService;
|
import com.cloud.server.ManagementService;
|
||||||
import com.cloud.server.api.response.netapp.ListVolumesOnFilerCmdResponse;
|
import com.cloud.server.api.response.netapp.ListVolumesOnFilerCmdResponse;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@APICommand(name = "listVolumesOnFiler", description="List Volumes", responseObject = ListVolumesOnFilerCmdResponse.class)
|
@APICommand(name = "listVolumesOnFiler", description="List Volumes", responseObject = ListVolumesOnFilerCmdResponse.class)
|
||||||
public class ListVolumesOnFilerCmd extends BaseCmd {
|
public class ListVolumesOnFilerCmd extends BaseCmd {
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||||||
import com.cloud.netapp.NetappManager;
|
import com.cloud.netapp.NetappManager;
|
||||||
import com.cloud.server.ManagementService;
|
import com.cloud.server.ManagementService;
|
||||||
import com.cloud.server.api.response.netapp.ModifyVolumePoolCmdResponse;
|
import com.cloud.server.api.response.netapp.ModifyVolumePoolCmdResponse;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@APICommand(name = "modifyPool", description="Modify pool", responseObject = ModifyVolumePoolCmdResponse.class)
|
@APICommand(name = "modifyPool", description="Modify pool", responseObject = ModifyVolumePoolCmdResponse.class)
|
||||||
public class ModifyVolumePoolCmd extends BaseCmd {
|
public class ModifyVolumePoolCmd extends BaseCmd {
|
||||||
|
|||||||
@ -36,7 +36,6 @@ import com.cloud.host.HostVO;
|
|||||||
import com.cloud.host.dao.HostDao;
|
import com.cloud.host.dao.HostDao;
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.resource.ResourceManager;
|
import com.cloud.resource.ResourceManager;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
import com.cloud.vm.VirtualMachineProfile;
|
import com.cloud.vm.VirtualMachineProfile;
|
||||||
|
|
||||||
@ -56,14 +55,14 @@ public class RandomAllocator implements HostAllocator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type,
|
public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type,
|
||||||
ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity) {
|
ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity) {
|
||||||
|
|
||||||
long dcId = plan.getDataCenterId();
|
long dcId = plan.getDataCenterId();
|
||||||
Long podId = plan.getPodId();
|
Long podId = plan.getPodId();
|
||||||
Long clusterId = plan.getClusterId();
|
Long clusterId = plan.getClusterId();
|
||||||
ServiceOffering offering = vmProfile.getServiceOffering();
|
ServiceOffering offering = vmProfile.getServiceOffering();
|
||||||
|
|
||||||
List<Host> suitableHosts = new ArrayList<Host>();
|
List<Host> suitableHosts = new ArrayList<Host>();
|
||||||
|
|
||||||
if (type == Host.Type.Storage) {
|
if (type == Host.Type.Storage) {
|
||||||
return suitableHosts;
|
return suitableHosts;
|
||||||
@ -71,17 +70,17 @@ public class RandomAllocator implements HostAllocator {
|
|||||||
|
|
||||||
String hostTag = offering.getHostTag();
|
String hostTag = offering.getHostTag();
|
||||||
if(hostTag != null){
|
if(hostTag != null){
|
||||||
s_logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId + " having host tag:" + hostTag);
|
s_logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId + " having host tag:" + hostTag);
|
||||||
}else{
|
}else{
|
||||||
s_logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId);
|
s_logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// list all computing hosts, regardless of whether they support routing...it's random after all
|
// list all computing hosts, regardless of whether they support routing...it's random after all
|
||||||
List<? extends Host> hosts = new ArrayList<HostVO>();
|
List<? extends Host> hosts = new ArrayList<HostVO>();
|
||||||
if(hostTag != null){
|
if(hostTag != null){
|
||||||
hosts = _hostDao.listByHostTag(type, clusterId, podId, dcId, hostTag);
|
hosts = _hostDao.listByHostTag(type, clusterId, podId, dcId, hostTag);
|
||||||
}else{
|
}else{
|
||||||
hosts = _resourceMgr.listAllUpAndEnabledHosts(type, clusterId, podId, dcId);
|
hosts = _resourceMgr.listAllUpAndEnabledHosts(type, clusterId, podId, dcId);
|
||||||
}
|
}
|
||||||
|
|
||||||
s_logger.debug("Random Allocator found " + hosts.size() + " hosts");
|
s_logger.debug("Random Allocator found " + hosts.size() + " hosts");
|
||||||
@ -93,12 +92,12 @@ public class RandomAllocator implements HostAllocator {
|
|||||||
|
|
||||||
Collections.shuffle(hosts);
|
Collections.shuffle(hosts);
|
||||||
for (Host host : hosts) {
|
for (Host host : hosts) {
|
||||||
if(suitableHosts.size() == returnUpTo){
|
if(suitableHosts.size() == returnUpTo){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!avoid.shouldAvoid(host)) {
|
if (!avoid.shouldAvoid(host)) {
|
||||||
suitableHosts.add(host);
|
suitableHosts.add(host);
|
||||||
}else{
|
}else{
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Host name: " + host.getName() + ", hostId: "+ host.getId() +" is in avoid set, skipping this and trying other available hosts");
|
s_logger.debug("Host name: " + host.getName() + ", hostId: "+ host.getId() +" is in avoid set, skipping this and trying other available hosts");
|
||||||
|
|||||||
@ -212,7 +212,7 @@ import com.cloud.storage.template.TemplateLocation;
|
|||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.PropertiesUtil;
|
import com.cloud.utils.PropertiesUtil;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.utils.net.NetUtils;
|
import com.cloud.utils.net.NetUtils;
|
||||||
import com.cloud.utils.script.OutputInterpreter;
|
import com.cloud.utils.script.OutputInterpreter;
|
||||||
|
|||||||
@ -58,7 +58,7 @@ import com.cloud.simulator.MockVMVO;
|
|||||||
import com.cloud.simulator.dao.MockHostDao;
|
import com.cloud.simulator.dao.MockHostDao;
|
||||||
import com.cloud.simulator.dao.MockVMDao;
|
import com.cloud.simulator.dao.MockVMDao;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
|
|||||||
@ -77,7 +77,7 @@ import com.cloud.storage.Storage.ImageFormat;
|
|||||||
import com.cloud.storage.Storage.StoragePoolType;
|
import com.cloud.storage.Storage.StoragePoolType;
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
import com.cloud.storage.template.TemplateInfo;
|
import com.cloud.storage.template.TemplateInfo;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.vm.DiskProfile;
|
import com.cloud.vm.DiskProfile;
|
||||||
|
|||||||
@ -46,7 +46,7 @@ import com.cloud.simulator.dao.MockSecurityRulesDao;
|
|||||||
import com.cloud.simulator.dao.MockVMDao;
|
import com.cloud.simulator.dao.MockVMDao;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.Ternary;
|
import com.cloud.utils.Ternary;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.vm.VirtualMachine.State;
|
import com.cloud.vm.VirtualMachine.State;
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import com.cloud.simulator.MockVMVO;
|
|||||||
import com.cloud.simulator.dao.MockConfigurationDao;
|
import com.cloud.simulator.dao.MockConfigurationDao;
|
||||||
import com.cloud.simulator.dao.MockHostDao;
|
import com.cloud.simulator.dao.MockHostDao;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.db.ConnectionConcierge;
|
import com.cloud.utils.db.ConnectionConcierge;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import com.cloud.exception.ResourceAllocationException;
|
|||||||
import com.cloud.exception.ResourceUnavailableException;
|
import com.cloud.exception.ResourceUnavailableException;
|
||||||
import com.cloud.server.ManagementService;
|
import com.cloud.server.ManagementService;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@APICommand(name = "configureSimulator", description="configure simulator", responseObject=SuccessResponse.class)
|
@APICommand(name = "configureSimulator", description="configure simulator", responseObject=SuccessResponse.class)
|
||||||
public class ConfigureSimulator extends BaseCmd {
|
public class ConfigureSimulator extends BaseCmd {
|
||||||
|
|||||||
@ -43,7 +43,7 @@ import com.cloud.agent.manager.SimulatorManager.AgentType;
|
|||||||
import com.cloud.host.Host;
|
import com.cloud.host.Host;
|
||||||
import com.cloud.host.Host.Type;
|
import com.cloud.host.Host.Type;
|
||||||
import com.cloud.simulator.MockHost;
|
import com.cloud.simulator.MockHost;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
public class AgentResourceBase implements ServerResource {
|
public class AgentResourceBase implements ServerResource {
|
||||||
private static final Logger s_logger = Logger
|
private static final Logger s_logger = Logger
|
||||||
|
|||||||
@ -54,7 +54,7 @@ import com.cloud.storage.VMTemplateZoneVO;
|
|||||||
import com.cloud.storage.dao.VMTemplateDao;
|
import com.cloud.storage.dao.VMTemplateDao;
|
||||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||||
import com.cloud.storage.dao.VMTemplateZoneDao;
|
import com.cloud.storage.dao.VMTemplateZoneDao;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
|
|
||||||
@Local(value = Discoverer.class)
|
@Local(value = Discoverer.class)
|
||||||
public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, Listener, ResourceStateAdapter {
|
public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, Listener, ResourceStateAdapter {
|
||||||
|
|||||||
@ -38,7 +38,7 @@ import com.cloud.host.Status;
|
|||||||
import com.cloud.storage.SnapshotVO;
|
import com.cloud.storage.SnapshotVO;
|
||||||
import com.cloud.storage.dao.SnapshotDao;
|
import com.cloud.storage.dao.SnapshotDao;
|
||||||
import com.cloud.storage.secondary.SecondaryStorageDiscoverer;
|
import com.cloud.storage.secondary.SecondaryStorageDiscoverer;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import com.cloud.hypervisor.HypervisorGuruBase;
|
|||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.storage.GuestOSVO;
|
import com.cloud.storage.GuestOSVO;
|
||||||
import com.cloud.storage.dao.GuestOSDao;
|
import com.cloud.storage.dao.GuestOSDao;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
import com.cloud.vm.VirtualMachineProfile;
|
import com.cloud.vm.VirtualMachineProfile;
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import javax.naming.ConfigurationException;
|
|||||||
|
|
||||||
import com.cloud.simulator.MockHostVO;
|
import com.cloud.simulator.MockHostVO;
|
||||||
import com.cloud.simulator.MockVMVO;
|
import com.cloud.simulator.MockVMVO;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.JoinBuilder;
|
import com.cloud.utils.db.JoinBuilder;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
|
|||||||
@ -66,7 +66,7 @@ import com.cloud.storage.VMTemplateVO;
|
|||||||
import com.cloud.storage.dao.VMTemplateDao;
|
import com.cloud.storage.dao.VMTemplateDao;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.UriUtils;
|
import com.cloud.utils.UriUtils;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.vmware.vim25.ClusterDasConfigInfo;
|
import com.vmware.vim25.ClusterDasConfigInfo;
|
||||||
import com.vmware.vim25.ManagedObjectReference;
|
import com.vmware.vim25.ManagedObjectReference;
|
||||||
|
|
||||||
|
|||||||
@ -86,7 +86,7 @@ import com.cloud.storage.secondary.SecondaryStorageVmManager;
|
|||||||
import com.cloud.utils.FileUtil;
|
import com.cloud.utils.FileUtil;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.component.Manager;
|
import com.cloud.utils.component.Manager;
|
||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import org.apache.log4j.Logger;
|
|||||||
import com.cloud.hypervisor.vmware.manager.VmwareManager;
|
import com.cloud.hypervisor.vmware.manager.VmwareManager;
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
import com.cloud.utils.StringUtils;
|
import com.cloud.utils.StringUtils;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.vmware.apputils.version.ExtendedAppUtil;
|
import com.vmware.apputils.version.ExtendedAppUtil;
|
||||||
|
|
||||||
public class VmwareContextFactory {
|
public class VmwareContextFactory {
|
||||||
|
|||||||
@ -200,7 +200,7 @@ import com.cloud.storage.template.TemplateInfo;
|
|||||||
import com.cloud.utils.DateUtil;
|
import com.cloud.utils.DateUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.StringUtils;
|
import com.cloud.utils.StringUtils;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.utils.exception.ExceptionUtil;
|
import com.cloud.utils.exception.ExceptionUtil;
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import com.cloud.network.dao.LoadBalancerDao;
|
|||||||
import com.cloud.network.dao.LoadBalancerDaoImpl;
|
import com.cloud.network.dao.LoadBalancerDaoImpl;
|
||||||
import com.cloud.network.router.VirtualRouter.Role;
|
import com.cloud.network.router.VirtualRouter.Role;
|
||||||
import com.cloud.network.router.VirtualRouter.Role;
|
import com.cloud.network.router.VirtualRouter.Role;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.JoinBuilder.JoinType;
|
import com.cloud.utils.db.JoinBuilder.JoinType;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import com.cloud.server.ManagementServer;
|
import com.cloud.server.ManagementServer;
|
||||||
import com.cloud.user.UserAccount;
|
import com.cloud.user.UserAccount;
|
||||||
import com.cloud.user.dao.UserAccountDao;
|
import com.cloud.user.dao.UserAccountDao;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import com.cloud.server.ManagementServer;
|
import com.cloud.server.ManagementServer;
|
||||||
import com.cloud.user.UserAccount;
|
import com.cloud.user.UserAccount;
|
||||||
import com.cloud.user.dao.UserAccountDao;
|
import com.cloud.user.dao.UserAccountDao;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -32,8 +32,8 @@ import com.cloud.server.ManagementServer;
|
|||||||
import com.cloud.servlet.CloudStartupServlet;
|
import com.cloud.servlet.CloudStartupServlet;
|
||||||
import com.cloud.user.UserAccount;
|
import com.cloud.user.UserAccount;
|
||||||
import com.cloud.user.dao.UserAccountDao;
|
import com.cloud.user.dao.UserAccountDao;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
@Local(value={UserAuthenticator.class})
|
@Local(value={UserAuthenticator.class})
|
||||||
|
|||||||
@ -66,7 +66,6 @@ import com.cloud.agent.transport.Response;
|
|||||||
import com.cloud.alert.AlertManager;
|
import com.cloud.alert.AlertManager;
|
||||||
import com.cloud.capacity.dao.CapacityDao;
|
import com.cloud.capacity.dao.CapacityDao;
|
||||||
import com.cloud.cluster.ManagementServerNode;
|
import com.cloud.cluster.ManagementServerNode;
|
||||||
import com.cloud.cluster.StackMaid;
|
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.dc.ClusterDetailsDao;
|
import com.cloud.dc.ClusterDetailsDao;
|
||||||
@ -977,8 +976,6 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
s_logger.error("Exception caught while handling disconnect: ", e);
|
s_logger.error("Exception caught while handling disconnect: ", e);
|
||||||
} finally {
|
|
||||||
StackMaid.current().exitCleanup();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1150,7 +1147,6 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||||||
if (actionDelegate != null) {
|
if (actionDelegate != null) {
|
||||||
actionDelegate.action(new Long(id));
|
actionDelegate.action(new Long(id));
|
||||||
}
|
}
|
||||||
StackMaid.current().exitCleanup();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1381,7 +1377,6 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
StackMaid.current().exitCleanup();
|
|
||||||
txn.close();
|
txn.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,7 +62,6 @@ import com.cloud.cluster.ClusterManagerListener;
|
|||||||
import com.cloud.cluster.ClusteredAgentRebalanceService;
|
import com.cloud.cluster.ClusteredAgentRebalanceService;
|
||||||
import com.cloud.cluster.ManagementServerHost;
|
import com.cloud.cluster.ManagementServerHost;
|
||||||
import com.cloud.cluster.ManagementServerHostVO;
|
import com.cloud.cluster.ManagementServerHostVO;
|
||||||
import com.cloud.cluster.StackMaid;
|
|
||||||
import com.cloud.cluster.agentlb.AgentLoadBalancerPlanner;
|
import com.cloud.cluster.agentlb.AgentLoadBalancerPlanner;
|
||||||
import com.cloud.cluster.agentlb.HostTransferMapVO;
|
import com.cloud.cluster.agentlb.HostTransferMapVO;
|
||||||
import com.cloud.cluster.agentlb.HostTransferMapVO.HostTransferState;
|
import com.cloud.cluster.agentlb.HostTransferMapVO.HostTransferState;
|
||||||
@ -1120,8 +1119,6 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||||||
rebalanceHost(hostId, currentOwnerId, futureOwnerId);
|
rebalanceHost(hostId, currentOwnerId, futureOwnerId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.warn("Unable to rebalance host id=" + hostId, e);
|
s_logger.warn("Unable to rebalance host id=" + hostId, e);
|
||||||
} finally {
|
|
||||||
StackMaid.current().exitCleanup();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -104,12 +104,12 @@ import org.apache.http.protocol.ResponseContent;
|
|||||||
import org.apache.http.protocol.ResponseDate;
|
import org.apache.http.protocol.ResponseDate;
|
||||||
import org.apache.http.protocol.ResponseServer;
|
import org.apache.http.protocol.ResponseServer;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.api.response.ApiResponseSerializer;
|
import com.cloud.api.response.ApiResponseSerializer;
|
||||||
import com.cloud.async.AsyncJob;
|
import com.cloud.async.AsyncJob;
|
||||||
import com.cloud.async.AsyncJobManager;
|
import com.cloud.async.AsyncJobManager;
|
||||||
import com.cloud.async.AsyncJobVO;
|
import com.cloud.async.AsyncJobVO;
|
||||||
import com.cloud.cluster.StackMaid;
|
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.ConfigurationVO;
|
import com.cloud.configuration.ConfigurationVO;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
@ -136,19 +136,20 @@ import com.cloud.utils.db.Transaction;
|
|||||||
import com.cloud.utils.exception.CSExceptionErrorCode;
|
import com.cloud.utils.exception.CSExceptionErrorCode;
|
||||||
import com.cloud.uuididentity.dao.IdentityDao;
|
import com.cloud.uuididentity.dao.IdentityDao;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class ApiServer implements HttpRequestHandler {
|
public class ApiServer implements HttpRequestHandler {
|
||||||
private static final Logger s_logger = Logger.getLogger(ApiServer.class.getName());
|
private static final Logger s_logger = Logger.getLogger(ApiServer.class.getName());
|
||||||
private static final Logger s_accessLogger = Logger.getLogger("apiserver." + ApiServer.class.getName());
|
private static final Logger s_accessLogger = Logger.getLogger("apiserver." + ApiServer.class.getName());
|
||||||
|
|
||||||
public static boolean encodeApiResponse = false;
|
public static boolean encodeApiResponse = false;
|
||||||
public static String jsonContentType = "text/javascript";
|
public static String jsonContentType = "text/javascript";
|
||||||
private ApiDispatcher _dispatcher;
|
@Inject ApiDispatcher _dispatcher;
|
||||||
|
|
||||||
@Inject private final AccountManager _accountMgr = null;
|
@Inject AccountManager _accountMgr;
|
||||||
@Inject private final DomainManager _domainMgr = null;
|
@Inject DomainManager _domainMgr;
|
||||||
@Inject private final AsyncJobManager _asyncMgr = null;
|
@Inject AsyncJobManager _asyncMgr;
|
||||||
@Inject private ConfigurationDao _configDao;
|
@Inject ConfigurationDao _configDao;
|
||||||
@Inject protected List<APIAccessChecker> _apiAccessCheckers;
|
@Inject List<APIAccessChecker> _apiAccessCheckers;
|
||||||
|
|
||||||
@Inject List<PluggableService> _pluggableServices;
|
@Inject List<PluggableService> _pluggableServices;
|
||||||
@Inject IdentityDao _identityDao;
|
@Inject IdentityDao _identityDao;
|
||||||
@ -190,7 +191,6 @@ public class ApiServer implements HttpRequestHandler {
|
|||||||
|
|
||||||
_systemAccount = _accountMgr.getSystemAccount();
|
_systemAccount = _accountMgr.getSystemAccount();
|
||||||
_systemUser = _accountMgr.getSystemUser();
|
_systemUser = _accountMgr.getSystemUser();
|
||||||
_dispatcher = ApiDispatcher.getInstance();
|
|
||||||
|
|
||||||
Integer apiPort = null; // api port, null by default
|
Integer apiPort = null; // api port, null by default
|
||||||
SearchCriteria<ConfigurationVO> sc = _configDao.createSearchCriteria();
|
SearchCriteria<ConfigurationVO> sc = _configDao.createSearchCriteria();
|
||||||
@ -907,12 +907,8 @@ public class ApiServer implements HttpRequestHandler {
|
|||||||
HttpContext context = new BasicHttpContext(null);
|
HttpContext context = new BasicHttpContext(null);
|
||||||
try {
|
try {
|
||||||
while (!Thread.interrupted() && _conn.isOpen()) {
|
while (!Thread.interrupted() && _conn.isOpen()) {
|
||||||
try {
|
_httpService.handleRequest(_conn, context);
|
||||||
_httpService.handleRequest(_conn, context);
|
_conn.close();
|
||||||
_conn.close();
|
|
||||||
} finally {
|
|
||||||
StackMaid.current().exitCleanup();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (ConnectionClosedException ex) {
|
} catch (ConnectionClosedException ex) {
|
||||||
if (s_logger.isTraceEnabled()) {
|
if (s_logger.isTraceEnabled()) {
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import java.util.Enumeration;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@ -32,14 +33,11 @@ import org.apache.cloudstack.api.BaseCmd;
|
|||||||
import org.apache.cloudstack.api.ServerApiException;
|
import org.apache.cloudstack.api.ServerApiException;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.cluster.StackMaid;
|
|
||||||
import com.cloud.exception.CloudAuthenticationException;
|
import com.cloud.exception.CloudAuthenticationException;
|
||||||
import com.cloud.server.ManagementServer;
|
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.user.AccountService;
|
import com.cloud.user.AccountService;
|
||||||
import com.cloud.user.UserContext;
|
import com.cloud.user.UserContext;
|
||||||
import com.cloud.utils.StringUtils;
|
import com.cloud.utils.StringUtils;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@ -47,8 +45,8 @@ public class ApiServlet extends HttpServlet {
|
|||||||
public static final Logger s_logger = Logger.getLogger(ApiServlet.class.getName());
|
public static final Logger s_logger = Logger.getLogger(ApiServlet.class.getName());
|
||||||
private static final Logger s_accessLogger = Logger.getLogger("apiserver." + ApiServer.class.getName());
|
private static final Logger s_accessLogger = Logger.getLogger("apiserver." + ApiServer.class.getName());
|
||||||
|
|
||||||
private ApiServer _apiServer = null;
|
ApiServer _apiServer;
|
||||||
private AccountService _accountMgr = null;
|
@Inject AccountService _accountMgr;
|
||||||
|
|
||||||
public ApiServlet() {
|
public ApiServlet() {
|
||||||
super();
|
super();
|
||||||
@ -56,26 +54,16 @@ public class ApiServlet extends HttpServlet {
|
|||||||
if (_apiServer == null) {
|
if (_apiServer == null) {
|
||||||
throw new CloudRuntimeException("ApiServer not initialized");
|
throw new CloudRuntimeException("ApiServer not initialized");
|
||||||
}
|
}
|
||||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
|
|
||||||
_accountMgr = locator.getManager(AccountService.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
||||||
try {
|
processRequest(req, resp);
|
||||||
processRequest(req, resp);
|
|
||||||
} finally {
|
|
||||||
StackMaid.current().exitCleanup();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
|
||||||
try {
|
processRequest(req, resp);
|
||||||
processRequest(req, resp);
|
|
||||||
} finally {
|
|
||||||
StackMaid.current().exitCleanup();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void utf8Fixup(HttpServletRequest req, Map<String, Object[]> params) {
|
private void utf8Fixup(HttpServletRequest req, Map<String, Object[]> params) {
|
||||||
@ -305,7 +293,7 @@ public class ApiServlet extends HttpServlet {
|
|||||||
|
|
||||||
auditTrailSb.insert(0,
|
auditTrailSb.insert(0,
|
||||||
"(userId=" + UserContext.current().getCallerUserId() + " accountId=" + UserContext.current().getCaller().getId() + " sessionId=" + (session != null ? session.getId() : null)
|
"(userId=" + UserContext.current().getCallerUserId() + " accountId=" + UserContext.current().getCaller().getId() + " sessionId=" + (session != null ? session.getId() : null)
|
||||||
+ ")");
|
+ ")");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String response = _apiServer.handleRequest(params, false, responseType, auditTrailSb);
|
String response = _apiServer.handleRequest(params, false, responseType, auditTrailSb);
|
||||||
|
|||||||
@ -16,91 +16,93 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.*;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.api.APICommand;
|
||||||
|
import org.apache.cloudstack.api.ApiConstants;
|
||||||
|
import org.apache.cloudstack.api.BaseCmd;
|
||||||
|
import org.apache.cloudstack.api.Parameter;
|
||||||
|
import org.apache.cloudstack.api.ServerApiException;
|
||||||
|
import org.apache.cloudstack.api.response.TrafficMonitorResponse;
|
||||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.host.Host;
|
import com.cloud.host.Host;
|
||||||
import com.cloud.network.NetworkUsageManager;
|
import com.cloud.network.NetworkUsageManager;
|
||||||
import com.cloud.server.ManagementService;
|
|
||||||
import org.apache.cloudstack.api.response.TrafficMonitorResponse;
|
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
@APICommand(name = "addTrafficMonitor", description="Adds Traffic Monitor Host for Direct Network Usage", responseObject = TrafficMonitorResponse.class)
|
@APICommand(name = "addTrafficMonitor", description="Adds Traffic Monitor Host for Direct Network Usage", responseObject = TrafficMonitorResponse.class)
|
||||||
public class AddTrafficMonitorCmd extends BaseCmd {
|
public class AddTrafficMonitorCmd extends BaseCmd {
|
||||||
public static final Logger s_logger = Logger.getLogger(AddTrafficMonitorCmd.class.getName());
|
public static final Logger s_logger = Logger.getLogger(AddTrafficMonitorCmd.class.getName());
|
||||||
private static final String s_name = "addtrafficmonitorresponse";
|
private static final String s_name = "addtrafficmonitorresponse";
|
||||||
|
@Inject NetworkUsageManager networkUsageMgr;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
//////////////// API parameters /////////////////////
|
//////////////// API parameters /////////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
|
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
|
||||||
required = true, description="Zone in which to add the external firewall appliance.")
|
required = true, description="Zone in which to add the external firewall appliance.")
|
||||||
private Long zoneId;
|
private Long zoneId;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.URL, type=CommandType.STRING, required = true, description="URL of the traffic monitor Host")
|
@Parameter(name=ApiConstants.URL, type=CommandType.STRING, required = true, description="URL of the traffic monitor Host")
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.INCL_ZONES, type=CommandType.STRING, description="Traffic going into the listed zones will be metered")
|
@Parameter(name=ApiConstants.INCL_ZONES, type=CommandType.STRING, description="Traffic going into the listed zones will be metered")
|
||||||
private String inclZones;
|
private String inclZones;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.EXCL_ZONES, type=CommandType.STRING, description="Traffic going into the listed zones will not be metered")
|
@Parameter(name=ApiConstants.EXCL_ZONES, type=CommandType.STRING, description="Traffic going into the listed zones will not be metered")
|
||||||
private String exclZones;
|
private String exclZones;
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
/////////////////// Accessors ///////////////////////
|
/////////////////// Accessors ///////////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
public String getInclZones() {
|
public String getInclZones() {
|
||||||
return inclZones;
|
return inclZones;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getExclZones() {
|
public String getExclZones() {
|
||||||
return exclZones;
|
return exclZones;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getZoneId() {
|
public Long getZoneId() {
|
||||||
return zoneId;
|
return zoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCommandName() {
|
public String getCommandName() {
|
||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getEntityOwnerId() {
|
public long getEntityOwnerId() {
|
||||||
return Account.ACCOUNT_ID_SYSTEM;
|
return Account.ACCOUNT_ID_SYSTEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(){
|
public void execute(){
|
||||||
try {
|
try {
|
||||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
|
Host trafficMonitor = networkUsageMgr.addTrafficMonitor(this);
|
||||||
NetworkUsageManager networkUsageMgr = locator.getManager(NetworkUsageManager.class);
|
TrafficMonitorResponse response = networkUsageMgr.getApiResponse(trafficMonitor);
|
||||||
Host trafficMonitor = networkUsageMgr.addTrafficMonitor(this);
|
response.setObjectName("trafficmonitor");
|
||||||
TrafficMonitorResponse response = networkUsageMgr.getApiResponse(trafficMonitor);
|
response.setResponseName(getCommandName());
|
||||||
response.setObjectName("trafficmonitor");
|
this.setResponseObject(response);
|
||||||
response.setResponseName(getCommandName());
|
} catch (InvalidParameterValueException ipve) {
|
||||||
this.setResponseObject(response);
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
|
||||||
} catch (InvalidParameterValueException ipve) {
|
} catch (CloudRuntimeException cre) {
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
|
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
|
||||||
} catch (CloudRuntimeException cre) {
|
}
|
||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,71 +16,70 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.response.HostResponse;
|
import javax.inject.Inject;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
|
import org.apache.cloudstack.api.APICommand;
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
import org.apache.cloudstack.api.ApiConstants;
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
import org.apache.cloudstack.api.BaseCmd;
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import org.apache.cloudstack.api.Parameter;
|
import org.apache.cloudstack.api.Parameter;
|
||||||
import org.apache.cloudstack.api.ServerApiException;
|
import org.apache.cloudstack.api.ServerApiException;
|
||||||
|
import org.apache.cloudstack.api.response.HostResponse;
|
||||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.network.NetworkUsageManager;
|
import com.cloud.network.NetworkUsageManager;
|
||||||
import com.cloud.server.ManagementService;
|
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@APICommand(name = "deleteTrafficMonitor", description="Deletes an traffic monitor host.", responseObject = SuccessResponse.class)
|
@APICommand(name = "deleteTrafficMonitor", description="Deletes an traffic monitor host.", responseObject = SuccessResponse.class)
|
||||||
public class DeleteTrafficMonitorCmd extends BaseCmd {
|
public class DeleteTrafficMonitorCmd extends BaseCmd {
|
||||||
public static final Logger s_logger = Logger.getLogger(DeleteTrafficMonitorCmd.class.getName());
|
public static final Logger s_logger = Logger.getLogger(DeleteTrafficMonitorCmd.class.getName());
|
||||||
private static final String s_name = "deletetrafficmonitorresponse";
|
private static final String s_name = "deletetrafficmonitorresponse";
|
||||||
|
@Inject NetworkUsageManager _networkUsageMgr;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
//////////////// API parameters /////////////////////
|
//////////////// API parameters /////////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = HostResponse.class,
|
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = HostResponse.class,
|
||||||
required = true, description="Id of the Traffic Monitor Host.")
|
required = true, description="Id of the Traffic Monitor Host.")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
/////////////////// Accessors ///////////////////////
|
/////////////////// Accessors ///////////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCommandName() {
|
public String getCommandName() {
|
||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getEntityOwnerId() {
|
public long getEntityOwnerId() {
|
||||||
return Account.ACCOUNT_ID_SYSTEM;
|
return Account.ACCOUNT_ID_SYSTEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(){
|
public void execute(){
|
||||||
try {
|
try {
|
||||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
|
boolean result = _networkUsageMgr.deleteTrafficMonitor(this);
|
||||||
NetworkUsageManager _networkUsageMgr = locator.getManager(NetworkUsageManager.class);
|
if (result) {
|
||||||
boolean result = _networkUsageMgr.deleteTrafficMonitor(this);
|
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||||
if (result) {
|
response.setResponseName(getCommandName());
|
||||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
this.setResponseObject(response);
|
||||||
response.setResponseName(getCommandName());
|
} else {
|
||||||
this.setResponseObject(response);
|
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete traffic monitor.");
|
||||||
} else {
|
}
|
||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete traffic monitor.");
|
} catch (InvalidParameterValueException e) {
|
||||||
}
|
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Failed to delete traffic monitor.");
|
||||||
} catch (InvalidParameterValueException e) {
|
}
|
||||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Failed to delete traffic monitor.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,7 @@ import com.cloud.host.Host;
|
|||||||
import com.cloud.network.NetworkUsageManager;
|
import com.cloud.network.NetworkUsageManager;
|
||||||
import com.cloud.server.ManagementService;
|
import com.cloud.server.ManagementService;
|
||||||
import org.apache.cloudstack.api.response.TrafficMonitorResponse;
|
import org.apache.cloudstack.api.response.TrafficMonitorResponse;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@APICommand(name = "listTrafficMonitors", description="List traffic monitor Hosts.", responseObject = TrafficMonitorResponse.class)
|
@APICommand(name = "listTrafficMonitors", description="List traffic monitor Hosts.", responseObject = TrafficMonitorResponse.class)
|
||||||
public class ListTrafficMonitorsCmd extends BaseListCmd {
|
public class ListTrafficMonitorsCmd extends BaseListCmd {
|
||||||
|
|||||||
@ -20,21 +20,19 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||||
|
import org.apache.cloudstack.api.response.NicResponse;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.api.ApiResponseHelper;
|
import com.cloud.api.ApiResponseHelper;
|
||||||
import com.cloud.api.query.vo.DomainRouterJoinVO;
|
import com.cloud.api.query.vo.DomainRouterJoinVO;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
|
||||||
import org.apache.cloudstack.api.response.NicResponse;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.cloud.network.Networks.TrafficType;
|
import com.cloud.network.Networks.TrafficType;
|
||||||
import com.cloud.network.router.VirtualRouter;
|
import com.cloud.network.router.VirtualRouter;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
@ -47,9 +45,9 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO,
|
|||||||
@Inject
|
@Inject
|
||||||
private ConfigurationDao _configDao;
|
private ConfigurationDao _configDao;
|
||||||
|
|
||||||
private SearchBuilder<DomainRouterJoinVO> vrSearch;
|
private final SearchBuilder<DomainRouterJoinVO> vrSearch;
|
||||||
|
|
||||||
private SearchBuilder<DomainRouterJoinVO> vrIdSearch;
|
private final SearchBuilder<DomainRouterJoinVO> vrIdSearch;
|
||||||
|
|
||||||
protected DomainRouterJoinDaoImpl() {
|
protected DomainRouterJoinDaoImpl() {
|
||||||
|
|
||||||
|
|||||||
@ -25,21 +25,19 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.api.ApiConstants.HostDetails;
|
||||||
|
import org.apache.cloudstack.api.response.HostResponse;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.api.ApiDBUtils;
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.query.vo.HostJoinVO;
|
import com.cloud.api.query.vo.HostJoinVO;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.host.Host;
|
import com.cloud.host.Host;
|
||||||
import com.cloud.host.HostStats;
|
import com.cloud.host.HostStats;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.ApiConstants.HostDetails;
|
|
||||||
import org.apache.cloudstack.api.response.HostResponse;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.cloud.storage.StorageStats;
|
import com.cloud.storage.StorageStats;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
@ -52,9 +50,9 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
|
|||||||
@Inject
|
@Inject
|
||||||
private ConfigurationDao _configDao;
|
private ConfigurationDao _configDao;
|
||||||
|
|
||||||
private SearchBuilder<HostJoinVO> hostSearch;
|
private final SearchBuilder<HostJoinVO> hostSearch;
|
||||||
|
|
||||||
private SearchBuilder<HostJoinVO> hostIdSearch;
|
private final SearchBuilder<HostJoinVO> hostIdSearch;
|
||||||
|
|
||||||
|
|
||||||
protected HostJoinDaoImpl() {
|
protected HostJoinDaoImpl() {
|
||||||
@ -97,14 +95,14 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
|
|||||||
if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity)
|
if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity)
|
||||||
|| details.contains(HostDetails.stats) || details.contains(HostDetails.events)) {
|
|| details.contains(HostDetails.stats) || details.contains(HostDetails.events)) {
|
||||||
|
|
||||||
hostResponse.setOsCategoryId(host.getOsCategoryUuid());
|
hostResponse.setOsCategoryId(host.getOsCategoryUuid());
|
||||||
hostResponse.setOsCategoryName(host.getOsCategoryName());
|
hostResponse.setOsCategoryName(host.getOsCategoryName());
|
||||||
hostResponse.setZoneName(host.getZoneName());
|
hostResponse.setZoneName(host.getZoneName());
|
||||||
hostResponse.setPodName(host.getPodName());
|
hostResponse.setPodName(host.getPodName());
|
||||||
if ( host.getClusterId() > 0) {
|
if ( host.getClusterId() > 0) {
|
||||||
hostResponse.setClusterName(host.getClusterName());
|
hostResponse.setClusterName(host.getClusterName());
|
||||||
hostResponse.setClusterType(host.getClusterType().toString());
|
hostResponse.setClusterType(host.getClusterType().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DecimalFormat decimalFormat = new DecimalFormat("#.##");
|
DecimalFormat decimalFormat = new DecimalFormat("#.##");
|
||||||
|
|||||||
@ -20,19 +20,17 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.api.ApiDBUtils;
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.query.vo.ProjectJoinVO;
|
import com.cloud.api.query.vo.ProjectJoinVO;
|
||||||
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.cloud.projects.Project;
|
import com.cloud.projects.Project;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
@ -45,9 +43,9 @@ public class ProjectJoinDaoImpl extends GenericDaoBase<ProjectJoinVO, Long> impl
|
|||||||
@Inject
|
@Inject
|
||||||
private ConfigurationDao _configDao;
|
private ConfigurationDao _configDao;
|
||||||
|
|
||||||
private SearchBuilder<ProjectJoinVO> prjSearch;
|
private final SearchBuilder<ProjectJoinVO> prjSearch;
|
||||||
|
|
||||||
private SearchBuilder<ProjectJoinVO> prjIdSearch;
|
private final SearchBuilder<ProjectJoinVO> prjIdSearch;
|
||||||
|
|
||||||
protected ProjectJoinDaoImpl() {
|
protected ProjectJoinDaoImpl() {
|
||||||
|
|
||||||
|
|||||||
@ -20,18 +20,16 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.api.response.ResourceTagResponse;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.api.ApiResponseHelper;
|
import com.cloud.api.ApiResponseHelper;
|
||||||
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.response.ResourceTagResponse;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.cloud.server.ResourceTag;
|
import com.cloud.server.ResourceTag;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
@ -44,9 +42,9 @@ public class ResourceTagJoinDaoImpl extends GenericDaoBase<ResourceTagJoinVO, Lo
|
|||||||
@Inject
|
@Inject
|
||||||
private ConfigurationDao _configDao;
|
private ConfigurationDao _configDao;
|
||||||
|
|
||||||
private SearchBuilder<ResourceTagJoinVO> tagSearch;
|
private final SearchBuilder<ResourceTagJoinVO> tagSearch;
|
||||||
|
|
||||||
private SearchBuilder<ResourceTagJoinVO> tagIdSearch;
|
private final SearchBuilder<ResourceTagJoinVO> tagIdSearch;
|
||||||
|
|
||||||
protected ResourceTagJoinDaoImpl() {
|
protected ResourceTagJoinDaoImpl() {
|
||||||
|
|
||||||
|
|||||||
@ -20,23 +20,21 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
||||||
|
import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.api.ApiDBUtils;
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.ApiResponseHelper;
|
import com.cloud.api.ApiResponseHelper;
|
||||||
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
||||||
import com.cloud.api.query.vo.SecurityGroupJoinVO;
|
import com.cloud.api.query.vo.SecurityGroupJoinVO;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
|
||||||
import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.cloud.network.security.SecurityGroup;
|
import com.cloud.network.security.SecurityGroup;
|
||||||
import com.cloud.network.security.SecurityRule.SecurityRuleType;
|
import com.cloud.network.security.SecurityRule.SecurityRuleType;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
@ -49,9 +47,9 @@ public class SecurityGroupJoinDaoImpl extends GenericDaoBase<SecurityGroupJoinVO
|
|||||||
@Inject
|
@Inject
|
||||||
private ConfigurationDao _configDao;
|
private ConfigurationDao _configDao;
|
||||||
|
|
||||||
private SearchBuilder<SecurityGroupJoinVO> sgSearch;
|
private final SearchBuilder<SecurityGroupJoinVO> sgSearch;
|
||||||
|
|
||||||
private SearchBuilder<SecurityGroupJoinVO> sgIdSearch;
|
private final SearchBuilder<SecurityGroupJoinVO> sgIdSearch;
|
||||||
|
|
||||||
protected SecurityGroupJoinDaoImpl() {
|
protected SecurityGroupJoinDaoImpl() {
|
||||||
|
|
||||||
|
|||||||
@ -18,19 +18,19 @@ package com.cloud.api.query.dao;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.ejb.Local;
|
|
||||||
|
|
||||||
|
import javax.ejb.Local;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.api.response.StoragePoolResponse;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.api.ApiDBUtils;
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.query.vo.StoragePoolJoinVO;
|
import com.cloud.api.query.vo.StoragePoolJoinVO;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import org.apache.cloudstack.api.response.StoragePoolResponse;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.cloud.storage.StoragePool;
|
import com.cloud.storage.StoragePool;
|
||||||
import com.cloud.storage.StorageStats;
|
import com.cloud.storage.StorageStats;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
@ -44,9 +44,9 @@ public class StoragePoolJoinDaoImpl extends GenericDaoBase<StoragePoolJoinVO, Lo
|
|||||||
@Inject
|
@Inject
|
||||||
private ConfigurationDao _configDao;
|
private ConfigurationDao _configDao;
|
||||||
|
|
||||||
private SearchBuilder<StoragePoolJoinVO> spSearch;
|
private final SearchBuilder<StoragePoolJoinVO> spSearch;
|
||||||
|
|
||||||
private SearchBuilder<StoragePoolJoinVO> spIdSearch;
|
private final SearchBuilder<StoragePoolJoinVO> spIdSearch;
|
||||||
|
|
||||||
|
|
||||||
protected StoragePoolJoinDaoImpl() {
|
protected StoragePoolJoinDaoImpl() {
|
||||||
|
|||||||
@ -24,23 +24,21 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
import javax.inject.Inject;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.cloud.api.ApiDBUtils;
|
|
||||||
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
|
||||||
import com.cloud.api.query.vo.UserVmJoinVO;
|
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.ApiConstants.VMDetails;
|
import org.apache.cloudstack.api.ApiConstants.VMDetails;
|
||||||
import org.apache.cloudstack.api.response.NicResponse;
|
import org.apache.cloudstack.api.response.NicResponse;
|
||||||
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
||||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
|
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
||||||
|
import com.cloud.api.query.vo.UserVmJoinVO;
|
||||||
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.uservm.UserVm;
|
import com.cloud.uservm.UserVm;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
@ -55,7 +53,7 @@ public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO, Long> implem
|
|||||||
@Inject
|
@Inject
|
||||||
private ConfigurationDao _configDao;
|
private ConfigurationDao _configDao;
|
||||||
|
|
||||||
private SearchBuilder<UserVmJoinVO> VmDetailSearch;
|
private final SearchBuilder<UserVmJoinVO> VmDetailSearch;
|
||||||
|
|
||||||
protected UserVmJoinDaoImpl() {
|
protected UserVmJoinDaoImpl() {
|
||||||
|
|
||||||
@ -68,6 +66,7 @@ public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO, Long> implem
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public UserVmResponse newUserVmResponse(String objectName, UserVmJoinVO userVm, EnumSet<VMDetails> details, Account caller) {
|
public UserVmResponse newUserVmResponse(String objectName, UserVmJoinVO userVm, EnumSet<VMDetails> details, Account caller) {
|
||||||
UserVmResponse userVmResponse = new UserVmResponse();
|
UserVmResponse userVmResponse = new UserVmResponse();
|
||||||
|
|
||||||
@ -216,8 +215,9 @@ public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO, Long> implem
|
|||||||
userVmResponse.setObjectName(objectName);
|
userVmResponse.setObjectName(objectName);
|
||||||
|
|
||||||
return userVmResponse;
|
return userVmResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public UserVmResponse setUserVmResponse(UserVmResponse userVmData, UserVmJoinVO uvo) {
|
public UserVmResponse setUserVmResponse(UserVmResponse userVmData, UserVmJoinVO uvo) {
|
||||||
Long securityGroupId = uvo.getSecurityGroupId();
|
Long securityGroupId = uvo.getSecurityGroupId();
|
||||||
if (securityGroupId != null && securityGroupId.longValue() != 0) {
|
if (securityGroupId != null && securityGroupId.longValue() != 0) {
|
||||||
|
|||||||
@ -20,26 +20,24 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.api.response.VolumeResponse;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.api.ApiDBUtils;
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.ApiResponseHelper;
|
import com.cloud.api.ApiResponseHelper;
|
||||||
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
import com.cloud.api.query.vo.ResourceTagJoinVO;
|
||||||
import com.cloud.api.query.vo.VolumeJoinVO;
|
import com.cloud.api.query.vo.VolumeJoinVO;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.response.VolumeResponse;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.storage.Storage;
|
import com.cloud.storage.Storage;
|
||||||
import com.cloud.storage.VMTemplateHostVO;
|
import com.cloud.storage.VMTemplateHostVO;
|
||||||
import com.cloud.storage.Volume;
|
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
|
import com.cloud.storage.Volume;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.user.UserContext;
|
import com.cloud.user.UserContext;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
@ -53,9 +51,9 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
|
|||||||
@Inject
|
@Inject
|
||||||
private ConfigurationDao _configDao;
|
private ConfigurationDao _configDao;
|
||||||
|
|
||||||
private SearchBuilder<VolumeJoinVO> volSearch;
|
private final SearchBuilder<VolumeJoinVO> volSearch;
|
||||||
|
|
||||||
private SearchBuilder<VolumeJoinVO> volIdSearch;
|
private final SearchBuilder<VolumeJoinVO> volIdSearch;
|
||||||
|
|
||||||
protected VolumeJoinDaoImpl() {
|
protected VolumeJoinDaoImpl() {
|
||||||
|
|
||||||
@ -176,12 +174,12 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
|
|||||||
volResponse.setDestroyed(volume.getState() == Volume.State.Destroy);
|
volResponse.setDestroyed(volume.getState() == Volume.State.Destroy);
|
||||||
boolean isExtractable = true;
|
boolean isExtractable = true;
|
||||||
if (volume.getVolumeType() != Volume.Type.DATADISK) { // Datadisk dont
|
if (volume.getVolumeType() != Volume.Type.DATADISK) { // Datadisk dont
|
||||||
// have any
|
// have any
|
||||||
// template
|
// template
|
||||||
// dependence.
|
// dependence.
|
||||||
if (volume.getTemplateId() > 0) { // For ISO based volumes template
|
if (volume.getTemplateId() > 0) { // For ISO based volumes template
|
||||||
// = null and we allow extraction
|
// = null and we allow extraction
|
||||||
// of all ISO based volumes
|
// of all ISO based volumes
|
||||||
isExtractable = volume.isExtractable() && volume.getTemplateType() != Storage.TemplateType.SYSTEM;
|
isExtractable = volume.isExtractable() && volume.getTemplateType() != Storage.TemplateType.SYSTEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,6 @@ import com.cloud.storage.snapshot.SnapshotManager;
|
|||||||
import com.cloud.user.AccountManager;
|
import com.cloud.user.AccountManager;
|
||||||
import com.cloud.user.dao.AccountDao;
|
import com.cloud.user.dao.AccountDao;
|
||||||
import com.cloud.user.dao.UserDao;
|
import com.cloud.user.dao.UserDao;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.vm.UserVmManager;
|
import com.cloud.vm.UserVmManager;
|
||||||
import com.cloud.vm.VirtualMachineManager;
|
import com.cloud.vm.VirtualMachineManager;
|
||||||
import com.cloud.vm.dao.DomainRouterDao;
|
import com.cloud.vm.dao.DomainRouterDao;
|
||||||
@ -45,7 +44,7 @@ import com.cloud.vm.dao.UserVmDao;
|
|||||||
@Component
|
@Component
|
||||||
@Local(value={AsyncJobExecutorContext.class})
|
@Local(value={AsyncJobExecutorContext.class})
|
||||||
public class AsyncJobExecutorContextImpl implements AsyncJobExecutorContext {
|
public class AsyncJobExecutorContextImpl implements AsyncJobExecutorContext {
|
||||||
private String _name;
|
private String _name;
|
||||||
|
|
||||||
@Inject private AgentManager _agentMgr;
|
@Inject private AgentManager _agentMgr;
|
||||||
@Inject private NetworkManager _networkMgr;
|
@Inject private NetworkManager _networkMgr;
|
||||||
@ -65,93 +64,93 @@ public class AsyncJobExecutorContextImpl implements AsyncJobExecutorContext {
|
|||||||
|
|
||||||
@Inject private ManagementServer _managementServer;
|
@Inject private ManagementServer _managementServer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ManagementServer getManagementServer() {
|
public ManagementServer getManagementServer() {
|
||||||
return _managementServer;
|
return _managementServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AgentManager getAgentMgr() {
|
public AgentManager getAgentMgr() {
|
||||||
return _agentMgr;
|
return _agentMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NetworkManager getNetworkMgr() {
|
public NetworkManager getNetworkMgr() {
|
||||||
return _networkMgr;
|
return _networkMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserVmManager getVmMgr() {
|
public UserVmManager getVmMgr() {
|
||||||
return _vmMgr;
|
return _vmMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StorageManager getStorageMgr() {
|
public StorageManager getStorageMgr() {
|
||||||
return _storageMgr;
|
return _storageMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**server/src/com/cloud/async/AsyncJobExecutorContext.java
|
/**server/src/com/cloud/async/AsyncJobExecutorContext.java
|
||||||
* @return the _snapMgr
|
* @return the _snapMgr
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SnapshotManager getSnapshotMgr() {
|
public SnapshotManager getSnapshotMgr() {
|
||||||
return _snapMgr;
|
return _snapMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AccountManager getAccountMgr() {
|
public AccountManager getAccountMgr() {
|
||||||
return _accountMgr;
|
return _accountMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EventDao getEventDao() {
|
public EventDao getEventDao() {
|
||||||
return _eventDao;
|
return _eventDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserVmDao getVmDao() {
|
public UserVmDao getVmDao() {
|
||||||
return _vmDao;
|
return _vmDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AccountDao getAccountDao() {
|
public AccountDao getAccountDao() {
|
||||||
return _accountDao;
|
return _accountDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VolumeDao getVolumeDao() {
|
public VolumeDao getVolumeDao() {
|
||||||
return _volumeDao;
|
return _volumeDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DomainRouterDao getRouterDao() {
|
public DomainRouterDao getRouterDao() {
|
||||||
return _routerDao;
|
return _routerDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPAddressDao getIpAddressDao() {
|
public IPAddressDao getIpAddressDao() {
|
||||||
return _ipAddressDao;
|
return _ipAddressDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AsyncJobDao getJobDao() {
|
public AsyncJobDao getJobDao() {
|
||||||
return _jobDao;
|
return _jobDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDao getUserDao() {
|
public UserDao getUserDao() {
|
||||||
return _userDao;
|
return _userDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VirtualMachineManager getItMgr() {
|
public VirtualMachineManager getItMgr() {
|
||||||
return _itMgr;
|
return _itMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||||
_name = name;
|
_name = name;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -166,6 +165,6 @@ public class AsyncJobExecutorContextImpl implements AsyncJobExecutorContext {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,11 @@ import javax.ejb.Local;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||||
|
import org.apache.cloudstack.api.BaseCmd;
|
||||||
|
import org.apache.cloudstack.api.ServerApiException;
|
||||||
import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
|
import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
|
||||||
|
import org.apache.cloudstack.api.response.ExceptionResponse;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.apache.log4j.NDC;
|
import org.apache.log4j.NDC;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -43,15 +47,10 @@ import org.springframework.stereotype.Component;
|
|||||||
import com.cloud.api.ApiDispatcher;
|
import com.cloud.api.ApiDispatcher;
|
||||||
import com.cloud.api.ApiGsonHelper;
|
import com.cloud.api.ApiGsonHelper;
|
||||||
import com.cloud.api.ApiSerializerHelper;
|
import com.cloud.api.ApiSerializerHelper;
|
||||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
|
||||||
import org.apache.cloudstack.api.ServerApiException;
|
|
||||||
import org.apache.cloudstack.api.response.ExceptionResponse;
|
|
||||||
import com.cloud.async.dao.AsyncJobDao;
|
import com.cloud.async.dao.AsyncJobDao;
|
||||||
import com.cloud.cluster.ClusterManager;
|
import com.cloud.cluster.ClusterManager;
|
||||||
import com.cloud.cluster.ClusterManagerListener;
|
import com.cloud.cluster.ClusterManagerListener;
|
||||||
import com.cloud.cluster.ManagementServerHostVO;
|
import com.cloud.cluster.ManagementServerHostVO;
|
||||||
import com.cloud.cluster.StackMaid;
|
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
@ -64,7 +63,6 @@ import com.cloud.user.dao.AccountDao;
|
|||||||
import com.cloud.utils.DateUtil;
|
import com.cloud.utils.DateUtil;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.PropertiesUtil;
|
import com.cloud.utils.PropertiesUtil;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GlobalLock;
|
import com.cloud.utils.db.GlobalLock;
|
||||||
@ -80,7 +78,7 @@ import com.google.gson.reflect.TypeToken;
|
|||||||
@Local(value={AsyncJobManager.class})
|
@Local(value={AsyncJobManager.class})
|
||||||
public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListener {
|
public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListener {
|
||||||
public static final Logger s_logger = Logger.getLogger(AsyncJobManagerImpl.class.getName());
|
public static final Logger s_logger = Logger.getLogger(AsyncJobManagerImpl.class.getName());
|
||||||
private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 3; // 3 seconds
|
private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 3; // 3 seconds
|
||||||
|
|
||||||
private static final int MAX_ONETIME_SCHEDULE_SIZE = 50;
|
private static final int MAX_ONETIME_SCHEDULE_SIZE = 50;
|
||||||
private static final int HEARTBEAT_INTERVAL = 2000;
|
private static final int HEARTBEAT_INTERVAL = 2000;
|
||||||
@ -98,167 +96,167 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
private long _jobExpireSeconds = 86400; // 1 day
|
private long _jobExpireSeconds = 86400; // 1 day
|
||||||
private long _jobCancelThresholdSeconds = 3600; // 1 hour (for cancelling the jobs blocking other jobs)
|
private long _jobCancelThresholdSeconds = 3600; // 1 hour (for cancelling the jobs blocking other jobs)
|
||||||
|
|
||||||
private ApiDispatcher _dispatcher;
|
@Inject private ApiDispatcher _dispatcher;
|
||||||
|
|
||||||
private final ScheduledExecutorService _heartbeatScheduler =
|
private final ScheduledExecutorService _heartbeatScheduler =
|
||||||
Executors.newScheduledThreadPool(1, new NamedThreadFactory("AsyncJobMgr-Heartbeat"));
|
Executors.newScheduledThreadPool(1, new NamedThreadFactory("AsyncJobMgr-Heartbeat"));
|
||||||
private ExecutorService _executor;
|
private ExecutorService _executor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AsyncJobExecutorContext getExecutorContext() {
|
public AsyncJobExecutorContext getExecutorContext() {
|
||||||
return _context;
|
return _context;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AsyncJobVO getAsyncJob(long jobId) {
|
|
||||||
return _jobDao.findById(jobId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AsyncJobVO findInstancePendingAsyncJob(String instanceType, long instanceId) {
|
public AsyncJobVO getAsyncJob(long jobId) {
|
||||||
return _jobDao.findInstancePendingAsyncJob(instanceType, instanceId);
|
return _jobDao.findById(jobId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AsyncJobVO findInstancePendingAsyncJob(String instanceType, long instanceId) {
|
||||||
|
return _jobDao.findInstancePendingAsyncJob(instanceType, instanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AsyncJobVO> findInstancePendingAsyncJobs(AsyncJob.Type instanceType, Long accountId) {
|
public List<AsyncJobVO> findInstancePendingAsyncJobs(AsyncJob.Type instanceType, Long accountId) {
|
||||||
return _jobDao.findInstancePendingAsyncJobs(instanceType, accountId);
|
return _jobDao.findInstancePendingAsyncJobs(instanceType, accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long submitAsyncJob(AsyncJobVO job) {
|
public long submitAsyncJob(AsyncJobVO job) {
|
||||||
return submitAsyncJob(job, false);
|
return submitAsyncJob(job, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
public long submitAsyncJob(AsyncJobVO job, boolean scheduleJobExecutionInContext) {
|
public long submitAsyncJob(AsyncJobVO job, boolean scheduleJobExecutionInContext) {
|
||||||
Transaction txt = Transaction.currentTxn();
|
Transaction txt = Transaction.currentTxn();
|
||||||
try {
|
try {
|
||||||
txt.start();
|
txt.start();
|
||||||
job.setInitMsid(getMsid());
|
job.setInitMsid(getMsid());
|
||||||
_jobDao.persist(job);
|
_jobDao.persist(job);
|
||||||
txt.commit();
|
txt.commit();
|
||||||
|
|
||||||
// no sync source originally
|
// no sync source originally
|
||||||
job.setSyncSource(null);
|
job.setSyncSource(null);
|
||||||
scheduleExecution(job, scheduleJobExecutionInContext);
|
scheduleExecution(job, scheduleJobExecutionInContext);
|
||||||
if(s_logger.isDebugEnabled()) {
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("submit async job-" + job.getId() + ", details: " + job.toString());
|
s_logger.debug("submit async job-" + job.getId() + ", details: " + job.toString());
|
||||||
}
|
}
|
||||||
return job.getId();
|
return job.getId();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
txt.rollback();
|
txt.rollback();
|
||||||
String errMsg = "Unable to schedule async job for command " + job.getCmd() + ", unexpected exception.";
|
String errMsg = "Unable to schedule async job for command " + job.getCmd() + ", unexpected exception.";
|
||||||
s_logger.warn(errMsg, e);
|
s_logger.warn(errMsg, e);
|
||||||
throw new CloudRuntimeException(errMsg);
|
throw new CloudRuntimeException(errMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
public void completeAsyncJob(long jobId, int jobStatus, int resultCode, Object resultObject) {
|
public void completeAsyncJob(long jobId, int jobStatus, int resultCode, Object resultObject) {
|
||||||
if(s_logger.isDebugEnabled()) {
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Complete async job-" + jobId + ", jobStatus: " + jobStatus +
|
s_logger.debug("Complete async job-" + jobId + ", jobStatus: " + jobStatus +
|
||||||
", resultCode: " + resultCode + ", result: " + resultObject);
|
", resultCode: " + resultCode + ", result: " + resultObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transaction txt = Transaction.currentTxn();
|
Transaction txt = Transaction.currentTxn();
|
||||||
try {
|
try {
|
||||||
txt.start();
|
txt.start();
|
||||||
AsyncJobVO job = _jobDao.findById(jobId);
|
AsyncJobVO job = _jobDao.findById(jobId);
|
||||||
if(job == null) {
|
if(job == null) {
|
||||||
if(s_logger.isDebugEnabled()) {
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("job-" + jobId + " no longer exists, we just log completion info here. " + jobStatus +
|
s_logger.debug("job-" + jobId + " no longer exists, we just log completion info here. " + jobStatus +
|
||||||
", resultCode: " + resultCode + ", result: " + resultObject);
|
", resultCode: " + resultCode + ", result: " + resultObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
txt.rollback();
|
txt.rollback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
job.setCompleteMsid(getMsid());
|
job.setCompleteMsid(getMsid());
|
||||||
job.setStatus(jobStatus);
|
job.setStatus(jobStatus);
|
||||||
job.setResultCode(resultCode);
|
job.setResultCode(resultCode);
|
||||||
|
|
||||||
// reset attached object
|
// reset attached object
|
||||||
job.setInstanceType(null);
|
job.setInstanceType(null);
|
||||||
job.setInstanceId(null);
|
job.setInstanceId(null);
|
||||||
|
|
||||||
if (resultObject != null) {
|
if (resultObject != null) {
|
||||||
job.setResult(ApiSerializerHelper.toSerializedStringOld(resultObject));
|
job.setResult(ApiSerializerHelper.toSerializedStringOld(resultObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
job.setLastUpdated(DateUtil.currentGMTTime());
|
job.setLastUpdated(DateUtil.currentGMTTime());
|
||||||
_jobDao.update(jobId, job);
|
_jobDao.update(jobId, job);
|
||||||
txt.commit();
|
txt.commit();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
s_logger.error("Unexpected exception while completing async job-" + jobId, e);
|
s_logger.error("Unexpected exception while completing async job-" + jobId, e);
|
||||||
txt.rollback();
|
txt.rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
public void updateAsyncJobStatus(long jobId, int processStatus, Object resultObject) {
|
public void updateAsyncJobStatus(long jobId, int processStatus, Object resultObject) {
|
||||||
if(s_logger.isDebugEnabled()) {
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Update async-job progress, job-" + jobId + ", processStatus: " + processStatus +
|
s_logger.debug("Update async-job progress, job-" + jobId + ", processStatus: " + processStatus +
|
||||||
", result: " + resultObject);
|
", result: " + resultObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transaction txt = Transaction.currentTxn();
|
Transaction txt = Transaction.currentTxn();
|
||||||
try {
|
try {
|
||||||
txt.start();
|
txt.start();
|
||||||
AsyncJobVO job = _jobDao.findById(jobId);
|
AsyncJobVO job = _jobDao.findById(jobId);
|
||||||
if(job == null) {
|
if(job == null) {
|
||||||
if(s_logger.isDebugEnabled()) {
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("job-" + jobId + " no longer exists, we just log progress info here. progress status: " + processStatus);
|
s_logger.debug("job-" + jobId + " no longer exists, we just log progress info here. progress status: " + processStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
txt.rollback();
|
txt.rollback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
job.setProcessStatus(processStatus);
|
job.setProcessStatus(processStatus);
|
||||||
if(resultObject != null) {
|
if(resultObject != null) {
|
||||||
job.setResult(ApiSerializerHelper.toSerializedStringOld(resultObject));
|
job.setResult(ApiSerializerHelper.toSerializedStringOld(resultObject));
|
||||||
}
|
}
|
||||||
job.setLastUpdated(DateUtil.currentGMTTime());
|
job.setLastUpdated(DateUtil.currentGMTTime());
|
||||||
_jobDao.update(jobId, job);
|
_jobDao.update(jobId, job);
|
||||||
txt.commit();
|
txt.commit();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
s_logger.error("Unexpected exception while updating async job-" + jobId + " status: ", e);
|
s_logger.error("Unexpected exception while updating async job-" + jobId + " status: ", e);
|
||||||
txt.rollback();
|
txt.rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
public void updateAsyncJobAttachment(long jobId, String instanceType, Long instanceId) {
|
public void updateAsyncJobAttachment(long jobId, String instanceType, Long instanceId) {
|
||||||
if(s_logger.isDebugEnabled()) {
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Update async-job attachment, job-" + jobId + ", instanceType: " + instanceType +
|
s_logger.debug("Update async-job attachment, job-" + jobId + ", instanceType: " + instanceType +
|
||||||
", instanceId: " + instanceId);
|
", instanceId: " + instanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transaction txt = Transaction.currentTxn();
|
Transaction txt = Transaction.currentTxn();
|
||||||
try {
|
try {
|
||||||
txt.start();
|
txt.start();
|
||||||
|
|
||||||
AsyncJobVO job = _jobDao.createForUpdate();
|
AsyncJobVO job = _jobDao.createForUpdate();
|
||||||
//job.setInstanceType(instanceType);
|
//job.setInstanceType(instanceType);
|
||||||
job.setInstanceId(instanceId);
|
job.setInstanceId(instanceId);
|
||||||
job.setLastUpdated(DateUtil.currentGMTTime());
|
job.setLastUpdated(DateUtil.currentGMTTime());
|
||||||
_jobDao.update(jobId, job);
|
_jobDao.update(jobId, job);
|
||||||
|
|
||||||
txt.commit();
|
txt.commit();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
s_logger.error("Unexpected exception while updating async job-" + jobId + " attachment: ", e);
|
s_logger.error("Unexpected exception while updating async job-" + jobId + " attachment: ", e);
|
||||||
txt.rollback();
|
txt.rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void syncAsyncJobExecution(AsyncJob job, String syncObjType, long syncObjId, long queueSizeLimit) {
|
public void syncAsyncJobExecution(AsyncJob job, String syncObjType, long syncObjId, long queueSizeLimit) {
|
||||||
// This method is re-entrant. If an API developer wants to synchronized on an object, e.g. the router,
|
// This method is re-entrant. If an API developer wants to synchronized on an object, e.g. the router,
|
||||||
// when executing business logic, they will call this method (actually a method in BaseAsyncCmd that calls this).
|
// when executing business logic, they will call this method (actually a method in BaseAsyncCmd that calls this).
|
||||||
// This method will get called every time their business logic executes. The first time it exectues for a job
|
// This method will get called every time their business logic executes. The first time it exectues for a job
|
||||||
// there will be no sync source, but on subsequent execution there will be a sync souce. If this is the first
|
// there will be no sync source, but on subsequent execution there will be a sync souce. If this is the first
|
||||||
// time the job executes we queue the job, otherwise we just return so that the business logic can execute.
|
// time the job executes we queue the job, otherwise we just return so that the business logic can execute.
|
||||||
if (job.getSyncSource() != null) {
|
if (job.getSyncSource() != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -267,29 +265,29 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
s_logger.debug("Sync job-" + job.getId() + " execution on object " + syncObjType + "." + syncObjId);
|
s_logger.debug("Sync job-" + job.getId() + " execution on object " + syncObjType + "." + syncObjId);
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncQueueVO queue = null;
|
SyncQueueVO queue = null;
|
||||||
|
|
||||||
// to deal with temporary DB exceptions like DB deadlock/Lock-wait time out cased rollbacks
|
// to deal with temporary DB exceptions like DB deadlock/Lock-wait time out cased rollbacks
|
||||||
// we retry five times until we throw an exception
|
// we retry five times until we throw an exception
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
for(int i = 0; i < 5; i++) {
|
for(int i = 0; i < 5; i++) {
|
||||||
queue = _queueMgr.queue(syncObjType, syncObjId, SyncQueueItem.AsyncJobContentType, job.getId(), queueSizeLimit);
|
queue = _queueMgr.queue(syncObjType, syncObjId, SyncQueueItem.AsyncJobContentType, job.getId(), queueSizeLimit);
|
||||||
if(queue != null) {
|
if(queue != null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000 + random.nextInt(5000));
|
Thread.sleep(1000 + random.nextInt(5000));
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queue == null) {
|
if (queue == null) {
|
||||||
throw new CloudRuntimeException("Unable to insert queue item into database, DB is full?");
|
throw new CloudRuntimeException("Unable to insert queue item into database, DB is full?");
|
||||||
} else {
|
} else {
|
||||||
throw new AsyncCommandQueued(queue, "job-" + job.getId() + " queued");
|
throw new AsyncCommandQueued(queue, "job-" + job.getId() + " queued");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -321,56 +319,56 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
public AsyncJobResult queryAsyncJobResult(long jobId) {
|
public AsyncJobResult queryAsyncJobResult(long jobId) {
|
||||||
if(s_logger.isTraceEnabled()) {
|
if(s_logger.isTraceEnabled()) {
|
||||||
s_logger.trace("Query async-job status, job-" + jobId);
|
s_logger.trace("Query async-job status, job-" + jobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transaction txt = Transaction.currentTxn();
|
Transaction txt = Transaction.currentTxn();
|
||||||
AsyncJobResult jobResult = new AsyncJobResult(jobId);
|
AsyncJobResult jobResult = new AsyncJobResult(jobId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
txt.start();
|
txt.start();
|
||||||
AsyncJobVO job = _jobDao.findById(jobId);
|
AsyncJobVO job = _jobDao.findById(jobId);
|
||||||
if(job != null) {
|
if(job != null) {
|
||||||
jobResult.setCmdOriginator(job.getCmdOriginator());
|
jobResult.setCmdOriginator(job.getCmdOriginator());
|
||||||
jobResult.setJobStatus(job.getStatus());
|
jobResult.setJobStatus(job.getStatus());
|
||||||
jobResult.setProcessStatus(job.getProcessStatus());
|
jobResult.setProcessStatus(job.getProcessStatus());
|
||||||
jobResult.setResult(job.getResult());
|
jobResult.setResult(job.getResult());
|
||||||
jobResult.setResultCode(job.getResultCode());
|
jobResult.setResultCode(job.getResultCode());
|
||||||
jobResult.setUuid(job.getUuid());
|
jobResult.setUuid(job.getUuid());
|
||||||
|
|
||||||
if(job.getStatus() == AsyncJobResult.STATUS_SUCCEEDED ||
|
if(job.getStatus() == AsyncJobResult.STATUS_SUCCEEDED ||
|
||||||
job.getStatus() == AsyncJobResult.STATUS_FAILED) {
|
job.getStatus() == AsyncJobResult.STATUS_FAILED) {
|
||||||
|
|
||||||
if(s_logger.isDebugEnabled()) {
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Async job-" + jobId + " completed");
|
s_logger.debug("Async job-" + jobId + " completed");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
job.setLastPolled(DateUtil.currentGMTTime());
|
job.setLastPolled(DateUtil.currentGMTTime());
|
||||||
_jobDao.update(jobId, job);
|
_jobDao.update(jobId, job);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(s_logger.isDebugEnabled()) {
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Async job-" + jobId + " does not exist, invalid job id?");
|
s_logger.debug("Async job-" + jobId + " does not exist, invalid job id?");
|
||||||
}
|
}
|
||||||
|
|
||||||
jobResult.setJobStatus(AsyncJobResult.STATUS_FAILED);
|
jobResult.setJobStatus(AsyncJobResult.STATUS_FAILED);
|
||||||
jobResult.setResult("job-" + jobId + " does not exist");
|
jobResult.setResult("job-" + jobId + " does not exist");
|
||||||
}
|
}
|
||||||
txt.commit();
|
txt.commit();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
s_logger.error("Unexpected exception while querying async job-" + jobId + " status: ", e);
|
s_logger.error("Unexpected exception while querying async job-" + jobId + " status: ", e);
|
||||||
|
|
||||||
jobResult.setJobStatus(AsyncJobResult.STATUS_FAILED);
|
jobResult.setJobStatus(AsyncJobResult.STATUS_FAILED);
|
||||||
jobResult.setResult("Exception: " + e.toString());
|
jobResult.setResult("Exception: " + e.toString());
|
||||||
txt.rollback();
|
txt.rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s_logger.isTraceEnabled()) {
|
if(s_logger.isTraceEnabled()) {
|
||||||
s_logger.trace("Job status: " + jobResult.toString());
|
s_logger.trace("Job status: " + jobResult.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return jobResult;
|
return jobResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scheduleExecution(final AsyncJobVO job) {
|
private void scheduleExecution(final AsyncJobVO job) {
|
||||||
@ -382,7 +380,7 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
if (executeInContext) {
|
if (executeInContext) {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
} else {
|
} else {
|
||||||
_executor.submit(runnable);
|
_executor.submit(runnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,9 +392,9 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
long jobId = 0;
|
long jobId = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JmxUtil.registerMBean("AsyncJobManager", "Active Job " + job.getId(), new AsyncJobMBeanImpl(job));
|
JmxUtil.registerMBean("AsyncJobManager", "Active Job " + job.getId(), new AsyncJobMBeanImpl(job));
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
s_logger.warn("Unable to register active job " + job.getId() + " to JMX monitoring due to exception " + ExceptionUtil.toString(e));
|
s_logger.warn("Unable to register active job " + job.getId() + " to JMX monitoring due to exception " + ExceptionUtil.toString(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseAsyncCmd cmdObj = null;
|
BaseAsyncCmd cmdObj = null;
|
||||||
@ -492,12 +490,11 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JmxUtil.unregisterMBean("AsyncJobManager", "Active Job " + job.getId());
|
JmxUtil.unregisterMBean("AsyncJobManager", "Active Job " + job.getId());
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
s_logger.warn("Unable to unregister active job " + job.getId() + " from JMX monitoring");
|
s_logger.warn("Unable to unregister active job " + job.getId() + " from JMX monitoring");
|
||||||
}
|
}
|
||||||
|
|
||||||
StackMaid.current().exitCleanup();
|
|
||||||
txn.close();
|
txn.close();
|
||||||
NDC.pop();
|
NDC.pop();
|
||||||
}
|
}
|
||||||
@ -525,11 +522,11 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
_jobDao.update(job.getId(), job);
|
_jobDao.update(job.getId(), job);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
scheduleExecution(job);
|
scheduleExecution(job);
|
||||||
} catch(RejectedExecutionException e) {
|
} catch(RejectedExecutionException e) {
|
||||||
s_logger.warn("Execution for job-" + job.getId() + " is rejected, return it to the queue for next turn");
|
s_logger.warn("Execution for job-" + job.getId() + " is rejected, return it to the queue for next turn");
|
||||||
_queueMgr.returnItem(item.getId());
|
_queueMgr.returnItem(item.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if(s_logger.isDebugEnabled()) {
|
if(s_logger.isDebugEnabled()) {
|
||||||
@ -542,120 +539,116 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void releaseSyncSource(AsyncJobExecutor executor) {
|
public void releaseSyncSource(AsyncJobExecutor executor) {
|
||||||
if(executor.getSyncSource() != null) {
|
if(executor.getSyncSource() != null) {
|
||||||
if(s_logger.isDebugEnabled()) {
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Release sync source for job-" + executor.getJob().getId() + " sync source: "
|
s_logger.debug("Release sync source for job-" + executor.getJob().getId() + " sync source: "
|
||||||
+ executor.getSyncSource().getContentType() + "-"
|
+ executor.getSyncSource().getContentType() + "-"
|
||||||
+ executor.getSyncSource().getContentId());
|
+ executor.getSyncSource().getContentId());
|
||||||
}
|
}
|
||||||
|
|
||||||
_queueMgr.purgeItem(executor.getSyncSource().getId());
|
_queueMgr.purgeItem(executor.getSyncSource().getId());
|
||||||
checkQueue(executor.getSyncSource().getQueueId());
|
checkQueue(executor.getSyncSource().getQueueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkQueue(long queueId) {
|
private void checkQueue(long queueId) {
|
||||||
while(true) {
|
while(true) {
|
||||||
try {
|
try {
|
||||||
SyncQueueItemVO item = _queueMgr.dequeueFromOne(queueId, getMsid());
|
SyncQueueItemVO item = _queueMgr.dequeueFromOne(queueId, getMsid());
|
||||||
if(item != null) {
|
if(item != null) {
|
||||||
if(s_logger.isDebugEnabled()) {
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Executing sync queue item: " + item.toString());
|
s_logger.debug("Executing sync queue item: " + item.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
executeQueueItem(item, false);
|
executeQueueItem(item, false);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch(Throwable e) {
|
} catch(Throwable e) {
|
||||||
s_logger.error("Unexpected exception when kicking sync queue-" + queueId, e);
|
s_logger.error("Unexpected exception when kicking sync queue-" + queueId, e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Runnable getHeartbeatTask() {
|
private Runnable getHeartbeatTask() {
|
||||||
return new Runnable() {
|
return new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
List<SyncQueueItemVO> l = _queueMgr.dequeueFromAny(getMsid(), MAX_ONETIME_SCHEDULE_SIZE);
|
List<SyncQueueItemVO> l = _queueMgr.dequeueFromAny(getMsid(), MAX_ONETIME_SCHEDULE_SIZE);
|
||||||
if(l != null && l.size() > 0) {
|
if(l != null && l.size() > 0) {
|
||||||
for(SyncQueueItemVO item: l) {
|
for(SyncQueueItemVO item: l) {
|
||||||
if(s_logger.isDebugEnabled()) {
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Execute sync-queue item: " + item.toString());
|
s_logger.debug("Execute sync-queue item: " + item.toString());
|
||||||
}
|
}
|
||||||
executeQueueItem(item, false);
|
executeQueueItem(item, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Throwable e) {
|
} catch(Throwable e) {
|
||||||
s_logger.error("Unexpected exception when trying to execute queue item, ", e);
|
s_logger.error("Unexpected exception when trying to execute queue item, ", e);
|
||||||
} finally {
|
}
|
||||||
StackMaid.current().exitCleanup();
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@DB
|
@DB
|
||||||
private Runnable getGCTask() {
|
private Runnable getGCTask() {
|
||||||
return new Runnable() {
|
return new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GlobalLock scanLock = GlobalLock.getInternLock("AsyncJobManagerGC");
|
GlobalLock scanLock = GlobalLock.getInternLock("AsyncJobManagerGC");
|
||||||
try {
|
try {
|
||||||
if(scanLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION)) {
|
if(scanLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION)) {
|
||||||
try {
|
try {
|
||||||
reallyRun();
|
reallyRun();
|
||||||
} finally {
|
} finally {
|
||||||
scanLock.unlock();
|
scanLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
scanLock.releaseRef();
|
scanLock.releaseRef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reallyRun() {
|
public void reallyRun() {
|
||||||
try {
|
try {
|
||||||
s_logger.trace("Begin cleanup expired async-jobs");
|
s_logger.trace("Begin cleanup expired async-jobs");
|
||||||
|
|
||||||
Date cutTime = new Date(DateUtil.currentGMTTime().getTime() - _jobExpireSeconds*1000);
|
Date cutTime = new Date(DateUtil.currentGMTTime().getTime() - _jobExpireSeconds*1000);
|
||||||
|
|
||||||
// limit to 100 jobs per turn, this gives cleanup throughput as 600 jobs per minute
|
// limit to 100 jobs per turn, this gives cleanup throughput as 600 jobs per minute
|
||||||
// hopefully this will be fast enough to balance potential growth of job table
|
// hopefully this will be fast enough to balance potential growth of job table
|
||||||
List<AsyncJobVO> l = _jobDao.getExpiredJobs(cutTime, 100);
|
List<AsyncJobVO> l = _jobDao.getExpiredJobs(cutTime, 100);
|
||||||
if(l != null && l.size() > 0) {
|
if(l != null && l.size() > 0) {
|
||||||
for(AsyncJobVO job : l) {
|
for(AsyncJobVO job : l) {
|
||||||
expungeAsyncJob(job);
|
expungeAsyncJob(job);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// forcefully cancel blocking queue items if they've been staying there for too long
|
// forcefully cancel blocking queue items if they've been staying there for too long
|
||||||
List<SyncQueueItemVO> blockItems = _queueMgr.getBlockedQueueItems(_jobCancelThresholdSeconds*1000, false);
|
List<SyncQueueItemVO> blockItems = _queueMgr.getBlockedQueueItems(_jobCancelThresholdSeconds*1000, false);
|
||||||
if(blockItems != null && blockItems.size() > 0) {
|
if(blockItems != null && blockItems.size() > 0) {
|
||||||
for(SyncQueueItemVO item : blockItems) {
|
for(SyncQueueItemVO item : blockItems) {
|
||||||
if(item.getContentType().equalsIgnoreCase(SyncQueueItem.AsyncJobContentType)) {
|
if(item.getContentType().equalsIgnoreCase(SyncQueueItem.AsyncJobContentType)) {
|
||||||
completeAsyncJob(item.getContentId(), AsyncJobResult.STATUS_FAILED, 0,
|
completeAsyncJob(item.getContentId(), AsyncJobResult.STATUS_FAILED, 0,
|
||||||
getResetResultResponse("Job is cancelled as it has been blocking others for too long"));
|
getResetResultResponse("Job is cancelled as it has been blocking others for too long"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// purge the item and resume queue processing
|
// purge the item and resume queue processing
|
||||||
_queueMgr.purgeItem(item.getId());
|
_queueMgr.purgeItem(item.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s_logger.trace("End cleanup expired async-jobs");
|
s_logger.trace("End cleanup expired async-jobs");
|
||||||
} catch(Throwable e) {
|
} catch(Throwable e) {
|
||||||
s_logger.error("Unexpected exception when trying to execute queue item, ", e);
|
s_logger.error("Unexpected exception when trying to execute queue item, ", e);
|
||||||
} finally {
|
}
|
||||||
StackMaid.current().exitCleanup();
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@DB
|
@DB
|
||||||
protected void expungeAsyncJob(AsyncJobVO job) {
|
protected void expungeAsyncJob(AsyncJobVO job) {
|
||||||
@ -667,53 +660,50 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
txn.commit();
|
txn.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getMsid() {
|
private long getMsid() {
|
||||||
if(_clusterMgr != null) {
|
if(_clusterMgr != null) {
|
||||||
return _clusterMgr.getManagementNodeId();
|
return _clusterMgr.getManagementNodeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
return MacAddress.getMacAddress().toLong();
|
return MacAddress.getMacAddress().toLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanupPendingJobs(List<SyncQueueItemVO> l) {
|
private void cleanupPendingJobs(List<SyncQueueItemVO> l) {
|
||||||
if(l != null && l.size() > 0) {
|
if(l != null && l.size() > 0) {
|
||||||
for(SyncQueueItemVO item: l) {
|
for(SyncQueueItemVO item: l) {
|
||||||
if(s_logger.isInfoEnabled()) {
|
if(s_logger.isInfoEnabled()) {
|
||||||
s_logger.info("Discard left-over queue item: " + item.toString());
|
s_logger.info("Discard left-over queue item: " + item.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
String contentType = item.getContentType();
|
String contentType = item.getContentType();
|
||||||
if(contentType != null && contentType.equalsIgnoreCase(SyncQueueItem.AsyncJobContentType)) {
|
if(contentType != null && contentType.equalsIgnoreCase(SyncQueueItem.AsyncJobContentType)) {
|
||||||
Long jobId = item.getContentId();
|
Long jobId = item.getContentId();
|
||||||
if(jobId != null) {
|
if(jobId != null) {
|
||||||
s_logger.warn("Mark job as failed as its correspoding queue-item has been discarded. job id: " + jobId);
|
s_logger.warn("Mark job as failed as its correspoding queue-item has been discarded. job id: " + jobId);
|
||||||
completeAsyncJob(jobId, AsyncJobResult.STATUS_FAILED, 0, getResetResultResponse("Execution was cancelled because of server shutdown"));
|
completeAsyncJob(jobId, AsyncJobResult.STATUS_FAILED, 0, getResetResultResponse("Execution was cancelled because of server shutdown"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_queueMgr.purgeItem(item.getId());
|
_queueMgr.purgeItem(item.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||||
_name = name;
|
_name = name;
|
||||||
|
|
||||||
int expireMinutes = NumbersUtil.parseInt(
|
int expireMinutes = NumbersUtil.parseInt(
|
||||||
_configDao.getValue(Config.JobExpireMinutes.key()), 24*60);
|
_configDao.getValue(Config.JobExpireMinutes.key()), 24*60);
|
||||||
_jobExpireSeconds = (long)expireMinutes*60;
|
_jobExpireSeconds = (long)expireMinutes*60;
|
||||||
|
|
||||||
_jobCancelThresholdSeconds = NumbersUtil.parseInt(
|
_jobCancelThresholdSeconds = NumbersUtil.parseInt(
|
||||||
_configDao.getValue(Config.JobCancelThresholdMinutes.key()), 60);
|
_configDao.getValue(Config.JobCancelThresholdMinutes.key()), 60);
|
||||||
_jobCancelThresholdSeconds *= 60;
|
_jobCancelThresholdSeconds *= 60;
|
||||||
|
|
||||||
_dispatcher = ApiDispatcher.getInstance();
|
try {
|
||||||
|
final File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
|
||||||
|
final Properties dbProps = new Properties();
|
||||||
try {
|
dbProps.load(new FileInputStream(dbPropsFile));
|
||||||
final File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
|
|
||||||
final Properties dbProps = new Properties();
|
|
||||||
dbProps.load(new FileInputStream(dbPropsFile));
|
|
||||||
|
|
||||||
final int cloudMaxActive = Integer.parseInt(dbProps.getProperty("db.cloud.maxActive"));
|
final int cloudMaxActive = Integer.parseInt(dbProps.getProperty("db.cloud.maxActive"));
|
||||||
|
|
||||||
@ -721,63 +711,63 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
|
|
||||||
s_logger.info("Start AsyncJobManager thread pool in size " + poolSize);
|
s_logger.info("Start AsyncJobManager thread pool in size " + poolSize);
|
||||||
_executor = Executors.newFixedThreadPool(poolSize, new NamedThreadFactory("Job-Executor"));
|
_executor = Executors.newFixedThreadPool(poolSize, new NamedThreadFactory("Job-Executor"));
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new ConfigurationException("Unable to load db.properties to configure AsyncJobManagerImpl");
|
throw new ConfigurationException("Unable to load db.properties to configure AsyncJobManagerImpl");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onManagementNodeJoined(List<ManagementServerHostVO> nodeList, long selfNodeId) {
|
public void onManagementNodeJoined(List<ManagementServerHostVO> nodeList, long selfNodeId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onManagementNodeLeft(List<ManagementServerHostVO> nodeList, long selfNodeId) {
|
public void onManagementNodeLeft(List<ManagementServerHostVO> nodeList, long selfNodeId) {
|
||||||
for(ManagementServerHostVO msHost : nodeList) {
|
for(ManagementServerHostVO msHost : nodeList) {
|
||||||
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
||||||
try {
|
try {
|
||||||
txn.start();
|
txn.start();
|
||||||
List<SyncQueueItemVO> items = _queueMgr.getActiveQueueItems(msHost.getId(), true);
|
List<SyncQueueItemVO> items = _queueMgr.getActiveQueueItems(msHost.getId(), true);
|
||||||
cleanupPendingJobs(items);
|
cleanupPendingJobs(items);
|
||||||
_jobDao.resetJobProcess(msHost.getId(), BaseCmd.INTERNAL_ERROR, getSerializedErrorMessage("job cancelled because of management server restart"));
|
_jobDao.resetJobProcess(msHost.getId(), BaseCmd.INTERNAL_ERROR, getSerializedErrorMessage("job cancelled because of management server restart"));
|
||||||
txn.commit();
|
txn.commit();
|
||||||
} catch(Throwable e) {
|
} catch(Throwable e) {
|
||||||
s_logger.warn("Unexpected exception ", e);
|
s_logger.warn("Unexpected exception ", e);
|
||||||
txn.rollback();
|
txn.rollback();
|
||||||
} finally {
|
} finally {
|
||||||
txn.close();
|
txn.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onManagementNodeIsolated() {
|
public void onManagementNodeIsolated() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean start() {
|
public boolean start() {
|
||||||
try {
|
try {
|
||||||
List<SyncQueueItemVO> l = _queueMgr.getActiveQueueItems(getMsid(), false);
|
List<SyncQueueItemVO> l = _queueMgr.getActiveQueueItems(getMsid(), false);
|
||||||
cleanupPendingJobs(l);
|
cleanupPendingJobs(l);
|
||||||
_jobDao.resetJobProcess(getMsid(), BaseCmd.INTERNAL_ERROR, getSerializedErrorMessage("job cancelled because of management server restart"));
|
_jobDao.resetJobProcess(getMsid(), BaseCmd.INTERNAL_ERROR, getSerializedErrorMessage("job cancelled because of management server restart"));
|
||||||
} catch(Throwable e) {
|
} catch(Throwable e) {
|
||||||
s_logger.error("Unexpected exception " + e.getMessage(), e);
|
s_logger.error("Unexpected exception " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
_heartbeatScheduler.scheduleAtFixedRate(getHeartbeatTask(), HEARTBEAT_INTERVAL,
|
_heartbeatScheduler.scheduleAtFixedRate(getHeartbeatTask(), HEARTBEAT_INTERVAL,
|
||||||
HEARTBEAT_INTERVAL, TimeUnit.MILLISECONDS);
|
HEARTBEAT_INTERVAL, TimeUnit.MILLISECONDS);
|
||||||
_heartbeatScheduler.scheduleAtFixedRate(getGCTask(), GC_INTERVAL,
|
_heartbeatScheduler.scheduleAtFixedRate(getGCTask(), GC_INTERVAL,
|
||||||
GC_INTERVAL, TimeUnit.MILLISECONDS);
|
GC_INTERVAL, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ExceptionResponse getResetResultResponse(String errorMessage) {
|
private static ExceptionResponse getResetResultResponse(String errorMessage) {
|
||||||
ExceptionResponse resultObject = new ExceptionResponse();
|
ExceptionResponse resultObject = new ExceptionResponse();
|
||||||
resultObject.setErrorCode(BaseCmd.INTERNAL_ERROR);
|
resultObject.setErrorCode(BaseCmd.INTERNAL_ERROR);
|
||||||
resultObject.setErrorText(errorMessage);
|
resultObject.setErrorText(errorMessage);
|
||||||
return resultObject;
|
return resultObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getSerializedErrorMessage(String errorMessage) {
|
private static String getSerializedErrorMessage(String errorMessage) {
|
||||||
@ -786,13 +776,13 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stop() {
|
public boolean stop() {
|
||||||
_heartbeatScheduler.shutdown();
|
_heartbeatScheduler.shutdown();
|
||||||
_executor.shutdown();
|
_executor.shutdown();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,6 @@ import org.springframework.stereotype.Component;
|
|||||||
import com.cloud.async.dao.SyncQueueDao;
|
import com.cloud.async.dao.SyncQueueDao;
|
||||||
import com.cloud.async.dao.SyncQueueItemDao;
|
import com.cloud.async.dao.SyncQueueItemDao;
|
||||||
import com.cloud.utils.DateUtil;
|
import com.cloud.utils.DateUtil;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
@ -50,190 +49,190 @@ public class SyncQueueManagerImpl implements SyncQueueManager {
|
|||||||
@DB
|
@DB
|
||||||
public SyncQueueVO queue(String syncObjType, long syncObjId, String itemType, long itemId, long queueSizeLimit) {
|
public SyncQueueVO queue(String syncObjType, long syncObjId, String itemType, long itemId, long queueSizeLimit) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
try {
|
try {
|
||||||
txn.start();
|
txn.start();
|
||||||
|
|
||||||
_syncQueueDao.ensureQueue(syncObjType, syncObjId);
|
_syncQueueDao.ensureQueue(syncObjType, syncObjId);
|
||||||
SyncQueueVO queueVO = _syncQueueDao.find(syncObjType, syncObjId);
|
SyncQueueVO queueVO = _syncQueueDao.find(syncObjType, syncObjId);
|
||||||
if(queueVO == null)
|
if(queueVO == null)
|
||||||
throw new CloudRuntimeException("Unable to queue item into DB, DB is full?");
|
throw new CloudRuntimeException("Unable to queue item into DB, DB is full?");
|
||||||
|
|
||||||
queueVO.setQueueSizeLimit(queueSizeLimit);
|
queueVO.setQueueSizeLimit(queueSizeLimit);
|
||||||
_syncQueueDao.update(queueVO.getId(), queueVO);
|
_syncQueueDao.update(queueVO.getId(), queueVO);
|
||||||
|
|
||||||
Date dt = DateUtil.currentGMTTime();
|
Date dt = DateUtil.currentGMTTime();
|
||||||
SyncQueueItemVO item = new SyncQueueItemVO();
|
SyncQueueItemVO item = new SyncQueueItemVO();
|
||||||
item.setQueueId(queueVO.getId());
|
item.setQueueId(queueVO.getId());
|
||||||
item.setContentType(itemType);
|
item.setContentType(itemType);
|
||||||
item.setContentId(itemId);
|
item.setContentId(itemId);
|
||||||
item.setCreated(dt);
|
item.setCreated(dt);
|
||||||
|
|
||||||
_syncQueueItemDao.persist(item);
|
_syncQueueItemDao.persist(item);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|
||||||
return queueVO;
|
return queueVO;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
s_logger.error("Unexpected exception: ", e);
|
s_logger.error("Unexpected exception: ", e);
|
||||||
txn.rollback();
|
txn.rollback();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DB
|
@DB
|
||||||
public SyncQueueItemVO dequeueFromOne(long queueId, Long msid) {
|
public SyncQueueItemVO dequeueFromOne(long queueId, Long msid) {
|
||||||
Transaction txt = Transaction.currentTxn();
|
Transaction txt = Transaction.currentTxn();
|
||||||
try {
|
try {
|
||||||
txt.start();
|
txt.start();
|
||||||
|
|
||||||
SyncQueueVO queueVO = _syncQueueDao.lockRow(queueId, true);
|
SyncQueueVO queueVO = _syncQueueDao.lockRow(queueId, true);
|
||||||
if(queueVO == null) {
|
if(queueVO == null) {
|
||||||
s_logger.error("Sync queue(id: " + queueId + ") does not exist");
|
s_logger.error("Sync queue(id: " + queueId + ") does not exist");
|
||||||
txt.commit();
|
txt.commit();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(queueReadyToProcess(queueVO)) {
|
if(queueReadyToProcess(queueVO)) {
|
||||||
SyncQueueItemVO itemVO = _syncQueueItemDao.getNextQueueItem(queueVO.getId());
|
SyncQueueItemVO itemVO = _syncQueueItemDao.getNextQueueItem(queueVO.getId());
|
||||||
if(itemVO != null) {
|
if(itemVO != null) {
|
||||||
Long processNumber = queueVO.getLastProcessNumber();
|
Long processNumber = queueVO.getLastProcessNumber();
|
||||||
if(processNumber == null)
|
if(processNumber == null)
|
||||||
processNumber = new Long(1);
|
processNumber = new Long(1);
|
||||||
else
|
else
|
||||||
processNumber = processNumber + 1;
|
processNumber = processNumber + 1;
|
||||||
Date dt = DateUtil.currentGMTTime();
|
Date dt = DateUtil.currentGMTTime();
|
||||||
queueVO.setLastProcessNumber(processNumber);
|
queueVO.setLastProcessNumber(processNumber);
|
||||||
queueVO.setLastUpdated(dt);
|
queueVO.setLastUpdated(dt);
|
||||||
queueVO.setQueueSize(queueVO.getQueueSize() + 1);
|
queueVO.setQueueSize(queueVO.getQueueSize() + 1);
|
||||||
_syncQueueDao.update(queueVO.getId(), queueVO);
|
_syncQueueDao.update(queueVO.getId(), queueVO);
|
||||||
|
|
||||||
itemVO.setLastProcessMsid(msid);
|
itemVO.setLastProcessMsid(msid);
|
||||||
itemVO.setLastProcessNumber(processNumber);
|
itemVO.setLastProcessNumber(processNumber);
|
||||||
itemVO.setLastProcessTime(dt);
|
itemVO.setLastProcessTime(dt);
|
||||||
_syncQueueItemDao.update(itemVO.getId(), itemVO);
|
_syncQueueItemDao.update(itemVO.getId(), itemVO);
|
||||||
|
|
||||||
txt.commit();
|
txt.commit();
|
||||||
return itemVO;
|
return itemVO;
|
||||||
} else {
|
} else {
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled())
|
||||||
s_logger.debug("Sync queue (" + queueId + ") is currently empty");
|
s_logger.debug("Sync queue (" + queueId + ") is currently empty");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled())
|
||||||
s_logger.debug("There is a pending process in sync queue(id: " + queueId + ")");
|
s_logger.debug("There is a pending process in sync queue(id: " + queueId + ")");
|
||||||
}
|
}
|
||||||
txt.commit();
|
txt.commit();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
s_logger.error("Unexpected exception: ", e);
|
s_logger.error("Unexpected exception: ", e);
|
||||||
txt.rollback();
|
txt.rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DB
|
@DB
|
||||||
public List<SyncQueueItemVO> dequeueFromAny(Long msid, int maxItems) {
|
public List<SyncQueueItemVO> dequeueFromAny(Long msid, int maxItems) {
|
||||||
|
|
||||||
List<SyncQueueItemVO> resultList = new ArrayList<SyncQueueItemVO>();
|
List<SyncQueueItemVO> resultList = new ArrayList<SyncQueueItemVO>();
|
||||||
Transaction txt = Transaction.currentTxn();
|
Transaction txt = Transaction.currentTxn();
|
||||||
try {
|
try {
|
||||||
txt.start();
|
txt.start();
|
||||||
|
|
||||||
List<SyncQueueItemVO> l = _syncQueueItemDao.getNextQueueItems(maxItems);
|
List<SyncQueueItemVO> l = _syncQueueItemDao.getNextQueueItems(maxItems);
|
||||||
if(l != null && l.size() > 0) {
|
if(l != null && l.size() > 0) {
|
||||||
for(SyncQueueItemVO item : l) {
|
for(SyncQueueItemVO item : l) {
|
||||||
SyncQueueVO queueVO = _syncQueueDao.lockRow(item.getQueueId(), true);
|
SyncQueueVO queueVO = _syncQueueDao.lockRow(item.getQueueId(), true);
|
||||||
SyncQueueItemVO itemVO = _syncQueueItemDao.lockRow(item.getId(), true);
|
SyncQueueItemVO itemVO = _syncQueueItemDao.lockRow(item.getId(), true);
|
||||||
if(queueReadyToProcess(queueVO) && itemVO.getLastProcessNumber() == null) {
|
if(queueReadyToProcess(queueVO) && itemVO.getLastProcessNumber() == null) {
|
||||||
Long processNumber = queueVO.getLastProcessNumber();
|
Long processNumber = queueVO.getLastProcessNumber();
|
||||||
if(processNumber == null)
|
if(processNumber == null)
|
||||||
processNumber = new Long(1);
|
processNumber = new Long(1);
|
||||||
else
|
else
|
||||||
processNumber = processNumber + 1;
|
processNumber = processNumber + 1;
|
||||||
|
|
||||||
Date dt = DateUtil.currentGMTTime();
|
Date dt = DateUtil.currentGMTTime();
|
||||||
queueVO.setLastProcessNumber(processNumber);
|
queueVO.setLastProcessNumber(processNumber);
|
||||||
queueVO.setLastUpdated(dt);
|
queueVO.setLastUpdated(dt);
|
||||||
queueVO.setQueueSize(queueVO.getQueueSize() + 1);
|
queueVO.setQueueSize(queueVO.getQueueSize() + 1);
|
||||||
_syncQueueDao.update(queueVO.getId(), queueVO);
|
_syncQueueDao.update(queueVO.getId(), queueVO);
|
||||||
|
|
||||||
itemVO.setLastProcessMsid(msid);
|
itemVO.setLastProcessMsid(msid);
|
||||||
itemVO.setLastProcessNumber(processNumber);
|
itemVO.setLastProcessNumber(processNumber);
|
||||||
itemVO.setLastProcessTime(dt);
|
itemVO.setLastProcessTime(dt);
|
||||||
_syncQueueItemDao.update(item.getId(), itemVO);
|
_syncQueueItemDao.update(item.getId(), itemVO);
|
||||||
|
|
||||||
resultList.add(item);
|
resultList.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txt.commit();
|
txt.commit();
|
||||||
return resultList;
|
return resultList;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
s_logger.error("Unexpected exception: ", e);
|
s_logger.error("Unexpected exception: ", e);
|
||||||
txt.rollback();
|
txt.rollback();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DB
|
@DB
|
||||||
public void purgeItem(long queueItemId) {
|
public void purgeItem(long queueItemId) {
|
||||||
Transaction txt = Transaction.currentTxn();
|
Transaction txt = Transaction.currentTxn();
|
||||||
try {
|
try {
|
||||||
txt.start();
|
txt.start();
|
||||||
|
|
||||||
SyncQueueItemVO itemVO = _syncQueueItemDao.findById(queueItemId);
|
SyncQueueItemVO itemVO = _syncQueueItemDao.findById(queueItemId);
|
||||||
if(itemVO != null) {
|
if(itemVO != null) {
|
||||||
SyncQueueVO queueVO = _syncQueueDao.lockRow(itemVO.getQueueId(), true);
|
SyncQueueVO queueVO = _syncQueueDao.lockRow(itemVO.getQueueId(), true);
|
||||||
|
|
||||||
_syncQueueItemDao.expunge(itemVO.getId());
|
_syncQueueItemDao.expunge(itemVO.getId());
|
||||||
|
|
||||||
//if item is active, reset queue information
|
//if item is active, reset queue information
|
||||||
if (itemVO.getLastProcessMsid() != null) {
|
if (itemVO.getLastProcessMsid() != null) {
|
||||||
queueVO.setLastUpdated(DateUtil.currentGMTTime());
|
queueVO.setLastUpdated(DateUtil.currentGMTTime());
|
||||||
//decrement the count
|
//decrement the count
|
||||||
assert (queueVO.getQueueSize() > 0) : "Count reduce happens when it's already <= 0!";
|
assert (queueVO.getQueueSize() > 0) : "Count reduce happens when it's already <= 0!";
|
||||||
queueVO.setQueueSize(queueVO.getQueueSize() - 1);
|
queueVO.setQueueSize(queueVO.getQueueSize() - 1);
|
||||||
_syncQueueDao.update(queueVO.getId(), queueVO);
|
_syncQueueDao.update(queueVO.getId(), queueVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txt.commit();
|
txt.commit();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
s_logger.error("Unexpected exception: ", e);
|
s_logger.error("Unexpected exception: ", e);
|
||||||
txt.rollback();
|
txt.rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DB
|
@DB
|
||||||
public void returnItem(long queueItemId) {
|
public void returnItem(long queueItemId) {
|
||||||
Transaction txt = Transaction.currentTxn();
|
Transaction txt = Transaction.currentTxn();
|
||||||
try {
|
try {
|
||||||
txt.start();
|
txt.start();
|
||||||
|
|
||||||
SyncQueueItemVO itemVO = _syncQueueItemDao.findById(queueItemId);
|
SyncQueueItemVO itemVO = _syncQueueItemDao.findById(queueItemId);
|
||||||
if(itemVO != null) {
|
if(itemVO != null) {
|
||||||
SyncQueueVO queueVO = _syncQueueDao.lockRow(itemVO.getQueueId(), true);
|
SyncQueueVO queueVO = _syncQueueDao.lockRow(itemVO.getQueueId(), true);
|
||||||
|
|
||||||
itemVO.setLastProcessMsid(null);
|
itemVO.setLastProcessMsid(null);
|
||||||
itemVO.setLastProcessNumber(null);
|
itemVO.setLastProcessNumber(null);
|
||||||
itemVO.setLastProcessTime(null);
|
itemVO.setLastProcessTime(null);
|
||||||
_syncQueueItemDao.update(queueItemId, itemVO);
|
_syncQueueItemDao.update(queueItemId, itemVO);
|
||||||
|
|
||||||
queueVO.setLastUpdated(DateUtil.currentGMTTime());
|
queueVO.setLastUpdated(DateUtil.currentGMTTime());
|
||||||
_syncQueueDao.update(queueVO.getId(), queueVO);
|
_syncQueueDao.update(queueVO.getId(), queueVO);
|
||||||
}
|
}
|
||||||
txt.commit();
|
txt.commit();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
s_logger.error("Unexpected exception: ", e);
|
s_logger.error("Unexpected exception: ", e);
|
||||||
txt.rollback();
|
txt.rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SyncQueueItemVO> getActiveQueueItems(Long msid, boolean exclusive) {
|
public List<SyncQueueItemVO> getActiveQueueItems(Long msid, boolean exclusive) {
|
||||||
return _syncQueueItemDao.getActiveQueueItems(msid, exclusive);
|
return _syncQueueItemDao.getActiveQueueItems(msid, exclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -243,8 +242,8 @@ public class SyncQueueManagerImpl implements SyncQueueManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||||
_name = name;
|
_name = name;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -259,7 +258,7 @@ public class SyncQueueManagerImpl implements SyncQueueManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean queueReadyToProcess(SyncQueueVO queueVO) {
|
private boolean queueReadyToProcess(SyncQueueVO queueVO) {
|
||||||
|
|||||||
@ -35,10 +35,7 @@ import com.cloud.capacity.CapacityVO;
|
|||||||
import com.cloud.storage.Storage;
|
import com.cloud.storage.Storage;
|
||||||
import com.cloud.storage.StoragePoolVO;
|
import com.cloud.storage.StoragePoolVO;
|
||||||
import com.cloud.storage.dao.StoragePoolDao;
|
import com.cloud.storage.dao.StoragePoolDao;
|
||||||
import com.cloud.storage.dao.StoragePoolDaoImpl;
|
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.StringUtils;
|
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.Filter;
|
import com.cloud.utils.db.Filter;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.GenericSearchBuilder;
|
import com.cloud.utils.db.GenericSearchBuilder;
|
||||||
@ -60,116 +57,116 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||||||
|
|
||||||
private static final String LIST_CLUSTERSINZONE_BY_HOST_CAPACITIES_PART1 = "SELECT DISTINCT capacity.cluster_id FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`cluster` cluster on (cluster.id = capacity.cluster_id AND cluster.removed is NULL) WHERE ";
|
private static final String LIST_CLUSTERSINZONE_BY_HOST_CAPACITIES_PART1 = "SELECT DISTINCT capacity.cluster_id FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`cluster` cluster on (cluster.id = capacity.cluster_id AND cluster.removed is NULL) WHERE ";
|
||||||
private static final String LIST_CLUSTERSINZONE_BY_HOST_CAPACITIES_PART2 = " AND capacity_type = ? AND ((total_capacity * ?) - used_capacity + reserved_capacity) >= ? " +
|
private static final String LIST_CLUSTERSINZONE_BY_HOST_CAPACITIES_PART2 = " AND capacity_type = ? AND ((total_capacity * ?) - used_capacity + reserved_capacity) >= ? " +
|
||||||
"AND cluster_id IN (SELECT distinct cluster_id FROM `cloud`.`op_host_capacity` WHERE ";
|
"AND cluster_id IN (SELECT distinct cluster_id FROM `cloud`.`op_host_capacity` WHERE ";
|
||||||
private static final String LIST_CLUSTERSINZONE_BY_HOST_CAPACITIES_PART3 = " AND capacity_type = ? AND ((total_capacity * ?) - used_capacity + reserved_capacity) >= ?) ";
|
private static final String LIST_CLUSTERSINZONE_BY_HOST_CAPACITIES_PART3 = " AND capacity_type = ? AND ((total_capacity * ?) - used_capacity + reserved_capacity) >= ?) ";
|
||||||
|
|
||||||
private final SearchBuilder<CapacityVO> _hostIdTypeSearch;
|
private final SearchBuilder<CapacityVO> _hostIdTypeSearch;
|
||||||
private final SearchBuilder<CapacityVO> _hostOrPoolIdSearch;
|
private final SearchBuilder<CapacityVO> _hostOrPoolIdSearch;
|
||||||
protected GenericSearchBuilder<CapacityVO, SummedCapacity> SummedCapacitySearch;
|
protected GenericSearchBuilder<CapacityVO, SummedCapacity> SummedCapacitySearch;
|
||||||
private SearchBuilder<CapacityVO> _allFieldsSearch;
|
private final SearchBuilder<CapacityVO> _allFieldsSearch;
|
||||||
@Inject protected StoragePoolDao _storagePoolDao;
|
@Inject protected StoragePoolDao _storagePoolDao;
|
||||||
|
|
||||||
|
|
||||||
private static final String LIST_HOSTS_IN_CLUSTER_WITH_ENOUGH_CAPACITY = "SELECT a.host_id FROM (host JOIN op_host_capacity a ON host.id = a.host_id AND host.cluster_id = ? AND host.type = ? " +
|
private static final String LIST_HOSTS_IN_CLUSTER_WITH_ENOUGH_CAPACITY = "SELECT a.host_id FROM (host JOIN op_host_capacity a ON host.id = a.host_id AND host.cluster_id = ? AND host.type = ? " +
|
||||||
"AND (a.total_capacity * ? - a.used_capacity) >= ? and a.capacity_type = 1) " +
|
"AND (a.total_capacity * ? - a.used_capacity) >= ? and a.capacity_type = 1) " +
|
||||||
"JOIN op_host_capacity b ON a.host_id = b.host_id AND b.total_capacity - b.used_capacity >= ? AND b.capacity_type = 0";
|
"JOIN op_host_capacity b ON a.host_id = b.host_id AND b.total_capacity - b.used_capacity >= ? AND b.capacity_type = 0";
|
||||||
|
|
||||||
private static final String ORDER_CLUSTERS_BY_AGGREGATE_CAPACITY_PART1 = "SELECT cluster_id, SUM(used_capacity+reserved_capacity)/SUM(total_capacity * ?) FROM `cloud`.`op_host_capacity` WHERE " ;
|
private static final String ORDER_CLUSTERS_BY_AGGREGATE_CAPACITY_PART1 = "SELECT cluster_id, SUM(used_capacity+reserved_capacity)/SUM(total_capacity * ?) FROM `cloud`.`op_host_capacity` WHERE " ;
|
||||||
private static final String ORDER_CLUSTERS_BY_AGGREGATE_CAPACITY_PART2 = " AND capacity_type = ? GROUP BY cluster_id ORDER BY SUM(used_capacity+reserved_capacity)/SUM(total_capacity * ?) ASC";
|
private static final String ORDER_CLUSTERS_BY_AGGREGATE_CAPACITY_PART2 = " AND capacity_type = ? GROUP BY cluster_id ORDER BY SUM(used_capacity+reserved_capacity)/SUM(total_capacity * ?) ASC";
|
||||||
|
|
||||||
private static final String LIST_PODSINZONE_BY_HOST_CAPACITIES = "SELECT DISTINCT capacity.pod_id FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`host_pod_ref` pod " +
|
private static final String LIST_PODSINZONE_BY_HOST_CAPACITIES = "SELECT DISTINCT capacity.pod_id FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`host_pod_ref` pod " +
|
||||||
" ON (pod.id = capacity.pod_id AND pod.removed is NULL) WHERE " +
|
" ON (pod.id = capacity.pod_id AND pod.removed is NULL) WHERE " +
|
||||||
" capacity.data_center_id = ? AND capacity_type = ? AND ((total_capacity * ?) - used_capacity + reserved_capacity) >= ? " +
|
" capacity.data_center_id = ? AND capacity_type = ? AND ((total_capacity * ?) - used_capacity + reserved_capacity) >= ? " +
|
||||||
" AND pod_id IN (SELECT distinct pod_id FROM `cloud`.`op_host_capacity` WHERE " +
|
" AND pod_id IN (SELECT distinct pod_id FROM `cloud`.`op_host_capacity` WHERE " +
|
||||||
" capacity.data_center_id = ? AND capacity_type = ? AND ((total_capacity * ?) - used_capacity + reserved_capacity) >= ?) ";
|
" capacity.data_center_id = ? AND capacity_type = ? AND ((total_capacity * ?) - used_capacity + reserved_capacity) >= ?) ";
|
||||||
|
|
||||||
private static final String ORDER_PODS_BY_AGGREGATE_CAPACITY = "SELECT pod_id, SUM(used_capacity+reserved_capacity)/SUM(total_capacity * ?) FROM `cloud`.`op_host_capacity` WHERE data_center_id = ? " +
|
private static final String ORDER_PODS_BY_AGGREGATE_CAPACITY = "SELECT pod_id, SUM(used_capacity+reserved_capacity)/SUM(total_capacity * ?) FROM `cloud`.`op_host_capacity` WHERE data_center_id = ? " +
|
||||||
" AND capacity_type = ? GROUP BY pod_id ORDER BY SUM(used_capacity+reserved_capacity)/SUM(total_capacity * ?) ASC";
|
" AND capacity_type = ? GROUP BY pod_id ORDER BY SUM(used_capacity+reserved_capacity)/SUM(total_capacity * ?) ASC";
|
||||||
|
|
||||||
private static final String LIST_CAPACITY_BY_RESOURCE_STATE = "SELECT capacity.data_center_id, sum(capacity.used_capacity), sum(capacity.reserved_quantity), sum(capacity.total_capacity), capacity_capacity_type "+
|
private static final String LIST_CAPACITY_BY_RESOURCE_STATE = "SELECT capacity.data_center_id, sum(capacity.used_capacity), sum(capacity.reserved_quantity), sum(capacity.total_capacity), capacity_capacity_type "+
|
||||||
"FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`data_center` dc ON (dc.id = capacity.data_center_id AND dc.removed is NULL)"+
|
"FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`data_center` dc ON (dc.id = capacity.data_center_id AND dc.removed is NULL)"+
|
||||||
"FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`host_pod_ref` pod ON (pod.id = capacity.pod_id AND pod.removed is NULL)"+
|
"FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`host_pod_ref` pod ON (pod.id = capacity.pod_id AND pod.removed is NULL)"+
|
||||||
"FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`cluster` cluster ON (cluster.id = capacity.cluster_id AND cluster.removed is NULL)"+
|
"FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`cluster` cluster ON (cluster.id = capacity.cluster_id AND cluster.removed is NULL)"+
|
||||||
"FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`host` host ON (host.id = capacity.host_id AND host.removed is NULL)"+
|
"FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`host` host ON (host.id = capacity.host_id AND host.removed is NULL)"+
|
||||||
"WHERE dc.allocation_state = ? AND pod.allocation_state = ? AND cluster.allocation_state = ? AND host.resource_state = ? AND capacity_type not in (3,4) ";
|
"WHERE dc.allocation_state = ? AND pod.allocation_state = ? AND cluster.allocation_state = ? AND host.resource_state = ? AND capacity_type not in (3,4) ";
|
||||||
|
|
||||||
private static final String LIST_CAPACITY_GROUP_BY_ZONE_TYPE_PART1 = "SELECT (sum(capacity.used_capacity) + sum(capacity.reserved_capacity)), (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`configuration` where name like 'cpu.overprovisioning.factor')) else sum(total_capacity) end), " +
|
private static final String LIST_CAPACITY_GROUP_BY_ZONE_TYPE_PART1 = "SELECT (sum(capacity.used_capacity) + sum(capacity.reserved_capacity)), (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`configuration` where name like 'cpu.overprovisioning.factor')) else sum(total_capacity) end), " +
|
||||||
"((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`configuration` where name like 'cpu.overprovisioning.factor')) else sum(total_capacity) end)) percent,"+
|
"((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`configuration` where name like 'cpu.overprovisioning.factor')) else sum(total_capacity) end)) percent,"+
|
||||||
" capacity.capacity_type, capacity.data_center_id "+
|
" capacity.capacity_type, capacity.data_center_id "+
|
||||||
"FROM `cloud`.`op_host_capacity` capacity "+
|
"FROM `cloud`.`op_host_capacity` capacity "+
|
||||||
"WHERE total_capacity > 0 AND data_center_id is not null AND capacity_state='Enabled'";
|
"WHERE total_capacity > 0 AND data_center_id is not null AND capacity_state='Enabled'";
|
||||||
private static final String LIST_CAPACITY_GROUP_BY_ZONE_TYPE_PART2 = " GROUP BY data_center_id, capacity_type order by percent desc limit ";
|
private static final String LIST_CAPACITY_GROUP_BY_ZONE_TYPE_PART2 = " GROUP BY data_center_id, capacity_type order by percent desc limit ";
|
||||||
private static final String LIST_CAPACITY_GROUP_BY_POD_TYPE_PART1 = "SELECT (sum(capacity.used_capacity) + sum(capacity.reserved_capacity)), (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`configuration` where name like 'cpu.overprovisioning.factor')) else sum(total_capacity) end), " +
|
private static final String LIST_CAPACITY_GROUP_BY_POD_TYPE_PART1 = "SELECT (sum(capacity.used_capacity) + sum(capacity.reserved_capacity)), (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`configuration` where name like 'cpu.overprovisioning.factor')) else sum(total_capacity) end), " +
|
||||||
"((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`configuration` where name like 'cpu.overprovisioning.factor')) else sum(total_capacity) end)) percent,"+
|
"((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`configuration` where name like 'cpu.overprovisioning.factor')) else sum(total_capacity) end)) percent,"+
|
||||||
" capacity.capacity_type, capacity.data_center_id, pod_id "+
|
" capacity.capacity_type, capacity.data_center_id, pod_id "+
|
||||||
"FROM `cloud`.`op_host_capacity` capacity "+
|
"FROM `cloud`.`op_host_capacity` capacity "+
|
||||||
"WHERE total_capacity > 0 AND pod_id is not null AND capacity_state='Enabled'";
|
"WHERE total_capacity > 0 AND pod_id is not null AND capacity_state='Enabled'";
|
||||||
private static final String LIST_CAPACITY_GROUP_BY_POD_TYPE_PART2 = " GROUP BY pod_id, capacity_type order by percent desc limit ";
|
private static final String LIST_CAPACITY_GROUP_BY_POD_TYPE_PART2 = " GROUP BY pod_id, capacity_type order by percent desc limit ";
|
||||||
|
|
||||||
private static final String LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART1 = "SELECT (sum(capacity.used_capacity) + sum(capacity.reserved_capacity)), (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`configuration` where name like 'cpu.overprovisioning.factor')) else sum(total_capacity) end), " +
|
private static final String LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART1 = "SELECT (sum(capacity.used_capacity) + sum(capacity.reserved_capacity)), (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`configuration` where name like 'cpu.overprovisioning.factor')) else sum(total_capacity) end), " +
|
||||||
"((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`configuration` where name like 'cpu.overprovisioning.factor')) else sum(total_capacity) end)) percent,"+
|
"((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / (case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`configuration` where name like 'cpu.overprovisioning.factor')) else sum(total_capacity) end)) percent,"+
|
||||||
"capacity.capacity_type, capacity.data_center_id, pod_id, cluster_id "+
|
"capacity.capacity_type, capacity.data_center_id, pod_id, cluster_id "+
|
||||||
"FROM `cloud`.`op_host_capacity` capacity "+
|
"FROM `cloud`.`op_host_capacity` capacity "+
|
||||||
"WHERE total_capacity > 0 AND cluster_id is not null AND capacity_state='Enabled'";
|
"WHERE total_capacity > 0 AND cluster_id is not null AND capacity_state='Enabled'";
|
||||||
private static final String LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART2 = " GROUP BY cluster_id, capacity_type order by percent desc limit ";
|
private static final String LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART2 = " GROUP BY cluster_id, capacity_type order by percent desc limit ";
|
||||||
private static final String UPDATE_CAPACITY_STATE = "UPDATE `cloud`.`op_host_capacity` SET capacity_state = ? WHERE ";
|
private static final String UPDATE_CAPACITY_STATE = "UPDATE `cloud`.`op_host_capacity` SET capacity_state = ? WHERE ";
|
||||||
private static final String LIST_CLUSTERS_CROSSING_THRESHOLD = "SELECT cluster_id " +
|
private static final String LIST_CLUSTERS_CROSSING_THRESHOLD = "SELECT cluster_id " +
|
||||||
"FROM (SELECT cluster_id, ( (sum(capacity.used_capacity) + sum(capacity.reserved_capacity) + ?)/sum(total_capacity) ) ratio "+
|
"FROM (SELECT cluster_id, ( (sum(capacity.used_capacity) + sum(capacity.reserved_capacity) + ?)/sum(total_capacity) ) ratio "+
|
||||||
"FROM `cloud`.`op_host_capacity` capacity "+
|
"FROM `cloud`.`op_host_capacity` capacity "+
|
||||||
"WHERE capacity.data_center_id = ? AND capacity.capacity_type = ? AND capacity.total_capacity > 0 "+
|
"WHERE capacity.data_center_id = ? AND capacity.capacity_type = ? AND capacity.total_capacity > 0 "+
|
||||||
"GROUP BY cluster_id) tmp " +
|
"GROUP BY cluster_id) tmp " +
|
||||||
"WHERE tmp.ratio > ? ";
|
"WHERE tmp.ratio > ? ";
|
||||||
|
|
||||||
|
|
||||||
public CapacityDaoImpl() {
|
public CapacityDaoImpl() {
|
||||||
_hostIdTypeSearch = createSearchBuilder();
|
_hostIdTypeSearch = createSearchBuilder();
|
||||||
_hostIdTypeSearch.and("hostId", _hostIdTypeSearch.entity().getHostOrPoolId(), SearchCriteria.Op.EQ);
|
_hostIdTypeSearch.and("hostId", _hostIdTypeSearch.entity().getHostOrPoolId(), SearchCriteria.Op.EQ);
|
||||||
_hostIdTypeSearch.and("type", _hostIdTypeSearch.entity().getCapacityType(), SearchCriteria.Op.EQ);
|
_hostIdTypeSearch.and("type", _hostIdTypeSearch.entity().getCapacityType(), SearchCriteria.Op.EQ);
|
||||||
_hostIdTypeSearch.done();
|
_hostIdTypeSearch.done();
|
||||||
|
|
||||||
_hostOrPoolIdSearch = createSearchBuilder();
|
_hostOrPoolIdSearch = createSearchBuilder();
|
||||||
_hostOrPoolIdSearch.and("hostId", _hostOrPoolIdSearch.entity().getHostOrPoolId(), SearchCriteria.Op.EQ);
|
_hostOrPoolIdSearch.and("hostId", _hostOrPoolIdSearch.entity().getHostOrPoolId(), SearchCriteria.Op.EQ);
|
||||||
_hostOrPoolIdSearch.done();
|
_hostOrPoolIdSearch.done();
|
||||||
|
|
||||||
_allFieldsSearch = createSearchBuilder();
|
_allFieldsSearch = createSearchBuilder();
|
||||||
_allFieldsSearch.and("id", _allFieldsSearch.entity().getId(), SearchCriteria.Op.EQ);
|
_allFieldsSearch.and("id", _allFieldsSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||||
_allFieldsSearch.and("hostId", _allFieldsSearch.entity().getHostOrPoolId(), SearchCriteria.Op.EQ);
|
_allFieldsSearch.and("hostId", _allFieldsSearch.entity().getHostOrPoolId(), SearchCriteria.Op.EQ);
|
||||||
_allFieldsSearch.and("zoneId", _allFieldsSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
_allFieldsSearch.and("zoneId", _allFieldsSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||||
_allFieldsSearch.and("podId", _allFieldsSearch.entity().getPodId(), SearchCriteria.Op.EQ);
|
_allFieldsSearch.and("podId", _allFieldsSearch.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||||
_allFieldsSearch.and("clusterId", _allFieldsSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
|
_allFieldsSearch.and("clusterId", _allFieldsSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
|
||||||
_allFieldsSearch.and("capacityType", _allFieldsSearch.entity().getCapacityType(), SearchCriteria.Op.EQ);
|
_allFieldsSearch.and("capacityType", _allFieldsSearch.entity().getCapacityType(), SearchCriteria.Op.EQ);
|
||||||
_allFieldsSearch.and("capacityState", _allFieldsSearch.entity().getCapacityState(), SearchCriteria.Op.EQ);
|
_allFieldsSearch.and("capacityState", _allFieldsSearch.entity().getCapacityState(), SearchCriteria.Op.EQ);
|
||||||
|
|
||||||
_allFieldsSearch.done();
|
_allFieldsSearch.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Long> listClustersCrossingThreshold(short capacityType, Long zoneId, Float disableThreshold, long compute_requested, Float overProvFactor){
|
public List<Long> listClustersCrossingThreshold(short capacityType, Long zoneId, Float disableThreshold, long compute_requested, Float overProvFactor){
|
||||||
|
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
List<Long> result = new ArrayList<Long>();
|
List<Long> result = new ArrayList<Long>();
|
||||||
StringBuilder sql = new StringBuilder(LIST_CLUSTERS_CROSSING_THRESHOLD);
|
StringBuilder sql = new StringBuilder(LIST_CLUSTERS_CROSSING_THRESHOLD);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||||
pstmt.setLong(1, compute_requested);
|
pstmt.setLong(1, compute_requested);
|
||||||
pstmt.setLong(2, zoneId);
|
pstmt.setLong(2, zoneId);
|
||||||
pstmt.setShort(3, capacityType);
|
pstmt.setShort(3, capacityType);
|
||||||
pstmt.setFloat(4, disableThreshold*overProvFactor);
|
pstmt.setFloat(4, disableThreshold*overProvFactor);
|
||||||
|
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
result.add(rs.getLong(1));
|
result.add(rs.getLong(1));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new CloudRuntimeException("DB Exception on: " + sql, e);
|
throw new CloudRuntimeException("DB Exception on: " + sql, e);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new CloudRuntimeException("Caught: " + sql, e);
|
throw new CloudRuntimeException("Caught: " + sql, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static String preparePlaceHolders(int length) {
|
/*public static String preparePlaceHolders(int length) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
@ -247,17 +244,17 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||||||
List<SummedCapacity> result = new ArrayList<SummedCapacity>();
|
List<SummedCapacity> result = new ArrayList<SummedCapacity>();
|
||||||
|
|
||||||
switch(level){
|
switch(level){
|
||||||
case 1: // List all the capacities grouped by zone, capacity Type
|
case 1: // List all the capacities grouped by zone, capacity Type
|
||||||
finalQuery.append(LIST_CAPACITY_GROUP_BY_ZONE_TYPE_PART1);
|
finalQuery.append(LIST_CAPACITY_GROUP_BY_ZONE_TYPE_PART1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: // List all the capacities grouped by pod, capacity Type
|
case 2: // List all the capacities grouped by pod, capacity Type
|
||||||
finalQuery.append(LIST_CAPACITY_GROUP_BY_POD_TYPE_PART1);
|
finalQuery.append(LIST_CAPACITY_GROUP_BY_POD_TYPE_PART1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: // List all the capacities grouped by cluster, capacity Type
|
case 3: // List all the capacities grouped by cluster, capacity Type
|
||||||
finalQuery.append(LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART1);
|
finalQuery.append(LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoneId != null){
|
if (zoneId != null){
|
||||||
@ -294,9 +291,9 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
SummedCapacity summedCapacity = new SummedCapacity( rs.getLong(1), rs.getLong(2), rs.getFloat(3),
|
SummedCapacity summedCapacity = new SummedCapacity( rs.getLong(1), rs.getLong(2), rs.getFloat(3),
|
||||||
(short)rs.getLong(4), rs.getLong(5),
|
(short)rs.getLong(4), rs.getLong(5),
|
||||||
level != 1 ? rs.getLong(6): null,
|
level != 1 ? rs.getLong(6): null,
|
||||||
level == 3 ? rs.getLong(7): null);
|
level == 3 ? rs.getLong(7): null);
|
||||||
|
|
||||||
result.add(summedCapacity);
|
result.add(summedCapacity);
|
||||||
}
|
}
|
||||||
@ -312,8 +309,8 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||||||
@Override
|
@Override
|
||||||
public List<SummedCapacity> findCapacityBy(Integer capacityType, Long zoneId, Long podId, Long clusterId){
|
public List<SummedCapacity> findCapacityBy(Integer capacityType, Long zoneId, Long podId, Long clusterId){
|
||||||
|
|
||||||
SummedCapacitySearch = createSearchBuilder(SummedCapacity.class);
|
SummedCapacitySearch = createSearchBuilder(SummedCapacity.class);
|
||||||
SummedCapacitySearch.select("dcId", Func.NATIVE, SummedCapacitySearch.entity().getDataCenterId());
|
SummedCapacitySearch.select("dcId", Func.NATIVE, SummedCapacitySearch.entity().getDataCenterId());
|
||||||
SummedCapacitySearch.select("sumUsed", Func.SUM, SummedCapacitySearch.entity().getUsedCapacity());
|
SummedCapacitySearch.select("sumUsed", Func.SUM, SummedCapacitySearch.entity().getUsedCapacity());
|
||||||
SummedCapacitySearch.select("sumReserved", Func.SUM, SummedCapacitySearch.entity().getReservedCapacity());
|
SummedCapacitySearch.select("sumReserved", Func.SUM, SummedCapacitySearch.entity().getReservedCapacity());
|
||||||
SummedCapacitySearch.select("sumTotal", Func.SUM, SummedCapacitySearch.entity().getTotalCapacity());
|
SummedCapacitySearch.select("sumTotal", Func.SUM, SummedCapacitySearch.entity().getTotalCapacity());
|
||||||
@ -326,16 +323,16 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (zoneId != null){
|
if (zoneId != null){
|
||||||
SummedCapacitySearch.and("dcId", SummedCapacitySearch.entity().getDataCenterId(), Op.EQ);
|
SummedCapacitySearch.and("dcId", SummedCapacitySearch.entity().getDataCenterId(), Op.EQ);
|
||||||
}
|
}
|
||||||
if (podId != null){
|
if (podId != null){
|
||||||
SummedCapacitySearch.and("podId", SummedCapacitySearch.entity().getPodId(), Op.EQ);
|
SummedCapacitySearch.and("podId", SummedCapacitySearch.entity().getPodId(), Op.EQ);
|
||||||
}
|
}
|
||||||
if (clusterId != null){
|
if (clusterId != null){
|
||||||
SummedCapacitySearch.and("clusterId", SummedCapacitySearch.entity().getClusterId(), Op.EQ);
|
SummedCapacitySearch.and("clusterId", SummedCapacitySearch.entity().getClusterId(), Op.EQ);
|
||||||
}
|
}
|
||||||
if (capacityType != null){
|
if (capacityType != null){
|
||||||
SummedCapacitySearch.and("capacityType", SummedCapacitySearch.entity().getCapacityType(), Op.EQ);
|
SummedCapacitySearch.and("capacityType", SummedCapacitySearch.entity().getCapacityType(), Op.EQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
SummedCapacitySearch.done();
|
SummedCapacitySearch.done();
|
||||||
@ -343,16 +340,16 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||||||
|
|
||||||
SearchCriteria<SummedCapacity> sc = SummedCapacitySearch.create();
|
SearchCriteria<SummedCapacity> sc = SummedCapacitySearch.create();
|
||||||
if (zoneId != null){
|
if (zoneId != null){
|
||||||
sc.setParameters("dcId", zoneId);
|
sc.setParameters("dcId", zoneId);
|
||||||
}
|
}
|
||||||
if (podId != null){
|
if (podId != null){
|
||||||
sc.setParameters("podId", podId);
|
sc.setParameters("podId", podId);
|
||||||
}
|
}
|
||||||
if (clusterId != null){
|
if (clusterId != null){
|
||||||
sc.setParameters("clusterId", clusterId);
|
sc.setParameters("clusterId", clusterId);
|
||||||
}
|
}
|
||||||
if (capacityType != null){
|
if (capacityType != null){
|
||||||
sc.setParameters("capacityType", capacityType);
|
sc.setParameters("capacityType", capacityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
Filter filter = new Filter(CapacityVO.class, null, true, null, null);
|
Filter filter = new Filter(CapacityVO.class, null, true, null, null);
|
||||||
@ -387,45 +384,45 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CapacityVO findByHostIdType(Long hostId, short capacityType) {
|
public CapacityVO findByHostIdType(Long hostId, short capacityType) {
|
||||||
SearchCriteria<CapacityVO> sc = _hostIdTypeSearch.create();
|
SearchCriteria<CapacityVO> sc = _hostIdTypeSearch.create();
|
||||||
sc.setParameters("hostId", hostId);
|
sc.setParameters("hostId", hostId);
|
||||||
sc.setParameters("type", capacityType);
|
sc.setParameters("type", capacityType);
|
||||||
return findOneBy(sc);
|
return findOneBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Long> listClustersInZoneOrPodByHostCapacities(long id, int requiredCpu, long requiredRam, short capacityTypeForOrdering, boolean isZone, float cpuOverprovisioningFactor){
|
public List<Long> listClustersInZoneOrPodByHostCapacities(long id, int requiredCpu, long requiredRam, short capacityTypeForOrdering, boolean isZone, float cpuOverprovisioningFactor){
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
List<Long> result = new ArrayList<Long>();
|
List<Long> result = new ArrayList<Long>();
|
||||||
|
|
||||||
StringBuilder sql = new StringBuilder(LIST_CLUSTERSINZONE_BY_HOST_CAPACITIES_PART1);
|
StringBuilder sql = new StringBuilder(LIST_CLUSTERSINZONE_BY_HOST_CAPACITIES_PART1);
|
||||||
|
|
||||||
if(isZone){
|
if(isZone){
|
||||||
sql.append("capacity.data_center_id = ?");
|
sql.append("capacity.data_center_id = ?");
|
||||||
}else{
|
}else{
|
||||||
sql.append("capacity.pod_id = ?");
|
sql.append("capacity.pod_id = ?");
|
||||||
}
|
}
|
||||||
sql.append(LIST_CLUSTERSINZONE_BY_HOST_CAPACITIES_PART2);
|
sql.append(LIST_CLUSTERSINZONE_BY_HOST_CAPACITIES_PART2);
|
||||||
if(isZone){
|
if(isZone){
|
||||||
sql.append("capacity.data_center_id = ?");
|
sql.append("capacity.data_center_id = ?");
|
||||||
}else{
|
}else{
|
||||||
sql.append("capacity.pod_id = ?");
|
sql.append("capacity.pod_id = ?");
|
||||||
}
|
}
|
||||||
sql.append(LIST_CLUSTERSINZONE_BY_HOST_CAPACITIES_PART3);
|
sql.append(LIST_CLUSTERSINZONE_BY_HOST_CAPACITIES_PART3);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||||
pstmt.setLong(1, id);
|
pstmt.setLong(1, id);
|
||||||
pstmt.setShort(2, CapacityVO.CAPACITY_TYPE_CPU);
|
pstmt.setShort(2, CapacityVO.CAPACITY_TYPE_CPU);
|
||||||
pstmt.setFloat(3, cpuOverprovisioningFactor);
|
pstmt.setFloat(3, cpuOverprovisioningFactor);
|
||||||
pstmt.setLong(4, requiredCpu);
|
pstmt.setLong(4, requiredCpu);
|
||||||
pstmt.setLong(5, id);
|
pstmt.setLong(5, id);
|
||||||
pstmt.setShort(6, CapacityVO.CAPACITY_TYPE_MEMORY);
|
pstmt.setShort(6, CapacityVO.CAPACITY_TYPE_MEMORY);
|
||||||
pstmt.setFloat(7, 1);
|
pstmt.setFloat(7, 1);
|
||||||
pstmt.setLong(8, requiredRam);
|
pstmt.setLong(8, requiredRam);
|
||||||
|
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
result.add(rs.getLong(1));
|
result.add(rs.getLong(1));
|
||||||
}
|
}
|
||||||
@ -440,7 +437,7 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Long> listHostsWithEnoughCapacity(int requiredCpu, long requiredRam, Long clusterId, String hostType, float cpuOverprovisioningFactor){
|
public List<Long> listHostsWithEnoughCapacity(int requiredCpu, long requiredRam, Long clusterId, String hostType, float cpuOverprovisioningFactor){
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
List<Long> result = new ArrayList<Long>();
|
List<Long> result = new ArrayList<Long>();
|
||||||
|
|
||||||
@ -448,10 +445,10 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||||||
try {
|
try {
|
||||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||||
pstmt.setLong(1, clusterId);
|
pstmt.setLong(1, clusterId);
|
||||||
pstmt.setString(2, hostType);
|
pstmt.setString(2, hostType);
|
||||||
pstmt.setFloat(3, cpuOverprovisioningFactor);
|
pstmt.setFloat(3, cpuOverprovisioningFactor);
|
||||||
pstmt.setLong(4, requiredCpu);
|
pstmt.setLong(4, requiredCpu);
|
||||||
pstmt.setLong(5, requiredRam);
|
pstmt.setLong(5, requiredRam);
|
||||||
|
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@ -465,60 +462,60 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SummedCapacity {
|
public static class SummedCapacity {
|
||||||
public long sumUsed;
|
public long sumUsed;
|
||||||
public long sumReserved;
|
public long sumReserved;
|
||||||
public long sumTotal;
|
public long sumTotal;
|
||||||
public Float percentUsed;
|
public Float percentUsed;
|
||||||
public short capacityType;
|
public short capacityType;
|
||||||
public Long clusterId;
|
public Long clusterId;
|
||||||
public Long podId;
|
public Long podId;
|
||||||
public Long dcId;
|
public Long dcId;
|
||||||
public SummedCapacity() {
|
public SummedCapacity() {
|
||||||
}
|
}
|
||||||
public SummedCapacity(long sumUsed, long sumReserved, long sumTotal,
|
public SummedCapacity(long sumUsed, long sumReserved, long sumTotal,
|
||||||
short capacityType, Long clusterId, Long podId) {
|
short capacityType, Long clusterId, Long podId) {
|
||||||
super();
|
super();
|
||||||
this.sumUsed = sumUsed;
|
this.sumUsed = sumUsed;
|
||||||
this.sumReserved = sumReserved;
|
this.sumReserved = sumReserved;
|
||||||
this.sumTotal = sumTotal;
|
this.sumTotal = sumTotal;
|
||||||
this.capacityType = capacityType;
|
this.capacityType = capacityType;
|
||||||
this.clusterId = clusterId;
|
this.clusterId = clusterId;
|
||||||
this.podId = podId;
|
this.podId = podId;
|
||||||
}
|
}
|
||||||
public SummedCapacity(long sumUsed, long sumReserved, long sumTotal,
|
public SummedCapacity(long sumUsed, long sumReserved, long sumTotal,
|
||||||
short capacityType, Long clusterId, Long podId, Long zoneId) {
|
short capacityType, Long clusterId, Long podId, Long zoneId) {
|
||||||
this(sumUsed, sumReserved, sumTotal, capacityType, clusterId, podId);
|
this(sumUsed, sumReserved, sumTotal, capacityType, clusterId, podId);
|
||||||
this.dcId = zoneId;
|
this.dcId = zoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SummedCapacity(long sumUsed, long sumTotal, float percentUsed, short capacityType, Long zoneId, Long podId, Long clusterId) {
|
public SummedCapacity(long sumUsed, long sumTotal, float percentUsed, short capacityType, Long zoneId, Long podId, Long clusterId) {
|
||||||
super();
|
super();
|
||||||
this.sumUsed = sumUsed;
|
this.sumUsed = sumUsed;
|
||||||
this.sumTotal = sumTotal;
|
this.sumTotal = sumTotal;
|
||||||
this.percentUsed = percentUsed;
|
this.percentUsed = percentUsed;
|
||||||
this.capacityType = capacityType;
|
this.capacityType = capacityType;
|
||||||
this.clusterId = clusterId;
|
this.clusterId = clusterId;
|
||||||
this.podId = podId;
|
this.podId = podId;
|
||||||
this.dcId = zoneId;
|
this.dcId = zoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Short getCapacityType() {
|
public Short getCapacityType() {
|
||||||
return capacityType;
|
return capacityType;
|
||||||
}
|
}
|
||||||
public Long getUsedCapacity() {
|
public Long getUsedCapacity() {
|
||||||
return sumUsed;
|
return sumUsed;
|
||||||
}
|
}
|
||||||
public long getReservedCapacity() {
|
public long getReservedCapacity() {
|
||||||
return sumReserved;
|
return sumReserved;
|
||||||
}
|
}
|
||||||
public Long getTotalCapacity() {
|
public Long getTotalCapacity() {
|
||||||
return sumTotal;
|
return sumTotal;
|
||||||
}
|
}
|
||||||
public Long getDataCenterId() {
|
public Long getDataCenterId() {
|
||||||
return dcId;
|
return dcId;
|
||||||
}
|
}
|
||||||
public Long getClusterId() {
|
public Long getClusterId() {
|
||||||
return clusterId;
|
return clusterId;
|
||||||
}
|
}
|
||||||
public Long getPodId() {
|
public Long getPodId() {
|
||||||
@ -527,63 +524,64 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||||||
public Float getPercentUsed() {
|
public Float getPercentUsed() {
|
||||||
return percentUsed;
|
return percentUsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public List<SummedCapacity> findByClusterPodZone(Long zoneId, Long podId, Long clusterId){
|
@Override
|
||||||
|
public List<SummedCapacity> findByClusterPodZone(Long zoneId, Long podId, Long clusterId){
|
||||||
|
|
||||||
SummedCapacitySearch = createSearchBuilder(SummedCapacity.class);
|
SummedCapacitySearch = createSearchBuilder(SummedCapacity.class);
|
||||||
SummedCapacitySearch.select("sumUsed", Func.SUM, SummedCapacitySearch.entity().getUsedCapacity());
|
SummedCapacitySearch.select("sumUsed", Func.SUM, SummedCapacitySearch.entity().getUsedCapacity());
|
||||||
SummedCapacitySearch.select("sumTotal", Func.SUM, SummedCapacitySearch.entity().getTotalCapacity());
|
SummedCapacitySearch.select("sumTotal", Func.SUM, SummedCapacitySearch.entity().getTotalCapacity());
|
||||||
SummedCapacitySearch.select("capacityType", Func.NATIVE, SummedCapacitySearch.entity().getCapacityType());
|
SummedCapacitySearch.select("capacityType", Func.NATIVE, SummedCapacitySearch.entity().getCapacityType());
|
||||||
SummedCapacitySearch.groupBy(SummedCapacitySearch.entity().getCapacityType());
|
SummedCapacitySearch.groupBy(SummedCapacitySearch.entity().getCapacityType());
|
||||||
|
|
||||||
if(zoneId != null){
|
if(zoneId != null){
|
||||||
SummedCapacitySearch.and("zoneId", SummedCapacitySearch.entity().getDataCenterId(), Op.EQ);
|
SummedCapacitySearch.and("zoneId", SummedCapacitySearch.entity().getDataCenterId(), Op.EQ);
|
||||||
}
|
}
|
||||||
if (podId != null){
|
if (podId != null){
|
||||||
SummedCapacitySearch.and("podId", SummedCapacitySearch.entity().getPodId(), Op.EQ);
|
SummedCapacitySearch.and("podId", SummedCapacitySearch.entity().getPodId(), Op.EQ);
|
||||||
}
|
}
|
||||||
if (clusterId != null){
|
if (clusterId != null){
|
||||||
SummedCapacitySearch.and("clusterId", SummedCapacitySearch.entity().getClusterId(), Op.EQ);
|
SummedCapacitySearch.and("clusterId", SummedCapacitySearch.entity().getClusterId(), Op.EQ);
|
||||||
}
|
}
|
||||||
SummedCapacitySearch.done();
|
SummedCapacitySearch.done();
|
||||||
|
|
||||||
|
|
||||||
SearchCriteria<SummedCapacity> sc = SummedCapacitySearch.create();
|
SearchCriteria<SummedCapacity> sc = SummedCapacitySearch.create();
|
||||||
if (zoneId != null){
|
if (zoneId != null){
|
||||||
sc.setParameters("zoneId", zoneId);
|
sc.setParameters("zoneId", zoneId);
|
||||||
}
|
}
|
||||||
if (podId != null){
|
if (podId != null){
|
||||||
sc.setParameters("podId", podId);
|
sc.setParameters("podId", podId);
|
||||||
}
|
}
|
||||||
if (clusterId != null){
|
if (clusterId != null){
|
||||||
sc.setParameters("clusterId", clusterId);
|
sc.setParameters("clusterId", clusterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return customSearchIncludingRemoved(sc, null);
|
return customSearchIncludingRemoved(sc, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SummedCapacity> findNonSharedStorageForClusterPodZone(Long zoneId, Long podId, Long clusterId){
|
public List<SummedCapacity> findNonSharedStorageForClusterPodZone(Long zoneId, Long podId, Long clusterId){
|
||||||
|
|
||||||
SummedCapacitySearch = createSearchBuilder(SummedCapacity.class);
|
SummedCapacitySearch = createSearchBuilder(SummedCapacity.class);
|
||||||
SummedCapacitySearch.select("sumUsed", Func.SUM, SummedCapacitySearch.entity().getUsedCapacity());
|
SummedCapacitySearch.select("sumUsed", Func.SUM, SummedCapacitySearch.entity().getUsedCapacity());
|
||||||
SummedCapacitySearch.select("sumTotal", Func.SUM, SummedCapacitySearch.entity().getTotalCapacity());
|
SummedCapacitySearch.select("sumTotal", Func.SUM, SummedCapacitySearch.entity().getTotalCapacity());
|
||||||
SummedCapacitySearch.select("capacityType", Func.NATIVE, SummedCapacitySearch.entity().getCapacityType());
|
SummedCapacitySearch.select("capacityType", Func.NATIVE, SummedCapacitySearch.entity().getCapacityType());
|
||||||
SummedCapacitySearch.and("capacityType", SummedCapacitySearch.entity().getCapacityType(), Op.EQ);
|
SummedCapacitySearch.and("capacityType", SummedCapacitySearch.entity().getCapacityType(), Op.EQ);
|
||||||
|
|
||||||
SearchBuilder<StoragePoolVO> nonSharedStorage = _storagePoolDao.createSearchBuilder();
|
SearchBuilder<StoragePoolVO> nonSharedStorage = _storagePoolDao.createSearchBuilder();
|
||||||
nonSharedStorage.and("poolTypes", nonSharedStorage.entity().getPoolType(), SearchCriteria.Op.IN);
|
nonSharedStorage.and("poolTypes", nonSharedStorage.entity().getPoolType(), SearchCriteria.Op.IN);
|
||||||
SummedCapacitySearch.join("nonSharedStorage", nonSharedStorage, nonSharedStorage.entity().getId(), SummedCapacitySearch.entity().getHostOrPoolId(), JoinType.INNER);
|
SummedCapacitySearch.join("nonSharedStorage", nonSharedStorage, nonSharedStorage.entity().getId(), SummedCapacitySearch.entity().getHostOrPoolId(), JoinType.INNER);
|
||||||
nonSharedStorage.done();
|
nonSharedStorage.done();
|
||||||
|
|
||||||
if(zoneId != null){
|
if(zoneId != null){
|
||||||
SummedCapacitySearch.and("zoneId", SummedCapacitySearch.entity().getDataCenterId(), Op.EQ);
|
SummedCapacitySearch.and("zoneId", SummedCapacitySearch.entity().getDataCenterId(), Op.EQ);
|
||||||
}
|
}
|
||||||
if (podId != null){
|
if (podId != null){
|
||||||
SummedCapacitySearch.and("podId", SummedCapacitySearch.entity().getPodId(), Op.EQ);
|
SummedCapacitySearch.and("podId", SummedCapacitySearch.entity().getPodId(), Op.EQ);
|
||||||
}
|
}
|
||||||
if (clusterId != null){
|
if (clusterId != null){
|
||||||
SummedCapacitySearch.and("clusterId", SummedCapacitySearch.entity().getClusterId(), Op.EQ);
|
SummedCapacitySearch.and("clusterId", SummedCapacitySearch.entity().getClusterId(), Op.EQ);
|
||||||
}
|
}
|
||||||
SummedCapacitySearch.done();
|
SummedCapacitySearch.done();
|
||||||
|
|
||||||
@ -592,17 +590,17 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||||||
sc.setJoinParameters("nonSharedStorage", "poolTypes", Storage.getNonSharedStoragePoolTypes().toArray());
|
sc.setJoinParameters("nonSharedStorage", "poolTypes", Storage.getNonSharedStoragePoolTypes().toArray());
|
||||||
sc.setParameters("capacityType", Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED);
|
sc.setParameters("capacityType", Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED);
|
||||||
if (zoneId != null){
|
if (zoneId != null){
|
||||||
sc.setParameters("zoneId", zoneId);
|
sc.setParameters("zoneId", zoneId);
|
||||||
}
|
}
|
||||||
if (podId != null){
|
if (podId != null){
|
||||||
sc.setParameters("podId", podId);
|
sc.setParameters("podId", podId);
|
||||||
}
|
}
|
||||||
if (clusterId != null){
|
if (clusterId != null){
|
||||||
sc.setParameters("clusterId", clusterId);
|
sc.setParameters("clusterId", clusterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return customSearchIncludingRemoved(sc, null);
|
return customSearchIncludingRemoved(sc, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeBy(Short capacityType, Long zoneId, Long podId, Long clusterId, Long hostId) {
|
public boolean removeBy(Short capacityType, Long zoneId, Long podId, Long clusterId, Long hostId) {
|
||||||
|
|||||||
@ -1,52 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package com.cloud.cluster;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TaskManager helps business logic deal with clustering failover.
|
|
||||||
* Say you're writing code that introduces an inconsistent state over
|
|
||||||
* of your operation? Who will come back to cleanup this state? TaskManager
|
|
||||||
* with different content during your process. If the server dies, TaskManager
|
|
||||||
* running elsewhere. If there are no clustered servers, then TaskManager will
|
|
||||||
* cleanup when the dead server resumes.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface CheckPointManager {
|
|
||||||
/**
|
|
||||||
* responsible for cleaning up.
|
|
||||||
*
|
|
||||||
* @param context context information to be stored.
|
|
||||||
* @return Check point id.
|
|
||||||
*/
|
|
||||||
long pushCheckPoint(CleanupMaid context);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* update the task with new context
|
|
||||||
* @param taskId
|
|
||||||
* @param updatedContext new updated context.
|
|
||||||
*/
|
|
||||||
void updateCheckPointState(long taskId, CleanupMaid updatedContext);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* removes the task as it is completed.
|
|
||||||
*
|
|
||||||
* @param taskId
|
|
||||||
*/
|
|
||||||
void popCheckPoint(long taskId);
|
|
||||||
}
|
|
||||||
@ -1,247 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package com.cloud.cluster;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import javax.ejb.Local;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.cloud.cluster.dao.StackMaidDao;
|
|
||||||
import com.cloud.configuration.Config;
|
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
|
||||||
import com.cloud.serializer.SerializerHelper;
|
|
||||||
import com.cloud.utils.DateUtil;
|
|
||||||
import com.cloud.utils.NumbersUtil;
|
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.component.Manager;
|
|
||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
|
||||||
import com.cloud.utils.db.DB;
|
|
||||||
import com.cloud.utils.db.GlobalLock;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Local(value=CheckPointManager.class)
|
|
||||||
public class CheckPointManagerImpl implements CheckPointManager, Manager, ClusterManagerListener {
|
|
||||||
private static final Logger s_logger = Logger.getLogger(CheckPointManagerImpl.class);
|
|
||||||
|
|
||||||
private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 3; // 3 seconds
|
|
||||||
private int _cleanupRetryInterval;
|
|
||||||
|
|
||||||
private String _name;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private StackMaidDao _maidDao;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ClusterManager _clusterMgr;
|
|
||||||
|
|
||||||
@Inject ConfigurationDao _configDao;
|
|
||||||
|
|
||||||
long _msId;
|
|
||||||
|
|
||||||
private final ScheduledExecutorService _cleanupScheduler = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Task-Cleanup"));
|
|
||||||
|
|
||||||
protected CheckPointManagerImpl() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean configure(String name, Map<String, Object> xmlParams) throws ConfigurationException {
|
|
||||||
_name = name;
|
|
||||||
|
|
||||||
if (s_logger.isInfoEnabled()) {
|
|
||||||
s_logger.info("Start configuring StackMaidManager : " + name);
|
|
||||||
}
|
|
||||||
|
|
||||||
StackMaid.init(ManagementServerNode.getManagementServerId());
|
|
||||||
_msId = ManagementServerNode.getManagementServerId();
|
|
||||||
|
|
||||||
_clusterMgr.registerListener(this);
|
|
||||||
|
|
||||||
Map<String, String> params = _configDao.getConfiguration(xmlParams);
|
|
||||||
|
|
||||||
_cleanupRetryInterval = NumbersUtil.parseInt(params.get(Config.TaskCleanupRetryInterval.key()), 600);
|
|
||||||
_maidDao.takeover(_msId, _msId);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cleanupLeftovers(List<CheckPointVO> l) {
|
|
||||||
for (CheckPointVO maid : l) {
|
|
||||||
if (StackMaid.doCleanup(maid)) {
|
|
||||||
_maidDao.expunge(maid.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onManagementNodeIsolated() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@DB
|
|
||||||
private Runnable getGCTask() {
|
|
||||||
return new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
GlobalLock scanLock = GlobalLock.getInternLock("StackMaidManagerGC");
|
|
||||||
try {
|
|
||||||
if (scanLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION)) {
|
|
||||||
try {
|
|
||||||
reallyRun();
|
|
||||||
} finally {
|
|
||||||
scanLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
scanLock.releaseRef();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reallyRun() {
|
|
||||||
try {
|
|
||||||
Date cutTime = new Date(DateUtil.currentGMTTime().getTime() - 7200000);
|
|
||||||
List<CheckPointVO> l = _maidDao.listLeftoversByCutTime(cutTime);
|
|
||||||
cleanupLeftovers(l);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
s_logger.error("Unexpected exception when trying to execute queue item, ", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean start() {
|
|
||||||
_cleanupScheduler.schedule(new CleanupTask(), _cleanupRetryInterval > 0 ? _cleanupRetryInterval : 600, TimeUnit.SECONDS);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean stop() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return _name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onManagementNodeJoined(List<ManagementServerHostVO> nodeList, long selfNodeId) {
|
|
||||||
// Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onManagementNodeLeft(List<ManagementServerHostVO> nodeList, long selfNodeId) {
|
|
||||||
for (ManagementServerHostVO node : nodeList) {
|
|
||||||
if (_maidDao.takeover(node.getMsid(), selfNodeId)) {
|
|
||||||
s_logger.info("Taking over from " + node.getMsid());
|
|
||||||
_cleanupScheduler.execute(new CleanupTask());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@DB
|
|
||||||
public long pushCheckPoint(CleanupMaid context) {
|
|
||||||
long seq = _maidDao.pushCleanupDelegate(_msId, 0, context.getClass().getName(), context);
|
|
||||||
return seq;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@DB
|
|
||||||
public void updateCheckPointState(long taskId, CleanupMaid updatedContext) {
|
|
||||||
CheckPointVO task = _maidDao.createForUpdate();
|
|
||||||
task.setDelegate(updatedContext.getClass().getName());
|
|
||||||
task.setContext(SerializerHelper.toSerializedStringOld(updatedContext));
|
|
||||||
_maidDao.update(taskId, task);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@DB
|
|
||||||
public void popCheckPoint(long taskId) {
|
|
||||||
_maidDao.remove(taskId);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean cleanup(CheckPointVO task) {
|
|
||||||
s_logger.info("Cleaning up " + task);
|
|
||||||
CleanupMaid delegate = (CleanupMaid)SerializerHelper.fromSerializedString(task.getContext());
|
|
||||||
assert delegate.getClass().getName().equals(task.getDelegate()) : "Deserializer says " + delegate.getClass().getName() + " but it's suppose to be " + task.getDelegate();
|
|
||||||
|
|
||||||
int result = delegate.cleanup(this);
|
|
||||||
if (result <= 0) {
|
|
||||||
if (result == 0) {
|
|
||||||
s_logger.info("Successfully cleaned up " + task.getId());
|
|
||||||
} else {
|
|
||||||
s_logger.warn("Unsuccessful in cleaning up " + task + ". Procedure to cleanup manaully: " + delegate.getCleanupProcedure());
|
|
||||||
}
|
|
||||||
popCheckPoint(task.getId());
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
s_logger.error("Unable to cleanup " + task.getId());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class CleanupTask implements Runnable {
|
|
||||||
private Date _curDate;
|
|
||||||
public CleanupTask() {
|
|
||||||
_curDate = new Date();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
List<CheckPointVO> tasks = _maidDao.listLeftoversByCutTime(_curDate, _msId);
|
|
||||||
tasks.addAll(_maidDao.listCleanupTasks(_msId));
|
|
||||||
|
|
||||||
List<CheckPointVO> retries = new ArrayList<CheckPointVO>();
|
|
||||||
|
|
||||||
for (CheckPointVO task : tasks) {
|
|
||||||
try {
|
|
||||||
if (!cleanup(task)) {
|
|
||||||
retries.add(task);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
s_logger.warn("Unable to clean up " + task, e);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (retries.size() > 0) {
|
|
||||||
if (_cleanupRetryInterval > 0) {
|
|
||||||
_cleanupScheduler.schedule(this, _cleanupRetryInterval, TimeUnit.SECONDS);
|
|
||||||
} else {
|
|
||||||
for (CheckPointVO task : retries) {
|
|
||||||
s_logger.warn("Cleanup procedure for " + task + ": " + ((CleanupMaid)SerializerHelper.fromSerializedString(task.getContext())).getCleanupProcedure());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
s_logger.error("Unable to cleanup all of the tasks for " + _msId, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package com.cloud.cluster;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* task. The state is serialized and stored. When cleanup is required
|
|
||||||
* CleanupMaid is instantiated from the stored data and cleanup() is called.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface CleanupMaid {
|
|
||||||
/**
|
|
||||||
* cleanup according the state that was stored.
|
|
||||||
*
|
|
||||||
* @return 0 indicates cleanup was successful. Negative number
|
|
||||||
* indicates the cleanup was unsuccessful but don't retry. Positive number
|
|
||||||
* indicates the cleanup was unsuccessful and retry in this many seconds.
|
|
||||||
*/
|
|
||||||
int cleanup(CheckPointManager checkPointMgr);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returned here is recorded.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
String getCleanupProcedure();
|
|
||||||
}
|
|
||||||
@ -29,7 +29,6 @@ import java.sql.SQLException;
|
|||||||
import java.sql.SQLRecoverableException;
|
import java.sql.SQLRecoverableException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -75,8 +74,6 @@ import com.cloud.utils.DateUtil;
|
|||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Profiler;
|
import com.cloud.utils.Profiler;
|
||||||
import com.cloud.utils.PropertiesUtil;
|
import com.cloud.utils.PropertiesUtil;
|
||||||
import com.cloud.utils.component.Adapters;
|
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
import com.cloud.utils.db.ConnectionConcierge;
|
import com.cloud.utils.db.ConnectionConcierge;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
@ -150,9 +147,9 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
private double _connectedAgentsThreshold = 0.7;
|
private double _connectedAgentsThreshold = 0.7;
|
||||||
private static boolean _agentLbHappened = false;
|
private static boolean _agentLbHappened = false;
|
||||||
|
|
||||||
private List<ClusterServicePdu> _clusterPduOutgoingQueue = new ArrayList<ClusterServicePdu>();
|
private final List<ClusterServicePdu> _clusterPduOutgoingQueue = new ArrayList<ClusterServicePdu>();
|
||||||
private List<ClusterServicePdu> _clusterPduIncomingQueue = new ArrayList<ClusterServicePdu>();
|
private final List<ClusterServicePdu> _clusterPduIncomingQueue = new ArrayList<ClusterServicePdu>();
|
||||||
private Map<Long, ClusterServiceRequestPdu> _outgoingPdusWaitingForAck = new HashMap<Long, ClusterServiceRequestPdu>();
|
private final Map<Long, ClusterServiceRequestPdu> _outgoingPdusWaitingForAck = new HashMap<Long, ClusterServiceRequestPdu>();
|
||||||
|
|
||||||
public ClusterManagerImpl() {
|
public ClusterManagerImpl() {
|
||||||
_clusterPeers = new HashMap<String, ClusterService>();
|
_clusterPeers = new HashMap<String, ClusterService>();
|
||||||
@ -205,53 +202,54 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addOutgoingClusterPdu(ClusterServicePdu pdu) {
|
private void addOutgoingClusterPdu(ClusterServicePdu pdu) {
|
||||||
synchronized(_clusterPduOutgoingQueue) {
|
synchronized(_clusterPduOutgoingQueue) {
|
||||||
_clusterPduOutgoingQueue.add(pdu);
|
_clusterPduOutgoingQueue.add(pdu);
|
||||||
_clusterPduOutgoingQueue.notifyAll();
|
_clusterPduOutgoingQueue.notifyAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClusterServicePdu popOutgoingClusterPdu(long timeoutMs) {
|
private ClusterServicePdu popOutgoingClusterPdu(long timeoutMs) {
|
||||||
synchronized(_clusterPduOutgoingQueue) {
|
synchronized(_clusterPduOutgoingQueue) {
|
||||||
try {
|
try {
|
||||||
_clusterPduOutgoingQueue.wait(timeoutMs);
|
_clusterPduOutgoingQueue.wait(timeoutMs);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_clusterPduOutgoingQueue.size() > 0) {
|
if(_clusterPduOutgoingQueue.size() > 0) {
|
||||||
ClusterServicePdu pdu = _clusterPduOutgoingQueue.get(0);
|
ClusterServicePdu pdu = _clusterPduOutgoingQueue.get(0);
|
||||||
_clusterPduOutgoingQueue.remove(0);
|
_clusterPduOutgoingQueue.remove(0);
|
||||||
return pdu;
|
return pdu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIncomingClusterPdu(ClusterServicePdu pdu) {
|
private void addIncomingClusterPdu(ClusterServicePdu pdu) {
|
||||||
synchronized(_clusterPduIncomingQueue) {
|
synchronized(_clusterPduIncomingQueue) {
|
||||||
_clusterPduIncomingQueue.add(pdu);
|
_clusterPduIncomingQueue.add(pdu);
|
||||||
_clusterPduIncomingQueue.notifyAll();
|
_clusterPduIncomingQueue.notifyAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClusterServicePdu popIncomingClusterPdu(long timeoutMs) {
|
private ClusterServicePdu popIncomingClusterPdu(long timeoutMs) {
|
||||||
synchronized(_clusterPduIncomingQueue) {
|
synchronized(_clusterPduIncomingQueue) {
|
||||||
try {
|
try {
|
||||||
_clusterPduIncomingQueue.wait(timeoutMs);
|
_clusterPduIncomingQueue.wait(timeoutMs);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_clusterPduIncomingQueue.size() > 0) {
|
if(_clusterPduIncomingQueue.size() > 0) {
|
||||||
ClusterServicePdu pdu = _clusterPduIncomingQueue.get(0);
|
ClusterServicePdu pdu = _clusterPduIncomingQueue.get(0);
|
||||||
_clusterPduIncomingQueue.remove(0);
|
_clusterPduIncomingQueue.remove(0);
|
||||||
return pdu;
|
return pdu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Runnable getClusterPduSendingTask() {
|
private Runnable getClusterPduSendingTask() {
|
||||||
return new Runnable() {
|
return new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
onSendingClusterPdu();
|
onSendingClusterPdu();
|
||||||
}
|
}
|
||||||
@ -260,6 +258,7 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
|
|
||||||
private Runnable getClusterPduNotificationTask() {
|
private Runnable getClusterPduNotificationTask() {
|
||||||
return new Runnable() {
|
return new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
onNotifyingClusterPdu();
|
onNotifyingClusterPdu();
|
||||||
}
|
}
|
||||||
@ -271,7 +270,7 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
try {
|
try {
|
||||||
ClusterServicePdu pdu = popOutgoingClusterPdu(1000);
|
ClusterServicePdu pdu = popOutgoingClusterPdu(1000);
|
||||||
if(pdu == null)
|
if(pdu == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ClusterService peerService = null;
|
ClusterService peerService = null;
|
||||||
for(int i = 0; i < 2; i++) {
|
for(int i = 0; i < 2; i++) {
|
||||||
@ -285,15 +284,15 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
try {
|
try {
|
||||||
if(s_logger.isDebugEnabled()) {
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Cluster PDU " + getSelfPeerName() + " -> " + pdu.getDestPeer() + ". agent: " + pdu.getAgentId()
|
s_logger.debug("Cluster PDU " + getSelfPeerName() + " -> " + pdu.getDestPeer() + ". agent: " + pdu.getAgentId()
|
||||||
+ ", pdu seq: " + pdu.getSequenceId() + ", pdu ack seq: " + pdu.getAckSequenceId() + ", json: " + pdu.getJsonPackage());
|
+ ", pdu seq: " + pdu.getSequenceId() + ", pdu ack seq: " + pdu.getAckSequenceId() + ", json: " + pdu.getJsonPackage());
|
||||||
}
|
}
|
||||||
|
|
||||||
long startTick = System.currentTimeMillis();
|
long startTick = System.currentTimeMillis();
|
||||||
String strResult = peerService.execute(pdu);
|
String strResult = peerService.execute(pdu);
|
||||||
if(s_logger.isDebugEnabled()) {
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Cluster PDU " + getSelfPeerName() + " -> " + pdu.getDestPeer() + " completed. time: " +
|
s_logger.debug("Cluster PDU " + getSelfPeerName() + " -> " + pdu.getDestPeer() + " completed. time: " +
|
||||||
(System.currentTimeMillis() - startTick) + "ms. agent: " + pdu.getAgentId()
|
(System.currentTimeMillis() - startTick) + "ms. agent: " + pdu.getAgentId()
|
||||||
+ ", pdu seq: " + pdu.getSequenceId() + ", pdu ack seq: " + pdu.getAckSequenceId() + ", json: " + pdu.getJsonPackage());
|
+ ", pdu seq: " + pdu.getSequenceId() + ", pdu ack seq: " + pdu.getAckSequenceId() + ", json: " + pdu.getJsonPackage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if("true".equals(strResult))
|
if("true".equals(strResult))
|
||||||
@ -319,37 +318,38 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
try {
|
try {
|
||||||
final ClusterServicePdu pdu = popIncomingClusterPdu(1000);
|
final ClusterServicePdu pdu = popIncomingClusterPdu(1000);
|
||||||
if(pdu == null)
|
if(pdu == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
_executor.execute(new Runnable() {
|
_executor.execute(new Runnable() {
|
||||||
public void run() {
|
@Override
|
||||||
if(pdu.getPduType() == ClusterServicePdu.PDU_TYPE_RESPONSE) {
|
public void run() {
|
||||||
ClusterServiceRequestPdu requestPdu = popRequestPdu(pdu.getAckSequenceId());
|
if(pdu.getPduType() == ClusterServicePdu.PDU_TYPE_RESPONSE) {
|
||||||
if(requestPdu != null) {
|
ClusterServiceRequestPdu requestPdu = popRequestPdu(pdu.getAckSequenceId());
|
||||||
requestPdu.setResponseResult(pdu.getJsonPackage());
|
if(requestPdu != null) {
|
||||||
synchronized(requestPdu) {
|
requestPdu.setResponseResult(pdu.getJsonPackage());
|
||||||
requestPdu.notifyAll();
|
synchronized(requestPdu) {
|
||||||
}
|
requestPdu.notifyAll();
|
||||||
} else {
|
}
|
||||||
s_logger.warn("Original request has already been cancelled. pdu: " + _gson.toJson(pdu));
|
} else {
|
||||||
}
|
s_logger.warn("Original request has already been cancelled. pdu: " + _gson.toJson(pdu));
|
||||||
} else {
|
}
|
||||||
String result = dispatchClusterServicePdu(pdu);
|
} else {
|
||||||
if(result == null)
|
String result = dispatchClusterServicePdu(pdu);
|
||||||
result = "";
|
if(result == null)
|
||||||
|
result = "";
|
||||||
|
|
||||||
if(pdu.getPduType() == ClusterServicePdu.PDU_TYPE_REQUEST) {
|
if(pdu.getPduType() == ClusterServicePdu.PDU_TYPE_REQUEST) {
|
||||||
ClusterServicePdu responsePdu = new ClusterServicePdu();
|
ClusterServicePdu responsePdu = new ClusterServicePdu();
|
||||||
responsePdu.setPduType(ClusterServicePdu.PDU_TYPE_RESPONSE);
|
responsePdu.setPduType(ClusterServicePdu.PDU_TYPE_RESPONSE);
|
||||||
responsePdu.setSourcePeer(pdu.getDestPeer());
|
responsePdu.setSourcePeer(pdu.getDestPeer());
|
||||||
responsePdu.setDestPeer(pdu.getSourcePeer());
|
responsePdu.setDestPeer(pdu.getSourcePeer());
|
||||||
responsePdu.setAckSequenceId(pdu.getSequenceId());
|
responsePdu.setAckSequenceId(pdu.getSequenceId());
|
||||||
responsePdu.setJsonPackage(result);
|
responsePdu.setJsonPackage(result);
|
||||||
|
|
||||||
addOutgoingClusterPdu(responsePdu);
|
addOutgoingClusterPdu(responsePdu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch(Throwable e) {
|
} catch(Throwable e) {
|
||||||
s_logger.error("Unexcpeted exception: ", e);
|
s_logger.error("Unexcpeted exception: ", e);
|
||||||
@ -416,22 +416,22 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
answers[0] = new Answer(cmd, result, null);
|
answers[0] = new Answer(cmd, result, null);
|
||||||
return _gson.toJson(answers);
|
return _gson.toJson(answers);
|
||||||
} else if (cmds.length == 1 && cmds[0] instanceof PropagateResourceEventCommand ) {
|
} else if (cmds.length == 1 && cmds[0] instanceof PropagateResourceEventCommand ) {
|
||||||
PropagateResourceEventCommand cmd = (PropagateResourceEventCommand) cmds[0];
|
PropagateResourceEventCommand cmd = (PropagateResourceEventCommand) cmds[0];
|
||||||
|
|
||||||
s_logger.debug("Intercepting command to propagate event " + cmd.getEvent().name() + " for host " + cmd.getHostId());
|
s_logger.debug("Intercepting command to propagate event " + cmd.getEvent().name() + " for host " + cmd.getHostId());
|
||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
try {
|
try {
|
||||||
result = executeResourceUserRequest(cmd.getHostId(), cmd.getEvent());
|
result = executeResourceUserRequest(cmd.getHostId(), cmd.getEvent());
|
||||||
s_logger.debug("Result is " + result);
|
s_logger.debug("Result is " + result);
|
||||||
} catch (AgentUnavailableException ex) {
|
} catch (AgentUnavailableException ex) {
|
||||||
s_logger.warn("Agent is unavailable", ex);
|
s_logger.warn("Agent is unavailable", ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Answer[] answers = new Answer[1];
|
Answer[] answers = new Answer[1];
|
||||||
answers[0] = new Answer(cmd, result, null);
|
answers[0] = new Answer(cmd, result, null);
|
||||||
return _gson.toJson(answers);
|
return _gson.toJson(answers);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -465,8 +465,9 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void OnReceiveClusterServicePdu(ClusterServicePdu pdu) {
|
public void OnReceiveClusterServicePdu(ClusterServicePdu pdu) {
|
||||||
addIncomingClusterPdu(pdu);
|
addIncomingClusterPdu(pdu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -577,7 +578,7 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
|
|
||||||
if(s_logger.isDebugEnabled()) {
|
if(s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug(getSelfPeerName() + " -> " + strPeer + "." + agentId + " completed. result: " +
|
s_logger.debug(getSelfPeerName() + " -> " + strPeer + "." + agentId + " completed. result: " +
|
||||||
pdu.getResponseResult());
|
pdu.getResponseResult());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pdu.getResponseResult() != null && pdu.getResponseResult().length() > 0) {
|
if(pdu.getResponseResult() != null && pdu.getResponseResult().length() > 0) {
|
||||||
@ -625,18 +626,18 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
// Note : we don't check duplicates
|
// Note : we don't check duplicates
|
||||||
synchronized (_listeners) {
|
synchronized (_listeners) {
|
||||||
|
|
||||||
s_logger.info("register cluster listener " + listener.getClass());
|
s_logger.info("register cluster listener " + listener.getClass());
|
||||||
|
|
||||||
_listeners.add(listener);
|
_listeners.add(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unregisterListener(ClusterManagerListener listener) {
|
public void unregisterListener(ClusterManagerListener listener) {
|
||||||
synchronized(_listeners) {
|
synchronized(_listeners) {
|
||||||
s_logger.info("unregister cluster listener " + listener.getClass());
|
s_logger.info("unregister cluster listener " + listener.getClass());
|
||||||
|
|
||||||
_listeners.remove(listener);
|
_listeners.remove(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -788,9 +789,9 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
if(profiler.getDuration() >= _heartbeatInterval) {
|
if(profiler.getDuration() >= _heartbeatInterval) {
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled())
|
||||||
s_logger.debug("Management server heartbeat takes too long to finish. profiler: " + profiler.toString() +
|
s_logger.debug("Management server heartbeat takes too long to finish. profiler: " + profiler.toString() +
|
||||||
", profilerHeartbeatUpdate: " + profilerHeartbeatUpdate.toString() +
|
", profilerHeartbeatUpdate: " + profilerHeartbeatUpdate.toString() +
|
||||||
", profilerPeerScan: " + profilerPeerScan.toString() +
|
", profilerPeerScan: " + profilerPeerScan.toString() +
|
||||||
", profilerAgentLB: " + profilerAgentLB.toString());
|
", profilerAgentLB: " + profilerAgentLB.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -936,26 +937,26 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
|
|
||||||
switch(msg.getMessageType()) {
|
switch(msg.getMessageType()) {
|
||||||
case nodeAdded:
|
case nodeAdded:
|
||||||
{
|
{
|
||||||
List<ManagementServerHostVO> l = msg.getNodes();
|
List<ManagementServerHostVO> l = msg.getNodes();
|
||||||
if(l != null && l.size() > 0) {
|
if(l != null && l.size() > 0) {
|
||||||
for(ManagementServerHostVO mshost: l) {
|
for(ManagementServerHostVO mshost: l) {
|
||||||
_mshostPeerDao.updatePeerInfo(_mshostId, mshost.getId(), mshost.getRunid(), ManagementServerHost.State.Up);
|
_mshostPeerDao.updatePeerInfo(_mshostId, mshost.getId(), mshost.getRunid(), ManagementServerHost.State.Up);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case nodeRemoved:
|
case nodeRemoved:
|
||||||
{
|
{
|
||||||
List<ManagementServerHostVO> l = msg.getNodes();
|
List<ManagementServerHostVO> l = msg.getNodes();
|
||||||
if(l != null && l.size() > 0) {
|
if(l != null && l.size() > 0) {
|
||||||
for(ManagementServerHostVO mshost: l) {
|
for(ManagementServerHostVO mshost: l) {
|
||||||
_mshostPeerDao.updatePeerInfo(_mshostId, mshost.getId(), mshost.getRunid(), ManagementServerHost.State.Down);
|
_mshostPeerDao.updatePeerInfo(_mshostId, mshost.getId(), mshost.getRunid(), ManagementServerHost.State.Down);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
break;
|
break;
|
||||||
@ -983,34 +984,34 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
// remove records from mshost table, this will leave orphan mgmt_serve_id reference in host table.
|
// remove records from mshost table, this will leave orphan mgmt_serve_id reference in host table.
|
||||||
List<Long> orphanList = _mshostDao.listOrphanMsids();
|
List<Long> orphanList = _mshostDao.listOrphanMsids();
|
||||||
if(orphanList.size() > 0) {
|
if(orphanList.size() > 0) {
|
||||||
for(Long orphanMsid : orphanList) {
|
for(Long orphanMsid : orphanList) {
|
||||||
// construct fake ManagementServerHostVO based on orphan MSID
|
// construct fake ManagementServerHostVO based on orphan MSID
|
||||||
s_logger.info("Add orphan management server msid found in host table to initial clustering notification, orphan msid: " + orphanMsid);
|
s_logger.info("Add orphan management server msid found in host table to initial clustering notification, orphan msid: " + orphanMsid);
|
||||||
inactiveList.add(new ManagementServerHostVO(orphanMsid, 0, "orphan", 0, new Date()));
|
inactiveList.add(new ManagementServerHostVO(orphanMsid, 0, "orphan", 0, new Date()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s_logger.info("We are good, no orphan management server msid in host table is found");
|
s_logger.info("We are good, no orphan management server msid in host table is found");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inactiveList.size() > 0) {
|
if(inactiveList.size() > 0) {
|
||||||
if(s_logger.isInfoEnabled()) {
|
if(s_logger.isInfoEnabled()) {
|
||||||
s_logger.info("Found " + inactiveList.size() + " inactive management server node based on timestamp");
|
s_logger.info("Found " + inactiveList.size() + " inactive management server node based on timestamp");
|
||||||
for(ManagementServerHostVO host : inactiveList)
|
for(ManagementServerHostVO host : inactiveList)
|
||||||
s_logger.info("management server node msid: " + host.getMsid() + ", name: " + host.getName() + ", service ip: " + host.getServiceIP() + ", version: " + host.getVersion());
|
s_logger.info("management server node msid: " + host.getMsid() + ", name: " + host.getName() + ", service ip: " + host.getServiceIP() + ", version: " + host.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ManagementServerHostVO> downHostList = new ArrayList<ManagementServerHostVO>();
|
List<ManagementServerHostVO> downHostList = new ArrayList<ManagementServerHostVO>();
|
||||||
for(ManagementServerHostVO host : inactiveList) {
|
for(ManagementServerHostVO host : inactiveList) {
|
||||||
if(!pingManagementNode(host)) {
|
if(!pingManagementNode(host)) {
|
||||||
s_logger.warn("Management node " + host.getId() + " is detected inactive by timestamp and also not pingable");
|
s_logger.warn("Management node " + host.getId() + " is detected inactive by timestamp and also not pingable");
|
||||||
downHostList.add(host);
|
downHostList.add(host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(downHostList.size() > 0)
|
if(downHostList.size() > 0)
|
||||||
this.queueNotification(new ClusterManagerMessage(ClusterManagerMessage.MessageType.nodeRemoved, downHostList));
|
this.queueNotification(new ClusterManagerMessage(ClusterManagerMessage.MessageType.nodeRemoved, downHostList));
|
||||||
} else {
|
} else {
|
||||||
s_logger.info("No inactive management server node found");
|
s_logger.info("No inactive management server node found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1140,10 +1141,10 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
if(profiler.getDuration() >= this._heartbeatInterval) {
|
if(profiler.getDuration() >= this._heartbeatInterval) {
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled())
|
||||||
s_logger.debug("Peer scan takes too long to finish. profiler: " + profiler.toString()
|
s_logger.debug("Peer scan takes too long to finish. profiler: " + profiler.toString()
|
||||||
+ ", profilerQueryActiveList: " + profilerQueryActiveList.toString()
|
+ ", profilerQueryActiveList: " + profilerQueryActiveList.toString()
|
||||||
+ ", profilerSyncClusterInfo: " + profilerSyncClusterInfo.toString()
|
+ ", profilerSyncClusterInfo: " + profilerSyncClusterInfo.toString()
|
||||||
+ ", profilerInvalidatedNodeList: " + profilerInvalidatedNodeList.toString()
|
+ ", profilerInvalidatedNodeList: " + profilerInvalidatedNodeList.toString()
|
||||||
+ ", profilerRemovedList: " + profilerRemovedList.toString());
|
+ ", profilerRemovedList: " + profilerRemovedList.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1294,7 +1295,7 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < DEFAULT_OUTGOING_WORKERS; i++)
|
for(int i = 0; i < DEFAULT_OUTGOING_WORKERS; i++)
|
||||||
_executor.execute(getClusterPduSendingTask());
|
_executor.execute(getClusterPduSendingTask());
|
||||||
|
|
||||||
// notification task itself in turn works as a task dispatcher
|
// notification task itself in turn works as a task dispatcher
|
||||||
_executor.execute(getClusterPduNotificationTask());
|
_executor.execute(getClusterPduNotificationTask());
|
||||||
@ -1381,7 +1382,7 @@ public class ClusterManagerImpl implements ClusterManager {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (e instanceof ConnectException) {
|
if (e instanceof ConnectException) {
|
||||||
s_logger.error("Unable to ping management server at " + targetIp + ":" + mshost.getServicePort() + " due to ConnectException", e);
|
s_logger.error("Unable to ping management server at " + targetIp + ":" + mshost.getServicePort() + " due to ConnectException", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (sch != null) {
|
if (sch != null) {
|
||||||
|
|||||||
@ -1,153 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package com.cloud.cluster;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.cloud.cluster.dao.StackMaidDao;
|
|
||||||
import com.cloud.cluster.dao.StackMaidDaoImpl;
|
|
||||||
import com.cloud.serializer.SerializerHelper;
|
|
||||||
import com.cloud.utils.CleanupDelegate;
|
|
||||||
import com.cloud.utils.db.Transaction;
|
|
||||||
|
|
||||||
public class StackMaid {
|
|
||||||
protected final static Logger s_logger = Logger.getLogger(StackMaid.class);
|
|
||||||
|
|
||||||
private static ThreadLocal<StackMaid> threadMaid = new ThreadLocal<StackMaid>();
|
|
||||||
|
|
||||||
private static long msid_setby_manager = 0;
|
|
||||||
|
|
||||||
private StackMaidDao maidDao = new StackMaidDaoImpl();
|
|
||||||
private int currentSeq = 0;
|
|
||||||
private Map<String, Object> context = new HashMap<String, Object>();
|
|
||||||
|
|
||||||
public static void init(long msid) {
|
|
||||||
msid_setby_manager = msid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static StackMaid current() {
|
|
||||||
StackMaid maid = threadMaid.get();
|
|
||||||
if(maid == null) {
|
|
||||||
maid = new StackMaid();
|
|
||||||
threadMaid.set(maid);
|
|
||||||
}
|
|
||||||
return maid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerContext(String key, Object contextObject) {
|
|
||||||
assert(!context.containsKey(key)) : "Context key has already been registered";
|
|
||||||
context.put(key, contextObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getContext(String key) {
|
|
||||||
return context.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void expungeMaidItem(long maidId) {
|
|
||||||
// this is a bit ugly, but when it is not loaded by component locator, this is just a workable way for now
|
|
||||||
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
|
||||||
try {
|
|
||||||
maidDao.expunge(maidId);
|
|
||||||
} finally {
|
|
||||||
txn.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int push(String delegateClzName, Object context) {
|
|
||||||
assert(msid_setby_manager != 0) : "Fatal, make sure StackMaidManager is loaded";
|
|
||||||
if(msid_setby_manager == 0)
|
|
||||||
s_logger.error("Fatal, make sure StackMaidManager is loaded");
|
|
||||||
|
|
||||||
return push(msid_setby_manager, delegateClzName, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int push(long currentMsid, String delegateClzName, Object context) {
|
|
||||||
int savePoint = currentSeq;
|
|
||||||
maidDao.pushCleanupDelegate(currentMsid, currentSeq++, delegateClzName, context);
|
|
||||||
return savePoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void pop(int savePoint) {
|
|
||||||
assert(msid_setby_manager != 0) : "Fatal, make sure StackMaidManager is loaded";
|
|
||||||
if(msid_setby_manager == 0)
|
|
||||||
s_logger.error("Fatal, make sure StackMaidManager is loaded");
|
|
||||||
|
|
||||||
pop(msid_setby_manager, savePoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void pop() {
|
|
||||||
if(currentSeq > 0)
|
|
||||||
pop(currentSeq -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* must be called within thread context
|
|
||||||
* @param currentMsid
|
|
||||||
*/
|
|
||||||
public void pop(long currentMsid, int savePoint) {
|
|
||||||
while(currentSeq > savePoint) {
|
|
||||||
maidDao.popCleanupDelegate(currentMsid);
|
|
||||||
currentSeq--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void exitCleanup() {
|
|
||||||
exitCleanup(msid_setby_manager);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void exitCleanup(long currentMsid) {
|
|
||||||
if(currentSeq > 0) {
|
|
||||||
CheckPointVO maid = null;
|
|
||||||
while((maid = maidDao.popCleanupDelegate(currentMsid)) != null) {
|
|
||||||
doCleanup(maid);
|
|
||||||
}
|
|
||||||
currentSeq = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean doCleanup(CheckPointVO maid) {
|
|
||||||
if(maid.getDelegate() != null) {
|
|
||||||
try {
|
|
||||||
Class<?> clz = Class.forName(maid.getDelegate());
|
|
||||||
Object delegate = clz.newInstance();
|
|
||||||
if(delegate instanceof CleanupDelegate) {
|
|
||||||
return ((CleanupDelegate)delegate).cleanup(SerializerHelper.fromSerializedString(maid.getContext()), maid);
|
|
||||||
} else {
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
} catch (final ClassNotFoundException e) {
|
|
||||||
s_logger.error("Unable to load StackMaid delegate class: " + maid.getDelegate(), e);
|
|
||||||
} catch (final SecurityException e) {
|
|
||||||
s_logger.error("Security excetion when loading resource: " + maid.getDelegate());
|
|
||||||
} catch (final IllegalArgumentException e) {
|
|
||||||
s_logger.error("Illegal argument excetion when loading resource: " + maid.getDelegate());
|
|
||||||
} catch (final InstantiationException e) {
|
|
||||||
s_logger.error("Instantiation excetion when loading resource: " + maid.getDelegate());
|
|
||||||
} catch (final IllegalAccessException e) {
|
|
||||||
s_logger.error("Illegal access exception when loading resource: " + maid.getDelegate());
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -34,7 +34,6 @@ import com.cloud.configuration.ResourceLimit;
|
|||||||
import com.cloud.domain.dao.DomainDaoImpl;
|
import com.cloud.domain.dao.DomainDaoImpl;
|
||||||
import com.cloud.exception.UnsupportedServiceException;
|
import com.cloud.exception.UnsupportedServiceException;
|
||||||
import com.cloud.user.dao.AccountDaoImpl;
|
import com.cloud.user.dao.AccountDaoImpl;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
@ -44,90 +43,90 @@ import com.cloud.utils.db.Transaction;
|
|||||||
@Component
|
@Component
|
||||||
@Local(value={ResourceCountDao.class})
|
@Local(value={ResourceCountDao.class})
|
||||||
public class ResourceCountDaoImpl extends GenericDaoBase<ResourceCountVO, Long> implements ResourceCountDao {
|
public class ResourceCountDaoImpl extends GenericDaoBase<ResourceCountVO, Long> implements ResourceCountDao {
|
||||||
private SearchBuilder<ResourceCountVO> TypeSearch;
|
private final SearchBuilder<ResourceCountVO> TypeSearch;
|
||||||
|
|
||||||
private SearchBuilder<ResourceCountVO> AccountSearch;
|
private final SearchBuilder<ResourceCountVO> AccountSearch;
|
||||||
private SearchBuilder<ResourceCountVO> DomainSearch;
|
private final SearchBuilder<ResourceCountVO> DomainSearch;
|
||||||
|
|
||||||
//protected final DomainDaoImpl _domainDao = ComponentLocator.inject(DomainDaoImpl.class);
|
//protected final DomainDaoImpl _domainDao = ComponentLocator.inject(DomainDaoImpl.class);
|
||||||
//protected final AccountDaoImpl _accountDao = ComponentLocator.inject(AccountDaoImpl.class);
|
//protected final AccountDaoImpl _accountDao = ComponentLocator.inject(AccountDaoImpl.class);
|
||||||
|
|
||||||
@Inject protected DomainDaoImpl _domainDao;
|
@Inject protected DomainDaoImpl _domainDao;
|
||||||
@Inject protected AccountDaoImpl _accountDao;
|
@Inject protected AccountDaoImpl _accountDao;
|
||||||
|
|
||||||
public ResourceCountDaoImpl() {
|
public ResourceCountDaoImpl() {
|
||||||
TypeSearch = createSearchBuilder();
|
TypeSearch = createSearchBuilder();
|
||||||
TypeSearch.and("type", TypeSearch.entity().getType(), SearchCriteria.Op.EQ);
|
TypeSearch.and("type", TypeSearch.entity().getType(), SearchCriteria.Op.EQ);
|
||||||
TypeSearch.and("accountId", TypeSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
TypeSearch.and("accountId", TypeSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||||
TypeSearch.and("domainId", TypeSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
|
TypeSearch.and("domainId", TypeSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
|
||||||
TypeSearch.done();
|
TypeSearch.done();
|
||||||
|
|
||||||
AccountSearch = createSearchBuilder();
|
AccountSearch = createSearchBuilder();
|
||||||
AccountSearch.and("accountId", AccountSearch.entity().getAccountId(), SearchCriteria.Op.NNULL);
|
AccountSearch.and("accountId", AccountSearch.entity().getAccountId(), SearchCriteria.Op.NNULL);
|
||||||
AccountSearch.done();
|
AccountSearch.done();
|
||||||
|
|
||||||
DomainSearch = createSearchBuilder();
|
DomainSearch = createSearchBuilder();
|
||||||
DomainSearch.and("domainId", DomainSearch.entity().getDomainId(), SearchCriteria.Op.NNULL);
|
DomainSearch.and("domainId", DomainSearch.entity().getDomainId(), SearchCriteria.Op.NNULL);
|
||||||
DomainSearch.done();
|
DomainSearch.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceCountVO findByOwnerAndType(long ownerId, ResourceOwnerType ownerType, ResourceType type) {
|
public ResourceCountVO findByOwnerAndType(long ownerId, ResourceOwnerType ownerType, ResourceType type) {
|
||||||
SearchCriteria<ResourceCountVO> sc = TypeSearch.create();
|
SearchCriteria<ResourceCountVO> sc = TypeSearch.create();
|
||||||
sc.setParameters("type", type);
|
sc.setParameters("type", type);
|
||||||
|
|
||||||
if (ownerType == ResourceOwnerType.Account) {
|
if (ownerType == ResourceOwnerType.Account) {
|
||||||
sc.setParameters("accountId", ownerId);
|
sc.setParameters("accountId", ownerId);
|
||||||
return findOneIncludingRemovedBy(sc);
|
|
||||||
} else if (ownerType == ResourceOwnerType.Domain) {
|
|
||||||
sc.setParameters("domainId", ownerId);
|
|
||||||
return findOneIncludingRemovedBy(sc);
|
return findOneIncludingRemovedBy(sc);
|
||||||
} else {
|
} else if (ownerType == ResourceOwnerType.Domain) {
|
||||||
return null;
|
sc.setParameters("domainId", ownerId);
|
||||||
}
|
return findOneIncludingRemovedBy(sc);
|
||||||
}
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getResourceCount(long ownerId, ResourceOwnerType ownerType, ResourceType type) {
|
public long getResourceCount(long ownerId, ResourceOwnerType ownerType, ResourceType type) {
|
||||||
ResourceCountVO vo = findByOwnerAndType(ownerId, ownerType, type);
|
ResourceCountVO vo = findByOwnerAndType(ownerId, ownerType, type);
|
||||||
if (vo != null) {
|
if (vo != null) {
|
||||||
return vo.getCount();
|
return vo.getCount();
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setResourceCount(long ownerId, ResourceOwnerType ownerType, ResourceType type, long count) {
|
public void setResourceCount(long ownerId, ResourceOwnerType ownerType, ResourceType type, long count) {
|
||||||
ResourceCountVO resourceCountVO = findByOwnerAndType(ownerId, ownerType, type);
|
ResourceCountVO resourceCountVO = findByOwnerAndType(ownerId, ownerType, type);
|
||||||
if (count != resourceCountVO.getCount()) {
|
if (count != resourceCountVO.getCount()) {
|
||||||
resourceCountVO.setCount(count);
|
resourceCountVO.setCount(count);
|
||||||
update(resourceCountVO.getId(), resourceCountVO);
|
update(resourceCountVO.getId(), resourceCountVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @Deprecated
|
@Override @Deprecated
|
||||||
public void updateDomainCount(long domainId, ResourceType type, boolean increment, long delta) {
|
public void updateDomainCount(long domainId, ResourceType type, boolean increment, long delta) {
|
||||||
delta = increment ? delta : delta * -1;
|
delta = increment ? delta : delta * -1;
|
||||||
|
|
||||||
ResourceCountVO resourceCountVO = findByOwnerAndType(domainId, ResourceOwnerType.Domain, type);
|
ResourceCountVO resourceCountVO = findByOwnerAndType(domainId, ResourceOwnerType.Domain, type);
|
||||||
resourceCountVO.setCount(resourceCountVO.getCount() + delta);
|
resourceCountVO.setCount(resourceCountVO.getCount() + delta);
|
||||||
update(resourceCountVO.getId(), resourceCountVO);
|
update(resourceCountVO.getId(), resourceCountVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateById(long id, boolean increment, long delta) {
|
public boolean updateById(long id, boolean increment, long delta) {
|
||||||
delta = increment ? delta : delta * -1;
|
delta = increment ? delta : delta * -1;
|
||||||
|
|
||||||
ResourceCountVO resourceCountVO = findById(id);
|
ResourceCountVO resourceCountVO = findById(id);
|
||||||
resourceCountVO.setCount(resourceCountVO.getCount() + delta);
|
resourceCountVO.setCount(resourceCountVO.getCount() + delta);
|
||||||
return update(resourceCountVO.getId(), resourceCountVO);
|
return update(resourceCountVO.getId(), resourceCountVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Long> listRowsToUpdateForDomain(long domainId, ResourceType type) {
|
public Set<Long> listRowsToUpdateForDomain(long domainId, ResourceType type) {
|
||||||
Set<Long> rowIds = new HashSet<Long>();
|
Set<Long> rowIds = new HashSet<Long>();
|
||||||
Set<Long> domainIdsToUpdate = _domainDao.getDomainParentIds(domainId);
|
Set<Long> domainIdsToUpdate = _domainDao.getDomainParentIds(domainId);
|
||||||
for (Long domainIdToUpdate : domainIdsToUpdate) {
|
for (Long domainIdToUpdate : domainIdsToUpdate) {
|
||||||
ResourceCountVO domainCountRecord = findByOwnerAndType(domainIdToUpdate, ResourceOwnerType.Domain, type);
|
ResourceCountVO domainCountRecord = findByOwnerAndType(domainIdToUpdate, ResourceOwnerType.Domain, type);
|
||||||
if (domainCountRecord != null) {
|
if (domainCountRecord != null) {
|
||||||
@ -135,29 +134,29 @@ public class ResourceCountDaoImpl extends GenericDaoBase<ResourceCountVO, Long>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rowIds;
|
return rowIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Long> listAllRowsToUpdate(long ownerId, ResourceOwnerType ownerType, ResourceType type) {
|
public Set<Long> listAllRowsToUpdate(long ownerId, ResourceOwnerType ownerType, ResourceType type) {
|
||||||
Set<Long> rowIds = new HashSet<Long>();
|
Set<Long> rowIds = new HashSet<Long>();
|
||||||
|
|
||||||
if (ownerType == ResourceOwnerType.Account) {
|
if (ownerType == ResourceOwnerType.Account) {
|
||||||
//get records for account
|
//get records for account
|
||||||
ResourceCountVO accountCountRecord = findByOwnerAndType(ownerId, ResourceOwnerType.Account, type);
|
ResourceCountVO accountCountRecord = findByOwnerAndType(ownerId, ResourceOwnerType.Account, type);
|
||||||
if (accountCountRecord != null) {
|
if (accountCountRecord != null) {
|
||||||
rowIds.add(accountCountRecord.getId());
|
rowIds.add(accountCountRecord.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
//get records for account's domain and all its parent domains
|
//get records for account's domain and all its parent domains
|
||||||
rowIds.addAll(listRowsToUpdateForDomain(_accountDao.findByIdIncludingRemoved(ownerId).getDomainId(),type));
|
rowIds.addAll(listRowsToUpdateForDomain(_accountDao.findByIdIncludingRemoved(ownerId).getDomainId(),type));
|
||||||
} else if (ownerType == ResourceOwnerType.Domain) {
|
} else if (ownerType == ResourceOwnerType.Domain) {
|
||||||
return listRowsToUpdateForDomain(ownerId, type);
|
return listRowsToUpdateForDomain(ownerId, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rowIds;
|
return rowIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
public void createResourceCounts(long ownerId, ResourceLimit.ResourceOwnerType ownerType){
|
public void createResourceCounts(long ownerId, ResourceLimit.ResourceOwnerType ownerType){
|
||||||
|
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
@ -175,19 +174,19 @@ public class ResourceCountDaoImpl extends GenericDaoBase<ResourceCountVO, Long>
|
|||||||
txn.commit();
|
txn.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ResourceCountVO> listByDomainId(long domainId) {
|
private List<ResourceCountVO> listByDomainId(long domainId) {
|
||||||
SearchCriteria<ResourceCountVO> sc = TypeSearch.create();
|
SearchCriteria<ResourceCountVO> sc = TypeSearch.create();
|
||||||
sc.setParameters("domainId", domainId);
|
sc.setParameters("domainId", domainId);
|
||||||
|
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ResourceCountVO> listByAccountId(long accountId) {
|
private List<ResourceCountVO> listByAccountId(long accountId) {
|
||||||
SearchCriteria<ResourceCountVO> sc = TypeSearch.create();
|
SearchCriteria<ResourceCountVO> sc = TypeSearch.create();
|
||||||
sc.setParameters("accountId", accountId);
|
sc.setParameters("accountId", accountId);
|
||||||
|
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ResourceCountVO> listByOwnerId(long ownerId, ResourceOwnerType ownerType) {
|
public List<ResourceCountVO> listByOwnerId(long ownerId, ResourceOwnerType ownerType) {
|
||||||
@ -200,24 +199,24 @@ public class ResourceCountDaoImpl extends GenericDaoBase<ResourceCountVO, Long>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ResourceCountVO> listResourceCountByOwnerType(ResourceOwnerType ownerType) {
|
public List<ResourceCountVO> listResourceCountByOwnerType(ResourceOwnerType ownerType) {
|
||||||
if (ownerType == ResourceOwnerType.Account) {
|
if (ownerType == ResourceOwnerType.Account) {
|
||||||
return listBy(AccountSearch.create());
|
return listBy(AccountSearch.create());
|
||||||
} else if (ownerType == ResourceOwnerType.Domain) {
|
} else if (ownerType == ResourceOwnerType.Domain) {
|
||||||
return listBy(DomainSearch.create());
|
return listBy(DomainSearch.create());
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<ResourceCountVO>();
|
return new ArrayList<ResourceCountVO>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceCountVO persist(ResourceCountVO resourceCountVO){
|
public ResourceCountVO persist(ResourceCountVO resourceCountVO){
|
||||||
ResourceOwnerType ownerType = resourceCountVO.getResourceOwnerType();
|
ResourceOwnerType ownerType = resourceCountVO.getResourceOwnerType();
|
||||||
ResourceType resourceType = resourceCountVO.getType();
|
ResourceType resourceType = resourceCountVO.getType();
|
||||||
if (!resourceType.supportsOwner(ownerType)) {
|
if (!resourceType.supportsOwner(ownerType)) {
|
||||||
throw new UnsupportedServiceException("Resource type " + resourceType + " is not supported for owner of type " + ownerType.getName());
|
throw new UnsupportedServiceException("Resource type " + resourceType + " is not supported for owner of type " + ownerType.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.persist(resourceCountVO);
|
return super.persist(resourceCountVO);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,6 @@ import com.cloud.host.dao.HostDao;
|
|||||||
import com.cloud.info.ConsoleProxyInfo;
|
import com.cloud.info.ConsoleProxyInfo;
|
||||||
import com.cloud.network.Network;
|
import com.cloud.network.Network;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.vm.ConsoleProxyVO;
|
import com.cloud.vm.ConsoleProxyVO;
|
||||||
import com.cloud.vm.ReservationContext;
|
import com.cloud.vm.ReservationContext;
|
||||||
import com.cloud.vm.UserVmVO;
|
import com.cloud.vm.UserVmVO;
|
||||||
@ -276,7 +275,7 @@ public class AgentBasedConsoleProxyManager implements ConsoleProxyManager, Virtu
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConsoleProxyManagementState getManagementState() {
|
public ConsoleProxyManagementState getManagementState() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -27,9 +27,6 @@ import javax.naming.ConfigurationException;
|
|||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
|
||||||
import com.cloud.utils.NumbersUtil;
|
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.vm.ConsoleProxyVO;
|
import com.cloud.vm.ConsoleProxyVO;
|
||||||
|
|
||||||
import edu.emory.mathcs.backport.java.util.Collections;
|
import edu.emory.mathcs.backport.java.util.Collections;
|
||||||
@ -42,40 +39,40 @@ public class ConsoleProxyBalanceAllocator implements ConsoleProxyAllocator {
|
|||||||
private final Random _rand = new Random(System.currentTimeMillis());
|
private final Random _rand = new Random(System.currentTimeMillis());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConsoleProxyVO allocProxy(List<ConsoleProxyVO> candidates, final Map<Long, Integer> loadInfo, long dataCenterId) {
|
public ConsoleProxyVO allocProxy(List<ConsoleProxyVO> candidates, final Map<Long, Integer> loadInfo, long dataCenterId) {
|
||||||
if(candidates != null) {
|
if(candidates != null) {
|
||||||
|
|
||||||
List<ConsoleProxyVO> allocationList = new ArrayList<ConsoleProxyVO>();
|
List<ConsoleProxyVO> allocationList = new ArrayList<ConsoleProxyVO>();
|
||||||
for(ConsoleProxyVO proxy : candidates) {
|
for(ConsoleProxyVO proxy : candidates) {
|
||||||
allocationList.add(proxy);
|
allocationList.add(proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(candidates, new Comparator<ConsoleProxyVO> () {
|
Collections.sort(candidates, new Comparator<ConsoleProxyVO> () {
|
||||||
@Override
|
@Override
|
||||||
public int compare(ConsoleProxyVO x, ConsoleProxyVO y) {
|
public int compare(ConsoleProxyVO x, ConsoleProxyVO y) {
|
||||||
Integer loadOfX = loadInfo.get(x.getId());
|
Integer loadOfX = loadInfo.get(x.getId());
|
||||||
Integer loadOfY = loadInfo.get(y.getId());
|
Integer loadOfY = loadInfo.get(y.getId());
|
||||||
|
|
||||||
if(loadOfX != null && loadOfY != null) {
|
if(loadOfX != null && loadOfY != null) {
|
||||||
if(loadOfX < loadOfY)
|
if(loadOfX < loadOfY)
|
||||||
return -1;
|
return -1;
|
||||||
else if(loadOfX > loadOfY)
|
else if(loadOfX > loadOfY)
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
} else if(loadOfX == null && loadOfY == null) {
|
} else if(loadOfX == null && loadOfY == null) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
if(loadOfX == null)
|
if(loadOfX == null)
|
||||||
return -1;
|
return -1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(allocationList.size() > 0)
|
if(allocationList.size() > 0)
|
||||||
return allocationList.get(0);
|
return allocationList.get(0);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -19,7 +19,6 @@ package com.cloud.consoleproxy;
|
|||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -32,6 +31,7 @@ import javax.inject.Inject;
|
|||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.api.ServerApiException;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -55,7 +55,6 @@ import com.cloud.agent.api.proxy.StartConsoleProxyAgentHttpHandlerCommand;
|
|||||||
import com.cloud.agent.api.to.NicTO;
|
import com.cloud.agent.api.to.NicTO;
|
||||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||||
import com.cloud.agent.manager.Commands;
|
import com.cloud.agent.manager.Commands;
|
||||||
import org.apache.cloudstack.api.ServerApiException;
|
|
||||||
import com.cloud.api.commands.DestroyConsoleProxyCmd;
|
import com.cloud.api.commands.DestroyConsoleProxyCmd;
|
||||||
import com.cloud.certificate.dao.CertificateDao;
|
import com.cloud.certificate.dao.CertificateDao;
|
||||||
import com.cloud.cluster.ClusterManager;
|
import com.cloud.cluster.ClusterManager;
|
||||||
@ -128,8 +127,6 @@ import com.cloud.utils.DateUtil;
|
|||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.Ternary;
|
import com.cloud.utils.Ternary;
|
||||||
import com.cloud.utils.component.Adapters;
|
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.component.Manager;
|
import com.cloud.utils.component.Manager;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GlobalLock;
|
import com.cloud.utils.db.GlobalLock;
|
||||||
@ -478,9 +475,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
assert (ksVo != null);
|
assert (ksVo != null);
|
||||||
|
|
||||||
if (_staticPublicIp == null) {
|
if (_staticPublicIp == null) {
|
||||||
return new ConsoleProxyInfo(proxy.isSslEnabled(), proxy.getPublicIpAddress(), _consoleProxyPort, proxy.getPort(), ksVo.getDomainSuffix());
|
return new ConsoleProxyInfo(proxy.isSslEnabled(), proxy.getPublicIpAddress(), _consoleProxyPort, proxy.getPort(), ksVo.getDomainSuffix());
|
||||||
} else {
|
} else {
|
||||||
return new ConsoleProxyInfo(proxy.isSslEnabled(), _staticPublicIp, _consoleProxyPort, _staticPort, ksVo.getDomainSuffix());
|
return new ConsoleProxyInfo(proxy.isSslEnabled(), _staticPublicIp, _consoleProxyPort, _staticPort, ksVo.getDomainSuffix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -809,9 +806,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
|
|
||||||
private ConsoleProxyAllocator getCurrentAllocator() {
|
private ConsoleProxyAllocator getCurrentAllocator() {
|
||||||
// for now, only one adapter is supported
|
// for now, only one adapter is supported
|
||||||
for(ConsoleProxyAllocator allocator : _consoleProxyAllocators) {
|
for(ConsoleProxyAllocator allocator : _consoleProxyAllocators) {
|
||||||
return allocator;
|
return allocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -903,26 +900,26 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!cmd.isReauthenticating()) {
|
if(!cmd.isReauthenticating()) {
|
||||||
String ticket = ConsoleProxyServlet.genAccessTicket(cmd.getHost(), cmd.getPort(), cmd.getSid(), cmd.getVmId());
|
String ticket = ConsoleProxyServlet.genAccessTicket(cmd.getHost(), cmd.getPort(), cmd.getSid(), cmd.getVmId());
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Console authentication. Ticket in 1 minute boundary for " + cmd.getHost() + ":" + cmd.getPort() + "-" + cmd.getVmId() + " is " + ticket);
|
s_logger.debug("Console authentication. Ticket in 1 minute boundary for " + cmd.getHost() + ":" + cmd.getPort() + "-" + cmd.getVmId() + " is " + ticket);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ticket.equals(ticketInUrl)) {
|
if (!ticket.equals(ticketInUrl)) {
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
// considering of minute round-up
|
// considering of minute round-up
|
||||||
String minuteEarlyTicket = ConsoleProxyServlet.genAccessTicket(cmd.getHost(), cmd.getPort(), cmd.getSid(), cmd.getVmId(), new Date(now.getTime() - 60 * 1000));
|
String minuteEarlyTicket = ConsoleProxyServlet.genAccessTicket(cmd.getHost(), cmd.getPort(), cmd.getSid(), cmd.getVmId(), new Date(now.getTime() - 60 * 1000));
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Console authentication. Ticket in 2-minute boundary for " + cmd.getHost() + ":" + cmd.getPort() + "-" + cmd.getVmId() + " is " + minuteEarlyTicket);
|
s_logger.debug("Console authentication. Ticket in 2-minute boundary for " + cmd.getHost() + ":" + cmd.getPort() + "-" + cmd.getVmId() + " is " + minuteEarlyTicket);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!minuteEarlyTicket.equals(ticketInUrl)) {
|
if (!minuteEarlyTicket.equals(ticketInUrl)) {
|
||||||
s_logger.error("Access ticket expired or has been modified. vmId: " + cmd.getVmId() + "ticket in URL: " + ticketInUrl + ", tickets to check against: " + ticket + ","
|
s_logger.error("Access ticket expired or has been modified. vmId: " + cmd.getVmId() + "ticket in URL: " + ticketInUrl + ", tickets to check against: " + ticket + ","
|
||||||
+ minuteEarlyTicket);
|
+ minuteEarlyTicket);
|
||||||
return new ConsoleAccessAuthenticationAnswer(cmd, false);
|
return new ConsoleAccessAuthenticationAnswer(cmd, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd.getVmId() != null && cmd.getVmId().isEmpty()) {
|
if (cmd.getVmId() != null && cmd.getVmId().isEmpty()) {
|
||||||
@ -965,30 +962,30 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
authenticationAnswer.setReauthenticating(true);
|
authenticationAnswer.setReauthenticating(true);
|
||||||
|
|
||||||
s_logger.info("Re-authentication request, ask host " + vm.getHostId() + " for new console info");
|
s_logger.info("Re-authentication request, ask host " + vm.getHostId() + " for new console info");
|
||||||
GetVncPortAnswer answer = (GetVncPortAnswer) _agentMgr.easySend(vm.getHostId(), new
|
GetVncPortAnswer answer = (GetVncPortAnswer) _agentMgr.easySend(vm.getHostId(), new
|
||||||
GetVncPortCommand(vm.getId(), vm.getInstanceName()));
|
GetVncPortCommand(vm.getId(), vm.getInstanceName()));
|
||||||
|
|
||||||
if (answer != null && answer.getResult()) {
|
if (answer != null && answer.getResult()) {
|
||||||
Ternary<String, String, String> parsedHostInfo = ConsoleProxyServlet.parseHostInfo(answer.getAddress());
|
Ternary<String, String, String> parsedHostInfo = ConsoleProxyServlet.parseHostInfo(answer.getAddress());
|
||||||
|
|
||||||
if(parsedHostInfo.second() != null && parsedHostInfo.third() != null) {
|
if(parsedHostInfo.second() != null && parsedHostInfo.third() != null) {
|
||||||
|
|
||||||
s_logger.info("Re-authentication result. vm: " + vm.getId() + ", tunnel url: " + parsedHostInfo.second()
|
s_logger.info("Re-authentication result. vm: " + vm.getId() + ", tunnel url: " + parsedHostInfo.second()
|
||||||
+ ", tunnel session: " + parsedHostInfo.third());
|
+ ", tunnel session: " + parsedHostInfo.third());
|
||||||
|
|
||||||
authenticationAnswer.setTunnelUrl(parsedHostInfo.second());
|
authenticationAnswer.setTunnelUrl(parsedHostInfo.second());
|
||||||
authenticationAnswer.setTunnelSession(parsedHostInfo.third());
|
authenticationAnswer.setTunnelSession(parsedHostInfo.third());
|
||||||
} else {
|
} else {
|
||||||
s_logger.info("Re-authentication result. vm: " + vm.getId() + ", host address: " + parsedHostInfo.first()
|
s_logger.info("Re-authentication result. vm: " + vm.getId() + ", host address: " + parsedHostInfo.first()
|
||||||
+ ", port: " + answer.getPort());
|
+ ", port: " + answer.getPort());
|
||||||
|
|
||||||
authenticationAnswer.setHost(parsedHostInfo.first());
|
authenticationAnswer.setHost(parsedHostInfo.first());
|
||||||
authenticationAnswer.setPort(answer.getPort());
|
authenticationAnswer.setPort(answer.getPort());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s_logger.warn("Re-authentication request failed");
|
s_logger.warn("Re-authentication request failed");
|
||||||
|
|
||||||
authenticationAnswer.setSuccess(false);
|
authenticationAnswer.setSuccess(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return authenticationAnswer;
|
return authenticationAnswer;
|
||||||
@ -1198,11 +1195,11 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
if (secondaryStorageHost != null) {
|
if (secondaryStorageHost != null) {
|
||||||
s_logger.debug("Zone host is ready, but console proxy template: " + template.getId() + " is not ready on secondary storage: " + secondaryStorageHost.getId());
|
s_logger.debug("Zone host is ready, but console proxy template: " + template.getId() + " is not ready on secondary storage: " + secondaryStorageHost.getId());
|
||||||
} else {
|
} else {
|
||||||
s_logger.debug("Zone host is ready, but console proxy template: " + template.getId() + " is not ready on secondary storage.");
|
s_logger.debug("Zone host is ready, but console proxy template: " + template.getId() + " is not ready on secondary storage.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1532,8 +1529,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(_serviceOffering == null || !_serviceOffering.getSystemUse()){
|
if(_serviceOffering == null || !_serviceOffering.getSystemUse()){
|
||||||
int ramSize = NumbersUtil.parseInt(_configDao.getValue("console.ram.size"), DEFAULT_PROXY_VM_RAMSIZE);
|
int ramSize = NumbersUtil.parseInt(_configDao.getValue("console.ram.size"), DEFAULT_PROXY_VM_RAMSIZE);
|
||||||
int cpuFreq = NumbersUtil.parseInt(_configDao.getValue("console.cpu.mhz"), DEFAULT_PROXY_VM_CPUMHZ);
|
int cpuFreq = NumbersUtil.parseInt(_configDao.getValue("console.cpu.mhz"), DEFAULT_PROXY_VM_CPUMHZ);
|
||||||
_serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, ramSize, cpuFreq, 0, 0, false, null, useLocalStorage, true, null, true, VirtualMachine.Type.ConsoleProxy, true);
|
_serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, ramSize, cpuFreq, 0, 0, false, null, useLocalStorage, true, null, true, VirtualMachine.Type.ConsoleProxy, true);
|
||||||
_serviceOffering.setUniqueName(ServiceOffering.consoleProxyDefaultOffUniqueName);
|
_serviceOffering.setUniqueName(ServiceOffering.consoleProxyDefaultOffUniqueName);
|
||||||
_serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);
|
_serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);
|
||||||
@ -1552,7 +1549,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
|
|
||||||
_staticPublicIp = _configDao.getValue("consoleproxy.static.publicIp");
|
_staticPublicIp = _configDao.getValue("consoleproxy.static.publicIp");
|
||||||
if (_staticPublicIp != null) {
|
if (_staticPublicIp != null) {
|
||||||
_staticPort = NumbersUtil.parseInt(_configDao.getValue("consoleproxy.static.port"), 8443);
|
_staticPort = NumbersUtil.parseInt(_configDao.getValue("consoleproxy.static.port"), 8443);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_logger.isInfoEnabled()) {
|
if (s_logger.isInfoEnabled()) {
|
||||||
@ -2037,7 +2034,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||||||
throw new UnsupportedOperationException("Unplug nic is not supported for vm of type " + vm.getType());
|
throw new UnsupportedOperationException("Unplug nic is not supported for vm of type " + vm.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepareStop(VirtualMachineProfile<ConsoleProxyVO> profile) {
|
public void prepareStop(VirtualMachineProfile<ConsoleProxyVO> profile) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,6 @@ import com.cloud.host.Host.Type;
|
|||||||
import com.cloud.host.HostVO;
|
import com.cloud.host.HostVO;
|
||||||
import com.cloud.info.ConsoleProxyInfo;
|
import com.cloud.info.ConsoleProxyInfo;
|
||||||
import com.cloud.resource.ResourceManager;
|
import com.cloud.resource.ResourceManager;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.vm.VMInstanceVO;
|
import com.cloud.vm.VMInstanceVO;
|
||||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,6 @@ import com.cloud.dc.ClusterVO;
|
|||||||
import com.cloud.dc.HostPodVO;
|
import com.cloud.dc.HostPodVO;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.org.Grouping;
|
import com.cloud.org.Grouping;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.GenericSearchBuilder;
|
import com.cloud.utils.db.GenericSearchBuilder;
|
||||||
import com.cloud.utils.db.JoinBuilder;
|
import com.cloud.utils.db.JoinBuilder;
|
||||||
@ -145,7 +144,7 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Long, List<Long>> getPodClusterIdMap(List<Long> clusterIds){
|
public Map<Long, List<Long>> getPodClusterIdMap(List<Long> clusterIds){
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
Map<Long, List<Long>> result = new HashMap<Long, List<Long>>();
|
Map<Long, List<Long>> result = new HashMap<Long, List<Long>>();
|
||||||
|
|
||||||
@ -162,16 +161,16 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
|
|||||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
Long podId = rs.getLong(1);
|
Long podId = rs.getLong(1);
|
||||||
Long clusterIdInPod = rs.getLong(2);
|
Long clusterIdInPod = rs.getLong(2);
|
||||||
if(result.containsKey(podId)){
|
if(result.containsKey(podId)){
|
||||||
List<Long> clusterList = result.get(podId);
|
List<Long> clusterList = result.get(podId);
|
||||||
clusterList.add(clusterIdInPod);
|
clusterList.add(clusterIdInPod);
|
||||||
result.put(podId, clusterList);
|
result.put(podId, clusterList);
|
||||||
}else{
|
}else{
|
||||||
List<Long> clusterList = new ArrayList<Long>();
|
List<Long> clusterList = new ArrayList<Long>();
|
||||||
clusterList.add(clusterIdInPod);
|
clusterList.add(clusterIdInPod);
|
||||||
result.put(podId, clusterList);
|
result.put(podId, clusterList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -184,21 +183,21 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Long> listDisabledClusters(long zoneId, Long podId) {
|
public List<Long> listDisabledClusters(long zoneId, Long podId) {
|
||||||
GenericSearchBuilder<ClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
|
GenericSearchBuilder<ClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
|
||||||
clusterIdSearch.selectField(clusterIdSearch.entity().getId());
|
clusterIdSearch.selectField(clusterIdSearch.entity().getId());
|
||||||
clusterIdSearch.and("dataCenterId", clusterIdSearch.entity().getDataCenterId(), Op.EQ);
|
clusterIdSearch.and("dataCenterId", clusterIdSearch.entity().getDataCenterId(), Op.EQ);
|
||||||
if(podId != null){
|
if(podId != null){
|
||||||
clusterIdSearch.and("podId", clusterIdSearch.entity().getPodId(), Op.EQ);
|
clusterIdSearch.and("podId", clusterIdSearch.entity().getPodId(), Op.EQ);
|
||||||
}
|
}
|
||||||
clusterIdSearch.and("allocationState", clusterIdSearch.entity().getAllocationState(), Op.EQ);
|
clusterIdSearch.and("allocationState", clusterIdSearch.entity().getAllocationState(), Op.EQ);
|
||||||
clusterIdSearch.done();
|
clusterIdSearch.done();
|
||||||
|
|
||||||
|
|
||||||
SearchCriteria<Long> sc = clusterIdSearch.create();
|
SearchCriteria<Long> sc = clusterIdSearch.create();
|
||||||
sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId);
|
sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId);
|
||||||
if (podId != null) {
|
if (podId != null) {
|
||||||
sc.addAnd("podId", SearchCriteria.Op.EQ, podId);
|
sc.addAnd("podId", SearchCriteria.Op.EQ, podId);
|
||||||
}
|
}
|
||||||
sc.addAnd("allocationState", SearchCriteria.Op.EQ, Grouping.AllocationState.Disabled);
|
sc.addAnd("allocationState", SearchCriteria.Op.EQ, Grouping.AllocationState.Disabled);
|
||||||
return customSearch(sc, null);
|
return customSearch(sc, null);
|
||||||
}
|
}
|
||||||
@ -206,18 +205,18 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
|
|||||||
@Override
|
@Override
|
||||||
public List<Long> listClustersWithDisabledPods(long zoneId) {
|
public List<Long> listClustersWithDisabledPods(long zoneId) {
|
||||||
|
|
||||||
GenericSearchBuilder<HostPodVO, Long> disabledPodIdSearch = _hostPodDao.createSearchBuilder(Long.class);
|
GenericSearchBuilder<HostPodVO, Long> disabledPodIdSearch = _hostPodDao.createSearchBuilder(Long.class);
|
||||||
disabledPodIdSearch.selectField(disabledPodIdSearch.entity().getId());
|
disabledPodIdSearch.selectField(disabledPodIdSearch.entity().getId());
|
||||||
disabledPodIdSearch.and("dataCenterId", disabledPodIdSearch.entity().getDataCenterId(), Op.EQ);
|
disabledPodIdSearch.and("dataCenterId", disabledPodIdSearch.entity().getDataCenterId(), Op.EQ);
|
||||||
disabledPodIdSearch.and("allocationState", disabledPodIdSearch.entity().getAllocationState(), Op.EQ);
|
disabledPodIdSearch.and("allocationState", disabledPodIdSearch.entity().getAllocationState(), Op.EQ);
|
||||||
|
|
||||||
GenericSearchBuilder<ClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
|
GenericSearchBuilder<ClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
|
||||||
clusterIdSearch.selectField(clusterIdSearch.entity().getId());
|
clusterIdSearch.selectField(clusterIdSearch.entity().getId());
|
||||||
clusterIdSearch.join("disabledPodIdSearch", disabledPodIdSearch, clusterIdSearch.entity().getPodId(), disabledPodIdSearch.entity().getId(), JoinBuilder.JoinType.INNER);
|
clusterIdSearch.join("disabledPodIdSearch", disabledPodIdSearch, clusterIdSearch.entity().getPodId(), disabledPodIdSearch.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||||
clusterIdSearch.done();
|
clusterIdSearch.done();
|
||||||
|
|
||||||
|
|
||||||
SearchCriteria<Long> sc = clusterIdSearch.create();
|
SearchCriteria<Long> sc = clusterIdSearch.create();
|
||||||
sc.setJoinParameters("disabledPodIdSearch", "dataCenterId", zoneId);
|
sc.setJoinParameters("disabledPodIdSearch", "dataCenterId", zoneId);
|
||||||
sc.setJoinParameters("disabledPodIdSearch", "allocationState", Grouping.AllocationState.Disabled);
|
sc.setJoinParameters("disabledPodIdSearch", "allocationState", Grouping.AllocationState.Disabled);
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -37,7 +38,6 @@ import com.cloud.utils.db.SearchBuilder;
|
|||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
import com.cloud.utils.db.SearchCriteria.Op;
|
import com.cloud.utils.db.SearchCriteria.Op;
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.vm.VMInstanceVO;
|
import com.cloud.vm.VMInstanceVO;
|
||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
import com.cloud.vm.dao.VMInstanceDaoImpl;
|
import com.cloud.vm.dao.VMInstanceDaoImpl;
|
||||||
@ -46,32 +46,32 @@ import com.cloud.vm.dao.VMInstanceDaoImpl;
|
|||||||
@Local(value={HostPodDao.class})
|
@Local(value={HostPodDao.class})
|
||||||
public class HostPodDaoImpl extends GenericDaoBase<HostPodVO, Long> implements HostPodDao {
|
public class HostPodDaoImpl extends GenericDaoBase<HostPodVO, Long> implements HostPodDao {
|
||||||
private static final Logger s_logger = Logger.getLogger(HostPodDaoImpl.class);
|
private static final Logger s_logger = Logger.getLogger(HostPodDaoImpl.class);
|
||||||
|
@Inject VMInstanceDaoImpl _vmDao;
|
||||||
|
|
||||||
protected SearchBuilder<HostPodVO> DataCenterAndNameSearch;
|
protected SearchBuilder<HostPodVO> DataCenterAndNameSearch;
|
||||||
protected SearchBuilder<HostPodVO> DataCenterIdSearch;
|
protected SearchBuilder<HostPodVO> DataCenterIdSearch;
|
||||||
|
|
||||||
protected HostPodDaoImpl() {
|
protected HostPodDaoImpl() {
|
||||||
DataCenterAndNameSearch = createSearchBuilder();
|
DataCenterAndNameSearch = createSearchBuilder();
|
||||||
DataCenterAndNameSearch.and("dc", DataCenterAndNameSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
DataCenterAndNameSearch.and("dc", DataCenterAndNameSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||||
DataCenterAndNameSearch.and("name", DataCenterAndNameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
DataCenterAndNameSearch.and("name", DataCenterAndNameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||||
DataCenterAndNameSearch.done();
|
DataCenterAndNameSearch.done();
|
||||||
|
|
||||||
DataCenterIdSearch = createSearchBuilder();
|
DataCenterIdSearch = createSearchBuilder();
|
||||||
DataCenterIdSearch.and("dcId", DataCenterIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
DataCenterIdSearch.and("dcId", DataCenterIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||||
DataCenterIdSearch.done();
|
DataCenterIdSearch.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HostPodVO> listByDataCenterId(long id) {
|
public List<HostPodVO> listByDataCenterId(long id) {
|
||||||
SearchCriteria<HostPodVO> sc = DataCenterIdSearch.create();
|
SearchCriteria<HostPodVO> sc = DataCenterIdSearch.create();
|
||||||
sc.setParameters("dcId", id);
|
sc.setParameters("dcId", id);
|
||||||
|
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HostPodVO> listByDataCenterIdVMTypeAndStates(long id, VirtualMachine.Type type, VirtualMachine.State... states) {
|
public List<HostPodVO> listByDataCenterIdVMTypeAndStates(long id, VirtualMachine.Type type, VirtualMachine.State... states) {
|
||||||
final VMInstanceDaoImpl _vmDao = ComponentLocator.inject(VMInstanceDaoImpl.class);
|
|
||||||
SearchBuilder<VMInstanceVO> vmInstanceSearch = _vmDao.createSearchBuilder();
|
SearchBuilder<VMInstanceVO> vmInstanceSearch = _vmDao.createSearchBuilder();
|
||||||
vmInstanceSearch.and("type", vmInstanceSearch.entity().getType(), SearchCriteria.Op.EQ);
|
vmInstanceSearch.and("type", vmInstanceSearch.entity().getType(), SearchCriteria.Op.EQ);
|
||||||
vmInstanceSearch.and("states", vmInstanceSearch.entity().getState(), SearchCriteria.Op.IN);
|
vmInstanceSearch.and("states", vmInstanceSearch.entity().getState(), SearchCriteria.Op.IN);
|
||||||
@ -90,43 +90,43 @@ public class HostPodDaoImpl extends GenericDaoBase<HostPodVO, Long> implements H
|
|||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HostPodVO findByName(String name, long dcId) {
|
public HostPodVO findByName(String name, long dcId) {
|
||||||
SearchCriteria<HostPodVO> sc = DataCenterAndNameSearch.create();
|
SearchCriteria<HostPodVO> sc = DataCenterAndNameSearch.create();
|
||||||
sc.setParameters("dc", dcId);
|
sc.setParameters("dc", dcId);
|
||||||
sc.setParameters("name", name);
|
sc.setParameters("name", name);
|
||||||
|
|
||||||
return findOneBy(sc);
|
return findOneBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<Long, List<Object>> getCurrentPodCidrSubnets(long zoneId, long podIdToSkip) {
|
public HashMap<Long, List<Object>> getCurrentPodCidrSubnets(long zoneId, long podIdToSkip) {
|
||||||
HashMap<Long, List<Object>> currentPodCidrSubnets = new HashMap<Long, List<Object>>();
|
HashMap<Long, List<Object>> currentPodCidrSubnets = new HashMap<Long, List<Object>>();
|
||||||
|
|
||||||
String selectSql = "SELECT id, cidr_address, cidr_size FROM host_pod_ref WHERE data_center_id=" + zoneId +" and removed IS NULL";
|
String selectSql = "SELECT id, cidr_address, cidr_size FROM host_pod_ref WHERE data_center_id=" + zoneId +" and removed IS NULL";
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
try {
|
try {
|
||||||
PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql);
|
PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql);
|
||||||
ResultSet rs = stmt.executeQuery();
|
ResultSet rs = stmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
Long podId = rs.getLong("id");
|
Long podId = rs.getLong("id");
|
||||||
if (podId.longValue() == podIdToSkip) {
|
if (podId.longValue() == podIdToSkip) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String cidrAddress = rs.getString("cidr_address");
|
String cidrAddress = rs.getString("cidr_address");
|
||||||
long cidrSize = rs.getLong("cidr_size");
|
long cidrSize = rs.getLong("cidr_size");
|
||||||
List<Object> cidrPair = new ArrayList<Object>();
|
List<Object> cidrPair = new ArrayList<Object>();
|
||||||
cidrPair.add(0, cidrAddress);
|
cidrPair.add(0, cidrAddress);
|
||||||
cidrPair.add(1, new Long(cidrSize));
|
cidrPair.add(1, new Long(cidrSize));
|
||||||
currentPodCidrSubnets.put(podId, cidrPair);
|
currentPodCidrSubnets.put(podId, cidrPair);
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
s_logger.warn("DB exception " + ex.getMessage(), ex);
|
s_logger.warn("DB exception " + ex.getMessage(), ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentPodCidrSubnets;
|
return currentPodCidrSubnets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Long id) {
|
public boolean remove(Long id) {
|
||||||
|
|||||||
@ -36,7 +36,6 @@ import com.cloud.dc.Vlan.VlanType;
|
|||||||
import com.cloud.dc.VlanVO;
|
import com.cloud.dc.VlanVO;
|
||||||
import com.cloud.network.dao.IPAddressDao;
|
import com.cloud.network.dao.IPAddressDao;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.JoinBuilder;
|
import com.cloud.utils.db.JoinBuilder;
|
||||||
@ -49,39 +48,39 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||||||
@Local(value={VlanDao.class})
|
@Local(value={VlanDao.class})
|
||||||
public class VlanDaoImpl extends GenericDaoBase<VlanVO, Long> implements VlanDao {
|
public class VlanDaoImpl extends GenericDaoBase<VlanVO, Long> implements VlanDao {
|
||||||
|
|
||||||
private final String FindZoneWideVlans = "SELECT * FROM vlan WHERE data_center_id=? and vlan_type=? and vlan_id!=? and id not in (select vlan_db_id from account_vlan_map)";
|
private final String FindZoneWideVlans = "SELECT * FROM vlan WHERE data_center_id=? and vlan_type=? and vlan_id!=? and id not in (select vlan_db_id from account_vlan_map)";
|
||||||
|
|
||||||
protected SearchBuilder<VlanVO> ZoneVlanIdSearch;
|
protected SearchBuilder<VlanVO> ZoneVlanIdSearch;
|
||||||
protected SearchBuilder<VlanVO> ZoneSearch;
|
protected SearchBuilder<VlanVO> ZoneSearch;
|
||||||
protected SearchBuilder<VlanVO> ZoneTypeSearch;
|
protected SearchBuilder<VlanVO> ZoneTypeSearch;
|
||||||
protected SearchBuilder<VlanVO> ZoneTypeAllPodsSearch;
|
protected SearchBuilder<VlanVO> ZoneTypeAllPodsSearch;
|
||||||
protected SearchBuilder<VlanVO> ZoneTypePodSearch;
|
protected SearchBuilder<VlanVO> ZoneTypePodSearch;
|
||||||
protected SearchBuilder<VlanVO> ZoneVlanSearch;
|
protected SearchBuilder<VlanVO> ZoneVlanSearch;
|
||||||
protected SearchBuilder<VlanVO> NetworkVlanSearch;
|
protected SearchBuilder<VlanVO> NetworkVlanSearch;
|
||||||
protected SearchBuilder<VlanVO> PhysicalNetworkVlanSearch;
|
protected SearchBuilder<VlanVO> PhysicalNetworkVlanSearch;
|
||||||
|
|
||||||
@Inject protected PodVlanMapDao _podVlanMapDao;
|
@Inject protected PodVlanMapDao _podVlanMapDao;
|
||||||
@Inject protected AccountVlanMapDao _accountVlanMapDao;
|
@Inject protected AccountVlanMapDao _accountVlanMapDao;
|
||||||
@Inject protected IPAddressDao _ipAddressDao;
|
@Inject protected IPAddressDao _ipAddressDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VlanVO findByZoneAndVlanId(long zoneId, String vlanId) {
|
public VlanVO findByZoneAndVlanId(long zoneId, String vlanId) {
|
||||||
SearchCriteria<VlanVO> sc = ZoneVlanIdSearch.create();
|
SearchCriteria<VlanVO> sc = ZoneVlanIdSearch.create();
|
||||||
sc.setParameters("zoneId", zoneId);
|
sc.setParameters("zoneId", zoneId);
|
||||||
sc.setParameters("vlanId", vlanId);
|
sc.setParameters("vlanId", vlanId);
|
||||||
return findOneBy(sc);
|
return findOneBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VlanVO> listByZone(long zoneId) {
|
public List<VlanVO> listByZone(long zoneId) {
|
||||||
SearchCriteria<VlanVO> sc = ZoneSearch.create();
|
SearchCriteria<VlanVO> sc = ZoneSearch.create();
|
||||||
sc.setParameters("zoneId", zoneId);
|
sc.setParameters("zoneId", zoneId);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VlanDaoImpl() {
|
public VlanDaoImpl() {
|
||||||
ZoneVlanIdSearch = createSearchBuilder();
|
ZoneVlanIdSearch = createSearchBuilder();
|
||||||
ZoneVlanIdSearch.and("zoneId", ZoneVlanIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
ZoneVlanIdSearch.and("zoneId", ZoneVlanIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||||
ZoneVlanIdSearch.and("vlanId", ZoneVlanIdSearch.entity().getVlanTag(), SearchCriteria.Op.EQ);
|
ZoneVlanIdSearch.and("vlanId", ZoneVlanIdSearch.entity().getVlanTag(), SearchCriteria.Op.EQ);
|
||||||
ZoneVlanIdSearch.done();
|
ZoneVlanIdSearch.done();
|
||||||
|
|
||||||
@ -105,79 +104,79 @@ public class VlanDaoImpl extends GenericDaoBase<VlanVO, Long> implements VlanDao
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VlanVO> listZoneWideVlans(long zoneId, VlanType vlanType, String vlanId){
|
public List<VlanVO> listZoneWideVlans(long zoneId, VlanType vlanType, String vlanId){
|
||||||
SearchCriteria<VlanVO> sc = ZoneVlanSearch.create();
|
SearchCriteria<VlanVO> sc = ZoneVlanSearch.create();
|
||||||
sc.setParameters("zoneId", zoneId);
|
sc.setParameters("zoneId", zoneId);
|
||||||
sc.setParameters("vlanId", vlanId);
|
sc.setParameters("vlanId", vlanId);
|
||||||
sc.setParameters("vlanType", vlanType);
|
sc.setParameters("vlanType", vlanType);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VlanVO> listByZoneAndType(long zoneId, VlanType vlanType) {
|
public List<VlanVO> listByZoneAndType(long zoneId, VlanType vlanType) {
|
||||||
SearchCriteria<VlanVO> sc = ZoneTypeSearch.create();
|
SearchCriteria<VlanVO> sc = ZoneTypeSearch.create();
|
||||||
sc.setParameters("zoneId", zoneId);
|
sc.setParameters("zoneId", zoneId);
|
||||||
sc.setParameters("vlanType", vlanType);
|
sc.setParameters("vlanType", vlanType);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VlanVO> listByType(VlanType vlanType) {
|
public List<VlanVO> listByType(VlanType vlanType) {
|
||||||
SearchCriteria<VlanVO> sc = ZoneTypeSearch.create();
|
SearchCriteria<VlanVO> sc = ZoneTypeSearch.create();
|
||||||
sc.setParameters("vlanType", vlanType);
|
sc.setParameters("vlanType", vlanType);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VlanVO> listVlansForPod(long podId) {
|
public List<VlanVO> listVlansForPod(long podId) {
|
||||||
//FIXME: use a join statement to improve the performance (should be minor since we expect only one or two
|
//FIXME: use a join statement to improve the performance (should be minor since we expect only one or two
|
||||||
List<PodVlanMapVO> vlanMaps = _podVlanMapDao.listPodVlanMapsByPod(podId);
|
List<PodVlanMapVO> vlanMaps = _podVlanMapDao.listPodVlanMapsByPod(podId);
|
||||||
List<VlanVO> result = new ArrayList<VlanVO>();
|
List<VlanVO> result = new ArrayList<VlanVO>();
|
||||||
for (PodVlanMapVO pvmvo: vlanMaps) {
|
for (PodVlanMapVO pvmvo: vlanMaps) {
|
||||||
result.add(findById(pvmvo.getVlanDbId()));
|
result.add(findById(pvmvo.getVlanDbId()));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VlanVO> listVlansForPodByType(long podId, VlanType vlanType) {
|
public List<VlanVO> listVlansForPodByType(long podId, VlanType vlanType) {
|
||||||
//FIXME: use a join statement to improve the performance (should be minor since we expect only one or two)
|
//FIXME: use a join statement to improve the performance (should be minor since we expect only one or two)
|
||||||
List<PodVlanMapVO> vlanMaps = _podVlanMapDao.listPodVlanMapsByPod(podId);
|
List<PodVlanMapVO> vlanMaps = _podVlanMapDao.listPodVlanMapsByPod(podId);
|
||||||
List<VlanVO> result = new ArrayList<VlanVO>();
|
List<VlanVO> result = new ArrayList<VlanVO>();
|
||||||
for (PodVlanMapVO pvmvo: vlanMaps) {
|
for (PodVlanMapVO pvmvo: vlanMaps) {
|
||||||
VlanVO vlan =findById(pvmvo.getVlanDbId());
|
VlanVO vlan =findById(pvmvo.getVlanDbId());
|
||||||
if (vlan.getVlanType() == vlanType) {
|
if (vlan.getVlanType() == vlanType) {
|
||||||
result.add(vlan);
|
result.add(vlan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VlanVO> listVlansForAccountByType(Long zoneId, long accountId, VlanType vlanType) {
|
public List<VlanVO> listVlansForAccountByType(Long zoneId, long accountId, VlanType vlanType) {
|
||||||
//FIXME: use a join statement to improve the performance (should be minor since we expect only one or two)
|
//FIXME: use a join statement to improve the performance (should be minor since we expect only one or two)
|
||||||
List<AccountVlanMapVO> vlanMaps = _accountVlanMapDao.listAccountVlanMapsByAccount(accountId);
|
List<AccountVlanMapVO> vlanMaps = _accountVlanMapDao.listAccountVlanMapsByAccount(accountId);
|
||||||
List<VlanVO> result = new ArrayList<VlanVO>();
|
List<VlanVO> result = new ArrayList<VlanVO>();
|
||||||
for (AccountVlanMapVO acvmvo: vlanMaps) {
|
for (AccountVlanMapVO acvmvo: vlanMaps) {
|
||||||
VlanVO vlan =findById(acvmvo.getVlanDbId());
|
VlanVO vlan =findById(acvmvo.getVlanDbId());
|
||||||
if (vlan.getVlanType() == vlanType && (zoneId == null || vlan.getDataCenterId() == zoneId)) {
|
if (vlan.getVlanType() == vlanType && (zoneId == null || vlan.getDataCenterId() == zoneId)) {
|
||||||
result.add(vlan);
|
result.add(vlan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addToPod(long podId, long vlanDbId) {
|
public void addToPod(long podId, long vlanDbId) {
|
||||||
PodVlanMapVO pvmvo = new PodVlanMapVO(podId, vlanDbId);
|
PodVlanMapVO pvmvo = new PodVlanMapVO(podId, vlanDbId);
|
||||||
_podVlanMapDao.persist(pvmvo);
|
_podVlanMapDao.persist(pvmvo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params)
|
public boolean configure(String name, Map<String, Object> params)
|
||||||
throws ConfigurationException {
|
throws ConfigurationException {
|
||||||
boolean result = super.configure(name, params);
|
boolean result = super.configure(name, params);
|
||||||
ZoneTypeAllPodsSearch = createSearchBuilder();
|
ZoneTypeAllPodsSearch = createSearchBuilder();
|
||||||
ZoneTypeAllPodsSearch.and("zoneId", ZoneTypeAllPodsSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
ZoneTypeAllPodsSearch.and("zoneId", ZoneTypeAllPodsSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||||
ZoneTypeAllPodsSearch.and("vlanType", ZoneTypeAllPodsSearch.entity().getVlanType(), SearchCriteria.Op.EQ);
|
ZoneTypeAllPodsSearch.and("vlanType", ZoneTypeAllPodsSearch.entity().getVlanType(), SearchCriteria.Op.EQ);
|
||||||
@ -199,117 +198,117 @@ public class VlanDaoImpl extends GenericDaoBase<VlanVO, Long> implements VlanDao
|
|||||||
PodVlanSearch2.done();
|
PodVlanSearch2.done();
|
||||||
ZoneTypePodSearch.done();
|
ZoneTypePodSearch.done();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private VlanVO findNextVlan(long zoneId, Vlan.VlanType vlanType) {
|
private VlanVO findNextVlan(long zoneId, Vlan.VlanType vlanType) {
|
||||||
List<VlanVO> allVlans = listByZoneAndType(zoneId, vlanType);
|
List<VlanVO> allVlans = listByZoneAndType(zoneId, vlanType);
|
||||||
List<VlanVO> emptyVlans = new ArrayList<VlanVO>();
|
List<VlanVO> emptyVlans = new ArrayList<VlanVO>();
|
||||||
List<VlanVO> fullVlans = new ArrayList<VlanVO>();
|
List<VlanVO> fullVlans = new ArrayList<VlanVO>();
|
||||||
|
|
||||||
// Try to find a VLAN that is partially allocated
|
// Try to find a VLAN that is partially allocated
|
||||||
for (VlanVO vlan : allVlans) {
|
for (VlanVO vlan : allVlans) {
|
||||||
long vlanDbId = vlan.getId();
|
long vlanDbId = vlan.getId();
|
||||||
|
|
||||||
int countOfAllocatedIps = _ipAddressDao.countIPs(zoneId, vlanDbId, true);
|
int countOfAllocatedIps = _ipAddressDao.countIPs(zoneId, vlanDbId, true);
|
||||||
int countOfAllIps = _ipAddressDao.countIPs(zoneId, vlanDbId, false);
|
int countOfAllIps = _ipAddressDao.countIPs(zoneId, vlanDbId, false);
|
||||||
|
|
||||||
if ((countOfAllocatedIps > 0) && (countOfAllocatedIps < countOfAllIps)) {
|
if ((countOfAllocatedIps > 0) && (countOfAllocatedIps < countOfAllIps)) {
|
||||||
return vlan;
|
return vlan;
|
||||||
} else if (countOfAllocatedIps == 0) {
|
} else if (countOfAllocatedIps == 0) {
|
||||||
emptyVlans.add(vlan);
|
emptyVlans.add(vlan);
|
||||||
} else if (countOfAllocatedIps == countOfAllIps) {
|
} else if (countOfAllocatedIps == countOfAllIps) {
|
||||||
fullVlans.add(vlan);
|
fullVlans.add(vlan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emptyVlans.isEmpty()) {
|
if (emptyVlans.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to find an empty VLAN with the same tag/subnet as a VLAN that is full
|
// Try to find an empty VLAN with the same tag/subnet as a VLAN that is full
|
||||||
for (VlanVO fullVlan : fullVlans) {
|
for (VlanVO fullVlan : fullVlans) {
|
||||||
for (VlanVO emptyVlan : emptyVlans) {
|
for (VlanVO emptyVlan : emptyVlans) {
|
||||||
if (fullVlan.getVlanTag().equals(emptyVlan.getVlanTag()) &&
|
if (fullVlan.getVlanTag().equals(emptyVlan.getVlanTag()) &&
|
||||||
fullVlan.getVlanGateway().equals(emptyVlan.getVlanGateway()) &&
|
fullVlan.getVlanGateway().equals(emptyVlan.getVlanGateway()) &&
|
||||||
fullVlan.getVlanNetmask().equals(emptyVlan.getVlanNetmask())) {
|
fullVlan.getVlanNetmask().equals(emptyVlan.getVlanNetmask())) {
|
||||||
return emptyVlan;
|
return emptyVlan;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a random empty VLAN
|
// Return a random empty VLAN
|
||||||
return emptyVlans.get(0);
|
return emptyVlans.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean zoneHasDirectAttachUntaggedVlans(long zoneId) {
|
public boolean zoneHasDirectAttachUntaggedVlans(long zoneId) {
|
||||||
SearchCriteria<VlanVO> sc = ZoneTypeAllPodsSearch.create();
|
SearchCriteria<VlanVO> sc = ZoneTypeAllPodsSearch.create();
|
||||||
sc.setParameters("zoneId", zoneId);
|
sc.setParameters("zoneId", zoneId);
|
||||||
sc.setParameters("vlanType", VlanType.DirectAttached);
|
sc.setParameters("vlanType", VlanType.DirectAttached);
|
||||||
|
|
||||||
return listIncludingRemovedBy(sc).size() > 0;
|
return listIncludingRemovedBy(sc).size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Pair<String, VlanVO> assignPodDirectAttachIpAddress(long zoneId,
|
public Pair<String, VlanVO> assignPodDirectAttachIpAddress(long zoneId,
|
||||||
long podId, long accountId, long domainId) {
|
long podId, long accountId, long domainId) {
|
||||||
SearchCriteria<VlanVO> sc = ZoneTypePodSearch.create();
|
SearchCriteria<VlanVO> sc = ZoneTypePodSearch.create();
|
||||||
sc.setParameters("zoneId", zoneId);
|
sc.setParameters("zoneId", zoneId);
|
||||||
sc.setParameters("vlanType", VlanType.DirectAttached);
|
sc.setParameters("vlanType", VlanType.DirectAttached);
|
||||||
sc.setJoinParameters("vlan", "podId", podId);
|
sc.setJoinParameters("vlan", "podId", podId);
|
||||||
|
|
||||||
VlanVO vlan = findOneIncludingRemovedBy(sc);
|
VlanVO vlan = findOneIncludingRemovedBy(sc);
|
||||||
if (vlan == null) {
|
if (vlan == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
// String ipAddress = _ipAddressDao.assignIpAddress(accountId, domainId, vlan.getId(), false).getAddress();
|
// String ipAddress = _ipAddressDao.assignIpAddress(accountId, domainId, vlan.getId(), false).getAddress();
|
||||||
// if (ipAddress == null) {
|
// if (ipAddress == null) {
|
||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
// return new Pair<String, VlanVO>(ipAddress, vlan);
|
// return new Pair<String, VlanVO>(ipAddress, vlan);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DB
|
@DB
|
||||||
public List<VlanVO> searchForZoneWideVlans(long dcId, String vlanType, String vlanId){
|
public List<VlanVO> searchForZoneWideVlans(long dcId, String vlanType, String vlanId){
|
||||||
|
|
||||||
StringBuilder sql = new StringBuilder(FindZoneWideVlans);
|
StringBuilder sql = new StringBuilder(FindZoneWideVlans);
|
||||||
|
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
try {
|
try {
|
||||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||||
pstmt.setLong(1, dcId);
|
pstmt.setLong(1, dcId);
|
||||||
pstmt.setString(2, vlanType);
|
pstmt.setString(2, vlanType);
|
||||||
pstmt.setString(3, vlanId);
|
pstmt.setString(3, vlanId);
|
||||||
|
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
List<VlanVO> zoneWideVlans = new ArrayList<VlanVO>();
|
List<VlanVO> zoneWideVlans = new ArrayList<VlanVO>();
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
zoneWideVlans.add(toEntityBean(rs, false));
|
zoneWideVlans.add(toEntityBean(rs, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
return zoneWideVlans;
|
return zoneWideVlans;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
|
throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VlanVO> listVlansByNetworkId(long networkOfferingId) {
|
public List<VlanVO> listVlansByNetworkId(long networkOfferingId) {
|
||||||
SearchCriteria<VlanVO> sc = NetworkVlanSearch.create();
|
SearchCriteria<VlanVO> sc = NetworkVlanSearch.create();
|
||||||
sc.setParameters("networkOfferingId", networkOfferingId);
|
sc.setParameters("networkOfferingId", networkOfferingId);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VlanVO> listVlansByPhysicalNetworkId(long physicalNetworkId) {
|
public List<VlanVO> listVlansByPhysicalNetworkId(long physicalNetworkId) {
|
||||||
SearchCriteria<VlanVO> sc = PhysicalNetworkVlanSearch.create();
|
SearchCriteria<VlanVO> sc = PhysicalNetworkVlanSearch.create();
|
||||||
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,6 @@ package com.cloud.deploy;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -74,7 +73,6 @@ import com.cloud.storage.dao.VolumeDao;
|
|||||||
import com.cloud.user.AccountManager;
|
import com.cloud.user.AccountManager;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.Adapters;
|
|
||||||
import com.cloud.vm.DiskProfile;
|
import com.cloud.vm.DiskProfile;
|
||||||
import com.cloud.vm.ReservationContext;
|
import com.cloud.vm.ReservationContext;
|
||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
@ -115,7 +113,7 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
|||||||
@Override
|
@Override
|
||||||
public DeployDestination plan(VirtualMachineProfile<? extends VirtualMachine> vmProfile,
|
public DeployDestination plan(VirtualMachineProfile<? extends VirtualMachine> vmProfile,
|
||||||
DeploymentPlan plan, ExcludeList avoid)
|
DeploymentPlan plan, ExcludeList avoid)
|
||||||
throws InsufficientServerCapacityException {
|
throws InsufficientServerCapacityException {
|
||||||
VirtualMachine vm = vmProfile.getVirtualMachine();
|
VirtualMachine vm = vmProfile.getVirtualMachine();
|
||||||
DataCenter dc = _dcDao.findById(vm.getDataCenterIdToDeployIn());
|
DataCenter dc = _dcDao.findById(vm.getDataCenterIdToDeployIn());
|
||||||
|
|
||||||
@ -313,7 +311,7 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
|||||||
}
|
}
|
||||||
podsWithCapacity.removeAll(disabledPods);
|
podsWithCapacity.removeAll(disabledPods);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("No pods found having a host with enough capacity, returning.");
|
s_logger.debug("No pods found having a host with enough capacity, returning.");
|
||||||
@ -438,10 +436,10 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map<Short,Float> getCapacityThresholdMap(){
|
private Map<Short,Float> getCapacityThresholdMap(){
|
||||||
// Lets build this real time so that the admin wont have to restart MS if he changes these values
|
// Lets build this real time so that the admin wont have to restart MS if he changes these values
|
||||||
Map<Short,Float> disableThresholdMap = new HashMap<Short, Float>();
|
Map<Short,Float> disableThresholdMap = new HashMap<Short, Float>();
|
||||||
|
|
||||||
String cpuDisableThresholdString = _configDao.getValue(Config.CPUCapacityDisableThreshold.key());
|
String cpuDisableThresholdString = _configDao.getValue(Config.CPUCapacityDisableThreshold.key());
|
||||||
float cpuDisableThreshold = NumbersUtil.parseFloat(cpuDisableThresholdString, 0.85F);
|
float cpuDisableThreshold = NumbersUtil.parseFloat(cpuDisableThresholdString, 0.85F);
|
||||||
disableThresholdMap.put(Capacity.CAPACITY_TYPE_CPU, cpuDisableThreshold);
|
disableThresholdMap.put(Capacity.CAPACITY_TYPE_CPU, cpuDisableThreshold);
|
||||||
|
|
||||||
@ -449,21 +447,21 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
|||||||
float memoryDisableThreshold = NumbersUtil.parseFloat(memoryDisableThresholdString, 0.85F);
|
float memoryDisableThreshold = NumbersUtil.parseFloat(memoryDisableThresholdString, 0.85F);
|
||||||
disableThresholdMap.put(Capacity.CAPACITY_TYPE_MEMORY, memoryDisableThreshold);
|
disableThresholdMap.put(Capacity.CAPACITY_TYPE_MEMORY, memoryDisableThreshold);
|
||||||
|
|
||||||
return disableThresholdMap;
|
return disableThresholdMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Short> getCapacitiesForCheckingThreshold(){
|
private List<Short> getCapacitiesForCheckingThreshold(){
|
||||||
List<Short> capacityList = new ArrayList<Short>();
|
List<Short> capacityList = new ArrayList<Short>();
|
||||||
capacityList.add(Capacity.CAPACITY_TYPE_CPU);
|
capacityList.add(Capacity.CAPACITY_TYPE_CPU);
|
||||||
capacityList.add(Capacity.CAPACITY_TYPE_MEMORY);
|
capacityList.add(Capacity.CAPACITY_TYPE_MEMORY);
|
||||||
return capacityList;
|
return capacityList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeClustersCrossingThreshold(List<Long> clusterListForVmAllocation, ExcludeList avoid, VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan){
|
private void removeClustersCrossingThreshold(List<Long> clusterListForVmAllocation, ExcludeList avoid, VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan){
|
||||||
|
|
||||||
Map<Short,Float> capacityThresholdMap = getCapacityThresholdMap();
|
Map<Short,Float> capacityThresholdMap = getCapacityThresholdMap();
|
||||||
List<Short> capacityList = getCapacitiesForCheckingThreshold();
|
List<Short> capacityList = getCapacitiesForCheckingThreshold();
|
||||||
List<Long> clustersCrossingThreshold = new ArrayList<Long>();
|
List<Long> clustersCrossingThreshold = new ArrayList<Long>();
|
||||||
|
|
||||||
ServiceOffering offering = vmProfile.getServiceOffering();
|
ServiceOffering offering = vmProfile.getServiceOffering();
|
||||||
int cpu_requested = offering.getCpu() * offering.getSpeed();
|
int cpu_requested = offering.getCpu() * offering.getSpeed();
|
||||||
@ -472,28 +470,28 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
|||||||
// For each capacity get the cluster list crossing the threshold and remove it from the clusterList that will be used for vm allocation.
|
// For each capacity get the cluster list crossing the threshold and remove it from the clusterList that will be used for vm allocation.
|
||||||
for(short capacity : capacityList){
|
for(short capacity : capacityList){
|
||||||
|
|
||||||
if (clusterListForVmAllocation == null || clusterListForVmAllocation.size() == 0){
|
if (clusterListForVmAllocation == null || clusterListForVmAllocation.size() == 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (capacity == Capacity.CAPACITY_TYPE_CPU){
|
if (capacity == Capacity.CAPACITY_TYPE_CPU){
|
||||||
clustersCrossingThreshold = _capacityDao.listClustersCrossingThreshold(Capacity.CAPACITY_TYPE_CPU, plan.getDataCenterId(),
|
clustersCrossingThreshold = _capacityDao.listClustersCrossingThreshold(Capacity.CAPACITY_TYPE_CPU, plan.getDataCenterId(),
|
||||||
capacityThresholdMap.get(capacity), cpu_requested, ApiDBUtils.getCpuOverprovisioningFactor());
|
capacityThresholdMap.get(capacity), cpu_requested, ApiDBUtils.getCpuOverprovisioningFactor());
|
||||||
}else{
|
}else{
|
||||||
clustersCrossingThreshold = _capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(),
|
clustersCrossingThreshold = _capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(),
|
||||||
capacityThresholdMap.get(capacity), ram_requested, 1.0f);//Mem overprov not supported yet
|
capacityThresholdMap.get(capacity), ram_requested, 1.0f);//Mem overprov not supported yet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (clustersCrossingThreshold != null && clustersCrossingThreshold.size() != 0){
|
if (clustersCrossingThreshold != null && clustersCrossingThreshold.size() != 0){
|
||||||
// addToAvoid Set
|
// addToAvoid Set
|
||||||
avoid.addClusterList(clustersCrossingThreshold);
|
avoid.addClusterList(clustersCrossingThreshold);
|
||||||
// Remove clusters crossing disabled threshold
|
// Remove clusters crossing disabled threshold
|
||||||
clusterListForVmAllocation.removeAll(clustersCrossingThreshold);
|
clusterListForVmAllocation.removeAll(clustersCrossingThreshold);
|
||||||
|
|
||||||
s_logger.debug("Cannot allocate cluster list " + clustersCrossingThreshold.toString() + " for vm creation since their allocated percentage" +
|
s_logger.debug("Cannot allocate cluster list " + clustersCrossingThreshold.toString() + " for vm creation since their allocated percentage" +
|
||||||
" crosses the disable capacity threshold: " + capacityThresholdMap.get(capacity) + " for capacity Type : " + capacity + ", skipping these clusters");
|
" crosses the disable capacity threshold: " + capacityThresholdMap.get(capacity) + " for capacity Type : " + capacity + ", skipping these clusters");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -801,8 +799,8 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
|||||||
// when deploying VM based on ISO, we have a service offering and an additional disk offering, use-local storage flag is actually
|
// when deploying VM based on ISO, we have a service offering and an additional disk offering, use-local storage flag is actually
|
||||||
// saved in service offering, overrde the flag from service offering when it is a ROOT disk
|
// saved in service offering, overrde the flag from service offering when it is a ROOT disk
|
||||||
if(!useLocalStorage && vmProfile.getServiceOffering().getUseLocalStorage()) {
|
if(!useLocalStorage && vmProfile.getServiceOffering().getUseLocalStorage()) {
|
||||||
if(toBeCreated.getVolumeType() == Volume.Type.ROOT)
|
if(toBeCreated.getVolumeType() == Volume.Type.ROOT)
|
||||||
useLocalStorage = true;
|
useLocalStorage = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
diskProfile.setUseLocalStorage(useLocalStorage);
|
diskProfile.setUseLocalStorage(useLocalStorage);
|
||||||
|
|||||||
@ -37,7 +37,6 @@ import com.cloud.agent.AgentManager;
|
|||||||
import com.cloud.alert.AlertManager;
|
import com.cloud.alert.AlertManager;
|
||||||
import com.cloud.cluster.ClusterManagerListener;
|
import com.cloud.cluster.ClusterManagerListener;
|
||||||
import com.cloud.cluster.ManagementServerHostVO;
|
import com.cloud.cluster.ManagementServerHostVO;
|
||||||
import com.cloud.cluster.StackMaid;
|
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.dc.ClusterDetailsDao;
|
import com.cloud.dc.ClusterDetailsDao;
|
||||||
@ -192,7 +191,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu
|
|||||||
|
|
||||||
if(host.getHypervisorType() == HypervisorType.VMware) {
|
if(host.getHypervisorType() == HypervisorType.VMware) {
|
||||||
s_logger.info("Don't restart for VMs on host " + host.getId() + " as the host is VMware host");
|
s_logger.info("Don't restart for VMs on host " + host.getId() + " as the host is VMware host");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_logger.warn("Scheduling restart for VMs on host " + host.getId());
|
s_logger.warn("Scheduling restart for VMs on host " + host.getId());
|
||||||
@ -268,28 +267,28 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scheduleRestart(VMInstanceVO vm, boolean investigate) {
|
public void scheduleRestart(VMInstanceVO vm, boolean investigate) {
|
||||||
Long hostId = vm.getHostId();
|
Long hostId = vm.getHostId();
|
||||||
if (hostId == null) {
|
if (hostId == null) {
|
||||||
try {
|
try {
|
||||||
s_logger.debug("Found a vm that is scheduled to be restarted but has no host id: " + vm);
|
s_logger.debug("Found a vm that is scheduled to be restarted but has no host id: " + vm);
|
||||||
_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||||
} catch (ResourceUnavailableException e) {
|
} catch (ResourceUnavailableException e) {
|
||||||
assert false : "How do we hit this when force is true?";
|
assert false : "How do we hit this when force is true?";
|
||||||
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
||||||
} catch (OperationTimedoutException e) {
|
} catch (OperationTimedoutException e) {
|
||||||
assert false : "How do we hit this when force is true?";
|
assert false : "How do we hit this when force is true?";
|
||||||
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
||||||
} catch (ConcurrentOperationException e) {
|
} catch (ConcurrentOperationException e) {
|
||||||
assert false : "How do we hit this when force is true?";
|
assert false : "How do we hit this when force is true?";
|
||||||
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(vm.getHypervisorType() == HypervisorType.VMware) {
|
if(vm.getHypervisorType() == HypervisorType.VMware) {
|
||||||
s_logger.info("Skip HA for VMware VM " + vm.getInstanceName());
|
s_logger.info("Skip HA for VMware VM " + vm.getInstanceName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!investigate) {
|
if (!investigate) {
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
@ -319,13 +318,13 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu
|
|||||||
_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||||
} catch (ResourceUnavailableException e) {
|
} catch (ResourceUnavailableException e) {
|
||||||
assert false : "How do we hit this when force is true?";
|
assert false : "How do we hit this when force is true?";
|
||||||
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
||||||
} catch (OperationTimedoutException e) {
|
} catch (OperationTimedoutException e) {
|
||||||
assert false : "How do we hit this when force is true?";
|
assert false : "How do we hit this when force is true?";
|
||||||
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
||||||
} catch (ConcurrentOperationException e) {
|
} catch (ConcurrentOperationException e) {
|
||||||
assert false : "How do we hit this when force is true?";
|
assert false : "How do we hit this when force is true?";
|
||||||
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +419,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu
|
|||||||
|
|
||||||
Investigator investigator = null;
|
Investigator investigator = null;
|
||||||
for(Investigator it : _investigators) {
|
for(Investigator it : _investigators) {
|
||||||
investigator = it;
|
investigator = it;
|
||||||
alive = investigator.isVmAlive(vm, host);
|
alive = investigator.isVmAlive(vm, host);
|
||||||
s_logger.info(investigator.getName() + " found " + vm + "to be alive? " + alive);
|
s_logger.info(investigator.getName() + " found " + vm + "to be alive? " + alive);
|
||||||
if (alive != null) {
|
if (alive != null) {
|
||||||
@ -464,13 +463,13 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu
|
|||||||
_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||||
} catch (ResourceUnavailableException e) {
|
} catch (ResourceUnavailableException e) {
|
||||||
assert false : "How do we hit this when force is true?";
|
assert false : "How do we hit this when force is true?";
|
||||||
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
||||||
} catch (OperationTimedoutException e) {
|
} catch (OperationTimedoutException e) {
|
||||||
assert false : "How do we hit this when force is true?";
|
assert false : "How do we hit this when force is true?";
|
||||||
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
||||||
} catch (ConcurrentOperationException e) {
|
} catch (ConcurrentOperationException e) {
|
||||||
assert false : "How do we hit this when force is true?";
|
assert false : "How do we hit this when force is true?";
|
||||||
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
work.setStep(Step.Scheduled);
|
work.setStep(Step.Scheduled);
|
||||||
@ -481,13 +480,13 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu
|
|||||||
_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||||
} catch (ResourceUnavailableException e) {
|
} catch (ResourceUnavailableException e) {
|
||||||
assert false : "How do we hit this when force is true?";
|
assert false : "How do we hit this when force is true?";
|
||||||
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
||||||
} catch (OperationTimedoutException e) {
|
} catch (OperationTimedoutException e) {
|
||||||
assert false : "How do we hit this when force is true?";
|
assert false : "How do we hit this when force is true?";
|
||||||
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
||||||
} catch (ConcurrentOperationException e) {
|
} catch (ConcurrentOperationException e) {
|
||||||
assert false : "How do we hit this when force is true?";
|
assert false : "How do we hit this when force is true?";
|
||||||
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -785,8 +784,6 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu
|
|||||||
_haDao.cleanup(System.currentTimeMillis() - _timeBetweenFailures);
|
_haDao.cleanup(System.currentTimeMillis() - _timeBetweenFailures);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.warn("Error while cleaning up", e);
|
s_logger.warn("Error while cleaning up", e);
|
||||||
} finally {
|
|
||||||
StackMaid.current().exitCleanup();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -832,7 +829,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu
|
|||||||
nextTime = destroyVM(work);
|
nextTime = destroyVM(work);
|
||||||
} else {
|
} else {
|
||||||
assert false : "How did we get here with " + wt.toString();
|
assert false : "How did we get here with " + wt.toString();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextTime == null) {
|
if (nextTime == null) {
|
||||||
@ -852,7 +849,6 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu
|
|||||||
} catch (final Throwable th) {
|
} catch (final Throwable th) {
|
||||||
s_logger.error("Caught this throwable, ", th);
|
s_logger.error("Caught this throwable, ", th);
|
||||||
} finally {
|
} finally {
|
||||||
StackMaid.current().exitCleanup();
|
|
||||||
if (work != null) {
|
if (work != null) {
|
||||||
NDC.pop();
|
NDC.pop();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,6 @@ import com.cloud.info.RunningHostCountInfo;
|
|||||||
import com.cloud.org.Managed;
|
import com.cloud.org.Managed;
|
||||||
import com.cloud.resource.ResourceState;
|
import com.cloud.resource.ResourceState;
|
||||||
import com.cloud.utils.DateUtil;
|
import com.cloud.utils.DateUtil;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.Attribute;
|
import com.cloud.utils.db.Attribute;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.Filter;
|
import com.cloud.utils.db.Filter;
|
||||||
@ -346,8 +345,8 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
public List<HostVO> findAndUpdateDirectAgentToLoad(long lastPingSecondsAfter, Long limit, long managementServerId) {
|
public List<HostVO> findAndUpdateDirectAgentToLoad(long lastPingSecondsAfter, Long limit, long managementServerId) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
SearchCriteria<HostVO> sc = UnmanagedDirectConnectSearch.create();
|
SearchCriteria<HostVO> sc = UnmanagedDirectConnectSearch.create();
|
||||||
sc.setParameters("lastPinged", lastPingSecondsAfter);
|
sc.setParameters("lastPinged", lastPingSecondsAfter);
|
||||||
//sc.setParameters("resourceStates", ResourceState.ErrorInMaintenance, ResourceState.Maintenance, ResourceState.PrepareForMaintenance, ResourceState.Disabled);
|
//sc.setParameters("resourceStates", ResourceState.ErrorInMaintenance, ResourceState.Maintenance, ResourceState.PrepareForMaintenance, ResourceState.Disabled);
|
||||||
sc.setJoinParameters("ClusterManagedSearch", "managed", Managed.ManagedState.Managed);
|
sc.setJoinParameters("ClusterManagedSearch", "managed", Managed.ManagedState.Managed);
|
||||||
List<HostVO> hosts = lockRows(sc, new Filter(HostVO.class, "clusterId", true, 0L, limit), true);
|
List<HostVO> hosts = lockRows(sc, new Filter(HostVO.class, "clusterId", true, 0L, limit), true);
|
||||||
@ -364,22 +363,22 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
public List<HostVO> findAndUpdateApplianceToLoad(long lastPingSecondsAfter, long managementServerId) {
|
public List<HostVO> findAndUpdateApplianceToLoad(long lastPingSecondsAfter, long managementServerId) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
|
|
||||||
txn.start();
|
txn.start();
|
||||||
SearchCriteria<HostVO> sc = UnmanagedApplianceSearch.create();
|
SearchCriteria<HostVO> sc = UnmanagedApplianceSearch.create();
|
||||||
sc.setParameters("lastPinged", lastPingSecondsAfter);
|
sc.setParameters("lastPinged", lastPingSecondsAfter);
|
||||||
sc.setParameters("types", Type.ExternalDhcp, Type.ExternalFirewall, Type.ExternalLoadBalancer, Type.PxeServer, Type.TrafficMonitor, Type.L2Networking);
|
sc.setParameters("types", Type.ExternalDhcp, Type.ExternalFirewall, Type.ExternalLoadBalancer, Type.PxeServer, Type.TrafficMonitor, Type.L2Networking);
|
||||||
List<HostVO> hosts = lockRows(sc, null, true);
|
List<HostVO> hosts = lockRows(sc, null, true);
|
||||||
|
|
||||||
for (HostVO host : hosts) {
|
for (HostVO host : hosts) {
|
||||||
host.setManagementServerId(managementServerId);
|
host.setManagementServerId(managementServerId);
|
||||||
update(host.getId(), host);
|
update(host.getId(), host);
|
||||||
}
|
}
|
||||||
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|
||||||
return hosts;
|
return hosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -653,80 +652,80 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateState(Status oldStatus, Event event, Status newStatus, Host vo, Object data) {
|
public boolean updateState(Status oldStatus, Event event, Status newStatus, Host vo, Object data) {
|
||||||
HostVO host = findById(vo.getId());
|
HostVO host = findById(vo.getId());
|
||||||
long oldPingTime = host.getLastPinged();
|
long oldPingTime = host.getLastPinged();
|
||||||
|
|
||||||
SearchBuilder<HostVO> sb = createSearchBuilder();
|
SearchBuilder<HostVO> sb = createSearchBuilder();
|
||||||
sb.and("status", sb.entity().getStatus(), SearchCriteria.Op.EQ);
|
sb.and("status", sb.entity().getStatus(), SearchCriteria.Op.EQ);
|
||||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||||
sb.and("update", sb.entity().getUpdated(), SearchCriteria.Op.EQ);
|
sb.and("update", sb.entity().getUpdated(), SearchCriteria.Op.EQ);
|
||||||
if (newStatus.checkManagementServer()) {
|
if (newStatus.checkManagementServer()) {
|
||||||
sb.and("ping", sb.entity().getLastPinged(), SearchCriteria.Op.EQ);
|
sb.and("ping", sb.entity().getLastPinged(), SearchCriteria.Op.EQ);
|
||||||
sb.and().op("nullmsid", sb.entity().getManagementServerId(), SearchCriteria.Op.NULL);
|
sb.and().op("nullmsid", sb.entity().getManagementServerId(), SearchCriteria.Op.NULL);
|
||||||
sb.or("msid", sb.entity().getManagementServerId(), SearchCriteria.Op.EQ);
|
sb.or("msid", sb.entity().getManagementServerId(), SearchCriteria.Op.EQ);
|
||||||
sb.closeParen();
|
sb.closeParen();
|
||||||
}
|
}
|
||||||
sb.done();
|
sb.done();
|
||||||
|
|
||||||
SearchCriteria<HostVO> sc = sb.create();
|
SearchCriteria<HostVO> sc = sb.create();
|
||||||
|
|
||||||
sc.setParameters("status", oldStatus);
|
sc.setParameters("status", oldStatus);
|
||||||
sc.setParameters("id", host.getId());
|
sc.setParameters("id", host.getId());
|
||||||
sc.setParameters("update", host.getUpdated());
|
sc.setParameters("update", host.getUpdated());
|
||||||
long oldUpdateCount = host.getUpdated();
|
long oldUpdateCount = host.getUpdated();
|
||||||
if (newStatus.checkManagementServer()) {
|
if (newStatus.checkManagementServer()) {
|
||||||
sc.setParameters("ping", oldPingTime);
|
sc.setParameters("ping", oldPingTime);
|
||||||
sc.setParameters("msid", host.getManagementServerId());
|
sc.setParameters("msid", host.getManagementServerId());
|
||||||
}
|
}
|
||||||
|
|
||||||
long newUpdateCount = host.incrUpdated();
|
long newUpdateCount = host.incrUpdated();
|
||||||
UpdateBuilder ub = getUpdateBuilder(host);
|
UpdateBuilder ub = getUpdateBuilder(host);
|
||||||
ub.set(host, _statusAttr, newStatus);
|
ub.set(host, _statusAttr, newStatus);
|
||||||
if (newStatus.updateManagementServer()) {
|
if (newStatus.updateManagementServer()) {
|
||||||
if (newStatus.lostConnection()) {
|
if (newStatus.lostConnection()) {
|
||||||
ub.set(host, _msIdAttr, null);
|
ub.set(host, _msIdAttr, null);
|
||||||
} else {
|
} else {
|
||||||
ub.set(host, _msIdAttr, host.getManagementServerId());
|
ub.set(host, _msIdAttr, host.getManagementServerId());
|
||||||
}
|
}
|
||||||
if (event.equals(Event.Ping) || event.equals(Event.AgentConnected)) {
|
if (event.equals(Event.Ping) || event.equals(Event.AgentConnected)) {
|
||||||
ub.set(host, _pingTimeAttr, System.currentTimeMillis() >> 10);
|
ub.set(host, _pingTimeAttr, System.currentTimeMillis() >> 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.equals(Event.ManagementServerDown)) {
|
if (event.equals(Event.ManagementServerDown)) {
|
||||||
ub.set(host, _pingTimeAttr, ((System.currentTimeMillis() >> 10) - (10 * 60)));
|
ub.set(host, _pingTimeAttr, ((System.currentTimeMillis() >> 10) - (10 * 60)));
|
||||||
}
|
}
|
||||||
int result = update(ub, sc, null);
|
int result = update(ub, sc, null);
|
||||||
assert result <= 1 : "How can this update " + result + " rows? ";
|
assert result <= 1 : "How can this update " + result + " rows? ";
|
||||||
|
|
||||||
if (status_logger.isDebugEnabled() && result == 0) {
|
if (status_logger.isDebugEnabled() && result == 0) {
|
||||||
HostVO ho = findById(host.getId());
|
HostVO ho = findById(host.getId());
|
||||||
assert ho != null : "How how how? : " + host.getId();
|
assert ho != null : "How how how? : " + host.getId();
|
||||||
|
|
||||||
StringBuilder str = new StringBuilder("Unable to update host for event:").append(event.toString());
|
StringBuilder str = new StringBuilder("Unable to update host for event:").append(event.toString());
|
||||||
str.append(". Name=").append(host.getName());
|
str.append(". Name=").append(host.getName());
|
||||||
str.append("; New=[status=").append(newStatus.toString()).append(":msid=")
|
str.append("; New=[status=").append(newStatus.toString()).append(":msid=")
|
||||||
.append(newStatus.lostConnection() ? "null" : host.getManagementServerId()).append(":lastpinged=").append(host.getLastPinged()).append("]");
|
.append(newStatus.lostConnection() ? "null" : host.getManagementServerId()).append(":lastpinged=").append(host.getLastPinged()).append("]");
|
||||||
str.append("; Old=[status=").append(oldStatus.toString()).append(":msid=").append(host.getManagementServerId()).append(":lastpinged=")
|
str.append("; Old=[status=").append(oldStatus.toString()).append(":msid=").append(host.getManagementServerId()).append(":lastpinged=")
|
||||||
.append(oldPingTime).append("]");
|
.append(oldPingTime).append("]");
|
||||||
str.append("; DB=[status=").append(vo.getStatus().toString()).append(":msid=").append(vo.getManagementServerId()).append(":lastpinged=")
|
str.append("; DB=[status=").append(vo.getStatus().toString()).append(":msid=").append(vo.getManagementServerId()).append(":lastpinged=")
|
||||||
.append(vo.getLastPinged()).append(":old update count=").append(oldUpdateCount).append("]");
|
.append(vo.getLastPinged()).append(":old update count=").append(oldUpdateCount).append("]");
|
||||||
status_logger.debug(str.toString());
|
status_logger.debug(str.toString());
|
||||||
} else {
|
} else {
|
||||||
StringBuilder msg = new StringBuilder("Agent status update: [");
|
StringBuilder msg = new StringBuilder("Agent status update: [");
|
||||||
msg.append("id = " + host.getId());
|
msg.append("id = " + host.getId());
|
||||||
msg.append("; name = " + host.getName());
|
msg.append("; name = " + host.getName());
|
||||||
msg.append("; old status = " + oldStatus);
|
msg.append("; old status = " + oldStatus);
|
||||||
msg.append("; event = " + event);
|
msg.append("; event = " + event);
|
||||||
msg.append("; new status = " + newStatus);
|
msg.append("; new status = " + newStatus);
|
||||||
msg.append("; old update count = " + oldUpdateCount);
|
msg.append("; old update count = " + oldUpdateCount);
|
||||||
msg.append("; new update count = " + newUpdateCount + "]");
|
msg.append("; new update count = " + newUpdateCount + "]");
|
||||||
status_logger.debug(msg.toString());
|
status_logger.debug(msg.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result > 0;
|
return result > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateResourceState(ResourceState oldState, ResourceState.Event event, ResourceState newState, Host vo) {
|
public boolean updateResourceState(ResourceState oldState, ResourceState.Event event, ResourceState newState, Host vo) {
|
||||||
@ -751,20 +750,20 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
assert ho != null : "How how how? : " + host.getId();
|
assert ho != null : "How how how? : " + host.getId();
|
||||||
|
|
||||||
StringBuilder str = new StringBuilder("Unable to update resource state: [");
|
StringBuilder str = new StringBuilder("Unable to update resource state: [");
|
||||||
str.append("m = " + host.getId());
|
str.append("m = " + host.getId());
|
||||||
str.append("; name = " + host.getName());
|
str.append("; name = " + host.getName());
|
||||||
str.append("; old state = " + oldState);
|
str.append("; old state = " + oldState);
|
||||||
str.append("; event = " + event);
|
str.append("; event = " + event);
|
||||||
str.append("; new state = " + newState + "]");
|
str.append("; new state = " + newState + "]");
|
||||||
state_logger.debug(str.toString());
|
state_logger.debug(str.toString());
|
||||||
} else {
|
} else {
|
||||||
StringBuilder msg = new StringBuilder("Resource state update: [");
|
StringBuilder msg = new StringBuilder("Resource state update: [");
|
||||||
msg.append("id = " + host.getId());
|
msg.append("id = " + host.getId());
|
||||||
msg.append("; name = " + host.getName());
|
msg.append("; name = " + host.getName());
|
||||||
msg.append("; old state = " + oldState);
|
msg.append("; old state = " + oldState);
|
||||||
msg.append("; event = " + event);
|
msg.append("; event = " + event);
|
||||||
msg.append("; new state = " + newState + "]");
|
msg.append("; new state = " + newState + "]");
|
||||||
state_logger.debug(msg.toString());
|
state_logger.debug(msg.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result > 0;
|
return result > 0;
|
||||||
@ -779,15 +778,15 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
return findOneBy(sc);
|
return findOneBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HostVO> findHypervisorHostInCluster(long clusterId) {
|
public List<HostVO> findHypervisorHostInCluster(long clusterId) {
|
||||||
SearchCriteria<HostVO> sc = TypeClusterStatusSearch.create();
|
SearchCriteria<HostVO> sc = TypeClusterStatusSearch.create();
|
||||||
sc.setParameters("type", Host.Type.Routing);
|
sc.setParameters("type", Host.Type.Routing);
|
||||||
sc.setParameters("cluster", clusterId);
|
sc.setParameters("cluster", clusterId);
|
||||||
sc.setParameters("status", Status.Up);
|
sc.setParameters("status", Status.Up);
|
||||||
sc.setParameters("resourceState", ResourceState.Enabled);
|
sc.setParameters("resourceState", ResourceState.Enabled);
|
||||||
|
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,8 +33,6 @@ import com.cloud.host.Host;
|
|||||||
import com.cloud.host.HostVO;
|
import com.cloud.host.HostVO;
|
||||||
import com.cloud.host.dao.HostDao;
|
import com.cloud.host.dao.HostDao;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.utils.component.Adapters;
|
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Local(value = { HypervisorGuruManager.class } )
|
@Local(value = { HypervisorGuruManager.class } )
|
||||||
@ -43,53 +41,55 @@ public class HypervisorGuruManagerImpl implements HypervisorGuruManager {
|
|||||||
|
|
||||||
@Inject HostDao _hostDao;
|
@Inject HostDao _hostDao;
|
||||||
|
|
||||||
String _name;
|
String _name;
|
||||||
|
|
||||||
@Inject List<HypervisorGuru> _hvGuruList;
|
@Inject List<HypervisorGuru> _hvGuruList;
|
||||||
Map<HypervisorType, HypervisorGuru> _hvGurus = new HashMap<HypervisorType, HypervisorGuru>();
|
Map<HypervisorType, HypervisorGuru> _hvGurus = new HashMap<HypervisorType, HypervisorGuru>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||||
_name = name;
|
_name = name;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
for(HypervisorGuru guru : _hvGuruList) {
|
for(HypervisorGuru guru : _hvGuruList) {
|
||||||
_hvGurus.put(guru.getHypervisorType(), guru);
|
_hvGurus.put(guru.getHypervisorType(), guru);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean start() {
|
public boolean start() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stop() {
|
public boolean stop() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HypervisorGuru getGuru(HypervisorType hypervisorType) {
|
@Override
|
||||||
return _hvGurus.get(hypervisorType);
|
public HypervisorGuru getGuru(HypervisorType hypervisorType) {
|
||||||
}
|
return _hvGurus.get(hypervisorType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public long getGuruProcessedCommandTargetHost(long hostId, Command cmd) {
|
public long getGuruProcessedCommandTargetHost(long hostId, Command cmd) {
|
||||||
HostVO hostVo = _hostDao.findById(hostId);
|
HostVO hostVo = _hostDao.findById(hostId);
|
||||||
HypervisorGuru hvGuru = null;
|
HypervisorGuru hvGuru = null;
|
||||||
if(hostVo.getType() == Host.Type.Routing) {
|
if(hostVo.getType() == Host.Type.Routing) {
|
||||||
hvGuru = _hvGurus.get(hostVo.getHypervisorType());
|
hvGuru = _hvGurus.get(hostVo.getHypervisorType());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hvGuru != null)
|
if(hvGuru != null)
|
||||||
return hvGuru.getCommandHostDelegation(hostId, cmd);
|
return hvGuru.getCommandHostDelegation(hostId, cmd);
|
||||||
|
|
||||||
return hostId;
|
return hostId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,15 +36,14 @@ import javax.naming.ConfigurationException;
|
|||||||
|
|
||||||
import org.apache.commons.httpclient.HttpClient;
|
import org.apache.commons.httpclient.HttpClient;
|
||||||
import org.apache.commons.httpclient.HttpException;
|
import org.apache.commons.httpclient.HttpException;
|
||||||
import org.apache.commons.httpclient.methods.GetMethod;
|
|
||||||
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
|
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
|
||||||
|
import org.apache.commons.httpclient.methods.GetMethod;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.maint.dao.AgentUpgradeDao;
|
import com.cloud.maint.dao.AgentUpgradeDao;
|
||||||
import com.cloud.utils.PropertiesUtil;
|
import com.cloud.utils.PropertiesUtil;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -57,7 +56,7 @@ import com.cloud.utils.component.ComponentLocator;
|
|||||||
@Component
|
@Component
|
||||||
@Local(UpgradeManager.class)
|
@Local(UpgradeManager.class)
|
||||||
public class UpgradeManagerImpl implements UpgradeManager {
|
public class UpgradeManagerImpl implements UpgradeManager {
|
||||||
private final static Logger s_logger = Logger.getLogger(UpgradeManagerImpl.class);
|
private final static Logger s_logger = Logger.getLogger(UpgradeManagerImpl.class);
|
||||||
private static final MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager();
|
private static final MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager();
|
||||||
|
|
||||||
String _name;
|
String _name;
|
||||||
@ -90,7 +89,7 @@ public class UpgradeManagerImpl implements UpgradeManager {
|
|||||||
_upgradeDao.persist(vo);
|
_upgradeDao.persist(vo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@ -132,11 +131,11 @@ public class UpgradeManagerImpl implements UpgradeManager {
|
|||||||
|
|
||||||
s_logger.debug("New Agent zip file is now retrieved");
|
s_logger.debug("New Agent zip file is now retrieved");
|
||||||
} catch (final HttpException e) {
|
} catch (final HttpException e) {
|
||||||
return "Unable to retrieve the file from " + url;
|
return "Unable to retrieve the file from " + url;
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
return "Unable to retrieve the file from " + url;
|
return "Unable to retrieve the file from " + url;
|
||||||
} finally {
|
} finally {
|
||||||
method.releaseConnection();
|
method.releaseConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
file.delete();
|
file.delete();
|
||||||
|
|||||||
@ -19,9 +19,7 @@ package com.cloud.migration;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@ -32,21 +30,17 @@ import com.cloud.configuration.Resource.ResourceType;
|
|||||||
import com.cloud.configuration.ResourceCountVO;
|
import com.cloud.configuration.ResourceCountVO;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.configuration.dao.ResourceCountDao;
|
import com.cloud.configuration.dao.ResourceCountDao;
|
||||||
import com.cloud.dc.ClusterVO;
|
|
||||||
import com.cloud.dc.DataCenter.NetworkType;
|
import com.cloud.dc.DataCenter.NetworkType;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.dc.dao.ClusterDao;
|
import com.cloud.dc.dao.ClusterDao;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.domain.DomainVO;
|
||||||
import com.cloud.domain.dao.DomainDao;
|
import com.cloud.domain.dao.DomainDao;
|
||||||
import com.cloud.host.HostVO;
|
|
||||||
import com.cloud.host.dao.HostDao;
|
import com.cloud.host.dao.HostDao;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
|
||||||
import com.cloud.resource.ResourceManager;
|
import com.cloud.resource.ResourceManager;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.user.dao.AccountDao;
|
import com.cloud.user.dao.AccountDao;
|
||||||
import com.cloud.utils.PropertiesUtil;
|
import com.cloud.utils.PropertiesUtil;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
@ -57,16 +51,16 @@ import com.cloud.vm.dao.InstanceGroupVMMapDao;
|
|||||||
|
|
||||||
public class Db21to22MigrationUtil {
|
public class Db21to22MigrationUtil {
|
||||||
|
|
||||||
@Inject private ClusterDao _clusterDao;
|
@Inject private ClusterDao _clusterDao;
|
||||||
@Inject private HostDao _hostDao;
|
@Inject private HostDao _hostDao;
|
||||||
@Inject private AccountDao _accountDao;
|
@Inject private AccountDao _accountDao;
|
||||||
@Inject private DomainDao _domainDao;
|
@Inject private DomainDao _domainDao;
|
||||||
@Inject private ResourceCountDao _resourceCountDao;
|
@Inject private ResourceCountDao _resourceCountDao;
|
||||||
@Inject private InstanceGroupDao _vmGroupDao;
|
@Inject private InstanceGroupDao _vmGroupDao;
|
||||||
@Inject private InstanceGroupVMMapDao _groupVMMapDao;
|
@Inject private InstanceGroupVMMapDao _groupVMMapDao;
|
||||||
@Inject private ConfigurationDao _configurationDao;
|
@Inject private ConfigurationDao _configurationDao;
|
||||||
@Inject private DataCenterDao _zoneDao;
|
@Inject private DataCenterDao _zoneDao;
|
||||||
@Inject private ResourceManager _resourceMgr;
|
@Inject private ResourceManager _resourceMgr;
|
||||||
|
|
||||||
private void doMigration() {
|
private void doMigration() {
|
||||||
setupComponents();
|
setupComponents();
|
||||||
@ -85,8 +79,8 @@ public class Db21to22MigrationUtil {
|
|||||||
/* add guid in cluster table */
|
/* add guid in cluster table */
|
||||||
private void setupClusterGuid() {
|
private void setupClusterGuid() {
|
||||||
|
|
||||||
//FIXME moving out XenServer code out of server. This upgrade step need to be taken care of
|
//FIXME moving out XenServer code out of server. This upgrade step need to be taken care of
|
||||||
/*
|
/*
|
||||||
XenServerConnectionPool _connPool = XenServerConnectionPool.getInstance();
|
XenServerConnectionPool _connPool = XenServerConnectionPool.getInstance();
|
||||||
List<ClusterVO> clusters = _clusterDao.listByHyTypeWithoutGuid(HypervisorType.XenServer.toString());
|
List<ClusterVO> clusters = _clusterDao.listByHyTypeWithoutGuid(HypervisorType.XenServer.toString());
|
||||||
for (ClusterVO cluster : clusters) {
|
for (ClusterVO cluster : clusters) {
|
||||||
@ -120,7 +114,7 @@ public class Db21to22MigrationUtil {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -129,23 +123,23 @@ public class Db21to22MigrationUtil {
|
|||||||
* based on the param direct.attach.untagged.vlan.enabled, we update zone to basic or advanced for 2.2
|
* based on the param direct.attach.untagged.vlan.enabled, we update zone to basic or advanced for 2.2
|
||||||
*/
|
*/
|
||||||
private void migrateZones(){
|
private void migrateZones(){
|
||||||
try {
|
try {
|
||||||
System.out.println("Migrating zones");
|
System.out.println("Migrating zones");
|
||||||
String val = _configurationDao.getValue("direct.attach.untagged.vlan.enabled");
|
String val = _configurationDao.getValue("direct.attach.untagged.vlan.enabled");
|
||||||
NetworkType networkType;
|
NetworkType networkType;
|
||||||
if(val == null || val.equalsIgnoreCase("true")){
|
if(val == null || val.equalsIgnoreCase("true")){
|
||||||
networkType = NetworkType.Basic;
|
networkType = NetworkType.Basic;
|
||||||
}else{
|
}else{
|
||||||
networkType = NetworkType.Advanced;
|
networkType = NetworkType.Advanced;
|
||||||
}
|
}
|
||||||
List<DataCenterVO> existingZones = _zoneDao.listAll();
|
List<DataCenterVO> existingZones = _zoneDao.listAll();
|
||||||
for(DataCenterVO zone : existingZones){
|
for(DataCenterVO zone : existingZones){
|
||||||
zone.setNetworkType(networkType);
|
zone.setNetworkType(networkType);
|
||||||
_zoneDao.update(zone.getId(), zone);
|
_zoneDao.update(zone.getId(), zone);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Unhandled exception in migrateZones()" + e);
|
System.out.println("Unhandled exception in migrateZones()" + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void migrateResourceCounts() {
|
private void migrateResourceCounts() {
|
||||||
@ -177,44 +171,44 @@ public class Db21to22MigrationUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupInstanceGroups() {
|
private void setupInstanceGroups() {
|
||||||
System.out.println("setting up vm instance groups");
|
System.out.println("setting up vm instance groups");
|
||||||
|
|
||||||
//Search for all the vms that have not null groups
|
//Search for all the vms that have not null groups
|
||||||
Long vmId = 0L;
|
Long vmId = 0L;
|
||||||
Long accountId = 0L;
|
Long accountId = 0L;
|
||||||
String groupName;
|
String groupName;
|
||||||
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
||||||
txn.start();
|
txn.start();
|
||||||
try {
|
try {
|
||||||
String request = "SELECT vm.id, uservm.account_id, vm.group from vm_instance vm, user_vm uservm where vm.group is not null and vm.removed is null and vm.id=uservm.id order by id";
|
String request = "SELECT vm.id, uservm.account_id, vm.group from vm_instance vm, user_vm uservm where vm.group is not null and vm.removed is null and vm.id=uservm.id order by id";
|
||||||
System.out.println(request);
|
System.out.println(request);
|
||||||
PreparedStatement statement = txn.prepareStatement(request);
|
PreparedStatement statement = txn.prepareStatement(request);
|
||||||
ResultSet result = statement.executeQuery();
|
ResultSet result = statement.executeQuery();
|
||||||
while (result.next()) {
|
while (result.next()) {
|
||||||
vmId = result.getLong(1);
|
vmId = result.getLong(1);
|
||||||
accountId = result.getLong(2);
|
accountId = result.getLong(2);
|
||||||
groupName = result.getString(3);
|
groupName = result.getString(3);
|
||||||
InstanceGroupVO group = _vmGroupDao.findByAccountAndName(accountId, groupName);
|
InstanceGroupVO group = _vmGroupDao.findByAccountAndName(accountId, groupName);
|
||||||
//Create vm group if the group doesn't exist for this account
|
//Create vm group if the group doesn't exist for this account
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
group = new InstanceGroupVO(groupName, accountId);
|
group = new InstanceGroupVO(groupName, accountId);
|
||||||
group = _vmGroupDao.persist(group);
|
group = _vmGroupDao.persist(group);
|
||||||
System.out.println("Created new isntance group with name " + groupName + " for account id=" + accountId);
|
System.out.println("Created new isntance group with name " + groupName + " for account id=" + accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
InstanceGroupVMMapVO groupVmMapVO = new InstanceGroupVMMapVO(group.getId(), vmId);
|
InstanceGroupVMMapVO groupVmMapVO = new InstanceGroupVMMapVO(group.getId(), vmId);
|
||||||
_groupVMMapDao.persist(groupVmMapVO);
|
_groupVMMapDao.persist(groupVmMapVO);
|
||||||
System.out.println("Assigned vm id=" + vmId + " to group with name " + groupName + " for account id=" + accountId);
|
System.out.println("Assigned vm id=" + vmId + " to group with name " + groupName + " for account id=" + accountId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txn.commit();
|
txn.commit();
|
||||||
statement.close();
|
statement.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Unhandled exception: " + e);
|
System.out.println("Unhandled exception: " + e);
|
||||||
} finally {
|
} finally {
|
||||||
txn.close();
|
txn.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,6 @@ package com.cloud.network;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
@ -33,136 +32,135 @@ import org.apache.log4j.Logger;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
|
|
||||||
import com.cloud.dc.dao.VlanDao;
|
import com.cloud.dc.dao.VlanDao;
|
||||||
import com.cloud.network.dao.IPAddressDao;
|
import com.cloud.network.dao.IPAddressDao;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Local(value=IpAddrAllocator.class)
|
@Local(value=IpAddrAllocator.class)
|
||||||
public class ExteralIpAddressAllocator implements IpAddrAllocator{
|
public class ExteralIpAddressAllocator implements IpAddrAllocator{
|
||||||
private static final Logger s_logger = Logger.getLogger(ExteralIpAddressAllocator.class);
|
private static final Logger s_logger = Logger.getLogger(ExteralIpAddressAllocator.class);
|
||||||
String _name;
|
String _name;
|
||||||
@Inject ConfigurationDao _configDao = null;
|
@Inject ConfigurationDao _configDao = null;
|
||||||
@Inject IPAddressDao _ipAddressDao = null;
|
@Inject IPAddressDao _ipAddressDao = null;
|
||||||
@Inject VlanDao _vlanDao;
|
@Inject VlanDao _vlanDao;
|
||||||
private boolean _isExternalIpAllocatorEnabled = false;
|
private boolean _isExternalIpAllocatorEnabled = false;
|
||||||
private String _externalIpAllocatorUrl = null;
|
private String _externalIpAllocatorUrl = null;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IpAddr getPrivateIpAddress(String macAddr, long dcId, long podId) {
|
public IpAddr getPrivateIpAddress(String macAddr, long dcId, long podId) {
|
||||||
if (_externalIpAllocatorUrl == null || this._externalIpAllocatorUrl.equalsIgnoreCase("")) {
|
if (_externalIpAllocatorUrl == null || this._externalIpAllocatorUrl.equalsIgnoreCase("")) {
|
||||||
return new IpAddr();
|
return new IpAddr();
|
||||||
}
|
}
|
||||||
String urlString = this._externalIpAllocatorUrl + "?command=getIpAddr&mac=" + macAddr + "&dc=" + dcId + "&pod=" + podId;
|
String urlString = this._externalIpAllocatorUrl + "?command=getIpAddr&mac=" + macAddr + "&dc=" + dcId + "&pod=" + podId;
|
||||||
s_logger.debug("getIP:" + urlString);
|
s_logger.debug("getIP:" + urlString);
|
||||||
|
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
try {
|
try {
|
||||||
URL url = new URL(urlString);
|
URL url = new URL(urlString);
|
||||||
URLConnection conn = url.openConnection();
|
URLConnection conn = url.openConnection();
|
||||||
conn.setReadTimeout(30000);
|
conn.setReadTimeout(30000);
|
||||||
|
|
||||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||||
String inputLine;
|
String inputLine;
|
||||||
while ((inputLine = in.readLine()) != null) {
|
while ((inputLine = in.readLine()) != null) {
|
||||||
s_logger.debug(inputLine);
|
s_logger.debug(inputLine);
|
||||||
String[] tokens = inputLine.split(",");
|
String[] tokens = inputLine.split(",");
|
||||||
if (tokens.length != 3) {
|
if (tokens.length != 3) {
|
||||||
s_logger.debug("the return value should be: mac,netmask,gateway");
|
s_logger.debug("the return value should be: mac,netmask,gateway");
|
||||||
return new IpAddr();
|
return new IpAddr();
|
||||||
}
|
}
|
||||||
return new IpAddr(tokens[0], tokens[1], tokens[2]);
|
return new IpAddr(tokens[0], tokens[1], tokens[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new IpAddr();
|
return new IpAddr();
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
throw new CloudRuntimeException("URL is malformed " + urlString, e);
|
throw new CloudRuntimeException("URL is malformed " + urlString, e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return new IpAddr();
|
return new IpAddr();
|
||||||
} finally {
|
} finally {
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
try {
|
try {
|
||||||
in.close();
|
in.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IpAddr getPublicIpAddress(String macAddr, long dcId, long podId) {
|
public IpAddr getPublicIpAddress(String macAddr, long dcId, long podId) {
|
||||||
/*TODO: call API to get ip address from external DHCP server*/
|
/*TODO: call API to get ip address from external DHCP server*/
|
||||||
return getPrivateIpAddress(macAddr, dcId, podId);
|
return getPrivateIpAddress(macAddr, dcId, podId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean releasePrivateIpAddress(String ip, long dcId, long podId) {
|
public boolean releasePrivateIpAddress(String ip, long dcId, long podId) {
|
||||||
/*TODO: call API to release the ip address from external DHCP server*/
|
/*TODO: call API to release the ip address from external DHCP server*/
|
||||||
if (_externalIpAllocatorUrl == null || this._externalIpAllocatorUrl.equalsIgnoreCase("")) {
|
if (_externalIpAllocatorUrl == null || this._externalIpAllocatorUrl.equalsIgnoreCase("")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String urlString = this._externalIpAllocatorUrl + "?command=releaseIpAddr&ip=" + ip + "&dc=" + dcId + "&pod=" + podId;
|
String urlString = this._externalIpAllocatorUrl + "?command=releaseIpAddr&ip=" + ip + "&dc=" + dcId + "&pod=" + podId;
|
||||||
|
|
||||||
s_logger.debug("releaseIP:" + urlString);
|
s_logger.debug("releaseIP:" + urlString);
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
try {
|
try {
|
||||||
URL url = new URL(urlString);
|
URL url = new URL(urlString);
|
||||||
URLConnection conn = url.openConnection();
|
URLConnection conn = url.openConnection();
|
||||||
conn.setReadTimeout(30000);
|
conn.setReadTimeout(30000);
|
||||||
|
|
||||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
throw new CloudRuntimeException("URL is malformed " + urlString, e);
|
throw new CloudRuntimeException("URL is malformed " + urlString, e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
try {
|
try {
|
||||||
in.close();
|
in.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean releasePublicIpAddress(String ip, long dcId, long podId) {
|
public boolean releasePublicIpAddress(String ip, long dcId, long podId) {
|
||||||
/*TODO: call API to release the ip address from external DHCP server*/
|
/*TODO: call API to release the ip address from external DHCP server*/
|
||||||
return releasePrivateIpAddress(ip, dcId, podId);
|
return releasePrivateIpAddress(ip, dcId, podId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean exteralIpAddressAllocatorEnabled() {
|
@Override
|
||||||
return _isExternalIpAllocatorEnabled;
|
public boolean exteralIpAddressAllocatorEnabled() {
|
||||||
}
|
return _isExternalIpAllocatorEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||||
_isExternalIpAllocatorEnabled = Boolean.parseBoolean(_configDao.getValue("direct.attach.network.externalIpAllocator.enabled"));
|
_isExternalIpAllocatorEnabled = Boolean.parseBoolean(_configDao.getValue("direct.attach.network.externalIpAllocator.enabled"));
|
||||||
_externalIpAllocatorUrl = _configDao.getValue("direct.attach.network.externalIpAllocator.url");
|
_externalIpAllocatorUrl = _configDao.getValue("direct.attach.network.externalIpAllocator.url");
|
||||||
_name = name;
|
_name = name;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean start() {
|
public boolean start() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stop() {
|
public boolean stop() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,22 +27,21 @@ import javax.ejb.Local;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.api.ApiConstants;
|
||||||
import org.apache.cloudstack.api.command.admin.network.AddNetworkDeviceCmd;
|
import org.apache.cloudstack.api.command.admin.network.AddNetworkDeviceCmd;
|
||||||
|
import org.apache.cloudstack.api.command.admin.network.DeleteNetworkDeviceCmd;
|
||||||
import org.apache.cloudstack.api.command.admin.network.ListNetworkDeviceCmd;
|
import org.apache.cloudstack.api.command.admin.network.ListNetworkDeviceCmd;
|
||||||
|
import org.apache.cloudstack.api.response.NetworkDeviceResponse;
|
||||||
import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
|
import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.agent.AgentManager;
|
import com.cloud.agent.AgentManager;
|
||||||
import com.cloud.api.ApiDBUtils;
|
import com.cloud.api.ApiDBUtils;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.IdentityService;
|
|
||||||
import org.apache.cloudstack.api.command.admin.network.DeleteNetworkDeviceCmd;
|
|
||||||
import com.cloud.baremetal.ExternalDhcpManager;
|
import com.cloud.baremetal.ExternalDhcpManager;
|
||||||
import com.cloud.baremetal.PxeServerManager;
|
import com.cloud.baremetal.PxeServerManager;
|
||||||
import com.cloud.baremetal.PxeServerProfile;
|
|
||||||
import com.cloud.baremetal.PxeServerManager.PxeServerType;
|
import com.cloud.baremetal.PxeServerManager.PxeServerType;
|
||||||
|
import com.cloud.baremetal.PxeServerProfile;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.dc.DataCenter;
|
import com.cloud.dc.DataCenter;
|
||||||
import com.cloud.dc.Pod;
|
import com.cloud.dc.Pod;
|
||||||
@ -64,14 +63,11 @@ import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
|
|||||||
import com.cloud.network.dao.VpnUserDao;
|
import com.cloud.network.dao.VpnUserDao;
|
||||||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||||
import com.cloud.server.ManagementServer;
|
|
||||||
import org.apache.cloudstack.api.response.NetworkDeviceResponse;
|
|
||||||
import com.cloud.server.api.response.NwDeviceDhcpResponse;
|
import com.cloud.server.api.response.NwDeviceDhcpResponse;
|
||||||
import com.cloud.server.api.response.PxePingResponse;
|
import com.cloud.server.api.response.PxePingResponse;
|
||||||
import com.cloud.user.AccountManager;
|
import com.cloud.user.AccountManager;
|
||||||
import com.cloud.user.dao.AccountDao;
|
import com.cloud.user.dao.AccountDao;
|
||||||
import com.cloud.user.dao.UserStatisticsDao;
|
import com.cloud.user.dao.UserStatisticsDao;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.vm.dao.DomainRouterDao;
|
import com.cloud.vm.dao.DomainRouterDao;
|
||||||
import com.cloud.vm.dao.NicDao;
|
import com.cloud.vm.dao.NicDao;
|
||||||
@ -149,8 +145,8 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa
|
|||||||
if (cmd.getDeviceType().equalsIgnoreCase(NetworkDevice.ExternalDhcp.getName())) {
|
if (cmd.getDeviceType().equalsIgnoreCase(NetworkDevice.ExternalDhcp.getName())) {
|
||||||
//Long zoneId = _identityService.getIdentityId("data_center", (String) params.get(ApiConstants.ZONE_ID));
|
//Long zoneId = _identityService.getIdentityId("data_center", (String) params.get(ApiConstants.ZONE_ID));
|
||||||
//Long podId = _identityService.getIdentityId("host_pod_ref", (String)params.get(ApiConstants.POD_ID));
|
//Long podId = _identityService.getIdentityId("host_pod_ref", (String)params.get(ApiConstants.POD_ID));
|
||||||
Long zoneId = Long.valueOf((String) params.get(ApiConstants.ZONE_ID));
|
Long zoneId = Long.valueOf((String) params.get(ApiConstants.ZONE_ID));
|
||||||
Long podId = Long.valueOf((String)params.get(ApiConstants.POD_ID));
|
Long podId = Long.valueOf((String)params.get(ApiConstants.POD_ID));
|
||||||
String type = (String) params.get(ApiConstants.DHCP_SERVER_TYPE);
|
String type = (String) params.get(ApiConstants.DHCP_SERVER_TYPE);
|
||||||
String url = (String) params.get(ApiConstants.URL);
|
String url = (String) params.get(ApiConstants.URL);
|
||||||
String username = (String) params.get(ApiConstants.USERNAME);
|
String username = (String) params.get(ApiConstants.USERNAME);
|
||||||
@ -234,9 +230,9 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa
|
|||||||
// } else {
|
// } else {
|
||||||
// List<HostVO> devs = _hostDao.listBy(type, zoneId);
|
// List<HostVO> devs = _hostDao.listBy(type, zoneId);
|
||||||
// res.addAll(devs);
|
// res.addAll(devs);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// return res;
|
// return res;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +277,7 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteNetworkDevice(DeleteNetworkDeviceCmd cmd) {
|
public boolean deleteNetworkDevice(DeleteNetworkDeviceCmd cmd) {
|
||||||
HostVO device = _hostDao.findById(cmd.getId());
|
HostVO device = _hostDao.findById(cmd.getId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,27 +23,31 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import org.apache.cloudstack.acl.ControlledEntity;
|
import org.apache.cloudstack.acl.ControlledEntity;
|
||||||
import org.apache.cloudstack.api.command.admin.autoscale.CreateCounterCmd;
|
|
||||||
import org.apache.cloudstack.api.command.user.autoscale.*;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
import org.apache.cloudstack.api.ApiConstants;
|
||||||
import com.cloud.api.ApiDBUtils;
|
|
||||||
import com.cloud.api.ApiDispatcher;
|
|
||||||
import org.apache.cloudstack.api.BaseListAccountResourcesCmd;
|
import org.apache.cloudstack.api.BaseListAccountResourcesCmd;
|
||||||
|
import org.apache.cloudstack.api.command.admin.autoscale.CreateCounterCmd;
|
||||||
import org.apache.cloudstack.api.command.user.autoscale.CreateAutoScalePolicyCmd;
|
import org.apache.cloudstack.api.command.user.autoscale.CreateAutoScalePolicyCmd;
|
||||||
import org.apache.cloudstack.api.command.user.autoscale.CreateAutoScaleVmGroupCmd;
|
import org.apache.cloudstack.api.command.user.autoscale.CreateAutoScaleVmGroupCmd;
|
||||||
|
import org.apache.cloudstack.api.command.user.autoscale.CreateAutoScaleVmProfileCmd;
|
||||||
import org.apache.cloudstack.api.command.user.autoscale.CreateConditionCmd;
|
import org.apache.cloudstack.api.command.user.autoscale.CreateConditionCmd;
|
||||||
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
|
import org.apache.cloudstack.api.command.user.autoscale.ListAutoScalePoliciesCmd;
|
||||||
import org.apache.cloudstack.api.command.user.autoscale.ListAutoScaleVmGroupsCmd;
|
import org.apache.cloudstack.api.command.user.autoscale.ListAutoScaleVmGroupsCmd;
|
||||||
|
import org.apache.cloudstack.api.command.user.autoscale.ListAutoScaleVmProfilesCmd;
|
||||||
import org.apache.cloudstack.api.command.user.autoscale.ListConditionsCmd;
|
import org.apache.cloudstack.api.command.user.autoscale.ListConditionsCmd;
|
||||||
|
import org.apache.cloudstack.api.command.user.autoscale.ListCountersCmd;
|
||||||
import org.apache.cloudstack.api.command.user.autoscale.UpdateAutoScalePolicyCmd;
|
import org.apache.cloudstack.api.command.user.autoscale.UpdateAutoScalePolicyCmd;
|
||||||
|
import org.apache.cloudstack.api.command.user.autoscale.UpdateAutoScaleVmGroupCmd;
|
||||||
import org.apache.cloudstack.api.command.user.autoscale.UpdateAutoScaleVmProfileCmd;
|
import org.apache.cloudstack.api.command.user.autoscale.UpdateAutoScaleVmProfileCmd;
|
||||||
|
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
|
import com.cloud.api.ApiDispatcher;
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.ConfigurationManager;
|
import com.cloud.configuration.ConfigurationManager;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
@ -81,7 +85,6 @@ import com.cloud.user.dao.AccountDao;
|
|||||||
import com.cloud.user.dao.UserDao;
|
import com.cloud.user.dao.UserDao;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.Ternary;
|
import com.cloud.utils.Ternary;
|
||||||
import com.cloud.utils.component.Inject;
|
|
||||||
import com.cloud.utils.component.Manager;
|
import com.cloud.utils.component.Manager;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.Filter;
|
import com.cloud.utils.db.Filter;
|
||||||
|
|||||||
@ -32,7 +32,6 @@ import com.cloud.network.rules.FirewallRule.TrafficType;
|
|||||||
import com.cloud.network.rules.FirewallRuleVO;
|
import com.cloud.network.rules.FirewallRuleVO;
|
||||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||||
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.GenericSearchBuilder;
|
import com.cloud.utils.db.GenericSearchBuilder;
|
||||||
@ -291,6 +290,7 @@ public class FirewallRulesDaoImpl extends GenericDaoBase<FirewallRuleVO, Long> i
|
|||||||
|
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
@DB
|
@DB
|
||||||
public boolean remove(Long id) {
|
public boolean remove(Long id) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
|
|||||||
@ -35,7 +35,6 @@ import com.cloud.network.IPAddressVO;
|
|||||||
import com.cloud.network.IpAddress.State;
|
import com.cloud.network.IpAddress.State;
|
||||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||||
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.GenericSearchBuilder;
|
import com.cloud.utils.db.GenericSearchBuilder;
|
||||||
@ -111,7 +110,7 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, Long> implemen
|
|||||||
virtaulNetworkVlan.and("vlanType", virtaulNetworkVlan.entity().getVlanType(), SearchCriteria.Op.EQ);
|
virtaulNetworkVlan.and("vlanType", virtaulNetworkVlan.entity().getVlanType(), SearchCriteria.Op.EQ);
|
||||||
|
|
||||||
AllIpCountForDashboard.join("vlan", virtaulNetworkVlan, virtaulNetworkVlan.entity().getId(),
|
AllIpCountForDashboard.join("vlan", virtaulNetworkVlan, virtaulNetworkVlan.entity().getId(),
|
||||||
AllIpCountForDashboard.entity().getVlanId(), JoinBuilder.JoinType.INNER);
|
AllIpCountForDashboard.entity().getVlanId(), JoinBuilder.JoinType.INNER);
|
||||||
virtaulNetworkVlan.done();
|
virtaulNetworkVlan.done();
|
||||||
AllIpCountForDashboard.done();
|
AllIpCountForDashboard.done();
|
||||||
|
|
||||||
@ -248,7 +247,7 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, Long> implemen
|
|||||||
SearchCriteria<Integer> sc = AllIpCountForDashboard.create();
|
SearchCriteria<Integer> sc = AllIpCountForDashboard.create();
|
||||||
sc.setParameters("dc", dcId);
|
sc.setParameters("dc", dcId);
|
||||||
if (onlyCountAllocated){
|
if (onlyCountAllocated){
|
||||||
sc.setParameters("state", State.Free);
|
sc.setParameters("state", State.Free);
|
||||||
}
|
}
|
||||||
sc.setJoinParameters("vlan", "vlanType", vlanType.toString());
|
sc.setJoinParameters("vlan", "vlanType", vlanType.toString());
|
||||||
return customSearch(sc, null).get(0);
|
return customSearch(sc, null).get(0);
|
||||||
@ -297,7 +296,7 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, Long> implemen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long countAllocatedIPsForAccount(long accountId) {
|
public long countAllocatedIPsForAccount(long accountId) {
|
||||||
SearchCriteria<Long> sc = AllocatedIpCountForAccount.create();
|
SearchCriteria<Long> sc = AllocatedIpCountForAccount.create();
|
||||||
sc.setParameters("account", accountId);
|
sc.setParameters("account", accountId);
|
||||||
return customSearch(sc, null).get(0);
|
return customSearch(sc, null).get(0);
|
||||||
}
|
}
|
||||||
@ -311,9 +310,9 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, Long> implemen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long countFreePublicIPs() {
|
public long countFreePublicIPs() {
|
||||||
SearchCriteria<Long> sc = CountFreePublicIps.create();
|
SearchCriteria<Long> sc = CountFreePublicIps.create();
|
||||||
sc.setParameters("state", State.Free);
|
sc.setParameters("state", State.Free);
|
||||||
sc.setJoinParameters("vlans", "vlanType", VlanType.VirtualNetwork);
|
sc.setJoinParameters("vlans", "vlanType", VlanType.VirtualNetwork);
|
||||||
return customSearch(sc, null).get(0);
|
return customSearch(sc, null).get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,6 +328,7 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, Long> implemen
|
|||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public long countFreeIPsInNetwork(long networkId) {
|
public long countFreeIPsInNetwork(long networkId) {
|
||||||
SearchCriteria<Long> sc = CountFreePublicIps.create();
|
SearchCriteria<Long> sc = CountFreePublicIps.create();
|
||||||
sc.setParameters("state", State.Free);
|
sc.setParameters("state", State.Free);
|
||||||
|
|||||||
@ -29,7 +29,6 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import com.cloud.network.LoadBalancerVO;
|
import com.cloud.network.LoadBalancerVO;
|
||||||
import com.cloud.network.rules.FirewallRule.State;
|
import com.cloud.network.rules.FirewallRule.State;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
|
|||||||
@ -45,7 +45,6 @@ import com.cloud.offerings.NetworkOfferingVO;
|
|||||||
import com.cloud.offerings.dao.NetworkOfferingDaoImpl;
|
import com.cloud.offerings.dao.NetworkOfferingDaoImpl;
|
||||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||||
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.GenericSearchBuilder;
|
import com.cloud.utils.db.GenericSearchBuilder;
|
||||||
|
|||||||
@ -25,14 +25,11 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import com.cloud.network.Networks.TrafficType;
|
import com.cloud.network.Networks.TrafficType;
|
||||||
import com.cloud.network.PhysicalNetworkVO;
|
import com.cloud.network.PhysicalNetworkVO;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.GenericSearchBuilder;
|
|
||||||
import com.cloud.utils.db.JoinBuilder;
|
import com.cloud.utils.db.JoinBuilder;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
import com.cloud.utils.db.SearchCriteria.Func;
|
|
||||||
import com.cloud.utils.db.SearchCriteria.Op;
|
import com.cloud.utils.db.SearchCriteria.Op;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
|||||||
@ -25,10 +25,8 @@ import javax.inject.Inject;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.network.IPAddressVO;
|
|
||||||
import com.cloud.network.Site2SiteVpnConnectionVO;
|
import com.cloud.network.Site2SiteVpnConnectionVO;
|
||||||
import com.cloud.network.Site2SiteVpnGatewayVO;
|
import com.cloud.network.Site2SiteVpnGatewayVO;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.JoinBuilder.JoinType;
|
import com.cloud.utils.db.JoinBuilder.JoinType;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import org.apache.log4j.Logger;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.network.Site2SiteVpnGatewayVO;
|
import com.cloud.network.Site2SiteVpnGatewayVO;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
|
|||||||
@ -46,7 +46,7 @@ import com.cloud.network.Networks.Mode;
|
|||||||
import com.cloud.network.Networks.TrafficType;
|
import com.cloud.network.Networks.TrafficType;
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.utils.net.NetUtils;
|
import com.cloud.utils.net.NetUtils;
|
||||||
import com.cloud.vm.Nic;
|
import com.cloud.vm.Nic;
|
||||||
|
|||||||
@ -206,7 +206,7 @@ import com.cloud.utils.NumbersUtil;
|
|||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.PasswordGenerator;
|
import com.cloud.utils.PasswordGenerator;
|
||||||
import com.cloud.utils.StringUtils;
|
import com.cloud.utils.StringUtils;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.Filter;
|
import com.cloud.utils.db.Filter;
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import com.cloud.network.dao.FirewallRulesCidrsDaoImpl;
|
|||||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||||
import com.cloud.network.rules.FirewallRule.State;
|
import com.cloud.network.rules.FirewallRule.State;
|
||||||
import com.cloud.network.rules.PortForwardingRuleVO;
|
import com.cloud.network.rules.PortForwardingRuleVO;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
|
|||||||
@ -87,7 +87,7 @@ import com.cloud.uservm.UserVm;
|
|||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.Ternary;
|
import com.cloud.utils.Ternary;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.component.Manager;
|
import com.cloud.utils.component.Manager;
|
||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import com.cloud.network.security.SecurityGroupVO;
|
import com.cloud.network.security.SecurityGroupVO;
|
||||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||||
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
|
|||||||
@ -99,7 +99,7 @@ import com.cloud.user.UserContext;
|
|||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.Ternary;
|
import com.cloud.utils.Ternary;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.component.Manager;
|
import com.cloud.utils.component.Manager;
|
||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import com.cloud.network.vpc.StaticRoute;
|
|||||||
import com.cloud.network.vpc.StaticRouteVO;
|
import com.cloud.network.vpc.StaticRouteVO;
|
||||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||||
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.GenericSearchBuilder;
|
import com.cloud.utils.db.GenericSearchBuilder;
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import com.cloud.network.vpc.Vpc;
|
|||||||
import com.cloud.network.vpc.VpcVO;
|
import com.cloud.network.vpc.VpcVO;
|
||||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||||
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.GenericSearchBuilder;
|
import com.cloud.utils.db.GenericSearchBuilder;
|
||||||
|
|||||||
@ -70,7 +70,7 @@ import com.cloud.utils.NumbersUtil;
|
|||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.PasswordGenerator;
|
import com.cloud.utils.PasswordGenerator;
|
||||||
import com.cloud.utils.Ternary;
|
import com.cloud.utils.Ternary;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.component.Manager;
|
import com.cloud.utils.component.Manager;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.Filter;
|
import com.cloud.utils.db.Filter;
|
||||||
|
|||||||
@ -70,7 +70,7 @@ import com.cloud.user.dao.AccountDao;
|
|||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.Ternary;
|
import com.cloud.utils.Ternary;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.component.Manager;
|
import com.cloud.utils.component.Manager;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.Filter;
|
import com.cloud.utils.db.Filter;
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import com.cloud.projects.Project;
|
|||||||
import com.cloud.projects.ProjectVO;
|
import com.cloud.projects.ProjectVO;
|
||||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||||
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
import com.cloud.utils.db.GenericSearchBuilder;
|
import com.cloud.utils.db.GenericSearchBuilder;
|
||||||
|
|||||||
@ -34,7 +34,7 @@ import com.cloud.dc.dao.ClusterDao;
|
|||||||
import com.cloud.host.HostVO;
|
import com.cloud.host.HostVO;
|
||||||
import com.cloud.host.dao.HostDao;
|
import com.cloud.host.dao.HostDao;
|
||||||
import com.cloud.network.NetworkManager;
|
import com.cloud.network.NetworkManager;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.net.UrlUtil;
|
import com.cloud.utils.net.UrlUtil;
|
||||||
|
|
||||||
public abstract class DiscovererBase implements Discoverer {
|
public abstract class DiscovererBase implements Discoverer {
|
||||||
|
|||||||
@ -46,7 +46,7 @@ import com.cloud.user.User;
|
|||||||
import com.cloud.uservm.UserVm;
|
import com.cloud.uservm.UserVm;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.Ternary;
|
import com.cloud.utils.Ternary;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
import com.cloud.vm.VMInstanceVO;
|
import com.cloud.vm.VMInstanceVO;
|
||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
|
|||||||
@ -37,7 +37,7 @@ import com.cloud.user.User;
|
|||||||
import com.cloud.user.UserVO;
|
import com.cloud.user.UserVO;
|
||||||
import com.cloud.user.dao.UserDao;
|
import com.cloud.user.dao.UserDao;
|
||||||
import com.cloud.utils.SerialVersionUID;
|
import com.cloud.utils.SerialVersionUID;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
|
|
||||||
public class RegisterCompleteServlet extends HttpServlet implements ServletContextListener {
|
public class RegisterCompleteServlet extends HttpServlet implements ServletContextListener {
|
||||||
public static final Logger s_logger = Logger.getLogger(RegisterCompleteServlet.class.getName());
|
public static final Logger s_logger = Logger.getLogger(RegisterCompleteServlet.class.getName());
|
||||||
|
|||||||
@ -173,7 +173,7 @@ import com.cloud.utils.NumbersUtil;
|
|||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.UriUtils;
|
import com.cloud.utils.UriUtils;
|
||||||
import com.cloud.utils.component.Adapters;
|
import com.cloud.utils.component.Adapters;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.component.Manager;
|
import com.cloud.utils.component.Manager;
|
||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import com.cloud.cluster.CheckPointManager;
|
|||||||
import com.cloud.cluster.CleanupMaid;
|
import com.cloud.cluster.CleanupMaid;
|
||||||
import com.cloud.server.ManagementServer;
|
import com.cloud.server.ManagementServer;
|
||||||
import com.cloud.storage.dao.VolumeDao;
|
import com.cloud.storage.dao.VolumeDao;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
import com.cloud.utils.fsm.NoTransitionException;
|
import com.cloud.utils.fsm.NoTransitionException;
|
||||||
import com.cloud.utils.fsm.StateMachine2;
|
import com.cloud.utils.fsm.StateMachine2;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user