-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa04779
commit 67a7625
Showing
41 changed files
with
1,611 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Licensed 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. | ||
*/ | ||
|
||
export class AllowedAndBlockedHosts { | ||
private readonly allowedHostIds: Set<string>; | ||
private readonly blockedHostIds: Set<string>; | ||
|
||
constructor(allowedHostIds: Set<string>, blockedHostIds: Set<string>) { | ||
this.allowedHostIds = allowedHostIds; | ||
this.blockedHostIds = blockedHostIds; | ||
} | ||
|
||
getAllowedHostIds() { | ||
return this.allowedHostIds; | ||
} | ||
|
||
getBlockedHostIds() { | ||
return this.blockedHostIds; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
common/lib/plugins/custom_endpoint/custom_endpoint_info.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Licensed 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. | ||
*/ | ||
|
||
import { CustomEndpointRoleType, customEndpointRoleTypeFromValue } from "./custom_endpoint_role_type"; | ||
import { MemberListType } from "./member_list_type"; | ||
|
||
export class CustomEndpointInfo { | ||
private endpointIdentifier: string; // ID portion of the custom endpoint URL. | ||
private readonly clusterIdentifier: string; // ID of the cluster that the custom endpoint belongs to. | ||
private readonly url: string; | ||
private readonly roleType: CustomEndpointRoleType; | ||
|
||
// A given custom endpoint will either specify a static list or an exclusion list, as indicated by `memberListType`. | ||
// If the list is a static list, 'members' specifies instances included in the custom endpoint, and new cluster | ||
// instances will not be automatically added to the custom endpoint. If it is an exclusion list, 'members' specifies | ||
// instances excluded by the custom endpoint, and new cluster instances will be added to the custom endpoint. | ||
private readonly memberListType: MemberListType; | ||
private readonly members: Set<string>; | ||
|
||
constructor( | ||
endpointIdentifier: string, | ||
clusterIdentifier: string, | ||
url: string, | ||
roleType: CustomEndpointRoleType, | ||
members: Set<string>, | ||
memberListType: MemberListType | ||
) { | ||
this.endpointIdentifier = endpointIdentifier; | ||
this.clusterIdentifier = clusterIdentifier; | ||
this.url = url; | ||
this.roleType = roleType; | ||
this.members = members; | ||
this.memberListType = memberListType; | ||
} | ||
|
||
getMemberListType(): MemberListType { | ||
return this.memberListType; | ||
} | ||
|
||
static fromDbClusterEndpoint(responseEndpointInfo: any): CustomEndpointInfo { | ||
let members: Set<string>; | ||
let memberListType: MemberListType; | ||
|
||
if (responseEndpointInfo.StaticMembers) { | ||
members = responseEndpointInfo.StaticMembers; | ||
memberListType = MemberListType.STATIC_LIST; | ||
} else { | ||
members = responseEndpointInfo.ExcludedMembers; | ||
memberListType = MemberListType.EXCLUSION_LIST; | ||
} | ||
|
||
return new CustomEndpointInfo( | ||
responseEndpointInfo.DBClusterEndpointIdentifier, | ||
responseEndpointInfo.DBClusterIdentifier, | ||
responseEndpointInfo.Endpoint, | ||
customEndpointRoleTypeFromValue(responseEndpointInfo.CustomEndpointType), | ||
members, | ||
memberListType | ||
); | ||
} | ||
|
||
getStaticMembers(): Set<string> { | ||
return this.memberListType === MemberListType.STATIC_LIST ? this.members : null; | ||
} | ||
|
||
getExcludedMembers(): Set<string> { | ||
return this.memberListType === MemberListType.EXCLUSION_LIST ? this.members : null; | ||
} | ||
|
||
equals(obj: any): boolean { | ||
if (!obj) { | ||
return false; | ||
} | ||
|
||
if (obj === this) { | ||
return true; | ||
} | ||
|
||
const info = obj as CustomEndpointInfo; | ||
return ( | ||
this.endpointIdentifier === info.endpointIdentifier && | ||
this.clusterIdentifier === info.clusterIdentifier && | ||
this.url === info.url && | ||
this.roleType === info.roleType && | ||
this.members === info.members && | ||
this.memberListType === info.memberListType | ||
); | ||
} | ||
|
||
toString(): string { | ||
return `CustomEndpointInfo[url=${this.url}, clusterIdentifier=${this.clusterIdentifier}, customEndpointType=${this.roleType}, memberListType=${this.memberListType}, members=${this.members}]`; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
common/lib/plugins/custom_endpoint/custom_endpoint_monitor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Licensed 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. | ||
*/ | ||
|
||
export interface CustomEndpointMonitor { | ||
shouldDispose(): boolean; | ||
hasCustomEndpointInfo(): boolean; | ||
close(): Promise<void>; | ||
} |
Oops, something went wrong.