Author: reschke
Date: Fri Feb 13 13:57:42 2015
New Revision: 1659569
URL: http://svn.apache.org/r1659569
Log:
OAK-2518 - backport DocumentStoreException (OAK-1961) to Oak 1.0
Added:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreException.java
- copied, changed from r1609214,
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreException.java
Modified:
jackrabbit/oak/branches/1.0/ (props changed)
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/BatchCommit.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Collision.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/memory/MemoryDocumentStore.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/LoggingDocumentStoreWrapper.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/SynchronizingDocumentStoreWrapper.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/TimingDocumentStoreWrapper.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStoreBranch.java
jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Propchange: jackrabbit/oak/branches/1.0/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb 13 13:57:42 2015
@@ -1,2 +1,2 @@
-/jackrabbit/oak/trunk:1584578,1584602,1584614,1584616,1584709,1584781,1584937,1585297,1585304-1585305,1585420,1585424,1585427,1585448,1585465,1585468,1585486,1585497,1585509,1585647,1585655-1585656,1585661,1585665-1585666,1585669-1585670,1585673,1585680,1585719,1585763,1585770,1585896,1585904,1585907,1585940,1585949,1585951,1585956,1585962-1585963,1586287,1586320,1586364,1586372,1586655,1586836,1587130,1587224,1587399,1587408,1587472,1587485,1587488,1587538,1587580,1587807,1588033,1588042,1588046,1588066,1588201,1589025,1589101,1589137,1589141,1589263,1589440,1589442,1589484,1589488,1589661,1589664,1589682,1589708,1589741,1589748,1589789,1589794,1589850,1589864,1590628,1590660,1590684,1590697,1590701,1590980,1590988,1591101,1591226,1591229,1591293,1591314,1591317,1591362,1591374,1591381,1591438,1591467,1591552,1591704,1591713,1591715,1591723,1591874,1592487,1592512,1592658,1592665,1592677,1592742,1592744,1592787,1592809,1592955,1593036,1593048,1593061,1593133,1593210-1593211,1593231
,1593245,1593250,1593294,1593304,1593317,1593342,1593554,1594158-1594164,1594166-1594167,1594169,1594237,1594800,1594808,1594835,1594888,1595147,1595457,1595856,1596241,1596474,1596534,1596844,1597569,1597795,1597854,1597860,1598292,1598302,1598352,1598369,1598595,1598631,1598696,1598732,1598797-1598798,1599299,1599332,1599416,1599434,1599671,1600088,1600935,1601309,1601388,1601578,1601676,1601757,1601768,1601814,1601833,1601838,1601853,1601878,1601888,1601922,1602156,1602174,1602179,1602183,1602207,1602227,1602256,1602261,1602796-1602797,1602800,1602809,1602853,1602872,1602914,1603155,1603307,1603401,1603441,1603748,1604166,1605030,1605036,1605038,1605292,1605447,1605526,1605670,1605725,1605831,1605852,1606077,1606079,1606087,1606638,1606641,1606644,1606708,1606711,1607031-1607032,1607077,1607127,1607141,1607152,1607185,1607196,1607331,1607362,1607366,1607392,1607526,1607557,1607664,1607737,1608560,1608731,1608783,1609064,1609081,1609165,1609488,1610489,1610592,1610603,1610634,1610
658,1610664,1611021,1611041,1611275,1611277,1611313,1611332,1611584,1612560,1612825,1612993,1613018,1613041,1614265,1614272,1614344-1614345,1614384-1614385,1614397,1614405-1614406,1614574,1614591,1614593,1614596,1614604,1614689,1614807,1614835,1614891,1615417-1615418,1616182,1616236,1616463,1616719,1617417,1617451,1617463,1617711,1618158,1618613,1618624,1618709,1619222,1619411,1619695,1619800,1619808,1619815,1619823-1619824,1620512,1620581,1620585,1620634,1620898,1620905,1621115,1621123-1621124,1621168,1621192,1621201,1621706,1621962,1622197,1622201,1622207,1622250,1622479,1623364,1623766,1623827,1623949,1623969,1623973,1624216,1624317,1624551,1624559,1624973,1624993-1624994,1625025,1625036,1625158,1625224,1625237,1625299,1625348,1625620,1625916,1625962-1625963,1626021,1626053,1626163,1626168,1626175,1626191,1626265,1626770,1627047,1627052,1627228,1627346,1627470,1627473,1627479,1627503,1627586,1627590,1627715,1627731,1628180,1628198,1628262,1628447,1628608,1629688,1629840,1629917,1
630055-1630057,1630156,1630299,1630338,1630773,1631283-1631284,1631333-1631334,1631617-1631619,1631630,1631699,1631704,1631711,1631967-1631969,1631986,1631990,1631999,1632002-1632003,1632017,1632258,1632264,1632270,1632293,1632303,1632592,1632605,1633315,1633559-1633560,1633562,1633567,1633571,1633598,1633608,1633641,1633687,1633697,1633768,1633783,1634505,1634513,1634774,1634779,1634781,1634792,1634803,1634814,1634816,1634838,1634841,1634852,1634864,1634896,1634898,1635044-1635045,1635060,1635077,1635089,1635102,1635108,1635218,1635387,1635435,1635518,1635563,1635586,1636336,1636348,1636505,1636585,1636799,1637368,1637382,1637413,1637651,1637815,1638779-1638783,1639260,1639577,1639622,1639963,1639966,1639973,1640134,1640143,1640555-1640556,1640694-1640695,1640715,1640722-1640723,1640728,1640863-1640872,1641340,1641350,1641352,1641541,1641596-1641599,1641601,1641662,1641671,1641695,1641771,1641802,1641811,1641950,1642031,1642056,1642119,1642285,1642648,1642667,1642954,1642959,164311
1,1643178,1643186,1643204,1643287,1643767,1643774,1643982,1644016,1644106,1644366,1644383,1644397-1644398,1644407,1644479,1644547,1644552,1644554,1644588,1644650,1644654,1644689,1644750,1645421,1645424,1645459,1645585,1645611,1645637,1645646,1645660-1645663,1645888,1645901,1645948,1645966,1645970-1645971,1646014,1646164,1646174,1646684,1649743,1649803,1650015,1650239,1650529,1650797,1651323,1651382,1651643,1651652,1651730,1651988-1651989,1651996,1652024,1652035,1652058-1652059,1652075,1652127,1652158,1652467,1652965,1652971,1653207,1653446,1653463,1653572,1653579,1653591,1653804,1653809,1653849-1653850,1653882,1654116,1654743,1654756,1654778,1655049,1655054-1655055,1655237,1655248,1655996,1656027,1656394,1656400,1656425,1656427,1656453,1656628,1659483,1659527,1659550
+/jackrabbit/oak/trunk:1584578,1584602,1584614,1584616,1584709,1584781,1584937,1585297,1585304-1585305,1585420,1585424,1585427,1585448,1585465,1585468,1585486,1585497,1585509,1585647,1585655-1585656,1585661,1585665-1585666,1585669-1585670,1585673,1585680,1585719,1585763,1585770,1585896,1585904,1585907,1585940,1585949,1585951,1585956,1585962-1585963,1586287,1586320,1586364,1586372,1586655,1586836,1587130,1587224,1587399,1587408,1587472,1587485,1587488,1587538,1587580,1587807,1588033,1588042,1588046,1588066,1588201,1589025,1589101,1589137,1589141,1589263,1589440,1589442,1589484,1589488,1589661,1589664,1589682,1589708,1589741,1589748,1589789,1589794,1589850,1589864,1590628,1590660,1590684,1590697,1590701,1590980,1590988,1591101,1591226,1591229,1591293,1591314,1591317,1591362,1591374,1591381,1591438,1591467,1591552,1591704,1591713,1591715,1591723,1591874,1592487,1592512,1592658,1592665,1592677,1592742,1592744,1592787,1592809,1592955,1593036,1593048,1593061,1593133,1593210-1593211,1593231
,1593245,1593250,1593294,1593304,1593317,1593342,1593554,1594158-1594164,1594166-1594167,1594169,1594237,1594800,1594808,1594835,1594888,1595147,1595457,1595856,1596241,1596474,1596534,1596844,1597569,1597795,1597854,1597860,1598292,1598302,1598352,1598369,1598595,1598631,1598696,1598732,1598797-1598798,1599299,1599332,1599416,1599434,1599671,1600088,1600935,1601309,1601388,1601578,1601676,1601757,1601768,1601814,1601833,1601838,1601853,1601878,1601888,1601922,1602156,1602174,1602179,1602183,1602207,1602227,1602256,1602261,1602796-1602797,1602800,1602809,1602853,1602872,1602914,1603155,1603307,1603401,1603441,1603748,1604166,1605030,1605036,1605038,1605292,1605447,1605526,1605670,1605725,1605831,1605852,1606077,1606079,1606087,1606638,1606641,1606644,1606708,1606711,1607031-1607032,1607077,1607127,1607141,1607152,1607185,1607196,1607331,1607362,1607366,1607392,1607526,1607557,1607664,1607737,1608560,1608731,1608783,1609064,1609081,1609165,1609214,1609488,1610489,1610592,1610603,1610
634,1610658,1610664,1611021,1611041,1611270,1611275,1611277,1611313,1611332,1611584,1612560,1612825,1612993,1613018,1613041,1614265,1614272,1614344-1614345,1614384-1614385,1614397,1614405-1614406,1614574,1614591,1614593,1614596,1614604,1614689,1614807,1614835,1614891,1615417-1615418,1616182,1616236,1616463,1616719,1617417,1617451,1617463,1617711,1618158,1618613,1618624,1618709,1619222,1619411,1619695,1619800,1619808,1619815,1619823-1619824,1620512,1620581,1620585,1620634,1620898,1620905,1621115,1621123-1621124,1621168,1621192,1621201,1621706,1621962,1622197,1622201,1622207,1622250,1622479,1623364,1623766,1623827,1623949,1623969,1623973,1624216,1624317,1624551,1624559,1624973,1624993-1624994,1625025,1625036,1625158,1625224,1625237,1625299,1625348,1625620,1625916,1625962-1625963,1626021,1626053,1626163,1626168,1626175,1626191,1626265,1626770,1627047,1627052,1627228,1627346,1627470,1627473,1627479,1627503,1627586,1627590,1627715,1627731,1628180,1628198,1628262,1628447,1628608,1629688,1
629840,1629917,1630055-1630057,1630156,1630299,1630338,1630773,1631283-1631284,1631333-1631334,1631617-1631619,1631630,1631699,1631704,1631711,1631967-1631969,1631986,1631990,1631999,1632002-1632003,1632017,1632258,1632264,1632270,1632293,1632303,1632592,1632605,1633315,1633559-1633560,1633562,1633567,1633571,1633598,1633608,1633641,1633687,1633697,1633768,1633783,1634505,1634513,1634774,1634779,1634781,1634792,1634803,1634814,1634816,1634838,1634841,1634852,1634864,1634896,1634898,1635044-1635045,1635060,1635077,1635089,1635102,1635108,1635218,1635387,1635435,1635518,1635563,1635586,1636336,1636348,1636505,1636585,1636799,1637368,1637382,1637413,1637651,1637815,1638779-1638783,1639260,1639577,1639622,1639963,1639966,1639973,1640134,1640143,1640555-1640556,1640694-1640695,1640715,1640722-1640723,1640728,1640863-1640872,1641340,1641350,1641352,1641541,1641596-1641599,1641601,1641662,1641671,1641695,1641771,1641802,1641811,1641950,1642031,1642056,1642119,1642285,1642648,1642667,164295
4,1642959,1643111,1643178,1643186,1643204,1643287,1643767,1643774,1643982,1644016,1644106,1644366,1644383,1644397-1644398,1644407,1644479,1644547,1644552,1644554,1644588,1644650,1644654,1644689,1644750,1645421,1645424,1645459,1645585,1645611,1645637,1645646,1645660-1645663,1645888,1645901,1645948,1645966,1645970-1645971,1646014,1646164,1646174,1646684,1649743,1649803,1650015,1650239,1650529,1650797,1651323,1651382,1651643,1651652,1651730,1651988-1651989,1651996,1652024,1652035,1652058-1652059,1652075,1652127,1652158,1652467,1652965,1652971,1653207,1653446,1653463,1653572,1653579,1653591,1653804,1653809,1653849-1653850,1653882,1654116,1654743,1654756,1654778,1655049,1655054-1655055,1655237,1655248,1655996,1656027,1656394,1656400,1656425,1656427,1656453,1656628,1659483,1659527,1659550
/jackrabbit/trunk:1345480
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java?rev=1659569&r1=1659568&r2=1659569&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
Fri Feb 13 13:57:42 2015
@@ -32,6 +32,7 @@ import org.apache.jackrabbit.oak.spi.sta
import org.apache.jackrabbit.oak.spi.state.NodeState;
import static org.apache.jackrabbit.oak.api.CommitFailedException.MERGE;
+import static org.apache.jackrabbit.oak.api.CommitFailedException.OAK;
/**
* {@code NodeStoreBranch} based on {@link MicroKernel} branching and merging.
@@ -125,7 +126,19 @@ public class KernelNodeStoreBranch exten
return store.commit(">\"" + source + "\":\"" + target + '"', base);
}
-//------------------------< NodeStoreBranch >-------------------------------
+ @Override
+ protected CommitFailedException convertUnchecked(Exception cause,
+ String msg) {
+ String type;
+ if (cause instanceof MicroKernelException) {
+ type = MERGE;
+ } else {
+ type = OAK;
+ }
+ return new CommitFailedException(type, 1, msg, cause);
+ }
+
+ //------------------------< NodeStoreBranch
>-------------------------------
@Nonnull
@Override
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/BatchCommit.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/BatchCommit.java?rev=1659569&r1=1659568&r2=1659569&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/BatchCommit.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/BatchCommit.java
Fri Feb 13 13:57:42 2015
@@ -20,9 +20,9 @@ import java.util.Comparator;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-import org.apache.jackrabbit.mk.api.MicroKernelException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -83,7 +83,11 @@ final class BatchCommit {
BatchCommit.this.wait();
}
}
- return execute(idx).get();
+ try {
+ return execute(idx).get();
+ } catch (ExecutionException e) {
+ throw DocumentStoreException.convert(e.getCause());
+ }
}
};
} else {
@@ -138,7 +142,7 @@ final class BatchCommit {
finished.await();
} catch (InterruptedException e) {
String msg = "Interrupted while waiting for batch commit to
finish";
- return Futures.immediateFailedFuture(new
MicroKernelException(msg));
+ return Futures.immediateFailedFuture(new
DocumentStoreException(msg));
}
}
return results.get(idx);
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java?rev=1659569&r1=1659568&r2=1659569&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java
Fri Feb 13 13:57:42 2015
@@ -27,7 +27,6 @@ import java.util.Enumeration;
import java.util.List;
import java.util.UUID;
-import org.apache.jackrabbit.mk.api.MicroKernelException;
import org.apache.jackrabbit.oak.commons.StringUtils;
import org.apache.jackrabbit.oak.stats.Clock;
import org.slf4j.Logger;
@@ -295,7 +294,7 @@ public class ClusterNodeInfo {
return clusterNode;
}
}
- throw new MicroKernelException("Could not get cluster node info");
+ throw new DocumentStoreException("Could not get cluster node info");
}
private static ClusterNodeInfo createInstance(DocumentStore store, String
machineId,
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Collision.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Collision.java?rev=1659569&r1=1659568&r2=1659569&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Collision.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Collision.java
Fri Feb 13 13:57:42 2015
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.oak.plugin
import javax.annotation.Nonnull;
-import org.apache.jackrabbit.mk.api.MicroKernelException;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -68,10 +67,10 @@ class Collision {
*
* @param store the document store.
* @return the revision that was marked. Either our or their.
- * @throws MicroKernelException if the mark operation fails.
+ * @throws DocumentStoreException if the mark operation fails.
*/
@Nonnull
- Revision mark(DocumentStore store) throws MicroKernelException {
+ Revision mark(DocumentStore store) throws DocumentStoreException {
// first try to mark their revision
if (markCommitRoot(document, theirRev, store)) {
return theirRev;
@@ -146,8 +145,8 @@ class Collision {
private static void throwNoCommitRootException(@Nonnull Revision revision,
@Nonnull Document document)
- throws
MicroKernelException {
- throw new MicroKernelException("No commit root for revision: "
+ throws
DocumentStoreException {
+ throw new DocumentStoreException("No commit root for revision: "
+ revision + ", document: " + document.format());
}
}
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java?rev=1659569&r1=1659568&r2=1659569&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
Fri Feb 13 13:57:42 2015
@@ -29,7 +29,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.google.common.collect.Sets;
-import org.apache.jackrabbit.mk.api.MicroKernelException;
import org.apache.jackrabbit.oak.commons.json.JsopStream;
import org.apache.jackrabbit.oak.commons.json.JsopWriter;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
@@ -148,7 +147,7 @@ public class Commit {
if (operations.containsKey(path)) {
String msg = "Node already added: " + path;
LOG.error(msg);
- throw new MicroKernelException(msg);
+ throw new DocumentStoreException(msg);
}
operations.put(path, n.asOperation(true));
addedNodes.add(path);
@@ -162,11 +161,10 @@ public class Commit {
* Applies this commit to the store.
*
* @return the commit revision.
- * @throws MicroKernelException if the commit cannot be applied.
- * TODO: use non-MK exception type
+ * @throws DocumentStoreException if the commit cannot be applied.
*/
@Nonnull
- Revision apply() throws MicroKernelException {
+ Revision apply() throws DocumentStoreException {
boolean success = false;
Revision baseRev = getBaseRevision();
boolean isBranch = baseRev != null && baseRev.isBranch();
@@ -373,7 +371,7 @@ public class Commit {
if (before == null) {
String msg = "Conflicting concurrent change. " +
"Update operation failed: " + commitRoot;
- throw new MicroKernelException(msg);
+ throw new DocumentStoreException(msg);
} else {
// if we get here the commit was successful and
// the commit revision is set on the commitRoot
@@ -391,7 +389,7 @@ public class Commit {
}
operations.put(commitRootPath, commitRoot);
}
- } catch (MicroKernelException e) {
+ } catch (DocumentStoreException e) {
rollback(newNodes, opLog, commitRoot);
throw e;
}
@@ -525,7 +523,7 @@ public class Commit {
conflictMessage += ", before\n" + revision +
"; document:\n" + (before == null ? "" :
before.format()) +
",\nrevision order:\n" +
nodeStore.getRevisionComparator();
- throw new MicroKernelException(conflictMessage);
+ throw new DocumentStoreException(conflictMessage);
}
}
}
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java?rev=1659569&r1=1659568&r2=1659569&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java
Fri Feb 13 13:57:42 2015
@@ -142,7 +142,11 @@ public class DocumentMK implements Micro
@Override @Nonnull
public String checkpoint(long lifetime) throws MicroKernelException {
- return nodeStore.checkpoint(lifetime);
+ try {
+ return nodeStore.checkpoint(lifetime);
+ } catch (DocumentStoreException e) {
+ throw new MicroKernelException(e);
+ }
}
@Override
@@ -177,7 +181,11 @@ public class DocumentMK implements Micro
if (path == null || path.equals("")) {
path = "/";
}
- return nodeStore.diff(fromRevisionId, toRevisionId, path);
+ try {
+ return nodeStore.diff(fromRevisionId, toRevisionId, path);
+ } catch (DocumentStoreException e) {
+ throw new MicroKernelException(e);
+ }
}
@Override
@@ -188,7 +196,12 @@ public class DocumentMK implements Micro
}
revisionId = revisionId != null ? revisionId :
nodeStore.getHeadRevision().toString();
Revision rev = Revision.fromString(revisionId);
- DocumentNodeState n = nodeStore.getNode(path, rev);
+ DocumentNodeState n;
+ try {
+ n = nodeStore.getNode(path, rev);
+ } catch (DocumentStoreException e) {
+ throw new MicroKernelException(e);
+ }
return n != null;
}
@@ -208,40 +221,44 @@ public class DocumentMK implements Micro
}
revisionId = revisionId != null ? revisionId :
nodeStore.getHeadRevision().toString();
Revision rev = Revision.fromString(revisionId);
- DocumentNodeState n = nodeStore.getNode(path, rev);
- if (n == null) {
- return null;
- }
- JsopStream json = new JsopStream();
- boolean includeId = filter != null && filter.contains(":id");
- includeId |= filter != null && filter.contains(":hash");
- json.object();
- n.append(json, includeId);
- int max;
- if (maxChildNodes == -1) {
- max = Integer.MAX_VALUE;
- maxChildNodes = Integer.MAX_VALUE;
- } else {
- // use long to avoid overflows
- long m = ((long) maxChildNodes) + offset;
- max = (int) Math.min(m, Integer.MAX_VALUE);
- }
- Children c = nodeStore.getChildren(n, null, max);
- for (long i = offset; i < c.children.size(); i++) {
- if (maxChildNodes-- <= 0) {
- break;
+ try {
+ DocumentNodeState n = nodeStore.getNode(path, rev);
+ if (n == null) {
+ return null;
}
- String name = c.children.get((int) i);
- json.key(name).object().endObject();
- }
- if (c.hasMore) {
- // TODO use a better way to notify there are more children
- json.key(":childNodeCount").value(Long.MAX_VALUE);
- } else {
- json.key(":childNodeCount").value(c.children.size());
+ JsopStream json = new JsopStream();
+ boolean includeId = filter != null && filter.contains(":id");
+ includeId |= filter != null && filter.contains(":hash");
+ json.object();
+ n.append(json, includeId);
+ int max;
+ if (maxChildNodes == -1) {
+ max = Integer.MAX_VALUE;
+ maxChildNodes = Integer.MAX_VALUE;
+ } else {
+ // use long to avoid overflows
+ long m = ((long) maxChildNodes) + offset;
+ max = (int) Math.min(m, Integer.MAX_VALUE);
+ }
+ Children c = nodeStore.getChildren(n, null, max);
+ for (long i = offset; i < c.children.size(); i++) {
+ if (maxChildNodes-- <= 0) {
+ break;
+ }
+ String name = c.children.get((int) i);
+ json.key(name).object().endObject();
+ }
+ if (c.hasMore) {
+ // TODO use a better way to notify there are more children
+ json.key(":childNodeCount").value(Long.MAX_VALUE);
+ } else {
+ json.key(":childNodeCount").value(c.children.size());
+ }
+ json.endObject();
+ return json.toString();
+ } catch (DocumentStoreException e) {
+ throw new MicroKernelException(e);
}
- json.endObject();
- return json.toString();
}
@Override
@@ -257,6 +274,8 @@ public class DocumentMK implements Micro
parseJsonDiff(commit, jsonDiff, rootPath);
rev = commit.apply();
success = true;
+ } catch (DocumentStoreException e) {
+ throw new MicroKernelException(e);
} finally {
if (!success) {
nodeStore.canceled(commit);
@@ -286,8 +305,10 @@ public class DocumentMK implements Micro
}
try {
return nodeStore.merge(revision, null).toString();
+ } catch (DocumentStoreException e) {
+ throw new MicroKernelException(e);
} catch (CommitFailedException e) {
- throw new MicroKernelException(e.getMessage(), e);
+ throw new MicroKernelException(e);
}
}
@@ -316,7 +337,11 @@ public class DocumentMK implements Micro
if (!ancestor.isBranch()) {
throw new MicroKernelException("Not a branch revision: " +
ancestorRevisionId);
}
- return nodeStore.reset(branch, ancestor, null).toString();
+ try {
+ return nodeStore.reset(branch, ancestor, null).toString();
+ } catch (DocumentStoreException e) {
+ throw new MicroKernelException(e);
+ }
}
@Override
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java?rev=1659569&r1=1659568&r2=1659569&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
Fri Feb 13 13:57:42 2015
@@ -63,7 +63,6 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-import org.apache.jackrabbit.mk.api.MicroKernelException;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.commons.jmx.AnnotatedStandardMBean;
import org.apache.jackrabbit.oak.commons.json.JsopReader;
@@ -712,14 +711,14 @@ public final class DocumentNodeStore
});
return node == missing || node.equals(missing) ? null : node;
} catch (ExecutionException e) {
- throw new MicroKernelException(e);
+ throw DocumentStoreException.convert(e.getCause());
}
}
DocumentNodeState.Children getChildren(@Nonnull final DocumentNodeState
parent,
@Nullable final String name,
final int limit)
- throws MicroKernelException {
+ throws DocumentStoreException {
if (checkNotNull(parent).hasNoChildren()) {
return DocumentNodeState.NO_CHILDREN;
}
@@ -743,9 +742,9 @@ public final class DocumentNodeStore
}
return children;
} catch (ExecutionException e) {
- throw new MicroKernelException(
+ throw DocumentStoreException.convert(e.getCause(),
"Error occurred while fetching children for path "
- + path, e.getCause());
+ + path);
}
}
@@ -910,7 +909,7 @@ public final class DocumentNodeStore
String p = PathUtils.concat(parent.getPath(), input);
DocumentNodeState result = getNode(p, readRevision);
if (result == null) {
- throw new MicroKernelException("DocumentNodeState is null
for revision " + readRevision + " of " + p
+ throw new DocumentStoreException("DocumentNodeState is
null for revision " + readRevision + " of " + p
+ " (aborting getChildNodes())");
}
return result;
@@ -1028,10 +1027,10 @@ public final class DocumentNodeStore
* @param commit the updates to apply on the commit root document.
* @return the document before the update was applied or <code>null</code>
* if the update failed because of a collision.
- * @throws MicroKernelException if the update fails with an error.
+ * @throws DocumentStoreException if the update fails with an error.
*/
@CheckForNull
- NodeDocument updateCommitRoot(UpdateOp commit) throws MicroKernelException
{
+ NodeDocument updateCommitRoot(UpdateOp commit) throws
DocumentStoreException {
// use batch commit when there are only revision and modified updates
// and collision checks
boolean batch = true;
@@ -1053,25 +1052,15 @@ public final class DocumentNodeStore
}
private NodeDocument batchUpdateCommitRoot(UpdateOp commit)
- throws MicroKernelException {
+ throws DocumentStoreException {
try {
return batchCommitQueue.updateDocument(commit).call();
} catch (InterruptedException e) {
- throw new MicroKernelException("Interrupted while updating commit
root document");
- } catch (ExecutionException e) {
- if (e.getCause() instanceof MicroKernelException) {
- throw (MicroKernelException) e.getCause();
- } else {
- String msg = "Update of commit root document failed";
- throw new MicroKernelException(msg, e.getCause());
- }
+ throw DocumentStoreException.convert(e,
+ "Interrupted while updating commit root document");
} catch (Exception e) {
- if (e instanceof MicroKernelException) {
- throw (MicroKernelException) e;
- } else {
- String msg = "Update of commit root document failed";
- throw new MicroKernelException(msg, e);
- }
+ throw DocumentStoreException.convert(e,
+ "Update of commit root document failed");
}
}
@@ -1131,14 +1120,14 @@ public final class DocumentNodeStore
checkNotNull(ancestor);
Branch b = getBranches().getBranch(branchHead);
if (b == null) {
- throw new MicroKernelException("Empty branch cannot be reset");
+ throw new DocumentStoreException("Empty branch cannot be reset");
}
if (!b.getCommits().last().equals(branchHead)) {
- throw new MicroKernelException(branchHead + " is not the head " +
+ throw new DocumentStoreException(branchHead + " is not the head " +
"of a branch");
}
if (!b.containsCommit(ancestor)) {
- throw new MicroKernelException(ancestor + " is not " +
+ throw new DocumentStoreException(ancestor + " is not " +
"an ancestor revision of " + branchHead);
}
if (branchHead.equals(ancestor)) {
@@ -1265,7 +1254,7 @@ public final class DocumentNodeStore
String diff(@Nonnull final String fromRevisionId,
@Nonnull final String toRevisionId,
- @Nonnull final String path) throws MicroKernelException {
+ @Nonnull final String path) throws DocumentStoreException {
if (fromRevisionId.equals(toRevisionId)) {
return "";
}
@@ -1278,7 +1267,7 @@ public final class DocumentNodeStore
String msg = String.format("Diff is only supported if the node
exists in both cases. " +
"Node [%s], fromRev [%s] -> %s, toRev [%s] -> %s",
path, fromRev, from != null, toRev, to != null);
- throw new MicroKernelException(msg);
+ throw new DocumentStoreException(msg);
}
String compactDiff = diffCache.getChanges(fromRev, toRev, path,
new DiffCache.Loader() {
@@ -1705,7 +1694,7 @@ public final class DocumentNodeStore
}
private String diffImpl(DocumentNodeState from, DocumentNodeState to)
- throws MicroKernelException {
+ throws DocumentStoreException {
JsopWriter w = new JsopStream();
// TODO this does not work well for large child node lists
// use a document store index instead
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java?rev=1659569&r1=1659568&r2=1659569&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranch.java
Fri Feb 13 13:57:42 2015
@@ -32,6 +32,7 @@ import org.apache.jackrabbit.oak.spi.sta
import static com.google.common.base.Preconditions.checkState;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.jackrabbit.oak.api.CommitFailedException.MERGE;
+import static org.apache.jackrabbit.oak.api.CommitFailedException.OAK;
/**
* Implementation of a DocumentMK based node store branch.
@@ -127,6 +128,18 @@ class DocumentNodeStoreBranch
}, base, null);
}
+ @Override
+ protected CommitFailedException convertUnchecked(Exception cause,
+ String msg) {
+ String type;
+ if (cause instanceof DocumentStoreException) {
+ type = MERGE;
+ } else {
+ type = OAK;
+ }
+ return new CommitFailedException(type, 1, msg, cause);
+ }
+
@Nonnull
@Override
public NodeState merge(@Nonnull CommitHook hook, @Nonnull CommitInfo info)
Copied:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreException.java
(from r1609214,
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreException.java)
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreException.java?p2=jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreException.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreException.java&r1=1609214&r2=1659569&rev=1659569&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreException.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreException.java
Fri Feb 13 13:57:42 2015
@@ -45,7 +45,7 @@ public class DocumentStoreException exte
if (t instanceof DocumentStoreException) {
return (DocumentStoreException) t;
} else {
- return new DocumentStoreException(msg, t.getCause());
+ return new DocumentStoreException(msg, t);
}
}
}
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/memory/MemoryDocumentStore.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/memory/MemoryDocumentStore.java?rev=1659569&r1=1659568&r2=1659569&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/memory/MemoryDocumentStore.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/memory/MemoryDocumentStore.java
Fri Feb 13 13:57:42 2015
@@ -29,10 +29,10 @@ import java.util.concurrent.locks.Reentr
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
-import org.apache.jackrabbit.mk.api.MicroKernelException;
import org.apache.jackrabbit.oak.plugins.document.Collection;
import org.apache.jackrabbit.oak.plugins.document.Document;
import org.apache.jackrabbit.oak.plugins.document.DocumentStore;
+import org.apache.jackrabbit.oak.plugins.document.DocumentStoreException;
import org.apache.jackrabbit.oak.plugins.document.NodeDocument;
import org.apache.jackrabbit.oak.plugins.document.Revision;
import org.apache.jackrabbit.oak.plugins.document.StableRevisionComparator;
@@ -134,7 +134,7 @@ public class MemoryDocumentStore impleme
continue;
}
} else if (value != null) {
- throw new MicroKernelException("unexpected type for
property " + indexedProperty + ": "
+ throw new DocumentStoreException("unexpected type for
property " + indexedProperty + ": "
+ value.getClass());
}
}
@@ -169,14 +169,12 @@ public class MemoryDocumentStore impleme
@CheckForNull
@Override
- public <T extends Document> T createOrUpdate(Collection<T> collection,
UpdateOp update)
- throws MicroKernelException {
+ public <T extends Document> T createOrUpdate(Collection<T> collection,
UpdateOp update) {
return internalCreateOrUpdate(collection, update, false);
}
@Override
- public <T extends Document> T findAndUpdate(Collection<T> collection,
UpdateOp update)
- throws MicroKernelException {
+ public <T extends Document> T findAndUpdate(Collection<T> collection,
UpdateOp update) {
return internalCreateOrUpdate(collection, update, true);
}
@@ -216,7 +214,7 @@ public class MemoryDocumentStore impleme
T doc = collection.newDocument(this);
if (oldDoc == null) {
if (!update.isNew()) {
- throw new MicroKernelException("Document does not exist: "
+ update.getId());
+ throw new DocumentStoreException("Document does not exist:
" + update.getId());
}
} else {
oldDoc.deepCopy(doc);
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java?rev=1659569&r1=1659568&r2=1659569&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
Fri Feb 13 13:57:42 2015
@@ -40,13 +40,13 @@ import javax.annotation.Nullable;
import com.google.common.collect.Lists;
import com.mongodb.MongoClientURI;
import com.mongodb.ReadPreference;
-import org.apache.jackrabbit.mk.api.MicroKernelException;
import org.apache.jackrabbit.oak.cache.CacheStats;
import org.apache.jackrabbit.oak.cache.CacheValue;
import org.apache.jackrabbit.oak.plugins.document.CachedNodeDocument;
import org.apache.jackrabbit.oak.plugins.document.Collection;
import org.apache.jackrabbit.oak.plugins.document.Document;
import org.apache.jackrabbit.oak.plugins.document.DocumentMK;
+import org.apache.jackrabbit.oak.plugins.document.DocumentStoreException;
import org.apache.jackrabbit.oak.plugins.document.NodeDocument;
import org.apache.jackrabbit.oak.plugins.document.Revision;
import org.apache.jackrabbit.oak.plugins.document.StableRevisionComparator;
@@ -319,6 +319,7 @@ public class MongoDocumentStore implemen
}
}
}
+ Throwable t;
try {
TreeLock lock = acquire(key);
try {
@@ -354,8 +355,9 @@ public class MongoDocumentStore implemen
return (T) doc;
}
} catch (ExecutionException e) {
- throw new IllegalStateException("Failed to load document with " +
key, e);
+ t = e.getCause();
}
+ throw new DocumentStoreException("Failed to load document with " +
key, t);
}
@CheckForNull
@@ -501,7 +503,7 @@ public class MongoDocumentStore implemen
WriteResult writeResult =
dbCollection.remove(getByKeyQuery(key).get());
invalidateCache(collection, key);
if (writeResult.getError() != null) {
- throw new MicroKernelException("Remove failed: " +
writeResult.getError());
+ throw new DocumentStoreException("Remove failed: " +
writeResult.getError());
}
} finally {
end("remove", start);
@@ -517,7 +519,7 @@ public class MongoDocumentStore implemen
WriteResult writeResult = dbCollection.remove(query);
invalidateCache(collection, keyBatch);
if (writeResult.getError() != null) {
- throw new MicroKernelException("Remove failed: " +
writeResult.getError());
+ throw new DocumentStoreException("Remove failed: " +
writeResult.getError());
}
}
@@ -584,7 +586,7 @@ public class MongoDocumentStore implemen
}
return oldDoc;
} catch (Exception e) {
- throw new MicroKernelException(e);
+ throw DocumentStoreException.convert(e);
} finally {
lock.unlock();
end("findAndModify", start);
@@ -594,7 +596,7 @@ public class MongoDocumentStore implemen
@CheckForNull
@Override
public <T extends Document> T createOrUpdate(Collection<T> collection,
UpdateOp update)
- throws MicroKernelException {
+ throws DocumentStoreException {
log("createOrUpdate", update);
T doc = findAndModify(collection, update, true, false);
log("createOrUpdate returns ", doc);
@@ -603,7 +605,7 @@ public class MongoDocumentStore implemen
@Override
public <T extends Document> T findAndUpdate(Collection<T> collection,
UpdateOp update)
- throws MicroKernelException {
+ throws DocumentStoreException {
log("findAndUpdate", update);
T doc = findAndModify(collection, update, false, true);
log("findAndUpdate returns ", doc);
@@ -705,7 +707,7 @@ public class MongoDocumentStore implemen
try {
WriteResult writeResult = dbCollection.update(query.get(),
update, false, true);
if (writeResult.getError() != null) {
- throw new MicroKernelException("Update failed: " +
writeResult.getError());
+ throw new DocumentStoreException("Update failed: " +
writeResult.getError());
}
if (collection == Collection.NODES) {
// update cache
@@ -726,7 +728,7 @@ public class MongoDocumentStore implemen
}
}
} catch (MongoException e) {
- throw new MicroKernelException(e);
+ throw DocumentStoreException.convert(e);
}
} finally {
end("update", start);
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/LoggingDocumentStoreWrapper.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/LoggingDocumentStoreWrapper.java?rev=1659569&r1=1659568&r2=1659569&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/LoggingDocumentStoreWrapper.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/LoggingDocumentStoreWrapper.java
Fri Feb 13 13:57:42 2015
@@ -21,11 +21,11 @@ import java.util.concurrent.Callable;
import javax.annotation.Nonnull;
-import org.apache.jackrabbit.mk.api.MicroKernelException;
import org.apache.jackrabbit.oak.commons.json.JsopBuilder;
import org.apache.jackrabbit.oak.plugins.document.Collection;
import org.apache.jackrabbit.oak.plugins.document.Document;
import org.apache.jackrabbit.oak.plugins.document.DocumentStore;
+import org.apache.jackrabbit.oak.plugins.document.DocumentStoreException;
import org.apache.jackrabbit.oak.plugins.document.UpdateOp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -186,8 +186,7 @@ public class LoggingDocumentStoreWrapper
@Nonnull
@Override
public <T extends Document> T createOrUpdate(final Collection<T>
collection,
- final UpdateOp update)
- throws MicroKernelException {
+ final UpdateOp update) {
try {
logMethod("createOrUpdate", collection, update);
return logResult(new Callable<T>() {
@@ -204,8 +203,7 @@ public class LoggingDocumentStoreWrapper
@Override
public <T extends Document> T findAndUpdate(final Collection<T> collection,
- final UpdateOp update)
- throws MicroKernelException {
+ final UpdateOp update) {
try {
logMethod("findAndUpdate", collection, update);
return logResult(new Callable<T>() {
@@ -308,7 +306,7 @@ public class LoggingDocumentStoreWrapper
return (RuntimeException) e;
}
log("// unexpected exception type: " + e.getClass().getName());
- return new MicroKernelException("Unexpected exception: " +
e.toString(), e);
+ return new DocumentStoreException("Unexpected exception: " +
e.toString(), e);
}
private void logException(Exception e) {
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/SynchronizingDocumentStoreWrapper.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/SynchronizingDocumentStoreWrapper.java?rev=1659569&r1=1659568&r2=1659569&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/SynchronizingDocumentStoreWrapper.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/SynchronizingDocumentStoreWrapper.java
Fri Feb 13 13:57:42 2015
@@ -20,7 +20,6 @@ import java.util.List;
import javax.annotation.Nonnull;
-import org.apache.jackrabbit.mk.api.MicroKernelException;
import org.apache.jackrabbit.oak.plugins.document.Collection;
import org.apache.jackrabbit.oak.plugins.document.Document;
import org.apache.jackrabbit.oak.plugins.document.DocumentStore;
@@ -87,14 +86,12 @@ public class SynchronizingDocumentStoreW
@Nonnull
@Override
- public synchronized <T extends Document> T createOrUpdate(final
Collection<T> collection, final UpdateOp update)
- throws MicroKernelException {
+ public synchronized <T extends Document> T createOrUpdate(final
Collection<T> collection, final UpdateOp update) {
return store.createOrUpdate(collection, update);
}
@Override
- public synchronized <T extends Document> T findAndUpdate(final
Collection<T> collection, final UpdateOp update)
- throws MicroKernelException {
+ public synchronized <T extends Document> T findAndUpdate(final
Collection<T> collection, final UpdateOp update) {
return store.findAndUpdate(collection, update);
}
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/TimingDocumentStoreWrapper.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/TimingDocumentStoreWrapper.java?rev=1659569&r1=1659568&r2=1659569&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/TimingDocumentStoreWrapper.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/TimingDocumentStoreWrapper.java
Fri Feb 13 13:57:42 2015
@@ -28,10 +28,10 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.apache.jackrabbit.mk.api.MicroKernelException;
import org.apache.jackrabbit.oak.plugins.document.Collection;
import org.apache.jackrabbit.oak.plugins.document.Document;
import org.apache.jackrabbit.oak.plugins.document.DocumentStore;
+import org.apache.jackrabbit.oak.plugins.document.DocumentStoreException;
import org.apache.jackrabbit.oak.plugins.document.UpdateOp;
/**
@@ -217,8 +217,7 @@ public class TimingDocumentStoreWrapper
@Override
@CheckForNull
- public <T extends Document> T createOrUpdate(Collection<T> collection,
UpdateOp update)
- throws MicroKernelException {
+ public <T extends Document> T createOrUpdate(Collection<T> collection,
UpdateOp update) {
try {
long start = now();
T result = base.createOrUpdate(collection, update);
@@ -234,8 +233,7 @@ public class TimingDocumentStoreWrapper
@Override
@CheckForNull
- public <T extends Document> T findAndUpdate(Collection<T> collection,
UpdateOp update)
- throws MicroKernelException {
+ public <T extends Document> T findAndUpdate(Collection<T> collection,
UpdateOp update) {
try {
long start = now();
T result = base.findAndUpdate(collection, update);
@@ -336,7 +334,7 @@ public class TimingDocumentStoreWrapper
if (e instanceof RuntimeException) {
return (RuntimeException) e;
}
- return new MicroKernelException("Unexpected exception: " +
e.toString(), e);
+ return new DocumentStoreException("Unexpected exception: " +
e.toString(), e);
}
private void log(String message) {
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStoreBranch.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStoreBranch.java?rev=1659569&r1=1659568&r2=1659569&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStoreBranch.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStoreBranch.java
Fri Feb 13 13:57:42 2015
@@ -32,7 +32,6 @@ import static org.apache.jackrabbit.oak.
import javax.annotation.Nonnull;
-import org.apache.jackrabbit.mk.api.MicroKernelException;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.spi.commit.ChangeDispatcher;
@@ -209,6 +208,17 @@ public abstract class AbstractNodeStoreB
*/
protected abstract N move(String source, String target, N base);
+ /**
+ * Convert an implementation specific unchecked exception into a
+ * {@link CommitFailedException}.
+ *
+ * @param cause the unchecked exception cause.
+ * @param msg the message to use for the {@link CommitFailedException}.
+ * @return a {@link CommitFailedException}.
+ */
+ protected abstract CommitFailedException convertUnchecked(Exception cause,
+ String msg);
+
@Override
public String toString() {
return branchState.toString();
@@ -526,12 +536,9 @@ public abstract class AbstractNodeStoreB
dispatcher.contentChanged(newHead, info);
branchState = new Merged(base);
return newHead;
- } catch (MicroKernelException e) {
- throw new CommitFailedException(MERGE, 1,
- "Failed to merge changes to the underlying store",
e);
} catch (Exception e) {
- throw new CommitFailedException(OAK, 1,
- "Failed to merge changes to the underlying store",
e);
+ throw convertUnchecked(e,
+ "Failed to merge changes to the underlying store");
}
} finally {
dispatcher.contentChanged(getRoot(), null);
Modified:
jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java?rev=1659569&r1=1659568&r2=1659569&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
(original)
+++
jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Fri Feb 13 13:57:42 2015
@@ -47,7 +47,6 @@ import java.util.concurrent.atomic.Atomi
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
-import org.apache.jackrabbit.mk.api.MicroKernelException;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Type;
@@ -236,7 +235,7 @@ public class DocumentNodeStoreTest {
c.addNode(new DocumentNodeState(store, "/foo/node", r));
c.addNode(new DocumentNodeState(store, "/bar/node", r));
c.apply();
- } catch (MicroKernelException e) {
+ } catch (DocumentStoreException e) {
exceptions.add(e);
}
}