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


Java RequestUnsuccessfulException类代码示例

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


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

示例1: countCurrentDropletsSlaves

import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException; //导入依赖的package包/类
/**
 * Count the number of droplets provisioned with the specified Image ID
 * @param imageId
 * @return
 * @throws RequestUnsuccessfulException
 * @throws AccessDeniedException
 * @throws ResourceNotFoundException
 */
public int countCurrentDropletsSlaves(Integer imageId) throws RequestUnsuccessfulException, AccessDeniedException, ResourceNotFoundException {

    int count = 0;
    DigitalOceanClient apiClient = new DigitalOceanClient(clientId, apiKey);
    List<Droplet> availableDroplets = apiClient.getAvailableDroplets();

    for (Droplet droplet : availableDroplets) {
        if (imageId == null || droplet.getImageId() == imageId) {
            if (droplet.isActive() || droplet.isNew()) {
                count++;
            }
        }
    }

    return count;
}
 
开发者ID:pulse00,项目名称:digitalocean-plugin,代码行数:25,代码来源:Cloud.java

示例2: removeDropletsFromLoadBalancer

import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException; //导入依赖的package包/类
@Override
public Delete removeDropletsFromLoadBalancer(String loadBalancerId, List<Integer> dropletIds)
    throws DigitalOceanException,
    RequestUnsuccessfulException {
  validateLoadBalancerId(loadBalancerId);

  if (null == dropletIds || dropletIds.isEmpty()) {
    throw new IllegalArgumentException(
        "Missing required parameters [dropletIds].");
  }

  Object[] params = {loadBalancerId};
  Map<String, List<Integer>> data = new HashMap<>();
  data.put("droplet_ids", dropletIds);
  return (Delete) perform(
      new ApiRequest(ApiAction.REMOVE_DROPLET_FROM_LOAD_BALANCER, data, params)).getData();
}
 
开发者ID:jeevatkm,项目名称:digitalocean-api-java,代码行数:18,代码来源:DigitalOceanClient.java

示例3: resizeVolume

import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException; //导入依赖的package包/类
@Override
public Action resizeVolume(String volumeId, String regionSlug, Double sizeGigabytes)
    throws DigitalOceanException,
    RequestUnsuccessfulException {
  checkBlankAndThrowError(volumeId, "Missing required parameter - volumeId.");
  checkBlankAndThrowError(regionSlug, "Missing required parameter - regionSlug.");

  if (null == sizeGigabytes) {
    throw new IllegalArgumentException("Missing required parameter - sizeGigabytes.");
  }

  Object[] params = {volumeId};
  return (Action) perform(
      new ApiRequest(ApiAction.ACTIONS_VOLUME,
          new VolumeAction(ActionType.RESIZE, regionSlug, sizeGigabytes), params)).getData();
}
 
开发者ID:jeevatkm,项目名称:digitalocean-api-java,代码行数:17,代码来源:DigitalOceanClient.java

示例4: updateLoadBalancer

import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException; //导入依赖的package包/类
@Override
public LoadBalancer updateLoadBalancer(LoadBalancer loadBalancer) throws DigitalOceanException,
    RequestUnsuccessfulException {
  if (null == loadBalancer
      || StringUtils.isBlank(loadBalancer.getId())
      || StringUtils.isBlank(loadBalancer.getName())
      || null == loadBalancer.getRegion()) {
    throw new IllegalArgumentException(
        "Missing required parameters [Id, Name, Region Slug] for update loadBalancer.");
  }
  validateForwardingRules(loadBalancer.getForwardingRules());
  validateHealthCheck(loadBalancer.getHealthCheck());

  Object[] params = {loadBalancer.getId()};

  return (LoadBalancer) perform(
      new ApiRequest(ApiAction.UPDATE_LOAD_BALANCER, loadBalancer, params)).getData();
}
 
开发者ID:jeevatkm,项目名称:digitalocean-api-java,代码行数:19,代码来源:DigitalOceanClient.java

示例5: provision

