Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r2848 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/ma: . ui/actions

Subject: perfsonar development work

List archive

perfsonar: r2848 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/ma: . ui/actions


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r2848 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/ma: . ui/actions
  • Date: Fri, 14 Sep 2007 13:39:54 -0400

Author: nina
Date: 2007-09-14 13:39:53 -0400 (Fri, 14 Sep 2007)
New Revision: 2848

Modified:

branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequestPerfsonar2_0.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_NMWG2.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/UserData.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/ui/actions/SetupDataRefreshActionAll.java
Log:
cleanup

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequestPerfsonar2_0.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequestPerfsonar2_0.java
2007-09-14 11:43:53 UTC (rev 2847)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequestPerfsonar2_0.java
2007-09-14 17:39:53 UTC (rev 2848)
@@ -35,6 +35,9 @@
import org.w3c.dom.NodeList;

public class MARequestPerfsonar2_0 extends MARequest_NMWG2_Netutil {
+ public static String S_value= "value";
+ public static String S_timevalue= "value";
+ public static String S_valueUnits= "valueUnits";
public static String schemaID = "http://schemas.perfsonar.net/2.0";;
protected static String URI_nmwgr =
"http://ggf.org/ns/nmwg/result/2.0/";;

@@ -79,7 +82,7 @@
protected void processMetadata(Node metadata, UserData userData) {
if (isInterrupted()) return;
userData.clear();
- System.out.println("Process
metadata\t"+((Element)metadata).getAttribute("id"));
+ //System.out.println("Process
metadata\t"+((Element)metadata).getAttribute("id"));
NodeList subject =
((Element)metadata).getElementsByTagNameNS(URI_perfsonar[perfsonar_version][1],
"subject");
if (subject.getLength() == 0) return;
for (int m=0; m<subject.getLength(); m++)
@@ -160,7 +163,7 @@

}
protected synchronized void processData(Node data, UserData userData) {
- System.out.println(((org.w3c.dom.Element)data).getAttribute("id"));
+ //System.out.println(((org.w3c.dom.Element)data).getAttribute("id"));
//result code
NodeList datum =
((org.w3c.dom.Element)data).getElementsByTagNameNS(URI_perfsonar[perfsonar_version][1],IUserData.C_DATUM);
if (datum.getLength()==0)
@@ -237,8 +240,9 @@
* @param userData
*/
protected synchronized void processDatum(Element datum, PSCountsDatum d,
PSTime t) throws UnsupportedTypeException {
- String value = datum.getAttribute("value");
- String units = datum.getAttribute("valueUnits");
+
+ String value = datum.getAttribute(S_value);
+ String units = datum.getAttribute(S_valueUnits);
String time = datum.getAttribute("timeValue");
String timeType = datum.getAttribute("timeType");

@@ -246,18 +250,19 @@
if ((value == null) || "".equals(value) || (units == null) ||
"".equals(units)) {
NodeList l = datum.getChildNodes();
for (int i=0; i < l.getLength(); i++)
- if ("value".equals(l.item(i).getLocalName())) {
- units = ((Element) l.item(i)).getAttribute("valueUnits");
+ if (S_value.equals(l.item(i).getLocalName())) {
+ units = ((Element) l.item(i)).getAttribute(S_valueUnits);
value = l.item(i).getTextContent();
}
}
+
//Look for <nmtm:time type="unix" value="1021119880"
xmlns:nmtm="http://ggf.org/ns/nmwg/time/2.0/"/>
if ((time == null) || "".equals(time) || (timeType == null) ||
"".equals(timeType)) {
NodeList l = datum.getChildNodes();
for (int i=0; i < l.getLength(); i++)
if ("time".equals(l.item(i).getLocalName())) {
timeType = ((Element) l.item(i)).getAttribute("type");
- time = ((Element) l.item(i)).getAttribute("value");
+ time = ((Element) l.item(i)).getAttribute(S_value);
}
}
d.setValue(value, units);

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_NMWG2.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_NMWG2.java
2007-09-14 11:43:53 UTC (rev 2847)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_NMWG2.java
2007-09-14 17:39:53 UTC (rev 2848)
@@ -248,11 +248,16 @@
//Element IfDescrElem = new Element("ifDescription", "nmwgt",
"http://ggf.org/ns/nmwg/topology/";);
//IfDescrElem.setText(" Link to JAnet-Ukerna (Pr:Telecity Id:1)");
//NmwgtElem.addContent(IfDescrElem);
-
+ /*
if
((!userData.getIpVersion(AbstractUserData.ID_QUERY).equals(AbstractUserData.NULL_DATA))
&&

(!userData.getifAddress(AbstractUserData.ID_QUERY).equals(AbstractUserData.NULL_DATA))){
+ */
+ if
(!userData.getifAddress(AbstractUserData.ID_QUERY).equals(AbstractUserData.NULL_DATA))
{
Element IfAddrElem = new Element(E_IFADDRESS, nmwgt);
- IfAddrElem.setAttribute(E_IFTYPE,
userData.getIpVersion(AbstractUserData.ID_QUERY));
+
+ if
(!userData.getIpVersion(AbstractUserData.ID_QUERY).equals(AbstractUserData.NULL_DATA))
+ IfAddrElem.setAttribute(E_IFTYPE,
userData.getIpVersion(AbstractUserData.ID_QUERY));
+

IfAddrElem.setText(userData.getifAddress(AbstractUserData.ID_QUERY));
NmwgtElem.addContent(IfAddrElem);
}

Modified: branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/UserData.java
===================================================================
--- branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/UserData.java
2007-09-14 11:43:53 UTC (rev 2847)
+++ branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/UserData.java
2007-09-14 17:39:53 UTC (rev 2848)
@@ -1,5 +1,5 @@
/*
-Copyright perfsonar.acad.bg (C) 2005-2007
+Copyright perfsonar.acad.bg (C) 2005-2007
Contact:


This program is free software; you can redistribute it and/or
@@ -30,12 +30,12 @@
import org.perfsonar.perfsonarui.ui.PerfsonarModel;

/**
- * Adds some specifics for MA requests (in/out directions).
+ * Adds some specifics for MA requests (in/out directions).
* @author Nina Jeliazkova
*
*/
public class UserData extends AbstractUserData {
-
+
public final static String C_HOSTNAME="hostName";
public final static String C_IFNAME = "ifName";
public final static String C_IFADDRESS = "ifAddress";
@@ -49,27 +49,27 @@
public final static String C_CAPACITY="capacity";
public final static String C_TIMEVALUE="timeValue";
public final static String C_VALUE="value";
-
+
/**
- *
+ *
*/
private static final long serialVersionUID = -8142422585873396069L;
-
+
//protected String[][] data = null;

protected int direction = 0;

protected double[] utilization = new double[2];
protected double[] ifmbits = new double[2];
-
+
protected static int DATA_COLUMNS=3;
protected static int DATA_ROWS=18;
-
+
//public static int ID_NAME=0;
public static final int DIRECTION_INPUT=0;
public static final int DIRECTION_OUTPUT=1;
public static final int DIRECTION_UNKNOWN=-1;
-
+
public static final int INDEX_IPVERSION = 0;
public static final int INDEX_HOSTNAME = 1;
public static final int INDEX_IFADDRESS = 2;
@@ -79,7 +79,7 @@
public static final int INDEX_IFBITS_IN = 6;
public static final int INDEX_IFUTILIZATION_IN = 7;
public static final int INDEX_IFBITS_OUT = 8;
- public static final int INDEX_IFUTILIZATION_OUT = 9;
+ public static final int INDEX_IFUTILIZATION_OUT = 9;
public static final int INDEX_STARTTIME = 10;
public static final int INDEX_ENDTIME = 11;
public static final int INDEX_EVENTTYPE = 12;
@@ -89,7 +89,7 @@
public static final int INDEX_DOMAIN = 16;
public static final int INDEX_INERRORS = 17;
public static final int INDEX_OUTDISCARDS = 18;
-
+
public static String[] titles = {
"IP version",
"Hostname",
@@ -132,24 +132,24 @@
"Eps",
"Dps"
};
-
+
static final double M1 = 1.0/(1024.0*1024.0);
//static final double M1 = 1/(1024.0*1024.0);
-
+
public UserData() {
super();
setIpVersion("ipv4");
-
+
setQuery(names[INDEX_CONSOLIDATION], "AVERAGE");
setResponse(names[INDEX_CONSOLIDATION], "AVERAGE");
-
+
setQuery(names[INDEX_RESOLUTION], "300");
setResponse(names[INDEX_RESOLUTION], "300");
setChanged();
notifyObservers();
-
+
}
-
+
public UserData(boolean init) {
this();
if (init) {
@@ -157,16 +157,16 @@
setQuery(names[INDEX_IPVERSION],"ipv4");
direction = 0;
setQuery(names[INDEX_EVENTTYPE],"utilization");
-
+
setTime(timeNow-24*60*60, 24*60*60);
-
+
setQuery(names[INDEX_CONSOLIDATION],"AVERAGE");
setQuery(names[INDEX_RESOLUTION],"300");
setChanged();
notifyObservers();
}
}
-
+
public Date startTimeToDate(int index) {
try {
long t =
Long.parseLong(getQuery(names[INDEX_STARTTIME]));
@@ -196,7 +196,7 @@
}


-
+
@Override
public void clear() {
super.clear();
@@ -210,7 +210,7 @@
setQuery(names[INDEX_IPVERSION],value);
setChanged();
notifyObservers();
- }
+ }
public String getIpVersion(int index) {
return get(index,names[INDEX_IPVERSION]).toString();
}
@@ -221,8 +221,8 @@
}
public String getifAddress(int index) {
return get(index,names[INDEX_IFADDRESS]).toString();
- }
-
+ }
+
public String getUtilizationIn() {

return getResponse(names[INDEX_IFUTILIZATION_IN]).toString();
@@ -253,17 +253,17 @@
data[INDEX_DIRECTION][ID_QUERY] = value;
setChanged();
notifyObservers();
- }
+ }
public String getTrafficDirection(int index) {
return data[INDEX_DIRECTION][index];
- }
+ }
*/
public String getCharacteristic(int index) {
if (index ==ID_QUERY)
return getEndpoint().getEvent(direction);
else
return get(index,names[INDEX_EVENTTYPE]).toString();
-
+
}
public String getClassOfService(int index) {
return get(index,names[INDEX_CLASSOFSERVICE]).toString();
@@ -274,7 +274,7 @@
public String getEndTime(int index) {
return get(index,names[INDEX_ENDTIME]).toString();
}
-
+
public String getHostname(int index) {
return get(index,names[INDEX_HOSTNAME]).toString();
}
@@ -284,7 +284,7 @@
}
public String getIfDescr(int index) {
return get(index,names[INDEX_IFDESCR]).toString();
- }
+ }
public void setConsolidationFunc(String value) {
setQuery(names[INDEX_CONSOLIDATION],value);
setChanged();
@@ -305,12 +305,12 @@
setQuery(names[INDEX_EVENTTYPE],value);
setChanged();
notifyObservers();
- }
-
+ }
+
public String getResolution(int index) {
return get(index,names[INDEX_RESOLUTION]).toString();
}
-
+
//1133295112
@Override
public void makeQueryFromResponse() {
@@ -318,8 +318,10 @@

setQuery(names[INDEX_HOSTNAME],getResponse(names[INDEX_HOSTNAME]));

setQuery(names[INDEX_IFNAME],getResponse(names[INDEX_IFNAME]));

setQuery(names[INDEX_IFDESCR],getResponse(names[INDEX_IFDESCR]));
-
setQuery(names[INDEX_IFCAPACITY],getResponse(names[INDEX_IFCAPACITY]));

-
+
setQuery(names[INDEX_IFCAPACITY],getResponse(names[INDEX_IFCAPACITY]));
+
setQuery(names[INDEX_IPVERSION],getResponse(names[INDEX_IPVERSION]));
+
+
// data[INDEX_DIRECTION][ID_QUERY] =
data[INDEX_DIRECTION][ID_RESPONSE];
}

