Skip to content

Commit 6037aa0

Browse files
committed
Disable redis connectivity in sbc classes (for now)
1 parent c73d37c commit 6037aa0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1949
-3181
lines changed

include/OSS/Persistent/BerkeleyDb.h

+21-25
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <string>
2626
#include <sstream>
2727

28+
#include "OSS/UTL/CoreUtils.h"
29+
2830

2931
namespace OSS {
3032

@@ -120,7 +122,7 @@ class BerkeleyDb
120122
return true;
121123
}
122124

123-
bool get(const std::string& key_, std::string& value)
125+
bool get(const std::string& key_, std::string& value) const
124126
{
125127
if (!_pDb)
126128
return false;
@@ -169,7 +171,7 @@ class BerkeleyDb
169171
return true;
170172
}
171173

172-
bool nextKey(std::string& nextKey, bool first)
174+
bool nextKey(std::string& nextKey, bool first) const
173175
{
174176
if (!_pDb || !_pCursor)
175177
return false;
@@ -188,7 +190,7 @@ bool nextKey(std::string& nextKey, bool first)
188190
return true;
189191
}
190192

191-
void getKeys(std::vector<std::string>& keys)
193+
bool getKeys(std::vector<std::string>& keys) const
192194
{
193195
bool first = true;
194196
std::string key;
@@ -197,6 +199,22 @@ void getKeys(std::vector<std::string>& keys)
197199
first = false;
198200
keys.push_back(key);
199201
}
202+
return !keys.empty();
203+
}
204+
205+
bool getKeys(const std::string& pattern, std::vector<std::string>& keys) const
206+
{
207+
bool first = true;
208+
std::string key;
209+
while(nextKey(key, first))
210+
{
211+
first = false;
212+
if (OSS::string_wildcard_compare(pattern.c_str(), key))
213+
{
214+
keys.push_back(key);
215+
}
216+
}
217+
return !keys.empty();
200218
}
201219

202220
void clear()
@@ -209,28 +227,6 @@ void clear()
209227
erase(*iter);
210228
}
211229

212-
static bool decodeString( std::stringstream& s, std::string& value)
213-
{
214-
short len;
215-
s.read( (char*)(&len), sizeof(len) );
216-
217-
if (len > 8192)
218-
return false;
219-
220-
char buf[8192];
221-
s.read( buf, len );
222-
223-
value = std::string(buf, len);
224-
return true;
225-
}
226-
227-
static void encodeString( std::stringstream& s, const std::string& data )
228-
{
229-
short len = (short)data.size();
230-
s.write( (char*)(&len) , sizeof( len ) );
231-
s.write( data.data(), len );
232-
}
233-
234230
protected:
235231
bool _isOpen;
236232
Db* _pDb;

include/OSS/SIP/SBC/SBCAccountRecord.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define SBCACCOUNTRECORD_H_INCLUDED
2626

2727

28-
#include "OSS/SIP/SBC/SBCRedisManager.h"
28+
#include "OSS/SIP/SBC/SBCWorkSpaceManager.h"
2929
#include "OSS/JSON/reader.h"
3030
#include "OSS/JSON/writer.h"
3131
#include "OSS/SIP/SIPAuthorization.h"
@@ -64,9 +64,9 @@ class SBCAccountRecord
6464

6565
const std::string& getA1Hash() const;
6666

67-
bool readFromRedis(const SBCRedisManager::WorkSpace& workspace, const std::string& key);
67+
bool readFromWorkSpace(const SBCWorkSpaceManager::WorkSpace& workspace, const std::string& key);
6868

69-
bool writeToRedis(const SBCRedisManager::WorkSpace& workspace, const std::string& key);
69+
bool writeToWorkSpace(const SBCWorkSpaceManager::WorkSpace& workspace, const std::string& key);
7070

7171
void toJson(json::Object& object);
7272

include/OSS/SIP/SBC/SBCAccounts.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define SBCACCOUNTS_H_INCLUDED
2626

2727

