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


Java ServiceInstance类代码示例

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


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

示例1: bind_doNothing_returnMultitenantCredentialsMap

import org.cloudfoundry.community.servicebroker.model.ServiceInstance; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void bind_doNothing_returnMultitenantCredentialsMap() throws Exception {
  //given
  String host = "jojoservice";
  String port = "10000";
  String expected = "jdbc:hive2://jojoservice:10000/%{organization};"
                    + "principal=hive/[email protected];auth=kerberos";
  ExternalConfiguration conf = new ExternalConfiguration();
  conf.setHiveServerHost(host);
  conf.setHiveServerPort(port);
  conf.setHiveProvidedZip(hadoopConf);
  HivePlanMultitenant plan = new HivePlanMultitenant(HiveBindingClientFactory.create(conf));

  //when
  ServiceInstance serviceInstance = getServiceInstance();
  Map<String, Object> actualOutputCredentials = plan.bind(serviceInstance);

  //then
  assertThat(actualOutputCredentials, hasEntry("connectionUrl", expected));
}
 
开发者ID:trustedanalytics,项目名称:hive-broker,代码行数:22,代码来源:HivePlanMultitenantTest.java

示例2: createServiceInstance

import org.cloudfoundry.community.servicebroker.model.ServiceInstance; //导入依赖的package包/类
@Override
public ServiceInstance createServiceInstance(CreateServiceInstanceRequest request) throws ServiceInstanceExistsException, ServiceBrokerException, ServiceBrokerAsyncRequiredException {
    ServiceInstance serviceInstance = new ServiceInstance(request);
    serviceInstance.withDashboardUrl(appUri);
    serviceInstance.withAsync(false);
    if (this.oauthRegServiceInstanceRepo.exists(request.getServiceInstanceId())) {
        throw new ServiceInstanceExistsException(serviceInstance);
    }
    OauthRegServiceInstance instance = this.generateOauthRegServiceInstance(serviceInstance);
    Driver driver = this.getDriverFromInstance(instance);
    if (!this.manageGlobalProvider.hasGlobalProviderConfig(driver)) {
        this.loadLoginProviderToInstance(request.getParameters(), instance);
    }
    String authenticationCode = this.getParameter(request.getParameters(), AUTHENTICATION_CODE_PARAMETER, null);
    instance.setAuthenticationCode(authenticationCode);
    this.oauthRegServiceInstanceRepo.save(instance);
    return serviceInstance;
}
 
开发者ID:cloudfoundry-community,项目名称:oauth-register-broker,代码行数:19,代码来源:OauthRegInstanceService.java

示例3: updateServiceInstance

import org.cloudfoundry.community.servicebroker.model.ServiceInstance; //导入依赖的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

示例4: deleteServiceInstance

import org.cloudfoundry.community.servicebroker.model.ServiceInstance; //导入依赖的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

示例5: deProvision

