Package org.xmlBlaster.contrib.replication

Examples of org.xmlBlaster.contrib.replication.I_ReplSlave


               // individualInfo.putObject(INITIAL_FILES_LOCATION, null);
               individualInfo.put(INITIAL_FILES_LOCATION, null);
            }
            individualInfo.put(REPL_VERSION, requestedVersion);
            individualInfo.putObject("org.xmlBlaster.engine.Global", this.global);
            I_ReplSlave slave = null;
            synchronized (this.replSlaveMap) {
               slave = (I_ReplSlave)this.replSlaveMap.get(slaveSessionName);
            }
            if (slave != null) {
               individualInfo.put("_replName", replicationPrefix);
               String dbWatcherSessionId = individualInfo.get(SENDER_SESSION, null);
               if (dbWatcherSessionId == null)
                  throw new Exception("ReplSlave '" + slave + "' constructor: the master Session Id (which is passed in the properties as '" + SENDER_SESSION + "' are not found. Can not continue with initial update");

               if (cascadeSlaveSessionName != null) {
                  // check to avoid loops
                  cascadeSlaveSessionName = cascadeSlaveSessionName.trim();
                  if (slaveSessionName.equals(cascadeSlaveSessionName))
                     throw new Exception(ret + " did fail since having the same slave '" + slaveSessionName + "' for both replications would result in a loop");
                     // return "error: " + ret + " did fail since having the same slave '" + slaveSessionName + "' for both replications would result in a loop";
               }
              
               boolean isOkToStart = slave.run(individualInfo, dbWatcherSessionId, cascadeReplicationPrefix, cascadeSlaveSessionName, false);
               if (isOkToStart == false) {
                  ret += " did fail since your status is '" + slave.getStatus() + "'. Please invoke first 'Cancel Update'";
                  throw new Exception(ret);
                  // return "error: " + ret; // don't throw an exception here since MX4J seems to loose exception msg.
               }
            }
            else
View Full Code Here


         return "OK";
      int pos = receiver.indexOf("client/");
      if (pos < 0)
         return "OK";
      String key = receiver.substring(pos).trim();
      I_ReplSlave slave = null;
      synchronized(this.replSlaveMap) {
         slave = (I_ReplSlave)this.replSlaveMap.get(key);
      }
      slave.onDeadLetter(qos.getClientProperties());
      return "OK";
   }
View Full Code Here

               if (completeSlaveName == null)
                  log.severe("on initial data response the slave name was not specified. Can not perform operation");
               else {
                  String[] slaveNames = StringPairTokenizer.parseLine(completeSlaveName, ',');
                  for (int i=0; i < slaveNames.length; i++) {
                     I_ReplSlave slave = null;
                     synchronized (this.replSlaveMap) {
                        slave = (I_ReplSlave)this.replSlaveMap.get(slaveNames[i]);
                     }
                     if (slave == null)
                        log.severe("on initial data response the slave name '" + slaveNames[i] + "' was not registered (could have already logged out)");
                     else
                        slave.reactivateDestination(minReplKey, maxReplKey);
                  }
               }
            }
            catch (Exception ex) {
               log.warning("reactivateDestination encountered an exception '" + ex.getMessage());
            }
         }
         else if ("INITIATE_REPLICATION".equals(request)) {
            String slaveSessionName = updateQos.getClientProperty("_slaveSessionName", (String)null);
            String prefixWithVersion = updateQos.getClientProperty("_prefixWithVersion", (String)null);
            String cascadeSlaveSessionName = updateQos.getClientProperty("_cascadeSlaveSessionName", (String)null);
            String cascadeReplicationPrefix = updateQos.getClientProperty("_cascadeReplicationPrefix", (String)null);
            String realInitialFilesLocation = updateQos.getClientProperty("_realInitialFilesLocation", (String)null);
            boolean force = updateQos.getClientProperty("_force", false);
            if (force) {
               I_ReplSlave slave = null;
               try {
                  synchronized (this.replSlaveMap) {
                     slave = (I_ReplSlave)this.replSlaveMap.get(slaveSessionName);
                  }
                  if (slave != null)
                     slave.cancelInitialUpdate(false);
               }
               catch (Throwable ex) {
                  log.severe("Could not cancel initial update for slave '" + slave.getSessionName() + "'");
                  ex.printStackTrace();
               }
            }
            String ret = initiateReplication(slaveSessionName, prefixWithVersion, cascadeSlaveSessionName, cascadeReplicationPrefix, realInitialFilesLocation);
            log.info(ret);
View Full Code Here

         log.warning("got " + pushEntries.size() + " entries in Dispatcher Sync mode (happens on communication Exceptions. Will ignore this");
         // return pushEntries;
         return null;
      }

      I_ReplSlave slave = null;
      String relativeName = dispatchManager.getSessionName().getRelativeName();
      int maxEntriesToRetrieve = this.maxNumOfEntries;
      synchronized (this.replSlaveMap) {
         slave = (I_ReplSlave)this.replSlaveMap.get(relativeName);
         int status = slave.getStatusAsInt();
         if (status != I_ReplSlave.STATUS_NORMAL && status != I_ReplSlave.STATUS_INCONSISTENT) {
            log.info("Setting the number of entries to retreive to '1' since status is '" + slave.getStatus() + "' (otherwise it would be '" + this.maxNumOfEntries + "'");
            maxEntriesToRetrieve = 1;
         }
         else
            maxEntriesToRetrieve = getMaxNumOfEntries(slave);
      }
      // take messages from queue (none blocking) ...
      I_Queue cbQueue = dispatchManager.getQueue();
      // ArrayList entryList = cbQueue.peekSamePriority(-1, this.maxSize);
      List<I_Entry> entryList = cbQueue.peekSamePriority(maxEntriesToRetrieve, this.maxSize);
      log.info("handleNextMessages invoked with '" + entryList.size() + "' entries (max was '" + maxEntriesToRetrieve + "'");

      // filter expired entries etc. ...
      // you should always call this method after taking messages from queue
      entryList = dispatchManager.prepareMsgsFromQueue(entryList);
      log.info("handleNextMessages after cleaning up with '" + entryList.size() + "' entries");

      if (slave == null) {
         log.warning("could not find a slave for replication client '" + relativeName + "'");
         return entryList;
      }
      try {
         return slave.check(entryList, cbQueue);
      }
      catch (Exception ex) {
         if (slave != null)
            slave.handleException(ex);
         if (ex instanceof XmlBlasterException)
            throw (XmlBlasterException)ex;
         throw new XmlBlasterException(this.global, ErrorCode.INTERNAL, "exception occured when filtering replication messages", "", ex);
      }
      catch (Throwable ex) {
         if (slave != null)
            slave.handleException(ex);
         throw new XmlBlasterException(this.global, ErrorCode.INTERNAL, "throwable occured when filtering replication messages. " + Global.getStackTraceAsString(ex), "", ex);
      }
   }
