@Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof AtmosObject, "this binder is only valid for AtmosObject!"); checkNotNull(request, "request"); AtmosObject object = AtmosObject.class.cast(input); checkNotNull(object.getPayload(), "object payload"); checkArgument(object.getPayload().getContentMetadata().getContentLength() != null, "contentLength must be set, streaming not supported"); return metaBinder.bindToRequest(request, object.getUserMetadata()); } }
@Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof AtmosObject, "this binder is only valid for AtmosObject!"); checkNotNull(request, "request"); AtmosObject object = AtmosObject.class.cast(input); checkNotNull(object.getPayload(), "object payload"); checkArgument(object.getPayload().getContentMetadata().getContentLength() != null, "contentLength must be set, streaming not supported"); return metaBinder.bindToRequest(request, object.getUserMetadata()); } }
@Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof AtmosObject, "this binder is only valid for AtmosObject!"); checkNotNull(request, "request"); AtmosObject object = AtmosObject.class.cast(input); checkNotNull(object.getPayload(), "object payload"); checkArgument(object.getPayload().getContentMetadata().getContentLength() != null, "contentLength must be set, streaming not supported"); byte[] contentMD5 = object.getContentMetadata().getContentMD5(); if (contentMD5 != null) { request = (R) request.toBuilder() .addHeader(AtmosHeaders.CHECKSUM, "MD5/0/" + BaseEncoding.base16().encode(contentMD5)) .build(); } return metaBinder.bindToRequest(request, object.getUserMetadata()); } }
@Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof AtmosObject, "this binder is only valid for AtmosObject!"); checkNotNull(request, "request"); AtmosObject object = AtmosObject.class.cast(input); checkNotNull(object.getPayload(), "object payload"); checkArgument(object.getPayload().getContentMetadata().getContentLength() != null, "contentLength must be set, streaming not supported"); byte[] contentMD5 = object.getContentMetadata().getContentMD5(); if (contentMD5 != null) { request = (R) request.toBuilder() .addHeader(AtmosHeaders.CHECKSUM, "MD5/0/" + BaseEncoding.base16().encode(contentMD5)) .build(); } return metaBinder.bindToRequest(request, object.getUserMetadata()); } }
@Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof AtmosObject, "this binder is only valid for AtmosObject!"); checkNotNull(request, "request"); AtmosObject object = AtmosObject.class.cast(input); checkNotNull(object.getPayload(), "object payload"); checkArgument(object.getPayload().getContentMetadata().getContentLength() != null, "contentLength must be set, streaming not supported"); byte[] contentMD5 = object.getContentMetadata().getContentMD5(); if (contentMD5 != null) { request = (R) request.toBuilder() .addHeader(AtmosHeaders.CHECKSUM, "MD5/0/" + BaseEncoding.base16().encode(contentMD5)) .build(); } return metaBinder.bindToRequest(request, object.getUserMetadata()); } }
protected void retryAndCheckSystemMetadataAndPutIfPresentReplaceStrategy(AtmosObject object) throws Exception { int failures = 0; while (true) { try { checkSystemMetadataAndPutIfPresentReplaceStrategy(object); break; } catch (ExecutionException e1) {// bug if (!(e1.getCause() instanceof KeyAlreadyExistsException)) throw e1; else failures++; } } if (failures > 0) System.err.printf("%d failures create/replacing %s%n", failures, object.getPayload() instanceof InputStreamPayload ? "stream" : "string"); }
protected void retryAndCheckSystemMetadataAndPutIfPresentReplaceStrategy(AtmosObject object) throws Exception { int failures = 0; while (true) { try { checkSystemMetadataAndPutIfPresentReplaceStrategy(object); break; } catch (ExecutionException e1) {// bug if (!(e1.getCause() instanceof KeyAlreadyExistsException)) throw e1; else failures++; } } if (failures > 0) System.err.printf("%d failures create/replacing %s%n", failures, object.getPayload() instanceof InputStreamPayload ? "stream" : "string"); }
private void alwaysDeleteFirstReplaceStrategy(AtmosObject object) throws Exception { deleteConfirmed(privateDirectory + "/" + object.getContentMetadata().getName()); long time = System.currentTimeMillis(); try { getApi().createFile(privateDirectory, object); System.err.printf("%s %s; %dms%n", "created", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time); } catch (Exception e) { String message = Throwables.getRootCause(e).getMessage(); System.err.printf("failure %s %s; %dms: [%s]%n", "creating", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time, message); throw e; } }
private void alwaysDeleteFirstReplaceStrategy(AtmosObject object) throws Exception { deleteConfirmed(privateDirectory + "/" + object.getContentMetadata().getName()); long time = System.currentTimeMillis(); try { getApi().createFile(privateDirectory, object); System.err.printf("%s %s; %dms%n", "created", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time); } catch (Exception e) { String message = Throwables.getRootCause(e).getMessage(); System.err.printf("failure %s %s; %dms: [%s]%n", "creating", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time, message); throw e; } }
private static void verifyObject(AtmosClient connection, String path, String compare, String metadataValue) throws InterruptedException, ExecutionException, TimeoutException, IOException { AtmosObject getBlob = connection.readFile(path); assertEquals(Strings2.toString(getBlob.getPayload()), compare); verifyMetadata(metadataValue, getBlob); }
private static void verifyHeadObject(AtmosClient connection, String path, String metadataValue) throws InterruptedException, ExecutionException, TimeoutException, IOException { AtmosObject getBlob = connection.headFile(path); assertEquals(Strings2.toString(getBlob.getPayload()), ""); verifyMetadata(metadataValue, getBlob); }
public Blob apply(AtmosObject from) { if (from == null) return null; Blob blob = blobFactory.create(object2BlobMd.apply(from)); blob.setPayload(checkNotNull(from.getPayload(), "payload: " + from)); HttpUtils.copy(from.getContentMetadata(), blob.getPayload().getContentMetadata()); blob.setAllHeaders(from.getAllHeaders()); return blob; } }
public Blob apply(AtmosObject from) { if (from == null) return null; Blob blob = blobFactory.create(object2BlobMd.apply(from)); blob.setPayload(checkNotNull(from.getPayload(), "payload: " + from)); HttpUtils.copy(from.getContentMetadata(), blob.getPayload().getContentMetadata()); blob.setAllHeaders(from.getAllHeaders()); return blob; } }
public Blob apply(AtmosObject from) { if (from == null) return null; Blob blob = blobFactory.create(object2BlobMd.apply(from)); blob.setPayload(checkNotNull(from.getPayload(), "payload: " + from)); HttpUtils.copy(from.getContentMetadata(), blob.getPayload().getContentMetadata()); blob.setAllHeaders(from.getAllHeaders()); return blob; } }
public Blob apply(AtmosObject from) { if (from == null) return null; Blob blob = blobFactory.create(object2BlobMd.apply(from)); blob.setPayload(checkNotNull(from.getPayload(), "payload: " + from)); HttpUtils.copy(from.getContentMetadata(), blob.getPayload().getContentMetadata()); blob.setAllHeaders(from.getAllHeaders()); return blob; } }
public Blob apply(AtmosObject from) { if (from == null) return null; Blob blob = blobFactory.create(object2BlobMd.apply(from)); blob.setPayload(checkNotNull(from.getPayload(), "payload: " + from)); HttpUtils.copy(from.getContentMetadata(), blob.getPayload().getContentMetadata()); blob.setAllHeaders(from.getAllHeaders()); return blob; } }
public Blob apply(AtmosObject from) { if (from == null) return null; Blob blob = blobFactory.create(object2BlobMd.apply(from)); blob.setPayload(checkNotNull(from.getPayload(), "payload: " + from)); HttpUtils.copy(from.getContentMetadata(), blob.getPayload().getContentMetadata()); blob.setAllHeaders(from.getAllHeaders()); return blob; } }
public Blob apply(AtmosObject from) { if (from == null) return null; Blob blob = blobFactory.create(object2BlobMd.apply(from)); blob.setPayload(checkNotNull(from.getPayload(), "payload: " + from)); HttpUtils.copy(from.getContentMetadata(), blob.getPayload().getContentMetadata()); blob.setAllHeaders(from.getAllHeaders()); return blob; } }
private static void verifyObject(AtmosClient connection, String path, String compare, String metadataValue) throws InterruptedException, ExecutionException, TimeoutException, IOException { AtmosObject getBlob = connection.readFile(path); assertEquals(Strings2.toStringAndClose(getBlob.getPayload().openStream()), compare); verifyMetadata(metadataValue, getBlob); }
private static void verifyHeadObject(AtmosClient connection, String path, String metadataValue) throws InterruptedException, ExecutionException, TimeoutException, IOException { AtmosObject getBlob = connection.headFile(path); assertEquals(Strings2.toStringAndClose(getBlob.getPayload().openStream()), ""); verifyMetadata(metadataValue, getBlob); }