Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r5273 - in branches/new-structure-with-base2/ps-mdm-ls: ant conf src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/registration src/main/java/org/perfsonar/service/lookupservice/registration/summarization src/main/java/org/perfsonar/service/lookupservice/storage src/main/java/org/perfsonar/service/lookupservice/storage/exist

Subject: perfsonar development work

List archive

perfsonar: r5273 - in branches/new-structure-with-base2/ps-mdm-ls: ant conf src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/registration src/main/java/org/perfsonar/service/lookupservice/registration/summarization src/main/java/org/perfsonar/service/lookupservice/storage src/main/java/org/perfsonar/service/lookupservice/storage/exist


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r5273 - in branches/new-structure-with-base2/ps-mdm-ls: ant conf src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/registration src/main/java/org/perfsonar/service/lookupservice/registration/summarization src/main/java/org/perfsonar/service/lookupservice/storage src/main/java/org/perfsonar/service/lookupservice/storage/exist
  • Date: Tue, 1 Sep 2009 05:52:33 -0400

Author: trzaszcz
Date: 2009-09-01 05:52:32 -0400 (Tue, 01 Sep 2009)
New Revision: 5273

Removed:
branches/new-structure-with-base2/ps-mdm-ls/conf/configuration.xml-rrd

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSRegisterAction.java.tmp
Modified:
branches/new-structure-with-base2/ps-mdm-ls/ant/build.xml
branches/new-structure-with-base2/ps-mdm-ls/conf/configuration.xml

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/DiscoveryRequestGenerator.java

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/LSSummaryRegisterDataSource.java

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/summarization/IPAddressConvertor.java

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/summarization/TrieNode.java

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/LookupServiceDAO.java

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/LookupServiceDAOFactory.java

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/MultipleFilesExistDAOImpl.java

branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/XQueryExistDAOImpl.java
Log:
refactoring, LSStore-summarization implementation

Modified: branches/new-structure-with-base2/ps-mdm-ls/ant/build.xml
===================================================================
--- branches/new-structure-with-base2/ps-mdm-ls/ant/build.xml 2009-08-27
12:08:55 UTC (rev 5272)
+++ branches/new-structure-with-base2/ps-mdm-ls/ant/build.xml 2009-09-01
09:52:32 UTC (rev 5273)
@@ -142,7 +142,7 @@


<property name="temp" value="${build.dir}/temp" />
- <property name="war.name" value="${jar.name}"/>
+ <property name="war.name" value="perfsonar-java-xml-ls"/>


<target name="init">

Modified: branches/new-structure-with-base2/ps-mdm-ls/conf/configuration.xml
===================================================================
--- branches/new-structure-with-base2/ps-mdm-ls/conf/configuration.xml
2009-08-27 12:08:55 UTC (rev 5272)
+++ branches/new-structure-with-base2/ps-mdm-ls/conf/configuration.xml
2009-09-01 09:52:32 UTC (rev 5273)
@@ -102,7 +102,13 @@
<option name="username" value="guest"/>
<option name="password" value="guest"/>
</component>
-
+
+
+ <!-- Summarization Service DAO -->
+ <component name="summarizationdao"
+
className="org.perfsonar.service.lookupservice.summarization.SummarizationDAO">
+ <option name="exist-config" value="exist"/> <!-- reference to eXist
DB XML config-->
+ </component>

<!-- Lookup Service DAO -->
<component name="lsdao"
@@ -144,7 +150,7 @@

value="org.perfsonar.base2.service.registration.GenericLSRegistrator"/>

<option name="lsAddress-1"
-
value="http://localhost:8080/ps-mdm-ls/services/LookupService"/>
+
value="http://localhost:8080/perfsonar-java-xml-ls/services/LookupService"/>

<option name="keyRefresh" value="0"/>
</action>

Deleted:
branches/new-structure-with-base2/ps-mdm-ls/conf/configuration.xml-rrd

Deleted:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSRegisterAction.java.tmp

Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/DiscoveryRequestGenerator.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/DiscoveryRequestGenerator.java
2009-08-27 12:08:55 UTC (rev 5272)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/DiscoveryRequestGenerator.java
2009-09-01 09:52:32 UTC (rev 5273)
@@ -1,5 +1,8 @@
package org.perfsonar.service.lookupservice.registration;

+import java.util.ArrayList;
+import java.util.List;
+
import org.perfsonar.base2.xml.Element;
import org.perfsonar.base2.xml.nmwg.EventType;
import org.perfsonar.base2.xml.nmwg.Message;
@@ -12,7 +15,9 @@
*/
public class DiscoveryRequestGenerator {

- public Message createMessageElement() {
+ List<Metadata> metadataList=new ArrayList<Metadata>();
+
+ public Message createMessageElement() {

Message message= new Message();
message.setId("LSDiscoveryRequest");
@@ -44,6 +49,7 @@
data.addAttribute("id", metadataId+"_dataTriger");
data.addAttribute("metadataIdRef", metadataId);
message.addChild(data);
+ metadataList.add(metadata);

return subject;
}
@@ -126,5 +132,9 @@
parameter.setText(value);
parameters.addChild(parameter);
return parameter;
- }
+ }
+
+ public List<Metadata> getMetadataList() {
+ return metadataList;
+ }
}

Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/LSSummaryRegisterDataSource.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/LSSummaryRegisterDataSource.java
2009-08-27 12:08:55 UTC (rev 5272)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/LSSummaryRegisterDataSource.java
2009-09-01 09:52:32 UTC (rev 5273)
@@ -1,21 +1,31 @@
package org.perfsonar.service.lookupservice.registration;

