Cache: Take MXS_EXCEPTION_GUARD into use
This commit is contained in:
parent
ce94170eae
commit
bf35577941
@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#define MXS_MODULE_NAME "storage_inmemory"
|
||||
#include <maxscale/cppdefs.hh>
|
||||
#include <inttypes.h>
|
||||
#include "../../cache_storage_api.h"
|
||||
#include "inmemorystoragest.hh"
|
||||
@ -37,8 +38,6 @@ CACHE_STORAGE* createInstance(cache_thread_model_t model,
|
||||
{
|
||||
ss_dassert(zname);
|
||||
|
||||
CACHE_STORAGE* pStorage = 0;
|
||||
|
||||
if (max_count != 0)
|
||||
{
|
||||
MXS_WARNING("A maximum item count of %u specified, although 'storage_inMemory' "
|
||||
@ -51,36 +50,28 @@ CACHE_STORAGE* createInstance(cache_thread_model_t model,
|
||||
"does not enforce such a limit.", (unsigned long)max_size);
|
||||
}
|
||||
|
||||
try
|
||||
InMemoryStorage* pStorage = NULL;
|
||||
|
||||
switch (model)
|
||||
{
|
||||
switch (model)
|
||||
{
|
||||
case CACHE_THREAD_MODEL_ST:
|
||||
pStorage = reinterpret_cast<CACHE_STORAGE*>(InMemoryStorageST::create(zname, ttl, argc, argv));
|
||||
break;
|
||||
case CACHE_THREAD_MODEL_ST:
|
||||
MXS_EXCEPTION_GUARD(pStorage = InMemoryStorageST::create(zname, ttl, argc, argv));
|
||||
break;
|
||||
|
||||
default:
|
||||
MXS_ERROR("Unknown thread model %d, creating multi-thread aware storage.", (int)model);
|
||||
case CACHE_THREAD_MODEL_MT:
|
||||
pStorage = reinterpret_cast<CACHE_STORAGE*>(InMemoryStorageST::create(zname, ttl, argc, argv));
|
||||
}
|
||||
default:
|
||||
ss_dassert(!true);
|
||||
MXS_ERROR("Unknown thread model %d, creating multi-thread aware storage.", (int)model);
|
||||
case CACHE_THREAD_MODEL_MT:
|
||||
MXS_EXCEPTION_GUARD(pStorage = InMemoryStorageST::create(zname, ttl, argc, argv));
|
||||
break;
|
||||
}
|
||||
|
||||
if (pStorage)
|
||||
{
|
||||
MXS_NOTICE("Storage module created.");
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
MXS_OOM();
|
||||
}
|
||||
catch (const std::exception& x)
|
||||
{
|
||||
MXS_ERROR("Standard exception caught: %s", x.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
MXS_ERROR("Unknown exception caught.");
|
||||
}
|
||||
|
||||
return pStorage;
|
||||
return reinterpret_cast<CACHE_STORAGE*>(pStorage);
|
||||
}
|
||||
|
||||
void freeInstance(CACHE_STORAGE* pinstance)
|
||||
@ -88,7 +79,6 @@ void freeInstance(CACHE_STORAGE* pinstance)
|
||||
delete reinterpret_cast<InMemoryStorage*>(pinstance);
|
||||
}
|
||||
|
||||
|
||||
cache_result_t getInfo(CACHE_STORAGE* pStorage,
|
||||
uint32_t what,
|
||||
json_t** ppInfo)
|
||||
@ -97,22 +87,7 @@ cache_result_t getInfo(CACHE_STORAGE* pStorage,
|
||||
|
||||
cache_result_t result = CACHE_RESULT_ERROR;
|
||||
|
||||
try
|
||||
{
|
||||
result = reinterpret_cast<InMemoryStorage*>(pStorage)->get_info(what, ppInfo);
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
MXS_OOM();
|
||||
}
|
||||
catch (const std::exception& x)
|
||||
{
|
||||
MXS_ERROR("Standard exception caught: %s", x.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
MXS_ERROR("Unknown exception caught.");
|
||||
}
|
||||
MXS_EXCEPTION_GUARD(result = reinterpret_cast<InMemoryStorage*>(pStorage)->get_info(what, ppInfo));
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -129,22 +104,9 @@ cache_result_t getKey(CACHE_STORAGE* pstorage,
|
||||
|
||||
cache_result_t result = CACHE_RESULT_ERROR;
|
||||
|
||||
try
|
||||
{
|
||||
result = reinterpret_cast<InMemoryStorage*>(pstorage)->get_key(zdefault_db, pquery, pkey);
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
MXS_OOM();
|
||||
}
|
||||
catch (const std::exception& x)
|
||||
{
|
||||
MXS_ERROR("Standard exception caught: %s", x.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
MXS_ERROR("Unknown exception caught.");
|
||||
}
|
||||
MXS_EXCEPTION_GUARD(result = reinterpret_cast<InMemoryStorage*>(pstorage)->get_key(zdefault_db,
|
||||
pquery,
|
||||
pkey));
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -160,22 +122,9 @@ cache_result_t getValue(CACHE_STORAGE* pstorage,
|
||||
|
||||
cache_result_t result = CACHE_RESULT_ERROR;
|
||||
|
||||
try
|
||||
{
|
||||
result = reinterpret_cast<InMemoryStorage*>(pstorage)->get_value(*pkey, flags, ppresult);
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
MXS_OOM();
|
||||
}
|
||||
catch (const std::exception& x)
|
||||
{
|
||||
MXS_ERROR("Standard exception caught: %s", x.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
MXS_ERROR("Unknown exception caught.");
|
||||
}
|
||||
MXS_EXCEPTION_GUARD(result = reinterpret_cast<InMemoryStorage*>(pstorage)->get_value(*pkey,
|
||||
flags,
|
||||
ppresult));
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -190,22 +139,7 @@ cache_result_t putValue(CACHE_STORAGE* pstorage,
|
||||
|
||||
cache_result_t result = CACHE_RESULT_ERROR;
|
||||
|
||||
try
|
||||
{
|
||||
result = reinterpret_cast<InMemoryStorage*>(pstorage)->put_value(*pkey, pvalue);
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
MXS_OOM();
|
||||
}
|
||||
catch (const std::exception& x)
|
||||
{
|
||||
MXS_ERROR("Standard exception caught: %s", x.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
MXS_ERROR("Unknown exception caught.");
|
||||
}
|
||||
MXS_EXCEPTION_GUARD(result = reinterpret_cast<InMemoryStorage*>(pstorage)->put_value(*pkey, pvalue));
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -218,22 +152,7 @@ cache_result_t delValue(CACHE_STORAGE* pstorage,
|
||||
|
||||
cache_result_t result = CACHE_RESULT_ERROR;
|
||||
|
||||
try
|
||||
{
|
||||
result = reinterpret_cast<InMemoryStorage*>(pstorage)->del_value(*pkey);
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
MXS_OOM();
|
||||
}
|
||||
catch (const std::exception& x)
|
||||
{
|
||||
MXS_ERROR("Standard exception caught: %s", x.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
MXS_ERROR("Unknown exception caught.");
|
||||
}
|
||||
MXS_EXCEPTION_GUARD(result = reinterpret_cast<InMemoryStorage*>(pstorage)->del_value(*pkey));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#define MXS_MODULE_NAME "storage_rocksdb"
|
||||
#include <maxscale/cppdefs.hh>
|
||||
#include <inttypes.h>
|
||||
#include "../../cache_storage_api.h"
|
||||
#include "rocksdbstorage.hh"
|
||||
@ -35,8 +36,6 @@ CACHE_STORAGE* createInstance(cache_thread_model_t, // Ignored, RocksDB always M
|
||||
{
|
||||
ss_dassert(zName);
|
||||
|
||||
CACHE_STORAGE* pStorage = 0;
|
||||
|
||||
if (maxCount != 0)
|
||||
{
|
||||
MXS_WARNING("A maximum item count of %u specifed, although 'storage_rocksdb' "
|
||||
@ -49,26 +48,16 @@ CACHE_STORAGE* createInstance(cache_thread_model_t, // Ignored, RocksDB always M
|
||||
"does not enforce such a limit.", (unsigned long)maxSize);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
pStorage = reinterpret_cast<CACHE_STORAGE*>(RocksDBStorage::Create(zName, ttl, argc, argv));
|
||||
RocksDBStorage* pStorage = NULL;
|
||||
|
||||
MXS_EXCEPTION_GUARD(pStorage = RocksDBStorage::Create(zName, ttl, argc, argv));
|
||||
|
||||
if (pStorage)
|
||||
{
|
||||
MXS_NOTICE("Storage module created.");
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
MXS_OOM();
|
||||
}
|
||||
catch (const std::exception& x)
|
||||
{
|
||||
MXS_ERROR("Standard exception caught: %s", x.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
MXS_ERROR("Unknown exception caught.");
|
||||
}
|
||||
|
||||
return pStorage;
|
||||
return reinterpret_cast<CACHE_STORAGE*>(pStorage);
|
||||
}
|
||||
|
||||
void freeInstance(CACHE_STORAGE* pInstance)
|
||||
@ -84,22 +73,7 @@ cache_result_t getInfo(CACHE_STORAGE* pStorage,
|
||||
|
||||
cache_result_t result = CACHE_RESULT_ERROR;
|
||||
|
||||
try
|
||||
{
|
||||
result = reinterpret_cast<RocksDBStorage*>(pStorage)->getInfo(what, ppInfo);
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
MXS_OOM();
|
||||
}
|
||||
catch (const std::exception& x)
|
||||
{
|
||||
MXS_ERROR("Standard exception caught: %s", x.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
MXS_ERROR("Unknown exception caught.");
|
||||
}
|
||||
MXS_EXCEPTION_GUARD(result = reinterpret_cast<RocksDBStorage*>(pStorage)->getInfo(what, ppInfo));
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -116,22 +90,9 @@ cache_result_t getKey(CACHE_STORAGE* pStorage,
|
||||
|
||||
cache_result_t result = CACHE_RESULT_ERROR;
|
||||
|
||||
try
|
||||
{
|
||||
result = reinterpret_cast<RocksDBStorage*>(pStorage)->getKey(zDefaultDB, pQuery, pKey);
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
MXS_OOM();
|
||||
}
|
||||
catch (const std::exception& x)
|
||||
{
|
||||
MXS_ERROR("Standard exception caught: %s", x.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
MXS_ERROR("Unknown exception caught.");
|
||||
}
|
||||
MXS_EXCEPTION_GUARD(result = reinterpret_cast<RocksDBStorage*>(pStorage)->getKey(zDefaultDB,
|
||||
pQuery,
|
||||
pKey));
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -147,22 +108,9 @@ cache_result_t getValue(CACHE_STORAGE* pStorage,
|
||||
|
||||
cache_result_t result = CACHE_RESULT_ERROR;
|
||||
|
||||
try
|
||||
{
|
||||
result = reinterpret_cast<RocksDBStorage*>(pStorage)->getValue(pKey, flags, ppResult);
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
MXS_OOM();
|
||||
}
|
||||
catch (const std::exception& x)
|
||||
{
|
||||
MXS_ERROR("Standard exception caught: %s", x.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
MXS_ERROR("Unknown exception caught.");
|
||||
}
|
||||
MXS_EXCEPTION_GUARD(result = reinterpret_cast<RocksDBStorage*>(pStorage)->getValue(pKey,
|
||||
flags,
|
||||
ppResult));
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -177,22 +125,7 @@ cache_result_t putValue(CACHE_STORAGE* pStorage,
|
||||
|
||||
cache_result_t result = CACHE_RESULT_ERROR;
|
||||
|
||||
try
|
||||
{
|
||||
result = reinterpret_cast<RocksDBStorage*>(pStorage)->putValue(pKey, pValue);
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
MXS_OOM();
|
||||
}
|
||||
catch (const std::exception& x)
|
||||
{
|
||||
MXS_ERROR("Standard exception caught: %s", x.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
MXS_ERROR("Unknown exception caught.");
|
||||
}
|
||||
MXS_EXCEPTION_GUARD(result = reinterpret_cast<RocksDBStorage*>(pStorage)->putValue(pKey, pValue));
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -205,22 +138,7 @@ cache_result_t delValue(CACHE_STORAGE* pStorage,
|
||||
|
||||
cache_result_t result = CACHE_RESULT_ERROR;
|
||||
|
||||
try
|
||||
{
|
||||
result = reinterpret_cast<RocksDBStorage*>(pStorage)->delValue(pKey);
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
MXS_OOM();
|
||||
}
|
||||
catch (const std::exception& x)
|
||||
{
|
||||
MXS_ERROR("Standard exception caught: %s", x.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
MXS_ERROR("Unknown exception caught.");
|
||||
}
|
||||
MXS_EXCEPTION_GUARD(result = reinterpret_cast<RocksDBStorage*>(pStorage)->delValue(pKey));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user