Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rfe10303: support revised bulk-load mode interface

<release-note>
rfe10303: support revised bulk-load mode interface

With this change, the Java client now supports the revised
bulk-load mode interface.  Bulk mode is now persistent (sticks
even after closing and reopening the store), and is controlled
with the AGRepository#setBulkMode and AGRepository#isBulkMode
methods, rather than per session.
</release-note>

Updated prepush test BulkModeTests
make prepush passes

Change-Id: I0bd4abc89e107523ab0228f15b9ade5f3ece045a
Reviewed-on: https://gerrit.franz.com:9080/1062
Reviewed-by: John O'Rourke <john.orourke@franz.com>
Reviewed-by: Ahmon Dancy <dancy@franz.com>
Tested-by: Kevin Layer <layer@franz.com>
  • Loading branch information...
commit e7c4e56ae7f052d8bb30890a583629eb9dc280c0 1 parent 5d661e0
Bill Millar authored dklayer committed
View
12 src/com/franz/agraph/http/AGHttpRepoClient.java
@@ -74,7 +74,6 @@
// delay using a dedicated session until necessary
private boolean usingDedicatedSession = false;
private boolean autoCommit = true;
- private boolean bulkMode = false;
private String sessionRoot, repoRoot;
// TODO: choose proper defaults
@@ -487,9 +486,6 @@ public void upload(String url, RequestEntity reqEntity, String baseURI,
params.add(new NameValuePair(AGProtocol.URL_PARAM_NAME,
serverSideURL.stringValue()));
}
- if (bulkMode) {
- params.add(new NameValuePair("bulkMode","true"));
- }
if (!overwrite) {
getHTTPClient().post(url,
headers.toArray(new Header[headers.size()]),
@@ -1453,14 +1449,6 @@ public void dropIndex(String index) throws RepositoryException {
}
}
- public void setBulkMode(boolean bulkMode) throws RepositoryException {
- this.bulkMode = bulkMode;
- }
-
- public boolean isBulkMode() throws RepositoryException {
- return bulkMode;
- }
-
public void registerEncodableNamespace(String namespace, String format)
throws RepositoryException {
String url = getRoot() + "/encodedIds/prefixes";
View
46 src/com/franz/agraph/repository/AGRepository.java
@@ -12,7 +12,10 @@
package com.franz.agraph.repository;
import java.io.File;
+import java.io.IOException;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.NameValuePair;
import org.openrdf.model.Value;
import org.openrdf.query.BindingSet;
import org.openrdf.query.QueryEvaluationException;
@@ -20,6 +23,7 @@
import org.openrdf.repository.RepositoryException;
import com.franz.agraph.http.AGHTTPClient;
+import com.franz.agraph.http.AGHttpException;
import com.franz.agraph.http.AGHttpRepoClient;
import com.franz.util.Closeable;
@@ -161,4 +165,46 @@ public void close() throws RepositoryException {
shutDown();
}
+ /**
+ * Sets the repository's bulkMode (defaults to false).
+ *
+ * When in bulkMode, data can be added/loaded more quickly, but
+ * there is no guarantee of durability in the event of a crash.
+ * The bulkMode setting persists when the repository is closed.
+ *
+ * @param bulkMode a boolean indicating the bulkMode.
+ * @throws RepositoryException
+ * @see #isBulkMode()
+ */
+ public void setBulkMode(boolean bulkMode) throws RepositoryException {
+ String url = repositoryURL + "/bulkMode";
+ Header[] headers = new Header[0];
+ NameValuePair[] data = {};
+ try {
+ if (bulkMode) {
+ getHTTPClient().put(url,headers,data,null);
+ } else {
+ getHTTPClient().delete(url,headers,data);
+ }
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ } catch (AGHttpException e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * Returns the repository's bulkMode setting.
+ *
+ * @return a boolean indicating the bulkMode setting.
+ * @throws RepositoryException
+ * @see #setBulkMode(boolean)
+ */
+ public boolean isBulkMode() throws RepositoryException {
+ try {
+ return Boolean.parseBoolean(getHTTPClient().getString(repositoryURL+"/bulkMode"));
+ } catch (AGHttpException e) {
+ throw new RepositoryException(e);
+ }
+ }
}
View
25 src/com/franz/agraph/repository/AGRepositoryConnection.java
@@ -886,31 +886,6 @@ public void sendRDFTransaction(InputStream rdftransaction) throws RepositoryExce
getHttpRepoClient().sendRDFTransaction(rdftransaction);
}
- /**
- * Sets the connection's bulkMode (defaults to false).
- *
- * When in bulkMode, data can be added/loaded more quickly, but
- * there is no guarantee of durability in the event of a crash.
- *
- * @param bulkMode a boolean indicating the bulkMode.
- * @throws RepositoryException
- * @see #isBulkMode()
- */
- public void setBulkMode(boolean bulkMode) throws RepositoryException {
- getHttpRepoClient().setBulkMode(bulkMode);
- }
-
- /**
- * Returns the connection's bulkMode setting.
- *
- * @return a boolean indicating the bulkMode setting.
- * @throws RepositoryException
- * @see #setBulkMode(boolean)
- */
- public boolean isBulkMode() throws RepositoryException {
- return getHttpRepoClient().isBulkMode();
- }
-
/**
* Registers an encodable namespace having the specified format.
*
View
2  src/test/AGUpload.java
@@ -41,7 +41,7 @@ public static void main(String[] args) throws Exception {
try {
System.out.println("Loading: " + SOURCE_FILE);
long start = System.nanoTime();
- conn.setBulkMode(true);
+ //repo.setBulkMode(true);
conn.add(new FileInputStream(SOURCE_FILE), null, RDFFormat.NTRIPLES);
System.out.println("Loaded: " + conn.size() + " triples in " + (System.nanoTime()-start)/1.0e9 + " seconds.");
} finally {
View
10 src/test/BulkModeTests.java
@@ -24,19 +24,19 @@
@Test
@Category(TestSuites.Prepush.class)
- public void bulkMode_rfe10143() throws Exception {
+ public void bulkMode_rfe10303() throws Exception {
+ Assert.assertFalse("expected bulkMode false", repo.isBulkMode());
Assert.assertTrue("expected autoCommit true", conn.isAutoCommit());
- Assert.assertFalse("expected bulkMode false", conn.isBulkMode());
- conn.setBulkMode(true);
+ repo.setBulkMode(true);
Assert.assertTrue("expected autoCommit true", conn.isAutoCommit());
- Assert.assertTrue("expected bulkMode true", conn.isBulkMode());
+ Assert.assertTrue("expected bulkMode true", repo.isBulkMode());
String path1 = "src/tutorial/java-vcards.rdf";
URI context = vf.createURI("http://example.org#vcards");
conn.add(new File(path1), null, RDFFormat.RDFXML, context);
assertEquals("expected 16 vcard triples", 16, conn.size(context));
conn.setAutoCommit(false);
Assert.assertFalse("expected autoCommit false", conn.isAutoCommit());
- Assert.assertTrue("expected bulkMode true", conn.isBulkMode());
+ Assert.assertTrue("expected bulkMode true", repo.isBulkMode());
String path2 = "src/tutorial/java-kennedy.ntriples";
conn.add(new File(path2), null, RDFFormat.NTRIPLES);
assertEquals("expected 1214 kennedy triples", 1214, conn.size((Resource)null));
View
3  src/test/TestSuites.java
@@ -55,8 +55,7 @@
JenaTests.class,
BulkModeTests.class,
IndexManagementTests.class,
- EncodableNamespaceTests.class,
- FederationTests.class
+ EncodableNamespaceTests.class
})
public static class Prepush {}
Please sign in to comment.
Something went wrong with that request. Please try again.