Skip to content

Commit cc752d4

Browse files
author
David Lotts
committed
Merge branch 'vmExamplePR318' into patch-1
2 parents abd3910 + 5c8b228 commit cc752d4

5 files changed

Lines changed: 176 additions & 19 deletions

File tree

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Apache Rya (Incubating)
2-
Copyright 2015-2018 The Apache Software Foundation
2+
Copyright 2015-2020 The Apache Software Foundation
33

44
This product includes software developed at
55
The Apache Software Foundation (http://www.apache.org/).

extras/indexing/src/main/java/org/apache/rya/indexing/IndexingFunctionRegistry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class IndexingFunctionRegistry {
6464

6565
}
6666

67-
public enum FUNCTION_TYPE {GEO, TEMPORAL, FREETEXT}
67+
public enum FUNCTION_TYPE {GEO, TEMPORAL, FREETEXT, NONE}
6868

6969
public static Set<IRI> getFunctions() {
7070
return SEARCH_FUNCTIONS.keySet();
@@ -73,7 +73,7 @@ public static Set<IRI> getFunctions() {
7373

7474
public static Var getResultVarFromFunctionCall(IRI function, List<ValueExpr> args) {
7575

76-
FUNCTION_TYPE type = SEARCH_FUNCTIONS.get(function);
76+
FUNCTION_TYPE type = SEARCH_FUNCTIONS.getOrDefault(function, FUNCTION_TYPE.NONE);
7777

7878
switch(type) {
7979
case GEO:
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.rya.indexing;
20+
21+
import static org.junit.Assert.assertEquals;
22+
import static org.junit.Assert.assertNotEquals;
23+
import static org.junit.Assert.assertNotNull;
24+
import static org.junit.Assert.assertNull;
25+
26+
import java.util.ArrayList;
27+
import java.util.List;
28+
29+
import org.apache.accumulo.core.client.AccumuloException;
30+
import org.apache.accumulo.core.client.AccumuloSecurityException;
31+
import org.apache.accumulo.core.client.Connector;
32+
import org.apache.rya.accumulo.AccumuloRdfConfiguration;
33+
import org.apache.rya.accumulo.AccumuloRyaDAO;
34+
import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
35+
import org.apache.rya.api.persist.RyaDAOException;
36+
import org.apache.rya.indexing.accumulo.ConfigUtils;
37+
import org.apache.rya.rdftriplestore.inference.InferenceEngineException;
38+
import org.apache.rya.sail.config.RyaSailFactory;
39+
import org.eclipse.rdf4j.model.Statement;
40+
import org.eclipse.rdf4j.model.ValueFactory;
41+
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
42+
import org.eclipse.rdf4j.model.vocabulary.RDFS;
43+
import org.eclipse.rdf4j.query.BindingSet;
44+
import org.eclipse.rdf4j.query.QueryLanguage;
45+
import org.eclipse.rdf4j.query.TupleQueryResult;
46+
import org.eclipse.rdf4j.repository.Repository;
47+
import org.eclipse.rdf4j.repository.RepositoryConnection;
48+
import org.eclipse.rdf4j.repository.sail.SailRepository;
49+
import org.eclipse.rdf4j.sail.Sail;
50+
import org.junit.Test;
51+
52+
public class IndexingFunctionRegistryFreeTextTest {
53+
54+
private final static String STRING_LENGTH_QUERY = "select (strlen(?o) AS ?o_len) WHERE { ?s <http://worksAt> ?o } LIMIT 1";
55+
56+
private Sail accumuloSail;
57+
private Repository accumuloRepo;
58+
private RepositoryConnection accumuloConn;
59+
private AccumuloRyaDAO accumuloDao;
60+
61+
@Test
62+
public void accumuloConnTest1() throws Exception {
63+
this.init(getAccumuloConf(true));
64+
this.sparqlConnTest(this.accumuloConn, STRING_LENGTH_QUERY);
65+
this.close();
66+
}
67+
68+
@Test
69+
public void accumuloConnTest2() throws Exception {
70+
this.init(getAccumuloConf(false));
71+
this.sparqlConnTest(this.accumuloConn, STRING_LENGTH_QUERY);
72+
this.close();
73+
}
74+
75+
76+
private void init(RdfCloudTripleStoreConfiguration conf) throws AccumuloSecurityException, InferenceEngineException, AccumuloException, RyaDAOException {
77+
78+
this.accumuloSail = RyaSailFactory.getInstance(conf);
79+
this.accumuloRepo = new SailRepository(accumuloSail);
80+
this.accumuloConn = this.accumuloRepo.getConnection();
81+
82+
Connector conn = ConfigUtils.getConnector(conf);
83+
this.accumuloDao = new AccumuloRyaDAO();
84+
this.accumuloDao.setConnector(conn);
85+
this.accumuloDao.init();
86+
}
87+
88+
private void close() throws RyaDAOException {
89+
this.accumuloConn.close();
90+
this.accumuloRepo.shutDown();
91+
this.accumuloSail.shutDown();
92+
this.accumuloDao.destroy();
93+
}
94+
95+
private RdfCloudTripleStoreConfiguration getAccumuloConf(boolean useFreeText) {
96+
RdfCloudTripleStoreConfiguration conf;
97+
conf = new AccumuloRdfConfiguration();
98+
conf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, true);
99+
conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "rya_");
100+
conf.set(AccumuloRdfConfiguration.CLOUDBASE_USER, "root");
101+
conf.set(AccumuloRdfConfiguration.CLOUDBASE_PASSWORD, "");
102+
conf.set(AccumuloRdfConfiguration.CLOUDBASE_INSTANCE, "instance");
103+
conf.set(RdfCloudTripleStoreConfiguration.CONF_QUERY_AUTH, "");
104+
conf.setBoolean(ConfigUtils.DISPLAY_QUERY_PLAN, true);
105+
106+
conf.setBoolean(ConfigUtils.USE_FREETEXT, useFreeText);
107+
108+
if (useFreeText) {
109+
conf.setStrings(ConfigUtils.FREETEXT_PREDICATES_LIST, RDFS.LABEL.stringValue());
110+
}
111+
112+
return conf;
113+
}
114+
115+
private void sparqlConnTest(RepositoryConnection conn, String query) throws Exception {
116+
ValueFactory vf = SimpleValueFactory.getInstance();
117+
118+
Statement s = vf.createStatement(vf.createIRI("http://Joe"), vf.createIRI("http://worksAt"), vf.createLiteral("CoffeeShop"));
119+
conn.add(s);
120+
121+
TupleQueryResult result = null;
122+
Exception e = null;
123+
List<BindingSet> results = new ArrayList<>();
124+
String o_len = "";
125+
126+
try {
127+
result = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate();
128+
129+
while (result.hasNext()) {
130+
BindingSet bSet = result.next();
131+
o_len = bSet.getValue("o_len").stringValue();
132+
results.add(bSet);
133+
}
134+
135+
} catch (Exception ex) {
136+
e = ex;
137+
}
138+
139+
assertNull(e);
140+
assertNotNull(result);
141+
assertNotEquals(0, results.size());
142+
assertEquals("10", o_len);
143+
144+
conn.remove(s);
145+
}
146+
}

extras/vagrantExample/src/main/vagrant/Vagrantfile

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ Vagrant.configure(2) do |config|
4444
config.vm.hostname = "rya-example-box"
4545

4646
config.vm.provision "shell", inline: <<-SHELL
47-
# fixme #######################################
48-
set -x ## turn on command echo with expanded variables
47+
set -x ## turn on command echo with expanded variables
4948
# List of dependency versions
5049
export ACCUMULO_VERSION=1.6.6
5150
export HADOOP_VERSION=2.7.2
@@ -62,11 +61,13 @@ Vagrant.configure(2) do |config|
6261
EOF
6362
sudo -E apt-get -qq update
6463
echo "Installing Java installer..."
65-
# if you want dev tools like javac, change this to openjdk-8-jdk-headless
64+
# if you want dev tools like javac, change this to openjdk-8-jdk-headless
6665
sudo -E apt-get install -y openjdk-8-jre || exit $?
6766
6867
echo "Installing Tomcat..."
68+
sudo useradd -r -m -U -d /opt/tomcat -s /bin/false tomcat
6969
sudo -E apt-get install -y tomcat9 || exit $?
70+
sudo usermod -a -G tomcat vagrant
7071
echo "Installing Unzip..."
7172
apt-get install unzip || exit $?
7273
echo "Setting up environment..."
@@ -257,18 +258,28 @@ EOF
257258
echo 'Done!'
258259
# --------------------
259260
echo "Installing RDF4J Server"
260-
# creating log dir rdf4j-http-server-${RDF4J_VERSION}
261-
sudo mkdir --parents /usr/share/tomcat9/.RDF4J
262-
sudo chown -R tomcat:tomcat /usr/share/tomcat9
263-
sudo ln --force -s /usr/share/tomcat9/.RDF4J/Server/logs /var/log/tomcat9/rdf4j-server
264-
# create a property that the app will pickup. It defaults to $HOME.
265-
sudo echo 'export JAVA_OPTS="-Dorg.eclipse.rdf4j.appdata.basedir=/var/lib/tomcat9/webapps/rdf4j-server/"' | sudo tee --append '/usr/share/tomcat9/bin/setenv.sh'
261+
# this is the rdf4j data dir. It might need to be registered with tomcat to write there.
262+
export rdf4jServerBase=/opt/tomcat/
263+
sudo install -d -o tomcat -m u=rwx,go=rx ${rdf4jServerBase}
264+
sudo -u tomcat mkdir --parents ${rdf4jServerBase}/server/logs
265+
sudo -u tomcat mkdir --parents ${rdf4jServerBase}/.RDF4J/server/logs
266+
# tomcat v9 requires explicit permissions to the file system.
267+
sudo mkdir --parents /etc/systemd/system/tomcat9.service.d
268+
cat <<EOF | sudo tee --append /etc/systemd/system/tomcat9.service.d/logging-allow.conf
269+
[Service]
270+
ReadWritePaths=${rdf4jServerBase}
271+
EOF
272+
echo 'Restarting Tomcat (or starting)'
273+
sudo -E systemctl daemon-reload || exit 1080
274+
sudo -E systemctl enable tomcat9 || exit 1081
275+
sudo -E systemctl restart tomcat9 || exit 1082
266276
rdf4jwar=/var/lib/tomcat9/webapps/rdf4j-server.war
267277
if [[ ! -s $rdf4jwar ]] ; then
268278
echo "Downloading RDF4J Server"
269279
download --output $rdf4jwar ${mavenRepoUrl}org/eclipse/rdf4j/rdf4j-http-server/${RDF4J_VERSION}/rdf4j-http-server-${RDF4J_VERSION}.war || exit 110
270280
fi
271281
echo "RDF4J http server deployed at http://rya-example-box:8080/rdf4j-server"
282+
# --------------------
272283
echo "Installing RDF4J Workbench"
273284
workbench=/var/lib/tomcat9/webapps/rdf4j-workbench.war
274285
if [[ ! -s $workbench ]] ; then
@@ -294,16 +305,16 @@ EOF
294305
waitForDeploy /var/lib/tomcat9/webapps/rdf4j-workbench/WEB-INF/lib/
295306
waitForDeploy /var/lib/tomcat9/webapps/rdf4j-server/WEB-INF/lib/
296307
# soft linking the files doesn't seem to work in tomcat, so we copy them instead :(
297-
sudo cp ${ryaIndexing}/dist/lib/* /var/lib/tomcat9/webapps/rdf4j-workbench/WEB-INF/lib/ || exit 113
298-
sudo cp ${ryaIndexing}/dist/lib/* /var/lib/tomcat9/webapps/rdf4j-server/WEB-INF/lib/ || exit 114
308+
sudo -u tomcat cp ${ryaIndexing}/dist/lib/* /var/lib/tomcat9/webapps/rdf4j-workbench/WEB-INF/lib/ || exit 113
309+
sudo -u tomcat cp ${ryaIndexing}/dist/lib/* /var/lib/tomcat9/webapps/rdf4j-server/WEB-INF/lib/ || exit 114
299310
# These are older libs that break tomcat and rdf4j that come with Rya above.
300311
sudo rm --force /var/lib/tomcat9/webapps/rdf4j-workbench/WEB-INF/lib/servlet-api-2.5.jar
301312
sudo rm --force /var/lib/tomcat9/webapps/rdf4j-workbench/WEB-INF/lib/jsp-api-2.1.jar
302313
s=/var/lib/tomcat9/webapps/rdf4j-server/WEB-INF/lib/
303314
sudo rm --force $s/servlet-api-2.5.jar $s/lib/jsp-api-2.1.jar
304315
sudo find "$s" -name 'spring-*-3.*.jar' -exec sudo rm --force {} +
305316
sudo rm $s/spring-aop-4.2.1.RELEASE.jar $s/rdf4j-http-server-spring-2.3.1.jar
306-
sudo rm --force $s/slf4j-log4j12-1.7.25.jar $s/slf4j-api-1.7.25.jar $s/jcabi-log-0.14.jar $s/jcl-over-slf4j-1.7.25.jar $s/minlog-1.3.0.jar $s/commons-logging-1.1.1.jar $s/log4j-1.2.16.jar
317+
sudo rm --force $s/slf4j-log4j12-1.7.25.jar $s/slf4j-api-1.7.25.jar $s/jcabi-log-0.14.jar $s/jcl-over-slf4j-1.7.25.jar $s/minlog-1.3.0.jar $s/commons-logging-1.1.1.jar $s/log4j-1.2.16.jar
307318
sudo chown -R tomcat:tomcat /var/lib/tomcat9/webapps/rdf4j-workbench/WEB-INF/lib/
308319
sudo chown -R tomcat:tomcat /var/lib/tomcat9/webapps/rdf4j-server/WEB-INF/lib/
309320
# ----------------------
@@ -321,7 +332,7 @@ EOF
321332
sudo mkdir --parents ${ryaVagrant}
322333
sudo unzip -q -o ${ryaVagrant}.jar -d ${ryaVagrant}
323334
waitForDeploy /var/lib/tomcat9/webapps/rdf4j-workbench/transformations
324-
sudo cp ${ryaVagrant}/*.xsl /var/lib/tomcat9/webapps/rdf4j-workbench/transformations/
335+
sudo -u tomcat cp ${ryaVagrant}/*.xsl /var/lib/tomcat9/webapps/rdf4j-workbench/transformations/
325336
sudo chown tomcat:tomcat /var/lib/tomcat9/webapps/rdf4j-workbench/transformations/*
326337
# ----------------------
327338
echo "Deploying Rya Web"
@@ -338,7 +349,7 @@ EOF
338349
fi
339350
# remove this so we can wait for it to be recreated.
340351
sudo rm -rf /var/lib/tomcat9/webapps/web.rya/WEB-INF/classes
341-
sudo cp ${ryaWar} /var/lib/tomcat9/webapps/web.rya.war
352+
sudo -u tomcat cp ${ryaWar} /var/lib/tomcat9/webapps/web.rya.war
342353
# Wait for the war to deploy
343354
waitForDeploy /var/lib/tomcat9/webapps/web.rya/WEB-INF/classes/
344355
# These are older libs that break tomcat
@@ -356,7 +367,7 @@ rya.displayqueryplan=true
356367
EOF
357368
echo "Rya web deployed at http://rya-example-box:8080/web.rya/sparqlQuery.jsp"
358369
# restart tomcat
359-
sudo -E service tomcat9 restart
370+
systemctl restart tomcat9 || exit $?
360371
echo "Finished and ready to use!"
361372
echo "You can re-apply these settings without losing data by running the command 'vagrant provision'"
362373
SHELL

osgi/rdf4j-runtime-osgi/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ under the License.
133133
</snapshots>
134134
<id>bndrepo</id>
135135
<name>aQute BND Repo</name>
136-
<url>http://www.aqute.biz/repo</url>
136+
<url>https://www.aqute.biz/repo</url>
137137
</repository>
138138
</repositories>
139139
</project>

0 commit comments

Comments
 (0)