import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException; //导入依赖的package包/类
/**
 * Creates a new droplet on DigitalOcean to be used as a Jenkins slave.
 *
 * @param apiClient
 * @param privateKey
 * @param sshKeyId
 *@param listener  @return
 * @throws IOException
 * @throws RequestUnsuccessfulException
 * @throws AccessDeniedException
 * @throws ResourceNotFoundException
 * @throws Descriptor.FormException
 */
public Slave provision(DigitalOceanClient apiClient, String privateKey, Integer sshKeyId, StreamTaskListener listener) throws IOException, RequestUnsuccessfulException, AccessDeniedException, ResourceNotFoundException, Descriptor.FormException {

    PrintStream logger = listener.getLogger();
    try {
        logger.println("Starting to provision digital ocean droplet using image: " + imageId + ", region: " + regionId + ", size: " + sizeId);

        // check for existing droplets
        List<Droplet> availableDroplets = apiClient.getAvailableDroplets();
        for (Droplet existing : availableDroplets) {
            if (existing.getImageId().equals(imageId) && ! existing.isArchived() && (existing.getName() != null && ! existing.getName().startsWith("jenkins_"))) {
                logger.println("Creating slave from existing droplet " + existing.getId());
                return newSlave(existing, privateKey);
            }
        }

        // create a new droplet
        // TODO: set the data from the UI
        Droplet droplet = new Droplet();
        droplet.setName(dropletName);
        droplet.setSizeId(sizeId);
        droplet.setRegionId(regionId);
        droplet.setImageId(imageId);

        logger.println("Creating slave with new droplet " + dropletName);
        return newSlave(apiClient.createDroplet(droplet, sshKeyId.toString()), privateKey);
    } catch (Exception e) {
        e.printStackTrace(logger);
        throw new AssertionError();
    }
}
 
开发者ID:pulse00,项目名称:digitalocean-plugin,代码行数:44,代码来源:SlaveTemplate.java

示例6: connectToSsh

import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException; //导入依赖的package包/类
private Connection connectToSsh(Computer computer, PrintStream logger) throws InterruptedException, RequestUnsuccessfulException, AccessDeniedException, ResourceNotFoundException {

        // TODO: make configurable?
        final long timeout = TimeUnit2.MINUTES.toMillis(5);
        final long startTime = System.currentTimeMillis();

        while(true) {
            try {
                long waitTime = System.currentTimeMillis() - startTime;
                if ( waitTime > timeout ) {
                    throw new RuntimeException("Timed out after "+ (waitTime / 1000) + " seconds of waiting for ssh to become available. (maximum timeout configured is "+ (timeout / 1000) + ")" );
                }
                Droplet instance = computer.updateInstanceDescription();
                String host = instance.getIpAddress();

                if (Strings.isNullOrEmpty(host) || "0.0.0.0".equals(host)) {
                    logger.println("No ip address yet, your host is most likely waiting for an ip address.");
                    throw new IOException("sleep");
                }

                int port = computer.getSshPort();
                logger.println("Connecting to " + host + " on port " + port + ". ");
                Connection conn = new Connection(host, port);
                conn.connect();
                logger.println("Connected via SSH.");
                return conn; // successfully connected
            } catch (IOException e) {
                // keep retrying until SSH comes up
                logger.println("Waiting for SSH to come up. Sleeping 5 seconds.");
                Thread.sleep(5000);
            }
        }
    }
 
开发者ID:pulse00,项目名称:digitalocean-plugin,代码行数:34,代码来源:ComputerLauncher.java

示例7: getAvailableDroplets

import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException; //导入依赖的package包/类
@Override
public Droplets getAvailableDroplets(Integer pageNo, Integer perPage)
    throws DigitalOceanException, RequestUnsuccessfulException {
  validatePageNo(pageNo);

  return (Droplets) perform(new ApiRequest(ApiAction.AVAILABLE_DROPLETS, pageNo, perPage))
      .getData();
}
 
开发者ID:jeevatkm,项目名称:digitalocean-api-java,代码行数:9,代码来源:DigitalOceanClient.java

示例8: getDropletKernels

import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException; //导入依赖的package包/类
@Override
public Kernels getDropletKernels(Integer dropletId, Integer pageNo, Integer perPage)
    throws DigitalOceanException, RequestUnsuccessfulException {
  validateDropletIdAndPageNo(dropletId, pageNo);

  Object[] params = {dropletId};
  return (Kernels) perform(
      new ApiRequest(ApiAction.GET_DROPLETS_KERNELS, params, pageNo, perPage)).getData();
}
 
