Skip to content

Commit

Permalink
Add /query_result
Browse files Browse the repository at this point in the history
  • Loading branch information
karol-brejna-i committed Dec 29, 2021
1 parent eec2c1e commit 20572ce
Show file tree
Hide file tree
Showing 17 changed files with 786 additions and 55 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Add this dependency to your project's POM:

```xml
<dependency>
<groupId>io.github.karol_brejna_i.tigergraph</groupId>
<groupId>io.github.karol-brejna-i.tigergraph</groupId>
<artifactId>restpp-client</artifactId>
<version>1.0.0</version>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
```
Expand All @@ -49,7 +49,7 @@ Add this dependency to your project's POM:
Add this dependency to your project's build file:

```groovy
compile "io.github.karol_brejna_i.tigergraph:restpp-client:1.0.0"
compile "io.github.karol-brejna-i.tigergraph:restpp-client:0.0.1-SNAPSHOT"
```

### Others
Expand All @@ -62,7 +62,7 @@ mvn clean package

Then manually install the following JARs:

* `target/restpp-client-1.0.0.jar`
* `target/restpp-client-0.0.1-SNAPSHOT.jar`
* `target/lib/*.jar`

## Getting Started
Expand Down Expand Up @@ -615,7 +615,8 @@ Class | Method | HTTP request | Description
*DiagnosticsApi* | [**statistics**](docs/DiagnosticsApi.md#statistics) | **GET** /statistics/{graph_name} | Show query performance
*DiagnosticsApi* | [**version**](docs/DiagnosticsApi.md#version) | **GET** /version/{graph_name} | Show component versions
*QueryApi* | [**abortQueryGet**](docs/QueryApi.md#abortQueryGet) | **GET** /abortquery/{graph_name} | Abort a query
*QueryApi* | [**abortQueryPost**](docs/QueryApi.md#abortQueryPost) | **POST** /abortquery/{graph_name} | Abort a query ** NOT TESTED **
*QueryApi* | [**abortQueryPost**](docs/QueryApi.md#abortQueryPost) | **POST** /abortquery/{graph_name} | Abort a query
*QueryApi* | [**queryResult**](docs/QueryApi.md#queryResult) | **GET** /query_result/{requestid} | Check query results (Detached Mode)
*QueryApi* | [**queryStatus**](docs/QueryApi.md#queryStatus) | **GET** /query_status/{graph_name} | Check query status (Detached Mode)
*QueryApi* | [**runInstalledQueryGet**](docs/QueryApi.md#runInstalledQueryGet) | **GET** /query/{graph_name}/{query_name} | Run an installed query
*QueryApi* | [**runInstalledQueryPost**](docs/QueryApi.md#runInstalledQueryPost) | **POST** /query/{graph_name}/{query_name} | Run an installed query
Expand All @@ -633,8 +634,10 @@ Class | Method | HTTP request | Description
- [ProcessInfo](docs/ProcessInfo.md)
- [ProcessListResponse](docs/ProcessListResponse.md)
- [QueryResponse](docs/QueryResponse.md)
- [QueryResultResponse](docs/QueryResultResponse.md)
- [QueryStatusItem](docs/QueryStatusItem.md)
- [QueryStatusResponse](docs/QueryStatusResponse.md)
- [QuerySubmittedResponse](docs/QuerySubmittedResponse.md)
- [StatisticsResponse](docs/StatisticsResponse.md)
- [Version](docs/Version.md)

Expand Down
52 changes: 49 additions & 3 deletions docs/QueryApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ All URIs are relative to *{protocol}://{host}:{port}*
Method | HTTP request | Description
------------- | ------------- | -------------
[**abortQueryGet**](QueryApi.md#abortQueryGet) | **GET** /abortquery/{graph_name} | Abort a query
[**abortQueryPost**](QueryApi.md#abortQueryPost) | **POST** /abortquery/{graph_name} | Abort a query ** NOT TESTED **
[**abortQueryPost**](QueryApi.md#abortQueryPost) | **POST** /abortquery/{graph_name} | Abort a query
[**queryResult**](QueryApi.md#queryResult) | **GET** /query_result/{requestid} | Check query results (Detached Mode)
[**queryStatus**](QueryApi.md#queryStatus) | **GET** /query_status/{graph_name} | Check query status (Detached Mode)
[**runInstalledQueryGet**](QueryApi.md#runInstalledQueryGet) | **GET** /query/{graph_name}/{query_name} | Run an installed query
[**runInstalledQueryPost**](QueryApi.md#runInstalledQueryPost) | **POST** /query/{graph_name}/{query_name} | Run an installed query
Expand Down Expand Up @@ -63,7 +64,7 @@ No authorization required
# **abortQueryPost**
> AbortQueryResponse abortQueryPost(graphName)
Abort a query ** NOT TESTED **
Abort a query

This endpoint safely aborts a selected query by ID or all queries of an endpoint by endpoint URL of a graph. See: https://docs.tigergraph.com/tigergraph-server/current/api/built-in-endpoints#_abort_a_query

Expand Down Expand Up @@ -99,6 +100,51 @@ Name | Type | Description | Notes

No authorization required

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

<a name="queryResult"></a>
# **queryResult**
> QueryResultResponse queryResult(requestid)
Check query results (Detached Mode)

This endpoint allows you to check the results of queries run in Detached Mode if they have finished running. If the query is still running, the endpoint will respond with an error and a message saying \&quot;Unable to retrieve result for query &lt;requestid&gt;\&quot;. Ensure that the query is finished before checking its result. See: https://docs.tigergraph.com/tigergraph-server/current/api/built-in-endpoints#_check_query_results_detached_mode

### Example
```java
// Import classes:
//import io.github.karol_brejna_i.tigergraph.restppclient.invoker.ApiException;
//import io.github.karol_brejna_i.tigergraph.restppclient.api.QueryApi;


QueryApi apiInstance = new QueryApi();
String requestid = "requestid_example"; // String | The id of a query request.
try {
QueryResultResponse result = apiInstance.queryResult(requestid);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling QueryApi#queryResult");
e.printStackTrace();
}
```

### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**requestid** | **String**| The id of a query request. |

### Return type

[**QueryResultResponse**](QueryResultResponse.md)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: Not defined
Expand Down Expand Up @@ -279,7 +325,7 @@ No authorization required
List running queries

This endpoint reports statistics of running queries of a graph: the querys request ID, start time, expiration time, and the REST endpoints URL See: https://docs.tigergraph.com/tigergraph-server/current/api/built-in-endpoints#_list_running_queries
This endpoint reports statistics of running queries of a graph: the query&#x27;s request ID, start time, expiration time, and the REST endpoint&#x27;s URL. See: https://docs.tigergraph.com/tigergraph-server/current/api/built-in-endpoints#_list_running_queries

### Example
```java
Expand Down
1 change: 1 addition & 0 deletions docs/QueryResponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Name | Type | Description | Notes
**error** | **Boolean** | | [optional]
**message** | **String** | | [optional]
**results** | **List&lt;Object&gt;** | | [optional]
**requestId** | **String** | | [optional]
9 changes: 9 additions & 0 deletions docs/QueryResultResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# QueryResultResponse

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**version** | [**Version**](Version.md) | | [optional]
**error** | **Boolean** | | [optional]
**message** | **String** | | [optional]
**results** | **List&lt;Object&gt;** | | [optional]
5 changes: 5 additions & 0 deletions docs/QueryStatusItem.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**requestid** | **String** | | [optional]
**startTime** | **String** | | [optional]
**expirationTime** | **String** | | [optional]
**url** | **String** | | [optional]
**elapsedTime** | **Integer** | | [optional]
**status** | [**StatusEnum**](#StatusEnum) | The status of the given query. | [optional]

<a name="StatusEnum"></a>
Expand Down
2 changes: 1 addition & 1 deletion docs/QueryStatusResponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ Name | Type | Description | Notes
**error** | **Boolean** | |
**message** | **String** | |
**results** | [**List&lt;QueryStatusItem&gt;**](QueryStatusItem.md) | |
**unknownRequestid** | **List&lt;String&gt;** | | [optional]
**unknownRequestid** | **List&lt;String&gt;** | If one or more of the provided query IDs (requestid) are invalid, the return JSON will include an unknown_requestid field containing all the invalid query IDs. If a query ID is marked as unknown, it means either the query does not exist or that it was not run in Detached Mode. | [optional]
**code** | **String** | |
8 changes: 8 additions & 0 deletions docs/QuerySubmittedResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# QuerySubmittedResponse

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**error** | **Boolean** | | [optional]
**message** | **String** | | [optional]
**requestId** | **String** | | [optional]
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Example {

static {
ApiClient defaultApiClient = Configuration.getDefaultApiClient();
defaultApiClient.setBasePath("http://192.168.0.105:9000");
defaultApiClient.setBasePath("http://172.28.101.214:9000");
Configuration.setDefaultApiClient(defaultApiClient);
}

Expand Down Expand Up @@ -83,7 +83,9 @@ public static void abortQuery(String requestId) {
System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
QueryApi apiInstance = new QueryApi();
AbortQueryResponse result = null;
// String requestId = "";
if (requestId == null) {
requestId = "all";
}
try {
result = apiInstance.abortQueryGet(graphName, requestId);
} catch (ApiException e) {
Expand All @@ -100,7 +102,5 @@ public static void main(String[] args) {
statistics();
listProcessGet();
abortQuery("all");
// abortQuery("16908295.RESTPP_1_1.1640621537660.N");

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
import io.github.karol_brejna_i.tigergraph.restppclient.invoker.ApiClient;
import io.github.karol_brejna_i.tigergraph.restppclient.invoker.ApiException;
import io.github.karol_brejna_i.tigergraph.restppclient.invoker.Configuration;
import io.github.karol_brejna_i.tigergraph.restppclient.model.AbortQueryResponse;
import io.github.karol_brejna_i.tigergraph.restppclient.model.ProcessListResponse;
import io.github.karol_brejna_i.tigergraph.restppclient.model.QueryResponse;
import io.github.karol_brejna_i.tigergraph.restppclient.model.*;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -32,7 +31,7 @@ public class QueryExamples {

static {
ApiClient defaultApiClient = Configuration.getDefaultApiClient();
defaultApiClient.setBasePath("http://192.168.0.105:9000");
defaultApiClient.setBasePath("http://172.28.101.214:9000");
Configuration.setDefaultApiClient(defaultApiClient);
}

Expand Down Expand Up @@ -79,14 +78,39 @@ public static void runQueryGet(String queryName) {
}
QueryResponse result = null;
try {
result = apiInstance.runInstalledQueryGet(graphName, queryName);
result = apiInstance.runInstalledQueryGet(graphName, queryName,
null, null, null, null, null, null, null);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#runQueryGet");
e.printStackTrace();
}
System.out.println(result);
}

public static String runQueryDetachedGet(String queryName) {
System.out.println("runQueryGet");
QueryApi apiInstance = new QueryApi();

if (queryName == null) {
queryName = "aa";
}
QueryResponse result = null;
try {
result = apiInstance.runInstalledQueryGet(graphName, queryName,
null, null, null, true, null, null,
null);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#runQueryGet");
e.printStackTrace();
}
System.out.println(result);
String requestId = null;
if (result != null) {
requestId = result.getRequestId();
}
return requestId;
}

public static void runQueryGetAsync(String queryName) {
System.out.println("runQueryGetAsync");
QueryApi apiInstance = new QueryApi();
Expand All @@ -105,7 +129,7 @@ public void onFailure(ApiException e, int statusCode, Map<String, List<String>>

@Override
public void onSuccess(QueryResponse result, int statusCode, Map<String, List<String>> responseHeaders) {
System.out.println("Success!");
System.out.println("--------SUCCESS!");
System.out.println(result);
}

Expand All @@ -128,21 +152,57 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done)
System.out.println(result);
}

public static void dafd(String queryName) {
System.out.println("dafd");
public static void abortQuery(String requestId) {
System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
QueryApi apiInstance = new QueryApi();

AbortQueryResponse result = null;
if (requestId == null) {
requestId = "all";
}
try {
result = apiInstance.abortQueryGet(graphName, requestId);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#abortQuery");
e.printStackTrace();
}
System.out.println(result);
}

public static void queryStatus(String requestId) {
System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
QueryApi apiInstance = new QueryApi();

if (requestId == null) {
requestId = "all";
}
QueryStatusResponse result = null;
try {
result = apiInstance.queryStatus(graphName, Arrays.asList(requestId));
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#runQueryGet");
e.printStackTrace();
}
System.out.println(result);
}

public static void queryResult(String requestId) {
System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
QueryApi apiInstance = new QueryApi();

if (requestId == null) {
requestId = "all";
}
QueryResultResponse result = null;
try {
result = apiInstance.abortQueryGet(graphName, "all");
result = apiInstance.queryResult(requestId);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#runQueryGet");
e.printStackTrace();
}
System.out.println(result);
}

public static void zapchaj(int cnt) {
public static void makeTGBussy(int cnt) {
for (int i = 0; i < cnt; i++) {
runQueryGetAsync("a");
try {
Expand All @@ -155,15 +215,28 @@ public static void zapchaj(int cnt) {
}

public static void main(String[] args) {
// runQueryGetAsync(null);
// runQueryGet("aaa");
// runQueryGet("aa");
// runQueryGetAsync("a");
// runQueryGetAsync("a");
// runQueryGetAsync("a");
// listProcessGet();
// listProcessGet();
// listProcessGet();
zapchaj(10);
String requestId = null;
runQueryGetAsync(null);
runQueryGet("aaa");
runQueryGet("aa");
runQueryGetAsync("a");
listProcessGet();
listProcessGet();
listProcessGet();
queryStatus("all");
makeTGBussy(10);

// check status and result
requestId = runQueryDetachedGet("aa");
queryStatus(requestId);
queryResult(requestId);

// abort query
requestId = runQueryDetachedGet("a");
queryStatus(requestId);
queryResult(requestId);
abortQuery(requestId);
queryResult(requestId);

}
}

0 comments on commit 20572ce

Please sign in to comment.