jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1578557 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment: SegmentNodeStoreService.java http/HttpStore.java
Date Mon, 17 Mar 2014 20:42:19 GMT
Author: alexparvulescu
Date: Mon Mar 17 20:42:19 2014
New Revision: 1578557

URL: http://svn.apache.org/r1578557
Log:
OAK-1161 Simple failover for TarMK-based installations
 - exposed SegmentStore to be usable from the failover code
 - refactored 'get' method so that it can be extended

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/http/HttpStore.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java?rev=1578557&r1=1578556&r2=1578557&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
Mon Mar 17 20:42:19 2014
@@ -170,6 +170,14 @@ public class SegmentNodeStoreService ext
         }
     }
 
+    /**
+     * needed for situations where you have to unwrap the
+     * SegmentNodeStoreService, to get the SegmentStore, like the failover
+     */
+    public SegmentStore getSegmentStore() {
+        return store;
+    }
+
     //------------------------------------------------------------< Observable >---
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/http/HttpStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/http/HttpStore.java?rev=1578557&r1=1578556&r2=1578557&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/http/HttpStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/http/HttpStore.java
Mon Mar 17 20:42:19 2014
@@ -61,10 +61,26 @@ public class HttpStore implements Segmen
         return tracker;
     }
 
+    /**
+     * Builds a simple URLConnection. This method can be extended to add
+     * authorization headers if needed.
+     * 
+     */
+    protected URLConnection get(String fragment) throws MalformedURLException,
+            IOException {
+        final URL url;
+        if (fragment == null) {
+            url = base;
+        } else {
+            url = new URL(base, fragment);
+        }
+        return url.openConnection();
+    }
+
     @Override
     public SegmentNodeState getHead() {
         try {
-            URLConnection connection = base.openConnection();
+            URLConnection connection = get(null);
             InputStream stream = connection.getInputStream();
             try {
                 BufferedReader reader = new BufferedReader(
@@ -97,8 +113,7 @@ public class HttpStore implements Segmen
     @Override
     public Segment readSegment(SegmentId id) {
         try {
-            URLConnection connection =
-                    new URL(base, id.toString()).openConnection();
+            URLConnection connection = get(id.toString());
             InputStream stream = connection.getInputStream();
             try {
                 byte[] data = ByteStreams.toByteArray(stream);
@@ -117,8 +132,7 @@ public class HttpStore implements Segmen
     public void writeSegment(
             SegmentId id, byte[] bytes, int offset, int length) {
         try {
-            URLConnection connection =
-                    new URL(base, id.toString()).openConnection();
+            URLConnection connection = get(id.toString());
             connection.setDoInput(false);
             connection.setDoOutput(true);
             OutputStream stream = connection.getOutputStream();



Mime
View raw message