From ce95fd4f207f3ee3b3dbaa1b5724453f160a6c54 Mon Sep 17 00:00:00 2001 From: "cai.zhang" Date: Fri, 4 Sep 2020 11:25:20 +0800 Subject: [PATCH] Add interface for generated_ids Signed-off-by: cai.zhang --- go.sum | 15 ++ proxy/generate_entity_ids/client/getIds.go | 45 ++++ proxy/generate_entity_ids/collect_result.go | 45 ++++ .../proto/generate_id.pb.go | 210 ++++++++++++++++++ .../proto/generate_id.proto | 24 ++ .../server/generate_entity_ids.go | 63 ++++++ proxy/proxy_test/generate_entity_id.go | 1 - proxy/src/version.h | 6 +- storage/internal/minio/minio_storeEngine.go | 2 +- 9 files changed, 406 insertions(+), 5 deletions(-) create mode 100644 proxy/generate_entity_ids/client/getIds.go create mode 100644 proxy/generate_entity_ids/collect_result.go create mode 100644 proxy/generate_entity_ids/proto/generate_id.pb.go create mode 100644 proxy/generate_entity_ids/proto/generate_id.proto create mode 100644 proxy/generate_entity_ids/server/generate_entity_ids.go delete mode 100644 proxy/proxy_test/generate_entity_id.go diff --git a/go.sum b/go.sum index 1002365542..c26465eeae 100644 --- a/go.sum +++ b/go.sum @@ -44,6 +44,10 @@ github.com/apache/pulsar/pulsar-client-go v0.0.0-20200901051823-800681aaa9af h1: github.com/apache/pulsar/pulsar-client-go v0.0.0-20200901051823-800681aaa9af/go.mod h1:QdYxU2iG99VVU6cvoBRkCgkazfJSL9WwPZ20PZR6aUk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +<<<<<<< HEAD +github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= +======= +>>>>>>> 2a377a76d1925a76a011a2364b47f4a199f003bf github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -53,6 +57,7 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa v0.0.1 h1:r3ncXbtIiad9owWu22r8ryYogBEV9NbJykk8k6K+u0w= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa h1:OaNxuTZr7kxeODyLWsRMC+OD03aFUH+mW6r2d+MWa5Y= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/coreos/bbolt v1.3.2 h1:wZwiHHUieZCquLkDL0B8UhzreNWsPHooDAG3q34zk0s= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= @@ -172,11 +177,13 @@ github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 h1:Iju5GlWwrvL6UBg4zJJt3btmonfrMlCDdsejg4CZE7c= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4 h1:z53tR0945TRRQO/fLEVPI6SMv7ZflF0TEaTAoU7tOzg= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.8.1 h1:VNUuLKyFcJ5IektwBKcZU4J5GJKEt+Odb8dl1d61BGQ= github.com/grpc-ecosystem/grpc-gateway v1.8.1/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-gateway v1.9.5 h1:UImYN5qQ8tuGpGE16ZmjvcTtTw24zw1QAp/SlnNrZhI= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -272,6 +279,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.2 h1:awm861/B8OKDd2I/6o1dy3ra4BamzKhYOiGItCeZ740= github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= +github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -279,10 +287,12 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCb github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 h1:PnBWHBf+6L0jOqq0gIVUe6Yk0/QMZ640k6NvkxcBf+8= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.1 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6Kw= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a h1:9a8MnZMP0X2nLJdBg+pBmGgkJlSaKC2KaQmTCk1XDtE= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/protocolbuffers/protobuf v3.13.0+incompatible h1:omZA3Tuq+U2kJ2uMuqMR9c1VO5qLEgZ19m9878fXNtg= github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M= @@ -302,6 +312,7 @@ github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/pflag v1.0.1 h1:aCvUg6QPl3ibpQUxyLkrEkCHtPqYJL4x9AuhqVqFis4= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -332,6 +343,10 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.etcd.io/bbolt v1.3.2 h1:Z/90sZLPOeCy2PwprqkFa25PdkusRzaj9P8zm/KNyvk= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0= +go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= +go.etcd.io/etcd v0.5.0-alpha.5 h1:VOolFSo3XgsmnYDLozjvZ6JL6AAwIDu1Yx1y+4EYLDo= +go.etcd.io/etcd v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738 h1:lWF4f9Nypl1ZqSb4gLeh/DGvBYVaUYHuiB93teOmwgc= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/etcd v0.5.0-alpha.5 h1:VOolFSo3XgsmnYDLozjvZ6JL6AAwIDu1Yx1y+4EYLDo= go.etcd.io/etcd v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= diff --git a/proxy/generate_entity_ids/client/getIds.go b/proxy/generate_entity_ids/client/getIds.go new file mode 100644 index 0000000000..0dc9cefa80 --- /dev/null +++ b/proxy/generate_entity_ids/client/getIds.go @@ -0,0 +1,45 @@ +package main + +import ( + "context" + "fmt" + pb "github.com/czs007/suvlim/proxy/generate_entity_ids/proto" + "google.golang.org/grpc" + "log" + "time" +) + +const ( + address = "localhost:10087" +) + + +func getIds(length int64) { + con, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock()) + if err != nil { + log.Fatalf("did not connect: %v", err) + } + + defer con.Close() + c := pb.NewGreeterClient(con) + + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + r, err := c.GetEntityID(ctx, &pb.Request{Length: length}) + if err != nil { + log.Fatalf("could not greet: %v", err) + } + fmt.Println("+++++++++++++++++++++++++++++++++++++") + fmt.Println(r.GetIds()) + +} + + +func main() { + + go getIds(100) + + go getIds(100) + + time.Sleep(3 * time.Second) +} diff --git a/proxy/generate_entity_ids/collect_result.go b/proxy/generate_entity_ids/collect_result.go new file mode 100644 index 0000000000..7874778066 --- /dev/null +++ b/proxy/generate_entity_ids/collect_result.go @@ -0,0 +1,45 @@ +package generate_entity_ids + +import ( + "context" + "fmt" + "github.com/apache/pulsar/pulsar-client-go/pulsar" + "log" + "time" +) + +func CollectResult(clientNum int, topicName string) [][]byte { + client, err := pulsar.NewClient(pulsar.ClientOptions{ + URL: "pulsar://localhost:6650", + }) + if err != nil { + log.Fatal(err) + } + defer client.Close() + + consumer, err := client.Subscribe(pulsar.ConsumerOptions{ + Topic: topicName + "-partition-" + string(clientNum), + SubscriptionName: "subName", + }) + if err != nil { + log.Fatal(err) + } + defer consumer.Close() + + var result [][]byte + ctx, canc := context.WithTimeout(context.Background(), 5*time.Second) + msg, err := consumer.Receive(ctx) + if err != nil { + log.Fatal(err) + } + + err = consumer.Ack(msg) + if err != nil{ + log.Fatal(err) + } + result = append(result, msg.Payload()) + fmt.Println("consumer receive the message successful!") + canc() + + return result +} \ No newline at end of file diff --git a/proxy/generate_entity_ids/proto/generate_id.pb.go b/proxy/generate_entity_ids/proto/generate_id.pb.go new file mode 100644 index 0000000000..20cda69727 --- /dev/null +++ b/proxy/generate_entity_ids/proto/generate_id.pb.go @@ -0,0 +1,210 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: generate_id.proto + +package generate_entity_ids + +import ( + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +// The request message containing the user's name. +type Request struct { + Length int64 `protobuf:"varint,1,opt,name=length,proto3" json:"length,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Request) Reset() { *m = Request{} } +func (m *Request) String() string { return proto.CompactTextString(m) } +func (*Request) ProtoMessage() {} +func (*Request) Descriptor() ([]byte, []int) { + return fileDescriptor_72f50f761a21563e, []int{0} +} + +func (m *Request) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Request.Unmarshal(m, b) +} +func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Request.Marshal(b, m, deterministic) +} +func (m *Request) XXX_Merge(src proto.Message) { + xxx_messageInfo_Request.Merge(m, src) +} +func (m *Request) XXX_Size() int { + return xxx_messageInfo_Request.Size(m) +} +func (m *Request) XXX_DiscardUnknown() { + xxx_messageInfo_Request.DiscardUnknown(m) +} + +var xxx_messageInfo_Request proto.InternalMessageInfo + +func (m *Request) GetLength() int64 { + if m != nil { + return m.Length + } + return 0 +} + +// The response message containing the greetings +type Reply struct { + Ids []int64 `protobuf:"varint,1,rep,packed,name=ids,proto3" json:"ids,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Reply) Reset() { *m = Reply{} } +func (m *Reply) String() string { return proto.CompactTextString(m) } +func (*Reply) ProtoMessage() {} +func (*Reply) Descriptor() ([]byte, []int) { + return fileDescriptor_72f50f761a21563e, []int{1} +} + +func (m *Reply) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Reply.Unmarshal(m, b) +} +func (m *Reply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Reply.Marshal(b, m, deterministic) +} +func (m *Reply) XXX_Merge(src proto.Message) { + xxx_messageInfo_Reply.Merge(m, src) +} +func (m *Reply) XXX_Size() int { + return xxx_messageInfo_Reply.Size(m) +} +func (m *Reply) XXX_DiscardUnknown() { + xxx_messageInfo_Reply.DiscardUnknown(m) +} + +var xxx_messageInfo_Reply proto.InternalMessageInfo + +func (m *Reply) GetIds() []int64 { + if m != nil { + return m.Ids + } + return nil +} + +func init() { + proto.RegisterType((*Request)(nil), "generate_entity_ids.Request") + proto.RegisterType((*Reply)(nil), "generate_entity_ids.Reply") +} + +func init() { proto.RegisterFile("generate_id.proto", fileDescriptor_72f50f761a21563e) } + +var fileDescriptor_72f50f761a21563e = []byte{ + // 183 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4c, 0x4f, 0xcd, 0x4b, + 0x2d, 0x4a, 0x2c, 0x49, 0x8d, 0xcf, 0x4c, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, + 0x0b, 0xa5, 0xe6, 0x95, 0x64, 0x96, 0x54, 0xc6, 0x67, 0xa6, 0x14, 0x2b, 0x29, 0x72, 0xb1, 0x07, + 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x08, 0x89, 0x71, 0xb1, 0xe5, 0xa4, 0xe6, 0xa5, 0x97, 0x64, + 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x30, 0x07, 0x41, 0x79, 0x4a, 0x92, 0x5c, 0xac, 0x41, 0xa9, 0x05, + 0x39, 0x95, 0x42, 0x02, 0x5c, 0xcc, 0x99, 0x29, 0xc5, 0x12, 0x8c, 0x0a, 0xcc, 0x1a, 0xcc, 0x41, + 0x20, 0xa6, 0x51, 0x08, 0x17, 0xbb, 0x7b, 0x51, 0x6a, 0x6a, 0x49, 0x6a, 0x91, 0x90, 0x27, 0x17, + 0xb7, 0x7b, 0x6a, 0x89, 0x2b, 0xd8, 0x64, 0x4f, 0x17, 0x21, 0x19, 0x3d, 0x2c, 0xb6, 0xe9, 0x41, + 0xad, 0x92, 0x92, 0xc2, 0x21, 0x5b, 0x90, 0x53, 0xa9, 0xc4, 0xe0, 0x64, 0xce, 0x25, 0x94, 0x99, + 0xaf, 0x97, 0x5e, 0x54, 0x90, 0x0c, 0x57, 0xe6, 0xe9, 0xe2, 0xc4, 0xe5, 0x0e, 0x67, 0x07, 0x30, + 0x46, 0x61, 0xf3, 0x4c, 0x12, 0x1b, 0xd8, 0xa3, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xeb, + 0x7c, 0x51, 0xda, 0xfd, 0x00, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// GreeterClient is the client API for Greeter service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type GreeterClient interface { + // Sends a greeting + GetEntityID(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Reply, error) +} + +type greeterClient struct { + cc *grpc.ClientConn +} + +func NewGreeterClient(cc *grpc.ClientConn) GreeterClient { + return &greeterClient{cc} +} + +func (c *greeterClient) GetEntityID(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Reply, error) { + out := new(Reply) + err := c.cc.Invoke(ctx, "/generate_entity_ids.Greeter/GetEntityID", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// GreeterServer is the server API for Greeter service. +type GreeterServer interface { + // Sends a greeting + GetEntityID(context.Context, *Request) (*Reply, error) +} + +// UnimplementedGreeterServer can be embedded to have forward compatible implementations. +type UnimplementedGreeterServer struct { +} + +func (*UnimplementedGreeterServer) GetEntityID(ctx context.Context, req *Request) (*Reply, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetEntityID not implemented") +} + +func RegisterGreeterServer(s *grpc.Server, srv GreeterServer) { + s.RegisterService(&_Greeter_serviceDesc, srv) +} + +func _Greeter_GetEntityID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Request) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GreeterServer).GetEntityID(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/generate_entity_ids.Greeter/GetEntityID", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GreeterServer).GetEntityID(ctx, req.(*Request)) + } + return interceptor(ctx, in, info, handler) +} + +var _Greeter_serviceDesc = grpc.ServiceDesc{ + ServiceName: "generate_entity_ids.Greeter", + HandlerType: (*GreeterServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetEntityID", + Handler: _Greeter_GetEntityID_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "generate_id.proto", +} diff --git a/proxy/generate_entity_ids/proto/generate_id.proto b/proxy/generate_entity_ids/proto/generate_id.proto new file mode 100644 index 0000000000..6a43af4894 --- /dev/null +++ b/proxy/generate_entity_ids/proto/generate_id.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; + +option go_package = "generate_entity_ids"; +option java_multiple_files = true; +option java_package = "io.grpc.generateID"; +option java_outer_classname = "GenerateID"; + +package generate_entity_ids; + +// The greeting service definition. +service Greeter { + // Sends a greeting + rpc GetEntityID (Request) returns (Reply) {} +} + +// The request message containing the user's name. +message Request { + int64 length = 1; +} + +// The response message containing the greetings +message Reply { + repeated int64 ids = 1; +} diff --git a/proxy/generate_entity_ids/server/generate_entity_ids.go b/proxy/generate_entity_ids/server/generate_entity_ids.go new file mode 100644 index 0000000000..21c7fc9831 --- /dev/null +++ b/proxy/generate_entity_ids/server/generate_entity_ids.go @@ -0,0 +1,63 @@ +package main + +import ( + "context" + pb "github.com/czs007/suvlim/proxy/generate_entity_ids/proto" + "google.golang.org/grpc" + "log" + "net" + "sync" + "time" +) + +var ( + currentID int64 = 0 +) + + +const ( + port = ":10087" +) + +type server struct { + pb.UnimplementedGreeterServer +} + + +func (s *server) GetEntityID(ctx context.Context, in *pb.Request) (*pb.Reply, error) { + var mutex sync.Mutex + var ids []int64 + + length := in.Length + for i := int64(0); i < length; i++ { + go func() { + mutex.Lock() + ids = append(ids, currentID) + currentID++ + mutex.Unlock() + }() + + } + + for{ + if int64(len(ids)) < length { + time.Sleep(time.Second) + } else { + break + } + } + + return &pb.Reply{Ids: ids}, nil +} + +func main() { + listen, err := net.Listen("tcp", port) + if err != nil{ + log.Fatalf("failed to listen: %v", err) + } + s := grpc.NewServer() + pb.RegisterGreeterServer(s, &server{}) + if err := s.Serve(listen); err != nil{ + log.Fatalf("failed to serve: %v", err) + } +} \ No newline at end of file diff --git a/proxy/proxy_test/generate_entity_id.go b/proxy/proxy_test/generate_entity_id.go deleted file mode 100644 index 7ecefa5be6..0000000000 --- a/proxy/proxy_test/generate_entity_id.go +++ /dev/null @@ -1 +0,0 @@ -package proxy_test diff --git a/proxy/src/version.h b/proxy/src/version.h index 03da6b7074..b4c615cfbb 100644 --- a/proxy/src/version.h +++ b/proxy/src/version.h @@ -10,6 +10,6 @@ // or implied. See the License for the specific language governing permissions and limitations under the License. #define MILVUS_VERSION "0.10.0" -#define BUILD_TYPE "Release" -#define BUILD_TIME "2020-09-02 17:22.14" -#define LAST_COMMIT_ID "9598d59d297b62bb5327043817e64c74ae9b25df" +#define BUILD_TYPE "Debug" +#define BUILD_TIME "2020-09-03 16:41.13" +#define LAST_COMMIT_ID "a97d3e925e993f4a2a7409a9734dcc788f109767" diff --git a/storage/internal/minio/minio_storeEngine.go b/storage/internal/minio/minio_storeEngine.go index 620e72b66b..0a62eb8dd4 100644 --- a/storage/internal/minio/minio_storeEngine.go +++ b/storage/internal/minio/minio_storeEngine.go @@ -8,7 +8,7 @@ import ( . "github.com/czs007/suvlim/storage/pkg/types" ) -var bucketName = "zcbucket" +var bucketName = "zilliz" type minioStore struct { client *minio.Client