diff --git a/adapter/api/wso2/discovery/config/enforcer/claim_mapping.pb.go b/adapter/api/wso2/discovery/config/enforcer/claim_mapping.pb.go deleted file mode 100644 index b2a784bab0..0000000000 --- a/adapter/api/wso2/discovery/config/enforcer/claim_mapping.pb.go +++ /dev/null @@ -1,173 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0 -// protoc v3.6.1 -// source: wso2/discovery/config/enforcer/claim_mapping.proto - -package enforcer - -import ( - proto "github.com/golang/protobuf/proto" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -// Claim mapping model -type ClaimMapping struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Remote claim - RemoteClaim string `protobuf:"bytes,1,opt,name=remoteClaim,proto3" json:"remoteClaim,omitempty"` - // Local claim - LocalClaim string `protobuf:"bytes,2,opt,name=localClaim,proto3" json:"localClaim,omitempty"` -} - -func (x *ClaimMapping) Reset() { - *x = ClaimMapping{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_config_enforcer_claim_mapping_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ClaimMapping) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ClaimMapping) ProtoMessage() {} - -func (x *ClaimMapping) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_config_enforcer_claim_mapping_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ClaimMapping.ProtoReflect.Descriptor instead. -func (*ClaimMapping) Descriptor() ([]byte, []int) { - return file_wso2_discovery_config_enforcer_claim_mapping_proto_rawDescGZIP(), []int{0} -} - -func (x *ClaimMapping) GetRemoteClaim() string { - if x != nil { - return x.RemoteClaim - } - return "" -} - -func (x *ClaimMapping) GetLocalClaim() string { - if x != nil { - return x.LocalClaim - } - return "" -} - -var File_wso2_discovery_config_enforcer_claim_mapping_proto protoreflect.FileDescriptor - -var file_wso2_discovery_config_enforcer_claim_mapping_proto_rawDesc = []byte{ - 0x0a, 0x32, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, - 0x2f, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x5f, 0x6d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, - 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, - 0x72, 0x63, 0x65, 0x72, 0x22, 0x50, 0x0a, 0x0c, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x4d, 0x61, 0x70, - 0x70, 0x69, 0x6e, 0x67, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, 0x6c, - 0x61, 0x69, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x72, 0x65, 0x6d, 0x6f, 0x74, - 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x12, 0x1e, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x43, - 0x6c, 0x61, 0x69, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6c, 0x6f, 0x63, 0x61, - 0x6c, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x42, 0x91, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, - 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, - 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, - 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x11, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x4d, 0x61, 0x70, 0x70, - 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, - 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, - 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, - 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, - 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, -} - -var ( - file_wso2_discovery_config_enforcer_claim_mapping_proto_rawDescOnce sync.Once - file_wso2_discovery_config_enforcer_claim_mapping_proto_rawDescData = file_wso2_discovery_config_enforcer_claim_mapping_proto_rawDesc -) - -func file_wso2_discovery_config_enforcer_claim_mapping_proto_rawDescGZIP() []byte { - file_wso2_discovery_config_enforcer_claim_mapping_proto_rawDescOnce.Do(func() { - file_wso2_discovery_config_enforcer_claim_mapping_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_config_enforcer_claim_mapping_proto_rawDescData) - }) - return file_wso2_discovery_config_enforcer_claim_mapping_proto_rawDescData -} - -var file_wso2_discovery_config_enforcer_claim_mapping_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_wso2_discovery_config_enforcer_claim_mapping_proto_goTypes = []interface{}{ - (*ClaimMapping)(nil), // 0: wso2.discovery.config.enforcer.ClaimMapping -} -var file_wso2_discovery_config_enforcer_claim_mapping_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_wso2_discovery_config_enforcer_claim_mapping_proto_init() } -func file_wso2_discovery_config_enforcer_claim_mapping_proto_init() { - if File_wso2_discovery_config_enforcer_claim_mapping_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_wso2_discovery_config_enforcer_claim_mapping_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ClaimMapping); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_wso2_discovery_config_enforcer_claim_mapping_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_wso2_discovery_config_enforcer_claim_mapping_proto_goTypes, - DependencyIndexes: file_wso2_discovery_config_enforcer_claim_mapping_proto_depIdxs, - MessageInfos: file_wso2_discovery_config_enforcer_claim_mapping_proto_msgTypes, - }.Build() - File_wso2_discovery_config_enforcer_claim_mapping_proto = out.File - file_wso2_discovery_config_enforcer_claim_mapping_proto_rawDesc = nil - file_wso2_discovery_config_enforcer_claim_mapping_proto_goTypes = nil - file_wso2_discovery_config_enforcer_claim_mapping_proto_depIdxs = nil -} diff --git a/adapter/config/types.go b/adapter/config/types.go index af6c2ca1c5..e695932ec6 100644 --- a/adapter/config/types.go +++ b/adapter/config/types.go @@ -109,7 +109,7 @@ type Config struct { KeyStore keystore ListenerTLSEnabled bool - // Envoy Upstream Related Connfigurations + // Envoy Upstream Related Configurations Upstream struct { //UpstreamTLS related Configuration TLS struct { @@ -130,6 +130,7 @@ type Config struct { AuthService authService JwtGenerator jwtGenerator Cache cache + Throttling throttlingConfig JwtIssuer jwtIssuer } @@ -184,6 +185,58 @@ type eventHub struct { } `toml:"jmsConnectionParameters"` } +type throttlingConfig struct { + EnableGlobalEventPublishing bool `toml:"enableGlobalEventPublishing"` + EnableHeaderConditions bool `toml:"enableHeaderConditions"` + EnableQueryParamConditions bool `toml:"enableQueryParamConditions"` + EnableJwtClaimConditions bool `toml:"enableJwtClaimConditions"` + JmsConnectionInitialContextFactory string `toml:"jmsConnectioninitialContextFactory"` + JmsConnectionProviderURL string `toml:"jmsConnectionProviderUrl"` + Publisher binaryPublisher +} + +type binaryPublisher struct { + Username string + Password string + URLGroup []urlGroup `toml:"urlGroup"` + Pool publisherPool + Agent binaryAgent +} + +type urlGroup struct { + ReceiverURLs []string `toml:"receiverURLs"` + AuthURLs []string `toml:"authURLs"` + Type string `toml:"type"` +} + +type publisherPool struct { + MaxIdleDataPublishingAgents int32 + InitIdleObjectDataPublishingAgents int32 + PublisherThreadPoolCoreSize int32 + PublisherThreadPoolMaximumSize int32 + PublisherThreadPoolKeepAliveTime int32 +} + +type binaryAgent struct { + SslEnabledProtocols string + Ciphers string + QueueSize int32 + BatchSize int32 + CorePoolSize int32 + SocketTimeoutMS int32 + MaxPoolSize int32 + KeepAliveTimeInPool int32 + ReconnectionInterval int32 + MaxTransportPoolSize int32 + MaxIdleConnections int32 + EvictionTimePeriod int32 + MinIdleTimeInPool int32 + SecureMaxTransportPoolSize int32 + SecureMaxIdleConnections int32 + SecureEvictionTimePeriod int32 + SecureMinIdleTimeInPool int32 +} + type jwtGenerator struct { Enable bool `toml:"enable"` Encoding string `toml:"encoding"` @@ -223,8 +276,8 @@ type jwtIssuer struct { // JwtUser represents allowed users to generate JWT tokens type JwtUser struct { - Username string `toml:"username"` - Password string `toml:"password"` + Username string `toml:"username"` + Password string `toml:"password"` } // APICtlUser represents registered APICtl Users diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/am_credentials.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/am_credentials.pb.go index d68f40a9e9..e4f66de00b 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/am_credentials.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/am_credentials.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.13.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/am_credentials.proto package enforcer diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/auth_service.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/auth_service.pb.go index c7a2db1601..409ef94ff2 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/auth_service.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/auth_service.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.13.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/auth_service.proto package enforcer diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_publisher.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_publisher.pb.go new file mode 100644 index 0000000000..49f214a69b --- /dev/null +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_publisher.pb.go @@ -0,0 +1,226 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.15.5 +// source: wso2/discovery/config/enforcer/binary_publisher.proto + +package enforcer + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type BinaryPublisher struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` + Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` + UrlGroup []*TMURLGroup `protobuf:"bytes,4,rep,name=urlGroup,proto3" json:"urlGroup,omitempty"` + Pool *PublisherPool `protobuf:"bytes,5,opt,name=pool,proto3" json:"pool,omitempty"` + Agent *ThrottleAgent `protobuf:"bytes,6,opt,name=agent,proto3" json:"agent,omitempty"` +} + +func (x *BinaryPublisher) Reset() { + *x = BinaryPublisher{} + if protoimpl.UnsafeEnabled { + mi := &file_wso2_discovery_config_enforcer_binary_publisher_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BinaryPublisher) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BinaryPublisher) ProtoMessage() {} + +func (x *BinaryPublisher) ProtoReflect() protoreflect.Message { + mi := &file_wso2_discovery_config_enforcer_binary_publisher_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BinaryPublisher.ProtoReflect.Descriptor instead. +func (*BinaryPublisher) Descriptor() ([]byte, []int) { + return file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescGZIP(), []int{0} +} + +func (x *BinaryPublisher) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + +func (x *BinaryPublisher) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +func (x *BinaryPublisher) GetUrlGroup() []*TMURLGroup { + if x != nil { + return x.UrlGroup + } + return nil +} + +func (x *BinaryPublisher) GetPool() *PublisherPool { + if x != nil { + return x.Pool + } + return nil +} + +func (x *BinaryPublisher) GetAgent() *ThrottleAgent { + if x != nil { + return x.Agent + } + return nil +} + +var File_wso2_discovery_config_enforcer_binary_publisher_proto protoreflect.FileDescriptor + +var file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDesc = []byte{ + 0x0a, 0x35, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, + 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, + 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, + 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, + 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x1a, 0x31, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, + 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, + 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2f, 0x74, 0x6d, 0x5f, 0x75, 0x72, 0x6c, 0x5f, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3c, 0x77, 0x73, 0x6f, 0x32, + 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2f, 0x74, 0x68, 0x72, 0x6f, 0x74, + 0x74, 0x6c, 0x65, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x5f, 0x70, 0x6f, + 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x33, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, + 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, + 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, + 0x65, 0x5f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x99, 0x02, + 0x0a, 0x0f, 0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, + 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x46, 0x0a, 0x08, 0x75, 0x72, 0x6c, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x77, 0x73, + 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x54, 0x4d, 0x55, + 0x52, 0x4c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x08, 0x75, 0x72, 0x6c, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x12, 0x41, 0x0a, 0x04, 0x70, 0x6f, 0x6f, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2d, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, + 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, + 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x04, + 0x70, 0x6f, 0x6f, 0x6c, 0x12, 0x43, 0x0a, 0x05, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, + 0x72, 0x63, 0x65, 0x72, 0x2e, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x41, 0x67, 0x65, + 0x6e, 0x74, 0x52, 0x05, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x94, 0x01, 0x0a, 0x2a, 0x6f, 0x72, + 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, + 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, + 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x14, 0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, + 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, + 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, + 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, + 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, + 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescOnce sync.Once + file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescData = file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDesc +) + +func file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescGZIP() []byte { + file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescOnce.Do(func() { + file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescData) + }) + return file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescData +} + +var file_wso2_discovery_config_enforcer_binary_publisher_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_wso2_discovery_config_enforcer_binary_publisher_proto_goTypes = []interface{}{ + (*BinaryPublisher)(nil), // 0: wso2.discovery.config.enforcer.BinaryPublisher + (*TMURLGroup)(nil), // 1: wso2.discovery.config.enforcer.TMURLGroup + (*PublisherPool)(nil), // 2: wso2.discovery.config.enforcer.PublisherPool + (*ThrottleAgent)(nil), // 3: wso2.discovery.config.enforcer.ThrottleAgent +} +var file_wso2_discovery_config_enforcer_binary_publisher_proto_depIdxs = []int32{ + 1, // 0: wso2.discovery.config.enforcer.BinaryPublisher.urlGroup:type_name -> wso2.discovery.config.enforcer.TMURLGroup + 2, // 1: wso2.discovery.config.enforcer.BinaryPublisher.pool:type_name -> wso2.discovery.config.enforcer.PublisherPool + 3, // 2: wso2.discovery.config.enforcer.BinaryPublisher.agent:type_name -> wso2.discovery.config.enforcer.ThrottleAgent + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_wso2_discovery_config_enforcer_binary_publisher_proto_init() } +func file_wso2_discovery_config_enforcer_binary_publisher_proto_init() { + if File_wso2_discovery_config_enforcer_binary_publisher_proto != nil { + return + } + file_wso2_discovery_config_enforcer_tm_url_group_proto_init() + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_init() + file_wso2_discovery_config_enforcer_throttle_agent_proto_init() + if !protoimpl.UnsafeEnabled { + file_wso2_discovery_config_enforcer_binary_publisher_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BinaryPublisher); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_wso2_discovery_config_enforcer_binary_publisher_proto_goTypes, + DependencyIndexes: file_wso2_discovery_config_enforcer_binary_publisher_proto_depIdxs, + MessageInfos: file_wso2_discovery_config_enforcer_binary_publisher_proto_msgTypes, + }.Build() + File_wso2_discovery_config_enforcer_binary_publisher_proto = out.File + file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDesc = nil + file_wso2_discovery_config_enforcer_binary_publisher_proto_goTypes = nil + file_wso2_discovery_config_enforcer_binary_publisher_proto_depIdxs = nil +} diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_throttling.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_throttling.pb.go deleted file mode 100644 index cc8a5f6219..0000000000 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_throttling.pb.go +++ /dev/null @@ -1,236 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0 -// protoc v3.13.0 -// source: wso2/discovery/config/enforcer/binary_throttling.proto - -package enforcer - -import ( - proto "github.com/golang/protobuf/proto" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -type BinaryThrottling struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` - Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` - Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` - UrlGroup []*TMURLGroup `protobuf:"bytes,4,rep,name=urlGroup,proto3" json:"urlGroup,omitempty"` - Publisher *ThrottlePublisher `protobuf:"bytes,5,opt,name=publisher,proto3" json:"publisher,omitempty"` - Agent *ThrottleAgent `protobuf:"bytes,6,opt,name=agent,proto3" json:"agent,omitempty"` -} - -func (x *BinaryThrottling) Reset() { - *x = BinaryThrottling{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_config_enforcer_binary_throttling_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *BinaryThrottling) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BinaryThrottling) ProtoMessage() {} - -func (x *BinaryThrottling) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_config_enforcer_binary_throttling_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use BinaryThrottling.ProtoReflect.Descriptor instead. -func (*BinaryThrottling) Descriptor() ([]byte, []int) { - return file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescGZIP(), []int{0} -} - -func (x *BinaryThrottling) GetEnabled() bool { - if x != nil { - return x.Enabled - } - return false -} - -func (x *BinaryThrottling) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *BinaryThrottling) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -func (x *BinaryThrottling) GetUrlGroup() []*TMURLGroup { - if x != nil { - return x.UrlGroup - } - return nil -} - -func (x *BinaryThrottling) GetPublisher() *ThrottlePublisher { - if x != nil { - return x.Publisher - } - return nil -} - -func (x *BinaryThrottling) GetAgent() *ThrottleAgent { - if x != nil { - return x.Agent - } - return nil -} - -var File_wso2_discovery_config_enforcer_binary_throttling_proto protoreflect.FileDescriptor - -var file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDesc = []byte{ - 0x0a, 0x36, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, - 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x5f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, - 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, - 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x1a, 0x31, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, - 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, - 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2f, 0x74, 0x6d, 0x5f, 0x75, 0x72, 0x6c, 0x5f, - 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x37, 0x77, 0x73, 0x6f, - 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2f, 0x74, 0x68, 0x72, 0x6f, - 0x74, 0x74, 0x6c, 0x65, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x33, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, - 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, - 0x72, 0x63, 0x65, 0x72, 0x2f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x5f, 0x61, 0x67, - 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc2, 0x02, 0x0a, 0x10, 0x42, 0x69, - 0x6e, 0x61, 0x72, 0x79, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x12, 0x18, - 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, - 0x12, 0x46, 0x0a, 0x08, 0x75, 0x72, 0x6c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, - 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, - 0x63, 0x65, 0x72, 0x2e, 0x54, 0x4d, 0x55, 0x52, 0x4c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x08, - 0x75, 0x72, 0x6c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x4f, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, - 0x69, 0x73, 0x68, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x77, 0x73, - 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x54, 0x68, 0x72, - 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x52, 0x09, - 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x12, 0x43, 0x0a, 0x05, 0x61, 0x67, 0x65, - 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, - 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, - 0x6c, 0x65, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x95, - 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, - 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x15, 0x42, - 0x69, 0x6e, 0x61, 0x72, 0x79, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, - 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, - 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, - 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescOnce sync.Once - file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescData = file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDesc -) - -func file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescGZIP() []byte { - file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescOnce.Do(func() { - file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescData) - }) - return file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescData -} - -var file_wso2_discovery_config_enforcer_binary_throttling_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_wso2_discovery_config_enforcer_binary_throttling_proto_goTypes = []interface{}{ - (*BinaryThrottling)(nil), // 0: wso2.discovery.config.enforcer.BinaryThrottling - (*TMURLGroup)(nil), // 1: wso2.discovery.config.enforcer.TMURLGroup - (*ThrottlePublisher)(nil), // 2: wso2.discovery.config.enforcer.ThrottlePublisher - (*ThrottleAgent)(nil), // 3: wso2.discovery.config.enforcer.ThrottleAgent -} -var file_wso2_discovery_config_enforcer_binary_throttling_proto_depIdxs = []int32{ - 1, // 0: wso2.discovery.config.enforcer.BinaryThrottling.urlGroup:type_name -> wso2.discovery.config.enforcer.TMURLGroup - 2, // 1: wso2.discovery.config.enforcer.BinaryThrottling.publisher:type_name -> wso2.discovery.config.enforcer.ThrottlePublisher - 3, // 2: wso2.discovery.config.enforcer.BinaryThrottling.agent:type_name -> wso2.discovery.config.enforcer.ThrottleAgent - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name -} - -func init() { file_wso2_discovery_config_enforcer_binary_throttling_proto_init() } -func file_wso2_discovery_config_enforcer_binary_throttling_proto_init() { - if File_wso2_discovery_config_enforcer_binary_throttling_proto != nil { - return - } - file_wso2_discovery_config_enforcer_tm_url_group_proto_init() - file_wso2_discovery_config_enforcer_throttle_publisher_proto_init() - file_wso2_discovery_config_enforcer_throttle_agent_proto_init() - if !protoimpl.UnsafeEnabled { - file_wso2_discovery_config_enforcer_binary_throttling_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BinaryThrottling); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_wso2_discovery_config_enforcer_binary_throttling_proto_goTypes, - DependencyIndexes: file_wso2_discovery_config_enforcer_binary_throttling_proto_depIdxs, - MessageInfos: file_wso2_discovery_config_enforcer_binary_throttling_proto_msgTypes, - }.Build() - File_wso2_discovery_config_enforcer_binary_throttling_proto = out.File - file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDesc = nil - file_wso2_discovery_config_enforcer_binary_throttling_proto_goTypes = nil - file_wso2_discovery_config_enforcer_binary_throttling_proto_depIdxs = nil -} diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cache.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cache.pb.go index aac2db99c5..9080ab0c7b 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cache.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cache.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.13.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/cache.proto package enforcer diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cert.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cert.pb.go index be81f76082..44f6bbc0a2 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cert.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cert.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.13.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/cert.proto package enforcer diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/claim_mapping.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/claim_mapping.pb.go index b2a784bab0..805304c708 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/claim_mapping.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/claim_mapping.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.6.1 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/claim_mapping.proto package enforcer diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/config.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/config.pb.go index 9500ff200c..206c2832df 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/config.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.13.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/config.proto package enforcer @@ -31,16 +31,16 @@ type Config struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - JwtTokenConfig []*Issuer `protobuf:"bytes,1,rep,name=jwtTokenConfig,proto3" json:"jwtTokenConfig,omitempty"` - Keystore *CertStore `protobuf:"bytes,2,opt,name=keystore,proto3" json:"keystore,omitempty"` - Truststore *CertStore `protobuf:"bytes,3,opt,name=truststore,proto3" json:"truststore,omitempty"` - Eventhub *EventHub `protobuf:"bytes,4,opt,name=eventhub,proto3" json:"eventhub,omitempty"` - AuthService *AuthService `protobuf:"bytes,5,opt,name=authService,proto3" json:"authService,omitempty"` - ApimCredentials *AmCredentials `protobuf:"bytes,6,opt,name=apimCredentials,proto3" json:"apimCredentials,omitempty"` - JwtGenerator *JWTGenerator `protobuf:"bytes,7,opt,name=jwtGenerator,proto3" json:"jwtGenerator,omitempty"` - ThrottlingConfig *Throttling `protobuf:"bytes,8,opt,name=throttlingConfig,proto3" json:"throttlingConfig,omitempty"` - Cache *Cache `protobuf:"bytes,9,opt,name=cache,proto3" json:"cache,omitempty"` - JwtIssuer *JWTIssuer `protobuf:"bytes,10,opt,name=jwtIssuer,proto3" json:"jwtIssuer,omitempty"` + JwtTokenConfig []*Issuer `protobuf:"bytes,1,rep,name=jwtTokenConfig,proto3" json:"jwtTokenConfig,omitempty"` + Keystore *CertStore `protobuf:"bytes,2,opt,name=keystore,proto3" json:"keystore,omitempty"` + Truststore *CertStore `protobuf:"bytes,3,opt,name=truststore,proto3" json:"truststore,omitempty"` + Eventhub *EventHub `protobuf:"bytes,4,opt,name=eventhub,proto3" json:"eventhub,omitempty"` + AuthService *AuthService `protobuf:"bytes,5,opt,name=authService,proto3" json:"authService,omitempty"` + ApimCredentials *AmCredentials `protobuf:"bytes,6,opt,name=apimCredentials,proto3" json:"apimCredentials,omitempty"` + JwtGenerator *JWTGenerator `protobuf:"bytes,7,opt,name=jwtGenerator,proto3" json:"jwtGenerator,omitempty"` + Throttling *Throttling `protobuf:"bytes,8,opt,name=throttling,proto3" json:"throttling,omitempty"` + Cache *Cache `protobuf:"bytes,9,opt,name=cache,proto3" json:"cache,omitempty"` + JwtIssuer *JWTIssuer `protobuf:"bytes,10,opt,name=jwtIssuer,proto3" json:"jwtIssuer,omitempty"` } func (x *Config) Reset() { @@ -124,9 +124,9 @@ func (x *Config) GetJwtGenerator() *JWTGenerator { return nil } -func (x *Config) GetThrottlingConfig() *Throttling { +func (x *Config) GetThrottling() *Throttling { if x != nil { - return x.ThrottlingConfig + return x.Throttling } return nil } @@ -180,7 +180,7 @@ var file_wso2_discovery_config_enforcer_config_proto_rawDesc = []byte{ 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2f, 0x63, 0x61, 0x63, 0x68, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0x88, 0x06, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4e, 0x0a, 0x0e, 0x6a, 0x77, + 0xfc, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4e, 0x0a, 0x0e, 0x6a, 0x77, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, @@ -214,30 +214,30 @@ var file_wso2_discovery_config_enforcer_config_proto_rawDesc = []byte{ 0x32, 0x2c, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x4a, 0x57, 0x54, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x0c, - 0x6a, 0x77, 0x74, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x56, 0x0a, 0x10, - 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, - 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, - 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, - 0x6e, 0x67, 0x52, 0x10, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3b, 0x0a, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, - 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, - 0x72, 0x63, 0x65, 0x72, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x05, 0x63, 0x61, 0x63, 0x68, - 0x65, 0x12, 0x47, 0x0a, 0x09, 0x6a, 0x77, 0x74, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x18, 0x0a, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, - 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, - 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x4a, 0x57, 0x54, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x52, - 0x09, 0x6a, 0x77, 0x74, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x42, 0x8b, 0x01, 0x0a, 0x2a, 0x6f, - 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, + 0x6a, 0x77, 0x74, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x4a, 0x0a, 0x0a, + 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, + 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, + 0x72, 0x2e, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x52, 0x0a, 0x74, 0x68, + 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x12, 0x3b, 0x0a, 0x05, 0x63, 0x61, 0x63, 0x68, + 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, + 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, + 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x05, + 0x63, 0x61, 0x63, 0x68, 0x65, 0x12, 0x47, 0x0a, 0x09, 0x6a, 0x77, 0x74, 0x49, 0x73, 0x73, 0x75, + 0x65, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x0b, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, - 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, - 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, - 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x4a, 0x57, 0x54, 0x49, 0x73, 0x73, + 0x75, 0x65, 0x72, 0x52, 0x09, 0x6a, 0x77, 0x74, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x42, 0x8b, + 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, + 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x0b, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, + 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, + 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, + 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -273,7 +273,7 @@ var file_wso2_discovery_config_enforcer_config_proto_depIdxs = []int32{ 4, // 4: wso2.discovery.config.enforcer.Config.authService:type_name -> wso2.discovery.config.enforcer.AuthService 5, // 5: wso2.discovery.config.enforcer.Config.apimCredentials:type_name -> wso2.discovery.config.enforcer.AmCredentials 6, // 6: wso2.discovery.config.enforcer.Config.jwtGenerator:type_name -> wso2.discovery.config.enforcer.JWTGenerator - 7, // 7: wso2.discovery.config.enforcer.Config.throttlingConfig:type_name -> wso2.discovery.config.enforcer.Throttling + 7, // 7: wso2.discovery.config.enforcer.Config.throttling:type_name -> wso2.discovery.config.enforcer.Throttling 8, // 8: wso2.discovery.config.enforcer.Config.cache:type_name -> wso2.discovery.config.enforcer.Cache 9, // 9: wso2.discovery.config.enforcer.Config.jwtIssuer:type_name -> wso2.discovery.config.enforcer.JWTIssuer 10, // [10:10] is the sub-list for method output_type diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/event_hub.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/event_hub.pb.go index 2deb31cdde..b936919b15 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/event_hub.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/event_hub.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.13.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/event_hub.proto package enforcer diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/issuer.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/issuer.pb.go index 24f3908811..d8eae16696 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/issuer.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/issuer.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.13.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/issuer.proto package enforcer diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jms_connection_params.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jms_connection_params.pb.go index 14fdc19b95..706e43b6d2 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jms_connection_params.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jms_connection_params.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.13.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/jms_connection_params.proto package enforcer diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_generator.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_generator.pb.go index 13944d8fdd..a6cda5f5f5 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_generator.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_generator.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.13.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/jwt_generator.proto package enforcer diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_issuer.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_issuer.pb.go index abbc2b4dc8..11fd4d1d06 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_issuer.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_issuer.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.13.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/jwt_issuer.proto package enforcer diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_user.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_user.pb.go index 0b57b0171a..38c0348f0f 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_user.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_user.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.13.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/jwt_user.proto package enforcer diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/thread_pool.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/thread_pool.pb.go index c55540e414..dafa3bfb34 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/thread_pool.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/thread_pool.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.13.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/thread_pool.proto package enforcer diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_agent.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_agent.pb.go index 742dd4c3da..e667ea2896 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_agent.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_agent.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.13.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/throttle_agent.proto package enforcer @@ -25,6 +25,7 @@ const ( // of the legacy proto package is being used. const _ = proto.ProtoPackageIsVersion4 +// Throttle Agent configuration model type ThrottleAgent struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher.pb.go deleted file mode 100644 index 743faa5894..0000000000 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher.pb.go +++ /dev/null @@ -1,213 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0 -// protoc v3.13.0 -// source: wso2/discovery/config/enforcer/throttle_publisher.proto - -package enforcer - -import ( - proto "github.com/golang/protobuf/proto" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -type ThrottlePublisher struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - MaxIdleDataPublishingAgents int32 `protobuf:"varint,1,opt,name=maxIdleDataPublishingAgents,proto3" json:"maxIdleDataPublishingAgents,omitempty"` - InitIdleObjectDataPublishingAgents int32 `protobuf:"varint,2,opt,name=initIdleObjectDataPublishingAgents,proto3" json:"initIdleObjectDataPublishingAgents,omitempty"` - PublisherThreadPoolCoreSize int32 `protobuf:"varint,3,opt,name=publisherThreadPoolCoreSize,proto3" json:"publisherThreadPoolCoreSize,omitempty"` - PublisherThreadPoolMaximumSize int32 `protobuf:"varint,4,opt,name=publisherThreadPoolMaximumSize,proto3" json:"publisherThreadPoolMaximumSize,omitempty"` - PublisherThreadPoolKeepAliveTime int32 `protobuf:"varint,5,opt,name=publisherThreadPoolKeepAliveTime,proto3" json:"publisherThreadPoolKeepAliveTime,omitempty"` -} - -func (x *ThrottlePublisher) Reset() { - *x = ThrottlePublisher{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_config_enforcer_throttle_publisher_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ThrottlePublisher) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ThrottlePublisher) ProtoMessage() {} - -func (x *ThrottlePublisher) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_config_enforcer_throttle_publisher_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ThrottlePublisher.ProtoReflect.Descriptor instead. -func (*ThrottlePublisher) Descriptor() ([]byte, []int) { - return file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescGZIP(), []int{0} -} - -func (x *ThrottlePublisher) GetMaxIdleDataPublishingAgents() int32 { - if x != nil { - return x.MaxIdleDataPublishingAgents - } - return 0 -} - -func (x *ThrottlePublisher) GetInitIdleObjectDataPublishingAgents() int32 { - if x != nil { - return x.InitIdleObjectDataPublishingAgents - } - return 0 -} - -func (x *ThrottlePublisher) GetPublisherThreadPoolCoreSize() int32 { - if x != nil { - return x.PublisherThreadPoolCoreSize - } - return 0 -} - -func (x *ThrottlePublisher) GetPublisherThreadPoolMaximumSize() int32 { - if x != nil { - return x.PublisherThreadPoolMaximumSize - } - return 0 -} - -func (x *ThrottlePublisher) GetPublisherThreadPoolKeepAliveTime() int32 { - if x != nil { - return x.PublisherThreadPoolKeepAliveTime - } - return 0 -} - -var File_wso2_discovery_config_enforcer_throttle_publisher_proto protoreflect.FileDescriptor - -var file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDesc = []byte{ - 0x0a, 0x37, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, - 0x2f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, - 0x68, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x77, 0x73, 0x6f, 0x32, 0x2e, - 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x22, 0xfb, 0x02, 0x0a, 0x11, 0x54, 0x68, - 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x12, - 0x40, 0x0a, 0x1b, 0x6d, 0x61, 0x78, 0x49, 0x64, 0x6c, 0x65, 0x44, 0x61, 0x74, 0x61, 0x50, 0x75, - 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x1b, 0x6d, 0x61, 0x78, 0x49, 0x64, 0x6c, 0x65, 0x44, 0x61, 0x74, - 0x61, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x41, 0x67, 0x65, 0x6e, 0x74, - 0x73, 0x12, 0x4e, 0x0a, 0x22, 0x69, 0x6e, 0x69, 0x74, 0x49, 0x64, 0x6c, 0x65, 0x4f, 0x62, 0x6a, - 0x65, 0x63, 0x74, 0x44, 0x61, 0x74, 0x61, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, - 0x67, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x22, 0x69, - 0x6e, 0x69, 0x74, 0x49, 0x64, 0x6c, 0x65, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x44, 0x61, 0x74, - 0x61, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x41, 0x67, 0x65, 0x6e, 0x74, - 0x73, 0x12, 0x40, 0x0a, 0x1b, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x54, 0x68, - 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x43, 0x6f, 0x72, 0x65, 0x53, 0x69, 0x7a, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x1b, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, - 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x43, 0x6f, 0x72, 0x65, 0x53, - 0x69, 0x7a, 0x65, 0x12, 0x46, 0x0a, 0x1e, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, - 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x4d, 0x61, 0x78, 0x69, 0x6d, 0x75, - 0x6d, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x1e, 0x70, 0x75, 0x62, - 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, - 0x4d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x4a, 0x0a, 0x20, 0x70, - 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, - 0x6f, 0x6c, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, - 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, - 0x69, 0x76, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x42, 0x97, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, - 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, - 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, - 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x17, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, - 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, - 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, - 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, - 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, - 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescOnce sync.Once - file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescData = file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDesc -) - -func file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescGZIP() []byte { - file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescOnce.Do(func() { - file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescData) - }) - return file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescData -} - -var file_wso2_discovery_config_enforcer_throttle_publisher_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_wso2_discovery_config_enforcer_throttle_publisher_proto_goTypes = []interface{}{ - (*ThrottlePublisher)(nil), // 0: wso2.discovery.config.enforcer.ThrottlePublisher -} -var file_wso2_discovery_config_enforcer_throttle_publisher_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_wso2_discovery_config_enforcer_throttle_publisher_proto_init() } -func file_wso2_discovery_config_enforcer_throttle_publisher_proto_init() { - if File_wso2_discovery_config_enforcer_throttle_publisher_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_wso2_discovery_config_enforcer_throttle_publisher_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ThrottlePublisher); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_wso2_discovery_config_enforcer_throttle_publisher_proto_goTypes, - DependencyIndexes: file_wso2_discovery_config_enforcer_throttle_publisher_proto_depIdxs, - MessageInfos: file_wso2_discovery_config_enforcer_throttle_publisher_proto_msgTypes, - }.Build() - File_wso2_discovery_config_enforcer_throttle_publisher_proto = out.File - file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDesc = nil - file_wso2_discovery_config_enforcer_throttle_publisher_proto_goTypes = nil - file_wso2_discovery_config_enforcer_throttle_publisher_proto_depIdxs = nil -} diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher_pool.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher_pool.pb.go new file mode 100644 index 0000000000..c5c922b792 --- /dev/null +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher_pool.pb.go @@ -0,0 +1,214 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.15.5 +// source: wso2/discovery/config/enforcer/throttle_publisher_pool.proto + +package enforcer + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +// Throttle Publisher pool configuration model +type PublisherPool struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + MaxIdleDataPublishingAgents int32 `protobuf:"varint,1,opt,name=maxIdleDataPublishingAgents,proto3" json:"maxIdleDataPublishingAgents,omitempty"` + InitIdleObjectDataPublishingAgents int32 `protobuf:"varint,2,opt,name=initIdleObjectDataPublishingAgents,proto3" json:"initIdleObjectDataPublishingAgents,omitempty"` + PublisherThreadPoolCoreSize int32 `protobuf:"varint,3,opt,name=publisherThreadPoolCoreSize,proto3" json:"publisherThreadPoolCoreSize,omitempty"` + PublisherThreadPoolMaximumSize int32 `protobuf:"varint,4,opt,name=publisherThreadPoolMaximumSize,proto3" json:"publisherThreadPoolMaximumSize,omitempty"` + PublisherThreadPoolKeepAliveTime int32 `protobuf:"varint,5,opt,name=publisherThreadPoolKeepAliveTime,proto3" json:"publisherThreadPoolKeepAliveTime,omitempty"` +} + +func (x *PublisherPool) Reset() { + *x = PublisherPool{} + if protoimpl.UnsafeEnabled { + mi := &file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PublisherPool) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PublisherPool) ProtoMessage() {} + +func (x *PublisherPool) ProtoReflect() protoreflect.Message { + mi := &file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PublisherPool.ProtoReflect.Descriptor instead. +func (*PublisherPool) Descriptor() ([]byte, []int) { + return file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescGZIP(), []int{0} +} + +func (x *PublisherPool) GetMaxIdleDataPublishingAgents() int32 { + if x != nil { + return x.MaxIdleDataPublishingAgents + } + return 0 +} + +func (x *PublisherPool) GetInitIdleObjectDataPublishingAgents() int32 { + if x != nil { + return x.InitIdleObjectDataPublishingAgents + } + return 0 +} + +func (x *PublisherPool) GetPublisherThreadPoolCoreSize() int32 { + if x != nil { + return x.PublisherThreadPoolCoreSize + } + return 0 +} + +func (x *PublisherPool) GetPublisherThreadPoolMaximumSize() int32 { + if x != nil { + return x.PublisherThreadPoolMaximumSize + } + return 0 +} + +func (x *PublisherPool) GetPublisherThreadPoolKeepAliveTime() int32 { + if x != nil { + return x.PublisherThreadPoolKeepAliveTime + } + return 0 +} + +var File_wso2_discovery_config_enforcer_throttle_publisher_pool_proto protoreflect.FileDescriptor + +var file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDesc = []byte{ + 0x0a, 0x3c, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, + 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, + 0x2f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, + 0x68, 0x65, 0x72, 0x5f, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, + 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x22, 0xf7, + 0x02, 0x0a, 0x0d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x50, 0x6f, 0x6f, 0x6c, + 0x12, 0x40, 0x0a, 0x1b, 0x6d, 0x61, 0x78, 0x49, 0x64, 0x6c, 0x65, 0x44, 0x61, 0x74, 0x61, 0x50, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x73, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x1b, 0x6d, 0x61, 0x78, 0x49, 0x64, 0x6c, 0x65, 0x44, 0x61, + 0x74, 0x61, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x41, 0x67, 0x65, 0x6e, + 0x74, 0x73, 0x12, 0x4e, 0x0a, 0x22, 0x69, 0x6e, 0x69, 0x74, 0x49, 0x64, 0x6c, 0x65, 0x4f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x44, 0x61, 0x74, 0x61, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, + 0x6e, 0x67, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x22, + 0x69, 0x6e, 0x69, 0x74, 0x49, 0x64, 0x6c, 0x65, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x44, 0x61, + 0x74, 0x61, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x41, 0x67, 0x65, 0x6e, + 0x74, 0x73, 0x12, 0x40, 0x0a, 0x1b, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x54, + 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x43, 0x6f, 0x72, 0x65, 0x53, 0x69, 0x7a, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x1b, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, + 0x65, 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x43, 0x6f, 0x72, 0x65, + 0x53, 0x69, 0x7a, 0x65, 0x12, 0x46, 0x0a, 0x1e, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x4d, 0x61, 0x78, 0x69, 0x6d, + 0x75, 0x6d, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x1e, 0x70, 0x75, + 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, + 0x6c, 0x4d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x4a, 0x0a, 0x20, + 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, + 0x6f, 0x6f, 0x6c, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x54, 0x69, 0x6d, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x4b, 0x65, 0x65, 0x70, 0x41, + 0x6c, 0x69, 0x76, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x42, 0x92, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, + 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, + 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, + 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x12, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, + 0x65, 0x72, 0x50, 0x6f, 0x6f, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, + 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, + 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, + 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescOnce sync.Once + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescData = file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDesc +) + +func file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescGZIP() []byte { + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescOnce.Do(func() { + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescData) + }) + return file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescData +} + +var file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_goTypes = []interface{}{ + (*PublisherPool)(nil), // 0: wso2.discovery.config.enforcer.PublisherPool +} +var file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_init() } +func file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_init() { + if File_wso2_discovery_config_enforcer_throttle_publisher_pool_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PublisherPool); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_goTypes, + DependencyIndexes: file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_depIdxs, + MessageInfos: file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_msgTypes, + }.Build() + File_wso2_discovery_config_enforcer_throttle_publisher_pool_proto = out.File + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDesc = nil + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_goTypes = nil + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_depIdxs = nil +} diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttling.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttling.pb.go index eb8f5eda4f..1f27a2b29c 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttling.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttling.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.13.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/throttling.proto package enforcer @@ -31,7 +31,13 @@ type Throttling struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Binary *BinaryThrottling `protobuf:"bytes,1,opt,name=binary,proto3" json:"binary,omitempty"` + EnableGlobalEventPublishing bool `protobuf:"varint,1,opt,name=enable_global_event_publishing,json=enableGlobalEventPublishing,proto3" json:"enable_global_event_publishing,omitempty"` + EnableHeaderConditions bool `protobuf:"varint,2,opt,name=enable_header_conditions,json=enableHeaderConditions,proto3" json:"enable_header_conditions,omitempty"` + EnableQueryParamConditions bool `protobuf:"varint,3,opt,name=enable_query_param_conditions,json=enableQueryParamConditions,proto3" json:"enable_query_param_conditions,omitempty"` + EnableJwtClaimConditions bool `protobuf:"varint,4,opt,name=enable_jwt_claim_conditions,json=enableJwtClaimConditions,proto3" json:"enable_jwt_claim_conditions,omitempty"` + JmsConnectionInitialContextFactory string `protobuf:"bytes,5,opt,name=jms_connection_initial_context_factory,json=jmsConnectionInitialContextFactory,proto3" json:"jms_connection_initial_context_factory,omitempty"` + JmsConnectionProviderUrl string `protobuf:"bytes,6,opt,name=jms_connection_provider_url,json=jmsConnectionProviderUrl,proto3" json:"jms_connection_provider_url,omitempty"` + Publisher *BinaryPublisher `protobuf:"bytes,7,opt,name=publisher,proto3" json:"publisher,omitempty"` } func (x *Throttling) Reset() { @@ -66,9 +72,51 @@ func (*Throttling) Descriptor() ([]byte, []int) { return file_wso2_discovery_config_enforcer_throttling_proto_rawDescGZIP(), []int{0} } -func (x *Throttling) GetBinary() *BinaryThrottling { +func (x *Throttling) GetEnableGlobalEventPublishing() bool { if x != nil { - return x.Binary + return x.EnableGlobalEventPublishing + } + return false +} + +func (x *Throttling) GetEnableHeaderConditions() bool { + if x != nil { + return x.EnableHeaderConditions + } + return false +} + +func (x *Throttling) GetEnableQueryParamConditions() bool { + if x != nil { + return x.EnableQueryParamConditions + } + return false +} + +func (x *Throttling) GetEnableJwtClaimConditions() bool { + if x != nil { + return x.EnableJwtClaimConditions + } + return false +} + +func (x *Throttling) GetJmsConnectionInitialContextFactory() string { + if x != nil { + return x.JmsConnectionInitialContextFactory + } + return "" +} + +func (x *Throttling) GetJmsConnectionProviderUrl() string { + if x != nil { + return x.JmsConnectionProviderUrl + } + return "" +} + +func (x *Throttling) GetPublisher() *BinaryPublisher { + if x != nil { + return x.Publisher } return nil } @@ -81,25 +129,51 @@ var file_wso2_discovery_config_enforcer_throttling_proto_rawDesc = []byte{ 0x2f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, - 0x72, 0x1a, 0x36, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, + 0x72, 0x1a, 0x35, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, - 0x72, 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x5f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, - 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x56, 0x0a, 0x0a, 0x54, 0x68, 0x72, - 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x12, 0x48, 0x0a, 0x06, 0x62, 0x69, 0x6e, 0x61, 0x72, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, - 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x54, - 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x62, 0x69, 0x6e, 0x61, 0x72, - 0x79, 0x42, 0x8f, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, - 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, - 0x42, 0x0f, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, - 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, - 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, + 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xef, 0x03, 0x0a, 0x0a, 0x54, 0x68, 0x72, + 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x12, 0x43, 0x0a, 0x1e, 0x65, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x5f, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x70, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x1b, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x38, 0x0a, 0x18, + 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, + 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, + 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x64, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x41, 0x0a, 0x1d, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, + 0x5f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x5f, 0x63, 0x6f, 0x6e, + 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, 0x65, + 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x43, + 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3d, 0x0a, 0x1b, 0x65, 0x6e, 0x61, + 0x62, 0x6c, 0x65, 0x5f, 0x6a, 0x77, 0x74, 0x5f, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x5f, 0x63, 0x6f, + 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, + 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x4a, 0x77, 0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x43, 0x6f, + 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x52, 0x0a, 0x26, 0x6a, 0x6d, 0x73, 0x5f, + 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x69, 0x74, 0x69, + 0x61, 0x6c, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, + 0x72, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x22, 0x6a, 0x6d, 0x73, 0x43, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x43, 0x6f, + 0x6e, 0x74, 0x65, 0x78, 0x74, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x3d, 0x0a, 0x1b, + 0x6a, 0x6d, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x18, 0x6a, 0x6d, 0x73, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x55, 0x72, 0x6c, 0x12, 0x4d, 0x0a, 0x09, 0x70, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, + 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, + 0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x52, + 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x42, 0x8f, 0x01, 0x0a, 0x2a, 0x6f, + 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, + 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x0f, 0x54, 0x68, 0x72, 0x6f, 0x74, + 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, + 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, + 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, + 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -116,11 +190,11 @@ func file_wso2_discovery_config_enforcer_throttling_proto_rawDescGZIP() []byte { var file_wso2_discovery_config_enforcer_throttling_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_wso2_discovery_config_enforcer_throttling_proto_goTypes = []interface{}{ - (*Throttling)(nil), // 0: wso2.discovery.config.enforcer.Throttling - (*BinaryThrottling)(nil), // 1: wso2.discovery.config.enforcer.BinaryThrottling + (*Throttling)(nil), // 0: wso2.discovery.config.enforcer.Throttling + (*BinaryPublisher)(nil), // 1: wso2.discovery.config.enforcer.BinaryPublisher } var file_wso2_discovery_config_enforcer_throttling_proto_depIdxs = []int32{ - 1, // 0: wso2.discovery.config.enforcer.Throttling.binary:type_name -> wso2.discovery.config.enforcer.BinaryThrottling + 1, // 0: wso2.discovery.config.enforcer.Throttling.publisher:type_name -> wso2.discovery.config.enforcer.BinaryPublisher 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name @@ -133,7 +207,7 @@ func file_wso2_discovery_config_enforcer_throttling_proto_init() { if File_wso2_discovery_config_enforcer_throttling_proto != nil { return } - file_wso2_discovery_config_enforcer_binary_throttling_proto_init() + file_wso2_discovery_config_enforcer_binary_publisher_proto_init() if !protoimpl.UnsafeEnabled { file_wso2_discovery_config_enforcer_throttling_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Throttling); i { diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/tm_url_group.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/tm_url_group.pb.go index 932a500fd6..730e24a6d3 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/tm_url_group.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/tm_url_group.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 -// protoc v3.13.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/tm_url_group.proto package enforcer @@ -32,6 +32,7 @@ type TMURLGroup struct { ReceiverURLs []string `protobuf:"bytes,1,rep,name=receiverURLs,proto3" json:"receiverURLs,omitempty"` AuthURLs []string `protobuf:"bytes,2,rep,name=authURLs,proto3" json:"authURLs,omitempty"` + Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` } func (x *TMURLGroup) Reset() { @@ -80,6 +81,13 @@ func (x *TMURLGroup) GetAuthURLs() []string { return nil } +func (x *TMURLGroup) GetType() string { + if x != nil { + return x.Type + } + return "" +} + var File_wso2_discovery_config_enforcer_tm_url_group_proto protoreflect.FileDescriptor var file_wso2_discovery_config_enforcer_tm_url_group_proto_rawDesc = []byte{ @@ -88,21 +96,22 @@ var file_wso2_discovery_config_enforcer_tm_url_group_proto_rawDesc = []byte{ 0x2f, 0x74, 0x6d, 0x5f, 0x75, 0x72, 0x6c, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, - 0x63, 0x65, 0x72, 0x22, 0x4c, 0x0a, 0x0a, 0x54, 0x4d, 0x55, 0x52, 0x4c, 0x47, 0x72, 0x6f, 0x75, + 0x63, 0x65, 0x72, 0x22, 0x60, 0x0a, 0x0a, 0x54, 0x4d, 0x55, 0x52, 0x4c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x22, 0x0a, 0x0c, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x55, 0x52, 0x4c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x55, 0x52, 0x4c, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x75, 0x74, 0x68, 0x55, 0x52, 0x4c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x61, 0x75, 0x74, 0x68, 0x55, 0x52, 0x4c, - 0x73, 0x42, 0x8f, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, - 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, - 0x42, 0x0f, 0x54, 0x4d, 0x55, 0x52, 0x4c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, - 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, - 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x42, 0x8f, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, + 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, + 0x72, 0x63, 0x65, 0x72, 0x42, 0x0f, 0x54, 0x4d, 0x55, 0x52, 0x4c, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, + 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, + 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, + 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/adapter/internal/discovery/xds/marshaller.go b/adapter/internal/discovery/xds/marshaller.go index 643c75040f..0abf8384f6 100644 --- a/adapter/internal/discovery/xds/marshaller.go +++ b/adapter/internal/discovery/xds/marshaller.go @@ -17,6 +17,8 @@ import ( // enfocer's CDS resource representation. func MarshalConfig(config *config.Config) *enforcer.Config { issuers := []*enforcer.Issuer{} + urlGroups := []*enforcer.TMURLGroup{} + for _, issuer := range config.Enforcer.JwtTokenConfig { claimMaps := []*enforcer.ClaimMapping{} for _, claimMap := range issuer.ClaimMapping{ @@ -48,6 +50,15 @@ func MarshalConfig(config *config.Config) *enforcer.Config { jwtUsers = append(jwtUsers, jwtUser) } + for _, urlGroup := range config.Enforcer.Throttling.Publisher.URLGroup { + group := &enforcer.TMURLGroup{ + AuthURLs: urlGroup.AuthURLs, + ReceiverURLs: urlGroup.ReceiverURLs, + Type: urlGroup.Type, + } + urlGroups = append(urlGroups, group) + } + authService := &enforcer.AuthService{ KeepAliveTime: config.Enforcer.AuthService.KeepAliveTime, MaxHeaderLimit: config.Enforcer.AuthService.MaxHeaderLimit, @@ -106,6 +117,45 @@ func MarshalConfig(config *config.Config) *enforcer.Config { EventListeningEndpoints: config.ControlPlane.EventHub.JmsConnectionParameters.EventListeningEndpoints, }, }, + Throttling: &enforcer.Throttling{ + EnableGlobalEventPublishing: config.Enforcer.Throttling.EnableGlobalEventPublishing, + EnableHeaderConditions: config.Enforcer.Throttling.EnableHeaderConditions, + EnableQueryParamConditions: config.Enforcer.Throttling.EnableQueryParamConditions, + EnableJwtClaimConditions: config.Enforcer.Throttling.EnableJwtClaimConditions, + JmsConnectionInitialContextFactory: config.Enforcer.Throttling.JmsConnectionInitialContextFactory, + JmsConnectionProviderUrl: config.Enforcer.Throttling.JmsConnectionProviderURL, + Publisher: &enforcer.BinaryPublisher{ + Username: config.Enforcer.Throttling.Publisher.Username, + Password: config.Enforcer.Throttling.Publisher.Password, + UrlGroup: urlGroups, + Pool: &enforcer.PublisherPool{ + InitIdleObjectDataPublishingAgents: config.Enforcer.Throttling.Publisher.Pool.InitIdleObjectDataPublishingAgents, + MaxIdleDataPublishingAgents: config.Enforcer.Throttling.Publisher.Pool.MaxIdleDataPublishingAgents, + PublisherThreadPoolCoreSize: config.Enforcer.Throttling.Publisher.Pool.PublisherThreadPoolCoreSize, + PublisherThreadPoolKeepAliveTime: config.Enforcer.Throttling.Publisher.Pool.PublisherThreadPoolKeepAliveTime, + PublisherThreadPoolMaximumSize: config.Enforcer.Throttling.Publisher.Pool.PublisherThreadPoolMaximumSize, + }, + Agent: &enforcer.ThrottleAgent{ + BatchSize: config.Enforcer.Throttling.Publisher.Agent.BatchSize, + Ciphers: config.Enforcer.Throttling.Publisher.Agent.Ciphers, + CorePoolSize: config.Enforcer.Throttling.Publisher.Agent.CorePoolSize, + EvictionTimePeriod: config.Enforcer.Throttling.Publisher.Agent.EvictionTimePeriod, + KeepAliveTimeInPool: config.Enforcer.Throttling.Publisher.Agent.KeepAliveTimeInPool, + MaxIdleConnections: config.Enforcer.Throttling.Publisher.Agent.MaxIdleConnections, + MaxPoolSize: config.Enforcer.Throttling.Publisher.Agent.MaxPoolSize, + MaxTransportPoolSize: config.Enforcer.Throttling.Publisher.Agent.MaxTransportPoolSize, + MinIdleTimeInPool: config.Enforcer.Throttling.Publisher.Agent.MinIdleTimeInPool, + QueueSize: config.Enforcer.Throttling.Publisher.Agent.QueueSize, + ReconnectionInterval: config.Enforcer.Throttling.Publisher.Agent.ReconnectionInterval, + SecureEvictionTimePeriod: config.Enforcer.Throttling.Publisher.Agent.SecureEvictionTimePeriod, + SecureMaxIdleConnections: config.Enforcer.Throttling.Publisher.Agent.SecureMaxIdleConnections, + SecureMaxTransportPoolSize: config.Enforcer.Throttling.Publisher.Agent.SecureMaxTransportPoolSize, + SecureMinIdleTimeInPool: config.Enforcer.Throttling.Publisher.Agent.SecureMinIdleTimeInPool, + SocketTimeoutMS: config.Enforcer.Throttling.Publisher.Agent.SocketTimeoutMS, + SslEnabledProtocols: config.Enforcer.Throttling.Publisher.Agent.SslEnabledProtocols, + }, + }, + }, } } diff --git a/adapter/internal/discovery/xds/server.go b/adapter/internal/discovery/xds/server.go index 8e09441045..57da4ef578 100644 --- a/adapter/internal/discovery/xds/server.go +++ b/adapter/internal/discovery/xds/server.go @@ -40,10 +40,10 @@ import ( apiModel "github.com/wso2/micro-gw/internal/api/models" eventhubTypes "github.com/wso2/micro-gw/internal/eventhub/types" oasParser "github.com/wso2/micro-gw/internal/oasparser" + envoyconf "github.com/wso2/micro-gw/internal/oasparser/envoyconf" mgw "github.com/wso2/micro-gw/internal/oasparser/model" "github.com/wso2/micro-gw/internal/oasparser/operator" logger "github.com/wso2/micro-gw/loggers" - envoyconf "github.com/wso2/micro-gw/internal/oasparser/envoyconf" ) var ( @@ -335,7 +335,7 @@ func updateXdsCacheOnAPIAdd(oldLabels []string, newLabels []string) { // GenerateEnvoyResoucesForLabel generates envoy resources for a given label func GenerateEnvoyResoucesForLabel(label string) ([]types.Resource, []types.Resource, []types.Resource, -[]types.Resource, []types.Resource) { + []types.Resource, []types.Resource) { var clusterArray []*clusterv3.Cluster var routeArray []*routev3.Route var endpointArray []*corev3.Address @@ -534,7 +534,7 @@ func UpdateEnforcerApplicationKeyMappings(applicationKeyMappings *subscription.A // UpdateXdsCacheWithLock uses mutex and lock to avoid different go routines updating XDS at the same time func UpdateXdsCacheWithLock(label string, endpoints []types.Resource, clusters []types.Resource, routes []types.Resource, -listeners []types.Resource) { + listeners []types.Resource) { mutexForXdsUpdate.Lock() defer mutexForXdsUpdate.Unlock() updateXdsCache(label, endpoints, clusters, routes, listeners) diff --git a/api/wso2/discovery/config/enforcer/binary_throttling.proto b/api/wso2/discovery/config/enforcer/binary_publisher.proto similarity index 67% rename from api/wso2/discovery/config/enforcer/binary_throttling.proto rename to api/wso2/discovery/config/enforcer/binary_publisher.proto index 26db289fee..d7ef6c6464 100644 --- a/api/wso2/discovery/config/enforcer/binary_throttling.proto +++ b/api/wso2/discovery/config/enforcer/binary_publisher.proto @@ -3,21 +3,20 @@ syntax = "proto3"; package wso2.discovery.config.enforcer; import "wso2/discovery/config/enforcer/tm_url_group.proto"; -import "wso2/discovery/config/enforcer/throttle_publisher.proto"; +import "wso2/discovery/config/enforcer/throttle_publisher_pool.proto"; import "wso2/discovery/config/enforcer/throttle_agent.proto"; option go_package = "github.com/envoyproxy/go-control-plane/wso2/discovery/config/enforcer;enforcer"; option java_package = "org.wso2.gateway.discovery.config.enforcer"; -option java_outer_classname = "BinaryThrottlingProto"; +option java_outer_classname = "BinaryPublisherProto"; option java_multiple_files = true; -// [#protodoc-title: BinaryThrottling] +// [#protodoc-title: BinaryPublisher] -message BinaryThrottling { - bool enabled = 1; +message BinaryPublisher { string username = 2; string password = 3; repeated TMURLGroup urlGroup = 4; - ThrottlePublisher publisher = 5; + PublisherPool pool = 5; ThrottleAgent agent = 6; } diff --git a/api/wso2/discovery/config/enforcer/config.proto b/api/wso2/discovery/config/enforcer/config.proto index d456bbbcec..2aaca2ef09 100644 --- a/api/wso2/discovery/config/enforcer/config.proto +++ b/api/wso2/discovery/config/enforcer/config.proto @@ -35,7 +35,7 @@ message Config { JWTGenerator jwtGenerator = 7; - Throttling throttlingConfig = 8; + Throttling throttling = 8; Cache cache = 9; diff --git a/api/wso2/discovery/config/enforcer/throttle_agent.proto b/api/wso2/discovery/config/enforcer/throttle_agent.proto index bd130981e0..fd7a766972 100644 --- a/api/wso2/discovery/config/enforcer/throttle_agent.proto +++ b/api/wso2/discovery/config/enforcer/throttle_agent.proto @@ -9,6 +9,7 @@ option java_multiple_files = true; // [#protodoc-title: ThrottleAgent] +// Throttle Agent configuration model message ThrottleAgent { string sslEnabledProtocols = 1; string ciphers = 2; diff --git a/api/wso2/discovery/config/enforcer/throttle_publisher.proto b/api/wso2/discovery/config/enforcer/throttle_publisher_pool.proto similarity index 75% rename from api/wso2/discovery/config/enforcer/throttle_publisher.proto rename to api/wso2/discovery/config/enforcer/throttle_publisher_pool.proto index a308b6da66..bca84252cb 100644 --- a/api/wso2/discovery/config/enforcer/throttle_publisher.proto +++ b/api/wso2/discovery/config/enforcer/throttle_publisher_pool.proto @@ -4,12 +4,13 @@ package wso2.discovery.config.enforcer; option go_package = "github.com/envoyproxy/go-control-plane/wso2/discovery/config/enforcer;enforcer"; option java_package = "org.wso2.gateway.discovery.config.enforcer"; -option java_outer_classname = "ThrottlePublishergProto"; +option java_outer_classname = "PublisherPoolProto"; option java_multiple_files = true; -// [#protodoc-title: ThrottlePublisher] +// [#protodoc-title: PublisherPool] -message ThrottlePublisher { +// Throttle Publisher pool configuration model +message PublisherPool { int32 maxIdleDataPublishingAgents = 1; int32 initIdleObjectDataPublishingAgents = 2; int32 publisherThreadPoolCoreSize = 3; diff --git a/api/wso2/discovery/config/enforcer/throttling.proto b/api/wso2/discovery/config/enforcer/throttling.proto index 479051f6e5..2628ae3dfb 100644 --- a/api/wso2/discovery/config/enforcer/throttling.proto +++ b/api/wso2/discovery/config/enforcer/throttling.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package wso2.discovery.config.enforcer; -import "wso2/discovery/config/enforcer/binary_throttling.proto"; +import "wso2/discovery/config/enforcer/binary_publisher.proto"; option go_package = "github.com/envoyproxy/go-control-plane/wso2/discovery/config/enforcer;enforcer"; option java_package = "org.wso2.gateway.discovery.config.enforcer"; @@ -13,5 +13,11 @@ option java_multiple_files = true; // Throttling model message Throttling { - BinaryThrottling binary = 1; + bool enable_global_event_publishing = 1; + bool enable_header_conditions = 2; + bool enable_query_param_conditions = 3; + bool enable_jwt_claim_conditions = 4; + string jms_connection_initial_context_factory = 5; + string jms_connection_provider_url = 6; + BinaryPublisher publisher = 7; } diff --git a/api/wso2/discovery/config/enforcer/tm_url_group.proto b/api/wso2/discovery/config/enforcer/tm_url_group.proto index b7562f295e..2e88fcfab7 100644 --- a/api/wso2/discovery/config/enforcer/tm_url_group.proto +++ b/api/wso2/discovery/config/enforcer/tm_url_group.proto @@ -12,4 +12,5 @@ option java_multiple_files = true; message TMURLGroup { repeated string receiverURLs = 1; repeated string authURLs = 2; + string type = 3; } diff --git a/api/wso2/discovery/subscription/url_mapping.proto b/api/wso2/discovery/subscription/url_mapping.proto index 6e4c45bf5f..6e0d7cb40e 100644 --- a/api/wso2/discovery/subscription/url_mapping.proto +++ b/api/wso2/discovery/subscription/url_mapping.proto @@ -11,7 +11,7 @@ option java_multiple_files = true; // URLMapping data model message URLMapping { - string authScheme = 1; + string authScheme = 1; string httpMethod = 2; string urlPattern = 3; repeated string scopes = 4; diff --git a/enforcer/pom.xml b/enforcer/pom.xml index 0bf35093fa..1fe6c8641e 100644 --- a/enforcer/pom.xml +++ b/enforcer/pom.xml @@ -316,10 +316,25 @@ org.apache.commons commons-lang3 + + org.wso2.carbon.analytics-common + org.wso2.carbon.databridge.commons + + + org.wso2.carbon.analytics-common + org.wso2.carbon.databridge.commons.binary + + + commons-pool.wso2 + commons-pool + + + org.wso2.orbit.com.lmax + disruptor + org.wso2.carbon.apimgt org.wso2.carbon.apimgt.common.gateway - 9.0.0 diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisher.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisher.java new file mode 100644 index 0000000000..b571717c8c --- /dev/null +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisher.java @@ -0,0 +1,1422 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/config/enforcer/binary_publisher.proto + +package org.wso2.gateway.discovery.config.enforcer; + +/** + * Protobuf type {@code wso2.discovery.config.enforcer.BinaryPublisher} + */ +public final class BinaryPublisher extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:wso2.discovery.config.enforcer.BinaryPublisher) + BinaryPublisherOrBuilder { +private static final long serialVersionUID = 0L; + // Use BinaryPublisher.newBuilder() to construct. + private BinaryPublisher(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BinaryPublisher() { + username_ = ""; + password_ = ""; + urlGroup_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new BinaryPublisher(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BinaryPublisher( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + username_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + password_ = s; + break; + } + case 34: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + urlGroup_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + urlGroup_.add( + input.readMessage(org.wso2.gateway.discovery.config.enforcer.TMURLGroup.parser(), extensionRegistry)); + break; + } + case 42: { + org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder subBuilder = null; + if (pool_ != null) { + subBuilder = pool_.toBuilder(); + } + pool_ = input.readMessage(org.wso2.gateway.discovery.config.enforcer.PublisherPool.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(pool_); + pool_ = subBuilder.buildPartial(); + } + + break; + } + case 50: { + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.Builder subBuilder = null; + if (agent_ != null) { + subBuilder = agent_.toBuilder(); + } + agent_ = input.readMessage(org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(agent_); + agent_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + urlGroup_ = java.util.Collections.unmodifiableList(urlGroup_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.gateway.discovery.config.enforcer.BinaryPublisherProto.internal_static_wso2_discovery_config_enforcer_BinaryPublisher_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.gateway.discovery.config.enforcer.BinaryPublisherProto.internal_static_wso2_discovery_config_enforcer_BinaryPublisher_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.class, org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder.class); + } + + public static final int USERNAME_FIELD_NUMBER = 2; + private volatile java.lang.Object username_; + /** + * string username = 2; + * @return The username. + */ + @java.lang.Override + public java.lang.String getUsername() { + java.lang.Object ref = username_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + username_ = s; + return s; + } + } + /** + * string username = 2; + * @return The bytes for username. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getUsernameBytes() { + java.lang.Object ref = username_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + username_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PASSWORD_FIELD_NUMBER = 3; + private volatile java.lang.Object password_; + /** + * string password = 3; + * @return The password. + */ + @java.lang.Override + public java.lang.String getPassword() { + java.lang.Object ref = password_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + password_ = s; + return s; + } + } + /** + * string password = 3; + * @return The bytes for password. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getPasswordBytes() { + java.lang.Object ref = password_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + password_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int URLGROUP_FIELD_NUMBER = 4; + private java.util.List urlGroup_; + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + @java.lang.Override + public java.util.List getUrlGroupList() { + return urlGroup_; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + @java.lang.Override + public java.util.List + getUrlGroupOrBuilderList() { + return urlGroup_; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + @java.lang.Override + public int getUrlGroupCount() { + return urlGroup_.size(); + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.TMURLGroup getUrlGroup(int index) { + return urlGroup_.get(index); + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.TMURLGroupOrBuilder getUrlGroupOrBuilder( + int index) { + return urlGroup_.get(index); + } + + public static final int POOL_FIELD_NUMBER = 5; + private org.wso2.gateway.discovery.config.enforcer.PublisherPool pool_; + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + * @return Whether the pool field is set. + */ + @java.lang.Override + public boolean hasPool() { + return pool_ != null; + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + * @return The pool. + */ + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.PublisherPool getPool() { + return pool_ == null ? org.wso2.gateway.discovery.config.enforcer.PublisherPool.getDefaultInstance() : pool_; + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.PublisherPoolOrBuilder getPoolOrBuilder() { + return getPool(); + } + + public static final int AGENT_FIELD_NUMBER = 6; + private org.wso2.gateway.discovery.config.enforcer.ThrottleAgent agent_; + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + * @return Whether the agent field is set. + */ + @java.lang.Override + public boolean hasAgent() { + return agent_ != null; + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + * @return The agent. + */ + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.ThrottleAgent getAgent() { + return agent_ == null ? org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.getDefaultInstance() : agent_; + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.ThrottleAgentOrBuilder getAgentOrBuilder() { + return getAgent(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getUsernameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, username_); + } + if (!getPasswordBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, password_); + } + for (int i = 0; i < urlGroup_.size(); i++) { + output.writeMessage(4, urlGroup_.get(i)); + } + if (pool_ != null) { + output.writeMessage(5, getPool()); + } + if (agent_ != null) { + output.writeMessage(6, getAgent()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getUsernameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, username_); + } + if (!getPasswordBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, password_); + } + for (int i = 0; i < urlGroup_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, urlGroup_.get(i)); + } + if (pool_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, getPool()); + } + if (agent_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, getAgent()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.wso2.gateway.discovery.config.enforcer.BinaryPublisher)) { + return super.equals(obj); + } + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher other = (org.wso2.gateway.discovery.config.enforcer.BinaryPublisher) obj; + + if (!getUsername() + .equals(other.getUsername())) return false; + if (!getPassword() + .equals(other.getPassword())) return false; + if (!getUrlGroupList() + .equals(other.getUrlGroupList())) return false; + if (hasPool() != other.hasPool()) return false; + if (hasPool()) { + if (!getPool() + .equals(other.getPool())) return false; + } + if (hasAgent() != other.hasAgent()) return false; + if (hasAgent()) { + if (!getAgent() + .equals(other.getAgent())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + USERNAME_FIELD_NUMBER; + hash = (53 * hash) + getUsername().hashCode(); + hash = (37 * hash) + PASSWORD_FIELD_NUMBER; + hash = (53 * hash) + getPassword().hashCode(); + if (getUrlGroupCount() > 0) { + hash = (37 * hash) + URLGROUP_FIELD_NUMBER; + hash = (53 * hash) + getUrlGroupList().hashCode(); + } + if (hasPool()) { + hash = (37 * hash) + POOL_FIELD_NUMBER; + hash = (53 * hash) + getPool().hashCode(); + } + if (hasAgent()) { + hash = (37 * hash) + AGENT_FIELD_NUMBER; + hash = (53 * hash) + getAgent().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.wso2.gateway.discovery.config.enforcer.BinaryPublisher prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code wso2.discovery.config.enforcer.BinaryPublisher} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:wso2.discovery.config.enforcer.BinaryPublisher) + org.wso2.gateway.discovery.config.enforcer.BinaryPublisherOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.gateway.discovery.config.enforcer.BinaryPublisherProto.internal_static_wso2_discovery_config_enforcer_BinaryPublisher_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.gateway.discovery.config.enforcer.BinaryPublisherProto.internal_static_wso2_discovery_config_enforcer_BinaryPublisher_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.class, org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder.class); + } + + // Construct using org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getUrlGroupFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + username_ = ""; + + password_ = ""; + + if (urlGroupBuilder_ == null) { + urlGroup_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + urlGroupBuilder_.clear(); + } + if (poolBuilder_ == null) { + pool_ = null; + } else { + pool_ = null; + poolBuilder_ = null; + } + if (agentBuilder_ == null) { + agent_ = null; + } else { + agent_ = null; + agentBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.wso2.gateway.discovery.config.enforcer.BinaryPublisherProto.internal_static_wso2_discovery_config_enforcer_BinaryPublisher_descriptor; + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisher getDefaultInstanceForType() { + return org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.getDefaultInstance(); + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisher build() { + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisher buildPartial() { + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher result = new org.wso2.gateway.discovery.config.enforcer.BinaryPublisher(this); + int from_bitField0_ = bitField0_; + result.username_ = username_; + result.password_ = password_; + if (urlGroupBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + urlGroup_ = java.util.Collections.unmodifiableList(urlGroup_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.urlGroup_ = urlGroup_; + } else { + result.urlGroup_ = urlGroupBuilder_.build(); + } + if (poolBuilder_ == null) { + result.pool_ = pool_; + } else { + result.pool_ = poolBuilder_.build(); + } + if (agentBuilder_ == null) { + result.agent_ = agent_; + } else { + result.agent_ = agentBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.wso2.gateway.discovery.config.enforcer.BinaryPublisher) { + return mergeFrom((org.wso2.gateway.discovery.config.enforcer.BinaryPublisher)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.wso2.gateway.discovery.config.enforcer.BinaryPublisher other) { + if (other == org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.getDefaultInstance()) return this; + if (!other.getUsername().isEmpty()) { + username_ = other.username_; + onChanged(); + } + if (!other.getPassword().isEmpty()) { + password_ = other.password_; + onChanged(); + } + if (urlGroupBuilder_ == null) { + if (!other.urlGroup_.isEmpty()) { + if (urlGroup_.isEmpty()) { + urlGroup_ = other.urlGroup_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureUrlGroupIsMutable(); + urlGroup_.addAll(other.urlGroup_); + } + onChanged(); + } + } else { + if (!other.urlGroup_.isEmpty()) { + if (urlGroupBuilder_.isEmpty()) { + urlGroupBuilder_.dispose(); + urlGroupBuilder_ = null; + urlGroup_ = other.urlGroup_; + bitField0_ = (bitField0_ & ~0x00000001); + urlGroupBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getUrlGroupFieldBuilder() : null; + } else { + urlGroupBuilder_.addAllMessages(other.urlGroup_); + } + } + } + if (other.hasPool()) { + mergePool(other.getPool()); + } + if (other.hasAgent()) { + mergeAgent(other.getAgent()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.wso2.gateway.discovery.config.enforcer.BinaryPublisher) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object username_ = ""; + /** + * string username = 2; + * @return The username. + */ + public java.lang.String getUsername() { + java.lang.Object ref = username_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + username_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string username = 2; + * @return The bytes for username. + */ + public com.google.protobuf.ByteString + getUsernameBytes() { + java.lang.Object ref = username_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + username_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string username = 2; + * @param value The username to set. + * @return This builder for chaining. + */ + public Builder setUsername( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + username_ = value; + onChanged(); + return this; + } + /** + * string username = 2; + * @return This builder for chaining. + */ + public Builder clearUsername() { + + username_ = getDefaultInstance().getUsername(); + onChanged(); + return this; + } + /** + * string username = 2; + * @param value The bytes for username to set. + * @return This builder for chaining. + */ + public Builder setUsernameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + username_ = value; + onChanged(); + return this; + } + + private java.lang.Object password_ = ""; + /** + * string password = 3; + * @return The password. + */ + public java.lang.String getPassword() { + java.lang.Object ref = password_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + password_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string password = 3; + * @return The bytes for password. + */ + public com.google.protobuf.ByteString + getPasswordBytes() { + java.lang.Object ref = password_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + password_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string password = 3; + * @param value The password to set. + * @return This builder for chaining. + */ + public Builder setPassword( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + password_ = value; + onChanged(); + return this; + } + /** + * string password = 3; + * @return This builder for chaining. + */ + public Builder clearPassword() { + + password_ = getDefaultInstance().getPassword(); + onChanged(); + return this; + } + /** + * string password = 3; + * @param value The bytes for password to set. + * @return This builder for chaining. + */ + public Builder setPasswordBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + password_ = value; + onChanged(); + return this; + } + + private java.util.List urlGroup_ = + java.util.Collections.emptyList(); + private void ensureUrlGroupIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + urlGroup_ = new java.util.ArrayList(urlGroup_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.TMURLGroup, org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder, org.wso2.gateway.discovery.config.enforcer.TMURLGroupOrBuilder> urlGroupBuilder_; + + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public java.util.List getUrlGroupList() { + if (urlGroupBuilder_ == null) { + return java.util.Collections.unmodifiableList(urlGroup_); + } else { + return urlGroupBuilder_.getMessageList(); + } + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public int getUrlGroupCount() { + if (urlGroupBuilder_ == null) { + return urlGroup_.size(); + } else { + return urlGroupBuilder_.getCount(); + } + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public org.wso2.gateway.discovery.config.enforcer.TMURLGroup getUrlGroup(int index) { + if (urlGroupBuilder_ == null) { + return urlGroup_.get(index); + } else { + return urlGroupBuilder_.getMessage(index); + } + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder setUrlGroup( + int index, org.wso2.gateway.discovery.config.enforcer.TMURLGroup value) { + if (urlGroupBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureUrlGroupIsMutable(); + urlGroup_.set(index, value); + onChanged(); + } else { + urlGroupBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder setUrlGroup( + int index, org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder builderForValue) { + if (urlGroupBuilder_ == null) { + ensureUrlGroupIsMutable(); + urlGroup_.set(index, builderForValue.build()); + onChanged(); + } else { + urlGroupBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder addUrlGroup(org.wso2.gateway.discovery.config.enforcer.TMURLGroup value) { + if (urlGroupBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureUrlGroupIsMutable(); + urlGroup_.add(value); + onChanged(); + } else { + urlGroupBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder addUrlGroup( + int index, org.wso2.gateway.discovery.config.enforcer.TMURLGroup value) { + if (urlGroupBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureUrlGroupIsMutable(); + urlGroup_.add(index, value); + onChanged(); + } else { + urlGroupBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder addUrlGroup( + org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder builderForValue) { + if (urlGroupBuilder_ == null) { + ensureUrlGroupIsMutable(); + urlGroup_.add(builderForValue.build()); + onChanged(); + } else { + urlGroupBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder addUrlGroup( + int index, org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder builderForValue) { + if (urlGroupBuilder_ == null) { + ensureUrlGroupIsMutable(); + urlGroup_.add(index, builderForValue.build()); + onChanged(); + } else { + urlGroupBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder addAllUrlGroup( + java.lang.Iterable values) { + if (urlGroupBuilder_ == null) { + ensureUrlGroupIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, urlGroup_); + onChanged(); + } else { + urlGroupBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder clearUrlGroup() { + if (urlGroupBuilder_ == null) { + urlGroup_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + urlGroupBuilder_.clear(); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder removeUrlGroup(int index) { + if (urlGroupBuilder_ == null) { + ensureUrlGroupIsMutable(); + urlGroup_.remove(index); + onChanged(); + } else { + urlGroupBuilder_.remove(index); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder getUrlGroupBuilder( + int index) { + return getUrlGroupFieldBuilder().getBuilder(index); + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public org.wso2.gateway.discovery.config.enforcer.TMURLGroupOrBuilder getUrlGroupOrBuilder( + int index) { + if (urlGroupBuilder_ == null) { + return urlGroup_.get(index); } else { + return urlGroupBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public java.util.List + getUrlGroupOrBuilderList() { + if (urlGroupBuilder_ != null) { + return urlGroupBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(urlGroup_); + } + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder addUrlGroupBuilder() { + return getUrlGroupFieldBuilder().addBuilder( + org.wso2.gateway.discovery.config.enforcer.TMURLGroup.getDefaultInstance()); + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder addUrlGroupBuilder( + int index) { + return getUrlGroupFieldBuilder().addBuilder( + index, org.wso2.gateway.discovery.config.enforcer.TMURLGroup.getDefaultInstance()); + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public java.util.List + getUrlGroupBuilderList() { + return getUrlGroupFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.TMURLGroup, org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder, org.wso2.gateway.discovery.config.enforcer.TMURLGroupOrBuilder> + getUrlGroupFieldBuilder() { + if (urlGroupBuilder_ == null) { + urlGroupBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.TMURLGroup, org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder, org.wso2.gateway.discovery.config.enforcer.TMURLGroupOrBuilder>( + urlGroup_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + urlGroup_ = null; + } + return urlGroupBuilder_; + } + + private org.wso2.gateway.discovery.config.enforcer.PublisherPool pool_; + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.PublisherPool, org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder, org.wso2.gateway.discovery.config.enforcer.PublisherPoolOrBuilder> poolBuilder_; + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + * @return Whether the pool field is set. + */ + public boolean hasPool() { + return poolBuilder_ != null || pool_ != null; + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + * @return The pool. + */ + public org.wso2.gateway.discovery.config.enforcer.PublisherPool getPool() { + if (poolBuilder_ == null) { + return pool_ == null ? org.wso2.gateway.discovery.config.enforcer.PublisherPool.getDefaultInstance() : pool_; + } else { + return poolBuilder_.getMessage(); + } + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + public Builder setPool(org.wso2.gateway.discovery.config.enforcer.PublisherPool value) { + if (poolBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + pool_ = value; + onChanged(); + } else { + poolBuilder_.setMessage(value); + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + public Builder setPool( + org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder builderForValue) { + if (poolBuilder_ == null) { + pool_ = builderForValue.build(); + onChanged(); + } else { + poolBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + public Builder mergePool(org.wso2.gateway.discovery.config.enforcer.PublisherPool value) { + if (poolBuilder_ == null) { + if (pool_ != null) { + pool_ = + org.wso2.gateway.discovery.config.enforcer.PublisherPool.newBuilder(pool_).mergeFrom(value).buildPartial(); + } else { + pool_ = value; + } + onChanged(); + } else { + poolBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + public Builder clearPool() { + if (poolBuilder_ == null) { + pool_ = null; + onChanged(); + } else { + pool_ = null; + poolBuilder_ = null; + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + public org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder getPoolBuilder() { + + onChanged(); + return getPoolFieldBuilder().getBuilder(); + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + public org.wso2.gateway.discovery.config.enforcer.PublisherPoolOrBuilder getPoolOrBuilder() { + if (poolBuilder_ != null) { + return poolBuilder_.getMessageOrBuilder(); + } else { + return pool_ == null ? + org.wso2.gateway.discovery.config.enforcer.PublisherPool.getDefaultInstance() : pool_; + } + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.PublisherPool, org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder, org.wso2.gateway.discovery.config.enforcer.PublisherPoolOrBuilder> + getPoolFieldBuilder() { + if (poolBuilder_ == null) { + poolBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.PublisherPool, org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder, org.wso2.gateway.discovery.config.enforcer.PublisherPoolOrBuilder>( + getPool(), + getParentForChildren(), + isClean()); + pool_ = null; + } + return poolBuilder_; + } + + private org.wso2.gateway.discovery.config.enforcer.ThrottleAgent agent_; + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent, org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.Builder, org.wso2.gateway.discovery.config.enforcer.ThrottleAgentOrBuilder> agentBuilder_; + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + * @return Whether the agent field is set. + */ + public boolean hasAgent() { + return agentBuilder_ != null || agent_ != null; + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + * @return The agent. + */ + public org.wso2.gateway.discovery.config.enforcer.ThrottleAgent getAgent() { + if (agentBuilder_ == null) { + return agent_ == null ? org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.getDefaultInstance() : agent_; + } else { + return agentBuilder_.getMessage(); + } + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + public Builder setAgent(org.wso2.gateway.discovery.config.enforcer.ThrottleAgent value) { + if (agentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + agent_ = value; + onChanged(); + } else { + agentBuilder_.setMessage(value); + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + public Builder setAgent( + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.Builder builderForValue) { + if (agentBuilder_ == null) { + agent_ = builderForValue.build(); + onChanged(); + } else { + agentBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + public Builder mergeAgent(org.wso2.gateway.discovery.config.enforcer.ThrottleAgent value) { + if (agentBuilder_ == null) { + if (agent_ != null) { + agent_ = + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.newBuilder(agent_).mergeFrom(value).buildPartial(); + } else { + agent_ = value; + } + onChanged(); + } else { + agentBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + public Builder clearAgent() { + if (agentBuilder_ == null) { + agent_ = null; + onChanged(); + } else { + agent_ = null; + agentBuilder_ = null; + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + public org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.Builder getAgentBuilder() { + + onChanged(); + return getAgentFieldBuilder().getBuilder(); + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + public org.wso2.gateway.discovery.config.enforcer.ThrottleAgentOrBuilder getAgentOrBuilder() { + if (agentBuilder_ != null) { + return agentBuilder_.getMessageOrBuilder(); + } else { + return agent_ == null ? + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.getDefaultInstance() : agent_; + } + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent, org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.Builder, org.wso2.gateway.discovery.config.enforcer.ThrottleAgentOrBuilder> + getAgentFieldBuilder() { + if (agentBuilder_ == null) { + agentBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent, org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.Builder, org.wso2.gateway.discovery.config.enforcer.ThrottleAgentOrBuilder>( + getAgent(), + getParentForChildren(), + isClean()); + agent_ = null; + } + return agentBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:wso2.discovery.config.enforcer.BinaryPublisher) + } + + // @@protoc_insertion_point(class_scope:wso2.discovery.config.enforcer.BinaryPublisher) + private static final org.wso2.gateway.discovery.config.enforcer.BinaryPublisher DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.wso2.gateway.discovery.config.enforcer.BinaryPublisher(); + } + + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BinaryPublisher parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BinaryPublisher(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisher getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisherOrBuilder.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisherOrBuilder.java new file mode 100644 index 0000000000..042a6257a3 --- /dev/null +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisherOrBuilder.java @@ -0,0 +1,87 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/config/enforcer/binary_publisher.proto + +package org.wso2.gateway.discovery.config.enforcer; + +public interface BinaryPublisherOrBuilder extends + // @@protoc_insertion_point(interface_extends:wso2.discovery.config.enforcer.BinaryPublisher) + com.google.protobuf.MessageOrBuilder { + + /** + * string username = 2; + * @return The username. + */ + java.lang.String getUsername(); + /** + * string username = 2; + * @return The bytes for username. + */ + com.google.protobuf.ByteString + getUsernameBytes(); + + /** + * string password = 3; + * @return The password. + */ + java.lang.String getPassword(); + /** + * string password = 3; + * @return The bytes for password. + */ + com.google.protobuf.ByteString + getPasswordBytes(); + + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + java.util.List + getUrlGroupList(); + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + org.wso2.gateway.discovery.config.enforcer.TMURLGroup getUrlGroup(int index); + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + int getUrlGroupCount(); + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + java.util.List + getUrlGroupOrBuilderList(); + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + org.wso2.gateway.discovery.config.enforcer.TMURLGroupOrBuilder getUrlGroupOrBuilder( + int index); + + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + * @return Whether the pool field is set. + */ + boolean hasPool(); + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + * @return The pool. + */ + org.wso2.gateway.discovery.config.enforcer.PublisherPool getPool(); + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + org.wso2.gateway.discovery.config.enforcer.PublisherPoolOrBuilder getPoolOrBuilder(); + + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + * @return Whether the agent field is set. + */ + boolean hasAgent(); + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + * @return The agent. + */ + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent getAgent(); + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + org.wso2.gateway.discovery.config.enforcer.ThrottleAgentOrBuilder getAgentOrBuilder(); +} diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisherProto.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisherProto.java new file mode 100644 index 0000000000..0357c5cec4 --- /dev/null +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisherProto.java @@ -0,0 +1,68 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/config/enforcer/binary_publisher.proto + +package org.wso2.gateway.discovery.config.enforcer; + +public final class BinaryPublisherProto { + private BinaryPublisherProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_wso2_discovery_config_enforcer_BinaryPublisher_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_wso2_discovery_config_enforcer_BinaryPublisher_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n5wso2/discovery/config/enforcer/binary_" + + "publisher.proto\022\036wso2.discovery.config.e" + + "nforcer\0321wso2/discovery/config/enforcer/" + + "tm_url_group.proto\032bool enabled = 1; - * @return The enabled. - */ - @java.lang.Override - public boolean getEnabled() { - return enabled_; - } - public static final int USERNAME_FIELD_NUMBER = 2; private volatile java.lang.Object username_; /** @@ -332,9 +316,6 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (enabled_ != false) { - output.writeBool(1, enabled_); - } if (!getUsernameBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 2, username_); } @@ -359,10 +340,6 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (enabled_ != false) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(1, enabled_); - } if (!getUsernameBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, username_); } @@ -396,8 +373,6 @@ public boolean equals(final java.lang.Object obj) { } org.wso2.gateway.discovery.config.enforcer.BinaryThrottling other = (org.wso2.gateway.discovery.config.enforcer.BinaryThrottling) obj; - if (getEnabled() - != other.getEnabled()) return false; if (!getUsername() .equals(other.getUsername())) return false; if (!getPassword() @@ -425,9 +400,6 @@ public int hashCode() { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + ENABLED_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( - getEnabled()); hash = (37 * hash) + USERNAME_FIELD_NUMBER; hash = (53 * hash) + getUsername().hashCode(); hash = (37 * hash) + PASSWORD_FIELD_NUMBER; @@ -578,8 +550,6 @@ private void maybeForceBuilderInitialization() { @java.lang.Override public Builder clear() { super.clear(); - enabled_ = false; - username_ = ""; password_ = ""; @@ -629,7 +599,6 @@ public org.wso2.gateway.discovery.config.enforcer.BinaryThrottling build() { public org.wso2.gateway.discovery.config.enforcer.BinaryThrottling buildPartial() { org.wso2.gateway.discovery.config.enforcer.BinaryThrottling result = new org.wso2.gateway.discovery.config.enforcer.BinaryThrottling(this); int from_bitField0_ = bitField0_; - result.enabled_ = enabled_; result.username_ = username_; result.password_ = password_; if (urlGroupBuilder_ == null) { @@ -699,9 +668,6 @@ public Builder mergeFrom(com.google.protobuf.Message other) { public Builder mergeFrom(org.wso2.gateway.discovery.config.enforcer.BinaryThrottling other) { if (other == org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.getDefaultInstance()) return this; - if (other.getEnabled() != false) { - setEnabled(other.getEnabled()); - } if (!other.getUsername().isEmpty()) { username_ = other.username_; onChanged(); @@ -772,37 +738,6 @@ public Builder mergeFrom( } private int bitField0_; - private boolean enabled_ ; - /** - * bool enabled = 1; - * @return The enabled. - */ - @java.lang.Override - public boolean getEnabled() { - return enabled_; - } - /** - * bool enabled = 1; - * @param value The enabled to set. - * @return This builder for chaining. - */ - public Builder setEnabled(boolean value) { - - enabled_ = value; - onChanged(); - return this; - } - /** - * bool enabled = 1; - * @return This builder for chaining. - */ - public Builder clearEnabled() { - - enabled_ = false; - onChanged(); - return this; - } - private java.lang.Object username_ = ""; /** * string username = 2; diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingOrBuilder.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingOrBuilder.java index 38c0c6ba41..26ba771704 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingOrBuilder.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingOrBuilder.java @@ -7,12 +7,6 @@ public interface BinaryThrottlingOrBuilder extends // @@protoc_insertion_point(interface_extends:wso2.discovery.config.enforcer.BinaryThrottling) com.google.protobuf.MessageOrBuilder { - /** - * bool enabled = 1; - * @return The enabled. - */ - boolean getEnabled(); - /** * string username = 2; * @return The username. diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingProto.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingProto.java index f5f4be689d..c737602d4b 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingProto.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingProto.java @@ -34,17 +34,17 @@ public static void registerAllExtensions( "/tm_url_group.proto\0327wso2/discovery/conf" + "ig/enforcer/throttle_publisher.proto\0323ws" + "o2/discovery/config/enforcer/throttle_ag" + - "ent.proto\"\211\002\n\020BinaryThrottling\022\017\n\007enable" + - "d\030\001 \001(\010\022\020\n\010username\030\002 \001(\t\022\020\n\010password\030\003 " + - "\001(\t\022<\n\010urlGroup\030\004 \003(\0132*.wso2.discovery.c" + - "onfig.enforcer.TMURLGroup\022D\n\tpublisher\030\005" + - " \001(\01321.wso2.discovery.config.enforcer.Th" + - "rottlePublisher\022<\n\005agent\030\006 \001(\0132-.wso2.di" + - "scovery.config.enforcer.ThrottleAgentB\225\001" + - "\n*org.wso2.gateway.discovery.config.enfo" + - "rcerB\025BinaryThrottlingProtoP\001ZNgithub.co" + - "m/envoyproxy/go-control-plane/wso2/disco" + - "very/config/enforcer;enforcerb\006proto3" + "ent.proto\"\370\001\n\020BinaryThrottling\022\020\n\010userna" + + "me\030\002 \001(\t\022\020\n\010password\030\003 \001(\t\022<\n\010urlGroup\030\004" + + " \003(\0132*.wso2.discovery.config.enforcer.TM" + + "URLGroup\022D\n\tpublisher\030\005 \001(\01321.wso2.disco" + + "very.config.enforcer.ThrottlePublisher\022<" + + "\n\005agent\030\006 \001(\0132-.wso2.discovery.config.en" + + "forcer.ThrottleAgentB\225\001\n*org.wso2.gatewa" + + "y.discovery.config.enforcerB\025BinaryThrot" + + "tlingProtoP\001ZNgithub.com/envoyproxy/go-c" + + "ontrol-plane/wso2/discovery/config/enfor" + + "cer;enforcerb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -58,7 +58,7 @@ public static void registerAllExtensions( internal_static_wso2_discovery_config_enforcer_BinaryThrottling_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_config_enforcer_BinaryThrottling_descriptor, - new java.lang.String[] { "Enabled", "Username", "Password", "UrlGroup", "Publisher", "Agent", }); + new java.lang.String[] { "Username", "Password", "UrlGroup", "Publisher", "Agent", }); org.wso2.gateway.discovery.config.enforcer.TMURLGroupProto.getDescriptor(); org.wso2.gateway.discovery.config.enforcer.ThrottlePublishergProto.getDescriptor(); org.wso2.gateway.discovery.config.enforcer.ThrottleAgentProto.getDescriptor(); diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/Config.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/Config.java index a9633015ee..b78e64028e 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/Config.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/Config.java @@ -143,13 +143,13 @@ private Config( } case 66: { org.wso2.gateway.discovery.config.enforcer.Throttling.Builder subBuilder = null; - if (throttlingConfig_ != null) { - subBuilder = throttlingConfig_.toBuilder(); + if (throttling_ != null) { + subBuilder = throttling_.toBuilder(); } - throttlingConfig_ = input.readMessage(org.wso2.gateway.discovery.config.enforcer.Throttling.parser(), extensionRegistry); + throttling_ = input.readMessage(org.wso2.gateway.discovery.config.enforcer.Throttling.parser(), extensionRegistry); if (subBuilder != null) { - subBuilder.mergeFrom(throttlingConfig_); - throttlingConfig_ = subBuilder.buildPartial(); + subBuilder.mergeFrom(throttling_); + throttling_ = subBuilder.buildPartial(); } break; @@ -411,30 +411,30 @@ public org.wso2.gateway.discovery.config.enforcer.JWTGeneratorOrBuilder getJwtGe return getJwtGenerator(); } - public static final int THROTTLINGCONFIG_FIELD_NUMBER = 8; - private org.wso2.gateway.discovery.config.enforcer.Throttling throttlingConfig_; + public static final int THROTTLING_FIELD_NUMBER = 8; + private org.wso2.gateway.discovery.config.enforcer.Throttling throttling_; /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; - * @return Whether the throttlingConfig field is set. + * .wso2.discovery.config.enforcer.Throttling throttling = 8; + * @return Whether the throttling field is set. */ @java.lang.Override - public boolean hasThrottlingConfig() { - return throttlingConfig_ != null; + public boolean hasThrottling() { + return throttling_ != null; } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; - * @return The throttlingConfig. + * .wso2.discovery.config.enforcer.Throttling throttling = 8; + * @return The throttling. */ @java.lang.Override - public org.wso2.gateway.discovery.config.enforcer.Throttling getThrottlingConfig() { - return throttlingConfig_ == null ? org.wso2.gateway.discovery.config.enforcer.Throttling.getDefaultInstance() : throttlingConfig_; + public org.wso2.gateway.discovery.config.enforcer.Throttling getThrottling() { + return throttling_ == null ? org.wso2.gateway.discovery.config.enforcer.Throttling.getDefaultInstance() : throttling_; } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ @java.lang.Override - public org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder getThrottlingConfigOrBuilder() { - return getThrottlingConfig(); + public org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder getThrottlingOrBuilder() { + return getThrottling(); } public static final int CACHE_FIELD_NUMBER = 9; @@ -524,8 +524,8 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (jwtGenerator_ != null) { output.writeMessage(7, getJwtGenerator()); } - if (throttlingConfig_ != null) { - output.writeMessage(8, getThrottlingConfig()); + if (throttling_ != null) { + output.writeMessage(8, getThrottling()); } if (cache_ != null) { output.writeMessage(9, getCache()); @@ -570,9 +570,9 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeMessageSize(7, getJwtGenerator()); } - if (throttlingConfig_ != null) { + if (throttling_ != null) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(8, getThrottlingConfig()); + .computeMessageSize(8, getThrottling()); } if (cache_ != null) { size += com.google.protobuf.CodedOutputStream @@ -629,10 +629,10 @@ public boolean equals(final java.lang.Object obj) { if (!getJwtGenerator() .equals(other.getJwtGenerator())) return false; } - if (hasThrottlingConfig() != other.hasThrottlingConfig()) return false; - if (hasThrottlingConfig()) { - if (!getThrottlingConfig() - .equals(other.getThrottlingConfig())) return false; + if (hasThrottling() != other.hasThrottling()) return false; + if (hasThrottling()) { + if (!getThrottling() + .equals(other.getThrottling())) return false; } if (hasCache() != other.hasCache()) return false; if (hasCache()) { @@ -683,9 +683,9 @@ public int hashCode() { hash = (37 * hash) + JWTGENERATOR_FIELD_NUMBER; hash = (53 * hash) + getJwtGenerator().hashCode(); } - if (hasThrottlingConfig()) { - hash = (37 * hash) + THROTTLINGCONFIG_FIELD_NUMBER; - hash = (53 * hash) + getThrottlingConfig().hashCode(); + if (hasThrottling()) { + hash = (37 * hash) + THROTTLING_FIELD_NUMBER; + hash = (53 * hash) + getThrottling().hashCode(); } if (hasCache()) { hash = (37 * hash) + CACHE_FIELD_NUMBER; @@ -875,11 +875,11 @@ public Builder clear() { jwtGenerator_ = null; jwtGeneratorBuilder_ = null; } - if (throttlingConfigBuilder_ == null) { - throttlingConfig_ = null; + if (throttlingBuilder_ == null) { + throttling_ = null; } else { - throttlingConfig_ = null; - throttlingConfigBuilder_ = null; + throttling_ = null; + throttlingBuilder_ = null; } if (cacheBuilder_ == null) { cache_ = null; @@ -959,10 +959,10 @@ public org.wso2.gateway.discovery.config.enforcer.Config buildPartial() { } else { result.jwtGenerator_ = jwtGeneratorBuilder_.build(); } - if (throttlingConfigBuilder_ == null) { - result.throttlingConfig_ = throttlingConfig_; + if (throttlingBuilder_ == null) { + result.throttling_ = throttling_; } else { - result.throttlingConfig_ = throttlingConfigBuilder_.build(); + result.throttling_ = throttlingBuilder_.build(); } if (cacheBuilder_ == null) { result.cache_ = cache_; @@ -1066,8 +1066,8 @@ public Builder mergeFrom(org.wso2.gateway.discovery.config.enforcer.Config other if (other.hasJwtGenerator()) { mergeJwtGenerator(other.getJwtGenerator()); } - if (other.hasThrottlingConfig()) { - mergeThrottlingConfig(other.getThrottlingConfig()); + if (other.hasThrottling()) { + mergeThrottling(other.getThrottling()); } if (other.hasCache()) { mergeCache(other.getCache()); @@ -2059,123 +2059,123 @@ public org.wso2.gateway.discovery.config.enforcer.JWTGeneratorOrBuilder getJwtGe return jwtGeneratorBuilder_; } - private org.wso2.gateway.discovery.config.enforcer.Throttling throttlingConfig_; + private org.wso2.gateway.discovery.config.enforcer.Throttling throttling_; private com.google.protobuf.SingleFieldBuilderV3< - org.wso2.gateway.discovery.config.enforcer.Throttling, org.wso2.gateway.discovery.config.enforcer.Throttling.Builder, org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder> throttlingConfigBuilder_; + org.wso2.gateway.discovery.config.enforcer.Throttling, org.wso2.gateway.discovery.config.enforcer.Throttling.Builder, org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder> throttlingBuilder_; /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; - * @return Whether the throttlingConfig field is set. + * .wso2.discovery.config.enforcer.Throttling throttling = 8; + * @return Whether the throttling field is set. */ - public boolean hasThrottlingConfig() { - return throttlingConfigBuilder_ != null || throttlingConfig_ != null; + public boolean hasThrottling() { + return throttlingBuilder_ != null || throttling_ != null; } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; - * @return The throttlingConfig. + * .wso2.discovery.config.enforcer.Throttling throttling = 8; + * @return The throttling. */ - public org.wso2.gateway.discovery.config.enforcer.Throttling getThrottlingConfig() { - if (throttlingConfigBuilder_ == null) { - return throttlingConfig_ == null ? org.wso2.gateway.discovery.config.enforcer.Throttling.getDefaultInstance() : throttlingConfig_; + public org.wso2.gateway.discovery.config.enforcer.Throttling getThrottling() { + if (throttlingBuilder_ == null) { + return throttling_ == null ? org.wso2.gateway.discovery.config.enforcer.Throttling.getDefaultInstance() : throttling_; } else { - return throttlingConfigBuilder_.getMessage(); + return throttlingBuilder_.getMessage(); } } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ - public Builder setThrottlingConfig(org.wso2.gateway.discovery.config.enforcer.Throttling value) { - if (throttlingConfigBuilder_ == null) { + public Builder setThrottling(org.wso2.gateway.discovery.config.enforcer.Throttling value) { + if (throttlingBuilder_ == null) { if (value == null) { throw new NullPointerException(); } - throttlingConfig_ = value; + throttling_ = value; onChanged(); } else { - throttlingConfigBuilder_.setMessage(value); + throttlingBuilder_.setMessage(value); } return this; } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ - public Builder setThrottlingConfig( + public Builder setThrottling( org.wso2.gateway.discovery.config.enforcer.Throttling.Builder builderForValue) { - if (throttlingConfigBuilder_ == null) { - throttlingConfig_ = builderForValue.build(); + if (throttlingBuilder_ == null) { + throttling_ = builderForValue.build(); onChanged(); } else { - throttlingConfigBuilder_.setMessage(builderForValue.build()); + throttlingBuilder_.setMessage(builderForValue.build()); } return this; } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ - public Builder mergeThrottlingConfig(org.wso2.gateway.discovery.config.enforcer.Throttling value) { - if (throttlingConfigBuilder_ == null) { - if (throttlingConfig_ != null) { - throttlingConfig_ = - org.wso2.gateway.discovery.config.enforcer.Throttling.newBuilder(throttlingConfig_).mergeFrom(value).buildPartial(); + public Builder mergeThrottling(org.wso2.gateway.discovery.config.enforcer.Throttling value) { + if (throttlingBuilder_ == null) { + if (throttling_ != null) { + throttling_ = + org.wso2.gateway.discovery.config.enforcer.Throttling.newBuilder(throttling_).mergeFrom(value).buildPartial(); } else { - throttlingConfig_ = value; + throttling_ = value; } onChanged(); } else { - throttlingConfigBuilder_.mergeFrom(value); + throttlingBuilder_.mergeFrom(value); } return this; } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ - public Builder clearThrottlingConfig() { - if (throttlingConfigBuilder_ == null) { - throttlingConfig_ = null; + public Builder clearThrottling() { + if (throttlingBuilder_ == null) { + throttling_ = null; onChanged(); } else { - throttlingConfig_ = null; - throttlingConfigBuilder_ = null; + throttling_ = null; + throttlingBuilder_ = null; } return this; } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ - public org.wso2.gateway.discovery.config.enforcer.Throttling.Builder getThrottlingConfigBuilder() { + public org.wso2.gateway.discovery.config.enforcer.Throttling.Builder getThrottlingBuilder() { onChanged(); - return getThrottlingConfigFieldBuilder().getBuilder(); + return getThrottlingFieldBuilder().getBuilder(); } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ - public org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder getThrottlingConfigOrBuilder() { - if (throttlingConfigBuilder_ != null) { - return throttlingConfigBuilder_.getMessageOrBuilder(); + public org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder getThrottlingOrBuilder() { + if (throttlingBuilder_ != null) { + return throttlingBuilder_.getMessageOrBuilder(); } else { - return throttlingConfig_ == null ? - org.wso2.gateway.discovery.config.enforcer.Throttling.getDefaultInstance() : throttlingConfig_; + return throttling_ == null ? + org.wso2.gateway.discovery.config.enforcer.Throttling.getDefaultInstance() : throttling_; } } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ private com.google.protobuf.SingleFieldBuilderV3< org.wso2.gateway.discovery.config.enforcer.Throttling, org.wso2.gateway.discovery.config.enforcer.Throttling.Builder, org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder> - getThrottlingConfigFieldBuilder() { - if (throttlingConfigBuilder_ == null) { - throttlingConfigBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + getThrottlingFieldBuilder() { + if (throttlingBuilder_ == null) { + throttlingBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< org.wso2.gateway.discovery.config.enforcer.Throttling, org.wso2.gateway.discovery.config.enforcer.Throttling.Builder, org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder>( - getThrottlingConfig(), + getThrottling(), getParentForChildren(), isClean()); - throttlingConfig_ = null; + throttling_ = null; } - return throttlingConfigBuilder_; + return throttlingBuilder_; } private org.wso2.gateway.discovery.config.enforcer.Cache cache_; diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigOrBuilder.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigOrBuilder.java index b8f600ad38..9ad72f6a88 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigOrBuilder.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigOrBuilder.java @@ -122,19 +122,19 @@ org.wso2.gateway.discovery.config.enforcer.IssuerOrBuilder getJwtTokenConfigOrBu org.wso2.gateway.discovery.config.enforcer.JWTGeneratorOrBuilder getJwtGeneratorOrBuilder(); /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; - * @return Whether the throttlingConfig field is set. + * .wso2.discovery.config.enforcer.Throttling throttling = 8; + * @return Whether the throttling field is set. */ - boolean hasThrottlingConfig(); + boolean hasThrottling(); /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; - * @return The throttlingConfig. + * .wso2.discovery.config.enforcer.Throttling throttling = 8; + * @return The throttling. */ - org.wso2.gateway.discovery.config.enforcer.Throttling getThrottlingConfig(); + org.wso2.gateway.discovery.config.enforcer.Throttling getThrottling(); /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ - org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder getThrottlingConfigOrBuilder(); + org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder getThrottlingOrBuilder(); /** * .wso2.discovery.config.enforcer.Cache cache = 9; diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigProto.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigProto.java index 19124459d5..4840b11ed6 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigProto.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigProto.java @@ -40,7 +40,7 @@ public static void registerAllExtensions( "tor.proto\032/wso2/discovery/config/enforce" + "r/jwt_issuer.proto\032/wso2/discovery/confi" + "g/enforcer/throttling.proto\032*wso2/discov" + - "ery/config/enforcer/cache.proto\"\210\005\n\006Conf" + + "ery/config/enforcer/cache.proto\"\202\005\n\006Conf" + "ig\022>\n\016jwtTokenConfig\030\001 \003(\0132&.wso2.discov" + "ery.config.enforcer.Issuer\022;\n\010keystore\030\002" + " \001(\0132).wso2.discovery.config.enforcer.Ce" + @@ -52,15 +52,15 @@ public static void registerAllExtensions( "apimCredentials\030\006 \001(\0132-.wso2.discovery.c" + "onfig.enforcer.AmCredentials\022B\n\014jwtGener" + "ator\030\007 \001(\0132,.wso2.discovery.config.enfor" + - "cer.JWTGenerator\022D\n\020throttlingConfig\030\010 \001" + - "(\0132*.wso2.discovery.config.enforcer.Thro" + - "ttling\0224\n\005cache\030\t \001(\0132%.wso2.discovery.c" + - "onfig.enforcer.Cache\022<\n\tjwtIssuer\030\n \001(\0132" + - ").wso2.discovery.config.enforcer.JWTIssu" + - "erB\213\001\n*org.wso2.gateway.discovery.config" + - ".enforcerB\013ConfigProtoP\001ZNgithub.com/env" + - "oyproxy/go-control-plane/wso2/discovery/" + - "config/enforcer;enforcerb\006proto3" + "cer.JWTGenerator\022>\n\nthrottling\030\010 \001(\0132*.w" + + "so2.discovery.config.enforcer.Throttling" + + "\0224\n\005cache\030\t \001(\0132%.wso2.discovery.config." + + "enforcer.Cache\022<\n\tjwtIssuer\030\n \001(\0132).wso2" + + ".discovery.config.enforcer.JWTIssuerB\213\001\n" + + "*org.wso2.gateway.discovery.config.enfor" + + "cerB\013ConfigProtoP\001ZNgithub.com/envoyprox" + + "y/go-control-plane/wso2/discovery/config" + + "/enforcer;enforcerb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -80,7 +80,7 @@ public static void registerAllExtensions( internal_static_wso2_discovery_config_enforcer_Config_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_config_enforcer_Config_descriptor, - new java.lang.String[] { "JwtTokenConfig", "Keystore", "Truststore", "Eventhub", "AuthService", "ApimCredentials", "JwtGenerator", "ThrottlingConfig", "Cache", "JwtIssuer", }); + new java.lang.String[] { "JwtTokenConfig", "Keystore", "Truststore", "Eventhub", "AuthService", "ApimCredentials", "JwtGenerator", "Throttling", "Cache", "JwtIssuer", }); org.wso2.gateway.discovery.config.enforcer.CertStoreProto.getDescriptor(); org.wso2.gateway.discovery.config.enforcer.IssuerProto.getDescriptor(); org.wso2.gateway.discovery.config.enforcer.EventHubProto.getDescriptor(); diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPool.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPool.java new file mode 100644 index 0000000000..20ee1d8f25 --- /dev/null +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPool.java @@ -0,0 +1,747 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/config/enforcer/throttle_publisher_pool.proto + +package org.wso2.gateway.discovery.config.enforcer; + +/** + *
+ * Throttle Publisher pool configuration model
+ * 
+ * + * Protobuf type {@code wso2.discovery.config.enforcer.PublisherPool} + */ +public final class PublisherPool extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:wso2.discovery.config.enforcer.PublisherPool) + PublisherPoolOrBuilder { +private static final long serialVersionUID = 0L; + // Use PublisherPool.newBuilder() to construct. + private PublisherPool(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private PublisherPool() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new PublisherPool(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PublisherPool( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + maxIdleDataPublishingAgents_ = input.readInt32(); + break; + } + case 16: { + + initIdleObjectDataPublishingAgents_ = input.readInt32(); + break; + } + case 24: { + + publisherThreadPoolCoreSize_ = input.readInt32(); + break; + } + case 32: { + + publisherThreadPoolMaximumSize_ = input.readInt32(); + break; + } + case 40: { + + publisherThreadPoolKeepAliveTime_ = input.readInt32(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.gateway.discovery.config.enforcer.PublisherPoolProto.internal_static_wso2_discovery_config_enforcer_PublisherPool_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.gateway.discovery.config.enforcer.PublisherPoolProto.internal_static_wso2_discovery_config_enforcer_PublisherPool_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.gateway.discovery.config.enforcer.PublisherPool.class, org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder.class); + } + + public static final int MAXIDLEDATAPUBLISHINGAGENTS_FIELD_NUMBER = 1; + private int maxIdleDataPublishingAgents_; + /** + * int32 maxIdleDataPublishingAgents = 1; + * @return The maxIdleDataPublishingAgents. + */ + @java.lang.Override + public int getMaxIdleDataPublishingAgents() { + return maxIdleDataPublishingAgents_; + } + + public static final int INITIDLEOBJECTDATAPUBLISHINGAGENTS_FIELD_NUMBER = 2; + private int initIdleObjectDataPublishingAgents_; + /** + * int32 initIdleObjectDataPublishingAgents = 2; + * @return The initIdleObjectDataPublishingAgents. + */ + @java.lang.Override + public int getInitIdleObjectDataPublishingAgents() { + return initIdleObjectDataPublishingAgents_; + } + + public static final int PUBLISHERTHREADPOOLCORESIZE_FIELD_NUMBER = 3; + private int publisherThreadPoolCoreSize_; + /** + * int32 publisherThreadPoolCoreSize = 3; + * @return The publisherThreadPoolCoreSize. + */ + @java.lang.Override + public int getPublisherThreadPoolCoreSize() { + return publisherThreadPoolCoreSize_; + } + + public static final int PUBLISHERTHREADPOOLMAXIMUMSIZE_FIELD_NUMBER = 4; + private int publisherThreadPoolMaximumSize_; + /** + * int32 publisherThreadPoolMaximumSize = 4; + * @return The publisherThreadPoolMaximumSize. + */ + @java.lang.Override + public int getPublisherThreadPoolMaximumSize() { + return publisherThreadPoolMaximumSize_; + } + + public static final int PUBLISHERTHREADPOOLKEEPALIVETIME_FIELD_NUMBER = 5; + private int publisherThreadPoolKeepAliveTime_; + /** + * int32 publisherThreadPoolKeepAliveTime = 5; + * @return The publisherThreadPoolKeepAliveTime. + */ + @java.lang.Override + public int getPublisherThreadPoolKeepAliveTime() { + return publisherThreadPoolKeepAliveTime_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (maxIdleDataPublishingAgents_ != 0) { + output.writeInt32(1, maxIdleDataPublishingAgents_); + } + if (initIdleObjectDataPublishingAgents_ != 0) { + output.writeInt32(2, initIdleObjectDataPublishingAgents_); + } + if (publisherThreadPoolCoreSize_ != 0) { + output.writeInt32(3, publisherThreadPoolCoreSize_); + } + if (publisherThreadPoolMaximumSize_ != 0) { + output.writeInt32(4, publisherThreadPoolMaximumSize_); + } + if (publisherThreadPoolKeepAliveTime_ != 0) { + output.writeInt32(5, publisherThreadPoolKeepAliveTime_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (maxIdleDataPublishingAgents_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, maxIdleDataPublishingAgents_); + } + if (initIdleObjectDataPublishingAgents_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, initIdleObjectDataPublishingAgents_); + } + if (publisherThreadPoolCoreSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, publisherThreadPoolCoreSize_); + } + if (publisherThreadPoolMaximumSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(4, publisherThreadPoolMaximumSize_); + } + if (publisherThreadPoolKeepAliveTime_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(5, publisherThreadPoolKeepAliveTime_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.wso2.gateway.discovery.config.enforcer.PublisherPool)) { + return super.equals(obj); + } + org.wso2.gateway.discovery.config.enforcer.PublisherPool other = (org.wso2.gateway.discovery.config.enforcer.PublisherPool) obj; + + if (getMaxIdleDataPublishingAgents() + != other.getMaxIdleDataPublishingAgents()) return false; + if (getInitIdleObjectDataPublishingAgents() + != other.getInitIdleObjectDataPublishingAgents()) return false; + if (getPublisherThreadPoolCoreSize() + != other.getPublisherThreadPoolCoreSize()) return false; + if (getPublisherThreadPoolMaximumSize() + != other.getPublisherThreadPoolMaximumSize()) return false; + if (getPublisherThreadPoolKeepAliveTime() + != other.getPublisherThreadPoolKeepAliveTime()) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + MAXIDLEDATAPUBLISHINGAGENTS_FIELD_NUMBER; + hash = (53 * hash) + getMaxIdleDataPublishingAgents(); + hash = (37 * hash) + INITIDLEOBJECTDATAPUBLISHINGAGENTS_FIELD_NUMBER; + hash = (53 * hash) + getInitIdleObjectDataPublishingAgents(); + hash = (37 * hash) + PUBLISHERTHREADPOOLCORESIZE_FIELD_NUMBER; + hash = (53 * hash) + getPublisherThreadPoolCoreSize(); + hash = (37 * hash) + PUBLISHERTHREADPOOLMAXIMUMSIZE_FIELD_NUMBER; + hash = (53 * hash) + getPublisherThreadPoolMaximumSize(); + hash = (37 * hash) + PUBLISHERTHREADPOOLKEEPALIVETIME_FIELD_NUMBER; + hash = (53 * hash) + getPublisherThreadPoolKeepAliveTime(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.wso2.gateway.discovery.config.enforcer.PublisherPool prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * Throttle Publisher pool configuration model
+   * 
+ * + * Protobuf type {@code wso2.discovery.config.enforcer.PublisherPool} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:wso2.discovery.config.enforcer.PublisherPool) + org.wso2.gateway.discovery.config.enforcer.PublisherPoolOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.gateway.discovery.config.enforcer.PublisherPoolProto.internal_static_wso2_discovery_config_enforcer_PublisherPool_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.gateway.discovery.config.enforcer.PublisherPoolProto.internal_static_wso2_discovery_config_enforcer_PublisherPool_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.gateway.discovery.config.enforcer.PublisherPool.class, org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder.class); + } + + // Construct using org.wso2.gateway.discovery.config.enforcer.PublisherPool.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + maxIdleDataPublishingAgents_ = 0; + + initIdleObjectDataPublishingAgents_ = 0; + + publisherThreadPoolCoreSize_ = 0; + + publisherThreadPoolMaximumSize_ = 0; + + publisherThreadPoolKeepAliveTime_ = 0; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.wso2.gateway.discovery.config.enforcer.PublisherPoolProto.internal_static_wso2_discovery_config_enforcer_PublisherPool_descriptor; + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.PublisherPool getDefaultInstanceForType() { + return org.wso2.gateway.discovery.config.enforcer.PublisherPool.getDefaultInstance(); + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.PublisherPool build() { + org.wso2.gateway.discovery.config.enforcer.PublisherPool result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.PublisherPool buildPartial() { + org.wso2.gateway.discovery.config.enforcer.PublisherPool result = new org.wso2.gateway.discovery.config.enforcer.PublisherPool(this); + result.maxIdleDataPublishingAgents_ = maxIdleDataPublishingAgents_; + result.initIdleObjectDataPublishingAgents_ = initIdleObjectDataPublishingAgents_; + result.publisherThreadPoolCoreSize_ = publisherThreadPoolCoreSize_; + result.publisherThreadPoolMaximumSize_ = publisherThreadPoolMaximumSize_; + result.publisherThreadPoolKeepAliveTime_ = publisherThreadPoolKeepAliveTime_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.wso2.gateway.discovery.config.enforcer.PublisherPool) { + return mergeFrom((org.wso2.gateway.discovery.config.enforcer.PublisherPool)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.wso2.gateway.discovery.config.enforcer.PublisherPool other) { + if (other == org.wso2.gateway.discovery.config.enforcer.PublisherPool.getDefaultInstance()) return this; + if (other.getMaxIdleDataPublishingAgents() != 0) { + setMaxIdleDataPublishingAgents(other.getMaxIdleDataPublishingAgents()); + } + if (other.getInitIdleObjectDataPublishingAgents() != 0) { + setInitIdleObjectDataPublishingAgents(other.getInitIdleObjectDataPublishingAgents()); + } + if (other.getPublisherThreadPoolCoreSize() != 0) { + setPublisherThreadPoolCoreSize(other.getPublisherThreadPoolCoreSize()); + } + if (other.getPublisherThreadPoolMaximumSize() != 0) { + setPublisherThreadPoolMaximumSize(other.getPublisherThreadPoolMaximumSize()); + } + if (other.getPublisherThreadPoolKeepAliveTime() != 0) { + setPublisherThreadPoolKeepAliveTime(other.getPublisherThreadPoolKeepAliveTime()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.wso2.gateway.discovery.config.enforcer.PublisherPool parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.wso2.gateway.discovery.config.enforcer.PublisherPool) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int maxIdleDataPublishingAgents_ ; + /** + * int32 maxIdleDataPublishingAgents = 1; + * @return The maxIdleDataPublishingAgents. + */ + @java.lang.Override + public int getMaxIdleDataPublishingAgents() { + return maxIdleDataPublishingAgents_; + } + /** + * int32 maxIdleDataPublishingAgents = 1; + * @param value The maxIdleDataPublishingAgents to set. + * @return This builder for chaining. + */ + public Builder setMaxIdleDataPublishingAgents(int value) { + + maxIdleDataPublishingAgents_ = value; + onChanged(); + return this; + } + /** + * int32 maxIdleDataPublishingAgents = 1; + * @return This builder for chaining. + */ + public Builder clearMaxIdleDataPublishingAgents() { + + maxIdleDataPublishingAgents_ = 0; + onChanged(); + return this; + } + + private int initIdleObjectDataPublishingAgents_ ; + /** + * int32 initIdleObjectDataPublishingAgents = 2; + * @return The initIdleObjectDataPublishingAgents. + */ + @java.lang.Override + public int getInitIdleObjectDataPublishingAgents() { + return initIdleObjectDataPublishingAgents_; + } + /** + * int32 initIdleObjectDataPublishingAgents = 2; + * @param value The initIdleObjectDataPublishingAgents to set. + * @return This builder for chaining. + */ + public Builder setInitIdleObjectDataPublishingAgents(int value) { + + initIdleObjectDataPublishingAgents_ = value; + onChanged(); + return this; + } + /** + * int32 initIdleObjectDataPublishingAgents = 2; + * @return This builder for chaining. + */ + public Builder clearInitIdleObjectDataPublishingAgents() { + + initIdleObjectDataPublishingAgents_ = 0; + onChanged(); + return this; + } + + private int publisherThreadPoolCoreSize_ ; + /** + * int32 publisherThreadPoolCoreSize = 3; + * @return The publisherThreadPoolCoreSize. + */ + @java.lang.Override + public int getPublisherThreadPoolCoreSize() { + return publisherThreadPoolCoreSize_; + } + /** + * int32 publisherThreadPoolCoreSize = 3; + * @param value The publisherThreadPoolCoreSize to set. + * @return This builder for chaining. + */ + public Builder setPublisherThreadPoolCoreSize(int value) { + + publisherThreadPoolCoreSize_ = value; + onChanged(); + return this; + } + /** + * int32 publisherThreadPoolCoreSize = 3; + * @return This builder for chaining. + */ + public Builder clearPublisherThreadPoolCoreSize() { + + publisherThreadPoolCoreSize_ = 0; + onChanged(); + return this; + } + + private int publisherThreadPoolMaximumSize_ ; + /** + * int32 publisherThreadPoolMaximumSize = 4; + * @return The publisherThreadPoolMaximumSize. + */ + @java.lang.Override + public int getPublisherThreadPoolMaximumSize() { + return publisherThreadPoolMaximumSize_; + } + /** + * int32 publisherThreadPoolMaximumSize = 4; + * @param value The publisherThreadPoolMaximumSize to set. + * @return This builder for chaining. + */ + public Builder setPublisherThreadPoolMaximumSize(int value) { + + publisherThreadPoolMaximumSize_ = value; + onChanged(); + return this; + } + /** + * int32 publisherThreadPoolMaximumSize = 4; + * @return This builder for chaining. + */ + public Builder clearPublisherThreadPoolMaximumSize() { + + publisherThreadPoolMaximumSize_ = 0; + onChanged(); + return this; + } + + private int publisherThreadPoolKeepAliveTime_ ; + /** + * int32 publisherThreadPoolKeepAliveTime = 5; + * @return The publisherThreadPoolKeepAliveTime. + */ + @java.lang.Override + public int getPublisherThreadPoolKeepAliveTime() { + return publisherThreadPoolKeepAliveTime_; + } + /** + * int32 publisherThreadPoolKeepAliveTime = 5; + * @param value The publisherThreadPoolKeepAliveTime to set. + * @return This builder for chaining. + */ + public Builder setPublisherThreadPoolKeepAliveTime(int value) { + + publisherThreadPoolKeepAliveTime_ = value; + onChanged(); + return this; + } + /** + * int32 publisherThreadPoolKeepAliveTime = 5; + * @return This builder for chaining. + */ + public Builder clearPublisherThreadPoolKeepAliveTime() { + + publisherThreadPoolKeepAliveTime_ = 0; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:wso2.discovery.config.enforcer.PublisherPool) + } + + // @@protoc_insertion_point(class_scope:wso2.discovery.config.enforcer.PublisherPool) + private static final org.wso2.gateway.discovery.config.enforcer.PublisherPool DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.wso2.gateway.discovery.config.enforcer.PublisherPool(); + } + + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PublisherPool parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PublisherPool(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.PublisherPool getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPoolOrBuilder.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPoolOrBuilder.java new file mode 100644 index 0000000000..4b582b9dae --- /dev/null +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPoolOrBuilder.java @@ -0,0 +1,39 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/config/enforcer/throttle_publisher_pool.proto + +package org.wso2.gateway.discovery.config.enforcer; + +public interface PublisherPoolOrBuilder extends + // @@protoc_insertion_point(interface_extends:wso2.discovery.config.enforcer.PublisherPool) + com.google.protobuf.MessageOrBuilder { + + /** + * int32 maxIdleDataPublishingAgents = 1; + * @return The maxIdleDataPublishingAgents. + */ + int getMaxIdleDataPublishingAgents(); + + /** + * int32 initIdleObjectDataPublishingAgents = 2; + * @return The initIdleObjectDataPublishingAgents. + */ + int getInitIdleObjectDataPublishingAgents(); + + /** + * int32 publisherThreadPoolCoreSize = 3; + * @return The publisherThreadPoolCoreSize. + */ + int getPublisherThreadPoolCoreSize(); + + /** + * int32 publisherThreadPoolMaximumSize = 4; + * @return The publisherThreadPoolMaximumSize. + */ + int getPublisherThreadPoolMaximumSize(); + + /** + * int32 publisherThreadPoolKeepAliveTime = 5; + * @return The publisherThreadPoolKeepAliveTime. + */ + int getPublisherThreadPoolKeepAliveTime(); +} diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPoolProto.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPoolProto.java new file mode 100644 index 0000000000..2ed1db3fce --- /dev/null +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPoolProto.java @@ -0,0 +1,57 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/config/enforcer/throttle_publisher_pool.proto + +package org.wso2.gateway.discovery.config.enforcer; + +public final class PublisherPoolProto { + private PublisherPoolProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_wso2_discovery_config_enforcer_PublisherPool_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_wso2_discovery_config_enforcer_PublisherPool_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n builder) { private TMURLGroup() { receiverURLs_ = com.google.protobuf.LazyStringArrayList.EMPTY; authURLs_ = com.google.protobuf.LazyStringArrayList.EMPTY; + type_ = ""; } @java.lang.Override @@ -69,6 +70,12 @@ private TMURLGroup( authURLs_.add(s); break; } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + type_ = s; + break; + } default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { @@ -177,6 +184,44 @@ public java.lang.String getAuthURLs(int index) { return authURLs_.getByteString(index); } + public static final int TYPE_FIELD_NUMBER = 3; + private volatile java.lang.Object type_; + /** + * string type = 3; + * @return The type. + */ + @java.lang.Override + public java.lang.String getType() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + type_ = s; + return s; + } + } + /** + * string type = 3; + * @return The bytes for type. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -197,6 +242,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < authURLs_.size(); i++) { com.google.protobuf.GeneratedMessageV3.writeString(output, 2, authURLs_.getRaw(i)); } + if (!getTypeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, type_); + } unknownFields.writeTo(output); } @@ -222,6 +270,9 @@ public int getSerializedSize() { size += dataSize; size += 1 * getAuthURLsList().size(); } + if (!getTypeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, type_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -241,6 +292,8 @@ public boolean equals(final java.lang.Object obj) { .equals(other.getReceiverURLsList())) return false; if (!getAuthURLsList() .equals(other.getAuthURLsList())) return false; + if (!getType() + .equals(other.getType())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -260,6 +313,8 @@ public int hashCode() { hash = (37 * hash) + AUTHURLS_FIELD_NUMBER; hash = (53 * hash) + getAuthURLsList().hashCode(); } + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + getType().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -397,6 +452,8 @@ public Builder clear() { bitField0_ = (bitField0_ & ~0x00000001); authURLs_ = com.google.protobuf.LazyStringArrayList.EMPTY; bitField0_ = (bitField0_ & ~0x00000002); + type_ = ""; + return this; } @@ -434,6 +491,7 @@ public org.wso2.gateway.discovery.config.enforcer.TMURLGroup buildPartial() { bitField0_ = (bitField0_ & ~0x00000002); } result.authURLs_ = authURLs_; + result.type_ = type_; onBuilt(); return result; } @@ -502,6 +560,10 @@ public Builder mergeFrom(org.wso2.gateway.discovery.config.enforcer.TMURLGroup o } onChanged(); } + if (!other.getType().isEmpty()) { + type_ = other.type_; + onChanged(); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -751,6 +813,82 @@ public Builder addAuthURLsBytes( onChanged(); return this; } + + private java.lang.Object type_ = ""; + /** + * string type = 3; + * @return The type. + */ + public java.lang.String getType() { + java.lang.Object ref = type_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + type_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string type = 3; + * @return The bytes for type. + */ + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string type = 3; + * @param value The type to set. + * @return This builder for chaining. + */ + public Builder setType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value; + onChanged(); + return this; + } + /** + * string type = 3; + * @return This builder for chaining. + */ + public Builder clearType() { + + type_ = getDefaultInstance().getType(); + onChanged(); + return this; + } + /** + * string type = 3; + * @param value The bytes for type to set. + * @return This builder for chaining. + */ + public Builder setTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + type_ = value; + onChanged(); + return this; + } @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupOrBuilder.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupOrBuilder.java index ef4f140e53..9d451f798e 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupOrBuilder.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupOrBuilder.java @@ -56,4 +56,16 @@ public interface TMURLGroupOrBuilder extends */ com.google.protobuf.ByteString getAuthURLsBytes(int index); + + /** + * string type = 3; + * @return The type. + */ + java.lang.String getType(); + /** + * string type = 3; + * @return The bytes for type. + */ + com.google.protobuf.ByteString + getTypeBytes(); } diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupProto.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupProto.java index 559e247366..475af93be3 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupProto.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupProto.java @@ -30,12 +30,12 @@ public static void registerAllExtensions( java.lang.String[] descriptorData = { "\n1wso2/discovery/config/enforcer/tm_url_" + "group.proto\022\036wso2.discovery.config.enfor" + - "cer\"4\n\nTMURLGroup\022\024\n\014receiverURLs\030\001 \003(\t\022" + - "\020\n\010authURLs\030\002 \003(\tB\217\001\n*org.wso2.gateway.d" + - "iscovery.config.enforcerB\017TMURLGroupProt" + - "oP\001ZNgithub.com/envoyproxy/go-control-pl" + - "ane/wso2/discovery/config/enforcer;enfor" + - "cerb\006proto3" + "cer\"B\n\nTMURLGroup\022\024\n\014receiverURLs\030\001 \003(\t\022" + + "\020\n\010authURLs\030\002 \003(\t\022\014\n\004type\030\003 \001(\tB\217\001\n*org." + + "wso2.gateway.discovery.config.enforcerB\017" + + "TMURLGroupProtoP\001ZNgithub.com/envoyproxy" + + "/go-control-plane/wso2/discovery/config/" + + "enforcer;enforcerb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -46,7 +46,7 @@ public static void registerAllExtensions( internal_static_wso2_discovery_config_enforcer_TMURLGroup_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_config_enforcer_TMURLGroup_descriptor, - new java.lang.String[] { "ReceiverURLs", "AuthURLs", }); + new java.lang.String[] { "ReceiverURLs", "AuthURLs", "Type", }); } // @@protoc_insertion_point(outer_class_scope) diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottleAgent.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottleAgent.java index 07c5e0974d..c0dfc92865 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottleAgent.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottleAgent.java @@ -4,6 +4,10 @@ package org.wso2.gateway.discovery.config.enforcer; /** + *
+ * Throttle Agent configuration model
+ * 
+ * * Protobuf type {@code wso2.discovery.config.enforcer.ThrottleAgent} */ public final class ThrottleAgent extends @@ -740,6 +744,10 @@ protected Builder newBuilderForType( return builder; } /** + *
+   * Throttle Agent configuration model
+   * 
+ * * Protobuf type {@code wso2.discovery.config.enforcer.ThrottleAgent} */ public static final class Builder extends diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlePublisher.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlePublisher.java index 7aa75bfb7a..aa9d880e02 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlePublisher.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlePublisher.java @@ -4,6 +4,10 @@ package org.wso2.gateway.discovery.config.enforcer; /** + *
+ * Throttle Publisher configuration model
+ * 
+ * * Protobuf type {@code wso2.discovery.config.enforcer.ThrottlePublisher} */ public final class ThrottlePublisher extends @@ -360,6 +364,10 @@ protected Builder newBuilderForType( return builder; } /** + *
+   * Throttle Publisher configuration model
+   * 
+ * * Protobuf type {@code wso2.discovery.config.enforcer.ThrottlePublisher} */ public static final class Builder extends diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/Throttling.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/Throttling.java index 9bb4ef40c0..8bb7c1b95b 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/Throttling.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/Throttling.java @@ -20,6 +20,8 @@ private Throttling(com.google.protobuf.GeneratedMessageV3.Builder builder) { super(builder); } private Throttling() { + jmsConnectionInitialContextFactory_ = ""; + jmsConnectionProviderUrl_ = ""; } @java.lang.Override @@ -52,15 +54,47 @@ private Throttling( case 0: done = true; break; - case 10: { - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder subBuilder = null; - if (binary_ != null) { - subBuilder = binary_.toBuilder(); + case 8: { + + enableGlobalEventPublishing_ = input.readBool(); + break; + } + case 16: { + + enableHeaderConditions_ = input.readBool(); + break; + } + case 24: { + + enableQueryParamConditions_ = input.readBool(); + break; + } + case 32: { + + enableJwtClaimConditions_ = input.readBool(); + break; + } + case 42: { + java.lang.String s = input.readStringRequireUtf8(); + + jmsConnectionInitialContextFactory_ = s; + break; + } + case 50: { + java.lang.String s = input.readStringRequireUtf8(); + + jmsConnectionProviderUrl_ = s; + break; + } + case 58: { + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder subBuilder = null; + if (publisher_ != null) { + subBuilder = publisher_.toBuilder(); } - binary_ = input.readMessage(org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.parser(), extensionRegistry); + publisher_ = input.readMessage(org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.parser(), extensionRegistry); if (subBuilder != null) { - subBuilder.mergeFrom(binary_); - binary_ = subBuilder.buildPartial(); + subBuilder.mergeFrom(publisher_); + publisher_ = subBuilder.buildPartial(); } break; @@ -97,30 +131,150 @@ private Throttling( org.wso2.gateway.discovery.config.enforcer.Throttling.class, org.wso2.gateway.discovery.config.enforcer.Throttling.Builder.class); } - public static final int BINARY_FIELD_NUMBER = 1; - private org.wso2.gateway.discovery.config.enforcer.BinaryThrottling binary_; + public static final int ENABLE_GLOBAL_EVENT_PUBLISHING_FIELD_NUMBER = 1; + private boolean enableGlobalEventPublishing_; + /** + * bool enable_global_event_publishing = 1; + * @return The enableGlobalEventPublishing. + */ + @java.lang.Override + public boolean getEnableGlobalEventPublishing() { + return enableGlobalEventPublishing_; + } + + public static final int ENABLE_HEADER_CONDITIONS_FIELD_NUMBER = 2; + private boolean enableHeaderConditions_; /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; - * @return Whether the binary field is set. + * bool enable_header_conditions = 2; + * @return The enableHeaderConditions. */ @java.lang.Override - public boolean hasBinary() { - return binary_ != null; + public boolean getEnableHeaderConditions() { + return enableHeaderConditions_; } + + public static final int ENABLE_QUERY_PARAM_CONDITIONS_FIELD_NUMBER = 3; + private boolean enableQueryParamConditions_; /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; - * @return The binary. + * bool enable_query_param_conditions = 3; + * @return The enableQueryParamConditions. */ @java.lang.Override - public org.wso2.gateway.discovery.config.enforcer.BinaryThrottling getBinary() { - return binary_ == null ? org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.getDefaultInstance() : binary_; + public boolean getEnableQueryParamConditions() { + return enableQueryParamConditions_; } + + public static final int ENABLE_JWT_CLAIM_CONDITIONS_FIELD_NUMBER = 4; + private boolean enableJwtClaimConditions_; /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * bool enable_jwt_claim_conditions = 4; + * @return The enableJwtClaimConditions. */ @java.lang.Override - public org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder getBinaryOrBuilder() { - return getBinary(); + public boolean getEnableJwtClaimConditions() { + return enableJwtClaimConditions_; + } + + public static final int JMS_CONNECTION_INITIAL_CONTEXT_FACTORY_FIELD_NUMBER = 5; + private volatile java.lang.Object jmsConnectionInitialContextFactory_; + /** + * string jms_connection_initial_context_factory = 5; + * @return The jmsConnectionInitialContextFactory. + */ + @java.lang.Override + public java.lang.String getJmsConnectionInitialContextFactory() { + java.lang.Object ref = jmsConnectionInitialContextFactory_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + jmsConnectionInitialContextFactory_ = s; + return s; + } + } + /** + * string jms_connection_initial_context_factory = 5; + * @return The bytes for jmsConnectionInitialContextFactory. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getJmsConnectionInitialContextFactoryBytes() { + java.lang.Object ref = jmsConnectionInitialContextFactory_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + jmsConnectionInitialContextFactory_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int JMS_CONNECTION_PROVIDER_URL_FIELD_NUMBER = 6; + private volatile java.lang.Object jmsConnectionProviderUrl_; + /** + * string jms_connection_provider_url = 6; + * @return The jmsConnectionProviderUrl. + */ + @java.lang.Override + public java.lang.String getJmsConnectionProviderUrl() { + java.lang.Object ref = jmsConnectionProviderUrl_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + jmsConnectionProviderUrl_ = s; + return s; + } + } + /** + * string jms_connection_provider_url = 6; + * @return The bytes for jmsConnectionProviderUrl. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getJmsConnectionProviderUrlBytes() { + java.lang.Object ref = jmsConnectionProviderUrl_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + jmsConnectionProviderUrl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PUBLISHER_FIELD_NUMBER = 7; + private org.wso2.gateway.discovery.config.enforcer.BinaryPublisher publisher_; + /** + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; + * @return Whether the publisher field is set. + */ + @java.lang.Override + public boolean hasPublisher() { + return publisher_ != null; + } + /** + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; + * @return The publisher. + */ + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisher getPublisher() { + return publisher_ == null ? org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.getDefaultInstance() : publisher_; + } + /** + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; + */ + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisherOrBuilder getPublisherOrBuilder() { + return getPublisher(); } private byte memoizedIsInitialized = -1; @@ -137,8 +291,26 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (binary_ != null) { - output.writeMessage(1, getBinary()); + if (enableGlobalEventPublishing_ != false) { + output.writeBool(1, enableGlobalEventPublishing_); + } + if (enableHeaderConditions_ != false) { + output.writeBool(2, enableHeaderConditions_); + } + if (enableQueryParamConditions_ != false) { + output.writeBool(3, enableQueryParamConditions_); + } + if (enableJwtClaimConditions_ != false) { + output.writeBool(4, enableJwtClaimConditions_); + } + if (!getJmsConnectionInitialContextFactoryBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, jmsConnectionInitialContextFactory_); + } + if (!getJmsConnectionProviderUrlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, jmsConnectionProviderUrl_); + } + if (publisher_ != null) { + output.writeMessage(7, getPublisher()); } unknownFields.writeTo(output); } @@ -149,9 +321,31 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (binary_ != null) { + if (enableGlobalEventPublishing_ != false) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, getBinary()); + .computeBoolSize(1, enableGlobalEventPublishing_); + } + if (enableHeaderConditions_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(2, enableHeaderConditions_); + } + if (enableQueryParamConditions_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(3, enableQueryParamConditions_); + } + if (enableJwtClaimConditions_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(4, enableJwtClaimConditions_); + } + if (!getJmsConnectionInitialContextFactoryBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, jmsConnectionInitialContextFactory_); + } + if (!getJmsConnectionProviderUrlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, jmsConnectionProviderUrl_); + } + if (publisher_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(7, getPublisher()); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -168,10 +362,22 @@ public boolean equals(final java.lang.Object obj) { } org.wso2.gateway.discovery.config.enforcer.Throttling other = (org.wso2.gateway.discovery.config.enforcer.Throttling) obj; - if (hasBinary() != other.hasBinary()) return false; - if (hasBinary()) { - if (!getBinary() - .equals(other.getBinary())) return false; + if (getEnableGlobalEventPublishing() + != other.getEnableGlobalEventPublishing()) return false; + if (getEnableHeaderConditions() + != other.getEnableHeaderConditions()) return false; + if (getEnableQueryParamConditions() + != other.getEnableQueryParamConditions()) return false; + if (getEnableJwtClaimConditions() + != other.getEnableJwtClaimConditions()) return false; + if (!getJmsConnectionInitialContextFactory() + .equals(other.getJmsConnectionInitialContextFactory())) return false; + if (!getJmsConnectionProviderUrl() + .equals(other.getJmsConnectionProviderUrl())) return false; + if (hasPublisher() != other.hasPublisher()) return false; + if (hasPublisher()) { + if (!getPublisher() + .equals(other.getPublisher())) return false; } if (!unknownFields.equals(other.unknownFields)) return false; return true; @@ -184,9 +390,25 @@ public int hashCode() { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); - if (hasBinary()) { - hash = (37 * hash) + BINARY_FIELD_NUMBER; - hash = (53 * hash) + getBinary().hashCode(); + hash = (37 * hash) + ENABLE_GLOBAL_EVENT_PUBLISHING_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getEnableGlobalEventPublishing()); + hash = (37 * hash) + ENABLE_HEADER_CONDITIONS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getEnableHeaderConditions()); + hash = (37 * hash) + ENABLE_QUERY_PARAM_CONDITIONS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getEnableQueryParamConditions()); + hash = (37 * hash) + ENABLE_JWT_CLAIM_CONDITIONS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getEnableJwtClaimConditions()); + hash = (37 * hash) + JMS_CONNECTION_INITIAL_CONTEXT_FACTORY_FIELD_NUMBER; + hash = (53 * hash) + getJmsConnectionInitialContextFactory().hashCode(); + hash = (37 * hash) + JMS_CONNECTION_PROVIDER_URL_FIELD_NUMBER; + hash = (53 * hash) + getJmsConnectionProviderUrl().hashCode(); + if (hasPublisher()) { + hash = (37 * hash) + PUBLISHER_FIELD_NUMBER; + hash = (53 * hash) + getPublisher().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; @@ -325,11 +547,23 @@ private void maybeForceBuilderInitialization() { @java.lang.Override public Builder clear() { super.clear(); - if (binaryBuilder_ == null) { - binary_ = null; + enableGlobalEventPublishing_ = false; + + enableHeaderConditions_ = false; + + enableQueryParamConditions_ = false; + + enableJwtClaimConditions_ = false; + + jmsConnectionInitialContextFactory_ = ""; + + jmsConnectionProviderUrl_ = ""; + + if (publisherBuilder_ == null) { + publisher_ = null; } else { - binary_ = null; - binaryBuilder_ = null; + publisher_ = null; + publisherBuilder_ = null; } return this; } @@ -357,10 +591,16 @@ public org.wso2.gateway.discovery.config.enforcer.Throttling build() { @java.lang.Override public org.wso2.gateway.discovery.config.enforcer.Throttling buildPartial() { org.wso2.gateway.discovery.config.enforcer.Throttling result = new org.wso2.gateway.discovery.config.enforcer.Throttling(this); - if (binaryBuilder_ == null) { - result.binary_ = binary_; + result.enableGlobalEventPublishing_ = enableGlobalEventPublishing_; + result.enableHeaderConditions_ = enableHeaderConditions_; + result.enableQueryParamConditions_ = enableQueryParamConditions_; + result.enableJwtClaimConditions_ = enableJwtClaimConditions_; + result.jmsConnectionInitialContextFactory_ = jmsConnectionInitialContextFactory_; + result.jmsConnectionProviderUrl_ = jmsConnectionProviderUrl_; + if (publisherBuilder_ == null) { + result.publisher_ = publisher_; } else { - result.binary_ = binaryBuilder_.build(); + result.publisher_ = publisherBuilder_.build(); } onBuilt(); return result; @@ -410,8 +650,28 @@ public Builder mergeFrom(com.google.protobuf.Message other) { public Builder mergeFrom(org.wso2.gateway.discovery.config.enforcer.Throttling other) { if (other == org.wso2.gateway.discovery.config.enforcer.Throttling.getDefaultInstance()) return this; - if (other.hasBinary()) { - mergeBinary(other.getBinary()); + if (other.getEnableGlobalEventPublishing() != false) { + setEnableGlobalEventPublishing(other.getEnableGlobalEventPublishing()); + } + if (other.getEnableHeaderConditions() != false) { + setEnableHeaderConditions(other.getEnableHeaderConditions()); + } + if (other.getEnableQueryParamConditions() != false) { + setEnableQueryParamConditions(other.getEnableQueryParamConditions()); + } + if (other.getEnableJwtClaimConditions() != false) { + setEnableJwtClaimConditions(other.getEnableJwtClaimConditions()); + } + if (!other.getJmsConnectionInitialContextFactory().isEmpty()) { + jmsConnectionInitialContextFactory_ = other.jmsConnectionInitialContextFactory_; + onChanged(); + } + if (!other.getJmsConnectionProviderUrl().isEmpty()) { + jmsConnectionProviderUrl_ = other.jmsConnectionProviderUrl_; + onChanged(); + } + if (other.hasPublisher()) { + mergePublisher(other.getPublisher()); } this.mergeUnknownFields(other.unknownFields); onChanged(); @@ -442,123 +702,399 @@ public Builder mergeFrom( return this; } - private org.wso2.gateway.discovery.config.enforcer.BinaryThrottling binary_; + private boolean enableGlobalEventPublishing_ ; + /** + * bool enable_global_event_publishing = 1; + * @return The enableGlobalEventPublishing. + */ + @java.lang.Override + public boolean getEnableGlobalEventPublishing() { + return enableGlobalEventPublishing_; + } + /** + * bool enable_global_event_publishing = 1; + * @param value The enableGlobalEventPublishing to set. + * @return This builder for chaining. + */ + public Builder setEnableGlobalEventPublishing(boolean value) { + + enableGlobalEventPublishing_ = value; + onChanged(); + return this; + } + /** + * bool enable_global_event_publishing = 1; + * @return This builder for chaining. + */ + public Builder clearEnableGlobalEventPublishing() { + + enableGlobalEventPublishing_ = false; + onChanged(); + return this; + } + + private boolean enableHeaderConditions_ ; + /** + * bool enable_header_conditions = 2; + * @return The enableHeaderConditions. + */ + @java.lang.Override + public boolean getEnableHeaderConditions() { + return enableHeaderConditions_; + } + /** + * bool enable_header_conditions = 2; + * @param value The enableHeaderConditions to set. + * @return This builder for chaining. + */ + public Builder setEnableHeaderConditions(boolean value) { + + enableHeaderConditions_ = value; + onChanged(); + return this; + } + /** + * bool enable_header_conditions = 2; + * @return This builder for chaining. + */ + public Builder clearEnableHeaderConditions() { + + enableHeaderConditions_ = false; + onChanged(); + return this; + } + + private boolean enableQueryParamConditions_ ; + /** + * bool enable_query_param_conditions = 3; + * @return The enableQueryParamConditions. + */ + @java.lang.Override + public boolean getEnableQueryParamConditions() { + return enableQueryParamConditions_; + } + /** + * bool enable_query_param_conditions = 3; + * @param value The enableQueryParamConditions to set. + * @return This builder for chaining. + */ + public Builder setEnableQueryParamConditions(boolean value) { + + enableQueryParamConditions_ = value; + onChanged(); + return this; + } + /** + * bool enable_query_param_conditions = 3; + * @return This builder for chaining. + */ + public Builder clearEnableQueryParamConditions() { + + enableQueryParamConditions_ = false; + onChanged(); + return this; + } + + private boolean enableJwtClaimConditions_ ; + /** + * bool enable_jwt_claim_conditions = 4; + * @return The enableJwtClaimConditions. + */ + @java.lang.Override + public boolean getEnableJwtClaimConditions() { + return enableJwtClaimConditions_; + } + /** + * bool enable_jwt_claim_conditions = 4; + * @param value The enableJwtClaimConditions to set. + * @return This builder for chaining. + */ + public Builder setEnableJwtClaimConditions(boolean value) { + + enableJwtClaimConditions_ = value; + onChanged(); + return this; + } + /** + * bool enable_jwt_claim_conditions = 4; + * @return This builder for chaining. + */ + public Builder clearEnableJwtClaimConditions() { + + enableJwtClaimConditions_ = false; + onChanged(); + return this; + } + + private java.lang.Object jmsConnectionInitialContextFactory_ = ""; + /** + * string jms_connection_initial_context_factory = 5; + * @return The jmsConnectionInitialContextFactory. + */ + public java.lang.String getJmsConnectionInitialContextFactory() { + java.lang.Object ref = jmsConnectionInitialContextFactory_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + jmsConnectionInitialContextFactory_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string jms_connection_initial_context_factory = 5; + * @return The bytes for jmsConnectionInitialContextFactory. + */ + public com.google.protobuf.ByteString + getJmsConnectionInitialContextFactoryBytes() { + java.lang.Object ref = jmsConnectionInitialContextFactory_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + jmsConnectionInitialContextFactory_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string jms_connection_initial_context_factory = 5; + * @param value The jmsConnectionInitialContextFactory to set. + * @return This builder for chaining. + */ + public Builder setJmsConnectionInitialContextFactory( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + jmsConnectionInitialContextFactory_ = value; + onChanged(); + return this; + } + /** + * string jms_connection_initial_context_factory = 5; + * @return This builder for chaining. + */ + public Builder clearJmsConnectionInitialContextFactory() { + + jmsConnectionInitialContextFactory_ = getDefaultInstance().getJmsConnectionInitialContextFactory(); + onChanged(); + return this; + } + /** + * string jms_connection_initial_context_factory = 5; + * @param value The bytes for jmsConnectionInitialContextFactory to set. + * @return This builder for chaining. + */ + public Builder setJmsConnectionInitialContextFactoryBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + jmsConnectionInitialContextFactory_ = value; + onChanged(); + return this; + } + + private java.lang.Object jmsConnectionProviderUrl_ = ""; + /** + * string jms_connection_provider_url = 6; + * @return The jmsConnectionProviderUrl. + */ + public java.lang.String getJmsConnectionProviderUrl() { + java.lang.Object ref = jmsConnectionProviderUrl_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + jmsConnectionProviderUrl_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string jms_connection_provider_url = 6; + * @return The bytes for jmsConnectionProviderUrl. + */ + public com.google.protobuf.ByteString + getJmsConnectionProviderUrlBytes() { + java.lang.Object ref = jmsConnectionProviderUrl_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + jmsConnectionProviderUrl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string jms_connection_provider_url = 6; + * @param value The jmsConnectionProviderUrl to set. + * @return This builder for chaining. + */ + public Builder setJmsConnectionProviderUrl( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + jmsConnectionProviderUrl_ = value; + onChanged(); + return this; + } + /** + * string jms_connection_provider_url = 6; + * @return This builder for chaining. + */ + public Builder clearJmsConnectionProviderUrl() { + + jmsConnectionProviderUrl_ = getDefaultInstance().getJmsConnectionProviderUrl(); + onChanged(); + return this; + } + /** + * string jms_connection_provider_url = 6; + * @param value The bytes for jmsConnectionProviderUrl to set. + * @return This builder for chaining. + */ + public Builder setJmsConnectionProviderUrlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + jmsConnectionProviderUrl_ = value; + onChanged(); + return this; + } + + private org.wso2.gateway.discovery.config.enforcer.BinaryPublisher publisher_; private com.google.protobuf.SingleFieldBuilderV3< - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling, org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder, org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder> binaryBuilder_; + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher, org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder, org.wso2.gateway.discovery.config.enforcer.BinaryPublisherOrBuilder> publisherBuilder_; /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; - * @return Whether the binary field is set. + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; + * @return Whether the publisher field is set. */ - public boolean hasBinary() { - return binaryBuilder_ != null || binary_ != null; + public boolean hasPublisher() { + return publisherBuilder_ != null || publisher_ != null; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; - * @return The binary. + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; + * @return The publisher. */ - public org.wso2.gateway.discovery.config.enforcer.BinaryThrottling getBinary() { - if (binaryBuilder_ == null) { - return binary_ == null ? org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.getDefaultInstance() : binary_; + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisher getPublisher() { + if (publisherBuilder_ == null) { + return publisher_ == null ? org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.getDefaultInstance() : publisher_; } else { - return binaryBuilder_.getMessage(); + return publisherBuilder_.getMessage(); } } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ - public Builder setBinary(org.wso2.gateway.discovery.config.enforcer.BinaryThrottling value) { - if (binaryBuilder_ == null) { + public Builder setPublisher(org.wso2.gateway.discovery.config.enforcer.BinaryPublisher value) { + if (publisherBuilder_ == null) { if (value == null) { throw new NullPointerException(); } - binary_ = value; + publisher_ = value; onChanged(); } else { - binaryBuilder_.setMessage(value); + publisherBuilder_.setMessage(value); } return this; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ - public Builder setBinary( - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder builderForValue) { - if (binaryBuilder_ == null) { - binary_ = builderForValue.build(); + public Builder setPublisher( + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder builderForValue) { + if (publisherBuilder_ == null) { + publisher_ = builderForValue.build(); onChanged(); } else { - binaryBuilder_.setMessage(builderForValue.build()); + publisherBuilder_.setMessage(builderForValue.build()); } return this; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ - public Builder mergeBinary(org.wso2.gateway.discovery.config.enforcer.BinaryThrottling value) { - if (binaryBuilder_ == null) { - if (binary_ != null) { - binary_ = - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.newBuilder(binary_).mergeFrom(value).buildPartial(); + public Builder mergePublisher(org.wso2.gateway.discovery.config.enforcer.BinaryPublisher value) { + if (publisherBuilder_ == null) { + if (publisher_ != null) { + publisher_ = + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.newBuilder(publisher_).mergeFrom(value).buildPartial(); } else { - binary_ = value; + publisher_ = value; } onChanged(); } else { - binaryBuilder_.mergeFrom(value); + publisherBuilder_.mergeFrom(value); } return this; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ - public Builder clearBinary() { - if (binaryBuilder_ == null) { - binary_ = null; + public Builder clearPublisher() { + if (publisherBuilder_ == null) { + publisher_ = null; onChanged(); } else { - binary_ = null; - binaryBuilder_ = null; + publisher_ = null; + publisherBuilder_ = null; } return this; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ - public org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder getBinaryBuilder() { + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder getPublisherBuilder() { onChanged(); - return getBinaryFieldBuilder().getBuilder(); + return getPublisherFieldBuilder().getBuilder(); } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ - public org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder getBinaryOrBuilder() { - if (binaryBuilder_ != null) { - return binaryBuilder_.getMessageOrBuilder(); + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisherOrBuilder getPublisherOrBuilder() { + if (publisherBuilder_ != null) { + return publisherBuilder_.getMessageOrBuilder(); } else { - return binary_ == null ? - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.getDefaultInstance() : binary_; + return publisher_ == null ? + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.getDefaultInstance() : publisher_; } } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ private com.google.protobuf.SingleFieldBuilderV3< - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling, org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder, org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder> - getBinaryFieldBuilder() { - if (binaryBuilder_ == null) { - binaryBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling, org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder, org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder>( - getBinary(), + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher, org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder, org.wso2.gateway.discovery.config.enforcer.BinaryPublisherOrBuilder> + getPublisherFieldBuilder() { + if (publisherBuilder_ == null) { + publisherBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher, org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder, org.wso2.gateway.discovery.config.enforcer.BinaryPublisherOrBuilder>( + getPublisher(), getParentForChildren(), isClean()); - binary_ = null; + publisher_ = null; } - return binaryBuilder_; + return publisherBuilder_; } @java.lang.Override public final Builder setUnknownFields( diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingOrBuilder.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingOrBuilder.java index 1ea806dc93..47fefc7606 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingOrBuilder.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingOrBuilder.java @@ -8,17 +8,65 @@ public interface ThrottlingOrBuilder extends com.google.protobuf.MessageOrBuilder { /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; - * @return Whether the binary field is set. + * bool enable_global_event_publishing = 1; + * @return The enableGlobalEventPublishing. */ - boolean hasBinary(); + boolean getEnableGlobalEventPublishing(); + + /** + * bool enable_header_conditions = 2; + * @return The enableHeaderConditions. + */ + boolean getEnableHeaderConditions(); + + /** + * bool enable_query_param_conditions = 3; + * @return The enableQueryParamConditions. + */ + boolean getEnableQueryParamConditions(); + + /** + * bool enable_jwt_claim_conditions = 4; + * @return The enableJwtClaimConditions. + */ + boolean getEnableJwtClaimConditions(); + + /** + * string jms_connection_initial_context_factory = 5; + * @return The jmsConnectionInitialContextFactory. + */ + java.lang.String getJmsConnectionInitialContextFactory(); + /** + * string jms_connection_initial_context_factory = 5; + * @return The bytes for jmsConnectionInitialContextFactory. + */ + com.google.protobuf.ByteString + getJmsConnectionInitialContextFactoryBytes(); + + /** + * string jms_connection_provider_url = 6; + * @return The jmsConnectionProviderUrl. + */ + java.lang.String getJmsConnectionProviderUrl(); + /** + * string jms_connection_provider_url = 6; + * @return The bytes for jmsConnectionProviderUrl. + */ + com.google.protobuf.ByteString + getJmsConnectionProviderUrlBytes(); + + /** + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; + * @return Whether the publisher field is set. + */ + boolean hasPublisher(); /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; - * @return The binary. + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; + * @return The publisher. */ - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling getBinary(); + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher getPublisher(); /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ - org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder getBinaryOrBuilder(); + org.wso2.gateway.discovery.config.enforcer.BinaryPublisherOrBuilder getPublisherOrBuilder(); } diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingProto.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingProto.java index 5658b5fcd6..7fc683d5fe 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingProto.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingProto.java @@ -30,27 +30,33 @@ public static void registerAllExtensions( java.lang.String[] descriptorData = { "\n/wso2/discovery/config/enforcer/throttl" + "ing.proto\022\036wso2.discovery.config.enforce" + - "r\0326wso2/discovery/config/enforcer/binary" + - "_throttling.proto\"N\n\nThrottling\022@\n\006binar" + - "y\030\001 \001(\01320.wso2.discovery.config.enforcer" + - ".BinaryThrottlingB\217\001\n*org.wso2.gateway.d" + - "iscovery.config.enforcerB\017ThrottlingProt" + - "oP\001ZNgithub.com/envoyproxy/go-control-pl" + - "ane/wso2/discovery/config/enforcer;enfor" + - "cerb\006proto3" + "r\0325wso2/discovery/config/enforcer/binary" + + "_publisher.proto\"\273\002\n\nThrottling\022&\n\036enabl" + + "e_global_event_publishing\030\001 \001(\010\022 \n\030enabl" + + "e_header_conditions\030\002 \001(\010\022%\n\035enable_quer" + + "y_param_conditions\030\003 \001(\010\022#\n\033enable_jwt_c" + + "laim_conditions\030\004 \001(\010\022.\n&jms_connection_" + + "initial_context_factory\030\005 \001(\t\022#\n\033jms_con" + + "nection_provider_url\030\006 \001(\t\022B\n\tpublisher\030" + + "\007 \001(\0132/.wso2.discovery.config.enforcer.B" + + "inaryPublisherB\217\001\n*org.wso2.gateway.disc" + + "overy.config.enforcerB\017ThrottlingProtoP\001" + + "ZNgithub.com/envoyproxy/go-control-plane" + + "/wso2/discovery/config/enforcer;enforcer" + + "b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { - org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingProto.getDescriptor(), + org.wso2.gateway.discovery.config.enforcer.BinaryPublisherProto.getDescriptor(), }); internal_static_wso2_discovery_config_enforcer_Throttling_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_wso2_discovery_config_enforcer_Throttling_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_config_enforcer_Throttling_descriptor, - new java.lang.String[] { "Binary", }); - org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingProto.getDescriptor(); + new java.lang.String[] { "EnableGlobalEventPublishing", "EnableHeaderConditions", "EnableQueryParamConditions", "EnableJwtClaimConditions", "JmsConnectionInitialContextFactory", "JmsConnectionProviderUrl", "Publisher", }); + org.wso2.gateway.discovery.config.enforcer.BinaryPublisherProto.getDescriptor(); } // @@protoc_insertion_point(outer_class_scope) diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RequestContext.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RequestContext.java index 566d3b6d74..f549dee513 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RequestContext.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RequestContext.java @@ -19,6 +19,7 @@ import org.apache.commons.lang3.StringUtils; import org.wso2.micro.gateway.enforcer.api.config.ResourceConfig; +import org.wso2.micro.gateway.enforcer.security.AuthenticationContext; import java.util.HashMap; import java.util.Map; @@ -36,6 +37,9 @@ public class RequestContext { private ResourceConfig matchedResourcePath; private Map headers; private Map properties = new HashMap(); + private AuthenticationContext authenticationContext; + private String requestID; + private String address; // Denotes the cluster header name for each environment. Both properties can be null if // the openAPI has production endpoints alone. private String prodClusterHeader; @@ -60,6 +64,9 @@ public static class Builder { private String prodClusterHeader; private String sandClusterHeader; private Map properties = new HashMap(); + private AuthenticationContext authenticationContext = new AuthenticationContext(); + private String requestID; + private String address; public Builder(String requestPath) { this.requestPath = requestPath; @@ -99,6 +106,21 @@ public Builder sandClusterHeader(String cluster) { return this; } + public Builder authenticationContext(AuthenticationContext authenticationContext) { + this.authenticationContext = authenticationContext; + return this; + } + + public Builder requestID(String requestID) { + this.requestID = requestID; + return this; + } + + public Builder address(String address) { + this.address = address; + return this; + } + public RequestContext build() { RequestContext requestContext = new RequestContext(); requestContext.matchedResourcePath = this.matchedResourceConfig; @@ -109,6 +131,9 @@ public RequestContext build() { requestContext.prodClusterHeader = this.prodClusterHeader; requestContext.sandClusterHeader = this.sandClusterHeader; requestContext.properties = this.properties; + requestContext.authenticationContext = this.authenticationContext; + requestContext.requestID = this.requestID; + requestContext.address = this.address; // Adapter assigns header based routing only if both type of endpoints are present. if (!StringUtils.isEmpty(prodClusterHeader) && !StringUtils.isEmpty(sandClusterHeader)) { @@ -118,6 +143,18 @@ public RequestContext build() { } } + public AuthenticationContext getAuthenticationContext() { + return authenticationContext; + } + + public String getRequestID() { + return requestID; + } + + public String getAddress() { + return address; + } + public API getMathedAPI() { return mathedAPI; } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java index a0593d56e0..1ed1e4078d 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java @@ -25,8 +25,10 @@ import org.wso2.micro.gateway.enforcer.Filter; import org.wso2.micro.gateway.enforcer.api.config.APIConfig; import org.wso2.micro.gateway.enforcer.api.config.ResourceConfig; +import org.wso2.micro.gateway.enforcer.config.ConfigHolder; import org.wso2.micro.gateway.enforcer.constants.APIConstants; import org.wso2.micro.gateway.enforcer.cors.CorsFilter; +import org.wso2.micro.gateway.enforcer.filters.ThrottleFilter; import org.wso2.micro.gateway.enforcer.security.AuthFilter; import java.util.ArrayList; @@ -125,10 +127,18 @@ private ResourceConfig buildResource(Operation operation, String resPath) { private void initFilters() { CorsFilter corsFilter = new CorsFilter(); this.filters.add(corsFilter); + if (!APIConstants.PROTOTYPED_LIFE_CYCLE_STATUS.equals(apiLifeCycleState)) { AuthFilter authFilter = new AuthFilter(); authFilter.init(apiConfig); this.filters.add(authFilter); } + + // enable throttle filter + if (ConfigHolder.getInstance().getConfig().getThrottleConfig().isGlobalPublishingEnabled()) { + ThrottleFilter throttleFilter = new ThrottleFilter(); + throttleFilter.init(apiConfig); + this.filters.add(throttleFilter); + } } } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/APIConfig.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/APIConfig.java index 8595e032a5..12b3620e63 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/APIConfig.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/APIConfig.java @@ -17,7 +17,7 @@ */ package org.wso2.micro.gateway.enforcer.api.config; -import org.wso2.micro.gateway.enforcer.constants.APIConstants; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleConstants; import java.util.ArrayList; import java.util.List; @@ -32,7 +32,7 @@ public class APIConfig { private String apiLifeCycleState; private List securitySchemas = new ArrayList<>(); - private String tier = APIConstants.UNLIMITED_TIER; + private String tier = ThrottleConstants.UNLIMITED_TIER; private List resources = new ArrayList<>(); /** @@ -46,7 +46,7 @@ public static class Builder { private String apiLifeCycleState; private List securitySchemas = new ArrayList<>(); - private String tier = APIConstants.UNLIMITED_TIER; + private String tier = ThrottleConstants.UNLIMITED_TIER; private List resources = new ArrayList<>(); public Builder(String name) { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/ResourceConfig.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/ResourceConfig.java index 59322ab02a..bf94ed5886 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/ResourceConfig.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/ResourceConfig.java @@ -17,7 +17,7 @@ */ package org.wso2.micro.gateway.enforcer.api.config; -import org.wso2.micro.gateway.enforcer.constants.APIConstants; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleConstants; import java.util.HashMap; import java.util.List; @@ -32,7 +32,7 @@ public class ResourceConfig { private String path; private HttpMethods method; private Map> securitySchemas = new HashMap(); - private String tier = APIConstants.UNLIMITED_TIER; + private String tier = ThrottleConstants.UNLIMITED_TIER; public String getPath() { return path; @@ -67,7 +67,7 @@ public void setTier(String tier) { } /** - * ENUM to hold http operations + * ENUM to hold http operations. */ public enum HttpMethods { GET("get"), POST("post"), PUT("put"), DELETE("delete"), HEAD("head"), diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/common/CacheableEntity.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/common/CacheableEntity.java index f9865478dc..d01e721ed9 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/common/CacheableEntity.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/common/CacheableEntity.java @@ -19,7 +19,7 @@ package org.wso2.micro.gateway.enforcer.common; /** - * An interface to indicate that an entity provides a cacheKey + * An interface to indicate that an entity provides a cacheKey. * * @param Type of the CacheKey */ diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java index 0ca30afea0..2872e7c653 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java @@ -26,6 +26,7 @@ import org.wso2.carbon.apimgt.common.gateway.dto.JWTConfigurationDto; import org.wso2.gateway.discovery.config.enforcer.AmCredentials; import org.wso2.gateway.discovery.config.enforcer.AuthService; +import org.wso2.gateway.discovery.config.enforcer.BinaryPublisher; import org.wso2.gateway.discovery.config.enforcer.Cache; import org.wso2.gateway.discovery.config.enforcer.ClaimMapping; import org.wso2.gateway.discovery.config.enforcer.Config; @@ -33,17 +34,25 @@ import org.wso2.gateway.discovery.config.enforcer.Issuer; import org.wso2.gateway.discovery.config.enforcer.JWTGenerator; import org.wso2.gateway.discovery.config.enforcer.JWTIssuer; +import org.wso2.gateway.discovery.config.enforcer.PublisherPool; +import org.wso2.gateway.discovery.config.enforcer.TMURLGroup; +import org.wso2.gateway.discovery.config.enforcer.ThrottleAgent; +import org.wso2.gateway.discovery.config.enforcer.Throttling; import org.wso2.micro.gateway.enforcer.config.dto.AuthServiceConfigurationDto; import org.wso2.micro.gateway.enforcer.config.dto.CacheDto; import org.wso2.micro.gateway.enforcer.config.dto.CredentialDto; import org.wso2.micro.gateway.enforcer.config.dto.EventHubConfigurationDto; import org.wso2.micro.gateway.enforcer.config.dto.ExtendedTokenIssuerDto; import org.wso2.micro.gateway.enforcer.config.dto.JWTIssuerConfigurationDto; +import org.wso2.micro.gateway.enforcer.config.dto.ThrottleAgentConfigDto; +import org.wso2.micro.gateway.enforcer.config.dto.ThrottleConfigDto; import org.wso2.micro.gateway.enforcer.constants.Constants; import org.wso2.micro.gateway.enforcer.discovery.ConfigDiscoveryClient; import org.wso2.micro.gateway.enforcer.exception.DiscoveryException; import org.wso2.micro.gateway.enforcer.exception.MGWException; import org.wso2.micro.gateway.enforcer.security.jwt.JWTUtil; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.AgentConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.publisher.PublisherConfiguration; import org.wso2.micro.gateway.enforcer.util.TLSUtils; import java.io.IOException; @@ -119,9 +128,12 @@ private void parseConfigs(Config config) { // Read jwt token configuration populateJWTIssuerConfiguration(config.getJwtTokenConfigList()); - //Read credentials used to connect with APIM services + // Read credentials used to connect with APIM services populateAPIMCredentials(config.getApimCredentials()); + // Read throttle publisher configurations + populateThrottlingConfig(config.getThrottling()); + // Read backend jwt generation configurations populateJWTGeneratorConfigurations(config.getJwtGenerator()); @@ -188,7 +200,7 @@ private void populateJWTIssuerConfiguration(List cdsIssuers) { // Load jwt transformers map. config.setJwtTransformerMap(JWTUtil.loadJWTTransformers()); String certificateAlias = jwtIssuer.getCertificateAlias(); - if (certificateAlias != null) { + if (!certificateAlias.isBlank()) { try { Certificate cert = TLSUtils.getCertificateFromFile(jwtIssuer.getCertificateFilePath()); getTrustStoreForJWT().setCertificateEntry(certificateAlias, cert); @@ -210,6 +222,60 @@ private void populateJWTIssuerConfiguration(List cdsIssuers) { } } + private void populateThrottlingConfig(Throttling throttling) { + ThrottleConfigDto throttleConfig = new ThrottleConfigDto(); + throttleConfig.setGlobalPublishingEnabled(throttling.getEnableGlobalEventPublishing()); + throttleConfig.setHeaderConditionsEnabled(throttling.getEnableHeaderConditions()); + throttleConfig.setQueryConditionsEnabled(throttling.getEnableQueryParamConditions()); + throttleConfig.setJwtClaimConditionsEnabled(throttling.getEnableJwtClaimConditions()); + throttleConfig.setJmsConnectionInitialContextFactory(throttling.getJmsConnectionInitialContextFactory()); + throttleConfig.setJmsConnectionProviderUrl(throttling.getJmsConnectionProviderUrl()); + config.setThrottleConfig(throttleConfig); + populateTMBinaryConfig(throttling.getPublisher()); + } + + private void populateTMBinaryConfig(BinaryPublisher binary) { + ThrottleAgent binaryAgent = binary.getAgent(); + AgentConfiguration agentConf = AgentConfiguration.getInstance(); + agentConf.setBatchSize(binaryAgent.getBatchSize()); + agentConf.setCiphers(binaryAgent.getCiphers()); + agentConf.setCorePoolSize(binaryAgent.getCorePoolSize()); + agentConf.setEvictionTimePeriod(binaryAgent.getEvictionTimePeriod()); + agentConf.setKeepAliveTimeInPool(binaryAgent.getKeepAliveTimeInPool()); + agentConf.setMaxIdleConnections(binaryAgent.getMaxIdleConnections()); + agentConf.setMaxPoolSize(binaryAgent.getMaxPoolSize()); + agentConf.setMaxTransportPoolSize(binaryAgent.getMaxTransportPoolSize()); + agentConf.setMinIdleTimeInPool(binaryAgent.getMinIdleTimeInPool()); + agentConf.setQueueSize(binaryAgent.getQueueSize()); + agentConf.setReconnectionInterval(binaryAgent.getReconnectionInterval()); + agentConf.setSecureEvictionTimePeriod(binaryAgent.getSecureEvictionTimePeriod()); + agentConf.setSecureMaxIdleConnections(binaryAgent.getSecureMaxIdleConnections()); + agentConf.setSecureMaxTransportPoolSize(binaryAgent.getSecureMaxTransportPoolSize()); + agentConf.setSecureMinIdleTimeInPool(binaryAgent.getSecureMinIdleTimeInPool()); + agentConf.setSslEnabledProtocols(binaryAgent.getSslEnabledProtocols()); + agentConf.setSocketTimeoutMS(binaryAgent.getSocketTimeoutMS()); + agentConf.setTrustStore(trustStore); + + PublisherPool pool = binary.getPool(); + PublisherConfiguration pubConf = PublisherConfiguration.getInstance(); + pubConf.setUserName(binary.getUsername()); + pubConf.setPassword(binary.getPassword()); + pubConf.setInitIdleObjectDataPublishingAgents(pool.getInitIdleObjectDataPublishingAgents()); + pubConf.setMaxIdleDataPublishingAgents(pool.getMaxIdleDataPublishingAgents()); + pubConf.setPublisherThreadPoolCoreSize(pool.getPublisherThreadPoolCoreSize()); + pubConf.setPublisherThreadPoolKeepAliveTime(pool.getPublisherThreadPoolKeepAliveTime()); + pubConf.setPublisherThreadPoolMaximumSize(pool.getPublisherThreadPoolMaximumSize()); + + processTMPublisherURLGroup(binary.getUrlGroupList(), pubConf); + + ThrottleAgentConfigDto throttleAgent = new ThrottleAgentConfigDto(); + throttleAgent.setAgent(agentConf); + throttleAgent.setUsername(binary.getUsername()); + throttleAgent.setPassword(binary.getPassword()); + throttleAgent.setPublisher(pubConf); + config.getThrottleConfig().setThrottleAgent(throttleAgent); + } + private void loadTrustStore() { try { trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); @@ -230,6 +296,60 @@ private void populateAPIMCredentials(AmCredentials cred) { config.setApimCredentials(credentialDto); } + /** + * The receiverURLGroup and the authURLGroup is preprocessed + * such that to make them compatible with the binary agent. + */ + private void processTMPublisherURLGroup(List urlGroups, + PublisherConfiguration pubConfiguration) { + StringBuilder restructuredReceiverURL = new StringBuilder(); + StringBuilder restructuredAuthURL = new StringBuilder(); + + for (TMURLGroup urlGroup : urlGroups) { + List receiverUrls = urlGroup.getReceiverURLsList(); + List authUrls = urlGroup.getAuthURLsList(); + if (receiverUrls.size() == 1 && authUrls.size() == 1) { + restructuredReceiverURL.append("{").append(receiverUrls.get(0)).append("},"); + restructuredAuthURL.append("{").append(authUrls.get(0)).append("},"); + continue; + } + String urlType = urlGroup.getType(); + if (urlType.isBlank() || !(Constants.LOADBALANCE.equalsIgnoreCase(urlType) + || Constants.FAILOVER.equalsIgnoreCase(urlType))) { + logger.warn("Type is not " + + Constants.LOADBALANCE + " or " + Constants.FAILOVER + ". Hence proceeding as a " + + Constants.FAILOVER + " configuration."); + urlType = Constants.FAILOVER; + } + restructuredReceiverURL.append(processSingleURLGroup(receiverUrls, urlType)).append(","); + restructuredAuthURL.append(processSingleURLGroup(authUrls, urlType)).append(","); + } + + //to remove the final ',' in the URLs and set to publisher config + if (!restructuredReceiverURL.toString().isBlank() && !restructuredAuthURL.toString().isBlank()) { + pubConfiguration.setReceiverUrlGroup(restructuredReceiverURL.substring(0, + restructuredReceiverURL.length() - 1)); + pubConfiguration.setAuthUrlGroup(restructuredAuthURL.substring(0, restructuredAuthURL.length() - 1)); + } + } + + private String processSingleURLGroup(List urlArray, String urlType) { + StringBuilder concatenatedURLString = new StringBuilder("{"); + for (String url : urlArray) { + if (Constants.LOADBALANCE.equalsIgnoreCase(urlType)) { + concatenatedURLString.append(url).append(Constants.TM_BINARY_LOADBALANCE_SEPARATOR); + } else if (Constants.FAILOVER.equalsIgnoreCase(urlType)) { + concatenatedURLString.append(url).append(Constants.TM_BINARY_FAILOVER_SEPARATOR); + } else { + concatenatedURLString.append(url).append(Constants.TM_BINARY_FAILOVER_SEPARATOR); + } + } + //to remove the trailing '|' or ',' + concatenatedURLString = new StringBuilder( + concatenatedURLString.substring(0, concatenatedURLString.length() - 1) + "}"); + return concatenatedURLString.toString(); + } + private void populateJWTGeneratorConfigurations(JWTGenerator jwtGenerator) { JWTConfigurationDto jwtConfigurationDto = new JWTConfigurationDto(); jwtConfigurationDto.setEnabled(jwtGenerator.getEnable()); diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/EnforcerConfig.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/EnforcerConfig.java index 673e0785ac..2928a1dd4a 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/EnforcerConfig.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/EnforcerConfig.java @@ -26,6 +26,7 @@ import org.wso2.micro.gateway.enforcer.config.dto.EventHubConfigurationDto; import org.wso2.micro.gateway.enforcer.config.dto.ExtendedTokenIssuerDto; import org.wso2.micro.gateway.enforcer.config.dto.JWTIssuerConfigurationDto; +import org.wso2.micro.gateway.enforcer.config.dto.ThrottleConfigDto; import java.util.HashMap; import java.util.Map; @@ -39,6 +40,7 @@ public class EnforcerConfig { private EventHubConfigurationDto eventHub; private Map issuersMap = new HashMap<>(); private CredentialDto apimCredentials; + private ThrottleConfigDto throttleConfig; private JWTConfigurationDto jwtConfigurationDto; private CacheDto cacheDto; private JWTIssuerConfigurationDto jwtIssuerConfigurationDto; @@ -79,6 +81,14 @@ public void setApimCredentials(CredentialDto apimCredentials) { this.apimCredentials = apimCredentials; } + public ThrottleConfigDto getThrottleConfig() { + return throttleConfig; + } + + public void setThrottleConfig(ThrottleConfigDto throttleConfig) { + this.throttleConfig = throttleConfig; + } + public void setJwtConfigurationDto(JWTConfigurationDto jwtConfigurationDto) { this.jwtConfigurationDto = jwtConfigurationDto; } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleAgentConfigDto.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleAgentConfigDto.java new file mode 100644 index 0000000000..0b54b82441 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleAgentConfigDto.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.config.dto; + +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.AgentConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.publisher.PublisherConfiguration; + +import java.util.ArrayList; +import java.util.List; + +/** + * This contains throttle configurations. + */ +public class ThrottleAgentConfigDto { + String username; + String password; + List urlGroup = new ArrayList<>(); + PublisherConfiguration publisher; + AgentConfiguration agent; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public List getUrlGroup() { + return urlGroup; + } + + public void setUrlGroup(List urlGroup) { + this.urlGroup = urlGroup; + } + + public PublisherConfiguration getPublisher() { + return publisher; + } + + public void setPublisher(PublisherConfiguration publisher) { + this.publisher = publisher; + } + + public AgentConfiguration getAgent() { + return agent; + } + + public void setAgent(AgentConfiguration agent) { + this.agent = agent; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleConfigDto.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleConfigDto.java new file mode 100644 index 0000000000..cf1b619f0d --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleConfigDto.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.config.dto; + +/** + * Throttling configuration model. + */ +public class ThrottleConfigDto { + private boolean isGlobalPublishingEnabled; + private boolean isHeaderConditionsEnabled; + private boolean isQueryConditionsEnabled; + private boolean isJwtClaimConditionsEnabled; + private String jmsConnectionInitialContextFactory; + private String jmsConnectionProviderUrl; + private ThrottleAgentConfigDto throttleAgent; + + public boolean isGlobalPublishingEnabled() { + return isGlobalPublishingEnabled; + } + + public void setGlobalPublishingEnabled(boolean globalPublishingEnabled) { + isGlobalPublishingEnabled = globalPublishingEnabled; + } + + public boolean isHeaderConditionsEnabled() { + return isHeaderConditionsEnabled; + } + + public void setHeaderConditionsEnabled(boolean headerConditionsEnabled) { + isHeaderConditionsEnabled = headerConditionsEnabled; + } + + public boolean isQueryConditionsEnabled() { + return isQueryConditionsEnabled; + } + + public void setQueryConditionsEnabled(boolean queryConditionsEnabled) { + isQueryConditionsEnabled = queryConditionsEnabled; + } + + public boolean isJwtClaimConditionsEnabled() { + return isJwtClaimConditionsEnabled; + } + + public void setJwtClaimConditionsEnabled(boolean jwtClaimConditionsEnabled) { + isJwtClaimConditionsEnabled = jwtClaimConditionsEnabled; + } + + public String getJmsConnectionInitialContextFactory() { + return jmsConnectionInitialContextFactory; + } + + public void setJmsConnectionInitialContextFactory(String jmsConnectionInitialContextFactory) { + this.jmsConnectionInitialContextFactory = jmsConnectionInitialContextFactory; + } + + public String getJmsConnectionProviderUrl() { + return jmsConnectionProviderUrl; + } + + public void setJmsConnectionProviderUrl(String jmsConnectionProviderUrl) { + this.jmsConnectionProviderUrl = jmsConnectionProviderUrl; + } + + public ThrottleAgentConfigDto getThrottleAgent() { + return throttleAgent; + } + + public void setThrottleAgent(ThrottleAgentConfigDto throttleAgent) { + this.throttleAgent = throttleAgent; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleURLGroupDto.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleURLGroupDto.java new file mode 100644 index 0000000000..ef33fc715b --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleURLGroupDto.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.config.dto; + +/** + * Throttle URL groups configurations. + */ +public class ThrottleURLGroupDto { + String[] receiverURLs; + String[] authURLs; + String type; + + public String[] getReceiverURLs() { + return receiverURLs; + } + + public void setReceiverURLs(String[] receiverURLs) { + this.receiverURLs = receiverURLs; + } + + public String[] getAuthURLs() { + return authURLs; + } + + public void setAuthURLs(String[] authURLs) { + this.authURLs = authURLs; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java index bbc33970fa..9c075547ec 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java @@ -22,8 +22,6 @@ */ public class APIConstants { - public static final String UNLIMITED_TIER = "Unlimited"; - //open API extensions public static final String X_WSO2_BASE_PATH = "x-wso2-basepath"; @@ -34,7 +32,6 @@ public class APIConstants { public static final String GW_API_NAME_PARAM = "name"; public static final String PROTOTYPED_LIFE_CYCLE_STATUS = "PROTOTYPED"; - public static final String GATEWAY_SIGNED_JWT_CACHE = "SignedJWTParseCache"; public static final String GATEWAY_PUBLIC_CERTIFICATE_ALIAS = "wso2carbon"; public static final String HTTPS_PROTOCOL = "https"; @@ -88,7 +85,7 @@ private KeyValidationStatus() { } /** - * Holds the common set of constants for output of the subscription validation + * Holds the common set of constants for output of the subscription validation. */ public static class SubscriptionStatus { @@ -105,7 +102,7 @@ private SubscriptionStatus() { } /** - * Holds the common set of constants for validating the JWT tokens + * Holds the common set of constants for validating the JWT tokens. */ public static class JwtTokenConstants { @@ -294,19 +291,6 @@ public enum PolicyType { SUBSCRIPTION } - /** - * Topic Names. - */ - public static class TopicNames { - - //APIM default topic names - public static final String TOPIC_THROTTLE_DATA = "throttleData"; - public static final String TOPIC_TOKEN_REVOCATION = "tokenRevocation"; - public static final String TOPIC_CACHE_INVALIDATION = "cacheInvalidation"; - public static final String TOPIC_KEY_MANAGER = "keyManager"; - public static final String TOPIC_NOTIFICATION = "notification"; - } - /** * Holds the constants related to attributes to be sent in the response in case of an error * scenario raised within the enforcer. @@ -325,7 +309,8 @@ public enum StatusCodes { OK("200", 200), UNAUTHENTICATED("401", 401), UNAUTHORIZED("403", 403), - NOTFOUND("404", 404); + NOTFOUND("404", 404), + THROTTLED("429", 429); private String value; private int code; @@ -342,4 +327,5 @@ public int getCode() { return this.code; } } + } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APISecurityConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APISecurityConstants.java index 5eb4c07e12..635c3121e3 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APISecurityConstants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APISecurityConstants.java @@ -69,25 +69,12 @@ public class APISecurityConstants { public static final int API_AUTH_MISSING_OPEN_API_DEF = 900911; public static final String API_AUTH_MISSING_OPEN_API_DEF_ERROR_MESSAGE = "Internal Server Error"; - public static final int GRAPHQL_QUERY_TOO_DEEP = 900912; - public static final String GRAPHQL_QUERY_TOO_DEEP_MESSAGE = "QUERY TOO DEEP"; - - public static final int GRAPHQL_QUERY_TOO_COMPLEX = 900913; - public static final String GRAPHQL_QUERY_TOO_COMPLEX_MESSAGE = "QUERY TOO COMPLEX"; - - public static final int GRAPHQL_INVALID_QUERY = 900422; - public static final String GRAPHQL_API_FAILURE_HANDLER = "_graphql_failure_handler"; - public static final String GRAPHQL_INVALID_QUERY_MESSAGE = "INVALID QUERY"; - - public static final int OAUTH_TEMPORARY_SERVER_ERROR = 900424; - public static final String OAUTH_TEMPORARY_SERVER_ERROR_MESSAGE = "Temporary Server Error"; - // We have added this because we need to add an additional description to the original one and we need to // separate the 2 messages public static final String DESCRIPTION_SEPARATOR = ". "; /** - * returns an String that corresponds to errorCode passed in + * returns an String that corresponds to errorCode passed in. * * @param errorCode * @return String diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/Constants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/Constants.java index 7a400a20be..b9ac14f1a7 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/Constants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/Constants.java @@ -48,6 +48,12 @@ public class Constants { public static final String END_OF_PRIVATE_KEY = "-----END PRIVATE KEY-----"; public static final String RSA = "RSA"; + public static final String LOADBALANCE = "loadbalance"; + public static final String FAILOVER = "failover"; + public static final String TM_BINARY_LOADBALANCE_SEPARATOR = ","; + public static final String TM_BINARY_FAILOVER_SEPARATOR = "|"; + public static final String UNKNOWN_VALUE = "__unknown__"; + public static final String OBJECT_THIS_NOTATION = "this$"; public static final String ENV_PREFIX = "$env{"; public static final String START_BRACKET = "{"; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java new file mode 100644 index 0000000000..6df84a39b8 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java @@ -0,0 +1,312 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.filters; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.json.JSONObject; +import org.wso2.micro.gateway.enforcer.Filter; +import org.wso2.micro.gateway.enforcer.api.RequestContext; +import org.wso2.micro.gateway.enforcer.api.config.APIConfig; +import org.wso2.micro.gateway.enforcer.api.config.ResourceConfig; +import org.wso2.micro.gateway.enforcer.config.ConfigHolder; +import org.wso2.micro.gateway.enforcer.constants.APIConstants; +import org.wso2.micro.gateway.enforcer.security.AuthenticationContext; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleAgent; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleConstants; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleDataHolder; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.ThrottleEventConstants; +import org.wso2.micro.gateway.enforcer.util.FilterUtils; + +import java.net.Inet4Address; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.HashMap; +import java.util.Map; + +/** + * This is the filter handling the authentication for the requests flowing through the gateway. + */ +public class ThrottleFilter implements Filter { + private static final Logger log = LogManager.getLogger(ThrottleFilter.class); + + private final boolean isGlobalThrottlingEnabled; + private final ThrottleDataHolder dataHolder; + + public ThrottleFilter() { + this.dataHolder = ThrottleDataHolder.getInstance(); + this.isGlobalThrottlingEnabled = ConfigHolder.getInstance().getConfig().getThrottleConfig() + .isGlobalPublishingEnabled(); + } + + @Override + public void init(APIConfig apiConfig) {} + + @Override + public boolean handleRequest(RequestContext requestContext) { + log.debug("Throttle filter received the request"); + + if (doThrottle(requestContext)) { + // breaking filter chain since request is throttled + return false; + } + + // publish throttle event and continue the filter chain + ThrottleAgent.publishNonThrottledEvent(getThrottleEventMap(requestContext)); + return true; + } + + /** + * Evaluate the throttle policies to find out if the request is throttled at any supported throttling level. + * + * @param reqContext request context with all request related details, + * including the authentication details + * @return {@code true} if the request is throttled, otherwise {@code false} + */ + private boolean doThrottle(RequestContext reqContext) { + AuthenticationContext authContext = reqContext.getAuthenticationContext(); + + // TODO: (Praminda) Handle unauthenticated + subscription validation false scenarios + if (reqContext.getAuthenticationContext() != null) { + log.debug("Found AuthenticationContext for the request"); + APIConfig api = reqContext.getMathedAPI().getAPIConfig(); + String apiContext = api.getBasePath(); + String apiVersion = api.getVersion(); + String appId = authContext.getApplicationId(); + String apiTier = authContext.getApiTier(); + String apiThrottleKey = getApiThrottleKey(apiContext, apiVersion); + String resourceTier = getResourceTier(reqContext.getMatchedResourcePath()); + String resourceThrottleKey = getResourceThrottleKey(reqContext, apiContext, apiVersion); + String subTier = authContext.getTier(); + String appTier = authContext.getApplicationTier(); + + if (isAPILevelThrottled(apiThrottleKey, apiTier)) { + FilterUtils.setThrottleErrorToContext(reqContext, + ThrottleConstants.API_THROTTLE_OUT_ERROR_CODE, + ThrottleConstants.THROTTLE_OUT_MESSAGE, + ThrottleConstants.THROTTLE_OUT_DESCRIPTION); + reqContext.getProperties().put(ThrottleConstants.THROTTLE_OUT_REASON, + ThrottleConstants.THROTTLE_OUT_REASON_API_LIMIT_EXCEEDED); + return true; + } else if (isResourceLevelThrottled(resourceThrottleKey, resourceTier)) { + FilterUtils.setThrottleErrorToContext(reqContext, + ThrottleConstants.RESOURCE_THROTTLE_OUT_ERROR_CODE, + ThrottleConstants.THROTTLE_OUT_MESSAGE, + ThrottleConstants.THROTTLE_OUT_DESCRIPTION); + reqContext.getProperties().put(ThrottleConstants.THROTTLE_OUT_REASON, + ThrottleConstants.THROTTLE_OUT_REASON_RESOURCE_LIMIT_EXCEEDED); + return true; + } + String subThrottleKey = getSubscriptionThrottleKey(appId, apiContext, apiVersion); + boolean isSubscriptionThrottled = isSubscriptionLevelThrottled(subThrottleKey, subTier); + if (isSubscriptionThrottled) { + if (authContext.isStopOnQuotaReach()) { + log.debug("Setting subscription throttle out response"); + FilterUtils.setThrottleErrorToContext(reqContext, + ThrottleConstants.SUBSCRIPTION_THROTTLE_OUT_ERROR_CODE, + ThrottleConstants.THROTTLE_OUT_MESSAGE, + ThrottleConstants.THROTTLE_OUT_DESCRIPTION); + reqContext.getProperties().put(ThrottleConstants.THROTTLE_OUT_REASON, + ThrottleConstants.THROTTLE_OUT_REASON_SUBSCRIPTION_LIMIT_EXCEEDED); + return true; + } + log.debug("Proceeding since stopOnQuotaReach is false"); + } + + String appThrottleKey = appId + ':' + authContext.getUsername(); + boolean isAppThrottled = isAppLevelThrottled(appThrottleKey, appTier); + if (isAppThrottled) { + log.debug("Setting application throttle out response"); + FilterUtils.setThrottleErrorToContext(reqContext, + ThrottleConstants.APPLICATION_THROTTLE_OUT_ERROR_CODE, + ThrottleConstants.THROTTLE_OUT_MESSAGE, + ThrottleConstants.THROTTLE_OUT_DESCRIPTION); + reqContext.getProperties().put(ThrottleConstants.THROTTLE_OUT_REASON, + ThrottleConstants.THROTTLE_OUT_REASON_APPLICATION_LIMIT_EXCEEDED); + return true; + } + } + return false; + } + + private boolean isSubscriptionLevelThrottled(String throttleKey, String tier) { + boolean isThrottled = dataHolder.isThrottled(throttleKey); + log.debug("Subscription Level throttle decision is {} for key:tier {}:{}", isThrottled, throttleKey, tier); + return isThrottled; + } + + private boolean isAppLevelThrottled(String throttleKey, String tier) { + boolean isThrottled = dataHolder.isThrottled(throttleKey); + log.debug("Application Level throttle decision is {} for key:tier {}:{}", isThrottled, throttleKey, tier); + return isThrottled; + } + + private boolean isAPILevelThrottled(String throttleKey, String tier) { + log.debug("Checking if request is throttled at API level for tier: {}", tier); + + if (ThrottleConstants.UNLIMITED_TIER.equals(tier)) { + return false; + } + + if (isGlobalThrottlingEnabled) { + // TODO: (Praminda) Check conditional throttling decisions + boolean isThrottled; + throttleKey += "_default"; + + isThrottled = dataHolder.isThrottled(throttleKey); + log.debug("API Level throttle decision: {}", isThrottled); + return isThrottled; + } + return false; + } + + private boolean isResourceLevelThrottled(String throttleKey, String tier) { + log.debug("Checking if request is throttled at resource level for tier: " + tier); + + if (ThrottleConstants.UNLIMITED_TIER.equals(tier)) { + return false; + } + + if (isGlobalThrottlingEnabled) { + boolean isThrottled; + throttleKey += "_default"; + + isThrottled = dataHolder.isThrottled(throttleKey); + log.debug("Resource Level throttle decision: {}", isThrottled); + return isThrottled; + } + return false; + } + + //TODO (amaliMatharaarachchi) Add default values to keys. + // Handle fault invocations. + // Test all flows. + // Add unit tests. + + /** + * This will generate the throttling event map to be publish to the traffic manager. + * + * @param requestContext request context + * @return Map of throttle event data + */ + private Map getThrottleEventMap(RequestContext requestContext) { + AuthenticationContext authenticationContext = requestContext.getAuthenticationContext(); + Map throttleEvent = new HashMap<>(); + + String basePath = requestContext.getMathedAPI().getAPIConfig().getBasePath(); + String apiVersion = requestContext.getMathedAPI().getAPIConfig().getVersion(); + String apiContext = basePath + ':' + apiVersion; + String apiName = requestContext.getMathedAPI().getAPIConfig().getName(); + String tenantDomain = FilterUtils.getTenantDomainFromRequestURL(apiContext); + if (tenantDomain == null) { + tenantDomain = APIConstants.SUPER_TENANT_DOMAIN_NAME; + } + String resourceTier; + String resourceKey; + + if (!ThrottleConstants.UNLIMITED_TIER.equals(authenticationContext.getApiTier()) && + authenticationContext.getApiTier() != null && + !authenticationContext.getApiTier().isBlank()) { + resourceTier = authenticationContext.getApiTier(); + resourceKey = apiContext; + } else { + resourceTier = getResourceTier(requestContext.getMatchedResourcePath()); + resourceKey = getResourceThrottleKey(requestContext, apiContext, apiVersion); + } + + throttleEvent.put(ThrottleEventConstants.MESSAGE_ID, requestContext.getRequestID()); + throttleEvent.put(ThrottleEventConstants.APP_KEY, authenticationContext.getApplicationId() + ':' + + authenticationContext.getUsername()); + throttleEvent.put(ThrottleEventConstants.APP_TIER, authenticationContext.getApplicationTier()); + throttleEvent.put(ThrottleEventConstants.API_KEY, apiContext); + throttleEvent.put(ThrottleEventConstants.API_TIER, authenticationContext.getApiTier()); + throttleEvent.put(ThrottleEventConstants.SUBSCRIPTION_KEY, authenticationContext.getApplicationId() + ':' + + apiContext); + throttleEvent.put(ThrottleEventConstants.SUBSCRIPTION_TIER, authenticationContext.getTier()); + throttleEvent.put(ThrottleEventConstants.RESOURCE_KEY, resourceKey); + throttleEvent.put(ThrottleEventConstants.RESOURCE_TIER, resourceTier); + throttleEvent.put(ThrottleEventConstants.USER_ID, authenticationContext.getUsername()); + throttleEvent.put(ThrottleEventConstants.API_CONTEXT, basePath); + throttleEvent.put(ThrottleEventConstants.API_VERSION, apiVersion); + throttleEvent.put(ThrottleEventConstants.APP_TENANT, authenticationContext.getSubscriberTenantDomain()); + throttleEvent.put(ThrottleEventConstants.API_TENANT, tenantDomain); + throttleEvent.put(ThrottleEventConstants.APP_ID, authenticationContext.getApplicationId()); + throttleEvent.put(ThrottleEventConstants.API_NAME, apiName); + throttleEvent.put(ThrottleEventConstants.PROPERTIES, getProperties(requestContext).toString()); + return throttleEvent; + } + + private String getResourceThrottleKey(RequestContext requestContext, String apiContext, String apiVersion) { + String resourceThrottleKey = apiContext; + if (!apiVersion.isBlank()) { + resourceThrottleKey += "/" + apiVersion; + } + resourceThrottleKey += requestContext.getMatchedResourcePath().getPath() + ':' + + requestContext.getRequestMethod(); + return resourceThrottleKey; + } + + private String getApiThrottleKey(String apiContext, String apiVersion) { + String apiThrottleKey = apiContext; + if (!apiVersion.isBlank()) { + apiThrottleKey += ':' + apiVersion; + } + return apiThrottleKey; + } + + private String getSubscriptionThrottleKey(String appId, String apiContext, String apiVersion) { + String subThrottleKey = appId + ':' + apiContext; + if (!apiVersion.isBlank()) { + subThrottleKey += ':' + apiVersion; + } + return subThrottleKey; + } + + private String getResourceTier(ResourceConfig resourceConfig) { + if (!resourceConfig.getTier().isBlank()) { + return resourceConfig.getTier(); + } + return ThrottleConstants.UNLIMITED_TIER; + } + + + private JSONObject getProperties(RequestContext requestContext) { + String remoteIP = requestContext.getAddress(); + JSONObject jsonObMap = new JSONObject(); + if (remoteIP != null && remoteIP.length() > 0) { + try { + InetAddress address = InetAddress.getByName(remoteIP); + if (address instanceof Inet4Address) { + jsonObMap.put(ThrottleConstants.IP, FilterUtils.ipToLong(remoteIP)); + jsonObMap.put(ThrottleConstants.IPV6, 0); + } else if (address instanceof Inet6Address) { + jsonObMap.put(ThrottleConstants.IPV6, FilterUtils.ipToBigInteger(remoteIP)); + jsonObMap.put(ThrottleConstants.IP, 0); + } + } catch (UnknownHostException e) { + //send empty value as ip + log.error("Error while parsing host IP {}", remoteIP, e); + jsonObMap.put(ThrottleConstants.IPV6, 0); + jsonObMap.put(ThrottleConstants.IP, 0); + } + } + // TODO(amaliMatharaarachchi) Add advance throttling data to additional properties. + return jsonObMap; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/DeployAPIInGatewayEvent.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/DeployAPIInGatewayEvent.java index fcb7220feb..f6c2c4f85a 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/DeployAPIInGatewayEvent.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/DeployAPIInGatewayEvent.java @@ -20,7 +20,7 @@ import java.util.Set; /** - * Deploy API in Gateway Event + * Deploy API in Gateway Event. */ public class DeployAPIInGatewayEvent extends Event { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/PolicyEvent.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/PolicyEvent.java index 639333ea45..33acf5773b 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/PolicyEvent.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/PolicyEvent.java @@ -22,7 +22,7 @@ import org.wso2.micro.gateway.enforcer.constants.APIConstants; /** - * Policy Event class + * Policy Event class. */ public class PolicyEvent extends Event { protected APIConstants.PolicyType policyType; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApiPolicy.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApiPolicy.java index 72bae01419..1affda7ddc 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApiPolicy.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApiPolicy.java @@ -24,7 +24,7 @@ import java.util.List; /** - * Holds details about API/resource level Policy + * Holds details about API/resource level Policy. */ public class ApiPolicy extends Policy { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationKeyMappingCacheKey.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationKeyMappingCacheKey.java index 9c97589c53..80a9976e51 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationKeyMappingCacheKey.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationKeyMappingCacheKey.java @@ -21,7 +21,7 @@ import java.util.Objects; /** - * Cache Key For Application KeyMapping Entries + * Cache Key For Application KeyMapping Entries. */ public class ApplicationKeyMappingCacheKey { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationPolicy.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationPolicy.java index 438bea95d7..981adb5117 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationPolicy.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationPolicy.java @@ -21,7 +21,7 @@ import org.wso2.micro.gateway.enforcer.common.CacheableEntity; /** - * Entity for keeping Application Policy + * Entity for keeping Application Policy. */ public class ApplicationPolicy extends Policy { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/Subscription.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/Subscription.java index a604131382..d56c590e71 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/Subscription.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/Subscription.java @@ -22,7 +22,7 @@ import org.wso2.micro.gateway.enforcer.subscription.SubscriptionDataStoreUtil; /** - * Entity for representing a SubscriptionDTO in APIM + * Entity for representing a SubscriptionDTO in APIM. */ public class Subscription implements CacheableEntity { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AccessTokenInfo.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AccessTokenInfo.java index c8fd05aac0..48edbe9f4c 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AccessTokenInfo.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AccessTokenInfo.java @@ -101,7 +101,7 @@ public void setConsumerKey(String consumerKey) { } /** - * Get consumer secret corresponding to the access token + * Get consumer secret corresponding to the access token. * * @return consumer secret */ @@ -110,7 +110,7 @@ public String getConsumerSecret() { } /** - * Set consumer secret corresponding to the access token + * Set consumer secret corresponding to the access token. * * @param consumerSecret consumer secret to set */ diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AuthenticationContext.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AuthenticationContext.java index 11dd83f20d..aaf0b82ebb 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AuthenticationContext.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AuthenticationContext.java @@ -18,6 +18,9 @@ package org.wso2.micro.gateway.enforcer.security; +import org.wso2.micro.gateway.enforcer.constants.Constants; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleConstants; + import java.util.List; /** @@ -50,6 +53,19 @@ public class AuthenticationContext { private String apiPublisher; private String apiVersion; + public AuthenticationContext() { + this.applicationId = Constants.UNKNOWN_VALUE; + this.apiPublisher = Constants.UNKNOWN_VALUE; + this.apiTier = ""; + this.applicationId = Constants.UNKNOWN_VALUE; + this.applicationName = Constants.UNKNOWN_VALUE; + this.applicationTier = ThrottleConstants.UNLIMITED_TIER; + this.consumerKey = Constants.UNKNOWN_VALUE; + this.spikeArrestUnit = ""; + this.subscriber = Constants.UNKNOWN_VALUE; + this.subscriberTenantDomain = Constants.UNKNOWN_VALUE; + } + public List getThrottlingDataList() { return throttlingDataList; } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTAuthenticator.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTAuthenticator.java index ff8a977cc0..2819ac372c 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTAuthenticator.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTAuthenticator.java @@ -115,11 +115,9 @@ public AuthenticationContext authenticate(RequestContext requestContext) throws } - JWTValidationInfo validationInfo = - getJwtValidationInfo(signedJWTInfo, jwtTokenIdentifier); + JWTValidationInfo validationInfo = getJwtValidationInfo(signedJWTInfo, jwtTokenIdentifier); if (validationInfo != null) { if (validationInfo.isValid()) { - // Validate subscriptions APIKeyValidationInfoDTO apiKeyValidationInfoDTO = null; EnforcerConfig configuration = ConfigHolder.getInstance().getConfig(); @@ -167,8 +165,8 @@ public AuthenticationContext authenticate(RequestContext requestContext) throws } AuthenticationContext authenticationContext = FilterUtils - .generateAuthenticationContext(jwtTokenIdentifier, validationInfo, apiKeyValidationInfoDTO, - endUserToken, true); + .generateAuthenticationContext(requestContext, jwtTokenIdentifier, validationInfo, + apiKeyValidationInfoDTO, endUserToken, true); //TODO: (VirajSalaka) Place the keytype population logic properly for self contained token if (claims.getClaim("keytype") != null) { authenticationContext.setKeyType(claims.getClaim("keytype").toString()); diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTUtil.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTUtil.java index 56f54b80e0..e1e3c5755b 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTUtil.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTUtil.java @@ -78,7 +78,7 @@ public class JWTUtil { private static volatile long ttl = -1L; /** - * This method used to retrieve JWKS keys from endpoint + * This method used to retrieve JWKS keys from endpoint. * * @param jwksEndpoint * @return diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/SignedJWTInfo.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/SignedJWTInfo.java index 6d25ec2ae1..5a2ba889d3 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/SignedJWTInfo.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/SignedJWTInfo.java @@ -24,7 +24,7 @@ import java.io.Serializable; /** - * JWT internal Representation + * JWT internal Representation. */ public class SignedJWTInfo implements Serializable { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/validator/RevokedJWTDataHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/validator/RevokedJWTDataHolder.java index 1d20ea03e8..90596244f5 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/validator/RevokedJWTDataHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/validator/RevokedJWTDataHolder.java @@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentHashMap; /** - * Singleton which stores the revoked JWT map + * Singleton which stores the revoked JWT map. */ public class RevokedJWTDataHolder { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java index 6e5720dfd7..af959d1dff 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java @@ -37,6 +37,8 @@ import org.wso2.micro.gateway.enforcer.keymgt.KeyManagerHolder; import org.wso2.micro.gateway.enforcer.security.jwt.validator.RevokedJWTDataHolder; import org.wso2.micro.gateway.enforcer.subscription.SubscriptionDataHolder; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleAgent; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleEventListener; import java.io.File; import java.io.IOException; @@ -62,6 +64,11 @@ public static void main(String[] args) { // Initialise cache objects CacheProvider.init(); + if (ConfigHolder.getInstance().getConfig().getThrottleConfig().isGlobalPublishingEnabled()) { + ThrottleAgent.startThrottlePublisherPool(); + ThrottleEventListener.init(); + } + // Start the server server.start(); logger.info("Sever started Listening in port : " + 8081); diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/RequestHandler.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/RequestHandler.java index 6734c85e3e..c4c8431b0b 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/RequestHandler.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/RequestHandler.java @@ -68,10 +68,16 @@ private RequestContext buildRequestContext(API api, CheckRequest request) { .get(AdapterConstants.PROD_CLUSTER_HEADER_KEY); String sandCluster = request.getAttributes().getContextExtensionsMap() .get(AdapterConstants.SAND_CLUSTER_HEADER_KEY); + String requestID = request.getAttributes().getRequest().getHttp().getId(); + String address = ""; + if (request.getAttributes().getSource().hasAddress() && + request.getAttributes().getSource().getAddress().hasSocketAddress()) { + address = request.getAttributes().getSource().getAddress().getSocketAddress().getAddress(); + } ResourceConfig resourceConfig = APIFactory.getInstance().getMatchedResource(api, res, method); return new RequestContext.Builder(requestPath).matchedResourceConfig(resourceConfig).requestMethod(method) - .matchedAPI(api).headers(headers).prodClusterHeader(prodCluster).sandClusterHeader(sandCluster) - .build(); + .matchedAPI(api).headers(headers).requestID(requestID).address(address).prodClusterHeader(prodCluster) + .sandClusterHeader(sandCluster).build(); } } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataHolder.java index 45b547f4a1..7cfc9abde0 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataHolder.java @@ -19,7 +19,7 @@ package org.wso2.micro.gateway.enforcer.subscription; /** - * This class holds tenant wise subscription data stores + * This class holds tenant wise subscription data stores. */ public class SubscriptionDataHolder { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataStore.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataStore.java index cd727fbdaa..69d31f8f56 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataStore.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataStore.java @@ -35,7 +35,7 @@ public interface SubscriptionDataStore { /** - * Gets an {@link Application} by Id + * Gets an {@link Application} by Id. * * @param appId Id of the Application * @return {@link Application} with the appId @@ -43,7 +43,7 @@ public interface SubscriptionDataStore { Application getApplicationById(int appId); /** - * Gets the {@link ApplicationKeyMapping} entry by Key + * Gets the {@link ApplicationKeyMapping} entry by Key. * * @param key . * @param keyManager Keymanager Name @@ -52,7 +52,7 @@ public interface SubscriptionDataStore { ApplicationKeyMapping getKeyMappingByKeyAndKeyManager(String key, String keyManager); /** - * Get API by Context and Version + * Get API by Context and Version. * * @param context Context of the API * @param version Version of the API @@ -61,7 +61,7 @@ public interface SubscriptionDataStore { API getApiByContextAndVersion(String context, String version); /** - * Gets Subscription by ID + * Gets Subscription by ID. * * @param appId Application associated with the Subscription * @param apiId Api associated with the Subscription @@ -70,7 +70,7 @@ public interface SubscriptionDataStore { Subscription getSubscriptionById(int appId, int apiId); /** - * Gets API Throttling Policy by the name and Tenant Id + * Gets API Throttling Policy by the name and Tenant Id. * * @param policyName Name of the Throttling Policy * @param tenantId Tenant ID in the Policy @@ -79,7 +79,7 @@ public interface SubscriptionDataStore { ApiPolicy getApiPolicyByName(String policyName, int tenantId); /** - * Gets Subscription Throttling Policy by the name and Tenant Id + * Gets Subscription Throttling Policy by the name and Tenant Id. * * @param policyName Name of the Throttling Policy * @param tenantId Tenant ID in the Policy @@ -88,7 +88,7 @@ public interface SubscriptionDataStore { SubscriptionPolicy getSubscriptionPolicyByName(String policyName, int tenantId); /** - * Gets Application Throttling Policy by the name and Tenant Id + * Gets Application Throttling Policy by the name and Tenant Id. * * @param policyName Name of the Throttling Policy * @param tenantId Tenant ID in the Policy diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/APICondition.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/APICondition.java new file mode 100644 index 0000000000..6282a460d6 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/APICondition.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle; + +/** + * DTO of parameters defining a throttle condition. + */ +public class APICondition { + private final String resourceKey; + private final String name; + + public APICondition(String resourceKey, String name) { + this.resourceKey = resourceKey; + this.name = name; + } + + public String getResourceKey() { + return resourceKey; + } + + public String getName() { + return name; + } + + @Override + public String toString() { + return "resourceKey='" + resourceKey + "', name='" + name + '\''; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/PolicyConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/PolicyConstants.java new file mode 100644 index 0000000000..388f3dfccd --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/PolicyConstants.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle; + +/** + * Throttle policy constants. + */ +public class PolicyConstants { + public static final String IP_RANGE_TYPE = "IPRange"; + public static final String IP_SPECIFIC_TYPE = "IPSpecific"; + public static final String HEADER_TYPE = "Header"; + public static final String JWT_CLAIMS_TYPE = "JWTClaims"; + public static final String QUERY_PARAMETER_TYPE = "QueryParameterType"; +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleAgent.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleAgent.java new file mode 100644 index 0000000000..d4d983701e --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleAgent.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle; + +import org.wso2.micro.gateway.enforcer.throttle.databridge.publisher.ThrottleDataPublisher; + +import java.util.Map; + +/** + * This class is used for ballerina interop invocations related to Global Throttle Event Publishing + * via binary communication. + */ +public class ThrottleAgent { + + private static ThrottleDataPublisher throttleDataPublisher = null; + + public static void startThrottlePublisherPool() { + throttleDataPublisher = new ThrottleDataPublisher(); + } + + public static void publishNonThrottledEvent(Map throttleEvent) { + throttleDataPublisher.publishNonThrottledEvent(throttleEvent); + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleCondition.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleCondition.java new file mode 100644 index 0000000000..1e21b7d14b --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleCondition.java @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle; + +import java.math.BigInteger; +import java.util.HashMap; +import java.util.Map; + +/** + * Defines the applicable conditions and the types of conditions for a conditional throttle policy. + */ +public class ThrottleCondition { + private IPCondition ipCondition; + private IPCondition ipRangeCondition; + private HeaderConditions headerConditions; + private QueryParamConditions queryParameterConditions; + private JWTClaimConditions jwtClaimConditions; + + public IPCondition getIpCondition() { + return ipCondition; + } + + public void setIpCondition(IPCondition ipCondition) { + this.ipCondition = ipCondition; + } + + public IPCondition getIpRangeCondition() { + return ipRangeCondition; + } + + public void setIpRangeCondition(IPCondition ipRangeCondition) { + this.ipRangeCondition = ipRangeCondition; + } + + public HeaderConditions getHeaderConditions() { + return headerConditions; + } + + public void setHeaderConditions(HeaderConditions headerConditions) { + this.headerConditions = headerConditions; + } + + public QueryParamConditions getQueryParameterConditions() { + return queryParameterConditions; + } + + public void setQueryParameterConditions(QueryParamConditions queryParameterConditions) { + this.queryParameterConditions = queryParameterConditions; + } + + public JWTClaimConditions getJwtClaimConditions() { + return jwtClaimConditions; + } + + public void setJwtClaimConditions(JWTClaimConditions jwtClaimConditions) { + this.jwtClaimConditions = jwtClaimConditions; + } + + /** + * Throttle condition based on request headers. + */ + public static class HeaderConditions { + private Map values = new HashMap<>(); + private boolean invert; + + public Map getValues() { + return values; + } + + public void setValues(Map values) { + this.values = values; + } + + public boolean isInvert() { + return invert; + } + + public void setInvert(boolean invert) { + this.invert = invert; + } + } + + /** + * Throttle condition based on request query parameters. + */ + public static class QueryParamConditions { + private Map values = new HashMap<>(); + private boolean invert; + + public Map getValues() { + return values; + } + + public void setValues(Map values) { + this.values = values; + } + + public boolean isInvert() { + return invert; + } + + public void setInvert(boolean invert) { + this.invert = invert; + } + } + + /** + * Throttle condition based on jwt claim conditions. + */ + public static class JWTClaimConditions { + private Map values = new HashMap<>(); + private boolean invert; + + public Map getValues() { + return values; + } + + public void setValues(Map values) { + this.values = values; + } + + public boolean isInvert() { + return invert; + } + + public void setInvert(boolean invert) { + this.invert = invert; + } + } + + /** + * Throttle condition based on request IP address. + */ + public static class IPCondition { + private BigInteger specificIp; + private BigInteger startingIp; + private BigInteger endingIp; + private boolean invert; + + public IPCondition() { + + } + + public IPCondition(BigInteger specificIp, boolean invert) { + + this.specificIp = specificIp; + this.invert = invert; + } + + public IPCondition(BigInteger startingIp, BigInteger endingIp, boolean invert) { + + this.startingIp = startingIp; + this.endingIp = endingIp; + this.invert = invert; + } + + public BigInteger getSpecificIp() { + return specificIp; + } + + public void setSpecificIp(BigInteger specificIp) { + this.specificIp = specificIp; + } + + public BigInteger getStartingIp() { + return startingIp; + } + + public void setStartingIp(BigInteger startingIp) { + this.startingIp = startingIp; + } + + public BigInteger getEndingIp() { + return endingIp; + } + + public void setEndingIp(BigInteger endingIp) { + this.endingIp = endingIp; + } + + public boolean isInvert() { + return invert; + } + + public void setInvert(boolean invert) { + this.invert = invert; + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleConstants.java new file mode 100644 index 0000000000..76a27baccb --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleConstants.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle; + +/** + * Constants related to Throttling + */ +public class ThrottleConstants { + public static final int API_THROTTLE_OUT_ERROR_CODE = 900800; + public static final int HARD_LIMIT_EXCEEDED_ERROR_CODE = 900801; + public static final int RESOURCE_THROTTLE_OUT_ERROR_CODE = 900802; + public static final int APPLICATION_THROTTLE_OUT_ERROR_CODE = 900803; + public static final int SUBSCRIPTION_THROTTLE_OUT_ERROR_CODE = 900804; + public static final int SUBSCRIPTION_BURST_THROTTLE_OUT_ERROR_CODE = 900807; + public static final int BLOCKED_ERROR_CODE = 900805; + public static final int CUSTOM_POLICY_THROTTLE_OUT_ERROR_CODE = 900806; + public static final int CONNECTIONS_COUNT_THROTTLE_OUT_ERROR_CODE = 900808; + public static final int EVENTS_COUNT_THROTTLE_OUT_ERROR_CODE = 900808; + + public static final String THROTTLE_OUT_MESSAGE = "Message throttled out"; + public static final String THROTTLE_OUT_DESCRIPTION = "You have exceeded your quota"; + public static final String BLOCKING_MESSAGE = "Message blocked"; + public static final String BLOCKING_DESCRIPTION = "You have been blocked from accessing the resource"; + + public static final String THROTTLE_OUT_REASON_API_LIMIT_EXCEEDED = "API_LIMIT_EXCEEDED"; + public static final String THROTTLE_OUT_REASON_RESOURCE_LIMIT_EXCEEDED = "RESOURCE_LIMIT_EXCEEDED"; + public static final String THROTTLE_OUT_REASON_SUBSCRIPTION_LIMIT_EXCEEDED = "SUBSCRIPTION_LIMIT_EXCEEDED"; + public static final String THROTTLE_OUT_REASON_APPLICATION_LIMIT_EXCEEDED = "APPLICATION_LIMIT_EXCEEDED"; + public static final String POLICY_NOT_FOUND_DESCRIPTION = "POLICY ENFORCEMENT ERROR"; + + public static final String UNLIMITED_TIER = "Unlimited"; + public static final String IP = "ip"; + public static final String IPV6 = "ipv6"; + public static final String BLOCKING_CONDITION_KEY = "blockingCondition"; + public static final String POLICY_TEMPLATE_KEY = "keyTemplateValue"; + public static final String THROTTLE_KEY = "throttleKey"; + public static final String THROTTLE_OUT_REASON = "THROTTLED_OUT_REASON"; + public static final String TOPIC_THROTTLE_DATA = "throttleData"; + + /** + * Advanced Throttling related constants. + */ + public static class AdvancedThrottleConstants { + public static final String IS_THROTTLED = "isThrottled"; + public static final String THROTTLE_KEY = "throttleKey"; + public static final String EXPIRY_TIMESTAMP = "expiryTimeStamp"; + public static final String EVALUATED_CONDITIONS = "evaluatedConditions"; + public static final String TRUE = "true"; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleDataHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleDataHolder.java new file mode 100644 index 0000000000..936cb8bf91 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleDataHolder.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle; + + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * This class holds throttle data per given node. In addition to holding throttle data if provides + * required methods to evaluate throttle state of a given throttling key. + */ +public class ThrottleDataHolder { + private static final Log log = LogFactory.getLog(ThrottleDataHolder.class); + + private final Map throttleDataMap; + private static ThrottleDataHolder instance; + private final Map>> conditionDtoMap = new ConcurrentHashMap<>(); + + private ThrottleDataHolder() { + throttleDataMap = new ConcurrentHashMap<>(); + } + + public static ThrottleDataHolder getInstance() { + if (instance == null) { + instance = new ThrottleDataHolder(); + } + + return instance; + } + + /** + * Add throttle conditions to the Throttle Conditions map. + * + * @param key throttle key + * @param conditionKey condition key + * @param conditionValue conditions to be added to the map + */ + public void addThrottledConditions(String key, String conditionKey, List conditionValue) { + Map> conditionMap; + + if (conditionDtoMap.containsKey(key)) { + conditionMap = conditionDtoMap.get(key); + } else { + conditionMap = new ConcurrentHashMap<>(); + conditionDtoMap.put(key, conditionMap); + } + if (!conditionMap.containsKey(conditionKey)) { + conditionMap.put(conditionKey, conditionValue); + } + } + + /** + * Remove throttle conditions from the Throttle Conditions map. + * + * @param key throttle key + * @param conditionKey condition key to be removed + */ + public void removeThrottledConditions(String key, String conditionKey) { + if (conditionDtoMap.containsKey(key)) { + Map> conditionMap = conditionDtoMap.get(key); + conditionMap.remove(conditionKey); + if (conditionMap.isEmpty()) { + conditionDtoMap.remove(key); + } + } + } + + /** + * Add new throttle data item to the throttle data map. + * + * @param key throttle key to be added + * @param timestamp throttle timestamp + */ + public void addThrottleData(String key, Long timestamp) { + throttleDataMap.put(key, timestamp); + } + + /** + * Remove throttle data item from the throttle data map. + * + * @param key throttle key to be removed + */ + public void removeThrottleData(String key) { + throttleDataMap.remove(key); + } + + /** + * This method will check given key in throttle data Map. A key is considered throttled if, + *
    + *
  1. A values for the given @{code key} exists in the throttle data map
  2. + *
  3. Validity timestamp for the provided key is not passed already
  4. + *
+ * + * @param key throttle key + * @return {@code true} if event is throttled {@code false} if event is not throttled. + */ + public boolean isThrottled(String key) { + boolean isThrottled = this.throttleDataMap.containsKey(key); + + if (isThrottled) { + long currentTime = System.currentTimeMillis(); + long timestamp = this.throttleDataMap.get(key); + if (timestamp < currentTime) { + this.throttleDataMap.remove(key); + isThrottled = false; + } + } + + return isThrottled; + } + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java new file mode 100644 index 0000000000..8939b7e151 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.micro.gateway.enforcer.config.ConfigHolder; +import org.wso2.micro.gateway.enforcer.config.dto.ThrottleConfigDto; + +import java.util.Date; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.jms.JMSException; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.Topic; +import javax.jms.TopicConnection; +import javax.jms.TopicConnectionFactory; +import javax.jms.TopicSession; +import javax.jms.TopicSubscriber; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +/** + * JMS event listener for throttle data. + */ +public class ThrottleEventListener implements MessageListener { + private static final Logger log = LogManager.getLogger(ThrottleEventListener.class); + + // These patterns will be used to determine for which type of keys the throttling condition has occurred. + private final Pattern apiPattern = Pattern.compile("/.*/(.*):\\1_(condition_(\\d*)|default)"); + private static final int API_PATTERN_GROUPS = 3; + private static final int API_PATTERN_CONDITION_INDEX = 2; + + private final Pattern resourcePattern = Pattern.compile("/.*/(.*)/\\1(.*)?:[A-Z]{0,7}_(condition_(\\d*)|default)"); + public static final int RESOURCE_PATTERN_GROUPS = 4; + public static final int RESOURCE_PATTERN_CONDITION_INDEX = 3; + + private ThrottleEventListener() {} + + public static void init() { + ThrottleConfigDto throttleConf = ConfigHolder.getInstance().getConfig().getThrottleConfig(); + String initialContextFactory = throttleConf.getJmsConnectionInitialContextFactory(); + String connectionFactoryNamePrefix = "connectionfactory."; + String connectionFactoryName = "qpidConnectionfactory"; + String eventReceiverURL = throttleConf.getJmsConnectionProviderUrl(); + Runnable runnable = () -> { + try { + TopicConnection topicConnection; + TopicSession topicSession; + Properties properties = new Properties(); + properties.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory); + properties.put(connectionFactoryNamePrefix + connectionFactoryName, eventReceiverURL); + InitialContext context = new InitialContext(properties); + TopicConnectionFactory connFactory = (TopicConnectionFactory) context.lookup(connectionFactoryName); + topicConnection = connFactory.createTopicConnection(); + topicConnection.start(); + topicSession = topicConnection.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE); + Topic gatewayJmsTopic = topicSession.createTopic(ThrottleConstants.TOPIC_THROTTLE_DATA); + TopicSubscriber listener = topicSession.createSubscriber(gatewayJmsTopic); + listener.setMessageListener(new ThrottleEventListener()); + } catch (NamingException | JMSException e) { + log.error("Error while initiating jms connection...", e); + } + }; + Thread jmsThread = new Thread(runnable); + jmsThread.start(); + } + + @Override + public void onMessage(Message message) { + if (message == null) { + log.warn("Dropping the empty/null event received through jms receiver"); + return; + } else if (!(message instanceof MapMessage)) { + log.warn("Event dropped due to unsupported message type " + message.getClass()); + return; + } + + try { + Topic jmsDestination = (Topic) message.getJMSDestination(); + MapMessage mapMessage = (MapMessage) message; + Map map = new HashMap<>(); + Enumeration enumeration = mapMessage.getMapNames(); + while (enumeration.hasMoreElements()) { + String key = (String) enumeration.nextElement(); + map.put(key, mapMessage.getObject(key)); + } + + if (ThrottleConstants.TOPIC_THROTTLE_DATA.equalsIgnoreCase(jmsDestination.getTopicName())) { + if (map.get(ThrottleConstants.THROTTLE_KEY) != null) { + /* + * This message contains throttle data in map which contains Keys + * throttleKey - Key of particular throttling level + * isThrottled - Whether message has throttled or not + * expiryTimeStamp - When the throttling time window will expires + */ + + handleThrottleUpdateMessage(map); + } + } + } catch (JMSException e) { + log.error("Error occurred when processing the received message ", e); + } + } + + private void handleThrottleUpdateMessage(Map map) { + String throttleKey = map.get(ThrottleConstants.AdvancedThrottleConstants.THROTTLE_KEY).toString(); + String throttleState = map.get(ThrottleConstants.AdvancedThrottleConstants.IS_THROTTLED).toString(); + long timeStamp = Long.parseLong(map.get(ThrottleConstants. + AdvancedThrottleConstants.EXPIRY_TIMESTAMP).toString()); + Object evaluatedConditionObject = map.get(ThrottleConstants.AdvancedThrottleConstants.EVALUATED_CONDITIONS); + ThrottleDataHolder dataHolder = ThrottleDataHolder.getInstance(); + + if (log.isDebugEnabled()) { + log.debug("Received event - throttleKey : " + throttleKey + ", isThrottled: " + + throttleState + ", expiryTime: " + new Date(timeStamp).toString()); + } + + if (ThrottleConstants.AdvancedThrottleConstants.TRUE.equalsIgnoreCase(throttleState)) { + dataHolder.addThrottleData(throttleKey, timeStamp); + APICondition extractedKey = extractAPIorResourceKey(throttleKey); + log.debug("Adding throttling key : {}", extractedKey); + + if (extractedKey != null) { + if (evaluatedConditionObject != null) { + String conditionStr = (String) evaluatedConditionObject; + List conditions = ThrottleUtils.extractThrottleCondition(conditionStr); + dataHolder.addThrottledConditions(extractedKey.getResourceKey(), extractedKey.getName(), + conditions); + } + } + } else { + dataHolder.removeThrottleData(throttleKey); + APICondition extractedKey = extractAPIorResourceKey(throttleKey); + if (extractedKey != null) { + if (log.isDebugEnabled()) { + log.debug("Removing throttling key : " + extractedKey.getResourceKey()); + } + + dataHolder.removeThrottledConditions(extractedKey.getResourceKey(), extractedKey.getName()); + } + } + } + + private APICondition extractAPIorResourceKey(String throttleKey) { + Matcher m = resourcePattern.matcher(throttleKey); + if (m.matches()) { + if (m.groupCount() == RESOURCE_PATTERN_GROUPS) { + String condition = m.group(RESOURCE_PATTERN_CONDITION_INDEX); + String resourceKey = throttleKey.substring(0, throttleKey.indexOf("_" + condition)); + return new APICondition(resourceKey, condition); + } + } else { + m = apiPattern.matcher(throttleKey); + if (m.matches()) { + if (m.groupCount() == API_PATTERN_GROUPS) { + String condition = m.group(API_PATTERN_CONDITION_INDEX); + String resourceKey = throttleKey.substring(0, throttleKey.indexOf("_" + condition)); + return new APICondition(resourceKey, condition); + } + } + } + return null; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleUtils.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleUtils.java new file mode 100644 index 0000000000..f3172eb07f --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleUtils.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle; + +import com.google.gson.Gson; +import org.apache.commons.codec.binary.Base64; +import org.json.JSONArray; +import org.json.JSONObject; +import org.json.JSONTokener; + +import java.util.ArrayList; +import java.util.List; + +/** + * Utilities related to throttling. + */ +public class ThrottleUtils { + + /** + * Extract a {@code ThrottleCondition} from a provided compatible base64 encoded string. + * + * @param base64EncodedString base64 encoded string containing a json in compatible format + * @return list of extracted {@code ThrottleCondition}s + */ + public static List extractThrottleCondition(String base64EncodedString) { + + List conditionDtoList = new ArrayList<>(); + String base64Decoded = new String(Base64.decodeBase64(base64EncodedString)); + JSONTokener tokener = new JSONTokener(base64Decoded); + JSONArray conditionJsonArray = new JSONArray(tokener); + for (Object conditionJson : conditionJsonArray) { + ThrottleCondition conditionDto = new ThrottleCondition(); + JSONObject conditionJsonObject = (JSONObject) conditionJson; + if (conditionJsonObject.has(PolicyConstants.IP_SPECIFIC_TYPE.toLowerCase())) { + JSONObject ipSpecificCondition = (JSONObject) conditionJsonObject.get(PolicyConstants.IP_SPECIFIC_TYPE + .toLowerCase()); + ThrottleCondition.IPCondition ipCondition = new Gson().fromJson(ipSpecificCondition.toString(), + ThrottleCondition.IPCondition.class); + conditionDto.setIpCondition(ipCondition); + } else if (conditionJsonObject.has(PolicyConstants.IP_RANGE_TYPE.toLowerCase())) { + JSONObject ipRangeCondition = (JSONObject) conditionJsonObject.get(PolicyConstants.IP_RANGE_TYPE + .toLowerCase()); + ThrottleCondition.IPCondition ipCondition = new Gson().fromJson(ipRangeCondition.toString(), + ThrottleCondition.IPCondition.class); + conditionDto.setIpRangeCondition(ipCondition); + } + if (conditionJsonObject.has(PolicyConstants.JWT_CLAIMS_TYPE.toLowerCase())) { + JSONObject jwtClaimConditions = (JSONObject) conditionJsonObject.get(PolicyConstants.JWT_CLAIMS_TYPE + .toLowerCase()); + ThrottleCondition.JWTClaimConditions jwtClaimCondition = new Gson().fromJson(jwtClaimConditions + .toString(), ThrottleCondition.JWTClaimConditions.class); + conditionDto.setJwtClaimConditions(jwtClaimCondition); + } + if (conditionJsonObject.has(PolicyConstants.HEADER_TYPE.toLowerCase())) { + JSONObject headerConditionJson = (JSONObject) conditionJsonObject.get(PolicyConstants.HEADER_TYPE + .toLowerCase()); + ThrottleCondition.HeaderConditions headerConditions = new Gson().fromJson(headerConditionJson + .toString(), ThrottleCondition.HeaderConditions.class); + conditionDto.setHeaderConditions(headerConditions); + } + + if (conditionJsonObject.has(PolicyConstants.QUERY_PARAMETER_TYPE.toLowerCase())) { + JSONObject queryParamConditionJson = (JSONObject) conditionJsonObject.get(PolicyConstants + .QUERY_PARAMETER_TYPE.toLowerCase()); + ThrottleCondition.QueryParamConditions queryParamCondition = new Gson().fromJson(queryParamConditionJson + .toString(), ThrottleCondition.QueryParamConditions.class); + conditionDto.setQueryParameterConditions(queryParamCondition); + } + conditionDtoList.add(conditionDto); + } + conditionDtoList.sort((o1, o2) -> { + + if (o1.getIpCondition() != null && o2.getIpCondition() == null) { + return -1; + } else if (o1.getIpCondition() == null && o2.getIpCondition() != null) { + return 1; + } else { + if (o1.getIpRangeCondition() != null && o2.getIpRangeCondition() == null) { + return -1; + } else if (o1.getIpRangeCondition() == null && o2.getIpRangeCondition() != null) { + return 1; + } else { + if (o1.getHeaderConditions() != null && o2.getHeaderConditions() == null) { + return -1; + } else if (o1.getHeaderConditions() == null && o2.getHeaderConditions() != null) { + return 1; + } else { + if (o1.getQueryParameterConditions() != null && o2.getQueryParameterConditions() == null) { + return -1; + } else if (o1.getQueryParameterConditions() == null && o2.getQueryParameterConditions() + != null) { + return 1; + } else { + if (o1.getJwtClaimConditions() != null && o2.getJwtClaimConditions() == null) { + return -1; + } else if (o1.getJwtClaimConditions() == null && o2.getJwtClaimConditions() != null) { + return 1; + } + } + } + } + } + return 0; + }); + + return conditionDtoList; + } + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/AgentHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/AgentHolder.java new file mode 100644 index 0000000000..522e3065e7 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/AgentHolder.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent; + + +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.AgentConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; + +/** + * The holder the created agent and this is singleton class. + */ +public class AgentHolder { + + private static AgentHolder instance; + private DataEndpointAgent agent; + + private AgentHolder() { + agent = new DataEndpointAgent(AgentConfiguration.getInstance()); + } + + public static synchronized AgentHolder getInstance() { + if (instance == null) { + instance = new AgentHolder(); + } + return instance; + } + + public static synchronized void shutdown() throws DataEndpointException { + if (instance != null) { + instance.agent.shutDown(); + instance = null; + } + } + + /** + * Returns the default agent,and the first element in the data.agent.config.yaml + * is taken as default data publisher type. + * + * @return DataEndpointAgent for the default endpoint name. + */ + public DataEndpointAgent getDataEndpointAgent() { + return agent; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/DataEndpointAgent.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/DataEndpointAgent.java new file mode 100644 index 0000000000..4a49316c95 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/DataEndpointAgent.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent; + +import org.apache.commons.pool.impl.GenericKeyedObjectPool; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client.AbstractClientPoolFactory; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client.AbstractSecureClientPoolFactory; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client.ClientPool; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.AgentConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.DataEndpoint; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary.BinaryClientPoolFactory; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary.BinaryDataEndpoint; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary.BinarySecureClientPoolFactory; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; + + +import java.util.ArrayList; + +/** + * One agent is created for a specific data endpoint type,and this has the resources such as transport pool, etc + * which are shared by all the data publishers created for the endpoint type. + */ + +public class DataEndpointAgent { + + private ArrayList dataPublishers = new ArrayList<>(); + + private GenericKeyedObjectPool transportPool; + + private GenericKeyedObjectPool securedTransportPool; + + private AgentConfiguration agentConfiguration; + + public DataEndpointAgent(AgentConfiguration agentConfiguration) { + this.agentConfiguration = agentConfiguration; + initialize(); + } + + private void initialize() { + AbstractClientPoolFactory clientPoolFactory = new BinaryClientPoolFactory(); + AbstractSecureClientPoolFactory secureClientPoolFactory = new BinarySecureClientPoolFactory( + agentConfiguration.getTrustStore()); + ClientPool clientPool = new ClientPool(); + this.transportPool = clientPool.getClientPool( + clientPoolFactory, + agentConfiguration.getMaxTransportPoolSize(), + agentConfiguration.getMaxIdleConnections(), + true, + agentConfiguration.getEvictionTimePeriod(), + agentConfiguration.getMinIdleTimeInPool()); + + this.securedTransportPool = clientPool.getClientPool( + secureClientPoolFactory, + agentConfiguration.getSecureMaxTransportPoolSize(), + agentConfiguration.getSecureMaxIdleConnections(), + true, + agentConfiguration.getSecureEvictionTimePeriod(), + agentConfiguration.getSecureMinIdleTimeInPool()); + } + + public void addDataPublisher(DataPublisher dataPublisher) { + dataPublishers.add(dataPublisher); + } + + public AgentConfiguration getAgentConfiguration() { + return agentConfiguration; + } + + public GenericKeyedObjectPool getTransportPool() { + return transportPool; + } + + public GenericKeyedObjectPool getSecuredTransportPool() { + return securedTransportPool; + } + + public synchronized void shutDown(DataPublisher dataPublisher) { + dataPublishers.remove(dataPublisher); + } + + public DataEndpoint getNewDataEndpoint() { + return new BinaryDataEndpoint(); + } + + public synchronized void shutDown() throws DataEndpointException { + for (DataPublisher dataPublisher : dataPublishers) { + dataPublisher.shutdown(); + } + try { + transportPool.close(); + securedTransportPool.close(); + } catch (Exception e) { + throw new DataEndpointException("Error while closing the transport pool", e); + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/DataPublisher.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/DataPublisher.java new file mode 100644 index 0000000000..bce852a144 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/DataPublisher.java @@ -0,0 +1,313 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.carbon.databridge.commons.Event; +import org.wso2.carbon.databridge.commons.exception.TransportException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.DataEndpoint; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.DataEndpointGroup; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointAuthenticationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointConfigurationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.EventQueueFullException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.DataPublisherUtil; + + + +import java.util.ArrayList; +import java.util.Map; + +/** + * API Used to communicate with Data Receivers WSO2 BAM/CEP. It can be used to send events to + * multiple DAS/CEP nodes with load balancing and failover logic. + */ +public class DataPublisher { + + private static final Logger log = LogManager.getLogger(DataPublisher.class); + + /** + * List of group of endpoints where events needs to dispatched when + * events are published using this API. + */ + private ArrayList endpointGroups = new ArrayList<>(); + + /** + * The Agent for which the data publisher belongs to. + */ + private DataEndpointAgent dataEndpointAgent; + + private static final int FAILED_EVENT_LOG_INTERVAL = 10000; + + /** + * The last failed event time kept, use to determine when to log an warning + * message, without continuously doing so. + */ + private long lastFailedEventTime; + + /** + * The current failed event count. A normal long is used here, rather + * than an AtomicLong, since this is not a critical stat. + */ + private long failedEventCount; + + /** + * Creates the DataPublisher instance for a specific user, and the it creates + * connection asynchronously to receiver endpoint. + * + * @param receiverURLSet The receiving endpoint URL Set. This can be either load balancing URL set, + * or Failover URL set. + * @param authURLSet The authenticating URL Set for the endpoints given in receiverURLSet parameter. + * This should be in the same format as receiverURL set parameter. If null is passed + * the authURLs will be offsetted by value of 100. + * @param username Authorized username at receiver. + * @param password The password of the username provided. + * @throws DataEndpointException Exception to be thrown when communicating with DataEndpoint. + * @throws DataEndpointConfigurationException Exception to be thrown When parsing the Data Endpoint + * configurations when initializing data publisher + * @throws DataEndpointAuthenticationException Exception to be thrown when connecting the Data Endpoint + * @throws TransportException Transport level exception + */ + public DataPublisher(String receiverURLSet, String authURLSet, String username, String password) + throws DataEndpointException, DataEndpointConfigurationException, + DataEndpointAuthenticationException, TransportException { + dataEndpointAgent = AgentHolder.getInstance().getDataEndpointAgent(); + if (authURLSet == null) { + authURLSet = DataPublisherUtil.getDefaultAuthURLSet(receiverURLSet); + } + processEndpoints(dataEndpointAgent, receiverURLSet, authURLSet, username, password); + dataEndpointAgent.addDataPublisher(this); + } + + /** + * This validates the input that are passed in the DataPublisher creation, + * and initiates the endpoints connection. + * + * @param dataEndpointAgent Agent of the DataPublisher. + * @param receiverURLSet The receiving endpoint URL Set. This can be either load balancing URL set, + * or Failover URL set. + * @param authURLSet The authenticating URL Set for the endpoints given in receiverURLSet parameter. + * This should be in the same format as receiverURL set parameter. If the authURLSet + * is null, then default authURLSet will be generated from the receiverURL. + * @param username Authorized username at receiver. + * @param password The password of the username provided. + * @throws DataEndpointConfigurationException Exception to be thrown When parsing the Data Endpoint + * configurations when initializing data publisher + * @throws DataEndpointException Exception to be thrown when communicating with DataEndpoint. + * @throws DataEndpointAuthenticationException Exception to be thrown when connecting the Data Endpoint + * @throws TransportException Transport level exception + */ + private void processEndpoints(DataEndpointAgent dataEndpointAgent, + String receiverURLSet, String authURLSet, String username, String password) + throws DataEndpointConfigurationException, DataEndpointException, + DataEndpointAuthenticationException, TransportException { + ArrayList receiverURLGroups = DataPublisherUtil.getEndpointGroups(receiverURLSet); + ArrayList authURLGroups = DataPublisherUtil.getEndpointGroups(authURLSet); + DataPublisherUtil.validateURLs(receiverURLGroups, authURLGroups); + + for (int i = 0; i < receiverURLGroups.size(); i++) { + Object[] receiverGroup = (Object[]) receiverURLGroups.get(i); + Object[] authGroup = (Object[]) authURLGroups.get(i); + boolean failOver = (Boolean) receiverGroup[0]; + + DataEndpointGroup endpointGroup; + if (failOver) { + endpointGroup = new DataEndpointGroup(DataEndpointGroup.HAType.FAILOVER, dataEndpointAgent); + } else { + endpointGroup = new DataEndpointGroup(DataEndpointGroup.HAType.LOADBALANCE, + dataEndpointAgent); + } + /* + * Since the first element holds the failover/LB settings + * we need to start iterating from 2nd element. + */ + for (int j = 1; j < receiverGroup.length; j++) { + DataEndpointConfiguration endpointConfiguration = + new DataEndpointConfiguration((String) receiverGroup[j], + (String) authGroup[j], username, password, dataEndpointAgent.getTransportPool(), + dataEndpointAgent.getSecuredTransportPool(), dataEndpointAgent. + getAgentConfiguration().getBatchSize(), + dataEndpointAgent.getAgentConfiguration().getCorePoolSize(), + dataEndpointAgent.getAgentConfiguration().getMaxPoolSize(), + dataEndpointAgent.getAgentConfiguration().getKeepAliveTimeInPool()); + DataEndpoint dataEndpoint = dataEndpointAgent.getNewDataEndpoint(); + dataEndpoint.initialize(endpointConfiguration); + endpointGroup.addDataEndpoint(dataEndpoint); + } + endpointGroups.add(endpointGroup); + } + } + + /** + * Publish an event based on the event properties that are passed + * for all receiver groups which has been specified in the DataPublisher. + * This is a blocking invocation until the event can be inserted in to internal + * queue for the publishing to the endpoint groups. But in case if any one or all of the receiver + * groups cannot send the event to the endpoint due to network connection failure, + * or Receiver node is unreachable or Receiver node has shutdown, and + * internal queue has become full then it will be blocked until the receiver is reachable again. + * + * @param event The Event that needs to sent for the receiver groups + */ + public void publish(Event event) { + for (DataEndpointGroup endpointGroup : endpointGroups) { + endpointGroup.publish(event); + } + } + + /** + * Publish an event based on the event properties that are passed + * for all receiver groups which has been specified in the DataPublisher. + * This is a blocking invocation until the event can be inserted in to internal + * queue for the publishing to the endpoint groups. But in case if any one or all of the receiver + * groups cannot send the event to the endpoint due to network connection failure, + * or Receiver node is unreachable or Receiver node has shutdown, and + * internal queue has become full then it will be blocked until the receiver is reachable again. + * + * @param streamId StreamId for which the event belongs to. + * @param metaDataArray Meta data element of the event. + * @param correlationDataArray Correlation data element of the event. + * @param payloadDataArray Payload data element of the event. + */ + public void publish(String streamId, Object[] metaDataArray, Object[] correlationDataArray, + Object[] payloadDataArray) { + publish(new Event(streamId, System.currentTimeMillis(), metaDataArray, + correlationDataArray, payloadDataArray)); + } + + /** + * Publish an event based on the event properties that are passed + * for all receiver groups which has been specified in the DataPublisher. + * This is a blocking invocation until the event can be inserted in to internal + * queue for the publishing to the endpoint groups. But in case if any one or all of the receiver + * groups cannot send the event to the endpoint due to network connection failure, + * or Receiver node is unreachable or Receiver node has shutdown, and + * internal queue has become full then it will be blocked until the receiver is reachable again. + * + * @param streamId StreamId for which the event belongs to. + * @param metaDataArray Meta data element of the event. + * @param correlationDataArray Correlation data element of the event. + * @param payloadDataArray Payload data element of the event. + * @param arbitraryDataMap Arbitrary data element of the event, which was not included in the stream + * definition of the event, and intermittent data. + */ + public void publish(String streamId, Object[] metaDataArray, Object[] correlationDataArray, + Object[] payloadDataArray, Map arbitraryDataMap) { + publish(new Event(streamId, System.currentTimeMillis(), metaDataArray, + correlationDataArray, payloadDataArray, arbitraryDataMap)); + } + + /** + * Publish an event based on the event properties that are passed + * for all receiver groups which has been specified in the DataPublisher. + * This is a blocking invocation until the event can be inserted in to internal + * queue for the publishing to the endpoint groups. But in case if any one or all of the receiver + * groups cannot send the event to the endpoint due to network connection failure, + * or Receiver node is unreachable or Receiver node has shutdown, and + * internal queue has become full then it will be blocked until the receiver is reachable again. + * + * @param streamId StreamId for which the event belongs to. + * @param metaDataArray Meta data element of the event. + * @param correlationDataArray Correlation data element of the event. + * @param payloadDataArray Payload data element of the event. + * @param timeStamp Timestamp of the event. + */ + public void publish(String streamId, long timeStamp, Object[] metaDataArray, + Object[] correlationDataArray, Object[] payloadDataArray) { + publish(new Event(streamId, timeStamp, metaDataArray, correlationDataArray, payloadDataArray)); + } + + /** + * Publish an event based on the event properties that are passed + * for all receiver groups which has been specified in the DataPublisher. + * This is a blocking invocation until the event can be inserted in to internal + * queue for the publishing to the endpoint groups. But in case if any one or all of the receiver + * groups cannot send the event to the endpoint due to network connection failure, + * or Receiver node is unreachable or Receiver node has shutdown, and + * internal queue has become full then it will be blocked until the receiver is reachable again. + * + * @param streamId StreamId for which the event belongs to. + * @param metaDataArray Meta data element of the event. + * @param correlationDataArray Correlation data element of the event. + * @param payloadDataArray Payload data element of the event. + * @param timeStamp Timestamp of the event. + * @param arbitraryDataMap Arbitrary data element of the event, which was not included in the stream + * definition of the event, and intermittent data. + */ + public void publish(String streamId, long timeStamp, Object[] metaDataArray, + Object[] correlationDataArray, Object[] payloadDataArray, + Map arbitraryDataMap) { + publish(new Event(streamId, timeStamp, metaDataArray, correlationDataArray, + payloadDataArray, arbitraryDataMap)); + } + + private void onEventQueueFull(DataEndpointGroup endpointGroup, Event event) { + this.failedEventCount++; + long currentTime = System.currentTimeMillis(); + if (currentTime - this.lastFailedEventTime > FAILED_EVENT_LOG_INTERVAL) { + log.warn("Event queue is full, unable to process the event for endpoint group " + + endpointGroup.toString() + ", " + this.failedEventCount + " events dropped so far."); + this.lastFailedEventTime = currentTime; + } + if (log.isDebugEnabled()) { + log.debug("Dropped Event: " + event.toString() + " for the endpoint group " + + endpointGroup.toString()); + } + } + + /** + * Publish an event based on the event properties that are passed + * for all receiver groups which has been specified in the DataPublisher. + * This is a non-blocking invocation and if the queue if full + * then it will simply drop the event. + * + * @param event The event which needs to be published to the receiver groups + * @return the success/failure of the event that has been published/dropped. + */ + public boolean tryPublish(Event event) { + boolean sent = true; + for (DataEndpointGroup endpointGroup : endpointGroups) { + try { + endpointGroup.tryPublish(event); + sent = true; + } catch (EventQueueFullException e) { + this.onEventQueueFull(endpointGroup, event); + sent = false; + } + } + return sent; + } + + /** + * Graceful shutdown of all the operations of the data publisher. + * It will flush all the events to the relevant endpoint, and closes all the + * resources and thread pools used for its operation. Once the shutdown operation + * is called you can't publish events using the data publisher. + * + * @throws DataEndpointException Exception to be thrown when communicating with DataEndpoint. + */ + public void shutdown() throws DataEndpointException { + for (DataEndpointGroup dataEndpointGroup : endpointGroups) { + dataEndpointGroup.shutdown(); + } + dataEndpointAgent.shutDown(this); + } + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/AbstractClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/AbstractClientPoolFactory.java new file mode 100644 index 0000000000..74b86ef3ef --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/AbstractClientPoolFactory.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client; + +import org.apache.commons.pool.BaseKeyedPoolableObjectFactory; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointConfigurationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.DataPublisherUtil; + +/** + * The abstract class that needs to be implemented when supporting a new non-secure transport + * to mainly create, validate and terminate the client to the endpoint. + */ +public abstract class AbstractClientPoolFactory extends BaseKeyedPoolableObjectFactory { + + @Override + public Object makeObject(Object key) + throws DataEndpointException, DataEndpointConfigurationException { + Object[] urlParams = DataPublisherUtil.getProtocolHostPort(key.toString()); + return createClient(urlParams[0].toString(), urlParams[1].toString(), + Integer.parseInt(urlParams[2].toString())); + } + + /** + * Make a connection to the receiver and return the client. + * + * @param protocol protocol that is used to connect to the endpoint + * @param hostName hostname of the endpoint + * @param port port of the endpoint that is listening to + * @return A valid client which has connected to the receiver and can be used + * for rest of the operations regarding the endpoint. + * @throws DataEndpointException Exception to be thrown when communicating with DataEndpoint. + */ + public abstract Object createClient(String protocol, String hostName, int port) + throws DataEndpointException; + + @Override + public boolean validateObject(Object key, Object obj) { + return validateClient(obj); + } + + /** + * Check the validity of the client whether it's in the position to make the + * communication with endpoint. + * + * @param client Client object which needs to be validated. + * @return Returns true/false based on the client is valid or invalid. + */ + public abstract boolean validateClient(Object client); + + public void destroyObject(Object key, Object obj) { + terminateClient(obj); + } + + /** + * Terminates the connection between the client and the endpoint. + * + * @param client The client which needs to be terminated. + */ + public abstract void terminateClient(Object client); + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/AbstractSecureClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/AbstractSecureClientPoolFactory.java new file mode 100644 index 0000000000..7ef56a8a11 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/AbstractSecureClientPoolFactory.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client; + +import java.security.KeyStore; + +/** + * This abstract class needs to be implemented to handling secure communication with the endpoint. + */ +public abstract class AbstractSecureClientPoolFactory extends AbstractClientPoolFactory { + + private KeyStore trustStore; + + public AbstractSecureClientPoolFactory(KeyStore trustStore) { + this.trustStore = trustStore; + } + + public KeyStore getTrustStore() { + return trustStore; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/ClientPool.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/ClientPool.java new file mode 100644 index 0000000000..3efedcf65b --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/ClientPool.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client; + +import org.apache.commons.pool.impl.GenericKeyedObjectPool; + +/** + * This class is used hold the secure/non-secure connections for an Agent. + */ +public class ClientPool { + private GenericKeyedObjectPool socketPool; + private GenericKeyedObjectPool secureSocketPool; + + public GenericKeyedObjectPool getClientPool(AbstractClientPoolFactory factory, + int maxActive, + int maxIdle, + boolean testOnBorrow, + long timeBetweenEvictionRunsMillis, + long minEvictableIdleTimeMillis) { + if (socketPool == null) { + synchronized (this) { + if (socketPool == null) { + socketPool = new GenericKeyedObjectPool(); + socketPool.setFactory(factory); + socketPool.setMaxActive(maxActive); + socketPool.setTestOnBorrow(testOnBorrow); + socketPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); + socketPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); + socketPool.setMaxIdle(maxIdle); + socketPool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW); + } + } + } + return socketPool; + } + + public GenericKeyedObjectPool getClientPool(AbstractSecureClientPoolFactory factory, + int maxActive, + int maxIdle, + boolean testOnBorrow, + long timeBetweenEvictionRunsMillis, + long minEvictableIdleTimeMillis) { + if (secureSocketPool == null) { + synchronized (this) { + if (secureSocketPool == null) { + secureSocketPool = new GenericKeyedObjectPool(); + secureSocketPool.setFactory(factory); + secureSocketPool.setMaxActive(maxActive); + secureSocketPool.setTestOnBorrow(testOnBorrow); + secureSocketPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); + secureSocketPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); + secureSocketPool.setMaxIdle(maxIdle); + secureSocketPool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK); + } + } + } + return secureSocketPool; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/conf/AgentConfiguration.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/conf/AgentConfiguration.java new file mode 100644 index 0000000000..b2736cdf10 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/conf/AgentConfiguration.java @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf; + +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.DataEndpointConstants; + +import java.security.KeyStore; + +/** + * Agent configurations for throttle publisher. + */ +public class AgentConfiguration { + + private final String publishingStrategy = DataEndpointConstants.ASYNC_STRATEGY; + private KeyStore trustStore; + private int queueSize; + private int batchSize; + private int corePoolSize; + private int socketTimeoutMS; + private int maxPoolSize; + private int keepAliveTimeInPool; + private int reconnectionInterval; + private int maxTransportPoolSize; + private int maxIdleConnections; + private int evictionTimePeriod; + private int minIdleTimeInPool; + private int secureMaxTransportPoolSize; + private int secureMaxIdleConnections; + private int secureEvictionTimePeriod; + private int secureMinIdleTimeInPool; + private String sslEnabledProtocols; + private String ciphers; + + private static AgentConfiguration instance = new AgentConfiguration(); + + private AgentConfiguration() { + } + + public int getQueueSize() { + return queueSize; + } + + public void setQueueSize(int queueSize) { + this.queueSize = queueSize; + } + + public int getBatchSize() { + return batchSize; + } + + public void setBatchSize(int batchSize) { + this.batchSize = batchSize; + } + + public int getCorePoolSize() { + return corePoolSize; + } + + public void setCorePoolSize(int corePoolSize) { + this.corePoolSize = corePoolSize; + } + + public int getSocketTimeoutMS() { + return socketTimeoutMS; + } + + public void setSocketTimeoutMS(int socketTimeoutMS) { + this.socketTimeoutMS = socketTimeoutMS; + } + + public int getMaxPoolSize() { + return maxPoolSize; + } + + public void setMaxPoolSize(int maxPoolSize) { + this.maxPoolSize = maxPoolSize; + } + + public int getKeepAliveTimeInPool() { + return keepAliveTimeInPool; + } + + public void setKeepAliveTimeInPool(int keepAliveTimeInPool) { + this.keepAliveTimeInPool = keepAliveTimeInPool; + } + + public int getReconnectionInterval() { + return reconnectionInterval; + } + + public void setReconnectionInterval(int reconnectionInterval) { + this.reconnectionInterval = reconnectionInterval; + } + + public int getMaxTransportPoolSize() { + return maxTransportPoolSize; + } + + public void setMaxTransportPoolSize(int maxTransportPoolSize) { + this.maxTransportPoolSize = maxTransportPoolSize; + } + + public int getMaxIdleConnections() { + return maxIdleConnections; + } + + public void setMaxIdleConnections(int maxIdleConnections) { + this.maxIdleConnections = maxIdleConnections; + } + + public int getEvictionTimePeriod() { + return evictionTimePeriod; + } + + public void setEvictionTimePeriod(int evictionTimePeriod) { + this.evictionTimePeriod = evictionTimePeriod; + } + + public int getMinIdleTimeInPool() { + return minIdleTimeInPool; + } + + public void setMinIdleTimeInPool(int minIdleTimeInPool) { + this.minIdleTimeInPool = minIdleTimeInPool; + } + + public int getSecureMaxTransportPoolSize() { + return secureMaxTransportPoolSize; + } + + public void setSecureMaxTransportPoolSize(int secureMaxTransportPoolSize) { + this.secureMaxTransportPoolSize = secureMaxTransportPoolSize; + } + + public int getSecureMaxIdleConnections() { + return secureMaxIdleConnections; + } + + public void setSecureMaxIdleConnections(int secureMaxIdleConnections) { + this.secureMaxIdleConnections = secureMaxIdleConnections; + } + + public int getSecureEvictionTimePeriod() { + return secureEvictionTimePeriod; + } + + public void setSecureEvictionTimePeriod(int secureEvictionTimePeriod) { + this.secureEvictionTimePeriod = secureEvictionTimePeriod; + } + + public int getSecureMinIdleTimeInPool() { + return secureMinIdleTimeInPool; + } + + public void setSecureMinIdleTimeInPool(int secureMinIdleTimeInPool) { + this.secureMinIdleTimeInPool = secureMinIdleTimeInPool; + } + + public KeyStore getTrustStore() { + return trustStore; + } + + public void setTrustStore(KeyStore trustStore) { + this.trustStore = trustStore; + } + + public String getSslEnabledProtocols() { + return sslEnabledProtocols; + } + + public void setSslEnabledProtocols(String sslEnabledProtocols) { + this.sslEnabledProtocols = sslEnabledProtocols; + } + + public String getCiphers() { + return ciphers; + } + + public void setCiphers(String ciphers) { + this.ciphers = ciphers; + } + + public String getPublishingStrategy() { + return publishingStrategy; + } + + @Override + public String toString() { + return ", PublishingStrategy : " + publishingStrategy + + "QueueSize" + queueSize + + "BatchSize" + batchSize + + "CorePoolSize" + corePoolSize + + "SocketTimeoutMS" + socketTimeoutMS + + "MaxPoolSize" + maxPoolSize + + "KeepAliveTimeInPool" + keepAliveTimeInPool + + "ReconnectionInterval" + reconnectionInterval + + "MaxTransportPoolSize" + maxTransportPoolSize + + "MaxIdleConnections" + maxIdleConnections + + "EvictionTimePeriod" + evictionTimePeriod + + "MinIdleTimeInPool" + minIdleTimeInPool + + "SecureMaxTransportPoolSize" + secureMaxTransportPoolSize + + "SecureMaxIdleConnections" + secureMaxIdleConnections + + "SecureEvictionTimePeriod" + secureEvictionTimePeriod + + "SecureMinIdleTimeInPool" + secureMinIdleTimeInPool + + "SSLEnabledProtocols" + sslEnabledProtocols + + "Ciphers" + ciphers; + } + + public static AgentConfiguration getInstance() { + return instance; + } + + public static synchronized void setInstance(AgentConfiguration agentConfiguration) { + instance = agentConfiguration; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/conf/DataEndpointConfiguration.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/conf/DataEndpointConfiguration.java new file mode 100644 index 0000000000..4d49981f9b --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/conf/DataEndpointConfiguration.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf; + +import org.apache.commons.pool.impl.GenericKeyedObjectPool; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.DataEndpointConstants; + + +/** + * Data Endpoint Configuration. + */ +public class DataEndpointConfiguration { + + private final String receiverURL; + private final String authURL; + private final String username; + private final char[] password; + + private final GenericKeyedObjectPool transportPool; + private final GenericKeyedObjectPool securedTransportPool; + private final int batchSize; + private final String publisherKey; + private final String authKey; + private String sessionId; + private final int corePoolSize; + private final int maxPoolSize; + private final int keepAliveTimeInPool; + + /** + * Protocol Type. + */ + public enum Protocol { + TCP, SSL; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + public DataEndpointConfiguration(String receiverURL, String authURL, String username, String password, + GenericKeyedObjectPool transportPool, + GenericKeyedObjectPool securedTransportPool, + int batchSize, int corePoolSize, int maxPoolSize, int keepAliveTimeInPool) { + this.receiverURL = receiverURL; + this.authURL = authURL; + this.username = username; + this.password = password.toCharArray(); + this.transportPool = transportPool; + this.securedTransportPool = securedTransportPool; + this.publisherKey = this.receiverURL + DataEndpointConstants.SEPARATOR + username; + this.authKey = this.authURL + DataEndpointConstants.SEPARATOR + username; + this.batchSize = batchSize; + this.corePoolSize = corePoolSize; + this.maxPoolSize = maxPoolSize; + this.keepAliveTimeInPool = keepAliveTimeInPool; + } + + public String getReceiverURL() { + return receiverURL; + } + + public String getUsername() { + return username; + } + + public String getAuthURL() { + return authURL; + } + + public String getPassword() { + return String.valueOf(password); + } + + public String toString() { + return "ReceiverURL: " + receiverURL + "," + + "Authentication URL: " + authURL + "," + + "Username: " + username; + } + + public String getPublisherKey() { + return publisherKey; + } + + public String getAuthKey() { + return authKey; + } + + public String getSessionId() { + return sessionId; + } + + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + public GenericKeyedObjectPool getTransportPool() { + return transportPool; + } + + public GenericKeyedObjectPool getSecuredTransportPool() { + return securedTransportPool; + } + + public int getCorePoolSize() { + return corePoolSize; + } + + public int getMaxPoolSize() { + return maxPoolSize; + } + + public int getKeepAliveTimeInPool() { + return keepAliveTimeInPool; + } + + public int getBatchSize() { + return batchSize; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpoint.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpoint.java new file mode 100644 index 0000000000..00f061b214 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpoint.java @@ -0,0 +1,388 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint; + +import org.apache.commons.pool.impl.GenericKeyedObjectPool; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.carbon.databridge.commons.Event; +import org.wso2.carbon.databridge.commons.exception.SessionTimeoutException; +import org.wso2.carbon.databridge.commons.exception.TransportException; +import org.wso2.carbon.databridge.commons.exception.UndefinedEventTypeException; +import org.wso2.carbon.databridge.commons.utils.DataBridgeThreadFactory; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointAuthenticationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.DataEndpointConstants; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; + +/** + * Abstract class for DataEndpoint, and this is a main class that needs to be implemented + * for supporting different transports to DataPublisher. This abstraction provides the additional + * functionality to handle failover, asynchronous connection to the endpoint, etc. + */ + +public abstract class DataEndpoint { + + private static final Logger log = LogManager.getLogger(DataEndpoint.class); + + private DataEndpointConnectionWorker connectionWorker; + + private GenericKeyedObjectPool transportPool; + + private int batchSize; + + private EventPublisherThreadPoolExecutor threadPoolExecutor; + + private DataEndpointFailureCallback dataEndpointFailureCallback; + + private ExecutorService connectionService; + + private int maxPoolSize; + + private List events; + + private State state; + + private Semaphore immediateDispatchSemaphore; + + /** + * Endpoint state. + */ + public enum State { + ACTIVE, UNAVAILABLE, BUSY, INITIALIZING + } + + public DataEndpoint() { + this.batchSize = DataEndpointConstants.DEFAULT_DATA_AGENT_BATCH_SIZE; + this.state = State.INITIALIZING; + events = new ArrayList<>(); + } + + void collectAndSend(Event event) { + events.add(event); + if (events.size() >= batchSize) { + threadPoolExecutor.submitJobAndSetState(new EventPublisher(events), this); + events = new ArrayList<>(); + } + } + + void flushEvents() { + if (events.size() != 0) { + threadPoolExecutor.submitJobAndSetState(new EventPublisher(events), this); + events = new ArrayList<>(); + } + } + + void syncSend(Event event) { + List events = new ArrayList<>(1); + events.add(event); + EventPublisher eventPublisher = new EventPublisher(events); + setStateBusy(); + acquireImmediateDispatchSemaphore(); + try { + eventPublisher.run(); + } finally { + releaseImmediateDispatchSemaphore(); + } + } + + private void acquireImmediateDispatchSemaphore() { + boolean acquired = false; + do { + try { + immediateDispatchSemaphore.acquire(); + acquired = true; + } catch (final InterruptedException e) { + // Do nothing + } + } while (!acquired); + } + + private void releaseImmediateDispatchSemaphore() { + immediateDispatchSemaphore.release(); + } + + private void setStateBusy() { + int permits = immediateDispatchSemaphore.availablePermits(); + if (permits <= 1) { + setState(State.BUSY); + } + } + + void setState(State state) { + if (!this.state.equals(state)) { + this.state = state; + } + } + + void connect() + throws TransportException, + DataEndpointAuthenticationException, DataEndpointException { + if (connectionWorker != null) { + connectionService.submit(connectionWorker); + } else { + throw new DataEndpointException("Data Endpoint is not initialized"); + } + } + + synchronized void syncConnect(String oldSessionId) throws DataEndpointException { + if (oldSessionId == null || oldSessionId.equalsIgnoreCase(getDataEndpointConfiguration().getSessionId())) { + if (connectionWorker != null) { + connectionWorker.run(); + } else { + throw new DataEndpointException("Data Endpoint is not initialized"); + } + } + } + + public void initialize(DataEndpointConfiguration dataEndpointConfiguration) + throws DataEndpointException, DataEndpointAuthenticationException, + TransportException { + this.transportPool = dataEndpointConfiguration.getTransportPool(); + this.batchSize = dataEndpointConfiguration.getBatchSize(); + this.connectionWorker = new DataEndpointConnectionWorker(); + this.connectionWorker.initialize(this, dataEndpointConfiguration); + this.threadPoolExecutor = new EventPublisherThreadPoolExecutor(dataEndpointConfiguration.getCorePoolSize(), + dataEndpointConfiguration.getMaxPoolSize(), dataEndpointConfiguration.getKeepAliveTimeInPool(), + dataEndpointConfiguration.getReceiverURL()); + this.connectionService = Executors.newSingleThreadExecutor(new DataBridgeThreadFactory( + "ConnectionService-" + + dataEndpointConfiguration.getReceiverURL())); + this.maxPoolSize = dataEndpointConfiguration.getMaxPoolSize(); + this.immediateDispatchSemaphore = new Semaphore(maxPoolSize); + connect(); + } + + /** + * Login to the endpoint and return the sessionId. + * + * @param client The client which can be used to connect to the endpoint. + * @param userName The username which is used to login, + * @param password The password which is required for the login operation. + * @return returns the sessionId + * @throws DataEndpointAuthenticationException + */ + protected abstract String login(Object client, String userName, String password) + throws DataEndpointAuthenticationException; + + /** + * Logout from the endpoint. + * + * @param client The client that is used to logout operation. + * @param sessionId The current session Id. + * @throws DataEndpointAuthenticationException + */ + protected abstract void logout(Object client, String sessionId) + throws DataEndpointAuthenticationException; + + + public State getState() { + return state; + } + + void activate() { + this.setState(State.ACTIVE); + } + + void deactivate() { + this.setState(State.UNAVAILABLE); + } + + /** + * Send the list of events to the actual endpoint. + * + * @param client The client that can be used to send the events. + * @param events List of events that needs to be sent. + * @throws DataEndpointException + * @throws SessionTimeoutException + * @throws UndefinedEventTypeException + */ + protected abstract void send(Object client, List events) throws + DataEndpointException, SessionTimeoutException, UndefinedEventTypeException; + + protected DataEndpointConfiguration getDataEndpointConfiguration() { + if (connectionWorker == null) { + return null; + } + return this.connectionWorker.getDataEndpointConfiguration(); + } + + private Object getClient() throws DataEndpointException { + try { + return transportPool.borrowObject(getDataEndpointConfiguration().getPublisherKey()); + } catch (Exception e) { + throw new DataEndpointException("Cannot borrow client for " + + getDataEndpointConfiguration().getPublisherKey(), e); + } + } + + private void returnClient(Object client) { + try { + transportPool.returnObject(getDataEndpointConfiguration().getPublisherKey(), client); + } catch (Exception e) { + log.warn("Error occurred while returning object to connection pool", e); + discardClient(client); + } + } + + private void discardClient(Object client) { + if (client != null) { + try { + transportPool.invalidateObject(getDataEndpointConfiguration().getPublisherKey(), client); + } catch (Exception e) { + log.error("Error while invalidating the client ", e); + } + } + } + + void registerDataEndpointFailureCallback(DataEndpointFailureCallback callback) { + dataEndpointFailureCallback = callback; + } + + /** + * Event Publisher worker thread to actually sends the events to the endpoint. + */ + class EventPublisher implements Runnable { + List events; + private Semaphore semaphore; + + public EventPublisher(List events) { + this.events = events; + } + + @Override + public void run() { + String sessionId = getDataEndpointConfiguration().getSessionId(); + try { + publish(); + } catch (SessionTimeoutException e) { + try { + if (sessionId == null || sessionId.equalsIgnoreCase(getDataEndpointConfiguration(). + getSessionId())) { + syncConnect(sessionId); + } + publish(); + } catch (UndefinedEventTypeException ex) { + log.error("Unable to process this event.", ex); + semaphoreRelease(); + } catch (Exception ex) { + log.error("Unexpected error occurred while sending the event. ", ex); + handleFailedEvents(this.events); + } + } catch (DataEndpointException e) { + log.error("Unable to send events to the endpoint. ", e); + handleFailedEvents(this.events); + } catch (UndefinedEventTypeException e) { + log.error("Unable to process this event.", e); + semaphoreRelease(); + } catch (Exception ex) { + log.error("Unexpected error occurred while sending the event. ", ex); + handleFailedEvents(this.events); + } catch (Throwable t) { + //There can be situations where runtime exceptions/class not found exceptions occur, + // This block help to catch those exceptions. + //No need to retry send events. Deactivating the state would be enough. + log.error("Unexpected error occurred while sending events. ", t); + semaphoreRelease(); + deactivate(); + } finally { + //If any processing error occurred the state will be changed to unavailable, + // Hence the state switch should be happening only in busy state where the publishing was success. + if (state.equals(State.BUSY)) { + activate(); + } + if (log.isDebugEnabled()) { + log.debug("Current threads count is : " + threadPoolExecutor.getActiveCount() + + ", maxPoolSize is : " + + maxPoolSize + ", therefore state is now : " + getState() + " at time : " + + System.nanoTime()); + } + } + } + + public void setPoolSemaphore(Semaphore semaphore) { + this.semaphore = semaphore; + } + + private void publish() throws DataEndpointException, SessionTimeoutException, UndefinedEventTypeException { + Object client = getClient(); + try { + send(client, this.events); + semaphoreRelease(); + } finally { + returnClient(client); + } + } + + private void semaphoreRelease() { + if (this.semaphore != null) { + this.semaphore.release(); + } + } + } + + private void handleFailedEvents(List events) { + deactivate(); + dataEndpointFailureCallback.tryResendEvents(events, this); + } + + boolean isConnected() { + return !state.equals(State.UNAVAILABLE); + } + + public String toString() { + if (getDataEndpointConfiguration() == null) { + return "null"; + } + return "( Receiver URL : " + getDataEndpointConfiguration().getReceiverURL() + ", Authentication URL : " + + getDataEndpointConfiguration().getAuthURL() + ")"; + } + + /** + * Graceful shutdown until publish all the events given to the endpoint. + */ + public void shutdown() { + log.info("Shutdown triggered for data publisher endpoint URL - " + + getDataEndpointConfiguration().getReceiverURL()); + while (threadPoolExecutor.getActiveCount() != 0) { + try { + Thread.sleep(100); + } catch (InterruptedException ignored) { + } + } + connectionWorker.disconnect(getDataEndpointConfiguration()); + connectionService.shutdownNow(); + threadPoolExecutor.shutdownNow(); + try { + connectionService.awaitTermination(10, TimeUnit.SECONDS); + threadPoolExecutor.awaitTermination(10, TimeUnit.SECONDS); + } catch (InterruptedException e) { + + } + log.info("Completed shutdown for data publisher endpoint URL - " + + getDataEndpointConfiguration().getReceiverURL()); + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointConnectionWorker.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointConnectionWorker.java new file mode 100644 index 0000000000..9650da0176 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointConnectionWorker.java @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointAuthenticationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; + +/** + * DataEndpoint Connection worker class implementation. + */ +public class DataEndpointConnectionWorker implements Runnable { + + private static final Logger log = LogManager.getLogger(DataEndpointConnectionWorker.class); + + private DataEndpointConfiguration dataEndpointConfiguration; + + private DataEndpoint dataEndpoint; + + @Override + public void run() { + if (isInitialized()) { + try { + connect(); + dataEndpoint.activate(); + } catch (DataEndpointAuthenticationException e) { + log.error("Error while trying to connect to the endpoint. " + e.getErrorMessage(), e); + dataEndpoint.deactivate(); + } + } else { + String errorMsg = "Data endpoint connection worker is not properly initialized "; + if (dataEndpoint == null) { + errorMsg += ", data Endpoint is not provided "; + } + if (dataEndpointConfiguration == null) { + errorMsg += ", data Endpoint configuration is not provided"; + } + errorMsg += "."; + log.error(errorMsg); + } + } + + DataEndpointConfiguration getDataEndpointConfiguration() { + return dataEndpointConfiguration; + } + + /** + * Initialize the data endpoint connection worker. + * A connection worker can be instantiated only ONE time. + * + * @param dataEndpoint DataEndpoint instance to handle the connection. + * @param dataEndpointConfiguration DataEndpointConfiguration to handle the connection. + * @throws DataEndpointException if data endpoint configuration is already set or the data endpoint is + * already configured with connection worker + */ + public void initialize(DataEndpoint dataEndpoint, DataEndpointConfiguration dataEndpointConfiguration) + throws DataEndpointException { + if (this.dataEndpointConfiguration == null) { + this.dataEndpointConfiguration = dataEndpointConfiguration; + } else { + throw new DataEndpointException("Already data endpoint configuration is set: " + + this.dataEndpointConfiguration.toString() + " for the endpoint " + + dataEndpointConfiguration.toString()); + } + + if (this.dataEndpoint == null) { + this.dataEndpoint = dataEndpoint; + } else { + throw new DataEndpointException("Already data endpoint is configured for the connection worker"); + } + } + + private void connect() throws DataEndpointAuthenticationException { + Object client = null; + try { + client = this.dataEndpointConfiguration.getSecuredTransportPool(). + borrowObject(dataEndpointConfiguration.getAuthKey()); + String sessionId = this.dataEndpoint. + login(client, dataEndpointConfiguration.getUsername(), + dataEndpointConfiguration.getPassword()); + dataEndpointConfiguration.setSessionId(sessionId); + } catch (Throwable e) { + log.error(e.getMessage(), e); + throw new DataEndpointAuthenticationException("Cannot borrow client for " + + dataEndpointConfiguration.getAuthURL(), e); + } finally { + try { + this.dataEndpointConfiguration.getSecuredTransportPool(). + returnObject(dataEndpointConfiguration.getAuthKey(), client); + } catch (Exception e) { + this.dataEndpointConfiguration.getSecuredTransportPool(). + clear(dataEndpointConfiguration.getAuthKey()); + } + } + + } + + public void disconnect(DataEndpointConfiguration dataPublisherConfiguration) { + Object client = null; + try { + client = this.dataEndpointConfiguration.getSecuredTransportPool(). + borrowObject(dataPublisherConfiguration.getAuthKey()); + this.dataEndpoint.logout(client, dataPublisherConfiguration.getSessionId()); + } catch (Exception e) { + if (log.isDebugEnabled()) { + log.debug("Cannot connect to the server at " + dataPublisherConfiguration.getAuthURL() + + ", for user: " + dataPublisherConfiguration.getUsername(), e); + } + log.warn("Cannot connect to the server at " + dataPublisherConfiguration.getAuthURL() + + ", for user: " + dataPublisherConfiguration.getUsername()); + } finally { + try { + this.dataEndpointConfiguration.getSecuredTransportPool().returnObject( + dataPublisherConfiguration.getAuthKey(), client); + } catch (Exception e) { + this.dataEndpointConfiguration.getSecuredTransportPool().clear( + dataPublisherConfiguration.getAuthKey()); + } + } + } + + private boolean isInitialized() { + return dataEndpoint != null && dataEndpointConfiguration != null; + } + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointFailureCallback.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointFailureCallback.java new file mode 100644 index 0000000000..e2333d835b --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointFailureCallback.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint; + +import org.wso2.carbon.databridge.commons.Event; + +import java.util.List; + +/** + * This interface is used to implement a call back for get the notifications upon the unsuccessful event publishing. + */ +public interface DataEndpointFailureCallback { + + /** + * Notifies the The failed events, and should try to send the events again successfully. + * In case if this couldn't send the events, then the unsuccessful events list needs to be returned back. + * + * @param events List failed events + */ + public void tryResendEvents(List events, DataEndpoint failedEP); + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointGroup.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointGroup.java new file mode 100644 index 0000000000..34bd96b768 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointGroup.java @@ -0,0 +1,449 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint; + +import com.lmax.disruptor.BlockingWaitStrategy; +import com.lmax.disruptor.EventHandler; +import com.lmax.disruptor.InsufficientCapacityException; +import com.lmax.disruptor.RingBuffer; +import com.lmax.disruptor.dsl.Disruptor; +import com.lmax.disruptor.dsl.ProducerType; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.carbon.databridge.commons.Event; +import org.wso2.carbon.databridge.commons.utils.DataBridgeThreadFactory; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.DataEndpointAgent; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointConfigurationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.EventQueueFullException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.DataEndpointConstants; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.DataPublisherUtil; + +import java.io.IOException; +import java.net.Socket; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * This class holds the endpoints associated within a group. Also it has a queue + * to hold the list of events that needs to be processed by the endpoints with + * provided the load balancing, or failover configuration. + */ +public class DataEndpointGroup implements DataEndpointFailureCallback { + private static final Logger log = LogManager.getLogger(DataEndpointGroup.class); + + private List dataEndpoints; + + private HAType haType; + + private EventQueue eventQueue = null; + + private int reconnectionInterval; + + private final Integer startIndex = 0; + + private AtomicInteger currentDataPublisherIndex = new AtomicInteger(startIndex); + + private AtomicInteger maximumDataPublisherIndex = new AtomicInteger(); + + private ScheduledExecutorService reconnectionService; + + private final String publishingStrategy; + + private boolean isShutdown = false; + + /** + * HA Type. + */ + public enum HAType { + FAILOVER, LOADBALANCE + } + + public DataEndpointGroup(HAType haType, DataEndpointAgent agent) { + this.dataEndpoints = new ArrayList<>(); + this.haType = haType; + this.reconnectionService = Executors.newScheduledThreadPool(1, + new DataBridgeThreadFactory("ReconnectionService")); + this.reconnectionInterval = agent.getAgentConfiguration().getReconnectionInterval(); + this.publishingStrategy = agent.getAgentConfiguration().getPublishingStrategy(); + if (!publishingStrategy.equalsIgnoreCase(DataEndpointConstants.SYNC_STRATEGY)) { + this.eventQueue = new EventQueue(agent.getAgentConfiguration().getQueueSize()); + } + this.reconnectionService.scheduleAtFixedRate(new ReconnectionTask(), reconnectionInterval, + reconnectionInterval, TimeUnit.SECONDS); + currentDataPublisherIndex.set(startIndex); + } + + public void addDataEndpoint(DataEndpoint dataEndpoint) { + dataEndpoints.add(dataEndpoint); + dataEndpoint.registerDataEndpointFailureCallback(this); + maximumDataPublisherIndex.incrementAndGet(); + } + + public void tryPublish(Event event) throws EventQueueFullException { + if (eventQueue != null) { + eventQueue.tryPut(event); + } else if (!isShutdown) { + trySyncPublish(event); + } + } + + public void publish(Event event) { + if (eventQueue != null) { + eventQueue.put(event); + } else if (!isShutdown) { + syncPublish(event); + } + } + + private void trySyncPublish(Event event) { + try { + DataEndpoint endpoint = getDataEndpoint(false); + if (endpoint != null) { + endpoint.syncSend(event); + } else { + if (log.isDebugEnabled()) { + log.debug("DataEndpoint not available, dropping event : " + event); + } + } + } catch (Throwable t) { + log.error("Unexpected error: " + t.getMessage(), t); + } + } + + private void syncPublish(Event event) { + try { + DataEndpoint endpoint = getDataEndpoint(true); + if (endpoint != null) { + endpoint.syncSend(event); + } else { + log.error("Dropping event as DataPublisher is shutting down."); + if (log.isDebugEnabled()) { + log.debug("Data publisher is shutting down, dropping event : " + event); + } + } + } catch (Throwable t) { + log.error("Unexpected error: " + t.getMessage(), t); + } + } + + /** + * Event Queue Class. + */ + class EventQueue { + private RingBuffer ringBuffer = null; + private Disruptor eventQueueDisruptor = null; + private ExecutorService eventQueuePool = null; + + EventQueue(int queueSize) { + eventQueuePool = Executors.newCachedThreadPool( + new DataBridgeThreadFactory("EventQueue")); + eventQueueDisruptor = new Disruptor<>(new WrappedEventFactory(), queueSize, eventQueuePool, + ProducerType.MULTI, new BlockingWaitStrategy()); + eventQueueDisruptor.handleEventsWith(new EventQueueWorker()); + this.ringBuffer = eventQueueDisruptor.start(); + } + + private void tryPut(Event event) throws EventQueueFullException { + + long sequence; + try { + sequence = this.ringBuffer.tryNext(1); + WrappedEventFactory.WrappedEvent bufferedEvent = this.ringBuffer.get(sequence); + bufferedEvent.setEvent(event); + this.ringBuffer.publish(sequence); + } catch (InsufficientCapacityException e) { + throw new EventQueueFullException("Cannot send events because the event queue is full", e); + } + } + + //Endless wait if at-least once endpoint is available. + private void put(Event event) { + do { + try { + long sequence = this.ringBuffer.tryNext(1); + WrappedEventFactory.WrappedEvent bufferedEvent = this.ringBuffer.get(sequence); + bufferedEvent.setEvent(event); + this.ringBuffer.publish(sequence); + return; + } catch (InsufficientCapacityException ex) { + try { + Thread.sleep(2); + } catch (InterruptedException ignored) { + } + } + } while (isActiveDataEndpointExists()); + } + + private void shutdown() { + eventQueuePool.shutdown(); + eventQueueDisruptor.shutdown(); + } + } + + /** + * Event Queue Worker. + */ + class EventQueueWorker implements EventHandler { + + boolean isLastEventDropped = false; + + @Override + public void onEvent(WrappedEventFactory.WrappedEvent wrappedEvent, long sequence, boolean endOfBatch) { + DataEndpoint endpoint = getDataEndpoint(true); + Event event = wrappedEvent.getEvent(); + if (endpoint != null) { + isLastEventDropped = false; + endpoint.collectAndSend(event); + if (endOfBatch) { + flushAllDataEndpoints(); + } + } else { + if (!isLastEventDropped) { + log.error("Dropping all events as DataPublisher is shutting down."); + } + if (log.isDebugEnabled()) { + log.debug("Data publisher is shutting down, dropping event : " + event); + } + isLastEventDropped = true; + } + } + } + + private void flushAllDataEndpoints() { + for (DataEndpoint dataEndpoint : dataEndpoints) { + if (dataEndpoint.getState().equals(DataEndpoint.State.ACTIVE)) { + dataEndpoint.flushEvents(); + } + } + } + + private DataEndpoint getDataEndpoint(boolean isBusyWait) { + return getDataEndpoint(isBusyWait, null); + } + + /** + * Find the next event processable endpoint to the + * data endpoint based on load balancing and failover logic, and wait + * indefinitely until at least one data endpoint becomes available based + * on busywait parameter. + * + * @param isBusyWait waitUntil atleast one endpoint becomes available + * @return DataEndpoint which can accept and send the events. + */ + private DataEndpoint getDataEndpoint(boolean isBusyWait, DataEndpoint failedEP) { + int startIndex; + if (haType.equals(HAType.LOADBALANCE)) { + startIndex = getDataPublisherIndex(); + } else { + startIndex = this.startIndex; + } + int index = startIndex; + + while (true) { + DataEndpoint dataEndpoint = dataEndpoints.get(index); + if (dataEndpoint.getState().equals(DataEndpoint.State.ACTIVE) && dataEndpoint != failedEP) { + return dataEndpoint; + } else if (haType.equals(HAType.FAILOVER) && (dataEndpoint.getState().equals(DataEndpoint.State.BUSY) || + dataEndpoint.getState().equals(DataEndpoint.State.INITIALIZING))) { + /** + * Wait for some time until the failover endpoint finish publishing + * + */ + busyWait(1); + } else { + index++; + if (index > maximumDataPublisherIndex.get() - 1) { + index = this.startIndex; + } + if (index == startIndex) { + if (isBusyWait) { + if (!reconnectionService.isShutdown()) { + + /** + * Have fully iterated the data publisher list, + * and busy wait until data publisher + * becomes available + */ + busyWait(1); + } else { + if (!isActiveDataEndpointExists()) { + return null; + } else { + busyWait(1); + } + } + } else { + return null; + } + } + } + } + } + + private void busyWait(long timeInMilliSec) { + try { + Thread.sleep(timeInMilliSec); + } catch (InterruptedException ignored) { + } + } + + private boolean isActiveDataEndpointExists() { + int index = startIndex; + while (index < maximumDataPublisherIndex.get()) { + DataEndpoint dataEndpoint = dataEndpoints.get(index); + if (dataEndpoint.getState() != DataEndpoint.State.UNAVAILABLE) { + if (log.isDebugEnabled()) { + log.debug("Available endpoint : " + dataEndpoint + " existing in state - " + + dataEndpoint.getState()); + } + return true; + } + index++; + } + return false; + } + + private synchronized int getDataPublisherIndex() { + int index = currentDataPublisherIndex.getAndIncrement(); + if (index == maximumDataPublisherIndex.get() - 1) { + currentDataPublisherIndex.set(startIndex); + } + return index; + } + + public void tryResendEvents(List events, DataEndpoint dataEndpoint) { + List unsuccessfulEvents = trySendActiveEndpoints(events, dataEndpoint); + for (Event event : unsuccessfulEvents) { + try { + if (eventQueue != null) { + eventQueue.tryPut(event); + } else { + trySyncPublish(event); + } + } catch (EventQueueFullException e) { + log.error("Unable to put the event :" + event, e); + } + } + } + + private List trySendActiveEndpoints(List events, DataEndpoint failedEP) { + ArrayList unsuccessfulEvents = new ArrayList<>(); + for (Event event : events) { + DataEndpoint endpoint = getDataEndpoint(false, failedEP); + if (endpoint != null) { + endpoint.collectAndSend(event); + } else { + unsuccessfulEvents.add(event); + } + } + flushAllDataEndpoints(); + return unsuccessfulEvents; + } + + private class ReconnectionTask implements Runnable { + String failedDataEndpoints = ""; + public void run() { + boolean isOneReceiverConnected = false; + for (int i = startIndex; i < maximumDataPublisherIndex.get(); i++) { + DataEndpoint dataEndpoint = dataEndpoints.get(i); + if (!dataEndpoint.isConnected()) { + try { + dataEndpoint.connect(); + } catch (Exception ex) { + dataEndpoint.deactivate(); + } + } else { + try { + String[] urlElements = DataPublisherUtil.getProtocolHostPort( + dataEndpoint.getDataEndpointConfiguration().getReceiverURL()); + if (!isServerExists(urlElements[1], Integer.parseInt(urlElements[2]))) { + dataEndpoint.deactivate(); + } + } catch (DataEndpointConfigurationException exception) { + log.warn("Data Endpoint with receiver URL:" + + dataEndpoint.getDataEndpointConfiguration().getReceiverURL() + + " could not be deactivated", exception); + } + } + if (dataEndpoint.isConnected()) { + isOneReceiverConnected = true; + } else { + failedDataEndpoints = (dataEndpoint.getDataEndpointConfiguration() != null + ? dataEndpoint.getDataEndpointConfiguration().getReceiverURL() : "Null") + ","; + } + } + if (!isOneReceiverConnected) { + log.warn("Receiver is not reachable at reconnection for the endpoints: " + failedDataEndpoints + + ", will try to reconnect every " + reconnectionInterval + " sec"); + } + } + + private boolean isServerExists(String ip, int port) { + try { + Socket socket = new Socket(ip, port); + socket.close(); + return true; + } catch (UnknownHostException e) { + return false; + } catch (IOException e) { + return false; + } catch (Exception e) { + return false; + } + } + + } + + public String toString() { + StringBuilder group = new StringBuilder(); + group.append("[ "); + for (int i = 0; i < dataEndpoints.size(); i++) { + DataEndpoint endpoint = dataEndpoints.get(i); + group.append(endpoint.toString()); + if (i == dataEndpoints.size() - 1) { + group.append(" ]"); + return group.toString(); + } else { + if (haType == HAType.FAILOVER) { + group.append(DataEndpointConstants.FAILOVER_URL_GROUP_SEPARATOR); + } else { + group.append(DataEndpointConstants.LB_URL_GROUP_SEPARATOR); + } + } + } + return group.toString(); + } + + public void shutdown() { + reconnectionService.shutdownNow(); + if (eventQueue != null) { + eventQueue.shutdown(); + } + isShutdown = true; + for (DataEndpoint dataEndpoint : dataEndpoints) { + dataEndpoint.shutdown(); + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java new file mode 100644 index 0000000000..6b881d3635 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint; + +import org.wso2.carbon.databridge.commons.utils.DataBridgeThreadFactory; + +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.Semaphore; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +/** + * Event Publisher Threadpool Executor. + */ +public class EventPublisherThreadPoolExecutor extends ThreadPoolExecutor { + + private final Semaphore semaphore; + + public EventPublisherThreadPoolExecutor(int corePoolSize, int maxPoolSize, long keepAliveTimeInPool, + String receiverURL) { + super(corePoolSize, maxPoolSize, keepAliveTimeInPool, TimeUnit.SECONDS, new LinkedBlockingQueue(), + new DataBridgeThreadFactory(receiverURL)); + semaphore = new Semaphore(maxPoolSize); + } + + @Override + public void execute(final Runnable task) { + boolean acquired = false; + do { + try { + semaphore.acquire(); + acquired = true; + } catch (final InterruptedException e) { + // Do nothing + } + } while (!acquired); + super.execute(task); + } + + public void submitJobAndSetState(DataEndpoint.EventPublisher publisher, DataEndpoint dataEndpoint) { + int permits = semaphore.availablePermits(); + if (permits <= 1) { + dataEndpoint.setState(DataEndpoint.State.BUSY); + } + publisher.setPoolSemaphore(semaphore); + submit(new Thread(publisher)); + } + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/WrappedEventFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/WrappedEventFactory.java new file mode 100644 index 0000000000..1b86a5c7a1 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/WrappedEventFactory.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint; + +import com.lmax.disruptor.EventFactory; +import org.wso2.carbon.databridge.commons.Event; + +/** + * Wrapper Event Factory. + */ +public class WrappedEventFactory implements EventFactory { + + public WrappedEvent newInstance() { + return new WrappedEvent(); + } + + /** + * Wrapped Event. + */ + public static class WrappedEvent { + + private Event event; + + public Event getEvent() { + return event; + } + + public void setEvent(Event event) { + this.event = event; + } + + @Override + public String toString() { + return "WrappedEvent{" + + "event=" + event + + "}"; + } + } + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java new file mode 100644 index 0000000000..8c7b515aff --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.AgentHolder; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client.AbstractClientPoolFactory; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; + +import java.io.IOException; +import java.net.Socket; + +/** + * This class implements AbstractClientPoolFactory to handle the Binary transport related connections. + */ +public class BinaryClientPoolFactory extends AbstractClientPoolFactory { + private static final Logger log = LogManager.getLogger(BinaryClientPoolFactory.class); + + @Override + public Object createClient(String protocol, String hostName, int port) throws DataEndpointException { + if (protocol.equalsIgnoreCase(DataEndpointConfiguration.Protocol.TCP.toString())) { + int timeout = AgentHolder.getInstance().getDataEndpointAgent().getAgentConfiguration() + .getSocketTimeoutMS(); + try { + Socket socket = new Socket(hostName, port); + socket.setSoTimeout(timeout); + return socket; + } catch (IOException e) { + throw new DataEndpointException("Error while opening socket to " + hostName + ":" + port + ". " + + e.getMessage(), e); + } + } else { + throw new DataEndpointException("Unsupported protocol: " + protocol + ". Currently only " + + DataEndpointConfiguration.Protocol.TCP.toString() + " supported."); + } + } + + @Override + public boolean validateClient(Object client) { + return ((Socket) client).isConnected(); + } + + @Override + public void terminateClient(Object client) { + Socket socket = null; + try { + socket = (Socket) client; + socket.close(); + } catch (IOException e) { + log.warn("Cannot close the socket successfully from " + socket.getLocalAddress().getHostAddress() + + ":" + socket.getPort()); + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java new file mode 100644 index 0000000000..9002d56f48 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary; + +import org.wso2.carbon.databridge.commons.Event; +import org.wso2.carbon.databridge.commons.exception.SessionTimeoutException; +import org.wso2.carbon.databridge.commons.exception.UndefinedEventTypeException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.DataEndpoint; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointAuthenticationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; + +import java.net.Socket; +import java.util.List; + +import static org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary.BinaryEventSender.processResponse; +import static org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary.BinaryEventSender.sendBinaryLoginMessage; +import static org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary.BinaryEventSender.sendBinaryLogoutMessage; +import static org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary.BinaryEventSender.sendBinaryPublishMessage; + +/** + * This class is Binary transport implementation for the Data Endpoint. + */ +public class BinaryDataEndpoint extends DataEndpoint { + + @Override + protected String login(Object client, String userName, String password) throws DataEndpointAuthenticationException { + Socket socket = (Socket) client; + try { + sendBinaryLoginMessage(socket, userName, password); + return processResponse(socket); + } catch (Exception e) { + if (e instanceof DataEndpointAuthenticationException) { + throw (DataEndpointAuthenticationException) e; + } else { + throw new DataEndpointAuthenticationException("Error while trying to login to data receiver :" + + socket.getRemoteSocketAddress().toString(), e); + } + } + } + + @Override + protected void logout(Object client, String sessionId) throws DataEndpointAuthenticationException { + Socket socket = (Socket) client; + try { + sendBinaryLogoutMessage(socket, sessionId); + processResponse(socket); + } catch (Exception e) { + if (e instanceof DataEndpointAuthenticationException) { + throw (DataEndpointAuthenticationException) e; + } else { + throw new DataEndpointAuthenticationException("Error while trying to logout to data receiver :" + + socket.getRemoteSocketAddress().toString(), e); + } + } + } + + @Override + protected void send(Object client, List events) throws DataEndpointException, + SessionTimeoutException, UndefinedEventTypeException { + Socket socket = (Socket) client; + String sessionId = getDataEndpointConfiguration().getSessionId(); + try { + sendBinaryPublishMessage(socket, events, sessionId); + processResponse(socket); + } catch (Exception e) { + if (e instanceof DataEndpointException) { + throw (DataEndpointException) e; + } else if (e instanceof UndefinedEventTypeException) { + throw new UndefinedEventTypeException("Undefined Event Type Exception ", e); + } else if (e instanceof SessionTimeoutException) { + throw new SessionTimeoutException("Binary Session Expired Exception ", e); + } else { + throw new DataEndpointException("Error while trying to publish events to data receiver :" + + socket.getRemoteSocketAddress().toString(), e); + } + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryEventSender.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryEventSender.java new file mode 100644 index 0000000000..6f83d376e1 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryEventSender.java @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary; + +import org.wso2.carbon.databridge.commons.Event; +import org.wso2.carbon.databridge.commons.binary.BinaryMessageConstants; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import static org.wso2.carbon.databridge.commons.binary.BinaryMessageConverterUtil.assignData; +import static org.wso2.carbon.databridge.commons.binary.BinaryMessageConverterUtil.getSize; +import static org.wso2.carbon.databridge.commons.binary.BinaryMessageConverterUtil.loadData; + +/** + * This is a Util class which does the Binary message transformation for publish, login, logout operations. + */ +public class BinaryEventSender { + public static void sendBinaryLoginMessage(Socket socket, String userName, String password) throws IOException { + ByteBuffer buf = ByteBuffer.allocate(13 + userName.length() + password.length()); + buf.put((byte) 0); + buf.putInt(8 + userName.length() + password.length()); + buf.putInt(userName.length()); + buf.putInt(password.length()); + buf.put(userName.getBytes(BinaryMessageConstants.DEFAULT_CHARSET)); + buf.put(password.getBytes(BinaryMessageConstants.DEFAULT_CHARSET)); + + OutputStream outputStream = new BufferedOutputStream(socket.getOutputStream()); + outputStream.write(buf.array()); + outputStream.flush(); + } + + public static void sendBinaryLogoutMessage(Socket socket, String sessionId) throws IOException { + ByteBuffer buf = ByteBuffer.allocate(9 + sessionId.length()); + buf.put((byte) 1); + buf.putInt(4 + sessionId.length()); + buf.putInt(sessionId.length()); + buf.put(sessionId.getBytes(BinaryMessageConstants.DEFAULT_CHARSET)); + + OutputStream outputStream = new BufferedOutputStream(socket.getOutputStream()); + outputStream.write(buf.array()); + outputStream.flush(); + } + + public static void sendBinaryPublishMessage(Socket socket, List events, String sessionId) + throws IOException { + int messageSize = 8 + sessionId.length(); + List bytes = new ArrayList<>(); + + for (Event event : events) { + + int eventSize = getEventSize(event); + messageSize += eventSize + 4; + ByteBuffer eventDataBuffer = ByteBuffer.allocate(4 + eventSize); + eventDataBuffer.putInt(eventSize); + eventDataBuffer.putLong(event.getTimeStamp()); + eventDataBuffer.putInt(event.getStreamId().length()); + eventDataBuffer.put(event.getStreamId().getBytes(BinaryMessageConstants.DEFAULT_CHARSET)); + + if (event.getMetaData() != null && event.getMetaData().length != 0) { + for (Object aMetaData : event.getMetaData()) { + assignData(aMetaData, eventDataBuffer); + } + } + if (event.getCorrelationData() != null && event.getCorrelationData().length != 0) { + for (Object aCorrelationData : event.getCorrelationData()) { + assignData(aCorrelationData, eventDataBuffer); + } + } + if (event.getPayloadData() != null && event.getPayloadData().length != 0) { + for (Object aPayloadData : event.getPayloadData()) { + assignData(aPayloadData, eventDataBuffer); + } + } + if (event.getArbitraryDataMap() != null && event.getArbitraryDataMap().size() != 0) { + for (Map.Entry aArbitraryData : event.getArbitraryDataMap().entrySet()) { + assignData(aArbitraryData.getKey(), eventDataBuffer); + assignData(aArbitraryData.getValue(), eventDataBuffer); + } + } + bytes.add(eventDataBuffer.array()); + } + + ByteBuffer buf = ByteBuffer.allocate(sessionId.length() + 13); + buf.put((byte) 2); //1 + buf.putInt(messageSize); //4 + buf.putInt(sessionId.length()); //4 + buf.put(sessionId.getBytes(BinaryMessageConstants.DEFAULT_CHARSET)); + buf.putInt(events.size()); //4 + + OutputStream outputstream = new BufferedOutputStream(socket.getOutputStream()); + outputstream.write(buf.array()); + for (byte[] byteArray : bytes) { + outputstream.write(byteArray); + } + outputstream.flush(); + } + + private static int getEventSize(Event event) { + int eventSize = 4 + event.getStreamId().length() + 8; + Object[] data = event.getMetaData(); + if (data != null) { + for (Object aData : data) { + eventSize += getSize(aData); + } + } + data = event.getCorrelationData(); + if (data != null) { + for (Object aData : data) { + eventSize += getSize(aData); + } + } + data = event.getPayloadData(); + if (data != null) { + for (Object aData : data) { + eventSize += getSize(aData); + } + } + if (event.getArbitraryDataMap() != null && event.getArbitraryDataMap().size() != 0) { + for (Map.Entry aArbitraryData : event.getArbitraryDataMap().entrySet()) { + eventSize += 8 + aArbitraryData.getKey().length() + aArbitraryData.getValue().length(); + } + } + return eventSize; + } + + public static String processResponse(Socket socket) throws Exception { + + InputStream inputStream = socket.getInputStream(); + BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); + int messageType = bufferedInputStream.read(); + ByteBuffer bbuf; + switch (messageType) { + case 0: + //OK message + break; + case 1: + //Error Message + bbuf = ByteBuffer.wrap(loadData(bufferedInputStream, new byte[8])); + int errorClassNameLength = bbuf.getInt(); + int errorMsgLength = bbuf.getInt(); + + String className = new String(ByteBuffer.wrap(loadData(bufferedInputStream, + new byte[errorClassNameLength])).array()); + String errorMsg = new String(ByteBuffer.wrap(loadData(bufferedInputStream, + new byte[errorMsgLength])).array()); + + throw (Exception) (BinaryDataEndpoint.class.getClassLoader(). + loadClass(className).getConstructor(String.class).newInstance(errorMsg)); + case 2: + //Logging OK response + bbuf = ByteBuffer.wrap(loadData(bufferedInputStream, new byte[4])); + int sessionIdLength = bbuf.getInt(); + return new String(ByteBuffer.wrap(loadData(bufferedInputStream, new byte[sessionIdLength])).array()); + } + return null; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java new file mode 100644 index 0000000000..b18898324a --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary; + +import org.apache.http.conn.ssl.SSLContexts; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.AgentHolder; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client.AbstractSecureClientPoolFactory; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; + +import java.io.IOException; +import java.net.Socket; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; + +/** + * This is a Binary Transport secure implementation for AbstractSecureClientPoolFactory to be used by BinaryEndpoint. + */ +public class BinarySecureClientPoolFactory extends AbstractSecureClientPoolFactory { + private static final Logger log = LogManager.getLogger(BinarySecureClientPoolFactory.class); + private static SSLSocketFactory sslSocketFactory; + + public BinarySecureClientPoolFactory(KeyStore trustStore) { + super(trustStore); + SSLContext ctx; + try { + ctx = createSSLContext(); + sslSocketFactory = ctx.getSocketFactory(); + } catch (DataEndpointException e) { + log.error("Error while initializing the SSL Context with provided parameters" + + e.getErrorMessage(), e); + log.warn("Default SSLSocketFactory will be used for the data publishing clients."); + sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); + } + } + + @Override + public Object createClient(String protocol, String hostName, int port) throws DataEndpointException { + if (protocol.equalsIgnoreCase(DataEndpointConfiguration.Protocol.SSL.toString())) { + int timeout = AgentHolder.getInstance().getDataEndpointAgent().getAgentConfiguration() + .getSocketTimeoutMS(); + String sslProtocols = AgentHolder.getInstance().getDataEndpointAgent().getAgentConfiguration() + .getSslEnabledProtocols(); + String ciphers = AgentHolder.getInstance().getDataEndpointAgent().getAgentConfiguration().getCiphers(); + + try { + SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(hostName, port); + sslSocket.setSoTimeout(timeout); + + if (sslProtocols != null && sslProtocols.length() != 0) { + String[] sslProtocolsArray = sslProtocols.split(","); + sslSocket.setEnabledProtocols(sslProtocolsArray); + } + + if (ciphers != null && ciphers.length() != 0) { + String[] ciphersArray = ciphers.replaceAll(" ", "").split(","); + sslSocket.setEnabledCipherSuites(ciphersArray); + } else { + sslSocket.setEnabledCipherSuites(sslSocket.getSupportedCipherSuites()); + } + return sslSocket; + } catch (IOException e) { + throw new DataEndpointException("Error while opening socket to " + hostName + ":" + port + ". " + + e.getMessage(), e); + } + } else { + throw new DataEndpointException("Unsupported protocol: " + protocol + ". Currently only " + + DataEndpointConfiguration.Protocol.SSL.toString() + " supported."); + } + } + + @Override + public boolean validateClient(Object client) { + Socket socket = (Socket) client; + return socket.isConnected(); + } + + @Override + public void terminateClient(Object client) { + Socket socket = null; + try { + socket = (Socket) client; + socket.close(); + } catch (IOException e) { + log.warn("Cannot close the socket successfully from " + socket.getLocalAddress().getHostAddress() + + ":" + socket.getPort()); + } + } + + private SSLContext createSSLContext() throws DataEndpointException { + SSLContext ctx; + try { + KeyStore trustStore = getTrustStore(); + ctx = SSLContexts.custom().loadTrustMaterial(trustStore).build(); + return ctx; + } catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) { + throw new DataEndpointException("Error while creating the SSLContext with instance type : TLS.", e); + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointAuthenticationException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointAuthenticationException.java new file mode 100644 index 0000000000..d04ad0c64a --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointAuthenticationException.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception; + +/** + * Exception to be thrown when connecting the Data Endpoint. + */ +public class DataEndpointAuthenticationException extends Exception { + private String errorMessage; + + public DataEndpointAuthenticationException(String message) { + super(message); + errorMessage = message; + } + + public DataEndpointAuthenticationException(String message, Throwable cause) { + super(message, cause); + errorMessage = message; + } + + public DataEndpointAuthenticationException(Throwable cause) { + super(cause); + } + + public String getErrorMessage() { + return errorMessage; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointConfigurationException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointConfigurationException.java new file mode 100644 index 0000000000..273abfdc2a --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointConfigurationException.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception; + +/** + * Exception to be thrown When parsing the Data Endpoint configurations when initializing data publisher. + */ +public class DataEndpointConfigurationException extends Exception { + private String errorMessage; + + public DataEndpointConfigurationException(String message) { + super(message); + errorMessage = message; + } + + public DataEndpointConfigurationException(String message, Throwable cause) { + super(message, cause); + errorMessage = message; + } + + public DataEndpointConfigurationException(Throwable cause) { + super(cause); + } + + public String getErrorMessage() { + return errorMessage; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointException.java new file mode 100644 index 0000000000..12288d7278 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointException.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception; + +/** + * Exception to be thrown when communicating with DataEndpoint. + */ +public class DataEndpointException extends Exception { + private String errorMessage; + + public DataEndpointException(String message) { + super(message); + errorMessage = message; + } + + public DataEndpointException(String message, Throwable cause) { + super(message, cause); + errorMessage = message; + } + + public DataEndpointException(Throwable cause) { + super(cause); + } + + public String getErrorMessage() { + return errorMessage; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/EventQueueFullException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/EventQueueFullException.java new file mode 100644 index 0000000000..743a8e343e --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/EventQueueFullException.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception; + +/** + * Exception to be thrown when the event is tried to insert into the queue + * which doesn't have adequate capacity to hold. + */ +public class EventQueueFullException extends Exception { + private String errorMessage; + + public EventQueueFullException(String message) { + super(message); + errorMessage = message; + } + + public EventQueueFullException(String message, Throwable cause) { + super(message, cause); + errorMessage = message; + } + + public EventQueueFullException(Throwable cause) { + super(cause); + } + + public String getErrorMessage() { + return errorMessage; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/DataEndpointConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/DataEndpointConstants.java new file mode 100644 index 0000000000..2386486a5b --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/DataEndpointConstants.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util; + +/** + * Class to define the constants that are used. + */ +public class DataEndpointConstants { + + private DataEndpointConstants() { + } + + public static final int DEFAULT_DATA_AGENT_BATCH_SIZE = 100; + public static final String LB_URL_GROUP_SEPARATOR = ","; + public static final String FAILOVER_URL_GROUP_SEPARATOR = "|"; + public static final String FAILOVER_URL_GROUP_SEPARATOR_REGEX = "\\|"; + public static final int DEFAULT_AUTH_PORT_OFFSET = 100; + public static final String SEPARATOR = "##"; + + public static final String SYNC_STRATEGY = "sync"; + public static final String ASYNC_STRATEGY = "async"; + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/DataPublisherUtil.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/DataPublisherUtil.java new file mode 100644 index 0000000000..faed0b2fa9 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/DataPublisherUtil.java @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util; + +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointConfigurationException; + +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * A Util class which holds all the utility processing methods in the data publisher operation. + */ +public class DataPublisherUtil { + + /** + * Making as private to avoid the instantiation of the class. + */ + private DataPublisherUtil() {} + + /** + * Process and extracts the receiver Groups from the string of URL set pattern passed in. + * + * @param urlSet receiverGroups URL set + * @return List of Receiver groups + * @throws DataEndpointConfigurationException + */ + public static ArrayList getEndpointGroups(String urlSet) + throws DataEndpointConfigurationException { + ArrayList urlGroups = new ArrayList(); + ArrayList endPointGroups = new ArrayList(); + Pattern regex = Pattern.compile("\\{.*?\\}"); + Matcher regexMatcher = regex.matcher(urlSet); + while (regexMatcher.find()) { + urlGroups.add(regexMatcher.group().replace("{", "").replace("}", "")); + } + if (urlGroups.size() == 0) { + urlGroups.add(urlSet.replace("{", "").replace("}", "")); + } + for (String aURLGroup : urlGroups) { + endPointGroups.add(getEndpoints(aURLGroup)); + } + return endPointGroups; + } + + /** + * Returns an object array which has first element as boolean + * for specify the URLs are fail over configuration or LB configuration. + * From the 2nd element onwards the object array will hold the separated URLs + * + * @param aURLGroup one receiver group's URL + * @return First element - boolean (isFailOver), next elements are each URLs + * @throws DataEndpointConfigurationException + */ + private static Object[] getEndpoints(String aURLGroup) + throws DataEndpointConfigurationException { + boolean isLBURL = false, isFailOverURL = false; + String[] urls; + if (aURLGroup.contains(",")) { + isLBURL = true; + } + if (aURLGroup.contains("|")) { + isFailOverURL = true; + } + + if (isLBURL && isFailOverURL) { + throw new DataEndpointConfigurationException("Invalid data endpoints URL set provided : " + aURLGroup + + ", a URL group can be configured as failover OR load balancing endpoints."); + } else if (isLBURL) { + urls = aURLGroup.split(DataEndpointConstants.LB_URL_GROUP_SEPARATOR); + } else if (isFailOverURL) { + urls = aURLGroup.split(DataEndpointConstants.FAILOVER_URL_GROUP_SEPARATOR_REGEX); + } else { + urls = new String[]{aURLGroup}; + } + Object[] endpoint = new Object[urls.length + 1]; + endpoint[0] = isFailOverURL; + for (int i = 0; i < urls.length; i++) { + endpoint[i + 1] = urls[i].trim(); + } + return endpoint; + } + + /** + * Validate whether the receiverGroup and authenticationGroups are matching with pattern. + * Basically if the receiver groups has been configured to be in the failover pattern, + * then the authentication URL also needs to be in the same way. Hence this method validates + * the provided receiverGroups, and authenticationGroup. + * + * @param receiverGroups List of Receiver groups + * @param authGroups List of Authentication groups. + * @throws DataEndpointConfigurationException + */ + public static void validateURLs(ArrayList receiverGroups, ArrayList authGroups) + throws DataEndpointConfigurationException { + if (receiverGroups.size() == authGroups.size()) { + for (int i = 0; i < receiverGroups.size(); i++) { + Object[] receiverGroup = (Object[]) receiverGroups.get(i); + Object[] authGroup = (Object[]) authGroups.get(i); + + if (receiverGroup.length == authGroup.length) { + boolean isFailOver = (Boolean) receiverGroup[0]; + boolean isAuthFailOver = (Boolean) ((Object[]) receiverGroups.get(i))[0]; + if (isFailOver != isAuthFailOver) { + throw new DataEndpointConfigurationException("Receiver and authentication URL group set " + + "doesn't match. Receiver URL group: " + getURLSet(receiverGroup) + + " is configured as failOver : " + isFailOver + ", but Authentication URL group: " + + getURLSet(authGroup) + " is configured as failOver :" + isAuthFailOver); + } + } else { + throw new DataEndpointConfigurationException("Receiver and authentication URL group set " + + "doesn't match. Receiver URL group: " + getURLSet(receiverGroup) + ", " + + "but Authentication URL group: " + getURLSet(authGroup)); + } + } + } else { + throw new DataEndpointConfigurationException("Receiver and authentication URL set doesn't match. " + + "Receiver URL groups: " + receiverGroups.size() + ", but Authentication URL groups: " + + authGroups.size()); + } + } + + /** + * Returns the URL set string based on the URLs provided. The first element of the array is + * a boolean which indicates whether it's failover or load balancing. + * + * @param urlGroup Array of url and the first element of array should specify + * whether its load balancing or fail over + * @return String representation of URL set. + */ + private static String getURLSet(Object[] urlGroup) { + boolean isFailOver = (Boolean) urlGroup[0]; + StringBuilder urlSet = new StringBuilder(""); + for (int i = 1; i < urlGroup.length; i++) { + urlSet.append(urlGroup[i]); + if (i != urlGroup.length - 1) { + if (isFailOver) { + urlSet.append(DataEndpointConstants.FAILOVER_URL_GROUP_SEPARATOR); + } else { + urlSet.append(DataEndpointConstants.LB_URL_GROUP_SEPARATOR); + } + } + } + return urlSet.toString(); + } + + /** + * Extracts and return the protocol, host, port elements from the URL. + * + * @param url String of URL that needs to be processed. + * @return Array which has elements - protocol, host, and port in the given order. + */ + public static String[] getProtocolHostPort(String url) throws DataEndpointConfigurationException { + String[] keyElements = url.split(DataEndpointConstants.SEPARATOR); + String[] urlElements = keyElements[0].split(":"); + if (urlElements.length != 3) { + throw new DataEndpointConfigurationException("Invalid URL is provided :" + url + + ". Receiver URL property should take the format : " + "protocol://host:port"); + } + return new String[]{urlElements[0], urlElements[1].replace("//", ""), urlElements[2]}; + } + + /** + * Deduce the default authentication URL based on the receiver URL passed in. + * + * @param receiverURL receiver URL for which it's required to get the authentication URL. + * @return default authentication URL. + */ + public static String getDefaultAuthUrl(String receiverURL) throws DataEndpointConfigurationException { + String[] urlElements = getProtocolHostPort(receiverURL); + int port = Integer.parseInt(urlElements[2]); + String host = urlElements[1]; + return DataEndpointConfiguration.Protocol.SSL.toString() + "://" + host + ":" + + (port + DataEndpointConstants.DEFAULT_AUTH_PORT_OFFSET); + } + + /** + * Deduce the default authentication URL set based on the receiver URL set passed in. + * + * @param receiverURLSet receiver URL set for which it's required to get the authentication URL set. + * @return default authentication URL set. + */ + public static String getDefaultAuthURLSet(String receiverURLSet) throws DataEndpointConfigurationException { + ArrayList receiverURLGroups = DataPublisherUtil.getEndpointGroups(receiverURLSet); + StringBuilder authURLSet = new StringBuilder(""); + for (int i = 0; i < receiverURLGroups.size(); i++) { + Object[] receiverGroup = receiverURLGroups.get(i); + boolean failOver = (Boolean) receiverGroup[0]; + authURLSet.append("{"); + for (int j = 1; j < receiverGroup.length; j++) { + authURLSet.append(DataPublisherUtil.getDefaultAuthUrl(receiverGroup[j].toString())); + if (j != receiverGroup.length - 1) { + if (failOver) { + authURLSet.append(DataEndpointConstants.FAILOVER_URL_GROUP_SEPARATOR); + } else { + authURLSet.append(DataEndpointConstants.LB_URL_GROUP_SEPARATOR); + } + } + } + authURLSet.append("}"); + if (i != receiverURLGroups.size() - 1) { + authURLSet.append(","); + } + } + return authURLSet.toString(); + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/ThrottleEventConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/ThrottleEventConstants.java new file mode 100644 index 0000000000..7c33314964 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/ThrottleEventConstants.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util; + +/** + * This class holds the constants required to fetch the properties from the ThrottleEvent. + */ +public class ThrottleEventConstants { + + private ThrottleEventConstants() { + } + + public static final String MESSAGE_ID = "messageID"; + public static final String APP_KEY = "appKey"; + public static final String APP_TIER = "appTier"; + public static final String API_KEY = "apiKey"; + public static final String API_TIER = "apiTier"; + public static final String SUBSCRIPTION_KEY = "subscriptionKey"; + public static final String SUBSCRIPTION_TIER = "subscriptionTier"; + public static final String RESOURCE_KEY = "resourceKey"; + public static final String RESOURCE_TIER = "resourceTier"; + public static final String USER_ID = "userId"; + public static final String API_CONTEXT = "apiContext"; + public static final String API_VERSION = "apiVersion"; + public static final String APP_TENANT = "appTenant"; + public static final String API_TENANT = "apiTenant"; + public static final String APP_ID = "appId"; + public static final String API_NAME = "apiName"; + public static final String PROPERTIES = "properties"; +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/DataProcessAndPublishingAgent.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/DataProcessAndPublishingAgent.java new file mode 100644 index 0000000000..f414384747 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/DataProcessAndPublishingAgent.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.publisher; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.carbon.databridge.commons.Event; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.DataPublisher; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.ThrottleEventConstants; + +import java.util.Map; + +/** + * This class is responsible for executing data publishing logic. This class implements runnable interface and + * need to execute using thread pool executor. Primary task of this class it is accept message context as parameter + * and perform time consuming data extraction and publish event to data publisher. Having data extraction and + * transformation logic in this class will help to reduce overhead added to main message flow. + */ +public class DataProcessAndPublishingAgent implements Runnable { + private static final Logger log = LogManager.getLogger(DataProcessAndPublishingAgent.class); + + private static String streamID = "org.wso2.throttle.request.stream:1.0.0"; + private DataPublisher dataPublisher; + + String messageId; + String applicationLevelThrottleKey; + String applicationLevelTier; + String apiLevelThrottleKey; + String apiLevelTier; + String subscriptionLevelThrottleKey; + String subscriptionLevelTier; + String resourceLevelThrottleKey; + String authorizedUser; + String resourceLevelTier; + String apiContext; + String apiVersion; + String appTenant; + String apiTenant; + String apiName; + String appId; + String properties; + + public DataProcessAndPublishingAgent() { + dataPublisher = getDataPublisher(); + } + + /** + * This method will clean data references. This method should call whenever we return data process and publish + * agent back to pool. Every time when we add new property we need to implement cleaning logic as well. + */ + public void clearDataReference() { + this.messageId = null; + this.applicationLevelThrottleKey = null; + this.applicationLevelTier = null; + this.apiLevelThrottleKey = null; + this.apiLevelTier = null; + this.subscriptionLevelThrottleKey = null; + this.subscriptionLevelTier = null; + this.resourceLevelThrottleKey = null; + this.resourceLevelTier = null; + this.authorizedUser = null; + this.apiContext = null; + this.apiVersion = null; + this.appTenant = null; + this.apiTenant = null; + this.appId = null; + this.apiName = null; + } + + /** + * This method will use to set message context. + */ + public void setDataReference(Map throttleEvent) { + this.messageId = throttleEvent.get(ThrottleEventConstants.MESSAGE_ID); + this.applicationLevelThrottleKey = throttleEvent.get(ThrottleEventConstants.APP_KEY); + this.applicationLevelTier = throttleEvent.get(ThrottleEventConstants.APP_TIER); + this.apiLevelThrottleKey = throttleEvent.get(ThrottleEventConstants.API_KEY); + this.apiLevelTier = throttleEvent.get(ThrottleEventConstants.API_TIER); + this.subscriptionLevelThrottleKey = throttleEvent.get(ThrottleEventConstants.SUBSCRIPTION_KEY); + this.subscriptionLevelTier = throttleEvent.get(ThrottleEventConstants.SUBSCRIPTION_TIER); + this.resourceLevelThrottleKey = throttleEvent.get(ThrottleEventConstants.RESOURCE_KEY); + this.resourceLevelTier = throttleEvent.get(ThrottleEventConstants.RESOURCE_TIER); + this.authorizedUser = throttleEvent.get(ThrottleEventConstants.USER_ID); + this.apiContext = throttleEvent.get(ThrottleEventConstants.API_CONTEXT); + this.apiVersion = throttleEvent.get(ThrottleEventConstants.API_VERSION); + this.appTenant = throttleEvent.get(ThrottleEventConstants.APP_TENANT); + this.apiTenant = throttleEvent.get(ThrottleEventConstants.API_TENANT); + this.appId = throttleEvent.get(ThrottleEventConstants.APP_ID); + this.apiName = throttleEvent.get(ThrottleEventConstants.API_NAME); + this.properties = throttleEvent.get(ThrottleEventConstants.PROPERTIES); + } + + public void run() { + + Object[] objects = new Object[]{messageId, + this.applicationLevelThrottleKey, this.applicationLevelTier, + this.apiLevelThrottleKey, this.apiLevelTier, + this.subscriptionLevelThrottleKey, this.subscriptionLevelTier, + this.resourceLevelThrottleKey, this.resourceLevelTier, + this.authorizedUser, this.apiContext, this.apiVersion, + this.appTenant, this.apiTenant, this.appId, this.apiName, properties}; + Event event = new Event(streamID, System.currentTimeMillis(), null, null, objects); + dataPublisher.tryPublish(event); + } + + protected DataPublisher getDataPublisher() { + return ThrottleDataPublisher.getDataPublisher(); + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/DataPublisherConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/DataPublisherConstants.java new file mode 100644 index 0000000000..cb08c1afa9 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/DataPublisherConstants.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.publisher; + +/** + * Class to define the constants for Data Agent. + */ +public class DataPublisherConstants { + + private DataPublisherConstants() { + } + + public static final String RECEIVER_URL_GROUP = "receiverURLGroup"; + public static final String AUTH_URL_GROUP = "authURLGroup"; + public static final String USERNAME = "username"; + public static final String PASSWORD = "password"; + public static final String MAX_IDLE = "maxIdle"; + public static final String INIT_IDLE_CAPACITY = "initIdleCapacity"; + public static final String CORE_POOL_SIZE = "corePoolSize"; + public static final String MAX_POOL_SIZE = "maxPoolSize"; + public static final String KEEP_ALIVE_TIME = "keepAliveTime"; +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/PublisherConfiguration.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/PublisherConfiguration.java new file mode 100644 index 0000000000..6519173a16 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/PublisherConfiguration.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.publisher; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.Map; + +/** + * This class holds the configurations related to binary data publisher. + */ +public class PublisherConfiguration { + private static final Logger log = LogManager.getLogger(PublisherConfiguration.class); + + private int maxIdleDataPublishingAgents; + private int initIdleObjectDataPublishingAgents; + private int publisherThreadPoolCoreSize; + private int publisherThreadPoolMaximumSize; + private int publisherThreadPoolKeepAliveTime; + + private String receiverUrlGroup; + private String authUrlGroup; + private String userName; + private char[] password; + + private static PublisherConfiguration instance = new PublisherConfiguration(); + + private PublisherConfiguration() { + } + + public void setMaxIdleDataPublishingAgents(int maxIdleDataPublishingAgents) { + this.maxIdleDataPublishingAgents = maxIdleDataPublishingAgents; + } + + public void setInitIdleObjectDataPublishingAgents(int initIdleObjectDataPublishingAgents) { + this.initIdleObjectDataPublishingAgents = initIdleObjectDataPublishingAgents; + } + + public void setPublisherThreadPoolCoreSize(int publisherThreadPoolCoreSize) { + this.publisherThreadPoolCoreSize = publisherThreadPoolCoreSize; + } + + public void setPublisherThreadPoolMaximumSize(int publisherThreadPoolMaximumSize) { + this.publisherThreadPoolMaximumSize = publisherThreadPoolMaximumSize; + } + + public void setPublisherThreadPoolKeepAliveTime(int publisherThreadPoolKeepAliveTime) { + this.publisherThreadPoolKeepAliveTime = publisherThreadPoolKeepAliveTime; + } + + public void setAuthUrlGroup(String authUrlGroup) { + this.authUrlGroup = authUrlGroup; + } + + public void setReceiverUrlGroup(String receiverUrlGroup) { + this.receiverUrlGroup = receiverUrlGroup; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public void setPassword(String password) { + this.password = password.toCharArray(); + } + + public int getMaxIdleDataPublishingAgents() { + return maxIdleDataPublishingAgents; + } + + public int getInitIdleObjectDataPublishingAgents() { + return initIdleObjectDataPublishingAgents; + } + + public int getPublisherThreadPoolCoreSize() { + return publisherThreadPoolCoreSize; + } + + public int getPublisherThreadPoolMaximumSize() { + return publisherThreadPoolMaximumSize; + } + + public int getPublisherThreadPoolKeepAliveTime() { + return publisherThreadPoolKeepAliveTime; + } + + public String getReceiverUrlGroup() { + return receiverUrlGroup; + } + + public String getAuthUrlGroup() { + return authUrlGroup; + } + + public String getUserName() { + return userName; + } + + public String getPassword() { + return String.valueOf(password); + } + + public static PublisherConfiguration getInstance() { + return instance; + } + + public static synchronized void setInstance(PublisherConfiguration publisherConfiguration) { + instance = publisherConfiguration; + } + + public void setConfiguration(Map publisherConfiguration) { + this.receiverUrlGroup = String.valueOf(publisherConfiguration.get(DataPublisherConstants.RECEIVER_URL_GROUP)); + this.authUrlGroup = String.valueOf(publisherConfiguration.get(DataPublisherConstants.AUTH_URL_GROUP)); + this.userName = String.valueOf(publisherConfiguration.get(DataPublisherConstants.USERNAME)); + this.password = String.valueOf(publisherConfiguration.get(DataPublisherConstants.PASSWORD)).toCharArray(); + try { + this.maxIdleDataPublishingAgents = + Math.toIntExact((long) publisherConfiguration.get(DataPublisherConstants.MAX_IDLE)); + this.initIdleObjectDataPublishingAgents = + Math.toIntExact((long) publisherConfiguration.get(DataPublisherConstants.INIT_IDLE_CAPACITY)); + this.publisherThreadPoolCoreSize = + Math.toIntExact((long) publisherConfiguration.get(DataPublisherConstants.CORE_POOL_SIZE)); + this.publisherThreadPoolMaximumSize = + (Math.toIntExact((long) publisherConfiguration.get(DataPublisherConstants.MAX_POOL_SIZE))); + this.publisherThreadPoolKeepAliveTime = Math.toIntExact((long) publisherConfiguration + .get(DataPublisherConstants.KEEP_ALIVE_TIME)); + } catch (ArithmeticException e) { + log.error("Error while processing the publisher configuration.", e); + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/ThrottleDataPublisher.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/ThrottleDataPublisher.java new file mode 100644 index 0000000000..13b7f15ef5 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/ThrottleDataPublisher.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.publisher; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.carbon.databridge.commons.exception.TransportException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.DataPublisher; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointAuthenticationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointConfigurationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.ThrottleEventConstants; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; +import java.util.concurrent.Executor; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +/** + * Throttle data publisher class is here to publish throttle data to global policy engine. + * This can publish data according to defined protocol. Protocol can be thrift or binary. + * When we use this for high concurrency usecases proper tuning is mandatory. + */ +public class ThrottleDataPublisher { + public static ThrottleDataPublisherPool dataPublisherPool; + + private static final Logger LOG = LogManager.getLogger(ThrottleDataPublisher.class); + private static volatile DataPublisher dataPublisher = null; + private Executor executor; + + public static DataPublisher getDataPublisher() { + return dataPublisher; + } + + /** + * This method will initialize throttle data publisher. Inside this we will start executor and initialize data + * publisher which we used to publish throttle data. + */ + public ThrottleDataPublisher() { + dataPublisherPool = ThrottleDataPublisherPool.getInstance(); + PublisherConfiguration publisherConfiguration = PublisherConfiguration.getInstance(); + + try { + executor = new DataPublisherThreadPoolExecutor( + publisherConfiguration.getPublisherThreadPoolCoreSize(), + publisherConfiguration.getPublisherThreadPoolMaximumSize(), + publisherConfiguration.getPublisherThreadPoolKeepAliveTime(), + TimeUnit.SECONDS, + new LinkedBlockingDeque() { + }); + dataPublisher = new DataPublisher(publisherConfiguration.getReceiverUrlGroup(), + publisherConfiguration.getAuthUrlGroup(), publisherConfiguration.getUserName(), + publisherConfiguration.getPassword()); + + } catch (DataEndpointException | DataEndpointConfigurationException | DataEndpointAuthenticationException + | TransportException e) { + LOG.error("Error in initializing binary data-publisher to send requests to global throttling engine " + + e.getMessage(), e); + } + } + + /** + * This method used to pass message context and let it run within separate thread. + */ + public void publishNonThrottledEvent(Map throttleEvent) { + try { + if (dataPublisherPool != null) { + DataProcessAndPublishingAgent agent = dataPublisherPool.get(); + agent.setDataReference(throttleEvent); + if (LOG.isDebugEnabled()) { + String messageId = throttleEvent.getOrDefault(ThrottleEventConstants.MESSAGE_ID, "null"); + String apiContext = throttleEvent.getOrDefault(ThrottleEventConstants.API_CONTEXT, "null"); + LOG.debug("Publishing throttle data from gateway to traffic-manager for: " + apiContext + + " with ID: " + messageId + " started" + " at " + + new SimpleDateFormat("[yyyy.MM.dd HH:mm:ss,SSS zzz]").format(new Date())); + } + executor.execute(agent); + if (LOG.isDebugEnabled()) { + String messageId = throttleEvent.getOrDefault(ThrottleEventConstants.MESSAGE_ID, "null"); + String apiContext = throttleEvent.getOrDefault(ThrottleEventConstants.API_CONTEXT, "null"); + LOG.debug("Publishing throttle data from gateway to traffic-manager for: " + apiContext + + " with ID: " + messageId + " ended" + " at " + + new SimpleDateFormat("[yyyy.MM.dd HH:mm:ss,SSS zzz]").format(new Date())); + } + } else { + LOG.debug("Throttle data publisher pool is not initialized."); + } + } catch (Exception e) { + LOG.error("Error while publishing throttling events to global policy server", e); + } + } + + /** + * This class will act as thread pool executor and after executing each thread it will return runnable + * object back to pool. This implementation specifically used to minimize number of objectes created during + * runtime. In this queuing strategy the submitted task will wait in the queue if the corePoolsize theads are + * busy and the task will be allocated if any of the threads become idle.Thus ThreadPool will always have number + * of threads running as mentioned in the corePoolSize. + * LinkedBlockingQueue without the capacity can be used for this queuing strategy.If the corePoolsize of the + * threadpool is less and there are more number of time consuming task were submitted,there is more possibility + * that the task has to wait in the queue for more time before it is run by any of the ideal thread. + * So tuning core pool size is something we need to tune properly. + * Also no task will be rejected in Threadpool until the threadpool was shutdown. + */ + private class DataPublisherThreadPoolExecutor extends ThreadPoolExecutor { + public DataPublisherThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, + TimeUnit unit, LinkedBlockingDeque workQueue) { + super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); + } + + protected void afterExecute(Runnable r, Throwable t) { + try { + DataProcessAndPublishingAgent agent = (DataProcessAndPublishingAgent) r; + ThrottleDataPublisher.dataPublisherPool.release(agent); + } catch (Exception e) { + LOG.error("Error while returning Throttle data publishing agent back to pool" + e.getMessage()); + } + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/ThrottleDataPublisherPool.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/ThrottleDataPublisherPool.java new file mode 100644 index 0000000000..a8257ac946 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/ThrottleDataPublisherPool.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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 org.wso2.micro.gateway.enforcer.throttle.databridge.publisher; + +import org.apache.commons.pool.BasePoolableObjectFactory; +import org.apache.commons.pool.ObjectPool; +import org.apache.commons.pool.impl.StackObjectPool; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +/** + * This class implemented to hold throttle data publishing agent pool. Reason for implement this is to + * reduce unwanted object creation. This is using stack object pool as we may need to handle some scenarios + * where unexpected load comes. In such cases we cannot have fixed size pool. + */ +public class ThrottleDataPublisherPool { + + private static final Logger log = LogManager.getLogger(ThrottleDataPublisherPool.class); + + private ObjectPool clientPool; + + private ThrottleDataPublisherPool() { + //Using stack object pool to handle high concurrency scenarios without droping any messages. + //Tuning this pool is mandatory according to use cases. + //A finite number of "sleeping" or idle instances is enforced, but when the pool is empty, new instances + // are created to support the new load. Hence this following data stricture places no limit on the number of " + // active" instance created by the pool, but is quite useful for re-using Objects without introducing + // artificial limits. + //Proper tuning is mandatory for good performance according to system load. + PublisherConfiguration configuration = PublisherConfiguration.getInstance(); + clientPool = new StackObjectPool(new BasePoolableObjectFactory() { + @Override + public Object makeObject() throws Exception { + if (log.isDebugEnabled()) { + log.debug("Initializing new ThrottleDataPublisher instance"); + } + return new DataProcessAndPublishingAgent(); + } + }, configuration.getMaxIdleDataPublishingAgents(), configuration.getInitIdleObjectDataPublishingAgents()); + } + + private static class ThrottleDataPublisherPoolHolder { + private static final ThrottleDataPublisherPool INSTANCE = new ThrottleDataPublisherPool(); + + private ThrottleDataPublisherPoolHolder() { + } + } + + public static ThrottleDataPublisherPool getInstance() { + return ThrottleDataPublisherPoolHolder.INSTANCE; + } + + public DataProcessAndPublishingAgent get() throws Exception { + return (DataProcessAndPublishingAgent) clientPool.borrowObject(); + } + + public void release(DataProcessAndPublishingAgent client) throws Exception { + //We must clean data references as it can caused to pass old data to global policy server. + client.clearDataReference(); + clientPool.returnObject(client); + } + + public void cleanup() { + try { + clientPool.close(); + } catch (Exception e) { + log.warn("Error while cleaning up the object pool", e); + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java index dd3378641a..1c1f2e851d 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java @@ -44,6 +44,9 @@ import org.wso2.micro.gateway.enforcer.exception.MGWException; import org.wso2.micro.gateway.enforcer.security.AuthenticationContext; +import java.math.BigInteger; +import java.net.InetAddress; +import java.net.UnknownHostException; import java.security.KeyManagementException; import java.security.KeyStore; import java.security.KeyStoreException; @@ -72,7 +75,7 @@ public static String getMaskedToken(String token) { } /** - * Return a http client instance + * Return a http client instance. * * @param protocol - service endpoint protocol http/https * @return @@ -99,7 +102,7 @@ public static HttpClient getHttpClient(String protocol) { } /** - * Return a PoolingHttpClientConnectionManager instance + * Return a PoolingHttpClientConnectionManager instance. * * @param protocol- service endpoint protocol. It can be http/https * @return PoolManager @@ -166,10 +169,12 @@ public static String getTenantDomainFromRequestURL(String requestURI) { return domain; } - public static AuthenticationContext generateAuthenticationContext(String jti, JWTValidationInfo jwtValidationInfo, - APIKeyValidationInfoDTO apiKeyValidationInfoDTO, String endUserToken, boolean isOauth) { + public static AuthenticationContext generateAuthenticationContext(RequestContext requestContext, String jti, + JWTValidationInfo jwtValidationInfo, + APIKeyValidationInfoDTO apiKeyValidationInfoDTO, + String endUserToken, boolean isOauth) { - AuthenticationContext authContext = new AuthenticationContext(); + AuthenticationContext authContext = requestContext.getAuthenticationContext(); authContext.setAuthenticated(true); authContext.setApiKey(jti); authContext.setUsername(jwtValidationInfo.getUser()); @@ -202,6 +207,43 @@ public static AuthenticationContext generateAuthenticationContext(String jti, JW return authContext; } + public static long ipToLong(String ipAddress) { + + long result = 0; + String[] ipAddressInArray = ipAddress.split("\\."); + for (int i = 3; i >= 0; i--) { + long ip = Long.parseLong(ipAddressInArray[3 - i]); + //left shifting 24,16,8,0 and bitwise OR + //1. 192 << 24 + //1. 168 << 16 + //1. 1 << 8 + //1. 2 << 0 + result |= ip << (i * 8); + + } + return result; + } + + /** + * This method provides the BigInteger value for the given IP address. This supports both IPv4 and IPv6 address + * + * @param ipAddress ip address + * @return BigInteger value for the given ip address. returns 0 for unknown host + */ + public static BigInteger ipToBigInteger(String ipAddress) { + + InetAddress address; + try { + address = InetAddress.getByName(ipAddress); + byte[] bytes = address.getAddress(); + return new BigInteger(1, bytes); + } catch (UnknownHostException e) { + //ignore the error and log it + log.error("Error while parsing host IP " + ipAddress, e); + } + return BigInteger.ZERO; + } + public static JWTInfoDto generateJWTInfoDto(JSONObject subscribedAPI, JWTValidationInfo jwtValidationInfo, APIKeyValidationInfoDTO apiKeyValidationInfoDTO, RequestContext requestContext) { @@ -298,4 +340,20 @@ public static void setUnauthenticatedErrorToContext(RequestContext requestContex APISecurityConstants.API_AUTH_INVALID_CREDENTIALS_DESCRIPTION); } + /** + * Set the throttle error related details to the {@code RequestContext}. + * + * @param context request context object to set the details. + * @param errorCode internal wso2 throttle error code. + * @param msg wso2 throttle error message. + * @param desc description of throttle decision. + */ + public static void setThrottleErrorToContext(RequestContext context, int errorCode, String msg, String desc) { + context.getProperties().put(APIConstants.MessageFormat.ERROR_CODE, errorCode); + context.getProperties().put(APIConstants.MessageFormat.STATUS_CODE, + APIConstants.StatusCodes.THROTTLED.getCode()); + context.getProperties().put(APIConstants.MessageFormat.ERROR_MESSAGE, msg); + context.getProperties().put(APIConstants.MessageFormat.ERROR_DESCRIPTION, desc); + } + } diff --git a/pom.xml b/pom.xml index 5fd4c0726e..6c14859d7d 100644 --- a/pom.xml +++ b/pom.xml @@ -275,6 +275,31 @@ testng ${testng.version} + + org.wso2.carbon.analytics-common + org.wso2.carbon.databridge.commons + ${analytics.common.version} + + + org.wso2.carbon.analytics-common + org.wso2.carbon.databridge.commons.binary + ${analytics.common.version} + + + commons-pool.wso2 + commons-pool + ${apache.commons.version} + + + org.wso2.orbit.com.lmax + disruptor + ${lmax.version} + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.common.gateway + ${apim.common.version} + @@ -282,6 +307,7 @@ UTF-8 3.3.12 + 9.0.0 3.2.0 3.9 2.6 @@ -314,5 +340,8 @@ 6.11 6.0.53 0.7.2 + 6.1.45 + 1.5.6.wso2v1 + 3.4.2.wso2v1 diff --git a/resources/conf/config.toml b/resources/conf/config.toml index a09ff922c5..136821dc5b 100644 --- a/resources/conf/config.toml +++ b/resources/conf/config.toml @@ -132,6 +132,68 @@ username = "admin" password = "admin" +# Throttling configurations +[enforcer.throttling] + # Connect with the central traffic manager + enableGlobalEventPublishing = false + # Enable global advanced throttling based on request header conditions + enableHeaderConditions = false + # Enable global advanced throttling based on request query parameter conditions + enableQueryParamConditions = false + # Enable global advanced throttling based on jwt claim conditions + enableJwtClaimConditions = false + # The message broker context factory + jmsConnectioninitialContextFactory = "org.wso2.andes.jndi.PropertiesFileInitialContextFactory" + # The message broker connection URL + jmsConnectionProviderUrl = "amqp://admin:admin@carbon/carbon?brokerlist='tcp://localhost:5672'" + # Throttling configurations related to event publishing using a binary connection + [enforcer.throttling.publisher] + # Credentials required to establish connection between Traffic Manager + username = "admin" + password = "admin" + # Receiver URL and the authentication URL of the Traffic manager node/nodes + [[enforcer.throttling.publisher.urlGroup]] + receiverURLs = ["tcp://localhost:9611"] + authURLs = ["ssl://localhost:9711"] + # Data publisher object pool configurations + [enforcer.throttling.publisher.pool] + maxIdleDataPublishingAgents = 1000 + initIdleObjectDataPublishingAgents = 200 + # Data publisher thread pool configurations + publisherThreadPoolCoreSize = 200 + publisherThreadPoolMaximumSize = 1000 + publisherThreadPoolKeepAliveTime = 200 + [enforcer.throttling.publisher.agent] + # SSL Protocols + sslEnabledProtocols = "TLSv1.2" + # ciphers + ciphers="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDH_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 ,TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA,TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA,TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA,SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA,TLS_EMPTY_RENEGOTIATION_INFO_SCSV" + # The size of the queue event disruptor which handles events before they are published. + # The value specified should always be the result of an exponent with 2 as the base. + queueSize = 32768 + # The maximum number of events in a batch sent to the queue event disruptor at a given time + batchSize = 200 + # The number of threads that will be reserved to handle events at the time you start + corePoolSize = 1 + # Socket timeout + socketTimeoutMS = 30000 + # The maximum number of threads that should be reserved at any given time to handle events + maxPoolSize = 1 + # The amount of time which threads in excess of the core pool size may remain idle before being terminated. + keepAliveTimeInPool = 20 + # The time interval between reconnection + reconnectionInterval = 30 + # TCP connection pool configurations (for data publishing) + maxTransportPoolSize = 250 + maxIdleConnections = 250 + evictionTimePeriod = 5500 + minIdleTimeInPool = 5000 + # SSL connection pool configurations (for authentication) + secureMaxTransportPoolSize = 250 + secureMaxIdleConnections = 250 + secureEvictionTimePeriod = 5500 + secureMinIdleTimeInPool = 5000 + [controlPlane] # Control plane's eventHub details diff --git a/test/test-integration/pom.xml b/test/test-integration/pom.xml index 41e2d1a35b..863fdafa7d 100644 --- a/test/test-integration/pom.xml +++ b/test/test-integration/pom.xml @@ -192,7 +192,6 @@ org.wso2.carbon.apimgt org.wso2.carbon.apimgt.common.gateway - 9.0.0 org.wso2.orbit.com.nimbusds