perfsonar-dev - perfsonar: r4503 - in branches/WebAdmin: . ant perfSONARWebAdmin/auxiliary
Subject: perfsonar development work
List archive
- From:
- To:
- Subject: perfsonar: r4503 - in branches/WebAdmin: . ant perfSONARWebAdmin/auxiliary
- Date: Thu, 18 Sep 2008 17:26:06 -0400
Author: pgerakios
Date: 2008-09-18 17:26:05 -0400 (Thu, 18 Sep 2008)
New Revision: 4503
Modified:
branches/WebAdmin/ant/const.properties
branches/WebAdmin/index.jsp
branches/WebAdmin/perfSONARWebAdmin/auxiliary/FileMonitor.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/MyDynProperties.java
Log:
Modified: branches/WebAdmin/ant/const.properties
===================================================================
--- branches/WebAdmin/ant/const.properties 2008-09-18 17:55:53 UTC (rev
4502)
+++ branches/WebAdmin/ant/const.properties 2008-09-18 21:26:05 UTC (rev
4503)
@@ -9,7 +9,7 @@
target.server=127.0.0.1
service.name=perfsonar-web-admin
jarfilename=perfsonar-web-admin
-version=0.9.4b
+version=0.9.5b
antcontrib.jar=${basedir}/lib/misc/ant-contrib-1.0b3.jar
antpsbase.jar=${basedir}/lib/misc/perfsonar-base-ant-1.0.20080303.jar
Modified: branches/WebAdmin/index.jsp
===================================================================
--- branches/WebAdmin/index.jsp 2008-09-18 17:55:53 UTC (rev 4502)
+++ branches/WebAdmin/index.jsp 2008-09-18 21:26:05 UTC (rev 4503)
@@ -1,5 +1,23 @@
<%@ page
import="perfSONARWebAdmin.auxiliary.PerfsonarProperties,perfSONARWebAdmin.auxiliary.PerfsonarPropertiesImpl,perfSONARWebAdmin.auxiliary.PerfsonarProperty,java.io.File,java.io.FileInputStream,java.io.FileOutputStream,java.io.IOException"
%>
+<%!
+ private perfSONARWebAdmin.auxiliary.MyDynProperties prop;
+
+ public void jspInit()
+ {
+ super.jspInit();
+ prop =
perfSONARWebAdmin.auxiliary.MyDynProperties.create(getServletContext().getRealPath("/")
,false);
+ prop.reloadAll();
+ prop.updateClientProperties();
+ }
+
+ public void jspDestroy()
+ {
+ super.jspDestroy();
+ prop.reloadAll();
+ prop.updateClientProperties();
+ }
+%>
<html>
<head>
<title>perfSONAR Service Web Administration page</title>
@@ -66,8 +84,6 @@
serviceProperties.loadProperties(new FileInputStream(ServicePath
+ ServicePropertiesPath));
- perfSONARWebAdmin.auxiliary.MyDynProperties.register(ServicePath); //
start monitoring
-
String serviceName=
serviceProperties.getProperty("service.r.service_name").getValue().trim();
String serviceVersion=
serviceProperties.getProperty("service.r.service_version").getValue().trim();
Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/FileMonitor.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/FileMonitor.java
2008-09-18 17:55:53 UTC (rev 4502)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/FileMonitor.java
2008-09-18 21:26:05 UTC (rev 4503)
@@ -140,7 +140,7 @@
// MyDynProperties mdf = new
MyDynProperties(base1+file1,base2+file2,"component.ma.xmldb.db_uri");
// monPut(base1,file1, mdf );
// monPut(base2,file2, mdf );
-
MyDynProperties.register("/opt/perfsonar/tomcat/webapps/geant2-java-rrd-ma/");
+ //
MyDynProperties.create("/opt/perfsonar/tomcat/webapps/geant2-java-rrd-ma/");
waitForKey("waiting for key");
}
Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/MyDynProperties.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/MyDynProperties.java
2008-09-18 17:55:53 UTC (rev 4502)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/MyDynProperties.java
2008-09-18 21:26:05 UTC (rev 4503)
@@ -5,7 +5,70 @@
import java.util.Date;
import java.util.Properties;
import java.io.File;
+import java.net.URI;
+ class MyURI
+ {
+ private URI uri;
+ private boolean isvalid = true;
+
+ private URI newURI( String s )
+ {
+ URI urii=null;
+ try
+ {
+ s = s.trim();
+ if( s == null || s.startsWith("xmldb:") == false || s.length() < 7 )
+ {
+ isvalid = false;
+ return null;
+ }
+
+ urii = new URI(s.substring(6));
+ isvalid = true;
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ isvalid = false;
+ }
+ return urii;
+ }
+
+ public boolean isValid() { return isvalid; }
+
+ public MyURI( String u )
+ {
+ uri = newURI(u);
+ }
+
+ public String getPort(){ return str(""+uri.getPort(),null); }
+
+ private String str( String s , String add, boolean b )
+ {
+ if( s == null || s.equals("") ) return "";
+ else if ( add == null ) return s;
+ else if( b) return s + add;
+ else return add + s;
+ }
+
+ private String str( String s, String add ) { return str(s,add,true); }
+ private String bstr( String s , String add ) { return str(s,add,false); }
+
+ public void setPort( String port )
+ {
+ uri = newURI( "xmldb:"+ str(uri.getScheme(),"://") +
str(uri.getUserInfo(),"@") + uri.getHost()
+ + bstr( port , ":") + str(uri.getPath(),null) +
bstr(uri.getQuery(),"?") +
+ bstr(uri.getFragment(),"#"));
+ }
+
+ public String toString()
+ {
+ if( isvalid ) return "xmldb:" + uri.toString();
+ else return "";
+ }
+ } ;
+
public class MyDynProperties extends DynProperties
{
String serviceProp;
@@ -50,11 +113,39 @@
}
}
-
- private void updateClientProperties()
+
+ public void reloadAll()
{
+ client.reload();
+ servlet.reload();
+ reload();
+ }
+
+ private static String updateURI( String s1 , String s2 )
+ {
+ MyURI suri = new MyURI(s1), curi = new MyURI(s2) ;
+
+ if( !suri.isValid() || !curi.isValid() )
+ {
+ System.out.println("updateClientProperties: Invalid URL -
Aborting");
+ return null;
+ }
+
+ curi.setPort(suri.getPort());
+ if( !curi.isValid() )
+ {
+ System.out.println("updateClientProperties: Invalid URL !
Aborting");
+ return null;
+ }
+ return curi.toString();
+ }
+
+ public void updateClientProperties()
+ {
client.reload();
- client.setProperty("uri", getProperty(servlet.getProperty(key)) );
//r restore the correct value
+ String s =
updateURI(getProperty(servlet.getProperty(key)),client.getProperty("uri"));
+ if( s == null ) return;
+ client.setProperty("uri", s ); //r restore the correct value
client.dynStore();
update = true;
}
@@ -72,26 +163,34 @@
}
- public static void register( String file)
+ public static MyDynProperties create( String file, boolean monitor )
{
// if( System.getProperty("perfsonar.web.admin.path") != null )
return; // if registered eixt
// System.setProperty("perfsonar.web.admin.path","1");
String webservicePath = getPath(file,0) +
"WEB-INF/classes/perfsonar/conf/";
String webappsPath = getPath(file,-1) + "exist/WEB-INF/";
+
+ System.out.println("Creating MyDynProperties. Root path : " + file );
+ MyDynProperties mdf = new
MyDynProperties(webservicePath,webappsPath+"client.properties");
- MyDynProperties mdf = new
MyDynProperties(webservicePath,webappsPath+"client.properties");
- try
+ if( monitor )
{
- FileMonitor.monPut(webservicePath,"service.properties", mdf );
- FileMonitor.monPut(webservicePath,"servlet.properties", mdf );
- FileMonitor.monPut(webappsPath,"client.properties", mdf );
+ try
+ {
+ FileMonitor.monPut(webservicePath,"service.properties", mdf );
+ FileMonitor.monPut(webservicePath,"servlet.properties", mdf );
+ FileMonitor.monPut(webappsPath,"client.properties", mdf );
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ return null;
+ }
}
- catch( Exception e )
- {
- e.printStackTrace();
- }
+ return mdf;
}
- private static String getPath(String file, int skip )
+
+ public static String getPath(String file, int skip )
{
if( file == null) return "";
String[] tmp = file.split(File.separator);
@@ -108,5 +207,18 @@
}
return path;
}
+
+ public static void main(String[] args )
+ {
+ String base1 =
"/opt/perfsonar/tomcat/webapps/geant2-java-rrd-ma/WEB-INF/classes/perfsonar/conf/",
+ file1 = "service.properties",
+ base2 = "/opt/perfsonar/tomcat/webapps/exist/WEB-INF/",
+ file2 = "client.properties";
+
+ String uri1 = (new
DynProperties(base1+file1)).getProperty("component.ma.xmldb.db_uri");
+ String uri2 = (new DynProperties(base2+file2)).getProperty("uri");
+ System.out.println("Uri 1 : " + uri1 + "\nUri 2 " + uri2 +
"\nConverted uri " + updateURI(uri1,uri2) );
+
+ }
};
- perfsonar: r4503 - in branches/WebAdmin: . ant perfSONARWebAdmin/auxiliary, svnlog, 09/18/2008
Archive powered by MHonArc 2.6.16.