use of com.emc.storageos.isilon.restapi.IsilonSmartQuota in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doModifyFS.
@Override
public BiosCommandResult doModifyFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
try {
_log.info("IsilonFileStorageDevice doModifyFS {} - start", args.getFsId());
IsilonApi isi = getIsilonDevice(storage);
String quotaId = null;
if (args.getFsExtensions() != null && args.getFsExtensions().get(QUOTA) != null) {
quotaId = args.getFsExtensions().get(QUOTA);
} else {
final ServiceError serviceError = DeviceControllerErrors.isilon.unableToUpdateFileSystem(args.getFsId());
_log.error(serviceError.getMessage());
return BiosCommandResult.createErrorResult(serviceError);
}
IsilonSmartQuota expandedQuota = getExpandedQuota(isi, args, args.getFsCapacity());
isi.modifyQuota(quotaId, expandedQuota);
_log.info("IsilonFileStorageDevice doModifyFS {} - complete", args.getFsId());
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
_log.error("doModifyFS failed.", e);
return BiosCommandResult.createErrorResult(e);
} catch (Exception e) {
_log.error("doModifyFS failed.", e);
// convert this to a ServiceError and create/or reuse a service
// code
ServiceError serviceError = DeviceControllerErrors.isilon.unableToUpdateFileSystem(args.getFsId());
return BiosCommandResult.createErrorResult(serviceError);
}
}
use of com.emc.storageos.isilon.restapi.IsilonSmartQuota in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverAllFileSystem.
private HashMap<String, Object> discoverAllFileSystem(StorageSystem storageSystem, String resumetoken, String umfsDiscoverPath) {
URI storageSystemId = storageSystem.getId();
try {
_log.info("discoverAllFileSystem for storage system {} - start", storageSystemId);
IsilonApi isilonApi = getIsilonDevice(storageSystem);
List<IsilonAccessZone> accessZones = isilonApi.getAccessZones(null);
List<String> tempAccessZonePath = new ArrayList<>();
for (IsilonAccessZone accessZone : accessZones) {
if (!accessZone.isSystem()) {
tempAccessZonePath.add(accessZone.getPath() + "/");
}
}
HashSet<String> fsPathSet = new HashSet<>();
HashSet<String> fsQuotaPathSet = new HashSet<>();
HashMap<String, IsilonSmartQuota> tempQuotaMap = new HashMap<>();
IsilonApi.IsilonList<FileShare> isilonFSList = new IsilonApi.IsilonList<>();
int accessZoneDiscPathLength = computeCustomConfigPathLengths(umfsDiscoverPath);
IsilonApi.IsilonList<IsilonSmartQuota> quotas = isilonApi.listQuotas(resumetoken, umfsDiscoverPath);
isilonFSList.setToken(quotas.getToken());
for (IsilonSmartQuota quota : quotas.getList()) {
if (quota.getType().compareTo("directory") != 0) {
_log.debug("ignore quota path {} with quota id {}:", quota.getPath(), quota.getId() + " and quota type" + quota.getType());
continue;
}
if ("/ifs/".equals(umfsDiscoverPath) && isQuotaUnderAccessZonePath(quota.getPath(), tempAccessZonePath)) {
continue;
}
String fsNativeId = quota.getPath();
if (isUnderUnmanagedDiscoveryPath(fsNativeId)) {
int fsPathType = isQuotaOrFile(fsNativeId, accessZoneDiscPathLength);
if (fsPathType == PATH_IS_FILE) {
tempQuotaMap.put(quota.getPath(), quota);
fsPathSet.add(fsNativeId);
}
if (fsPathType == PATH_IS_QUOTA) {
tempQuotaMap.put(quota.getPath(), quota);
fsQuotaPathSet.add(fsNativeId);
}
}
}
/*
* Associate Quota directories with correct File paths
*/
HashMap<String, Set<String>> fileQuotas = new HashMap<>();
for (String filePath : fsPathSet) {
HashSet<String> qdPaths = new HashSet<>();
for (String qdPath : fsQuotaPathSet) {
if (qdPath.startsWith(filePath + "/")) {
qdPaths.add(qdPath);
}
}
if (!qdPaths.isEmpty()) {
fsQuotaPathSet.removeAll(qdPaths);
fileQuotas.put(filePath, qdPaths);
}
}
HashMap<String, FileShare> fsWithQuotaMap = new HashMap<>();
HashMap<String, UnManagedFileQuotaDirectory> qdMap = new HashMap<>();
for (String fsNativeId : fsPathSet) {
IsilonSmartQuota fileFsQuota = tempQuotaMap.get(fsNativeId);
FileShare fs = extractFileShare(fsNativeId, fileFsQuota, storageSystem);
_log.debug("quota id {} with capacity {}", fsNativeId + ":QUOTA:" + fileFsQuota.getId(), fs.getCapacity() + " used capacity " + fs.getUsedCapacity());
fsWithQuotaMap.put(fsNativeId, fs);
Set<String> fsQuotaIds = fileQuotas.get(fsNativeId);
if (null != fsQuotaIds) {
for (String quotaNativeId : fsQuotaIds) {
IsilonSmartQuota qdQuota = tempQuotaMap.get(quotaNativeId);
if (null != qdQuota) {
UnManagedFileQuotaDirectory qd = getUnManagedFileQuotaDirectory(fs.getNativeGuid(), qdQuota, storageSystem);
qdMap.put(quotaNativeId, qd);
}
}
}
}
List<FileShare> discoveredFS = new ArrayList<>();
discoveredFS.addAll(fsWithQuotaMap.values());
isilonFSList.addList(discoveredFS);
List<UnManagedFileQuotaDirectory> discoverdQuotaDirectory = new ArrayList<>();
discoverdQuotaDirectory.addAll(qdMap.values());
HashMap<String, Object> discoveredFileDetails = new HashMap<>();
discoveredFileDetails.put(UMFS_DETAILS, isilonFSList);
discoveredFileDetails.put(UMFSQD_DETAILS, discoverdQuotaDirectory);
discoveredFileDetails.put(UMFS_QD_MAP, fileQuotas);
return discoveredFileDetails;
} catch (IsilonException ie) {
_log.error("discoverAllFileSystem failed. Storage system: {}", storageSystemId, ie);
throw ie;
} catch (Exception e) {
_log.error("discoverAllFileSystem failed. Storage system: {}", storageSystemId, e);
IsilonCollectionException ice = new IsilonCollectionException("discoverAllFileSystem failed. Storage system: " + storageSystemId);
ice.initCause(e);
throw ice;
}
}
use of com.emc.storageos.isilon.restapi.IsilonSmartQuota in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method collectStatisticsInformation.
@Override
public void collectStatisticsInformation(AccessProfile accessProfile) throws BaseCollectionException {
URI storageSystemId = null;
StorageSystem isilonCluster = null;
long statsCount = 0;
try {
_log.info("Metering for {} using ip {}", accessProfile.getSystemId(), accessProfile.getIpAddress());
IsilonApi api = getIsilonDevice(accessProfile);
long latestSampleTime = accessProfile.getLastSampleTime();
storageSystemId = accessProfile.getSystemId();
isilonCluster = _dbClient.queryObject(StorageSystem.class, storageSystemId);
String serialNumber = isilonCluster.getSerialNumber();
String deviceType = isilonCluster.getSystemType();
initializeKeyMap(accessProfile);
boolean fsChanged = false;
List<Stat> stats = new ArrayList<Stat>();
List<FileShare> modifiedFileSystems = new ArrayList<FileShare>();
ZeroRecordGenerator zeroRecordGenerator = new FileZeroRecordGenerator();
CassandraInsertion statsColumnInjector = new FileDBInsertion();
// get usage stats from quotas
IsilonStatsRecorder recorder = new IsilonStatsRecorder(zeroRecordGenerator, statsColumnInjector);
_keyMap.put(Constants._TimeCollected, System.currentTimeMillis());
// compute static load processor code
computeStaticLoadMetrics(storageSystemId);
Map<String, String> fileSystemsMap = getStorageSystemFileShares(storageSystemId);
if (fileSystemsMap.isEmpty()) {
// No file shares for the storage system,
// ignore stats collection for the system!!!
_log.info("No file systems found for storage device {}. Hence metering stats collection ignored.", storageSystemId);
return;
}
// Process IsilonQuotas page by page (MAX 1000) in a page...
String resumeToken = null;
do {
IsilonApi.IsilonList<IsilonSmartQuota> quotas = api.listQuotas(resumeToken);
resumeToken = quotas.getToken();
for (IsilonSmartQuota quota : quotas.getList()) {
String fsNativeId = quota.getPath();
String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(deviceType, serialNumber, fsNativeId);
String fsId = fileSystemsMap.get(fsNativeGuid);
if (fsId == null || fsId.isEmpty()) {
// No file shares found for the quota
// ignore stats collection for the file system!!!
_log.debug("File System does not exists with nativeid {}. Hence ignoring stats collection.", fsNativeGuid);
continue;
}
Stat stat = recorder.addUsageStat(quota, _keyMap, fsId, api);
fsChanged = false;
if (null != stat) {
stats.add(stat);
// Persists the file system, only if change in used capacity.
FileShare fileSystem = _dbClient.queryObject(FileShare.class, stat.getResourceId());
if (fileSystem != null) {
if (!fileSystem.getInactive()) {
if (null != fileSystem.getUsedCapacity() && null != stat.getAllocatedCapacity() && !fileSystem.getUsedCapacity().equals(stat.getAllocatedCapacity())) {
fileSystem.setUsedCapacity(stat.getAllocatedCapacity());
fsChanged = true;
}
if (null != fileSystem.getSoftLimit() && null != fileSystem.getSoftLimitExceeded() && null != quota.getThresholds() && null != quota.getThresholds().getsoftExceeded() && !fileSystem.getSoftLimitExceeded().equals(quota.getThresholds().getsoftExceeded())) {
// softLimitExceeded
fileSystem.setSoftLimitExceeded(quota.getThresholds().getsoftExceeded());
fsChanged = true;
}
if (fsChanged) {
modifiedFileSystems.add(fileSystem);
}
}
}
}
// Each batch with MAX_RECORDS_SIZE - 100 records!!!
if (modifiedFileSystems.size() >= MAX_RECORDS_SIZE) {
_dbClient.updateObject(modifiedFileSystems);
_log.info("Processed {} file systems stats ", modifiedFileSystems.size());
modifiedFileSystems.clear();
}
if (stats.size() >= MAX_RECORDS_SIZE) {
_log.info("Processed {} stats", stats.size());
persistStatsInDB(stats);
}
}
statsCount = statsCount + quotas.size();
_log.info("Processed {} file system stats for device {} ", quotas.size(), storageSystemId);
} while (resumeToken != null);
zeroRecordGenerator.identifyRecordstobeZeroed(_keyMap, stats, FileShare.class);
// write the remaining records!!
if (!modifiedFileSystems.isEmpty()) {
_dbClient.updateObject(modifiedFileSystems);
_log.info("Processed {} file systems stats ", modifiedFileSystems.size());
modifiedFileSystems.clear();
}
if (!stats.isEmpty()) {
_log.info("Processed {} stats", stats.size());
persistStatsInDB(stats);
}
latestSampleTime = System.currentTimeMillis();
accessProfile.setLastSampleTime(latestSampleTime);
_log.info("Done metering device {}, processed {} file system stats ", storageSystemId, statsCount);
} catch (Exception e) {
if (isilonCluster != null) {
cleanupDiscovery(isilonCluster);
}
_log.error("CollectStatisticsInformation failed. Storage system: " + storageSystemId, e);
throw (new IsilonCollectionException(e.getMessage()));
}
}
Aggregations