perfsonar-dev - perfsonar: r5085 - in branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2: service/configuration service/registration service/requesthandler service/scheduler service/storage/xml service/util xml xml/nmwg
Subject: perfsonar development work
List archive
perfsonar: r5085 - in branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2: service/configuration service/registration service/requesthandler service/scheduler service/storage/xml service/util xml xml/nmwg
Chronological Thread
- From:
- To:
- Subject: perfsonar: r5085 - in branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2: service/configuration service/registration service/requesthandler service/scheduler service/storage/xml service/util xml xml/nmwg
- Date: Tue, 17 Mar 2009 06:34:15 -0400
Author: mac
Date: 2009-03-17 06:34:13 -0400 (Tue, 17 Mar 2009)
New Revision: 5085
Added:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/xml/nmwg/Datum.java
Removed:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/xml/nmwgr/
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/configuration/ConfigurationManager.java
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/registration/LSRegistrationAction.java
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/requesthandler/EchoServiceEngine.java
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/Scheduler.java
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulerTask.java
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulingComponent.java
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SimpleAction.java
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SimpleScheduler.java
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/storage/xml/DataCredential.java
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/util/ResultCodesUtil.java
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/xml/nmwg/Data.java
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/xml/nmwg/NMWGNamespaceFactory.java
Log:
Some commentary, some refactoring before the next release
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/configuration/ConfigurationManager.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/configuration/ConfigurationManager.java
2009-03-17 05:33:06 UTC (rev 5084)
+++
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/configuration/ConfigurationManager.java
2009-03-17 10:34:13 UTC (rev 5085)
@@ -129,7 +129,7 @@
digesterRulesURL =
Thread.currentThread().getContextClassLoader().getResource(digesterRules);
else
- digesterRulesURL = (new File(digesterRules)).toURL();
+ digesterRulesURL = (new File(digesterRules)).toURI().toURL();
if (digesterRulesURL == null)
throw new IOException("Can not find resource " +
digesterRulesURL);
} catch (Exception ex) {
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/registration/LSRegistrationAction.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/registration/LSRegistrationAction.java
2009-03-17 05:33:06 UTC (rev 5084)
+++
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/registration/LSRegistrationAction.java
2009-03-17 10:34:13 UTC (rev 5085)
@@ -30,7 +30,18 @@
import org.perfsonar.base2.xml.nmwg.NMWGNamespaceFactory;
import org.perfsonar.base2.xml.nmwg.Subject;
-
+/**
+ *
+ * TODO: to be refactored...
+ *
+ * need of more complex structure keeping information about LS-es
+ * - status of LS (available, unavailable)
+ * - failures (increment after each connection failure, reset when
connected)
+ * - last result code
+ * - key to be sent as keepalive
+ * - ...
+ *
+ */
public class LSRegistrationAction extends Action implements SchedulerAction {
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/requesthandler/EchoServiceEngine.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/requesthandler/EchoServiceEngine.java
2009-03-17 05:33:06 UTC (rev 5084)
+++
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/requesthandler/EchoServiceEngine.java
2009-03-17 10:34:13 UTC (rev 5085)
@@ -1,6 +1,5 @@
package org.perfsonar.base2.service.requesthandler;
-
import org.perfsonar.base2.service.exceptions.PerfSONARException;
import org.perfsonar.base2.service.requesthandler.ServiceEngine;
import org.perfsonar.base2.service.requesthandler.ServiceMessage;
@@ -13,31 +12,35 @@
import org.apache.log4j.Logger;
-
/**
* $Id: EchoServiceEngine.java 4684 2008-11-03 13:07:33Z roman $
+ *
+ * Echo service engine. Can handle echo-ping action for all services
+ *
*/
public class EchoServiceEngine implements ServiceEngine {
+ // ------------------------------------------------------------- class
+ // fields
- // ------------------------------------------------------------- class
fields
+ private static final Logger logger = Logger
+ .getLogger(EchoServiceEngine.class.getName());
+ public static final String ECHO_EVENT_TYPE =
"http://schemas.perfsonar.net/tools/admin/echo/2.0";
- private static final Logger logger =
Logger.getLogger(EchoServiceEngine.class.getName());
+ public static final String ECHO_SUCCESS_RESULT_CODE = "echo/success";
- public static final String ECHO_EVENT_TYPE =
"http://schemas.perfsonar.net/tools/admin/echo/2.0";
- public static final String ECHO_SUCCESS_RESULT_CODE = "echo/success";
public static final String ECHO_SUCCESS_RESULT_CODE_DSC = "This is the
success echo response from the service.";
public static final String ECHO_SELF_TEST =
"http://schemas.perfsonar.net/tools/admin/selftest";
+
// ------------------------------------------------------------- methods
+ public void takeAction(ServiceMessage serviceRequest,
+ ServiceMessage serviceResponse) throws PerfSONARException {
- public void takeAction(ServiceMessage serviceRequest, ServiceMessage
serviceResponse)
- throws PerfSONARException {
-
logger.debug("Simple echo ServiceEngine started.");
Message request = serviceRequest.getMessageElement();
@@ -46,8 +49,8 @@
throw new PerfSONARException(
"Wrong echo eventType value in the request");
- Message response =
- ResultCodesUtil.generateResultMessage(ECHO_SUCCESS_RESULT_CODE,
ECHO_SUCCESS_RESULT_CODE_DSC);
+ Message response = ResultCodesUtil.generateResultMessage(
+ ECHO_SUCCESS_RESULT_CODE, ECHO_SUCCESS_RESULT_CODE_DSC);
response.setId("Resp_" + request.getAttribute("id"));
response.addAttribute("type", "EchoResponse");
@@ -58,11 +61,11 @@
protected String getEventType(Message request) throws PerfSONARException
{
- Metadata reqMetadata =
request.getMetadataCollection().iterator().next();
+ Metadata reqMetadata = request.getMetadataCollection().iterator()
+ .next();
if (reqMetadata == null)
- throw new PerfSONARException(
- "There is no metadata in the request.");
+ throw new PerfSONARException("There is no metadata in the
request.");
if (reqMetadata.getEventTypes() == null)
throw new PerfSONARException(
@@ -85,7 +88,8 @@
meta.addChild(evt);
Data data = new Data("result-code-description", "result-code",
"nmwg");
- Element datum = new Element("datum", "nmwgr",
"http://ggf.org/ns/nmwg/result/2.0/");
+ Element datum = new Element("datum", "nmwgr",
+ "http://ggf.org/ns/nmwg/result/2.0/");
datum.setText(description);
data.addChild(datum);
@@ -117,5 +121,4 @@
}
-
-} //EchoServiceEngine
+} // EchoServiceEngine
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/Scheduler.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/Scheduler.java
2009-03-17 05:33:06 UTC (rev 5084)
+++
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/Scheduler.java
2009-03-17 10:34:13 UTC (rev 5085)
@@ -2,21 +2,51 @@
/**
* Scheduler interface
+ *
+ * @author Maciej Glowiak
+ * @author Roman Lapacz
*/
public interface Scheduler {
+ /**
+ * Starts scheduling tasks
+ */
public void start();
+ /**
+ * Finishes scheduling tasks
+ */
public void finish();
+ /**
+ * Set interval between two subsequent runs
+ * @param interval in seconds
+ */
public void setInterval(int interval);
+ /**
+ * Get interval between two subsequent runs
+ * @return seconds
+ */
public int getInterval();
+ /**
+ * Adds scheduler task with default interval for the task
+ * @param t task
+ */
public void addTask(SchedulerTask t);
+ /**
+ * Adds SchedulerAction encapsuled in a SchedulerTask with specific
interval
+ * @param interval in seconds
+ * @param action any action to be run each <code>interval</code> seconds
+ */
public void addTask(int interval, SchedulerAction action);
+ /**
+ * Removes task containing specific action
+ */
public void removeTask(SchedulerAction action);
+
} //Scheduler
\ No newline at end of file
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulerTask.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulerTask.java
2009-03-17 05:33:06 UTC (rev 5084)
+++
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulerTask.java
2009-03-17 10:34:13 UTC (rev 5085)
@@ -1,8 +1,14 @@
package org.perfsonar.base2.service.scheduler;
import org.apache.log4j.Logger;
-
-
+/**
+ * Scheduler Task is a wrapper for Scheduler Action. Scheduler runs tasks
+ * with specific interval. If the interval is not specified, the defaul one
+ * will be taken.
+ *
+ * @author Maciej Glowiak
+ * @author Roman Lapacz
+ */
public class SchedulerTask {
protected static final Logger logger =
Logger.getLogger(SchedulerTask.class.getName());
@@ -93,6 +99,10 @@
}
+ /**
+ * get encapsulated SchedulerAction
+ * @return
+ */
public SchedulerAction getAction() {
return action;
@@ -100,6 +110,10 @@
}
+ /**
+ * sets Action that will be run as a task
+ * @param action
+ */
public void setAction(SchedulerAction action) {
this.action = action;
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulingComponent.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulingComponent.java
2009-03-17 05:33:06 UTC (rev 5084)
+++
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulingComponent.java
2009-03-17 10:34:13 UTC (rev 5085)
@@ -4,7 +4,13 @@
import org.perfsonar.base2.service.configuration.Action;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
-
+/**
+ * Scheduling component is loaded automatically by ConfigurationManager
+ * when there exists a scheduler entry in configuration file.
+ *
+ * @author Maciej Glowiak
+ * @author Roman Lapacz
+ */
public class SchedulingComponent extends
org.perfsonar.base2.service.configuration.SchedulingComponent {
@@ -39,6 +45,10 @@
}
+ /**
+ * gets settings from configuration file
+ * @throws PerfSONARException
+ */
protected void loadSettings() throws PerfSONARException {
logger.debug("SchedulingComponenet - loading configuration");
@@ -82,8 +92,7 @@
scheduler.setInterval(interval); //seconds
scheduler.start();
} else
- logger
- .error("Can not start the scheduler because it does not
exist");
+ logger.error("Can not start the scheduler because it does not
exist");
}
@@ -127,6 +136,14 @@
}
+ /**
+ * Adds all actions from configuration file
+ * Each action may have two common parameters (in option parameter):
+ * - <code>interval</code> in seconds
+ * - <code>status</code> = on / off
+ * If status is off, action won't be loaded by the scheduler
+ *
+ */
public void registerActions() {
logger.debug("RegisterActions: Start of registering schedulling
tasks. Default interval is ["+interval+"] sec");
@@ -160,13 +177,12 @@
+ action.getClass()
+ "] registered to the scheduler with interval ["
+ actionInterval + "] seconds");
- } else
+ } else {
logger.info("Action [" + action.getName() + "] class ["
+ action.getClass()
+ "] not loaded, status set to [OFF]");
+ }
-
-
}
}
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SimpleAction.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SimpleAction.java
2009-03-17 05:33:06 UTC (rev 5084)
+++
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SimpleAction.java
2009-03-17 10:34:13 UTC (rev 5085)
@@ -7,6 +7,12 @@
import org.perfsonar.base2.service.configuration.Action;
import org.apache.log4j.Logger;
+/**
+ * This is an example of scheduler action. It just prints a message into Log
+ *
+ * @author Maciej Glowiak
+ * @author Roman Lapacz
+ */
public class SimpleAction extends Action implements SchedulerAction {
@@ -15,6 +21,7 @@
protected static final Logger logger =
Logger.getLogger(SimpleAction.class.getName());
+ int counter = 0;
// -----------------------------------------------------------
Constructors
@@ -28,7 +35,8 @@
public void runAction() {
- logger.info("This is simple scheduled action with the name " +
getName());
+ logger.info("This is simple SchedulerAction called [" + getName()+"]"
+ + " and run ["+counter+"] time");
}
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SimpleScheduler.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SimpleScheduler.java
2009-03-17 05:33:06 UTC (rev 5084)
+++
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/scheduler/SimpleScheduler.java
2009-03-17 10:34:13 UTC (rev 5085)
@@ -8,22 +8,36 @@
import org.apache.log4j.Logger;
/**
- * Simple implementation of Scheduler for perfSONAR services
- *
+ * Simple and default implementation of Scheduler for perfSONAR services
+ * It starts after <code>startDelayTime</code> (seconds) and runs all tasks
+ * each <code>interval</code> seconds. The intervals for all actions may be
+ * set separately.
+ *
+ * @author Maciej Glowiak
+ * @author Roman Lapacz
*/
public class SimpleScheduler extends Thread implements Scheduler {
// ----------------------------------------------------------- Variables
-
+ /**
+ * a set of scheduled tasks
+ */
protected Set<SchedulerTask> tasks = Collections.synchronizedSet(new
HashSet<SchedulerTask>());
protected boolean working = true;
protected boolean paused = false;
+ /**
+ * interval for scheduler, in seconds
+ */
protected int interval = SchedulingComponent.DEFAULT_INTERVAL;
+
+ /**
+ * Scheduler will start after this time (in seconds)
+ */
protected int startDelayTime = 10; //sec
protected static final Logger logger =
Logger.getLogger(SimpleScheduler.class.getName());
@@ -39,7 +53,9 @@
logger.debug("Scheduler started");
}
-
+ /**
+ * Stops the scheduler Thread
+ */
public void finish() {
this.working = false;
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/storage/xml/DataCredential.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/storage/xml/DataCredential.java
2009-03-17 05:33:06 UTC (rev 5084)
+++
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/storage/xml/DataCredential.java
2009-03-17 10:34:13 UTC (rev 5085)
@@ -1,38 +1,40 @@
package org.perfsonar.base2.service.storage.xml;
+/**
+ * The class represents username and password
+ * @author Maciej Glowiak
+ */
public class DataCredential {
-
// ----------------------------------------------------- instance
variables
-
- String username;
+ String username;
String password;
-
+
+
// ------------------------------------------------------------
Constructor
-
-
+
public DataCredential(String username, String password) {
-
+
this.password = password;
this.username = username;
-
+
}
-
+
// --------------------------------------------------------- Public
methods
-
-
+
public String getUsername() {
+
return username;
}
-
+
public String getPassword() {
+
return password;
}
-
}
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/util/ResultCodesUtil.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/util/ResultCodesUtil.java
2009-03-17 05:33:06 UTC (rev 5084)
+++
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/service/util/ResultCodesUtil.java
2009-03-17 10:34:13 UTC (rev 5085)
@@ -1,6 +1,5 @@
package org.perfsonar.base2.service.util;
-import org.apache.log4j.Logger;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
import org.perfsonar.base2.xml.Element;
import org.perfsonar.base2.xml.nmwg.Data;
@@ -16,9 +15,15 @@
public class ResultCodesUtil {
- private static final Logger logger =
Logger.getLogger(ResultCodesUtil.class.getName());
-
-
+ /**
+ * Generates result code
+ *
+ * @param reqMessage message to be populated with the result code. If
null,
+ * the new Message will be created.
+ * @param code result code
+ * @param description result additional description
+ * @return
+ */
public static Message generateResultMessage(Message reqMessage, String
code, String description) {
Message message = reqMessage;
@@ -31,7 +36,7 @@
meta.addChild(evt);
Data data = new Data("result-code-description", "result-code",
"nmwg");
- //Element datum = NMWGNamespaceFactory.getElement("datum", "nmwg");
+
Element datum = new Element("datum", "nmwgr",
"http://ggf.org/ns/nmwg/result/2.0/");
datum.setText(description);
data.addChild(datum);
@@ -39,28 +44,45 @@
message.addChild(meta);
message.addChild(data);
- //System.out.println(message.toString());
-
return message;
}
+ /**
+ * Creating result code basing on PerfSONARException
+ * @param reqMessage message to be populated with the result code. If
null,
+ * the new Message will be created.
+ * @param ex exception containing result code
+ * @return
+ */
public static Message generateResultMessage(Message reqMessage,
PerfSONARException ex) {
return generateResultMessage(reqMessage, ex.getResultCode(),
ex.getResultDescription());
}
+ /**
+ * New Message with result code will be created.
+ * @param code result code
+ * @param description result additional description
+ * @return
+ */
public static Message generateResultMessage(String code, String
description) {
return generateResultMessage(null, code, description);
}
+ /**
+ * Creating result code basing on PerfSONARException, will create new
Message
+ */
public static Message generateResultMessage(PerfSONARException ex) {
return generateResultMessage(null, ex.getResultCode(),
ex.getResultDescription());
}
+ /**
+ * TODO: why is it needed??? Need description or move to another
class/package
+ */
public static Message generateOldResultMessage(Message reqMessage,
String code, String description) {
Message message = reqMessage;
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/xml/nmwg/Data.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/xml/nmwg/Data.java
2009-03-17 05:33:06 UTC (rev 5084)
+++
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/xml/nmwg/Data.java
2009-03-17 10:34:13 UTC (rev 5085)
@@ -1,7 +1,6 @@
package org.perfsonar.base2.xml.nmwg;
import org.perfsonar.base2.xml.Element;
-import org.perfsonar.base2.xml.nmwgr.Datum;
public class Data extends Element {
Copied:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/xml/nmwg/Datum.java
(from rev 5084,
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/xml/nmwgr/Datum.java)
Property changes on:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/xml/nmwg/Datum.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified:
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/xml/nmwg/NMWGNamespaceFactory.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/xml/nmwg/NMWGNamespaceFactory.java
2009-03-17 05:33:06 UTC (rev 5084)
+++
branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2/xml/nmwg/NMWGNamespaceFactory.java
2009-03-17 10:34:13 UTC (rev 5085)
@@ -10,10 +10,12 @@
static HashMap<String,String> namespaces = new HashMap<String,String>();
static {
+ //TODO: to be loaded from file ?
namespaces.put("nmwg", "http://ggf.org/ns/nmwg/base/2.0/");
namespaces.put("perfsonar",
"http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/");
namespaces.put("psservice",
"http://ggf.org/ns/nmwg/tools/org/perfsonar/service/1.0/");
namespaces.put("xquery",
"http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/xquery/1.0/");
+ namespaces.put("nmwgr", "http://ggf.org/ns/nmwg/result/2.0/");
//..........
}
- perfsonar: r5085 - in branches/new-structure-with-base2/ps-mdm-base2/src/main/java/org/perfsonar/base2: service/configuration service/registration service/requesthandler service/scheduler service/storage/xml service/util xml xml/nmwg, svnlog, 03/17/2009
Archive powered by MHonArc 2.6.16.