Fixing bad mering and test for search manager

This commit is contained in:
Gasper Jansa
2011-01-10 23:06:46 +01:00
parent a5f44c97c2
commit b3fb43800f
3 changed files with 341 additions and 12 deletions

View File

@@ -60,7 +60,7 @@ bool BaseSearchInstance::generateSearchRequestMessage(ByteBuffer* requestMessage
return false;
}
const string name = getChannelName();
const String name = getSearchInstanceName();
// not nice...
const int addedPayloadSize = sizeof(int32)/sizeof(int8) + (1 + sizeof(int32)/sizeof(int8) + name.length());
@@ -69,7 +69,7 @@ bool BaseSearchInstance::generateSearchRequestMessage(ByteBuffer* requestMessage
return false;
}
requestMessage->putInt(getChannelID());
requestMessage->putInt(getSearchInstanceID());
SerializeHelper::serializeString(name, requestMessage, control);
requestMessage->putInt(PAYLOAD_POSITION, requestMessage->getPosition() - CA_MESSAGE_HEADER_SIZE);
@@ -421,7 +421,7 @@ const int64 ChannelSearchManager::MAX_SEARCH_PERIOD_LOWER_LIMIT = 60000;
const int64 ChannelSearchManager::BEACON_ANOMALY_SEARCH_PERIOD = 5000;
const int32 ChannelSearchManager::MAX_TIMERS = 18;
ChannelSearchManager::ChannelSearchManager(ClientContextImpl* context):
ChannelSearchManager::ChannelSearchManager(Context* context):
_context(context),
_canceled(false),
_rttmean(MIN_RTT),
@@ -503,17 +503,17 @@ void ChannelSearchManager::registerChannel(SearchInstance* channel)
Lock guard(&_channelMutex);
//overrides if already registered
_channels[channel->getChannelID()] = channel;
_channels[channel->getSearchInstanceID()] = channel;
_timers[0]->installChannel(channel);
}
void ChannelSearchManager::unregisterChannel(SearchInstance* channel)
{
Lock guard(&_channelMutex);
_channelsIter = _channels.find(channel->getChannelID());
_channelsIter = _channels.find(channel->getSearchInstanceID());
if(_channelsIter != _channels.end())
{
_channels.erase(channel->getChannelID());
_channels.erase(channel->getSearchInstanceID());
}
channel->removeAndUnsetListOwnership();
@@ -590,7 +590,7 @@ void ChannelSearchManager::flushSendBuffer()
TimeStamp now;
now.getCurrent();
_timeAtLastSend = now.getMilliseconds();
_context->getSearchTransport()->send(_sendBuffer);
((BlockingUDPTransport*)_context->getSearchTransport())->send(_sendBuffer);
initializeSendBuffer();
}

View File

@@ -24,7 +24,7 @@ using namespace epics::pvData;
namespace epics { namespace pvAccess {
//TODO check the const of paramerers
//TODO check the const of parameters
/**
* SearchInstance.

View File

@@ -6,12 +6,341 @@
using namespace epics::pvData;
using namespace epics::pvAccess;
//TODO this will be deleted
class ChannelImpl;
class ContextImpl : public Context
{
private:
Timer* _timer;
public:
ContextImpl()
{
_timer = new Timer("krneki",lowPriority);
}
virtual Version* getVersion() {
return NULL;
}
virtual ChannelProvider* getProvider() {
return NULL;
}
Timer* getTimer()
{
return _timer;
}
virtual void initialize() {
}
virtual void printInfo() {
}
virtual void printInfo(epics::pvData::StringBuilder out) {
}
virtual void destroy()
{
}
virtual void dispose()
{
}
BlockingUDPTransport* getSearchTransport()
{
return NULL;
}
/**
* Searches for a channel with given channel ID.
* @param channelID CID.
* @return channel with given CID, <code></code> if non-existent.
*/
Channel* getChannel(pvAccessID channelID)
{
return NULL;
}
Configuration* getConfiguration() {return NULL;}
TransportRegistry* getTransportRegistry() {return NULL;}
~ContextImpl() { delete _timer;};
private:
void loadConfiguration() {
}
void internalInitialize() {
}
void initializeUDPTransport() {
}
void internalDestroy() {
}
void destroyAllChannels() {
}
/**
* Check channel name.
*/
void checkChannelName(String& name) {
}
/**
* Check context state and tries to establish necessary state.
*/
void checkState() {
}
/**
* Generate Client channel ID (CID).
* @return Client channel ID (CID).
*/
pvAccessID generateCID()
{
return 0;
}
/**
* Free generated channel ID (CID).
*/
void freeCID(int cid)
{
}
/**
* Get, or create if necessary, transport of given server address.
* @param serverAddress required transport address
* @param priority process priority.
* @return transport for given address
*/
Transport* getTransport(TransportClient* client, osiSockAddr* serverAddress, int minorRevision, int priority)
{
return NULL;
}
/**
* Internal create channel.
*/
// TODO no minor version with the addresses
// TODO what if there is an channel with the same name, but on different host!
Channel* createChannelInternal(String name, ChannelRequester* requester, short priority,
InetAddrVector* addresses) {
return NULL;
}
/**
* Destroy channel.
* @param channel
* @param force
* @throws CAException
* @throws IllegalStateException
*/
void destroyChannel(ChannelImpl* channel, bool force) {
}
/**
* Get channel search manager.
* @return channel search manager.
*/
ChannelSearchManager* getChannelSearchManager() {
return NULL;
}
};
class TestSearcInstance : public BaseSearchInstance
{
public:
TestSearcInstance(string channelName, pvAccessID channelID): _channelID(channelID), _channelName(channelName) {}
pvAccessID getChannelID() { return _channelID;};
string getChannelName() {return _channelName;};
pvAccessID getSearchInstanceID() { return _channelID;};
string getSearchInstanceName() {return _channelName;};
void searchResponse(int8 minorRevision, osiSockAddr* serverAddress) {};
private:
pvAccessID _channelID;
@@ -19,8 +348,8 @@ private:
};
static const int max_channels = 100;
ClientContextImpl* context = new ClientContextImpl();
ChannelSearchManager* manager = new ChannelSearchManager(context);
ContextImpl* context = new ContextImpl();
ChannelSearchManager* manager = new ChannelSearchManager(static_cast<Context*>(context));
TestSearcInstance** chanArray = new TestSearcInstance*[max_channels];
void* testWorker1(void* p)