com.sap.cloud.mt.subscription.InstanceLifecycleManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of multi-tenant-subscription Show documentation
Show all versions of multi-tenant-subscription Show documentation
Spring Boot Enablement Parent
/******************************************************************************
* © 2020 SAP SE or an SAP affiliate company. All rights reserved. *
******************************************************************************/
package com.sap.cloud.mt.subscription;
import com.sap.cloud.mt.subscription.exceptions.InternalError;
import com.sap.cloud.mt.subscription.exceptions.UnknownTenant;
import com.sap.xsa.core.instancemanager.client.InstanceCreationOptions;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
public interface InstanceLifecycleManager {
public static final String DATABASE_ID = "database_id";
public void createNewInstance(String tenantId, InstanceCreationOptions instanceCreationOptions) throws InternalError;
public void deleteInstance(String tenantId) throws InternalError;
public DataSourceInfo getDataSourceInfo(String tenantId, boolean forceCacheUpdate) throws InternalError, UnknownTenant;
public ContainerStatus getContainerStatus(String tenantId) throws InternalError;
/**
* Returns all tenants that have a DB container/schema
*
* @param forceCacheUpdate If set, the current list of tenants is re-determined.
* @return A set with all tenant ids
* @throws InternalError
*/
public Set getAllTenants(boolean forceCacheUpdate) throws InternalError;
/**
* Checks if a schema has been created for a tenant
*
* @param tenantId identifier of tenant that is checked
* @throws UnknownTenant is thrown if tenant doesn't exist
* @throws InternalError is thrown if a problem occurs, if for example service manager or DB cannot be accessed
*/
public void checkThatTenantExists(String tenantId) throws UnknownTenant, InternalError;
public static enum ContainerStatus {
OK("ok"), IN_PROGRESS("in progress"), ERRONEOUS("erroneous"), DOES_NOT_EXIST("doesn't exist"), CREATION_ERROR("creation error");
private String status;
ContainerStatus(String status) {
this.status = status;
}
@Override
public String toString() {
return status;
}
}
/**
* Creates on the database used by the given datasource a hdi container/schema reserved of the library itself.
* If the parameter is null or the database cannot be determined, the missing containers are created on all databases.
* When used with Hana a service instance is created for tenant MT_LIB_TENANT-"database id"
* No error is thrown if container creation failed !
*
* @param dataSourceInfo Credentials of dataSource for which lib container is created
* @return Info for lib container
* @throws InternalError is thrown when a communication problems arises
*/
public List createAndGetLibContainers(DataSourceInfo dataSourceInfo) throws InternalError;
/**
* @return the credentials of mt-libs's own containers/schemas. In case of HANA, the list is based
* on the current state of the instance manager client libs cache.
* @throws InternalError is thrown when a communication problems arises
*/
public List getLibContainers() throws InternalError;
/**
* The mt-lib creates a container/schema in each provided database for itself. This function returns
* the fake tenantId which is used for it.
*
* @param databaseId
* @return tenantId for mt-lib schema/container
*/
public default String getMtLibContainerName(String databaseId) {
return FilterTenants.MT_LIB_TENANT_PREFIX + databaseId;
}
/**
* Create InstanceCreateOptions that contain the specified database id
*
* @param databaseId
* @return new instance create options with set database id
*/
public default InstanceCreationOptions createInstanceCreationOptions(String databaseId) {
InstanceCreationOptions instanceCreationOptions = new InstanceCreationOptions();
Map provisioningParameters = new HashMap<>();
provisioningParameters.put(DATABASE_ID, databaseId);
instanceCreationOptions.withProvisioningParameters(provisioningParameters);
return instanceCreationOptions;
}
public boolean hasDbIdentifiers();
public void insertDbIdentifiers(DbIdentifiers dbIdentifiers);
default DbIdentifiers.DB getDbType() {
return DbIdentifiers.DB.HANA;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy