當前位置: 首頁>>代碼示例>>Java>>正文


Java ContextBuilder.endpoint方法代碼示例

本文整理匯總了Java中org.jclouds.ContextBuilder.endpoint方法的典型用法代碼示例。如果您正苦於以下問題:Java ContextBuilder.endpoint方法的具體用法?Java ContextBuilder.endpoint怎麽用?Java ContextBuilder.endpoint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jclouds.ContextBuilder的用法示例。


在下文中一共展示了ContextBuilder.endpoint方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: withCompute

import org.jclouds.ContextBuilder; //導入方法依賴的package包/類
private <T> T withCompute(ComputeTask<T> task) throws HekateException {
    ContextBuilder builder = ContextBuilder.newBuilder(provider)
        .credentialsSupplier(credentials::get)
        .modules(ImmutableSet.<Module>of(new SLF4JLoggingModule()));

    if (!properties.isEmpty()) {
        builder.overrides(properties);
    }

    if (endpoint != null && !endpoint.trim().isEmpty()) {
        builder.endpoint(endpoint.trim());
    }

    try (ComputeServiceContext ctx = builder.buildView(ComputeServiceContext.class)) {
        return task.execute(ctx);
    }
}
 
開發者ID:hekate-io,項目名稱:hekate,代碼行數:18,代碼來源:CloudSeedNodeProvider.java

示例2: createContextBuilder

import org.jclouds.ContextBuilder; //導入方法依賴的package包/類
private static ContextBuilder createContextBuilder(ObjectProperties objectProperties) {
    Set<Module> modules = new HashSet<>();
    modules.add(new DynamicSshClientModule());
    modules.add(new SocketFinderOnlyPublicInterfacesModule());
    modules.add(new SLF4JLoggingModule());

    Properties overrides = new Properties();
    overrides.setProperty("jclouds.ssh.retry-auth", Boolean.FALSE.toString());
    overrides.setProperty("jclouds.ssh.max-retries", Integer.toString(1));

    ContextBuilder contextBuilder = ContextBuilder.newBuilder("openstack-nova");
    String endpoint = objectProperties.getProperty(Config.CloudProvider.Openstack.ENDPOINT);
    if (!Strings.isNullOrEmpty(endpoint)) {
        contextBuilder.endpoint(endpoint);
    }
    contextBuilder
            .credentials(
                    objectProperties.getProperty(Config.CloudProvider.Openstack.USERNAME),
                    objectProperties.getProperty(Config.CloudProvider.Openstack.PASSWORD)
            )
            .overrides(overrides)
            .modules(modules);

    return contextBuilder;
}
 
開發者ID:wildfly-extras,項目名稱:sunstone,代碼行數:26,代碼來源:OpenstackCloudProvider.java

示例3: blobStoreContextFromProperties

import org.jclouds.ContextBuilder; //導入方法依賴的package包/類
private static BlobStoreContext blobStoreContextFromProperties(
        Properties properties) {
    String provider = properties.getProperty(Constants.PROPERTY_PROVIDER);
    String identity = properties.getProperty(Constants.PROPERTY_IDENTITY);
    String credential = properties.getProperty(
            Constants.PROPERTY_CREDENTIAL);
    String endpoint = properties.getProperty(Constants.PROPERTY_ENDPOINT);
    if (provider == null || identity == null || credential == null) {
        System.err.println("Properties file must contain:\n" +
                Constants.PROPERTY_PROVIDER + "\n" +
                Constants.PROPERTY_IDENTITY + "\n" +
                Constants.PROPERTY_CREDENTIAL);
        System.exit(1);
    }

    ContextBuilder builder = ContextBuilder
            .newBuilder(provider)
            .credentials(identity, credential)
            .modules(ImmutableList.<Module>of(new SLF4JLoggingModule()))
            .overrides(properties);
    if (endpoint != null) {
        builder = builder.endpoint(endpoint);
    }
    return builder.build(BlobStoreContext.class);
}
 
開發者ID:gaul,項目名稱:are-we-consistent-yet,代碼行數:26,代碼來源:AreWeConsistentYet.java

示例4: createContextBuilder

