Package org.xmlBlaster.util.qos

Examples of org.xmlBlaster.util.qos.ClientProperty


   /**
    * This is invoked for dump files
    */
   private void updateDump(String topic, InputStream is, Map attrMap) throws Exception {
      clearSqlInfoCache();
      ClientProperty prop = (ClientProperty)attrMap.get(FILENAME_ATTR);
      String filename = null;
      if (prop == null) {
         log.warning("The property '" + FILENAME_ATTR + "' has not been found. Will choose an own temporary one");
         filename = "tmpFilename.dmp";
      }
      else
         filename = prop.getStringValue();
      log.info("'" + topic + "' dumping file '" + filename + "' on '" + this.importLocation + "'");
      // will now write to the file system
      this.callback.update(topic, is, attrMap);
      // and now perform an import of the DB
      boolean isEof = true;
      boolean isException = false;
      int seqNumber = -1;
      String exTxt = "";
      prop = XBMessage.get(XBConnectionMetaData.JMSX_GROUP_SEQ, attrMap);
      if (prop != null) {
         seqNumber = prop.getIntValue();
         prop = XBMessage.get(XBConnectionMetaData.JMSX_GROUP_EOF, attrMap);
         if (prop == null) {
            isEof = false;
         }
         else {
            prop = XBMessage.get(XBConnectionMetaData.JMSX_GROUP_EX, attrMap);
            if (prop != null) {
               exTxt = prop.getStringValue();
               isException = true;
            }
         }
      }
      log.info("'" + topic + "' dumped file '" + filename + "' on '" + this.importLocation + "' seq nr. '" + seqNumber + "' ex='" + exTxt + "'");
View Full Code Here


        
      }
   }

   private void updateManualTransfer(String topic, InputStream is, Map attrMap) throws Exception {
      ClientProperty subDirProp = (ClientProperty)attrMap.get(ReplicationConstants.INITIAL_DATA_ID);
      if (subDirProp == null)
         throw new Exception("updateManualTransfer: the mandatory property '" + ReplicationConstants.INITIAL_DATA_ID + "' was not found in the message");
      String subDirName = subDirProp.getStringValue();
      if (subDirName == null || subDirName.trim().length() < 1)
         throw new Exception("updateManualTransfer: the mandatory property '" + ReplicationConstants.INITIAL_DATA_ID + "' was empty");
     
      String initialFilesLocation = this.info.get("replication.initialFilesLocation", "${user.home}/tmp");
      XmlScriptParser xmlScriptParser = new XmlScriptParser();
View Full Code Here

      if (this.nirvanaClient) {
         log.warning("The content of the data for this writer ' is sent to nirvana since 'replication.nirvanaClient' is set to 'true'");
         return;
      }
     
      ClientProperty dumpProp = (ClientProperty)attrMap.get(ReplicationConstants.DUMP_ACTION);
      ClientProperty endToRemoteProp = (ClientProperty)attrMap.get(ReplicationConstants.INITIAL_DATA_END_TO_REMOTE);
      ClientProperty endOfTransition = (ClientProperty)attrMap.get(ReplicationConstants.END_OF_TRANSITION);

      if (endOfTransition != null && endOfTransition.getBooleanValue()) {
         deleteFiles(attrMap);
      }
      else if (dumpProp != null)
         updateDump(topic, is, attrMap);
      else if (endToRemoteProp != null)
View Full Code Here

    * @param txt
    * @return
    */
   public String getRaw(String key) {
      try {
         ClientProperty prop = this.storage.getProperty(key);
         if (prop == null)
            return null;
         return prop.getStringValue();
      }
      catch (Exception ex) {
         log.warning("An exception occured when retrieving the entry '" + key + "': " + ex.getMessage());
         return null;
      }
View Full Code Here

    * @param txt
    * @return
    */
   protected String getPropAsString(String key) {
      try {
         ClientProperty prop = this.storage.getProperty(key);
         if (prop == null)
            return null;
         String ret = prop.getStringValue();
         if (ret != null) {
            return this.helper.replace(ret);
         }
         return null;
      }
View Full Code Here

          value = this.helper.replace(value);
       try {
          if (value == null)
             this.storage.remove(key);
           else {
              ClientProperty prop = new ClientProperty(key, null, null, value);
              this.storage.put(prop);
           }
       }
       catch (Exception ex) {
          log.warning("An exception occured when putting the entry '" + key + "': " + ex.getMessage());
View Full Code Here

     public synchronized void putRaw(String key, String value) {
        try {
           if (value == null)
              this.storage.remove(key);
            else {
               ClientProperty prop = new ClientProperty(key, null, null, value);
               this.storage.put(prop);
            }
        }
        catch (Exception ex) {
           log.warning("An exception occured when putting the raw the entry '" + key + "': " + ex.getMessage());
View Full Code Here

      }

      SubscribeQos subscribeQos2 = new SubscribeQos(this.glob, subscribeQos.getData());
      // The cluster master needs to accept our "__subId:heron-3456646466"
     
      ClientProperty clientProperty = subscribeQos2.getClientProperty(Constants.PERSISTENCE_ID);
      if (clientProperty != null) {
         // remove marker that this is from persistent store, the other node would react wrong
         subscribeQos2 = new SubscribeQos(this.glob, (QueryQosData)subscribeQos.getData().clone());
         subscribeQos2.getData().getClientProperties().remove(Constants.PERSISTENCE_ID);
      }
View Full Code Here

        
         // check if already processed ... and at the same time do the versioning transformation (if needed)
         for (int i=entries.size()-1; i > -1; i--) {
            ReferenceEntry entry = (ReferenceEntry)entries.get(i);
            MsgUnit msgUnit = entry.getMsgUnit();
            ClientProperty alreadyProcessed = msgUnit.getQosData().getClientProperty(ReplicationConstants.ALREADY_PROCESSED_ATTR);
            if (alreadyProcessed != null) {
               log.warning("Received entry for client '" + this.slaveSessionId + "' which was already processed. Will remove it");
               queue.removeRandom(entry);
               entries.remove(i);
            }
            else
               doTransform(msgUnit);
         }
        
         // check if one of the messages is the transition end tag, also check if the total size is exceeded
         ArrayList remoteEntries = new ArrayList();
         long totalSize = 0L;
         for (int i=0; i < entries.size(); i++) {
            ReferenceEntry entry = (ReferenceEntry)entries.get(i);
            MsgUnit msgUnit = entry.getMsgUnit();
            ClientProperty endMsg = msgUnit.getQosData().getClientProperty(ReplicationConstants.END_OF_TRANSITION);
           
            // check if the message is the end of the data (only sent in case the initial data has to be stored on
            // file in which case the dispatcher shall return in its waiting state.
            ClientProperty endOfData = msgUnit.getQosData().getClientProperty(ReplicationConstants.INITIAL_DATA_END);
            ClientProperty initialFilesLocation = msgUnit.getQosData().getClientProperty(ReplicationConstants.INITIAL_FILES_LOCATION);
            ClientProperty subDirName = msgUnit.getQosData().getClientProperty(ReplicationConstants.INITIAL_DATA_ID);
            if (endOfData != null) {
               final boolean doPersist = true;
               doPause(doPersist);
               queue.removeRandom(entry);
               // entries.remove(i); // endOfData will be kept locally, not sent to slave
               String dirName = "unknown";
               if (subDirName != null) {
                  if (initialFilesLocation != null) {
                     File base = new File(initialFilesLocation.getStringValue().trim());
                     File complete = new File(base, subDirName.getStringValue().trim());
                     dirName = complete.getAbsolutePath();
                  }
               }
               changeLastMessage("Manual Data transfer: WAITING (stored on '" + dirName + "')");
               break; // we need to interrupt here: all subsequent entries will be processed later.
            }

            // check if the message has to be stored locally
            ClientProperty endToRemote = msgUnit.getQosData().getClientProperty(ReplicationConstants.INITIAL_DATA_END_TO_REMOTE);
            if (initialFilesLocation != null && (endToRemote == null || !endToRemote.getBooleanValue()) && (endMsg == null || !endMsg.getBooleanValue())) {
               storeChunkLocally(entry, initialFilesLocation, subDirName);
               queue.removeRandom(entry);
               // entries.remove(i);
               continue;
            }
           
            if (endMsg != null) {
               log.info("Received msg marking the end of the initial for client '" + this.slaveSessionId + "' update: '" + this.name + "' going into NORMAL operations");
               startCascadedAndChangeStatus();
            }
            byte[] content = msgUnit.getContent();
            if (content != null)
               totalSize += content.length;
            if (totalSize <= this.maxChunkSize || i == 0)
               remoteEntries.add(entry);
            else
               break;
         }
         entries = null; // we can free it here since not needed anymore
        
         if (this.status == STATUS_NORMAL || this.status == STATUS_INCONSISTENT || this.status == STATUS_UNCONFIGURED)
            return remoteEntries;
        
         ArrayList ret = new ArrayList();
         for (int i=0; i < remoteEntries.size(); i++) {
            ReferenceEntry entry = (ReferenceEntry)remoteEntries.get(i);
            MsgUnit msgUnit = entry.getMsgUnit();
            long replKey = msgUnit.getQosData().getClientProperty(ReplicationConstants.REPL_KEY_ATTR, -1L);
            /* this is done when acknowledge comes
            if (replKey > -1L) {
               setMaxReplKey(replKey, this.tmpTransSeq, this.tmpMsgSeq);
            }
            */
            log.info("check: processing '" + replKey + "' for client '" + this.slaveSessionId + "' ");
            if (replKey < 0L) { // this does not come from the normal replication, so these are other messages which we just deliver
               ClientProperty endMsg = msgUnit.getQosData().getClientProperty(ReplicationConstants.END_OF_TRANSITION);
               if (endMsg == null) {
                  log.warning("the message unit with qos='" + msgUnit.getQosData().toXml() + "' and key '" + msgUnit.getKey() + "'  for client '" + this.slaveSessionId + "' has no 'replKey' Attribute defined.");
                  ret.add(entry);
                  continue;
               }
View Full Code Here

      if (clientProperties == null)
         return "";
      Iterator iter = clientProperties.values().iterator();
      StringBuffer buf = new StringBuffer(512);
      while (iter.hasNext()) {
         ClientProperty prop = (ClientProperty)iter.next();
         buf.append(prop.toXml()).append("\n");
      }
      return buf.toString();
   }
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.qos.ClientProperty

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.