import org.cloudfoundry.community.servicebroker.model.ServiceInstance; //导入依赖的package包/类
private void deProvision(DeleteServiceInstanceRequest request, String id,
		ServiceInstance instance) {
	executor.execute(new Runnable() {
		@Override
		public void run() {
			try {
				if (COPY.equals(request.getPlanId())) {
					copyProvider.deleteCopy(instanceManager
							.getCopyIdForInstance(id));
				}
				log(id, "Deleted service instance", COMPLETE);
				instanceManager.removeInstance(id);
			} catch (ServiceBrokerException e) {
				log(id,
						"Failed to delete service instance: "
								+ e.getMessage(), FAILED);
				instance.withLastOperation(new ServiceInstanceLastOperation(
						"failed to delete", OperationState.FAILED));
				String copyId = instanceManager.getCopyIdForInstance(id);
				instanceManager.saveInstance(instance, copyId);
			}
		}
	});
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:25,代码来源:LCServiceInstanceService.java

示例6: testCreateInstanceBinding_success_shouldReturnZookeeperNodeInCredentials

import org.cloudfoundry.community.servicebroker.model.ServiceInstance; //导入依赖的package包/类
@Test
public void testCreateInstanceBinding_success_shouldReturnZookeeperNodeInCredentials()
    throws Exception {
  //arrange
  String bindingId = UUID.randomUUID().toString();
  String serviceInstanceId = UUID.randomUUID().toString();
  ServiceInstance instance = getServiceInstance(serviceInstanceId, "fakeBaseGuid-shared-plan");
  CreateServiceInstanceRequest instanceReq = getCreateInstanceRequest(instance);
  CreateServiceInstanceBindingRequest bindReq = getCreateBindingRequest(serviceInstanceId).withBindingId(bindingId);

  //act
  serviceBean.createServiceInstance(getCreateInstanceRequest(instance));
  ServiceInstanceBinding binding = bindingBean.createServiceInstanceBinding(bindReq);
  String namespaceInCredentials = (String) binding.getCredentials().get("zk.node");

  //assert
  assertThat(namespaceInCredentials, equalTo(conf.getBrokerRootNode() + "/" + serviceInstanceId));
}
 
开发者ID:trustedanalytics,项目名称:zookeeper-broker,代码行数:19,代码来源:ZookeeperBrokerIntegrationTest.java

示例7: itReturnsTheCorrectListOfServices

import org.cloudfoundry.community.servicebroker.model.ServiceInstance; //导入依赖的package包/类
@Test
public void itReturnsTheCorrectListOfServices()
		throws ServiceBrokerException, ServiceInstanceExistsException {

	Collection<Pair<String, ServiceInstance>> instances = createInstances();

	when(instanceManager.getInstances()).thenReturn(instances);

	List<InstancePair> provisionedInstances = service
			.getProvisionedInstances();
	assertThat(provisionedInstances, hasSize(5));
	assertTrue(provisionedInstances.contains(new InstancePair(
			"source_instance_id", "copy_instance2")));
	assertTrue(provisionedInstances.contains(new InstancePair(
			"source_instance_id", "source_instance_id")));
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:17,代码来源:LCServiceInstanceServiceCopyTest.java

示例8: itShouldSaveTheInstnaceAsFailedIfDeprovisionFails

import org.cloudfoundry.community.servicebroker.model.ServiceInstance; //导入依赖的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

示例9: deleteServiceInstance

import org.cloudfoundry.community.servicebroker.model.ServiceInstance; //导入依赖的package包/类
@Override
public ServiceInstance deleteServiceInstance(DeleteServiceInstanceRequest request)
    throws ServiceBrokerException {

    LOGGER.debug(LoggerHelper
        .getParamsAsString("deleteServiceInstance", request.getServiceInstanceId(),
            request.getServiceId(), request.getPlanId()));

    Optional<ServiceInstance> instance;
    try {
        Location storingLocation = Location.newInstance(request.getServiceInstanceId());
        instance = store.deleteById(storingLocation);
    } catch (IOException e) {
        throw new ServiceBrokerException(e.getMessage(), e);
    }
    return instance.orElse(null);
}
 
开发者ID:trustedanalytics,项目名称:broker-store,代码行数:18,代码来源:ServiceInstanceServiceStore.java

示例10: findServiceInstance

import org.cloudfoundry.community.servicebroker.model.ServiceInstance; //导入依赖的package包/类
public ServiceInstance findServiceInstance(String instanceId) throws SQLException {
    Utils.checkValidUUID(instanceId);

    Map<Integer, String> parameterMap = new HashMap<Integer, String>();
    parameterMap.put(1, instanceId);

    Map<String, String> result = PostgreSQLDatabase.executePreparedSelect("SELECT * FROM service WHERE serviceinstanceid = ?", parameterMap);

    String serviceDefinitionId = result.get("servicedefinitionid");
    String organizationGuid = result.get("organizationguid");
    String planId = result.get("planid");
    String spaceGuid = result.get("spaceguid");

    CreateServiceInstanceRequest wrapper = new CreateServiceInstanceRequest(serviceDefinitionId, planId, organizationGuid, spaceGuid).withServiceInstanceId(instanceId);
    return new ServiceInstance(wrapper);
}
 
开发者ID:cloudfoundry-community,项目名称:postgresql-cf-service-broker,代码行数:17,代码来源:Database.java

示例11: createServiceInstance

import org.cloudfoundry.community.servicebroker.model.ServiceInstance; //导入依赖的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

示例12: testCreateServiceInstance_success_shouldReturnCreatedInstanceAndStoreCredentials

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

  // arrange
  final String INSTANCE_ID = "instanceId0";
  when(h2oProvisionerRestApi.createH2oInstance(INSTANCE_ID, conf.getH2oMapperNodes(),
      conf.getH2oMapperMemory(), true, yarnConfig))
          .thenReturn(new ResponseEntity<>(CREDENTIALS, HttpStatus.OK));

  // act
  CreateServiceInstanceRequest request =
      CfBrokerRequestsFactory.getCreateInstanceRequest(INSTANCE_ID);
  ServiceInstance createdInstance = instanceService.createServiceInstance(request);

  // assert
  assertThat(createdInstance.getServiceInstanceId(), equalTo(INSTANCE_ID));

  freeze().until(() -> credentialsStore.getById(Location.newInstance(INSTANCE_ID)).get(),
      equalTo(CREDENTIALS));

  verify(h2oProvisionerRestApi, times(1)).createH2oInstance(INSTANCE_ID, conf.getH2oMapperNodes(),
      conf.getH2oMapperMemory(), true, yarnConfig);
}
 
开发者ID:trustedanalytics,项目名称:h2o-broker,代码行数:25,代码来源:H2oBrokerIntegrationTest.java

示例13: testDeleteServiceInstance_success_shouldReturnRemovedInstance

import org.cloudfoundry.community.servicebroker.model.ServiceInstance; //导入依赖的package包/类
@Test
public void testDeleteServiceInstance_success_shouldReturnRemovedInstance() throws Exception {
  // arrange
  final String INSTANCE_ID = "instanceId1";
  when(h2oProvisionerRestApi.createH2oInstance(INSTANCE_ID, conf.getH2oMapperNodes(),
      conf.getH2oMapperMemory(), true, yarnConfig))
          .thenReturn(new ResponseEntity<>(CREDENTIALS, HttpStatus.OK));
  when(h2oProvisionerRestApi.deleteH2oInstance(INSTANCE_ID, yarnConfig))
      .thenReturn(new ResponseEntity<>("test-job-id", HttpStatus.OK));
  ServiceInstance instance = instanceService
      .createServiceInstance(CfBrokerRequestsFactory.getCreateInstanceRequest(INSTANCE_ID));

  // act
  ServiceInstance removedInstance = instanceService
      .deleteServiceInstance(new DeleteServiceInstanceRequest(instance.getServiceInstanceId(),
          instance.getServiceDefinitionId(), instance.getPlanId()));

  // assert
  verify(h2oProvisionerRestApi, times(1)).deleteH2oInstance(INSTANCE_ID, yarnConfig);
  assertThat(instance.getServiceInstanceId(), equalTo(removedInstance.getServiceInstanceId()));
}
 
开发者ID:trustedanalytics,项目名称:h2o-broker,代码行数:22,代码来源:H2oBrokerIntegrationTest.java

示例14: createServiceInstance_provisionerAndStoreWorks_instanceCreated

import org.cloudfoundry.community.servicebroker.model.ServiceInstance; //导入依赖的package包/类
@Test
public void createServiceInstance_provisionerAndStoreWorks_instanceCreated() throws Exception {
  // arrange
  CreateServiceInstanceRequest request =
      CfBrokerRequestsFactory.getCreateInstanceRequest(INSTANCE_ID);
  ServiceInstance expectedInstance = new ServiceInstance(request);
  H2oCredentials expectedCredentials = new H2oCredentials("a", "b", "c", "d");

  when(delegateMock.createServiceInstance(request)).thenReturn(expectedInstance);
  when(h2oProvisioner.provisionInstance(INSTANCE_ID)).thenReturn(expectedCredentials);
  doNothing().when(credentialsStoreMock).save(Location.newInstance(INSTANCE_ID),
      expectedCredentials);

  // act
  ServiceInstance createdInstance = instanceService.createServiceInstance(request);

  // assert
  assertThat(createdInstance, equalTo(expectedInstance));
  verify(delegateMock, timeout(200)).createServiceInstance(request);
  verify(h2oProvisioner, timeout(200)).provisionInstance(INSTANCE_ID);
  verify(credentialsStoreMock, timeout(200)).save(Location.newInstance(INSTANCE_ID),
      expectedCredentials);
}
 
开发者ID:trustedanalytics,项目名称:h2o-broker,代码行数:24,代码来源:H2oServiceInstanceServiceTest.java

示例15: createServiceInstance_provisionerFails_instanceCreated

import org.cloudfoundry.community.servicebroker.model.ServiceInstance; //导入依赖的package包/类
@Test
public void createServiceInstance_provisionerFails_instanceCreated() throws Exception {
  // arrange
  CreateServiceInstanceRequest request =
      CfBrokerRequestsFactory.getCreateInstanceRequest(INSTANCE_ID);
  ServiceInstance expectedInstance = new ServiceInstance(request);

  when(delegateMock.createServiceInstance(request)).thenReturn(expectedInstance);
  when(h2oProvisioner.provisionInstance(INSTANCE_ID)).thenThrow(new ServiceBrokerException(""));

  // act
  ServiceInstance createdInstance = instanceService.createServiceInstance(request);

  // assert
  assertThat(createdInstance, equalTo(expectedInstance));
  verify(delegateMock, timeout(200)).createServiceInstance(request);
  verify(h2oProvisioner, timeout(200)).provisionInstance(INSTANCE_ID);
}
 
开发者ID:trustedanalytics,项目名称:h2o-broker,代码行数:19,代码来源:H2oServiceInstanceServiceTest.java


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