本文整理汇总了Java中com.amazonaws.services.elasticloadbalancing.model.Instance类的典型用法代码示例。如果您正苦于以下问题:Java Instance类的具体用法?Java Instance怎么用?Java Instance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Instance类属于com.amazonaws.services.elasticloadbalancing.model包,在下文中一共展示了Instance类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: instanceIsGoneFromList
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
/**
* True if ec2InstanceId is not in the input list.
*/
private boolean instanceIsGoneFromList(List<Instance> instances)
{
if (instances == null)
{
throw new IllegalArgumentException();
}
for (Instance instance : instances)
{
if (StringUtils.equals(instance.getInstanceId(), ec2InstanceId))
{
return false;
}
}
return true;
}
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:19,代码来源:ElbInstanceGoneProgressChecker.java
示例2: registerInstance
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
/**
* Requests registration of the ec2 instance with the ELB.
* <p/>
* After calling here, you need to call DescribeLoadBalancers or DescribeInstanceHealth to see if registration is
* complete.
*/
public void registerInstance(String elbName, String ec2InstanceId)
{
LOGGER.debug("registerInstancesWithLoadBalancer(elbName: " + elbName + ", ec2InstanceId: " + ec2InstanceId + ")");
assertNonBlankArgs(elbName, ec2InstanceId);
StopWatch stopWatch = new StopWatch();
try
{
stopWatch.start();
RegisterInstancesWithLoadBalancerRequest request = new RegisterInstancesWithLoadBalancerRequest();
request.setLoadBalancerName(elbName);
request.setInstances(Arrays.asList(new Instance(ec2InstanceId)));
awsElbClient.registerInstancesWithLoadBalancer(request);
//Currently not doing anything with the RegisterInstancesWithLoadBalancerResult
}
finally
{
stopWatch.stop();
LOGGER.debug("registerInstancesWithLoadBalancer time elapsed " + stopWatch);
}
}
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:27,代码来源:ElbClient.java
示例3: deregisterInstance
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
/**
* Requests deregistration of the ec2 instance from the ELB.
* <p/>
* After calling here, you need to call DescribeLoadBalancers to see if registration is complete.
*/
public void deregisterInstance(String elbName, String ec2InstanceId)
{
LOGGER.debug("deregisterInstancesFromLoadBalancer(elbName: " + elbName + ", ec2InstanceId: " + ec2InstanceId + ")");
assertNonBlankArgs(elbName, ec2InstanceId);
StopWatch stopWatch = new StopWatch();
try
{
stopWatch.start();
DeregisterInstancesFromLoadBalancerRequest request = new DeregisterInstancesFromLoadBalancerRequest();
request.setLoadBalancerName(elbName);
request.setInstances(Arrays.asList(new Instance(ec2InstanceId)));
awsElbClient.deregisterInstancesFromLoadBalancer(request);
//Currently not doing anything with the DeregisterInstancesFromLoadBalancerResult
}
finally
{
stopWatch.stop();
LOGGER.debug("deregisterInstancesFromLoadBalancer time elapsed " + stopWatch);
}
}
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:26,代码来源:ElbClient.java
示例4: makeLoadBalancerDescription
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
/**
* Test helper - makes a fake LB description.
*/
private LoadBalancerDescription makeLoadBalancerDescription(String elbName, String... instanceIds)
{
LoadBalancerDescription loadBalancerDescription = new LoadBalancerDescription();
loadBalancerDescription.setLoadBalancerName(elbName);
List<Instance> instances = new ArrayList<Instance>();
if (instanceIds != null)
{
for (String instanceId : instanceIds)
{
Instance instance = new Instance();
instance.setInstanceId(instanceId);
instances.add(instance);
}
}
loadBalancerDescription.setInstances(instances);
return loadBalancerDescription;
}
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:21,代码来源:ElbInstanceGoneProgressCheckerTest.java
示例5: updateExistingLoadBalancer
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
private Boolean updateExistingLoadBalancer(Cluster cluster) {
Boolean isUpdated=false;
LoadBalancerInfo loadBalancerInfo = clusterIdToLoadBalancerMap.get(cluster.getClusterId());
String loadBalancerName = loadBalancerInfo.getName();
String region = loadBalancerInfo.getRegion();
// Get all the instances attached - Attach newly added instances to load balancer
// attachedInstances list is useful in finding out what are the new instances which
// should be attached to this load balancer.
List<Instance> attachedInstances = awsHelper.getAttachedInstances(loadBalancerName, region);
// clusterMembers stores all the members of a cluster.
Collection<Member> clusterMembers = cluster.getMembers();
isUpdated= addClusterMembersInfo(clusterMembers, loadBalancerName, region);
return isUpdated;
}
开发者ID:apache,项目名称:stratos,代码行数:21,代码来源:AWSLoadBalancer.java
示例6: deregisterInstancesFromLoadBalancer
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
/**
* Detaches provided instances from the load balancer, associated with some
* cluster. Useful when instances are removed from the cluster with which
* this load balancer is associated.
*
* @param loadBalancerName
* @param instances to be de-registered from load balancer
* @param region of the load balancer
*/
public void deregisterInstancesFromLoadBalancer(String loadBalancerName, List<Instance> instances, String region) {
log.info("De-registering following instance(s) from load balancer "
+ loadBalancerName);
for (Instance instance : instances) {
log.info(instance.getInstanceId());
}
DeregisterInstancesFromLoadBalancerRequest deregisterInstancesFromLoadBalancerRequest = new DeregisterInstancesFromLoadBalancerRequest(
loadBalancerName, instances);
try {
elbClient.setEndpoint(String.format(
Constants.ELB_ENDPOINT_URL_FORMAT, region));
elbClient
.deregisterInstancesFromLoadBalancer(deregisterInstancesFromLoadBalancerRequest);
} catch (AmazonClientException e) {
log.error("Could not de-register instances from load balancer "
+ loadBalancerName, e);
}
}
开发者ID:apache,项目名称:stratos,代码行数:34,代码来源:AWSHelper.java
示例7: getAttachedInstances
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
/**
* Returns instances attached to the load balancer. Useful when deciding if
* all attached instances are required or some should be detached.
*
* @param loadBalancerName
* @param region
* @return list of instances attached
*/
public List<Instance> getAttachedInstances(String loadBalancerName,
String region) {
try {
LoadBalancerDescription lbDescription = getLoadBalancerDescription(loadBalancerName, region);
if (lbDescription == null) {
log.warn("Could not find description of load balancer "+ loadBalancerName);
return null;
}
return lbDescription.getInstances();
} catch (AmazonClientException e) {
log.error("Could not find instances attached load balancer "+ loadBalancerName, e);
}
return null;
}
开发者ID:apache,项目名称:stratos,代码行数:27,代码来源:AWSHelper.java
示例8: getAllInstancesMatchingType
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
@Override
public List<Instance> getAllInstancesMatchingType(SearchCriteria criteria, String typeTag) throws CfnAssistException {
Collection<String> instancesIds = getAllInstancesFor(criteria);
List<Instance> instances = new LinkedList<Instance>();
for (String id : instancesIds) {
if (instanceHasCorrectType(typeTag, id)) {
logger.info(String.format("Adding instance %s as it matched %s %s",id, AwsFacade.TYPE_TAG, typeTag));
instances.add(new Instance(id));
} else {
logger.info(String.format("Not adding instance %s as did not match %s %s",id, AwsFacade.TYPE_TAG, typeTag));
}
}
logger.info(String.format("Found %s instances matching %s and type: %s", instances.size(), criteria, typeTag));
return instances;
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:17,代码来源:CfnRepository.java
示例9: addInstancesThatMatchBuildAndType
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
private List<Instance> addInstancesThatMatchBuildAndType(ProjectAndEnv projAndEnv, String typeTag) throws CfnAssistException {
if (!projAndEnv.hasBuildNumber()) {
throw new MustHaveBuildNumber();
}
LoadBalancerDescription elb = findELBFor(projAndEnv, typeTag);
List<Instance> currentInstances = elb.getInstances();
String lbName = elb.getLoadBalancerName();
SearchCriteria criteria = new SearchCriteria(projAndEnv);
List<Instance> allMatchingInstances = cfnRepository.getAllInstancesMatchingType(criteria, typeTag);
List<Instance> instancesToAdd = filterBy(currentInstances, allMatchingInstances);
if (allMatchingInstances.size()==0) {
logger.warn(String.format("No instances matched %s and type tag %s (%s)", projAndEnv, typeTag, AwsFacade.TYPE_TAG));
} else {
logger.info(String.format("Regsister matching %s instances with the LB %s ", instancesToAdd.size(),lbName));
elbClient.registerInstances(instancesToAdd, lbName);
}
return instancesToAdd;
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:20,代码来源:ELBRepository.java
示例10: removeInstancesNotMatching
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
private List<Instance> removeInstancesNotMatching(ProjectAndEnv projAndEnv, List<Instance> matchingInstances, String typeTag) throws MustHaveBuildNumber, TooManyELBException {
LoadBalancerDescription elb = findELBFor(projAndEnv, typeTag);
logger.info("Checking if instances should be removed from ELB " + elb.getLoadBalancerName());
List<Instance> currentInstances = elb.getInstances();
List<Instance> toRemove = new LinkedList<Instance>();
for(Instance current : currentInstances) {
String instanceId = current.getInstanceId();
if (matchingInstances.contains(current)) {
logger.info("Instance matched project/env/build/type, will not be removed " + instanceId);
} else {
logger.info("Instance did not match, will be removed from ELB " +instanceId);
toRemove.add(new Instance(instanceId));
}
}
if (toRemove.isEmpty()) {
logger.info("No instances to remove from ELB " + elb.getLoadBalancerName());
return new LinkedList<Instance>();
}
return removeInstances(elb,toRemove);
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:23,代码来源:ELBRepository.java
示例11: shouldGetInstancesForTheLB
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
@Test
public void shouldGetInstancesForTheLB() throws TooManyELBException {
String vpcId = "myVPC";
Instance insA = new Instance().withInstanceId("instanceA"); // associated
List<LoadBalancerDescription> theLB = new LinkedList<>();
theLB.add(new LoadBalancerDescription().withVPCId(vpcId).
withInstances(insA).
withLoadBalancerName("lbName").withDNSName("dnsName"));
EasyMock.expect(vpcRepository.getCopyOfVpc(projAndEnv)).andStubReturn(new Vpc().withVpcId(vpcId));
EasyMock.expect(elbClient.describeLoadBalancers()).andReturn(theLB);
replayAll();
List<Instance> result = elbRepository.findInstancesAssociatedWithLB(projAndEnv,"typeNotUsedWhenOneMatchingLB");
verifyAll();
assertEquals(1, result.size());
assertEquals("instanceA", result.get(0).getInstanceId());
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:21,代码来源:TestELBRepository.java
示例12: attemptRemoveAgent
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
public AgentCheckInResponse attemptRemoveAgent(BaragonAgentMetadata agent, Optional<BaragonGroup> group, String groupName, boolean isStatusCheck) throws AmazonClientException {
TrafficSourceState state = TrafficSourceState.DONE;
long maxWaitTime = 0L;
Optional<String> maybeExceptions = Optional.absent();
if (isElbEnabledAgent(agent, group, groupName)) {
for (TrafficSource source : group.get().getTrafficSources()) {
Instance instance = new Instance(agent.getEc2().getInstanceId().get());
AgentCheckInResponse response = isStatusCheck ?
getLoadBalancer(source.getType()).checkRemovedInstance(instance, source.getName(), agent.getAgentId()) :
getLoadBalancer(source.getType()).removeInstance(instance, source.getName(), agent.getAgentId());
if (response.getState().ordinal() > state.ordinal()) {
state = response.getState();
}
if (response.getExceptionMessage().isPresent()) {
maybeExceptions = Optional.of(maybeExceptions.or("") + response.getExceptionMessage().get() + "\n");
}
if (response.getWaitTime() > maxWaitTime) {
maxWaitTime = response.getWaitTime();
}
}
}
return new AgentCheckInResponse(state, maybeExceptions, maxWaitTime);
}
开发者ID:HubSpot,项目名称:Baragon,代码行数:25,代码来源:ElbManager.java
示例13: attemptAddAgent
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
public AgentCheckInResponse attemptAddAgent(BaragonAgentMetadata agent, Optional<BaragonGroup> group, String groupName, boolean isStatusCheck) throws AmazonClientException, NoMatchingElbForVpcException {
TrafficSourceState state = TrafficSourceState.DONE;
Optional<String> maybeVpcException = Optional.absent();
long maxWaitTime = 0L;
if (isElbEnabledAgent(agent, group, groupName)) {
for (TrafficSource source : group.get().getTrafficSources()) {
Instance instance = new Instance(agent.getEc2().getInstanceId().get());
AgentCheckInResponse response = isStatusCheck ?
getLoadBalancer(source.getType()).checkRegisteredInstance(instance, source.getName(), agent) :
getLoadBalancer(source.getType()).registerInstance(instance, source.getName(), agent);
if (response.getExceptionMessage().isPresent()) {
maybeVpcException = Optional.of(maybeVpcException.or("") + response.getExceptionMessage().get() + "\n");
}
if (response.getState().ordinal() > state.ordinal()) {
state = response.getState();
}
if (response.getWaitTime() > maxWaitTime) {
maxWaitTime = response.getWaitTime();
}
}
if (maybeVpcException.isPresent() && configuration.get().isFailWhenNoElbForVpc()) {
throw new NoMatchingElbForVpcException(maybeVpcException.get());
}
}
return new AgentCheckInResponse(state, maybeVpcException, maxWaitTime);
}
开发者ID:HubSpot,项目名称:Baragon,代码行数:27,代码来源:ElbManager.java
示例14: registerInstance
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
public AgentCheckInResponse registerInstance(Instance instance, String elbName, BaragonAgentMetadata agent) {
Optional<String> maybeException = Optional.absent();
Optional<LoadBalancerDescription> elb = getElb(elbName);
if (elb.isPresent()) {
if (isVpcOk(agent, elb.get())) {
if (!elb.get().getInstances().contains(instance)) {
checkAZEnabled(agent, elbName, elb.get());
RegisterInstancesWithLoadBalancerRequest request = new RegisterInstancesWithLoadBalancerRequest(elbName, Arrays.asList(instance));
elbClient.registerInstancesWithLoadBalancer(request);
LOG.info("Registered instances {} with ELB {}", request.getInstances(), request.getLoadBalancerName());
} else {
LOG.debug("Agent {} already registered with ELB {}", agent.getAgentId(), elbName);
}
} else {
maybeException = Optional.of(String.format("No ELB found for vpc %s", agent.getEc2().getVpcId()));
}
}
return new AgentCheckInResponse(TrafficSourceState.DONE, maybeException, 0L);
}
开发者ID:HubSpot,项目名称:Baragon,代码行数:20,代码来源:ClassicLoadBalancer.java
示例15: shouldRegister
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
private boolean shouldRegister(BaragonAgentMetadata agent, String elbName, List<LoadBalancerDescription> elbs) {
Optional<LoadBalancerDescription> matchingElb = Optional.absent();
for (LoadBalancerDescription elb : elbs) {
if (elbName.equals(elb.getLoadBalancerName())) {
matchingElb = Optional.of(elb);
}
}
if (!matchingElb.isPresent()) {
return false;
}
boolean alreadyRegistered = false;
for (Instance instance : matchingElb.get().getInstances()) {
if (agent.getEc2().getInstanceId().get().equals(instance.getInstanceId())) {
alreadyRegistered = true;
}
}
return !alreadyRegistered && (isVpcOk(agent, matchingElb.get()) || !configuration.get().isCheckForCorrectVpc());
}
开发者ID:HubSpot,项目名称:Baragon,代码行数:21,代码来源:ClassicLoadBalancer.java
示例16: deregisterRequests
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
private List<DeregisterInstancesFromLoadBalancerRequest> deregisterRequests(BaragonGroup group, Collection<BaragonAgentMetadata> agents, List<LoadBalancerDescription> elbs) {
List<String> agentInstanceIds = agentInstanceIds(agents);
List<DeregisterInstancesFromLoadBalancerRequest> requests = new ArrayList<>();
for (LoadBalancerDescription elb : elbs) {
if (group.getTrafficSources().contains(new TrafficSource(elb.getLoadBalancerName(), TrafficSourceType.CLASSIC))) {
for (Instance instance : elb.getInstances()) {
if (!agentInstanceIds.contains(instance.getInstanceId()) && canDeregisterAgent(group, instance.getInstanceId())) {
List<Instance> instanceList = new ArrayList<>(1);
instanceList.add(instance);
requests.add(new DeregisterInstancesFromLoadBalancerRequest(elb.getLoadBalancerName(), instanceList));
LOG.info("Will deregister instance {} from ELB {}", instance.getInstanceId(), elb.getLoadBalancerName());
}
}
}
}
return requests;
}
开发者ID:HubSpot,项目名称:Baragon,代码行数:18,代码来源:ClassicLoadBalancer.java
示例17: describeInstanceHealth
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
/**
* Checks the instance health of the ec2 instance in the given ELB.
*/
public InstanceState describeInstanceHealth(String elbName, String ec2InstanceId)
{
LOGGER.debug("describeInstanceHealth(elbName: " + elbName + ", ec2InstanceId: " + ec2InstanceId + ")");
assertNonBlankArgs(elbName, ec2InstanceId);
StopWatch stopWatch = new StopWatch();
try
{
stopWatch.start();
DescribeInstanceHealthRequest request = new DescribeInstanceHealthRequest();
request.setLoadBalancerName(elbName);
request.setInstances(Arrays.asList(new Instance(ec2InstanceId)));
DescribeInstanceHealthResult result = awsElbClient.describeInstanceHealth(request);
if (result == null || CollectionUtils.isEmpty(result.getInstanceStates()))
{
throw new RuntimeException("ELB '" + elbName + "' didn't match instance id '" + ec2InstanceId + "'");
}
else if (result.getInstanceStates().size() > 1)
{
LOGGER.warn("Expected 1 instance state for instance id '" + ec2InstanceId + "' in elb '" + elbName + "', found "
+ result.getInstanceStates().size());
}
return result.getInstanceStates().get(0);
}
finally
{
stopWatch.stop();
LOGGER.debug("describeInstanceHealth time elapsed " + stopWatch);
}
}
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:33,代码来源:ElbClient.java
示例18: assignInstances
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
private DeferredResult<AWSLoadBalancerContext> assignInstances(AWSLoadBalancerContext context) {
// If the registered instances are null this is a newly provisioned load balancer
// so add all instances from the load balancer state to the registration request
if (context.registeredInstances == null) {
context.instanceIdsToRegister = context.loadBalancerStateExpanded.computes.stream()
.map(computeState -> computeState.id)
.collect(Collectors.toList());
context.instanceIdsToDeregister = Collections.emptyList();
} else {
context.instanceIdsToRegister = context.loadBalancerStateExpanded.computes.stream()
.map(computeState -> computeState.id)
.filter(csId -> context.registeredInstances.stream()
.noneMatch(i -> i.getInstanceId().equals(csId))
)
.collect(Collectors.toList());
context.instanceIdsToDeregister = context.registeredInstances.stream()
.map(Instance::getInstanceId)
.filter(instanceId -> context.loadBalancerStateExpanded.computes.stream()
.noneMatch(computeState -> computeState.id.equals(instanceId))
)
.collect(Collectors.toList());
}
return DeferredResult.completed(context)
.thenCompose(this::registerInstances)
.thenCompose(this::deregisterInstances);
}
开发者ID:vmware,项目名称:photon-model,代码行数:31,代码来源:AWSLoadBalancerService.java
示例19: buildInstanceRegistrationRequest
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
private RegisterInstancesWithLoadBalancerRequest buildInstanceRegistrationRequest(
AWSLoadBalancerContext context) {
return new RegisterInstancesWithLoadBalancerRequest()
.withLoadBalancerName(context.loadBalancerStateExpanded.name)
.withInstances(context.instanceIdsToRegister.stream()
.map(Instance::new)
.collect(Collectors.toList())
);
}
开发者ID:vmware,项目名称:photon-model,代码行数:11,代码来源:AWSLoadBalancerService.java
示例20: buildInstanceDeregistrationRequest
import com.amazonaws.services.elasticloadbalancing.model.Instance; //导入依赖的package包/类
private DeregisterInstancesFromLoadBalancerRequest buildInstanceDeregistrationRequest(
AWSLoadBalancerContext context) {
return new DeregisterInstancesFromLoadBalancerRequest()
.withLoadBalancerName(context.loadBalancerStateExpanded.name)
.withInstances(context.instanceIdsToDeregister.stream()
.map(Instance::new)
.collect(Collectors.toList())
);
}
开发者ID:vmware,项目名称:photon-model,代码行数:11,代码来源:AWSLoadBalancerService.java
注:本文中的com.amazonaws.services.elasticloadbalancing.model.Instance类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论