zoukankan      html  css  js  c++  java
  • ceph主要数据结构解析1

    1.Msgr.h文件:定义消息传输层的数据类型,以供ceph使用

    (1)默认的监控端口:
    #define CEPH_MON_PORT    6789
    (2)客户端处理端口范围定义:
    #define CEPH_PORT_FIRST  6789//监控
    #define CEPH_PORT_START  6800  //开始
    #define CEPH_PORT_LAST   6900//结束
    (3)tcp协议标识和版本信息:
    #define CEPH_BANNER "ceph v027"
    #define CEPH_BANNER_MAX_LEN 30//最大长度
    (4)ceph中的实体名称:在网络传输中使用,例如mds0表示元数据服务器0
    struct ceph_entity_name {
    __u8 type;      /* CEPH_ENTITY_TYPE_* */
    __le64 num;
    } __attribute__ ((packed));//按照紧凑模式分配内存,而不是内存对齐
    
    #define CEPH_ENTITY_TYPE_MON    0x01//监控服务器实体
    #define CEPH_ENTITY_TYPE_MDS    0x02//元数据服务器实体
    #define CEPH_ENTITY_TYPE_OSD    0x04//对象存储设备实体
    #define CEPH_ENTITY_TYPE_CLIENT 0x08//客户端实体
    #define CEPH_ENTITY_TYPE_AUTH   0x20//权限实体
    #define CEPH_ENTITY_TYPE_ANY    0xFF//任何
    同时提供一个函数用于将类型转换为名字字符串的函数如下:
    const char *ceph_entity_type_name(int type)
    {
    switch (type) {
    case CEPH_ENTITY_TYPE_MDS: return "mds";
    case CEPH_ENTITY_TYPE_OSD: return "osd";
    case CEPH_ENTITY_TYPE_MON: return "mon";
    case CEPH_ENTITY_TYPE_CLIENT: return "client";
    case CEPH_ENTITY_TYPE_AUTH: return "auth";
    default: return "unknown";
    }
    }
    (5)实体网络地址以及与名字实体的对应关系结构体
    struct ceph_entity_addr {
    __le32 type;
    __le32 nonce;  /* unique id for process (e.g. pid) */
    struct sockaddr_storage in_addr;
    } __attribute__ ((packed));
    
    struct ceph_entity_inst {
    struct ceph_entity_name name;
    struct ceph_entity_addr addr;
    } __attribute__ ((packed));
    (6)消息交换协议定义:
    #define CEPH_MSGR_TAG_READY         1  /* server->client: ready for messages */
    #define CEPH_MSGR_TAG_RESETSESSION  2  /* server->client: reset, try again */
    #define CEPH_MSGR_TAG_WAIT          3  /* server->client: wait for racing
      incoming connection */
    #define CEPH_MSGR_TAG_RETRY_SESSION 4  /* server->client + cseq: try again
      with higher cseq */
    #define CEPH_MSGR_TAG_RETRY_GLOBAL  5  /* server->client + gseq: try again
      with higher gseq */
    #define CEPH_MSGR_TAG_CLOSE         6  /* closing pipe */
    #define CEPH_MSGR_TAG_MSG           7  /* message */
    #define CEPH_MSGR_TAG_ACK           8  /* message ack */
    #define CEPH_MSGR_TAG_KEEPALIVE     9  /* just a keepalive byte! */
    #define CEPH_MSGR_TAG_BADPROTOVER  10  /* bad protocol version */
    #define CEPH_MSGR_TAG_BADAUTHORIZER 11 /* bad authorizer */
    #define CEPH_MSGR_TAG_FEATURES      12 /* insufficient features */
    #define CEPH_MSGR_TAG_SEQ           13 /* 64-bit int follows with seen seq number */
    (7)连接协商
    struct ceph_msg_connect {//连接消息结构体
    __le64 features;     /* supported feature bits */支持的特征位
    __le32 host_type;    /* CEPH_ENTITY_TYPE_* */上面提到的实体类型
    __le32 global_seq;   /* count connections initiated by this host */主机初始化的连接数量
    __le32 connect_seq;  /* count connections initiated in this session */在这个对话中的连接数量
    __le32 protocol_version;//协议版本
    __le32 authorizer_protocol;//权限协议
    __le32 authorizer_len;//权限长度
    __u8  flags;         /* CEPH_MSG_CONNECT_* */
    } __attribute__ ((packed));
    
    struct ceph_msg_connect_reply {//连接回复消息结构体
    __u8 tag;//上面定义传递消息的类型
    __le64 features;     /* feature bits for this session */这个对话的特征位
    __le32 global_seq;
    __le32 connect_seq;
    __le32 protocol_version;
    __le32 authorizer_len;
    __u8 flags;
    } __attribute__ ((packed));
    
    #define CEPH_MSG_CONNECT_LOSSY  1  /* messages i send may be safely dropped */
    (8)消息头部结构:有老的
    struct ceph_msg_header_old {
    __le64 seq;       /* message seq# for this session */消息序列号
    __le64 tid;       /* transaction id */传输id
    __le16 type;      /* message type */消息类型
    __le16 priority;  /* priority.  higher value == higher priority */优先级,值高优先级就高
    __le16 version;   /* version of message encoding */消息编码版本
    
    __le32 front_len; /* bytes in main payload */开头主要的有效数据的长度
    __le32 middle_len;/* bytes in middle payload */
    __le32 data_len;  /* bytes of data payload */数据
    __le16 data_off;  /* sender: include full offset;
         receiver: mask against ~PAGE_MASK */
    
    struct ceph_entity_inst src, orig_src;
    __le32 reserved;
    __le32 crc;       /* header crc32c */
    } __attribute__ ((packed));
    
    struct ceph_msg_header {
    __le64 seq;       /* message seq# for this session */
    __le64 tid;       /* transaction id */
    __le16 type;      /* message type */
    __le16 priority;  /* priority.  higher value == higher priority */
    __le16 version;   /* version of message encoding */
    
    __le32 front_len; /* bytes in main payload */
    __le32 middle_len;/* bytes in middle payload */
    __le32 data_len;  /* bytes of data payload */
    __le16 data_off;  /* sender: include full offset;
         receiver: mask against ~PAGE_MASK */
    
    struct ceph_entity_name src;
    
    /* oldest code we think can decode this.  unknown if zero. */
    __le16 compat_version;
    __le16 reserved;
    __le32 crc;       /* header crc32c */
    } __attribute__ ((packed));
    
    #define CEPH_MSG_PRIO_LOW     64
    #define CEPH_MSG_PRIO_DEFAULT 127
    #define CEPH_MSG_PRIO_HIGH    196
    #define CEPH_MSG_PRIO_HIGHEST 255
    (9)数据有效载荷结构
    struct ceph_msg_footer {
    __le32 front_crc, middle_crc, data_crc;
    __u8 flags;
    } __attribute__ ((packed));
    
    #define CEPH_MSG_FOOTER_COMPLETE  (1<<0)   /* msg wasn't aborted */
    #define CEPH_MSG_FOOTER_NOCRC     (1<<1)   /* no data crc */
  • 相关阅读:
    MySQL Unable to convert MySQL datetime value to System.DateTime 解决方案
    Zend 无限试用
    SQL 触发器
    C# 多线程示例
    JS 实现打印
    apache开启.htaccess
    MySQL 安装包下载教程
    js系列(10)js的运用(二)
    js系列(9)js的运用(一)
    js系列(8)简介
  • 原文地址:https://www.cnblogs.com/bbsno1/p/3258360.html
Copyright © 2011-2022 走看看