• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ServiceBrokerException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: provisionTest_kerberosEnabled_createsDBAddGrants

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Test
public void provisionTest_kerberosEnabled_createsDBAddGrants()
    throws ServiceBrokerException, ServiceInstanceExistsException {
  //given
  when(hiveBindingClient.isKerberosEnabled()).thenReturn(true);
  HiveShared toTest = new HiveShared(hiveBindingClient, jdbcOperations);

  //when
  toTest.provision(getServiceInstance("04d4e5d2-0568-11e6-8d01-00155d3d2c21"));

  //then
  InOrder inOrder = inOrder(jdbcOperations);
  inOrder.verify(jdbcOperations)
      .execute("create database if not exists `04d4e5d2_0568_11e6_8d01_00155d3d2c21`");
  inOrder.verify(jdbcOperations)
      .execute("GRANT ALL ON DATABASE `04d4e5d2_0568_11e6_8d01_00155d3d2c21` "
               + "TO ROLE `f0487d90-fde6-4da1-a933-03f38776115d`");
}
 
开发者ID:trustedanalytics,项目名称:hive-broker,代码行数:19,代码来源:HiveSharedTest.java


示例2: createServiceInstanceBinding

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Override
public ServiceInstanceBinding createServiceInstanceBinding(CreateServiceInstanceBindingRequest createServiceInstanceBindingRequest)
        throws ServiceInstanceBindingExistsException, ServiceBrokerException {
    String bindingId = createServiceInstanceBindingRequest.getBindingId();
    String serviceInstanceId = createServiceInstanceBindingRequest.getServiceInstanceId();
    String appGuid = createServiceInstanceBindingRequest.getAppGuid();
    String passwd = "";

    try {
        passwd = this.role.bindRoleToDatabase(serviceInstanceId);
    } catch (SQLException e) {
        logger.error("Error while creating service instance binding '" + bindingId + "'", e);
        throw new ServiceBrokerException(e.getMessage());
    }

    String dbURL = String.format("postgres://%s:%[email protected]%s:%d/%s", serviceInstanceId, passwd, PostgreSQLDatabase.getDatabaseHost(), PostgreSQLDatabase.getDatabasePort(), serviceInstanceId);

    Map<String, Object> credentials = new HashMap<String, Object>();
    credentials.put("uri", dbURL);

    return new ServiceInstanceBinding(bindingId, serviceInstanceId, credentials, null, appGuid);
}
 
开发者ID:cloudfoundry-community,项目名称:postgresql-cf-service-broker,代码行数:23,代码来源:PostgreSQLServiceInstanceBindingService.java


示例3: restoreDump

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
private void restoreDump(Map<String, Object> parameters, DbDumperServiceInstance dbDumperServiceInstance) throws ServiceBrokerException, RestoreException {
    String targetUrl = getParameterAsString(parameters, TARGET_URL_PARAMETER, null);
    if (targetUrl == null) {
        targetUrl = getParameterAsString(parameters, NEW_TARGET_URL_PARAMETER);
    }
    String createdAtString = getParameterAsString(parameters, CREATED_AT_PARAMETER, null);
    DatabaseRef databaseRefTarget = this.getDatabaseRefFromParams(parameters, targetUrl);
    if (createdAtString == null || createdAtString.isEmpty()) {
        this.jobFactory.createJobRestoreDump(databaseRefTarget, null, dbDumperServiceInstance);
        return;
    }
    Date createdAt;
    try {
        createdAt = this.parseDate(createdAtString);
    } catch (ParseException e) {
        throw new ServiceBrokerException("When use " + CREATED_AT_PARAMETER + " parameter you should pass a date in one of this forms: " + String.join(", ", VALID_DATES_FORMAT));
    }
    this.jobFactory.createJobRestoreDump(databaseRefTarget, createdAt, dbDumperServiceInstance);
}
 
开发者ID:orange-cloudfoundry,项目名称:db-dumper-service,代码行数:20,代码来源:DbDumperServiceInstanceService.java


