You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by mr...@apache.org on 2015/08/10 16:25:41 UTC
svn commit: r1695086 - in /jackrabbit/oak/branches/1.0: ./
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/
oak-core/src/main/java/org/apache/jackrabbi...
Author: mreutegg
Date: Mon Aug 10 14:25:41 2015
New Revision: 1695086
URL: http://svn.apache.org/r1695086
Log:
OAK-2685: Track root state revision when reading the tree
Merged revision 1677804 and 1677806 from trunk
Added:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/TieredDiffCache.java
- copied unchanged from r1677806, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/TieredDiffCache.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/RevisionsKey.java
- copied unchanged from r1677806, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/RevisionsKey.java
jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/RevisionsKeyTest.java
- copied unchanged from r1677806, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/RevisionsKeyTest.java
Removed:
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ContentChangeInfo.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ContentChangeInfoProvider.java
Modified:
jackrabbit/oak/branches/1.0/ (props changed)
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/DiffCache.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/DocumentNodeState.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/DocumentNodeStoreService.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/LocalDiffCache.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MemoryDiffCache.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/CacheType.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/PersistentCache.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/StringValue.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventGenerator.java
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/NodeObserver.java
jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/AbstractMongoConnectionTest.java
jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/AmnesiaDiffCache.java
jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreDiffTest.java
jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LocalDiffCacheTest.java
jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/MeasureMemory.java
jackrabbit/oak/branches/1.0/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/EventQueue.java
Propchange: jackrabbit/oak/branches/1.0/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug 10 14:25:41 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,1594987,1595147,1595457,1595856,1596241,1596474,1596534,1596844,1596889,1597569,1597795,1597854,1597860,1598292,1598302,1598352,1598369,1598595,1598631,1598696,1598732,1598797-1598798,1599160,1599299,1599332,1599416,1599434,1599671,1600088,1600935,1601309,1601388,1601578,1601649,1601676,1601757,1601768,1601814,1601833,1601838,1601853,1601878,1601888,1601922,1602156,1602170,1602174,1602179,1602183,1602201,1602207,1602227,1602256,1602261,1602342,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,1609
081,1609165,1609214,1609488,1610489,1610592,1610603,1610634,1610658,1610664,1611021,1611041,1611270,1611275,1611277,1611313,1611332,1611584,1612560,1612825,1612848,1612892,1612899,1612993,1613018,1613041,1614032,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,1
627503,1627586,1627590,1627715,1627731,1628180,1628198,1628262,1628447,1628608,1629688,1629840,1629858,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,1633327,1633389,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,1635178,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,1640523,1640555-1640556,1640694-1640695,1640715,1640722-1640723,1640728,1640863-1640872,1641340,1641346,1641350,1641352,164154
1,1641596-1641599,1641601,1641662,1641671,1641695,1641771,1641802,1641811,1641950,1642031,1642056,1642119,1642285,1642648,1642667,1642954,1642959,1643111,1643178,1643186,1643204,1643287,1643767,1643774,1643982,1644016,1644106,1644366,1644383,1644397-1644398,1644407,1644479,1644547,1644552,1644554,1644588,1644645,1644650,1644654,1644689,1644750,1645421,1645424,1645459,1645585,1645611,1645637,1645646,1645660-1645663,1645888,1645901,1645948,1645966,1645970-1645971,1646014,1646164,1646174,1646469,1646684,1646687,1646726-1646728,1646766,1646795,1646981,1649743,1649803,1650015,1650239,1650529,1650797,1651323,1651382,1651643,1651652,1651730,1651988-1651989,1651996,1652024,1652035,1652058-1652059,1652075,1652127,1652158,1652467,1652965,1652971,1652992,1653207,1653446,1653463,1653484,1653572,1653579,1653591,1653804,1653809,1653813,1653848-1653850,1653882,1654116,1654174,1654743,1654756,1654778,1655028,1655049,1655054-1655055,1655086,1655237,1655248,1655996,1656019,1656027,1656033,1656303,165
6394,1656400,1656425,1656427,1656432,1656453,1656628,1656678,1657128,1657132,1657163,1657188,1657265,1657511,1657766,1657804,1658470,1658977,1658983,1659285,1659483,1659527,1659550,1659578,1659765,1660100,1660154-1660155,1660383-1660384,1660409,1660426,1660676,1660870,1660872,1660897,1660903,1661069,1661122,1661146,1661158,1661226,1661630,1661643,1661645,1662313-1662315,1662323,1662381,1662450,1662456,1663241,1663275,1663288,1663448,1663526,1663528,1663565,1663578,1663614,1663666,1663705,1663730,1663753,1663854,1664038,1664184,1664228-1664229,1664231,1664381,1664569,1664947,1664987,1665184,1665257,1665271-1665272,1665274-1665275,1665436,1665604,1665634,1665758,1665835,1665892,1665897,1665910,1665918,1666100,1666102,1666177,1666218,1666220,1666351-1666352,1666381,1666384,1666426,1666491,1666787,1667062,1667184,1667293,1667462,1667498,1667502,1667573,1667590,1667696,1667782,1668160,1668275,1668624,1668641,1668645,1668649,1668665,1668671,1668683,1668688,1668845,1669072,1669096,1669135,
1669337,1669361,1669579,1669680,1669989,1670030,1670693,1670705,1671489,1671512,1671773,1671787,1671795,1672055,1672277,1672350,1672468,1672537,1672603,1672642,1672644,1672834-1672835,1673351,1673410,1673431,1673436,1673644,1673662-1673663,1673695,1673713,1673738,1673787,1673791,1674046,1674065,1674075,1674107,1674150,1674780,1675054,1675319,1675332,1675382,1675555,1675566,1676198,1676407,1676458,1676670,1676703,1677579,1677609,1677611,1677774,1677788,1677797,1677939,1677991,1678095-1678096,1678173,1678323,1678758,1678938,1678954,1679144,1679147,1679165,1679191,1679232,1679503,1679961,1680170,1680182,1680222,1680232,1680236,1680461,1680633,1680643,1680747,1680805-1680806,1680903,1681282,1681767,1681918,1682218,1682235,1682437,1682494,1682555,1682855,1682904,1683059,1683089,1683213,1683249,1683259,1683278,1683323,1683687,1683700,1684174,1684376,1684442,1684561,1684570,1684618,1684836,1684868,1685023,1685370,1685552,1685589,1685840,1685999,1686097,1686229,1686234,1686253,1686414,16867
80,1686854,1686857,1686971,1687053,1687175,1687196,1687198,1687220,1687239-1687240,1687301,1687441,1687553,1688090,1688349,1688421,1688436,1688453,1688622,1688636,1688817,1689003-1689004,1689008,1689577,1689581,1689623,1689774,1689810,1689828,1689833,1689903,1690017,1690043,1690047,1690057,1690247,1690249,1690634-1690637,1690650,1690669,1690674,1690941,1691139,1691159,1691167,1691183,1691188,1691210,1691307,1691331-1691333,1691345,1691384-1691385,1691401,1691509,1692133,1692156,1692250,1692274,1692363,1692382,1692478,1692955,1693030,1693209,1693421,1693525-1693526,1694007,1694393
+/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,1594987,1595147,1595457,1595856,1596241,1596474,1596534,1596844,1596889,1597569,1597795,1597854,1597860,1598292,1598302,1598352,1598369,1598595,1598631,1598696,1598732,1598797-1598798,1599160,1599299,1599332,1599416,1599434,1599671,1600088,1600935,1601309,1601388,1601578,1601649,1601676,1601757,1601768,1601814,1601833,1601838,1601853,1601878,1601888,1601922,1602156,1602170,1602174,1602179,1602183,1602201,1602207,1602227,1602256,1602261,1602342,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,1609
081,1609165,1609214,1609488,1610489,1610592,1610603,1610634,1610658,1610664,1611021,1611041,1611270,1611275,1611277,1611313,1611332,1611584,1612560,1612825,1612848,1612892,1612899,1612993,1613018,1613041,1614032,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,1
627503,1627586,1627590,1627715,1627731,1628180,1628198,1628262,1628447,1628608,1629688,1629840,1629858,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,1633327,1633389,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,1635178,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,1640523,1640555-1640556,1640694-1640695,1640715,1640722-1640723,1640728,1640863-1640872,1641340,1641346,1641350,1641352,164154
1,1641596-1641599,1641601,1641662,1641671,1641695,1641771,1641802,1641811,1641950,1642031,1642056,1642119,1642285,1642648,1642667,1642954,1642959,1643111,1643178,1643186,1643204,1643287,1643767,1643774,1643982,1644016,1644106,1644366,1644383,1644397-1644398,1644407,1644479,1644547,1644552,1644554,1644588,1644645,1644650,1644654,1644689,1644750,1645421,1645424,1645459,1645585,1645611,1645637,1645646,1645660-1645663,1645888,1645901,1645948,1645966,1645970-1645971,1646014,1646164,1646174,1646469,1646684,1646687,1646726-1646728,1646766,1646795,1646981,1649743,1649803,1650015,1650239,1650529,1650797,1651323,1651382,1651643,1651652,1651730,1651988-1651989,1651996,1652024,1652035,1652058-1652059,1652075,1652127,1652158,1652467,1652965,1652971,1652992,1653207,1653446,1653463,1653484,1653572,1653579,1653591,1653804,1653809,1653813,1653848-1653850,1653882,1654116,1654174,1654743,1654756,1654778,1655028,1655049,1655054-1655055,1655086,1655237,1655248,1655996,1656019,1656027,1656033,1656303,165
6394,1656400,1656425,1656427,1656432,1656453,1656628,1656678,1657128,1657132,1657163,1657188,1657265,1657511,1657766,1657804,1658470,1658977,1658983,1659285,1659483,1659527,1659550,1659578,1659765,1660100,1660154-1660155,1660383-1660384,1660409,1660426,1660676,1660870,1660872,1660897,1660903,1661069,1661122,1661146,1661158,1661226,1661630,1661643,1661645,1662313-1662315,1662323,1662381,1662450,1662456,1663241,1663275,1663288,1663448,1663526,1663528,1663565,1663578,1663614,1663666,1663705,1663730,1663753,1663854,1664038,1664184,1664228-1664229,1664231,1664381,1664569,1664947,1664987,1665184,1665257,1665271-1665272,1665274-1665275,1665436,1665604,1665634,1665758,1665835,1665892,1665897,1665910,1665918,1666100,1666102,1666177,1666218,1666220,1666351-1666352,1666381,1666384,1666426,1666491,1666787,1667062,1667184,1667293,1667462,1667498,1667502,1667573,1667590,1667696,1667782,1668160,1668275,1668624,1668641,1668645,1668649,1668665,1668671,1668683,1668688,1668845,1669072,1669096,1669135,
1669337,1669361,1669579,1669680,1669989,1670030,1670693,1670705,1671489,1671512,1671773,1671787,1671795,1672055,1672277,1672350,1672468,1672537,1672603,1672642,1672644,1672834-1672835,1673351,1673410,1673431,1673436,1673644,1673662-1673663,1673695,1673713,1673738,1673787,1673791,1674046,1674065,1674075,1674107,1674150,1674780,1675054,1675319,1675332,1675382,1675555,1675566,1676198,1676407,1676458,1676670,1676703,1677579,1677609,1677611,1677774,1677788,1677797,1677804,1677806,1677939,1677991,1678095-1678096,1678173,1678323,1678758,1678938,1678954,1679144,1679147,1679165,1679191,1679232,1679503,1679961,1680170,1680182,1680222,1680232,1680236,1680461,1680633,1680643,1680747,1680805-1680806,1680903,1681282,1681767,1681918,1682218,1682235,1682437,1682494,1682555,1682855,1682904,1683059,1683089,1683213,1683249,1683259,1683278,1683323,1683687,1683700,1684174,1684376,1684442,1684561,1684570,1684618,1684836,1684868,1685023,1685370,1685552,1685589,1685840,1685999,1686097,1686229,1686234,16862
53,1686414,1686780,1686854,1686857,1686971,1687053,1687175,1687196,1687198,1687220,1687239-1687240,1687301,1687441,1687553,1688090,1688349,1688421,1688436,1688453,1688622,1688636,1688817,1689003-1689004,1689008,1689577,1689581,1689623,1689774,1689810,1689828,1689833,1689903,1690017,1690043,1690047,1690057,1690247,1690249,1690634-1690637,1690650,1690669,1690674,1690941,1691139,1691159,1691167,1691183,1691188,1691210,1691307,1691331-1691333,1691345,1691384-1691385,1691401,1691509,1692133,1692156,1692250,1692274,1692363,1692382,1692478,1692955,1693030,1693209,1693421,1693525-1693526,1694007,1694393
/jackrabbit/trunk:1345480
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=1695086&r1=1695085&r2=1695086&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 Mon Aug 10 14:25:41 2015
@@ -583,7 +583,7 @@ public class Commit {
}
list.add(p);
}
- DiffCache.Entry cacheEntry = nodeStore.getLocalDiffCache().newEntry(before, revision);
+ DiffCache.Entry cacheEntry = nodeStore.getDiffCache().newEntry(before, revision);
List<String> added = new ArrayList<String>();
List<String> removed = new ArrayList<String>();
List<String> changed = new ArrayList<String>();
Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DiffCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DiffCache.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DiffCache.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DiffCache.java Mon Aug 10 14:25:41 2015
@@ -20,6 +20,8 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import org.apache.jackrabbit.oak.cache.CacheStats;
+
/**
* A cache for child node diffs.
*/
@@ -60,7 +62,13 @@ public interface DiffCache {
Entry newEntry(@Nonnull Revision from,
@Nonnull Revision to);
- public interface Entry {
+ /**
+ * @return the statistics for this cache.
+ */
+ @Nonnull
+ Iterable<CacheStats> getStats();
+
+ interface Entry {
/**
* Appends changes about children of the node at the given path.
@@ -81,7 +89,7 @@ public interface DiffCache {
boolean done();
}
- public interface Loader {
+ interface Loader {
String call();
}
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=1695086&r1=1695085&r2=1695086&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 Mon Aug 10 14:25:41 2015
@@ -45,7 +45,6 @@ import org.apache.jackrabbit.oak.commons
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeState.Children;
import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore;
import org.apache.jackrabbit.oak.plugins.document.mongo.MongoBlobStore;
-import org.apache.jackrabbit.oak.plugins.document.mongo.MongoDiffCache;
import org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore;
import org.apache.jackrabbit.oak.plugins.document.mongo.MongoVersionGCSupport;
import org.apache.jackrabbit.oak.plugins.document.persistentCache.CacheType;
@@ -53,6 +52,7 @@ import org.apache.jackrabbit.oak.plugins
import org.apache.jackrabbit.oak.plugins.document.rdb.RDBBlobStore;
import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore;
import org.apache.jackrabbit.oak.plugins.document.rdb.RDBOptions;
+import org.apache.jackrabbit.oak.plugins.document.util.RevisionsKey;
import org.apache.jackrabbit.oak.plugins.document.util.StringValue;
import org.apache.jackrabbit.oak.spi.blob.BlobStore;
import org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore;
@@ -507,13 +507,11 @@ public class DocumentMK implements Micro
private DocumentNodeStore nodeStore;
private DocumentStore documentStore;
private DiffCache diffCache;
- private LocalDiffCache localDiffCache;
private BlobStore blobStore;
private int clusterId = Integer.getInteger("oak.documentMK.clusterId", 0);
private int asyncDelay = 1000;
private boolean timing;
private boolean logging;
- private boolean disableLocalDiffCache = Boolean.getBoolean("oak.documentMK.disableLocalDiffCache");
private Weigher<CacheValue, CacheValue> weigher = new EmpiricalWeigher();
private long memoryCacheSize = DEFAULT_MEMORY_CACHE_SIZE;
private int nodeCachePercentage = DEFAULT_NODE_CACHE_PERCENTAGE;
@@ -557,10 +555,6 @@ public class DocumentMK implements Micro
}
this.blobStore = s;
}
-
- if (this.diffCache == null) {
- this.diffCache = new MongoDiffCache(db, changesSizeMB, this);
- }
}
return this;
}
@@ -676,23 +670,11 @@ public class DocumentMK implements Micro
public DiffCache getDiffCache() {
if (diffCache == null) {
- diffCache = new MemoryDiffCache(this);
+ diffCache = new TieredDiffCache(this);
}
return diffCache;
}
- public LocalDiffCache getLocalDiffCache() {
- if (localDiffCache == null && !disableLocalDiffCache) {
- localDiffCache = new LocalDiffCache(this);
- }
- return localDiffCache;
- }
-
- public Builder setDisableLocalDiffCache(boolean disableLocalDiffCache) {
- this.disableLocalDiffCache = disableLocalDiffCache;
- return this;
- }
-
public Builder setDiffCache(DiffCache diffCache) {
this.diffCache = diffCache;
return this;
@@ -810,6 +792,14 @@ public class DocumentMK implements Micro
return memoryCacheSize * diffCachePercentage / 100;
}
+ public long getMemoryDiffCacheSize() {
+ return getDiffCacheSize() / 2;
+ }
+
+ public long getLocalDiffCacheSize() {
+ return getDiffCacheSize() / 2;
+ }
+
public Builder setUseSimpleRevision(boolean useSimpleRevision) {
this.useSimpleRevision = useSimpleRevision;
return this;
@@ -910,12 +900,12 @@ public class DocumentMK implements Micro
return buildCache(CacheType.DOC_CHILDREN, getDocChildrenCacheSize(), null, null);
}
- public Cache<PathRev, StringValue> buildDiffCache() {
- return buildCache(CacheType.DIFF, getDiffCacheSize(), null, null);
+ public Cache<PathRev, StringValue> buildMemoryDiffCache() {
+ return buildCache(CacheType.DIFF, getMemoryDiffCacheSize(), null, null);
}
- public Cache<StringValue, LocalDiffCache.ConsolidatedDiff> buildConsolidatedDiffCache() {
- return buildCache(CacheType.CONSOLIDATED_DIFF, getDiffCacheSize(), null, null);
+ public Cache<RevisionsKey, LocalDiffCache.Diff> buildLocalDiffCache() {
+ return buildCache(CacheType.LOCAL_DIFF, getLocalDiffCacheSize(), null, null);
}
public Cache<CacheValue, NodeDocument> buildDocumentCache(DocumentStore docStore) {
Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java Mon Aug 10 14:25:41 2015
@@ -218,7 +218,18 @@ public class DocumentNodeState extends A
@Nonnull
@Override
public NodeState getChildNode(@Nonnull String name) {
- return getChildNode(name, lastRevision);
+ if (!hasChildren) {
+ checkValidName(name);
+ return EmptyNodeState.MISSING_NODE;
+ }
+ String p = PathUtils.concat(getPath(), name);
+ DocumentNodeState child = store.getNode(p, lastRevision);
+ if (child == null) {
+ checkValidName(name);
+ return EmptyNodeState.MISSING_NODE;
+ } else {
+ return child.withRootRevision(rootRevision);
+ }
}
@Override
@@ -321,23 +332,6 @@ public class DocumentNodeState extends A
return super.compareAgainstBaseState(base, diff);
}
- @Nonnull
- NodeState getChildNode(@Nonnull String name,
- @Nonnull Revision revision) {
- if (!hasChildren) {
- checkValidName(name);
- return EmptyNodeState.MISSING_NODE;
- }
- String p = PathUtils.concat(getPath(), name);
- DocumentNodeState child = store.getNode(p, checkNotNull(revision));
- if (child == null) {
- checkValidName(name);
- return EmptyNodeState.MISSING_NODE;
- } else {
- return child.withRootRevision(rootRevision);
- }
- }
-
void setProperty(String propertyName, String value) {
if (value == null) {
properties.remove(propertyName);
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=1695086&r1=1695085&r2=1695086&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 Mon Aug 10 14:25:41 2015
@@ -78,8 +78,6 @@ import org.apache.jackrabbit.oak.plugins
import org.apache.jackrabbit.oak.plugins.document.mongo.MongoBlobReferenceIterator;
import org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore;
import org.apache.jackrabbit.oak.plugins.document.persistentCache.PersistentCache;
-import org.apache.jackrabbit.oak.plugins.observation.ContentChangeInfo;
-import org.apache.jackrabbit.oak.plugins.observation.ContentChangeInfoProvider;
import org.apache.jackrabbit.oak.spi.blob.BlobStore;
import org.apache.jackrabbit.oak.commons.json.JsopStream;
import org.apache.jackrabbit.oak.commons.json.JsopWriter;
@@ -309,8 +307,6 @@ public final class DocumentNodeStore
*/
private final DiffCache diffCache;
- private final LocalDiffCache localDiffCache;
-
/**
* The blob store.
*/
@@ -417,7 +413,6 @@ public final class DocumentNodeStore
builder.getWeigher(), builder.getDocChildrenCacheSize());
diffCache = builder.getDiffCache();
- localDiffCache = builder.getLocalDiffCache();
checkpoints = new Checkpoints(this);
// check if root node exists
@@ -700,6 +695,11 @@ public final class DocumentNodeStore
return docChildrenCacheStats;
}
+ @Nonnull
+ public Iterable<CacheStats> getDiffCacheStats() {
+ return diffCache.getStats();
+ }
+
void invalidateDocChildrenCache() {
docChildrenCache.invalidateAll();
}
@@ -1357,53 +1357,14 @@ public final class DocumentNodeStore
if (node.hasNoChildren() && base.hasNoChildren()) {
return true;
}
- String jsop = getJsopDiffIfLocalChange(diff, node);
-
- boolean useReadRevision = true;
- if (jsop == null) {
- // first lookup with read revisions of nodes and without loader
- jsop = diffCache.getChanges(base.getRevision(),
- node.getRevision(), node.getPath(), null);
- if (jsop == null) {
- useReadRevision = false;
- // fall back to last revisions with loader, this
- // guarantees we get a diff
- jsop = diffCache.getChanges(base.getLastRevision(),
- node.getLastRevision(), node.getPath(),
- new DiffCache.Loader() {
- @Override
- public String call() {
- return diffImpl(base, node);
- }
- });
- }
- }
- return dispatch(jsop, node, base, diff, useReadRevision);
- }
-
- @CheckForNull
- private String getJsopDiffIfLocalChange(NodeStateDiff diff, DocumentNodeState nodeState) {
- if (localDiffCache == null){
- //Local diff cache support not enabled
- return null;
- }
-
- if (diff instanceof ContentChangeInfoProvider){
- ContentChangeInfo info = ((ContentChangeInfoProvider) diff).getChangeInfo();
- if (info.isLocalChange() && info.getAfter() instanceof DocumentNodeState){
- DocumentNodeState rootAfterState = (DocumentNodeState) info.getAfter();
- DocumentNodeState rootBeforeState = (DocumentNodeState) info.getBefore();
- String jsopDiff = localDiffCache.getChanges(rootBeforeState.getRevision(),
- rootAfterState.getRevision(),
- nodeState.getPath(),
- null);
- if (jsopDiff != null){
- LOG.trace("Got diff from local cache for path {}", nodeState.getPath());
- return jsopDiff;
- }
- }
- }
- return null;
+ return dispatch(diffCache.getChanges(base.getRootRevision(),
+ node.getRootRevision(), node.getPath(),
+ new DiffCache.Loader() {
+ @Override
+ public String call() {
+ return diffImpl(base, node);
+ }
+ }), node, base, diff);
}
String diff(@Nonnull final String fromRevisionId,
@@ -1973,13 +1934,10 @@ public final class DocumentNodeStore
private boolean dispatch(@Nonnull String jsonDiff,
@Nonnull DocumentNodeState node,
@Nonnull DocumentNodeState base,
- @Nonnull NodeStateDiff diff,
- boolean useReadRevision) {
+ @Nonnull NodeStateDiff diff) {
if (jsonDiff.trim().isEmpty()) {
return true;
}
- Revision nodeRev = useReadRevision ? node.getRevision() : node.getLastRevision();
- Revision baseRev = useReadRevision ? base.getRevision() : base.getLastRevision();
JsopTokenizer t = new JsopTokenizer(jsonDiff);
boolean continueComparison = true;
while (continueComparison) {
@@ -1996,13 +1954,13 @@ public final class DocumentNodeStore
// skip properties
}
continueComparison = diff.childNodeAdded(name,
- node.getChildNode(name, nodeRev));
+ node.getChildNode(name));
break;
}
case '-': {
String name = unshareString(t.readString());
continueComparison = diff.childNodeDeleted(name,
- base.getChildNode(name, baseRev));
+ base.getChildNode(name));
break;
}
case '^': {
@@ -2011,8 +1969,8 @@ public final class DocumentNodeStore
if (t.matches('{')) {
t.read('}');
continueComparison = diff.childNodeChanged(name,
- base.getChildNode(name, baseRev),
- node.getChildNode(name, nodeRev));
+ base.getChildNode(name),
+ node.getChildNode(name));
} else if (t.matches('[')) {
// ignore multi valued property
while (t.read() != ']') {
@@ -2089,29 +2047,32 @@ public final class DocumentNodeStore
final long getChildrenDoneIn = debug ? now() : 0;
String diffAlgo;
+ Revision fromRev = from.getLastRevision();
+ Revision toRev = to.getLastRevision();
if (!fromChildren.hasMore && !toChildren.hasMore) {
diffAlgo = "diffFewChildren";
diffFewChildren(w, from.getPath(), fromChildren,
- from.getLastRevision(), toChildren, to.getLastRevision());
+ fromRev, toChildren, toRev);
} else {
if (FAST_DIFF) {
diffAlgo = "diffManyChildren";
- diffManyChildren(w, from.getPath(),
- from.getRootRevision(), to.getRootRevision());
+ fromRev = from.getRootRevision();
+ toRev = to.getRootRevision();
+ diffManyChildren(w, from.getPath(), fromRev, toRev);
} else {
diffAlgo = "diffAllChildren";
max = Integer.MAX_VALUE;
fromChildren = getChildren(from, null, max);
toChildren = getChildren(to, null, max);
diffFewChildren(w, from.getPath(), fromChildren,
- from.getLastRevision(), toChildren, to.getLastRevision());
+ fromRev, toChildren, toRev);
}
}
if (debug) {
long end = now();
LOG.debug("Diff performed via '{}' at [{}] between revisions [{}] => [{}] took {} ms ({} ms)",
- diffAlgo, from.getPath(), from.getLastRevision(), to.getLastRevision(),
+ diffAlgo, from.getPath(), fromRev, toRev,
end - start, getChildrenDoneIn - start);
}
return w.toString();
@@ -2492,13 +2453,6 @@ public final class DocumentNodeStore
return diffCache;
}
- public DiffCache getLocalDiffCache(){
- if (localDiffCache != null){
- return localDiffCache;
- }
- return diffCache;
- }
-
public Clock getClock() {
return clock;
}
Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java Mon Aug 10 14:25:41 2015
@@ -42,6 +42,7 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.jackrabbit.oak.api.jmx.CacheStatsMBean;
+import org.apache.jackrabbit.oak.cache.CacheStats;
import org.apache.jackrabbit.oak.commons.PropertiesUtil;
import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
import org.apache.jackrabbit.oak.osgi.ObserverTracker;
@@ -457,28 +458,12 @@ public class DocumentNodeStoreService {
"Document node store management")
);
- DiffCache cl = store.getDiffCache();
- if (cl instanceof MemoryDiffCache) {
- MemoryDiffCache mcl = (MemoryDiffCache) cl;
+ for (CacheStats cs : store.getDiffCacheStats()) {
registrations.add(
registerMBean(whiteboard,
- CacheStatsMBean.class,
- mcl.getDiffCacheStats(),
- CacheStatsMBean.TYPE,
- mcl.getDiffCacheStats().getName()));
+ CacheStatsMBean.class, cs,
+ CacheStatsMBean.TYPE, cs.getName()));
}
-
- DiffCache localCache = store.getLocalDiffCache();
- if (localCache instanceof LocalDiffCache) {
- LocalDiffCache mcl = (LocalDiffCache) localCache;
- registrations.add(
- registerMBean(whiteboard,
- CacheStatsMBean.class,
- mcl.getDiffCacheStats(),
- CacheStatsMBean.TYPE,
- mcl.getDiffCacheStats().getName()));
- }
-
DocumentStore ds = store.getDocumentStore();
if (ds.getCacheStats() != null) {
registrations.add(
Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/LocalDiffCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/LocalDiffCache.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/LocalDiffCache.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/LocalDiffCache.java Mon Aug 10 14:25:41 2015
@@ -1,22 +1,19 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
-
package org.apache.jackrabbit.oak.plugins.document;
import java.util.Collections;
@@ -25,31 +22,35 @@ import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import com.google.common.base.Joiner;
-import com.google.common.base.Splitter;
import com.google.common.cache.Cache;
import com.google.common.collect.Maps;
+
import org.apache.jackrabbit.oak.cache.CacheStats;
import org.apache.jackrabbit.oak.cache.CacheValue;
+import org.apache.jackrabbit.oak.commons.json.JsopBuilder;
+import org.apache.jackrabbit.oak.commons.json.JsopReader;
+import org.apache.jackrabbit.oak.commons.json.JsopTokenizer;
+import org.apache.jackrabbit.oak.plugins.document.util.RevisionsKey;
import org.apache.jackrabbit.oak.plugins.document.util.StringValue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+/**
+ * A diff cache, which is pro-actively filled after a commit.
+ */
public class LocalDiffCache implements DiffCache {
+
/**
* Limit is arbitrary for now i.e. 16 MB. Same as in MongoDiffCache
*/
private static int MAX_ENTRY_SIZE = 16 * 1024 * 1024;
- private static final String NO_DIFF = "";
- private final Logger log = LoggerFactory.getLogger(getClass());
- private final Cache<StringValue, ConsolidatedDiff> diffCache;
+
+ private final Cache<RevisionsKey, Diff> diffCache;
private final CacheStats diffCacheStats;
- public LocalDiffCache(DocumentMK.Builder builder) {
- diffCache = builder.buildConsolidatedDiffCache();
- diffCacheStats = new CacheStats(diffCache, "Document-Diff2",
- builder.getWeigher(), builder.getDiffCacheSize());
+ LocalDiffCache(DocumentMK.Builder builder) {
+ this.diffCache = builder.buildLocalDiffCache();
+ this.diffCacheStats = new CacheStats(diffCache,
+ "Document-LocalDiff",
+ builder.getWeigher(), builder.getLocalDiffCacheSize());
}
@Override
@@ -57,27 +58,22 @@ public class LocalDiffCache implements D
@Nonnull Revision to,
@Nonnull String path,
@Nullable Loader loader) {
- ConsolidatedDiff diff = diffCache.getIfPresent(new StringValue(to.toString()));
- if (diff != null){
+ RevisionsKey key = new RevisionsKey(from, to);
+ Diff diff = diffCache.getIfPresent(key);
+ if (diff != null) {
String result = diff.get(path);
- if (result == null){
- return NO_DIFF;
- }
- return result;
- } else {
- log.debug("Did not got the diff for local change in the cache for change {} => {} ", from, to);
+ return result != null ? result : "";
+ }
+ if (loader != null) {
+ return loader.call();
}
return null;
}
- ConsolidatedDiff getDiff(@Nonnull Revision from,
- @Nonnull Revision to){
- return diffCache.getIfPresent(new StringValue(to.toString()));
- }
-
@Nonnull
@Override
- public Entry newEntry(@Nonnull Revision from, final @Nonnull Revision to) {
+ public Entry newEntry(final @Nonnull Revision from,
+ final @Nonnull Revision to) {
return new Entry() {
private final Map<String, String> changesPerPath = Maps.newHashMap();
private int size;
@@ -95,7 +91,8 @@ public class LocalDiffCache implements D
if (exceedsSize()){
return false;
}
- diffCache.put(new StringValue(to.toString()), new ConsolidatedDiff(changesPerPath, size));
+ diffCache.put(new RevisionsKey(from, to),
+ new Diff(changesPerPath, size));
return true;
}
@@ -105,33 +102,55 @@ public class LocalDiffCache implements D
};
}
- public CacheStats getDiffCacheStats() {
- return diffCacheStats;
+ @Nonnull
+ @Override
+ public Iterable<CacheStats> getStats() {
+ return Collections.singleton(diffCacheStats);
}
- public static final class ConsolidatedDiff implements CacheValue{
- //TODO need to come up with better serialization strategy as changes are json themselves
- //cannot use JSON. '/' and '*' are considered invalid chars so would not
- //cause issue
- static final Joiner.MapJoiner mapJoiner = Joiner.on("//").withKeyValueSeparator("**");
- static final Splitter.MapSplitter splitter = Splitter.on("//").withKeyValueSeparator("**");
+ //-----------------------------< internal >---------------------------------
+
+
+ public static final class Diff implements CacheValue {
+
private final Map<String, String> changes;
private int memory;
- public ConsolidatedDiff(Map<String, String> changes, int memory) {
+ public Diff(Map<String, String> changes, int memory) {
this.changes = changes;
this.memory = memory;
}
- public static ConsolidatedDiff fromString(String value){
- if (value.isEmpty()){
- return new ConsolidatedDiff(Collections.<String, String>emptyMap(), 0);
+ public static Diff fromString(String value) {
+ Map<String, String> map = Maps.newHashMap();
+ JsopReader reader = new JsopTokenizer(value);
+ while (true) {
+ if (reader.matches(JsopReader.END)) {
+ break;
+ }
+ String k = reader.readString();
+ reader.read(':');
+ String v = reader.readString();
+ map.put(k, v);
+ if (reader.matches(JsopReader.END)) {
+ break;
+ }
+ reader.read(',');
}
- return new ConsolidatedDiff(splitter.split(value), 0);
+ return new Diff(map, 0);
}
public String asString(){
- return mapJoiner.join(changes);
+ JsopBuilder builder = new JsopBuilder();
+ for (Map.Entry<String, String> entry : changes.entrySet()) {
+ builder.key(entry.getKey());
+ builder.value(entry.getValue());
+ }
+ return builder.toString();
+ }
+
+ public Map<String, String> getChanges() {
+ return Collections.unmodifiableMap(changes);
}
@Override
@@ -146,38 +165,29 @@ public class LocalDiffCache implements D
return memory;
}
- @Override
- public String toString() {
- return changes.toString();
- }
-
String get(String path) {
return changes.get(path);
}
- @SuppressWarnings("RedundantIfStatement")
@Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- ConsolidatedDiff that = (ConsolidatedDiff) o;
-
- if (!changes.equals(that.changes)) return false;
-
- return true;
+ public String toString() {
+ return asString();
}
@Override
- public int hashCode() {
- return changes.hashCode();
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (obj instanceof Diff) {
+ Diff other = (Diff) obj;
+ return changes.equals(other.changes);
+ }
+ return false;
}
}
private static int size(String s){
- //Taken from StringValue
- return 16 // shallow size
- + 40 + s.length() * 2;
+ return StringValue.getMemory(s);
}
-
}
Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MemoryDiffCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MemoryDiffCache.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MemoryDiffCache.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/MemoryDiffCache.java Mon Aug 10 14:25:41 2015
@@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.oak.plugins.document;
+import java.util.Collections;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -45,9 +46,9 @@ public class MemoryDiffCache implements
protected MemoryDiffCache(DocumentMK.Builder builder) {
- diffCache = builder.buildDiffCache();
- diffCacheStats = new CacheStats(diffCache, "Document-Diff",
- builder.getWeigher(), builder.getDiffCacheSize());
+ diffCache = builder.buildMemoryDiffCache();
+ diffCacheStats = new CacheStats(diffCache, "Document-MemoryDiff",
+ builder.getWeigher(), builder.getMemoryDiffCacheSize());
}
@CheckForNull
@@ -83,8 +84,10 @@ public class MemoryDiffCache implements
return new MemoryEntry(from, to);
}
- public CacheStats getDiffCacheStats() {
- return diffCacheStats;
+ @Nonnull
+ @Override
+ public Iterable<CacheStats> getStats() {
+ return Collections.singleton(diffCacheStats);
}
protected class MemoryEntry implements Entry {
Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/CacheType.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/CacheType.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/CacheType.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/CacheType.java Mon Aug 10 14:25:41 2015
@@ -22,6 +22,7 @@ import org.apache.jackrabbit.oak.plugins
import org.apache.jackrabbit.oak.plugins.document.DocumentStore;
import org.apache.jackrabbit.oak.plugins.document.NodeDocument;
import org.apache.jackrabbit.oak.plugins.document.PathRev;
+import org.apache.jackrabbit.oak.plugins.document.util.RevisionsKey;
import org.apache.jackrabbit.oak.plugins.document.util.StringValue;
public enum CacheType {
@@ -104,7 +105,7 @@ public enum CacheType {
}
},
- CONSOLIDATED_DIFF {
+ DOC_CHILDREN {
@Override
public <K> String keyToString(K key) {
return ((StringValue) key).asString();
@@ -117,20 +118,20 @@ public enum CacheType {
@Override
public <K> int compareKeys(K a, K b) {
return ((StringValue) a).asString().compareTo(((StringValue) b).asString());
- }
+ }
@Override
public <V> String valueToString(V value) {
- return ((LocalDiffCache.ConsolidatedDiff) value).asString();
+ return ((NodeDocument.Children) value).asString();
}
@SuppressWarnings("unchecked")
@Override
public <V> V valueFromString(
DocumentNodeStore store, DocumentStore docStore, String value) {
- return (V) LocalDiffCache.ConsolidatedDiff.fromString(value);
+ return (V) NodeDocument.Children.fromString(value);
}
- },
+ },
- DOC_CHILDREN {
+ DOCUMENT {
@Override
public <K> String keyToString(K key) {
return ((StringValue) key).asString();
@@ -146,42 +147,42 @@ public enum CacheType {
}
@Override
public <V> String valueToString(V value) {
- return ((NodeDocument.Children) value).asString();
+ return ((NodeDocument) value).asString();
}
@SuppressWarnings("unchecked")
@Override
public <V> V valueFromString(
DocumentNodeStore store, DocumentStore docStore, String value) {
- return (V) NodeDocument.Children.fromString(value);
+ return (V) NodeDocument.fromString(docStore, value);
}
- },
-
- DOCUMENT {
+ },
+
+ LOCAL_DIFF {
@Override
public <K> String keyToString(K key) {
- return ((StringValue) key).asString();
+ return ((RevisionsKey) key).asString();
}
@SuppressWarnings("unchecked")
@Override
public <K> K keyFromString(String key) {
- return (K) StringValue.fromString(key);
+ return (K) RevisionsKey.fromString(key);
}
@Override
public <K> int compareKeys(K a, K b) {
- return ((StringValue) a).asString().compareTo(((StringValue) b).asString());
- }
+ return ((RevisionsKey) a).compareTo((RevisionsKey) b);
+ }
@Override
public <V> String valueToString(V value) {
- return ((NodeDocument) value).asString();
+ return ((LocalDiffCache.Diff) value).asString();
}
@SuppressWarnings("unchecked")
@Override
public <V> V valueFromString(
DocumentNodeStore store, DocumentStore docStore, String value) {
- return (V) NodeDocument.fromString(docStore, value);
+ return (V) LocalDiffCache.Diff.fromString(value);
}
- };
-
+ };
+
public abstract <K> String keyToString(K key);
public abstract <K> K keyFromString(String key);
public abstract <K> int compareKeys(K a, K b);
Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/PersistentCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/PersistentCache.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/PersistentCache.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/persistentCache/PersistentCache.java Mon Aug 10 14:25:41 2015
@@ -49,6 +49,7 @@ public class PersistentCache {
private boolean cacheNodes = true;
private boolean cacheChildren = true;
private boolean cacheDiff = true;
+ private boolean cacheLocalDiff = true;
private boolean cacheDocs;
private boolean cacheDocChildren;
private boolean compactOnClose;
@@ -84,6 +85,8 @@ public class PersistentCache {
cacheChildren = false;
} else if (p.equals("-diff")) {
cacheDiff = false;
+ } else if (p.equals("-localDiff")) {
+ cacheLocalDiff = false;
} else if (p.equals("+all")) {
cacheDocs = true;
cacheDocChildren = true;
@@ -316,8 +319,8 @@ public class PersistentCache {
case DIFF:
wrap = cacheDiff;
break;
- case CONSOLIDATED_DIFF:
- wrap = cacheDiff;
+ case LOCAL_DIFF:
+ wrap = cacheLocalDiff;
break;
case DOC_CHILDREN:
wrap = cacheDocChildren;
Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/StringValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/StringValue.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/StringValue.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/StringValue.java Mon Aug 10 14:25:41 2015
@@ -37,8 +37,12 @@ public final class StringValue implement
@Override
public int getMemory() {
+ return getMemory(value);
+ }
+
+ public static int getMemory(@Nonnull String s) {
return 16 // shallow size
- + 40 + value.length() * 2; // value
+ + 40 + s.length() * 2; // value
}
@Override
Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventGenerator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventGenerator.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventGenerator.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventGenerator.java Mon Aug 10 14:25:41 2015
@@ -76,25 +76,18 @@ public class EventGenerator {
private final LinkedList<Continuation> continuations = newLinkedList();
- private final ContentChangeInfo changeInfo;
-
/**
* Creates a new generator instance. Changes to process need to be added
* through {@link #addHandler(NodeState, NodeState, EventHandler)}
- * @param changeInfo
*/
- public EventGenerator(ContentChangeInfo changeInfo) {
- this.changeInfo = changeInfo;
- }
+ public EventGenerator() {}
/**
* Creates a new generator instance for processing the given changes.
*/
public EventGenerator(
@Nonnull NodeState before, @Nonnull NodeState after,
- @Nonnull ContentChangeInfo changeInfo,
@Nonnull EventHandler handler) {
- this(changeInfo);
continuations.addFirst(new Continuation(handler, before, after, 0));
}
@@ -127,7 +120,7 @@ public class EventGenerator {
}
}
- private class Continuation implements NodeStateDiff, Runnable, ContentChangeInfoProvider {
+ private class Continuation implements NodeStateDiff, Runnable {
/**
* Filtered handler of detected content changes.
@@ -183,13 +176,6 @@ public class EventGenerator {
}
}
- //-------------------------------------------------< ContentChangeInfoProvider >--
-
- @Override
- public ContentChangeInfo getChangeInfo() {
- return changeInfo;
- }
-
//-------------------------------------------------< NodeStateDiff >--
@Override
Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/NodeObserver.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/NodeObserver.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/NodeObserver.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/NodeObserver.java Mon Aug 10 14:25:41 2015
@@ -157,8 +157,7 @@ public abstract class NodeObserver imple
handler = handler.getChildHandler(oakName, before, after);
}
- ContentChangeInfo changeInfo = new ContentChangeInfo(before, after, info);
- EventGenerator generator = new EventGenerator(before, after, changeInfo, handler);
+ EventGenerator generator = new EventGenerator(before, after, handler);
while (!generator.isDone()) {
generator.generate();
}
Modified: jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/AbstractMongoConnectionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/AbstractMongoConnectionTest.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/AbstractMongoConnectionTest.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/AbstractMongoConnectionTest.java Mon Aug 10 14:25:41 2015
@@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.plugins.document;
-import com.mongodb.DB;
import org.apache.jackrabbit.mk.api.MicroKernel;
import org.apache.jackrabbit.oak.plugins.document.util.MongoConnection;
import org.apache.jackrabbit.oak.stats.Clock;
@@ -45,17 +44,13 @@ public abstract class AbstractMongoConne
mongoConnection = MongoUtils.getConnection();
MongoUtils.dropCollections(mongoConnection.getDB());
Revision.setClock(getTestClock());
- mk = prepare(new DocumentMK.Builder().clock(getTestClock()),mongoConnection.getDB()).open();
+ mk = new DocumentMK.Builder().clock(getTestClock()).setMongoDB(mongoConnection.getDB()).open();
}
protected Clock getTestClock() throws InterruptedException {
return Clock.SIMPLE;
}
- protected DocumentMK.Builder prepare(DocumentMK.Builder builder, DB db){
- return builder.setMongoDB(db);
- }
-
@After
public void tearDownConnection() throws Exception {
mk.dispose();
Modified: jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/AmnesiaDiffCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/AmnesiaDiffCache.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/AmnesiaDiffCache.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/AmnesiaDiffCache.java Mon Aug 10 14:25:41 2015
@@ -16,9 +16,13 @@
*/
package org.apache.jackrabbit.oak.plugins.document;
+import java.util.Collections;
+
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import org.apache.jackrabbit.oak.cache.CacheStats;
+
/**
* A diff cache implementation, which immediately forgets the diff.
*/
@@ -55,4 +59,10 @@ class AmnesiaDiffCache implements DiffCa
}
};
}
+
+ @Nonnull
+ @Override
+ public Iterable<CacheStats> getStats() {
+ return Collections.emptyList();
+ }
}
Modified: jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreDiffTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreDiffTest.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreDiffTest.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreDiffTest.java Mon Aug 10 14:25:41 2015
@@ -64,18 +64,16 @@ public class DocumentNodeStoreDiffTest e
merge(store, builder);
}
- CacheStats stats = ((MemoryDiffCache) store.getDiffCache()).getDiffCacheStats();
- stats.resetStats();
+ Iterable<CacheStats> stats = store.getDiffCacheStats();
+ for (CacheStats cs : stats) {
+ cs.resetStats();
+ }
// must not cause cache misses
Diff.perform(before, after);
- assertEquals(0, stats.getMissCount());
- }
-
- @Override
- protected DocumentMK.Builder prepare(DocumentMK.Builder builder, DB db) {
- builder.setDisableLocalDiffCache(true);
- return super.prepare(builder, db);
+ for (CacheStats cs : stats) {
+ assertEquals(0, cs.getMissCount());
+ }
}
@Override
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=1695086&r1=1695085&r2=1695086&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 Mon Aug 10 14:25:41 2015
@@ -823,8 +823,7 @@ public class DocumentNodeStoreTest {
long startValue,
int limit) {
numQueries.getAndIncrement();
- return super.query(collection, fromKey, toKey,
- indexedProperty, startValue, limit);
+ return super.query(collection, fromKey, toKey, indexedProperty, startValue, limit);
}
};
final DocumentNodeStore ns = new DocumentMK.Builder()
@@ -1139,8 +1138,7 @@ public class DocumentNodeStoreTest {
reads.clear();
NodeState existingChild = parentNodeState.getChildNode("child25");
- assertTrue("Fully cached entry in doc child cache should be able to find existing children" +
- " even if doc store sort order is incompatible to that of Java", reads.size() > 0);
+ assertTrue("Fully cached entry in doc child cache should be able to find existing children" + " even if doc store sort order is incompatible to that of Java", reads.size() > 0);
assertTrue("Existing children should be reported as such", existingChild.exists());
store.dispose();
@@ -1684,6 +1682,83 @@ public class DocumentNodeStoreTest {
ns.dispose();
}
+ @Test
+ public void rootRevision() throws Exception {
+ DocumentNodeStore ns = new DocumentMK.Builder().getNodeStore();
+
+ NodeBuilder builder = ns.getRoot().builder();
+ builder.child("foo").child("child");
+ builder.child("bar").child("child");
+ merge(ns, builder);
+
+ builder = ns.getRoot().builder();
+ builder.child("foo").child("child").child("node");
+ merge(ns, builder);
+
+ Revision head = ns.getHeadRevision();
+ NodeState child = ns.getRoot().getChildNode("bar").getChildNode("child");
+ assertTrue(child instanceof DocumentNodeState);
+ DocumentNodeState state = (DocumentNodeState) child;
+ assertEquals(head, state.getRootRevision());
+
+ ns.dispose();
+ }
+
+ @Test
+ public void diffCache() throws Exception {
+ final AtomicInteger numQueries = new AtomicInteger();
+ MemoryDocumentStore store = new MemoryDocumentStore() {
+ @Nonnull
+ @Override
+ public <T extends Document> List<T> query(Collection<T> collection,
+ String fromKey,
+ String toKey,
+ int limit) {
+ numQueries.incrementAndGet();
+ return super.query(collection, fromKey, toKey, limit);
+ }
+ };
+ DocumentNodeStore ns = new DocumentMK.Builder()
+ .setDocumentStore(store).setAsyncDelay(0).getNodeStore();
+
+ NodeBuilder builder = ns.getRoot().builder();
+ builder.child("foo").child("child");
+ merge(ns, builder);
+
+ builder = ns.getRoot().builder();
+ builder.child("bar");
+ merge(ns, builder);
+
+ DocumentNodeState before = ns.getRoot();
+
+ builder = ns.getRoot().builder();
+ builder.child("foo").child("child").child("node");
+ merge(ns, builder);
+
+ DocumentNodeState after = ns.getRoot();
+
+ numQueries.set(0);
+ final List<String> added = Lists.newArrayList();
+ ns.compare(asDocumentNodeState(after.getChildNode("foo").getChildNode("child")),
+ asDocumentNodeState(before.getChildNode("foo").getChildNode("child")),
+ new DefaultNodeStateDiff() {
+ @Override
+ public boolean childNodeAdded(String name,
+ NodeState after) {
+ added.add(name);
+ return super.childNodeAdded(name, after);
+ }
+ });
+
+
+ assertEquals(1, added.size());
+ assertEquals("node", added.get(0));
+ assertEquals("must not run queries", 0, numQueries.get());
+
+ ns.dispose();
+
+ }
+
// OAK-1970
@Test
public void diffMany() throws Exception {
Modified: jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LocalDiffCacheTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LocalDiffCacheTest.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LocalDiffCacheTest.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LocalDiffCacheTest.java Mon Aug 10 14:25:41 2015
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.jackrabbit.oak.plugins.document;
import java.util.HashMap;
@@ -25,15 +24,18 @@ import java.util.Set;
import javax.annotation.Nonnull;
+import com.google.common.collect.Maps;
+
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.cache.CacheStats;
-import org.apache.jackrabbit.oak.plugins.document.LocalDiffCache.ConsolidatedDiff;
+import org.apache.jackrabbit.oak.plugins.document.LocalDiffCache.Diff;
import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore;
import org.apache.jackrabbit.oak.plugins.observation.NodeObserver;
import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.junit.After;
import org.junit.Test;
import static com.google.common.collect.Maps.newHashMap;
@@ -45,59 +47,67 @@ public class LocalDiffCacheTest {
DocumentNodeStore store;
+ @After
+ public void dispose() {
+ if (store != null) {
+ store.dispose();
+ store = null;
+ }
+ }
+
@Test
public void simpleDiff() throws Exception{
TestNodeObserver o = new TestNodeObserver("/");
- store = createMK().getNodeStore();
+ store = createMK().getNodeStore();
store.addObserver(o);
o.reset();
- LocalDiffCache cache = getLocalDiffCache();
- CacheStats stats = cache.getDiffCacheStats();
+ DiffCache cache = store.getDiffCache();
+ Iterable<CacheStats> stats = cache.getStats();
- DocumentNodeState beforeState = store.getRoot();
NodeBuilder builder = store.getRoot().builder();
builder.child("a").child("a2").setProperty("foo", "bar");
builder.child("b");
- DocumentNodeState afterState = merge(store, builder);
+ merge(store, builder);
- assertTrue(stats.getHitCount() > 0);
- assertEquals(0, stats.getMissCount());
+ assertTrue(getHitCount(stats) > 0);
+ assertEquals(0, getMissCount(stats));
assertEquals(3, o.added.size());
- ConsolidatedDiff diff = cache.getDiff(beforeState.getRevision(), afterState.getRevision());
- String serailized = diff.asString();
- ConsolidatedDiff diff2 = ConsolidatedDiff.fromString(serailized);
- assertEquals(diff, diff2);
-
builder = store.getRoot().builder();
builder.child("a").child("a2").removeProperty("foo");
o.reset();
- stats.resetStats();
+ resetStats(stats);
merge(store, builder);
- assertTrue(stats.getHitCount() > 0);
- assertEquals(0, stats.getMissCount());
+ assertTrue(getHitCount(stats) > 0);
+ assertEquals(0, getMissCount(stats));
assertEquals(1, o.changed.size());
+ }
+
+ @Test
+ public void diffFromAsString() {
+ Map<String, String> changes = Maps.newHashMap();
+ changes.put("/", "+\"foo\":{}^\"bar\":{}-\"baz\"");
+ changes.put("/foo", "");
+ changes.put("/bar", "+\"qux\"");
+ changes.put("/bar/qux", "");
+ Diff diff = new Diff(changes, 0);
- store.dispose();
+ assertEquals(changes, Diff.fromString(diff.asString()).getChanges());
}
@Test
public void emptyDiff() throws Exception{
Map<String, String> changes = new HashMap<String, String>();
- ConsolidatedDiff diff = new ConsolidatedDiff(changes, 100);
+ Diff diff = new Diff(changes, 100);
String asString = diff.asString();
- ConsolidatedDiff diff2 = ConsolidatedDiff.fromString(asString);
+ Diff diff2 = Diff.fromString(asString);
assertEquals(diff, diff2);
}
- private LocalDiffCache getLocalDiffCache(){
- return (LocalDiffCache) store.getLocalDiffCache();
- }
-
private static DocumentNodeState merge(NodeStore store, NodeBuilder builder)
throws CommitFailedException {
return (DocumentNodeState) store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
@@ -116,6 +126,28 @@ public class LocalDiffCacheTest {
.open();
}
+ private static long getHitCount(Iterable<CacheStats> stats) {
+ long hitCount = 0;
+ for (CacheStats cs : stats) {
+ hitCount += cs.getHitCount();
+ }
+ return hitCount;
+ }
+
+ private static long getMissCount(Iterable<CacheStats> stats) {
+ long missCount = 0;
+ for (CacheStats cs : stats) {
+ missCount += cs.getMissCount();
+ }
+ return missCount;
+ }
+
+ private static void resetStats(Iterable<CacheStats> stats) {
+ for (CacheStats cs : stats) {
+ cs.resetStats();
+ }
+ }
+
//------------------------------------------------------------< TestNodeObserver >---
private static class TestNodeObserver extends NodeObserver {
Modified: jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/MeasureMemory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/MeasureMemory.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/MeasureMemory.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/MeasureMemory.java Mon Aug 10 14:25:41 2015
@@ -23,6 +23,8 @@ import java.util.LinkedList;
import java.util.concurrent.Callable;
import com.mongodb.BasicDBObject;
+
+import org.apache.jackrabbit.oak.plugins.document.util.RevisionsKey;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
import org.junit.Test;
@@ -125,6 +127,18 @@ public class MeasureMemory {
}
});
}
+
+ @Test
+ public void revisionsKey() throws Exception {
+ measureMemory(new Callable<Object[]>() {
+ @Override
+ public Object[] call() {
+ RevisionsKey k = new RevisionsKey(
+ Revision.newRevision(0), Revision.newRevision(0));
+ return new Object[]{k, k.getMemory() + OVERHEAD};
+ }
+ });
+ }
private static void measureMemory(Callable<Object[]> c) throws Exception {
LinkedList<Object> list = new LinkedList<Object>();
Modified: jackrabbit/oak/branches/1.0/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/EventQueue.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/EventQueue.java?rev=1695086&r1=1695085&r2=1695086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/EventQueue.java (original)
+++ jackrabbit/oak/branches/1.0/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/EventQueue.java Mon Aug 10 14:25:41 2015
@@ -29,7 +29,6 @@ import javax.jcr.observation.EventIterat
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
-import org.apache.jackrabbit.oak.plugins.observation.ContentChangeInfo;
import org.apache.jackrabbit.oak.plugins.observation.EventGenerator;
import org.apache.jackrabbit.oak.plugins.observation.EventHandler;
import org.apache.jackrabbit.oak.plugins.observation.FilteredHandler;
@@ -52,7 +51,7 @@ class EventQueue implements EventIterato
@Nonnull NamePathMapper mapper, CommitInfo info,
@Nonnull NodeState before, @Nonnull NodeState after,
@Nonnull Iterable<String> basePaths, @Nonnull EventFilter filter) {
- this.generator = new EventGenerator(new ContentChangeInfo(before, after, info));
+ this.generator = new EventGenerator();
EventFactory factory = new EventFactory(mapper, info);
EventHandler handler = new FilteredHandler(
filter, new QueueingHandler(this, factory, before, after));