本文整理汇总了Java中org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException类的典型用法代码示例。如果您正苦于以下问题:Java ServiceInstanceExistsException类的具体用法?Java ServiceInstanceExistsException怎么用?Java ServiceInstanceExistsException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceInstanceExistsException类属于org.springframework.cloud.servicebroker.exception包,在下文中一共展示了ServiceInstanceExistsException类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createServiceInstance
import org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException; //导入依赖的package包/类
@Override
public CreateServiceInstanceResponse createServiceInstance(CreateServiceInstanceRequest request) {
// TODO MongoDB dashboard
ServiceInstance instance = repository.findOne(request.getServiceInstanceId());
if (instance != null) {
throw new ServiceInstanceExistsException(request.getServiceInstanceId(), request.getServiceDefinitionId());
}
instance = new ServiceInstance(request);
if (mongo.databaseExists(instance.getServiceInstanceId())) {
// ensure the instance is empty
mongo.deleteDatabase(instance.getServiceInstanceId());
}
DB db = mongo.createDatabase(instance.getServiceInstanceId());
if (db == null) {
throw new ServiceBrokerException("Failed to create new DB instance: " + instance.getServiceInstanceId());
}
repository.save(instance);
return new CreateServiceInstanceResponse();
}
开发者ID:cf-platform-eng,项目名称:mongodb-broker,代码行数:24,代码来源:MongoServiceInstanceService.java
示例2: newServiceInstanceCreatedSuccessfully
import org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException; //导入依赖的package包/类
@Test
public void newServiceInstanceCreatedSuccessfully()
throws ServiceInstanceExistsException, ServiceBrokerException {
when(admin.createApplication(any(String.class))).thenReturn(new AsyncResult<>(entity));
when(catalogService.getServiceDefinition(any(String.class))).thenReturn(serviceDefinition);
when(serviceDefinition.getPlans()).thenReturn(ImmutableList.of(new DefaultBlueprintPlan("planId", "test_name", "test_description","Test App", ImmutableMap.of("location", "test_location"))));
when(serviceDefinition.getId()).thenReturn(SVC_DEFINITION_ID);
when(admin.getDashboardUrl(any(String.class))).thenReturn(new AsyncResult<>(null));
CreateServiceInstanceRequest request = new CreateServiceInstanceRequest(serviceDefinition.getId(), "planId", "organizationGuid", "spaceGuid");
CreateServiceInstanceResponse instance = service.createServiceInstance(request.withServiceInstanceId(SVC_INST_ID));
assertNotNull(instance);
// TODO: assert service instance created successfully
// assertEquals(SVC_INST_ID, instance.getServiceInstanceId());
}
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:18,代码来源:BrooklynServiceInstanceServiceTest.java
示例3: createServiceInstance
import org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException; //导入依赖的package包/类
@Override
public CreateServiceInstanceResponse createServiceInstance(CreateServiceInstanceRequest request) {
// TODO MongoDB dashboard
ServiceInstance instance = repository.findOne(request.getServiceInstanceId());
if (instance != null) {
throw new ServiceInstanceExistsException(request.getServiceInstanceId(), request.getServiceDefinitionId());
}
instance = new ServiceInstance(request);
if (mongo.databaseExists(instance.getServiceInstanceId())) {
// ensure the instance is empty
mongo.deleteDatabase(instance.getServiceInstanceId());
}
MongoDatabase db = mongo.createDatabase(instance.getServiceInstanceId());
if (db == null) {
throw new ServiceBrokerException("Failed to create new DB instance: " + instance.getServiceInstanceId());
}
repository.save(instance);
return new CreateServiceInstanceResponse();
}
开发者ID:spring-cloud-samples,项目名称:cloudfoundry-service-broker,代码行数:24,代码来源:MongoServiceInstanceService.java
示例4: createServiceInstance
import org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException; //导入依赖的package包/类
@Override
public CreateServiceInstanceResponse createServiceInstance(final CreateServiceInstanceRequest request) {
ServiceInstance instance = repository.findOne(request.getServiceInstanceId());
if (instance != null) {
throw new ServiceInstanceExistsException(request.getServiceInstanceId(), request.getServiceDefinitionId());
}
instance = new ServiceInstance(request);
if (cloudKarafkaAdminService.brokerInstanceExists(instance.getServiceInstanceId())) {
// ensure the instance is empty
cloudKarafkaAdminService.deleteBrokerInstance(instance.getServiceInstanceId());
}
//collect params
final String iid = instance.getServiceInstanceId();
final String iplan = instance.getPlanId().split("_")[0];
final CloudKarafkaCreateInstanceResponse response = cloudKarafkaAdminService.createInstance(iid, iplan);
if (response == null) {
throw new ServiceBrokerException("Failed to create new broker instance: " + instance.getServiceInstanceId());
}
//fill object with required information
instance.setCloudKarafkaId(response.getId());
instance.setCloudKarafkaBrokers(response.getBrokers());
instance.setCloudKarafkaCa(response.getCa());
instance.setCloudKarafkaCert(response.getCert());
instance.setCloudKarafkaPrivateKey(response.getPrivateKey());
instance.setCloudKarafkaTopicPrefix(response.getTopicPrefix());
instance.setCloudKarafkaMessage(response.getMessage());
repository.save(instance);
return new CreateServiceInstanceResponse();
}
开发者ID:ipolyzos,项目名称:cloudkarafka-broker,代码行数:37,代码来源:CloudKarafkaServiceInstanceService.java
示例5: createServiceInstance
import org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException; //导入依赖的package包/类
@Override
public CreateServiceInstanceResponse createServiceInstance(CreateServiceInstanceRequest request)
throws ServiceInstanceExistsException {
if (getInstance(request.getServiceInstanceId()) != null) {
throw new ServiceInstanceExistsException(request.getServiceInstanceId(), request.getServiceDefinitionId());
}
ServiceDefinition sd = catalogService.getServiceDefinition(request
.getServiceDefinitionId());
if (sd == null) {
throw new ServiceBrokerException(
"Unable to find service definition with id: "
+ request.getServiceDefinitionId());
}
LOG.info("creating service instance: " + request.getServiceInstanceId()
+ " service definition: " + request.getServiceDefinitionId());
VrServiceInstance instance = vraClient.createInstance(request, sd);
instance = saveInstance(instance);
LOG.info("registered service instance: "
+ instance.getId()
+ " requestId: "
+ instance.getMetadata().get(
VrServiceInstance.CREATE_REQUEST_ID));
return new CreateServiceInstanceResponse().withAsync(true);
}
开发者ID:cf-platform-eng,项目名称:vrealize-service-broker,代码行数:33,代码来源:VrServiceInstanceService.java
示例6: createBucket
import org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException; //导入依赖的package包/类
void createBucket(String id, ServiceDefinitionProxy service,
PlanProxy plan, Map<String, Object> parameters) {
if (parameters == null) parameters = new HashMap<>();
logger.info(String.format("Creating bucket %s", id));
try {
if (bucketExists(id)) {
throw new ServiceInstanceExistsException(id, service.getId());
}
parameters.putAll(plan.getServiceSettings());
parameters.putAll(service.getServiceSettings());
BucketAction.create(connection, new ObjectBucketCreate(prefix(id),
broker.getNamespace(), replicationGroupID, parameters));
if (parameters.containsKey(QUOTA)) {
logger.info("Applying quota");
@SuppressWarnings(UNCHECKED)
Map<String, Integer> quota = (Map<String, Integer>) parameters
.get(QUOTA);
BucketQuotaAction.create(connection, prefix(id),
broker.getNamespace(), quota.get(LIMIT), quota.get(WARN));
}
if (parameters.containsKey(DEFAULT_RETENTION)) {
logger.info("Applying retention policy");
BucketRetentionAction.update(connection, broker.getNamespace(),
prefix(id), (int) parameters.get(DEFAULT_RETENTION));
}
} catch (Exception e) {
logger.error(String.format("Failed to create bucket %s", id), e);
throw new ServiceBrokerException(e);
}
}
开发者ID:codedellemc,项目名称:ecs-cf-service-broker,代码行数:35,代码来源:EcsService.java
示例7: createNamespace
import org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException; //导入依赖的package包/类
void createNamespace(String id, ServiceDefinitionProxy service,
PlanProxy plan, Map<String, Object> parameters)
throws EcsManagementClientException {
if (namespaceExists(id))
throw new ServiceInstanceExistsException(id, service.getId());
parameters.putAll(plan.getServiceSettings());
parameters.putAll(service.getServiceSettings());
NamespaceAction.create(connection, new NamespaceCreate(prefix(id),
replicationGroupID, parameters));
if (parameters.containsKey(QUOTA)) {
@SuppressWarnings(UNCHECKED)
Map<String, Integer> quota = (Map<String, Integer>) parameters
.get(QUOTA);
NamespaceQuotaParam quotaParam = new NamespaceQuotaParam(id,
quota.get(LIMIT), quota.get(WARN));
NamespaceQuotaAction.create(connection, prefix(id), quotaParam);
}
if (parameters.containsKey(RETENTION)) {
@SuppressWarnings(UNCHECKED)
Map<String, Integer> retention = (Map<String, Integer>) parameters
.get(RETENTION);
for (Map.Entry<String, Integer> entry : retention.entrySet()) {
NamespaceRetentionAction.create(connection, prefix(id),
new RetentionClassCreate(entry.getKey(),
entry.getValue()));
}
}
}
开发者ID:codedellemc,项目名称:ecs-cf-service-broker,代码行数:31,代码来源:EcsService.java
示例8: createDuplicateServiceInstanceIdFails
import org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException; //导入依赖的package包/类
@Test
public void createDuplicateServiceInstanceIdFails() throws Exception {
when(serviceInstanceService.createServiceInstance(eq(syncCreateRequest)))
.thenThrow(new ServiceInstanceExistsException(syncCreateRequest.getServiceInstanceId(),
syncCreateRequest.getServiceDefinitionId()));
setupCatalogService(syncCreateRequest.getServiceDefinitionId());
mockMvc.perform(put(buildUrl(syncCreateRequest, false))
.content(DataFixture.toJson(syncCreateRequest))
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isConflict())
.andExpect(jsonPath("$.description", containsString(syncCreateRequest.getServiceInstanceId())));
}
开发者ID:spring-cloud,项目名称:spring-cloud-cloudfoundry-service-broker,代码行数:16,代码来源:ServiceInstanceControllerIntegrationTest.java
示例9: createServiceInstance
import org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException; //导入依赖的package包/类
@Override
public CreateServiceInstanceResponse createServiceInstance(CreateServiceInstanceRequest request) {
admin.createRepositoryIfNotExists();
// check if exists already
BrooklynServiceInstance instance = getServiceInstance(request.getServiceInstanceId());
if (instance != null) {
throw new ServiceInstanceExistsException(instance.getServiceInstanceId(), instance.getServiceDefinitionId());
}
LOG.info("creating service: [serviceInstanceId={}, planID={}, organizationGuid={}, spaceGuid={}",
request.getServiceInstanceId(),
request.getPlanId(),
request.getOrganizationGuid(),
request.getSpaceGuid()
);
ServiceDefinition service = catalogService.getServiceDefinition(request.getServiceDefinitionId());
String blueprint = createBlueprint(service, request);
Future<TaskSummary> taskSummaryFuture = admin.createApplication(blueprint);
TaskSummary taskSummary = ServiceUtil.getFutureValueLoggingError(taskSummaryFuture);
instance = new BrooklynServiceInstance(request.getServiceInstanceId(), request.getServiceDefinitionId())
.withPlanId(request.getPlanId())
.withEntityId(taskSummary.getEntityId());
repository.save(instance.withOperation(Operations.CREATING).withOperationStatus(OperationState.IN_PROGRESS));
return new CreateServiceInstanceResponse().withAsync(request.isAsyncAccepted());
}
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:28,代码来源:BrooklynServiceInstanceService.java
示例10: serviceInstanceCreationFailsWithExistingInstance
import org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException; //导入依赖的package包/类
@Test(expected=ServiceInstanceExistsException.class)
public void serviceInstanceCreationFailsWithExistingInstance()
throws ServiceInstanceExistsException, ServiceBrokerException {
when(repository.findOne(any(String.class))).thenReturn(TEST_SERVICE_INSTANCE);
CreateServiceInstanceRequest request = new CreateServiceInstanceRequest(serviceDefinition.getId(), "planId", "organizationGuid", "spaceGuid");
service.createServiceInstance(request.withServiceInstanceId(SVC_INST_ID));
}
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:8,代码来源:BrooklynServiceInstanceServiceTest.java
示例11: serviceInstanceRetrievedSuccessfully
import org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException; //导入依赖的package包/类
@Test
public void serviceInstanceRetrievedSuccessfully()
throws ServiceInstanceExistsException, ServiceBrokerException{
when(repository.findOne(any(String.class))).thenReturn(TEST_SERVICE_INSTANCE);
String serviceInstanceId = TEST_SERVICE_INSTANCE.getServiceInstanceId();
assertEquals(serviceInstanceId, service.getServiceInstance(serviceInstanceId).getServiceInstanceId());
}
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:9,代码来源:BrooklynServiceInstanceServiceTest.java
示例12: serviceInstanceDeletedSuccessfully
import org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException; //导入依赖的package包/类
@Test
public void serviceInstanceDeletedSuccessfully()
throws ServiceInstanceExistsException, ServiceBrokerException {
when(repository.findOne(any(String.class))).thenReturn(TEST_SERVICE_INSTANCE);
String instanceId = TEST_SERVICE_INSTANCE.getServiceInstanceId();
DeleteServiceInstanceRequest request = new DeleteServiceInstanceRequest(instanceId, "serviceId", "planId", null);
assertNotNull(service.deleteServiceInstance(request));
}
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:10,代码来源:BrooklynServiceInstanceServiceTest.java
示例13: serviceInstanceCreationFailsWithExistingInstance
import org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException; //导入依赖的package包/类
@Test(expected=ServiceInstanceExistsException.class)
public void serviceInstanceCreationFailsWithExistingInstance() throws Exception {
when(repository.findOne(any(String.class))).thenReturn(ServiceInstanceFixture.getServiceInstance());
service.createServiceInstance(buildCreateRequest());
}
开发者ID:cf-platform-eng,项目名称:mongodb-broker,代码行数:7,代码来源:MongoServiceInstanceServiceTest.java
示例14: handleException
import org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException; //导入依赖的package包/类
@ExceptionHandler(ServiceInstanceExistsException.class)
public ResponseEntity<ErrorMessage> handleException(ServiceInstanceExistsException ex) {
log.debug("Service instance already exists: ", ex);
return getErrorResponse(ex.getMessage(), HttpStatus.CONFLICT);
}
开发者ID:spring-cloud,项目名称:spring-cloud-cloudfoundry-service-broker,代码行数:6,代码来源:ServiceInstanceController.java
注:本文中的org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论