use of alma.acs.monitoring.MonitorPointValue in project ACS by ACS-Community.
the class CorbaAnyExtractionTest method testExtractData_floatSeqBlobDataSeq_multivalued.
/**
* Test of extractData method for 'floatSeqBlobDataSeq' data for a multi-valued MP.
*/
@Test
public void testExtractData_floatSeqBlobDataSeq_multivalued() throws Exception {
String propertyName = "MODULE_MODE_STATUS";
Any any = create_any();
float[] floatData_time1 = { 1.111111f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f };
float[] floatData_time2 = { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
float[] floatData_time3 = { 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 };
float[][] floatDataMatrix = { floatData_time1, floatData_time2, floatData_time3 };
floatSeqBlobData[] floatSeqBlobDataArray = createFloatSeqBlobData(floatDataMatrix);
floatSeqBlobDataSeqHelper.insert(any, floatSeqBlobDataArray);
monitorPointExpert.setMultivalued(propertyName, true);
// Test the AnyExtractor stand-alone
List<MonitorPointTimeSeries> extractedData = anyExtractor.extractData(any, propertyName);
assertThat("No demultiplexing into several MonitorPointTimeSeries instances expected", extractedData, hasSize(1));
// Check the raw data
MonitorPointTimeSeries mpTs = extractedData.get(0);
assertThat(mpTs.getCorbaTypeId(), equalTo("IDL:alma/TMCDB/floatSeqBlobDataSeq:1.0"));
assertThat(mpTs.getMonitorPointIndex(), equalTo(0));
List<MonitorPointValue> dataList = mpTs.getDataList();
assertThat(dataList, hasSize(floatDataMatrix.length));
for (int i = 0; i < floatDataMatrix.length; i++) {
MonitorPointValue mpVal = dataList.get(i);
assertThat(mpVal.getTime(), equalTo(BASE_TIME + i));
List<Object> data = mpVal.getData();
assertThat(data, hasSize(floatData_time1.length));
for (int j = 0; j < floatData_time1.length; j++) {
Object dataPart = data.get(j);
assertThat(dataPart, instanceOf(Float.class));
float dataPartExpected = floatDataMatrix[i][j];
assertThat(((Float) dataPart).floatValue(), equalTo(dataPartExpected));
}
}
logger.info("Validated floatSeqBlobDataSeq interpreted as coming from a multivalued MP.");
// As a variation we test also "BlobberWorker.createBlobData" which in real life surrounds the AnyExtractor call
String componentName = "CONTROL/DV01/PSA";
String serialNumber = "3456328928847";
MonitorBlob blob = new MonitorBlob(false, (short) 0, new String[] {}, "wrong:" + propertyName, any);
MonitorBlob[] blobs = new MonitorBlob[] { blob };
long startTime = BASE_TIME + 100;
long stopTime = BASE_TIME + 101;
MonitorDataBlock block = new MonitorDataBlock(startTime, stopTime, componentName, serialNumber, blobs);
BlobData blobData = BlobberWorker.createBlobData(block, blob, extractedData.get(0), propertyName, serialNumber, logger);
String clobExpected = BASE_TIME + "|1.111111 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0|" + (BASE_TIME + 1) + "|11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0|" + (BASE_TIME + 2) + "|21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0\n";
checkComponentData(blobData, clobExpected, 3, componentName, propertyName, serialNumber, startTime, stopTime, 0, null);
}
use of alma.acs.monitoring.MonitorPointValue in project ACS by ACS-Community.
the class AnyExtractor method extractData.
/**
* The main method of this class.
* It checks <code>inSequence</code> for the recognized data types
* and extracts them using the respective Corba Helper classes.
* We keep NaN floating point types, so that they will have to be supressed later in the
* data processing if needed.
* <p>
* Currently this method also rearranges the sequence data based on information
* obtained from monitorPointExpert. This should be done separately in the future.
*
* @param inSequence
* The sequence of data from one property (monitor point) from one collector interval.
* @param propertyName Used along with {@link #monitorPointExpert} for MP-specific data restructuring.
* @return List of one or many MonitorPointTimeSeries objects extracted from inSequence.
* The list position is in line with the "derived index" in case a monitor point was expanded into many.
* @throws AcsJNoResourcesEx
*/
List<MonitorPointTimeSeries> extractData(Any inSequence, String propertyName) throws AcsJNoResourcesEx {
List<MonitorPointTimeSeries> outList = new ArrayList<MonitorPointTimeSeries>();
try {
// For this case, the index, i.e., the position inside the sequence is 0
if (inSequence.type().equal(doubleBlobDataSeqHelper.type())) {
doubleBlobData[] blobDataArray = doubleBlobDataSeqHelper.extract(inSequence);
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, doubleBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (doubleBlobData blobData : blobDataArray) {
MonitorPointValue mpv = new MonitorPointValue(blobData.time);
// Double
mpv.addValue(blobData.value);
mpTs.addMonitorPointValue(mpv);
}
} else // This is time series data coming from a multi-valued property.
if (inSequence.type().equal(doubleSeqBlobDataSeqHelper.type())) {
doubleSeqBlobData[] blobDataMatrix = doubleSeqBlobDataSeqHelper.extract(inSequence);
if (blobDataMatrix != null && blobDataMatrix.length > 0) {
if (monitorPointExpert.isMultivaluedMonitorPoint(propertyName)) {
// We interpret this as a time series of a single multi-valued monitor point
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, doubleSeqBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (doubleSeqBlobData blobDataArray : blobDataMatrix) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
for (double value : blobDataArray.value) {
// Double
mpv.addValue(value);
}
mpTs.addMonitorPointValue(mpv);
}
} else {
// We interpret this as a time series of multiple single-valued monitor points
populateList(outList, blobDataMatrix[0].value.length, doubleBlobDataSeqHelper.type().id());
for (doubleSeqBlobData blobDataArray : blobDataMatrix) {
int index = 0;
for (double value : blobDataArray.value) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
// Double
mpv.addValue(value);
MonitorPointTimeSeries mpTs = outList.get(index);
mpTs.addMonitorPointValue(mpv);
index++;
}
}
}
}
} else // This is time series data coming from a simple property.
if (inSequence.type().equal(floatBlobDataSeqHelper.type())) {
floatBlobData[] blobDataArray = floatBlobDataSeqHelper.extract(inSequence);
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, floatBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (floatBlobData blobData : blobDataArray) {
MonitorPointValue mpv = new MonitorPointValue(blobData.time);
// Float
mpv.addValue(blobData.value);
mpTs.addMonitorPointValue(mpv);
}
} else // This is time series data coming from a multi-valued property.
if (inSequence.type().equal(floatSeqBlobDataSeqHelper.type())) {
floatSeqBlobData[] blobDataMatrix = floatSeqBlobDataSeqHelper.extract(inSequence);
if (blobDataMatrix != null && blobDataMatrix.length > 0) {
if (monitorPointExpert.isMultivaluedMonitorPoint(propertyName)) {
// We interpret this as a time series of a single multi-valued monitor point
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, floatSeqBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (floatSeqBlobData blobDataArray : blobDataMatrix) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
for (float value : blobDataArray.value) {
// Float
mpv.addValue(value);
}
mpTs.addMonitorPointValue(mpv);
}
} else {
// We interpret this as a time series of multiple single-valued monitor points
populateList(outList, blobDataMatrix[0].value.length, floatBlobDataSeqHelper.type().id());
for (floatSeqBlobData blobDataArray : blobDataMatrix) {
int index = 0;
for (float value : blobDataArray.value) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
// Float
mpv.addValue(value);
MonitorPointTimeSeries mpTs = outList.get(index);
mpTs.addMonitorPointValue(mpv);
index++;
}
}
}
}
} else // This is time series data coming from a simple property.
if (inSequence.type().equal(longBlobDataSeqHelper.type())) {
longBlobData[] blobDataArray = longBlobDataSeqHelper.extract(inSequence);
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, longBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (longBlobData blobData : blobDataArray) {
MonitorPointValue mpv = new MonitorPointValue(blobData.time);
// Long
mpv.addValue(blobData.value);
mpTs.addMonitorPointValue(mpv);
}
} else // This is time series data coming from a multi-valued property.
if (inSequence.type().equal(longSeqBlobDataSeqHelper.type())) {
longSeqBlobData[] blobDataMatrix = longSeqBlobDataSeqHelper.extract(inSequence);
if (blobDataMatrix != null && blobDataMatrix.length > 0) {
if (monitorPointExpert.isMultivaluedMonitorPoint(propertyName)) {
// We interpret this as a time series of a single multi-valued monitor point
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, longSeqBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (longSeqBlobData blobDataArray : blobDataMatrix) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
for (long value : blobDataArray.value) {
// Long
mpv.addValue(value);
}
mpTs.addMonitorPointValue(mpv);
}
} else {
// We interpret this as a time series of multiple single-valued monitor points
populateList(outList, blobDataMatrix[0].value.length, longBlobDataSeqHelper.type().id());
for (longSeqBlobData blobDataArray : blobDataMatrix) {
int index = 0;
for (long value : blobDataArray.value) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
// Long
mpv.addValue(value);
MonitorPointTimeSeries mpTs = outList.get(index);
mpTs.addMonitorPointValue(mpv);
index++;
}
}
}
}
} else // This is time series data coming from a simple property.
if (inSequence.type().equal(uLongBlobDataSeqHelper.type())) {
uLongBlobData[] blobDataArray = uLongBlobDataSeqHelper.extract(inSequence);
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, uLongBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (uLongBlobData blobData : blobDataArray) {
MonitorPointValue mpv = new MonitorPointValue(blobData.time);
// TODO: use Long and fix mismatch if blobData.value < 0
// Integer
mpv.addValue(blobData.value);
mpTs.addMonitorPointValue(mpv);
}
} else // This is time series data coming from a multi-valued property.
if (inSequence.type().equal(uLongSeqBlobDataSeqHelper.type())) {
uLongSeqBlobData[] blobDataMatrix = uLongSeqBlobDataSeqHelper.extract(inSequence);
if (blobDataMatrix != null && blobDataMatrix.length > 0) {
if (monitorPointExpert.isMultivaluedMonitorPoint(propertyName)) {
// We interpret this as a time series of a single multi-valued monitor point
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, uLongSeqBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (uLongSeqBlobData blobDataArray : blobDataMatrix) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
for (int value : blobDataArray.value) {
// TODO: use Long and fix mismatch if value < 0
// Integer
mpv.addValue(value);
}
mpTs.addMonitorPointValue(mpv);
}
} else {
// We interpret this as a time series of multiple single-valued monitor points
populateList(outList, blobDataMatrix[0].value.length, uLongBlobDataSeqHelper.type().id());
for (uLongSeqBlobData blobDataArray : blobDataMatrix) {
int index = 0;
for (int value : blobDataArray.value) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
// TODO: use Long and fix mismatch if value < 0
// Integer
mpv.addValue(value);
MonitorPointTimeSeries mpTs = outList.get(index);
mpTs.addMonitorPointValue(mpv);
index++;
}
}
}
}
} else // This is time series data coming from a simple property.
if (inSequence.type().equal(longLongBlobDataSeqHelper.type())) {
longLongBlobData[] blobDataArray = longLongBlobDataSeqHelper.extract(inSequence);
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, longLongBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (longLongBlobData blobData : blobDataArray) {
MonitorPointValue mpv = new MonitorPointValue(blobData.time);
// Long
mpv.addValue(blobData.value);
mpTs.addMonitorPointValue(mpv);
}
} else // This is time series data coming from a multi-valued property.
if (inSequence.type().equal(longLongSeqBlobDataSeqHelper.type())) {
longLongSeqBlobData[] blobDataMatrix = longLongSeqBlobDataSeqHelper.extract(inSequence);
if (blobDataMatrix != null && blobDataMatrix.length > 0) {
if (monitorPointExpert.isMultivaluedMonitorPoint(propertyName)) {
// We interpret this as a time series of a single multi-valued monitor point
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, longLongSeqBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (longLongSeqBlobData blobDataArray : blobDataMatrix) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
for (long value : blobDataArray.value) {
// Long
mpv.addValue(value);
}
mpTs.addMonitorPointValue(mpv);
}
} else {
// We interpret this as a time series of multiple single-valued monitor points
populateList(outList, blobDataMatrix[0].value.length, longLongBlobDataSeqHelper.type().id());
for (longLongSeqBlobData blobDataArray : blobDataMatrix) {
int index = 0;
for (long value : blobDataArray.value) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
// Long
mpv.addValue(value);
MonitorPointTimeSeries mpTs = outList.get(index);
mpTs.addMonitorPointValue(mpv);
index++;
}
}
}
}
} else // This is time series data coming from a simple property.
if (inSequence.type().equal(uLongLongBlobDataSeqHelper.type())) {
uLongLongBlobData[] blobDataArray = uLongLongBlobDataSeqHelper.extract(inSequence);
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, uLongLongBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (uLongLongBlobData blobData : blobDataArray) {
MonitorPointValue mpv = new MonitorPointValue(blobData.time);
// TODO: Use BigInteger and fix mismatch for negative values, something like
// if (blobData.value < 0) {BigInteger.valueOf(blobData.value).add(new BigInteger("10000000000000000", 16)));
// This will not resolve overflow problems with computing the statistics though.
// Or better get rid of "unsigned long long" in our IDL, or replace it with something like
// "typedef fixed<31,0> BigInt"
// Long
mpv.addValue(blobData.value);
mpTs.addMonitorPointValue(mpv);
}
} else // This is time series data coming from a multi-valued property.
if (inSequence.type().equal(uLongLongSeqBlobDataSeqHelper.type())) {
uLongLongSeqBlobData[] blobDataMatrix = uLongLongSeqBlobDataSeqHelper.extract(inSequence);
if (blobDataMatrix != null && blobDataMatrix.length > 0) {
if (monitorPointExpert.isMultivaluedMonitorPoint(propertyName)) {
// We interpret this as a time series of a single multi-valued monitor point
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, uLongLongSeqBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (uLongLongSeqBlobData blobDataArray : blobDataMatrix) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
// TODO: See type mismatch comment above for uLongLongBlobDataSeq
for (long value : blobDataArray.value) {
// Long
mpv.addValue(value);
}
mpTs.addMonitorPointValue(mpv);
}
} else {
// We interpret this as a time series of multiple single-valued monitor points
populateList(outList, blobDataMatrix[0].value.length, uLongLongBlobDataSeqHelper.type().id());
for (uLongLongSeqBlobData blobDataArray : blobDataMatrix) {
int index = 0;
// TODO: See type mismatch comment above for uLongLongBlobDataSeq
for (long value : blobDataArray.value) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
// Long
mpv.addValue(value);
MonitorPointTimeSeries mpTs = outList.get(index);
mpTs.addMonitorPointValue(mpv);
index++;
}
}
}
}
} else // This is time series data coming from a simple property.
if (inSequence.type().equal(booleanBlobDataSeqHelper.type())) {
booleanBlobData[] blobDataArray = booleanBlobDataSeqHelper.extract(inSequence);
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, booleanBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (booleanBlobData blobData : blobDataArray) {
MonitorPointValue mpv = new MonitorPointValue(blobData.time);
// Boolean
mpv.addValue(blobData.value);
mpTs.addMonitorPointValue(mpv);
}
} else // This is time series data coming from a multi-valued property.
if (inSequence.type().equal(booleanSeqBlobDataSeqHelper.type())) {
booleanSeqBlobData[] blobDataMatrix = booleanSeqBlobDataSeqHelper.extract(inSequence);
if (blobDataMatrix != null && blobDataMatrix.length > 0) {
if (monitorPointExpert.isMultivaluedMonitorPoint(propertyName)) {
// We interpret this as a time series of a single multi-valued monitor point
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, booleanSeqBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (booleanSeqBlobData blobDataArray : blobDataMatrix) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
for (boolean value : blobDataArray.value) {
// Boolean
mpv.addValue(value);
}
mpTs.addMonitorPointValue(mpv);
}
} else {
// We interpret this as a time series of multiple single-valued monitor points
populateList(outList, blobDataMatrix[0].value.length, booleanBlobDataSeqHelper.type().id());
for (booleanSeqBlobData blobDataArray : blobDataMatrix) {
int index = 0;
for (boolean value : blobDataArray.value) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
// Boolean
mpv.addValue(value);
MonitorPointTimeSeries mpTs = outList.get(index);
mpTs.addMonitorPointValue(mpv);
index++;
}
}
}
}
} else // patternBlobDataSeq
if (inSequence.type().equal(patternBlobDataSeqHelper.type())) {
patternBlobData[] blobDataArray = patternBlobDataSeqHelper.extract(inSequence);
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, patternBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (patternBlobData blobData : blobDataArray) {
MonitorPointValue mpv = new MonitorPointValue(blobData.time);
// Long
mpv.addValue(blobData.value);
mpTs.addMonitorPointValue(mpv);
}
} else // stringBlobDataSeq
if (inSequence.type().equal(stringBlobDataSeqHelper.type())) {
stringBlobData[] blobDataArray = stringBlobDataSeqHelper.extract(inSequence);
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, stringBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (stringBlobData blobData : blobDataArray) {
MonitorPointValue mpv = new MonitorPointValue(blobData.time);
// String
mpv.addValue(blobData.value);
mpTs.addMonitorPointValue(mpv);
}
} else // stringSeqBlobDataSeq
if (inSequence.type().equal(stringSeqBlobDataSeqHelper.type())) {
stringSeqBlobData[] blobDataMatrix = stringSeqBlobDataSeqHelper.extract(inSequence);
if (blobDataMatrix != null && blobDataMatrix.length > 0) {
if (monitorPointExpert.isMultivaluedMonitorPoint(propertyName)) {
// We interpret this as a time series of a single multi-valued monitor point
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, stringSeqBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (stringSeqBlobData blobDataArray : blobDataMatrix) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
for (String value : blobDataArray.value) {
// String
mpv.addValue(value);
}
mpTs.addMonitorPointValue(mpv);
}
} else {
// We interpret this as a time series of multiple single-valued monitor points
populateList(outList, blobDataMatrix[0].value.length, stringBlobDataSeqHelper.type().id());
for (stringSeqBlobData blobDataArray : blobDataMatrix) {
int index = 0;
for (String value : blobDataArray.value) {
MonitorPointValue mpv = new MonitorPointValue(blobDataArray.time);
// String
mpv.addValue(value);
MonitorPointTimeSeries mpTs = outList.get(index);
mpTs.addMonitorPointValue(mpv);
index++;
}
}
}
}
} else // enumBlobDataSeq
if (inSequence.type().equal(enumBlobDataSeqHelper.type())) {
enumBlobData[] blobDataArray = enumBlobDataSeqHelper.extract(inSequence);
MonitorPointTimeSeries mpTs = new MonitorPointTimeSeries(0, enumBlobDataSeqHelper.type().id());
outList.add(mpTs);
for (enumBlobData blobData : blobDataArray) {
MonitorPointValue mpv = new MonitorPointValue(blobData.time);
// Integer
mpv.addValue(blobData.value);
mpTs.addMonitorPointValue(mpv);
}
} else {
logger.warning("Unknown CORBA data type received by blobber");
throw new IllegalStateException("Unknown CORBA data type received, " + inSequence.type());
}
} catch (BadKind ex) {
// This should never happen because we call TypeCode.id() only on TypeCodes
// that do have an ID.
logger.log(Level.WARNING, "Unexpected exception related to reading Any TypeCode IDs.", ex);
}
return outList;
}
use of alma.acs.monitoring.MonitorPointValue in project ACS by ACS-Community.
the class CorbaAnyExtractionTest method testExtractData_doubleSeqBlobDataSeq_multivalued.
/**
* Test of extractData method for 'doubleSeqBlobDataSeq' data for a multi-valued MP.
*/
@Test
public void testExtractData_doubleSeqBlobDataSeq_multivalued() throws Exception {
String propertyName = "MODULE_MODE_STATUS";
Any any = create_any();
double[] doubleData_time1 = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
double[] doubleData_time2 = { 11.1, 12.2, 13.3, 14.4, 15.5, 16.6, 17.7, 18.8, 19.9, 20.0 };
double[] doubleData_time3 = { 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0 };
double[][] doubleDataMatrix = { doubleData_time1, doubleData_time2, doubleData_time3 };
doubleSeqBlobData[] doubleSeqBlobDataArray = createDoubleSeqBlobData(doubleDataMatrix);
doubleSeqBlobDataSeqHelper.insert(any, doubleSeqBlobDataArray);
monitorPointExpert.setMultivalued(propertyName, true);
// Test the AnyExtractor stand-alone
List<MonitorPointTimeSeries> extractedData = anyExtractor.extractData(any, propertyName);
assertThat("No demultiplexing into several MonitorPointTimeSeries instances expected", extractedData, hasSize(1));
// Check the raw data
MonitorPointTimeSeries mpTs = extractedData.get(0);
assertThat(mpTs.getCorbaTypeId(), equalTo("IDL:alma/TMCDB/doubleSeqBlobDataSeq:1.0"));
assertThat(mpTs.getMonitorPointIndex(), equalTo(0));
List<MonitorPointValue> dataList = mpTs.getDataList();
assertThat(dataList, hasSize(doubleDataMatrix.length));
for (int i = 0; i < doubleDataMatrix.length; i++) {
MonitorPointValue mpVal = dataList.get(i);
assertThat(mpVal.getTime(), equalTo(BASE_TIME + i));
List<Object> data = mpVal.getData();
assertThat(data, hasSize(doubleData_time1.length));
for (int j = 0; j < doubleData_time1.length; j++) {
Object dataPart = data.get(j);
assertThat(dataPart, instanceOf(Double.class));
double dataPartExpected = doubleDataMatrix[i][j];
assertThat(((Double) dataPart).doubleValue(), equalTo(dataPartExpected));
}
}
logger.info("Validated doubleSeqBlobDataSeq interpreted as coming from a multivalued MP.");
// As a variation we test also "BlobberWorker.createBlobData" which in real life surrounds the AnyExtractor call
String componentName = "CONTROL/DV01/PSA";
String serialNumber = "3456328928847";
MonitorBlob blob = new MonitorBlob(false, (short) 0, new String[] {}, "wrong:" + propertyName, any);
MonitorBlob[] blobs = new MonitorBlob[] { blob };
long startTime = BASE_TIME + 100;
long stopTime = BASE_TIME + 101;
MonitorDataBlock block = new MonitorDataBlock(startTime, stopTime, componentName, serialNumber, blobs);
BlobData blobData = BlobberWorker.createBlobData(block, blob, extractedData.get(0), propertyName, serialNumber, logger);
String clobExpected = BASE_TIME + "|1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0|" + (BASE_TIME + 1) + "|11.1 12.2 13.3 14.4 15.5 16.6 17.7 18.8 19.9 20.0|" + (BASE_TIME + 2) + "|21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0\n";
checkComponentData(blobData, clobExpected, 3, componentName, propertyName, serialNumber, startTime, stopTime, 0, null);
}
use of alma.acs.monitoring.MonitorPointValue in project ACS by ACS-Community.
the class CorbaAnyExtractionTest method testExtractData_floatBlobDataSeq.
/**
* Test of extractData method for 'floatBlobDataSeq' data.
*/
@Test
public void testExtractData_floatBlobDataSeq() throws Exception {
String propertyName = "MODULE_MODE_STATUS";
Any any = create_any();
float[] floatDataArray = { 1f, 2.1f, 3f, 4f, 5f, 6.666666f, 7f, 8f, 9f, 10f };
floatBlobData[] floatBlobDataArray = createFloatBlobData(floatDataArray);
floatBlobDataSeqHelper.insert(any, floatBlobDataArray);
List<MonitorPointTimeSeries> extractedData = anyExtractor.extractData(any, propertyName);
assertThat(extractedData, hasSize(1));
// Check the raw data
MonitorPointTimeSeries mpTs = extractedData.get(0);
assertThat(mpTs.getCorbaTypeId(), equalTo("IDL:alma/TMCDB/floatBlobDataSeq:1.0"));
assertThat(mpTs.getMonitorPointIndex(), equalTo(0));
List<MonitorPointValue> dataList = mpTs.getDataList();
assertThat(dataList, hasSize(floatDataArray.length));
for (int i = 0; i < floatBlobDataArray.length; i++) {
MonitorPointValue mpVal = dataList.get(i);
assertThat(mpVal.getTime(), equalTo(BASE_TIME + i));
assertThat(mpVal.getData(), contains((Object) new Float(floatDataArray[i])));
}
// Generate and check the CLOB data
String clobActual = clobber.generateClob(mpTs);
String clobExpected = BASE_TIME + "|1.0|" + (BASE_TIME + 1) + "|2.1|" + (BASE_TIME + 2) + "|3.0|" + (BASE_TIME + 3) + "|4.0|" + (BASE_TIME + 4) + "|5.0|" + (BASE_TIME + 5) + "|6.666666|" + (BASE_TIME + 6) + "|7.0|" + (BASE_TIME + 7) + "|8.0|" + (BASE_TIME + 8) + "|9.0|" + (BASE_TIME + 9) + "|10.0\n";
assertThat(clobActual, equalTo(clobExpected));
logger.info("Validated floatBlobDataSeq.");
}
use of alma.acs.monitoring.MonitorPointValue in project ACS by ACS-Community.
the class CorbaAnyExtractionTest method testExtractData_doubleBlobDataSeq.
/**
* Test of extractData method for 'doubleBlobDataSeq' data.
*/
@Test
public void testExtractData_doubleBlobDataSeq() throws Exception {
String propertyName = "MODULE_MODE_STATUS";
Any any = create_any();
double[] doubleDataArray = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
doubleBlobData[] doubleBlobDataArray = createDoubleBlobData(doubleDataArray);
doubleBlobDataSeqHelper.insert(any, doubleBlobDataArray);
List<MonitorPointTimeSeries> extractedData = anyExtractor.extractData(any, propertyName);
assertThat(extractedData, hasSize(1));
// Check the raw data
MonitorPointTimeSeries mpTs = extractedData.get(0);
assertThat(mpTs.getCorbaTypeId(), equalTo("IDL:alma/TMCDB/doubleBlobDataSeq:1.0"));
assertThat(mpTs.getMonitorPointIndex(), equalTo(0));
List<MonitorPointValue> dataList = mpTs.getDataList();
assertThat(dataList, hasSize(doubleDataArray.length));
for (int i = 0; i < doubleBlobDataArray.length; i++) {
MonitorPointValue mpVal = dataList.get(i);
assertThat(mpVal.getTime(), equalTo(BASE_TIME + i));
assertThat(mpVal.getData(), contains((Object) new Double(doubleDataArray[i])));
}
// Generate and check the CLOB data
String clobActual = clobber.generateClob(mpTs);
String clobExpected = BASE_TIME + "|1.0|" + (BASE_TIME + 1) + "|2.0|" + (BASE_TIME + 2) + "|3.0|" + (BASE_TIME + 3) + "|4.0|" + (BASE_TIME + 4) + "|5.0|" + (BASE_TIME + 5) + "|6.0|" + (BASE_TIME + 6) + "|7.0|" + (BASE_TIME + 7) + "|8.0|" + (BASE_TIME + 8) + "|9.0|" + (BASE_TIME + 9) + "|10.0\n";
assertThat(clobActual, equalTo(clobExpected));
logger.info("Validated doubleBlobDataSeq.");
}
Aggregations