+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
import java.util.Map.Entry;

+import javax.xml.stream.XMLStreamException;
+
import org.apache.log4j.Logger;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
import org.perfsonar.base2.service.registration.RegisterDataSource;
import org.perfsonar.base2.service.requesthandler.ServiceMessage;
import org.perfsonar.base2.xml.Element;
+import org.perfsonar.base2.xml.ElementSerializer;
import org.perfsonar.base2.xml.nmwg.Message;
+import org.perfsonar.base2.xml.nmwg.Metadata;
import
org.perfsonar.service.lookupservice.registration.summarization.SummarizeIpAddrs;
-import org.perfsonar.service.lookupservice.storage.LookupServiceDAO;
import org.perfsonar.service.lookupservice.storage.LookupServiceDAOFactory;
+import org.perfsonar.service.lookupservice.summarization.ISummarizationDAO;
+import org.perfsonar.service.lookupservice.summarization.ServiceSummary;

/**
* This class get data and summarize
@@ -33,14 +43,14 @@
private static final int EVENT_TYPE = 300;
private static final int KEYWORD = 400;

- protected LookupServiceDAO dao;
+ protected ISummarizationDAO dao;

//
----------------------------------------------------------------------

public LSSummaryRegisterDataSource() throws PerfSONARException {

super();
- dao = LookupServiceDAOFactory.getDAO();
+ dao = LookupServiceDAOFactory.getSumarizationDAO();
}

public ServiceMessage getRegisterData() throws PerfSONARException {
@@ -65,11 +75,11 @@

// summarize IPs
logger.debug("Summarize IP addresses for service #["
+ i + "]");
- s.ipAddresses = summarizeIPAddresses(s.ipAddresses);
+
s.setIpAddresses(summarizeIPAddresses(s.getIpAddresses()));

// summarize domains
logger.debug("Summarize domains for service #[" + i +
"]");
- s.domains = summarizeDomains(s.domains);
+ s.setDomains(summarizeDomains(s.getDomains()));

logger.debug("Summarize eventTypes and keywords...");
// summarize eventTypes
@@ -87,11 +97,11 @@
Message msg = gen.createMessageElement();

// for every single summary get XML
- for (ServiceSummary s : summaries.values()) {
+ for (Entry<String, ServiceSummary> s : summaries.entrySet()) {

- Element subject = gen.createSubjectElement(msg,
"summmary.md");
+ Element subject = gen.createSubjectElement(msg,
s.getKey());

- for (String ip : s.ipAddresses) {
+ for (String ip : s.getValue().getIpAddresses()) {

// split results - ip/netmask or assume 32 as
netmask if wrong
// format
@@ -102,23 +112,24 @@
gen.createAddressElement(subject, ipvals[0],
ipvals[1]);
}

- for (String dom : s.domains) {
+ for (String dom : s.getValue().getDomains()) {
gen.createDomainElement(subject, dom);
}

// get sum of parameters to determine whether there
is any parameter
// to be printed
- int paramsSum = s.eventTypes.size() +
s.keywords.size();
+ int paramsSum = s.getValue().getEventTypes().size()
+ + s.getValue().getKeywords().size();
// if it is at least one, put it.
if (paramsSum > 0) {
Element parametersElement = gen

.createParametersElement(subject);

- for (String evt : s.eventTypes) {
+ for (String evt :
s.getValue().getEventTypes()) {

gen.createParameterElement(parametersElement, "eventType",
evt);
}
- for (String kw : s.keywords) {
+ for (String kw : s.getValue().getKeywords()) {
gen

.createParameterElement(parametersElement,

"keyword", kw);
@@ -126,8 +137,27 @@
}

}
- // logger.debug("Summary data is:\n"+msg);
-
+ // logger.debug("Summary data is:\n" + msg);
+
+ dao.removeSummaryData();
+
+ for (Metadata metadata : gen.getMetadataList()) {
+ dao.putSummaryData(metadata);
+ }
+
+ ElementSerializer es = new ElementSerializer();
+ File file = new File("/home/czacha/Desktop/log");
+
+ try {
+ es.write(new FileOutputStream(file), msg);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (XMLStreamException e) {
+ // TODO Auto-generated catch block
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
return new ServiceMessage(msg);

}
@@ -142,22 +172,16 @@
throws PerfSONARException {

Map<String, ServiceSummary> summaries = new HashMap<String,
ServiceSummary>();
- String[] ipResults = queryIpResults();
- String[] domainResults = queryDomainResults();
- String[] eventTypeResults = queryEventTypeResults();
- String[] keywordResults = queryKeywordResults();
+ String[] ipResults = dao.queryIpResults();
+ String[] domainResults = dao.queryDomainResults();
+ String[] eventTypeResults = dao.queryEventTypeResults();
+ String[] keywordResults = dao.queryKeywordResults();

logger

.debug("LSSummaryServiceContent.getAllServicesSummaries: got summary from
database. Number of: ");
try {
logger.debug(" - IP: [" + ipResults.length +
"]");
- } catch (Exception ex) {
- }
- try {
logger.debug(" - domains: [" +
domainResults.length + "]");
- } catch (Exception ex) {
- }
- try {
logger.debug(" - eventvTypes: [" +
eventTypeResults.length
+ "]");
} catch (Exception ex) {
@@ -215,9 +239,9 @@
* @param data
* @return
*/
- private HashSet<String> summarizeIPAddresses(HashSet<String>
ipAddresses) {
+ private Set<String> summarizeIPAddresses(Set<String> ipAddresses) {

- HashSet<String> result;
+ Set<String> result;

try {
result = SummarizeIpAddrs.getSummary(ipAddresses);
@@ -237,7 +261,7 @@
* @param data
* @return
*/
- private HashSet<String> summarizeDomains(HashSet<String> data) {
+ private Set<String> summarizeDomains(Set<String> data) {

HashSet<String> summarizedData = new HashSet<String>();
for (String s : data) {
@@ -286,16 +310,16 @@
// fill the right field
switch (type) {
case IP:
- summary.ipAddresses.add(content);
+ summary.getIpAddresses().add(content);
break;
case DOMAIN:
- summary.domains.add(content);
+ summary.getDomains().add(content);
break;
case EVENT_TYPE:
- summary.eventTypes.add(content);
+ summary.getEventTypes().add(content);
break;
case KEYWORD:
- summary.keywords.add(content);
+ summary.getKeywords().add(content);
break;
}

@@ -303,137 +327,15 @@

}

- /**
- * Return set of IP addresses used by services
- *
- * @return
- */
- private String[] queryIpResults() throws PerfSONARException {
-
- String xq = " declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; \n"
- + " for $d in
/nmwg:store[@type='LSStore']/nmwg:data
\n"
- + " let $metaIdRef :=
data($d/@metadataIdRef) \n"
- + " for $val in
$d/nmwg:metadata/*:subject//*:ifAddress/text() \n"
- + " return if (empty($val)) then $val else
concat($metaIdRef,',',$val) \n";
- return dao.performXQuery(xq).getTextResults();
-
- }
-
- /**
- * Return set of domains used by services
- *
- * @return
- */
- private String[] queryDomainResults() throws PerfSONARException {
-
- String xq = " declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; \n"
- + " for $d in
/nmwg:store[@type='LSStore']/nmwg:data
\n"
- + " let $metaIdRef :=
data($d/@metadataIdRef) \n"
- + " for $val in
$d/nmwg:metadata/*:subject//*:hostName/text() \n"
- + " return if (empty($val)) then $val
else concat($metaIdRef,',',$val) \n";
-
- return dao.performXQuery(xq).getTextResults();
- }
-
- /**
- * Return set of eventTypes used by services
- *
- * @return
- */
- private String[] queryEventTypeResults() throws PerfSONARException {
-
- String xq = " declare namespace
nmwg='http://ggf.org/ns/nmwg/base/2.0/'; \n"
- + " declare namespace
nmwgt='http://ggf.org/ns/nmwg/topology/2.0/';\n"
- + " for $d in
/nmwg:store[@type='LSStore']/nmwg:data
\n"
- + " let $metaIdRef := data($d/@metadataIdRef)
\n"
- + " for $e in $d/nmwg:metadata/nmwg:eventType
\n"
- + " let $val := $e/text() \n"
- + " return concat($metaIdRef,',',$val)\n";
- return dao.performXQuery(xq).getTextResults();
- }
-
- /**
- * Return set of keywords Takes either //nmwg:parameter/@value or
- * //nmwg:parameter/text()
- *
- * @return
- */
- private String[] queryKeywordResults() throws PerfSONARException {
-
- String xq = " declare namespace
nmwg='http://ggf.org/ns/nmwg/base/2.0/'; "
- + " declare namespace
nmwgt='http://ggf.org/ns/nmwg/topology/2.0/'; "
- + " for $d in
/nmwg:store[@type='LSStore']/nmwg:data
"
- + " for $p in
$d/nmwg:metadata/*:parameters/nmwg:parameter[@name='keyword']
"
- + " let $val1 := $p/text() "
- + " let $val2 :=$p/@value "
- + " let $metaIdRef :=
data($d/@metadataIdRef) "
- + " return "
- + " if (empty($val1)) then
concat($metaIdRef,',',data($val2)) "
- + " else concat($metaIdRef,',', $val1)";
- return dao.performXQuery(xq).getTextResults();
- }
-
private void showSummary(Map<String, ServiceSummary> summaries) {
Iterator<Entry<String, ServiceSummary>> i =
summaries.entrySet()
.iterator();
while (i.hasNext()) {
- Map.Entry e = i.next();
+ Map.Entry<String, ServiceSummary> e = i.next();
logger.debug("\n==== " + e.getKey() + " ====\n");
logger.debug(e.getValue().toString());

}
}

- //
----------------------------------------------------------------------
-
- /**
- * Contains summary from a single service
- *
- * @author Maciej Glowiak
- *
- */
- class ServiceSummary {
-
- public HashSet<String> eventTypes = new HashSet<String>();
- public HashSet<String> domains = new HashSet<String>();
- public HashSet<String> ipAddresses = new HashSet<String>();
- public HashSet<String> keywords = new HashSet<String>();
-
- public String toString() {
-
- StringBuffer sb = new StringBuffer();
-
- sb.append("1. eventTypes:\n");
- for (String s : eventTypes) {
- sb.append(" -- ");
- sb.append(s);
- sb.append("\n");
- }
- sb.append("2. domains:\n");
- for (String s : domains) {
- sb.append(" -- ");
- sb.append(s);
- sb.append("\n");
- }
- sb.append("3. IPs:\n");
- for (String s : ipAddresses) {
- sb.append(" -- ");
- sb.append(s);
- sb.append("\n");
- }
- sb.append("4. Keywords:\n");
- for (String s : keywords) {
- sb.append(" -- ");
- sb.append(s);
- sb.append("\n");
- }
- return sb.toString();
- }
-
- } // ServiceSummary
-
- // public static void main(String[] s) {
- //
- // }
-
-}// LSSummaryServiceContent
+}
\ No newline at end of file

Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/summarization/IPAddressConvertor.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/summarization/IPAddressConvertor.java
2009-08-27 12:08:55 UTC (rev 5272)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/summarization/IPAddressConvertor.java
2009-09-01 09:52:32 UTC (rev 5273)
@@ -8,7 +8,7 @@
*/
public class IPAddressConvertor {
private String ipAddress;
- private int subnetMask;
+// private int subnetMask;
private String keyMappedToIPAddress;
String message = "Invalid IP address specified";

@@ -22,7 +22,7 @@
public void splitIPAddressOnSubnetMask() {
String[] splitIP = ipAddress.split("/");
if(splitIP.length == 2){
- subnetMask = Integer.parseInt(splitIP[1]);
+// subnetMask = Integer.parseInt(splitIP[1]);
ipAddress = splitIP[0];
}
else{

Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/summarization/TrieNode.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/summarization/TrieNode.java
2009-08-27 12:08:55 UTC (rev 5272)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/summarization/TrieNode.java
2009-09-01 09:52:32 UTC (rev 5273)
@@ -371,14 +371,14 @@
if (c0 != null) {
long c0Key = c0.getKey() << (position - c0.getKeyLength());
long c0Position = position - c0.getKeyLength();
- long c0Mask = Constants.MAX_KEY_LENGTH - c0Position;
+// long c0Mask = Constants.MAX_KEY_LENGTH - c0Position;
c0Key = c0Key | currentKey;
c0.listInternalNodes(listOfNodes, c0Position, c0Key);
}
if (c1 != null) {
long c1Key = c1.getKey() << (position - c1.getKeyLength());
long c1Position = position - c1.getKeyLength();
- long c1Mask = Constants.MAX_KEY_LENGTH - c1Position;
+// long c1Mask = Constants.MAX_KEY_LENGTH - c1Position;
c1Key = c1Key | currentKey;
c1.listInternalNodes(listOfNodes, c1Position, c1Key);
}

Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/LookupServiceDAO.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/LookupServiceDAO.java
2009-08-27 12:08:55 UTC (rev 5272)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/LookupServiceDAO.java
2009-09-01 09:52:32 UTC (rev 5273)
@@ -20,7 +20,6 @@
* The name of the control collection of LS
*/
public static final String LS_STORE_CONTROL_COLLECTION_TYPE =
"LSStore-control";
-

public final static String DECLARE_NMWG_NAMESPACE =
"declare namespace nmwg='http://ggf.org/ns/nmwg/base/2.0/'; \n";
@@ -138,5 +137,4 @@
*/
public boolean isDBConnectivity() throws PerfSONARException;

-
} //LookupServiceDAO

Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/LookupServiceDAOFactory.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/LookupServiceDAOFactory.java
2009-08-27 12:08:55 UTC (rev 5272)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/LookupServiceDAOFactory.java
2009-09-01 09:52:32 UTC (rev 5273)
@@ -2,13 +2,17 @@

import org.perfsonar.base2.service.configuration.ConfigurationManager;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
+import org.perfsonar.service.lookupservice.summarization.ISummarizationDAO;

public class LookupServiceDAOFactory {

private static LookupServiceDAO dao = null;
private static LookupServiceDAO daoRO = null;
+ private static ISummarizationDAO summariaztionDAO=null;
+
private final static String LS_DAO = "lsdao";
private final static String LS_DAO_RO = "lsdao-ro";
+ private final static String SUMMARIZATION_DAO = "summarizationdao";

public static LookupServiceDAO getDAO() throws PerfSONARException {

@@ -36,11 +40,27 @@

.getConfiguration().getAuxiliaryComponent(LS_DAO_RO);
return daoRO;
} catch (Exception ex) {
- throw new PerfSONARException("no_ls_dao",
- "Cannot find 'lsdao'
component");
+ throw new PerfSONARException("no_ls_ro_dao",
+ "Cannot find 'lsdao-ro'
component");
}

}
}
+
+ public static ISummarizationDAO getSumarizationDAO() throws
PerfSONARException {

+ if (summariaztionDAO != null) {
+ return summariaztionDAO;
+ } else {
+ try {
+ summariaztionDAO = (ISummarizationDAO)
ConfigurationManager.getInstance()
+
.getConfiguration().getAuxiliaryComponent(SUMMARIZATION_DAO);
+ return summariaztionDAO;
+ } catch (Exception ex) {
+ throw new
PerfSONARException("no_summarization_dao",
+ "Cannot find
'summarizationdao' component");
+ }
+ }
+ }
+
} // LookupServiceDAOFactory

Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/MultipleFilesExistDAOImpl.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/MultipleFilesExistDAOImpl.java
2009-08-27 12:08:55 UTC (rev 5272)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/MultipleFilesExistDAOImpl.java
2009-09-01 09:52:32 UTC (rev 5273)
@@ -231,5 +231,17 @@
}
}

+
+ public void putSummaryData(Metadata m) throws PerfSONARException {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void removeSummaryData() throws PerfSONARException {
+ // TODO Auto-generated method stub
+
+ }
+

} //MultipleFilesExistDAOImpl

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-08-27 12:08:55 UTC (rev 5272)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/storage/exist/XQueryExistDAOImpl.java
2009-09-01 09:52:32 UTC (rev 5273)
@@ -17,249 +17,299 @@
*/
public class XQueryExistDAOImpl extends CommonExistDAOImpl {

- //
---------------------------------------------------------------constants
+ //
---------------------------------------------------------------constants

- private static final String UPDATE_FOR = " for $i in ";
+ protected static final String UPDATE_FOR = " for $i in ";

- private static final String UPDATE_REMOVE = " return (update delete $i,
'removed')";
+ protected static final String UPDATE_REMOVE = " return (update delete
$i, 'removed')";

- private static final String UPDATE_INSERT = " update insert ";
+ protected static final String UPDATE_INSERT = " update insert ";

- private static final String UPDATE_INTO = " into ";
+ protected static final String UPDATE_INTO = " into ";

- private static final String UPDATE_LSSTORE = "
/nmwg:store[@type='"
- + LS_STORE_COLLECTION_TYPE + "'] ";
+ protected static final String UPDATE_LSSTORE = "
/nmwg:store[@type='"
+ + LS_STORE_COLLECTION_TYPE + "'] ";
+
+// protected static final String UPDATE_LSSTORE_SUMMARY =
"/nmwg:store[@type='"
+// + LS_STORE_SUMMARY_COLLECTION_TYPE + "']";

- // ------------------------------------------------------instance
variables
+ // ------------------------------------------------------instance
variables

- public XQueryExistDAOImpl() {
- super();
- }
+ public XQueryExistDAOImpl() {
+ super();
+ }

- // --------------------------------------------------------- Public
methods
+ // --------------------------------------------------------- Public
methods

- public void putLookupInfo(Metadata m, Data[] d) throws
PerfSONARException {
-
- if (m == null) {
- String msg = "No metadata. Cannot put into database";
- logger.error(msg);
- throw new PerfSONARException("error/ls/no_metadata",msg);
- }
- if (d == null) {
- String msg = "No data (null). Cannot put into database";
- logger.error(msg);
- throw new PerfSONARException("error/ls/no_data",msg);
- }
- if (d.length<1) {
- String msg = "No data (0). Cannot put into database";
- logger.error(msg);
- throw new PerfSONARException("error/ls/no_data",msg);
- }
-
- // serialize Metadata and Data
+ public void putLookupInfo(Metadata m, Data[] d) throws
PerfSONARException {

- // send xquery update expression containing all metadata and data
- // elements in one xquery
- // instruction; should work faster than code above (commented)
- ElementSerializer ser = new ElementSerializer();
- ser.setStartingDocumentDeclaration(false);
- StringBuffer xmls = new StringBuffer();
- StringBufferOutputStream os = new StringBufferOutputStream(xmls);
+ if (m == null) {
+ String msg = "No metadata. Cannot put into database";
+ logger.error(msg);
+ throw new PerfSONARException("error/ls/no_metadata",
msg);
+ }
+ if (d == null) {
+ String msg = "No data (null). Cannot put into
database";
+ logger.error(msg);
+ throw new PerfSONARException("error/ls/no_data", msg);
+ }
+ if (d.length < 1) {
+ String msg = "No data (0). Cannot put into database";
+ logger.error(msg);
+ throw new PerfSONARException("error/ls/no_data", msg);
+ }

- //add xquery namespaces and UPDATE instruction
- xmls.append(XQUERY_DECLARE_NAMESPACES);
- xmls.append(UPDATE_INSERT);
- xmls.append(" (\n"); //IMPORTANT - begin Xquery collection (m, d, d,
...)
+ // serialize Metadata and Data

- try {
+ // send xquery update expression containing all metadata and
data
+ // elements in one xquery
+ // instruction; should work faster than code above (commented)
+ ElementSerializer ser = new ElementSerializer();
+ ser.setStartingDocumentDeclaration(false);
+ StringBuffer xmls = new StringBuffer();
+ StringBufferOutputStream os = new
StringBufferOutputStream(xmls);

- // add metadata to StringBuffer
- ser.write(os, m);
-
- // convert data to Strings
- for (int i = 0; i < d.length; i++) {
- xmls.append(", \n"); //IMPORTANT - separator for next
element of Xquery collection (m, d, d, ...)
- ser.write(os, d[i]);
+ // add xquery namespaces and UPDATE instruction
+ xmls.append(XQUERY_DECLARE_NAMESPACES);
+ xmls.append(UPDATE_INSERT);
+ xmls.append(" (\n"); // IMPORTANT - begin Xquery collection
(m, d, d,
+ // ...)

- }
-
- } catch (Exception e) {
- throw new PerfSONARException("error/parse",
- "Cannot serialize elements in XQueryExistDAOImpl");
- }
- // send XQuery
- xmls.append(" )\n"); //IMPORTANT - end of Xquery collection (m, d,
d, ...)
- xmls.append(UPDATE_INTO);
- xmls.append(UPDATE_LSSTORE);
-
- String query = xmls.toString();
- getDataStorage().performXQuery(query, getDataCollection(),
- getDataCredential());
- }
+ try {

- public int removeLookupInfo(String metadataId) throws PerfSONARException
{
+ // add metadata to StringBuffer
+ ser.write(os, m);

- String xquery = XQUERY_DECLARE_NAMESPACES + UPDATE_FOR
- + getRemoveLookupInfoXQueryPart(metadataId) + UPDATE_REMOVE;
- // remove by xquery
- XMLDBResult res = getDataStorage().performXQuery(xquery,
- getDataCollection(), getDataCredential());
- logger.debug("REMOVE LOOKUP QUERY:\n"+xquery);
- logger.debug("REMOVE LOOKUP RESULT:\n"+res);
- if (res != null)
- return res.getTotal();
- else
- return -1; // if error
+ // convert data to Strings
+ for (int i = 0; i < d.length; i++) {
+ xmls.append(", \n"); // IMPORTANT - separator
for next element
+
// of Xquery collection (m, d, d, ...)
+ ser.write(os, d[i]);

- }
+ }

- public int cleanupLookupInfo(long timestamp, long defaultInterval)
- throws PerfSONARException {
+ } catch (Exception e) {
+ throw new PerfSONARException("error/parse",
+ "Cannot serialize elements in
XQueryExistDAOImpl");
+ }
+ // send XQuery
+ xmls.append(" )\n"); // IMPORTANT - end of Xquery collection
(m, d, d,
+ // ...)
+ xmls.append(UPDATE_INTO);
+ xmls.append(UPDATE_LSSTORE);

- String xquery = DECLARE_NMWG_NAMESPACE
- +
+ String query = xmls.toString();
+ getDataStorage().performXQuery(query, getDataCollection(),
+ getDataCredential());
+ }

- "let $now:="
- + timestamp
- + "\n"
- + "let $interval:="
- + defaultInterval
- + "\n"
- +
- // to be changed - get interval from parameter
+ public int removeLookupInfo(String metadataId) throws
PerfSONARException {

- "for $meta in
/nmwg:store[@type='LSStore-control']/nmwg:metadata
\n"
- + " let $ts :=
data($meta/nmwg:parameters/nmwg:parameter[@name='timestamp']/@value)
cast as xs:integer\n"
- + " let $metaid := data($meta/@id)\n "
- + "where ("
- +"
if(exists($meta/nmwg:parameters/nmwg:parameter[@name='lsTTL']))"

- +" then ( let $serviceLsTTL :=
data($meta/nmwg:parameters/nmwg:parameter[@name='lsTTL']/@value)
cast as xs:double"
- +" where ($ts + $serviceLsTTL) <
$now return true()"
- +" )"
- +" else"
- +" ($ts + $interval) < $now"
- +" )"
- + "return \n"
- +
+ String xquery = XQUERY_DECLARE_NAMESPACES + UPDATE_FOR
+ + getRemoveLookupInfoXQueryPart(metadataId) +
UPDATE_REMOVE;
+ // remove by xquery
+ XMLDBResult res = getDataStorage().performXQuery(xquery,
+ getDataCollection(), getDataCredential());
+ logger.debug("REMOVE LOOKUP QUERY:\n" + xquery);
+ logger.debug("REMOVE LOOKUP RESULT:\n" + res);
+ if (res != null)
+ return res.getTotal();
+ else
+ return -1; // if error

- "(\n"
- + " $metaid,\n"
- + " update delete
/nmwg:store[@type='LSStore-control']/nmwg:metadata[@id=$metaid],\n"
- + " update delete
/nmwg:store[@type='LSStore']/nmwg:metadata[@id=$metaid],
\n"
- + " update delete
/nmwg:store[@type='LSStore']/nmwg:data[@metadataIdRef=$metaid]\n"
- + " )\n";
+ }

- // System.out.println("---\n"+xquery+"\n---\n");
+ public int cleanupLookupInfo(long timestamp, long defaultInterval)
+ throws PerfSONARException {

- /* XmlDbResult res = */getDataStorage().performXQuery(xquery,
- getDataCollection(), getDataCredential());
+ String xquery = DECLARE_NMWG_NAMESPACE
+ +

- return -1;
- }
+ "let $now:="
+ + timestamp
+ + "\n"
+ + "let $interval:="
+ + defaultInterval
+ + "\n"
+ +
+ // to be changed - get interval from parameter

- public void setControlParameter(String metadataId, String parameter,
- String value) throws PerfSONARException {
+ "for $meta in
/nmwg:store[@type='LSStore-control']/nmwg:metadata
\n"
+ + " let $ts :=
data($meta/nmwg:parameters/nmwg:parameter[@name='timestamp']/@value)
cast as xs:integer\n"
+ + " let $metaid := data($meta/@id)\n "
+ + "where ("
+ + "
if(exists($meta/nmwg:parameters/nmwg:parameter[@name='lsTTL']))"
+ + " then ( let $serviceLsTTL :=
data($meta/nmwg:parameters/nmwg:parameter[@name='lsTTL']/@value)
cast as xs:double"
+ + " where ($ts +
$serviceLsTTL) < $now return true()"
+ + " )"
+ + " else"
+ + " ($ts + $interval) <
$now"
+ + " )"
+ + "return \n"
+ +

- String xquery = DECLARE_NMWG_NAMESPACE
- +
+ "(\n"
+ + " $metaid,\n"
+ + " update delete
/nmwg:store[@type='LSStore-control']/nmwg:metadata[@id=$metaid],\n"
+ + " update delete
/nmwg:store[@type='LSStore']/nmwg:metadata[@id=$metaid],
\n"
+ + " update delete
/nmwg:store[@type='LSStore']/nmwg:data[@metadataIdRef=$metaid]\n"
+ + " )\n";

- "let $paramName := '"
- + parameter
- + "' \n"
- + "let $paramValue := '"
- + value
- + "' \n"
- + "let $metadataId := '"
- + metadataId
- + "' \n"
- +
+ // System.out.println("---\n"+xquery+"\n---\n");

- "let $command := \n"
- + " if
(count(/nmwg:store[@type='"
- + LS_STORE_CONTROL_COLLECTION_TYPE
- +
"']/nmwg:metadata[@id=$metadataId]/nmwg:parameters/nmwg:parameter[@name=$paramName])
> 0) then \n"
- + " update replace
/nmwg:store[@type='"
- + LS_STORE_CONTROL_COLLECTION_TYPE
- +
"']/nmwg:metadata[@id=$metadataId]/nmwg:parameters/nmwg:parameter[@name=$paramName]/@value
with $paramValue \n"
- + " else if
(count(/nmwg:store[@type='"
- + LS_STORE_CONTROL_COLLECTION_TYPE
- +
"']/nmwg:metadata[@id=$metadataId]/nmwg:parameters)
> 0) then \n"
- + " update insert <nmwg:parameter name='{$paramName}'
value='{$paramValue}'/> into
/nmwg:store[@type='"
- + LS_STORE_CONTROL_COLLECTION_TYPE
- +
"']/nmwg:metadata[@id=$metadataId]/nmwg:parameters
\n"
- + " else if
(count(/nmwg:store[@type='"
- + LS_STORE_CONTROL_COLLECTION_TYPE
- +
"']/nmwg:metadata[@id=$metadataId])
> 0) then \n"
- + " update insert <nmwg:parameters
id='control-parameters'><nmwg:parameter name='{$paramName}'
value='{$paramValue}'/></nmwg:parameters> into
/nmwg:store[@type='"
- + LS_STORE_CONTROL_COLLECTION_TYPE
- +
"']/nmwg:metadata[@id=$metadataId]
\n"
- + " else "
- + " update insert <nmwg:metadata
id='{$metadataId}'><nmwg:parameters id='control-parameters'><nmwg:parameter
name='{$paramName}' value='{$paramValue}'/></nmwg:parameters></nmwg:metadata>
into
/nmwg:store[@type='"
- + LS_STORE_CONTROL_COLLECTION_TYPE + "'] \n" +
+ /* XmlDbResult res = */getDataStorage().performXQuery(xquery,
+ getDataCollection(), getDataCredential());

- "return $command \n";
+ return -1;
+ }

- // put
- getDataStorage().performXQuery(xquery, getDataCollection(),
- getDataCredential());
+ public void setControlParameter(String metadataId, String parameter,
+ String value) throws PerfSONARException {

- } // set parameter
+ String xquery = DECLARE_NMWG_NAMESPACE
+ +

- public void removeControlParameter(String metadataId, String parameter)
- throws PerfSONARException {
- String xquery = DECLARE_NMWG_NAMESPACE
- +
+ "let $paramName := '"
+ + parameter
+ + "' \n"
+ + "let $paramValue := '"
+ + value
+ + "' \n"
+ + "let $metadataId := '"
+ + metadataId
+ + "' \n"
+ +

- "let $paramName := '"
- + parameter
- + "'\n"
- + "let $metadataId := '"
- + metadataId
- + "'\n"
- +
+ "let $command := \n"
+ + " if
(count(/nmwg:store[@type='"
+ + LS_STORE_CONTROL_COLLECTION_TYPE
+ +
"']/nmwg:metadata[@id=$metadataId]/nmwg:parameters/nmwg:parameter[@name=$paramName])
> 0) then \n"
+ + " update replace
/nmwg:store[@type='"
+ + LS_STORE_CONTROL_COLLECTION_TYPE
+ +
"']/nmwg:metadata[@id=$metadataId]/nmwg:parameters/nmwg:parameter[@name=$paramName]/@value
with $paramValue \n"
+ + " else if
(count(/nmwg:store[@type='"
+ + LS_STORE_CONTROL_COLLECTION_TYPE
+ +
"']/nmwg:metadata[@id=$metadataId]/nmwg:parameters)
> 0) then \n"
+ + " update insert <nmwg:parameter
name='{$paramName}' value='{$paramValue}'/> into
/nmwg:store[@type='"
+ + LS_STORE_CONTROL_COLLECTION_TYPE
+ +
"']/nmwg:metadata[@id=$metadataId]/nmwg:parameters
\n"
+ + " else if
(count(/nmwg:store[@type='"
+ + LS_STORE_CONTROL_COLLECTION_TYPE
+ +
"']/nmwg:metadata[@id=$metadataId])
> 0) then \n"
+ + " update insert <nmwg:parameters
id='control-parameters'><nmwg:parameter name='{$paramName}'
value='{$paramValue}'/></nmwg:parameters> into
/nmwg:store[@type='"
+ + LS_STORE_CONTROL_COLLECTION_TYPE
+ +
"']/nmwg:metadata[@id=$metadataId]
\n"
+ + " else "
+ + " update insert <nmwg:metadata
id='{$metadataId}'><nmwg:parameters id='control-parameters'><nmwg:parameter
name='{$paramName}' value='{$paramValue}'/></nmwg:parameters></nmwg:metadata>
into
/nmwg:store[@type='"
+ + LS_STORE_CONTROL_COLLECTION_TYPE + "'] \n" +

- "let $metadata :=
/nmwg:store[@type='"
- + LS_STORE_CONTROL_COLLECTION_TYPE
- +
"']/nmwg:metadata[@id=$metadataId]\n"
- + "let $parameters := \n"
- + " $metadata/nmwg:parameters\n"
- + "let $parameter := \n"
- + "
$parameters/nmwg:parameter[@name=$paramName]\n"
- +
+ "return $command \n";

- "let $o := \n"
- + " if (count($parameter) > 0) \n"
- + " then if ((count($parameters/child::*) -
count($parameter)) = 0)\n"
- + " then if (count($metadata/child::*) = 1) \n"
- + " then $metadata\n"
- + " else $parameters\n"
- + " else $parameter\n" + " else ()\n" +
+ // put
+ getDataStorage().performXQuery(xquery, getDataCollection(),
+ getDataCredential());

- "for $i in $o return update delete $i\n";
+ } // set parameter

- // remove
- getDataStorage().performXQuery(xquery, getDataCollection(),
- getDataCredential());
+ public void removeControlParameter(String metadataId, String
parameter)
+ throws PerfSONARException {
+ String xquery = DECLARE_NMWG_NAMESPACE
+ +

- }
+ "let $paramName := '"
+ + parameter
+ + "'\n"
+ + "let $metadataId := '"
+ + metadataId
+ + "'\n"
+ +

- protected String getRemoveLookupInfoXQueryPart(String metadataId) {
- return
- // a set of ()
- "("
- +
- // metadata from "+LS_STORE_CONTROL_COLLECTION_TYPE+"
-
"/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE
- +
"']/nmwg:metadata[@id='"
+ metadataId + "']"
- + ", "
- +
- // metadata from "+LS_STORE_COLLECTION_TYPE+"
-
"/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE
- +
"']/nmwg:metadata[@id='"
+ metadataId + "']" + ", "
- +
- // data from "+LS_STORE_COLLECTION_TYPE+"
-
"/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE
- +
"']/nmwg:data[@metadataIdRef='"
+ metadataId + "']" + ")";
- }
+ "let $metadata :=
/nmwg:store[@type='"
+ + LS_STORE_CONTROL_COLLECTION_TYPE
+ +
"']/nmwg:metadata[@id=$metadataId]\n"
+ + "let $parameters := \n"
+ + " $metadata/nmwg:parameters\n"
+ + "let $parameter := \n"
+ + "
$parameters/nmwg:parameter[@name=$paramName]\n"
+ +

+ "let $o := \n"
+ + " if (count($parameter) > 0) \n"
+ + " then if ((count($parameters/child::*)
- count($parameter)) = 0)\n"
+ + " then if
(count($metadata/child::*) = 1) \n"
+ + " then $metadata\n"
+ + " else $parameters\n"
+ + " else $parameter\n" + " else
()\n" +
+
+ "for $i in $o return update delete $i\n";
+
+ // remove
+ getDataStorage().performXQuery(xquery, getDataCollection(),
+ getDataCredential());
+
+ }
+
+ protected String getRemoveLookupInfoXQueryPart(String metadataId) {
+ return
+ // a set of ()
+ "("
+ +
+ // metadata from
"+LS_STORE_CONTROL_COLLECTION_TYPE+"
+
"/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE
+ +
"']/nmwg:metadata[@id='"
+ metadataId + "']"
+ + ", "
+ +
+ // metadata from "+LS_STORE_COLLECTION_TYPE+"
+
"/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE
+ +
"']/nmwg:metadata[@id='"
+ metadataId + "']" + ", "
+ +
+ // data from "+LS_STORE_COLLECTION_TYPE+"
+
"/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE
+ +
"']/nmwg:data[@metadataIdRef='"
+ metadataId + "']" + ")";
+ }
+
+// public void removeSummaryData() throws PerfSONARException {
+//
+// StringBuffer sb = new StringBuffer();
+//
+// sb.append(XQUERY_DECLARE_NAMESPACES);
+// sb.append("update delete
/nmwg:store[@type='LSStore-summary']/nmwg:metadata");
+//
+// getDataStorage().performXQuery(sb.toString(),
getDataCollection(),
+// getDataCredential());
+//
+// }
+//
+// public void putSummaryData(Metadata m) throws PerfSONARException {
+// ElementSerializer ser = new ElementSerializer();
+// ser.setStartingDocumentDeclaration(false);
+// StringBuffer xmls = new StringBuffer();
+// StringBufferOutputStream os = new
StringBufferOutputStream(xmls);
+//
+// // add xquery namespaces and UPDATE instruction
+// xmls.append(XQUERY_DECLARE_NAMESPACES);
+// xmls.append(UPDATE_INSERT);
+// xmls.append(" (\n"); // IMPORTANT - begin Xquery collection
(m, d, d,
+// // ...)
+//
+// try {
+//
+// // add metadata to StringBuffer
+// ser.write(os, m);
+//
+// } catch (Exception e) {
+// throw new PerfSONARException("error/parse",
+// "Cannot serialize elements in
XQueryExistDAOImpl");
+// }
+// // send XQuery
+// xmls.append(" )\n"); // IMPORTANT - end of Xquery collection
(m, d, d,
+// // ...)
+// xmls.append(UPDATE_INTO);
+// xmls.append(UPDATE_LSSTORE_SUMMARY);
+//
+// String query = xmls.toString();
+// getDataStorage().performXQuery(query, getDataCollection(),
+// getDataCredential());
+// }
+
} // SingleFileExistHttpDAOImpl



  • perfsonar: r5273 - in branches/new-structure-with-base2/ps-mdm-ls: ant conf src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/registration src/main/java/org/perfsonar/service/lookupservice/registration/summarization src/main/java/org/perfsonar/service/lookupservice/storage src/main/java/org/perfsonar/service/lookupservice/storage/exist, svnlog, 09/01/2009

Archive powered by MHonArc 2.6.16.

Top of Page