Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r2657 - in branches/perfsonarui/src: . org/perfsonar/perfsonarui/flowsa org/perfsonar/perfsonarui/flowsa/panels org/perfsonar/perfsonarui/flowsa/requestTemplates

Subject: perfsonar development work

List archive

perfsonar: r2657 - in branches/perfsonarui/src: . org/perfsonar/perfsonarui/flowsa org/perfsonar/perfsonarui/flowsa/panels org/perfsonar/perfsonarui/flowsa/requestTemplates


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r2657 - in branches/perfsonarui/src: . org/perfsonar/perfsonarui/flowsa org/perfsonar/perfsonarui/flowsa/panels org/perfsonar/perfsonarui/flowsa/requestTemplates
  • Date: Wed, 15 Aug 2007 07:44:26 -0400

Author: gijs
Date: 2007-08-15 07:44:26 -0400 (Wed, 15 Aug 2007)
New Revision: 2657

Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/MA.conf
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/requestTemplates/

branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/requestTemplates/raw.xml

branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/requestTemplates/stat.xml

branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/requestTemplates/top.xml
Removed:

branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSARequestAction.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/SetupDataRequest-rawFlows.xml
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSAModel.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSARequest.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSAResponse.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/panels/RouterOptionsPanel.java
branches/perfsonarui/src/resources.files
Log:


Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSAModel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSAModel.java
2007-08-14 15:46:20 UTC (rev 2656)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSAModel.java
2007-08-15 11:44:26 UTC (rev 2657)
@@ -107,6 +107,7 @@
@Override
protected PerfsonarRequestAction createMetadataRequestAction() {
// TODO Auto-generated method stub
+ logger.warn("not yet implemented");
return null;
}


Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSARequest.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSARequest.java
2007-08-14 15:46:20 UTC (rev 2656)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSARequest.java
2007-08-15 11:44:26 UTC (rev 2657)
@@ -7,11 +7,13 @@

package org.perfsonar.perfsonarui.flowsa;

+import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;

import org.perfsonar.perfsonarui.AbstractMARequest;
import org.perfsonar.perfsonarui.plugins.IPerfsonarResponse;
@@ -22,19 +24,34 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;

import com.sun.org.apache.xml.internal.serialize.OutputFormat;
import com.sun.org.apache.xml.internal.serialize.XMLSerializer;