示例4: provisionInstance

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Override
public H2oCredentials provisionInstance(String serviceInstanceId) throws ServiceBrokerException {

  ResponseEntity<H2oCredentials> h2oCredentialsResponseEntity;
  try {
    h2oCredentialsResponseEntity =
        h2oRest.createH2oInstance(serviceInstanceId, nodesCount, memory, kerberos, yarnConf);
    LOGGER.info("response: '" + h2oCredentialsResponseEntity.getStatusCode() + "'");
  } catch (RestClientException e) {
    throw new ServiceBrokerException(errorMsg(serviceInstanceId), e);
  }

  if (h2oCredentialsResponseEntity.getStatusCode() == HttpStatus.OK) {
    return h2oCredentialsResponseEntity.getBody();
  } else {
    throw new ServiceBrokerException(errorMsg(serviceInstanceId));
  }
}
 
开发者ID:trustedanalytics,项目名称:h2o-broker,代码行数:19,代码来源:H2oProvisionerClient.java


示例5: createServiceInstance

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Override
public ServiceInstance createServiceInstance(CreateServiceInstanceRequest createServiceInstanceRequest)
        throws ServiceInstanceExistsException, ServiceBrokerException {
    String serviceInstanceId = createServiceInstanceRequest.getServiceInstanceId();
    String serviceId = createServiceInstanceRequest.getServiceDefinitionId();
    String planId = createServiceInstanceRequest.getPlanId();
    String organizationGuid = createServiceInstanceRequest.getOrganizationGuid();
    String spaceGuid = createServiceInstanceRequest.getSpaceGuid();
    try {
        db.createDatabaseForInstance(serviceInstanceId, serviceId, planId, organizationGuid, spaceGuid);
        role.createRoleForInstance(serviceInstanceId);
    } catch (SQLException e) {
        logger.error("Error while creating service instance '" + serviceInstanceId + "'", e);
        throw new ServiceBrokerException(e.getMessage());
    }
    return new ServiceInstance(createServiceInstanceRequest);
}
 
开发者ID:cloudfoundry-community,项目名称:postgresql-cf-service-broker,代码行数:18,代码来源:PostgreSQLServiceInstanceService.java


示例6: createServiceInstanceBinding_credentialsNotExistInStore_exceptionThrown

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Test
public void createServiceInstanceBinding_credentialsNotExistInStore_exceptionThrown()
    throws Exception {

  // arrange
  expectedException.expect(ServiceBrokerException.class);
  expectedException.expectMessage(
      "There are no stored credentials for service instance '" + INSTANCE_ID + "'");

  CreateServiceInstanceBindingRequest request =
      CfBrokerRequestsFactory.getCreateServiceBindingRequest(INSTANCE_ID, BINDING_ID);
  when(delegateMock.createServiceInstanceBinding(request))
      .thenReturn(new ServiceInstanceBinding(BINDING_ID, INSTANCE_ID, null, SYSLOG, APP_GUID));

  when(credentialsStoreMock.getById(Location.newInstance(INSTANCE_ID)))
      .thenReturn(Optional.ofNullable(null));

  // act
  bindingService.createServiceInstanceBinding(request);
}
 
开发者ID:trustedanalytics,项目名称:h2o-broker,代码行数:21,代码来源:H2oServiceInstanceBindingServiceTest.java


示例7: when

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Test
public void when_creating_service_instance_binding_with_service_id_existing_and_user_find_by_tags_it_should_give_a_correct_service_instance_binding() throws ServiceInstanceBindingExistsException, ServiceBrokerException {
    when(repositoryInstanceBinding.findOne(anyString())).thenReturn(null);
    String tag = "mytag";
    DbDumperCredential dbDumperCredential = this.forgeDbDumperCredential(dbDumperCredentials.size() + 1, true);
    dbDumperCredential.setTags(Arrays.asList(tag));

    List<DbDumperCredential> dumperCredentials = Arrays.asList(dbDumperCredential1, dbDumperCredential2, dbDumperCredential3, dbDumperCredential);
    when(credentials.getDumpsCredentials((DbDumperServiceInstance) notNull())).thenReturn(dumperCredentials);

    parameters.put(DbDumperServiceInstanceBindingService.FIND_BY_TAGS_KEY, Arrays.asList(tag));

    ServiceInstanceBinding instanceBinding = this.instanceBindingService.createServiceInstanceBinding(createRequest);
    assertThat(instanceBinding).isNotNull();
    assertThat(instanceBinding.getAppGuid()).isEqualTo(appGuid);
    assertThat(instanceBinding.getId()).isEqualTo(bindingId);
    assertCredentials(instanceBinding, Arrays.asList(dbDumperCredential));
}
 
