Search in sources :

Example 1 with ExternalBlockStorageDevice

use of com.emc.storageos.volumecontroller.impl.externaldevice.ExternalBlockStorageDevice in project coprhd-controller by CoprHD.

the class ControllerServiceImpl method initExternalBlockStorageDevice.

private void initExternalBlockStorageDevice(List<StorageSystemType> types) {
    ExternalBlockStorageDevice blockDevice = (ExternalBlockStorageDevice) getBean(StorageDriverManager.EXTERNAL_STORAGE_DEVICE);
    // key: storage system type name, value: driver instance
    Map<String, AbstractStorageDriver> blockDeviceDrivers = blockDevice.getDrivers();
    // key: main class name, value: driver instance
    Map<String, AbstractStorageDriver> cachedDriverInstances = new HashMap<String, AbstractStorageDriver>();
    for (StorageSystemType type : types) {
        String typeName = type.getStorageTypeName();
        String metaType = type.getMetaType();
        if (!StringUtils.equals(metaType, StorageSystemType.META_TYPE.BLOCK.toString())) {
            // TODO for now it seems that we only support block type driver
            // In future, to support file/object or other type, we need add more codes here
            _log.info("Skip load info of {}, for its type is {} which is not supported for now", typeName, metaType);
            continue;
        }
        String className = type.getDriverClassName();
        // provider and managed system should use the same driver instance
        if (cachedDriverInstances.containsKey(className)) {
            blockDeviceDrivers.put(typeName, cachedDriverInstances.get(className));
            _log.info("Driver info for storage system type {} has been set into externalBlockStorageDevice instance", typeName);
            continue;
        }
        String mainClassName = type.getDriverClassName();
        try {
            AbstractStorageDriver driverInstance = (AbstractStorageDriver) Class.forName(mainClassName).newInstance();
            blockDeviceDrivers.put(typeName, driverInstance);
            cachedDriverInstances.put(className, driverInstance);
            _log.info("Driver info for storage system type {} has been set into externalBlockStorageDevice instance", typeName);
        } catch (Exception e) {
            _log.error("Error happened when instantiating class {}", mainClassName);
        }
    }
}
Also used : ExternalBlockStorageDevice(com.emc.storageos.volumecontroller.impl.externaldevice.ExternalBlockStorageDevice) HashMap(java.util.HashMap) AbstractStorageDriver(com.emc.storageos.storagedriver.AbstractStorageDriver) StorageSystemType(com.emc.storageos.db.client.model.StorageSystemType) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) BeansException(org.springframework.beans.BeansException)

Aggregations

StorageSystemType (com.emc.storageos.db.client.model.StorageSystemType)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 AbstractStorageDriver (com.emc.storageos.storagedriver.AbstractStorageDriver)1 ExternalBlockStorageDevice (com.emc.storageos.volumecontroller.impl.externaldevice.ExternalBlockStorageDevice)1 HashMap (java.util.HashMap)1 BeansException (org.springframework.beans.BeansException)1