class HighAvailabilityServicesUtils {

	public static Path getClusterHighAvailableStoragePath(Configuration configuration) {
		final String storagePath = configuration.getValue(
			HighAvailabilityOptions.HA_STORAGE_PATH);

		if (isNullOrWhitespaceOnly(storagePath)) {
			throw new IllegalConfigurationException("Configuration is missing the mandatory parameter: " +
				HighAvailabilityOptions.HA_STORAGE_PATH);
		}

		final Path path;
		try {
			path = new Path(storagePath);
		} catch (Exception e) {
			throw new IllegalConfigurationException("Invalid path for highly available storage (" +
				HighAvailabilityOptions.HA_STORAGE_PATH.key() + ')', e);
		}

		final String clusterId = configuration.getValue(HighAvailabilityOptions.HA_CLUSTER_ID);

		final Path clusterStoragePath;

		try {
			clusterStoragePath = new Path(path, clusterId);
		} catch (Exception e) {
			throw new IllegalConfigurationException(
				String.format("Cannot create cluster high available storage path '%s/%s'. This indicates that an invalid cluster id (%s) has been specified.",
					storagePath,
					clusterId,
					HighAvailabilityOptions.HA_CLUSTER_ID.key()),
				e);
		}
		return clusterStoragePath;
	}

}