开发者ID:orange-cloudfoundry,项目名称:db-dumper-service,代码行数:19,代码来源:DbDumperServiceInstanceBindingServiceTest.java


示例8: bind

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Override
public Map<String, Object> bind(ServiceInstance serviceInstance) throws ServiceBrokerException {
  UUID instanceId = UUID.fromString(serviceInstance.getServiceInstanceId());
  UUID orgId = UUID.fromString(serviceInstance.getOrganizationGuid());
  Map<String, Object> configurationMap =
      bindingOperations.createCredentialsMap(instanceId, orgId);
  Map<String, Object> storedCredentials = credentialsStore.get(instanceId);

  if (getParameterUri(storedCredentials, URI_KEY).isPresent()) {
    configurationMap.remove(URI_KEY);
  }

  Map<String, Object> credentials = new HashMap<>();
  credentials.putAll(configurationMap);
  credentials.putAll(storedCredentials);
  return credentials;
}
 
开发者ID:trustedanalytics,项目名称:hdfs-broker,代码行数:18,代码来源:HdfsPlanGetUserDirectory.java


示例9: updateServiceInstance

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Override
public ServiceInstance updateServiceInstance(UpdateServiceInstanceRequest request)
        throws ServiceInstanceUpdateNotSupportedException,
        ServiceBrokerException,
        ServiceInstanceDoesNotExistException {

    PersistableServiceInstance one = this.serviceInstanceRepository.findOne(
            request.getServiceInstanceId());

    PersistableServiceInstance two = new PersistableServiceInstance(
            one.getServiceDefinitionId(),
            request.getPlanId(),
            one.getOrganizationGuid(),
            one.getSpaceGuid(),
            request.getServiceInstanceId(), true);

    return this.serviceInstanceRepository.save(two);
}
 
开发者ID:joshlong,项目名称:cloudfoundry-ftp-service-broker,代码行数:19,代码来源:FtpServiceInstanceService.java


