当前位置: 首页>>代码示例>>Java>>正文


Java NodeMetadata类代码示例

本文整理汇总了Java中org.jclouds.compute.domain.NodeMetadata的典型用法代码示例。如果您正苦于以下问题:Java NodeMetadata类的具体用法?Java NodeMetadata怎么用?Java NodeMetadata使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NodeMetadata类属于org.jclouds.compute.domain包,在下文中一共展示了NodeMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: waitForState

import org.jclouds.compute.domain.NodeMetadata; //导入依赖的package包/类
protected final boolean waitForState(NodeMetadata.Status targetStatus, long timeoutInSeconds) {
    Objects.requireNonNull(targetStatus, "targetStatus");
    LOGGER.debug("Waiting for status '{}' on node '{}' (timeout {}s)", targetStatus.name(), getName(), timeoutInSeconds);
    long endTime = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(timeoutInSeconds);
    while (System.currentTimeMillis() < endTime) {
        NodeMetadata.Status status = getFreshNodeMetadata().getStatus();
        if (status != null && status.equals(targetStatus)) {
            LOGGER.debug("Node '{}' is in status '{}'", getName(), targetStatus.name());
            return true;
        } else if (!NodeMetadata.Status.ERROR.equals(targetStatus) && NodeMetadata.Status.ERROR.equals(status)) {
            // fail fast
            throw new IllegalStateException("Node '" + getName() + "' is in unexpected ERROR state.");
        }

        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            LOGGER.warn("Interrupted while waiting for node '{}' to reach state '{}'", getName(), targetStatus.name(), e);
            Thread.currentThread().interrupt();
            break;
        }
    }

    LOGGER.warn("Node '{}' didn't reach status '{}' in given time ({}s)", getName(), targetStatus.name(), timeoutInSeconds);
    return false;
}
 
开发者ID:wildfly-extras,项目名称:sunstone,代码行数:27,代码来源:AbstractJCloudsNode.java

示例2: test

import org.jclouds.compute.domain.NodeMetadata; //导入依赖的package包/类
@Test
public void test() {
    CloudProperties.getInstance().reset().load(this.getClass());
    try (DockerCloudProvider cloudProvider = (DockerCloudProvider) CloudProvider.create("provider0")) {
        final ComputeService computeService = cloudProvider.getComputeServiceContext().getComputeService();
        assertTrue("No node-group should be 'node-leak-test' before test", computeService.listNodes().stream()
                .noneMatch(cm -> "node-leak-test".equals(((NodeMetadata) cm).getGroup())));
        try {
            cloudProvider.createNode("node0").close();
            Assert.fail("Port 2468 was unexpectedly opened");
        } catch (PortOpeningException e) {
            assertTrue("No node-group should be 'node-leak-test' after test", computeService.listNodes().stream()
                    .noneMatch(cm -> "node-leak-test".equals(((NodeMetadata) cm).getGroup())));
        }
    }
}
 
开发者ID:wildfly-extras,项目名称:sunstone,代码行数:17,代码来源:NodeLeakOnBadPortsTest.java

示例3: listNodesByIds

