Check all warnings in core and fix where applicable, also apply autoformatting on save.

This commit is contained in:
Hugo Trippaers 2013-09-21 16:15:36 +08:00
parent bb8b7340f3
commit 4945d465bf
21 changed files with 580 additions and 575 deletions

View File

@ -20,9 +20,6 @@ import java.util.List;
import org.apache.cloudstack.storage.to.VolumeObjectTO; import org.apache.cloudstack.storage.to.VolumeObjectTO;
import com.cloud.agent.api.to.DiskTO;
import com.cloud.agent.api.to.VolumeTO;
public class MigrateWithStorageAnswer extends Answer { public class MigrateWithStorageAnswer extends Answer {
List<VolumeObjectTO> volumeTos; List<VolumeObjectTO> volumeTos;

View File

@ -20,8 +20,6 @@ import java.util.List;
import org.apache.cloudstack.storage.to.VolumeObjectTO; import org.apache.cloudstack.storage.to.VolumeObjectTO;
import com.cloud.agent.api.to.VolumeTO;
public class MigrateWithStorageCompleteAnswer extends Answer { public class MigrateWithStorageCompleteAnswer extends Answer {
List<VolumeObjectTO> volumeTos; List<VolumeObjectTO> volumeTos;

View File

@ -16,7 +16,6 @@
// under the License. // under the License.
package com.cloud.agent.api; package com.cloud.agent.api;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine;
public class RebootCommand extends Command { public class RebootCommand extends Command {

View File

@ -20,7 +20,6 @@ import java.util.List;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
import com.cloud.agent.api.to.LoadBalancerTO; import com.cloud.agent.api.to.LoadBalancerTO;
import com.cloud.agent.api.to.NicTO;
/** /**
* LoadBalancerConfigCommand sends the load balancer configuration * LoadBalancerConfigCommand sends the load balancer configuration

View File

@ -17,7 +17,6 @@
package com.cloud.agent.api.routing; package com.cloud.agent.api.routing;
import com.cloud.agent.api.to.LoadBalancerTO; import com.cloud.agent.api.to.LoadBalancerTO;
import com.cloud.agent.api.to.NicTO;
/** /**
* LoadBalancerConfigCommand sends the load balancer configuration * LoadBalancerConfigCommand sends the load balancer configuration

View File

@ -20,9 +20,7 @@ package com.cloud.agent.api.routing;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import com.cloud.agent.api.to.NetworkACLTO; import com.cloud.agent.api.to.NetworkACLTO;
import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.NicTO;

View File

@ -41,30 +41,30 @@ public class UploadCommand extends AbstractUploadCommand implements InternalIden
this.template = new TemplateTO(template); this.template = new TemplateTO(template);
this.url = url; this.url = url;
this.installPath = installPath; this.installPath = installPath;
this.checksum = template.getChecksum(); checksum = template.getChecksum();
this.id = template.getId(); id = template.getId();
this.templateSizeInBytes = sizeInBytes; templateSizeInBytes = sizeInBytes;
} }
public UploadCommand(String url, long id, long sizeInBytes, String installPath, Type type){ public UploadCommand(String url, long id, long sizeInBytes, String installPath, Type type){
this.template = null; template = null;
this.url = url; this.url = url;
this.installPath = installPath; this.installPath = installPath;
this.id = id; this.id = id;
this.type = type; this.type = type;
this.templateSizeInBytes = sizeInBytes; templateSizeInBytes = sizeInBytes;
} }
protected UploadCommand() { protected UploadCommand() {
} }
public UploadCommand(UploadCommand that) { public UploadCommand(UploadCommand that) {
this.template = that.template; template = that.template;
this.url = that.url; url = that.url;
this.installPath = that.installPath; installPath = that.installPath;
this.checksum = that.getChecksum(); checksum = that.getChecksum();
this.id = that.id; id = that.id;
} }
public String getDescription() { public String getDescription() {
@ -114,6 +114,7 @@ public class UploadCommand extends AbstractUploadCommand implements InternalIden
this.templateSizeInBytes = templateSizeInBytes; this.templateSizeInBytes = templateSizeInBytes;
} }
@Override
public long getId() { public long getId() {
return id; return id;
} }

View File

@ -108,7 +108,6 @@ public class VirtualRoutingResource implements Manager {
private String _firewallPath; private String _firewallPath;
private String _loadbPath; private String _loadbPath;
private String _dhcpEntryPath; private String _dhcpEntryPath;
private String _vmDataPath;
private String _publicEthIf; private String _publicEthIf;
private String _privateEthIf; private String _privateEthIf;
private String _bumpUpPriorityPath; private String _bumpUpPriorityPath;

View File

@ -31,14 +31,6 @@ import java.util.zip.GZIPOutputStream;
import org.apache.log4j.Level; import org.apache.log4j.Level;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.SecStorageFirewallCfgCommand.PortConfig;
import com.cloud.exception.UnsupportedVersionException;
import com.cloud.serializer.GsonHelper;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
import com.cloud.utils.exception.CloudRuntimeException;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializationContext;
@ -50,6 +42,15 @@ import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer; import com.google.gson.JsonSerializer;
import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonReader;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.SecStorageFirewallCfgCommand.PortConfig;
import com.cloud.exception.UnsupportedVersionException;
import com.cloud.serializer.GsonHelper;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
import com.cloud.utils.exception.CloudRuntimeException;
/** /**
* Request is a simple wrapper around command and answer to add sequencing, * Request is a simple wrapper around command and answer to add sequencing,
* versioning, and flags. Note that the version here represents the changes * versioning, and flags. Note that the version here represents the changes
@ -158,14 +159,14 @@ public class Request {
} }
protected Request(final Request that, final Command[] cmds) { protected Request(final Request that, final Command[] cmds) {
this._ver = that._ver; _ver = that._ver;
this._seq = that._seq; _seq = that._seq;
setInSequence(that.executeInSequence()); setInSequence(that.executeInSequence());
setStopOnError(that.stopOnError()); setStopOnError(that.stopOnError());
this._cmds = cmds; _cmds = cmds;
this._mgmtId = that._mgmtId; _mgmtId = that._mgmtId;
this._via = that._via; _via = that._via;
this._agentId = that._agentId; _agentId = that._agentId;
setFromServer(!that.isFromServer()); setFromServer(!that.isFromServer());
} }
@ -447,7 +448,7 @@ public class Request {
if (version.ordinal() != Version.v1.ordinal() && version.ordinal() != Version.v3.ordinal()) { if (version.ordinal() != Version.v1.ordinal() && version.ordinal() != Version.v3.ordinal()) {
throw new UnsupportedVersionException("This version is no longer supported: " + version.toString(), UnsupportedVersionException.IncompatibleVersion); throw new UnsupportedVersionException("This version is no longer supported: " + version.toString(), UnsupportedVersionException.IncompatibleVersion);
} }
final byte reserved = buff.get(); // tossed away for now. buff.get();
final short flags = buff.getShort(); final short flags = buff.getShort();
final boolean isRequest = (flags & FLAG_REQUEST) > 0; final boolean isRequest = (flags & FLAG_REQUEST) > 0;

View File

@ -18,6 +18,11 @@ package com.cloud.exception;
public class UsageServerException extends CloudException { public class UsageServerException extends CloudException {
/**
*
*/
private static final long serialVersionUID = -8398313106067116466L;
public UsageServerException() { public UsageServerException() {
} }

View File

@ -17,7 +17,6 @@
package com.cloud.storage; package com.cloud.storage;
import java.io.File; import java.io.File;
import java.io.FileFilter;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -41,7 +40,7 @@ public class JavaStorageLayer implements StorageLayer {
public JavaStorageLayer(boolean makeWorldWriteable) { public JavaStorageLayer(boolean makeWorldWriteable) {
this(); this();
this._makeWorldWriteable = makeWorldWriteable; _makeWorldWriteable = makeWorldWriteable;
} }
@Override @Override
@ -171,7 +170,7 @@ public class JavaStorageLayer implements StorageLayer {
File dir = new File(dirName); File dir = new File(dirName);
if (dir.exists()) { if (dir.exists()) {
String uniqDirName = dir.getAbsolutePath() + File.separator + UUID.randomUUID().toString(); String uniqDirName = dir.getAbsolutePath() + File.separator + UUID.randomUUID().toString();
if (this.mkdir(uniqDirName)) { if (mkdir(uniqDirName)) {
return new File(uniqDirName); return new File(uniqDirName);
} }
} }
@ -219,6 +218,7 @@ public class JavaStorageLayer implements StorageLayer {
return dirPaths; return dirPaths;
} }
@Override
public boolean setWorldReadableAndWriteable(File file) { public boolean setWorldReadableAndWriteable(File file) {
return (file.setReadable(true, false) && file.setWritable(true, false)); return (file.setReadable(true, false) && file.setWritable(true, false));
} }

View File

@ -21,8 +21,6 @@ import com.cloud.agent.api.storage.CopyVolumeAnswer;
import com.cloud.agent.api.storage.CopyVolumeCommand; import com.cloud.agent.api.storage.CopyVolumeCommand;
import com.cloud.agent.api.storage.CreateAnswer; import com.cloud.agent.api.storage.CreateAnswer;
import com.cloud.agent.api.storage.CreateCommand; import com.cloud.agent.api.storage.CreateCommand;
import com.cloud.agent.api.storage.CreateVolumeOVAAnswer;
import com.cloud.agent.api.storage.CreateVolumeOVACommand;
import com.cloud.agent.api.storage.DestroyCommand; import com.cloud.agent.api.storage.DestroyCommand;
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer; import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;

View File

@ -39,7 +39,6 @@ public class FtpTemplateUploader implements TemplateUploader {
private String sourcePath; private String sourcePath;
private String ftpUrl; private String ftpUrl;
private UploadCompleteCallback completionCallback; private UploadCompleteCallback completionCallback;
private boolean resume;
private BufferedInputStream inputStream = null; private BufferedInputStream inputStream = null;
private BufferedOutputStream outputStream = null; private BufferedOutputStream outputStream = null;
private static final int CHUNK_SIZE = 1024*1024; //1M private static final int CHUNK_SIZE = 1024*1024; //1M
@ -47,12 +46,13 @@ public class FtpTemplateUploader implements TemplateUploader {
public FtpTemplateUploader(String sourcePath, String url, UploadCompleteCallback callback, long entitySizeinBytes){ public FtpTemplateUploader(String sourcePath, String url, UploadCompleteCallback callback, long entitySizeinBytes){
this.sourcePath = sourcePath; this.sourcePath = sourcePath;
this.ftpUrl = url; ftpUrl = url;
this.completionCallback = callback; completionCallback = callback;
this.entitySizeinBytes = entitySizeinBytes; this.entitySizeinBytes = entitySizeinBytes;
} }
@Override
public long upload(UploadCompleteCallback callback ) public long upload(UploadCompleteCallback callback )
{ {
@ -65,7 +65,7 @@ public class FtpTemplateUploader implements TemplateUploader {
} }
Date start = new Date(); new Date();
StringBuffer sb = new StringBuffer(ftpUrl); StringBuffer sb = new StringBuffer(ftpUrl);
// check for authentication else assume its anonymous access. // check for authentication else assume its anonymous access.
@ -185,7 +185,6 @@ public class FtpTemplateUploader implements TemplateUploader {
@Override @Override
public void setResume(boolean resume) { public void setResume(boolean resume) {
this.resume = resume;
} }

View File

@ -22,14 +22,9 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.Date; import java.util.Date;
import org.apache.cloudstack.storage.command.DownloadCommand.ResourceType;
import org.apache.commons.httpclient.ChunkedInputStream; import org.apache.commons.httpclient.ChunkedInputStream;
import org.apache.commons.httpclient.Credentials; import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.Header;
@ -46,9 +41,10 @@ import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.params.HttpMethodParams; import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.cloudstack.storage.command.DownloadCommand.ResourceType;
import com.cloud.agent.api.storage.Proxy; import com.cloud.agent.api.storage.Proxy;
import com.cloud.storage.StorageLayer; import com.cloud.storage.StorageLayer;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.Pair; import com.cloud.utils.Pair;
import com.cloud.utils.UriUtils; import com.cloud.utils.UriUtils;
@ -83,17 +79,18 @@ public class HttpTemplateDownloader implements TemplateDownloader {
public HttpTemplateDownloader (StorageLayer storageLayer, String downloadUrl, String toDir, DownloadCompleteCallback callback, long maxTemplateSizeInBytes, String user, String password, Proxy proxy, ResourceType resourceType) { public HttpTemplateDownloader (StorageLayer storageLayer, String downloadUrl, String toDir, DownloadCompleteCallback callback, long maxTemplateSizeInBytes, String user, String password, Proxy proxy, ResourceType resourceType) {
this._storage = storageLayer; _storage = storageLayer;
this.downloadUrl = downloadUrl; this.downloadUrl = downloadUrl;
this.setToDir(toDir); setToDir(toDir);
this.status = TemplateDownloader.Status.NOT_STARTED; status = TemplateDownloader.Status.NOT_STARTED;
this.resourceType = resourceType; this.resourceType = resourceType;
this.MAX_TEMPLATE_SIZE_IN_BYTES = maxTemplateSizeInBytes; MAX_TEMPLATE_SIZE_IN_BYTES = maxTemplateSizeInBytes;
this.totalBytes = 0; totalBytes = 0;
this.client = new HttpClient(s_httpClientManager); client = new HttpClient(s_httpClientManager);
myretryhandler = new HttpMethodRetryHandler() { myretryhandler = new HttpMethodRetryHandler() {
@Override
public boolean retryMethod( public boolean retryMethod(
final HttpMethod method, final HttpMethod method,
final IOException exception, final IOException exception,
@ -117,9 +114,9 @@ public class HttpTemplateDownloader implements TemplateDownloader {
}; };
try { try {
this.request = new GetMethod(downloadUrl); request = new GetMethod(downloadUrl);
this.request.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, myretryhandler); request.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, myretryhandler);
this.completionCallback = callback; completionCallback = callback;
//this.request.setFollowRedirects(false); //this.request.setFollowRedirects(false);
File f = File.createTempFile("dnld", "tmp_", new File(toDir)); File f = File.createTempFile("dnld", "tmp_", new File(toDir));
@ -236,8 +233,8 @@ public class HttpTemplateDownloader implements TemplateDownloader {
remoteSize = MAX_TEMPLATE_SIZE_IN_BYTES; remoteSize = MAX_TEMPLATE_SIZE_IN_BYTES;
} }
InputStream in = !chunked?new BufferedInputStream(request.getResponseBodyAsStream()) InputStream in = !chunked ? new BufferedInputStream(request.getResponseBodyAsStream()) : new ChunkedInputStream(
: new ChunkedInputStream(request.getResponseBodyAsStream()); request.getResponseBodyAsStream());
RandomAccessFile out = new RandomAccessFile(file, "rwd"); RandomAccessFile out = new RandomAccessFile(file, "rwd");
out.seek(localFileSize); out.seek(localFileSize);
@ -266,6 +263,7 @@ public class HttpTemplateDownloader implements TemplateDownloader {
} }
errorString = "Downloaded " + totalBytes + " bytes " + downloaded; errorString = "Downloaded " + totalBytes + " bytes " + downloaded;
downloadTime += finish.getTime() - start.getTime(); downloadTime += finish.getTime() - start.getTime();
in.close();
out.close(); out.close();
return totalBytes; return totalBytes;
@ -297,16 +295,19 @@ public class HttpTemplateDownloader implements TemplateDownloader {
return file.getAbsolutePath(); return file.getAbsolutePath();
} }
@Override
public TemplateDownloader.Status getStatus() { public TemplateDownloader.Status getStatus() {
return status; return status;
} }
@Override
public long getDownloadTime() { public long getDownloadTime() {
return downloadTime; return downloadTime;
} }
@Override
public long getDownloadedBytes() { public long getDownloadedBytes() {
return totalBytes; return totalBytes;
} }
@ -381,6 +382,7 @@ public class HttpTemplateDownloader implements TemplateDownloader {
return getToFile(); return getToFile();
} }
@Override
public void setResume(boolean resume) { public void setResume(boolean resume) {
this.resume = resume; this.resume = resume;
} }
@ -393,14 +395,15 @@ public class HttpTemplateDownloader implements TemplateDownloader {
return toDir; return toDir;
} }
@Override
public long getMaxTemplateSizeInBytes() { public long getMaxTemplateSizeInBytes() {
return this.MAX_TEMPLATE_SIZE_IN_BYTES; return MAX_TEMPLATE_SIZE_IN_BYTES;
} }
public static void main(String[] args) { public static void main(String[] args) {
String url ="http:// dev.mysql.com/get/Downloads/MySQL-5.0/mysql-noinstall-5.0.77-win32.zip/from/http://mirror.services.wisc.edu/mysql/"; String url ="http:// dev.mysql.com/get/Downloads/MySQL-5.0/mysql-noinstall-5.0.77-win32.zip/from/http://mirror.services.wisc.edu/mysql/";
try { try {
URI uri = new java.net.URI(url); new java.net.URI(url);
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();

View File

@ -64,6 +64,8 @@ public class LocalTemplateDownloader extends TemplateDownloaderBase implements T
FileChannel fic = null; FileChannel fic = null;
FileChannel foc = null; FileChannel foc = null;
FileInputStream fis = null;
FileOutputStream fos = null;
try { try {
if (_storage != null) { if (_storage != null) {
@ -72,7 +74,7 @@ public class LocalTemplateDownloader extends TemplateDownloaderBase implements T
} }
ByteBuffer buffer = ByteBuffer.allocate(1024 * 512); ByteBuffer buffer = ByteBuffer.allocate(1024 * 512);
FileInputStream fis;
try { try {
fis = new FileInputStream(src); fis = new FileInputStream(src);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
@ -81,7 +83,6 @@ public class LocalTemplateDownloader extends TemplateDownloaderBase implements T
return -1; return -1;
} }
fic = fis.getChannel(); fic = fis.getChannel();
FileOutputStream fos;
try { try {
fos = new FileOutputStream(dst); fos = new FileOutputStream(dst);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
@ -91,7 +92,7 @@ public class LocalTemplateDownloader extends TemplateDownloaderBase implements T
foc = fos.getChannel(); foc = fos.getChannel();
_remoteSize = src.length(); _remoteSize = src.length();
this._totalBytes = 0; _totalBytes = 0;
_status = TemplateDownloader.Status.IN_PROGRESS; _status = TemplateDownloader.Status.IN_PROGRESS;
try { try {
@ -133,6 +134,20 @@ public class LocalTemplateDownloader extends TemplateDownloaderBase implements T
} }
} }
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
}
}
if (_status == Status.UNRECOVERABLE_ERROR && dst.exists()) { if (_status == Status.UNRECOVERABLE_ERROR && dst.exists()) {
dst.delete(); dst.delete();
} }

View File

@ -25,9 +25,8 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.cloud.exception.InternalErrorException; import com.cloud.exception.InternalErrorException;
import com.cloud.storage.StorageLayer;
import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.template.Processor.FormatInfo; import com.cloud.storage.StorageLayer;
import com.cloud.utils.component.AdapterBase; import com.cloud.utils.component.AdapterBase;
@Local(value=Processor.class) @Local(value=Processor.class)

View File

@ -24,7 +24,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Date; import java.util.Date;
import org.apache.cloudstack.storage.command.DownloadCommand.ResourceType;
import org.apache.commons.httpclient.ChunkedInputStream; import org.apache.commons.httpclient.ChunkedInputStream;
import org.apache.commons.httpclient.Credentials; import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.Header;
@ -43,8 +42,6 @@ import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.amazonaws.AmazonClientException; import com.amazonaws.AmazonClientException;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.model.ObjectMetadata; import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.ProgressEvent; import com.amazonaws.services.s3.model.ProgressEvent;
import com.amazonaws.services.s3.model.ProgressListener; import com.amazonaws.services.s3.model.ProgressListener;
@ -52,6 +49,9 @@ import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.StorageClass; import com.amazonaws.services.s3.model.StorageClass;
import com.amazonaws.services.s3.transfer.TransferManager; import com.amazonaws.services.s3.transfer.TransferManager;
import com.amazonaws.services.s3.transfer.Upload; import com.amazonaws.services.s3.transfer.Upload;
import org.apache.cloudstack.storage.command.DownloadCommand.ResourceType;
import com.cloud.agent.api.storage.Proxy; import com.cloud.agent.api.storage.Proxy;
import com.cloud.agent.api.to.S3TO; import com.cloud.agent.api.to.S3TO;
import com.cloud.utils.Pair; import com.cloud.utils.Pair;
@ -89,15 +89,15 @@ public class S3TemplateDownloader implements TemplateDownloader {
public S3TemplateDownloader(S3TO storageLayer, String downloadUrl, String installPath, public S3TemplateDownloader(S3TO storageLayer, String downloadUrl, String installPath,
DownloadCompleteCallback callback, long maxTemplateSizeInBytes, String user, String password, Proxy proxy, DownloadCompleteCallback callback, long maxTemplateSizeInBytes, String user, String password, Proxy proxy,
ResourceType resourceType) { ResourceType resourceType) {
this.s3 = storageLayer; s3 = storageLayer;
this.downloadUrl = downloadUrl; this.downloadUrl = downloadUrl;
this.installPath = installPath; this.installPath = installPath;
this.status = TemplateDownloader.Status.NOT_STARTED; status = TemplateDownloader.Status.NOT_STARTED;
this.resourceType = resourceType; this.resourceType = resourceType;
this.maxTemplateSizeInByte = maxTemplateSizeInBytes; maxTemplateSizeInByte = maxTemplateSizeInBytes;
this.totalBytes = 0; totalBytes = 0;
this.client = new HttpClient(s_httpClientManager); client = new HttpClient(s_httpClientManager);
myretryhandler = new HttpMethodRetryHandler() { myretryhandler = new HttpMethodRetryHandler() {
@Override @Override
@ -121,12 +121,12 @@ public class S3TemplateDownloader implements TemplateDownloader {
}; };
try { try {
this.request = new GetMethod(downloadUrl); request = new GetMethod(downloadUrl);
this.request.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, myretryhandler); request.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, myretryhandler);
this.completionCallback = callback; completionCallback = callback;
Pair<String, Integer> hostAndPort = UriUtils.validateUrl(downloadUrl); Pair<String, Integer> hostAndPort = UriUtils.validateUrl(downloadUrl);
this.fileName = StringUtils.substringAfterLast(downloadUrl, "/"); fileName = StringUtils.substringAfterLast(downloadUrl, "/");
if (proxy != null) { if (proxy != null) {
client.getHostConfiguration().setProxy(proxy.getHost(), proxy.getPort()); client.getHostConfiguration().setProxy(proxy.getHost(), proxy.getPort());
@ -388,7 +388,7 @@ public class S3TemplateDownloader implements TemplateDownloader {
@Override @Override
public String getDownloadLocalPath() { public String getDownloadLocalPath() {
return this.s3Key; return s3Key;
} }
@Override @Override
@ -398,7 +398,7 @@ public class S3TemplateDownloader implements TemplateDownloader {
@Override @Override
public long getMaxTemplateSizeInBytes() { public long getMaxTemplateSizeInBytes() {
return this.maxTemplateSizeInByte; return maxTemplateSizeInByte;
} }
@Override @Override

View File

@ -22,9 +22,10 @@ import java.net.URISyntaxException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.trilead.ssh2.SCPClient;
import com.cloud.storage.StorageLayer; import com.cloud.storage.StorageLayer;
import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.exception.CloudRuntimeException;
import com.trilead.ssh2.SCPClient;
public class ScpTemplateDownloader extends TemplateDownloaderBase implements TemplateDownloader { public class ScpTemplateDownloader extends TemplateDownloaderBase implements TemplateDownloader {
private static final Logger s_logger = Logger.getLogger(ScpTemplateDownloader.class); private static final Logger s_logger = Logger.getLogger(ScpTemplateDownloader.class);
@ -83,7 +84,6 @@ public class ScpTemplateDownloader extends TemplateDownloaderBase implements Tem
if (port == -1) { if (port == -1) {
port = 22; port = 22;
} }
long length = 0;
File file = new File(_toFile); File file = new File(_toFile);
com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(uri.getHost(), port); com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(uri.getHost(), port);

View File

@ -16,9 +16,6 @@
// under the License. // under the License.
package com.cloud.storage.template; package com.cloud.storage.template;
import com.cloud.storage.template.TemplateUploader.UploadCompleteCallback;
import com.cloud.storage.template.TemplateUploader.Status;
public interface TemplateUploader extends Runnable{ public interface TemplateUploader extends Runnable{
/** /**

View File

@ -26,7 +26,6 @@ import com.cloud.agent.api.storage.Proxy;
import com.cloud.agent.api.to.DataStoreTO; import com.cloud.agent.api.to.DataStoreTO;
import com.cloud.agent.api.to.NfsTO; import com.cloud.agent.api.to.NfsTO;
import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Volume;
public class DownloadCommand extends AbstractDownloadCommand implements InternalIdentity { public class DownloadCommand extends AbstractDownloadCommand implements InternalIdentity {
@ -53,29 +52,29 @@ public class DownloadCommand extends AbstractDownloadCommand implements Internal
public DownloadCommand(DownloadCommand that) { public DownloadCommand(DownloadCommand that) {
super(that); super(that);
this.hvm = that.hvm; hvm = that.hvm;
this.checksum = that.checksum; checksum = that.checksum;
this.id = that.id; id = that.id;
this.description = that.description; description = that.description;
this.auth = that.getAuth(); auth = that.getAuth();
this.setSecUrl(that.getSecUrl()); setSecUrl(that.getSecUrl());
this.maxDownloadSizeInBytes = that.getMaxDownloadSizeInBytes(); maxDownloadSizeInBytes = that.getMaxDownloadSizeInBytes();
this.resourceType = that.resourceType; resourceType = that.resourceType;
this.installPath = that.installPath; installPath = that.installPath;
this._store = that._store; _store = that._store;
} }
public DownloadCommand(TemplateObjectTO template, Long maxDownloadSizeInBytes) { public DownloadCommand(TemplateObjectTO template, Long maxDownloadSizeInBytes) {
super(template.getName(), template.getOrigUrl(), template.getFormat(), template.getAccountId()); super(template.getName(), template.getOrigUrl(), template.getFormat(), template.getAccountId());
this._store = template.getDataStore(); _store = template.getDataStore();
this.installPath = template.getPath(); installPath = template.getPath();
this.hvm = template.isRequiresHvm(); hvm = template.isRequiresHvm();
this.checksum = template.getChecksum(); checksum = template.getChecksum();
this.id = template.getId(); id = template.getId();
this.description = template.getDescription(); description = template.getDescription();
if (_store instanceof NfsTO) { if (_store instanceof NfsTO) {
this.setSecUrl(((NfsTO) _store).getUrl()); setSecUrl(((NfsTO) _store).getUrl());
} }
this.maxDownloadSizeInBytes = maxDownloadSizeInBytes; this.maxDownloadSizeInBytes = maxDownloadSizeInBytes;
} }
@ -87,12 +86,12 @@ public class DownloadCommand extends AbstractDownloadCommand implements Internal
public DownloadCommand(VolumeObjectTO volume, Long maxDownloadSizeInBytes, String checkSum, String url, ImageFormat format) { public DownloadCommand(VolumeObjectTO volume, Long maxDownloadSizeInBytes, String checkSum, String url, ImageFormat format) {
super(volume.getName(), url, format, volume.getAccountId()); super(volume.getName(), url, format, volume.getAccountId());
this.checksum = checkSum; checksum = checkSum;
this.id = volume.getVolumeId(); id = volume.getVolumeId();
this.installPath = volume.getPath(); installPath = volume.getPath();
this._store = volume.getDataStore(); _store = volume.getDataStore();
this.maxDownloadSizeInBytes = maxDownloadSizeInBytes; this.maxDownloadSizeInBytes = maxDownloadSizeInBytes;
this.resourceType = ResourceType.VOLUME; resourceType = ResourceType.VOLUME;
} }
@Override @Override
public long getId() { public long getId() {
@ -184,6 +183,6 @@ public class DownloadCommand extends AbstractDownloadCommand implements Internal
} }
public DataStoreTO getCacheStore() { public DataStoreTO getCacheStore() {
return this.cacheStore; return cacheStore;
} }
} }

View File

@ -27,7 +27,6 @@ import java.util.Date;
import org.junit.Test; import org.junit.Test;
import com.cloud.agent.api.BackupSnapshotCommand; import com.cloud.agent.api.BackupSnapshotCommand;
import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.agent.api.to.SwiftTO; import com.cloud.agent.api.to.SwiftTO;
import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePool;