Package org.xmlBlaster.util.checkpoint

Examples of org.xmlBlaster.util.checkpoint.I_Checkpoint


      MsgUnit msgUnit = null;
      try {
         msgUnit = importAndAuthorize(sessionInfo, addressServer, msgUnitRaw, MethodName.PUBLISH);
        
         I_Checkpoint cp = glob.getCheckpointPlugin();
         if (cp != null) {
               cp.passingBy(I_Checkpoint.CP_PUBLISH_ENTER, msgUnit,
                     null, null);
         }

         String ret = requestBroker.publish(sessionInfo, msgUnit);
View Full Code Here


         MsgQueueUpdateEntry entry = createEntryFromWrapper(msgUnitWrapper, sub);

         sub.getMsgQueue().put(entry, I_Queue.USE_PUT_INTERCEPTOR);

         I_Checkpoint cp = serverScope.getCheckpointPlugin();
         if (cp != null) {
               cp.passingBy(I_Checkpoint.CP_UPDATE_QUEUE_ADD, entry.getMsgUnit(),
                     sub.getSessionInfo().getSessionName(), null);
         }

         // If in MsgQueueUpdateEntry we set super.wantReturnObj = true; (see ReferenceEntry.java):
         //UpdateReturnQosServer retQos = (UpdateReturnQosServer)entry.getReturnObj();
View Full Code Here

      this.checkPointContext = new String[] {"sessionName", qr.getSessionName().getAbsoluteName()};
   }

   private void publish(MsgQueueEntry[] msgArr_) throws XmlBlasterException {
     
      I_Checkpoint cp = glob.getCheckpointPlugin();

      // Convert to PublishEntry
      MsgUnit[] msgArr = new MsgUnit[msgArr_.length];
      for (int i=0; i<msgArr.length; i++) {
         MsgQueuePublishEntry publishEntry = (MsgQueuePublishEntry)msgArr_[i];
         msgArr[i] = publishEntry.getMsgUnit();
      }

      MsgUnitRaw[] msgUnitRawArr = new MsgUnitRaw[msgArr.length];
      // We export/encrypt the message (call the interceptor)
      if (securityInterceptor != null) {
         for (int i=0; i<msgArr.length; i++) {
            CryptDataHolder dataHolder = new CryptDataHolder(MethodName.PUBLISH, msgArr[i].getMsgUnitRaw());
            msgUnitRawArr[i] = securityInterceptor.exportMessage(dataHolder);
         }
         if (log.isLoggable(Level.FINE)) log.fine("Exported/encrypted " + msgArr.length + " publish messages.");
      }
      else {
         log.warning("No session security context, sending " + msgArr.length + " publish messages without encryption");
         for (int i=0; i<msgArr.length; i++) {
            msgUnitRawArr[i] = msgArr[i].getMsgUnitRaw();
         }
      }

      if (MethodName.PUBLISH_ONEWAY == msgArr_[0].getMethodName()) {
         this.driver.publishOneway(msgUnitRawArr);
         connectionsHandler.getDispatchStatistic().incrNumPublish(msgUnitRawArr.length);
         if (log.isLoggable(Level.FINE)) log.fine("Success, sent " + msgArr.length + " oneway publish messages.");
         if (cp != null) {
            for (int i=0; i<msgArr.length; i++) {
               cp.passingBy(I_Checkpoint.CP_CONNECTION_PUBLISH_ACK, msgArr[i],
                     null, this.checkPointContext);
            }
         }
         return;
      }

      if (log.isLoggable(Level.FINE)) log.fine("Before publish " + msgArr.length + " acknowledged messages ...");

      String[] rawReturnVal = this.driver.publishArr(msgUnitRawArr);
      if (rawReturnVal == null) {
         String text = "driver.publishArr len= " + msgUnitRawArr.length + " returned null: " + ((msgUnitRawArr.length>0)?msgUnitRawArr[0].getKey():"");
         throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME, text);
      }
      connectionsHandler.getDispatchStatistic().incrNumPublish(rawReturnVal.length);

      if (log.isLoggable(Level.FINE)) log.fine("Success, sent " + msgArr.length + " acknowledged publish messages, return value #1 is '" + rawReturnVal[0] + "'");

      if (rawReturnVal != null) {
         for (int i=0; i<rawReturnVal.length; i++) {
            if (cp != null) {
               MsgQueuePublishEntry publishEntry = (MsgQueuePublishEntry)msgArr_[i];
               cp.passingBy(I_Checkpoint.CP_CONNECTION_PUBLISH_ACK, publishEntry.getMsgUnit(),
                        null, this.checkPointContext);
            }
           
            if (!msgArr_[i].wantReturnObj())
               continue;
View Full Code Here

            raws[i] = ((Holder)oneways.get(i)).msgUnitRaw;
         }
         cbDriver.sendUpdateOneway(raws);
         connectionsHandler.getDispatchStatistic().incrNumUpdate(oneways.size());
         if (log.isLoggable(Level.FINE)) log.fine(ME+": Success, sent " + oneways.size() + " oneway messages.");
         I_Checkpoint cp = glob.getCheckpointPlugin();
         if (cp != null) {
            for (int i=0; i<oneways.size(); i++) {
               Holder h = (Holder)oneways.get(i);
               cp.passingBy(I_Checkpoint.CP_UPDATE_ACK, (MsgUnit)h.msgUnitRaw.getMsgUnit(),
                     sessionName, null);
            }
         }
      }

      if (responders != null) {
         if (log.isLoggable(Level.FINE)) log.fine(ME+": Before update " + responders.size() + " acknowledged messages ...");
         MsgUnitRaw[] raws = new MsgUnitRaw[responders.size()];
         for (int i=0; i<responders.size(); i++) {
            raws[i] = ((Holder)responders.get(i)).msgUnitRaw;
         }
         String[] rawReturnVal = null;
         try {
            rawReturnVal = cbDriver.sendUpdate(raws);
         }
         catch (Throwable t) {
            // http://www.xmlblaster.org/xmlBlaster/doc/requirements/interface.update.html#exception
            XmlBlasterException ex = (t instanceof XmlBlasterException) ? (XmlBlasterException)t :
               new XmlBlasterException(glob, ErrorCode.USER_UPDATE_INTERNALERROR, ME, "Callback failed", t);
            if (!ex.isServerSide()) { // Transform remote exceptions must be of type user.* or communication.*
               if (!ex.isUser() && !ex.isCommunication())
                  ex = new XmlBlasterException(glob, ErrorCode.USER_UPDATE_INTERNALERROR, ME, "Callback failed", ex);
            }
            throw ex;
         }
         connectionsHandler.getDispatchStatistic().incrNumUpdate(raws.length);
         if (log.isLoggable(Level.FINE)) log.fine(ME+": Success, sent " + raws.length + " acknowledged messages, return value #1 is '" + rawReturnVal[0] + "'");

         I_Checkpoint cp = glob.getCheckpointPlugin();
         if (cp != null) {
            for (int i=0; i<raws.length; i++) {
               cp.passingBy(I_Checkpoint.CP_UPDATE_ACK, (MsgUnit)raws[i].getMsgUnit(),
                     sessionName, null);
            }
         }

         // this is done since the client could send one single bulk acknowledge
View Full Code Here

   /**
    * Put the given message entry into the queue
    */
   private Object queueMessage(MsgQueueEntry entry) throws XmlBlasterException {
      try {
         final I_Checkpoint cp = glob.getCheckpointPlugin();
         if (cp != null) {
            cp.passingBy(I_Checkpoint.CP_CONNECTION_PUBLISH_ENTER, entry.getMsgUnit(), null, this.checkPointContext);
         }
         this.clientQueue.put(entry, I_Queue.USE_PUT_INTERCEPTOR);
         if (log.isLoggable(Level.FINE)) log.fine(getLogId()+"Forwarded one '" + entry.getEmbeddedType() + "' message, current state is " + getState().toString());
         return entry.getReturnObj();
      }
View Full Code Here

            this.transientWarn = true;
         }
      }
      sessionQueue.put(entry, I_Queue.USE_PUT_INTERCEPTOR);

      I_Checkpoint cp = glob.getCheckpointPlugin();
      if (cp != null) {
         cp.passingBy(I_Checkpoint.CP_UPDATE_QUEUE_ADD, entry.getMsgUnit(),
                  this.getSessionName(), null);
      }
   }