import org.jclouds.compute.domain.NodeMetadata; //导入依赖的package包/类
@Override
public Iterable<NodeMetadata> listNodesByIds(Iterable<String> ids) {
   List<Instance> instances = new ArrayList<Instance>();
   for (String id : ids) {
      IAcsClient client = api.getAcsClient(api.decodeToRegion(id));
      DescribeInstancesRequest req = new DescribeInstancesRequest();
      Gson gson = new GsonBuilder().create();
      String iids = gson.toJson(new String[] { api.decodeToId(id) });
      req.setInstanceIds(iids);
      try {
         DescribeInstancesResponse resp = client.getAcsResponse(req);
         instances.addAll(resp.getInstances());
      } catch (Exception e) {
         logger.warn(e.getMessage());
      }
   }
   Builder<NodeMetadata> builder = ImmutableSet.builder();
   builder.addAll(transform(instances, new InstanceToNodeMetadata(api, nodeStatus)));
   return builder.build();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:21,代码来源:ECSComputeServiceAdapter.java

示例4: listNodes

import org.jclouds.compute.domain.NodeMetadata; //导入依赖的package包/类
@Override
public Iterable<NodeMetadata> listNodes() {
   Builder<NodeMetadata> builder = ImmutableSet.builder();
   Set<String> regions = api.getAvailableRegions();
   for (String region : regions) {
      try {
         IAcsClient client = api.getAcsClient(region);
         DescribeInstancesRequest req = new DescribeInstancesRequest();
         DescribeInstancesResponse resp = client.getAcsResponse(req);
         builder.addAll(transform(resp.getInstances(), new InstanceToNodeMetadata(api, nodeStatus)));
      } catch (Exception e) {
         logger.warn(e.getMessage());
      }
   }
   return builder.build();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:17,代码来源:ECSComputeServiceAdapter.java

示例5: getNode

import org.jclouds.compute.domain.NodeMetadata; //导入依赖的package包/类
@Override
public NodeMetadata getNode(String id) {
   NodeMetadata nodeMetadata = null;
   IAcsClient client = api.getAcsClient(api.decodeToRegion(id));
   DescribeInstancesRequest req = new DescribeInstancesRequest();
   Gson gson = new GsonBuilder().create();
   String ids = gson.toJson(new String[] { api.decodeToId(id) });
   req.setInstanceIds(ids);
   try {
      DescribeInstancesResponse resp = client.getAcsResponse(req);
      if (resp.getTotalCount() > 0) {
         Iterator<NodeMetadata> it = transform(resp.getInstances(), new InstanceToNodeMetadata(api, nodeStatus)).iterator();
         if (it.hasNext()) {
            nodeMetadata = it.next();
         }
      }
   } catch (Exception e) {
      logger.warn(e.getMessage());
   }
   return nodeMetadata;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:22,代码来源:ECSComputeServiceAdapter.java

示例6: apply

import org.jclouds.compute.domain.NodeMetadata; //导入依赖的package包/类
@Override
public NodeMetadata apply(Instance input) {
   NodeMetadataBuilder builder = new NodeMetadataBuilder();
   builder.id(api.encodeToId(input.getRegionId(), input.getInstanceId()));
   builder.providerId(input.getInstanceId());
   builder.name(input.getInstanceName());
   builder.group(input.getRegionId());
   builder.status(status.get(input.getStatus()));
   builder.imageId(input.getImageId());
   Hardware hardware = new HardwareBuilder()
         .id(input.getInstanceType())
         .build();
   builder.hardware(hardware);
   Location location = new LocationBuilder()
         .scope(LocationScope.REGION)
         .id(input.getRegionId())
         .description(input.getRegionId())
         .build();
   builder.location(location);
   builder.publicAddresses(input.getPublicIpAddress());
   builder.privateAddresses(input.getInnerIpAddress());
   return builder.build();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:24,代码来源:InstanceToNodeMetadata.java

示例7: createLoadBalancerInLocation

import org.jclouds.compute.domain.NodeMetadata; //导入依赖的package包/类
@Override
public LoadBalancerMetadata createLoadBalancerInLocation(
      Location location,
      String name,
      String protocol,
      int loadBalancerPort,
      int instancePort,
      Iterable<? extends NodeMetadata> nodes) {
   IAcsClient client = api.getAcsClient(location.getId());
   LoadBalancerMetadata lbm = adapter
         .createLoadBalancerInLocation(location, name, protocol, loadBalancerPort, instancePort, nodes);
   String loadBalancerId = lbm.getId();
   if (SLBLoadBalancerProtocol.HTTP.name().equalsIgnoreCase(protocol)) {
      this.createLoadBalancerHTTPListener(client, loadBalancerId, loadBalancerPort, instancePort);
   } else if (SLBLoadBalancerProtocol.HTTPS.name().equals(protocol)) {
      this.createLoadBalancerHTTPSListener(client, loadBalancerId, loadBalancerPort, instancePort);
   } else if (SLBLoadBalancerProtocol.TCP.name().equals(protocol)) {
      this.createLoadBalancerTCPListener(client, loadBalancerId, loadBalancerPort, instancePort);
   } else if (SLBLoadBalancerProtocol.UDP.name().equals(protocol)) {
      this.createLoadBalancerUDPListener(client, loadBalancerId, loadBalancerPort, instancePort);
   } else {
      logger.warn("unrecognized protocol");
   }
   this.addBackendServers(client, loadBalancerId, nodes);
   return lbm;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:27,代码来源:SLBLoadBalanceNodesStrategy.java

示例8: beforeClass

import org.jclouds.compute.domain.NodeMetadata; //导入依赖的package包/类
@BeforeClass
public void beforeClass() {
   LocationBuilder location = new LocationBuilder()
         .scope(LocationScope.REGION)
         .id(testRegion)
         .description(testRegion);
   Set<NodeMetadata> nodes = ImmutableSet.<NodeMetadata> builder()
         .add(new NodeMetadataBuilder()
               .status(Status.RUNNING)
               .id("cn-hangzhou:i-233ehfkdv")
               .build())
         .build();
   lbm = loadBalancerService
         .createLoadBalancerInLocation(
               location.build(),
               testLoadBalancer,
               "http", 80, 80, nodes);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:19,代码来源:SLBTest.java

示例9: DimensionDataCloudControllerComputeService

import org.jclouds.compute.domain.NodeMetadata; //导入依赖的package包/类
@Inject
protected DimensionDataCloudControllerComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
                                                     @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
                                                     @Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
                                                     GetImageStrategy getImageStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy,
                                                     CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy,
                                                     DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy,
                                                     SuspendNodeStrategy stopNodeStrategy, Provider<TemplateBuilder> templateBuilderProvider,
                                                     @Named("DEFAULT") Provider<TemplateOptions> templateOptionsProvider,
                                                     @Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
                                                     @Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
                                                     @Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
                                                     InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
                                                     RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
                                                     PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
                                                     @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
                                                     CleanupServer cleanupServer,
                                                     Optional<ImageExtension> imageExtension,
                                                     Optional<SecurityGroupExtension> securityGroupExtension) {
   super(context, credentialStore, images, sizes, locations, listNodesStrategy, getImageStrategy,
            getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
            startNodeStrategy, stopNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning,
            nodeTerminated, nodeSuspended, initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory,
            persistNodeCredentials, timeouts, userExecutor, imageExtension, securityGroupExtension);
   this.cleanupServer = checkNotNull(cleanupServer, "cleanupServer");
}
 
开发者ID:cloudsoft,项目名称:amp-dimensiondata,代码行数:27,代码来源:DimensionDataCloudControllerComputeService.java

示例10: configure

import org.jclouds.compute.domain.NodeMetadata; //导入依赖的package包/类
@Override
protected void configure() {
    super.configure();
    bind(new TypeLiteral<ComputeServiceAdapter<ServerWithExternalIp, OsImage, OsImage, Datacenter>>() {
    }).to(DimensionDataCloudControllerComputeServiceAdapter.class);
    bind(ComputeService.class).to(DimensionDataCloudControllerComputeService.class);

    bind(new TypeLiteral<Function<ServerWithExternalIp, NodeMetadata>>() {
    }).to(ServerWithNatRuleToNodeMetadata.class);
    bind(new TypeLiteral<Function<OsImage, Image>>() {
    }).to(OsImageToImage.class);
    bind(new TypeLiteral<Function<OsImage, Hardware>>() {
    }).to(OsImageToHardware.class);
    bind(new TypeLiteral<Function<Datacenter, Location>>() {
    }).to(DatacenterToLocation.class);
    bind(TemplateOptions.class).to(DimensionDataCloudControllerTemplateOptions.class);
    bind(CreateNodesInGroupThenAddToSet.class).to(GetOrCreateNetworkDomainThenCreateNodes.class);
    bind(PrioritizeCredentialsFromTemplate.class).to(UseNodeCredentialsButOverrideFromTemplate.class);

    // to have the compute service adapter override default locations
    install(new LocationsFromComputeServiceAdapterModule<ServerWithExternalIp, OsImage, OsImage, Datacenter>() {
    });
}
 
开发者ID:cloudsoft,项目名称:amp-dimensiondata,代码行数:24,代码来源:DimensionDataCloudControllerComputeServiceContextModule.java

示例11: execute

import org.jclouds.compute.domain.NodeMetadata; //导入依赖的package包/类
@Override
public Map<?, ListenableFuture<Void>> execute(
        final String group, final int count, final Template template,
        final Set<NodeMetadata> goodNodes, final Map<NodeMetadata, Exception> badNodes,
        final Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {

    final DimensionDataCloudControllerTemplateOptions templateOptions = template.getOptions().as(DimensionDataCloudControllerTemplateOptions.class);

    String networkDomainName = firstNonNull(templateOptions.getNetworkDomainName(), DEFAULT_NETWORK_DOMAIN_NAME);
    String vlanName = firstNonNull(templateOptions.getVlanName(), DEFAULT_VLAN_NAME);
    String defaultPrivateIPv4BaseAddress = firstNonNull(templateOptions.getDefaultPrivateIPv4BaseAddress(), DEFAULT_PRIVATE_IPV4_BASE_ADDRESS);
    Integer defaultPrivateIPv4PrefixSize = firstNonNull(templateOptions.getDefaultPrivateIPv4PrefixSize(), DEFAULT_PRIVATE_IPV4_PREFIX_SIZE);
    String location = template.getLocation().getId();

    // If networkDomain and vlanId overrides are supplied in TemplateOptions, always prefer those.
    if (templateOptions.getNetworkDomainId() == null && templateOptions.getVlanId() == null) {
        String networkDomainId = tryCreateOrGetExistingNetworkDomain(api, location, networkDomainName);
        templateOptions.networkDomainId(networkDomainId);
        String vlanId = tryCreateOrGetExistingVlan(api, templateOptions.getNetworkDomainId(), vlanName, defaultPrivateIPv4BaseAddress, defaultPrivateIPv4PrefixSize);
        templateOptions.vlanId(vlanId);
    }
    return super.execute(group, count, template, goodNodes, badNodes, customizationResponses);
}
 
开发者ID:cloudsoft,项目名称:amp-dimensiondata,代码行数:24,代码来源:GetOrCreateNetworkDomainThenCreateNodes.java

示例12: discoverNodes

import org.jclouds.compute.domain.NodeMetadata; //导入依赖的package包/类
@Override
public Iterable<DiscoveryNode> discoverNodes() {
    List<DiscoveryNode> discoveryNodes = new ArrayList<DiscoveryNode>();
    try {
        Iterable<? extends NodeMetadata> nodes = computeServiceBuilder.getFilteredNodes();
        for (NodeMetadata metadata : nodes) {
            if (metadata.getStatus() != NodeMetadata.Status.RUNNING) {
                continue;
            }
            discoveryNodes.add(buildDiscoveredNode(metadata));
        }
        if (discoveryNodes.isEmpty()) {
            LOGGER.warning("No running nodes discovered in configured cloud provider.");
        } else {
            StringBuilder sb = new StringBuilder("Discovered the following nodes with public IPS:\n");
            for (DiscoveryNode node : discoveryNodes) {
                sb.append("    ").append(node.getPublicAddress().toString()).append("\n");
            }
            LOGGER.finest(sb.toString());
        }
    } catch (Exception e) {
        throw new HazelcastException("Failed to get registered addresses", e);
    }
    return discoveryNodes;
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:26,代码来源:JCloudsDiscoveryStrategy.java

示例13: getFilteredNodes

import org.jclouds.compute.domain.NodeMetadata; //导入依赖的package包/类
/**
 * Gets filtered nodes.
 *
 * @return the filtered nodes
 */
public Iterable<? extends NodeMetadata> getFilteredNodes() {
    final String group = getOrNull(JCloudsProperties.GROUP);
    Set<? extends NodeMetadata> result = computeService.listNodesDetailsMatching(nodesFilter);
    Iterable<? extends NodeMetadata> filteredResult = new HashSet<NodeMetadata>();
    for (NodeMetadata metadata : result) {
        if (group != null && !group.equals(metadata.getGroup())) {
            continue;
        }
        if (!isNodeInsideZones(metadata) || !isNodeInsideRegions(metadata)) {
            continue;
        }
        ((HashSet<NodeMetadata>) filteredResult).add(metadata);
    }
    return filteredResult;
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:21,代码来源:ComputeServiceBuilder.java

示例14: test_buildNodeFilter_with_NodeMetadata_with_multiple_tags

import org.jclouds.compute.domain.NodeMetadata; //导入依赖的package包/类
@Test
public void test_buildNodeFilter_with_NodeMetadata_with_multiple_tags() {
    Map<String, Comparable> properties = new HashMap<String, Comparable>();
    properties.put("tag-keys", "tag1,tag2");
    properties.put("tag-values", "value1,value2");
    ComputeServiceBuilder builder = new ComputeServiceBuilder(properties);
    builder.buildTagConfig();
    Predicate<ComputeMetadata> nodeFilter = builder.buildNodeFilter();

    Map<String, String> userMetaData = new HashMap<String, String>();
    userMetaData.put("tag1", "value1");

    NodeMetadata metadata = new NodeMetadataBuilder()
            .userMetadata(userMetaData)
            .id(newSecureUuidString())
            .status(NodeMetadata.Status.RUNNING)
            .build();

    assertFalse(nodeFilter.apply(metadata));
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:21,代码来源:ComputeServiceBuilderTest.java

示例15: test_buildNodeFilter_with_NodeMetadata_with_single_tag

import org.jclouds.compute.domain.NodeMetadata; //导入依赖的package包/类
@Test
public void test_buildNodeFilter_with_NodeMetadata_with_single_tag() {
    Map<String, Comparable> properties = new HashMap<String, Comparable>();
    properties.put("tag-keys", "tag1");
    properties.put("tag-values", "value1");
    ComputeServiceBuilder builder = new ComputeServiceBuilder(properties);
    builder.buildTagConfig();
    Predicate<ComputeMetadata> nodeFilter = builder.buildNodeFilter();

    Map<String, String> userMetaData = new HashMap<String, String>();
    userMetaData.put("tag1", "value2");

    NodeMetadata metadata = new NodeMetadataBuilder()
            .userMetadata(userMetaData)
            .id(newSecureUuidString())
            .status(NodeMetadata.Status.RUNNING)
            .build();

    assertFalse(nodeFilter.apply(metadata));
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:21,代码来源:ComputeServiceBuilderTest.java


注:本文中的org.jclouds.compute.domain.NodeMetadata类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。