Skip to content

Commit 3127706

Browse files
committed
Merge branch '2_1_5_reverse_merge'
2 parents 64bb8ca + 459f113 commit 3127706

File tree

507 files changed

+5920
-1550
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

507 files changed

+5920
-1550
lines changed

LEGAL/aduna-bsd.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright Aduna (http://www.aduna-software.com/) 2001-2013
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice,
8+
this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above copyright notice,
10+
this list of conditions and the following disclaimer in the documentation
11+
and/or other materials provided with the distribution.
12+
* Neither the name of the copyright holder nor the names of its contributors
13+
may be used to endorse or promote products derived from this software
14+
without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
## Welcome to the Blazegraph Database
2-
Blazegraph™ DB is a ultra high-performance graph database supporting Blueprints and RDF/SPARQL APIs. It supports up to 50 Billion edges on a single machine and has a enterprise features for High Availability, Scale-out architecture, and [GPU Acceleration](https://www.blazegraph.com/product/gpu-accelerated/). It is in production use for Fortune 500 customers such as EMC, Autodesk, and many others. It is supporting key [Precision Medicine](http://www.syapse.com) applications and has wide-spread usage for life science applications. It is used extensively to support Cyber anaytics in commercial and government applications. It powers the Wikimedia Foundation's [Wiki Data Query Service](https://query.wikidata.org/). See the latest [Feature Matrix](http://www.blazegraph.com/product/).
1+
## Welcome to the Blazegraph Database ##
2+
Blazegraph™ DB is a ultra high-performance graph database supporting Blueprints and RDF/SPARQL APIs. It supports up to 50 Billion edges on a single machine. It is in production use for Fortune 500 customers such as EMC, Autodesk, and many others. It is supporting key [Precision Medicine](http://www.syapse.com) applications and has wide-spread usage for life science applications. It is used extensively to support Cyber anaytics in commercial and government applications. It powers the Wikimedia Foundation's [Wikidata Query Service](https://query.wikidata.org/).
33

44
![image](http://blog.blazegraph.com/wp-content/uploads/2015/07/blazegraph_by_systap_favicon.png)
55

@@ -9,20 +9,47 @@ Please see the release notes in [releases](bigdata/src/releases) for version cha
99

1010
Please also visit us at our: [website](https://www.blazegraph.com), [wiki](https://wiki.blazegraph.com), and [blog](https://blog.blazegraph.com/).
1111

12-
Find an issue? Need help? See [JIRA](https://jira.blazegraph.com) or purchase [Support](https://www.blazegraph.com/buy).
12+
Find an issue? Need help? See [JIRA](https://jira.blazegraph.com).
1313

1414
Reporting a security issue: [Security Reporting](Security.md).
1515

16-
###Quick Start with the Executable Jar
16+
### Quick Start with the Executable Jar ###
1717
Up and running with Blazegraph in under 30 seconds: [Quick Start](https://wiki.blazegraph.com/wiki/index.php/Quick_Start).
1818

19-
###Samples and Examples
19+
### Deploying in Production ###
20+
Blazegraph is designed to be easy to use and get started. It ships without SSL or authentication by default for this reason. For production deployments, we _strongly_ recommend you enable SSL, authentication, and appropriate network configurations. There are some helpful links below to enable you to do this.
21+
22+
#### Enabling SSL support ####
23+
To enable SSL support, uncomment the example [jetty.xml](blazegraph-jar/src/main/resources/jetty.xml#L141) and configure it for your local keystore.
24+
25+
#### Configuration Authentication ####
26+
By default, Blazegraph ships without authentication enabled. This is great for developing, getting started, and doing research with Blazegraph. However, it's not recommended for any production deployment. To configuration authentication, you must configure it either within the web app container or via a reverse-proxy configuration.
27+
28+
Note that the Blazegraph namespace feature for [multi-tenancy](https://wiki.blazegraph.com/wiki/index.php/REST_API#Multi-Tenancy_API) does not provide security isolation. Users that can access the base URI of the server can access any of the available namespaces. You can further restrict this through a combination of authentication configuration and restricting access to specific namespace URIs, i.e. `/blazegraph/namespace/NAMESPACE/sparql`.
29+
30+
There are three basic options:
31+
32+
1. **Configuring Jetty Authentication for a standalone Jetty deployment**: Follow the [jetty](http://www.eclipse.org/jetty/documentation/9.2.22.v20170531/configuring-security-authentication.html) guide to configure authentication for the [jetty.xml](blazegraph-jar/src/main/resources/jetty.xml) you use to deploy the server by uncommenting the `<Get name="securityHandler">` section. You'll need to create a [realm.properties](blazegraph-jar/src/main/resources/realm.properties) and update the jetty.xml to point to its location on the filesystem. Then configure the [web.xml](bigdata-war-html/src/main/webapp/WEB-INF/web.xml) to uncomment the security-constraint.
33+
1. **Configuring Tomcat Authentication for a standalone Tomcat deployment**: First configure a Tomcat [Realm](https://tomcat.apache.org/tomcat-7.0-doc/realm-howto.html) with your choice of authentication method (JDBC, JNDI, etc.). Then configure the [web.xml](bigdata-war-html/src/main/webapp/WEB-INF/web.xml) to uncomment the security-constraint.
34+
1. **Setup a reverse-proxy configuration with authentication**: You can setup an http or https reverse proxy configuration that has authentication and forward requests to the local Blazegraph instance (typically running on localhost:9999). This is a good option with [Nginx](https://community.openhab.org/t/using-nginx-reverse-proxy-authentication-and-https/14542) and [Apache](https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication).
35+
36+
##### Mitigating Cross-Site Request Forgery (CSRF) #####
37+
If you enable authentication and expose the Blazegraph workbench, you should also take steps to protect against CSRF. Tomcat8 provides a [CSRF filter](https://tomcat.apache.org/tomcat-8.0-doc/config/filter.html#CSRF_Prevention_Filter_for_REST_APIs) that can be configured. For Jetty, if you configure authentication the default value for `SecurityHandler.setSessionRenewedOnAuthentication(true)` can also be used. CSRF protection may require REST clients to implement HTTP headers to be used to interact with the service.
38+
39+
### Building the code ###
40+
As a quick start, run `mvn install -DskipTests` or the utility script `./scripts/mavenInstall.sh `.
41+
42+
For more detailed maven information see the [wiki](https://wiki.blazegraph.com/wiki/index.php/MavenNotes).
43+
44+
If you build with Java 7, you need to add Maven options for TLS 1.2, i.e. `export MAVEN_OPTS="-Dhttps.protocols=TLSv1.2"`.
45+
46+
### Samples and Examples ###
2047
There are code samples and examples to get started with the Blazegraph Database [here] (https://github.com/blazegraph/blazegraph-samples). Tinkerpop3 examples are included directly within the Tinkerpop3 repository per below.
2148

22-
###Javadocs
49+
### Javadocs ###
2350
Click here to view the lastest [API Javadocs](https://blazegraph.github.io/database/apidocs/index.html).
2451

25-
###Maven Central
52+
### Maven Central ###
2653
Starting with the 2.0.0 release, the Blazegraph Database is available on Maven Central. To include the core platform and dependencies, include the artifact below in your dependencies. [Developing with Maven](https://wiki.blazegraph.com/wiki/index.php/MavenNotes) has notes on developing with Blazegraph Database source code and Maven.
2754

2855
```
@@ -49,13 +76,13 @@ If you'd just link the Blazegraph Database dependencies without any of the exter
4976
</dependency>
5077
```
5178

52-
###Deployers
79+
### Deployers ###
5380

5481
Starting with 2.0.0, the default context path for deployment is `http://localhost:9999/blazegraph/`. There are also Maven artifacts for WAR deployers (`blazegraph-war`), executable Jar files (`blazegraph-jar`), [Debian Package](blazegraph-deb/) (`blazegraph-deb`), [RPM](blazegraph-rpm/) (`blazegraph-rpm`), and a [Tarball](blazegraph-tgz/) (`blazegraph-tgz`).
5582

5683
The `bigdata-war` and `bigdata-jar` artifacts are included for legacy purposes and use the `/bigdata/` context path.
5784

58-
###Tinkerpop3
85+
### Tinkerpop3 ###
5986
Tinkerpop3 supports requires Java 1.8 and is now in a separate repository. See [Tinkerpop3](https://github.com/blazegraph/tinkerpop3). It is also available as Maven Central artifact.
6087

6188
```
@@ -67,19 +94,11 @@ Tinkerpop3 supports requires Java 1.8 and is now in a separate repository. See
6794
6895
```
6996

70-
###Triple Pattern Fragment (TPF) Server
71-
There is a [Triple Pattern Fragment (TPF) for Blazegraph](https://github.com/TPF4Blazegraph/TPF4Blazegraph) server that supports [Linked Data Fragments](http://linkeddatafragments.org/).
72-
73-
```
74-
<dependency>
75-
<groupId>com.blazegraph</groupId>
76-
<artifactId>BlazegraphBasedTPFServer</artifactId>
77-
<version>0.1.0</version>
78-
</dependency>
79-
```
97+
### Triple Pattern Fragment (TPF) Server ###
98+
There is a [Blazegraph Triple Pattern Fragment TPF](https://github.com/hartig/BlazegraphBasedTPFServer) server that supports [Linked Data Fragments](http://linkeddatafragments.org/).
8099

81-
###Blazegraph Python Client
82-
There is a Blazegraph Python Client [here] (https://github.com/blazegraph/blazegraph-python)
100+
### Blazegraph Python Client ###
101+
There is a Blazegraph Python Client [here](https://github.com/blazegraph/blazegraph-python)
83102

84-
###Blazegraph Dot Net RDF Client
103+
### Blazegraph Dot Net RDF Client ###
85104
There is a Blazegraph Dot Net RDF Client [here](https://github.com/blazegraph/blazegraph-dotnetrdf)

Security.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
##Reporting a Blazegraph Security Issue##
1+
## Reporting a Blazegraph Security Issue ##
22

33
For customers and Blazegraph users, please send an email to security [at] blazegraph.com to report a security issue. You may send an encrypted message using the public key below.
44

55
This alias is monitored on a daily basis. All security reports are acknowledged within 24 hours. Mitigations for reported security issues are made in a reasonable timeframe, which may be as quickly as 24 hours for high-severity issues.
66

7-
###Public Key###
7+
### Public Key ###
88
Please use the public key below for transmitting any sensitive information to the security alias.
99

1010
```

bigdata-blueprints/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ Copyright 2010 by TalkingTrends (Amsterdam, The Netherlands)
2828
<parent>
2929
<groupId>com.blazegraph</groupId>
3030
<artifactId>blazegraph-parent</artifactId>
31-
<version>2.1.4</version>
31+
<version>2.1.6-SNAPSHOT</version>
3232
<relativePath>../pom.xml</relativePath>
3333
</parent>
3434
<groupId>com.blazegraph</groupId>
3535
<artifactId>bigdata-blueprints</artifactId>
36-
<version>2.1.4</version>
36+
<version>2.1.6-SNAPSHOT</version>
3737
<name>Blazegraph Blueprints API</name>
3838
<description>Blazegraph support for Tinkerpop 2.5</description>
3939
<packaging>jar</packaging>

bigdata-cache/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ Copyright 2010 by TalkingTrends (Amsterdam, The Netherlands)
2828
<parent>
2929
<groupId>com.blazegraph</groupId>
3030
<artifactId>blazegraph-parent</artifactId>
31-
<version>2.1.4</version>
31+
<version>2.1.6-SNAPSHOT</version>
3232
<relativePath>../pom.xml</relativePath>
3333
</parent>
3434
<groupId>com.blazegraph</groupId>
3535
<artifactId>bigdata-cache</artifactId>
36-
<version>2.1.4</version>
36+
<version>2.1.6-SNAPSHOT</version>
3737
<name>Blazegraph Cache</name>
3838
<description>Blazegraph Cache utilities</description>
3939
<packaging>jar</packaging>

bigdata-client/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ Copyright 2010 by TalkingTrends (Amsterdam, The Netherlands)
2828
<parent>
2929
<groupId>com.blazegraph</groupId>
3030
<artifactId>blazegraph-parent</artifactId>
31-
<version>2.1.4</version>
31+
<version>2.1.6-SNAPSHOT</version>
3232
<relativePath>../pom.xml</relativePath>
3333
</parent>
3434
<groupId>com.blazegraph</groupId>
3535
<artifactId>bigdata-client</artifactId>
36-
<version>2.1.4</version>
36+
<version>2.1.6-SNAPSHOT</version>
3737
<name>Blazegraph Client API</name>
3838
<description>Blazegraph Client API tools</description>
3939
<build>

bigdata-client/src/main/java/com/bigdata/rdf/sail/webapp/client/AST2SPARQLUtil.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import org.openrdf.model.Literal;
3535
import org.openrdf.model.URI;
3636
import org.openrdf.model.Value;
37+
import org.openrdf.model.vocabulary.XMLSchema;
38+
import org.openrdf.query.parser.sparql.SPARQLUtil;
3739

3840
/**
3941
* Utility class for externalizing SPARQL prefix declaration management.
@@ -154,7 +156,7 @@ public String toExternal(final Literal lit) {
154156
+ (datatypeURI != null ? datatypeStr.length() + 2 : 0));
155157

156158
sb.append('"');
157-
sb.append(label);
159+
sb.append(SPARQLUtil.encodeString(label));
158160
sb.append('"');
159161

160162
if (languageCode != null) {

bigdata-client/src/test/java/com/bigdata/rdf/sail/webapp/client/MockRemoteRepository.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.eclipse.jetty.client.api.Response.ResponseListener;
1313
import org.eclipse.jetty.client.api.Result;
1414
import org.eclipse.jetty.http.HttpHeader;
15+
import org.eclipse.jetty.util.Callback;
1516
import org.openrdf.query.resultio.TupleQueryResultFormat;
1617
import org.openrdf.rio.RDFFormat;
1718

@@ -34,7 +35,7 @@ public static MockRemoteRepository create(final String tupleQueryResponse, final
3435
// pojo to retrieve values from mock service
3536
final Data data = new Data();
3637

37-
String serviceURL = "localhost";
38+
String serviceURL = "http://localhost";
3839
HttpClient httpClient = new HttpClient() {
3940
@Override
4041
protected void send(HttpRequest request,
@@ -67,7 +68,7 @@ public int getStatus() {
6768
java.nio.ByteBuffer buf = java.nio.ByteBuffer.allocate(responseContent.length());
6869
buf.put(responseContent.getBytes(Charset.forName(StandardCharsets.UTF_8.name())));
6970
buf.flip();
70-
((JettyResponseListener)listener).onContent(response, buf);
71+
((JettyResponseListener)listener).onContent(response, buf, Callback.NOOP);
7172
((JettyResponseListener)listener).onSuccess(response);
7273
((JettyResponseListener)listener).onComplete(new Result(request, response));
7374
}

bigdata-common-util/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ Copyright 2010 by TalkingTrends (Amsterdam, The Netherlands)
2828
<parent>
2929
<groupId>com.blazegraph</groupId>
3030
<artifactId>blazegraph-parent</artifactId>
31-
<version>2.1.4</version>
31+
<version>2.1.6-SNAPSHOT</version>
3232
<relativePath>../pom.xml</relativePath>
3333
</parent>
3434
<groupId>com.blazegraph</groupId>
3535
<artifactId>bigdata-common-util</artifactId>
36-
<version>2.1.4</version>
36+
<version>2.1.6-SNAPSHOT</version>
3737
<name>Blazegraph Common Utilities</name>
3838
<description>Blazegraph utilities common across artifacts</description>
3939
<build>
@@ -113,7 +113,7 @@ ga('send', 'pageview');
113113
</dependency>
114114
<dependency>
115115
<groupId>com.blazegraph</groupId>
116-
<artifactId>colt</artifactId>
116+
<artifactId>blazegraph-colt</artifactId>
117117
<version>${colt.version}</version>
118118
</dependency>
119119
<dependency>

bigdata-core-test/bigdata/src/test/com/bigdata/htree/TestHTree.java

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,24 @@
2727

2828
package com.bigdata.htree;
2929

30+
import java.util.HashSet;
31+
import java.util.LinkedList;
32+
import java.util.List;
33+
import java.util.Random;
34+
import java.util.Set;
35+
36+
import org.apache.commons.lang3.tuple.Pair;
37+
3038
import com.bigdata.btree.AbstractBTreeTestCase;
3139
import com.bigdata.btree.ITuple;
3240
import com.bigdata.btree.ITupleIterator;
3341
import com.bigdata.btree.raba.ReadOnlyKeysRaba;
3442
import com.bigdata.btree.raba.ReadOnlyValuesRaba;
3543
import com.bigdata.htree.data.MockBucketData;
44+
import com.bigdata.io.ByteArrayBuffer;
3645
import com.bigdata.rawstore.IRawStore;
3746
import com.bigdata.rawstore.SimpleMemoryRawStore;
47+
import com.bigdata.util.BytesUtil;
3848

3949
/**
4050
* Unit tests for {@link HTree}.
@@ -857,5 +867,97 @@ public void test_distinctBits() {
857867
}
858868

859869
}
860-
870+
871+
872+
/**
873+
* Insert data into the BTRee, making sure that data previously
874+
* inserted is found in later stages when looking it up.
875+
*/
876+
public void testInsertAndLookupDups() {
877+
878+
final int addressBits = 2;
879+
final IRawStore store = new SimpleMemoryRawStore();
880+
final HTree htree = getHTree(store, addressBits, true, true);
881+
882+
final Random rand = new Random(0);
883+
final List<Pair<byte[],byte[]>> keyValuePairs = new LinkedList<>();
884+
885+
final Set<Integer> insertedKeys = new HashSet<Integer>();
886+
for (int i=0; i<100000; i++) {
887+
888+
final int idx = nextKeyValuePair(keyValuePairs, rand);
889+
final Pair<byte[],byte[]> keyValuePair = keyValuePairs.get(idx);
890+
891+
// did we see this one before?
892+
final boolean isDuplicate = insertedKeys.contains(idx);
893+
894+
final byte[] key = keyValuePair.getLeft();
895+
final byte[] val = keyValuePair.getRight();
896+
897+
898+
if (isDuplicate) {
899+
900+
// validate that the key value pair is found in the HTree
901+
boolean confirmed = false;
902+
903+
904+
final ITupleIterator<?> titr = htree.lookupAll(key);
905+
906+
while (titr.hasNext()) {
907+
908+
final ITuple<?> t = titr.next();
909+
910+
final ByteArrayBuffer tb = t.getValueBuffer();
911+
912+
if (0 == BytesUtil.compareBytesWithLenAndOffset(
913+
0/* aoff */, val.length/* alen */, val, //
914+
0/* boff */, tb.limit()/* blen */, tb.array()/* b */
915+
)) {
916+
917+
confirmed = true;
918+
break;
919+
920+
}
921+
}
922+
923+
if (!confirmed) {
924+
throw new RuntimeException("Expected to find, but did not succeed");
925+
}
926+
927+
} else {
928+
929+
htree.insert(key, val); // insert into HTree
930+
insertedKeys.add(idx); // remember as duplicate for next encounter
931+
932+
}
933+
}
934+
}
935+
936+
937+
/**
938+
* Randomly either expends the keyValuePairs list by an element and
939+
* returns the index of the last list position OR returns an index
940+
* of a known position (i.e., a duplicate). Duplicates will be returned
941+
* about every 10th call.
942+
*/
943+
private int nextKeyValuePair(final List<Pair<byte[],byte[]>> keyValuePairs, final Random rand) {
944+
945+
// usually we generate a new key-value pair and append it to the index
946+
if (keyValuePairs.isEmpty() || rand.nextInt(10) != 0) {
947+
final byte[] key = new byte[4];
948+
final byte[] value = new byte[18];
949+
950+
rand.nextBytes(key);
951+
rand.nextBytes(value);
952+
953+
keyValuePairs.add(Pair.of(key, value));
954+
955+
return keyValuePairs.size()-1; // idx of generated value
956+
957+
} else { // !keyValuePairs.isEmpty() && rand.nextInt()==10
958+
959+
// return a tripe from before
960+
return rand.nextInt(keyValuePairs.size());
961+
}
962+
}
861963
}

0 commit comments

Comments
 (0)