View Full Code Here

                              // TODO: cluster forwarding with multiple destinations:
                              String txt = "Messages with more than one destinations in a cluster environment is not implemented, only destination '" + destinationArr[ii].toXml() + "' of '" + msgUnit.getLogId() + "' was delivered";
                              log.warning(txt);
                              throw new XmlBlasterException(glob, ErrorCode.INTERNAL_NOTIMPLEMENTED, ME, txt);
                           }
                           I_Checkpoint cp = glob.getCheckpointPlugin();
                           if (cp != null)
                              cp.passingBy(I_Checkpoint.CP_PUBLISH_ACK, msgUnit, null, null);
                           return publishReturnQos.toXml();
                        }
                        /*
                        if (publishReturnQos != null) {
                           // Message was forwarded. TODO: How to return multiple publishReturnQos from multiple destinations? !!!
                           BUGGY: We need to take a clone to not remove the destination of the sent message
                           publishQos.removeDestination(destinationArr[ii]);
                        }
                        */
                     }
                     /*
                     if (publishQos.getNumDestinations() == 0) { // we are done, all messages where forwarded
                        return publishReturnQos.toXml();
                     }
                     */
                  }
                  // Publish/Subscribe mode (or if PtP had no result)
                  else { // if (publishQos.isSubscribable()) {
                     try {
                        PublishRetQosWrapper ret = glob.getClusterManager().forwardPublish(sessionInfo, msgUnit);
                        //Thread.currentThread().dumpStack();
                        if (ret != null) { // Message was forwarded to master cluster
                            I_Checkpoint cp = glob.getCheckpointPlugin();
                            if (cp != null)
                               cp.passingBy(I_Checkpoint.CP_PUBLISH_ACK, msgUnit, null, null);
                           publishReturnQos = ret.getPublishReturnQos();
                           if (ret.getNodeMasterInfo().isDirtyRead() == false) {
                              if (log.isLoggable(Level.FINE)) log.fine("Message " + msgKeyData.getOid() + " forwarded to master " + ret.getNodeMasterInfo().getId() + ", dirtyRead==false nothing more to do");
                              return publishReturnQos.toXml();
                           }
                           // else we publish it locally as well (dirty read!)
                        }
                     }
                     catch (XmlBlasterException e) {
                        if (e.getErrorCode() == ErrorCode.RESOURCE_CONFIGURATION_PLUGINFAILED) {
                           this.glob.setUseCluster(false);
                        }
                        else {
                           e.printStackTrace();
                           throw e;
                        }
                     }
                  }
               }
               else {
                  if (! publishQos.isFromPersistenceStore()) {
                     if (msgKeyData.isInternal()) {
                        if (log.isLoggable(Level.FINE)) log.fine("Cluster manager is not ready, handling message '" + msgKeyData.getOid() + "' locally");
                     }
                     else {
                        log.warning("Cluster manager is not ready, handling message '" + msgKeyData.getOid() + "' locally");
                     }
                  }
               }
            }
         }

         // Handle local message

         if (!msgKeyData.getOid().equals(msgUnit.getKeyOid())) {
            Thread.dumpStack();
            log.severe("Unexpected change of keyOid " + msgKeyData.getOid() + " and msgUnit " + msgUnit.toXml());
         }

         /*
         // Find or create the topic
         TopicHandler topicHandler = null;
         synchronized(this.topicHandlerMap) {
            if (!msgKeyData.getOid().equals(msgUnit.getKeyOid())) {
               Thread.dumpStack();
               log.severe("Unexpected change of keyOid " + msgKeyData.getOid() + " and msgUnit " + msgUnit.toXml());
            }
            Object obj = topicHandlerMap.get(msgUnit.getKeyOid());
            if (obj == null) {
               topicHandler = new TopicHandler(this, sessionInfo, msgUnit.getKeyOid()); // adds itself to topicHandlerMap
            }
            else {
               topicHandler = (TopicHandler)obj;
            }
         }
         */

         TopicHandler topicHandler = null;
         try {
            topicHandler = this.glob.getTopicAccessor().findOrCreate(sessionInfo, msgUnit.getKeyOid());
            // Process the message
            publishReturnQos = topicHandler.publish(sessionInfo, msgUnit, publishQos);
         }
         finally {
            this.glob.getTopicAccessor().release(topicHandler);
         }

         if (publishReturnQos == null) {  // assert only
            StatusQosData qos = new StatusQosData(glob, MethodName.PUBLISH);
            qos.setKeyOid(msgKeyData.getOid());
            qos.setState(Constants.STATE_OK);
            publishReturnQos = new PublishReturnQos(glob, qos);
            publishReturnQos.getData().setRcvTimestamp(publishQos.getRcvTimestamp());
            log.severe("Internal: did not excpect to build a PublishReturnQos, but message '" + msgKeyData.getOid() + "' is processed correctly");
            Thread.dumpStack();
         }

         if (!publishQos.isFromPersistenceStore()) {
            I_Checkpoint cp = glob.getCheckpointPlugin();
            if (cp != null)
               cp.passingBy(I_Checkpoint.CP_PUBLISH_ACK, msgUnit, null, null);
         }

         return publishReturnQos.toXml(); // Use the return value of the cluster master node
      }
      catch (XmlBlasterException e) {
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.checkpoint.I_Checkpoint

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.