Skip to Content.
Sympa Menu

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

Subject: perfsonar development work

List archive

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


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r2563 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa: . panels
  • Date: Tue, 24 Jul 2007 04:36:13 -0400

Author: gijs
Date: 2007-07-24 04:36:12 -0400 (Tue, 24 Jul 2007)
New Revision: 2563

Modified:

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

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

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

branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/panels/RouterOptionsPanel.java
Log:
trying to make request code

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSARequest.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSARequest.java
2007-07-20 14:58:16 UTC (rev 2562)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSARequest.java
2007-07-24 08:36:12 UTC (rev 2563)
@@ -1,62 +1,202 @@
-
/*

$Id$
$Copyright$

-*/
+ */

package org.perfsonar.perfsonarui.flowsa;

import javax.xml.parsers.DocumentBuilderFactory;

+import org.jdom.Element;
+import org.jdom.Namespace;
import org.perfsonar.perfsonarui.AbstractMARequest;
+import org.perfsonar.perfsonarui.AbstractUserData;
+import org.perfsonar.perfsonarui.ma.UserData;
import org.perfsonar.perfsonarui.plugins.IPerfsonarResponse;
import org.perfsonar.perfsonarui.plugins.IUserData;
import org.perfsonar.perfsonarui.plugins.MAEndpoint;
import org.perfsonar.perfsonarui.plugins.MetaDataList;
import org.w3c.dom.Document;

