public String getKylinProperties() throws IOException { String url = baseUrl + "/admin/config"; HttpGet request = new HttpGet(url); HttpResponse response = null; try { response = client.execute(request); String msg = EntityUtils.toString(response.getEntity()); Map<String, String> map = JsonUtil.readValueAsMap(msg); msg = map.get("config"); if (response.getStatusLine().getStatusCode() != 200) throw new IOException(INVALID_RESPONSE + response.getStatusLine().getStatusCode() + " with cache wipe url " + url + "\n" + msg); return msg; } finally { cleanup(request, response); } }
public void wipeCache(String entity, String event, String cacheKey) throws IOException { HttpPut request; String url; if (cacheKey.contains("/")) { url = baseUrl + "/cache/" + entity + "/" + event; request = new HttpPut(url); request.setEntity(new StringEntity(cacheKey, ContentType.create(APPLICATION_JSON, UTF_8))); } else { url = baseUrl + "/cache/" + entity + "/" + cacheKey + "/" + event; request = new HttpPut(url); } HttpResponse response = null; try { response = client.execute(request); if (response.getStatusLine().getStatusCode() != 200) { String msg = EntityUtils.toString(response.getEntity()); throw new IOException(INVALID_RESPONSE + response.getStatusLine().getStatusCode() + " with cache wipe url " + url + "\n" + msg); } } finally { cleanup(request, response); } }
private boolean setCache(boolean flag) throws IOException { String url = baseUrl + "/admin/config"; HttpPut put = newPut(url); HttpResponse response = null; try { HashMap<String, String> paraMap = new HashMap<String, String>(); paraMap.put("key", "kylin.query.cache-enabled"); paraMap.put("value", flag + ""); put.setEntity(new StringEntity(new ObjectMapper().writeValueAsString(paraMap), UTF_8)); response = client.execute(put); EntityUtils.consume(response.getEntity()); if (response.getStatusLine().getStatusCode() != 200) { return false; } else { return true; } } finally { cleanup(put, response); } }
private boolean changeCubeStatus(String url) throws Exception { HttpPut put = newPut(url); HttpResponse response = null; try { HashMap<String, String> paraMap = new HashMap<String, String>(); String jsonMsg = new ObjectMapper().writeValueAsString(paraMap); put.setEntity(new StringEntity(jsonMsg, UTF_8)); response = client.execute(put); getContent(response); if (response.getStatusLine().getStatusCode() != 200) { throw new IOException( INVALID_RESPONSE + response.getStatusLine().getStatusCode() + WITH_URL + url + "\n" + jsonMsg); } else { return true; } } finally { cleanup(put, response); } }
public boolean buildCube(String cubeName, long startTime, long endTime, String buildType) throws Exception { String url = baseUrl + CUBES + cubeName + "/build"; HttpPut put = newPut(url); HttpResponse response = null; try { HashMap<String, String> paraMap = new HashMap<String, String>(); paraMap.put("startTime", startTime + ""); paraMap.put("endTime", endTime + ""); paraMap.put("buildType", buildType); String jsonMsg = new ObjectMapper().writeValueAsString(paraMap); put.setEntity(new StringEntity(jsonMsg, UTF_8)); response = client.execute(put); getContent(response); if (response.getStatusLine().getStatusCode() != 200) { throw new IOException(INVALID_RESPONSE + response.getStatusLine().getStatusCode() + " with build cube url " + url + "\n" + jsonMsg); } else { return true; } } finally { cleanup(put, response); } }
public HashMap getCube(String cubeName) throws Exception { String url = baseUrl + CUBES + cubeName; HttpGet get = newGet(url); HttpResponse response = null; try { get.setURI(new URI(url)); response = client.execute(get); return dealResponse(response); } finally { cleanup(get, response); } }
public String getKylinProperties() throws IOException { String url = baseUrl + "/admin/config"; HttpGet request = new HttpGet(url); HttpResponse response = null; try { response = client.execute(request); String msg = EntityUtils.toString(response.getEntity()); Map<String, String> map = JsonUtil.readValueAsMap(msg); msg = map.get("config"); if (response.getStatusLine().getStatusCode() != 200) throw new IOException(INVALID_RESPONSE + response.getStatusLine().getStatusCode() + " with cache wipe url " + url + "\n" + msg); return msg; } finally { cleanup(request, response); } }
public void wipeCache(String entity, String event, String cacheKey) throws IOException { HttpPut request; String url; if (cacheKey.contains("/")) { url = baseUrl + "/cache/" + entity + "/" + event; request = new HttpPut(url); request.setEntity(new StringEntity(cacheKey, ContentType.create(APPLICATION_JSON, UTF_8))); } else { url = baseUrl + "/cache/" + entity + "/" + cacheKey + "/" + event; request = new HttpPut(url); } HttpResponse response = null; try { response = client.execute(request); if (response.getStatusLine().getStatusCode() != 200) { String msg = EntityUtils.toString(response.getEntity()); throw new IOException(INVALID_RESPONSE + response.getStatusLine().getStatusCode() + " with cache wipe url " + url + "\n" + msg); } } finally { cleanup(request, response); } }
private boolean setCache(boolean flag) throws IOException { String url = baseUrl + "/admin/config"; HttpPut put = newPut(url); HttpResponse response = null; try { HashMap<String, String> paraMap = new HashMap<String, String>(); paraMap.put("key", "kylin.query.cache-enabled"); paraMap.put("value", flag + ""); put.setEntity(new StringEntity(new ObjectMapper().writeValueAsString(paraMap), UTF_8)); response = client.execute(put); EntityUtils.consume(response.getEntity()); if (response.getStatusLine().getStatusCode() != 200) { return false; } else { return true; } } finally { cleanup(put, response); } }
private boolean changeCubeStatus(String url) throws Exception { HttpPut put = newPut(url); HttpResponse response = null; try { HashMap<String, String> paraMap = new HashMap<String, String>(); String jsonMsg = new ObjectMapper().writeValueAsString(paraMap); put.setEntity(new StringEntity(jsonMsg, UTF_8)); response = client.execute(put); getContent(response); if (response.getStatusLine().getStatusCode() != 200) { throw new IOException( INVALID_RESPONSE + response.getStatusLine().getStatusCode() + WITH_URL + url + "\n" + jsonMsg); } else { return true; } } finally { cleanup(put, response); } }
public boolean buildCube(String cubeName, long startTime, long endTime, String buildType) throws Exception { String url = baseUrl + CUBES + cubeName + "/build"; HttpPut put = newPut(url); HttpResponse response = null; try { HashMap<String, String> paraMap = new HashMap<String, String>(); paraMap.put("startTime", startTime + ""); paraMap.put("endTime", endTime + ""); paraMap.put("buildType", buildType); String jsonMsg = new ObjectMapper().writeValueAsString(paraMap); put.setEntity(new StringEntity(jsonMsg, UTF_8)); response = client.execute(put); getContent(response); if (response.getStatusLine().getStatusCode() != 200) { throw new IOException(INVALID_RESPONSE + response.getStatusLine().getStatusCode() + " with build cube url " + url + "\n" + jsonMsg); } else { return true; } } finally { cleanup(put, response); } }
public HashMap getCube(String cubeName) throws Exception { String url = baseUrl + CUBES + cubeName; HttpGet get = newGet(url); HttpResponse response = null; try { get.setURI(new URI(url)); response = client.execute(get); return dealResponse(response); } finally { cleanup(get, response); } }