Search in sources :

Example 26 with CoordinatorException

use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.

the class CoordinatorClientImpl method commitTransaction.

@Override
public void commitTransaction() throws CoordinatorException {
    try {
        CuratorTransaction handler = zkTransactionHandler.get();
        CuratorTransactionFinal tx = (CuratorTransactionFinal) handler;
        tx.commit();
        zkTransactionHandler.remove();
    } catch (Exception ex) {
        throw CoordinatorException.fatals.unableToPersistTheConfiguration(ex);
    }
}
Also used : CuratorTransaction(org.apache.curator.framework.api.transaction.CuratorTransaction) CuratorTransactionFinal(org.apache.curator.framework.api.transaction.CuratorTransactionFinal) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 27 with CoordinatorException

use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.

the class CoordinatorClientImpl method removeServiceConfiguration.

@Override
public void removeServiceConfiguration(String siteId, Configuration... configs) throws CoordinatorException {
    for (int i = 0; i < configs.length; i++) {
        Configuration config = configs[i];
        String prefix = "";
        if (siteId != null) {
            prefix = getSitePrefix(siteId);
        }
        String servicePath = String.format("%1$s%2$s/%3$s/%4$s", prefix, ZkPath.CONFIG, config.getKind(), config.getId());
        try {
            CuratorTransaction handler = zkTransactionHandler.get();
            if (handler != null) {
                CuratorTransactionFinal tx = handler.delete().forPath(servicePath).and();
                zkTransactionHandler.set(tx);
            } else {
                _zkConnection.curator().delete().forPath(servicePath);
            }
        } catch (KeeperException.NoNodeException ignore) {
            // Ignore exception, don't re-throw
            log.debug("Caught exception but ignoring it: " + ignore);
        } catch (Exception e) {
            throw CoordinatorException.fatals.unableToRemoveConfiguration(config.getId(), e);
        }
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) CuratorTransaction(org.apache.curator.framework.api.transaction.CuratorTransaction) CuratorTransactionFinal(org.apache.curator.framework.api.transaction.CuratorTransactionFinal) PropertyInfoMapper.decodeFromString(com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString) KeeperException(org.apache.zookeeper.KeeperException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 28 with CoordinatorException

use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.

the class WorkPoolImpl method start.

@Override
public synchronized void start() throws CoordinatorException {
    // setup group, lock, and item paths
    EnsurePath path = new EnsurePath(_workItemPath);
    try {
        path.ensure(_zkClient.getZookeeperClient());
        path = new EnsurePath(_workItemLockPath);
        path.ensure(_zkClient.getZookeeperClient());
    } catch (Exception e) {
        throw CoordinatorException.retryables.unableToStartWork(_workItemPath, e);
    }
    // add listeners
    _zkClient.getConnectionStateListenable().addListener(_connectionStateListener);
    _zkClient.getCuratorListenable().addListener(_changeWatcher);
    // prime assignment loop
    refresh();
}
Also used : EnsurePath(org.apache.curator.utils.EnsurePath) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) KeeperException(org.apache.zookeeper.KeeperException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException)

Example 29 with CoordinatorException

use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.

the class LoggingMBean method persistLogLevel.

private void persistLogLevel(String level, int expirInMin, String scope) {
    ConfigurationImpl config = new ConfigurationImpl();
    config.setKind(_logName);
    config.setId(_hostId);
    long expiration = System.currentTimeMillis() + expirInMin * 60 * 1000;
    String configStr = level + LOG_LEVEL_DELIMITER + String.valueOf(expiration) + LOG_LEVEL_DELIMITER + scope;
    config.setConfig(LOG_LEVEL_CONFIG, configStr);
    try {
        _log.info("Persisting log level configuration");
        _coordinator.persistServiceConfiguration(config);
        _log.info("Persist log level configuration succeed");
    } catch (CoordinatorException e) {
        _log.error("Exception persisting log level config {}:", configStr, e);
        return;
    }
}
Also used : CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Aggregations

CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)29 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)19 UnknownHostException (java.net.UnknownHostException)14 KeeperException (org.apache.zookeeper.KeeperException)13 PropertyInfoMapper.decodeFromString (com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString)12 IOException (java.io.IOException)12 Site (com.emc.storageos.coordinator.client.model.Site)6 Configuration (com.emc.storageos.coordinator.common.Configuration)6 EnsurePath (org.apache.curator.utils.EnsurePath)6 Service (com.emc.storageos.coordinator.common.Service)5 PropertyInfo (com.emc.storageos.model.property.PropertyInfo)3 ClusterInfo (com.emc.vipr.model.sys.ClusterInfo)3 ArrayList (java.util.ArrayList)3 CuratorTransaction (org.apache.curator.framework.api.transaction.CuratorTransaction)3 CuratorTransactionFinal (org.apache.curator.framework.api.transaction.CuratorTransactionFinal)3 CoordinatorClientImpl (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl)2 ZkPath (com.emc.storageos.coordinator.common.impl.ZkPath)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)2 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)2