void Server::connect(SocksClientSocket &me, const Host &host, IPPort port) { #if 1 //@@@ should be using Hostname (server resolution) mode, but this won't get us //@@@ any useful peer address to use for bind relaying. Need to rethink this scenario. set<IPAddress> addrs = host.addresses(); for (set<IPAddress>::const_iterator it = addrs.begin(); it != addrs.end(); it++) { try { IPSockAddress addr(*it, port); connect(me, addr); return; } catch (const UnixError &err) { errno = err.error; } } // exhausted UnixError::throwMe(); #else open(me, me); Message request(socksConnect, host.name().c_str(), port); request.send(me); Message reply(me); me.mLocalAddress = reply.address(); //me.mPeerAddress = not provided by Socks5 protocol; secdebug("socks", "%d socks connected to %s", me.fd(), host.name().c_str()); #endif }
void Loader::servePendingRequests(Priority minimumPriority) { if (m_isSuspendingPendingRequests) return; m_requestTimer.stop(); m_nonHTTPProtocolHost->servePendingRequests(minimumPriority); Vector<Host*> hostsToServe; m_hosts.checkConsistency(); HostMap::iterator i = m_hosts.begin(); HostMap::iterator end = m_hosts.end(); for (; i != end; ++i) hostsToServe.append(i->second.get()); for (unsigned n = 0; n < hostsToServe.size(); ++n) { Host* host = hostsToServe[n]; if (host->hasRequests()) host->servePendingRequests(minimumPriority); else if (!host->processingResource()) { AtomicString name = host->name(); m_hosts.remove(name.impl()); } } }
void Master::schedule_tasks() { log_debug("Scheduling %d tasks on %d slots...", ready_queue.size(), free_slots.size()); int scheduled = 0; TaskList deferred_tasks; while (ready_queue.size() > 0 && free_slots.size() > 0) { Task *task = ready_queue.top(); ready_queue.pop(); log_trace("Scheduling task %s", task->name.c_str()); bool match = false; for (SlotList::iterator s = free_slots.begin(); s != free_slots.end(); s++) { Slot *slot = *s; Host *host = slot->host; // If the task fits, schedule it if (host->can_run(task)) { log_trace("Matched task %s to slot %d on host %s", task->name.c_str(), slot->rank, host->name()); // Reserve the resources vector<cpu_t> bindings = host->allocate_resources(task); host->log_resources(resource_log); submit_task(task, slot->rank, bindings); s = free_slots.erase(s); // so that the s++ in the loop doesn't skip one s--; match = true; scheduled += 1; // This is to break out of the slot loop so that we can // consider the next task break; } } if (!match) { // If the task could not be scheduled, then we save it // and move on to the next one. It will be requeued later. log_trace("No slot found for task %s", task->name.c_str()); deferred_tasks.push_back(task); } } log_debug("Scheduled %d tasks and deferred %d tasks", scheduled, deferred_tasks.size()); // Requeue all the deferred tasks for (TaskList::iterator t = deferred_tasks.begin(); t != deferred_tasks.end(); t++) { ready_queue.push(*t); } }
QVariant HostModel::data(const QModelIndex &index, int role) const { if (index.row() < 0 || index.row() >= m_hosts.count()) return QVariant(); Host* host = m_hosts.at(index.row()); switch (index.column()) { case 0: { switch (role) { case NameRole: return host->name(); case AddressRole: return host->address(); } break; } case 1: if (role == Qt::DisplayRole) return host->name(); break; case 2: if (role == Qt::DisplayRole) return host->productVersion(); break; case 3: if (role == Qt::DisplayRole) return host->systemName(); break; case 4: if (role == Qt::DisplayRole) return QString("%1:%2").arg(host->address()).arg(host->port()); break; } return QVariant(); }
void SnafuHostItem::setHost(Host host) { mHost = host; setIcon(0, QIcon( SnafuWidget::statusPixmap(host.status()) ) ); setText(0, host.name()); setText(1, host.os()); setText(2, host.description()); setText(3, host.hostStatus().slaveStatus()); setText(4, host.slavePulse().toString("yyyy.MM.dd hh:mm:ss")); //setText(5, host.xcatImageVersion); //setText(6, host.xcatNodeStat); //setText(7, QString::number(host.taskCount)); //setText(8, QString::number(host.errorCount)); //setText(9, MainWindow::timeCode(host.taskAverageTime)); //setText(10, MainWindow::timeCode(host.taskSuccessTime)); }
void Loader::servePendingRequests(Priority minimumPriority) { m_requestTimer.stop(); m_nonHTTPProtocolHost.servePendingRequests(minimumPriority); Vector<Host*> hostsToServe; copyValuesToVector(m_hosts, hostsToServe); for (unsigned n = 0; n < hostsToServe.size(); ++n) { Host* host = hostsToServe[n]; if (host->hasRequests()) host->servePendingRequests(minimumPriority); else if (!host->processingResource()){ AtomicString name = host->name(); delete host; m_hosts.remove(name.impl()); } } }