Format filters
This commit is contained in:
8
server/modules/filter/cache/cache.cc
vendored
8
server/modules/filter/cache/cache.cc
vendored
@ -124,7 +124,7 @@ json_t* Cache::show_json() const
|
|||||||
|
|
||||||
cache_result_t Cache::get_key(const char* zDefault_db,
|
cache_result_t Cache::get_key(const char* zDefault_db,
|
||||||
const GWBUF* pQuery,
|
const GWBUF* pQuery,
|
||||||
CACHE_KEY* pKey) const
|
CACHE_KEY* pKey) const
|
||||||
{
|
{
|
||||||
// TODO: Take config into account.
|
// TODO: Take config into account.
|
||||||
return get_default_key(zDefault_db, pQuery, pKey);
|
return get_default_key(zDefault_db, pQuery, pKey);
|
||||||
@ -133,7 +133,7 @@ cache_result_t Cache::get_key(const char* zDefault_db,
|
|||||||
// static
|
// static
|
||||||
cache_result_t Cache::get_default_key(const char* zDefault_db,
|
cache_result_t Cache::get_default_key(const char* zDefault_db,
|
||||||
const GWBUF* pQuery,
|
const GWBUF* pQuery,
|
||||||
CACHE_KEY* pKey)
|
CACHE_KEY* pKey)
|
||||||
{
|
{
|
||||||
mxb_assert(GWBUF_IS_CONTIGUOUS(pQuery));
|
mxb_assert(GWBUF_IS_CONTIGUOUS(pQuery));
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ json_t* Cache::do_get_info(uint32_t what) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//static
|
// static
|
||||||
uint64_t Cache::time_ms()
|
uint64_t Cache::time_ms()
|
||||||
{
|
{
|
||||||
timespec t;
|
timespec t;
|
||||||
@ -219,7 +219,7 @@ uint64_t Cache::time_ms()
|
|||||||
int rv = clock_gettime(CLOCK_MONOTONIC_COARSE, &t);
|
int rv = clock_gettime(CLOCK_MONOTONIC_COARSE, &t);
|
||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
{
|
{
|
||||||
mxb_assert(errno == EINVAL); // CLOCK_MONOTONIC_COARSE not supported.
|
mxb_assert(errno == EINVAL); // CLOCK_MONOTONIC_COARSE not supported.
|
||||||
rv = clock_gettime(CLOCK_MONOTONIC, &t);
|
rv = clock_gettime(CLOCK_MONOTONIC, &t);
|
||||||
mxb_assert(rv == 0);
|
mxb_assert(rv == 0);
|
||||||
}
|
}
|
||||||
|
|||||||
6
server/modules/filter/cache/cache.hh
vendored
6
server/modules/filter/cache/cache.hh
vendored
@ -112,7 +112,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
cache_result_t get_key(const char* zDefault_db,
|
cache_result_t get_key(const char* zDefault_db,
|
||||||
const GWBUF* pQuery,
|
const GWBUF* pQuery,
|
||||||
CACHE_KEY* pKey) const;
|
CACHE_KEY* pKey) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a key for the statement. Does not take the current config
|
* Returns a key for the statement. Does not take the current config
|
||||||
@ -126,7 +126,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
static cache_result_t get_default_key(const char* zDefault_db,
|
static cache_result_t get_default_key(const char* zDefault_db,
|
||||||
const GWBUF* pQuery,
|
const GWBUF* pQuery,
|
||||||
CACHE_KEY* pKey);
|
CACHE_KEY* pKey);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See @Storage::get_value
|
* See @Storage::get_value
|
||||||
@ -135,7 +135,7 @@ public:
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const = 0;
|
GWBUF** ppValue) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See @Storage::put_value
|
* See @Storage::put_value
|
||||||
|
|||||||
@ -231,7 +231,7 @@ typedef struct cache_storage_api
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** result);
|
GWBUF** result);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put a value to the cache.
|
* Put a value to the cache.
|
||||||
|
|||||||
32
server/modules/filter/cache/cacheconfig.cc
vendored
32
server/modules/filter/cache/cacheconfig.cc
vendored
@ -41,7 +41,7 @@ config::ParamDuration<std::chrono::milliseconds> CacheConfig::s_hard_ttl(
|
|||||||
"used before it is discarded and the result is fetched from the backend. "
|
"used before it is discarded and the result is fetched from the backend. "
|
||||||
"See also 'soft_ttl'.",
|
"See also 'soft_ttl'.",
|
||||||
mxs::config::INTERPRET_AS_SECONDS,
|
mxs::config::INTERPRET_AS_SECONDS,
|
||||||
std::chrono::milliseconds { 0 }
|
std::chrono::milliseconds {0}
|
||||||
);
|
);
|
||||||
|
|
||||||
config::ParamDuration<std::chrono::milliseconds> CacheConfig::s_soft_ttl(
|
config::ParamDuration<std::chrono::milliseconds> CacheConfig::s_soft_ttl(
|
||||||
@ -51,7 +51,7 @@ config::ParamDuration<std::chrono::milliseconds> CacheConfig::s_soft_ttl(
|
|||||||
"used before the first client querying for the result is used for refreshing "
|
"used before the first client querying for the result is used for refreshing "
|
||||||
"the cached data from the backend. See also 'hard_ttl'.",
|
"the cached data from the backend. See also 'hard_ttl'.",
|
||||||
mxs::config::INTERPRET_AS_SECONDS,
|
mxs::config::INTERPRET_AS_SECONDS,
|
||||||
std::chrono::milliseconds { 0 }
|
std::chrono::milliseconds {0}
|
||||||
);
|
);
|
||||||
|
|
||||||
config::ParamCount CacheConfig::s_max_resultset_rows(
|
config::ParamCount CacheConfig::s_max_resultset_rows(
|
||||||
@ -107,10 +107,10 @@ config::ParamEnum<cache_thread_model_t> CacheConfig::s_thread_model(
|
|||||||
&s_specification,
|
&s_specification,
|
||||||
"cached_data",
|
"cached_data",
|
||||||
"An enumeration option specifying how data is shared between threads.",
|
"An enumeration option specifying how data is shared between threads.",
|
||||||
{
|
{
|
||||||
{ CACHE_THREAD_MODEL_MT, "shared" },
|
{CACHE_THREAD_MODEL_MT, "shared"},
|
||||||
{ CACHE_THREAD_MODEL_ST, "thread_specific" }
|
{CACHE_THREAD_MODEL_ST, "thread_specific"}
|
||||||
},
|
},
|
||||||
CACHE_THREAD_MODEL_ST
|
CACHE_THREAD_MODEL_ST
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -119,10 +119,10 @@ config::ParamEnum<cache_selects_t> CacheConfig::s_selects(
|
|||||||
"selects",
|
"selects",
|
||||||
"An enumeration option specifying what approach the cache should take with "
|
"An enumeration option specifying what approach the cache should take with "
|
||||||
"respect to SELECT statements.",
|
"respect to SELECT statements.",
|
||||||
{
|
{
|
||||||
{ CACHE_SELECTS_ASSUME_CACHEABLE, "assume_cacheable" },
|
{CACHE_SELECTS_ASSUME_CACHEABLE, "assume_cacheable"},
|
||||||
{ CACHE_SELECTS_VERIFY_CACHEABLE, "verify_cacheable" }
|
{CACHE_SELECTS_VERIFY_CACHEABLE, "verify_cacheable"}
|
||||||
},
|
},
|
||||||
CACHE_SELECTS_ASSUME_CACHEABLE
|
CACHE_SELECTS_ASSUME_CACHEABLE
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -131,11 +131,11 @@ config::ParamEnum<cache_in_trxs_t> CacheConfig::s_cache_in_trxs(
|
|||||||
"cache_in_transactions",
|
"cache_in_transactions",
|
||||||
"An enumeration option specifying how the cache should behave when there "
|
"An enumeration option specifying how the cache should behave when there "
|
||||||
"are active transactions.",
|
"are active transactions.",
|
||||||
{
|
{
|
||||||
{ CACHE_IN_TRXS_NEVER, "never" },
|
{CACHE_IN_TRXS_NEVER, "never"},
|
||||||
{ CACHE_IN_TRXS_READ_ONLY, "read_only_transactions" },
|
{CACHE_IN_TRXS_READ_ONLY, "read_only_transactions"},
|
||||||
{ CACHE_IN_TRXS_ALL, "all_transactions" }
|
{CACHE_IN_TRXS_ALL, "all_transactions"}
|
||||||
},
|
},
|
||||||
CACHE_IN_TRXS_ALL
|
CACHE_IN_TRXS_ALL
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ bool CacheConfig::configure()
|
|||||||
if (this->soft_ttl > this->hard_ttl)
|
if (this->soft_ttl > this->hard_ttl)
|
||||||
{
|
{
|
||||||
MXS_WARNING("The value of 'soft_ttl' must be less than or equal to that of 'hard_ttl'. "
|
MXS_WARNING("The value of 'soft_ttl' must be less than or equal to that of 'hard_ttl'. "
|
||||||
"Setting 'soft_ttl' to the same value as 'hard_ttl'.");
|
"Setting 'soft_ttl' to the same value as 'hard_ttl'.");
|
||||||
this->soft_ttl = this->hard_ttl;
|
this->soft_ttl = this->hard_ttl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
server/modules/filter/cache/cacheconfig.hh
vendored
10
server/modules/filter/cache/cacheconfig.hh
vendored
@ -42,7 +42,7 @@ public:
|
|||||||
~CacheConfig();
|
~CacheConfig();
|
||||||
|
|
||||||
CacheConfig(const CacheConfig&) = delete;
|
CacheConfig(const CacheConfig&) = delete;
|
||||||
CacheConfig& operator = (const CacheConfig&) = delete;
|
CacheConfig& operator=(const CacheConfig&) = delete;
|
||||||
|
|
||||||
using milliseconds = std::chrono::milliseconds;
|
using milliseconds = std::chrono::milliseconds;
|
||||||
|
|
||||||
@ -60,9 +60,9 @@ public:
|
|||||||
config::Enum<cache_selects_t> selects;
|
config::Enum<cache_selects_t> selects;
|
||||||
config::Enum<cache_in_trxs_t> cache_in_trxs;
|
config::Enum<cache_in_trxs_t> cache_in_trxs;
|
||||||
config::Bool enabled;
|
config::Bool enabled;
|
||||||
char* zStorage_options { nullptr}; /**< Raw options for storage module. */
|
char* zStorage_options {nullptr}; /**< Raw options for storage module. */
|
||||||
char** storage_argv { nullptr }; /**< Cooked options for storage module. */
|
char** storage_argv {nullptr}; /**< Cooked options for storage module. */
|
||||||
int storage_argc { 0 }; /**< Number of cooked options. */
|
int storage_argc {0}; /**< Number of cooked options. */
|
||||||
|
|
||||||
static const config::Specification& specification()
|
static const config::Specification& specification()
|
||||||
{
|
{
|
||||||
@ -73,7 +73,7 @@ private:
|
|||||||
bool configure() override;
|
bool configure() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static config::Specification s_specification;
|
static config::Specification s_specification;
|
||||||
|
|
||||||
static config::ParamString s_storage;
|
static config::ParamString s_storage;
|
||||||
static config::ParamString s_storage_options;
|
static config::ParamString s_storage_options;
|
||||||
|
|||||||
4
server/modules/filter/cache/cachept.cc
vendored
4
server/modules/filter/cache/cachept.cc
vendored
@ -50,7 +50,7 @@ CachePT::CachePT(const std::string& name,
|
|||||||
const CacheConfig* pConfig,
|
const CacheConfig* pConfig,
|
||||||
const std::vector<SCacheRules>& rules,
|
const std::vector<SCacheRules>& rules,
|
||||||
SStorageFactory sFactory,
|
SStorageFactory sFactory,
|
||||||
const Caches& caches)
|
const Caches& caches)
|
||||||
: Cache(name, pConfig, rules, sFactory)
|
: Cache(name, pConfig, rules, sFactory)
|
||||||
, m_caches(caches)
|
, m_caches(caches)
|
||||||
{
|
{
|
||||||
@ -131,7 +131,7 @@ cache_result_t CachePT::get_value(const CACHE_KEY& key,
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const
|
GWBUF** ppValue) const
|
||||||
{
|
{
|
||||||
return thread_cache().get_value(key, flags, soft_ttl, hard_ttl, ppValue);
|
return thread_cache().get_value(key, flags, soft_ttl, hard_ttl, ppValue);
|
||||||
}
|
}
|
||||||
|
|||||||
4
server/modules/filter/cache/cachept.hh
vendored
4
server/modules/filter/cache/cachept.hh
vendored
@ -36,7 +36,7 @@ public:
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const;
|
GWBUF** ppValue) const;
|
||||||
|
|
||||||
cache_result_t put_value(const CACHE_KEY& key, const GWBUF* pValue);
|
cache_result_t put_value(const CACHE_KEY& key, const GWBUF* pValue);
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ private:
|
|||||||
const CacheConfig* pConfig,
|
const CacheConfig* pConfig,
|
||||||
const std::vector<SCacheRules>& rules,
|
const std::vector<SCacheRules>& rules,
|
||||||
SStorageFactory sFactory,
|
SStorageFactory sFactory,
|
||||||
const Caches& caches);
|
const Caches& caches);
|
||||||
|
|
||||||
static CachePT* Create(const std::string& name,
|
static CachePT* Create(const std::string& name,
|
||||||
const CacheConfig* pConfig,
|
const CacheConfig* pConfig,
|
||||||
|
|||||||
2
server/modules/filter/cache/cachesimple.cc
vendored
2
server/modules/filter/cache/cachesimple.cc
vendored
@ -56,7 +56,7 @@ cache_result_t CacheSimple::get_value(const CACHE_KEY& key,
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const
|
GWBUF** ppValue) const
|
||||||
{
|
{
|
||||||
return m_pStorage->get_value(key, flags, soft_ttl, hard_ttl, ppValue);
|
return m_pStorage->get_value(key, flags, soft_ttl, hard_ttl, ppValue);
|
||||||
}
|
}
|
||||||
|
|||||||
2
server/modules/filter/cache/cachesimple.hh
vendored
2
server/modules/filter/cache/cachesimple.hh
vendored
@ -28,7 +28,7 @@ public:
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const;
|
GWBUF** ppValue) const;
|
||||||
|
|
||||||
cache_result_t put_value(const CACHE_KEY& key, const GWBUF* pValue);
|
cache_result_t put_value(const CACHE_KEY& key, const GWBUF* pValue);
|
||||||
|
|
||||||
|
|||||||
6
server/modules/filter/cache/lrustorage.cc
vendored
6
server/modules/filter/cache/lrustorage.cc
vendored
@ -76,7 +76,7 @@ cache_result_t LRUStorage::do_get_value(const CACHE_KEY& key,
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const
|
GWBUF** ppValue) const
|
||||||
{
|
{
|
||||||
return access_value(APPROACH_GET, key, flags, soft_ttl, hard_ttl, ppValue);
|
return access_value(APPROACH_GET, key, flags, soft_ttl, hard_ttl, ppValue);
|
||||||
}
|
}
|
||||||
@ -220,11 +220,11 @@ cache_result_t LRUStorage::do_get_items(uint64_t* pItems) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
cache_result_t LRUStorage::access_value(access_approach_t approach,
|
cache_result_t LRUStorage::access_value(access_approach_t approach,
|
||||||
const CACHE_KEY& key,
|
const CACHE_KEY& key,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const
|
GWBUF** ppValue) const
|
||||||
{
|
{
|
||||||
cache_result_t result = CACHE_RESULT_NOT_FOUND;
|
cache_result_t result = CACHE_RESULT_NOT_FOUND;
|
||||||
|
|
||||||
|
|||||||
8
server/modules/filter/cache/lrustorage.hh
vendored
8
server/modules/filter/cache/lrustorage.hh
vendored
@ -43,7 +43,7 @@ protected:
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const;
|
GWBUF** ppValue) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Storage::put_value
|
* @see Storage::put_value
|
||||||
@ -89,15 +89,15 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
cache_result_t access_value(access_approach_t approach,
|
cache_result_t access_value(access_approach_t approach,
|
||||||
const CACHE_KEY& key,
|
const CACHE_KEY& key,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const;
|
GWBUF** ppValue) const;
|
||||||
|
|
||||||
cache_result_t peek_value(const CACHE_KEY& key,
|
cache_result_t peek_value(const CACHE_KEY& key,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
GWBUF** ppValue) const
|
GWBUF** ppValue) const
|
||||||
{
|
{
|
||||||
return access_value(APPROACH_PEEK, key, flags, CACHE_USE_CONFIG_TTL, CACHE_USE_CONFIG_TTL, ppValue);
|
return access_value(APPROACH_PEEK, key, flags, CACHE_USE_CONFIG_TTL, CACHE_USE_CONFIG_TTL, ppValue);
|
||||||
}
|
}
|
||||||
|
|||||||
2
server/modules/filter/cache/lrustoragemt.cc
vendored
2
server/modules/filter/cache/lrustoragemt.cc
vendored
@ -45,7 +45,7 @@ cache_result_t LRUStorageMT::get_value(const CACHE_KEY& key,
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const
|
GWBUF** ppValue) const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(m_lock);
|
std::lock_guard<std::mutex> guard(m_lock);
|
||||||
|
|
||||||
|
|||||||
2
server/modules/filter/cache/lrustoragemt.hh
vendored
2
server/modules/filter/cache/lrustoragemt.hh
vendored
@ -32,7 +32,7 @@ public:
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const;
|
GWBUF** ppValue) const;
|
||||||
|
|
||||||
cache_result_t put_value(const CACHE_KEY& key,
|
cache_result_t put_value(const CACHE_KEY& key,
|
||||||
const GWBUF* pValue);
|
const GWBUF* pValue);
|
||||||
|
|||||||
2
server/modules/filter/cache/lrustoragest.cc
vendored
2
server/modules/filter/cache/lrustoragest.cc
vendored
@ -43,7 +43,7 @@ cache_result_t LRUStorageST::get_value(const CACHE_KEY& key,
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const
|
GWBUF** ppValue) const
|
||||||
{
|
{
|
||||||
return LRUStorage::do_get_value(key, flags, soft_ttl, hard_ttl, ppValue);
|
return LRUStorage::do_get_value(key, flags, soft_ttl, hard_ttl, ppValue);
|
||||||
}
|
}
|
||||||
|
|||||||
2
server/modules/filter/cache/lrustoragest.hh
vendored
2
server/modules/filter/cache/lrustoragest.hh
vendored
@ -29,7 +29,7 @@ public:
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const;
|
GWBUF** ppValue) const;
|
||||||
|
|
||||||
cache_result_t put_value(const CACHE_KEY& key,
|
cache_result_t put_value(const CACHE_KEY& key,
|
||||||
const GWBUF* pValue);
|
const GWBUF* pValue);
|
||||||
|
|||||||
4
server/modules/filter/cache/storage.hh
vendored
4
server/modules/filter/cache/storage.hh
vendored
@ -68,11 +68,11 @@ public:
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const = 0;
|
GWBUF** ppValue) const = 0;
|
||||||
|
|
||||||
cache_result_t get_value(const CACHE_KEY& key,
|
cache_result_t get_value(const CACHE_KEY& key,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
GWBUF** ppValue) const
|
GWBUF** ppValue) const
|
||||||
{
|
{
|
||||||
return get_value(key, flags, CACHE_USE_CONFIG_TTL, CACHE_USE_CONFIG_TTL, ppValue);
|
return get_value(key, flags, CACHE_USE_CONFIG_TTL, CACHE_USE_CONFIG_TTL, ppValue);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,6 @@ const size_t INMEMORY_KEY_LENGTH = 2 * SHA512_DIGEST_LENGTH;
|
|||||||
#if INMEMORY_KEY_LENGTH > CACHE_KEY_MAXLEN
|
#if INMEMORY_KEY_LENGTH > CACHE_KEY_MAXLEN
|
||||||
#error storage_inmemory key is too long.
|
#error storage_inmemory key is too long.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InMemoryStorage::InMemoryStorage(const string& name, const CACHE_STORAGE_CONFIG& config)
|
InMemoryStorage::InMemoryStorage(const string& name, const CACHE_STORAGE_CONFIG& config)
|
||||||
@ -137,7 +136,7 @@ cache_result_t InMemoryStorage::do_get_value(const CACHE_KEY& key,
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppResult)
|
GWBUF** ppResult)
|
||||||
{
|
{
|
||||||
cache_result_t result = CACHE_RESULT_NOT_FOUND;
|
cache_result_t result = CACHE_RESULT_NOT_FOUND;
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public:
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppResult) = 0;
|
GWBUF** ppResult) = 0;
|
||||||
virtual cache_result_t put_value(const CACHE_KEY& key, const GWBUF& value) = 0;
|
virtual cache_result_t put_value(const CACHE_KEY& key, const GWBUF& value) = 0;
|
||||||
virtual cache_result_t del_value(const CACHE_KEY& key) = 0;
|
virtual cache_result_t del_value(const CACHE_KEY& key) = 0;
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ protected:
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppResult);
|
GWBUF** ppResult);
|
||||||
cache_result_t do_put_value(const CACHE_KEY& key, const GWBUF& value);
|
cache_result_t do_put_value(const CACHE_KEY& key, const GWBUF& value);
|
||||||
cache_result_t do_del_value(const CACHE_KEY& key);
|
cache_result_t do_del_value(const CACHE_KEY& key);
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@ cache_result_t InMemoryStorageMT::get_value(const CACHE_KEY& key,
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppResult)
|
GWBUF** ppResult)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(m_lock);
|
std::lock_guard<std::mutex> guard(m_lock);
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ public:
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppResult);
|
GWBUF** ppResult);
|
||||||
cache_result_t put_value(const CACHE_KEY& key, const GWBUF& value);
|
cache_result_t put_value(const CACHE_KEY& key, const GWBUF& value);
|
||||||
cache_result_t del_value(const CACHE_KEY& key);
|
cache_result_t del_value(const CACHE_KEY& key);
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,7 @@ cache_result_t InMemoryStorageST::get_value(const CACHE_KEY& key,
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppResult)
|
GWBUF** ppResult)
|
||||||
{
|
{
|
||||||
return do_get_value(key, flags, soft_ttl, hard_ttl, ppResult);
|
return do_get_value(key, flags, soft_ttl, hard_ttl, ppResult);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public:
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppResult);
|
GWBUF** ppResult);
|
||||||
cache_result_t put_value(const CACHE_KEY& key, const GWBUF& pValue);
|
cache_result_t put_value(const CACHE_KEY& key, const GWBUF& pValue);
|
||||||
cache_result_t del_value(const CACHE_KEY& key);
|
cache_result_t del_value(const CACHE_KEY& key);
|
||||||
|
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
|
||||||
CACHE_STORAGE_API* CacheGetStorageAPI()
|
CACHE_STORAGE_API* CacheGetStorageAPI()
|
||||||
{
|
{
|
||||||
return &StorageModule<InMemoryStorage>::s_api;
|
return &StorageModule<InMemoryStorage>::s_api;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,7 +74,7 @@ public:
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppResult)
|
GWBUF** ppResult)
|
||||||
{
|
{
|
||||||
mxb_assert(pCache_storage);
|
mxb_assert(pCache_storage);
|
||||||
mxb_assert(pKey);
|
mxb_assert(pKey);
|
||||||
|
|||||||
2
server/modules/filter/cache/storagereal.cc
vendored
2
server/modules/filter/cache/storagereal.cc
vendored
@ -42,7 +42,7 @@ cache_result_t StorageReal::get_value(const CACHE_KEY& key,
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const
|
GWBUF** ppValue) const
|
||||||
{
|
{
|
||||||
return m_pApi->getValue(m_pStorage, &key, flags, soft_ttl, hard_ttl, ppValue);
|
return m_pApi->getValue(m_pStorage, &key, flags, soft_ttl, hard_ttl, ppValue);
|
||||||
}
|
}
|
||||||
|
|||||||
2
server/modules/filter/cache/storagereal.hh
vendored
2
server/modules/filter/cache/storagereal.hh
vendored
@ -29,7 +29,7 @@ public:
|
|||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
uint32_t soft_ttl,
|
uint32_t soft_ttl,
|
||||||
uint32_t hard_ttl,
|
uint32_t hard_ttl,
|
||||||
GWBUF** ppValue) const;
|
GWBUF** ppValue) const;
|
||||||
|
|
||||||
cache_result_t put_value(const CACHE_KEY& key,
|
cache_result_t put_value(const CACHE_KEY& key,
|
||||||
const GWBUF* pValue);
|
const GWBUF* pValue);
|
||||||
|
|||||||
@ -26,14 +26,14 @@ unsigned int millisleep(unsigned int milliseconds)
|
|||||||
unsigned int seconds = milliseconds / 1000;
|
unsigned int seconds = milliseconds / 1000;
|
||||||
milliseconds -= (seconds * 1000);
|
milliseconds -= (seconds * 1000);
|
||||||
|
|
||||||
timespec req = { seconds, milliseconds * 1000000 };
|
// Parentheses required by uncrustify, otherwise it'll think it's a pointer
|
||||||
timespec rem = { 0, 0 };
|
timespec req = {seconds, (milliseconds * 1000000)};
|
||||||
|
timespec rem = {0, 0};
|
||||||
|
|
||||||
nanosleep(&req, &rem);
|
nanosleep(&req, &rem);
|
||||||
|
|
||||||
return rem.tv_sec * 1000 + rem.tv_nsec / 1000000;
|
return rem.tv_sec * 1000 + rem.tv_nsec / 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
10
server/modules/filter/cache/test/teststorage.cc
vendored
10
server/modules/filter/cache/test/teststorage.cc
vendored
@ -27,11 +27,11 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
TestStorage::TestStorage(ostream* pOut,
|
TestStorage::TestStorage(ostream* pOut,
|
||||||
size_t threads,
|
size_t threads,
|
||||||
size_t seconds,
|
size_t seconds,
|
||||||
size_t items,
|
size_t items,
|
||||||
size_t min_size,
|
size_t min_size,
|
||||||
size_t max_size)
|
size_t max_size)
|
||||||
: m_out(*pOut)
|
: m_out(*pOut)
|
||||||
, m_threads(threads)
|
, m_threads(threads)
|
||||||
, m_seconds(seconds)
|
, m_seconds(seconds)
|
||||||
|
|||||||
@ -39,7 +39,6 @@ const MXS_ENUM_VALUE option_values[] =
|
|||||||
{"extended", PCRE2_EXTENDED},
|
{"extended", PCRE2_EXTENDED},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CCRFilter;
|
class CCRFilter;
|
||||||
@ -62,7 +61,7 @@ private:
|
|||||||
CCRFilter& m_instance;
|
CCRFilter& m_instance;
|
||||||
int m_hints_left = 0; /* Number of hints left to add to queries */
|
int m_hints_left = 0; /* Number of hints left to add to queries */
|
||||||
time_t m_last_modification = 0; /* Time of the last data modifying operation */
|
time_t m_last_modification = 0; /* Time of the last data modifying operation */
|
||||||
pcre2_match_data* m_md = nullptr; /* PCRE2 match data */
|
pcre2_match_data* m_md = nullptr; /* PCRE2 match data */
|
||||||
|
|
||||||
enum CcrHintValue
|
enum CcrHintValue
|
||||||
{
|
{
|
||||||
@ -183,8 +182,8 @@ private:
|
|||||||
int m_count = 0; /* Number of hints to add after each operation that modifies data. */
|
int m_count = 0; /* Number of hints to add after each operation that modifies data. */
|
||||||
|
|
||||||
LagStats m_stats;
|
LagStats m_stats;
|
||||||
pcre2_code* re = nullptr; /* Compiled regex text of match */
|
pcre2_code* re = nullptr; /* Compiled regex text of match */
|
||||||
pcre2_code* nore = nullptr; /* Compiled regex text of ignore */
|
pcre2_code* nore = nullptr; /* Compiled regex text of ignore */
|
||||||
uint32_t ovector_size = 0; /* PCRE2 match data ovector size */
|
uint32_t ovector_size = 0; /* PCRE2 match data ovector size */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -343,16 +342,22 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
"V1.1.0",
|
"V1.1.0",
|
||||||
RCAP_TYPE_CONTIGUOUS_INPUT,
|
RCAP_TYPE_CONTIGUOUS_INPUT,
|
||||||
&CCRFilter::s_object,
|
&CCRFilter::s_object,
|
||||||
NULL, /* Process init. */
|
NULL,
|
||||||
NULL, /* Process finish. */
|
NULL,
|
||||||
NULL, /* Thread init. */
|
NULL,
|
||||||
NULL, /* Thread finish. */
|
NULL,
|
||||||
{
|
{
|
||||||
{"count", MXS_MODULE_PARAM_COUNT, "0"},
|
{"count", MXS_MODULE_PARAM_COUNT, "0" },
|
||||||
{"time", MXS_MODULE_PARAM_DURATION, "60s"},
|
{"time", MXS_MODULE_PARAM_DURATION, "60s"},
|
||||||
{PARAM_MATCH, MXS_MODULE_PARAM_REGEX},
|
{PARAM_MATCH, MXS_MODULE_PARAM_REGEX},
|
||||||
{PARAM_IGNORE, MXS_MODULE_PARAM_REGEX},
|
{PARAM_IGNORE, MXS_MODULE_PARAM_REGEX},
|
||||||
{"options", MXS_MODULE_PARAM_ENUM, "ignorecase", MXS_MODULE_OPT_NONE, option_values},
|
{
|
||||||
|
"options",
|
||||||
|
MXS_MODULE_PARAM_ENUM,
|
||||||
|
"ignorecase",
|
||||||
|
MXS_MODULE_OPT_NONE,
|
||||||
|
option_values
|
||||||
|
},
|
||||||
{MXS_END_MODULE_PARAMS}
|
{MXS_END_MODULE_PARAMS}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -50,7 +50,8 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommentFilter::CommentFilter(std::string comment) : m_comment(comment)
|
CommentFilter::CommentFilter(std::string comment)
|
||||||
|
: m_comment(comment)
|
||||||
{
|
{
|
||||||
MXS_INFO("Comment filter with comment [%s] created.", m_comment.c_str());
|
MXS_INFO("Comment filter with comment [%s] created.", m_comment.c_str());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -148,7 +148,7 @@ public:
|
|||||||
if (!(m_options & m_option))
|
if (!(m_options & m_option))
|
||||||
{
|
{
|
||||||
uint32_t options = (m_options | m_option);
|
uint32_t options = (m_options | m_option);
|
||||||
MXB_AT_DEBUG(bool rv = )qc_set_options(options);
|
MXB_AT_DEBUG(bool rv = ) qc_set_options(options);
|
||||||
mxb_assert(rv);
|
mxb_assert(rv);
|
||||||
m_disable = true;
|
m_disable = true;
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (m_disable)
|
if (m_disable)
|
||||||
{
|
{
|
||||||
MXB_AT_DEBUG(bool rv = )qc_set_options(m_options);
|
MXB_AT_DEBUG(bool rv = ) qc_set_options(m_options);
|
||||||
mxb_assert(rv);
|
mxb_assert(rv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,7 +169,6 @@ private:
|
|||||||
uint32_t m_options;
|
uint32_t m_options;
|
||||||
bool m_disable;
|
bool m_disable;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parse_at_times(const char** tok, char** saveptr, Rule* ruledef);
|
bool parse_at_times(const char** tok, char** saveptr, Rule* ruledef);
|
||||||
@ -1799,8 +1798,8 @@ static char* create_parse_error(Dbfw* my_instance,
|
|||||||
bool rule_matches(Dbfw* my_instance,
|
bool rule_matches(Dbfw* my_instance,
|
||||||
DbfwSession* my_session,
|
DbfwSession* my_session,
|
||||||
GWBUF* queue,
|
GWBUF* queue,
|
||||||
SRule rule,
|
SRule rule,
|
||||||
char* query)
|
char* query)
|
||||||
{
|
{
|
||||||
mxb_assert(GWBUF_IS_CONTIGUOUS(queue));
|
mxb_assert(GWBUF_IS_CONTIGUOUS(queue));
|
||||||
char* msg = NULL;
|
char* msg = NULL;
|
||||||
|
|||||||
@ -313,6 +313,6 @@ char* create_error(const char* format, ...);
|
|||||||
bool rule_matches(Dbfw* my_instance,
|
bool rule_matches(Dbfw* my_instance,
|
||||||
DbfwSession* my_session,
|
DbfwSession* my_session,
|
||||||
GWBUF* queue,
|
GWBUF* queue,
|
||||||
SRule rule,
|
SRule rule,
|
||||||
char* query);
|
char* query);
|
||||||
bool rule_is_active(SRule rule);
|
bool rule_is_active(SRule rule);
|
||||||
|
|||||||
@ -87,26 +87,26 @@ extern "C"
|
|||||||
*
|
*
|
||||||
* @return The module object
|
* @return The module object
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
|
{
|
||||||
|
static MXS_MODULE info =
|
||||||
{
|
{
|
||||||
static MXS_MODULE info =
|
MXS_MODULE_API_FILTER,
|
||||||
|
MXS_MODULE_ALPHA_RELEASE,
|
||||||
|
MXS_FILTER_VERSION,
|
||||||
|
"A hint parsing filter",
|
||||||
|
"V1.0.0",
|
||||||
|
RCAP_TYPE_CONTIGUOUS_INPUT,
|
||||||
|
&HintInstance::s_object,
|
||||||
|
NULL, /* Process init. */
|
||||||
|
NULL, /* Process finish. */
|
||||||
|
NULL, /* Thread init. */
|
||||||
|
NULL, /* Thread finish. */
|
||||||
{
|
{
|
||||||
MXS_MODULE_API_FILTER,
|
{MXS_END_MODULE_PARAMS}
|
||||||
MXS_MODULE_ALPHA_RELEASE,
|
}
|
||||||
MXS_FILTER_VERSION,
|
};
|
||||||
"A hint parsing filter",
|
|
||||||
"V1.0.0",
|
|
||||||
RCAP_TYPE_CONTIGUOUS_INPUT,
|
|
||||||
&HintInstance::s_object,
|
|
||||||
NULL, /* Process init. */
|
|
||||||
NULL, /* Process finish. */
|
|
||||||
NULL, /* Thread init. */
|
|
||||||
NULL, /* Thread finish. */
|
|
||||||
{
|
|
||||||
{MXS_END_MODULE_PARAMS}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@ void test(const std::string& input, std::initializer_list<std::string> expected)
|
|||||||
if (it == expected.end())
|
if (it == expected.end())
|
||||||
{
|
{
|
||||||
std::cout << "Too much output: " << std::string(output.first, output.second) << std::endl;
|
std::cout << "Too much output: " << std::string(output.first, output.second) << std::endl;
|
||||||
errors++;;
|
errors++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,12 +46,12 @@ void test(const std::string& input, std::initializer_list<std::string> expected)
|
|||||||
if (have != need)
|
if (have != need)
|
||||||
{
|
{
|
||||||
std::cout << "Need " << need << " bytes but only have " << have << std::endl;
|
std::cout << "Need " << need << " bytes but only have " << have << std::endl;
|
||||||
errors++;;
|
errors++;
|
||||||
}
|
}
|
||||||
else if (!std::equal(output.first, output.second, it->begin()))
|
else if (!std::equal(output.first, output.second, it->begin()))
|
||||||
{
|
{
|
||||||
std::cout << "Output not equal to expected output" << std::endl;
|
std::cout << "Output not equal to expected output" << std::endl;
|
||||||
errors++;;
|
errors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rval)
|
if (!rval)
|
||||||
@ -69,7 +69,7 @@ void test(const std::string& input, std::initializer_list<std::string> expected)
|
|||||||
{
|
{
|
||||||
std::cout << "Not enough output, need " << std::distance(it, expected.end())
|
std::cout << "Not enough output, need " << std::distance(it, expected.end())
|
||||||
<< " more comments" << std::endl;
|
<< " more comments" << std::endl;
|
||||||
errors++;;
|
errors++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ void test_parse(const std::string& input, int expected_type)
|
|||||||
else if (hint && hint->type != expected_type)
|
else if (hint && hint->type != expected_type)
|
||||||
{
|
{
|
||||||
std::cout << "Expected hint of type " << expected_type << " but got type "
|
std::cout << "Expected hint of type " << expected_type << " but got type "
|
||||||
<< (int)hint->type << ": " << input << std::endl;
|
<< (int)hint->type << ": " << input << std::endl;
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -97,47 +97,47 @@ extern "C"
|
|||||||
*
|
*
|
||||||
* @return The module object
|
* @return The module object
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
|
{
|
||||||
|
|
||||||
|
static MXS_FILTER_OBJECT MyObject =
|
||||||
{
|
{
|
||||||
|
createInstance,
|
||||||
|
newSession,
|
||||||
|
closeSession,
|
||||||
|
freeSession,
|
||||||
|
setDownstream,
|
||||||
|
setUpstream,
|
||||||
|
routeQuery,
|
||||||
|
clientReply,
|
||||||
|
diagnostic,
|
||||||
|
diagnostic_json,
|
||||||
|
getCapabilities,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
static MXS_FILTER_OBJECT MyObject =
|
static MXS_MODULE info =
|
||||||
|
{
|
||||||
|
MXS_MODULE_API_FILTER,
|
||||||
|
MXS_MODULE_EXPERIMENTAL,
|
||||||
|
MXS_FILTER_VERSION,
|
||||||
|
"Data streaming filter",
|
||||||
|
"1.0.0",
|
||||||
|
RCAP_TYPE_TRANSACTION_TRACKING,
|
||||||
|
&MyObject,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
{
|
{
|
||||||
createInstance,
|
{"source", MXS_MODULE_PARAM_STRING },
|
||||||
newSession,
|
{"user", MXS_MODULE_PARAM_STRING },
|
||||||
closeSession,
|
{MXS_END_MODULE_PARAMS}
|
||||||
freeSession,
|
}
|
||||||
setDownstream,
|
};
|
||||||
setUpstream,
|
|
||||||
routeQuery,
|
|
||||||
clientReply,
|
|
||||||
diagnostic,
|
|
||||||
diagnostic_json,
|
|
||||||
getCapabilities,
|
|
||||||
NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
static MXS_MODULE info =
|
return &info;
|
||||||
{
|
}
|
||||||
MXS_MODULE_API_FILTER,
|
|
||||||
MXS_MODULE_EXPERIMENTAL,
|
|
||||||
MXS_FILTER_VERSION,
|
|
||||||
"Data streaming filter",
|
|
||||||
"1.0.0",
|
|
||||||
RCAP_TYPE_TRANSACTION_TRACKING,
|
|
||||||
&MyObject,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
{
|
|
||||||
{"source", MXS_MODULE_PARAM_STRING },
|
|
||||||
{"user", MXS_MODULE_PARAM_STRING },
|
|
||||||
{MXS_END_MODULE_PARAMS}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return &info;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -47,7 +47,6 @@ extern "C"
|
|||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@ -87,46 +86,46 @@ extern "C"
|
|||||||
*
|
*
|
||||||
* @return The module object
|
* @return The module object
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
|
{
|
||||||
|
static MXS_FILTER_OBJECT MyObject =
|
||||||
{
|
{
|
||||||
static MXS_FILTER_OBJECT MyObject =
|
createInstance,
|
||||||
{
|
newSession,
|
||||||
createInstance,
|
closeSession,
|
||||||
newSession,
|
freeSession,
|
||||||
closeSession,
|
setDownstream,
|
||||||
freeSession,
|
setUpstream,
|
||||||
setDownstream,
|
routeQuery,
|
||||||
setUpstream,
|
clientReply,
|
||||||
routeQuery,
|
diagnostic,
|
||||||
clientReply,
|
diagnostic_json,
|
||||||
diagnostic,
|
getCapabilities,
|
||||||
diagnostic_json,
|
NULL, // No destroyInstance
|
||||||
getCapabilities,
|
};
|
||||||
NULL, // No destroyInstance
|
|
||||||
};
|
|
||||||
|
|
||||||
static MXS_MODULE info =
|
static MXS_MODULE info =
|
||||||
|
{
|
||||||
|
MXS_MODULE_API_FILTER,
|
||||||
|
MXS_MODULE_EXPERIMENTAL,
|
||||||
|
MXS_FILTER_VERSION,
|
||||||
|
"Lua Filter",
|
||||||
|
"V1.0.0",
|
||||||
|
RCAP_TYPE_CONTIGUOUS_INPUT,
|
||||||
|
&MyObject,
|
||||||
|
NULL, /* Process init. */
|
||||||
|
NULL, /* Process finish. */
|
||||||
|
NULL, /* Thread init. */
|
||||||
|
NULL, /* Thread finish. */
|
||||||
{
|
{
|
||||||
MXS_MODULE_API_FILTER,
|
{"global_script", MXS_MODULE_PARAM_PATH, NULL, MXS_MODULE_OPT_PATH_R_OK},
|
||||||
MXS_MODULE_EXPERIMENTAL,
|
{"session_script", MXS_MODULE_PARAM_PATH, NULL, MXS_MODULE_OPT_PATH_R_OK},
|
||||||
MXS_FILTER_VERSION,
|
{MXS_END_MODULE_PARAMS}
|
||||||
"Lua Filter",
|
}
|
||||||
"V1.0.0",
|
};
|
||||||
RCAP_TYPE_CONTIGUOUS_INPUT,
|
|
||||||
&MyObject,
|
|
||||||
NULL, /* Process init. */
|
|
||||||
NULL, /* Process finish. */
|
|
||||||
NULL, /* Thread init. */
|
|
||||||
NULL, /* Thread finish. */
|
|
||||||
{
|
|
||||||
{"global_script", MXS_MODULE_PARAM_PATH, NULL, MXS_MODULE_OPT_PATH_R_OK},
|
|
||||||
{"session_script", MXS_MODULE_PARAM_PATH, NULL, MXS_MODULE_OPT_PATH_R_OK},
|
|
||||||
{MXS_END_MODULE_PARAMS}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int id_pool = 0;
|
static int id_pool = 0;
|
||||||
|
|||||||
@ -90,10 +90,10 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
"V1.0.0",
|
"V1.0.0",
|
||||||
RCAP_TYPE_CONTIGUOUS_INPUT | RCAP_TYPE_CONTIGUOUS_OUTPUT,
|
RCAP_TYPE_CONTIGUOUS_INPUT | RCAP_TYPE_CONTIGUOUS_OUTPUT,
|
||||||
&MaskingFilter::s_object,
|
&MaskingFilter::s_object,
|
||||||
NULL, /* Process init. */
|
NULL, /* Process init. */
|
||||||
NULL, /* Process finish. */
|
NULL, /* Process finish. */
|
||||||
NULL, /* Thread init. */
|
NULL, /* Thread init. */
|
||||||
NULL, /* Thread finish. */
|
NULL, /* Thread finish. */
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Config::rules_name,
|
Config::rules_name,
|
||||||
|
|||||||
@ -17,24 +17,23 @@
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
const char config_name_check_subqueries[] = "check_subqueries";
|
const char config_name_check_subqueries[] = "check_subqueries";
|
||||||
const char config_name_check_unions[] = "check_unions";
|
const char config_name_check_unions[] = "check_unions";
|
||||||
const char config_name_check_user_variables[] = "check_user_variables";
|
const char config_name_check_user_variables[] = "check_user_variables";
|
||||||
const char config_name_large_payload[] = "large_payload";
|
const char config_name_large_payload[] = "large_payload";
|
||||||
const char config_name_prevent_function_usage[] = "prevent_function_usage";
|
const char config_name_prevent_function_usage[] = "prevent_function_usage";
|
||||||
const char config_name_require_fully_parsed[] = "require_fully_parsed";
|
const char config_name_require_fully_parsed[] = "require_fully_parsed";
|
||||||
const char config_name_rules[] = "rules";
|
const char config_name_rules[] = "rules";
|
||||||
const char config_name_warn_type_mismatch[] = "warn_type_mismatch";
|
const char config_name_warn_type_mismatch[] = "warn_type_mismatch";
|
||||||
const char config_name_treat_string_arg_as_field[] = "treat_string_arg_as_field";
|
const char config_name_treat_string_arg_as_field[] = "treat_string_arg_as_field";
|
||||||
|
|
||||||
|
|
||||||
const char config_value_abort[] = "abort";
|
const char config_value_abort[] = "abort";
|
||||||
const char config_value_always[] = "always";
|
const char config_value_always[] = "always";
|
||||||
const char config_value_ignore[] = "ignore";
|
const char config_value_ignore[] = "ignore";
|
||||||
const char config_value_never[] = "never";
|
const char config_value_never[] = "never";
|
||||||
|
|
||||||
const char config_value_true[] = "true";
|
const char config_value_true[] = "true";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -67,7 +67,7 @@ public:
|
|||||||
if (!(m_options & m_option))
|
if (!(m_options & m_option))
|
||||||
{
|
{
|
||||||
uint32_t options = (m_options | m_option);
|
uint32_t options = (m_options | m_option);
|
||||||
MXB_AT_DEBUG(bool rv = )qc_set_options(options);
|
MXB_AT_DEBUG(bool rv = ) qc_set_options(options);
|
||||||
mxb_assert(rv);
|
mxb_assert(rv);
|
||||||
m_disable = true;
|
m_disable = true;
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (m_disable)
|
if (m_disable)
|
||||||
{
|
{
|
||||||
MXB_AT_DEBUG(bool rv = )qc_set_options(m_options);
|
MXB_AT_DEBUG(bool rv = ) qc_set_options(m_options);
|
||||||
mxb_assert(rv);
|
mxb_assert(rv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +88,6 @@ private:
|
|||||||
uint32_t m_options;
|
uint32_t m_options;
|
||||||
bool m_disable;
|
bool m_disable;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MaskingFilterSession::MaskingFilterSession(MXS_SESSION* pSession, const MaskingFilter* pFilter)
|
MaskingFilterSession::MaskingFilterSession(MXS_SESSION* pSession, const MaskingFilter* pFilter)
|
||||||
@ -580,19 +579,19 @@ bool MaskingFilterSession::is_function_used(GWBUF* pPacket, const char* zUser, c
|
|||||||
SMaskingRules sRules = m_filter.rules();
|
SMaskingRules sRules = m_filter.rules();
|
||||||
|
|
||||||
auto pred1 = [&sRules, zUser, zHost](const QC_FIELD_INFO& field_info) {
|
auto pred1 = [&sRules, zUser, zHost](const QC_FIELD_INFO& field_info) {
|
||||||
const MaskingRules::Rule* pRule = sRules->get_rule_for(field_info, zUser, zHost);
|
const MaskingRules::Rule* pRule = sRules->get_rule_for(field_info, zUser, zHost);
|
||||||
|
|
||||||
return pRule ? true : false;
|
return pRule ? true : false;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto pred2 = [&sRules, zUser, zHost, &pred1](const QC_FUNCTION_INFO& function_info) {
|
auto pred2 = [&sRules, zUser, zHost, &pred1](const QC_FUNCTION_INFO& function_info) {
|
||||||
const QC_FIELD_INFO* begin = function_info.fields;
|
const QC_FIELD_INFO* begin = function_info.fields;
|
||||||
const QC_FIELD_INFO* end = begin + function_info.n_fields;
|
const QC_FIELD_INFO* end = begin + function_info.n_fields;
|
||||||
|
|
||||||
auto i = std::find_if(begin, end, pred1);
|
auto i = std::find_if(begin, end, pred1);
|
||||||
|
|
||||||
return i != end;
|
return i != end;
|
||||||
};
|
};
|
||||||
|
|
||||||
const QC_FUNCTION_INFO* pInfos;
|
const QC_FUNCTION_INFO* pInfos;
|
||||||
size_t nInfos;
|
size_t nInfos;
|
||||||
@ -627,20 +626,20 @@ bool MaskingFilterSession::is_variable_defined(GWBUF* pPacket, const char* zUser
|
|||||||
SMaskingRules sRules = m_filter.rules();
|
SMaskingRules sRules = m_filter.rules();
|
||||||
|
|
||||||
auto pred = [&sRules, zUser, zHost](const QC_FIELD_INFO& field_info) {
|
auto pred = [&sRules, zUser, zHost](const QC_FIELD_INFO& field_info) {
|
||||||
bool rv = false;
|
bool rv = false;
|
||||||
|
|
||||||
if (strcmp(field_info.column, "*") == 0)
|
if (strcmp(field_info.column, "*") == 0)
|
||||||
{
|
{
|
||||||
// If "*" is used, then we must block if there is any rule for the current user.
|
// If "*" is used, then we must block if there is any rule for the current user.
|
||||||
rv = sRules->has_rule_for(zUser, zHost);
|
rv = sRules->has_rule_for(zUser, zHost);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rv = sRules->get_rule_for(field_info, zUser, zHost) ? true : false;
|
rv = sRules->get_rule_for(field_info, zUser, zHost) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
};
|
};
|
||||||
|
|
||||||
const QC_FIELD_INFO* pInfos;
|
const QC_FIELD_INFO* pInfos;
|
||||||
size_t nInfos;
|
size_t nInfos;
|
||||||
@ -701,23 +700,23 @@ bool MaskingFilterSession::is_union_or_subquery_used(GWBUF* pPacket, const char*
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto pred = [&sRules, mask, zUser, zHost](const QC_FIELD_INFO& field_info) {
|
auto pred = [&sRules, mask, zUser, zHost](const QC_FIELD_INFO& field_info) {
|
||||||
bool rv = false;
|
bool rv = false;
|
||||||
|
|
||||||
if (field_info.context & mask)
|
if (field_info.context & mask)
|
||||||
{
|
|
||||||
if (strcmp(field_info.column, "*") == 0)
|
|
||||||
{
|
{
|
||||||
// If "*" is used, then we must block if there is any rule for the current user.
|
if (strcmp(field_info.column, "*") == 0)
|
||||||
rv = sRules->has_rule_for(zUser, zHost);
|
{
|
||||||
|
// If "*" is used, then we must block if there is any rule for the current user.
|
||||||
|
rv = sRules->has_rule_for(zUser, zHost);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rv = sRules->get_rule_for(field_info, zUser, zHost) ? true : false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
rv = sRules->get_rule_for(field_info, zUser, zHost) ? true : false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
};
|
};
|
||||||
|
|
||||||
const QC_FIELD_INFO* pInfos;
|
const QC_FIELD_INFO* pInfos;
|
||||||
size_t nInfos;
|
size_t nInfos;
|
||||||
|
|||||||
@ -187,7 +187,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
AccountRegexp(const string& user,
|
AccountRegexp(const string& user,
|
||||||
const string& host,
|
const string& host,
|
||||||
pcre2_code* pCode)
|
pcre2_code* pCode)
|
||||||
: m_user(user)
|
: m_user(user)
|
||||||
, m_host(host)
|
, m_host(host)
|
||||||
, m_pCode(pCode)
|
, m_pCode(pCode)
|
||||||
@ -692,7 +692,7 @@ static bool rule_get_common_values(json_t* pRule,
|
|||||||
std::string* column,
|
std::string* column,
|
||||||
std::string* table,
|
std::string* table,
|
||||||
std::string* database,
|
std::string* database,
|
||||||
const char* rule_type)
|
const char* rule_type)
|
||||||
{
|
{
|
||||||
// Get database, table && column
|
// Get database, table && column
|
||||||
json_t* pDatabase = json_object_get(pRule, KEY_DATABASE);
|
json_t* pDatabase = json_object_get(pRule, KEY_DATABASE);
|
||||||
@ -745,7 +745,7 @@ bool rule_get_values(json_t* pRule,
|
|||||||
std::string* column,
|
std::string* column,
|
||||||
std::string* table,
|
std::string* table,
|
||||||
std::string* database,
|
std::string* database,
|
||||||
const char* rule_type)
|
const char* rule_type)
|
||||||
{
|
{
|
||||||
json_t* pKeyObj;
|
json_t* pKeyObj;
|
||||||
// Get Key object based on 'rule_type' param
|
// Get Key object based on 'rule_type' param
|
||||||
@ -1174,8 +1174,8 @@ bool MaskingRules::Rule::matches_account(const char* zUser,
|
|||||||
template<class FillIter, class OutIter>
|
template<class FillIter, class OutIter>
|
||||||
inline void fill_buffer(FillIter f_first,
|
inline void fill_buffer(FillIter f_first,
|
||||||
FillIter f_last,
|
FillIter f_last,
|
||||||
OutIter o_first,
|
OutIter o_first,
|
||||||
OutIter o_last)
|
OutIter o_last)
|
||||||
{
|
{
|
||||||
FillIter pFill = f_first;
|
FillIter pFill = f_first;
|
||||||
while (o_first != o_last)
|
while (o_first != o_last)
|
||||||
@ -1471,8 +1471,8 @@ const MaskingRules::Rule* MaskingRules::get_rule_for(const QC_FIELD_INFO& field_
|
|||||||
bool MaskingRules::has_rule_for(const char* zUser, const char* zHost) const
|
bool MaskingRules::has_rule_for(const char* zUser, const char* zHost) const
|
||||||
{
|
{
|
||||||
auto i = std::find_if(m_rules.begin(), m_rules.end(), [zUser, zHost](SRule sRule) {
|
auto i = std::find_if(m_rules.begin(), m_rules.end(), [zUser, zHost](SRule sRule) {
|
||||||
return sRule->matches_account(zUser, zHost);
|
return sRule->matches_account(zUser, zHost);
|
||||||
});
|
});
|
||||||
|
|
||||||
return i != m_rules.end();
|
return i != m_rules.end();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,66 +83,66 @@ extern "C"
|
|||||||
*
|
*
|
||||||
* @return The module object.
|
* @return The module object.
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
|
{
|
||||||
|
static MXS_FILTER_OBJECT object =
|
||||||
{
|
{
|
||||||
static MXS_FILTER_OBJECT object =
|
createInstance,
|
||||||
{
|
newSession,
|
||||||
createInstance,
|
closeSession,
|
||||||
newSession,
|
freeSession,
|
||||||
closeSession,
|
setDownstream,
|
||||||
freeSession,
|
setUpstream,
|
||||||
setDownstream,
|
routeQuery,
|
||||||
setUpstream,
|
clientReply,
|
||||||
routeQuery,
|
diagnostics,
|
||||||
clientReply,
|
diagnostics_json,
|
||||||
diagnostics,
|
getCapabilities,
|
||||||
diagnostics_json,
|
NULL, // No destroyInstance
|
||||||
getCapabilities,
|
};
|
||||||
NULL, // No destroyInstance
|
|
||||||
};
|
|
||||||
|
|
||||||
static MXS_MODULE info =
|
static MXS_MODULE info =
|
||||||
|
{
|
||||||
|
MXS_MODULE_API_FILTER,
|
||||||
|
MXS_MODULE_IN_DEVELOPMENT,
|
||||||
|
MXS_FILTER_VERSION,
|
||||||
|
"A filter that is capable of limiting the resultset number of rows.",
|
||||||
|
"V1.0.0",
|
||||||
|
RCAP_TYPE_STMT_INPUT | RCAP_TYPE_STMT_OUTPUT,
|
||||||
|
&object,
|
||||||
|
NULL, /* Process init. */
|
||||||
|
NULL, /* Process finish. */
|
||||||
|
NULL, /* Thread init. */
|
||||||
|
NULL, /* Thread finish. */
|
||||||
{
|
{
|
||||||
MXS_MODULE_API_FILTER,
|
|
||||||
MXS_MODULE_IN_DEVELOPMENT,
|
|
||||||
MXS_FILTER_VERSION,
|
|
||||||
"A filter that is capable of limiting the resultset number of rows.",
|
|
||||||
"V1.0.0",
|
|
||||||
RCAP_TYPE_STMT_INPUT | RCAP_TYPE_STMT_OUTPUT,
|
|
||||||
&object,
|
|
||||||
NULL, /* Process init. */
|
|
||||||
NULL, /* Process finish. */
|
|
||||||
NULL, /* Thread init. */
|
|
||||||
NULL, /* Thread finish. */
|
|
||||||
{
|
{
|
||||||
{
|
"max_resultset_rows",
|
||||||
"max_resultset_rows",
|
MXS_MODULE_PARAM_COUNT,
|
||||||
MXS_MODULE_PARAM_COUNT,
|
MAXROWS_DEFAULT_MAX_RESULTSET_ROWS
|
||||||
MAXROWS_DEFAULT_MAX_RESULTSET_ROWS
|
},
|
||||||
},
|
{
|
||||||
{
|
"max_resultset_size",
|
||||||
"max_resultset_size",
|
MXS_MODULE_PARAM_SIZE,
|
||||||
MXS_MODULE_PARAM_SIZE,
|
MAXROWS_DEFAULT_MAX_RESULTSET_SIZE
|
||||||
MAXROWS_DEFAULT_MAX_RESULTSET_SIZE
|
},
|
||||||
},
|
{
|
||||||
{
|
"debug",
|
||||||
"debug",
|
MXS_MODULE_PARAM_COUNT,
|
||||||
MXS_MODULE_PARAM_COUNT,
|
MAXROWS_DEFAULT_DEBUG
|
||||||
MAXROWS_DEFAULT_DEBUG
|
},
|
||||||
},
|
{
|
||||||
{
|
"max_resultset_return",
|
||||||
"max_resultset_return",
|
MXS_MODULE_PARAM_ENUM,
|
||||||
MXS_MODULE_PARAM_ENUM,
|
"empty",
|
||||||
"empty",
|
MXS_MODULE_OPT_ENUM_UNIQUE,
|
||||||
MXS_MODULE_OPT_ENUM_UNIQUE,
|
return_option_values
|
||||||
return_option_values
|
},
|
||||||
},
|
{MXS_END_MODULE_PARAMS}
|
||||||
{MXS_END_MODULE_PARAMS}
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implementation */
|
/* Implementation */
|
||||||
|
|||||||
@ -263,78 +263,84 @@ extern "C"
|
|||||||
*
|
*
|
||||||
* @return The module object
|
* @return The module object
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
|
{
|
||||||
|
static MXS_FILTER_OBJECT MyObject =
|
||||||
{
|
{
|
||||||
static MXS_FILTER_OBJECT MyObject =
|
createInstance,
|
||||||
{
|
newSession,
|
||||||
createInstance,
|
closeSession,
|
||||||
newSession,
|
freeSession,
|
||||||
closeSession,
|
setDownstream,
|
||||||
freeSession,
|
setUpstream,
|
||||||
setDownstream,
|
routeQuery,
|
||||||
setUpstream,
|
clientReply,
|
||||||
routeQuery,
|
diagnostic,
|
||||||
clientReply,
|
diagnostic_json,
|
||||||
diagnostic,
|
getCapabilities,
|
||||||
diagnostic_json,
|
NULL, // No destroyInstance
|
||||||
getCapabilities,
|
};
|
||||||
NULL, // No destroyInstance
|
|
||||||
};
|
|
||||||
|
|
||||||
static MXS_MODULE info =
|
static MXS_MODULE info =
|
||||||
|
{
|
||||||
|
MXS_MODULE_API_FILTER,
|
||||||
|
MXS_MODULE_ALPHA_RELEASE,
|
||||||
|
MXS_FILTER_VERSION,
|
||||||
|
"A RabbitMQ query logging filter",
|
||||||
|
"V1.0.2",
|
||||||
|
RCAP_TYPE_CONTIGUOUS_INPUT,
|
||||||
|
&MyObject,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
{
|
{
|
||||||
MXS_MODULE_API_FILTER,
|
{"hostname", MXS_MODULE_PARAM_STRING, "localhost" },
|
||||||
MXS_MODULE_ALPHA_RELEASE,
|
{"username", MXS_MODULE_PARAM_STRING, "guest" },
|
||||||
MXS_FILTER_VERSION,
|
{"password", MXS_MODULE_PARAM_STRING, "guest" },
|
||||||
"A RabbitMQ query logging filter",
|
{"vhost", MXS_MODULE_PARAM_STRING, "/" },
|
||||||
"V1.0.2",
|
{"port", MXS_MODULE_PARAM_COUNT, "5672" },
|
||||||
RCAP_TYPE_CONTIGUOUS_INPUT,
|
{"exchange", MXS_MODULE_PARAM_STRING, "default_exchange"},
|
||||||
&MyObject,
|
{"key", MXS_MODULE_PARAM_STRING, "key" },
|
||||||
NULL, /* Process init. */
|
{"queue", MXS_MODULE_PARAM_STRING},
|
||||||
NULL, /* Process finish. */
|
{"exchange_type", MXS_MODULE_PARAM_STRING, "direct" },
|
||||||
NULL, /* Thread init. */
|
{"logging_source_user", MXS_MODULE_PARAM_STRING},
|
||||||
NULL, /* Thread finish. */
|
{"logging_source_host", MXS_MODULE_PARAM_STRING},
|
||||||
|
{"logging_schema", MXS_MODULE_PARAM_STRING},
|
||||||
|
{"logging_object", MXS_MODULE_PARAM_STRING},
|
||||||
|
{"logging_log_all", MXS_MODULE_PARAM_BOOL, "false" },
|
||||||
|
{"logging_strict", MXS_MODULE_PARAM_BOOL, "true" },
|
||||||
{
|
{
|
||||||
{"hostname", MXS_MODULE_PARAM_STRING,
|
"ssl_client_certificate",
|
||||||
"localhost"},
|
MXS_MODULE_PARAM_PATH,
|
||||||
{"username", MXS_MODULE_PARAM_STRING,
|
NULL,
|
||||||
"guest"},
|
MXS_MODULE_OPT_PATH_R_OK
|
||||||
{"password", MXS_MODULE_PARAM_STRING,
|
},
|
||||||
"guest"},
|
{
|
||||||
{"vhost", MXS_MODULE_PARAM_STRING,
|
"ssl_client_key",
|
||||||
"/"},
|
MXS_MODULE_PARAM_PATH,
|
||||||
{"port", MXS_MODULE_PARAM_COUNT,
|
NULL,
|
||||||
"5672"},
|
MXS_MODULE_OPT_PATH_R_OK
|
||||||
{"exchange", MXS_MODULE_PARAM_STRING,
|
},
|
||||||
"default_exchange"},
|
{
|
||||||
{"key", MXS_MODULE_PARAM_STRING,
|
"ssl_CA_cert",
|
||||||
"key"},
|
MXS_MODULE_PARAM_PATH,
|
||||||
{"queue", MXS_MODULE_PARAM_STRING},
|
NULL,
|
||||||
{"ssl_client_certificate", MXS_MODULE_PARAM_PATH, NULL,
|
MXS_MODULE_OPT_PATH_R_OK},
|
||||||
MXS_MODULE_OPT_PATH_R_OK},
|
|
||||||
{"ssl_client_key", MXS_MODULE_PARAM_PATH, NULL,
|
|
||||||
MXS_MODULE_OPT_PATH_R_OK},
|
|
||||||
{"ssl_CA_cert", MXS_MODULE_PARAM_PATH, NULL,
|
|
||||||
MXS_MODULE_OPT_PATH_R_OK},
|
|
||||||
{"exchange_type", MXS_MODULE_PARAM_STRING,
|
|
||||||
"direct"},
|
|
||||||
{"logging_trigger", MXS_MODULE_PARAM_ENUM, "all",
|
|
||||||
MXS_MODULE_OPT_NONE,
|
|
||||||
trigger_values},
|
|
||||||
{"logging_source_user", MXS_MODULE_PARAM_STRING},
|
|
||||||
{"logging_source_host", MXS_MODULE_PARAM_STRING},
|
|
||||||
{"logging_schema", MXS_MODULE_PARAM_STRING},
|
|
||||||
{"logging_object", MXS_MODULE_PARAM_STRING},
|
|
||||||
{"logging_log_all", MXS_MODULE_PARAM_BOOL,
|
|
||||||
"false"},
|
|
||||||
{"logging_strict", MXS_MODULE_PARAM_BOOL,
|
|
||||||
"true"},
|
|
||||||
{MXS_END_MODULE_PARAMS}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return &info;
|
{
|
||||||
}
|
"logging_trigger",
|
||||||
|
MXS_MODULE_PARAM_ENUM,
|
||||||
|
"all",
|
||||||
|
MXS_MODULE_OPT_NONE,
|
||||||
|
trigger_values
|
||||||
|
},
|
||||||
|
{MXS_END_MODULE_PARAMS}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return &info;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -878,7 +878,7 @@ bool RegexHintFilter::add_source_address(const char* input_host, SourceHostVecto
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RegexHintFilter::set_source_addresses(const std::string& input_host_names,
|
void RegexHintFilter::set_source_addresses(const std::string& input_host_names,
|
||||||
SourceHostVector& source_hosts,
|
SourceHostVector& source_hosts,
|
||||||
StringVector& hostnames)
|
StringVector& hostnames)
|
||||||
{
|
{
|
||||||
std::string host_names(input_host_names);
|
std::string host_names(input_host_names);
|
||||||
|
|||||||
@ -204,7 +204,7 @@ QlaInstance* QlaInstance::create(const std::string name, MXS_CONFIG_PARAMETER* p
|
|||||||
|
|
||||||
QlaFilterSession* QlaInstance::newSession(MXS_SESSION* session)
|
QlaFilterSession* QlaInstance::newSession(MXS_SESSION* session)
|
||||||
{
|
{
|
||||||
auto my_session = new (std::nothrow) QlaFilterSession(*this, session);
|
auto my_session = new(std::nothrow) QlaFilterSession(*this, session);
|
||||||
if (my_session)
|
if (my_session)
|
||||||
{
|
{
|
||||||
if (!my_session->prepare())
|
if (!my_session->prepare())
|
||||||
@ -311,7 +311,7 @@ void QlaInstance::diagnostics(DCB* dcb) const
|
|||||||
}
|
}
|
||||||
if (!m_settings.exclude.empty())
|
if (!m_settings.exclude.empty())
|
||||||
{
|
{
|
||||||
output += string_printf("\t\tExclude queries that match %s\n", m_settings.exclude.c_str());
|
output += string_printf("\t\tExclude queries that match %s\n", m_settings.exclude.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
output += string_printf("\t\tColumn separator %s\n", m_settings.separator.c_str());
|
output += string_printf("\t\tColumn separator %s\n", m_settings.separator.c_str());
|
||||||
@ -878,7 +878,6 @@ void diagnostic(MXS_FILTER* instance, MXS_FILTER_SESSION* fsession, DCB* dcb)
|
|||||||
{
|
{
|
||||||
auto my_instance = static_cast<QlaInstance*>(instance);
|
auto my_instance = static_cast<QlaInstance*>(instance);
|
||||||
my_instance->diagnostics(dcb);
|
my_instance->diagnostics(dcb);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -910,7 +909,6 @@ bool cb_log(const MODULECMD_ARG* argv, json_t** output)
|
|||||||
|
|
||||||
return instance->read_to_json(start, end, output);
|
return instance->read_to_json(start, end, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -42,15 +42,15 @@ public:
|
|||||||
~QlaInstance();
|
~QlaInstance();
|
||||||
|
|
||||||
/* Log file save mode flags. */
|
/* Log file save mode flags. */
|
||||||
static const int64_t LOG_FILE_SESSION = (1 << 0); /**< Default value, session specific files */
|
static const int64_t LOG_FILE_SESSION = (1 << 0); /**< Default value, session specific files */
|
||||||
static const int64_t LOG_FILE_UNIFIED = (1 << 1); /**< One file shared by all sessions */
|
static const int64_t LOG_FILE_UNIFIED = (1 << 1); /**< One file shared by all sessions */
|
||||||
|
|
||||||
/* Flags for controlling extra log entry contents */
|
/* Flags for controlling extra log entry contents */
|
||||||
static const int64_t LOG_DATA_SERVICE = (1 << 0);
|
static const int64_t LOG_DATA_SERVICE = (1 << 0);
|
||||||
static const int64_t LOG_DATA_SESSION = (1 << 1);
|
static const int64_t LOG_DATA_SESSION = (1 << 1);
|
||||||
static const int64_t LOG_DATA_DATE = (1 << 2);
|
static const int64_t LOG_DATA_DATE = (1 << 2);
|
||||||
static const int64_t LOG_DATA_USER = (1 << 3);
|
static const int64_t LOG_DATA_USER = (1 << 3);
|
||||||
static const int64_t LOG_DATA_QUERY = (1 << 4);
|
static const int64_t LOG_DATA_QUERY = (1 << 4);
|
||||||
static const int64_t LOG_DATA_REPLY_TIME = (1 << 5);
|
static const int64_t LOG_DATA_REPLY_TIME = (1 << 5);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,15 +80,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool read_to_json(int start, int end, json_t** output) const;
|
bool read_to_json(int start, int end, json_t** output) const;
|
||||||
|
|
||||||
void diagnostics(DCB* dcb) const;
|
void diagnostics(DCB* dcb) const;
|
||||||
json_t* diagnostics_json() const;
|
json_t* diagnostics_json() const;
|
||||||
|
|
||||||
std::string generate_log_header(uint64_t data_flags) const;
|
std::string generate_log_header(uint64_t data_flags) const;
|
||||||
|
|
||||||
FILE* open_session_log_file(const std::string& filename) const;
|
FILE* open_session_log_file(const std::string& filename) const;
|
||||||
void check_reopen_session_file(const std::string& filename, FILE** ppFile) const;
|
void check_reopen_session_file(const std::string& filename, FILE** ppFile) const;
|
||||||
void write_unified_log_entry(const std::string& contents);
|
void write_unified_log_entry(const std::string& contents);
|
||||||
bool write_to_logfile(FILE* fp, const std::string& contents) const;
|
bool write_to_logfile(FILE* fp, const std::string& contents) const;
|
||||||
|
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
@ -97,39 +97,38 @@ public:
|
|||||||
|
|
||||||
bool write_unified_log {false};
|
bool write_unified_log {false};
|
||||||
bool write_session_log {false};
|
bool write_session_log {false};
|
||||||
uint32_t log_file_data_flags {0}; /* What data is saved to the files */
|
uint32_t log_file_data_flags {0}; /* What data is saved to the files */
|
||||||
std::string filebase; /* The filename base */
|
std::string filebase; /* The filename base */
|
||||||
bool flush_writes {false}; /* Flush log file after every write? */
|
bool flush_writes {false}; /* Flush log file after every write? */
|
||||||
bool append {false}; /* Open files in append-mode? */
|
bool append {false}; /* Open files in append-mode? */
|
||||||
std::string query_newline; /* Character(s) used to replace a newline within a query */
|
std::string query_newline; /* Character(s) used to replace a newline within a query */
|
||||||
std::string separator; /* Character(s) used to separate elements */
|
std::string separator; /* Character(s) used to separate elements */
|
||||||
std::string user_name; /* The user name to filter on */
|
std::string user_name; /* The user name to filter on */
|
||||||
std::string source; /* The source of the client connection to filter on */
|
std::string source; /* The source of the client connection to filter on */
|
||||||
std::string match; /* Optional text to match against */
|
std::string match; /* Optional text to match against */
|
||||||
std::string exclude; /* Optional text to match against for exclusion */
|
std::string exclude; /* Optional text to match against for exclusion */
|
||||||
};
|
};
|
||||||
|
|
||||||
Settings m_settings;
|
Settings m_settings;
|
||||||
|
|
||||||
const std::string m_name; /* Filter definition name */
|
const std::string m_name; /* Filter definition name */
|
||||||
|
|
||||||
pcre2_code* m_re_match {nullptr}; /* Compiled regex text */
|
pcre2_code* m_re_match {nullptr}; /* Compiled regex text */
|
||||||
pcre2_code* m_re_exclude {nullptr}; /* Compiled regex nomatch text */
|
pcre2_code* m_re_exclude {nullptr}; /* Compiled regex nomatch text */
|
||||||
uint32_t m_ovec_size {0}; /* PCRE2 match data ovector size */
|
uint32_t m_ovec_size {0}; /* PCRE2 match data ovector size */
|
||||||
|
|
||||||
uint64_t m_session_data_flags {0}; /* What data is printed to session files */
|
uint64_t m_session_data_flags {0}; /* What data is printed to session files */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool open_unified_logfile();
|
bool open_unified_logfile();
|
||||||
FILE* open_log_file(uint64_t data_flags, const std::string& filename) const;
|
FILE* open_log_file(uint64_t data_flags, const std::string& filename) const;
|
||||||
void check_reopen_file(const std::string& filename, uint64_t data_flags, FILE** ppFile) const;
|
void check_reopen_file(const std::string& filename, uint64_t data_flags, FILE** ppFile) const;
|
||||||
|
|
||||||
std::mutex m_file_lock; /* Protects access to the unified log file */
|
|
||||||
std::string m_unified_filename; /* Filename of the unified log file */
|
|
||||||
FILE* m_unified_fp {nullptr}; /* Unified log file. */
|
|
||||||
int m_rotation_count {0}; /* Log rotation counter */
|
|
||||||
bool m_write_error_logged {false}; /* Avoid repeatedly printing some errors/warnings. */
|
|
||||||
|
|
||||||
|
std::mutex m_file_lock; /* Protects access to the unified log file */
|
||||||
|
std::string m_unified_filename; /* Filename of the unified log file */
|
||||||
|
FILE* m_unified_fp {nullptr}; /* Unified log file. */
|
||||||
|
int m_rotation_count {0}; /* Log rotation counter */
|
||||||
|
bool m_write_error_logged {false}; /* Avoid repeatedly printing some errors/warnings. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The session structure for this QLA filter. */
|
/* The session structure for this QLA filter. */
|
||||||
@ -172,26 +171,26 @@ public:
|
|||||||
MXS_UPSTREAM up;
|
MXS_UPSTREAM up;
|
||||||
MXS_DOWNSTREAM down;
|
MXS_DOWNSTREAM down;
|
||||||
|
|
||||||
std::string m_filename; /* The session-specific log file name */
|
std::string m_filename; /* The session-specific log file name */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QlaInstance& m_instance;
|
QlaInstance& m_instance;
|
||||||
|
|
||||||
const std::string m_user; /* Client username */
|
const std::string m_user; /* Client username */
|
||||||
const std::string m_remote; /* Client address */
|
const std::string m_remote; /* Client address */
|
||||||
const std::string m_service; /* The service name this filter is attached to. */
|
const std::string m_service; /* The service name this filter is attached to. */
|
||||||
const uint64_t m_ses_id {0}; /* The session this filter session serves. */
|
const uint64_t m_ses_id {0}; /* The session this filter session serves. */
|
||||||
|
|
||||||
bool m_active {false}; /* Is session active? */
|
bool m_active {false}; /* Is session active? */
|
||||||
pcre2_match_data* m_mdata {nullptr}; /* Regex match data */
|
pcre2_match_data* m_mdata {nullptr}; /* Regex match data */
|
||||||
|
|
||||||
FILE* m_logfile {nullptr}; /* The session-specific log file */
|
FILE* m_logfile {nullptr}; /* The session-specific log file */
|
||||||
int m_rotation_count {0}; /* Log rotation counter */
|
int m_rotation_count {0}; /* Log rotation counter */
|
||||||
bool m_write_error_logged {false}; /* Has write error been logged */
|
bool m_write_error_logged {false}; /* Has write error been logged */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper struct for holding data before it's written to file.
|
* Helper struct for holding data before it's written to file.
|
||||||
*/
|
*/
|
||||||
class LogEventData
|
class LogEventData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -224,10 +223,10 @@ private:
|
|||||||
timespec begin_time {0, 0}; // Timer value at the moment of receiving query.
|
timespec begin_time {0, 0}; // Timer value at the moment of receiving query.
|
||||||
};
|
};
|
||||||
|
|
||||||
LogEventData m_event_data; /* Information about the latest event, used if logging execution time. */
|
LogEventData m_event_data; /* Information about the latest event, used if logging execution time. */
|
||||||
|
|
||||||
void write_log_entries(const LogEventElems& elems);
|
void write_log_entries(const LogEventElems& elems);
|
||||||
void write_session_log_entry(const std::string& entry);
|
void write_session_log_entry(const std::string& entry);
|
||||||
std::string generate_log_entry(uint64_t data_flags, const LogEventElems& elems) const;
|
std::string generate_log_entry(uint64_t data_flags, const LogEventElems& elems) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -237,15 +236,16 @@ private:
|
|||||||
*/
|
*/
|
||||||
struct LogEventElems
|
struct LogEventElems
|
||||||
{
|
{
|
||||||
const char* date_string {nullptr}; /**< Formatted date */
|
const char* date_string {nullptr}; /**< Formatted date */
|
||||||
const char* query {nullptr}; /**< Query. Not necessarily 0-terminated */
|
const char* query {nullptr}; /**< Query. Not necessarily 0-terminated */
|
||||||
int querylen {0}; /**< Length of query */
|
int querylen {0}; /**< Length of query */
|
||||||
int elapsed_ms {0}; /**< Processing time on backend */
|
int elapsed_ms {0}; /**< Processing time on backend */
|
||||||
|
|
||||||
LogEventElems(const char* date_string, const char* query, int querylen, int elapsed_ms = -1)
|
LogEventElems(const char* date_string, const char* query, int querylen, int elapsed_ms = -1)
|
||||||
: date_string(date_string)
|
: date_string(date_string)
|
||||||
, query(query)
|
, query(query)
|
||||||
, querylen(querylen)
|
, querylen(querylen)
|
||||||
, elapsed_ms(elapsed_ms)
|
, elapsed_ms(elapsed_ms)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -58,13 +58,13 @@ static char* regex_replace(const char* sql,
|
|||||||
*/
|
*/
|
||||||
struct RegexInstance
|
struct RegexInstance
|
||||||
{
|
{
|
||||||
char* source; /*< Source address to restrict matches */
|
char* source; /*< Source address to restrict matches */
|
||||||
char* user; /*< User name to restrict matches */
|
char* user; /*< User name to restrict matches */
|
||||||
char* match; /*< Regular expression to match */
|
char* match; /*< Regular expression to match */
|
||||||
char* replace; /*< Replacement text */
|
char* replace; /*< Replacement text */
|
||||||
pcre2_code* re; /*< Compiled regex text */
|
pcre2_code* re; /*< Compiled regex text */
|
||||||
FILE* logfile; /*< Log file */
|
FILE* logfile; /*< Log file */
|
||||||
bool log_trace; /*< Whether messages should be printed to tracelog */
|
bool log_trace; /*< Whether messages should be printed to tracelog */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,10 +72,10 @@ struct RegexInstance
|
|||||||
*/
|
*/
|
||||||
struct RegexSession
|
struct RegexSession
|
||||||
{
|
{
|
||||||
MXS_DOWNSTREAM down; /* The downstream filter */
|
MXS_DOWNSTREAM down; /* The downstream filter */
|
||||||
pthread_mutex_t lock;
|
pthread_mutex_t lock;
|
||||||
int no_change; /* No. of unchanged requests */
|
int no_change; /* No. of unchanged requests */
|
||||||
int replacements; /* No. of changed requests */
|
int replacements; /* No. of changed requests */
|
||||||
pcre2_match_data* match_data; /*< Matching data used by the compiled regex */
|
pcre2_match_data* match_data; /*< Matching data used by the compiled regex */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -100,73 +100,73 @@ extern "C"
|
|||||||
*
|
*
|
||||||
* @return The module object
|
* @return The module object
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
|
{
|
||||||
|
static MXS_FILTER_OBJECT MyObject =
|
||||||
{
|
{
|
||||||
static MXS_FILTER_OBJECT MyObject =
|
createInstance,
|
||||||
{
|
newSession,
|
||||||
createInstance,
|
closeSession,
|
||||||
newSession,
|
freeSession,
|
||||||
closeSession,
|
setDownstream,
|
||||||
freeSession,
|
NULL, // No Upstream requirement
|
||||||
setDownstream,
|
routeQuery,
|
||||||
NULL, // No Upstream requirement
|
NULL, // No clientReply
|
||||||
routeQuery,
|
diagnostic,
|
||||||
NULL, // No clientReply
|
diagnostic_json,
|
||||||
diagnostic,
|
getCapabilities,
|
||||||
diagnostic_json,
|
NULL, // No destroyInstance
|
||||||
getCapabilities,
|
};
|
||||||
NULL, // No destroyInstance
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char description[] = "A query rewrite filter that uses regular "
|
static const char description[] = "A query rewrite filter that uses regular "
|
||||||
"expressions to rewrite queries";
|
"expressions to rewrite queries";
|
||||||
static MXS_MODULE info =
|
static MXS_MODULE info =
|
||||||
|
{
|
||||||
|
MXS_MODULE_API_FILTER,
|
||||||
|
MXS_MODULE_GA,
|
||||||
|
MXS_FILTER_VERSION,
|
||||||
|
description,
|
||||||
|
"V1.1.0",
|
||||||
|
RCAP_TYPE_CONTIGUOUS_INPUT,
|
||||||
|
&MyObject,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
{
|
{
|
||||||
MXS_MODULE_API_FILTER,
|
|
||||||
MXS_MODULE_GA,
|
|
||||||
MXS_FILTER_VERSION,
|
|
||||||
description,
|
|
||||||
"V1.1.0",
|
|
||||||
RCAP_TYPE_CONTIGUOUS_INPUT,
|
|
||||||
&MyObject,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
{
|
{
|
||||||
{
|
"match",
|
||||||
"match",
|
MXS_MODULE_PARAM_STRING,
|
||||||
MXS_MODULE_PARAM_STRING,
|
NULL,
|
||||||
NULL,
|
MXS_MODULE_OPT_REQUIRED
|
||||||
MXS_MODULE_OPT_REQUIRED
|
},
|
||||||
},
|
{
|
||||||
{
|
"replace",
|
||||||
"replace",
|
MXS_MODULE_PARAM_STRING,
|
||||||
MXS_MODULE_PARAM_STRING,
|
NULL,
|
||||||
NULL,
|
MXS_MODULE_OPT_REQUIRED
|
||||||
MXS_MODULE_OPT_REQUIRED
|
},
|
||||||
},
|
{
|
||||||
{
|
"options",
|
||||||
"options",
|
MXS_MODULE_PARAM_ENUM,
|
||||||
MXS_MODULE_PARAM_ENUM,
|
"ignorecase",
|
||||||
"ignorecase",
|
MXS_MODULE_OPT_NONE,
|
||||||
MXS_MODULE_OPT_NONE,
|
option_values
|
||||||
option_values
|
},
|
||||||
},
|
{
|
||||||
{
|
"log_trace",
|
||||||
"log_trace",
|
MXS_MODULE_PARAM_BOOL,
|
||||||
MXS_MODULE_PARAM_BOOL,
|
"false"
|
||||||
"false"
|
},
|
||||||
},
|
{"source", MXS_MODULE_PARAM_STRING },
|
||||||
{"source", MXS_MODULE_PARAM_STRING },
|
{"user", MXS_MODULE_PARAM_STRING },
|
||||||
{"user", MXS_MODULE_PARAM_STRING },
|
{"log_file", MXS_MODULE_PARAM_STRING },
|
||||||
{"log_file", MXS_MODULE_PARAM_STRING },
|
{MXS_END_MODULE_PARAMS}
|
||||||
{MXS_END_MODULE_PARAMS}
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,7 +247,7 @@ bool matching_connection(RegexInstance* my_instance, MXS_SESSION* session)
|
|||||||
{
|
{
|
||||||
rval = false;
|
rval = false;
|
||||||
}
|
}
|
||||||
else if (my_instance->user && strcmp(session_get_user(session), my_instance->user) != 0)
|
else if (my_instance->user && strcmp(session_get_user(session), my_instance->user) != 0)
|
||||||
{
|
{
|
||||||
rval = false;
|
rval = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
TeeSession::TeeSession(MXS_SESSION* session,
|
TeeSession::TeeSession(MXS_SESSION* session,
|
||||||
LocalClient* client,
|
LocalClient* client,
|
||||||
pcre2_code* match,
|
pcre2_code* match,
|
||||||
pcre2_match_data* md_match,
|
pcre2_match_data* md_match,
|
||||||
pcre2_code* exclude,
|
pcre2_code* exclude,
|
||||||
pcre2_match_data* md_exclude)
|
pcre2_match_data* md_exclude)
|
||||||
|
|||||||
@ -39,7 +39,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
TeeSession(MXS_SESSION* session,
|
TeeSession(MXS_SESSION* session,
|
||||||
LocalClient* client,
|
LocalClient* client,
|
||||||
pcre2_code* match,
|
pcre2_code* match,
|
||||||
pcre2_match_data* md_match,
|
pcre2_match_data* md_match,
|
||||||
pcre2_code* exclude,
|
pcre2_code* exclude,
|
||||||
pcre2_match_data* md_exclude);
|
pcre2_match_data* md_exclude);
|
||||||
|
|||||||
@ -46,8 +46,8 @@ public:
|
|||||||
* @param pHandler Optional handler.
|
* @param pHandler Optional handler.
|
||||||
*/
|
*/
|
||||||
Dcb(MXS_SESSION* pSession,
|
Dcb(MXS_SESSION* pSession,
|
||||||
const char* zUser,
|
const char* zUser,
|
||||||
const char* zHost,
|
const char* zHost,
|
||||||
Handler* pHandler = NULL);
|
Handler* pHandler = NULL);
|
||||||
~Dcb();
|
~Dcb();
|
||||||
|
|
||||||
|
|||||||
@ -107,7 +107,7 @@ private:
|
|||||||
Backend* m_pBackend;
|
Backend* m_pBackend;
|
||||||
FilterModule::Session* m_pUpstream_filter_session;
|
FilterModule::Session* m_pUpstream_filter_session;
|
||||||
|
|
||||||
maxscale::mock::Session* m_pSession;
|
maxscale::mock::Session* m_pSession;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,8 +31,8 @@ namespace mock
|
|||||||
{
|
{
|
||||||
|
|
||||||
Dcb::Dcb(MXS_SESSION* pSession,
|
Dcb::Dcb(MXS_SESSION* pSession,
|
||||||
const char* zUser,
|
const char* zUser,
|
||||||
const char* zHost,
|
const char* zHost,
|
||||||
Handler* pHandler)
|
Handler* pHandler)
|
||||||
: DCB(DCB::Role::CLIENT, pSession)
|
: DCB(DCB::Role::CLIENT, pSession)
|
||||||
, m_user(zUser)
|
, m_user(zUser)
|
||||||
|
|||||||
@ -43,7 +43,7 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
NULL, /* Thread init. */
|
NULL, /* Thread init. */
|
||||||
NULL, /* Thread finish. */
|
NULL, /* Thread finish. */
|
||||||
{
|
{
|
||||||
{MAX_QPS_CFG, MXS_MODULE_PARAM_INT },
|
{MAX_QPS_CFG, MXS_MODULE_PARAM_INT },
|
||||||
{SAMPLING_DURATION_CFG, MXS_MODULE_PARAM_DURATION, "250ms"},
|
{SAMPLING_DURATION_CFG, MXS_MODULE_PARAM_DURATION, "250ms"},
|
||||||
{THROTTLE_DURATION_CFG, MXS_MODULE_PARAM_DURATION },
|
{THROTTLE_DURATION_CFG, MXS_MODULE_PARAM_DURATION },
|
||||||
{CONTINUOUS_DURATION_CFG, MXS_MODULE_PARAM_DURATION, "2000ms"},
|
{CONTINUOUS_DURATION_CFG, MXS_MODULE_PARAM_DURATION, "2000ms"},
|
||||||
@ -57,7 +57,8 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
namespace throttle
|
namespace throttle
|
||||||
{
|
{
|
||||||
|
|
||||||
ThrottleFilter::ThrottleFilter(const ThrottleConfig& config) : m_config(config)
|
ThrottleFilter::ThrottleFilter(const ThrottleConfig& config)
|
||||||
|
: m_config(config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -141,58 +141,58 @@ extern "C"
|
|||||||
*
|
*
|
||||||
* @return The module object
|
* @return The module object
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
|
{
|
||||||
|
static MXS_FILTER_OBJECT MyObject =
|
||||||
{
|
{
|
||||||
static MXS_FILTER_OBJECT MyObject =
|
createInstance,
|
||||||
{
|
newSession,
|
||||||
createInstance,
|
closeSession,
|
||||||
newSession,
|
freeSession,
|
||||||
closeSession,
|
setDownstream,
|
||||||
freeSession,
|
setUpstream,
|
||||||
setDownstream,
|
routeQuery,
|
||||||
setUpstream,
|
clientReply,
|
||||||
routeQuery,
|
diagnostic,
|
||||||
clientReply,
|
diagnostic_json,
|
||||||
diagnostic,
|
getCapabilities,
|
||||||
diagnostic_json,
|
NULL, // No destroyInstance
|
||||||
getCapabilities,
|
};
|
||||||
NULL, // No destroyInstance
|
|
||||||
};
|
|
||||||
|
|
||||||
static MXS_MODULE info =
|
static MXS_MODULE info =
|
||||||
|
{
|
||||||
|
MXS_MODULE_API_FILTER,
|
||||||
|
MXS_MODULE_GA,
|
||||||
|
MXS_FILTER_VERSION,
|
||||||
|
"A top N query "
|
||||||
|
"logging filter",
|
||||||
|
"V1.0.1",
|
||||||
|
RCAP_TYPE_CONTIGUOUS_INPUT,
|
||||||
|
&MyObject,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
{
|
{
|
||||||
MXS_MODULE_API_FILTER,
|
{"count", MXS_MODULE_PARAM_COUNT, "10" },
|
||||||
MXS_MODULE_GA,
|
{"filebase", MXS_MODULE_PARAM_STRING, NULL, MXS_MODULE_OPT_REQUIRED},
|
||||||
MXS_FILTER_VERSION,
|
{"match", MXS_MODULE_PARAM_STRING},
|
||||||
"A top N query "
|
{"exclude", MXS_MODULE_PARAM_STRING},
|
||||||
"logging filter",
|
{"source", MXS_MODULE_PARAM_STRING},
|
||||||
"V1.0.1",
|
{"user", MXS_MODULE_PARAM_STRING},
|
||||||
RCAP_TYPE_CONTIGUOUS_INPUT,
|
|
||||||
&MyObject,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
{
|
{
|
||||||
{"count", MXS_MODULE_PARAM_COUNT, "10" },
|
"options",
|
||||||
{"filebase", MXS_MODULE_PARAM_STRING, NULL, MXS_MODULE_OPT_REQUIRED},
|
MXS_MODULE_PARAM_ENUM,
|
||||||
{"match", MXS_MODULE_PARAM_STRING},
|
"ignorecase",
|
||||||
{"exclude", MXS_MODULE_PARAM_STRING},
|
MXS_MODULE_OPT_NONE,
|
||||||
{"source", MXS_MODULE_PARAM_STRING},
|
option_values
|
||||||
{"user", MXS_MODULE_PARAM_STRING},
|
},
|
||||||
{
|
{MXS_END_MODULE_PARAMS}
|
||||||
"options",
|
}
|
||||||
MXS_MODULE_PARAM_ENUM,
|
};
|
||||||
"ignorecase",
|
|
||||||
MXS_MODULE_OPT_NONE,
|
|
||||||
option_values
|
|
||||||
},
|
|
||||||
{MXS_END_MODULE_PARAMS}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -160,51 +160,51 @@ extern "C"
|
|||||||
*
|
*
|
||||||
* @return The module object
|
* @return The module object
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
|
{
|
||||||
|
static const char description[] = "Transaction Performance Monitoring filter";
|
||||||
|
static MXS_FILTER_OBJECT MyObject =
|
||||||
{
|
{
|
||||||
static const char description[] = "Transaction Performance Monitoring filter";
|
createInstance,
|
||||||
static MXS_FILTER_OBJECT MyObject =
|
newSession,
|
||||||
{
|
closeSession,
|
||||||
createInstance,
|
freeSession,
|
||||||
newSession,
|
setDownstream,
|
||||||
closeSession,
|
setUpstream,
|
||||||
freeSession,
|
routeQuery,
|
||||||
setDownstream,
|
clientReply,
|
||||||
setUpstream,
|
diagnostic,
|
||||||
routeQuery,
|
diagnostic_json,
|
||||||
clientReply,
|
getCapabilities,
|
||||||
diagnostic,
|
destroyInstance
|
||||||
diagnostic_json,
|
};
|
||||||
getCapabilities,
|
|
||||||
destroyInstance
|
|
||||||
};
|
|
||||||
|
|
||||||
static MXS_MODULE info =
|
static MXS_MODULE info =
|
||||||
|
{
|
||||||
|
MXS_MODULE_API_FILTER,
|
||||||
|
MXS_MODULE_GA,
|
||||||
|
MXS_FILTER_VERSION,
|
||||||
|
description,
|
||||||
|
"V1.0.1",
|
||||||
|
RCAP_TYPE_CONTIGUOUS_INPUT,
|
||||||
|
&MyObject,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
{
|
{
|
||||||
MXS_MODULE_API_FILTER,
|
{"named_pipe", MXS_MODULE_PARAM_STRING, DEFAULT_NAMED_PIPE },
|
||||||
MXS_MODULE_GA,
|
{"filename", MXS_MODULE_PARAM_STRING, DEFAULT_FILE_NAME },
|
||||||
MXS_FILTER_VERSION,
|
{"delimiter", MXS_MODULE_PARAM_STRING, DEFAULT_LOG_DELIMITER },
|
||||||
description,
|
{"query_delimiter", MXS_MODULE_PARAM_STRING, DEFAULT_QUERY_DELIMITER},
|
||||||
"V1.0.1",
|
{"source", MXS_MODULE_PARAM_STRING},
|
||||||
RCAP_TYPE_CONTIGUOUS_INPUT,
|
{"user", MXS_MODULE_PARAM_STRING},
|
||||||
&MyObject,
|
{MXS_END_MODULE_PARAMS}
|
||||||
NULL,
|
}
|
||||||
NULL,
|
};
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
{
|
|
||||||
{"named_pipe", MXS_MODULE_PARAM_STRING, DEFAULT_NAMED_PIPE },
|
|
||||||
{"filename", MXS_MODULE_PARAM_STRING, DEFAULT_FILE_NAME },
|
|
||||||
{"delimiter", MXS_MODULE_PARAM_STRING, DEFAULT_LOG_DELIMITER },
|
|
||||||
{"query_delimiter", MXS_MODULE_PARAM_STRING, DEFAULT_QUERY_DELIMITER},
|
|
||||||
{"source", MXS_MODULE_PARAM_STRING},
|
|
||||||
{"user", MXS_MODULE_PARAM_STRING},
|
|
||||||
{MXS_END_MODULE_PARAMS}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user