Tag: xml

  • Spring and Logback

    IoC, or DI definitely takes a perspective turnaround inside your head, but you get around it slowly.  I was playing around ways to integrate LogBack, and Spring – essentially around having Spring give me a pre-created instance of LogBack logger.

    I searched around posts, but most people seem to be against using Spring just for substituting one-line of Logback (Logger log = LoggerFactory.getLogger("LogbackTest");) to get your logger.

    I, on the other hand, was more interested in how to get Spring give me a LogBack logger instance without too much contrived hand-written code to achieve so. And with a bit of reading through Spring principles, documentation I found the way.

    Essentially, when using Logback’s LoggerFactory you have access to only a single getLogger() factory method. This is static which makes things a bit different for what Spring would call a bean – a class providing constructor, getter, setter methods. To circumvent this non-bean style, Spring provides what you call as static initializers a.k.a substitutes for constructors, which allow you to call a static method in lieu of calling a constructor on an object.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
     "http://www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>
     <bean id="bean1" class="org.slf4j.LoggerFactory" factory-method="getLogger">
     <constructor-arg value="LogbackTest" />
     </bean>
    </beans>

    Now, this bean1 can be used as a regular bean inside your class

    ApplicationContext ctx = new FileSystemXmlApplicationContext("logbacktest.xml");
     Logger log = (Logger) ctx.getBean("bean1");
    
     log.debug("This is my first message");
     log.info("How about this information message");

    Throw in a logback.xml in your classpath, and viola you have a nice Spring injected dependency – log in your code, while still using Logback!

  • Wikimedia Downloads

    Wikimedia Downloads

    The following kinds of downloads are available:

    Database backup dumps
    A complete copy of all Wikimedia wikis, in the form of wikitext source and metadata embedded in XML. A number of raw database tables in SQL form are also available.
    Static HTML dumps
    A copy of all pages from all Wikipedia wikis, in HTML form.
    DVD distributions
    Available for some Wikipedia editions.

    Wikimedia Downloads.

  • Solr replication

    1)On solr.master:
    +Edit scripts.conf:
    solr_hostname=localhost
    solr_port=8983
    rsyncd_port=18983
    +Enable and start rsync:
    rsyncd-enable; rsyncd-start
    +Run snapshooter:
    snapshooter
    After running this, you should be able to see a new folder named snapshot.*
    in data/index folder.
    You can can solrconfig.xml to trigger snapshooter after a commit or
    optimise.
    
    2) On slave:
    +Edit scripts.conf:
    solr_hostname=solr.master
    solr_port=8986
    rsyncd_port=18986
    data_dir=
    webapp_name=solr
    master_host=localhost
    master_data_dir=$MASTER_SOLR_HOME/data/
    master_status_dir=$MASTER_SOLR_HOME/logs/clients/
    +Run snappuller:
    snappuller -P 18983
    +Run snapinstaller:
    snapinstaller
    
    You should setup crontab to run snappuller and snapinstaller periodically.

    Re: Solr replication.