Permalink
Browse files

rfe9318: Support session-based (rather than persistent) federation

<release-note>
rfe9318: Support session-based (rather than persistent) federation

The methods in AGServer for creating and deleting federations have
been replaced by a single method, federate, which takes any number of
repository objects, and returns a 'virtual' repository that federates
all of them.
</release-note>

<documentation>
I filed rfe9383 for Bruce to update the documentation.
</documentation>
  • Loading branch information...
marijnh committed Mar 2, 2010
1 parent 3c60b65 commit 369fcf0c66a0ebcd94a0b8b7b72ed6c1e0960454
@@ -91,12 +91,12 @@
(defn repo-federation
"rcons: may be of type AGRepository or AGRepositoryConnection"
- [#^AGServer server repo-name rcons rcon-args]
- (-> (.createFederation server repo-name
- (into-array AGRepository (map #(cond (instance? AGRepository %) %
- (nil? %) nil
- :else (.getRepository #^AGRepositoryConnection %))
- rcons)))
+ [#^AGServer server rcons rcon-args]
+ (-> (.federate server
+ (into-array AGRepository (map #(cond (instance? AGRepository %) %
+ (nil? %) nil
+ :else (.getRepository #^AGRepositoryConnection %))
+ rcons)))
open repo-init (repo-connection rcon-args)))
(defn ag-server
@@ -211,8 +211,7 @@
;; create two ordinary stores, and one federated store:
red-con (ag-repo-con cat "redthings" rcon-args)
green-con (ag-repo-con cat "greenthings" rcon-args)
- rainbow-con (repo-federation server "rainbowthings"
- [red-con green-con] rcon-args)
+ rainbow-con (repo-federation server [red-con green-con] rcon-args)
rf (value-factory red-con)
gf (value-factory green-con)
rbf (value-factory rainbow-con)]
@@ -382,7 +382,6 @@
green-rep (repo-init (repository cat "greenthings" :renew))
green-con (repo-connection green-rep rcon-args)
rainbow-rep (repo-init (repo-federation server
- "rainbowthings"
red-rep green-rep))
rainbow-con (repo-connection rainbow-rep rcon-args)
rf (value-factory red-con)
@@ -336,6 +336,25 @@ public TupleQueryResult getTupleQueryResult(String url) throws RepositoryExcepti
return handler.getString().split("\n");
}
+ public String openSession(String spec, boolean autocommit) throws RepositoryException {
+ String url = AGProtocol.getSessionURL(serverURL);
+ Header[] headers = new Header[0];
+ NameValuePair[] data = { new NameValuePair("store", spec),
+ new NameValuePair(AGProtocol.AUTOCOMMIT_PARAM_NAME,
+ Boolean.toString(autocommit)),
+ new NameValuePair(AGProtocol.LIFETIME_PARAM_NAME,
+ Long.toString(3600)) }; // TODO have some kind of policy for this
+ AGResponseHandler handler = new AGResponseHandler("");
+ try {
+ post(url, headers, data, null, handler);
+ } catch (HttpException e) {
+ throw new RepositoryException(e);
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ } catch (RDFParseException e) {}
+ return handler.getString();
+ }
+
@Override
public void close() {
Util.close(this.mManager);
Oops, something went wrong.

0 comments on commit 369fcf0

Please sign in to comment.