int ObjectObserverTopic::objectInit(Ice::Long dbSerial, const ObjectInfoSeq& objects) { Lock sync(*this); if(_topics.empty()) { return -1; } updateSerial(dbSerial); _objects.clear(); for(ObjectInfoSeq::const_iterator r = objects.begin(); r != objects.end(); ++r) { _objects.insert(make_pair(r->proxy->ice_getIdentity(), *r)); } try { for(vector<ObjectObserverPrx>::const_iterator p = _publishers.begin(); p != _publishers.end(); ++p) { (*p)->objectInit(objects, getContext(_serial, dbSerial)); } } catch(const Ice::LocalException& ex) { Ice::Warning out(_logger); out << "unexpected exception while publishing `objectInit' update:\n" << ex; } addExpectedUpdate(_serial); return _serial; }
void WellKnownObjectsManager::updateReplicatedWellKnownObjects() { if(!initialized()) { return; } // // Update replicated objects. // Ice::Identity id; id.category = _database->getInstanceName(); ObjectInfo info; ObjectInfoSeq objects; Lock sync(*this); Ice::ObjectPrx replicatedClientProxy = _database->getReplicaCache().getEndpoints("Client", _endpoints["Client"]); id.name = "Query"; info.type = Query::ice_staticId(); info.proxy = replicatedClientProxy->ice_identity(id); objects.push_back(info); id.name = "Locator"; info.type = Ice::Locator::ice_staticId(); info.proxy = replicatedClientProxy->ice_identity(id); objects.push_back(info); _database->addOrUpdateObjectsInDatabase(objects); }
int ObjectObserverTopic::wellKnownObjectsAddedOrUpdated(const ObjectInfoSeq& infos) { Lock sync(*this); if(_topics.empty()) { return -1; } for(ObjectInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p) { updateSerial(); map<Ice::Identity, ObjectInfo>::iterator q = _objects.find(p->proxy->ice_getIdentity()); if(q != _objects.end()) { q->second = *p; try { for(vector<ObjectObserverPrx>::const_iterator q = _publishers.begin(); q != _publishers.end(); ++q) { (*q)->objectUpdated(*p, getContext(_serial)); } } catch(const Ice::LocalException& ex) { Ice::Warning out(_logger); out << "unexpected exception while publishing `objectUpdated' update:\n" << ex; } } else { _objects.insert(make_pair(p->proxy->ice_getIdentity(), *p)); try { for(vector<ObjectObserverPrx>::const_iterator q = _publishers.begin(); q != _publishers.end(); ++q) { (*q)->objectAdded(*p, getContext(_serial)); } } catch(const Ice::LocalException& ex) { Ice::Warning out(_logger); out << "unexpected exception while publishing `objectAdded' update:\n" << ex; } } } // // We don't wait for the update to be received by the replicas // here. This operation is called by ReplicaSessionI. // addExpectedUpdate(_serial); //waitForSyncedSubscribersNoSync(_serial); return _serial; }
void ObjectObserverTopic::initObserver(const Ice::ObjectPrx& obsv) { ObjectObserverPrx observer = ObjectObserverPrx::uncheckedCast(obsv); ObjectInfoSeq objects; for(map<Ice::Identity, ObjectInfo>::const_iterator p = _objects.begin(); p != _objects.end(); ++p) { objects.push_back(p->second); } observer->objectInit(objects, getContext(_serial, _dbSerial)); }
ObjectInfoSeq ObjectCache::getAll(const string& expression) { Lock sync(*this); ObjectInfoSeq infos; for(map<Ice::Identity, ObjectEntryPtr>::const_iterator p = _entries.begin(); p != _entries.end(); ++p) { if(expression.empty() || IceUtilInternal::match(_communicator->identityToString(p->first), expression, true)) { infos.push_back(p->second->getObjectInfo()); } } return infos; }
ObjectInfoSeq ObjectCache::getAllByType(const string& type) { Lock sync(*this); ObjectInfoSeq infos; map<string, TypeEntry>::const_iterator p = _types.find(type); if(p == _types.end()) { return infos; } const vector<ObjectEntryPtr>& objects = p->second.getObjects(); for(vector<ObjectEntryPtr>::const_iterator q = objects.begin(); q != objects.end(); ++q) { infos.push_back((*q)->getObjectInfo()); } return infos; }
int ObjectObserverTopic::wellKnownObjectsRemoved(const ObjectInfoSeq& infos) { Lock sync(*this); if(_topics.empty()) { return -1; } for(ObjectInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p) { updateSerial(); _objects.erase(p->proxy->ice_getIdentity()); try { for(vector<ObjectObserverPrx>::const_iterator q = _publishers.begin(); q != _publishers.end(); ++q) { (*q)->objectRemoved(p->proxy->ice_getIdentity(), getContext(_serial)); } } catch(const Ice::LocalException& ex) { Ice::Warning out(_logger); out << "unexpected exception while publishing `objectUpdated' update:\n" << ex; } } // // We don't need to wait for the update to be received by the // replicas here. This operation is only called internaly by // IceGrid. // addExpectedUpdate(_serial); //waitForSyncedSubscribersNoSync(_serial); return _serial; }