cxorm commented on a change in pull request #6: URL: https://github.com/apache/ozone-go/pull/6#discussion_r614805865
########## File path: api/datanode/datanode.go ########## @@ -0,0 +1,261 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package datanode + +import ( + "context" + "errors" + "fmt" + dnapi "github.com/apache/ozone-go/api/proto/datanode" + "github.com/apache/ozone-go/api/proto/hdds" + "github.com/apache/ozone-go/api/proto/ratis" + "google.golang.org/grpc" + "io" + "strconv" +) + +type ChunkInfo struct { + Name string + Offset uint64 + Len uint64 +} + +type DatanodeClient struct { + ratisClient *ratis.RaftClientProtocolService_UnorderedClient + ratisReceiver chan ratis.RaftClientReplyProto + standaloneClient *dnapi.XceiverClientProtocolService_SendClient + standaloneReceiver chan dnapi.ContainerCommandResponseProto + + ctx context.Context + datanodes []*hdds.DatanodeDetailsProto + currentDatanode hdds.DatanodeDetailsProto + grpcConnection *grpc.ClientConn + pipelineId *hdds.PipelineID + memberIndex int +} + +func (dn *DatanodeClient) GetCurrentDnUUid() *string { + uid := dn.currentDatanode.GetUuid() + return &uid +} + +func (dnClient *DatanodeClient) connectToNext() error { + if dnClient.grpcConnection != nil { + dnClient.grpcConnection.Close() + } + dnClient.memberIndex = dnClient.memberIndex + 1 + if dnClient.memberIndex == len(dnClient.datanodes) { + dnClient.memberIndex = 0 + } + selectedDatanode := dnClient.datanodes[dnClient.memberIndex] + dnClient.currentDatanode = *selectedDatanode + + standalonePort := 0 + for _, port := range dnClient.currentDatanode.Ports { + if *port.Name == "STANDALONE" { + standalonePort = int(*port.Value) + } + } + + address := *dnClient.currentDatanode.IpAddress + ":" + strconv.Itoa(standalonePort) + println("Connecting to the " + address) + conn, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock()) + if err != nil { + return err + } + + dnClient.ratisReceiver = make(chan ratis.RaftClientReplyProto) + dnClient.standaloneReceiver = make(chan dnapi.ContainerCommandResponseProto) + + client, err := dnapi.NewXceiverClientProtocolServiceClient(conn).Send(dnClient.ctx) + dnClient.standaloneClient = &client + // + //client, err := ratis.NewRaftClientProtocolServiceClient(conn).Unordered(dnClient.ctx) + //if err != nil { + // panic(err) + //} + //dnClient.ratisClient = &client + //go dnClient.RaftReceiver() Review comment: Should we leave this snippet ? (IMHO we could do it in the future, but I'm fine with leaving it here and go ahead.) ########## File path: api/bucket.go ########## @@ -0,0 +1,31 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package api + +import "github.com/apache/ozone-go/api/common" + +func (ozoneClient *OzoneClient) CreateBucket(volume string, bucket string) error { + return ozoneClient.OmClient.CreateBucket(volume, bucket) +} + +func (ozoneClient *OzoneClient) GetBucket(volume string, bucket string) (common.Bucket, error) { + return ozoneClient.OmClient.GetBucket(volume, bucket) +} + +func (ozoneClient *OzoneClient) ListBucket(volume string) ([]common.Bucket, error) { + return ozoneClient.OmClient.ListBucket(volume) + +} Review comment: Nit: No newline at end of file. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
