This section introduces methods for managing processes and jobs.
Process
top()
Retrieves all running processes in the database.
Parameters
config: RequestConfig
(Optional): Request configuration.
Returns
Process[]
: The list of retrieved processes.
// Retrieves all running processes in the database
const processes = await conn.top();
for (const process of processes){
console.log(`${process.processId} - ${process.processQuery}`)
}
1049542 - MATCH p = ()->{1,3}() RETURN p LIMIT 5000
kill()
Kills running processes in the database.
Parameters
processId: string
: ID of the process to kill; set to*
to kill all.config: RequestConfig
(Optional): Request configuration.
Returns
Response
: Response of the request.
// Retrieves all running processes in the database and kills them all
const processes = await conn.top();
for (const process of processes) {
const response = await conn.kill(process.processId);
console.log(`${process.processId} - ${process.processQuery} - Kill ${response.status?.message}`);
}
1049607 - MATCH p = ()->{1,3}() RETURN p LIMIT 5000 - Kill SUCCESS
Job
showJob()
Retrieves jobs in the graph.
Parameters
id: string
(Optional): Job ID.config: RequestConfig
(Optional): Request configuration.
Returns
Job[]
: The list of retrieved jobs.
// Retrieves all failed jobs in the graph 'miniCircle'
const requestConfig:RequestConfig = {
graph: "miniCircle"
}
const jobs = await conn.showJob(undefined,requestConfig);
const failed_jobs = jobs.filter(job => job.status === "FAILED")
if (failed_jobs.length > 0) {
for (const job of failed_jobs) {
console.log(`${job.id} - ${job.type} - ${job.errMsg}`)
}
} else {
console.log("No failed jobs")
}
64 - CREATE_FULLTEXT - Fulltext name already exists.
56 - CREATE_INDEX - @account.year does not exist.
55 - CREATE_INDEX - @transfer.year does not exist.
53 - CREATE_INDEX - String type must set index length.
40 - CREATE_HDC_GRAPH - The projection aa already existed!
27 - CREATE_HDC_GRAPH - Hdc server sss not found.
stopJob()
Stops a running job in the graph.
Parameters
id: string
: ID of the job to stop.config: RequestConfig
(Optional): Request configuration.
Returns
Response
: Response of the request.
// Retrieves all running jobs in the graph 'miniCircle' and stops them all
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const jobs = await conn.showJob(undefined,requestConfig);
const running_jobs = jobs.filter((job) => job.status === "RUNNING");
for (const running_job of running_jobs) {
const response = await conn.stopJob(running_job.id, requestConfig);
console.log(
`${running_job.id} - ${running_job.type} - Stop - ${response.status?.message}`
);
}
10 - CREATE_FULLTEXT - Stop FAILED
10_1- CREATE_FULLTEXT - Stop SUCCESS
10_2 - CREATE_FULLTEXT - Stop SUCCESS
clearJob()
Clears a job that is not running from the graph.
Parameters
id: string
: ID of the job to stop.config: RequestConfig
(Optional): Request configuration.
Returns
Response
: Response of the request.
// Retrieves all failed jobs in the graph 'miniCircle' and clears them all
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const jobs = await conn.showJob(undefined,requestConfig);
const failed_jobs = jobs.filter((job) => job.status === "FAILED");
if (failed_jobs.length > 0) {
for (const job of failed_jobs) {
const response = await conn.clearJob(job.id, requestConfig);
console.log(`Clear ${job.id} ${response.status?.message}`);
}
} else {
console.log("No failed jobs");
}
Clear 51 SUCCESS
Clear 42 SUCCESS
Clear 26 SUCCESS
Clear 26_1 SUCCESS
Clear 17 SUCCESS
Clear 17_1 SUCCESS
Full Example
import { UltipaDriver } from "@ultipa-graph/ultipa-driver";
import { ULTIPA } from "@ultipa-graph/ultipa-driver/dist/types";
import { RequestConfig } from "@ultipa-graph/ultipa-driver/dist/types/types";
let sdkUsage = async () => {
// URI example: ultipaConfig.hosts: ["mqj4zouys.us-east-1.cloud.ultipa.com:60010"]
const ultipaConfig: ULTIPA.UltipaConfig = {
hosts: ["192.168.1.85:60061", "192.168.1.87:60061", "192.168.1.88:60061"],
username: "<username>",
password: "<password>"
};
const conn = new UltipaDriver(ultipaConfig);
const isSuccess = await conn.test();
console.log(`Connection succeeds: ${isSuccess}`);
// Retrieves all failed jobs in the graph 'miniCircle'
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const jobs = await conn.showJob(undefined, requestConfig);
const failed_jobs = jobs.filter((job) => job.status === "FAILED");
if (failed_jobs.length > 0) {
for (const job of failed_jobs) {
console.log(`${job.id} - ${job.type} - ${job.errMsg}`);
}
} else {
console.log("No failed jobs");
}
};
sdkUsage().catch(console.error);