mirror of https://github.com/apache/jclouds.git
Merge pull request #888 from andreisavu/issue-973-1.5.x
Issue 973. Performance problems with Synaptic's Atmos service
This commit is contained in:
commit
108cd55676
|
@ -58,6 +58,7 @@ import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.ResponseParser;
|
import org.jclouds.rest.annotations.ResponseParser;
|
||||||
import org.jclouds.rest.annotations.SkipEncoding;
|
import org.jclouds.rest.annotations.SkipEncoding;
|
||||||
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
|
||||||
|
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ import com.google.inject.Inject;
|
||||||
/**
|
/**
|
||||||
* Handles Retryable responses with error codes in the 4xx range
|
* Handles Retryable responses with error codes in the 4xx range
|
||||||
*
|
*
|
||||||
|
* @see Error codes section at <a href="https://www.synaptic.att.com/assets/us/en/home/Atmos_Programmers_Guide_1.3.4A.pdf" />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class AtmosClientErrorRetryHandler implements HttpRetryHandler {
|
public class AtmosClientErrorRetryHandler implements HttpRetryHandler {
|
||||||
|
@ -62,14 +63,14 @@ public class AtmosClientErrorRetryHandler implements HttpRetryHandler {
|
||||||
if (response.getStatusCode() == 404 && command.getCurrentRequest().getMethod().equals("DELETE")) {
|
if (response.getStatusCode() == 404 && command.getCurrentRequest().getMethod().equals("DELETE")) {
|
||||||
command.incrementFailureCount();
|
command.incrementFailureCount();
|
||||||
return true;
|
return true;
|
||||||
} else if (response.getStatusCode() == 409 || response.getStatusCode() == 400) {
|
} else if (response.getStatusCode() == 409) {
|
||||||
byte[] content = HttpUtils.closeClientButKeepContentStream(response);
|
byte[] content = HttpUtils.closeClientButKeepContentStream(response);
|
||||||
// Content can be null in the case of HEAD requests
|
// Content can be null in the case of HEAD requests
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
try {
|
try {
|
||||||
AtmosError error = utils.parseAtmosErrorFromContent(command, response,
|
AtmosError error = utils.parseAtmosErrorFromContent(command, response,
|
||||||
new String(content));
|
new String(content));
|
||||||
if (error.getCode() == 1016) {
|
if (error.getCode() == 1006) {
|
||||||
return backoffHandler.shouldRetryRequest(command, response);
|
return backoffHandler.shouldRetryRequest(command, response);
|
||||||
}
|
}
|
||||||
// don't increment count before here, since backoff handler does already
|
// don't increment count before here, since backoff handler does already
|
||||||
|
|
|
@ -27,9 +27,11 @@ import javax.inject.Provider;
|
||||||
import org.jclouds.atmos.AtmosClient;
|
import org.jclouds.atmos.AtmosClient;
|
||||||
import org.jclouds.atmos.blobstore.functions.BlobToObject;
|
import org.jclouds.atmos.blobstore.functions.BlobToObject;
|
||||||
import org.jclouds.atmos.domain.AtmosError;
|
import org.jclouds.atmos.domain.AtmosError;
|
||||||
|
import org.jclouds.atmos.domain.AtmosObject;
|
||||||
import org.jclouds.atmos.filters.SignRequest;
|
import org.jclouds.atmos.filters.SignRequest;
|
||||||
import org.jclouds.atmos.options.PutOptions;
|
import org.jclouds.atmos.options.PutOptions;
|
||||||
import org.jclouds.atmos.xml.ErrorHandler;
|
import org.jclouds.atmos.xml.ErrorHandler;
|
||||||
|
import org.jclouds.blobstore.KeyAlreadyExistsException;
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.jclouds.crypto.Crypto;
|
import org.jclouds.crypto.Crypto;
|
||||||
import org.jclouds.http.HttpCommand;
|
import org.jclouds.http.HttpCommand;
|
||||||
|
@ -70,8 +72,15 @@ public class AtmosUtils {
|
||||||
public static String putBlob(final AtmosClient sync, Crypto crypto, BlobToObject blob2Object, String container,
|
public static String putBlob(final AtmosClient sync, Crypto crypto, BlobToObject blob2Object, String container,
|
||||||
Blob blob, PutOptions options) {
|
Blob blob, PutOptions options) {
|
||||||
final String path = container + "/" + blob.getMetadata().getName();
|
final String path = container + "/" + blob.getMetadata().getName();
|
||||||
deleteAndEnsureGone(sync, path);
|
final AtmosObject object = blob2Object.apply(blob);
|
||||||
sync.createFile(container, blob2Object.apply(blob), options);
|
|
||||||
|
try {
|
||||||
|
sync.createFile(container, object, options);
|
||||||
|
|
||||||
|
} catch(KeyAlreadyExistsException e) {
|
||||||
|
deleteAndEnsureGone(sync, path);
|
||||||
|
sync.createFile(container, object, options);
|
||||||
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ public class AtmosLiveTest extends BaseBlobLiveTest {
|
||||||
public AtmosLiveTest() {
|
public AtmosLiveTest() {
|
||||||
provider = "atmos";
|
provider = "atmos";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void checkMD5(String container, String name, byte[] md5) {
|
protected void checkMD5(String container, String name, byte[] md5) {
|
||||||
// atmos does not support content-md5 yet
|
// atmos does not support content-md5 yet
|
||||||
assertEquals(view.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), null);
|
assertEquals(view.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), null);
|
||||||
|
|
|
@ -29,4 +29,7 @@ import org.testng.annotations.Test;
|
||||||
@Test(groups = "live", sequential = true, testName = "SynapticStorageClientLiveTest")
|
@Test(groups = "live", sequential = true, testName = "SynapticStorageClientLiveTest")
|
||||||
public class SynapticStorageClientLiveTest extends AtmosClientLiveTest {
|
public class SynapticStorageClientLiveTest extends AtmosClientLiveTest {
|
||||||
|
|
||||||
|
public SynapticStorageClientLiveTest() {
|
||||||
|
provider = "synaptic-storage";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue