Protocol Buffer 时间类型定义

时间:2025-05-15 09:13:22
ProtoBuf3中新增了TimeStamp类型,使用示例如下:
syntax = "proto3";
import public "google/protobuf/";

message MonitorData { 
 Time = 1;//收集时间
int64 LongValue = 2;//监控值--长整型
string MetaData = 3;//监控元数据ID
string Ins = 4;//监控元数据实例
string Host = 5;//应用节点ApplicationNode
string ServiceHost = 6;//服务宿主ApplicationHost
string StringValue = 7;//监控值--字符串
double DoubleValue = 8;//监控值--浮点型
map<string, string> Tags = 9;//监控数据维度字典 
map<string, string> Ext = 10;//扩展属性
string Cluster = 11;//集群
string RowKey = 12;//RowKey
}

 根据.proto文件生成对应的Java类:

D:\tmp> -I=d:/tmp --java_out=d:/tmp d:/tmp/

 注:protoc下载:

/maven2/com/google/protobuf/protoc/