perfsonar-dev - perfsonar: r5277 - in branches/new-structure-with-base2/ps-mdm-ls: . conf samples/requests src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/storage/exist src/main/java/org/perfsonar/service/lookupservice/summarization
Subject: perfsonar development work
List archive
perfsonar: r5277 - in branches/new-structure-with-base2/ps-mdm-ls: . conf samples/requests src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/storage/exist src/main/java/org/perfsonar/service/lookupservice/summarization
Chronological Thread
- From:
- To:
- Subject: perfsonar: r5277 - in branches/new-structure-with-base2/ps-mdm-ls: . conf samples/requests src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/storage/exist src/main/java/org/perfsonar/service/lookupservice/summarization
- Date: Fri, 4 Sep 2009 07:50:29 -0400
Author: trzaszcz
Date: 2009-09-04 07:50:27 -0400 (Fri, 04 Sep 2009)
New Revision: 5277
Modified:
branches/new-structure-with-base2/ps-mdm-ls/conf/configuration.xml
branches/new-structure-with-base2/ps-mdm-ls/pom.xml
branches/new-structure-with-base2/ps-mdm-ls/samples/requests/LSRegisterRequest.xml
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSCleanupServiceEngine.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSDeregisterServiceEngine.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSRegisterServiceEngine.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/XQueryExistDAOImpl.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/summarization/LSSummarySynchronizationAction.java
Log:
LS-summary implementation
Modified: branches/new-structure-with-base2/ps-mdm-ls/conf/configuration.xml
===================================================================
--- branches/new-structure-with-base2/ps-mdm-ls/conf/configuration.xml
2009-09-03 14:10:14 UTC (rev 5276)
+++ branches/new-structure-with-base2/ps-mdm-ls/conf/configuration.xml
2009-09-04 11:50:27 UTC (rev 5277)
@@ -116,6 +116,10 @@
className="org.perfsonar.service.lookupservice.dao.SummarizationDAO">
<option name="exist-config" value="exist"/> <!-- reference to eXist
DB XML config-->
</component>
+
+ <component name="countChangesComponent"
+
className="org.perfsonar.service.lookupservice.summarization.CountChangesComponent">
+ </component>
<!-- Scheduler -->
<component name="scheduling"
Modified: branches/new-structure-with-base2/ps-mdm-ls/pom.xml
===================================================================
--- branches/new-structure-with-base2/ps-mdm-ls/pom.xml 2009-09-03 14:10:14
UTC (rev 5276)
+++ branches/new-structure-with-base2/ps-mdm-ls/pom.xml 2009-09-04 11:50:27
UTC (rev 5277)
@@ -38,8 +38,8 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <source>1.6</source>
+ <target>1.6</target>
</configuration>
</plugin>
Modified:
branches/new-structure-with-base2/ps-mdm-ls/samples/requests/LSRegisterRequest.xml
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/samples/requests/LSRegisterRequest.xml
2009-09-03 14:10:14 UTC (rev 5276)
+++
branches/new-structure-with-base2/ps-mdm-ls/samples/requests/LSRegisterRequest.xml
2009-09-04 11:50:27 UTC (rev 5277)
@@ -7,7 +7,7 @@
<nmwg:parameters>
- <nmwg:parameter name="lsTTL">2000000000000</nmwg:parameter>
+ <nmwg:parameter name="lsTTL">100000000</nmwg:parameter>
</nmwg:parameters>
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSCleanupServiceEngine.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSCleanupServiceEngine.java
2009-09-03 14:10:14 UTC (rev 5276)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSCleanupServiceEngine.java
2009-09-04 11:50:27 UTC (rev 5277)
@@ -1,10 +1,12 @@
package org.perfsonar.service.lookupservice;
import org.apache.log4j.Logger;
+import org.perfsonar.base2.service.configuration.ConfigurationManager;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
import org.perfsonar.base2.service.requesthandler.ServiceMessage;
import org.perfsonar.base2.service.util.ResultCodesUtil;
import org.perfsonar.base2.xml.nmwg.Message;
+import
org.perfsonar.service.lookupservice.summarization.CountChangesComponent;
@@ -92,7 +94,14 @@
logger.debug("[LSCleanup] cleanup action started,
timestamp=["+now+"]s lsTTL=["+lsTTL+"]s");
//perform cleanup operation
- dao.cleanupLookupInfo(now, getLsTTLInSeconds());
+ int elementRemoved=dao.cleanupLookupInfo(now, getLsTTLInSeconds());
+
+ if ( elementRemoved > 0){
+ // some elements were removed, ChangesRecorder should be
informed about it
+ ConfigurationManager cm=ConfigurationManager.getInstance();
+ CountChangesComponent component =(CountChangesComponent)
cm.getConfiguration().getAuxiliaryComponent("countChangesComponent");
+ component.increaseCounter();
+ }
//result usually unimportant, may be required if
//it was run not by Scheduler but by ServiceEngine
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSDeregisterServiceEngine.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSDeregisterServiceEngine.java
2009-09-03 14:10:14 UTC (rev 5276)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSDeregisterServiceEngine.java
2009-09-04 11:50:27 UTC (rev 5277)
@@ -1,11 +1,13 @@
package org.perfsonar.service.lookupservice;
import org.apache.log4j.Logger;
+import org.perfsonar.base2.service.configuration.ConfigurationManager;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
import org.perfsonar.base2.service.requesthandler.ServiceMessage;
import org.perfsonar.base2.service.util.ResultCodesUtil;
import org.perfsonar.base2.xml.nmwg.Message;
import org.perfsonar.base2.xml.nmwg.Metadata;
+import
org.perfsonar.service.lookupservice.summarization.CountChangesComponent;
/**
@@ -72,6 +74,14 @@
"There were no metadata and data for key
["+keyValue+"]");
//return success code
+
+ // inform about changes Component !
+ ConfigurationManager cm = ConfigurationManager.getInstance();
+ CountChangesComponent component = (CountChangesComponent) cm
+ .getConfiguration().getAuxiliaryComponent(
+ "countChangesComponent");
+ component.increaseCounter();
+
logger.debug("!!! C");
Message msg = ResultCodesUtil.generateResultMessage(null,
"success/ls/deregister", "Removed total ["+
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSRegisterServiceEngine.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSRegisterServiceEngine.java
2009-09-03 14:10:14 UTC (rev 5276)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSRegisterServiceEngine.java
2009-09-04 11:50:27 UTC (rev 5277)
@@ -2,6 +2,7 @@
import java.util.List;
+import org.perfsonar.base2.service.configuration.ConfigurationManager;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
import org.perfsonar.base2.service.requesthandler.ServiceMessage;
import org.perfsonar.base2.xml.Element;
@@ -11,6 +12,7 @@
import org.perfsonar.base2.xml.nmwg.Metadata;
import
org.perfsonar.service.lookupservice.registerService.LSRegisterServiceHelper;
import org.perfsonar.service.lookupservice.registration.LsTTLParameterStatus;
+import
org.perfsonar.service.lookupservice.summarization.CountChangesComponent;
/**
* REGISTER and UPDATE Action
@@ -22,7 +24,6 @@
// --------------------------------------------------------------
Constants
-
private boolean allowReplaceIfAlreadyRegistered = true;
// -----------------------------------------------------------
Constructor
@@ -50,14 +51,13 @@
public void takeAction(ServiceMessage serviceRequest,
ServiceMessage serviceResponse) throws
PerfSONARException {
-
- /// -> REFACTORING
-
+ // / -> REFACTORING
+
// extract message
Message request = serviceRequest.getMessageElement();
- //lsTTL param processing
-
+ // lsTTL param processing
+
List<Element> parametersNodes = (List<Element>) serviceRequest
.getElement().getChildren("parameters");
if (parametersNodes != null && parametersNodes.size() == 1) {
@@ -174,8 +174,8 @@
boolean doRemove = false;
boolean doRemoveOldKey = false;
- /// <-- REFACTORING
-
+ // / <-- REFACTORING
+
// check keyValue
if (keyValue == null) { // REGISTER
@@ -271,7 +271,6 @@
}
-
// remove old lookup information if there is any
if (doRemove) {
logger.info("[LS Registration] Remove old Lookup Info
("
@@ -291,6 +290,14 @@
}
// register new lookup info
dao.putLookupInfo(requestMetadata, dataElements);
+
+ // some element was added, ChangesRecorder should be informed
about it
+ ConfigurationManager cm = ConfigurationManager.getInstance();
+ CountChangesComponent component = (CountChangesComponent) cm
+ .getConfiguration().getAuxiliaryComponent(
+ "countChangesComponent");
+ component.increaseCounter();
+
logger.info("[LS Registration] Put new Lookup Info (" +
metadataId
+ ") metadata + " + dataElements.length + "
data elements");
// update control time - last modification
@@ -304,7 +311,4 @@
} // end performAction
-
-
-
} // LSLookupAction
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/XQueryExistDAOImpl.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/XQueryExistDAOImpl.java
2009-09-03 14:10:14 UTC (rev 5276)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/XQueryExistDAOImpl.java
2009-09-04 11:50:27 UTC (rev 5277)
@@ -157,10 +157,10 @@
// System.out.println("---\n"+xquery+"\n---\n");
- /* XmlDbResult res = */getDataStorage().performXQuery(xquery,
+ XMLDBResult res = getDataStorage().performXQuery(xquery,
getDataCollection(), getDataCredential());
- return -1;
+ return res.getTextResults().length;
}
public void setControlParameter(String metadataId, String parameter,
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/summarization/LSSummarySynchronizationAction.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/summarization/LSSummarySynchronizationAction.java
2009-09-03 14:10:14 UTC (rev 5276)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/summarization/LSSummarySynchronizationAction.java
2009-09-04 11:50:27 UTC (rev 5277)
@@ -4,11 +4,11 @@
import java.util.logging.Logger;
import org.perfsonar.base2.service.configuration.Action;
+import org.perfsonar.base2.service.configuration.ConfigurationManager;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
import org.perfsonar.base2.service.scheduler.SchedulerAction;
import org.perfsonar.base2.xml.Element;
import org.perfsonar.service.lookupservice.dao.ISummarizationDAO;
-import org.perfsonar.service.lookupservice.storage.LookupServiceDAO;
import org.perfsonar.service.lookupservice.storage.LookupServiceDAOFactory;
public class LSSummarySynchronizationAction extends Action implements
SchedulerAction {
@@ -17,46 +17,51 @@
private int DIFF_COUNT;
private int LOOP_COUNT;
private int loopCountNr=0;
- private long time;
- private LookupServiceDAO dao;
private ISummarizationDAO summarizationDao;
private SummarizationBuilder builder;
private Logger logger=Logger.getAnonymousLogger();
+ private boolean firstLoop=true;
public LSSummarySynchronizationAction() throws PerfSONARException {
super();
- time=0;
}
@Override
public void runAction() {
try {
summarizationDao=LookupServiceDAOFactory.getSumarizationDAO();
- dao=LookupServiceDAOFactory.getDAO();
builder=new SummarizationBuilder(summarizationDao);
} catch (PerfSONARException e) {
e.printStackTrace();
}
- List<Element> datas;
+ int nrOfChanges=0;
+ CountChangesComponent component = null;
+ try {
+ ConfigurationManager cm =
ConfigurationManager.getInstance();
+
+ component = (CountChangesComponent) cm
+
.getConfiguration().getAuxiliaryComponent(
+
"countChangesComponent");
+ nrOfChanges=component.getCounter();
+ } catch (PerfSONARException e) {
+ e.printStackTrace();
+ }
DIFF_COUNT=getOption("diffCount").getValueAsInteger();
LOOP_COUNT=getOption("loopCount").getValueAsInteger();
- int count;
+
try {
-
- count = dao.getControlParameterCount(time);
-
- if(time==0){
- datas=builder.build();
- synchronizeSummarizationCollection(datas);
+
+ if(firstLoop){
+ synchronizeSummarizationCollection();
+ firstLoop=false;
logger.info("--------------FIRST TIME");
}else if(loopCountNr!=LOOP_COUNT){
-
- if (count >= DIFF_COUNT){
- datas=builder.build();
-
synchronizeSummarizationCollection(datas);
+ if (nrOfChanges >= DIFF_COUNT){
+
synchronizeSummarizationCollection();
+ component.resetCounter();
logger.info("--------------DO
");
}else{
logger.info("--------------LAZY");
@@ -64,17 +69,15 @@
loopCountNr++;
}else{
loopCountNr=0;
- if(count != 0){
- datas=builder.build();
-
synchronizeSummarizationCollection(datas);
- logger.info("--------------LAZY ==
0");
+ if(nrOfChanges != 0){
+ synchronizeSummarizationCollection();
+ component.resetCounter();
+ logger.info("--------------DO != 0");
}else{
logger.info("--------------LAZY - >
0");
}
}
- time=System.currentTimeMillis();
-
} catch (NumberFormatException e1) {
e1.printStackTrace();
} catch (PerfSONARException e1) {
@@ -84,10 +87,14 @@
}
- private void synchronizeSummarizationCollection(List<Element> datas)
throws PerfSONARException{
+ private void synchronizeSummarizationCollection() throws
PerfSONARException{
+ logger.info("------------SYNC--------------");
summarizationDao.removeSummaryData();
- datas=builder.build();
+ List<Element> datas=builder.build();
+ for(Element element:datas){
+ summarizationDao.putSummaryData(element);
+ }
+
}
-
}
- perfsonar: r5277 - in branches/new-structure-with-base2/ps-mdm-ls: . conf samples/requests src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/storage/exist src/main/java/org/perfsonar/service/lookupservice/summarization, svnlog, 09/04/2009
Archive powered by MHonArc 2.6.16.