Revision 45309
Added by Claudio Atzori over 7 years ago
modules/dnet-actionmanager-common/releases/1.0.3/src/test/resources/eu/dnetlib/actionmanager/test/applicationContext-actionmanager-test.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<beans xmlns="http://www.springframework.org/schema/beans" |
|
3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" |
|
4 |
xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing" |
|
5 |
xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration" |
|
6 |
xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template" |
|
7 |
xmlns:util="http://www.springframework.org/schema/util" |
|
8 |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd |
|
9 |
http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd |
|
10 |
http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd |
|
11 |
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd |
|
12 |
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd |
|
13 |
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd |
|
14 |
http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd"> |
|
15 |
|
|
16 |
<bean id="hbaseActionManagerCore" class="eu.dnetlib.actionmanager.hbase.HBaseActionManagerCore" |
|
17 |
p:actionFactory-ref="actionFactory" |
|
18 |
p:hbaseClient-ref="hbaseClient" /> |
|
19 |
|
|
20 |
<bean id="hbaseClient" class="eu.dnetlib.actionmanager.hbase.HBaseClient" |
|
21 |
p:tableName="db_actions_michele" |
|
22 |
p:hbaseConf="${services.data.hbase.dm.properties}" |
|
23 |
init-method="initWithEmptyTable" /> |
|
24 |
<!-- p:hbaseConf="classpath:/eu/dnetlib/actionmanager/test/hbase.properties" --> |
|
25 |
|
|
26 |
<bean id="actionFactory" class="eu.dnetlib.actionmanager.actions.ActionFactory"> |
|
27 |
<property name="xslts"> |
|
28 |
<util:map> |
|
29 |
<entry key="dmf2actions" value="classpath:/eu/dnetlib/actionmanager/xslt/dmf2actions.xslt" /> |
|
30 |
</util:map> |
|
31 |
</property> |
|
32 |
</bean> |
|
33 |
|
|
34 |
|
|
35 |
</beans> |
modules/dnet-actionmanager-common/releases/1.0.3/src/test/resources/eu/dnetlib/actionmanager/test/hbase.properties | ||
---|---|---|
1 |
#COMMON |
|
2 |
hadoop.entry.node = node1.hadoop.research-infrastructures.eu |
|
3 |
|
|
4 |
#CORE-SITE |
|
5 |
fs.defaultFS = hdfs://${hadoop.entry.node}:8020 |
|
6 |
io.file.buffer.size = 65536 |
|
7 |
io.compression.codecs = org.apache.hadoop.io.compress.DefaultCodec,org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.BZip2Codec,org.apache.hadoop.io.compress.DeflateCodec,org.apache.hadoop.io.compress.SnappyCodec |
|
8 |
hadoop.security.authentication = simple |
|
9 |
hadoop.security.auth_to_local = DEFAULT |
|
10 |
|
|
11 |
#HBASE-SITE |
|
12 |
hbase.rootdir = ${fs.defaultFS}/hbase |
|
13 |
hbase.client.write.buffer = 2097152 |
|
14 |
hbase.client.pause = 1000 |
|
15 |
hbase.client.retries.number = 10 |
|
16 |
hbase.client.scanner.caching = 1 |
|
17 |
hbase.client.keyvalue.maxsize = 10485760 |
|
18 |
hbase.security.authentication = simple |
|
19 |
zookeeper.session.timeout = 60000 |
|
20 |
zookeeper.znode.parent = /hbase |
|
21 |
zookeeper.znode.rootserver = root-region-server |
|
22 |
hbase.zookeeper.quorum = ${hadoop.entry.node} |
|
23 |
hbase.zookeeper.property.clientPort = 2182 |
|
24 |
|
|
25 |
#HDFS-SITE |
|
26 |
dfs.https.port = 50470 |
|
27 |
dfs.namenode.https-address = ${hadoop.entry.node}:${dfs.https.port} |
|
28 |
dfs.namenode.http-address = ${hadoop.entry.node}:50070 |
|
29 |
dfs.replication = 3 |
|
30 |
dfs.blocksize = 134217728 |
|
31 |
dfs.client.use.datanode.hostname= false |
|
32 |
|
|
33 |
#MAPRED-SITE |
|
34 |
mapreduce.jobtracker.address = ${hadoop.entry.node}:8021 |
|
35 |
mapred.job.tracker = ${hadoop.entry.node}:8021 |
|
36 |
mapred.mapper.new-api = true |
|
37 |
mapred.reducer.new-api = true |
|
38 |
mapred.output.compress = false |
|
39 |
mapred.output.compression.type = BLOCK |
|
40 |
mapred.output.compression.codec = org.apache.hadoop.io.compress.DefaultCodec |
|
41 |
#mapred.map.output.compression.codec = org.apache.hadoop.io.compress.SnappyCodec |
|
42 |
mapred.compress.map.output = true |
|
43 |
#io.sort.factor = 64 |
|
44 |
#io.sort.record.percent = 0.05 |
|
45 |
#io.sort.spill.percent = 0.8 |
|
46 |
#mapred.reduce.parallel.copies = 10 |
|
47 |
#mapred.submit.replication = 1 |
|
48 |
#mapred.reduce.tasks = 8 |
|
49 |
#io.sort.mb = 56 |
|
50 |
#mapred.child.java.opts = -Xmx238449165 |
|
51 |
#mapred.job.reuse.jvm.num.tasks = 1 |
|
52 |
#mapred.map.tasks = 6 |
|
53 |
#mapred.map.tasks.speculative.execution = false |
|
54 |
#mapred.reduce.tasks.speculative.execution = false |
|
55 |
#mapred.reduce.slowstart.completed.maps = 0.8 |
|
56 |
##mapred.local.dir = /data/mapred/local,/data/mapred/jt |
|
57 |
mapred.local.dir = /tmp |
|
58 |
mapred.child.java.opts = -Xmx512973352 |
|
59 |
|
|
60 |
#dfs.client.use.legacy.blockreader=true |
|
61 |
|
modules/dnet-actionmanager-common/releases/1.0.3/src/test/resources/eu/dnetlib/actionmanager/test/record.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<record xmlns="http://www.driver-repository.eu/" xmlns:dc="http://purl.org/dc/elements/1.1/" |
|
3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
4 |
xmlns:dr="http://www.driver-repository.eu/namespace/dr" |
|
5 |
xmlns:dri="http://www.driver-repository.eu/namespace/dri"> |
|
6 |
<header> |
|
7 |
<dri:objIdentifier>b91fdb84-1030-49d9-b398-813ab7cae968_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=::4d4life.eu/2009_Presentation_29301_!W__!V_1</dri:objIdentifier> |
|
8 |
<dri:recordIdentifier>7ce67201-b143-4ba8-aeaf-32f218778733_TURTdG9yZURTUmVzb3VyY2VzL01EU3RvcmVEU1Jlc291cmNlVHlwZQ==::4d4life.eu/2009_Presentation_29301_!W__!V_1</dri:recordIdentifier> |
|
9 |
<dri:dateOfCollection>2013-02-10T14:33:11Z</dri:dateOfCollection> |
|
10 |
<dri:mdFormat/> |
|
11 |
<dri:mdFormatInterpretation/> |
|
12 |
<dri:repositoryId>b91fdb84-1030-49d9-b398-813ab7cae968_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=</dri:repositoryId> |
|
13 |
<dr:objectIdentifier>b91fdb84-1030-49d9-b398-813ab7cae968_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=::4d4life.eu/2009_Presentation_29301_!W__!V_1</dr:objectIdentifier> |
|
14 |
<dr:dateOfCollection>2013-02-10T14:33:11Z</dr:dateOfCollection> |
|
15 |
</header> |
|
16 |
<metadata> |
|
17 |
<dr:CobjContentSynthesis/> |
|
18 |
<dr:CobjTypology>Textual</dr:CobjTypology> |
|
19 |
<dr:CobjModel>OAI</dr:CobjModel> |
|
20 |
<dr:CobjMDFormats>oai_dc</dr:CobjMDFormats> |
|
21 |
<dr:CobjDescriptionSynthesis/> |
|
22 |
<dr:aggregatorName>DRIVER</dr:aggregatorName> |
|
23 |
<dr:aggregatorInstitution>Bielefeld University Library</dr:aggregatorInstitution> |
|
24 |
<dr:repositoryName>BELIEF e-Infrastructure Digital Library</dr:repositoryName> |
|
25 |
<dr:repositoryLink>http://belief-dl.research-infrastructures.eu</dr:repositoryLink> |
|
26 |
<dr:repositoryCountry>IT</dr:repositoryCountry> |
|
27 |
<dr:repositoryInstitution>European Commission</dr:repositoryInstitution> |
|
28 |
<dc:creator>Frank Bisby, Frank</dc:creator> |
|
29 |
<dc:title>Distributed Dynamic Diversity Databases for Life (4D4Life)</dc:title> |
|
30 |
<dc:subject>Biology</dc:subject> |
|
31 |
<dc:subject>Natural Sciences</dc:subject> |
|
32 |
<dc:subject>Biodiversity</dc:subject> |
|
33 |
<dc:subject>Species Catalogue</dc:subject> |
|
34 |
<dr:CobjCategory>0000</dr:CobjCategory> |
|
35 |
<dc:language>eng</dc:language> |
|
36 |
<dc:dateAccepted/> |
|
37 |
<dc:identifier>http://belief-dl.research-infrastructures.eu/UIMain.jsp?handle=4d4life.eu/2009_Presentation_29301&view=&version=1</dc:identifier> |
|
38 |
<dc:publisher>4d4Life Project</dc:publisher> |
|
39 |
<dc:description>Brief presentation on the objectives of the D4DLife project. The |
|
40 |
presentation was provided in the data session of the 7th eConcertation Meeting in |
|
41 |
Brussels</dc:description> |
|
42 |
</metadata> |
|
43 |
</record> |
modules/dnet-actionmanager-common/releases/1.0.3/src/main/java/eu/dnetlib/actionmanager/actions/XsltInfoPackageAction.java | ||
---|---|---|
1 |
package eu.dnetlib.actionmanager.actions; |
|
2 |
|
|
3 |
import java.io.StringReader; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import javax.xml.transform.Transformer; |
|
7 |
import javax.xml.transform.TransformerException; |
|
8 |
|
|
9 |
import org.apache.commons.codec.binary.Base64; |
|
10 |
import org.apache.commons.logging.Log; |
|
11 |
import org.apache.commons.logging.LogFactory; |
|
12 |
import org.apache.hadoop.hbase.util.Bytes; |
|
13 |
import org.dom4j.Document; |
|
14 |
import org.dom4j.DocumentException; |
|
15 |
import org.dom4j.Element; |
|
16 |
import org.dom4j.io.DocumentResult; |
|
17 |
import org.dom4j.io.DocumentSource; |
|
18 |
import org.dom4j.io.SAXReader; |
|
19 |
|
|
20 |
import com.google.common.collect.Lists; |
|
21 |
|
|
22 |
import eu.dnetlib.actionmanager.ActionManagerConstants.ACTION_TYPE; |
|
23 |
import eu.dnetlib.actionmanager.common.Agent; |
|
24 |
import eu.dnetlib.actionmanager.common.Operation; |
|
25 |
import eu.dnetlib.actionmanager.common.Provenance; |
|
26 |
import eu.dnetlib.actionmanager.rmi.ActionManagerException; |
|
27 |
|
|
28 |
public class XsltInfoPackageAction extends AbstractMetaAction<String> { |
|
29 |
|
|
30 |
private final Transformer transformer; |
|
31 |
|
|
32 |
private static final Log log = LogFactory.getLog(XsltInfoPackageAction.class); // NOPMD by marko on 11/24/08 5:02 PM |
|
33 |
|
|
34 |
protected XsltInfoPackageAction(String set, Agent agent, Operation operation, String infoPackage, Transformer transformer, ActionFactory actionFactory) { |
|
35 |
super(set, agent, operation, infoPackage, actionFactory); |
|
36 |
this.transformer = transformer; |
|
37 |
} |
|
38 |
|
|
39 |
private Document applyXslt(String xml, Provenance provenance, String trust, String nsprefix) throws DocumentException, TransformerException { |
|
40 |
Document doc = new SAXReader().read(new StringReader(xml)); |
|
41 |
|
|
42 |
final DocumentResult result = new DocumentResult(); |
|
43 |
|
|
44 |
transformer.setParameter("trust", trust); |
|
45 |
transformer.setParameter("provenance", provenance.toString()); |
|
46 |
transformer.setParameter("namespaceprefix", nsprefix); |
|
47 |
|
|
48 |
transformer.transform(new DocumentSource(doc), result); |
|
49 |
|
|
50 |
// System.out.println(result.getDocument().asXML()); |
|
51 |
|
|
52 |
return result.getDocument(); |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
protected List<AtomicAction> calculateAtomicActions(Provenance provenance, String trust, String nsprefix) throws ActionManagerException { |
|
57 |
List<AtomicAction> list = Lists.newArrayList(); |
|
58 |
|
|
59 |
try { |
|
60 |
Document doc = applyXslt(getMetaContent(), provenance, trust, nsprefix); |
|
61 |
for (Object o : doc.selectNodes("//ACTION")) { |
|
62 |
list.add(createAtomicAction((Element) o)); |
|
63 |
} |
|
64 |
} catch (Exception e) { |
|
65 |
log.error("Error generating actions", e); |
|
66 |
throw new ActionManagerException(e); |
|
67 |
} |
|
68 |
|
|
69 |
return list; |
|
70 |
} |
|
71 |
|
|
72 |
private AtomicAction createAtomicAction(Element elem) { |
|
73 |
String key = elem.valueOf("./@targetKey"); |
|
74 |
String colFamily = elem.valueOf("./@targetColumnFamily"); |
|
75 |
String col = elem.valueOf("./@targetColumn"); |
|
76 |
String value64 = elem.getTextTrim(); |
|
77 |
byte[] value = value64.isEmpty() ? null : Base64.decodeBase64(value64); |
|
78 |
|
|
79 |
return getActionFactory().createAtomicAction(getSet(), getAgent(), key, colFamily, col, value); |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public boolean isValid() { |
|
84 |
// TODO Auto-generated method stub |
|
85 |
return true; |
|
86 |
} |
|
87 |
|
|
88 |
@Override |
|
89 |
public ACTION_TYPE getTypology() { |
|
90 |
return ACTION_TYPE.pkg; |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
protected byte[] getBytesContent(String content) { |
|
95 |
return Bytes.toBytes(content); |
|
96 |
} |
|
97 |
|
|
98 |
} |
modules/dnet-actionmanager-common/releases/1.0.3/src/main/java/eu/dnetlib/actionmanager/actions/AbstractAction.java | ||
---|---|---|
1 |
package eu.dnetlib.actionmanager.actions; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.UUID; |
|
5 |
|
|
6 |
import org.apache.hadoop.hbase.client.Put; |
|
7 |
|
|
8 |
import eu.dnetlib.actionmanager.ActionManagerConstants.ACTION_TYPE; |
|
9 |
import eu.dnetlib.actionmanager.common.Agent; |
|
10 |
import eu.dnetlib.actionmanager.common.Provenance; |
|
11 |
import eu.dnetlib.actionmanager.rmi.ActionManagerException; |
|
12 |
import eu.dnetlib.miscutils.functional.hash.Hashing; |
|
13 |
|
|
14 |
public abstract class AbstractAction implements Action { |
|
15 |
|
|
16 |
private String set; |
|
17 |
private String rowKey; |
|
18 |
private Agent agent; |
|
19 |
|
|
20 |
public AbstractAction(String set, Agent agent) { |
|
21 |
super(); |
|
22 |
this.set = set; |
|
23 |
this.agent = agent; |
|
24 |
this.rowKey = getTypology() + "|" + Hashing.md5(agent.getId()) + "|" + UUID.randomUUID(); |
|
25 |
} |
|
26 |
|
|
27 |
@Override |
|
28 |
abstract public List<Put> asPutOperations(String infoPackageId, Provenance provenance, String trust, String nsprefix) throws ActionManagerException; |
|
29 |
|
|
30 |
@Override |
|
31 |
abstract public boolean isValid(); |
|
32 |
|
|
33 |
@Override |
|
34 |
abstract public ACTION_TYPE getTypology(); |
|
35 |
|
|
36 |
public String getSet() { |
|
37 |
return set; |
|
38 |
} |
|
39 |
|
|
40 |
public void setSet(String set) { |
|
41 |
this.set = set; |
|
42 |
} |
|
43 |
|
|
44 |
public String getRowKey() { |
|
45 |
return rowKey; |
|
46 |
} |
|
47 |
|
|
48 |
public void setRowKey(String rowKey) { |
|
49 |
this.rowKey = rowKey; |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* @return the agent |
|
54 |
*/ |
|
55 |
public Agent getAgent() { |
|
56 |
return agent; |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* @param agent |
|
61 |
* the agent to set |
|
62 |
*/ |
|
63 |
public void setAgent(Agent agent) { |
|
64 |
this.agent = agent; |
|
65 |
} |
|
66 |
|
|
67 |
} |
modules/dnet-actionmanager-common/releases/1.0.3/src/main/java/eu/dnetlib/actionmanager/actions/ActionFactory.java | ||
---|---|---|
1 |
package eu.dnetlib.actionmanager.actions; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import javax.xml.transform.Transformer; |
|
7 |
import javax.xml.transform.TransformerFactory; |
|
8 |
|
|
9 |
import org.apache.hadoop.hbase.util.Bytes; |
|
10 |
import org.dom4j.Document; |
|
11 |
import org.dom4j.io.DocumentSource; |
|
12 |
import org.dom4j.io.SAXReader; |
|
13 |
import org.springframework.beans.factory.annotation.Required; |
|
14 |
import org.springframework.core.io.Resource; |
|
15 |
|
|
16 |
import com.google.common.collect.Lists; |
|
17 |
|
|
18 |
import eu.dnetlib.actionmanager.common.Agent; |
|
19 |
import eu.dnetlib.actionmanager.common.Operation; |
|
20 |
import eu.dnetlib.actionmanager.rmi.ActionManagerException; |
|
21 |
import eu.dnetlib.data.proto.RelTypeProtos.RelType; |
|
22 |
import eu.dnetlib.data.proto.TypeProtos.Type; |
|
23 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
24 |
|
|
25 |
/** |
|
26 |
* Factory bean to create Actions bypassing the Action Manager API |
|
27 |
* |
|
28 |
* @author michele |
|
29 |
*/ |
|
30 |
public class ActionFactory { |
|
31 |
|
|
32 |
private Map<String, Resource> xslts; |
|
33 |
|
|
34 |
final TransformerFactory tFactory = TransformerFactory.newInstance(); |
|
35 |
|
|
36 |
/** |
|
37 |
* Creates a list of AtomicAction(s) to handle an UPDATE. 1 body and 2 similarRel(s) |
|
38 |
* |
|
39 |
* @param set |
|
40 |
* the given set. |
|
41 |
* @param agent |
|
42 |
* the given agent. |
|
43 |
* @param originalId |
|
44 |
* main entity identifier to be updated (already existing in the information space). |
|
45 |
* @param updateId |
|
46 |
* new and unique identifier, must be the same used into "updateContent". |
|
47 |
* @param entityType |
|
48 |
* one of: result, person, project, datasource, organization |
|
49 |
* {@link eu.dnetlib.data.proto.TypeProtos.Type}. |
|
50 |
* @param updateContent |
|
51 |
* content to be updated over the original main entity. note that: the given trust level has to be [>.9 | |
|
52 |
* NEUTRAL | INFINITE] in order to gain visibility after the merging process. |
|
53 |
* @return the list of AtomicActions. |
|
54 |
*/ |
|
55 |
@Deprecated |
|
56 |
public List<AtomicAction> createUpdateActions(String set, Agent agent, String originalId, String updateId, Type entityType, byte[] updateContent) { |
|
57 |
List<AtomicAction> res = Lists.newArrayList(); |
|
58 |
|
|
59 |
if (originalId.equals(updateId)) { |
|
60 |
throw new IllegalArgumentException("originalId and updateId must be different"); |
|
61 |
} |
|
62 |
|
|
63 |
res.add(createAtomicAction(set, agent, updateId, entityType.toString(), "body", updateContent)); |
|
64 |
res.add(createAtomicAction(set, agent, updateId, RelType.similarRel.toString(), originalId, Bytes.toBytes(""))); |
|
65 |
res.add(createAtomicAction(set, agent, originalId, RelType.similarRel.toString(), updateId, Bytes.toBytes(""))); |
|
66 |
|
|
67 |
return res; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Creates a list of AtomicAction(s) to handle an UPDATE. Produces one Oaf, stored in CF = |
|
72 |
* [entity]:update_[timestamp] |
|
73 |
* |
|
74 |
* @param set |
|
75 |
* the given set. |
|
76 |
* @param agent |
|
77 |
* the given agent. |
|
78 |
* @param originalId |
|
79 |
* main entity identifier to be updated (already existing in the information space). |
|
80 |
* @param entityType |
|
81 |
* one of: result, person, project, datasource, organization |
|
82 |
* {@link eu.dnetlib.data.proto.TypeProtos.Type}. |
|
83 |
* @param updateContent |
|
84 |
* content to be updated over the original main entity. Oaf#OafEntity#[entity]#id must be consistent with |
|
85 |
* the originalId. note that: the given trust level has to be [>.9 | NEUTRAL | INFINITE] in order to gain |
|
86 |
* visibility after the merging process. |
|
87 |
* @return the list of AtomicActions. |
|
88 |
*/ |
|
89 |
public List<AtomicAction> createUpdateActions(String set, Agent agent, String originalId, Type entityType, byte[] updateContent) { |
|
90 |
List<AtomicAction> res = Lists.newArrayList(); |
|
91 |
|
|
92 |
res.add(createAtomicAction(set, agent, originalId, entityType.toString(), "update_" + DateUtils.now(), updateContent)); |
|
93 |
|
|
94 |
return res; |
|
95 |
} |
|
96 |
|
|
97 |
public AtomicAction createAtomicAction(String set, Agent agent, String targetKey, String targetColFamily, String targetCol, byte[] targetContent) { |
|
98 |
AtomicAction action = new AtomicAction(set, agent); |
|
99 |
|
|
100 |
action.setTargetRowKey(targetKey); |
|
101 |
action.setTargetColumnFamily(targetColFamily); |
|
102 |
action.setTargetColumn(targetCol); |
|
103 |
action.setTargetValue(targetContent); |
|
104 |
|
|
105 |
return action; |
|
106 |
} |
|
107 |
|
|
108 |
public XsltInfoPackageAction generateInfoPackageAction(String xsltResource, String set, Agent agent, Operation operation, String infoPackage) |
|
109 |
throws ActionManagerException { |
|
110 |
Transformer transformer = prepareXsltTransformer(xsltResource); |
|
111 |
return new XsltInfoPackageAction(set, agent, operation, infoPackage, transformer, this); |
|
112 |
} |
|
113 |
|
|
114 |
public Transformer prepareXsltTransformer(String xsltName) throws ActionManagerException { |
|
115 |
try { |
|
116 |
if (!xslts.containsKey(xsltName)) { |
|
117 |
throw new ActionManagerException("XSLT " + xsltName + " not found"); |
|
118 |
} |
|
119 |
|
|
120 |
final Document doc = new SAXReader().read(xslts.get(xsltName).getInputStream()); |
|
121 |
return tFactory.newTransformer(new DocumentSource(doc)); |
|
122 |
} catch (Exception e) { |
|
123 |
throw new ActionManagerException("Problem with xslt resource " + xsltName, e); |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 |
public Map<String, Resource> getXslts() { |
|
128 |
return xslts; |
|
129 |
} |
|
130 |
|
|
131 |
@Required |
|
132 |
public void setXslts(Map<String, Resource> xslts) { |
|
133 |
this.xslts = xslts; |
|
134 |
} |
|
135 |
|
|
136 |
} |
modules/dnet-actionmanager-common/releases/1.0.3/src/main/java/eu/dnetlib/actionmanager/actions/AbstractMetaAction.java | ||
---|---|---|
1 |
package eu.dnetlib.actionmanager.actions; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.apache.hadoop.hbase.client.Put; |
|
6 |
import org.apache.hadoop.hbase.util.Bytes; |
|
7 |
|
|
8 |
import com.google.common.collect.Lists; |
|
9 |
|
|
10 |
import eu.dnetlib.actionmanager.ActionManagerConstants; |
|
11 |
import eu.dnetlib.actionmanager.common.Agent; |
|
12 |
import eu.dnetlib.actionmanager.common.Operation; |
|
13 |
import eu.dnetlib.actionmanager.common.Provenance; |
|
14 |
import eu.dnetlib.actionmanager.hbase.HBasePutFactory; |
|
15 |
import eu.dnetlib.actionmanager.rmi.ActionManagerException; |
|
16 |
|
|
17 |
abstract public class AbstractMetaAction<T> extends AbstractAction { |
|
18 |
|
|
19 |
private Operation operation; |
|
20 |
|
|
21 |
private T metaContent; |
|
22 |
|
|
23 |
private ActionFactory actionFactory; |
|
24 |
|
|
25 |
public AbstractMetaAction(String set, Agent agent, Operation operation, T metaContent, ActionFactory actionFactory) { |
|
26 |
super(set, agent); |
|
27 |
this.setOperation(operation); |
|
28 |
this.metaContent = metaContent; |
|
29 |
this.setActionFactory(actionFactory); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public List<Put> asPutOperations(String parentId, Provenance provenance, String trust, String nsprefix) throws ActionManagerException { |
|
34 |
List<Put> puts = Lists.newArrayList(); |
|
35 |
List<String> partIds = Lists.newArrayList(); |
|
36 |
|
|
37 |
for (AtomicAction action : calculateAtomicActions(provenance, trust, nsprefix)) { |
|
38 |
if (action != null && action.isValid()) { |
|
39 |
puts.addAll(action.asPutOperations(getRowKey(), provenance, trust, nsprefix)); |
|
40 |
partIds.add(action.getRowKey()); |
|
41 |
} |
|
42 |
} |
|
43 |
puts.add(prepareMetaPut(partIds)); |
|
44 |
|
|
45 |
return puts; |
|
46 |
} |
|
47 |
|
|
48 |
private Put prepareMetaPut(List<String> partIds) { |
|
49 |
final Put put = HBasePutFactory.createPutOperation(getRowKey(), getSet(), getAgent()); |
|
50 |
|
|
51 |
put.add(ActionManagerConstants.OPERATION_COLFAMILY, Bytes.toBytes(getOperation().toString()), Bytes.toBytes(getOperation().toString())); |
|
52 |
put.add(ActionManagerConstants.ACTION_COLFAMILY, Bytes.toBytes(getTypology().toString()), getBytesContent(metaContent)); |
|
53 |
|
|
54 |
for (String id : partIds) { |
|
55 |
put.add(ActionManagerConstants.RELATION_COLFAMILY, Bytes.toBytes(id), ActionManagerConstants.HASPARTS); |
|
56 |
} |
|
57 |
return put; |
|
58 |
} |
|
59 |
|
|
60 |
abstract protected List<AtomicAction> calculateAtomicActions(Provenance provenance, String trust, String nsprefix) throws ActionManagerException; |
|
61 |
|
|
62 |
abstract protected byte[] getBytesContent(T content); |
|
63 |
|
|
64 |
public Operation getOperation() { |
|
65 |
return operation; |
|
66 |
} |
|
67 |
|
|
68 |
public void setOperation(Operation operation) { |
|
69 |
this.operation = operation; |
|
70 |
} |
|
71 |
|
|
72 |
public T getMetaContent() { |
|
73 |
return metaContent; |
|
74 |
} |
|
75 |
|
|
76 |
public void setMetaContent(T metaContent) { |
|
77 |
this.metaContent = metaContent; |
|
78 |
} |
|
79 |
|
|
80 |
public ActionFactory getActionFactory() { |
|
81 |
return actionFactory; |
|
82 |
} |
|
83 |
|
|
84 |
public void setActionFactory(ActionFactory actionFactory) { |
|
85 |
this.actionFactory = actionFactory; |
|
86 |
} |
|
87 |
|
|
88 |
} |
modules/dnet-actionmanager-common/releases/1.0.3/src/main/java/eu/dnetlib/actionmanager/actions/AtomicAction.java | ||
---|---|---|
1 |
package eu.dnetlib.actionmanager.actions; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.apache.hadoop.hbase.client.Put; |
|
6 |
import org.apache.hadoop.hbase.util.Bytes; |
|
7 |
|
|
8 |
import com.google.common.collect.Lists; |
|
9 |
|
|
10 |
import eu.dnetlib.actionmanager.ActionManagerConstants; |
|
11 |
import eu.dnetlib.actionmanager.ActionManagerConstants.ACTION_TYPE; |
|
12 |
import eu.dnetlib.actionmanager.common.Agent; |
|
13 |
import eu.dnetlib.actionmanager.common.Operation; |
|
14 |
import eu.dnetlib.actionmanager.common.Provenance; |
|
15 |
import eu.dnetlib.actionmanager.hbase.HBasePutFactory; |
|
16 |
|
|
17 |
public class AtomicAction extends AbstractAction { |
|
18 |
|
|
19 |
private String targetRowKey; |
|
20 |
private String targetColumnFamily; |
|
21 |
private String targetColumn; |
|
22 |
|
|
23 |
private byte[] targetValue; |
|
24 |
|
|
25 |
public AtomicAction(String set, Agent agent) { |
|
26 |
super(set, agent); |
|
27 |
} |
|
28 |
|
|
29 |
public AtomicAction(String set, Agent agent, Operation operation, String targetRowKey, String targetColumnFamily, String targetColumn, |
|
30 |
byte[] targetValue) { |
|
31 |
this(set, agent); |
|
32 |
this.targetRowKey = targetRowKey; |
|
33 |
this.targetColumnFamily = targetColumnFamily; |
|
34 |
this.targetColumn = targetColumn; |
|
35 |
this.targetValue = targetValue; |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public List<Put> asPutOperations(String parentId, Provenance provenance, String trust, String nsprefix) { |
|
40 |
final Put put = HBasePutFactory.createPutOperation(getRowKey(), getSet(), getAgent()); |
|
41 |
|
|
42 |
put.add(ActionManagerConstants.SET_COLFAMILY, Bytes.toBytes(getSet()), Bytes.toBytes(getSet())); |
|
43 |
put.add(ActionManagerConstants.TARGET_COLFAMILY, ActionManagerConstants.TARGET_KEY_COL, Bytes.toBytes(targetRowKey)); |
|
44 |
put.add(ActionManagerConstants.TARGET_COLFAMILY, ActionManagerConstants.TARGET_COLFAMILY_COL, Bytes.toBytes(targetColumnFamily)); |
|
45 |
put.add(ActionManagerConstants.TARGET_COLFAMILY, ActionManagerConstants.TARGET_COL_COL, Bytes.toBytes(targetColumn)); |
|
46 |
put.add(ActionManagerConstants.TARGET_COLFAMILY, ActionManagerConstants.TARGET_OAF_COL, targetValue); |
|
47 |
|
|
48 |
if (parentId != null && !parentId.isEmpty()) { |
|
49 |
put.add(ActionManagerConstants.RELATION_COLFAMILY, Bytes.toBytes(parentId), ActionManagerConstants.ISPARTOF); |
|
50 |
} |
|
51 |
|
|
52 |
return Lists.newArrayList(put); |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
public ACTION_TYPE getTypology() { |
|
57 |
return ACTION_TYPE.aac; |
|
58 |
} |
|
59 |
|
|
60 |
public String getTargetRowKey() { |
|
61 |
return targetRowKey; |
|
62 |
} |
|
63 |
|
|
64 |
public void setTargetRowKey(String targetRowKey) { |
|
65 |
this.targetRowKey = targetRowKey; |
|
66 |
} |
|
67 |
|
|
68 |
public String getTargetColumnFamily() { |
|
69 |
return targetColumnFamily; |
|
70 |
} |
|
71 |
|
|
72 |
public void setTargetColumnFamily(String targetColumnFamily) { |
|
73 |
this.targetColumnFamily = targetColumnFamily; |
|
74 |
} |
|
75 |
|
|
76 |
public String getTargetColumn() { |
|
77 |
return targetColumn; |
|
78 |
} |
|
79 |
|
|
80 |
public void setTargetColumn(String targetColumn) { |
|
81 |
this.targetColumn = targetColumn; |
|
82 |
} |
|
83 |
|
|
84 |
public byte[] getTargetValue() { |
|
85 |
return targetValue; |
|
86 |
} |
|
87 |
|
|
88 |
public void setTargetValue(byte[] targetValue) { |
|
89 |
this.targetValue = targetValue; |
|
90 |
} |
|
91 |
|
|
92 |
@Override |
|
93 |
public boolean isValid() { |
|
94 |
return (getRowKey() != null && !getRowKey().isEmpty() && getSet() != null && !getSet().isEmpty() && targetRowKey != null |
|
95 |
&& !targetRowKey.isEmpty() && targetColumnFamily != null && !targetColumnFamily.isEmpty() && targetColumn != null |
|
96 |
&& !targetColumn.isEmpty() && targetValue != null && targetValue.length > 0); |
|
97 |
} |
|
98 |
|
|
99 |
} |
modules/dnet-actionmanager-common/releases/1.0.3/src/main/java/eu/dnetlib/actionmanager/actions/Action.java | ||
---|---|---|
1 |
package eu.dnetlib.actionmanager.actions; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.apache.hadoop.hbase.client.Put; |
|
6 |
|
|
7 |
import eu.dnetlib.actionmanager.ActionManagerConstants.ACTION_TYPE; |
|
8 |
import eu.dnetlib.actionmanager.common.Provenance; |
|
9 |
import eu.dnetlib.actionmanager.rmi.ActionManagerException; |
|
10 |
|
|
11 |
public interface Action { |
|
12 |
|
|
13 |
ACTION_TYPE getTypology(); |
|
14 |
|
|
15 |
List<Put> asPutOperations(String parentId, Provenance provenance, String trust, String nsprefix) throws ActionManagerException; |
|
16 |
|
|
17 |
boolean isValid(); |
|
18 |
|
|
19 |
} |
modules/dnet-actionmanager-common/releases/1.0.3/src/main/java/eu/dnetlib/actionmanager/hbase/HBasePutFactory.java | ||
---|---|---|
1 |
package eu.dnetlib.actionmanager.hbase; |
|
2 |
|
|
3 |
import org.apache.hadoop.hbase.client.Put; |
|
4 |
import org.apache.hadoop.hbase.util.Bytes; |
|
5 |
|
|
6 |
import eu.dnetlib.actionmanager.ActionManagerConstants; |
|
7 |
import eu.dnetlib.actionmanager.common.Agent; |
|
8 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
9 |
|
|
10 |
public class HBasePutFactory { |
|
11 |
public static Put createPutOperation(String key, String set, Agent agent) { |
|
12 |
final long date = DateUtils.now(); |
|
13 |
final String dateS = DateUtils.calculate_ISO8601(date); |
|
14 |
final Put put = new Put(Bytes.toBytes(key)); |
|
15 |
put.add(ActionManagerConstants.SET_COLFAMILY, Bytes.toBytes(set), Bytes.toBytes(set)); |
|
16 |
put.add(ActionManagerConstants.DATE_COLFAMILY, Bytes.toBytes(Long.toString(date)), Bytes.toBytes(dateS)); |
|
17 |
|
|
18 |
put.add(ActionManagerConstants.AGENT_COLFAMILY, ActionManagerConstants.AGENT_ID_COL, Bytes.toBytes(agent.getId())); |
|
19 |
put.add(ActionManagerConstants.AGENT_COLFAMILY, ActionManagerConstants.AGENT_NAME_COL, Bytes.toBytes(agent.getName())); |
|
20 |
put.add(ActionManagerConstants.AGENT_COLFAMILY, ActionManagerConstants.AGENT_TYPE_COL, Bytes.toBytes(agent.getType().toString())); |
|
21 |
return put; |
|
22 |
} |
|
23 |
} |
modules/dnet-actionmanager-common/releases/1.0.3/src/main/java/eu/dnetlib/actionmanager/ActionManagerConstants.java | ||
---|---|---|
1 |
package eu.dnetlib.actionmanager; |
|
2 |
|
|
3 |
import org.apache.hadoop.hbase.util.Bytes; |
|
4 |
|
|
5 |
public class ActionManagerConstants { |
|
6 |
|
|
7 |
public static enum COLUMN_FAMILIES { |
|
8 |
action, rel, status, set, target, operation, date, agent |
|
9 |
} |
|
10 |
|
|
11 |
public static enum ACTION_TYPE { |
|
12 |
aac, //atomicAction, |
|
13 |
pkg, //infoPackage, |
|
14 |
all //all |
|
15 |
} |
|
16 |
|
|
17 |
public static final byte[] ACTION_COLFAMILY = Bytes.toBytes(COLUMN_FAMILIES.action.toString()); |
|
18 |
public static final byte[] RELATION_COLFAMILY = Bytes.toBytes(COLUMN_FAMILIES.rel.toString()); |
|
19 |
public static final byte[] STATUS_COLFAMILY = Bytes.toBytes(COLUMN_FAMILIES.status.toString()); |
|
20 |
public static final byte[] SET_COLFAMILY = Bytes.toBytes(COLUMN_FAMILIES.set.toString()); |
|
21 |
public static final byte[] TARGET_COLFAMILY = Bytes.toBytes(COLUMN_FAMILIES.target.toString()); |
|
22 |
public static final byte[] OPERATION_COLFAMILY = Bytes.toBytes(COLUMN_FAMILIES.operation.toString()); |
|
23 |
public static final byte[] DATE_COLFAMILY = Bytes.toBytes(COLUMN_FAMILIES.date.toString()); |
|
24 |
public static final byte[] AGENT_COLFAMILY = Bytes.toBytes(COLUMN_FAMILIES.agent.toString()); |
|
25 |
|
|
26 |
public static final byte[] OPERATION_COL = Bytes.toBytes("operation"); |
|
27 |
public static final byte[] TARGET_KEY_COL = Bytes.toBytes("rowKey"); |
|
28 |
public static final byte[] TARGET_COLFAMILY_COL = Bytes.toBytes("columnFamily"); |
|
29 |
public static final byte[] TARGET_COL_COL = Bytes.toBytes("column"); |
|
30 |
public static final byte[] TARGET_OAF_COL = Bytes.toBytes("content"); |
|
31 |
public static final byte[] HASPARTS = Bytes.toBytes("hasParts"); |
|
32 |
public static final byte[] ISPARTOF = Bytes.toBytes("isPartOf"); |
|
33 |
|
|
34 |
public static final byte[] AGENT_ID_COL = Bytes.toBytes("id"); |
|
35 |
public static final byte[] AGENT_NAME_COL = Bytes.toBytes("name"); |
|
36 |
public static final byte[] AGENT_TYPE_COL = Bytes.toBytes("type"); |
|
37 |
|
|
38 |
} |
modules/dnet-actionmanager-common/releases/1.0.3/.springBeans | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<beansProjectDescription> |
|
3 |
<version>1</version> |
|
4 |
<pluginVersion><![CDATA[3.1.0.201210040510-RELEASE]]></pluginVersion> |
|
5 |
<configSuffixes> |
|
6 |
<configSuffix><![CDATA[xml]]></configSuffix> |
|
7 |
</configSuffixes> |
|
8 |
<enableImports><![CDATA[false]]></enableImports> |
|
9 |
<configs> |
|
10 |
<config>src/main/resources/eu/dnetlib/actionmanager/hack/applicationContext-claimed-import.xml</config> |
|
11 |
</configs> |
|
12 |
<configSets> |
|
13 |
</configSets> |
|
14 |
</beansProjectDescription> |
modules/dnet-actionmanager-common/releases/1.0.3/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
3 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
4 |
<parent> |
|
5 |
<groupId>eu.dnetlib</groupId> |
|
6 |
<artifactId>dnet-parent</artifactId> |
|
7 |
<version>0.0.1-alpha</version> |
|
8 |
</parent> |
|
9 |
<modelVersion>4.0.0</modelVersion> |
|
10 |
<groupId>eu.dnetlib</groupId> |
|
11 |
<artifactId>dnet-actionmanager-common</artifactId> |
|
12 |
<packaging>jar</packaging> |
|
13 |
<version>1.0.3</version> |
|
14 |
<repositories> |
|
15 |
<!-- Cloudera Repositories --> |
|
16 |
<repository> |
|
17 |
<snapshots> |
|
18 |
<enabled>false</enabled> |
|
19 |
</snapshots> |
|
20 |
<id>cloudera-central</id> |
|
21 |
<name>cloundera-libs-release</name> |
|
22 |
<url>http://maven.research-infrastructures.eu/nexus/content/repositories/cloudera-central</url> |
|
23 |
</repository> |
|
24 |
<repository> |
|
25 |
<id>cloudera-snapshots</id> |
|
26 |
<name>cloudera-libs-snapshot</name> |
|
27 |
<url>http://maven.research-infrastructures.eu/nexus/content/repositories/cloudera-snapshots</url> |
|
28 |
</repository> |
|
29 |
</repositories> |
|
30 |
<dependencies> |
|
31 |
<dependency> |
|
32 |
<groupId>eu.dnetlib</groupId> |
|
33 |
<artifactId>dnet-openaireplus-mapping-utils</artifactId> |
|
34 |
<version>[0.2.0]</version> |
|
35 |
</dependency> |
|
36 |
<dependency> |
|
37 |
<groupId>eu.dnetlib</groupId> |
|
38 |
<artifactId>dnet-actionmanager-api</artifactId> |
|
39 |
<version>[1.0]</version> |
|
40 |
</dependency> |
|
41 |
<dependency> |
|
42 |
<groupId>org.apache.hadoop</groupId> |
|
43 |
<artifactId>hadoop-common</artifactId> |
|
44 |
<version>${hadoop.common.version}</version> |
|
45 |
</dependency> |
|
46 |
<dependency> |
|
47 |
<groupId>org.apache.hbase</groupId> |
|
48 |
<artifactId>hbase</artifactId> |
|
49 |
<version>${apache.hbase.version}</version> |
|
50 |
<exclusions> |
|
51 |
<exclusion> |
|
52 |
<groupId>tomcat</groupId> |
|
53 |
<artifactId>jasper-runtime</artifactId> |
|
54 |
</exclusion> |
|
55 |
<exclusion> |
|
56 |
<groupId>tomcat</groupId> |
|
57 |
<artifactId>jasper-compiler</artifactId> |
|
58 |
</exclusion> |
|
59 |
<exclusion> |
|
60 |
<artifactId>slf4j-api</artifactId> |
|
61 |
<groupId>org.slf4j</groupId> |
|
62 |
</exclusion> |
|
63 |
<exclusion> |
|
64 |
<artifactId>slf4j-log4j12</artifactId> |
|
65 |
<groupId>org.slf4j</groupId> |
|
66 |
</exclusion> |
|
67 |
<exclusion> |
|
68 |
<artifactId>commons-lang</artifactId> |
|
69 |
<groupId>commons-lang</groupId> |
|
70 |
</exclusion> |
|
71 |
<exclusion> |
|
72 |
<artifactId>commons-httpclient</artifactId> |
|
73 |
<groupId>commons-httpclient</groupId> |
|
74 |
</exclusion> |
|
75 |
<exclusion> |
|
76 |
<artifactId>httpclient</artifactId> |
|
77 |
<groupId>org.apache.httpcomponents</groupId> |
|
78 |
</exclusion> |
|
79 |
<exclusion> |
|
80 |
<artifactId>httpcore</artifactId> |
|
81 |
<groupId>org.apache.httpcomponents</groupId> |
|
82 |
</exclusion> |
|
83 |
</exclusions> |
|
84 |
</dependency> |
|
85 |
<dependency> |
|
86 |
<groupId>junit</groupId> |
|
87 |
<artifactId>junit</artifactId> |
|
88 |
<version>${junit.version}</version> |
|
89 |
<scope>test</scope> |
|
90 |
</dependency> |
|
91 |
</dependencies> |
|
92 |
</project> |
modules/dnet-actionmanager-common/releases/1.0.1/src/test/resources/eu/dnetlib/actionmanager/test/applicationContext-actionmanager-test.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<beans xmlns="http://www.springframework.org/schema/beans" |
|
3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" |
|
4 |
xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing" |
|
5 |
xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration" |
|
6 |
xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template" |
|
7 |
xmlns:util="http://www.springframework.org/schema/util" |
|
8 |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd |
|
9 |
http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd |
|
10 |
http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd |
|
11 |
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd |
|
12 |
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd |
|
13 |
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd |
|
14 |
http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd"> |
|
15 |
|
|
16 |
<bean id="hbaseActionManagerCore" class="eu.dnetlib.actionmanager.hbase.HBaseActionManagerCore" |
|
17 |
p:actionFactory-ref="actionFactory" |
|
18 |
p:hbaseClient-ref="hbaseClient" /> |
|
19 |
|
|
20 |
<bean id="hbaseClient" class="eu.dnetlib.actionmanager.hbase.HBaseClient" |
|
21 |
p:tableName="db_actions_michele" |
|
22 |
p:hbaseConf="${services.data.hbase.dm.properties}" |
|
23 |
init-method="initWithEmptyTable" /> |
|
24 |
<!-- p:hbaseConf="classpath:/eu/dnetlib/actionmanager/test/hbase.properties" --> |
|
25 |
|
|
26 |
<bean id="actionFactory" class="eu.dnetlib.actionmanager.actions.ActionFactory"> |
|
27 |
<property name="xslts"> |
|
28 |
<util:map> |
|
29 |
<entry key="dmf2actions" value="classpath:/eu/dnetlib/actionmanager/xslt/dmf2actions.xslt" /> |
|
30 |
</util:map> |
|
31 |
</property> |
|
32 |
</bean> |
|
33 |
|
|
34 |
|
|
35 |
</beans> |
modules/dnet-actionmanager-common/releases/1.0.1/src/test/resources/eu/dnetlib/actionmanager/test/hbase.properties | ||
---|---|---|
1 |
#COMMON |
|
2 |
hadoop.entry.node = node1.hadoop.research-infrastructures.eu |
|
3 |
|
|
4 |
#CORE-SITE |
|
5 |
fs.defaultFS = hdfs://${hadoop.entry.node}:8020 |
|
6 |
io.file.buffer.size = 65536 |
|
7 |
io.compression.codecs = org.apache.hadoop.io.compress.DefaultCodec,org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.BZip2Codec,org.apache.hadoop.io.compress.DeflateCodec,org.apache.hadoop.io.compress.SnappyCodec |
|
8 |
hadoop.security.authentication = simple |
|
9 |
hadoop.security.auth_to_local = DEFAULT |
|
10 |
|
|
11 |
#HBASE-SITE |
|
12 |
hbase.rootdir = ${fs.defaultFS}/hbase |
|
13 |
hbase.client.write.buffer = 2097152 |
|
14 |
hbase.client.pause = 1000 |
|
15 |
hbase.client.retries.number = 10 |
|
16 |
hbase.client.scanner.caching = 1 |
|
17 |
hbase.client.keyvalue.maxsize = 10485760 |
|
18 |
hbase.security.authentication = simple |
|
19 |
zookeeper.session.timeout = 60000 |
|
20 |
zookeeper.znode.parent = /hbase |
|
21 |
zookeeper.znode.rootserver = root-region-server |
|
22 |
hbase.zookeeper.quorum = ${hadoop.entry.node} |
|
23 |
hbase.zookeeper.property.clientPort = 2182 |
|
24 |
|
|
25 |
#HDFS-SITE |
|
26 |
dfs.https.port = 50470 |
|
27 |
dfs.namenode.https-address = ${hadoop.entry.node}:${dfs.https.port} |
|
28 |
dfs.namenode.http-address = ${hadoop.entry.node}:50070 |
|
29 |
dfs.replication = 3 |
|
30 |
dfs.blocksize = 134217728 |
|
31 |
dfs.client.use.datanode.hostname= false |
|
32 |
|
|
33 |
#MAPRED-SITE |
|
34 |
mapreduce.jobtracker.address = ${hadoop.entry.node}:8021 |
|
35 |
mapred.job.tracker = ${hadoop.entry.node}:8021 |
|
36 |
mapred.mapper.new-api = true |
|
37 |
mapred.reducer.new-api = true |
|
38 |
mapred.output.compress = false |
|
39 |
mapred.output.compression.type = BLOCK |
|
40 |
mapred.output.compression.codec = org.apache.hadoop.io.compress.DefaultCodec |
|
41 |
#mapred.map.output.compression.codec = org.apache.hadoop.io.compress.SnappyCodec |
|
42 |
mapred.compress.map.output = true |
|
43 |
#io.sort.factor = 64 |
|
44 |
#io.sort.record.percent = 0.05 |
|
45 |
#io.sort.spill.percent = 0.8 |
|
46 |
#mapred.reduce.parallel.copies = 10 |
|
47 |
#mapred.submit.replication = 1 |
|
48 |
#mapred.reduce.tasks = 8 |
|
49 |
#io.sort.mb = 56 |
|
50 |
#mapred.child.java.opts = -Xmx238449165 |
|
51 |
#mapred.job.reuse.jvm.num.tasks = 1 |
|
52 |
#mapred.map.tasks = 6 |
|
53 |
#mapred.map.tasks.speculative.execution = false |
|
54 |
#mapred.reduce.tasks.speculative.execution = false |
|
55 |
#mapred.reduce.slowstart.completed.maps = 0.8 |
|
56 |
##mapred.local.dir = /data/mapred/local,/data/mapred/jt |
|
57 |
mapred.local.dir = /tmp |
|
58 |
mapred.child.java.opts = -Xmx512973352 |
|
59 |
|
|
60 |
#dfs.client.use.legacy.blockreader=true |
|
61 |
|
modules/dnet-actionmanager-common/releases/1.0.1/src/test/resources/eu/dnetlib/actionmanager/test/record.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<record xmlns="http://www.driver-repository.eu/" xmlns:dc="http://purl.org/dc/elements/1.1/" |
|
3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
4 |
xmlns:dr="http://www.driver-repository.eu/namespace/dr" |
|
5 |
xmlns:dri="http://www.driver-repository.eu/namespace/dri"> |
|
6 |
<header> |
|
7 |
<dri:objIdentifier>b91fdb84-1030-49d9-b398-813ab7cae968_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=::4d4life.eu/2009_Presentation_29301_!W__!V_1</dri:objIdentifier> |
|
8 |
<dri:recordIdentifier>7ce67201-b143-4ba8-aeaf-32f218778733_TURTdG9yZURTUmVzb3VyY2VzL01EU3RvcmVEU1Jlc291cmNlVHlwZQ==::4d4life.eu/2009_Presentation_29301_!W__!V_1</dri:recordIdentifier> |
|
9 |
<dri:dateOfCollection>2013-02-10T14:33:11Z</dri:dateOfCollection> |
|
10 |
<dri:mdFormat/> |
|
11 |
<dri:mdFormatInterpretation/> |
|
12 |
<dri:repositoryId>b91fdb84-1030-49d9-b398-813ab7cae968_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=</dri:repositoryId> |
|
13 |
<dr:objectIdentifier>b91fdb84-1030-49d9-b398-813ab7cae968_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=::4d4life.eu/2009_Presentation_29301_!W__!V_1</dr:objectIdentifier> |
|
14 |
<dr:dateOfCollection>2013-02-10T14:33:11Z</dr:dateOfCollection> |
|
15 |
</header> |
|
16 |
<metadata> |
|
17 |
<dr:CobjContentSynthesis/> |
|
18 |
<dr:CobjTypology>Textual</dr:CobjTypology> |
|
19 |
<dr:CobjModel>OAI</dr:CobjModel> |
|
20 |
<dr:CobjMDFormats>oai_dc</dr:CobjMDFormats> |
|
21 |
<dr:CobjDescriptionSynthesis/> |
|
22 |
<dr:aggregatorName>DRIVER</dr:aggregatorName> |
|
23 |
<dr:aggregatorInstitution>Bielefeld University Library</dr:aggregatorInstitution> |
|
24 |
<dr:repositoryName>BELIEF e-Infrastructure Digital Library</dr:repositoryName> |
|
25 |
<dr:repositoryLink>http://belief-dl.research-infrastructures.eu</dr:repositoryLink> |
|
26 |
<dr:repositoryCountry>IT</dr:repositoryCountry> |
|
27 |
<dr:repositoryInstitution>European Commission</dr:repositoryInstitution> |
|
28 |
<dc:creator>Frank Bisby, Frank</dc:creator> |
|
29 |
<dc:title>Distributed Dynamic Diversity Databases for Life (4D4Life)</dc:title> |
|
30 |
<dc:subject>Biology</dc:subject> |
|
31 |
<dc:subject>Natural Sciences</dc:subject> |
|
32 |
<dc:subject>Biodiversity</dc:subject> |
|
33 |
<dc:subject>Species Catalogue</dc:subject> |
|
34 |
<dr:CobjCategory>0000</dr:CobjCategory> |
|
35 |
<dc:language>eng</dc:language> |
|
36 |
<dc:dateAccepted/> |
|
37 |
<dc:identifier>http://belief-dl.research-infrastructures.eu/UIMain.jsp?handle=4d4life.eu/2009_Presentation_29301&view=&version=1</dc:identifier> |
|
38 |
<dc:publisher>4d4Life Project</dc:publisher> |
|
39 |
<dc:description>Brief presentation on the objectives of the D4DLife project. The |
|
40 |
presentation was provided in the data session of the 7th eConcertation Meeting in |
|
41 |
Brussels</dc:description> |
|
42 |
</metadata> |
|
43 |
</record> |
modules/dnet-actionmanager-common/releases/1.0.1/src/main/java/eu/dnetlib/actionmanager/actions/XsltInfoPackageAction.java | ||
---|---|---|
1 |
package eu.dnetlib.actionmanager.actions; |
|
2 |
|
|
3 |
import java.io.StringReader; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import javax.xml.transform.Transformer; |
|
7 |
import javax.xml.transform.TransformerException; |
|
8 |
|
|
9 |
import org.apache.commons.codec.binary.Base64; |
|
10 |
import org.apache.commons.logging.Log; |
|
11 |
import org.apache.commons.logging.LogFactory; |
|
12 |
import org.apache.hadoop.hbase.util.Bytes; |
|
13 |
import org.dom4j.Document; |
|
14 |
import org.dom4j.DocumentException; |
|
15 |
import org.dom4j.Element; |
|
16 |
import org.dom4j.io.DocumentResult; |
|
17 |
import org.dom4j.io.DocumentSource; |
|
18 |
import org.dom4j.io.SAXReader; |
|
19 |
|
|
20 |
import com.google.common.collect.Lists; |
|
21 |
|
|
22 |
import eu.dnetlib.actionmanager.ActionManagerConstants.ACTION_TYPE; |
|
23 |
import eu.dnetlib.actionmanager.common.Agent; |
|
24 |
import eu.dnetlib.actionmanager.common.Operation; |
|
25 |
import eu.dnetlib.actionmanager.common.Provenance; |
|
26 |
|
|
27 |
public class XsltInfoPackageAction extends AbstractMetaAction<String> { |
|
28 |
|
|
29 |
private final Transformer transformer; |
|
30 |
|
|
31 |
private static final Log log = LogFactory.getLog(XsltInfoPackageAction.class); // NOPMD by marko on 11/24/08 5:02 PM |
|
32 |
|
|
33 |
protected XsltInfoPackageAction(String set, Agent agent, Operation operation, String infoPackage, Transformer transformer, ActionFactory actionFactory) { |
|
34 |
super(set, agent, operation, infoPackage, actionFactory); |
|
35 |
this.transformer = transformer; |
|
36 |
} |
|
37 |
|
|
38 |
private Document applyXslt(String xml, Provenance provenance, String trust, String nsprefix) throws DocumentException, TransformerException { |
|
39 |
Document doc = (new SAXReader()).read(new StringReader(xml)); |
|
40 |
|
|
41 |
final DocumentResult result = new DocumentResult(); |
|
42 |
|
|
43 |
transformer.setParameter("trust", trust); |
|
44 |
transformer.setParameter("provenance", provenance.toString()); |
|
45 |
transformer.setParameter("namespaceprefix", nsprefix); |
|
46 |
|
|
47 |
transformer.transform(new DocumentSource(doc), result); |
|
48 |
|
|
49 |
//System.out.println(result.getDocument().asXML()); |
|
50 |
|
|
51 |
return result.getDocument(); |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
protected List<AtomicAction> calculateAtomicActions(Provenance provenance, String trust, String nsprefix) { |
|
56 |
List<AtomicAction> list = Lists.newArrayList(); |
|
57 |
|
|
58 |
try { |
|
59 |
Document doc = applyXslt(getMetaContent(), provenance, trust, nsprefix); |
|
60 |
for (Object o : doc.selectNodes("//ACTION")) { |
|
61 |
list.add(createAtomicAction((Element) o)); |
|
62 |
} |
|
63 |
} catch (Exception e) { |
|
64 |
log.error("Error generating actions", e); |
|
65 |
} |
|
66 |
|
|
67 |
return list; |
|
68 |
} |
|
69 |
|
|
70 |
private AtomicAction createAtomicAction(Element elem) { |
|
71 |
String key = elem.valueOf("./@targetKey"); |
|
72 |
String colFamily = elem.valueOf("./@targetColumnFamily"); |
|
73 |
String col = elem.valueOf("./@targetColumn"); |
|
74 |
String value64 = elem.getTextTrim(); |
|
75 |
byte[] value = value64.isEmpty() ? null : Base64.decodeBase64(value64); |
|
76 |
|
|
77 |
return getActionFactory().createAtomicAction(getSet(), getAgent(), key, colFamily, col, value); |
|
78 |
} |
|
79 |
|
|
80 |
@Override |
|
81 |
public boolean isValid() { |
|
82 |
// TODO Auto-generated method stub |
|
83 |
return true; |
|
84 |
} |
|
85 |
|
|
86 |
@Override |
|
87 |
public ACTION_TYPE getTypology() { |
|
88 |
return ACTION_TYPE.pkg; |
|
89 |
} |
|
90 |
|
|
91 |
@Override |
|
92 |
protected byte[] getBytesContent(String content) { |
|
93 |
return Bytes.toBytes(content); |
|
94 |
} |
|
95 |
|
|
96 |
} |
modules/dnet-actionmanager-common/releases/1.0.1/src/main/java/eu/dnetlib/actionmanager/actions/AbstractAction.java | ||
---|---|---|
1 |
package eu.dnetlib.actionmanager.actions; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.UUID; |
|
5 |
|
|
6 |
import org.apache.hadoop.hbase.client.Put; |
|
7 |
|
|
8 |
import com.google.common.hash.Hashing; |
|
9 |
|
|
10 |
import eu.dnetlib.actionmanager.ActionManagerConstants.ACTION_TYPE; |
|
11 |
import eu.dnetlib.actionmanager.common.Agent; |
|
12 |
import eu.dnetlib.actionmanager.common.Provenance; |
|
13 |
|
|
14 |
public abstract class AbstractAction implements Action { |
|
15 |
|
|
16 |
private String set; |
|
17 |
private String rowKey; |
|
18 |
private Agent agent; |
|
19 |
|
|
20 |
public AbstractAction(String set, Agent agent) { |
|
21 |
super(); |
|
22 |
this.set = set; |
|
23 |
this.agent = agent; |
|
24 |
this.rowKey = getTypology() + "|" + Hashing.md5().hashString(agent.getId()) + "|" + UUID.randomUUID(); |
|
25 |
} |
|
26 |
|
|
27 |
@Override |
|
28 |
abstract public List<Put> asPutOperations(String infoPackageId, Provenance provenance, String trust, String nsprefix); |
|
29 |
|
|
30 |
@Override |
|
31 |
abstract public boolean isValid(); |
|
32 |
|
|
33 |
@Override |
|
34 |
abstract public ACTION_TYPE getTypology(); |
|
35 |
|
|
36 |
public String getSet() { |
|
37 |
return set; |
|
38 |
} |
|
39 |
|
|
40 |
public void setSet(String set) { |
|
41 |
this.set = set; |
|
42 |
} |
|
43 |
|
|
44 |
public String getRowKey() { |
|
45 |
return rowKey; |
|
46 |
} |
|
47 |
|
|
48 |
public void setRowKey(String rowKey) { |
|
49 |
this.rowKey = rowKey; |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* @return the agent |
|
54 |
*/ |
|
55 |
public Agent getAgent() { |
|
56 |
return agent; |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* @param agent |
|
61 |
* the agent to set |
|
62 |
*/ |
|
63 |
public void setAgent(Agent agent) { |
|
64 |
this.agent = agent; |
|
65 |
} |
|
66 |
|
|
67 |
} |
modules/dnet-actionmanager-common/releases/1.0.1/src/main/java/eu/dnetlib/actionmanager/actions/ActionFactory.java | ||
---|---|---|
1 |
package eu.dnetlib.actionmanager.actions; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import javax.xml.transform.Transformer; |
|
7 |
import javax.xml.transform.TransformerFactory; |
|
8 |
|
|
9 |
import org.apache.hadoop.hbase.util.Bytes; |
|
10 |
import org.dom4j.Document; |
|
11 |
import org.dom4j.io.DocumentSource; |
|
12 |
import org.dom4j.io.SAXReader; |
|
13 |
import org.springframework.beans.factory.annotation.Required; |
|
14 |
import org.springframework.core.io.Resource; |
|
15 |
|
|
16 |
import com.google.common.collect.Lists; |
|
17 |
|
|
18 |
import eu.dnetlib.actionmanager.common.Agent; |
|
19 |
import eu.dnetlib.actionmanager.common.Operation; |
|
20 |
import eu.dnetlib.actionmanager.rmi.ActionManagerException; |
|
21 |
import eu.dnetlib.data.proto.RelTypeProtos.RelType; |
|
22 |
import eu.dnetlib.data.proto.TypeProtos.Type; |
|
23 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
24 |
|
|
25 |
/** |
|
26 |
* Factory bean to create Actions bypassing the Action Manager API |
|
27 |
* |
|
28 |
* @author michele |
|
29 |
*/ |
|
30 |
public class ActionFactory { |
|
31 |
|
|
32 |
private Map<String, Resource> xslts; |
|
33 |
|
|
34 |
final TransformerFactory tFactory = TransformerFactory.newInstance(); |
|
35 |
|
|
36 |
/** |
|
37 |
* Creates a list of AtomicAction(s) to handle an UPDATE. 1 body and 2 similarRel(s) |
|
38 |
* |
|
39 |
* @param set |
|
40 |
* the given set. |
|
41 |
* @param agent |
|
42 |
* the given agent. |
|
43 |
* @param originalId |
|
44 |
* main entity identifier to be updated (already existing in the information space). |
|
45 |
* @param updateId |
|
46 |
* new and unique identifier, must be the same used into "updateContent". |
|
47 |
* @param entityType |
|
48 |
* one of: result, person, project, datasource, organization |
|
49 |
* {@link eu.dnetlib.data.proto.TypeProtos.Type}. |
|
50 |
* @param updateContent |
|
51 |
* content to be updated over the original main entity. note that: the given trust level has to be [>.9 | |
|
52 |
* NEUTRAL | INFINITE] in order to gain visibility after the merging process. |
|
53 |
* @return the list of AtomicActions. |
|
54 |
*/ |
|
55 |
@Deprecated |
|
56 |
public List<AtomicAction> createUpdateActions(String set, Agent agent, String originalId, String updateId, Type entityType, byte[] updateContent) { |
|
57 |
List<AtomicAction> res = Lists.newArrayList(); |
|
58 |
|
|
59 |
if (originalId.equals(updateId)) { |
|
60 |
throw new IllegalArgumentException("originalId and updateId must be different"); |
|
61 |
} |
|
62 |
|
|
63 |
res.add(createAtomicAction(set, agent, updateId, entityType.toString(), "body", updateContent)); |
|
64 |
res.add(createAtomicAction(set, agent, updateId, RelType.similarRel.toString(), originalId, Bytes.toBytes(""))); |
|
65 |
res.add(createAtomicAction(set, agent, originalId, RelType.similarRel.toString(), updateId, Bytes.toBytes(""))); |
|
66 |
|
|
67 |
return res; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Creates a list of AtomicAction(s) to handle an UPDATE. Produces one Oaf, stored in CF = |
|
72 |
* [entity]:update_[timestamp] |
|
73 |
* |
|
74 |
* @param set |
|
75 |
* the given set. |
|
76 |
* @param agent |
|
77 |
* the given agent. |
|
78 |
* @param originalId |
|
79 |
* main entity identifier to be updated (already existing in the information space). |
|
80 |
* @param entityType |
|
81 |
* one of: result, person, project, datasource, organization |
|
82 |
* {@link eu.dnetlib.data.proto.TypeProtos.Type}. |
|
83 |
* @param updateContent |
|
84 |
* content to be updated over the original main entity. Oaf#OafEntity#[entity]#id must be consistent with |
|
85 |
* the originalId. note that: the given trust level has to be [>.9 | NEUTRAL | INFINITE] in order to gain |
|
86 |
* visibility after the merging process. |
|
87 |
* @return the list of AtomicActions. |
|
88 |
*/ |
|
89 |
public List<AtomicAction> createUpdateActions(String set, Agent agent, String originalId, Type entityType, byte[] updateContent) { |
|
90 |
List<AtomicAction> res = Lists.newArrayList(); |
|
91 |
|
|
92 |
res.add(createAtomicAction(set, agent, originalId, entityType.toString(), "update_" + DateUtils.now(), updateContent)); |
|
93 |
|
|
94 |
return res; |
|
95 |
} |
|
96 |
|
|
97 |
public AtomicAction createAtomicAction(String set, Agent agent, String targetKey, String targetColFamily, String targetCol, byte[] targetContent) { |
|
98 |
AtomicAction action = new AtomicAction(set, agent); |
|
99 |
|
|
100 |
action.setTargetRowKey(targetKey); |
|
101 |
action.setTargetColumnFamily(targetColFamily); |
|
102 |
action.setTargetColumn(targetCol); |
|
103 |
action.setTargetValue(targetContent); |
|
104 |
|
|
105 |
return action; |
|
106 |
} |
|
107 |
|
|
108 |
public XsltInfoPackageAction generateInfoPackageAction(String xsltResource, String set, Agent agent, Operation operation, String infoPackage) |
|
109 |
throws ActionManagerException { |
|
110 |
Transformer transformer = prepareXsltTransformer(xsltResource); |
|
111 |
return new XsltInfoPackageAction(set, agent, operation, infoPackage, transformer, this); |
|
112 |
} |
|
113 |
|
|
114 |
public Transformer prepareXsltTransformer(String xsltName) throws ActionManagerException { |
|
115 |
try { |
|
116 |
if (!xslts.containsKey(xsltName)) { |
|
117 |
throw new ActionManagerException("XSLT " + xsltName + " not found"); |
|
118 |
} |
|
119 |
|
|
120 |
final Document doc = new SAXReader().read(xslts.get(xsltName).getInputStream()); |
|
121 |
return tFactory.newTransformer(new DocumentSource(doc)); |
|
122 |
} catch (Exception e) { |
|
123 |
throw new ActionManagerException("Problem with xslt resource " + xsltName, e); |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 |
public Map<String, Resource> getXslts() { |
|
128 |
return xslts; |
|
129 |
} |
|
130 |
|
|
131 |
@Required |
|
132 |
public void setXslts(Map<String, Resource> xslts) { |
|
133 |
this.xslts = xslts; |
|
134 |
} |
|
135 |
|
|
136 |
} |
modules/dnet-actionmanager-common/releases/1.0.1/src/main/java/eu/dnetlib/actionmanager/actions/AbstractMetaAction.java | ||
---|---|---|
1 |
package eu.dnetlib.actionmanager.actions; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.apache.commons.logging.Log; |
|
6 |
import org.apache.commons.logging.LogFactory; |
|
7 |
import org.apache.hadoop.hbase.client.Put; |
|
8 |
import org.apache.hadoop.hbase.util.Bytes; |
|
9 |
|
|
10 |
import com.google.common.collect.Lists; |
|
11 |
|
|
12 |
import eu.dnetlib.actionmanager.ActionManagerConstants; |
|
13 |
import eu.dnetlib.actionmanager.common.Agent; |
|
14 |
import eu.dnetlib.actionmanager.common.Operation; |
|
15 |
import eu.dnetlib.actionmanager.common.Provenance; |
|
16 |
import eu.dnetlib.actionmanager.hbase.HBasePutFactory; |
|
17 |
|
|
18 |
abstract public class AbstractMetaAction<T> extends AbstractAction { |
|
19 |
|
|
20 |
private Operation operation; |
|
21 |
|
|
22 |
private T metaContent; |
|
23 |
|
|
24 |
private ActionFactory actionFactory; |
|
25 |
|
|
26 |
private static final Log log = LogFactory.getLog(AbstractMetaAction.class); // NOPMD by marko on 11/24/08 5:02 PM |
|
27 |
|
|
28 |
public AbstractMetaAction(String set, Agent agent, Operation operation, T metaContent, ActionFactory actionFactory) { |
|
29 |
super(set, agent); |
|
30 |
this.setOperation(operation); |
|
31 |
this.metaContent = metaContent; |
|
32 |
this.setActionFactory(actionFactory); |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
public List<Put> asPutOperations(String parentId, Provenance provenance, String trust, String nsprefix) { |
|
37 |
List<Put> puts = Lists.newArrayList(); |
|
38 |
List<String> partIds = Lists.newArrayList(); |
|
39 |
try { |
|
40 |
for (AtomicAction action : calculateAtomicActions(provenance, trust, nsprefix)) { |
|
41 |
if (action != null && action.isValid()) { |
|
42 |
puts.addAll(action.asPutOperations(getRowKey(), provenance, trust, nsprefix)); |
|
43 |
partIds.add(action.getRowKey()); |
|
44 |
} |
|
45 |
} |
|
46 |
puts.add(prepareMetaPut(partIds)); |
|
47 |
} catch (Exception e) { |
|
48 |
log.error("Error generating actions", e); |
|
49 |
} |
|
50 |
|
|
51 |
return puts; |
|
52 |
} |
|
53 |
|
|
54 |
private Put prepareMetaPut(List<String> partIds) { |
|
55 |
final Put put = HBasePutFactory.createPutOperation(getRowKey(), getSet(), getAgent()); |
|
56 |
|
|
57 |
put.add(ActionManagerConstants.OPERATION_COLFAMILY, Bytes.toBytes(getOperation().toString()), Bytes.toBytes(getOperation().toString())); |
|
58 |
put.add(ActionManagerConstants.ACTION_COLFAMILY, Bytes.toBytes(getTypology().toString()), getBytesContent(metaContent)); |
|
59 |
|
|
60 |
for (String id : partIds) { |
|
61 |
put.add(ActionManagerConstants.RELATION_COLFAMILY, Bytes.toBytes(id), ActionManagerConstants.HASPARTS); |
|
62 |
} |
|
63 |
return put; |
|
64 |
} |
|
65 |
|
|
66 |
abstract protected List<AtomicAction> calculateAtomicActions(Provenance provenance, String trust, String nsprefix); |
|
67 |
|
|
68 |
abstract protected byte[] getBytesContent(T content); |
|
69 |
|
|
70 |
public Operation getOperation() { |
|
71 |
return operation; |
|
72 |
} |
|
73 |
|
|
74 |
public void setOperation(Operation operation) { |
|
75 |
this.operation = operation; |
|
76 |
} |
|
77 |
|
|
78 |
public T getMetaContent() { |
|
79 |
return metaContent; |
|
80 |
} |
|
81 |
|
|
82 |
public void setMetaContent(T metaContent) { |
|
83 |
this.metaContent = metaContent; |
|
84 |
} |
|
85 |
|
|
86 |
public ActionFactory getActionFactory() { |
|
87 |
return actionFactory; |
|
88 |
} |
|
89 |
|
|
90 |
public void setActionFactory(ActionFactory actionFactory) { |
|
91 |
this.actionFactory = actionFactory; |
|
92 |
} |
|
93 |
|
|
94 |
} |
modules/dnet-actionmanager-common/releases/1.0.1/src/main/java/eu/dnetlib/actionmanager/actions/AtomicAction.java | ||
---|---|---|
1 |
package eu.dnetlib.actionmanager.actions; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.apache.hadoop.hbase.client.Put; |
|
6 |
import org.apache.hadoop.hbase.util.Bytes; |
|
7 |
|
|
8 |
import com.google.common.collect.Lists; |
|
9 |
|
|
10 |
import eu.dnetlib.actionmanager.ActionManagerConstants; |
|
11 |
import eu.dnetlib.actionmanager.ActionManagerConstants.ACTION_TYPE; |
|
12 |
import eu.dnetlib.actionmanager.common.Agent; |
|
13 |
import eu.dnetlib.actionmanager.common.Operation; |
|
14 |
import eu.dnetlib.actionmanager.common.Provenance; |
|
15 |
import eu.dnetlib.actionmanager.hbase.HBasePutFactory; |
|
16 |
|
|
17 |
public class AtomicAction extends AbstractAction { |
|
18 |
|
|
19 |
private String targetRowKey; |
|
20 |
private String targetColumnFamily; |
|
21 |
private String targetColumn; |
|
22 |
|
|
23 |
private byte[] targetValue; |
|
24 |
|
|
25 |
public AtomicAction(String set, Agent agent) { |
|
26 |
super(set, agent); |
|
27 |
} |
|
28 |
|
|
29 |
public AtomicAction(String set, Agent agent, Operation operation, String targetRowKey, String targetColumnFamily, String targetColumn, |
|
30 |
byte[] targetValue) { |
|
31 |
this(set, agent); |
|
32 |
this.targetRowKey = targetRowKey; |
|
33 |
this.targetColumnFamily = targetColumnFamily; |
Also available in: Unified diff
codebase used to migrate to java8 the production system