Skip to content

Commit

Permalink
Changes from review
Browse files Browse the repository at this point in the history
Signed-off-by: jamienoss <james.noss@lexisnexis.com>
  • Loading branch information
jamienoss committed Nov 26, 2014
1 parent 21e84ca commit fece0a7
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions plugins/memcached/memcachedplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public :
eclDataType getKeyType(const char * key, const char * partitionKey);

bool isSameConnection(const char * _servers) const;
void refresh(ICodeContext * ctx) { connect(ctx); };

private :
void checkServersUp(ICodeContext * ctx);
Expand All @@ -123,12 +122,13 @@ private :
memcached_pool_st * pool;
StringAttr servers;
bool alreadyInitialized;
static unsigned typeMismatchCount;
};

#define OwnedMCached Owned<MemCachedPlugin::MCached>

#define MAX_TYPEMISMATCHCOUNT 10
static unsigned typeMismatchCount = 0;
unsigned MemCachedPlugin::MCached::typeMismatchCount = 0;

static CriticalSection crit;
static OwnedMCached cachedConnection;
Expand All @@ -143,10 +143,7 @@ MCached * createConnection(ICodeContext * ctx, const char * servers)
}

if (cachedConnection->isSameConnection(servers))
{
cachedConnection->refresh(ctx);
return LINK(cachedConnection);
}

cachedConnection.set(new MemCachedPlugin::MCached(ctx, servers));
return LINK(cachedConnection);
Expand Down Expand Up @@ -442,9 +439,7 @@ void MemCachedPlugin::MCached::reportKeyTypeMismatch(ICodeContext * ctx, const c
msg.append(key).append("' is of type ").append(enumToStr((eclDataType)(flag))).append(", not ").append(enumToStr(eclType)).append(" as requested.\n");

if (++typeMismatchCount <= MAX_TYPEMISMATCHCOUNT)
ctx->addWuException(msg.str(), WRN_FROM_PLUGIN, ExceptionSeverityInformation, "");
else
ctx->addWuException(msg.str(), ERR_FROM_PLUGIN, ExceptionSeverityError, "");
ctx->logString(msg.str());//NOTE: logging locally, rather than calling ctx->addWuException, to prevent flooding the WU if this is called multiple times by every node
}
}

Expand Down Expand Up @@ -504,7 +499,7 @@ void MemCachedPlugin::MCached::invokeConnectionSecurity(ICodeContext * ctx)
{
//NOTE: Whether to assert or just report? This depends on when this is called. If before checkServersUp() and
//a server is down, it will cause the following to fail if asserted with only a 'poor' libmemcached error message.
//Reporting means that these 'sercurity' measures may not be carried out. Moving checkServersUp() to here is probably the best
//Reporting means that these 'security' measures may not be carried out. Moving checkServersUp() to here is probably the best
//soln. however, this comes with extra overhead.
reportErrorOnFail(ctx, memcached_verbosity(connection, (uint32_t)(0)));
//reportErrorOnFail(ctx, memcached_callback_set(connection, MEMCACHED_CALLBACK_PREFIX_KEY, "ecl"));//NOTE: MEMCACHED_CALLBACK_PREFIX_KEY is an alias of MEMCACHED_CALLBACK_NAMESPACE
Expand Down Expand Up @@ -533,20 +528,20 @@ void MemCachedPlugin::MCached::connect(ICodeContext * ctx)
//--------------------------------------------------------------------------------
ECL_MEMCACHED_API bool ECL_MEMCACHED_CALL MClear(ICodeContext * ctx, const char * servers)
{
OwnedMCached connection = MemCachedPlugin::createConnection(ctx, servers);
bool returnValue = connection->clear(ctx, 0);
OwnedMCached serverPool = MemCachedPlugin::createConnection(ctx, servers);
bool returnValue = serverPool->clear(ctx, 0);
return returnValue;
}
ECL_MEMCACHED_API bool ECL_MEMCACHED_CALL MExist(ICodeContext * ctx, const char * servers, const char * key, const char * partitionKey)
{
OwnedMCached connection = MemCachedPlugin::createConnection(ctx, servers);
bool returnValue = connection->exist(ctx, key, partitionKey);
OwnedMCached serverPool = MemCachedPlugin::createConnection(ctx, servers);
bool returnValue = serverPool->exist(ctx, key, partitionKey);
return returnValue;
}
ECL_MEMCACHED_API const char * ECL_MEMCACHED_CALL MKeyType(ICodeContext * ctx, const char * servers, const char * key, const char * partitionKey)
{
OwnedMCached connection = MemCachedPlugin::createConnection(ctx, servers);
const char * keyType = enumToStr(connection->getKeyType(key, partitionKey));
OwnedMCached serverPool = MemCachedPlugin::createConnection(ctx, servers);
const char * keyType = enumToStr(serverPool->getKeyType(key, partitionKey));
return keyType;
}
//-----------------------------------SET------------------------------------------
Expand Down

0 comments on commit fece0a7

Please sign in to comment.