Log4php
  1. Log4php
  2. LOG4PHP-203

Capped collections support for Mongo Appender

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.0
    • Fix Version/s: 3.0.0
    • Component/s: Code
    • Labels:

      Description

      Mongo database now support capped collection. Capped collections are fixed-size collections that support high-throughput operations that insert, retrieve, and delete documents based on insertion order. Capped collections work in a way similar to circular buffers: once a collection fills its allocated space, it makes room for new documents by overwriting the oldest documents in the collection.

      For more information see: http://docs.mongodb.org/manual/core/capped-collections/

      1. capped_collections_docs.patch
        3 kB
        Vladimír Gorej
      2. capped_collections.patch
        16 kB
        Vladimír Gorej
      3. capped_collections.patch
        15 kB
        Vladimír Gorej

        Activity

        Hide
        Vladimír Gorej added a comment -

        Patch for capped collection support + tests.

        Show
        Vladimír Gorej added a comment - Patch for capped collection support + tests.
        Hide
        Vladimír Gorej added a comment -

        Support added. Tests pass.

        Show
        Vladimír Gorej added a comment - Support added. Tests pass.
        Hide
        Ivan Habunek added a comment -

        Cool.

        In future, could you use "LOG4PHP-203" instead of "Issue #203" in the commit comments? If you do that, JIRA should be able to link commits to issues, and display them in the web interface. Currently the feature is not enabled, but Infra is working on it.

        Show
        Ivan Habunek added a comment - Cool. In future, could you use " LOG4PHP-203 " instead of "Issue #203" in the commit comments? If you do that, JIRA should be able to link commits to issues, and display them in the web interface. Currently the feature is not enabled, but Infra is working on it.
        Hide
        Ivan Habunek added a comment -

        Also, wrap messages to 74 chars (or such), so they are readable in "git log".
        I need to write the contributing guidelines.

        Show
        Ivan Habunek added a comment - Also, wrap messages to 74 chars (or such), so they are readable in "git log". I need to write the contributing guidelines.
        Hide
        Vladimír Gorej added a comment -

        Ok, I'll keep both things in mind ;]

        Show
        Vladimír Gorej added a comment - Ok, I'll keep both things in mind ;]
        Hide
        Vladimír Gorej added a comment -

        This two issues can still be fixed in patch file by manualy editing the patch. Next time, I'll follow these guidelines.

        Show
        Vladimír Gorej added a comment - This two issues can still be fixed in patch file by manualy editing the patch. Next time, I'll follow these guidelines.
        Hide
        Ivan Habunek added a comment -

        I have tests failing with MongoDB versions 1.8.2 and 2.0.8 on Win XP. Tried testing with latest MongoDB 2.2.x, but they dropped support for XP.

        There was 1 failure:
        
        1) LoggerAppenderMongoDBTest::testCappedCollection
        Failed asserting that 10 matches expected 2.
        
        D:\Projects\apache\log4php\src\test\php\appenders\LoggerAppenderMongoDBTest.php:222
        

        Not sure why this happens, on Ubuntu with MongoDB 2.0.4, the tests pass OK.

        Also, if you run the tests multiple times, the actual number increases by 10 each time. After running the tests 5 times, the error is:

        1) LoggerAppenderMongoDBTest::testCappedCollection
        Failed asserting that 50 matches expected 2.
        
        Show
        Ivan Habunek added a comment - I have tests failing with MongoDB versions 1.8.2 and 2.0.8 on Win XP. Tried testing with latest MongoDB 2.2.x, but they dropped support for XP. There was 1 failure: 1) LoggerAppenderMongoDBTest::testCappedCollection Failed asserting that 10 matches expected 2. D:\Projects\apache\log4php\src\test\php\appenders\LoggerAppenderMongoDBTest.php:222 Not sure why this happens, on Ubuntu with MongoDB 2.0.4, the tests pass OK. Also, if you run the tests multiple times, the actual number increases by 10 each time. After running the tests 5 times, the error is: 1) LoggerAppenderMongoDBTest::testCappedCollection Failed asserting that 50 matches expected 2.
        Hide
        Vladimír Gorej added a comment -

        It looks like that mongo on windows have problems creating capped collection for some reason. I will try to test it on some windows virtual machine.

        Show
        Vladimír Gorej added a comment - It looks like that mongo on windows have problems creating capped collection for some reason. I will try to test it on some windows virtual machine.
        Hide
        Ivan Habunek added a comment -

        The same under Windows 7 64bit + MongoDB 2.2.2.

        Here's the log if it helps:
        http://pastebin.com/raw.php?i=K4bf7BBW

        Show
        Ivan Habunek added a comment - The same under Windows 7 64bit + MongoDB 2.2.2. Here's the log if it helps: http://pastebin.com/raw.php?i=K4bf7BBW
        Hide
        Vladimír Gorej added a comment -

        Thanks, that helped a lot. Uploading new patch.

        Show
        Vladimír Gorej added a comment - Thanks, that helped a lot. Uploading new patch.
        Hide
        Vladimír Gorej added a comment -

        Fixed patch

        Show
        Vladimír Gorej added a comment - Fixed patch
        Hide
        Ivan Habunek added a comment -

        Good! I'm off for this year. See you next. Have fun.

        Show
        Ivan Habunek added a comment - Good! I'm off for this year. See you next. Have fun.
        Hide
        Vladimír Gorej added a comment -

        Just to clarify, where the problem was:

        There were two tests testing capped collection functionality. First test created capped collection with max_size 1000. The second test was trying to create collection with max_size 10, but collection with name logs_capped already existed, so the old collection with max_size 1000 was used instead.

        Show
        Vladimír Gorej added a comment - Just to clarify, where the problem was: There were two tests testing capped collection functionality. First test created capped collection with max_size 1000. The second test was trying to create collection with max_size 10, but collection with name logs_capped already existed, so the old collection with max_size 1000 was used instead.
        Hide
        Ivan Habunek added a comment -

        Interesting that it was producing different results on Windows...

        Anyway, I can confirm all tests pass now, both on Windows and Ubuntu. The code is in the develop branch.

        Thank you for the work, however, there is one more thing to do here: add new parameters to the docs. Could you do that as well? It's in: src/site/xdoc/docs/appenders/mongodb.xml

        Show
        Ivan Habunek added a comment - Interesting that it was producing different results on Windows... Anyway, I can confirm all tests pass now, both on Windows and Ubuntu. The code is in the develop branch. Thank you for the work, however, there is one more thing to do here: add new parameters to the docs. Could you do that as well? It's in: src/site/xdoc/docs/appenders/mongodb.xml
        Hide
        Vladimír Gorej added a comment -

        Patch for mongo appender capped collection documentation.

        Show
        Vladimír Gorej added a comment - Patch for mongo appender capped collection documentation.
        Hide
        Ivan Habunek added a comment -

        Good work. Applied. Closing issue.

        Show
        Ivan Habunek added a comment - Good work. Applied. Closing issue.

          People

          • Assignee:
            Ivan Habunek
            Reporter:
            Vladimír Gorej
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 2h
              2h
              Remaining:
              Remaining Estimate - 2h
              2h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development