示例10: getCreds

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Override
public Map<String, Object> getCreds(final String instance)
		throws ServiceBrokerException {
	if (!instanceImages.containsKey(instance)) {
		return null;
	}
	Map<String, Object> newCreds = new HashMap<>(creds);

	String instanceIp = aws.getEC2InstancePublicIp(instance);
	String pgURI = (String) creds.get("uri");

	try {
		newCreds.put("uri",
				pgURI.replace(new URI(pgURI).getHost(), instanceIp));
	} catch (URISyntaxException e) {
		log.error("Bad URI!!" + pgURI);
		throw new ServiceBrokerException(e);
	}
	return newCreds;
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:21,代码来源:AWSCopyProvider.java


示例11: addElasticIp

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
/**
 * Associate the next available elastic IP with an instance.
 * 
 * @param instanceId
 * @throws ServiceBrokerException
 */
public void addElasticIp(String instanceId) throws ServiceBrokerException {
	AssociateAddressRequest addressRequest = new AssociateAddressRequest()
			.withInstanceId(instanceId).withPublicIp(
					getAvaliableElasticIp());
	log.info("Associating " + addressRequest.getPublicIp()
			+ " with instance " + instanceId);
	if (waitForInstance(instanceId)) {
		ec2Client.associateAddress(addressRequest);
	} else {
		throw new ServiceBrokerException(
				"Instance did not transition to 'running' in alotted time.");
	}
	// We need the machine to boot before this will work.
	if (!hostUtils.waitForBoot(addressRequest.getPublicIp(), bootCheckPort)) {
		throw new ServiceBrokerException(
				"Host failed to boot in time alotted");
	}
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:25,代码来源:AWSHelper.java


示例12: deleteServiceInstance

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Override
public ServiceInstance deleteServiceInstance(
		DeleteServiceInstanceRequest request)
		throws ServiceBrokerException, ServiceBrokerAsyncRequiredException {
	throwIfSync(request);
	String id = request.getServiceInstanceId();
	log(id, "Deleting service instance", IN_PROGRESS);
	ServiceInstance instance = instanceManager.getInstance(id);
	if (null == instance) {
		log(id, "Service instance not found", FAILED);
		return null;
	}
	String copyId = instanceManager.getCopyIdForInstance(id);

	instanceManager.saveInstance(
			instance.withLastOperation(
					new ServiceInstanceLastOperation("deprovisioning",
							OperationState.IN_PROGRESS)).isAsync(true),
			copyId);

	deProvision(request, id, instance);

	return instance;

}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:26,代码来源:LCServiceInstanceService.java


示例13: deleteServiceInstanceBinding

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Override
public ServiceInstanceBinding deleteServiceInstanceBinding(
		DeleteServiceInstanceBindingRequest request)
		throws ServiceBrokerException {
	try {
		log(request.getBindingId(), "Removing binding ", IN_PROGRESS);
		ServiceInstanceBinding binding = bindings.removeBinding(request
				.getBindingId());
		log(request.getBindingId(), "Removing binding ", COMPLETE);

		return binding;
	} catch (Exception e) {
		log(request.getBindingId(), "Failed to remove binding ", FAILED);
		throw e;
	}
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:17,代码来源:LCServiceInstanceBindingService.java


示例14: setUp

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Before
public void setUp() throws ServiceBrokerException, TimeoutException {
	MockitoAnnotations.initMocks(this);
	// TODO, need to get the aws helper in there.
	String pgUser = "pgUser";
	String pgPass = "pgPass";
	provider = new AWSCopyProvider(aws, pgUser, pgPass, pgURI,
			"sourceInstance");
	// TODO remove the description.......
	when(
			aws.createAMI("sourceInstance",
					"CF Service Broker Snapshot Image")).thenReturn(
			"test_ami");

	when(aws.startEC2Instance("test_ami")).thenReturn("test_instance");

	assertThat("test_instance",
			is(equalTo(provider.createCopy("sourceInstance"))));
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:20,代码来源:AWSCopyProviderTest.java


示例15: itShouldStartAnEC2InstanceFromAnAMI

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Test
public void itShouldStartAnEC2InstanceFromAnAMI()
		throws ServiceBrokerException {

	when(
			ec2Client.runInstances(awsRqst(r -> r.getImageId().equals(
					"test_image")))).thenReturn(runInstanceResult);

	when(ec2Client.describeAddresses()).thenReturn(
			new DescribeAddressesResult().withAddresses(Collections
					.singleton(new Address().withPublicIp("10.10.10.10"))));

	when(ec2Client.describeInstanceStatus(any())).thenReturn(
			new DescribeInstanceStatusResult()
					.withInstanceStatuses(Collections
							.singleton(new InstanceStatus()
									.withInstanceState(new InstanceState()
											.withName("running")))));

	when(hostUtils.waitForBoot(anyString(), anyInt())).thenReturn(true);
	assertThat(aws.startEC2Instance("test_image"),
			is(equalTo("test_instance")));
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:24,代码来源:AWSHelperTest.java


示例16: itShouldReturnAppToInstancePairsAndBindToMutipleApps

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Test
public void itShouldReturnAppToInstancePairsAndBindToMutipleApps()
		throws ServiceInstanceBindingExistsException,
		ServiceBrokerException {

	when(
			instanceService.getInstanceIdForServiceInstance(serviceInstance
					.getServiceInstanceId())).thenReturn("test_copy");

	List<ServiceInstanceBinding> bindings = buildServiceInstanceBindings();
	when(bindingManager.getBindings()).thenReturn(bindings);

	List<InstancePair> appBindings = bindingService.getAppToCopyBinding();
	assertThat(appBindings, hasSize(3));
	assertTrue(appBindings.contains(new InstancePair("test_app2",
			"test_copy")));
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:18,代码来源:LCServiceInstanceBindingServiceCopyTest.java


示例17: buildServiceInstanceBindings

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
private List<ServiceInstanceBinding> buildServiceInstanceBindings() {
	List<ServiceInstanceBinding> list = new ArrayList<ServiceInstanceBinding>();

	IntConsumer consumer = new IntConsumer() {
		@Override
		public void accept(int i) {
			createServiceInstanceBindingRequest.withBindingId("bind" + i)
					.setAppGuid("test_app" + i);
			try {
				list.add(bindingService
						.createServiceInstanceBinding(createServiceInstanceBindingRequest));
			} catch (ServiceInstanceBindingExistsException
					| ServiceBrokerException e) {
				fail("Failed to create service instance bindings");
			}
		}
	};
	IntStream.range(1, 4).forEach(consumer);
	return list;
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:21,代码来源:LCServiceInstanceBindingServiceCopyTest.java


示例18: deprovisionInstance

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Override
public String deprovisionInstance(String serviceInstanceId) throws ServiceBrokerException {
  ResponseEntity<String> deleteH2oInstanceResponse;
  try {
    deleteH2oInstanceResponse = h2oRest.deleteH2oInstance(serviceInstanceId, yarnConf);
    LOGGER.info("response: '" + deleteH2oInstanceResponse.getStatusCode() + "'");
  } catch (RestClientException e) {
    throw new ServiceBrokerException("Unable to deprovision h2o for: " + serviceInstanceId, e);
  }

  if (deleteH2oInstanceResponse.getStatusCode() == HttpStatus.OK) {
    return deleteH2oInstanceResponse.getBody();
  } else {
    throw new ServiceBrokerException("Unable to deprovision h2o for: " + serviceInstanceId);
  }
}
 
开发者ID:trustedanalytics,项目名称:h2o-broker,代码行数:17,代码来源:H2oProvisionerClient.java


示例19: itShouldSaveTheInstnaceAsFailedIfDeprovisionFails

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Test
public void itShouldSaveTheInstnaceAsFailedIfDeprovisionFails()
		throws Exception {

	ServiceInstance theInstance = new ServiceInstance(
			newCreateServiceInstanceRequest());

	doThrow(new ServiceBrokerException("Problem!")).when(copyProvider)
			.deleteCopy(anyString());

	when(instanceManager.getInstance(anyString())).thenReturn(theInstance);
	when(instanceManager.getCopyIdForInstance(anyString())).thenReturn(
			"copy_id");

	ServiceInstance failedInstance = service
			.deleteServiceInstance(new DeleteServiceInstanceRequest(
					theInstance.getServiceInstanceId(), theInstance
							.getServiceDefinitionId(), COPY, true));

	assertThat(failedInstance.getServiceInstanceLastOperation().getState(),
			is(equalTo("failed")));

	// Once for in progress, once for failed.
	verify(instanceManager, times(2)).saveInstance(any(), anyString());
	assertTrue(failedInstance.isAsync());
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:27,代码来源:LCServiceInstanceServiceCopyTest.java


示例20: itShouldReturnTheProdCreds

import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException; //导入依赖的package包/类
@Test
public void itShouldReturnTheProdCreds() throws ServiceBrokerException,
		ServiceInstanceBindingExistsException {

	Map<String, Object> testCreds = new HashMap<String, Object>();
	testCreds.put("uri", "prod_uri");
	when(provider.getCreds("source_instance")).thenReturn(testCreds);

	ServiceInstanceBinding bindResult = bindingService
			.createServiceInstanceBinding(new CreateServiceInstanceBindingRequest(
					serviceInstance.getServiceDefinitionId(), PRODUCTION,
					"test_app")
					.withBindingId(bindingId)
					.and()
					.withServiceInstanceId(
							serviceInstance.getServiceInstanceId()));
	assertThat(bindResult.getId(), is(equalTo(bindingId)));
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:19,代码来源:LCServiceInstanceBindingServiceProdTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PageParameters类代码示例发布时间:2022-05-21
下一篇:
Java KillJobRequest类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap