Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ops
/
monitor-service
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
qinchao
7 years ago
Commit
4edc1f66ce958c4b912f7b07d6f812ee534c19a4
1 parent
ff497a19
自动伸缩
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
5 deletions
monitor-service-awstools/src/main/java/com/monitor/awstools/service/AwsQueryService.java
monitor-service-awstools/src/main/java/com/monitor/awstools/service/AwsQueryService.java
View file @
4edc1f6
...
...
@@ -5,6 +5,7 @@ import com.amazonaws.regions.Regions;
import
com.amazonaws.services.autoscaling.AmazonAutoScaling
;
import
com.amazonaws.services.autoscaling.AmazonAutoScalingClient
;
import
com.amazonaws.services.autoscaling.model.*
;
import
com.amazonaws.services.autoscaling.model.TagDescription
;
import
com.amazonaws.services.ec2.model.*
;
import
com.amazonaws.services.ec2.model.Filter
;
import
com.amazonaws.services.ec2.model.Instance
;
...
...
@@ -32,6 +33,7 @@ import org.springframework.stereotype.Service;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Stream
;
/**
* Created by yoho on 2016/8/31.
...
...
@@ -57,6 +59,7 @@ public class AwsQueryService {
return
commAutoScalingGroups
;
}
/**
* 修改伸缩组信息
* @param req
...
...
@@ -116,13 +119,13 @@ public class AwsQueryService {
AmazonAutoScaling
client
=
new
AmazonAutoScalingClient
(
awsClientComp
.
getAWSCredentials
());
client
.
setRegion
(
awsClientComp
.
getRegion
(
Regions
.
CN_NORTH_1
));
DescribeAutoScalingGroupsRequest
request
=
null
;
if
(
StringUtils
.
isNotBlank
(
equalsName
)){
/*
if(StringUtils.isNotBlank(equalsName)){
request = new DescribeAutoScalingGroupsRequest()
.withAutoScalingGroupNames(equalsName);
}
else
{
}else{
*/
request
=
new
DescribeAutoScalingGroupsRequest
()
.
withAutoScalingGroupNames
();
}
//
}
DescribeAutoScalingGroupsResult
result
=
client
.
describeAutoScalingGroups
(
request
);
if
(
result
==
null
){
return
null
;
...
...
@@ -130,9 +133,23 @@ public class AwsQueryService {
commGroups
=
new
ArrayList
<>();
CommAutoScalingGroup
commGroup
;
for
(
AutoScalingGroup
group
:
result
.
getAutoScalingGroups
()){
if
(
StringUtils
.
isNotBlank
(
equalsName
)&&!
equalsName
.
equals
(
group
.
getAutoScalingGroupName
())){
continue
;
if
(
StringUtils
.
isNotBlank
(
equalsName
)){
String
nameTag
=
""
;
List
<
TagDescription
>
tags
=
group
.
getTags
();
if
(
tags
!=
null
&&
tags
.
size
()>
0
){
Stream
<
TagDescription
>
streams
=
tags
.
stream
().
filter
(
tag
->
tag
.
getKey
().
equalsIgnoreCase
(
"Name"
));
if
(
streams
!=
null
){
nameTag
=
streams
.
findFirst
().
get
().
getValue
();
}
}
if
(!
nameTag
.
equals
(
group
.
getAutoScalingGroupName
())&&!
equalsName
.
equals
(
group
.
getAutoScalingGroupName
())){
continue
;
}
}
commGroup
=
new
CommAutoScalingGroup
();
commGroup
.
setScalingGroupName
(
group
.
getAutoScalingGroupName
());
commGroup
.
setMinSize
(
group
.
getMinSize
());
...
...
Please
register
or
login
to post a comment