28-
#include "OSS/SIP/SBC/SBCRedisManager.h"
28+
#include "OSS/SIP/SBC/SBCWorkSpaceManager.h"
2929
#include "OSS/SIP/SBC/SBCAccountRecord.h"
3030

3131

@@ -43,9 +43,9 @@ class SBCAccounts
4343

4444
~SBCAccounts();
4545

46-
void initialize(const SBCRedisManager::WorkSpace& workspace);
46+
void initialize(const SBCWorkSpaceManager::WorkSpace& workspace);
4747

48-
const SBCRedisManager::WorkSpace& workspace() const;
48+
const SBCWorkSpaceManager::WorkSpace& workspace() const;
4949

5050
bool findAccount(const std::string& identity, SBCAccountRecord& account) const;
5151

@@ -61,7 +61,7 @@ class SBCAccounts
6161
protected:
6262
void determineRealms();
6363
private:
64-
SBCRedisManager::WorkSpace _workspace;
64+
SBCWorkSpaceManager::WorkSpace _workspace;
6565
VolatileAccounts _volatileAccounts;
6666
mutable OSS::mutex_critic_sec _volatileAccountsMutex;
6767
Realms _realms;
@@ -74,7 +74,7 @@ class SBCAccounts
7474
// Inlines
7575
//
7676

77-
inline const SBCRedisManager::WorkSpace& SBCAccounts::workspace() const
77+
inline const SBCWorkSpaceManager::WorkSpace& SBCAccounts::workspace() const
7878
{
7979
return _workspace;
8080
}

include/OSS/SIP/SBC/SBCCDRManager.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#define SBCCDRMANAGER_H_INCLUDED
2525

2626

27-
#include "OSS/SIP/SBC/SBCRedisManager.h"
27+
#include "OSS/SIP/SBC/SBCWorkSpaceManager.h"
2828
#include "OSS/SIP/SBC/SBCCDREvent.h"
2929
#include "OSS/SIP/SBC/SBCCDRRecord.h"
3030
#include "OSS/UTL/BlockingQueue.h"
@@ -79,7 +79,7 @@ class SBCCDRManager
7979
const SIPTransaction::Ptr& pTransaction
8080
);
8181

82-
SBCRedisManager::WorkSpace& cdr();
82+
SBCWorkSpaceManager::WorkSpace& cdr();
8383

8484
void setCDRLifeTime(unsigned int cdrLifeTime);
8585

@@ -99,8 +99,8 @@ class SBCCDRManager
9999
EventQueue _eventQueue;
100100
boost::thread* _pEventQueueThread;
101101
SBCManager* _pManager;
102-
SBCRedisManager* _pRedisManager;
103-
SBCRedisManager::WorkSpace _pCDRDb;
102+
SBCWorkSpaceManager* _pWorkSpaceManager;
103+
SBCWorkSpaceManager::WorkSpace _pCDRDb;
104104
unsigned int _cdrLifeTime;
105105
OSS::UTL::LogFile _logger;
106106
SBCChannelLimits _channelLimits;
@@ -112,7 +112,7 @@ class SBCCDRManager
112112
//
113113

114114

115-
inline SBCRedisManager::WorkSpace& SBCCDRManager::cdr()
115+
inline SBCWorkSpaceManager::WorkSpace& SBCCDRManager::cdr()
116116
{
117117
return _pCDRDb;
118118
}

include/OSS/SIP/SBC/SBCCDRRecord.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "OSS/UTL/LogFile.h"
3131
#include "OSS/JSON/reader.h"
3232
#include "OSS/JSON/writer.h"
33+
#include "OSS/SIP/SBC/SBCWorkSpace.h"
3334

