Exemple #1
0
WriteResultPtr DBWriterI::writeWithKeys(const string& dbSrc, const string& pattern, const string& sql, const string& nameSpace,
    const string& businessName, const MyUtil::StrSeq& keys, int op, int expireTime, const Ice::Current& current) {
  MCE_INFO("[DBWriterI::writeWithKeys] dbSrc = " << dbSrc << ", pattern = " << pattern << ", sql = [" << sql << "], nameSpace = "
      << nameSpace << ", businessName = " << businessName << ", keys.size = " << keys.size() << ", op = " << op);
  Statement sqlToExecute;
  sqlToExecute << sql;
  WriteResultInfoPtr writeResultInfoPtr = new WriteResultInfo();
  try {
    mysqlpp::SimpleResult simpleResult= QueryRunner(dbSrc, CDbWServer, pattern).execute(sqlToExecute);
    MCE_INFO("[DBWriterI::writeWithKeys] dbSrc = " << dbSrc << ", pattern = " << pattern << ", sql = [" << sql << "], nameSpace = "
        << nameSpace << ", businessName = " << businessName << ", keys.size = " << keys.size() << ", op = " << op << " executed success");
    bool loadTripodCacheOk = true;
    if (!opTripodCache(nameSpace, businessName, keys, op, expireTime)) {
      loadTripodCacheOk = false;
    }
    writeResultInfoPtr->setResult(simpleResult, loadTripodCacheOk);
  } catch (mysqlpp::Exception ex) {
    MCE_INFO("[DBWriterI::writeWithKeys] dbSrc = " << dbSrc << ", pattern = " << pattern << ", sql = [" << sql << "], nameSpace = "
        << nameSpace << ", businessName = " << businessName << ", keys.size = " << keys.size() << ", op = " << op << ", mysqlpp::exception = "
        << ex.what() << ", executed failure");
    writeResultInfoPtr->setInfo(ex.what());
  } catch (exception ex) {
    MCE_INFO("[DBWriterI::writeWithKeys] dbSrc = " << dbSrc << ", pattern = " << pattern << ", sql = [" << sql << "], nameSpace = "
        << nameSpace << ", businessName = " << businessName << ", keys.size = " << keys.size() << ", op = " << op << ", exception = "
        << ex.what() << ", executed failure");
    writeResultInfoPtr->setInfo(ex.what());
  } catch (...) {
    MCE_INFO("[DBWriterI::writeWithKeys] dbSrc = " << dbSrc << ", pattern = " << pattern << ", sql = [" << sql << "], nameSpace = "
        << nameSpace << ", businessName = " << businessName << ", keys.size = " << keys.size() << ", op = " << op << ", unknown exception"
        << ", executed failure");
    writeResultInfoPtr->setInfo("unknown exception");
  }
  return writeResultInfoPtr;
}
MyUtil::IntSeq AccountFilterAdapter::GetIdBySHA256(const MyUtil::StrSeq &digests) {
  try {
    return getProxy(0)->GetIdBySHA256(digests);
  } catch (Ice::Exception& e) {
    MCE_WARN("AccountFilterAdapter::AddAccount Exception digest.size: "
        << digests.size() << " ,e: " << e.what()); 
  }
  return MyUtil::IntSeq();
}
Exemple #3
0
MyUtil::IntSeq AccountFilterI::GetIdBySHA256(const MyUtil::StrSeq &digests, const Ice::Current &current) {
  ostringstream oss;
  oss << "digest.size: " << digests.size();
  InvokeClient ic = InvokeClient::create(current, oss.str(), InvokeClient::INVOKE_LEVEL_DEBUG);
  MyUtil::IntSeq result;
  MyUtil::StrSeq::const_iterator it = digests.begin();
  for(; it != digests.end(); ++it) {
    if(it->size() != SHA256::HEX_SIZE || !MyUtil::StrUtil::isXDigit(*it)) {
      MCE_WARN("AccountFilterI::GetIdBySHA256 invalid digest: " << *it << " ,size: " << it->size());
      continue;
    }
    string digest_lower = MyUtil::StrUtil::toLower(*it);
    int bucket = bucket_manager_.GetBucket(digest_lower);
    DigestMap& digest_map = buckets_[bucket];
    boost::shared_lock<boost::shared_mutex> read_lock(mutex_[bucket]);
    DigestMap::iterator it_digest = digest_map.find(digest_lower);
    if(it_digest != digest_map.end()) {
      BOOST_FOREACH(int id, it_digest->second.ids) {
        result.push_back(id);
      }
    }
  }
Exemple #4
0
bool DBWriterI::opTripodCache(const string& nameSpace, const string& businessName, const MyUtil::StrSeq& keys, int op, int expireTime) {
  com::renren::tripod::TripodClient* client = getTripodClient(nameSpace, businessName);
  try {
    if (op == OP_INSERT) {
      client->load(keys, expireTime, true);
    } else if (op == OP_UPDATE) {
      client->load(keys, expireTime, true);
    } else if (op == OP_DELETE) {
      client->deleteCache(keys, 2000);
    }
  } catch (Ice::TimeoutException ex) {
    MCE_INFO("[DBWriterI::opTripodCache] nameSpace = " << nameSpace << ", businessName = " << businessName << ", keys.size = " 
        << keys.size() << ", op = " << op << " exception = " << ex.what() << ", operate TripodCache failure");
  } catch (exception ex) {
    MCE_INFO("[DBWriterI::opTripodCache] nameSpace = " << nameSpace << ", businessName = " << businessName << ", keys.size = " 
        << keys.size() << ", op = " << op << " exception = " << ex.what() << ", operate TripodCache failure");
    return false;
  } catch (...) {
    MCE_INFO("[DBWriterI::opTripodCache] nameSpace = " << nameSpace << ", businessName = " << businessName << ", keys.size = " 
        << keys.size() << ", op = " << op << " unknown exception, operate TripodCache failure");
    return false;
  }
  return true;
}
Exemple #5
0
void PvLogHandler::PushBack(const MyUtil::StrSeq& logs) {
  IceUtil::Mutex::Lock lock(mutex_);
  for (MyUtil::StrSeq::const_iterator it = logs.begin(); it != logs.end(); ++it) {
    queue_.push(*it);
  }
}