Search in sources :

Example 1 with CoordinatorSerializable

use of com.emc.storageos.coordinator.client.model.CoordinatorSerializable in project coprhd-controller by CoprHD.

the class CoordinatorClientImpl method queryRuntimeState.

@Override
public <T extends CoordinatorSerializable> T queryRuntimeState(String key, Class<T> clazz) throws CoordinatorException {
    String path = String.format("%s/%s", ZkPath.STATE, key);
    try {
        byte[] data = _zkConnection.curator().getData().forPath(path);
        CoordinatorSerializable state = clazz.newInstance();
        return (T) state.decodeFromString(new String(data, "UTF-8"));
    } catch (KeeperException.NoNodeException ignore) {
        // Ignore exception, don't re-throw
        log.debug("Caught exception but ignoring it: " + ignore);
        return null;
    } catch (Exception e) {
        throw CoordinatorException.fatals.unableToFindTheState(key, e);
    }
}
Also used : CoordinatorSerializable(com.emc.storageos.coordinator.client.model.CoordinatorSerializable) 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)

Aggregations

CoordinatorSerializable (com.emc.storageos.coordinator.client.model.CoordinatorSerializable)1 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)1 PropertyInfoMapper.decodeFromString (com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 KeeperException (org.apache.zookeeper.KeeperException)1