@Override public String executeRequest(String url) throws Exception { trace("API call: " + url); String response = super.executeRequest(url); traceResponse(response); return response; }
public void tailLog(String appId, String logName, OutputStream out) throws Exception { Map<String, String> params = new HashMap<String, String>(); params.put("app_id", appId); params.put("log_name", logName); String url = getRequestURL("tail", params, false); trace("API call: " + url); InputStream input = executeCometRequest(url); byte[] bytes = new byte[1024]; int numRead = input.read(bytes); while (numRead != -1) { out.write(bytes, 0, numRead); numRead = input.read(bytes); } }
public void tailLog(String appId, String logName, OutputStream out) throws Exception { Map<String, String> params = new HashMap<String, String>(); params.put("app_id", appId); params.put("log_name", logName); String url = getRequestURL("tail", params, false); trace("API call: " + url); InputStream input = executeCometRequest(url); byte[] bytes = new byte[1024]; int numRead = input.read(bytes); while (numRead != -1) { out.write(bytes, 0, numRead); numRead = input.read(bytes); } }
@Override public String executeRequest(String url) throws Exception { trace("API call: " + url); String response = super.executeRequest(url); traceResponse(response); return response; }
@Override protected String executeUpload(String uploadURL, Map<String, String> params, Map<String, File> files, UploadProgress writeListener) throws Exception { if (isVerbose()) { String msg = "API call: " + uploadURL; if (params != null && params.size() > 0) msg += ",P" + params; if (files != null && files.size() > 0) msg += ",F" + files; trace(msg); } return super.executeUpload(uploadURL, params, files, writeListener); }
public void applicationInstanceTailLog(String instanceId, String logName, OutputStream out) throws Exception { Map<String, String> params = new HashMap<String, String>(); params.put("instance_id", instanceId); params.put("log_name", logName); String url = getRequestURL("tail", params, false); trace("API call: " + url); InputStream input = executeCometRequest(url); byte[] bytes = new byte[1024]; int numRead = input.read(bytes); while (numRead != -1) { out.write(bytes, 0, numRead); numRead = input.read(bytes); } }
@Override protected String executeUpload(String uploadURL, Map<String, String> params, Map<String, File> files, UploadProgress writeListener) throws Exception { if (isVerbose()) { String msg = "API call: " + uploadURL; if (params != null && params.size() > 0) msg += ",P" + params; if (files != null && files.size() > 0) msg += ",F" + files; trace(msg); } return super.executeUpload(uploadURL, params, files, writeListener); }
public void applicationInstanceTailLog(String instanceId, String logName, OutputStream out) throws Exception { Map<String, String> params = new HashMap<String, String>(); params.put("instance_id", instanceId); params.put("log_name", logName); String url = getRequestURL("tail", params, false); trace("API call: " + url); InputStream input = executeCometRequest(url); byte[] bytes = new byte[1024]; int numRead = input.read(bytes); while (numRead != -1) { out.write(bytes, 0, numRead); numRead = input.read(bytes); } }
/** * Sends a request in JSON and expects a JSON response back. * * @param urlTail The end point to hit. Appended to {@link #base}. Shouldn't start with '/' * @param headers HTTP headers * @param params * Form parameters */ /*package*/ HttpReply formUrlEncoded(String urlTail, Map<String, String> headers, Map<String,List<String>> params) throws IOException { String urlString = absolutize(urlTail); trace("API call: " + urlString); PostMethod httpMethod = new PostMethod(urlString); httpMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); for (Entry<String, List<String>> e : params.entrySet()) { for (String v : e.getValue()) { httpMethod.addParameter(e.getKey(),v); } } return executeRequest(httpMethod,headers); }
/** * Sends a request in JSON and expects a JSON response back. * * @param urlTail The end point to hit. Appended to {@link #base}. Shouldn't start with '/' * @param headers HTTP headers * @param params * Form parameters */ /*package*/ HttpReply formUrlEncoded(String urlTail, Map<String, String> headers, Map<String,List<String>> params) throws IOException { String urlString = absolutize(urlTail); trace("API call: " + urlString); PostMethod httpMethod = new PostMethod(urlString); httpMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); for (Entry<String, List<String>> e : params.entrySet()) { for (String v : e.getValue()) { httpMethod.addParameter(e.getKey(),v); } } return executeRequest(httpMethod,headers); }
trace("Get existing checksums"); ApplicationCheckSumsResponse applicationCheckSumsResponse = applicationCheckSums(args.appId, false); if (logger.isLoggable(Level.FINER)) { trace("No existing checksums, upload full archive"); } else { trace("Creating Delta archive for: " + archiveFile); archiveFile = ArchiveUtils.createDeltaWarFile(applicationCheckSumsResponse.getCheckSums(), archiveFile, archiveFile.getParent()); trace("Get existing jar hashes"); ApplicationJarHashesResponse applicationJarHashesResponse = applicationJarHashes(args.appId, JarUtils.getJarHashes(archiveFile)); if (applicationJarHashesResponse.getJarHash().size() == 0) { trace("No existing jars"); } else { trace("Creating Delta2 archive for: " + archiveFile); File archiveFile2 = JarUtils.createDeltaWarFile(applicationJarHashesResponse.getJarHash(), archiveFile, archiveFile.getParent()); trace("Uploading delta archive: " + archiveFile);
trace("Get existing checksums"); ApplicationCheckSumsResponse applicationCheckSumsResponse = applicationCheckSums(args.appId, false); if (logger.isLoggable(Level.FINER)) { trace("No existing checksums, upload full archive"); } else { trace("Creating Delta archive for: " + archiveFile); archiveFile = ArchiveUtils.createDeltaWarFile(applicationCheckSumsResponse.getCheckSums(), archiveFile, archiveFile.getParent()); trace("Get existing jar hashes"); ApplicationJarHashesResponse applicationJarHashesResponse = applicationJarHashes(args.appId, JarUtils.getJarHashes(archiveFile)); if (applicationJarHashesResponse.getJarHash().size() == 0) { trace("No existing jars"); } else { trace("Creating Delta2 archive for: " + archiveFile); File archiveFile2 = JarUtils.createDeltaWarFile(applicationJarHashesResponse.getJarHash(), archiveFile, archiveFile.getParent()); trace("Uploading delta archive: " + archiveFile);
/** * Executes an HTTP method. */ private HttpReply executeRequest(HttpMethod httpMethod, Map<String, String> headers) throws IOException { BeesClientConfiguration conf = getBeesClientConfiguration(); HttpClient httpClient = HttpClientHelper.createClient(conf); if (encodedAccountAuthorization != null) httpMethod.setRequestHeader("Authorization", encodedAccountAuthorization); if (headers != null) { for (Map.Entry<String, String> entry: headers.entrySet()) { httpMethod.setRequestHeader(entry.getKey(), entry.getValue()); } } int status = 500; String rsp = "Error"; try { status = httpClient.executeMethod(httpMethod); rsp = IOUtils.toString(httpMethod.getResponseBodyAsStream()); } catch (IOException e) { throw (IOException)new IOException("Failed to " + httpMethod.getName() + " : " + httpMethod.getURI() + " : code=" + status + " response=" + e.getMessage()).initCause(e); } finally { httpMethod.releaseConnection(); } trace(status + ": " + rsp); return new HttpReply(httpMethod, status, rsp); }
trace("API call: " + urlString); if (method.equalsIgnoreCase("GET")) { httpMethod = new GetMethod(urlString); StringRequestEntity requestEntity = new StringRequestEntity(jsonContent, "application/json", "UTF-8"); ((EntityEnclosingMethod)httpMethod).setRequestEntity(requestEntity); trace("Payload: " + jsonContent);
/** * Executes an HTTP method. */ private HttpReply executeRequest(HttpMethod httpMethod, Map<String, String> headers) throws IOException { BeesClientConfiguration conf = getBeesClientConfiguration(); HttpClient httpClient = HttpClientHelper.createClient(conf); if (encodedAccountAuthorization != null) httpMethod.setRequestHeader("Authorization", encodedAccountAuthorization); if (headers != null) { for (Map.Entry<String, String> entry: headers.entrySet()) { httpMethod.setRequestHeader(entry.getKey(), entry.getValue()); } } int status = 500; String rsp = "Error"; try { status = httpClient.executeMethod(httpMethod); rsp = IOUtils.toString(httpMethod.getResponseBodyAsStream()); } catch (IOException e) { throw (IOException)new IOException("Failed to " + httpMethod.getName() + " : " + httpMethod.getURI() + " : code=" + status + " response=" + e.getMessage()).initCause(e); } finally { httpMethod.releaseConnection(); } trace(status + ": " + rsp); return new HttpReply(httpMethod, status, rsp); }
trace("API call: " + urlString); if (method.equalsIgnoreCase("GET")) { httpMethod = new GetMethod(urlString); StringRequestEntity requestEntity = new StringRequestEntity(jsonContent, "application/json", "UTF-8"); ((EntityEnclosingMethod)httpMethod).setRequestEntity(requestEntity); trace("Payload: " + jsonContent);