Skip to content

Commit 80eee39

Browse files
author
Lloyd Watkin
committed
Add datastore methods to check whether node config is cached
1 parent 16fccb6 commit 80eee39

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/main/java/org/buddycloud/channelserver/db/NodeStore.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,14 @@ void deleteNodeItemById(String nodeId, String nodeItemId)
536536
*/
537537
boolean isCachedJID(JID jid) throws NodeStoreException;
538538

539+
/**
540+
* Return whether node config is cached locally
541+
*
542+
* @param nodeId
543+
* @return
544+
* @throws NodeStoreException
545+
*/
546+
boolean isCachedNodeConfig(String nodeId) throws NodeStoreException;
539547

540548
/**
541549
* Allows the server to determine if the requested (subscriptions) node

src/main/java/org/buddycloud/channelserver/db/jdbc/JDBCNodeStore.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,6 +1643,11 @@ public ArrayList<String> getNodeList() throws NodeStoreException {
16431643
public boolean isCachedNode(String nodeId) throws NodeStoreException {
16441644
return (this.countNodeItems(nodeId) > 0);
16451645
}
1646+
1647+
@Override
1648+
public boolean isCachedNodeConfig(String nodeId) throws NodeStoreException {
1649+
return (this.getNodeConf(nodeId).size() > 0);
1650+
}
16461651

16471652
@Override
16481653
public boolean isCachedJID(JID jid) throws NodeStoreException {

src/test/java/org/buddycloud/channelserver/db/jdbc/JDBCNodeStoreTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,17 @@ public void testGetNodeConf() throws Exception {
489489
entry.getValue(), result.get(entry.getKey()));
490490
}
491491
}
492+
493+
@Test
494+
public void testNodeWithConfigSaysConfigIsCached() throws Exception {
495+
dbTester.loadData("node_1");
496+
Assert.assertTrue(store.isCachedNodeConfig(TEST_SERVER1_NODE1_ID));
497+
}
498+
499+
@Test
500+
public void testNodeWithoutConfigSaysConfigNotCached() throws Exception {
501+
Assert.assertFalse(store.isCachedNodeConfig(TEST_SERVER1_NODE1_ID));
502+
}
492503

493504
@Test
494505
public void testAddUserSubscriptionNewSubscription() throws Exception {

0 commit comments

Comments
 (0)