public boolean isConnectionOpen() { return this.connection.isOpen(); }
public boolean isConnectionOpen() { return this.connection.isOpen(); }
/** * Prepare query. * * @param sql the sql * @param queryName the query name * @return the query prepare handle * @throws LensAPIException */ public LensAPIResult<QueryPrepareHandle> prepareQuery(String sql, String queryName, LensConf conf) throws LensAPIException { if (!connection.isOpen()) { throw new IllegalStateException("Lens Connection has to be established before querying"); } Client client = connection.buildClient(); WebTarget target = getPreparedQueriesWebTarget(client); Response response = target.request().post(Entity.entity(prepareForm(sql, "PREPARE", queryName, conf), MediaType.MULTIPART_FORM_DATA_TYPE)); if (response.getStatus() == Response.Status.OK.getStatusCode()) { return response.readEntity(new GenericType<LensAPIResult<QueryPrepareHandle>>() {}); } throw new LensAPIException(response.readEntity(LensAPIResult.class)); }
/** * Explain and prepare. * * @param sql the sql * @param queryName the query name * @param conf config to be used for the query * @return the query plan * @throws LensAPIException */ public LensAPIResult<QueryPlan> explainAndPrepare(String sql, String queryName, LensConf conf) throws LensAPIException { if (!connection.isOpen()) { throw new IllegalStateException("Lens Connection has to be established before querying"); } Client client = connection.buildClient(); WebTarget target = getPreparedQueriesWebTarget(client); Response response = target.request().post( Entity.entity(prepareForm(sql, "EXPLAIN_AND_PREPARE", queryName, conf), MediaType.MULTIPART_FORM_DATA_TYPE), Response.class); if (response.getStatus() == Response.Status.OK.getStatusCode()) { return response.readEntity(new GenericType<LensAPIResult<QueryPlan>>() {}); } throw new LensAPIException(response.readEntity(LensAPIResult.class)); }
/** * Prepare query. * * @param sql the sql * @param queryName the query name * @return the query prepare handle * @throws LensAPIException */ public LensAPIResult<QueryPrepareHandle> prepareQuery(String sql, String queryName, LensConf conf) throws LensAPIException { if (!connection.isOpen()) { throw new IllegalStateException("Lens Connection has to be established before querying"); } Client client = connection.buildClient(); WebTarget target = getPreparedQueriesWebTarget(client); Response response = target.request().post(Entity.entity(prepareForm(sql, "PREPARE", queryName, conf), MediaType.MULTIPART_FORM_DATA_TYPE)); if (response.getStatus() == Response.Status.OK.getStatusCode()) { return response.readEntity(new GenericType<LensAPIResult<QueryPrepareHandle>>() {}); } throw new LensAPIException(response.readEntity(LensAPIResult.class)); }
/** * Explain and prepare. * * @param sql the sql * @param queryName the query name * @param conf config to be used for the query * @return the query plan * @throws LensAPIException */ public LensAPIResult<QueryPlan> explainAndPrepare(String sql, String queryName, LensConf conf) throws LensAPIException { if (!connection.isOpen()) { throw new IllegalStateException("Lens Connection has to be established before querying"); } Client client = connection.buildClient(); WebTarget target = getPreparedQueriesWebTarget(client); Response response = target.request().post( Entity.entity(prepareForm(sql, "EXPLAIN_AND_PREPARE", queryName, conf), MediaType.MULTIPART_FORM_DATA_TYPE), Response.class); if (response.getStatus() == Response.Status.OK.getStatusCode()) { return response.readEntity(new GenericType<LensAPIResult<QueryPlan>>() {}); } throw new LensAPIException(response.readEntity(LensAPIResult.class)); }
/** * Explain query. * * @param sql the sql * @param conf config to be used for the query * @return the query plan * @throws LensAPIException */ public LensAPIResult<QueryPlan> explainQuery(String sql, LensConf conf) throws LensAPIException { if (!connection.isOpen()) { throw new IllegalStateException("Lens Connection has to be established before querying"); } Client client = connection.buildClient(); FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), connection .getSessionHandle(), MediaType.APPLICATION_XML_TYPE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), sql)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "explain")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, MediaType.APPLICATION_XML_TYPE)); WebTarget target = getQueryWebTarget(client); Response response = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE)); if (response.getStatus() == Response.Status.OK.getStatusCode()) { return response.readEntity(new GenericType<LensAPIResult<QueryPlan>>() {}); } throw new LensAPIException(response.readEntity(LensAPIResult.class)); }
/** * Explain query. * * @param sql the sql * @param conf config to be used for the query * @return the query plan * @throws LensAPIException */ public LensAPIResult<QueryPlan> explainQuery(String sql, LensConf conf) throws LensAPIException { if (!connection.isOpen()) { throw new IllegalStateException("Lens Connection has to be established before querying"); } Client client = connection.buildClient(); FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), connection .getSessionHandle(), MediaType.APPLICATION_XML_TYPE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), sql)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "explain")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, MediaType.APPLICATION_XML_TYPE)); WebTarget target = getQueryWebTarget(client); Response response = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE)); if (response.getStatus() == Response.Status.OK.getStatusCode()) { return response.readEntity(new GenericType<LensAPIResult<QueryPlan>>() {}); } throw new LensAPIException(response.readEntity(LensAPIResult.class)); }
if (!connection.isOpen()) { throw new IllegalStateException("Lens Connection has to be established before querying");
if (!connection.isOpen()) { throw new IllegalStateException("Lens Connection has to be established before querying");
/** * Execute query. * * @param phandle the phandle * @param queryName the query name * @param conf config to be used for the query * @return the query handle */ private QueryHandle submitQuery(QueryPrepareHandle phandle, String queryName, LensConf conf) { if (!connection.isOpen()) { throw new IllegalStateException("Lens Connection has to be " + "established before querying"); } Client client = connection.buildClient(); WebTarget target = getPreparedQueriesWebTarget((client)).path(phandle.toString()); FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), connection .getSessionHandle(), MediaType.APPLICATION_XML_TYPE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("queryName").build(), queryName == null ? "" : queryName)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, MediaType.APPLICATION_XML_TYPE)); QueryHandle handle = target.request() .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), QueryHandle.class); this.query = new ProxyLensQuery(this, handle); return handle; }
/** * Execute query. * * @param phandle the phandle * @param queryName the query name * @param conf config to be used for the query * @return the query handle */ private QueryHandle submitQuery(QueryPrepareHandle phandle, String queryName, LensConf conf) { if (!connection.isOpen()) { throw new IllegalStateException("Lens Connection has to be " + "established before querying"); } Client client = connection.buildClient(); WebTarget target = getPreparedQueriesWebTarget((client)).path(phandle.toString()); FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), connection .getSessionHandle(), MediaType.APPLICATION_XML_TYPE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("queryName").build(), queryName == null ? "" : queryName)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, MediaType.APPLICATION_XML_TYPE)); QueryHandle handle = target.request() .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), QueryHandle.class); this.query = new ProxyLensQuery(this, handle); return handle; }
if (!connection.isOpen()) { throw new IllegalStateException("Lens Connection has to be established before querying");
if (!connection.isOpen()) { throw new IllegalStateException("Lens Connection has to be established before querying");