use of alma.TMCDB.MonitorDataBlock in project ACS by ACS-Community.
the class BlobberWorkerUnitTest method testStandardLong.
public void testStandardLong() throws Exception {
// was 0, which is now illegal
blobber.setCollectorIntervalSeconds(1);
getTestWorker().setCanHandle(true);
// Collector "TestCollector" is just a dummy to trick the worker to believe that
// there is a collector registered and start operating. "TestCollector" is not used at all.
// The TestBlobberWorker creates its own single collector from which the blobber worker will get data.
getTestWorker().addCollector("TestCollector");
String componentName = "CONTROL/DV01/PSA";
String serialNumber = "3456328928847";
String propertyName = "VOLTAGE_MID_1";
// Note that CORBA long means Java int.
Any anyUp = create_any();
int[] dataArrayUp = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
longBlobData[] dataUp = new longBlobData[dataArrayUp.length];
int index = 0;
for (int value : dataArrayUp) {
dataUp[index] = new longBlobData(BASE_TIME + index, value);
index++;
}
longBlobDataSeqHelper.insert(anyUp, dataUp);
MonitorBlob blobUp = new MonitorBlob(false, (short) 0, null, "wrong:" + propertyName, anyUp);
MonitorBlob[] blobs = new MonitorBlob[1];
blobs[0] = blobUp;
long startTime = BASE_TIME + 100;
long stopTime = BASE_TIME + 101;
MonitorDataBlock block = new MonitorDataBlock(startTime, stopTime, componentName, serialNumber, blobs);
MonitorDataBlock[] blocks = new MonitorDataBlock[1];
blocks[0] = block;
getTestWorker().getCollector().setMonitorData(blocks);
ComponentData data = getTestWorker().fetchData();
String clob = BASE_TIME + "|1|" + (BASE_TIME + 1) + "|2|" + (BASE_TIME + 2) + "|3|" + (BASE_TIME + 3) + "|4|" + (BASE_TIME + 4) + "|5|" + (BASE_TIME + 5) + "|6|" + (BASE_TIME + 6) + "|7|" + (BASE_TIME + 7) + "|8|" + (BASE_TIME + 8) + "|9|" + (BASE_TIME + 9) + "|10\n";
checkData(data, clob, 10, componentName, propertyName, serialNumber, startTime, stopTime);
checkStatistics(data, 1.0, 10.0, 5.5, 3.0276503541);
}
use of alma.TMCDB.MonitorDataBlock in project ACS by ACS-Community.
the class CorbaAnyExtractionTest method testExtractData_longLongBlobDataSeq.
/**
* Test of extractData method for 'longLongBlobDataSeq' data.
*/
@Test
public void testExtractData_longLongBlobDataSeq() throws Exception {
String propertyName = "VOLTAGE_MID_1";
Any any = create_any();
// We try out a rather large outlyer value. Note that for even larger numbers
// such as 0x7f0fffffffffffffL, the double-based statistics yield a max value wrong by +-1,
// which is probably acceptable, but we avoid it here in the test and use
// only a number of the order of a quadrillion.
long[] longLongDataArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0x000fffffffffffffL };
longLongBlobData[] longLongBlobDataArray = createLongLongBlobData(longLongDataArray);
longLongBlobDataSeqHelper.insert(any, longLongBlobDataArray);
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/longLongBlobDataSeq:1.0"));
assertThat(mpTs.getMonitorPointIndex(), equalTo(0));
List<MonitorPointValue> dataList = mpTs.getDataList();
assertThat(dataList, hasSize(longLongBlobDataArray.length));
for (int i = 0; i < longLongBlobDataArray.length; i++) {
MonitorPointValue mpVal = dataList.get(i);
assertThat(mpVal.getTime(), equalTo(BASE_TIME + i));
assertThat(mpVal.getData(), contains((Object) new Long(longLongDataArray[i])));
}
logger.info("Validated longLongBlobDataSeq.");
// 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|" + (BASE_TIME + 1) + "|2|" + (BASE_TIME + 2) + "|3|" + (BASE_TIME + 3) + "|4|" + (BASE_TIME + 4) + "|5|" + (BASE_TIME + 5) + "|6|" + (BASE_TIME + 6) + "|7|" + (BASE_TIME + 7) + "|8|" + (BASE_TIME + 8) + "|9|" + (BASE_TIME + 9) + "|4503599627370495\n";
String statisticsExpected = "min: 1 max: 4503599627370495 mean: 4.50359962737054E14 stdDev: 1.4241632491976338E15\n";
checkComponentData(blobData, clobExpected, 10, componentName, propertyName, serialNumber, startTime, stopTime, 0, statisticsExpected);
}
use of alma.TMCDB.MonitorDataBlock in project ACS by ACS-Community.
the class BlobberWorkerUnitTest method testStandardULongLong.
public void testStandardULongLong() throws Exception {
// was 0, which is now illegal
blobber.setCollectorIntervalSeconds(1);
getTestWorker().setCanHandle(true);
// Collector "TestCollector" is just a dummy to trick the worker to believe that
// there is a collector registered and start operating. "TestCollector" is not used at all.
// The TestBlobberWorker creates its own single collector from which the blobber worker will get data.
getTestWorker().addCollector("TestCollector");
String componentName = "CONTROL/DV01/PSA";
String serialNumber = "3456328928847";
String propertyName = "VOLTAGE_MID_1";
// Note that CORBA ulonglong means Java long.
Any anyUp = create_any();
long[] dataArrayUp = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
uLongLongBlobData[] dataUp = new uLongLongBlobData[dataArrayUp.length];
int index = 0;
for (long value : dataArrayUp) {
dataUp[index] = new uLongLongBlobData(BASE_TIME + index, value);
index++;
}
uLongLongBlobDataSeqHelper.insert(anyUp, dataUp);
MonitorBlob blobUp = new MonitorBlob(false, (short) 0, null, "wrong:" + propertyName, anyUp);
MonitorBlob[] blobs = new MonitorBlob[1];
blobs[0] = blobUp;
long startTime = BASE_TIME + 100;
long stopTime = BASE_TIME + 101;
MonitorDataBlock block = new MonitorDataBlock(startTime, stopTime, componentName, serialNumber, blobs);
MonitorDataBlock[] blocks = new MonitorDataBlock[1];
blocks[0] = block;
getTestWorker().getCollector().setMonitorData(blocks);
ComponentData data = getTestWorker().fetchData();
String clob = BASE_TIME + "|1|" + (BASE_TIME + 1) + "|2|" + (BASE_TIME + 2) + "|3|" + (BASE_TIME + 3) + "|4|" + (BASE_TIME + 4) + "|5|" + (BASE_TIME + 5) + "|6|" + (BASE_TIME + 6) + "|7|" + (BASE_TIME + 7) + "|8|" + (BASE_TIME + 8) + "|9|" + (BASE_TIME + 9) + "|10\n";
checkData(data, clob, 10, componentName, propertyName, serialNumber, startTime, stopTime);
checkStatistics(data, 1.0, 10.0, 5.5, 3.0276503541);
}
use of alma.TMCDB.MonitorDataBlock in project ACS by ACS-Community.
the class BlobberWorkerUnitTest method testCorrelatorLong.
public void testCorrelatorLong() throws Exception {
// was 0, which is now illegal
blobber.setCollectorIntervalSeconds(1);
getTestWorker().setCanHandle(true);
// Collector "TestCollector" is just a dummy to trick the worker to believe that
// there is a collector registered and start operating. "TestCollector" is not used at all.
// The TestBlobberWorker creates its own single collector from which the blobber worker will get data.
getTestWorker().addCollector("TestCollector");
String componentName = "CONTROL/DV01/PSA";
String serialNumber = "3456328928847";
String propertyName = "VOLTAGE_MID_1";
// Note that CORBA long means Java int.
Any anyUp = create_any();
int[] dataArrayUp1 = { 1, 2, 3 };
int[] dataArrayUp2 = { 11, 12, 13 };
int[] dataArrayUp3 = { 21, 22, 23 };
int[][] dataUpMatrix = { dataArrayUp1, dataArrayUp2, dataArrayUp3 };
String[] serialNumbers = { "A", "B", "C" };
longSeqBlobData[] dataUp = new longSeqBlobData[dataUpMatrix.length];
int index = 0;
for (int[] value : dataUpMatrix) {
dataUp[index] = new longSeqBlobData(BASE_TIME + index, value);
index++;
}
longSeqBlobDataSeqHelper.insert(anyUp, dataUp);
MonitorBlob blobUp = new MonitorBlob(false, (short) 0, serialNumbers, "wrong:" + propertyName, anyUp);
MonitorBlob[] blobs = new MonitorBlob[1];
blobs[0] = blobUp;
long startTime = BASE_TIME + 100;
long stopTime = BASE_TIME + 101;
MonitorDataBlock block = new MonitorDataBlock(startTime, stopTime, componentName, serialNumber, blobs);
MonitorDataBlock[] blocks = new MonitorDataBlock[1];
blocks[0] = block;
getTestWorker().getCollector().setMonitorData(blocks);
ComponentData data = getTestWorker().fetchData();
String clob = BASE_TIME + "|1|" + (BASE_TIME + 1) + "|11|" + (BASE_TIME + 2) + "|21\n";
checkData(data, clob, 3, componentName, propertyName, "A", startTime, stopTime);
checkStatistics(data, 1.0, 21.0, 11.0, 10.0);
data = getTestWorker().fetchData();
clob = BASE_TIME + "|2|" + (BASE_TIME + 1) + "|12|" + (BASE_TIME + 2) + "|22\n";
propertyName = "" + propertyName;
checkData(data, clob, 3, componentName, propertyName, "B", startTime, stopTime);
checkStatistics(data, 2.0, 22.0, 12.0, 10.0);
data = getTestWorker().fetchData();
clob = BASE_TIME + "|3|" + (BASE_TIME + 1) + "|13|" + (BASE_TIME + 2) + "|23\n";
propertyName = "" + propertyName;
checkData(data, clob, 3, componentName, propertyName, "C", startTime, stopTime);
checkStatistics(data, 3.0, 23.0, 13.0, 10.0);
}
use of alma.TMCDB.MonitorDataBlock in project ACS by ACS-Community.
the class BlobberWorkerUnitTest method testStandardPattern.
public void testStandardPattern() throws Exception {
// was 0, which is now illegal
blobber.setCollectorIntervalSeconds(1);
getTestWorker().setCanHandle(true);
// Collector "TestCollector" is just a dummy to trick the worker to believe that
// there is a collector registered and start operating. "TestCollector" is not used at all.
// The TestBlobberWorker creates its own single collector from which the blobber worker will get data.
getTestWorker().addCollector("TestCollector");
String componentName = "CONTROL/DV01/PSA";
String serialNumber = "3456328928847";
String propertyName = "VOLTAGE_MID_1";
Any anyUp = create_any();
long[] dataArrayUp = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
patternBlobData[] dataUp = new patternBlobData[dataArrayUp.length];
int index = 0;
for (long value : dataArrayUp) {
dataUp[index] = new patternBlobData(BASE_TIME + index, (int) value);
index++;
}
patternBlobDataSeqHelper.insert(anyUp, dataUp);
MonitorBlob blobUp = new MonitorBlob(false, (short) 0, null, "wrong:" + propertyName, anyUp);
MonitorBlob[] blobs = new MonitorBlob[1];
blobs[0] = blobUp;
long startTime = BASE_TIME + 100;
long stopTime = BASE_TIME + 101;
MonitorDataBlock block = new MonitorDataBlock(startTime, stopTime, componentName, serialNumber, blobs);
MonitorDataBlock[] blocks = new MonitorDataBlock[1];
blocks[0] = block;
getTestWorker().getCollector().setMonitorData(blocks);
ComponentData data = getTestWorker().fetchData();
String clob = BASE_TIME + "|1|" + (BASE_TIME + 1) + "|2|" + (BASE_TIME + 2) + "|3|" + (BASE_TIME + 3) + "|4|" + (BASE_TIME + 4) + "|5|" + (BASE_TIME + 5) + "|6|" + (BASE_TIME + 6) + "|7|" + (BASE_TIME + 7) + "|8|" + (BASE_TIME + 8) + "|9|" + (BASE_TIME + 9) + "|10\n";
checkData(data, clob, 10, componentName, propertyName, serialNumber, startTime, stopTime);
checkStatistics(data);
}
Aggregations