本文整理汇总了Java中org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException类的典型用法代码示例。如果您正苦于以下问题:Java ServiceBrokerException类的具体用法?Java ServiceBrokerException怎么用?Java ServiceBrokerException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServiceBrokerException类属于org.cloudfoundry.community.servicebroker.exception包,在下文中一共展示了ServiceBrokerException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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`");
}
示例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);
}
示例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));
}
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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");
}
}
示例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;
}
示例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;
}
}
示例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"))));
}
示例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")));
}