View Full Code Here

   /**
    * @see org.xmlBlaster.util.dispatch.plugins.I_MsgDispatchInterceptor#shutdown(org.xmlBlaster.util.dispatch.DispatchManager)
    */
   public synchronized void shutdown(DispatchManager dispatchManager) throws XmlBlasterException {
      I_ReplSlave slave = null;
      String name = dispatchManager.getSessionName().getRelativeName();
      synchronized (this.replSlaveMap) {
         slave = (I_ReplSlave)this.replSlaveMap.remove(name);
      }
      if (slave != null) {
View Full Code Here

      log.fine("Connecting with qos : " + connQos.toXml());
      String sessionName = e.getSessionInfo().getSessionName().getRelativeName();
      log.info("addition of session for '" + sessionName +"' occured");
      synchronized (this.replSlaveMap) {
         if (!this.replSlaveMap.containsKey(sessionName)) {
            I_ReplSlave slave = new ReplSlave(this.global, this, sessionName, connQos.getData());
            try {
               slave.setDispatcher(false, false); // stop dispatcher without persisting the information
            }
            catch (Exception ex) {
               log.warning("Could not set the dispatcher for '" + sessionName + "' to false when adding the session");
               ex.printStackTrace();
            }
View Full Code Here

      log.info("removal of session for '" + sessionName +"' occured");
      synchronized (this.replSlaveMap) {
         if (!this.replSlaveMap.containsKey(sessionName))
            log.warning("The slave '" + sessionName + "' is not registered.");
         else {
            I_ReplSlave slave = (I_ReplSlave)this.replSlaveMap.remove(sessionName);
            if (slave != null) {
               try {
                  slave.shutdown();
               }
               catch (Exception ex) {
                  log.severe("Could not shut down the slave '" + sessionName + "' properly");
                  ex.printStackTrace();
               }
View Full Code Here

         return;
     
      String relativeSessionName = e.getSubscriptionInfo().getSessionInfo().getSessionName().getRelativeName();
      log.info("addition of subscription for '" + relativeSessionName +"' occured");
     
      I_ReplSlave slave = null;
      synchronized (this.replSlaveMap) {
          slave = (I_ReplSlave)this.replSlaveMap.get(relativeSessionName);
      }

      if (slave != null) {
         Map clientProperties = e.getSubscriptionInfo().getSubscribeQosServer().getData().getClientProperties();
         try {
            slave.init(new ClientPropertiesInfo(clientProperties));
         }
         catch (Exception ex) {
            throw new XmlBlasterException(this.global, ErrorCode.INTERNAL_UNKNOWN, "ReplManagerPlugin.subscriptionAdd", "", ex);
         }
      }
View Full Code Here

                  ex.printStackTrace();
               }
            }
         }
      }
      I_ReplSlave slave = null;
      String relativeName = dispatchManager.getSessionName().getRelativeName();
      synchronized (this.replSlaveMap) {
         slave = (I_ReplSlave)this.replSlaveMap.get(relativeName);
      }
      if (slave == null) {
         log.warning("could not find a slave for replication client '" + relativeName + "'");
      }
      try {
         slave.postCheck(processedEntries);
      }
      catch (Exception ex) {
         throw new XmlBlasterException(this.global, ErrorCode.INTERNAL, "exception occured when filtering replication messages", "", ex);
      }
      catch (Throwable ex) {
View Full Code Here

         throw new XmlBlasterException(this.global, ErrorCode.INTERNAL, "throwable occured when filtering replication messages. " + Global.getStackTraceAsString(ex), "", ex);
      }
   }

   public void onDispatchWorkerException(DispatchManager dispatchManager, Throwable ex) {
      I_ReplSlave slave = null;
      String relativeName = dispatchManager.getSessionName().getRelativeName();
      synchronized (this.replSlaveMap) {
         slave = (I_ReplSlave)this.replSlaveMap.get(relativeName);
      }
      if (slave == null) {
         log.severe("could not find a slave for replication client '" + relativeName + "'");
      }
      else
         slave.handleException(ex);
   }
View Full Code Here

TOP

Related Classes of org.xmlBlaster.contrib.replication.I_ReplSlave

Copyright © 2018 www.massapicom. 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.