3435
namespace OSS {
3536
namespace SIP {
@@ -64,8 +65,8 @@ class SBCCDRRecord
6465
OSS::UInt64& disconnectTime();
6566
std::string& sessionId();
6667

67-
bool writeToRedis(Persistent::RedisBroadcastClient& redis, const std::string& key, unsigned int expire);
68-
bool readFromRedis(Persistent::RedisBroadcastClient& redis, const std::string& key);
68+
bool writeToWorkSpace(SBCWorkSpace& redis, const std::string& key, unsigned int expire);
69+
bool readFromWorkSpace(SBCWorkSpace& redis, const std::string& key);
6970
bool writeToLogFile(OSS::UTL::LogFile& logFile);
7071
void toJson(json::Object& object);
7172

include/OSS/SIP/SBC/SBCChannelLimits.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#define SBCCHANNELLIMITS_H_INCLUDED
2525

2626

27-
#include "OSS/SIP/SBC/SBCRedisManager.h"
27+
#include "OSS/SIP/SBC/SBCWorkSpaceManager.h"
2828
#include "OSS/SIP/B2BUA/SIPB2BTransaction.h"
2929
#include "OSS/UTL/BlockingQueue.h"
3030
#include "OSS/UTL/LogFile.h"
@@ -60,7 +60,7 @@ class SBCChannelLimits
6060

6161
std::size_t removeCall(const std::string& sessionId, const std::string& dialString);
6262

63-
void setSystemDb(const SBCRedisManager::WorkSpace& systemDb);
63+
void setSystemDb(const SBCWorkSpaceManager::WorkSpace& systemDb);
6464

6565
std::size_t getCallCount(const std::string& prefix);
6666

@@ -75,13 +75,13 @@ class SBCChannelLimits
7575
Limits _limits;
7676
PrefixAliases _aliases;
7777
SBCManager* _pManager;
78-
SBCRedisManager::WorkSpace _systemDb;
78+
SBCWorkSpaceManager::WorkSpace _systemDb;
7979
};
8080

8181
//
8282
// Inlines
8383
//
84-
inline void SBCChannelLimits::setSystemDb(const SBCRedisManager::WorkSpace& systemDb)
84+
inline void SBCChannelLimits::setSystemDb(const SBCWorkSpaceManager::WorkSpace& systemDb)
8585
{
8686
_systemDb = systemDb;
8787
}

include/OSS/SIP/SBC/SBCDirectories.h

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#ifndef SBCDIRECTORIES_H_INCLUDED
2+
#define SBCDIRECTORIES_H_INCLUDED
3+
4+
#include "OSS/UTL/CoreUtils.h"
5+
#include "OSS/UTL/Singleton.h"
6+
7+
namespace OSS {
8+
namespace SIP {
9+
namespace SBC {
10+
11+
class SBCDirectories : public OSS::UTL::Singleton<SBCDirectories>
12+
{
13+
public:
14+
const std::string& getTempDirectory() const;
15+
void setTempDirectory(const std::string& dir);
16+
17+
const std::string& getDbDirectory() const;
18+
void setDbDirectory(const std::string& dir);
19+
20+
const std::string& getConfigDirectory() const;
21+
void setConfigDirectory(const std::string& dir);
22+
23+
const std::string& getLogDirectory() const;
24+
void setLogDirectory(const std::string& dir);
25+
26+
const std::string& getStateDirectory() const;
27+
void setStateDirectory(const std::string& dir);
28+
29+
private:
30+
std::string _tmp_dir;
31+
std::string _db_dir;
32+
std::string _conf_dir;
33+
std::string _log_dir;
34+
std::string _state_dir;
35+
};
36+
37+
38+
//
39+
// Inlines
40+
//
41+
42+
inline const std::string& SBCDirectories::getConfigDirectory() const
43+
{
44+
static std::string conf_dir = OSS::system_confdir() + std::string("/karoo.conf.d/config");
45+
return _conf_dir.empty() ? conf_dir : _conf_dir;
46+
}
47+
48+
inline void SBCDirectories::setConfigDirectory(const std::string& dir)
49+
{
50+
_conf_dir = dir;
51+
}
52+
53+
inline const std::string& SBCDirectories::getTempDirectory() const
54+
{
55+
static std::string temp_dir = "/tmp";
56+
return _tmp_dir.empty() ? temp_dir : _tmp_dir;
57+
}
58+
59+
inline void SBCDirectories::setTempDirectory(const std::string& dir)
60+
{
61+
_tmp_dir = dir;
62+
}
63+
64+
inline const std::string& SBCDirectories::getDbDirectory() const
65+
{
66+
static std::string db_dir = OSS::system_confdir() + std::string("/karoo.conf.d/workspace");
67+
return _db_dir.empty() ? _db_dir : _db_dir;
68+
}
69+
70+
inline void SBCDirectories::setDbDirectory(const std::string& dir)
71+
{
72+
_db_dir = dir;
73+
}
74+
75+
inline const std::string& SBCDirectories::getLogDirectory() const
76+
{
77+
static std::string log_dir = "/var/log/karoo";
78+
return _log_dir.empty() ? log_dir : _log_dir;
79+
}
80+
81+
inline void SBCDirectories::setLogDirectory(const std::string& dir)
82+
{
83+
_log_dir = dir;
84+
}
85+
86+
inline const std::string& SBCDirectories::getStateDirectory() const
87+
{
88+
static std::string state_dir = OSS::system_confdir() + std::string("/karoo.conf.d/states");
89+
return _state_dir.empty() ? state_dir : _state_dir;
90+
}
91+
92+
inline void SBCDirectories::setStateDirectory(const std::string& dir)
93+
{
94+
_state_dir = dir;
95+
}
96+
97+
} } } // OSS::SIP::SBC
98+
99+
#endif // SBCDIRECTORIES_H_INCLUDED
100+

include/OSS/SIP/SBC/SBCDomainLimits.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#define SBCDOMAINLIMITS_H_INCLUDED
2525

2626

27-
#include "OSS/SIP/SBC/SBCRedisManager.h"
27+
#include "OSS/SIP/SBC/SBCWorkSpaceManager.h"
2828
#include "OSS/SIP/B2BUA/SIPB2BTransaction.h"
2929
#include "OSS/UTL/BlockingQueue.h"
3030
#include "OSS/UTL/LogFile.h"
@@ -59,7 +59,7 @@ class SBCDomainLimits
5959

6060
std::size_t removeCall(const std::string& sessionId, const std::string& domain);
6161

62-
void setSystemDb(const SBCRedisManager::WorkSpace& systemDb);
62+
void setSystemDb(const SBCWorkSpaceManager::WorkSpace& systemDb);
6363

6464
std::size_t getCallCount(const std::string& domain);
6565

@@ -70,13 +70,13 @@ class SBCDomainLimits
7070
Poco::Timestamp::TimeDiff _cacheExpire;
7171
Limits _limits;
7272
SBCManager* _pManager;
73-
SBCRedisManager::WorkSpace _systemDb;
73+
SBCWorkSpaceManager::WorkSpace _systemDb;
7474
};
7575

7676
//
7777
// Inlines
7878
//
79-
inline void SBCDomainLimits::setSystemDb(const SBCRedisManager::WorkSpace& systemDb)
79+
inline void SBCDomainLimits::setSystemDb(const SBCWorkSpaceManager::WorkSpace& systemDb)
8080
{
8181
_systemDb = systemDb;
8282
}

include/OSS/SIP/SBC/SBCJSModuleManager.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SBCJSModuleManager
3939
{
4040
public:
4141
typedef OSS::JS::JSIsolate JSIsolate;
42-
void run();
42+
void run(const std::string& scriptFile, bool threaded = true);
4343
void stop();
4444
bool processTransactionEvent(const std::string& eventName, const SIPB2BTransaction::Ptr& pTransaction, OSS::JSON::Object& result);
4545
bool processRequestEvent(const std::string& eventName, const SIPMessage::Ptr& pMessage, OSS::JSON::Object& result);
@@ -60,6 +60,7 @@ class SBCJSModuleManager
6060
SBCManager* _pManager;
6161
JSIsolate::Ptr _pIsolate;
6262
boost::thread* _pThread;
63+
std::string _scriptFile;
6364
};
6465

6566
//

0 commit comments

Comments
 (0)