+/**
+ * @author gijs
+ *
+ */
public class FlowSARequest extends AbstractMARequest {

+ /**
+ * Generate a request and print it. For debugging purpose only.
+ */
public static void main(String[] args) {

FlowSARequest request = new FlowSARequest();
+
+ FlowSAUserData fakeUserData = new FlowSAUserData();
+ fakeUserData.setQuery(FlowSAUserData.ROUTERS, "ford arthur");
+ fakeUserData.setQuery(FlowSAUserData.RAWAGGREGATION,
"aggregation rule");
+ fakeUserData.setQuery(FlowSAUserData.RAWFILTER, "filter
rule");
+ fakeUserData.setQuery(FlowSAUserData.RAWFIELDS,
"AddressFamily TimeFirstSeen MsecFirstSeen");
+ fakeUserData.setQuery(FlowSAUserData.QUERYTYPE, "Raw");
+
try {
- FlowSAUserData fakeUserData = new FlowSAUserData();
- fakeUserData.setQuery(FlowSAUserData.ROUTERS, "ford
arthur");
- Document requestDocument =
request.createRequest(fakeUserData, "raw");
+ Document requestDocument =
request.createRequest(fakeUserData, "SetupDataRequest");
+ request.logRequest(requestDocument);
} catch (Exception e) {
e.printStackTrace();
}
@@ -45,91 +62,153 @@
super();
}

- @Override
- public Document createRequest(IUserData data, String messageType)
throws Exception {
- // String inputFile =
"org/perfsonar/perfsonarui/flowsa/SetupDataRequest-rawFlows.xml";
- String inputFile =
"/home/gijs/stuff/eclipse/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/SetupDataRequest-rawFlows.xml";
- DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- DocumentBuilder builder = factory.newDocumentBuilder();
- InputStream stream =
this.getClass().getClassLoader().getResourceAsStream(inputFile);
- // InputStream stream = new FileInputStream(inputFile);
+ public Document createRawRequest(IUserData data) throws Exception {
+ String inputFile =
"org/perfsonar/perfsonarui/flowsa/requestTemplates/raw.xml";
+ // String inputFile =
+ //
"/home/gijs/stuff/eclipse/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/SetupDataRequest-rawFlows.xml";
+ Document request = parseXmlFile(inputFile);

- Document request = builder.parse(inputFile);
+ replaceGenericParameters(request, data);

- // change start and end moment
- NodeList paraNodes =
request.getElementsByTagName("nmwg:parameter");
- for (int j = 0; j < paraNodes.getLength(); j++) {
- Element timeNode = (Element) paraNodes.item(j);
- String nameAttr = timeNode.getAttribute("name");
- if (nameAttr.equals("startTime")) {
- Element startNode = (Element)
timeNode.getElementsByTagName("nmtm:time").item(0);
- startNode.setAttribute("value",
data.getStartTime());
- } else if (nameAttr.equals("endTime")) {
- Element endNode = (Element)
timeNode.getElementsByTagName("nmtm:time").item(0);
- endNode.setAttribute("value",
data.getEndTime());
- }
+ // add fields parameters
+ Node parameters =
request.getElementsByTagName("flow:parameters").item(0);
+ for (String field :
data.getQuery(FlowSAUserData.RAWFIELDS).split(" ")) {
+ Element fieldNode =
request.createElementNS("http://ggf.org/ns/nmwg/base/2.0/";, "parameter");
+ fieldNode.setAttribute("name", "showField" + field);
+ parameters.appendChild(fieldNode);
}

- Node network =
request.getElementsByTagName("nmwgtopo3:network").item(0);
+ request.normalize();
+ logRequest(request);

- // remove example routers
- while (network.getChildNodes().getLength() > 0) {
- network.removeChild(network.getFirstChild());
- }
+ return request;
+ }

- // add routers from userdata
- int routerid = 1;
- for (String router :
data.getQuery(FlowSAUserData.ROUTERS).split(" ")) {
- Element routerNode =
request.createElement("nmwgtopo3:node");
- routerNode.setAttribute("id", "router" + routerid);
+ @Override
+ public Document createRequest(IUserData data, String messageType)
throws Exception {
+ String type = data.getQuery(FlowSAUserData.QUERYTYPE);

- Element routerSubNode =
request.createElement("nmwgtopo3:hostName");
-
routerSubNode.appendChild(request.createTextNode(router));
- routerNode.appendChild(routerSubNode);
- network.appendChild(routerNode);
- routerid++;
- }
+ if (type.equals("Raw")) {
+ return createRawRequest(data);

- // change filter rule
- // request.getElementById(elementId)
- // aggregationRule
+ } else if (type.equals("Top")) {
+ return createTopRequest(data);

- StringWriter sw = new StringWriter();
- OutputFormat format = new OutputFormat(request);
- format.setLineWidth(65);
- format.setIndenting(true);
- format.setIndent(2);
+ } else if (type.equals("Statistical")) {
+ return createStatRequest(data);

- XMLSerializer output = new XMLSerializer(sw, format);
- output.serialize(request);
- logger.info(sw.getBuffer());
- return request;
+ } else {
+ return null;
+ }
}

@Override
- public Document createRequest(MAEndpoint endpoint, MetaDataList
query, String messageType) throws Exception {
+ public Document createRequest(MAEndpoint endpoint, MetaDataList
metaDataList, String messageType) throws Exception {
// TODO Auto-generated method stub
+ logger.warn("not yet implemented");
return null;
}

+ private Document createStatRequest(IUserData data) throws
ParserConfigurationException, SAXException, IOException {
+ String inputFile =
"org/perfsonar/perfsonarui/flowsa/requestTemplates/stat.xml";
+ Document request = parseXmlFile(inputFile);
+ replaceGenericParameters(request, data);
+ return request;
+ }
+
+ private Document createTopRequest(IUserData data) throws
ParserConfigurationException, SAXException, IOException {
+ String inputFile =
"org/perfsonar/perfsonarui/flowsa/requestTemplates/top.xml";
+ Document request = parseXmlFile(inputFile);
+ replaceGenericParameters(request, data);
+ return request;
+ }
+
@Override
public String getMessageNamespace() {
// TODO Auto-generated method stub
+ logger.warn("not yet implemented");
return null;
}

public String[] getNamespaces() {
// TODO Auto-generated method stub
+ logger.warn("not yet implemented");
return null;
}

public String getRequestType() {
// TODO Auto-generated method stub
+ logger.warn("not yet implemented");
return null;
}

+ public void logRequest(Document request) {
+ // serialize for debugging
+ StringWriter sw = new StringWriter();
+ OutputFormat format = new OutputFormat(request);
+ format.setLineWidth(65);
+ format.setIndenting(true);
+ format.setIndent(2);
+
+ XMLSerializer output = new XMLSerializer(sw, format);
+ try {
+ output.serialize(request);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ logger.debug(sw.getBuffer());
+
+ }
+
+ private Document parseXmlFile(String inputFile) throws
ParserConfigurationException, SAXException, IOException {
+ DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ InputStream stream =
this.getClass().getClassLoader().getResourceAsStream(inputFile);
+ return builder.parse(stream);
+ }
+
public void process(IUserData data, Document response,
IPerfsonarResponse listener) throws Exception {
logger.debug(response);
}
+
+ private void replaceGenericParameters(Document request, IUserData
data) {
+ // change start moment, end moment, filter rule &
aggregationRule rule
+ NodeList paraNodes =
request.getElementsByTagName("nmwg:parameter");
+ for (int j = 0; j < paraNodes.getLength(); j++) {
+ Element paraNode = (Element) paraNodes.item(j);
+ String nameAttr = paraNode.getAttribute("name");
+ if (nameAttr.equals("startTime")) {
+ Element startNode = (Element)
paraNode.getElementsByTagName("nmtm:time").item(0);
+ startNode.setAttribute("value",
data.getStartTime());
+ } else if (nameAttr.equals("endTime")) {
+ Element endNode = (Element)
paraNode.getElementsByTagName("nmtm:time").item(0);
+ endNode.setAttribute("value",
data.getEndTime());
+ } else if (nameAttr.equals("aggregationRule")) {
+
paraNode.getFirstChild().setTextContent(data.getQuery(FlowSAUserData.RAWAGGREGATION));
+ } else if (nameAttr.equals("filterRule")) {
+
paraNode.getFirstChild().setTextContent(data.getQuery(FlowSAUserData.RAWFILTER));
+ }
+ }
+
+ Node network =
request.getElementsByTagName("nmwgtopo3:network").item(0);
+ // remove example routers
+ while (network.getChildNodes().getLength() > 0) {
+ network.removeChild(network.getFirstChild());
+ }
+
+ // add routers from userdata
+ int routerid = 1;
+ for (String router :
data.getQuery(FlowSAUserData.ROUTERS).split(" ")) {
+ Element routerNode =
request.createElementNS("http://ggf.org/ns/nmwg/topology/base/3.0/";, "node");
+ routerNode.setAttribute("id", "router" + routerid);
+
+ Element routerSubNode =
request.createElementNS("http://ggf.org/ns/nmwg/topology/base/3.0/";,
"hostName");
+
routerSubNode.appendChild(request.createTextNode(router));
+ routerNode.appendChild(routerSubNode);
+ network.appendChild(routerNode);
+ routerid++;
+ }
+ }
+
}

Deleted:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSARequestAction.java

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSAResponse.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSAResponse.java
2007-08-14 15:46:20 UTC (rev 2656)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSAResponse.java
2007-08-15 11:44:26 UTC (rev 2657)
@@ -31,7 +31,8 @@

@Override
public void process(IPerfsonarRequest request, IUserData uData,
Document response) throws Exception {
- logger.debug("response.process");
+ // TODO: implement
+ logger.warn("not yet implemented");

}


Added: branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/MA.conf

Deleted:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/SetupDataRequest-rawFlows.xml

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/panels/RouterOptionsPanel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/panels/RouterOptionsPanel.java
2007-08-14 15:46:20 UTC (rev 2656)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/panels/RouterOptionsPanel.java
2007-08-15 11:44:26 UTC (rev 2657)
@@ -16,11 +16,6 @@
addWidgets();
}

- @Override
- public String toString() {
- return "Routers";
- }
-
private void addWidgets() {
routerList = new javax.swing.JList();

this.setBorder(javax.swing.BorderFactory.createTitledBorder("Routers"));
@@ -29,13 +24,13 @@
private static final long serialVersionUID = 1L;
String[] strings = { "Arthur", "Zaphod", "Ford",
"Trillian" };

+ public Object getElementAt(int i) {
+ return strings[i];
+ }
+
public int getSize() {
return strings.length;
}
-
- public Object getElementAt(int i) {
- return strings[i];
- }
});

org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(this);
@@ -49,10 +44,16 @@
}

public String getRouters() {
+ // TODO: this should be replaced by an array or something
simulair. Just for printing now
StringBuffer buffer = new StringBuffer();
for (Object value : routerList.getSelectedValues())
buffer.append(value.toString() + " ");
return buffer.toString();
}

+ @Override
+ public String toString() {
+ return "Routers";
+ }
+
}

Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/requestTemplates/raw.xml

Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/requestTemplates/stat.xml

Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/requestTemplates/top.xml

Modified: branches/perfsonarui/src/resources.files
===================================================================
--- branches/perfsonarui/src/resources.files 2007-08-14 15:46:20 UTC (rev
2656)
+++ branches/perfsonarui/src/resources.files 2007-08-15 11:44:26 UTC (rev
2657)
@@ -12,6 +12,9 @@
org/perfsonar/perfsonarui/ippm/SetupGeant-template-mid.xml
org/perfsonar/perfsonarui/ippm/SetupGeant-template-noparams.xml
org/perfsonar/perfsonarui/ippm/KeyRequestEmpty.xml
-org/perfsonar/perfsonarui/flowsa/SetupDataRequest-rawFlows.xml
+org/perfsonar/perfsonarui/flowsa/requestTemplates/raw.xml
+org/perfsonar/perfsonarui/flowsa/requestTemplates/stat.xml
+org/perfsonar/perfsonarui/flowsa/requestTemplates/top.xml
+org/perfsonar/perfsonarui/flowsa/MA.conf
org/perfsonar/perfsonarui/config/MA.conf




  • perfsonar: r2657 - in branches/perfsonarui/src: . org/perfsonar/perfsonarui/flowsa org/perfsonar/perfsonarui/flowsa/panels org/perfsonar/perfsonarui/flowsa/requestTemplates, svnlog, 08/15/2007

Archive powered by MHonArc 2.6.16.

Top of Page