import org.jclouds.ContextBuilder; //導入方法依賴的package包/類
private static ContextBuilder createContextBuilder(ObjectProperties objectProperties) {
    Properties properties = new Properties();
    final String amiQuery = objectProperties.getProperty(Config.CloudProvider.EC2.AMI_QUERY);
    if (!Strings.isNullOrEmpty(amiQuery)) {
        properties.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, amiQuery);
    }
    final String ec2Regions = objectProperties.getProperty(Config.CloudProvider.EC2.REGION);
    if (!Strings.isNullOrEmpty(ec2Regions)) {
        properties.setProperty(LocationConstants.PROPERTY_REGIONS, ec2Regions);
    }

    Set<Module> modules = new HashSet<>();
    modules.add(new DynamicSshClientModule());
    modules.add(new SocketFinderOnlyPublicInterfacesModule());
    if (Boolean.parseBoolean(objectProperties.getProperty(Config.CloudProvider.EC2.LOG_EC2_OPERATIONS))) {
        // TODO we should add that unconditionally, like we do in all other cloud providers!
        // the reason why we don't [yet] is that the JClouds EC2 provider does some excessive logging,
        // e.g. the names of all available images, and we don't want our users to have to deal with that
        modules.add(new SLF4JLoggingModule());
    }

    final ContextBuilder contextBuilder = ContextBuilder.newBuilder("aws-ec2");
    final String endpoint = objectProperties.getProperty(Config.CloudProvider.EC2.ENDPOINT);
    if (!Strings.isNullOrEmpty(endpoint)) {
        contextBuilder.endpoint(endpoint);
    }
    contextBuilder
            .credentials(
                    objectProperties.getProperty(Config.CloudProvider.EC2.ACCESS_KEY_ID),
                    objectProperties.getProperty(Config.CloudProvider.EC2.SECRET_ACCESS_KEY)
            )
            .overrides(properties).modules(ImmutableSet.copyOf(modules));

    return contextBuilder;
}
 
開發者ID:wildfly-extras,項目名稱:sunstone,代碼行數:36,代碼來源:EC2CloudProvider.java

示例5: build

import org.jclouds.ContextBuilder; //導入方法依賴的package包/類
/**
 * Build compute service.
 *
 * @return the compute service
 */
