Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r2756 - branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa

Subject: perfsonar development work

List archive

perfsonar: r2756 - branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r2756 - branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa
  • Date: Fri, 31 Aug 2007 16:33:28 -0400

Author: michael.bischoff
Date: 2007-08-31 16:33:27 -0400 (Fri, 31 Aug 2007)
New Revision: 2756

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/FlowSAUserData.java
Log:


Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSAModel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSAModel.java
2007-08-31 12:53:07 UTC (rev 2755)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSAModel.java
2007-08-31 20:33:27 UTC (rev 2756)
@@ -1,6 +1,6 @@
/*

-$Id$
+ $Id$
$Copyright$

*/
@@ -32,78 +32,111 @@
import org.perfsonar.perfsonarui.ui.actions.SetOptionsAction;
import org.perfsonar.perfsonarui.ui.panels.UserDataDetailsPane;

+import static org.perfsonar.perfsonarui.flowsa.FlowSAUserData.*;
+
+/**
+ * Implementation of the FlowSA tab.
+ *
+ * @author Gijs Molenaar, Michael Bischoff
+ */
public class FlowSAModel extends PerfsonarModel {

- private final MainOptionsPanel mainOptionsPanel;
- private final MomentOptionsPanel momentOptionsPanel;
- private final RouterOptionsPanel routerOptionsPanel;
- private final RawOptionsPanel rawOptionsPanel;
- private final TopOptionsPanel topOptionsPanel;
+ private final MainOptionsPanel mainOptionsPanel = new
MainOptionsPanel();
+ private final MomentOptionsPanel momentOptionsPanel = new
MomentOptionsPanel();
+ private final RouterOptionsPanel routerOptionsPanel = new
RouterOptionsPanel();
+ private final RawOptionsPanel rawOptionsPanel = new RawOptionsPanel();
+ private final TopOptionsPanel topOptionsPanel = new TopOptionsPanel();

+ /**
+ * Default constructor
+ * just calls super.
+ */
public FlowSAModel() {
this(null);
}

+ /**
+ * Constructor initialises this tab with the first avail endpoint.
+ * @see PerfsonarModel#PerfsonarModel(MAEndpointList)
+ * @param endpoints
+ */
public FlowSAModel(MAEndpointList endpoints) {
super(endpoints);
- int enabledEndpoint = -1;
+ MAEndpoint currentEndPoint =
initialiseEndPoints(this.endpointList);
+ logger.error("currentEndpoint = "+currentEndPoint);
+ getUserData().setEndpoint(currentEndPoint);
+ }

- // reset status
+ /**
+ * Looks through the list and selects the fist avail endpoint if
+ * non are availiable then it picks the first from the list enables
+ * it and returns that endpoint
+ * @param endpointList
+ * @return a endpoint if avail or null.
+ */
+ private MAEndpoint initialiseEndPoints(MAEndpointList endpointList) {
for (int i = 0; i < endpointList.size(); i++) {
+ // reset status
(endpointList.get(i)).setStatusExplanation("");
(endpointList.get(i)).setStatus("");
- }
-
- // find first selected
- for (int i = 0; i < endpointList.size(); i++)
+ // find first selected
if ((endpointList.get(i)).isEnabled()) {
- enabledEndpoint = i;
- break;
+ return endpointList.get(i);
}
-
- // if no selected; select first
- if (enabledEndpoint == -1) {
- (endpointList.get(0)).setEnabled(true);
- enabledEndpoint = 0;
+ }
+ MAEndpoint first = endpointList.get(0);
+ if(first!=null) {
+ first.setEnabled(true);
+ return first;
}
-
- getUserData().setEndpoint(endpointList.get(enabledEndpoint));
-
- mainOptionsPanel = new MainOptionsPanel();
- momentOptionsPanel = new MomentOptionsPanel();
- routerOptionsPanel = new RouterOptionsPanel();
- rawOptionsPanel = new RawOptionsPanel();
- topOptionsPanel = new TopOptionsPanel();
+ return null;
}

+ /* (non-Javadoc)
+ * @see
org.perfsonar.perfsonarui.ui.PerfsonarModel#createDetailsComponent(java.awt.Component)
+ */
@Override
public JComponent[] createDetailsComponent(Component parentComponent)
{
- String[][] s = new String[][] { { FlowSAUserData.QUERYTYPE,
"Query Type" }, { FlowSAUserData.ROUTERS, "Routers" },
- { FlowSAUserData.STARTMOMENT, "Start Moment"
}, { FlowSAUserData.ENDMOMENT, "End Moment" },
- { FlowSAUserData.RAWFILTER, "Raw Filter rule"
}, { FlowSAUserData.RAWAGGREGATION, "Raw Aggregation rule" },
- { FlowSAUserData.RAWFIELDS, "Raw fields" }, {
FlowSAUserData.TOPELEMENTS, "Top fields" },
- { FlowSAUserData.TOPORDERBY, "Top Order by"
}, { FlowSAUserData.TOPNUMBER, "Top Numbers" },
- { FlowSAUserData.TOPTRANSGROUP, "Top Group
Transport ports" },
- { FlowSAUserData.TOPFILTER,
FlowSAUserData.TOPFILTER },
- { FlowSAUserData.TOPAGGREGATION,
FlowSAUserData.TOPAGGREGATION }, };
+ String[][] s = new String[][] {
+ { QUERYTYPE, "Query Type" },
+ { ROUTERS, "Routers" },
+ { STARTMOMENT, "Start Moment" },
+ { ENDMOMENT, "End Moment" },
+ { RAWFILTER, "Raw Filter rule" },
+ { RAWAGGREGATION, "Raw Aggregation rule" },
+ { RAWFIELDS, "Raw fields" },
+ { TOPELEMENTS, "Top fields" },
+ { TOPORDERBY, "Top Order by" },
+ { TOPNUMBER, "Top Numbers" },
+ { TOPTRANSGROUP, "Top Group Transport ports"
},
+ { TOPFILTER, FlowSAUserData.TOPFILTER },
+ { TOPAGGREGATION,
FlowSAUserData.TOPAGGREGATION }
+ };
UserDataDetailsPane userDataPanel = new
UserDataDetailsPane("Settings", getUserData(), s, true, false);
return new JComponent[] { userDataPanel };
}

+ /* (non-Javadoc)
+ * @see org.perfsonar.perfsonarui.ui.PerfsonarModel#createEndpoints()
+ */
@Override
public MAEndpointList createEndpoints() {
MAEndpointList endpoints = new MAEndpointList(false);
- MAEndpoint endpoint = new MAEndpoint(
-
"SURFnet,http://sonar1.amsterdam.surfnet.nl:8080/flowsa-ma-0.0.1/services/FlowsaMeasurementArchiveService,\"\",flowsa,flowsa";);
- //
"SURFnet,http://localhost:8080/flowsa-ma-0.0.1/services/FlowsaMeasurementArchiveService,\"\",flowsa,flowsa";);
- endpoints.add(endpoint);
+ endpoints.add(new
MAEndpoint("local,http://sonar1.amsterdam.surfnet.nl:8080/flowsa-ma-0.0.1/services/FlowsaMeasurementArchiveService,\"\",flowsa,flowsa";));
+ endpoints.add(new
MAEndpoint("SURFnet,http://localhost:8080/flowsa-ma-0.0.1/services/FlowsaMeasurementArchiveService,\"\",flowsa,flowsa";));
return endpoints;
}

+ /* (non-Javadoc)
+ * @see
org.perfsonar.perfsonarui.plugins.IPerfsonarTab#createMainComponent(java.awt.Component)
+ */
public PluginMainPanel createMainComponent(Component parentComponent)
{
return new QueryResultPanel(parentComponent, this,
getUserData());
}

+ /* (non-Javadoc)
+ * @see
org.perfsonar.perfsonarui.ui.PerfsonarModel#createMetadataRequestAction()
+ */
@Override
protected PerfsonarRequestAction createMetadataRequestAction() {
// TODO Auto-generated method stub
@@ -111,41 +144,64 @@
return null;
}

-
+ /* (non-Javadoc)
+ * @see
org.perfsonar.perfsonarui.ui.PerfsonarModel#createOptionsAction()
+ */
@Override
public PSUIAction createOptionsAction() {
- /*
- *Callen when optiondialog is closed
- */
return new SetOptionsAction(this) {

private static final long serialVersionUID = 1L;

@Override
protected void confirm(JComponent[] optionPanels) {
-
getUserData().setQuery(FlowSAUserData.QUERYTYPE,
mainOptionsPanel.getQueryType());
-
getUserData().setQuery(FlowSAUserData.STARTMOMENT,
momentOptionsPanel.getStartMoment());
-
getUserData().setQuery(FlowSAUserData.ENDMOMENT,
momentOptionsPanel.getEndMoment());
-
getUserData().setQuery(FlowSAUserData.ROUTERS,
routerOptionsPanel.getRouters());
-
getUserData().setQuery(FlowSAUserData.RAWFILTER, rawOptionsPanel.getFilter());
-
getUserData().setQuery(FlowSAUserData.RAWAGGREGATION,
rawOptionsPanel.getAggregation());
-
getUserData().setQuery(FlowSAUserData.RAWFIELDS, rawOptionsPanel.getFields());
-
getUserData().setQuery(FlowSAUserData.TOPELEMENTS,
topOptionsPanel.getElement());
-
getUserData().setQuery(FlowSAUserData.TOPORDERBY,
topOptionsPanel.getOrderBy());
-
getUserData().setQuery(FlowSAUserData.TOPNUMBER, topOptionsPanel.getNumber());
-
getUserData().setQuery(FlowSAUserData.TOPTRANSGROUP,
topOptionsPanel.getTransGroup());
-
getUserData().setQuery(FlowSAUserData.TOPFILTER, topOptionsPanel.getFilter());
-
getUserData().setQuery(FlowSAUserData.TOPAGGREGATION,
topOptionsPanel.getAggregation());
+
getUserData().setQuery(FlowSAUserData.QUERYTYPE,
+
mainOptionsPanel.getQueryType());
+
getUserData().setQuery(FlowSAUserData.STARTMOMENT,
+
momentOptionsPanel.getStartMoment());
+
getUserData().setQuery(FlowSAUserData.ENDMOMENT,
+
momentOptionsPanel.getEndMoment());
+ getUserData().setQuery(FlowSAUserData.ROUTERS,
+
routerOptionsPanel.getRouters());
+
getUserData().setQuery(FlowSAUserData.RAWFILTER,
+ rawOptionsPanel.getFilter());
+
getUserData().setQuery(FlowSAUserData.RAWAGGREGATION,
+
rawOptionsPanel.getAggregation());
+
getUserData().setQuery(FlowSAUserData.RAWFIELDS,
+ rawOptionsPanel.getFields());
+
getUserData().setQuery(FlowSAUserData.TOPELEMENTS,
+ topOptionsPanel.getElement());
+
getUserData().setQuery(FlowSAUserData.TOPORDERBY,
+ topOptionsPanel.getOrderBy());
+
getUserData().setQuery(FlowSAUserData.TOPNUMBER,
+ topOptionsPanel.getNumber());
+
getUserData().setQuery(FlowSAUserData.TOPTRANSGROUP,
+
topOptionsPanel.getTransGroup());
+
getUserData().setQuery(FlowSAUserData.TOPFILTER,
+ topOptionsPanel.getFilter());
+
getUserData().setQuery(FlowSAUserData.TOPAGGREGATION,
+
topOptionsPanel.getAggregation());
}
};
}

+ /* (non-Javadoc)
+ * @see
org.perfsonar.perfsonarui.ui.PerfsonarModel#createOptionsComponent(java.awt.Component)
+ */
@Override
public JComponent[] createOptionsComponent(Component parentComponent)
{
- return new JComponent[] { mainOptionsPanel,
momentOptionsPanel, routerOptionsPanel, rawOptionsPanel,
- topOptionsPanel };
+ return new JComponent[] {
+ mainOptionsPanel,
+ momentOptionsPanel,
+ routerOptionsPanel,
+ rawOptionsPanel,
+ topOptionsPanel
+ };
}

+ /* (non-Javadoc)
+ * @see
org.perfsonar.perfsonarui.ui.PerfsonarModel#createSmartRequest()
+ */
@Override
protected SmartMARequest createSmartRequest() {
return new SmartMARequest() {
@@ -156,15 +212,24 @@
};
}

+ /* (non-Javadoc)
+ * @see org.perfsonar.perfsonarui.ui.PerfsonarModel#createUserData()
+ */
@Override
public FlowSAUserData createUserData() {
return new FlowSAUserData();
}

+ /* (non-Javadoc)
+ * @see org.perfsonar.perfsonarui.plugins.IPerfsonarTab#getOrder()
+ */
public int getOrder() {
return 100;
}

+ /* (non-Javadoc)
+ * @see
org.perfsonar.perfsonarui.ui.PerfsonarModel#getSupportedRequests()
+ */
@Override
public List<IPerfsonarSchema> getSupportedRequests() {
ArrayList<IPerfsonarSchema> supported = new
ArrayList<IPerfsonarSchema>();
@@ -172,11 +237,17 @@
return supported;
}

+ /* (non-Javadoc)
+ * @see org.perfsonar.perfsonarui.ui.PerfsonarModel#getUserData()
+ */
@Override
public FlowSAUserData getUserData() {
return (FlowSAUserData) userData;
}

+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
@Override
public String toString() {
return "FlowSA";

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSARequest.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSARequest.java
2007-08-31 12:53:07 UTC (rev 2755)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSARequest.java
2007-08-31 20:33:27 UTC (rev 2756)
@@ -62,7 +62,41 @@
super();
}

- public Document createRawRequest(IUserData data) throws Exception {
+ @Override
+ public Document createRequest(MAEndpoint endpoint, MetaDataList
metaDataList, String messageType) throws Exception {
+ // TODO: not yet implemented
+ logger.warn("not yet implemented");
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.perfsonar.perfsonarui.AbstractMARequest#createRequest(org.perfsonar.perfsonarui.plugins.IUserData,
java.lang.String)
+ */
+ @Override
+ public Document createRequest(IUserData data, String messageType)
throws Exception {
+ String type = data.getQuery(FlowSAUserData.QUERYTYPE);
+
+ if (type.equals("Raw")) {
+ logger.debug("Creating raw request.");
+ return createRawRequest(data);
+ } else if (type.equals("Top")) {
+ logger.debug("Creating top request.");
+ return createTopRequest(data);
+ } else if (type.equals("Statistical")) {
+ logger.debug("Creating statistics request.");
+ return createStatRequest(data);
+ } else {
+ logger.error("Querytype not supported: " + type +
".");
+ return null;
+ }
+ }
+
+ /**
+ * @param data
+ * @return
+ * @throws Exception
+ */
+ protected Document createRawRequest(IUserData data) throws Exception {
String inputFile =
"org/perfsonar/perfsonarui/flowsa/requestTemplates/raw.xml";
Document request = parseXmlFile(inputFile);

@@ -94,41 +128,21 @@
return request;
}

- @Override
- public Document createRequest(IUserData data, String messageType)
throws Exception {
- String type = data.getQuery(FlowSAUserData.QUERYTYPE);
-
- if (type.equals("Raw")) {
- return createRawRequest(data);
-
- } else if (type.equals("Top")) {
- logger.error("top request");
- return createTopRequest(data);
-
- } else if (type.equals("Statistical")) {
- return createStatRequest(data);
-
- } else {
- logger.error("querytype not supported: " + type);
- return null;
- }
- }
-
- @Override
- public Document createRequest(MAEndpoint endpoint, MetaDataList
metaDataList, String messageType) throws Exception {
- // TODO: not yet implemented
- logger.warn("not yet implemented");
- return null;
- }
-
- private Document createStatRequest(IUserData data) throws
ParserConfigurationException, SAXException, IOException {
+ protected 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 {
+ /**
+ * @param data
+ * @return
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
+ */
+ protected Document createTopRequest(IUserData data) throws
ParserConfigurationException, SAXException, IOException {
String inputFile =
"org/perfsonar/perfsonarui/flowsa/requestTemplates/top.xml";

Document request = parseXmlFile(inputFile);
@@ -184,6 +198,10 @@
return null;
}

+ /**
+ * Logs a request / document
+ * @param request the request to be logged
+ */
public void logRequest(Document request) {
// serialize for debugging
StringWriter sw = new StringWriter();
@@ -199,31 +217,19 @@
e.printStackTrace();
}
logger.debug(sw.getBuffer());
-
}

- private Document parseXmlFile(String inputFile) {
- DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- InputStream stream =
this.getClass().getClassLoader().getResourceAsStream(inputFile);
-
- try {
- DocumentBuilder builder =
factory.newDocumentBuilder();
- return builder.parse(stream);
- } catch (SAXException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- }
- return null;
- }
-
+ /* (non-Javadoc)
+ * @see
org.perfsonar.perfsonarui.plugins.IPerfsonarRequest#process(org.perfsonar.perfsonarui.plugins.IUserData,
org.w3c.dom.Document, org.perfsonar.perfsonarui.plugins.IPerfsonarResponse)
+ */
public void process(IUserData data, Document response,
IPerfsonarResponse listener) throws Exception {
logger.debug(response);
}

+ /**
+ * @param request
+ * @param data
+ */
private void replaceGenericParameters(Document request, IUserData
data) {
// change start moment, end moment
NodeList paraNodes =
request.getElementsByTagName("nmwg:parameter");
@@ -260,4 +266,27 @@
}
}

+ /**
+ * Converts a String into a document.
+ * @param inputFile
+ * @return
+ */
+ private Document parseXmlFile(String inputFile) {
+ DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ InputStream stream =
this.getClass().getClassLoader().getResourceAsStream(inputFile);
+
+ try {
+ DocumentBuilder builder =
factory.newDocumentBuilder();
+ return builder.parse(stream);
+ } catch (SAXException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
}

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSAUserData.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSAUserData.java
2007-08-31 12:53:07 UTC (rev 2755)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSAUserData.java
2007-08-31 20:33:27 UTC (rev 2756)
@@ -11,6 +11,10 @@

import org.perfsonar.perfsonarui.AbstractUserData;

+/**
+ * Userdata object for FlowSA
+ * @author Gijs Molenaar
+ */
public class FlowSAUserData extends AbstractUserData {

private static final long serialVersionUID = 1L;
@@ -29,6 +33,9 @@
public final static String TOPFILTER = "Top Filter rule";
public final static String TOPAGGREGATION = "Top Aggregation rule";

+ /**
+ * Default no arg constructor
+ */
public FlowSAUserData() {
super();




  • perfsonar: r2756 - branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa, svnlog, 08/31/2007

Archive powered by MHonArc 2.6.16.

Top of Page