-
public class FlowSARequest extends AbstractMARequest {
+ protected static String[] URI_nmwgt = { "",
+ "http://ggf.org/ns/nmwg/topology/";,
+ "http://ggf.org/ns/nmwg/topology/2.0/"; };
+ protected static String[] URI_nmwg = { "", NMWG, NMWG2 };
+ protected static String[][] URI_perfsonar = {
+ { "perfsonar",
"http://ggf.org/ns/nmwg/tools/org/perfsonar/"; },
+ { "perfsonar",
"http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/"; },
+ { "flow", "http://ggf.org/ns/nmwg/tools/flow/2.0/"; }
};
+ protected static String[] URI_nmwg_select = { "",
+ "http://ggf.org/ns/nmwg/ops/select/";,
+ "http://ggf.org/ns/nmwg/ops/select/2.0/"; };

-
- public DocumentBuilderFactory factory;
+ protected Namespace nmwg = null;
+ protected Namespace nmwgt = null;
+ protected Namespace perfsonar = null;
+ protected Namespace select = null;
+ protected int nmwg_version; // nmwgv2
+ protected int perfsonar_version; // nmwgv2
+ protected int subjectid = 1;

- public FlowSARequest() {
- super();
- factory = DocumentBuilderFactory.newInstance();
- }
+ public DocumentBuilderFactory factory;

- @Override
- public Document createRequest(IUserData uData, String messageType) {
- return null;
- }
+ public FlowSARequest() {
+ super();
+ }

- @Override
- public Document createRequest(MAEndpoint endpoint, MetaDataList query,
- String messageType) throws Exception {
- throw new Exception("Request not available");
- }
+ @Override
+ public Document createRequest(IUserData uData, String messageType)
+ throws Exception {
+ return createSetupDataReq((UserData) uData);
+ }

- @Override
- public String getMessageNamespace() {
- return getClass().getName();
- }
+ @Override
+ public Document createRequest(MAEndpoint endpoint, MetaDataList query,
+ String messageType) throws Exception {
+ throw new Exception("Request not available");
+ }

- public String[] getNamespaces() {
- return new String[] { getClass().getName()};
- }
+ protected Document createSetupDataReq(UserData userData) throws
Exception {
+ initializeNamespaces();

- public String getRequestType() {
- return getClass().getName();
- }
+ Element MesgElem = new Element(E_MESSAGE, nmwg);
+ MesgElem.setAttribute(E_TYPE, MA_SetupDataRequest);
+ MesgElem.setAttribute(E_ID, "message" + getId());
+ MesgElem.addNamespaceDeclaration(nmwgt);
+ MesgElem.addNamespaceDeclaration(perfsonar);
+ MesgElem.addNamespaceDeclaration(select);

- public void process(IUserData uData, Document response,
- IPerfsonarResponse listener) throws Exception {
- }
+ createSetupDataMetaData(userData, MesgElem, userData
+ .getQuery(UserData.C_DIRECTION));

- protected String getEchoRequest() {
- return null;
- }
+ return createDocumentFromElement(MesgElem);
+ }
+
+ protected Element createSetupDataMetaData(UserData userData,
+ Element MesgElem, String id) {
+ String metadataID1 = "meta_" + id;// +
+ // Long.toString(System.currentTimeMillis());
+ Element MetElem = createMetadataSection(userData,
metadataID1);
+ MesgElem.addContent(MetElem);
+
+ String metadataID2 = "m_param_" + id;//
+Long.toString(System.currentTimeMillis());
+ Element MetElem2 = createMetadataSection2(userData,
metadataID2,
+ MetElem.getAttributeValue(E_ID));
+ MesgElem.addContent(MetElem2);
+
+ Element data = new Element(E_DATA, nmwg);
+ data.setAttribute(E_ID, "data_" + id);//
Long.toString(System.currentTimeMillis()));
+ data.setAttribute(E_METADATAIDREF,
MetElem2.getAttributeValue(E_ID));
+ MesgElem.addContent(data);
+ return MesgElem;
+
+ }
+
+ public Element createMetadataSection(UserData userData, String
metadataID) {
+ Element MetElem = new Element(E_METADATA, nmwg);
+ MetElem.setAttribute(E_ID, metadataID);
+ Element SubjElem = new Element(E_SUBJECT, perfsonar);
+ SubjElem.setAttribute(E_ID, "subject_" + subjectid);
+ subjectid++;
+ return MetElem;
+ }
+
+ public Element createMetadataSection2(UserData userData, String
metadataID,
+ String metadataIDRef) {
+
+ Namespace selectParams = getParamsNamespace();
+ Namespace subjectNS = getSubjectNamespace();
+
+ Element MetElem = new Element(E_METADATA, nmwg);
+
+ MetElem.setAttribute(E_ID, metadataID);
+
+ Element SubjElem = new Element(E_SUBJECT, subjectNS);
+
+ // SubjElem.setAttribute(E_ID,
+ // "subject"+Long.toString(System.currentTimeMillis()));
+ SubjElem.setAttribute(E_ID, "subject1_" + subjectid);
+ subjectid++;
+ SubjElem.setAttribute(E_METADATAIDREF, metadataIDRef);
+
+ MetElem.addContent(SubjElem);
+
+ MetElem.addContent(new Element("eventType", nmwg)
+ .setText(getSelectEventType()));
+
+ Element ParamElem = new Element(E_PARAMETERS, select);
+ ParamElem.setAttribute(E_ID, "param_" + subjectid);
+ MetElem.addContent(ParamElem);
+
+ Element ParamIntElem1 = new Element(E_PARAMETER,
selectParams);
+ ParamIntElem1.setAttribute(E_PARAMETERNAME, E_STARTTIME);
+
ParamIntElem1.setText(userData.getStartTime(AbstractUserData.ID_QUERY));
+ ParamElem.addContent(ParamIntElem1);
+
+ Element ParamIntElem2 = new Element(E_PARAMETER,
selectParams);
+ ParamIntElem2.setAttribute(E_PARAMETERNAME, E_ENDTIME);
+
ParamIntElem2.setText(userData.getEndTime(AbstractUserData.ID_QUERY));
+ ParamElem.addContent(ParamIntElem2);
+
+ Element ParamIntElem4 = new Element(E_PARAMETER,
selectParams);
+ ParamIntElem4.setAttribute(E_PARAMETERNAME,
E_CONSOLIDATIONFUNCTION);
+ ParamIntElem4.setText(userData
+
.getConsolidationFunc(AbstractUserData.ID_QUERY));
+ ParamElem.addContent(ParamIntElem4);
+
+ Element ParamIntElem5 = new Element(E_PARAMETER,
selectParams);
+ ParamIntElem5.setAttribute(E_PARAMETERNAME, E_RESOLUTION);
+ ParamIntElem5
+
.setText(userData.getResolution(AbstractUserData.ID_QUERY));
+ ParamElem.addContent(ParamIntElem5);
+
+ return MetElem;
+ }
+
+ public void initializeNamespaces() {
+ if (nmwg == null)
+ nmwg = Namespace.getNamespace("nmwg",
URI_nmwg[nmwg_version]);
+ if (nmwgt == null)
+ nmwgt = Namespace.getNamespace("nmwgt",
URI_nmwgt[nmwg_version]);
+ if (perfsonar == null)
+ perfsonar = Namespace.getNamespace(
+ URI_perfsonar[perfsonar_version][0],
+ URI_perfsonar[perfsonar_version][1]);
+ if (select == null)
+ select = Namespace.getNamespace("select",
+ URI_nmwg_select[nmwg_version]);
+
+ }
+
+ protected Namespace getParamsNamespace() {
+ return select;
+ }
+
+ protected Namespace getSubjectNamespace() {
+ return perfsonar;
+ }
+
+ protected String getSelectEventType() {
+ return "select";
+ }
+
+ @Override
+ public String getMessageNamespace() {
+ return getClass().getName();
+ }
+
+ public String[] getNamespaces() {
+ return new String[] { getClass().getName() };
+ }
+
+ public String getRequestType() {
+ return getClass().getName();
+ }
+
+ public void process(IUserData uData, Document response,
+ IPerfsonarResponse listener) throws Exception {
+ }
}

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSARequestAction.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSARequestAction.java
2007-07-20 14:58:16 UTC (rev 2562)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/FlowSARequestAction.java
2007-07-24 08:36:12 UTC (rev 2563)
@@ -3,7 +3,7 @@
$Id$
$Copyright$