ComputeService build() {
    final String cloudProvider = getOrNull(JCloudsProperties.PROVIDER);
    final String endpoint = getOrNull(JCloudsProperties.ENDPOINT);
    final String identity = getOrNull(JCloudsProperties.IDENTITY);
    String credential = getOrNull(JCloudsProperties.CREDENTIAL);
    final String credentialPath = getOrNull(JCloudsProperties.CREDENTIAL_PATH);
    isNotNull(cloudProvider, "Cloud Provider");

    if (credential != null && credentialPath != null) {
        throw new UnsupportedOperationException("Both credential and credentialPath are set. Use only one method.");
    }
    if (credentialPath != null) {
        credential = getCredentialFromFile(cloudProvider, credentialPath);
    }

    if (LOGGER.isFinestEnabled()) {
        LOGGER.finest("Using CLOUD_PROVIDER: " + cloudProvider);
    }

    final String roleName = getOrNull(JCloudsProperties.ROLE_NAME);
    ContextBuilder contextBuilder = newContextBuilder(cloudProvider, identity, credential, roleName);
    if (endpoint != null) {
        if (LOGGER.isFinestEnabled()) {
            LOGGER.finest("Using custom endpoint: " + endpoint);
        }
        contextBuilder.endpoint(endpoint);
    }

    Properties jcloudsProperties = buildRegionZonesConfig();
    buildTagConfig();
    buildNodeFilter();

    computeService = contextBuilder.overrides(jcloudsProperties)
            .modules(ImmutableSet.of(new HazelcastLoggingModule()))
            .buildView(ComputeServiceContext.class)
            .getComputeService();

    return computeService;
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jclouds,代碼行數:45,代碼來源:ComputeServiceBuilder.java

示例6: buildContext

import org.jclouds.ContextBuilder; //導入方法依賴的package包/類
private ContextBuilder buildContext() {
  //todo ugly hack
  final Properties properties = new Properties();
  if (regions != null) {
    properties.setProperty("jclouds.regions", regions);
  }
  if (requestTimeout != null) {
    properties.setProperty(org.jclouds.Constants.PROPERTY_REQUEST_TIMEOUT, requestTimeout);
  }

  //todo duplicates code from NovaApiProvider
  // loading ssh module of jclouds as it seems to be required for google,
  // we are using the jschsshclient as the sshj conflicts with the overthere bouncy castle impl.

  Set<Module> moduleSet = new HashSet<>();
  moduleSet.addAll(overrideModules());
  moduleSet.add(new JCloudsLoggingModule(loggerFactory));

  ContextBuilder contextBuilder = ContextBuilder.newBuilder(cloud.api().providerName());
  contextBuilder.credentials(cloud.credential().user(), cloud.credential().password())
      .modules(moduleSet).overrides(overrideProperties(properties));

  // setting optional endpoint, check for present first
  // as builder does not allow null values...
  if (cloud.endpoint().isPresent()) {
    contextBuilder.endpoint(cloud.endpoint().get());
  }

  return contextBuilder;
}
 
開發者ID:cloudiator,項目名稱:sword,代碼行數:31,代碼來源:BaseJCloudsViewFactory.java

示例7: mungeBuilder

import org.jclouds.ContextBuilder; //導入方法依賴的package包/類
@Override
public void mungeBuilder(ContextBuilder builder) {
	builder.endpoint("https://management.core.windows.net/" + getSubscriptionId());
}
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:5,代碼來源:AzureCloudTLCInstanceParameters.java

示例8: main

import org.jclouds.ContextBuilder; //導入方法依賴的package包/類
/**
 * Main method.
 * @param args
 */
public static void main(String[] args) throws Exception {
    if (args.length == 1 && args[0].equals("--version")) {
        System.err.println(
                Main.class.getPackage().getImplementationVersion());
        System.exit(0);
    } else if (args.length != 2) {
        System.err.println("Usage: swiftproxy --properties FILE");
        System.exit(1);
    }

    Properties properties = new Properties();
    try (InputStream is = new FileInputStream(new File(args[1]))) {
        properties.load(is);
    }
    properties.putAll(System.getProperties());

    String provider = properties.getProperty(Constants.PROPERTY_PROVIDER);
    String identity = properties.getProperty(Constants.PROPERTY_IDENTITY);
    String credential = properties.getProperty(Constants.PROPERTY_CREDENTIAL);
    String endpoint = properties.getProperty(Constants.PROPERTY_ENDPOINT);
    String proxyEndpoint = properties.getProperty(SwiftProxy.PROPERTY_ENDPOINT);
    if (provider == null || identity == null || credential == null || proxyEndpoint == null) {
        System.err.format("Properties file must contain:%n" +
                Constants.PROPERTY_PROVIDER + "%n" +
                Constants.PROPERTY_IDENTITY + "%n" +
                Constants.PROPERTY_CREDENTIAL + "%n" +
                SwiftProxy.PROPERTY_ENDPOINT + "%n");
        System.exit(1);
    }

    if (provider.equals("google-cloud-storage")) {
        File credentialFile = new File(credential);
        if (credentialFile.exists()) {
            credential = Files.toString(credentialFile,
                    StandardCharsets.UTF_8);
        }
        properties.remove(Constants.PROPERTY_CREDENTIAL);
    }

    ContextBuilder builder = ContextBuilder
            .newBuilder(provider)
            .credentials(identity, credential)
            .modules(ImmutableList.<Module>of(new SLF4JLoggingModule()))
            .overrides(properties);
    if (endpoint != null) {
        builder = builder.endpoint(endpoint);
    }
    BlobStoreContext context = builder.build(BlobStoreContext.class);

    SwiftProxy proxy = SwiftProxy.Builder.builder()
            .overrides(properties)
            .endpoint(new URI(proxyEndpoint))
            .build();
    proxy.start();
    System.out.format("Swift proxy listening on port %d%n", proxy.getPort());
    Thread.currentThread().join();
}
 
開發者ID:bouncestorage,項目名稱:swiftproxy,代碼行數:62,代碼來源:Main.java

示例9: setUp

import org.jclouds.ContextBuilder; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    Properties s3ProxyProperties = new Properties();
    InputStream is = Resources.asByteSource(Resources.getResource(
            "s3proxy.conf")).openStream();
    try {
        s3ProxyProperties.load(is);
    } finally {
        is.close();
    }

    String provider = s3ProxyProperties.getProperty(
            Constants.PROPERTY_PROVIDER);
    String identity = s3ProxyProperties.getProperty(
            Constants.PROPERTY_IDENTITY);
    String credential = s3ProxyProperties.getProperty(
            Constants.PROPERTY_CREDENTIAL);
    String endpoint = s3ProxyProperties.getProperty(
            Constants.PROPERTY_ENDPOINT);
    String s3Identity = s3ProxyProperties.getProperty(
            S3ProxyConstants.PROPERTY_IDENTITY);
    String s3Credential = s3ProxyProperties.getProperty(
            S3ProxyConstants.PROPERTY_CREDENTIAL);
    awsCreds = new BasicAWSCredentials(s3Identity, s3Credential);
    s3Endpoint = new URI(s3ProxyProperties.getProperty(
            S3ProxyConstants.PROPERTY_ENDPOINT));
    String keyStorePath = s3ProxyProperties.getProperty(
            S3ProxyConstants.PROPERTY_KEYSTORE_PATH);
    String keyStorePassword = s3ProxyProperties.getProperty(
            S3ProxyConstants.PROPERTY_KEYSTORE_PASSWORD);
    String virtualHost = s3ProxyProperties.getProperty(
            S3ProxyConstants.PROPERTY_VIRTUAL_HOST);

    ContextBuilder builder = ContextBuilder
            .newBuilder(provider)
            .credentials(identity, credential)
            .modules(ImmutableList.<Module>of(new SLF4JLoggingModule()))
            .overrides(s3ProxyProperties);
    if (!Strings.isNullOrEmpty(endpoint)) {
        builder.endpoint(endpoint);
    }
    context = builder.build(BlobStoreContext.class);
    BlobStore blobStore = context.getBlobStore();
    containerName = createRandomContainerName();
    key = "stuff";
    blobStore.createContainerInLocation(null, containerName);

    S3Proxy.Builder s3ProxyBuilder = S3Proxy.builder()
            .blobStore(blobStore)
            .endpoint(s3Endpoint);
    if (s3Identity != null || s3Credential != null) {
        s3ProxyBuilder.awsAuthentication(s3Identity, s3Credential);
    }
    if (keyStorePath != null || keyStorePassword != null) {
        s3ProxyBuilder.keyStore(
                Resources.getResource(keyStorePath).toString(),
                keyStorePassword);
    }
    if (virtualHost != null) {
        s3ProxyBuilder.virtualHost(virtualHost);
    }
    s3Proxy = s3ProxyBuilder.build();
    s3Proxy.start();
    while (!s3Proxy.getState().equals(AbstractLifeCycle.STARTED)) {
        Thread.sleep(1);
    }

    // reset endpoint to handle zero port
    s3Endpoint = new URI(s3Endpoint.getScheme(), s3Endpoint.getUserInfo(),
            s3Endpoint.getHost(), s3Proxy.getPort(), s3Endpoint.getPath(),
            s3Endpoint.getQuery(), s3Endpoint.getFragment());
}
 
