1
1
// **********************************************************************
3
// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
3
// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
5
5
// This copy of Ice is licensed to you under the terms described in the
6
6
// ICE_LICENSE file included in this distribution.
35
35
ice_exception(const Ice::Exception& ex)
37
Ice::Warning out(_observer->ice_communicator()->getLogger());
37
Ice::Warning out(_observer->ice_getCommunicator()->getLogger());
38
38
out << "couldn't initialize registry observer:\n" << ex;
66
66
ice_exception(const Ice::Exception& ex)
68
Ice::Warning out(_observer->ice_communicator()->getLogger());
68
Ice::Warning out(_observer->ice_getCommunicator()->getLogger());
69
69
out << "couldn't initialize node observer:\n" << ex;
80
NodeObserverTopic::NodeObserverTopic(const IceStorm::TopicPrx& topic, const NodeObserverPrx& publisher) :
81
_topic(topic), _publisher(publisher), _serial(0)
80
NodeObserverTopic::NodeObserverTopic(const IceStorm::TopicManagerPrx& topicManager) : _serial(0)
85
t = topicManager->create("NodeObserver");
87
catch(const IceStorm::TopicExists&)
89
t = topicManager->retrieve("NodeObserver");
93
// NOTE: collocation optimization needs to be turned on for the
94
// topic because the subscribe() method is given a fixed proxy
95
// which can't be marshalled.
97
const_cast<IceStorm::TopicPrx&>(_topic) = IceStorm::TopicPrx::uncheckedCast(t->ice_collocationOptimized(true));
98
const_cast<NodeObserverPrx&>(_publisher) = NodeObserverPrx::uncheckedCast(_topic->getPublisher());
229
244
_topic->unsubscribe(observer);
232
RegistryObserverTopic::RegistryObserverTopic(const IceStorm::TopicPrx& topic,
233
const RegistryObserverPrx& publisher,
234
NodeObserverTopic& nodeObserver) :
235
_topic(topic), _publisher(publisher), _nodeObserver(nodeObserver), _serial(0)
247
RegistryObserverTopic::RegistryObserverTopic(const IceStorm::TopicManagerPrx& topicManager) : _serial(0)
249
IceStorm::TopicPrx t;
252
t = topicManager->create("RegistryObserver");
254
catch(const IceStorm::TopicExists&)
256
t = topicManager->retrieve("RegistryObserver");
260
// NOTE: collocation optimization needs to be turned on for the
261
// topic because the subscribe() method is given a fixed proxy
262
// which can't be marshalled.
264
const_cast<IceStorm::TopicPrx&>(_topic) = IceStorm::TopicPrx::uncheckedCast(t->ice_collocationOptimized(true));
265
const_cast<RegistryObserverPrx&>(_publisher) = RegistryObserverPrx::uncheckedCast(_topic->getPublisher());
240
RegistryObserverTopic::init(int serial, const ApplicationDescriptorSeq& apps, const Ice::Current&)
269
RegistryObserverTopic::init(int serial,
270
const ApplicationDescriptorSeq& apps,
271
const AdapterInfoSeq& adpts,
272
const ObjectInfoSeq& objects,
242
275
Lock sync(*this);
244
277
_serial = serial;
245
_applications = apps;
247
_publisher->init(serial, apps);
279
for(ApplicationDescriptorSeq::const_iterator p = apps.begin(); p != apps.end(); ++p)
281
_applications.insert(make_pair(p->name, *p));
283
for(AdapterInfoSeq::const_iterator q = adpts.begin(); q != adpts.end(); ++q)
285
_adapters.insert(make_pair(q->id, *q));
287
for(ObjectInfoSeq::const_iterator r = objects.begin(); r != objects.end(); ++r)
289
_objects.insert(make_pair(r->proxy->ice_getIdentity(), *r));
292
_publisher->init(serial, apps, adpts, objects);
285
324
updateSerial(serial);
288
for(ApplicationDescriptorSeq::iterator p = _applications.begin(); p != _applications.end(); ++p)
327
map<string, ApplicationDescriptor>::iterator p = _applications.find(desc.name);
328
if(p != _applications.end())
290
if(p->name == desc.name)
292
ApplicationHelper helper(*p);
294
*p = helper.getDescriptor();
330
ApplicationHelper helper(c.adapter->getCommunicator(), p->second);
331
p->second = helper.update(desc);
299
334
catch(const DeploymentException& ex)
358
RegistryObserverTopic::adapterAdded(int serial, const AdapterInfo& info, const Ice::Current&)
362
updateSerial(serial);
364
_adapters.insert(make_pair(info.id, info));
366
_publisher->adapterAdded(serial, info);
370
RegistryObserverTopic::adapterUpdated(int serial, const AdapterInfo& info, const Ice::Current&)
374
updateSerial(serial);
376
_adapters[info.id] = info;
378
_publisher->adapterUpdated(serial, info);
382
RegistryObserverTopic::adapterRemoved(int serial, const string& id, const Ice::Current&)
386
updateSerial(serial);
390
_publisher->adapterRemoved(serial, id);
394
RegistryObserverTopic::objectAdded(int serial, const ObjectInfo& info, const Ice::Current&)
398
updateSerial(serial);
400
_objects.insert(make_pair(info.proxy->ice_getIdentity(), info));
402
_publisher->objectAdded(serial, info);
406
RegistryObserverTopic::objectUpdated(int serial, const ObjectInfo& info, const Ice::Current&)
410
updateSerial(serial);
412
_objects[info.proxy->ice_getIdentity()] = info;
414
_publisher->objectUpdated(serial, info);
418
RegistryObserverTopic::objectRemoved(int serial, const Ice::Identity& id, const Ice::Current&)
422
updateSerial(serial);
426
_publisher->objectRemoved(serial, id);
323
430
RegistryObserverTopic::subscribe(const RegistryObserverPrx& observer, int serial)
329
436
ApplicationDescriptorSeq applications;
437
AdapterInfoSeq adapters;
438
ObjectInfoSeq objects;
331
440
Lock sync(*this);
332
441
assert(_serial != -1);
333
442
serial = _serial;
334
applications = _applications;
444
map<string, ApplicationDescriptor>::const_iterator p;
445
for(p = _applications.begin(); p != _applications.end(); ++p)
447
applications.push_back(p->second);
450
map<string, AdapterInfo>::const_iterator q;
451
for(q = _adapters.begin(); q != _adapters.end(); ++q)
453
adapters.push_back(q->second);
456
map<Ice::Identity, ObjectInfo>::const_iterator r;
457
for(r = _objects.begin(); r != _objects.end(); ++r)
459
objects.push_back(r->second);
336
observer->init_async(new RegistryInitCB(this, observer, serial), serial, applications);
462
observer->init_async(new RegistryInitCB(this, observer, serial), serial, applications, adapters, objects);