protected Map<String, Long> readValues(File file) throws JSONSerDeException, IOException { if (file.exists()) { return JSONSerDe.deSer(Files.toString(file, UTF8), MAP_STRING_LONG_TYPE_REF); } else { return null; } } }
protected JSONTablespaceDefinition loadTablespaceFile(String tablespaceFile) throws IOException, JSONSerDe.JSONSerDeException { Path file = new Path(tablespaceFile); FileSystem fS = FileSystem.get(file.toUri(), getConf()); if (!fS.exists(file)) { throw new IllegalArgumentException("Config input file: " + file + " doesn't exist!"); } String strContents = HadoopUtils.fileToString(fS, file); JSONTablespaceDefinition def = JSONSerDe.deSer(strContents, JSONTablespaceDefinition.class); return def; }
@SuppressWarnings({"unchecked", "rawtypes"}) @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String tablespace = req.getParameter("tablespace"); StringBuffer postBody = new StringBuffer(); String line = null; BufferedReader reader = req.getReader(); while ((line = reader.readLine()) != null) { postBody.append(line); } Map<String, Object> params; try { params = JSONSerDe.deSer(postBody.toString(), Map.class); String[] keys = (String[]) ((ArrayList) params.get("key")).toArray(new String[0]); String sql = (String) params.get("sql"); String callback = (String) params.get("callback"); String partition = (String) params.get("partition"); handle(req, resp, keys, tablespace, sql, callback, partition); } catch(JSONSerDeException e) { throw new IOException(e); } }
public QueryStatus query(String tablespace, String key, String query, String partition) throws IOException { URI uri; try { uri = new URI("http", qNodesNoProtocol[(int) (Math.random() * qNodes.length)], "/api/query/" + tablespace, "&sql=" + query + (key != null ? "&key=" + key : "") + (partition != null ? "&partition=" + partition : ""), null); HttpRequest request = requestFactory.buildGetRequest(new GenericUrl(uri.toASCIIString())); HttpResponse resp = request.execute(); try { return JSONSerDe.deSer(asString(resp.getContent()), QueryStatus.class); } catch(JSONSerDeException e) { throw new IOException(e); } } catch(URISyntaxException e) { throw new IllegalArgumentException(e); } }
public DeployInfo deploy(final DeployRequest... requests) throws IOException { try { String strCont = JSONSerDe.ser(new ArrayList<DeployRequest>(Arrays.asList(requests))); HttpContent content = new StringHttpContent(strCont); HttpRequest request = requestFactory.buildPostRequest(new GenericUrl( qNodes[(int) (Math.random() * qNodes.length)] + "/api/deploy"), content); HttpResponse resp = request.execute(); return JSONSerDe.deSer(asString(resp.getContent()), DeployInfo.class); } catch (JSONSerDeException e) { throw new IOException(e); } }
public QueryStatus query(String tablespace, String key, String query, String partition) throws IOException { URI uri; try { uri = new URI("http", qNodesNoProtocol[(int) (Math.random() * qNodes.length)], "/api/query/" + tablespace, "&sql=" + query + (key != null ? "&key=" + key : "") + (partition != null ? "&partition=" + partition : "") , null); HttpRequest request = requestFactory.buildGetRequest(new GenericUrl(uri.toASCIIString())); HttpResponse resp = request.execute(); try { return JSONSerDe.deSer(asString(resp.getContent()), QueryStatus.class); } catch (JSONSerDeException e) { throw new IOException(e); } } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } }
public Tablespace tablespace(String tablespace) throws IOException { HttpRequest request = requestFactory.buildGetRequest(new GenericUrl( qNodes[(int) (Math.random() * qNodes.length)] + "/api/tablespace/" + tablespace)); HttpResponse resp = request.execute(); try { return JSONSerDe.deSer(asString(resp.getContent()), Tablespace.class); } catch (JSONSerDeException e) { throw new IOException(e); } }
@SuppressWarnings("unchecked") public List<String> dNodeList() throws IOException { HttpRequest request = requestFactory.buildGetRequest(new GenericUrl( qNodes[(int) (Math.random() * qNodes.length)] + "/api/dnodelist")); HttpResponse resp = request.execute(); try { return JSONSerDe.deSer(asString(resp.getContent()), ArrayList.class); } catch (JSONSerDeException e) { throw new IOException(e); } }
public Tablespace tablespace(String tablespace) throws IOException { HttpRequest request = requestFactory.buildGetRequest(new GenericUrl( qNodes[(int) (Math.random() * qNodes.length)] + "/api/tablespace/" + tablespace)); HttpResponse resp = request.execute(); try { return JSONSerDe.deSer(asString(resp.getContent()), Tablespace.class); } catch(JSONSerDeException e) { throw new IOException(e); } }
@SuppressWarnings("unchecked") public List<String> dNodeList() throws IOException { HttpRequest request = requestFactory.buildGetRequest(new GenericUrl( qNodes[(int) (Math.random() * qNodes.length)] + "/api/dnodelist")); HttpResponse resp = request.execute(); try { return JSONSerDe.deSer(asString(resp.getContent()), ArrayList.class); } catch(JSONSerDeException e) { throw new IOException(e); } }
public DeployInfo deploy(final DeployRequest... requests) throws IOException { try { String strCont = JSONSerDe.ser(new ArrayList<DeployRequest>(Arrays.asList(requests))); HttpContent content = new StringHttpContent(strCont); HttpRequest request = requestFactory.buildPostRequest(new GenericUrl( qNodes[(int) (Math.random() * qNodes.length)] + "/api/deploy"), content); HttpResponse resp = request.execute(); return JSONSerDe.deSer(asString(resp.getContent()), DeployInfo.class); } catch(JSONSerDeException e) { throw new IOException(e); } }
public QueryStatus queryPost(String tablespace, String key, String query, String partition) throws IOException { Map<String, Object> params = new HashMap<String, Object>(); params.put("sql", query); params.put("key", new String[] { key }); params.put("partition", partition); try { HttpContent content = new StringHttpContent(JSONSerDe.ser(params)); HttpRequest request = requestFactory.buildPostRequest(new GenericUrl( qNodes[(int) (Math.random() * qNodes.length)] + "/api/query/" + tablespace), content); HttpResponse resp = request.execute(); return JSONSerDe.deSer(asString(resp.getContent()), QueryStatus.class); } catch(JSONSerDeException e) { throw new IOException(e); } } }
public QNodeStatus overview() throws IOException { HttpRequest request = requestFactory.buildGetRequest(new GenericUrl( qNodes[(int) (Math.random() * qNodes.length)] + "/api/overview")); HttpResponse resp = request.execute(); try { return JSONSerDe.deSer(asString(resp.getContent()), QNodeStatus.class); } catch (JSONSerDeException e) { throw new IOException(e); } }
public QueryStatus queryPost(String tablespace, String key, String query, String partition) throws IOException { Map<String, Object> params = new HashMap<String, Object>(); params.put("sql", query); params.put("key", new String[]{key}); params.put("partition", partition); try { HttpContent content = new StringHttpContent(JSONSerDe.ser(params)); HttpRequest request = requestFactory.buildPostRequest(new GenericUrl( qNodes[(int) (Math.random() * qNodes.length)] + "/api/query/" + tablespace), content); HttpResponse resp = request.execute(); return JSONSerDe.deSer(asString(resp.getContent()), QueryStatus.class); } catch (JSONSerDeException e) { throw new IOException(e); } }
public QNodeStatus overview() throws IOException { HttpRequest request = requestFactory.buildGetRequest(new GenericUrl( qNodes[(int) (Math.random() * qNodes.length)] + "/api/overview")); HttpResponse resp = request.execute(); try { return JSONSerDe.deSer(asString(resp.getContent()), QNodeStatus.class); } catch(JSONSerDeException e) { throw new IOException(e); } }
public StatusMessage cancelDeploy(long version) throws IOException { HttpRequest request = requestFactory.buildGetRequest(new GenericUrl( qNodes[(int) (Math.random() * qNodes.length)] + "/api/canceldeployment?version=" + version)); HttpResponse resp = request.execute(); try { return JSONSerDe.deSer(asString(resp.getContent()), StatusMessage.class); } catch (JSONSerDeException e) { throw new IOException(e); } } }
JSONSerDe.deSer(manager.query("SELECT * FROM t;", 100), ArrayList.class); throw new AssertionError("Exception was not thrown but it was expected (query hard limit)"); } catch(EngineException e) { JSONSerDe.deSer(manager.query("SELECT * FROM t;", 10), ArrayList.class); throw new AssertionError("Exception was not thrown but it was expected (query hard limit)"); } catch(EngineException e) { JSONSerDe.deSer(manager.query("SELECT * FROM t;", 1), ArrayList.class); throw new AssertionError("Exception was not thrown but it was expected (query hard limit)"); } catch(EngineException e) {
/** * Return a properly filled {@link DNodeSystemStatus} */ @Override public DNodeSystemStatus dnodeStatus(String dnode) throws Exception { DNodeService.Client client = null; boolean renew = false; try { client = getContext().getDNodeClientFromPool(dnode); return JSONSerDe.deSer(client.status(), DNodeSystemStatus.class); } catch (TTransportException e) { renew = true; throw e; } finally { if (client != null) { context.returnDNodeClientToPool(dnode, client, renew); } } }
try { client = getContext().getDNodeClientFromPool(dnode.getAddress()); aliveDNodes.put(dnode.getAddress(), JSONSerDe.deSer(client.status(), DNodeSystemStatus.class)); } catch (TTransportException e) { renew = true;