Search in sources :

Example 1 with VersionChecker

use of com.emc.storageos.util.VersionChecker in project coprhd-controller by CoprHD.

the class DataCollectionTest method setup.

@Before
public void setup() {
    try {
        for (Lock lock : Lock.values()) {
            Method method = lock.getClass().getDeclaredMethod("setLock", InterProcessLock.class);
            method.setAccessible(true);
            Object[] parameters = new Object[1];
            parameters[0] = _coordinator.getLock(lock.name());
            method.invoke(lock, parameters);
        }
        _dbClient.start();
        if (_provider != null) {
            String providerKey = _provider.getIPAddress() + "-" + _provider.getPortNumber();
            List<StorageProvider> providers = CustomQueryUtility.getActiveStorageProvidersByProviderId(_dbClient, providerKey);
            if (providers != null && !providers.isEmpty()) {
                _providerURI = providers.get(0).getId();
                _logger.warn("Provider has already been in db.");
            } else if (isTestNewProvider) {
                _providerURI = URIUtil.createId(StorageProvider.class);
                _provider.setId(_providerURI);
                _dbClient.createObject(_provider);
            }
        }
        CIMConnectionFactory cimConnectionFactory = new CIMConnectionFactory();
        cimConnectionFactory.setDbClient(_dbClient);
        cimConnectionFactory.setConnectionManager(_connectionManager);
        DataCollectionJobScheduler scheduler = new DataCollectionJobScheduler();
        scheduler.setConfigInfo(_configInfo);
        scheduler.setConnectionFactory(cimConnectionFactory);
        scheduler.setCoordinator(_coordinator);
        scheduler.setDbClient(_dbClient);
        _jobUtil = new DataCollectionJobUtil();
        _jobUtil.setDbClient(_dbClient);
        _jobUtil.setConfigInfo(_configInfo);
        _jobConsumer = new TestDataCollectionJobConsumer();
        _jobConsumer.setConfigInfo(_configInfo);
        _jobConsumer.setConnectionFactory(cimConnectionFactory);
        _jobConsumer.setCoordinator(_coordinator);
        _jobConsumer.setDbClient(_dbClient);
        _jobConsumer.setUtil(_jobUtil);
        _jobConsumer.setJobScheduler(scheduler);
        VersionChecker versionChecker = new VersionChecker();
        versionChecker.setCoordinator(_coordinator);
    } catch (Exception e) {
        _logger.error("Failed to run setup. Exception - " + e.getMessage());
        _logger.error(e.getMessage(), e);
    }
}
Also used : Method(java.lang.reflect.Method) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) Lock(com.emc.storageos.volumecontroller.impl.ControllerServiceImpl.Lock) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) VersionChecker(com.emc.storageos.util.VersionChecker) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) DataObject(com.emc.storageos.db.client.model.DataObject) Before(org.junit.Before)

Aggregations

DataObject (com.emc.storageos.db.client.model.DataObject)1 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)1 VersionChecker (com.emc.storageos.util.VersionChecker)1 Lock (com.emc.storageos.volumecontroller.impl.ControllerServiceImpl.Lock)1 CIMConnectionFactory (com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory)1 Method (java.lang.reflect.Method)1 InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)1 Before (org.junit.Before)1