diff --git a/internal/services/command_service_ec.go b/internal/services/command_service_ec.go index 2974398..973243d 100644 --- a/internal/services/command_service_ec.go +++ b/internal/services/command_service_ec.go @@ -97,55 +97,3 @@ func (svc *Service) CreateEcObject(msg *coormsg.CreateEcObject) (*coormsg.Create return ramsg.ReplyOK(coormsg.NewCreateObjectResp(objID)) } - -//func (service *Service) ECWrite(msg *coormsg.ECWriteCommand) *coormsg.PreUploadResp { -// panic("not implement yet!") - -/* - //jh:根据command中的UserId查询用户节点权限表,返回用户可用的NodeIp - //kx:根据command中的ecName,得到ecN,然后从jh查到的NodeIp中选择ecN个,赋值给Ips - //jh:完成对象表、对象编码块表的插入(对象编码块表的Hash字段先不插入) - //返回消息 - //查询用户可用的节点IP - nodes, err := service.db.GetUserNodes(msg.Body.UserID) - if err != nil { - log.Warnf("query user nodes failed, err: %s", err.Error()) - return ramsg.NewCoorWriteRespFailed(errorcode.OPERATION_FAILED, "query user nodes failed") - } - - ecid := msg.Body.ECName - ecPolicies := *utils.GetEcPolicy() - ecPolicy := ecPolicies[ecid] - ecN := ecPolicy.GetN() - - if len(nodes) < ecN { - log.Warnf("user nodes are not enough, err: %s", err.Error()) - return ramsg.NewCoorWriteRespFailed(errorcode.OPERATION_FAILED, "user nodes are not enough") - } - - ids := make([]int, ecN) - ips := make([]string, ecN) - //随机选取numRep个nodeIp - start := utils.GetRandInt(len(nodes)) - for i := 0; i < ecN; i++ { - index := (start + i) % len(nodes) - ids[i] = nodes[index].NodeID - ips[i] = nodes[index].IP - } - - // TODO 参考RepWrite,将创建EC对象的逻辑移动到WriteECHash中,并合成成一个事务 - //根据BucketName查询BucketID - BucketID := Query_BucketID(msg.Body.BucketName) - if BucketID == -1 { - // TODO 日志 - return ramsg.NewCoorWriteRespFailed(errorcode.OPERATION_FAILED, fmt.Sprintf("bucket id not found for %s", msg.Body.BucketName)) - } - //对象表插入Insert_Cache - ObjectID := Insert_EcObject(msg.Body.ObjectName, BucketID, msg.Body.FileSize, msg.Body.ECName) - //对象编码块表插入,hash暂时为空 - for i := 0; i < ecN; i++ { - Insert_EcObjectBlock(ObjectID, i) - } - return ramsg.NewCoorWriteRespOK(ids, ips) -*/ -//} diff --git a/internal/services/object.go b/internal/services/object.go index 3938b3a..6371c5a 100644 --- a/internal/services/object.go +++ b/internal/services/object.go @@ -82,7 +82,7 @@ func (svc *Service) PreDownloadObject(msg *coormsg.PreDownloadObject) (*coormsg. ramsg.NewRespRepRedundancyData(objectRep.FileHash, respNodes), )) - }else{ + } else { // TODO 参考上面进行重写 ecName := object.Redundancy blocks, err := svc.db.QueryObjectBlock(object.ObjectID) @@ -95,9 +95,9 @@ func (svc *Service) PreDownloadObject(msg *coormsg.PreDownloadObject) (*coormsg. //查询纠删码参数 ec, err := svc.db.Ec().GetEc(svc.db.SQLCtx(), ecName) ecc := ramsg.NewEc(ec.EcID, ec.Name, ec.EcK, ec.EcN) - //查询每个编码块存放的所有节点 + //查询每个编码块存放的所有节点 respNodes := make([][]ramsg.RespNode, len(blocks)) - for i:=0; i