zoukankan      html  css  js  c++  java
  • thrift的使用及遇到的问题

    centos 系统安装官方文档:http://thrift.apache.org/docs/install/centos

    一、按该文档安装出现了一系列的问题,记录如下:

    1.安装thrift时./bootstrap.sh出错,然后安装libevent问题解决
    (首先:git gc,清除./configure 和make错误的信息)
    # wget http://www.monkey.org/~provos/libevent-1.2.tar.gz
    
    # tar zxvf libevent-1.2.tar.gz
    # cd libevent-1.2
    # ./configure –prefix=/usr
    # make
    # make install

    2.安装thrift到make步骤时出现如下错误:

      g++: error: /usr/lib64/libboost_unit_test_framework.a: No such file or directory

    3.../../../lib/cpp/.libs/libthriftnb.so: undefined reference to `evutil_make_socket_closeonexec'

      ../../../lib/cpp/.libs/libthriftnb.so: undefined reference to `evbuffer_get_length'

      ../../../lib/cpp/.libs/libthriftnb.so: undefined reference to `evbuffer_pullup'

      collect2: error: ld returned 1 exit status

    4.automake --add-missing”时出错及解决办法:

    a. configure.ac: error: no proper invocaction of AM_INIT_AUTOMAKE was found.
    b. Makefile.am: error: required file './NEWS' not found
        Makefile.am: error: required file './README' not found
        Makefile.am: error: required file './AUTHORS' not found
        Makefile.am: error: required file './ChangeLog' not found
        使用命令:automake --add-missing --copy --foreign
    c. required file `config.h.in' not found 
      解决:在执行automake --add-missing之前执行autoheader,生成config.h.in
    d. Libtool library used but `LIBTOOL' is undefined?
      解决:重装libtool 然后再运行
      try run “libtoolize” in that directory first, and then re-run autoreconf
    e. /usr/share/automake-1.14/am/depend2.am: error: am__fastdepCXX does not appear in AM_CONDITIONAL
      在configure.ac 中加入
    AC_INIT
    AM_INIT_AUTOMAKE
    
    dnl add this
    AC_PROG_CXX
    
    AC_PROG_LIBTOOL

      本人安装thrift遇到了各种各样的坑,真是一波三折,差点放弃,希望thrift能把安装过程完善一下,让使用者投入更多的时间在使用上而不是安装上。

    二、Thrift python使用过程遇到的错误:

    No handlers could be found for logger "thrift.server.TServer"

    参考网址:http://blog.csdn.net/mantoureganmian/article/details/48340215

      thrift框架做的很好,封装的也很好,不仅仅有代码生成功能,而且还有错误处理机制。这种错误处理机制处理过程是:当Handler类中的出现错误时,一律提示:“No handlers could be found for logger "thrift.server.TServer"”。换句话说,当变量拼写错误时,不会提示某个变量未命名,而提示“No handlers could be found for logger "thrift.server.TServer"”,这样无疑增加了改错难度,坑啊!!!

       对于此,比较好的解决方案是:使用try....except  Exception as e:模块来手动打印错误。try模块代码示例如下:

    try:  
        a=b  
    except Exception as  e:  
        print e  
    

      我代码出错的原因是:server端返回给了client端字符串为汉字,改成拼音问题解决。

      thrift整体来说还是很好用的,特别是支持跨多种语言,减少了开发者间的通信难度。

      本人菜鸟一枚,但不会在菜鸟的路上越走越远,thrift遇到问题还会持续更新。。。

  • 相关阅读:
    Object-C中
    实例变量可见度修饰符
    Object-C 类和对象
    C语言中线程和进程的区别
    动态内存分配
    C语言中union关键字
    C语言结构体
    const define static extern 关键词详解
    基于TensorFlow Object Detection API进行迁移学习训练自己的人脸检测模型(一)
    Ubuntu18.04+CUDA9.0+cuDNN7.1.3+TensorFlow1.8 安装总结
  • 原文地址:https://www.cnblogs.com/zhaochunhua/p/7069054.html
Copyright © 2011-2022 走看看