use of alma.acs.util.StopWatch in project ACS by ACS-Community.
the class DynAnyParserTest method parsePttDataEvent.
public ParsedAnyData[] parsePttDataEvent() {
pde = new pttDataEvent(new actuatorSpace(new double[2952]), new actuatorSpace(new double[2952]), 25, 32L);
try {
se = seCreator.createEvent(pde);
} catch (AcsJException e) {
e.printStackTrace();
fail("Couldn't create structured event for pttDataEvent");
}
eventName = se.header.fixed_header.event_type.type_name;
eventAny = se.filterable_data[0].value;
StopWatch sw = new StopWatch(logger);
parser = new DynAnyParser(eventAny, eventName);
ParsedAnyData[] pResults = parser.getParsedResults(null);
sw.logLapTime("parse this eventAny");
return pResults;
}
use of alma.acs.util.StopWatch in project ACS by ACS-Community.
the class EventDetailTestHarness method parsePttDataEvent.
public static ParsedAnyData[] parsePttDataEvent() {
pttDataEvent pde = new pttDataEvent(new actuatorSpace(new double[2952]), new actuatorSpace(new double[2952]), 25, 32L);
StructuredEvent se = null;
String eventName = null;
Any eventAny = null;
try {
se = seCreator.createEvent(pde);
eventName = se.header.fixed_header.event_type.type_name;
eventAny = se.filterable_data[0].value;
} catch (AcsJException e) {
e.printStackTrace();
System.err.println("Couldn't create structured event for pttDataEvent");
}
StopWatch sw = new StopWatch(logger);
DynAnyParser parser = new DynAnyParser(eventAny, eventName);
ParsedAnyData[] pResults = parser.getParsedResults(null);
sw.logLapTime("parse this eventAny");
return pResults;
}
use of alma.acs.util.StopWatch in project ACS by ACS-Community.
the class OrbProfilerParser method parse.
/**
* Parses the given file and returns the profiler messages extracted from the file as a list for further processing.
*/
public List<ProfilerMessage> parse(File stdoutLogFile) throws IOException {
if (stdoutLogFile == null) {
throw new IllegalArgumentException("No data file specified (null).");
} else if (!stdoutLogFile.exists() || !stdoutLogFile.canRead()) {
throw new IllegalArgumentException("Data file " + stdoutLogFile.getAbsolutePath() + " does not exist or cannot be read.");
}
StopWatch sw = new StopWatch(logger);
List<ProfilerMessage> messages = new ArrayList<ProfilerMessage>();
BufferedReader reader = new BufferedReader(new FileReader(stdoutLogFile));
String line = null;
int lineCount = 0;
try {
while ((line = reader.readLine()) != null) {
lineCount++;
ProfilerMessage msg = parseLine(line);
if (msg == null) {
// System.out.println("Skipping line: " + line);
} else {
messages.add(msg);
}
}
} finally {
reader.close();
}
logger.info("Parsed file " + stdoutLogFile.getAbsolutePath() + " in " + sw.getLapTimeMillis() + " ms, found " + lineCount + " lines total, and " + messages.size() + " orb profiler messages.");
return messages;
}
use of alma.acs.util.StopWatch in project ACS by ACS-Community.
the class OtherComponentClient method testTimeout.
/**
* This test will use custom client side timeout, ignoring Container Timeout.
* It is the client version of {@link #testGetReferenceWithCustomClientSideTimeout()}
* where m_contSrvTesterComp will take over the role of this junit test client for testing the timeout.
**/
public void testTimeout() throws Exception {
try {
org.omg.CORBA.Object compObj = getContainerServices().getComponent(DEFAULT_DUMMYCOMP_INSTANCE);
DummyComponent comp = DummyComponentHelper.narrow(compObj);
//secs. (should be at most 10 s longer than 'timeout'
int waitTime = 18;
// because component deactivation blocks only 10 seconds on a still running operation.
//secs.
int timeout = 10;
//first let's try to call the IF without applicable client-side timeout
try {
comp.callThatTakesSomeTime(waitTime * 1000);
} catch (org.omg.CORBA.TIMEOUT e) {
fail("It is not supposed to get a timeout before waitTime");
}
// then we call the ContainerServices to assign a timeout of 10 seconds
compObj = getContainerServices().getReferenceWithCustomClientSideTimeout(compObj, timeout);
comp = DummyComponentHelper.narrow(compObj);
//we call again the IF
StopWatch sw = new StopWatch(m_logger);
try {
comp.callThatTakesSomeTime(waitTime * 1000);
fail("It is supposed to get a timeout before waitTime");
} catch (org.omg.CORBA.TIMEOUT e) {
m_logger.info("Good: Got TIMEOUT exception from calling " + DEFAULT_DUMMYCOMP_INSTANCE + "#callThatTakesSomeTime with configured client timeout = " + timeout + " seconds.");
}
int elapsedTime = (int) sw.getLapTimeMillis() / 1000;
if (Math.abs(elapsedTime - timeout) > 1) {
String msg = "TIMEOUT exception caught as expected, but after " + elapsedTime + " seconds instead of the expected " + timeout + " seconds.";
fail(msg);
}
} finally {
// the release call should block for the remaining 8 s that 'callThatTakesSomeTime' executes after our client timeout.
getContainerServices().releaseComponent(DEFAULT_DUMMYCOMP_INSTANCE);
}
}
use of alma.acs.util.StopWatch in project ACS by ACS-Community.
the class ClientPendingReplyTimeoutTest method testClientPendingReplyTimeout.
/**
* Tests the client-side Corba timeout. Since this client is a JUnit test, the system-level ORB timeout should
* apply, regardless of any timeout setting for the container whose component we call.
*/
public void testClientPendingReplyTimeout() throws Exception {
org.omg.CORBA.Object compObj = getContainerServices().getDefaultComponent(DUMMYCOMP_TYPENAME);
assertNotNull(compObj);
dummyComponent = DummyComponentHelper.narrow(compObj);
int syslevelOrbTimeoutMillis = jconttestUtil.getSystemLevelOrbTimeoutMillis();
assertEquals("system-level jacorb timeout has changed (orb.properties or cmd line), please verify that this test still works as intended!", 180000, syslevelOrbTimeoutMillis);
StopWatch sw = new StopWatch();
try {
// call must last longer than the expected timeout
dummyComponent.callThatTakesSomeTime(syslevelOrbTimeoutMillis + 10000);
fail("Client side timeout was expected after " + syslevelOrbTimeoutMillis / 1000 + " seconds!");
} catch (org.omg.CORBA.TIMEOUT e) {
// good, but check the time
long elapsedMillis = sw.getLapTimeMillis();
int deviationSec = (int) Math.abs(elapsedMillis - syslevelOrbTimeoutMillis) / 1000;
assertTrue("Expected timeout exception was thrown, but after unexpected " + elapsedMillis + " ms.", deviationSec < 2);
}
// This call should take no time, so no exception should be thrown
try {
dummyComponent.callThatTakesSomeTime(0);
} catch (org.omg.CORBA.TIMEOUT e) {
fail("No TIMOUT exception expected for a fast call!");
}
}
Aggregations