開發者ID:alexmojaki,項目名稱:s3-stream-upload,代碼行數:73,代碼來源:StreamTransferManagerTest.java

示例10: createBlobStore

import org.jclouds.ContextBuilder; //導入方法依賴的package包/類
private static BlobStore createBlobStore(Properties properties,
        ExecutorService executorService) throws IOException {
    String provider = properties.getProperty(Constants.PROPERTY_PROVIDER);
    String identity = properties.getProperty(Constants.PROPERTY_IDENTITY);
    String credential = properties.getProperty(
            Constants.PROPERTY_CREDENTIAL);
    String endpoint = properties.getProperty(Constants.PROPERTY_ENDPOINT);
    properties.remove(Constants.PROPERTY_ENDPOINT);
    String region = properties.getProperty(
            LocationConstants.PROPERTY_REGION);

    if (provider == null) {
        System.err.println(
                "Properties file must contain: " +
                Constants.PROPERTY_PROVIDER);
        System.exit(1);
    }

    if (provider.equals("filesystem") || provider.equals("transient")) {
        // local blobstores do not require credentials
        identity = Strings.nullToEmpty(identity);
        credential = Strings.nullToEmpty(credential);
    } else if (provider.equals("google-cloud-storage")) {
        File credentialFile = new File(credential);
        if (credentialFile.exists()) {
            credential = Files.asCharSource(credentialFile,
                    StandardCharsets.UTF_8).read();
        }
        properties.remove(Constants.PROPERTY_CREDENTIAL);
    }

    if (identity == null || credential == null) {
        System.err.println(
                "Properties file must contain: " +
                Constants.PROPERTY_IDENTITY + " and " +
                Constants.PROPERTY_CREDENTIAL);
        System.exit(1);
    }

    properties.setProperty(Constants.PROPERTY_USER_AGENT,
            String.format("s3proxy/%s jclouds/%s java/%s",
                    Main.class.getPackage().getImplementationVersion(),
                    JcloudsVersion.get(),
                    System.getProperty("java.version")));

    ContextBuilder builder = ContextBuilder
            .newBuilder(provider)
            .credentials(identity, credential)
            .modules(ImmutableList.<Module>of(
                    new SLF4JLoggingModule(),
                    new ExecutorServiceModule(executorService)))
            .overrides(properties);
    if (!Strings.isNullOrEmpty(endpoint)) {
        builder = builder.endpoint(endpoint);
    }

    BlobStoreContext context = builder.build(BlobStoreContext.class);
    BlobStore blobStore = context.getBlobStore();
    if (context instanceof RegionScopedBlobStoreContext &&
            region != null) {
        blobStore = ((RegionScopedBlobStoreContext) context)
                .getBlobStore(region);
    }
    return blobStore;
}
 
