use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.
the class CoordinatorClientImpl method persistServiceConfiguration.
@Override
public void persistServiceConfiguration(String siteId, Configuration... configs) throws CoordinatorException {
try {
for (Configuration config : configs) {
String configParentPath = getKindPath(siteId, config.getKind());
EnsurePath path = new EnsurePath(configParentPath);
path.ensure(_zkConnection.curator().getZookeeperClient());
String servicePath = String.format("%1$s/%2$s", configParentPath, config.getId());
Stat stat = _zkConnection.curator().checkExists().forPath(servicePath);
CuratorTransaction handler = zkTransactionHandler.get();
if (stat != null) {
if (handler != null) {
CuratorTransactionFinal tx = handler.setData().forPath(servicePath, config.serialize()).and();
zkTransactionHandler.set(tx);
} else {
_zkConnection.curator().setData().forPath(servicePath, config.serialize());
}
} else {
if (handler != null) {
CuratorTransactionFinal tx = handler.create().forPath(servicePath, config.serialize()).and();
zkTransactionHandler.set(tx);
} else {
_zkConnection.curator().create().forPath(servicePath, config.serialize());
}
}
}
} catch (final Exception e) {
log.error("Failed to persist service configuration e=", e);
throw CoordinatorException.fatals.unableToPersistTheConfiguration(e);
}
}
use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.
the class CoordinatorClientImpl method queryAllConfiguration.
@Override
public List<Configuration> queryAllConfiguration(String siteId, String kind) throws CoordinatorException {
String serviceParentPath = getKindPath(siteId, kind);
List<String> configPaths;
try {
configPaths = _zkConnection.curator().getChildren().forPath(serviceParentPath);
} catch (KeeperException.NoNodeException ignore) {
// Ignore exception, don't re-throw
log.debug("Caught exception but ignoring it: " + ignore);
return Arrays.asList(new Configuration[0]);
} catch (Exception e) {
throw CoordinatorException.fatals.unableToListAllConfigurationForKind(kind, e);
}
List<Configuration> configs = new ArrayList<Configuration>(configPaths.size());
for (String configPath : configPaths) {
Configuration config = queryConfiguration(siteId, kind, configPath);
if (config != null) {
configs.add(config);
}
}
return configs;
}
use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.
the class GenericSerializer method serialize.
/**
* Will serialize any serializable object.
* @param object -- Java object that is serializable.
* @param logName -- Name of object for log messages (can be null)
* @param zkData -- if true, will impose a maximum size limit of MAX_ZK_OBJECT_SIZE_IN_BYTES, which is maximum size for zookeeper data
* @return byte[] representing serialized data
* @throws CoordinatorException for exceedingLimit if checked
*/
public static byte[] serialize(Object object, String logName, boolean zkData) {
String className = (object != null) ? object.getClass().getSimpleName() : "";
String label = (logName != null) ? logName : "";
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ObjectOutputStream ostream = new ObjectOutputStream(stream);
ostream.writeObject(object);
byte[] byteArray = stream.toByteArray();
if (zkData && byteArray.length > MAX_ZK_OBJECT_SIZE_IN_BYTES) {
_log.error(String.format("Serialization failure: Class %s %s Byte Array length is %d limit is %d", className, label, byteArray.length, MAX_ZK_OBJECT_SIZE_IN_BYTES));
throw CoordinatorException.fatals.exceedingLimit("byte array size", MAX_ZK_OBJECT_SIZE_IN_BYTES);
} else if (byteArray.length > LOG_SIZE_IN_BYTES) {
_log.info(String.format("Serialization large object class %s %s size %d", className, label, byteArray.length));
}
return byteArray;
} catch (Exception ex) {
throw CoordinatorException.fatals.failedToSerialize(ex);
}
}
use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.
the class DrUtil method isAllSyssvcUp.
/**
* Check if all syssvc is up and running for specified site
* @param siteId
* @return true if all syssvc is running
*/
public boolean isAllSyssvcUp(String siteId) {
// Get service beacons for given site - - assume syssvc on all sites share same service name in beacon
try {
String syssvcName = ((CoordinatorClientImpl) coordinator).getSysSvcName();
String syssvcVersion = ((CoordinatorClientImpl) coordinator).getSysSvcVersion();
List<Service> svcs = coordinator.locateAllServices(siteId, syssvcName, syssvcVersion, null, null);
Site site = this.getSiteFromLocalVdc(siteId);
log.info("Node count is {}, running syssvc count is", site.getNodeCount(), svcs.size());
return svcs.size() == site.getNodeCount();
} catch (CoordinatorException ex) {
return false;
}
}
use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.
the class CoordinatorClientImpl method isDatabaseServiceUp.
private Boolean isDatabaseServiceUp(String serviceName) {
try {
String siteId = _zkConnection.getSiteId();
List<Service> services = locateAllServices(siteId, serviceName, dbVersionInfo.getSchemaVersion(), null, null);
DrUtil drUtil = new DrUtil(this);
Site site = drUtil.getSiteFromLocalVdc(siteId);
log.info("Node count is {}, running {} count is {}", site.getNodeCount(), serviceName, services.size());
return services.size() == site.getNodeCount();
} catch (CoordinatorException e) {
return false;
}
}
Aggregations