ObjectPrx IceGrid::RegistryReplicaAdminRouter::getTarget(const Current& current) { ObjectPrx target; if(current.id.name == _name) { // Straight to the local Admin object target = current.adapter->getCommunicator()->getAdmin(); } else { try { // Forward to Admin object in remote replica target = _database->getReplica(current.id.name)->getAdminProxy(); } catch(const RegistryNotExistException&) { } } if(target == 0) { throw ObjectNotExistException(__FILE__, __LINE__); } return target->ice_facet(current.facet); }
ObjectPrx IceGrid::RegistryNodeAdminRouter::getTarget(const Current& current) { ObjectPrx target; if(!_collocNodeName.empty() && current.id.name == _collocNodeName) { // Straight to the local Admin object target = current.adapter->getCommunicator()->getAdmin(); } else { try { target = _database->getNode(current.id.name)->getAdminProxy(); } catch(const NodeUnreachableException&) { } catch(const NodeNotExistException&) { } if(target == 0) { throw ObjectNotExistException(__FILE__, __LINE__); } } return target->ice_facet(current.facet); }
ObjectPrx IceGrid::RegistryServerAdminRouter::getTarget(const Current& current) { ObjectPrx target = 0; try { target = _database->getServer(current.id.name)->getAdminProxy(); } catch(const ServerNotExistException&) { } catch(const NodeUnreachableException&) { } catch(const DeploymentException&) { } if(target == 0) { throw ObjectNotExistException(__FILE__, __LINE__); } return target->ice_facet(current.facet); }
void IceGrid::RegistryNodeAdminRouter::ice_invoke_async(const AMD_Object_ice_invokePtr& cb, const std::pair<const Ice::Byte*, const Ice::Byte*>& inParams, const Current& current) { ObjectPrx target; if(!_collocNodeName.empty() && current.id.name == _collocNodeName) { // Straight to the local Admin object target = current.adapter->getCommunicator()->getAdmin(); } else { try { target = _database->getNode(current.id.name)->getAdminProxy(); } catch(const NodeUnreachableException&) { } catch(const NodeNotExistException&) { } if(target == 0) { if(_traceLevels->admin > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->adminCat); out << "could not find Admin proxy for node `" << current.id.name << "'"; } throw ObjectNotExistException(__FILE__, __LINE__); } } target = target->ice_facet(current.facet); invokeOnTarget(target, cb, inParams, current); }
void IceGrid::RegistryServerAdminRouter::ice_invoke_async(const AMD_Object_ice_invokePtr& cb, const std::pair<const Ice::Byte*, const Ice::Byte*>& inParams, const Current& current) { ObjectPrx target = 0; try { ServerEntryPtr server = _database->getServer(current.id.name); try { target = server->getAdminProxy(); } catch(const SynchronizationException&) { server->addSyncCallback(new SynchronizationCallbackI(this, cb, inParams, current)); return; // Wait for the server synchronization to complete and retry. } } catch(const ServerNotExistException&) { } catch(const NodeUnreachableException&) { } catch(const DeploymentException&) { } if(target == 0) { throw ObjectNotExistException(__FILE__, __LINE__); } target = target->ice_facet(current.facet); invokeOnTarget(target, cb, inParams, current); }
Ice::ObjectPrx Freeze::BackgroundSaveEvictorI::addFacet(const ObjectPtr& servant, const Identity& ident, const string& facet) { checkIdentity(ident); checkServant(servant); DeactivateController::Guard deactivateGuard(_deactivateController); ObjectStore<BackgroundSaveEvictorElement>* store = findStore(facet, _createDb); if(store == 0) { throw NotFoundException(__FILE__, __LINE__, "addFacet: could not open database for facet '" + facet + "'"); } bool alreadyThere = false; for(;;) { // // Create a new entry // BackgroundSaveEvictorElementPtr element = new BackgroundSaveEvictorElement(*store); element->status = dead; BackgroundSaveEvictorElementPtr oldElt = store->putIfAbsent(ident, element); if(oldElt != 0) { element = oldElt; } { Lock sync(*this); if(element->stale) { // // Try again // continue; } fixEvictPosition(element); IceUtil::Mutex::Lock lock(element->mutex); switch(element->status) { case clean: case created: case modified: { alreadyThere = true; break; } case destroyed: { element->status = modified; element->rec.servant = servant; // // No need to push it on the modified queue, as a destroyed object // is either already on the queue or about to be saved. When saved, // it becomes dead. // break; } case dead: { element->status = created; ObjectRecord& rec = element->rec; rec.servant = servant; if(store->keepStats()) { rec.stats.creationTime = IceUtil::Time::now(IceUtil::Time::Monotonic).toMilliSeconds(); rec.stats.lastSaveTime = 0; rec.stats.avgSaveTime = 0; } addToModifiedQueue(element); break; } default: { assert(0); break; } } } break; // for(;;) } if(alreadyThere) { AlreadyRegisteredException ex(__FILE__, __LINE__); ex.kindOfObject = "servant"; ex.id = _communicator->identityToString(ident); if(!facet.empty()) { ex.id += " -f " + IceUtilInternal::escapeString(facet, ""); } throw ex; } if(_trace >= 1) { Trace out(_communicator->getLogger(), "Freeze.Evictor"); out << "added object \"" << _communicator->identityToString(ident) << "\""; if(!facet.empty()) { out << " with facet \"" << facet << "\""; } out << " to Db \"" << _filename << "\""; } ObjectPrx obj = _adapter->createProxy(ident); if(!facet.empty()) { obj = obj->ice_facet(facet); } return obj; }
void Glacier2::Blobject::invoke(ObjectPrx& proxy, const AMD_Object_ice_invokePtr& amdCB, const std::pair<const Byte*, const Byte*>& inParams, const Current& current) { // // Set the correct facet on the proxy. // if(!current.facet.empty()) { proxy = proxy->ice_facet(current.facet); } // // Modify the proxy according to the request id. This can // be overridden by the _fwd context. // if(current.requestId == 0) { if(_alwaysBatch && _requestQueue) { proxy = proxy->ice_batchOneway(); } else { proxy = proxy->ice_oneway(); } } else if(current.requestId > 0) { proxy = proxy->ice_twoway(); } // // Modify the proxy according to the _fwd context field. // Context::const_iterator p = current.ctx.find("_fwd"); if(p != current.ctx.end()) { for(unsigned int i = 0; i < p->second.length(); ++i) { char option = p->second[i]; switch(option) { case 't': { proxy = proxy->ice_twoway(); break; } case 'o': { if(_alwaysBatch && _requestQueue) { proxy = proxy->ice_batchOneway(); } else { proxy = proxy->ice_oneway(); } break; } case 'd': { if(_alwaysBatch && _requestQueue) { proxy = proxy->ice_batchDatagram(); } else { proxy = proxy->ice_datagram(); } break; } case 'O': { if(_requestQueue) { proxy = proxy->ice_batchOneway(); } else { proxy = proxy->ice_oneway(); } break; } case 'D': { if(_requestQueue) { proxy = proxy->ice_batchDatagram(); } else { proxy = proxy->ice_datagram(); } break; } case 's': { proxy = proxy->ice_secure(true); break; } case 'z': { proxy = proxy->ice_compress(true); break; } default: { Warning out(_instance->logger()); out << "unknown forward option `" << option << "'"; break; } } } } if(_requestTraceLevel >= 1) { Trace out(_instance->logger(), "Glacier2"); if(_reverseConnection) { out << "reverse "; } out << "routing"; if(_requestQueue) { out << " (buffered)"; } else { out << " (not buffered)"; } if(_reverseConnection) { out << "\nidentity = " << _instance->communicator()->identityToString(proxy->ice_getIdentity()); } else { out << "\nproxy = " << _instance->communicator()->proxyToString(proxy); } out << "\noperation = " << current.operation; out << "\ncontext = "; Context::const_iterator q = current.ctx.begin(); while(q != current.ctx.end()) { out << q->first << '/' << q->second; if(++q != current.ctx.end()) { out << ", "; } } } if(_requestQueue) { // // If we are in buffered mode, we create a new request and add // it to the request queue. If the request is twoway, we use // AMI. // bool override; try { override = _requestQueue->addRequest(new Request(proxy, inParams, current, _forwardContext, _context, amdCB)); } catch(const ObjectNotExistException& ex)