-*/
+ */

package org.perfsonar.perfsonarui.flowsa;

@@ -15,108 +15,66 @@
import org.perfsonar.perfsonarui.SmartMARequest;
import org.perfsonar.perfsonarui.plugins.IPerfsonarRequest;
import org.perfsonar.perfsonarui.plugins.IPerfsonarTab;
-import org.perfsonar.perfsonarui.plugins.IUserData;
import org.perfsonar.perfsonarui.plugins.MAEndpointList;
import org.perfsonar.perfsonarui.ui.actions.PerfsonarRequestAction;

-
public class FlowSARequestAction extends PerfsonarRequestAction {

-
private static final long serialVersionUID = -97086740851913593L;
protected MAEndpointList endpoints;

- public FlowSARequestAction(IPerfsonarRequest request, IUserData
userData, MAEndpointList endpoints) {
- this(request,
userData,endpoints,"Query",IPerfsonarTab.defaultGroupQuery);
+ public FlowSARequestAction(IPerfsonarRequest request, UserData
userData,
+ MAEndpointList endpoints) {
+ this(request, userData, endpoints, "Query",
+ IPerfsonarTab.defaultGroupQuery);
}

- public FlowSARequestAction(IPerfsonarRequest request,
- IUserData userData, MAEndpointList endpoints,
- String arg0, String group) {
- this(request, userData, endpoints, arg0,null, group);
+ public FlowSARequestAction(IPerfsonarRequest request, UserData
userData,
+ MAEndpointList endpoints, String arg0, String group) {
+ this(request, userData, endpoints, arg0, null, group);
}

- public FlowSARequestAction(IPerfsonarRequest request,
- IUserData userData, MAEndpointList endpoints,
- String arg0, Icon arg1, String group) {
+ public FlowSARequestAction(IPerfsonarRequest request, UserData
userData,
+ MAEndpointList endpoints, String arg0, Icon arg1,
String group) {
super(request, userData, arg0, arg1, group);
this.endpoints = endpoints;
}

+
@Override
public void run(ActionEvent arg0) {
- if (request == null) return ;
-
-
+ if (request == null)
+ return;
+
try {
- /*
- for (int i=0; i < endpoints.size();i++)
- if (endpoints.get(i).isEnabled()) {
-
userData.setEndpoint(endpoints.get(i));
- break;
- }
- */
- /*
- * Status bar is listening for events fired from
request
- */
- request.fireStatusMessage("Sending request to " +
userData.getEndpoint() + " for " + userData.toString());
-
+ request.fireStatusMessage("Sending request to "
+ + userData.getEndpoint() + " for " +
userData.toString());
+
boolean runInThread = false;
request.makeRequest(
- /*
- * The info in IUserData variable
will be used to generate XML message.
- */
- userData,
- /*
- * The request type. Ignored by
PlaygroundRequest, but important for other implementations.
- */
- IPerfsonarRequest.MA_SetupDataRequest,
- /*
- * The listener that will receive and
process the result
- */
- new FlowSAPerfsonarResponse(userData),
- /*
- * Running in current thread, change
to true to spawn a thread.
- *
- * Another option is to use the
SmartRequest variable, that is initialized via
- * command line option -p
- * boolean runInThread =
((SmartMARequest) request).isParallel();
- */
- runInThread);
-
- /*
- * This is to wait for the request threads to
complete.
- * Not necessary if runInThread is false, but here
for completeness.
- */
+ userData,
+ IPerfsonarRequest.MA_SetupDataRequest,
+ new FlowSAPerfsonarResponse(userData),
+ runInThread);
+
if (request instanceof SmartMARequest)
- ((SmartMARequest) request).isReady();
-
- request.fireStatusMessage(userData.toString()+" data
retrieved in " + userData.getServiceTime() + " ms.");
-
-
-
+ ((SmartMARequest) request).isReady();
+
+ request.fireStatusMessage(userData.toString()
+ + " data retrieved in " +
userData.getServiceTime()
+ + " ms.");
+
} catch (Exception x) {
- /*
- * Just in case -
- * Shouldn't go here, since makeRequest handles
exception via listener.
- */
- request.fireStatusMessage("Error retrieving data ");
-
JOptionPane.showMessageDialog(frame,x,"Error",JOptionPane.ERROR_MESSAGE);
+ request.fireStatusMessage("Error retrieving data ");
+ JOptionPane.showMessageDialog(frame, x, "Error",
+ JOptionPane.ERROR_MESSAGE);
logger.error(x);
}
-

}

@Override
public void done() {
- /*
- * Anything that is needed to finalize after request (run()
method) is completed.
- *
- */
-
}

}
-
-

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/PerfsonarFlowSAModel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/PerfsonarFlowSAModel.java
2007-07-20 14:58:16 UTC (rev 2562)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/PerfsonarFlowSAModel.java
2007-07-24 08:36:12 UTC (rev 2563)
@@ -17,6 +17,7 @@
import org.perfsonar.perfsonarui.PerfsonarSchema;
import org.perfsonar.perfsonarui.SmartMARequest;
import org.perfsonar.perfsonarui.plugins.IPerfsonarRequest;
+import org.perfsonar.perfsonarui.plugins.IPerfsonarTab;
import org.perfsonar.perfsonarui.plugins.MAEndpoint;
import org.perfsonar.perfsonarui.plugins.MAEndpointList;
import org.perfsonar.perfsonarui.ui.PerfsonarModel;
@@ -24,15 +25,11 @@
import org.perfsonar.perfsonarui.ui.actions.PSUIAction;
import org.perfsonar.perfsonarui.ui.actions.PerfsonarRequestAction;
import org.perfsonar.perfsonarui.ui.actions.SetOptionsAction;
-import org.perfsonar.perfsonarui.ui.panels.ResponseDetailsPane;
import org.perfsonar.perfsonarui.ui.panels.UserDataDetailsPane;
-import org.perfsonar.perfsonarui.ui.panels.UserDataPanel;
-
import org.perfsonar.perfsonarui.flowsa.panels.MainOptionsPanel;
import org.perfsonar.perfsonarui.flowsa.panels.MomentOptionsPanel;
import org.perfsonar.perfsonarui.flowsa.panels.QueryResultPanel;
import org.perfsonar.perfsonarui.flowsa.panels.RawOptionsPanel;
-import org.perfsonar.perfsonarui.flowsa.panels.RawPanel;
import org.perfsonar.perfsonarui.flowsa.panels.RouterOptionsPanel;
import org.perfsonar.perfsonarui.flowsa.panels.TopOptionsPanel;

@@ -46,7 +43,11 @@


public PerfsonarFlowSAModel() {
- super();
+ this(null);
+ }
+
+ public PerfsonarFlowSAModel(MAEndpointList endpoints) {
+ super(endpoints);
getEndpointList().setMultipleEndpoints(false);
mainOptionsPanel = new MainOptionsPanel();
momentOptionsPanel = new MomentOptionsPanel();
@@ -54,7 +55,9 @@
rawOptionsPanel = new RawOptionsPanel();
topOptionsPanel = new TopOptionsPanel();
}
+

+
@Override
public MAEndpointList getEndpointList() {
MAEndpointList endpoints = new MAEndpointList();
@@ -82,9 +85,9 @@
@Override
protected void confirm(JComponent[] optionPanels) {
getUserData().setQuery(UserData.QUERYTYPE,
mainOptionsPanel.getQueryType());
- getUserData().setQuery(UserData.ROUTERS,
routerOptionsPanel.getRouters());
getUserData().setQuery(UserData.STARTMOMENT,
momentOptionsPanel.getStartMoment());
getUserData().setQuery(UserData.ENDMOMENT,
momentOptionsPanel.getEndMoment());
+ getUserData().setQuery(UserData.ROUTERS,
routerOptionsPanel.getRouters());
getUserData().setQuery(UserData.RAWFILTER,
rawOptionsPanel.getFilter());

getUserData().setQuery(UserData.RAWAGGREGATION,
rawOptionsPanel.getAggregation());
getUserData().setQuery(UserData.RAWFIELDS,
rawOptionsPanel.getFields());
@@ -127,11 +130,15 @@
};
}

+
@Override
protected PerfsonarRequestAction createMetadataRequestAction() {
- return null;
+ metadataRequestAction = new FlowSARequestAction(request,
(UserData)getUserData(), endpointList);
+
metadataRequestAction.setGroup(IPerfsonarTab.defaultGroupQuery);
+ return metadataRequestAction;
}
-
+
+
public PluginMainPanel createMainComponent(Component parentComponent)
{
return new QueryResultPanel(parentComponent, this,
(UserData)getUserData());
}
@@ -146,10 +153,14 @@
}

@Override
+ public UserData getUserData() {
+ return (UserData)userData;
+ }
+
+ @Override
public List<IPerfsonarSchema> getSupportedRequests() {
ArrayList<IPerfsonarSchema> supported = new
ArrayList<IPerfsonarSchema>();
supported.add(new PerfsonarSchema("flowsa"));
return supported;
}
-
}

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/panels/RouterOptionsPanel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/panels/RouterOptionsPanel.java
2007-07-20 14:58:16 UTC (rev 2562)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa/panels/RouterOptionsPanel.java
2007-07-24 08:36:12 UTC (rev 2563)
@@ -7,8 +7,6 @@

package org.perfsonar.perfsonarui.flowsa.panels;

-import java.util.Collection;
-
public class RouterOptionsPanel extends javax.swing.JPanel {

private static final long serialVersionUID = 1L;



  • perfsonar: r2563 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/flowsa: . panels, svnlog, 07/24/2007

Archive powered by MHonArc 2.6.16.

Top of Page