use of net.sourceforge.processdash.msg.MessageEvent in project processdash by dtuma.
the class MessageImporterXMLv1 method doImport.
private static void doImport(ArchiveMetricsFileImporter caller, InputStream in, boolean serverMode) throws Exception {
// read the XML document from the input stream.
InputStream xmlIn = new NonclosingInputStream(in);
Document doc = XMLUtils.parse(xmlIn);
Set<String> serverIDs = new HashSet();
// Now, find all of the messages in the document
NodeList messages = doc.getElementsByTagName(MESSAGE_TAG);
if (messages != null) {
for (int i = 0; i < messages.getLength(); i++) {
Element msg = (Element) messages.item(i);
MessageEvent msgEvent = new MessageEvent(msg);
if (serverMode) {
// handle server messages immediately, and keep track of
// the server message IDs we've seen.
MessageDispatcher.getInstance().dispatch(msgEvent, false);
serverIDs.add(msgEvent.getServerId());
} else {
// Register a task to dispatch each message later on the
// background thread. (Message handling logic is defined
// by third parties, and we have no guarantee that it will
// finish in a timely manner. We can't risk hanging the
// import operation indefinitely.)
BackgroundTaskManager.getInstance().addTask(new MessageDispatchTask(msgEvent));
}
}
}
NodeList nl = doc.getElementsByTagName(DELETE_TAG);
if (nl != null && nl.getLength() > 0 && caller != null)
caller.deleteArchiveFileOnCompletion();
if (serverMode)
MessageDispatcher.getInstance().setKnownServerMessagesIDs(serverIDs);
}
Aggregations