use of com.emc.storageos.db.client.model.Stat in project coprhd-controller by CoprHD.
the class SSNProcessor method processSynchronizedInstance.
private void processSynchronizedInstance(CloseableIterator<CIMInstance> synchronizedInstances, Map<String, Object> keyMap) throws Exception {
while (synchronizedInstances.hasNext()) {
CIMInstance instance = synchronizedInstances.next();
CIMObjectPath volumePath = instance.getObjectPath();
CIMObjectPath sourcePath = (CIMObjectPath) volumePath.getKey(Constants._SystemElement).getValue();
CIMObjectPath destPath = (CIMObjectPath) volumePath.getKey(Constants._SyncedElement).getValue();
String syncType = instance.getProperty(Constants._SyncType).getValue().toString();
CIMProperty<?> prop = sourcePath.getKey(Constants._SystemName);
String[] serialNumber_split = prop.getValue().toString().split(Constants.PATH_DELIMITER_REGEX);
if (serialNumber_split[1].equalsIgnoreCase((String) keyMap.get(Constants._serialID))) {
_logger.debug("Finding Snapshots for Volumes in this Array with SyncType : {} : {}", prop.getValue().toString(), syncType);
if (syncType.equalsIgnoreCase(Constants._Seven)) {
String key = createKeyfromPath(sourcePath);
if (null == getMetrics(keyMap, key) || !(getMetrics(keyMap, key) instanceof Stat)) {
return;
}
Stat metrics = (Stat) getMetrics(keyMap, key);
String destkey = createKeyfromPath(destPath);
Object value = getMetrics(keyMap, destkey);
if (null == value) {
return;
}
Long allocatedCapacityForSnapShots = 0L;
if (value instanceof Stat) {
Stat syncedMetrics = (Stat) value;
allocatedCapacityForSnapShots = syncedMetrics.getAllocatedCapacity();
} else {
allocatedCapacityForSnapShots = (Long) value;
}
// removed parallel processing from framework, hence synchronization is not needed.
metrics.setSnapshotCount(metrics.getSnapshotCount() + 1);
metrics.setSnapshotCapacity(metrics.getSnapshotCapacity() + allocatedCapacityForSnapShots);
}
}
}
}
use of com.emc.storageos.db.client.model.Stat in project coprhd-controller by CoprHD.
the class StorageSystemStatsProcessor method processResult.
/**
* System metrics sequence: string CSVSequence[] = InstanceID, ElementType,
* TotalIOs, KBytesTransferred, ReadIOs, ReadHitIOs, KBytesRead, WriteIOs,
* WriteHitIOs, KBytesWritten;
*/
@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws SMIPluginException {
long timeInMillis;
try {
timeInMillis = (Long) keyMap.get(Constants._TimeCollected);
AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
CIMArgument<?>[] outputArguments = (CIMArgument<?>[]) resultObj;
List<Stat> metricsObjList = (List<Stat>) keyMap.get(Constants._Stats);
String[] arrayStats = ((String[]) outputArguments[0].getValue())[0].split("\n");
List<String> metricSequence = (List<String>) keyMap.get(Constants.STORAGEOS_SYSTEM_MANIFEST);
_logger.debug("System metricNames Sequence {}", metricSequence);
for (String arrayStat : arrayStats) {
if (arrayStat.isEmpty()) {
_logger.debug("Empty arrayStat returned as part of Statistics Response");
continue;
}
Stat systemStat = new Stat();
Iterable<String> splitIterator = Splitter.on(Constants.SEMI_COLON).split(arrayStat);
List<String> systemMetricList = Lists.newLinkedList(splitIterator);
String nativeGuid = getSystemNativeGuidFromMetric(systemMetricList.get(0).toUpperCase(), keyMap);
systemStat.setNativeGuid(nativeGuid);
systemStat.setResourceId(profile.getSystemId());
systemStat.setServiceType(Constants._Block);
systemStat.setTimeCollected((Long) keyMap.get(Constants._TimeCollected));
systemStat.setTimeInMillis(timeInMillis);
if (null != metricSequence && !metricSequence.isEmpty()) {
injectSystemStatMetrics(metricSequence, systemStat, systemMetricList);
} else {
_logger.error("failed processing System Metric values as metric sequence is null.");
}
metricsObjList.add(systemStat);
}
_logger.info("injected system statistics in DB.");
} catch (Exception e) {
_logger.error("Failed while extracting Stats for storage Systems: ", e);
}
resultObj = null;
}
use of com.emc.storageos.db.client.model.Stat in project coprhd-controller by CoprHD.
the class VolumeProcessor method addMetricstoMetricsObject.
/**
* Parse NativeGuid, create Volume CIMObjectPaths by using nativeGuids. Get
* the associated Metrics Object for each Volume, update with
* ReadIOs,WriteIOs, guid content.
*
* string CSVSequence[] = InstanceID,
* ElementType, TotalIOs, KBytesTransferred, ReadIOs, KBytesRead, WriteIOs,
* KBytesWritten;
*
* @param keyMap
* @param volume
* @param metricsObjList
* @throws SMIPluginException
*/
private void addMetricstoMetricsObject(Map<String, Object> keyMap, String volume, List<Stat> metricsObjList, long timeinMillis, List<String> metricSequence, DbClient dbClient) throws SMIPluginException {
String nativeGuid = null;
try {
_logger.debug("Volumes :" + volume);
Iterable<String> splitIterator = Splitter.on(Constants.SEMI_COLON).split(volume);
List<String> metricValuesList = Lists.newLinkedList(splitIterator);
// translated Attributes is needed to create CIMObject at runtime
// without querying it from Provider,
// which increases performance a lot, by reducing SMI-S calls
nativeGuid = translatedAttributes(metricValuesList.get(0).toUpperCase(), keyMap);
CIMObjectPath path = null;
if (nativeGuid.contains(_symm)) {
path = createCIMPath(nativeGuid, _symmvolume, _symmsystem, keyMap);
} else if (nativeGuid.contains(_clar)) {
path = createCIMPath(nativeGuid, _clarvolume, _clarsystem, keyMap);
}
// Inject Project, COS, tenant ID
Stat statObj = _zeroRecordGenerator.injectattr(keyMap, nativeGuid, null);
if (statObj != null) {
@SuppressWarnings("unchecked") List<CIMObjectPath> volList = (List<CIMObjectPath>) keyMap.get(Constants._Volumes);
volList.add(path);
statObj.setServiceType(Constants._Block);
statObj.setTimeCollected((Long) keyMap.get(Constants._TimeCollected));
statObj.setTimeInMillis(timeinMillis);
_statsColumnInjector.injectColumns(statObj, dbClient);
// Default Capacity in Model is -1. As snapshotCount and
// capacity is cumulative Count of multiple Snapshots, making to
// default 0
// for each retrieved Volume.
int count = 0;
for (String metricName : metricSequence) {
String metricValue = metricValuesList.get(count);
switch(VolumeMetric.lookup(metricName)) {
case InstanceID:
case ElementType:
count++;
break;
case KBytesWritten:
statObj.setBandwidthIn(ControllerUtils.getLongValue(metricValue));
count++;
break;
case KBytesRead:
statObj.setBandwidthOut(ControllerUtils.getLongValue(metricValue));
count++;
break;
case TotalIOs:
statObj.setTotalIOs(ControllerUtils.getLongValue(metricValue));
count++;
break;
case ReadIOs:
statObj.setReadIOs(ControllerUtils.getLongValue(metricValue));
count++;
break;
case WriteIOs:
statObj.setWriteIOs(ControllerUtils.getLongValue(metricValue));
count++;
break;
case KBytesTransferred:
statObj.setKbytesTransferred(ControllerUtils.getLongValue(metricValue));
count++;
break;
case IdleTimeCounter:
if (null != metricValue && 0 < metricValue.trim().length()) {
statObj.setIdleTimeCounter(ControllerUtils.getLongValue(metricValue));
}
count++;
break;
case IOTimeCounter:
if (null != metricValue && 0 < metricValue.trim().length()) {
statObj.setIoTimeCounter(ControllerUtils.getLongValue(metricValue));
}
count++;
break;
case EMCQueueLength:
if (null != metricValue && 0 < metricValue.trim().length()) {
statObj.setQueueLength(ControllerUtils.getLongValue(metricValue));
}
count++;
break;
default:
_logger.warn("Ignoring unknown metric {} during system metric processing:", metricName);
count++;
break;
}
}
metricsObjList.add(statObj);
}
} catch (Exception ex) {
_logger.error("Processing Volume : {} failed : ", volume, ex);
}
}
use of com.emc.storageos.db.client.model.Stat in project coprhd-controller by CoprHD.
the class VolumeProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws SMIPluginException {
long timeinMilis;
try {
timeinMilis = (Long) keyMap.get(Constants._TimeCollected);
CIMArgument<?>[] outputArguments = (CIMArgument<?>[]) resultObj;
@SuppressWarnings("unchecked") List<Stat> metricsObjList = (List<Stat>) keyMap.get(Constants._Stats);
DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
if ((null == outputArguments[0]) || ((String[]) outputArguments[0].getValue()).length == 0) {
_logger.warn("Empty Statistics response returned from Provider");
return;
}
String[] volumes = ((String[]) outputArguments[0].getValue())[0].split("\n");
List<String> metricSequence = (List<String>) keyMap.get(Constants.STORAGEOS_VOLUME_MANIFEST);
_logger.debug("volume metricNames Sequence {}", metricSequence);
for (String volume : volumes) {
if (volume.isEmpty()) {
_logger.debug("Empty Volume returned as part of Statistics Response");
continue;
}
if (null != metricSequence && !metricSequence.isEmpty()) {
addMetricstoMetricsObject(keyMap, volume, metricsObjList, timeinMilis, metricSequence, dbClient);
} else {
_logger.error("failed processing Volume Metric values as metric sequence is null.");
}
}
_zeroRecordGenerator.identifyRecordstobeZeroed(keyMap, metricsObjList, Volume.class);
} catch (Exception e) {
_logger.error("Failed while extracting Read & WriteIOs for Volumes : ", e);
}
resultObj = null;
}
use of com.emc.storageos.db.client.model.Stat in project coprhd-controller by CoprHD.
the class VNXFileSystemUsageProcessor method processFileShareInfo.
/**
* process the FileShareUsage response of the VNX XML API Server.
*
* @param fsUsageList
* : fileShareUsage map.
* @param keyMap
* : attribute map.
* @param statList
* : list of stat objects.
*/
@SuppressWarnings("rawtypes")
private void processFileShareInfo(final List<Object> fsUsageList, final Map<String, Object> keyMap, final List<Stat> statList, DbClient dbClient) throws VNXFilePluginException {
final String serialId = keyMap.get(Constants._serialID).toString();
Iterator iterator = fsUsageList.iterator();
keyMap.put(Constants._TimeCollected, System.currentTimeMillis());
Map<String, Long> fsCapacityMap = new HashMap<String, Long>();
while (iterator.hasNext()) {
FileSystemSetUsageStats fsSetUsageStats = (FileSystemSetUsageStats) iterator.next();
List<Item> fsUsageItems = fsSetUsageStats.getItem();
_logger.info("Received {} fileShareUsage records at server time {}", fsUsageItems.size(), fsSetUsageStats.getTime());
for (Item item : fsUsageItems) {
if (null == item.getFileSystem()) {
continue;
}
final String nativeGuid = NativeGUIDGenerator.generateNativeGuid(Type.vnxfile.toString(), serialId, item.getFileSystem());
Stat stat = _zeroRecordGenerator.injectattr(keyMap, nativeGuid, null);
if (null != stat) {
stat.setTimeInMillis((Long) keyMap.get(Constants._TimeCollected));
stat.setTimeCollected((Long) keyMap.get(Constants._TimeCollected));
injectProvisionedCapacity(stat, keyMap);
// The data coming in is in KB. Converting to Bytes
stat.setAllocatedCapacity(item.getSpaceUsed() * 1024);
_statsColumnInjector.injectColumns(stat, dbClient);
statList.add(stat);
// Persists the file system, only if change in used capacity.
DbClient client = (DbClient) keyMap.get(Constants.dbClient);
if (client != null) {
FileShare fileSystem = client.queryObject(FileShare.class, stat.getResourceId());
if (fileSystem != null) {
if (!fileSystem.getInactive() && fileSystem.getUsedCapacity() != stat.getAllocatedCapacity()) {
fileSystem.setUsedCapacity(stat.getAllocatedCapacity());
client.persistObject(fileSystem);
}
}
}
}
// filesystem and total capacity in Map
long totalSpace = item.getSpaceTotal();
String fsNativeId = item.getFileSystem();
fsCapacityMap.put(fsNativeId, Long.valueOf(totalSpace));
_logger.info("processFileShareInfo - FileSystem native id {} and file system total size{}", fsNativeId, String.valueOf(totalSpace));
}
_logger.info("Filesystems found - {} ", fsCapacityMap.size());
keyMap.put(VNXFileConstants.FILE_CAPACITY_MAP, fsCapacityMap);
}
_logger.info("No. of stat objects: {}", statList.size());
}
Aggregations