開發者ID:gaul,項目名稱:s3proxy,代碼行數:66,代碼來源:Main.java

示例11: start

import org.jclouds.ContextBuilder; //導入方法依賴的package包/類
@Override
public void start() {
   key2StringMapper = Util.getInstance(configuration.key2StringMapper(), initializationContext.getCache()
         .getAdvancedCache().getClassLoader());
   key2StringMapper.setMarshaller(initializationContext.getMarshaller());

   ContextBuilder contextBuilder = ContextBuilder.newBuilder(configuration.provider()).credentials(configuration.identity(), configuration.credential());
   if(configuration.overrides() != null)
      contextBuilder.overrides(configuration.overrides());
   if(configuration.endpoint() != null && !configuration.endpoint().isEmpty())
      contextBuilder.endpoint(configuration.endpoint());

   blobStoreContext = contextBuilder.buildView(BlobStoreContext.class);

   blobStore = blobStoreContext.getBlobStore();
   String cacheName = configuration.normalizeCacheNames() ? 
         initializationContext.getCache().getName().replaceAll("[^a-zA-Z0-9-]", "-") 
         : initializationContext.getCache().getName();
   containerName = String.format("%s-%s", configuration.container(), cacheName);

   if (!blobStore.containerExists(containerName)) {
      Location location = null;
      if (configuration.location() != null ) {
         location = new LocationBuilder()
            .scope(LocationScope.REGION)
            .id(configuration.location())
            .description(String.format("Infinispan cache store for %s", containerName))
            .build();
      }
      blobStore.createContainerInLocation(location, containerName);

      //make sure container is created
      if(!blobStore.containerExists(containerName)) {
         try {
            log.waitingForContainer();
            TimeUnit.SECONDS.sleep(10);
         } catch (InterruptedException e) {
            throw new PersistenceException(String.format("Aborted when creating blob container %s", containerName));
         }
         if(!blobStore.containerExists(containerName)) {
            throw new PersistenceException(String.format("Unable to create blob container %s", containerName));
         }
      }
   }
}
 
開發者ID:infinispan,項目名稱:infinispan-cachestore-cloud,代碼行數:46,代碼來源:CloudStore.java


注:本文中的org.jclouds.ContextBuilder.endpoint方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。