开发者ID:jeevatkm,项目名称:digitalocean-api-java,代码行数:10,代码来源:DigitalOceanClient.java

示例9: getDropletBackups

import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException; //导入依赖的package包/类
@Override
public Backups getDropletBackups(Integer dropletId, Integer pageNo, Integer perPage)
    throws DigitalOceanException, RequestUnsuccessfulException {
  validateDropletIdAndPageNo(dropletId, pageNo);

  Object[] params = {dropletId};
  return (Backups) perform(new ApiRequest(ApiAction.GET_DROPLET_BACKUPS, params, pageNo, perPage))
      .getData();
}
 
开发者ID:jeevatkm,项目名称:digitalocean-api-java,代码行数:10,代码来源:DigitalOceanClient.java

示例10: testGetCertifacteInfo

import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException; //导入依赖的package包/类
@Test
public void testGetCertifacteInfo() throws DigitalOceanException, RequestUnsuccessfulException {
  Certificate certificate = apiClient.getCertificateInfo("9620c5d3-783c-4096-90f3-a2e363aa10fd");

  assertNotNull(certificate);
  log.info(certificate.toString());
}
 
开发者ID:jeevatkm,项目名称:digitalocean-api-java,代码行数:8,代码来源:DigitalOceanIntegrationTest.java

示例11: testResetDropletPassword

import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException; //导入依赖的package包/类
@Test
public void testResetDropletPassword()
    throws DigitalOceanException, RequestUnsuccessfulException {

  Action action = apiClient.resetDropletPassword(2258168);

  assertNotNull(action);
  log.info(action.toString());
}
 
开发者ID:jeevatkm,项目名称:digitalocean-api-java,代码行数:10,代码来源:DigitalOceanIntegrationTest.java

示例12: testUpdateKeyById

import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException; //导入依赖的package包/类
@Test
public void testUpdateKeyById() throws DigitalOceanException, RequestUnsuccessfulException {
  Key resultKey = apiClient.updateKey(245798, "TestKey5");

  assertNotNull(resultKey);
  assertNotNull(resultKey.getId());
  log.info(resultKey.toString());
}
 
开发者ID:jeevatkm,项目名称:digitalocean-api-java,代码行数:9,代码来源:DigitalOceanIntegrationTest.java

示例13: testTakeDropletSnapshot

import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException; //导入依赖的package包/类
@Test
public void testTakeDropletSnapshot() throws DigitalOceanException, RequestUnsuccessfulException {

  // Action action = apiClient.takeDropletSnapshot(2258168, "api-client-test-snapshot1");
  Action action = apiClient.takeDropletSnapshot(2258136);

  assertNotNull(action);
  log.info(action.toString());
}
 
开发者ID:jeevatkm,项目名称:digitalocean-api-java,代码行数:10,代码来源:DigitalOceanIntegrationTest.java

示例14: getDropletNeighbors

import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException; //导入依赖的package包/类
@Override
public Droplets getDropletNeighbors(Integer dropletId, Integer pageNo)
    throws DigitalOceanException, RequestUnsuccessfulException {
  validateDropletIdAndPageNo(dropletId, pageNo);

  Object[] params = {dropletId};
  return (Droplets) perform(new ApiRequest(ApiAction.GET_DROPLET_NEIGHBORS, params, pageNo, null))
      .getData();
}
 
开发者ID:jeevatkm,项目名称:digitalocean-api-java,代码行数:10,代码来源:DigitalOceanClient.java

示例15: getAllDropletNeighbors

import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException; //导入依赖的package包/类
@Override
public Neighbors getAllDropletNeighbors(Integer pageNo) throws DigitalOceanException,
    RequestUnsuccessfulException {
  validatePageNo(pageNo);

  return (Neighbors) perform(new ApiRequest(ApiAction.ALL_DROPLET_NEIGHBORS, pageNo)).getData();
}
 
开发者ID:jeevatkm,项目名称:digitalocean-api-java,代码行数:8,代码来源:DigitalOceanClient.java


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