From db892b8d26e429ea2d92c17750762349c1cdb0e4 Mon Sep 17 00:00:00 2001 From: devad Date: Tue, 25 Jul 2023 11:18:42 +0800 Subject: [PATCH] :recycle: refactor RegisterParticipant impl Signed-off-by: devad Former-commit-id: 61f39aa179f89624701fb6b90f9b3ffe34fcd444 --- go.mod | 2 +- go.sum | 4 + model/scnodelabelinfomodel.go | 27 -- model/scnodelabelinfomodel_gen.go | 122 --------- model/scparticipantlabelinfomodel.go | 27 ++ model/scparticipantlabelinfomodel_gen.go | 123 +++++++++ .../participantservice/participantservice.go | 2 +- rpc/client/pcmcore/pcmcore.go | 2 +- rpc/etc/pcmcore.yaml | 4 +- .../registerparticipantlogic.go | 56 ++-- rpc/internal/svc/servicecontext.go | 10 +- rpc/pb/pcmCore.proto | 25 +- rpc/pcmCore/pcmCore.pb.go | 244 +++++++++--------- 13 files changed, 348 insertions(+), 300 deletions(-) delete mode 100755 model/scnodelabelinfomodel.go delete mode 100755 model/scnodelabelinfomodel_gen.go create mode 100755 model/scparticipantlabelinfomodel.go create mode 100755 model/scparticipantlabelinfomodel_gen.go diff --git a/go.mod b/go.mod index 6b71d047..b534d116 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,6 @@ require ( gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20230714013255-149a9b428b28 gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20230714012611-c66005610d0c gitlink.org.cn/jcce-pcm/pcm-participant-slurm v0.0.0-20230714015940-004100bfa168 - gitlink.org.cn/jcce-pcm/utils v0.0.0-20230724072501-2a0519bd57bd google.golang.org/grpc v1.56.2 google.golang.org/protobuf v1.31.0 gorm.io/driver/mysql v1.5.1 @@ -91,6 +90,7 @@ require ( github.com/prometheus/procfs v0.9.0 // indirect github.com/segmentio/kafka-go v0.4.38 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect + gitlink.org.cn/jcce-pcm/utils v0.0.0-20230725025032-ac218fa4db06 // indirect go.etcd.io/etcd/api/v3 v3.5.9 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect go.etcd.io/etcd/client/v3 v3.5.9 // indirect diff --git a/go.sum b/go.sum index 46dcc0c3..154f1cb8 100644 --- a/go.sum +++ b/go.sum @@ -1039,6 +1039,10 @@ gitlink.org.cn/jcce-pcm/pcm-participant-slurm v0.0.0-20230714015940-004100bfa168 gitlink.org.cn/jcce-pcm/pcm-participant-slurm v0.0.0-20230714015940-004100bfa168/go.mod h1:lY3jXmmMvC7j4Q2ogliThURWp9c1XCToSCnRkdc1aW8= gitlink.org.cn/jcce-pcm/utils v0.0.0-20230724072501-2a0519bd57bd h1:A9i6TPZ58OwycgWNQpIMrjSIMK8lXmmakig7IkonrVA= gitlink.org.cn/jcce-pcm/utils v0.0.0-20230724072501-2a0519bd57bd/go.mod h1:zTa+selMe02jZ3u6Ij1rTF2CrGd2ZqzqyMQ/FwhdpvY= +gitlink.org.cn/jcce-pcm/utils v0.0.0-20230725025032-ac218fa4db06 h1:mjt1ynoyzyowzm+pUXZKptoSHqjGyzw6uNCQzeHo1/g= +gitlink.org.cn/jcce-pcm/utils v0.0.0-20230725025032-ac218fa4db06/go.mod h1:u8PTlBpzUyOlbQJgfSiutq91q/JtrJIQiPNDe4S/pGs= +gitlink.org.cn/jcce-pcm/utils v0.0.1 h1:3PH93Z/JFTH5JRO9MFf3dD1Gnd12aGiIIViWBlQGuhE= +gitlink.org.cn/jcce-pcm/utils v0.0.1/go.mod h1:5cwaaqM0+HK5GXVbYozGlWvgwoUby0KytdvhbwQW1ks= go.etcd.io/etcd/api/v3 v3.5.5/go.mod h1:KFtNaxGDw4Yx/BA4iPPwevUTAuqcsPxzyX8PHydchN8= go.etcd.io/etcd/api/v3 v3.5.7/go.mod h1:9qew1gCdDDLu+VwmeG+iFpL+QlpHTo7iubavdVDgCAA= go.etcd.io/etcd/api/v3 v3.5.9 h1:4wSsluwyTbGGmyjJktOf3wFQoTBIURXHnq9n/G/JQHs= diff --git a/model/scnodelabelinfomodel.go b/model/scnodelabelinfomodel.go deleted file mode 100755 index 49fa9f55..00000000 --- a/model/scnodelabelinfomodel.go +++ /dev/null @@ -1,27 +0,0 @@ -package model - -import ( - "github.com/zeromicro/go-zero/core/stores/cache" - "github.com/zeromicro/go-zero/core/stores/sqlx" -) - -var _ ScNodeLabelInfoModel = (*customScNodeLabelInfoModel)(nil) - -type ( - // ScNodeLabelInfoModel is an interface to be customized, add more methods here, - // and implement the added methods in customScNodeLabelInfoModel. - ScNodeLabelInfoModel interface { - scNodeLabelInfoModel - } - - customScNodeLabelInfoModel struct { - *defaultScNodeLabelInfoModel - } -) - -// NewScNodeLabelInfoModel returns a model for the database table. -func NewScNodeLabelInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) ScNodeLabelInfoModel { - return &customScNodeLabelInfoModel{ - defaultScNodeLabelInfoModel: newScNodeLabelInfoModel(conn, c, opts...), - } -} diff --git a/model/scnodelabelinfomodel_gen.go b/model/scnodelabelinfomodel_gen.go deleted file mode 100755 index 60a84ea7..00000000 --- a/model/scnodelabelinfomodel_gen.go +++ /dev/null @@ -1,122 +0,0 @@ -// Code generated by goctl. DO NOT EDIT. - -package model - -import ( - "context" - "database/sql" - "fmt" - "strings" - "time" - - "github.com/zeromicro/go-zero/core/stores/builder" - "github.com/zeromicro/go-zero/core/stores/cache" - "github.com/zeromicro/go-zero/core/stores/sqlc" - "github.com/zeromicro/go-zero/core/stores/sqlx" - "github.com/zeromicro/go-zero/core/stringx" -) - -var ( - scNodeLabelInfoFieldNames = builder.RawFieldNames(&ScNodeLabelInfo{}) - scNodeLabelInfoRows = strings.Join(scNodeLabelInfoFieldNames, ",") - scNodeLabelInfoRowsExpectAutoSet = strings.Join(stringx.Remove(scNodeLabelInfoFieldNames, "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",") - scNodeLabelInfoRowsWithPlaceHolder = strings.Join(stringx.Remove(scNodeLabelInfoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?" - - cachePcmScNodeLabelInfoIdPrefix = "cache:pcm:scNodeLabelInfo:id:" -) - -type ( - scNodeLabelInfoModel interface { - Insert(ctx context.Context, data *ScNodeLabelInfo) (sql.Result, error) - FindOne(ctx context.Context, id int64) (*ScNodeLabelInfo, error) - Update(ctx context.Context, data *ScNodeLabelInfo) error - Delete(ctx context.Context, id int64) error - } - - defaultScNodeLabelInfoModel struct { - sqlc.CachedConn - table string - } - - ScNodeLabelInfo struct { - Id int64 `db:"id"` // id - Label string `db:"label"` // 类型 - NodeId int64 `db:"node_id"` // 节点id - DeletedFlag int64 `db:"deleted_flag"` // 是否删除 - CreatedBy sql.NullInt64 `db:"created_by"` // 创建人 - CreatedTime time.Time `db:"created_time"` // 创建时间 - UpdatedBy sql.NullInt64 `db:"updated_by"` // 更新人 - UpdatedTime sql.NullTime `db:"updated_time"` // 更新时间 - } -) - -func newScNodeLabelInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultScNodeLabelInfoModel { - return &defaultScNodeLabelInfoModel{ - CachedConn: sqlc.NewConn(conn, c, opts...), - table: "`sc_node_label_info`", - } -} - -func (m *defaultScNodeLabelInfoModel) withSession(session sqlx.Session) *defaultScNodeLabelInfoModel { - return &defaultScNodeLabelInfoModel{ - CachedConn: m.CachedConn.WithSession(session), - table: "`sc_node_label_info`", - } -} - -func (m *defaultScNodeLabelInfoModel) Delete(ctx context.Context, id int64) error { - pcmScNodeLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodeLabelInfoIdPrefix, id) - _, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("delete from %s where `id` = ?", m.table) - return conn.ExecCtx(ctx, query, id) - }, pcmScNodeLabelInfoIdKey) - return err -} - -func (m *defaultScNodeLabelInfoModel) FindOne(ctx context.Context, id int64) (*ScNodeLabelInfo, error) { - pcmScNodeLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodeLabelInfoIdPrefix, id) - var resp ScNodeLabelInfo - err := m.QueryRowCtx(ctx, &resp, pcmScNodeLabelInfoIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error { - query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scNodeLabelInfoRows, m.table) - return conn.QueryRowCtx(ctx, v, query, id) - }) - switch err { - case nil: - return &resp, nil - case sqlc.ErrNotFound: - return nil, ErrNotFound - default: - return nil, err - } -} - -func (m *defaultScNodeLabelInfoModel) Insert(ctx context.Context, data *ScNodeLabelInfo) (sql.Result, error) { - pcmScNodeLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodeLabelInfoIdPrefix, data.Id) - ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?)", m.table, scNodeLabelInfoRowsExpectAutoSet) - return conn.ExecCtx(ctx, query, data.Id, data.Label, data.NodeId, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime) - }, pcmScNodeLabelInfoIdKey) - return ret, err -} - -func (m *defaultScNodeLabelInfoModel) Update(ctx context.Context, data *ScNodeLabelInfo) error { - pcmScNodeLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodeLabelInfoIdPrefix, data.Id) - _, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, scNodeLabelInfoRowsWithPlaceHolder) - return conn.ExecCtx(ctx, query, data.Label, data.NodeId, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime, data.Id) - }, pcmScNodeLabelInfoIdKey) - return err -} - -func (m *defaultScNodeLabelInfoModel) formatPrimary(primary any) string { - return fmt.Sprintf("%s%v", cachePcmScNodeLabelInfoIdPrefix, primary) -} - -func (m *defaultScNodeLabelInfoModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error { - query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scNodeLabelInfoRows, m.table) - return conn.QueryRowCtx(ctx, v, query, primary) -} - -func (m *defaultScNodeLabelInfoModel) tableName() string { - return m.table -} diff --git a/model/scparticipantlabelinfomodel.go b/model/scparticipantlabelinfomodel.go new file mode 100755 index 00000000..d5dd99bc --- /dev/null +++ b/model/scparticipantlabelinfomodel.go @@ -0,0 +1,27 @@ +package model + +import ( + "github.com/zeromicro/go-zero/core/stores/cache" + "github.com/zeromicro/go-zero/core/stores/sqlx" +) + +var _ ScParticipantLabelInfoModel = (*customScParticipantLabelInfoModel)(nil) + +type ( + // ScParticipantLabelInfoModel is an interface to be customized, add more methods here, + // and implement the added methods in customScParticipantLabelInfoModel. + ScParticipantLabelInfoModel interface { + scParticipantLabelInfoModel + } + + customScParticipantLabelInfoModel struct { + *defaultScParticipantLabelInfoModel + } +) + +// NewScParticipantLabelInfoModel returns a model for the database table. +func NewScParticipantLabelInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) ScParticipantLabelInfoModel { + return &customScParticipantLabelInfoModel{ + defaultScParticipantLabelInfoModel: newScParticipantLabelInfoModel(conn, c, opts...), + } +} diff --git a/model/scparticipantlabelinfomodel_gen.go b/model/scparticipantlabelinfomodel_gen.go new file mode 100755 index 00000000..406dde92 --- /dev/null +++ b/model/scparticipantlabelinfomodel_gen.go @@ -0,0 +1,123 @@ +// Code generated by goctl. DO NOT EDIT. + +package model + +import ( + "context" + "database/sql" + "fmt" + "strings" + "time" + + "github.com/zeromicro/go-zero/core/stores/builder" + "github.com/zeromicro/go-zero/core/stores/cache" + "github.com/zeromicro/go-zero/core/stores/sqlc" + "github.com/zeromicro/go-zero/core/stores/sqlx" + "github.com/zeromicro/go-zero/core/stringx" +) + +var ( + scParticipantLabelInfoFieldNames = builder.RawFieldNames(&ScParticipantLabelInfo{}) + scParticipantLabelInfoRows = strings.Join(scParticipantLabelInfoFieldNames, ",") + scParticipantLabelInfoRowsExpectAutoSet = strings.Join(stringx.Remove(scParticipantLabelInfoFieldNames, "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",") + scParticipantLabelInfoRowsWithPlaceHolder = strings.Join(stringx.Remove(scParticipantLabelInfoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?" + + cachePcmScParticipantLabelInfoIdPrefix = "cache:pcm:scParticipantLabelInfo:id:" +) + +type ( + scParticipantLabelInfoModel interface { + Insert(ctx context.Context, data *ScParticipantLabelInfo) (sql.Result, error) + FindOne(ctx context.Context, id int64) (*ScParticipantLabelInfo, error) + Update(ctx context.Context, data *ScParticipantLabelInfo) error + Delete(ctx context.Context, id int64) error + } + + defaultScParticipantLabelInfoModel struct { + sqlc.CachedConn + table string + } + + ScParticipantLabelInfo struct { + Id int64 `db:"id"` // id + Label string `db:"label"` // 标签 + ParticipantId int64 `db:"participant_id"` // participant id + Metadata sql.NullString `db:"metadata"` // 元数据 + DeletedFlag int64 `db:"deleted_flag"` // 是否删除 + CreatedBy sql.NullInt64 `db:"created_by"` // 创建人 + CreatedTime time.Time `db:"created_time"` // 创建时间 + UpdatedBy sql.NullInt64 `db:"updated_by"` // 更新人 + UpdatedTime sql.NullTime `db:"updated_time"` // 更新时间 + } +) + +func newScParticipantLabelInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultScParticipantLabelInfoModel { + return &defaultScParticipantLabelInfoModel{ + CachedConn: sqlc.NewConn(conn, c, opts...), + table: "`sc_participant_label_info`", + } +} + +func (m *defaultScParticipantLabelInfoModel) withSession(session sqlx.Session) *defaultScParticipantLabelInfoModel { + return &defaultScParticipantLabelInfoModel{ + CachedConn: m.CachedConn.WithSession(session), + table: "`sc_participant_label_info`", + } +} + +func (m *defaultScParticipantLabelInfoModel) Delete(ctx context.Context, id int64) error { + pcmScParticipantLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantLabelInfoIdPrefix, id) + _, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { + query := fmt.Sprintf("delete from %s where `id` = ?", m.table) + return conn.ExecCtx(ctx, query, id) + }, pcmScParticipantLabelInfoIdKey) + return err +} + +func (m *defaultScParticipantLabelInfoModel) FindOne(ctx context.Context, id int64) (*ScParticipantLabelInfo, error) { + pcmScParticipantLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantLabelInfoIdPrefix, id) + var resp ScParticipantLabelInfo + err := m.QueryRowCtx(ctx, &resp, pcmScParticipantLabelInfoIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error { + query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scParticipantLabelInfoRows, m.table) + return conn.QueryRowCtx(ctx, v, query, id) + }) + switch err { + case nil: + return &resp, nil + case sqlc.ErrNotFound: + return nil, ErrNotFound + default: + return nil, err + } +} + +func (m *defaultScParticipantLabelInfoModel) Insert(ctx context.Context, data *ScParticipantLabelInfo) (sql.Result, error) { + pcmScParticipantLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantLabelInfoIdPrefix, data.Id) + ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { + query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, scParticipantLabelInfoRowsExpectAutoSet) + return conn.ExecCtx(ctx, query, data.Id, data.Label, data.ParticipantId, data.Metadata, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime) + }, pcmScParticipantLabelInfoIdKey) + return ret, err +} + +func (m *defaultScParticipantLabelInfoModel) Update(ctx context.Context, data *ScParticipantLabelInfo) error { + pcmScParticipantLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantLabelInfoIdPrefix, data.Id) + _, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { + query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, scParticipantLabelInfoRowsWithPlaceHolder) + return conn.ExecCtx(ctx, query, data.Label, data.ParticipantId, data.Metadata, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime, data.Id) + }, pcmScParticipantLabelInfoIdKey) + return err +} + +func (m *defaultScParticipantLabelInfoModel) formatPrimary(primary any) string { + return fmt.Sprintf("%s%v", cachePcmScParticipantLabelInfoIdPrefix, primary) +} + +func (m *defaultScParticipantLabelInfoModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error { + query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scParticipantLabelInfoRows, m.table) + return conn.QueryRowCtx(ctx, v, query, primary) +} + +func (m *defaultScParticipantLabelInfoModel) tableName() string { + return m.table +} diff --git a/rpc/client/participantservice/participantservice.go b/rpc/client/participantservice/participantservice.go index e91849e1..f545e243 100644 --- a/rpc/client/participantservice/participantservice.go +++ b/rpc/client/participantservice/participantservice.go @@ -18,8 +18,8 @@ type ( HpcInfo = pcmCore.HpcInfo InfoListReq = pcmCore.InfoListReq InfoListResp = pcmCore.InfoListResp - NodeLabel = pcmCore.NodeLabel NodePhyInfo = pcmCore.NodePhyInfo + ParticipantLabel = pcmCore.ParticipantLabel ParticipantPhyReq = pcmCore.ParticipantPhyReq ParticipantPhyResp = pcmCore.ParticipantPhyResp ParticipantTenant = pcmCore.ParticipantTenant diff --git a/rpc/client/pcmcore/pcmcore.go b/rpc/client/pcmcore/pcmcore.go index 4dc65dba..ef287894 100644 --- a/rpc/client/pcmcore/pcmcore.go +++ b/rpc/client/pcmcore/pcmcore.go @@ -18,8 +18,8 @@ type ( HpcInfo = pcmCore.HpcInfo InfoListReq = pcmCore.InfoListReq InfoListResp = pcmCore.InfoListResp - NodeLabel = pcmCore.NodeLabel NodePhyInfo = pcmCore.NodePhyInfo + ParticipantLabel = pcmCore.ParticipantLabel ParticipantPhyReq = pcmCore.ParticipantPhyReq ParticipantPhyResp = pcmCore.ParticipantPhyResp ParticipantTenant = pcmCore.ParticipantTenant diff --git a/rpc/etc/pcmcore.yaml b/rpc/etc/pcmcore.yaml index 5f1389af..65c58022 100644 --- a/rpc/etc/pcmcore.yaml +++ b/rpc/etc/pcmcore.yaml @@ -4,7 +4,7 @@ NacosConfig: ServerConfigs: # - IpAddr: 127.0.0.1 # Port: 8848 - - IpAddr: 10.101.15.7 + - IpAddr: nacos.jcce.dev Port: 8848 ClientConfig: NamespaceId: test @@ -12,4 +12,4 @@ NacosConfig: NotLoadCacheAtStart: true LogDir: CacheDir: - LogLevel: debug \ No newline at end of file + LogLevel: info \ No newline at end of file diff --git a/rpc/internal/logic/participantservice/registerparticipantlogic.go b/rpc/internal/logic/participantservice/registerparticipantlogic.go index c772c5a8..d164850d 100644 --- a/rpc/internal/logic/participantservice/registerparticipantlogic.go +++ b/rpc/internal/logic/participantservice/registerparticipantlogic.go @@ -29,15 +29,25 @@ func NewRegisterParticipantLogic(ctx context.Context, svcCtx *svc.ServiceContext // RegisterParticipant Participant注册接口 func (l *RegisterParticipantLogic) RegisterParticipant(in *pcmCore.ParticipantPhyReq) (*pcmCore.ParticipantPhyResp, error) { //判断ParticipantId是否存在 - db := l.svcCtx.DbEngin - if db.Error != nil { - return nil, db.Error - } + db := l.svcCtx.DbEngin.Begin() + // 执行回滚或者提交操作 + defer func() { + if p := recover(); p != nil { + db.Rollback() + logx.Error(p) + } else if db.Error != nil { + logx.Info("rollback") + db.Rollback() + } else { + db = db.Commit() + logx.Info("commit success") + } + }() participantInfo := &model.ScParticipantPhyInfo{} tool.Convert(in, participantInfo) if in.ParticipantId == 0 { var err error - participantInfo.Id, err = tool.GenSnowflakeID(l.svcCtx.Config.SnowflakeConf.MachineId) + participantInfo.Id = tool.GenSnowflakeID() if err != nil { logx.Errorf("生成id错误 err:", err) } @@ -48,24 +58,38 @@ func (l *RegisterParticipantLogic) RegisterParticipant(in *pcmCore.ParticipantPh //保存participant静态信息 result := db.Save(&participantInfo) //保存节点信息 - nodeInfo := &model.ScNodePhyInfo{} + nodeList := make([]*model.ScNodePhyInfo, 0) for _, info := range in.NodeInfo { - var err error + nodeInfo := &model.ScNodePhyInfo{} tool.Convert(info, nodeInfo) nodeInfo.CreatedTime = time.Now() nodeInfo.ParticipantId = participantInfo.Id - nodeInfo.Id, err = tool.GenSnowflakeID(l.svcCtx.Config.SnowflakeConf.MachineId) - if err != nil { - logx.Errorf("生成id错误 err:", err) - } - result = db.Save(nodeInfo) - if result.Error != nil { - logx.Errorf("orm err:", result.Error) - return &pcmCore.ParticipantPhyResp{}, nil + if nodeInfo.Id == 0 { + nodeInfo.Id = tool.GenSnowflakeID() } + nodeList = append(nodeList, nodeInfo) } + result = db.Save(&nodeList) + //保存标签信息 + labelList := make([]*model.ScParticipantLabelInfo, 0) + for _, label := range in.LabelInfo { + labelInfo := &model.ScParticipantLabelInfo{} + tool.Convert(label, labelInfo) + labelInfo.CreatedTime = time.Now() + labelInfo.ParticipantId = participantInfo.Id + if labelInfo.Id == 0 { + labelInfo.Id = tool.GenSnowflakeID() + } + labelList = append(labelList, labelInfo) + } + result = db.Save(&labelList) if result.Error != nil { logx.Errorf("orm err:", result.Error) + return &pcmCore.ParticipantPhyResp{}, nil } - return &pcmCore.ParticipantPhyResp{}, nil + return &pcmCore.ParticipantPhyResp{ + Code: 200, + Msg: "ok", + ParticipantId: participantInfo.Id, + }, nil } diff --git a/rpc/internal/svc/servicecontext.go b/rpc/internal/svc/servicecontext.go index 927fb984..4b4a9860 100644 --- a/rpc/internal/svc/servicecontext.go +++ b/rpc/internal/svc/servicecontext.go @@ -3,7 +3,9 @@ package svc import ( _ "github.com/go-sql-driver/mysql" "github.com/robfig/cron/v3" + "github.com/zeromicro/go-zero/core/logx" "gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/internal/config" + "gitlink.org.cn/jcce-pcm/utils/tool" "gorm.io/driver/mysql" "gorm.io/gorm" "gorm.io/gorm/logger" @@ -22,8 +24,14 @@ func NewServiceContext(c config.Config) *ServiceContext { NamingStrategy: schema.NamingStrategy{ SingularTable: true, // 使用单数表名,启用该选项,此时,`User` 的表名应该是 `t_user` }, - Logger: logger.Default.LogMode(logger.Info), + Logger: logger.Default.LogMode(logger.Error), }) + //添加snowflake支持 + err := tool.InitSnowflake(c.SnowflakeConf.MachineId) + if err != nil { + logx.Errorf("InitSnowflake err: ", err) + panic("InitSnowflake err") + } return &ServiceContext{ Cron: cron.New(cron.WithSeconds()), Config: c, diff --git a/rpc/pb/pcmCore.proto b/rpc/pb/pcmCore.proto index b6105ccd..8401d385 100644 --- a/rpc/pb/pcmCore.proto +++ b/rpc/pb/pcmCore.proto @@ -95,13 +95,13 @@ service pcmCore { } // participantTenant 租户信息 -message participantTenant{ +message ParticipantTenant{ string tenantName = 1; //租户名称 } -// 节点标签 -message NodeLabel { - string id = 1; //id +// 集群标签 +message ParticipantLabel { + int64 id = 1; //id string label = 2; //标签名称 } @@ -114,7 +114,7 @@ enum MessageStatus { message ParticipantPhyResp { int64 code = 1; string msg = 2; - string participantId = 3; //participant 唯一标识 + int64 participantId = 3; //participant 唯一标识 } //participantPhy 静态信息 @@ -132,17 +132,18 @@ message ParticipantPhyReq { string tenantName = 12; //租户名称 repeated NodePhyInfo nodeInfo = 13; //节点信息 int64 participantId = 14; //participant id + repeated ParticipantLabel labelInfo = 15; //标签信息 } // nodePhyInfo 节点信息 message NodePhyInfo { - string nodeName = 1; //节点名称 - string osName = 2; //系统名称 - string osVersion = 3; //系统版本 - string archType = 4; //架构类型 - string archName = 5; //架构名称 - string archFreq = 6; //架构频率 - repeated NodeLabel nodeLabel = 7; //节点标签 + int64 id = 1; + string nodeName = 2; //节点名称 + string osName = 3; //系统名称 + string osVersion = 4; //系统版本 + string archType = 5; //架构类型 + string archName = 6; //架构名称 + string archFreq = 7; //架构频率 } // participant 参与者 diff --git a/rpc/pcmCore/pcmCore.pb.go b/rpc/pcmCore/pcmCore.pb.go index a68cd006..25b84128 100644 --- a/rpc/pcmCore/pcmCore.pb.go +++ b/rpc/pcmCore/pcmCore.pb.go @@ -854,18 +854,18 @@ func (x *ParticipantTenant) GetTenantName() string { return "" } -// 节点标签 -type NodeLabel struct { +// 集群标签 +type ParticipantLabel struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` //id + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` //id Label string `protobuf:"bytes,2,opt,name=label,proto3" json:"label,omitempty"` //标签名称 } -func (x *NodeLabel) Reset() { - *x = NodeLabel{} +func (x *ParticipantLabel) Reset() { + *x = ParticipantLabel{} if protoimpl.UnsafeEnabled { mi := &file_pb_pcmCore_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -873,13 +873,13 @@ func (x *NodeLabel) Reset() { } } -func (x *NodeLabel) String() string { +func (x *ParticipantLabel) String() string { return protoimpl.X.MessageStringOf(x) } -func (*NodeLabel) ProtoMessage() {} +func (*ParticipantLabel) ProtoMessage() {} -func (x *NodeLabel) ProtoReflect() protoreflect.Message { +func (x *ParticipantLabel) ProtoReflect() protoreflect.Message { mi := &file_pb_pcmCore_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -891,19 +891,19 @@ func (x *NodeLabel) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use NodeLabel.ProtoReflect.Descriptor instead. -func (*NodeLabel) Descriptor() ([]byte, []int) { +// Deprecated: Use ParticipantLabel.ProtoReflect.Descriptor instead. +func (*ParticipantLabel) Descriptor() ([]byte, []int) { return file_pb_pcmCore_proto_rawDescGZIP(), []int{8} } -func (x *NodeLabel) GetId() string { +func (x *ParticipantLabel) GetId() int64 { if x != nil { return x.Id } - return "" + return 0 } -func (x *NodeLabel) GetLabel() string { +func (x *ParticipantLabel) GetLabel() string { if x != nil { return x.Label } @@ -917,7 +917,7 @@ type ParticipantPhyResp struct { Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` - ParticipantId string `protobuf:"bytes,3,opt,name=participantId,proto3" json:"participantId,omitempty"` //participant 唯一标识 + ParticipantId int64 `protobuf:"varint,3,opt,name=participantId,proto3" json:"participantId,omitempty"` //participant 唯一标识 } func (x *ParticipantPhyResp) Reset() { @@ -966,11 +966,11 @@ func (x *ParticipantPhyResp) GetMsg() string { return "" } -func (x *ParticipantPhyResp) GetParticipantId() string { +func (x *ParticipantPhyResp) GetParticipantId() int64 { if x != nil { return x.ParticipantId } - return "" + return 0 } // participantPhy 静态信息 @@ -979,19 +979,20 @@ type ParticipantPhyReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Host string `protobuf:"bytes,2,opt,name=host,proto3" json:"host,omitempty"` //host - Port string `protobuf:"bytes,3,opt,name=port,proto3" json:"port,omitempty"` //端口号 - NetworkType string `protobuf:"bytes,4,opt,name=networkType,proto3" json:"networkType,omitempty"` //集群网络类型 - NetworkBandwidth string `protobuf:"bytes,5,opt,name=networkBandwidth,proto3" json:"networkBandwidth,omitempty"` //集群网络带宽 - StorageType string `protobuf:"bytes,6,opt,name=storageType,proto3" json:"storageType,omitempty"` //集群存储类型 - StorageSpace string `protobuf:"bytes,7,opt,name=storageSpace,proto3" json:"storageSpace,omitempty"` //集群存储空间 - StorageAvailSpace string `protobuf:"bytes,8,opt,name=storageAvailSpace,proto3" json:"storageAvailSpace,omitempty"` //集群存储可用空间 - StorageBandwidth string `protobuf:"bytes,9,opt,name=storageBandwidth,proto3" json:"storageBandwidth,omitempty"` //集群存储带宽 - Type string `protobuf:"bytes,10,opt,name=type,proto3" json:"type,omitempty"` //参与者类型:0-数算集群;1-智算集群;2-超算集群 - TenantId int64 `protobuf:"varint,11,opt,name=tenantId,proto3" json:"tenantId,omitempty"` //租户id - TenantName string `protobuf:"bytes,12,opt,name=tenantName,proto3" json:"tenantName,omitempty"` //租户名称 - NodeInfo []*NodePhyInfo `protobuf:"bytes,13,rep,name=nodeInfo,proto3" json:"nodeInfo,omitempty"` //节点信息 - ParticipantId int64 `protobuf:"varint,14,opt,name=participantId,proto3" json:"participantId,omitempty"` //participant id + Host string `protobuf:"bytes,2,opt,name=host,proto3" json:"host,omitempty"` //host + Port string `protobuf:"bytes,3,opt,name=port,proto3" json:"port,omitempty"` //端口号 + NetworkType string `protobuf:"bytes,4,opt,name=networkType,proto3" json:"networkType,omitempty"` //集群网络类型 + NetworkBandwidth string `protobuf:"bytes,5,opt,name=networkBandwidth,proto3" json:"networkBandwidth,omitempty"` //集群网络带宽 + StorageType string `protobuf:"bytes,6,opt,name=storageType,proto3" json:"storageType,omitempty"` //集群存储类型 + StorageSpace string `protobuf:"bytes,7,opt,name=storageSpace,proto3" json:"storageSpace,omitempty"` //集群存储空间 + StorageAvailSpace string `protobuf:"bytes,8,opt,name=storageAvailSpace,proto3" json:"storageAvailSpace,omitempty"` //集群存储可用空间 + StorageBandwidth string `protobuf:"bytes,9,opt,name=storageBandwidth,proto3" json:"storageBandwidth,omitempty"` //集群存储带宽 + Type string `protobuf:"bytes,10,opt,name=type,proto3" json:"type,omitempty"` //参与者类型:0-数算集群;1-智算集群;2-超算集群 + TenantId int64 `protobuf:"varint,11,opt,name=tenantId,proto3" json:"tenantId,omitempty"` //租户id + TenantName string `protobuf:"bytes,12,opt,name=tenantName,proto3" json:"tenantName,omitempty"` //租户名称 + NodeInfo []*NodePhyInfo `protobuf:"bytes,13,rep,name=nodeInfo,proto3" json:"nodeInfo,omitempty"` //节点信息 + ParticipantId int64 `protobuf:"varint,14,opt,name=participantId,proto3" json:"participantId,omitempty"` //participant id + LabelInfo []*ParticipantLabel `protobuf:"bytes,15,rep,name=labelInfo,proto3" json:"labelInfo,omitempty"` //标签信息 } func (x *ParticipantPhyReq) Reset() { @@ -1117,19 +1118,26 @@ func (x *ParticipantPhyReq) GetParticipantId() int64 { return 0 } +func (x *ParticipantPhyReq) GetLabelInfo() []*ParticipantLabel { + if x != nil { + return x.LabelInfo + } + return nil +} + // nodePhyInfo 节点信息 type NodePhyInfo struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - NodeName string `protobuf:"bytes,1,opt,name=nodeName,proto3" json:"nodeName,omitempty"` //节点名称 - OsName string `protobuf:"bytes,2,opt,name=osName,proto3" json:"osName,omitempty"` //系统名称 - OsVersion string `protobuf:"bytes,3,opt,name=osVersion,proto3" json:"osVersion,omitempty"` //系统版本 - ArchType string `protobuf:"bytes,4,opt,name=archType,proto3" json:"archType,omitempty"` //架构类型 - ArchName string `protobuf:"bytes,5,opt,name=archName,proto3" json:"archName,omitempty"` //架构名称 - ArchFreq string `protobuf:"bytes,6,opt,name=archFreq,proto3" json:"archFreq,omitempty"` //架构频率 - NodeLabel []*NodeLabel `protobuf:"bytes,7,rep,name=nodeLabel,proto3" json:"nodeLabel,omitempty"` //节点标签 + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + NodeName string `protobuf:"bytes,2,opt,name=nodeName,proto3" json:"nodeName,omitempty"` //节点名称 + OsName string `protobuf:"bytes,3,opt,name=osName,proto3" json:"osName,omitempty"` //系统名称 + OsVersion string `protobuf:"bytes,4,opt,name=osVersion,proto3" json:"osVersion,omitempty"` //系统版本 + ArchType string `protobuf:"bytes,5,opt,name=archType,proto3" json:"archType,omitempty"` //架构类型 + ArchName string `protobuf:"bytes,6,opt,name=archName,proto3" json:"archName,omitempty"` //架构名称 + ArchFreq string `protobuf:"bytes,7,opt,name=archFreq,proto3" json:"archFreq,omitempty"` //架构频率 } func (x *NodePhyInfo) Reset() { @@ -1164,6 +1172,13 @@ func (*NodePhyInfo) Descriptor() ([]byte, []int) { return file_pb_pcmCore_proto_rawDescGZIP(), []int{11} } +func (x *NodePhyInfo) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + func (x *NodePhyInfo) GetNodeName() string { if x != nil { return x.NodeName @@ -1206,13 +1221,6 @@ func (x *NodePhyInfo) GetArchFreq() string { return "" } -func (x *NodePhyInfo) GetNodeLabel() []*NodeLabel { - if x != nil { - return x.NodeLabel - } - return nil -} - var File_pb_pcmCore_proto protoreflect.FileDescriptor var file_pb_pcmCore_proto_rawDesc = []byte{ @@ -1333,82 +1341,84 @@ var file_pb_pcmCore_proto_rawDesc = []byte{ 0x73, 0x74, 0x12, 0x2f, 0x0a, 0x0a, 0x41, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x41, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x4c, - 0x69, 0x73, 0x74, 0x22, 0x33, 0x0a, 0x11, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, + 0x69, 0x73, 0x74, 0x22, 0x33, 0x0a, 0x11, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x54, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x65, - 0x6e, 0x61, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x31, 0x0a, 0x09, 0x4e, 0x6f, 0x64, 0x65, - 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x22, 0x60, 0x0a, 0x12, 0x50, - 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, 0x79, 0x52, 0x65, 0x73, - 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, - 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, - 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x22, 0xd1, 0x03, - 0x0a, 0x11, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, 0x79, - 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x6e, - 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2a, 0x0a, - 0x10, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x42, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, - 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x42, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x74, 0x6f, - 0x72, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, - 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x73, - 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x12, - 0x2c, 0x0a, 0x11, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x53, - 0x70, 0x61, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x74, 0x6f, 0x72, - 0x61, 0x67, 0x65, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x53, 0x70, 0x61, 0x63, 0x65, 0x12, 0x2a, 0x0a, - 0x10, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x42, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, - 0x68, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, - 0x42, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, - 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, - 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x65, 0x6e, - 0x61, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, - 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x30, 0x0a, 0x08, 0x6e, 0x6f, 0x64, - 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x63, - 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x50, 0x68, 0x79, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x24, 0x0a, 0x0d, 0x70, - 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x0e, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, - 0x64, 0x22, 0xe5, 0x01, 0x0a, 0x0b, 0x4e, 0x6f, 0x64, 0x65, 0x50, 0x68, 0x79, 0x49, 0x6e, 0x66, - 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x6e, 0x61, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x38, 0x0a, 0x10, 0x50, 0x61, 0x72, 0x74, + 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, + 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x61, 0x62, + 0x65, 0x6c, 0x22, 0x60, 0x0a, 0x12, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, + 0x74, 0x50, 0x68, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, + 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x24, + 0x0a, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, + 0x6e, 0x74, 0x49, 0x64, 0x22, 0x8a, 0x04, 0x0a, 0x11, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, + 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, 0x79, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, + 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, + 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x6f, + 0x72, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x54, 0x79, 0x70, + 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x42, + 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, + 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x42, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, + 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x70, 0x61, + 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, + 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x12, 0x2c, 0x0a, 0x11, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, + 0x65, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x53, 0x70, 0x61, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x11, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x53, + 0x70, 0x61, 0x63, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x42, + 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, + 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x42, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, + 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, 0x64, + 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, 0x64, + 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x0c, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, + 0x12, 0x30, 0x0a, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x0d, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x4e, 0x6f, 0x64, + 0x65, 0x50, 0x68, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x6e, + 0x66, 0x6f, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, + 0x74, 0x49, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, + 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x37, 0x0a, 0x09, 0x6c, 0x61, 0x62, 0x65, + 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x63, + 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, + 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x52, 0x09, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x49, 0x6e, 0x66, + 0x6f, 0x22, 0xc3, 0x01, 0x0a, 0x0b, 0x4e, 0x6f, 0x64, 0x65, 0x50, 0x68, 0x79, 0x49, 0x6e, 0x66, + 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, - 0x06, 0x6f, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, + 0x06, 0x6f, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6f, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x73, 0x56, 0x65, 0x72, 0x73, + 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x72, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x72, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, - 0x1a, 0x0a, 0x08, 0x61, 0x72, 0x63, 0x68, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x72, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x1a, 0x0a, 0x08, 0x61, 0x72, 0x63, 0x68, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x72, 0x63, 0x68, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x61, - 0x72, 0x63, 0x68, 0x46, 0x72, 0x65, 0x71, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, - 0x72, 0x63, 0x68, 0x46, 0x72, 0x65, 0x71, 0x12, 0x30, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x4c, - 0x61, 0x62, 0x65, 0x6c, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x63, 0x6d, - 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x52, 0x09, - 0x6e, 0x6f, 0x64, 0x65, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x2a, 0x33, 0x0a, 0x0d, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x41, - 0x49, 0x4c, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, - 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x02, 0x32, 0x7b, - 0x0a, 0x07, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x12, 0x37, 0x0a, 0x08, 0x53, 0x79, 0x6e, - 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, - 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x63, - 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, - 0x73, 0x70, 0x12, 0x37, 0x0a, 0x08, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, - 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, - 0x74, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x49, - 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x32, 0x66, 0x0a, 0x12, 0x70, - 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x50, 0x0a, 0x13, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x50, 0x61, 0x72, - 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x12, 0x1a, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, - 0x72, 0x65, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, - 0x79, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x50, - 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, 0x79, 0x52, 0x65, 0x73, - 0x70, 0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2f, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x63, 0x68, 0x46, 0x72, 0x65, 0x71, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, + 0x72, 0x63, 0x68, 0x46, 0x72, 0x65, 0x71, 0x2a, 0x33, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x41, 0x49, 0x4c, + 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x01, 0x12, + 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x02, 0x32, 0x7b, 0x0a, 0x07, + 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x12, 0x37, 0x0a, 0x08, 0x53, 0x79, 0x6e, 0x63, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x79, + 0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43, + 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, + 0x12, 0x37, 0x0a, 0x08, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x2e, 0x70, + 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, + 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x66, + 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x32, 0x66, 0x0a, 0x12, 0x70, 0x61, 0x72, + 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x50, 0x0a, 0x13, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x50, 0x61, 0x72, 0x74, 0x69, + 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x12, 0x1a, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, + 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, 0x79, 0x52, + 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x61, 0x72, + 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, 0x79, 0x52, 0x65, 0x73, 0x70, 0x22, + 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2f, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1434,8 +1444,8 @@ var file_pb_pcmCore_proto_goTypes = []interface{}{ (*SyncInfoResp)(nil), // 5: pcmCore.SyncInfoResp (*InfoListReq)(nil), // 6: pcmCore.InfoListReq (*InfoListResp)(nil), // 7: pcmCore.InfoListResp - (*ParticipantTenant)(nil), // 8: pcmCore.participantTenant - (*NodeLabel)(nil), // 9: pcmCore.NodeLabel + (*ParticipantTenant)(nil), // 8: pcmCore.ParticipantTenant + (*ParticipantLabel)(nil), // 9: pcmCore.ParticipantLabel (*ParticipantPhyResp)(nil), // 10: pcmCore.ParticipantPhyResp (*ParticipantPhyReq)(nil), // 11: pcmCore.ParticipantPhyReq (*NodePhyInfo)(nil), // 12: pcmCore.NodePhyInfo @@ -1448,7 +1458,7 @@ var file_pb_pcmCore_proto_depIdxs = []int32{ 3, // 4: pcmCore.InfoListResp.CloudInfoList:type_name -> pcmCore.CloudInfo 2, // 5: pcmCore.InfoListResp.AiInfoList:type_name -> pcmCore.AiInfo 12, // 6: pcmCore.ParticipantPhyReq.nodeInfo:type_name -> pcmCore.NodePhyInfo - 9, // 7: pcmCore.NodePhyInfo.nodeLabel:type_name -> pcmCore.NodeLabel + 9, // 7: pcmCore.ParticipantPhyReq.labelInfo:type_name -> pcmCore.ParticipantLabel 1, // 8: pcmCore.pcmCore.SyncInfo:input_type -> pcmCore.SyncInfoReq 6, // 9: pcmCore.pcmCore.InfoList:input_type -> pcmCore.InfoListReq 11, // 10: pcmCore.participantService.registerParticipant:input_type -> pcmCore.ParticipantPhyReq @@ -1565,7 +1575,7 @@ func file_pb_pcmCore_proto_init() { } } file_pb_pcmCore_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NodeLabel); i { + switch v := v.(*ParticipantLabel); i { case 0: return &v.state case 1: