@Override protected void write(List<PingData> list, String clustername) { try { String filename = clustername + "/" + addressToFilename(local_addr); ByteArrayOutputStream out=new ByteArrayOutputStream(4096); write(list, out); byte[] data=out.toByteArray(); rackspaceClient.createObject(container, filename, data); } catch (Exception e) { log.error(Util.getMessage("ErrorMarshallingObject"), e); } }
/** * Create an object (=file) * * @param containerName Name of the container * @param objectName Name of the file * @param contents Binary content of the file */ public void createObject(String containerName, String objectName, byte[] contents) { HttpURLConnection conn = new ConnBuilder(credentials, containerName, objectName) .method("PUT") .addHeader(CONTENT_LENGTH_HEADER, String.valueOf(contents.length)) .getConnection(); Response response = doSendOperation(conn, contents); if (!response.isSuccessCode()) { if (response.isAuthDenied()) { log.warn("Refreshing credentials and retrying"); authenticate(); createObject(containerName, objectName, contents); } else { log.error(Util.getMessage("ErrorCreatingObject") + objectName + " in container " + containerName + ",code = " + response.code); } } }
@Override protected void write(List<PingData> list, String clustername) { try { String filename = clustername + "/" + addressToFilename(local_addr); ByteArrayOutputStream out=new ByteArrayOutputStream(4096); write(list, out); byte[] data=out.toByteArray(); rackspaceClient.createObject(container, filename, data); } catch (Exception e) { log.error(Util.getMessage("ErrorMarshallingObject"), e); } }
/** * Create an object (=file) * * @param containerName Name of the container * @param objectName Name of the file * @param contents Binary content of the file */ public void createObject(String containerName, String objectName, byte[] contents) { HttpURLConnection conn = new ConnBuilder(credentials, containerName, objectName) .method("PUT") .addHeader(CONTENT_LENGTH_HEADER, String.valueOf(contents.length)) .getConnection(); Response response = doSendOperation(conn, contents); if (!response.isSuccessCode()) { if (response.isAuthDenied()) { log.warn("Refreshing credentials and retrying"); authenticate(); createObject(containerName, objectName, contents); } else { log.error(Util.getMessage("ErrorCreatingObject") + objectName + " in container " + containerName + ",code = " + response.code); } } }