bool UniPAX::PublicationXref::merge(PublicationXref& object) { if (!object.getYear() != 0) { if (!getYear() != 0) { if (getYear() != object.getYear()) { std::cerr << "Error during merging: UniPAX::PublicationXref::year not equal ..." << getYear() << " != " << object.getYear() << std::endl; return false; } } else setYear(object.getYear()); } { std::set<std::string> tmp(getUrls().begin(), getUrls().end()); for (std::vector<std::string>::iterator it = object.getUrls().begin(); it != object.getUrls().end(); it++) { tmp.insert(*it); } getUrls().assign(tmp.begin(), tmp.end()); } if (!object.getTitle().empty()) { if (!getTitle().empty()) { if (getTitle() != object.getTitle()) { std::cerr << "Error during merging: UniPAX::PublicationXref::title not equal ..." << getTitle() << " != " << object.getTitle() << std::endl; return false; } } else setTitle(object.getTitle()); } { std::set<std::string> tmp(getSources().begin(), getSources().end()); for (std::vector<std::string>::iterator it = object.getSources().begin(); it != object.getSources().end(); it++) { tmp.insert(*it); } getSources().assign(tmp.begin(), tmp.end()); } { std::set<std::string> tmp(getAuthors().begin(), getAuthors().end()); for (std::vector<std::string>::iterator it = object.getAuthors().begin(); it != object.getAuthors().end(); it++) { tmp.insert(*it); } getAuthors().assign(tmp.begin(), tmp.end()); } return UniPAX::Xref::merge(object); }
void Cluster::memberUpdate(Lock& l) { // Ignore config changes while we are joining. if (state < CATCHUP) return; QPID_LOG(info, *this << " member update: " << map); size_t aliveCount = map.aliveCount(); assert(map.isAlive(self)); failoverExchange->updateUrls(getUrls(l)); // Mark store clean if I am the only broker, dirty otherwise. if (store.hasStore()) { if (aliveCount == 1) { if (store.getState() != STORE_STATE_CLEAN_STORE) { QPID_LOG(notice, *this << "Sole member of cluster, marking store clean."); store.clean(Uuid(true)); } } else { if (store.getState() != STORE_STATE_DIRTY_STORE) { QPID_LOG(notice, "Running in a cluster, marking store dirty."); store.dirty(); } } } // If I am the last member standing, set queue policies. if (aliveCount == 1 && lastAliveCount > 1 && state >= CATCHUP) { QPID_LOG(notice, *this << " last broker standing, update queue policies"); lastBroker = true; broker.getQueues().updateQueueClusterState(true); } else if (aliveCount > 1 && lastBroker) { QPID_LOG(notice, *this << " last broker standing joined by " << aliveCount-1 << " replicas, updating queue policies."); lastBroker = false; broker.getQueues().updateQueueClusterState(false); } lastAliveCount = aliveCount; // Close connections belonging to members that have left the cluster. ConnectionMap::iterator i = connections.begin(); while (i != connections.end()) { ConnectionMap::iterator j = i++; MemberId m = j->second->getId().getMember(); if (m != self && !map.isMember(m)) { j->second->close(); erase(j->second->getId(), l); } } }
// See comment on Cluster::setMgmtStatus void Cluster::updateMgmtMembership(Lock& l) { if (!mgmtObject) return; std::vector<Url> urls = getUrls(l); mgmtObject->set_clusterSize(urls.size()); string urlstr; for(std::vector<Url>::iterator i = urls.begin(); i != urls.end(); i++ ) { if (i != urls.begin()) urlstr += ";"; urlstr += i->str(); } std::vector<string> ids = getIds(l); string idstr; for(std::vector<string>::iterator i = ids.begin(); i != ids.end(); i++ ) { if (i != ids.begin()) idstr += ";"; idstr += *i; } mgmtObject->set_members(urlstr); mgmtObject->set_memberIDs(idstr); }
void Cluster::configChange(const MemberId&, const std::string& membersStr, const std::string& leftStr, const std::string& joinedStr, Lock& l) { if (state == LEFT) return; MemberSet members = decodeMemberSet(membersStr); MemberSet left = decodeMemberSet(leftStr); MemberSet joined = decodeMemberSet(joinedStr); QPID_LOG(notice, *this << " configuration change: " << members); QPID_LOG_IF(notice, !left.empty(), *this << " Members left: " << left); QPID_LOG_IF(notice, !joined.empty(), *this << " Members joined: " << joined); // If we are still joining, make sure there is someone to give us an update. elders = intersection(elders, members); if (elders.empty() && INIT < state && state < CATCHUP) { QPID_LOG(critical, "Cannot update, all potential updaters left the cluster."); leave(l); return; } bool memberChange = map.configChange(members); // Update initital status for members joining or leaving. initMap.configChange(members); if (initMap.isResendNeeded()) { mcast.mcastControl( ClusterInitialStatusBody( ProtocolVersion(), CLUSTER_VERSION, state > INIT, clusterId, store.getState(), store.getShutdownId(), initMap.getFirstConfigStr(), vectorToUrlArray(getUrls(l)) ), self); } if (initMap.transitionToComplete()) initMapCompleted(l); if (state >= CATCHUP && memberChange) { memberUpdate(l); if (elders.empty()) becomeElder(l); } updateMgmtMembership(l); // Update on every config change for consistency }
void views::treeView::performDrag() { QModelIndexList list=selectedIndexes(); QList<QUrl> urls=getUrls(list); if(urls.isEmpty() ) { return ; } QMimeData *mimeData = new QMimeData; mimeData->setUrls(urls); QDrag *drag = new QDrag(this); drag->setMimeData(mimeData); drag->setPixmap(QPixmap(decor->tagIcon(-1).pixmap(48,48)) ); drag->exec(Qt::CopyAction|Qt::MoveAction); if(reorderL.size() == 0) { return ; } QItemSelection sel; std::set<int>::const_iterator it=reorderL.begin(); for(;it!=reorderL.end();it++) { QItemSelection s; s.select(model ()->index (*it, 0),model ()->index (*it, model()->columnCount()-1)); sel.merge(s,QItemSelectionModel::SelectCurrent); } // selectionModel()->select (sel,QItemSelectionModel::Select ); reorderL.clear(); }
std::vector<Url> Cluster::getUrls() const { Lock l(lock); return getUrls(l); }