コード例 #1
0
void SoapServerInternal::CallMethod(const string& serviceName, const string& methodName, const google::protobuf::Message& request, SoapProtocol::ResponseCallback callback)
{
  Log(string("<ProtobuOutboundReq>") + request.DebugString() + "</ProtobuOutboundReq>");

  map<string, ServiceBinding>::iterator it = m_soapMappings.find(serviceName);

  if (it == m_soapMappings.end())
  {
    throw exception("Cant find service binding");
  }

  lock_guard<mutex> guard(m_protocolLock);
  map<string, SoapProtocol*>::iterator sp = m_protocolBindings.begin();

  //if (sp == m_protocolBindings.end())
  //{
  //  throw exception("Cant find protocol binding");
  //}

  tinyxml2::XMLDocument doc;

  ClassBinding& binding = GetClassBinding(request.GetDescriptor());
  tinyxml2::XMLElement* resp = binding.GetProtobufHelper()->GenerateRequest(methodName, request, doc);

  string actionUrl = it->second.GetActionUrl() + "/" + methodName;
  sp->second->SendRequest(actionUrl, doc, resp, callback);
}
コード例 #2
0
ファイル: Server.cpp プロジェクト: Bia10/clrn
    //! Client handle
    void HandleRequest(const google::protobuf::Message& message, const net::IConnection::Ptr& connection)
    {
        SCOPED_LOG(m_Log);

#ifdef _DEBUG
        std::string request;
#endif
        try
        {
#ifdef _DEBUG
            request = message.DebugString();
            assert(!request.empty());
#endif
            LOG_DEBUG("Request: [%s]") % message.DebugString();

            IStatistics* stats = 0;
            {
                boost::mutex::scoped_lock lock(m_StatsMutex);
                StatisticsMap::iterator it = m_Statistics.find(GetCurrentThreadId());
                if (it == m_Statistics.end())
                    it = m_Statistics.insert(std::make_pair(GetCurrentThreadId(), boost::shared_ptr<IStatistics>(new MongoStatistics(m_Log)))).first;
                stats = it->second.get();
            }

            NeuroDecisionMaker decisionMaker(m_Log, m_Evaluator, *stats, m_Network, *connection);
            pcmn::TableLogic logic(m_Log, decisionMaker, m_Evaluator);
            logic.Parse(static_cast<const net::Packet&>(message));

            LOG_WARNING("Requests processed: [%s]") % ++m_RequestsCount;
        }
        catch (const std::exception& e)
        {
            std::ostringstream oss;
            oss << "Error: " << e.what() << std::endl
                << "Packet: " << message.DebugString();

            net::Reply reply;
            reply.set_error(oss.str());

            LOG_ERROR("%s") % oss.str();
            connection->Send(reply);
        }
    }
コード例 #3
0
ファイル: communication.cpp プロジェクト: tigerinsky/push
int send(int fd, 
         const std::string& name,
         const ::google::protobuf::Message& message,
         uint64_t mid) {
    SocketWriter writer(fd);
    Version_1_Protocol protocol;
    Msg msg;
    message.SerializeToString(msg.mutable_content());
    msg.set_mid(mid);
    msg.set_name(name);
    int ret = protocol.encode(msg, &writer);
    if (ret) {
        LOG_WARN << "encode request error, method["
            << name << "] data[" << message.DebugString()<< "]";
        return 1;
    }
    return writer.write(1000) == SocketWriter::kOk ? 0 : -1;
}
コード例 #4
0
ファイル: state.cpp プロジェクト: aelovikov/mesos
Try<Nothing> checkpoint(
    const string& path,
    const google::protobuf::Message& message)
{
  // Create the base directory.
  Try<Nothing> result = os::mkdir(os::dirname(path).get());
  if (result.isError()) {
    return Error("Failed to create directory '" + os::dirname(path).get() +
                 "': " + result.error());
  }

  // Now checkpoint the protobuf to disk.
  result = ::protobuf::write(path, message);
  if (result.isError()) {
    return Error("Failed to checkpoint \n" + message.DebugString() +
                 "\n to '" + path + "': " + result.error());
  }

  return Nothing();
}
コード例 #5
0
static void wrapRequest(const GridClientMessageCommand& cmd, const ObjectWrapperType& type,
    const ::google::protobuf::Message& src, ObjectWrapper& objWrapper) {
    GG_LOG_DEBUG("Wrapping request: %s", src.DebugString().c_str());

    ProtoRequest req;

    fillRequestHeader(cmd, req);

    objWrapper.set_type(type);

    int8_t * pBuffer;
    unsigned long bufferLength;

    GridClientProtobufMarshaller::marshalMsg(src, pBuffer, bufferLength);

    req.set_body(pBuffer, bufferLength);

    delete[] pBuffer;

    GridClientProtobufMarshaller::marshalMsg(req, pBuffer, bufferLength);
    objWrapper.set_binary(pBuffer, bufferLength);

    delete[] pBuffer;
}
コード例 #6
0
ファイル: ClientServerLogicTests.cpp プロジェクト: Bia10/clrn
 virtual void Send(const google::protobuf::Message& message)
 {
     std::cout << "Answer number: " << g_Answers++ << " " << message.DebugString() << std::endl;
     ASSERT_FALSE(g_Answers > 1);
 }