/** * Get a service connector for the given service id, the connector type, configured with the given config * * @param serviceId the service id * @param serviceConnectorType The expected class of service connector such as, DataSource.class. * @param serviceConnectorConfig service connector configuration (such as pooling parameters). * */ public <SC> SC getServiceConnector(String serviceId, Class<SC> serviceConnectorType, ServiceConnectorConfig serviceConnectorConfig) { ServiceInfo serviceInfo = getServiceInfo(serviceId); return getServiceConnector(serviceInfo, serviceConnectorType, serviceConnectorConfig); }
/** * Get a service connector for the given service id, the connector type, configured with the given config * * * @param <SC> The class of the service connector to return. * @param serviceId the service id * @param serviceConnectorType The expected class of service connector such as, DataSource.class. * @param serviceConnectorConfig service connector configuration (such as pooling parameters). * @return a service connector of the specified type with the given configuration applied * */ public <SC> SC getServiceConnector(String serviceId, Class<SC> serviceConnectorType, ServiceConnectorConfig serviceConnectorConfig) { ServiceInfo serviceInfo = getServiceInfo(serviceId); return getServiceConnector(serviceInfo, serviceConnectorType, serviceConnectorConfig); }
/** * Get a service connector for the given service id, the connector type, configured with the given config * * * @param <SC> The class of the service connector to return. * @param serviceId the service id * @param serviceConnectorType The expected class of service connector such as, DataSource.class. * @param serviceConnectorConfig service connector configuration (such as pooling parameters). * @return a service connector of the specified type with the given configuration applied * */ public <SC> SC getServiceConnector(String serviceId, Class<SC> serviceConnectorType, ServiceConnectorConfig serviceConnectorConfig) { ServiceInfo serviceInfo = getServiceInfo(serviceId); return getServiceConnector(serviceInfo, serviceConnectorType, serviceConnectorConfig); }
/** * Get a service connector for the given service id, the connector type, configured with the given config * * * @param <SC> The class of the service connector to return. * @param serviceId the service id * @param serviceConnectorType The expected class of service connector such as, DataSource.class. * @param serviceConnectorConfig service connector configuration (such as pooling parameters). * @return a service connector of the specified type with the given configuration applied * */ public <SC> SC getServiceConnector(String serviceId, Class<SC> serviceConnectorType, ServiceConnectorConfig serviceConnectorConfig) { ServiceInfo serviceInfo = getServiceInfo(serviceId); return getServiceConnector(serviceInfo, serviceConnectorType, serviceConnectorConfig); }
private ObjectStoreServiceInfo getServiceInfo() { if (StringUtils.isEmpty(serviceName)) { LOGGER.warn("service name not specified in config files"); return null; } try { CloudFactory cloudFactory = new CloudFactory(); Cloud cloud = cloudFactory.getCloud(); return (ObjectStoreServiceInfo) cloud.getServiceInfo(serviceName); } catch (CloudException e) { LOGGER.warn(MessageFormat.format("Failed to detect service info for service \"{0}\"!", serviceName), e); } return null; }
private String getStoragePath(String serviceName) { if (StringUtils.isEmpty(serviceName)) { LOGGER.warn(Messages.FILE_SYSTEM_SERVICE_NAME_IS_NOT_SPECIFIED); return null; } try { CloudFactory cloudFactory = new CloudFactory(); Cloud cloud = cloudFactory.getCloud(); FileSystemServiceInfo serviceInfo = (FileSystemServiceInfo) cloud.getServiceInfo(serviceName); return serviceInfo.getStoragePath(); } catch (CloudException e) { LOGGER.warn(MessageFormat.format(Messages.FAILED_TO_DETECT_FILE_SERVICE_STORAGE_PATH, serviceName), e); } return null; }
@Test(expected=CloudException.class) public void getServiceInfoByInvalidId() { StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector(); Cloud testCloud = new Cloud(stubCloudConnector, serviceConnectorCreators); testCloud.getServiceInfo("foo"); }
@Test public void compositeServiceInfo() { StubServiceInfo testServiceInfo1 = new StubServiceInfo("test-id-1", "test-host", 1000, "test-username", "test-password"); StubServiceInfo testServiceInfo2 = new StubServiceInfo("test-id-2", "test-host", 1000, "test-username", "test-password"); ServiceInfo testCompositeServiceInfo = new StubCompositeServiceInfo("test-composite",testServiceInfo1, testServiceInfo2); StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector(testCompositeServiceInfo); Cloud testCloud = new Cloud(stubCloudConnector, serviceConnectorCreators); assertNotNull(testCloud.getServiceInfo("test-id-1")); assertNotNull(testCloud.getServiceInfo("test-id-2")); }
@Test public void compositeServiceInfoRecursive() { StubServiceInfo testServiceInfo1a = new StubServiceInfo("test-id-1a", "test-host", 1000, "test-username", "test-password"); StubServiceInfo testServiceInfo1b = new StubServiceInfo("test-id-1b", "test-host", 1000, "test-username", "test-password"); ServiceInfo testCompositeServiceInfo1 = new StubCompositeServiceInfo("test-composite-1",testServiceInfo1a, testServiceInfo1b); StubServiceInfo testServiceInfo2a = new StubServiceInfo("test-id-2a", "test-host", 1000, "test-username", "test-password"); StubServiceInfo testServiceInfo2b = new StubServiceInfo("test-id-2b", "test-host", 1000, "test-username", "test-password"); ServiceInfo testCompositeServiceInfo2 = new StubCompositeServiceInfo("test-composite-2",testServiceInfo2a, testServiceInfo2b); ServiceInfo testCompositeServiceInfo = new StubCompositeServiceInfo("test-composite",testCompositeServiceInfo1, testCompositeServiceInfo2); StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector(testCompositeServiceInfo); Cloud testCloud = new Cloud(stubCloudConnector, serviceConnectorCreators); assertNotNull(testCloud.getServiceInfo("test-id-1a")); assertNotNull(testCloud.getServiceInfo("test-id-1b")); assertNotNull(testCloud.getServiceInfo("test-id-2a")); assertNotNull(testCloud.getServiceInfo("test-id-2b")); }
@Test public void getServiceInfoByValidId() { StubServiceInfo testServiceInfo1 = new StubServiceInfo("test-id1", "test-host", 1000, "test-username", "test-password"); StubServiceInfo testServiceInfo2 = new StubServiceInfo("test-id2", "test-host", 1000, "test-username", "test-password"); StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector(testServiceInfo1, testServiceInfo2); Cloud testCloud = new Cloud(stubCloudConnector, serviceConnectorCreators); assertEquals(testServiceInfo1, testCloud.getServiceInfo(testServiceInfo1.getId())); assertEquals(testServiceInfo2, testCloud.getServiceInfo(testServiceInfo2.getId())); }