Always set cache type for CacheInfo returned from get cache REST endpoint
Callers don't want to deal with null values for the cache type. Change-Id: I76bd8b376780343020a1af08bf8d9bfe333211de Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
committed by
David Pursehouse
parent
4d26918293
commit
f11eadcf7b
@@ -60,6 +60,7 @@ The entries in the map are sorted by cache name.
|
|||||||
)]}'
|
)]}'
|
||||||
{
|
{
|
||||||
"accounts": {
|
"accounts": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {
|
"entries": {
|
||||||
"mem": 4
|
"mem": 4
|
||||||
},
|
},
|
||||||
@@ -69,6 +70,7 @@ The entries in the map are sorted by cache name.
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"accounts_byemail": {
|
"accounts_byemail": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {
|
"entries": {
|
||||||
"mem": 4
|
"mem": 4
|
||||||
},
|
},
|
||||||
@@ -78,6 +80,7 @@ The entries in the map are sorted by cache name.
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"accounts_byname": {
|
"accounts_byname": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {
|
"entries": {
|
||||||
"mem": 4
|
"mem": 4
|
||||||
},
|
},
|
||||||
@@ -86,6 +89,7 @@ The entries in the map are sorted by cache name.
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"adv_bases": {
|
"adv_bases": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {},
|
"entries": {},
|
||||||
"hit_ratio": {}
|
"hit_ratio": {}
|
||||||
},
|
},
|
||||||
@@ -97,6 +101,7 @@ The entries in the map are sorted by cache name.
|
|||||||
"hit_ratio": {}
|
"hit_ratio": {}
|
||||||
},
|
},
|
||||||
"changes": {
|
"changes": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {},
|
"entries": {},
|
||||||
"hit_ratio": {}
|
"hit_ratio": {}
|
||||||
},
|
},
|
||||||
@@ -145,6 +150,7 @@ The entries in the map are sorted by cache name.
|
|||||||
"hit_ratio": {}
|
"hit_ratio": {}
|
||||||
},
|
},
|
||||||
groups": {
|
groups": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {
|
"entries": {
|
||||||
"mem": 27
|
"mem": 27
|
||||||
},
|
},
|
||||||
@@ -154,14 +160,17 @@ The entries in the map are sorted by cache name.
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"groups_byinclude": {
|
"groups_byinclude": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {},
|
"entries": {},
|
||||||
"hit_ratio": {}
|
"hit_ratio": {}
|
||||||
},
|
},
|
||||||
"groups_byname": {
|
"groups_byname": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {},
|
"entries": {},
|
||||||
"hit_ratio": {}
|
"hit_ratio": {}
|
||||||
},
|
},
|
||||||
"groups_byuuid": {
|
"groups_byuuid": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {
|
"entries": {
|
||||||
"mem": 25
|
"mem": 25
|
||||||
},
|
},
|
||||||
@@ -171,10 +180,12 @@ The entries in the map are sorted by cache name.
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"groups_external": {
|
"groups_external": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {},
|
"entries": {},
|
||||||
"hit_ratio": {}
|
"hit_ratio": {}
|
||||||
},
|
},
|
||||||
groups_members": {
|
groups_members": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {
|
"entries": {
|
||||||
"mem": 4
|
"mem": 4
|
||||||
},
|
},
|
||||||
@@ -184,6 +195,7 @@ The entries in the map are sorted by cache name.
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"permission_sort": {
|
"permission_sort": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {
|
"entries": {
|
||||||
"mem": 16
|
"mem": 16
|
||||||
},
|
},
|
||||||
@@ -192,6 +204,7 @@ The entries in the map are sorted by cache name.
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"plugin_resources": {
|
"plugin_resources": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {
|
"entries": {
|
||||||
"mem": 2
|
"mem": 2
|
||||||
},
|
},
|
||||||
@@ -200,6 +213,7 @@ The entries in the map are sorted by cache name.
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"project_list": {
|
"project_list": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {
|
"entries": {
|
||||||
"mem": 1
|
"mem": 1
|
||||||
},
|
},
|
||||||
@@ -209,6 +223,7 @@ The entries in the map are sorted by cache name.
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"projects": {
|
"projects": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {
|
"entries": {
|
||||||
"mem": 35
|
"mem": 35
|
||||||
},
|
},
|
||||||
@@ -225,6 +240,7 @@ The entries in the map are sorted by cache name.
|
|||||||
"hit_ratio": {}
|
"hit_ratio": {}
|
||||||
},
|
},
|
||||||
"sshkeys": {
|
"sshkeys": {
|
||||||
|
"type": "MEM",
|
||||||
"entries": {
|
"entries": {
|
||||||
"mem": 1
|
"mem": 1
|
||||||
},
|
},
|
||||||
@@ -275,6 +291,7 @@ As result a link:#cache-info[CacheInfo] entity is returned.
|
|||||||
)]}'
|
)]}'
|
||||||
{
|
{
|
||||||
"name": "projects",
|
"name": "projects",
|
||||||
|
"type": "MEM",
|
||||||
"entries": {
|
"entries": {
|
||||||
"mem": 35
|
"mem": 35
|
||||||
},
|
},
|
||||||
@@ -443,7 +460,7 @@ The `CacheInfo` entity contains information about a cache.
|
|||||||
not set if returned in a map where the cache name is used as map key|
|
not set if returned in a map where the cache name is used as map key|
|
||||||
The cache name. If the cache is defined by a plugin the cache name
|
The cache name. If the cache is defined by a plugin the cache name
|
||||||
includes the plugin name: "<plugin-name>-<cache-name>".
|
includes the plugin name: "<plugin-name>-<cache-name>".
|
||||||
|`type` |not set for in memory caches|
|
|`type` ||
|
||||||
The type of the cache (`MEM`: in memory cache, `DISK`: disk cache).
|
The type of the cache (`MEM`: in memory cache, `DISK`: disk cache).
|
||||||
|`entries` ||
|
|`entries` ||
|
||||||
Information about the entries in the cache as a
|
Information about the entries in the cache as a
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue;
|
|||||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||||
import com.google.gerrit.acceptance.RestResponse;
|
import com.google.gerrit.acceptance.RestResponse;
|
||||||
import com.google.gerrit.server.config.ListCaches.CacheInfo;
|
import com.google.gerrit.server.config.ListCaches.CacheInfo;
|
||||||
|
import com.google.gerrit.server.config.ListCaches.CacheType;
|
||||||
|
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -37,7 +38,7 @@ public class GetCacheIT extends AbstractDaemonTest {
|
|||||||
CacheInfo result = newGson().fromJson(r.getReader(), CacheInfo.class);
|
CacheInfo result = newGson().fromJson(r.getReader(), CacheInfo.class);
|
||||||
|
|
||||||
assertEquals("accounts", result.name);
|
assertEquals("accounts", result.name);
|
||||||
assertNull(result.type);
|
assertEquals(CacheType.MEM, result.type);
|
||||||
assertEquals(1, result.entries.mem.longValue());
|
assertEquals(1, result.entries.mem.longValue());
|
||||||
assertNotNull(result.averageGet);
|
assertNotNull(result.averageGet);
|
||||||
assertTrue(result.averageGet.endsWith("s"));
|
assertTrue(result.averageGet.endsWith("s"));
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue;
|
|||||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||||
import com.google.gerrit.acceptance.RestResponse;
|
import com.google.gerrit.acceptance.RestResponse;
|
||||||
import com.google.gerrit.server.config.ListCaches.CacheInfo;
|
import com.google.gerrit.server.config.ListCaches.CacheInfo;
|
||||||
|
import com.google.gerrit.server.config.ListCaches.CacheType;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
@@ -42,7 +43,7 @@ public class ListCachesIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
assertTrue(result.containsKey("accounts"));
|
assertTrue(result.containsKey("accounts"));
|
||||||
CacheInfo accountsCacheInfo = result.get("accounts");
|
CacheInfo accountsCacheInfo = result.get("accounts");
|
||||||
assertNull(accountsCacheInfo.type);
|
assertEquals(CacheType.MEM, accountsCacheInfo.type);
|
||||||
assertEquals(1, accountsCacheInfo.entries.mem.longValue());
|
assertEquals(1, accountsCacheInfo.entries.mem.longValue());
|
||||||
assertNotNull(accountsCacheInfo.averageGet);
|
assertNotNull(accountsCacheInfo.averageGet);
|
||||||
assertTrue(accountsCacheInfo.averageGet.endsWith("s"));
|
assertTrue(accountsCacheInfo.averageGet.endsWith("s"));
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ public class ListCaches implements RestReadView<ConfigResource> {
|
|||||||
entries.setDisk(diskStats.size());
|
entries.setDisk(diskStats.size());
|
||||||
entries.setSpace(diskStats.space());
|
entries.setSpace(diskStats.space());
|
||||||
hitRatio.setDisk(diskStats.hitCount(), diskStats.requestCount());
|
hitRatio.setDisk(diskStats.hitCount(), diskStats.requestCount());
|
||||||
|
} else {
|
||||||
|
type = CacheType.MEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user