@@ -327,16 +329,30 @@
setBits(octets,8);
}
public void setBits(double bits, double multiplier) {
+
int indexBits = INDEX_IFBITS_IN;
int indexUtilization = INDEX_IFUTILIZATION_IN;
- if (direction==1) {
- indexBits = INDEX_IFBITS_OUT;
- indexUtilization = INDEX_IFUTILIZATION_OUT;
- }
-
+ switch (direction) {
+ case 0: {
+ indexBits = INDEX_IFBITS_IN;
+ indexUtilization = INDEX_IFUTILIZATION_IN;
+ break;
+ }
+ case 1: {
+ indexBits = INDEX_IFBITS_OUT;
+ indexUtilization = INDEX_IFUTILIZATION_OUT;
+ break;
+ }
+ default : {
+ System.err.println("Undefined direction "+direction);
+ return;
+ }
+ }
+
+
if (direction>=0) ifmbits[direction] = M1*multiplier*bits; //MBits

setResponse(names[indexBits],Long.toString(Math.round(bits*multiplier)));
//bits
-
+
double c = 0;
double d = -1;
try {
@@ -348,7 +364,7 @@

setResponse(names[indexUtilization],Double.toString(d));
} else {

setResponse(names[indexUtilization],NULL_DATA);
- }
+ }
} catch (Exception x) {
setResponse(names[indexUtilization],NULL_DATA);
}
@@ -359,7 +375,7 @@
public void setQuery(int index, String value) {
setQuery(names[index], value);
}
-
+
@Override
public void setResponse(String name, String value) {
/*
@@ -377,7 +393,7 @@
public String getIfName() {
return getQuery(names[INDEX_IFNAME]);
}
-
+
public void setIfName(String value) {
setQuery(names[INDEX_IFNAME],value);
}
@@ -385,7 +401,7 @@
public void next(long seconds) {
long t = Long.parseLong(getQuery(names[INDEX_STARTTIME]));
setQuery(names[INDEX_STARTTIME],Long.toString(t + seconds));
-
+
t = Long.parseLong(getQuery(names[INDEX_ENDTIME]));
setQuery(names[INDEX_ENDTIME],Long.toString(t + seconds));

@@ -405,41 +421,41 @@
UserData o = (UserData) arg0;
return
getHostname(AbstractUserData.ID_RESPONSE).equals(o.getHostname(AbstractUserData.ID_RESPONSE))
&&

getifAddress(AbstractUserData.ID_RESPONSE).equals(o.getifAddress(AbstractUserData.ID_RESPONSE))
&&
-
getIfName(AbstractUserData.ID_RESPONSE).equals(o.getIfName(AbstractUserData.ID_RESPONSE))
&&
+
getIfName(AbstractUserData.ID_RESPONSE).equals(o.getIfName(AbstractUserData.ID_RESPONSE))
&&

getIfDescr(AbstractUserData.ID_RESPONSE).equals(o.getIfDescr(AbstractUserData.ID_RESPONSE))
;
-
+
/*
String[][] o = ((UserData) arg0).getData();
for (int i=0; i<INDEX_IFDESCR;i++)
if
(!data[i][ID_QUERY].equals(o[i][ID_QUERY])) return false;
return true;
*/
- } else return false;
+ } else return false;
}
@Override
public int compareTo(Object arg0) {
//return 1;
-
+
if (arg0 instanceof UserData) {
UserData o = (UserData) arg0;
int r =
getEndpoint().toString().compareTo(o.getEndpoint().toString());
if (r == 0) {
r =
getHostname(ID_RESPONSE).compareTo(o.getHostname(ID_RESPONSE));
- if (r == 0) {
+ if (r == 0) {
r =
getifAddress(ID_RESPONSE).compareTo(o.getifAddress(ID_RESPONSE));
if (r == 0) {
r =
getIfName(ID_RESPONSE).compareTo(o.getIfName(ID_RESPONSE));
if (r ==0)
return
getIfDescr(ID_RESPONSE).compareTo(o.getIfDescr(ID_RESPONSE));
-
+
}
}
- }
+ }
return r;
} else return -1;
-
+
}
-
+
@Override
public String toString() {
StringBuffer b = new StringBuffer();
@@ -450,7 +466,7 @@
b.append(getifAddress(ID_RESPONSE));b.append(' ');
b.append(getIfName(ID_RESPONSE));b.append(' ');
b.append(getIfDescr(ID_RESPONSE));b.append(' ');
-
+
long tStart = 0;
long tEnd = 0;
try {
@@ -464,7 +480,7 @@
b.append(PerfsonarModel.timeInterval2Title(timeInterval));
b.append(" )");
//if (input) b.append("in"); else b.append("out");
-
+
return b.toString();
}
public void assign(UserData userData) {
@@ -485,7 +501,7 @@
}
public synchronized String getType() {
switch( direction) {
- case 0: return "inbound";
+ case 0: return "inbound";
case 1: return "outbound";
default: return NULL_DATA;
}
@@ -495,13 +511,13 @@
setChanged();
notifyObservers();
}
-
+
public synchronized void setDirection(String input) {
if (input.equals(C_DIRECTIONS[DIRECTION_INPUT]))
setDirection(DIRECTION_INPUT);
else if (input.equals(C_DIRECTIONS[DIRECTION_OUTPUT]))
setDirection(DIRECTION_OUTPUT);
else setDirection(DIRECTION_UNKNOWN);
}
-
+
@Override
public void setQuery(String name, String value) {
/*
@@ -511,7 +527,7 @@
if (C_DIRECTION.equals(name)) setDirection(value);
else super.setQuery(name, value);
}
-
+
public synchronized boolean isOutput() {
return direction==DIRECTION_OUTPUT;
}
@@ -535,6 +551,6 @@
this.num = num;
}

-
+
}


Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/ui/actions/SetupDataRefreshActionAll.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/ui/actions/SetupDataRefreshActionAll.java
2007-09-14 11:43:53 UTC (rev 2847)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/ui/actions/SetupDataRefreshActionAll.java
2007-09-14 17:39:53 UTC (rev 2848)
@@ -80,6 +80,7 @@

for (int i=0; i < dataList.size();i++) {
UserData data = (UserData)dataList.get(i);
+ data.makeQueryFromResponse();
data.setDirection(UserData.DIRECTION_UNKNOWN);
}
request.makeRequest(null, dataList,
IPerfsonarRequest.MA_SetupDataRequest,



  • perfsonar: r2848 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/ma: . ui/actions, svnlog, 09/14/2007

Archive powered by MHonArc 2.6.16.

Top of Page