Skip to content

Commit a570f9b

Browse files
committed
added engine stats
1 parent 374fe2c commit a570f9b

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

lib/ArangoDBClient/AdminHandler.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class AdminHandler extends Handler
2929
const OPTION_DETAILS = 'details';
3030

3131
/**
32-
* Get the server's storage engine
32+
* Get the server's storage engine
3333
*
3434
* This will throw if the engine data cannot be retrieved
3535
*
@@ -43,6 +43,22 @@ public function getEngine()
4343
$response = $this->getConnection()->get(Urls::URL_ENGINE);
4444
return $response->getJson();
4545
}
46+
47+
/**
48+
* Get the server's storage engine statistics
49+
*
50+
* This will throw if the engine data cannot be retrieved
51+
*
52+
* @throws Exception
53+
*
54+
* @return mixed - an object returning the engine statistics
55+
* @since 3.8
56+
*/
57+
public function getEngineStats()
58+
{
59+
$response = $this->getConnection()->get(Urls::URL_ENGINE_STATS);
60+
return $response->getJson();
61+
}
4662

4763
/**
4864
* Get the server version

lib/ArangoDBClient/Urls.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ abstract class Urls
177177
* URL for storage engine
178178
*/
179179
const URL_ENGINE = '/_api/engine';
180+
181+
/**
182+
* URL for storage engine stats
183+
*/
184+
const URL_ENGINE_STATS = '/_api/engine/stats';
180185

181186
/**
182187
* URL for admin version

tests/AdminTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,30 @@ public function setUp()
2121
$this->connection = getConnection();
2222
$this->adminHandler = new AdminHandler($this->connection);
2323
}
24+
25+
26+
/**
27+
* Test if we can get the storage engine
28+
*/
29+
public function testEngine()
30+
{
31+
$result = $this->adminHandler->getEngine();
32+
static::assertEquals("rocksdb", $result["name"]);
33+
static::assertTrue(isset($result["supports"]));
34+
}
35+
36+
37+
/**
38+
* Test if we can get the storage engine statistics
39+
*/
40+
public function testEngineStats()
41+
{
42+
$result = $this->adminHandler->getEngineStats();
43+
static::assertTrue(is_array($result));
44+
static::assertTrue(isset($result["cache.limit"]));
45+
static::assertTrue(isset($result["cache.allocated"]));
46+
static::assertTrue(isset($result["columnFamilies"]));
47+
}
2448

2549

2650
/**

0 commit comments

Comments
 (0)