Examples of DbWatcher


Examples of org.xmlBlaster.contrib.dbwatcher.DbWatcher

         log.info("The DbWatcher has been successfully restarted");
      }
   }

   private static DbWatcher initializeDbWatcher(I_Info readerInfo, DbWriter dbWriter) throws Exception {
      DbWatcher dbWatcher = null;
      if (readerInfo != null) {
         try {
            log.info("setUp: Instantiating DbWatcher");
            GlobalInfo.setStrippedHostname(readerInfo, GlobalInfo.UPPER_CASE);
            dbWatcher = new DbWatcher();
            dbWatcher.init(readerInfo);
           
            I_DbSpecific dbSpecific = null;
            if (readerInfo != null) {
               if (readerInfo.getBoolean("replication.doBootstrap", false)) {
                  boolean needsPublisher = readerInfo.getBoolean(I_DbSpecific.NEEDS_PUBLISHER_KEY, true);
                  boolean forceCreationAndInitNo = false;
                  dbSpecific = ReplicationConverter.getDbSpecific(readerInfo, forceCreationAndInitNo); // done only on master !!!
                  readerInfo.put(I_DbSpecific.NEEDS_PUBLISHER_KEY, "" + needsPublisher); // back to original
                  I_DbPool pool = (I_DbPool)readerInfo.getObject("db.pool");
                  if (pool == null)
                     throw new Exception("ReplicationAgent.init: the db pool is null");
                  Connection conn = pool.reserve();
                  try {
                     boolean doWarn = false;
                     boolean force = false;
                     dbSpecific.bootstrap(conn, doWarn, force);
                  }
                  catch (Exception ex) {
                     conn = SpecificDefault.removeFromPool(conn, SpecificDefault.ROLLBACK_YES, pool);
                  }
                  finally {
                     conn = SpecificDefault.releaseIntoPool(conn, SpecificDefault.COMMIT_YES, pool);
                  }
               }
            }
            dbWatcher.startAlertProducers();
         }
         catch (Exception ex) {
            if (dbWriter != null) {
               try {
                  dbWriter.shutdown();
View Full Code Here

Examples of org.xmlBlaster.contrib.dbwatcher.DbWatcher

   /**
    * @see org.xmlBlaster.util.plugin.I_Plugin#init(org.xmlBlaster.util.Global, org.xmlBlaster.util.plugin.PluginInfo)
    */
   protected void doInit(Global global_, PluginInfo pluginInfo) throws XmlBlasterException {
      try {
         this.dbWatcher = new DbWatcher(this);
         this.dbWatcher.startAlertProducers();
      }
      catch (Throwable e) {
         throw new XmlBlasterException(this.global, ErrorCode.RESOURCE_CONFIGURATION, "DbWatcherPlugin", "init failed", e);
      }
View Full Code Here

Examples of org.xmlBlaster.contrib.dbwatcher.DbWatcher

    */
   private void pollingExample(Preferences prefs) throws Exception {
      log.info("Start polling test");
     
      I_Info info = new Info(prefs);
      DbWatcher processor = new DbWatcher(info);
      processor.startAlertProducers();

      boolean interactive = info.getBoolean("interactive", true);
      if (interactive) {
         // Manually trigger db checking ...
         BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
         while (true) {
            System.out.print("Hit 'q' to exit, 't' to trigger an event > ");
            String line = in.readLine(); // Blocking in I/O
            if (line == null) continue;
            line = line.trim();
            if (line.toLowerCase().equals("q"))
               break;
            if (line.toLowerCase().equals("t"))
               processor.getChangeDetector().checkAgain(null);
         }
      }
      else {
         /*
         for (int i=0; i<10; i++) {
            processor.getChangeDetector().checkAgain(null);
            Thread.sleep(1000);
         }
         */
         log.info("Sleeping no a long time ...");
         Thread.sleep(1000000);
      }


      processor.shutdown();
      log.info("Done!");
   }
View Full Code Here

Examples of org.xmlBlaster.contrib.dbwatcher.DbWatcher

                     " </qos>");
      System.setProperty("protocol", "SOCKET");
      System.setProperty("protocol/socket/hostname", "192.168.110.10");
      */

      DbWatcher pc = new DbWatcher(info);
      XmlBlasterPublisher mom = (XmlBlasterPublisher)pc.getMom();
      mom.subscribe("XPATH://key", new I_Update() {
         public void update(String topic, java.io.InputStream is, Map attrMap) {
            log.info("Received '" + topic + "' from MoM");
            try {
               writeToFile(topic, new String(TestUtils.getContent(is)));
            }
            catch (Exception e) {
               // Ignore  
            }
            updateMap.put(topic, is);
         }
      });
     
      try { Thread.sleep(1000); } catch(Exception e) { /* Ignore */ }
      updateMap.clear(); // Ignore any existing topics

      pc.startAlertProducers();
     
      return pc;
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.