Example #1
0
/// Test whether or not the given name is the SSL client that sent this request.
bool HttpRequestContext::isTrustedPeer( const UtlString& peername ) const
{
   /*
    * This tests the host identity provided by the SSL handshake; it does not
    * test the HTTP user identity.
    * @returns
    * - true if the connection is SSL and the peername matches a name in the peer certificate.
    * - false if not.
    */
#  ifdef TEST_DEBUG
   UtlSListIterator peers(mPeerIdentities);
   UtlString peerNames("Peers: ");
   UtlString* peer;
   while((peer = dynamic_cast<UtlString*>(peers())))
   {
      peerNames.append(" '");
      peerNames.append(*peer);
      peerNames.append("'");
   }
   OsSysLog::add(FAC_SIP, PRI_DEBUG,
                 "HttpRequestContext::isTrustedPeer('%s')\n %s %s",
                 peername.data(), mPeerCertTrusted ? "Cert Trusted" : "Cert Not Trusted",
                 peerNames.data()
                 );
#  endif
   return mPeerCertTrusted && mPeerIdentities.contains(&peername);
}
Example #2
0
void MiniCluster<Dtype>::run(shared_ptr<Solver<Dtype> > root_solver,
                             const vector<int>& gpus,
                             int total_gpus) {
#ifdef INFINIBAND
  RDMAAdapter adapter;
  LOG(INFO) << "Found RDMA adapter " << adapter.name();

  // Create channel for each peer
  vector<shared_ptr<RDMAChannel> > peers(size_);
  for (int i = 0; i < size_; ++i) {
    if (i != rank_) {
      peers[i].reset(new RDMAChannel(adapter));
    }
  }
  // Connect channels all to all
  for (int i = 0; i < size_; ++i) {
    vector<string> addresses(1);
    if (i != rank_) {
      addresses[0] = peers[i]->address();
    }
    AllGather(&addresses);
    for (int j = 0; j < addresses.size(); ++j)
      LOG(INFO) << addresses[j];
    if (i == rank_) {
      for (int j = 0; j < size_; ++j) {
        if (j != rank_) {
          peers[j]->Connect(addresses[j]);
        }
      }
    }
  }
  vector<shared_ptr<P2PSync<Dtype> > > syncs(gpus.size());
  // RDMASync will create all necessary buffers
  syncs[0].reset(new RDMASync<Dtype>(root_solver, peers, rank_));
#else
  // Create channel for each peer
  vector<shared_ptr<SocketChannel> > peers(size_);
  for (int i = 0; i < size_; ++i) {
    if (i != rank_) {
      peers[i].reset(new SocketChannel());
    }
  }

  SocketAdapter adapter(&peers);
  usleep(10000);
  // Get all channels to connect to
  vector<string> addresses(1);
  // Set local address to send to master in AllGather.
  // If you are master, you still need to set it, so
  // that it is sent to everyone during regular broadcast in AllGather
  addresses[0] = adapter.address();
  LOG(INFO) << "Adapter address " << adapter.address().c_str();
  AllGather(&addresses);
  for (int j = 0; j < addresses.size(); ++j)
    LOG(INFO) << "ADDRESS [" << addresses.at(j).c_str() << "]";

  // Connect to all channnels
  for (int j = 0; j < size_; ++j) {
    if (j != rank_) {
      LOG(INFO) << "Connecting to [" << addresses[j].c_str() << "]";
      peers[j]->Connect(addresses[j]);
    }
  }

#ifndef CPU_ONLY
  vector<shared_ptr<P2PSync<Dtype> > > syncs(gpus.size());
  syncs[0].reset(new SocketSync<Dtype>(root_solver, peers, rank_));
#else
  vector<shared_ptr<P2PSyncCPU<Dtype> > > syncs(1);
  syncs[0].reset(new SocketSyncCPU<Dtype>(root_solver, peers, rank_));
#endif
#endif

#ifndef CPU_ONLY
  syncs[0]->prepare(gpus, &syncs);
  LOG(INFO)<< "Starting Optimization";

  // Switch to total number of GPUs once the datareaders are ready
  Caffe::set_solver_count(total_gpus);
  for (int i = 1; i < syncs.size(); ++i) {
    syncs[i]->StartInternalThread();
  }

  // Run root solver on current thread
  syncs[0]->solver()->Solve();

  for (int i = 1; i < syncs.size(); ++i) {
    syncs[i]->StopInternalThread();
  }
#else
  Caffe::set_solver_count(1);
  LOG(INFO) << "Starting solver...";
  syncs[0]->solver()->Solve();
#endif

}