Package org.xmlBlaster.util.qos

Examples of org.xmlBlaster.util.qos.StatusQosData


      if (log.isLoggable(Level.FINE)) log.fine(ME+": publish() publisherSessionInfo '" + publisherSessionInfo.getId() + "', message '" + msgUnit.getLogId() + "' ...");

      PublishReturnQos publishReturnQos = null;
      MsgQosData msgQosData = null;

      StatusQosData qos = new StatusQosData(serverScope, MethodName.PUBLISH);
      qos.setKeyOid(this.uniqueKey);
      qos.setState(Constants.STATE_OK);
      qos.setRcvTimestamp(publishQosServer.getRcvTimestamp());
      publishReturnQos = new PublishReturnQos(serverScope, qos);

      MsgKeyData msgKeyData = (MsgKeyData)msgUnit.getKeyData();
      msgQosData = (MsgQosData)msgUnit.getQosData();
      /* Happens in RequestBroker already
View Full Code Here


   /**
    * Constructor which allows you to set the return state.
    * @param state The state to return to the server. See Constants.java
    */
   public UpdateReturnQos(Global glob, String state) {
      this.statusQosData = new StatusQosData(glob, MethodName.UPDATE);
      this.statusQosData.setState(state);
   }
View Full Code Here

      for (int ii=0; ii<entries.length; ii++) {
         MsgQueueEntry msgQueueEntry = (MsgQueueEntry)entries[ii];
         if (!msgQueueEntry.wantReturnObj())
            continue;
         StatusQosData statRetQos = new StatusQosData(glob, MethodName.UNKNOWN);
         statRetQos.setStateInfo(stateInfo);
         statRetQos.setState(state);
         if (log.isLoggable(Level.FINE)) log.fine("Creating faked return for '" + msgQueueEntry.getMethodName() + "' invocation");

         if (MethodName.PUBLISH_ONEWAY == msgQueueEntry.getMethodName()) {
            MsgQueuePublishEntry entry = (MsgQueuePublishEntry)msgQueueEntry;
            entry.setReturnObj(null);
         }

         else if (MethodName.PUBLISH == msgQueueEntry.getMethodName()) {
            MsgQueuePublishEntry entry = (MsgQueuePublishEntry)msgQueueEntry;
            if (!entry.getMsgKeyData().hasOid()) {
               entry.getMsgKeyData().setOid(entry.getMsgKeyData().generateOid(entry.getSender().getRelativeName()));
            }
            statRetQos.setKeyOid(entry.getKeyOid());
            PublishReturnQos publishReturnQos = new PublishReturnQos(glob, statRetQos);
            //TODO: How to fake the RcvTimestamp -> it must be unique for an OID in the server
            //publishReturnQos.getData().setRcvTimestamp(new org.xmlBlaster.util.RcvTimestamp());
            entry.setReturnObj(publishReturnQos);
         }

         else if (MethodName.SUBSCRIBE == msgQueueEntry.getMethodName()) {
            if (getDispatchManager().getSessionName().getPublicSessionId() < 1) {
               // we should never allow a subscription without a positive sessionId if the
               // server is not accessible
               throw new XmlBlasterException(glob, ErrorCode.RESOURCE_TEMPORARY_UNAVAILABLE, ME,
                     "The Subscription for '" + getDispatchManager().getSessionName().toString() + "' failed since the server is currently not available");
            }
           
            MsgQueueSubscribeEntry entry = (MsgQueueSubscribeEntry)msgQueueEntry;
            if (!entry.getSubscribeQosData().hasSubscriptionId()) {
               entry.getSubscribeQosData().generateSubscriptionId(glob.getXmlBlasterAccess().getSessionName(), entry.getSubscribeKeyData());
               //String subscriptionId = QueryKeyData.generateSubscriptionId(dispatchManager.getQueue().getStorageId().getPostfix());
               //entry.getSubscribeQosData().setSubscriptionId(subscriptionId);
            }
            statRetQos.setSubscriptionId(entry.getSubscribeQosData().getSubscriptionId());
            SubscribeReturnQos subscribeReturnQos = new SubscribeReturnQos(glob, statRetQos, true);
            entry.setReturnObj(subscribeReturnQos);
         }

         else if (MethodName.UNSUBSCRIBE == msgQueueEntry.getMethodName()) {
            MsgQueueUnSubscribeEntry entry = (MsgQueueUnSubscribeEntry)msgQueueEntry;
            String id = entry.getUnSubscribeKey().getOid();
            if (id != null && id.startsWith(Constants.SUBSCRIPTIONID_PREFIX)) {
               statRetQos.setSubscriptionId(id);
               UnSubscribeReturnQos[] unSubscribeReturnQosArr = new UnSubscribeReturnQos[] { new UnSubscribeReturnQos(glob, statRetQos) };
               entry.setReturnObj(unSubscribeReturnQosArr);
            }
            else {
               throw new XmlBlasterException(glob, ErrorCode.USER_CONFIGURATION, ME,
                  "UnSubscribe on oid='" + id + "' is not possible in offline/polling mode without an exact subscription ID given. " +
                  "See 'http://www.xmlBlaster.org/xmlBlaster/doc/requirements/client.failsafe.html' for more details.");
            }
         }

         else if (MethodName.ERASE == msgQueueEntry.getMethodName()) {
            MsgQueueEraseEntry entry = (MsgQueueEraseEntry)msgQueueEntry;
            if (entry.getEraseKey().isExact()) {
               statRetQos.setKeyOid(entry.getEraseKey().getOid());
               EraseReturnQos[] eraseReturnQosArr = new EraseReturnQos[] { new EraseReturnQos(glob, statRetQos) };
               entry.setReturnObj(eraseReturnQosArr);
            }
            else {
               throw new XmlBlasterException(glob, ErrorCode.USER_CONFIGURATION, ME,
View Full Code Here

            "   <state id='ERASED' info='QUEUED[bilbo]'/>\n" +
            "   <key oid='yourMessageOid'/>\n" +
            "   <subscribe id='_subId:1'/>\n" +
            "</qos>\n";

         StatusQosData qos = factory.readObject(xml);

         assertEquals("", Constants.STATE_ERASED, qos.getState());
         assertEquals("", false, qos.isOk());
         assertEquals("", true, qos.isErased());
         assertEquals("", false, qos.isTimeout());
         assertEquals("", false, qos.isForwardError());
         assertEquals("", "QUEUED[bilbo]", qos.getStateInfo());
         assertEquals("", "yourMessageOid", qos.getKeyOid());
         assertEquals("", "_subId:1", qos.getSubscriptionId());
      }
      catch (XmlBlasterException e) {
         fail("testParse failed: " + e.toString());
      }
View Full Code Here

            "   <state id='ERASED' info='QUEUED[bilbo]'/>\n" +
            "   <key oid='yourMessageOid'/>\n" +
            "   <subscribe id='_subId:1'/>\n" +
            "</qos>\n";

         StatusQosData qos = factory.readObject(xml);
         String newXml = qos.toXml();
         log.info("New XML=" + newXml);
         qos = factory.readObject(newXml);

         assertEquals("", Constants.STATE_ERASED, qos.getState());
         assertEquals("", false, qos.isOk());
         assertEquals("", true, qos.isErased());
         assertEquals("", false, qos.isTimeout());
         assertEquals("", false, qos.isForwardError());
         assertEquals("", "QUEUED[bilbo]", qos.getStateInfo());
         assertEquals("", "yourMessageOid", qos.getKeyOid());
         assertEquals("", "_subId:1", qos.getSubscriptionId());
      }
      catch (XmlBlasterException e) {
         fail("testToXml failed: " + e.toString());
      }
View Full Code Here

    */
   public void testDefault() {
      System.out.println("***StatusQosFactoryTest: testDefault ...");
     
      try {
         StatusQosData qos = factory.readObject((String)null);

         assertEquals("", Constants.STATE_OK, qos.getState());
         assertEquals("", true, qos.isOk());
         assertEquals("", false, qos.isErased());
         assertEquals("", false, qos.isTimeout());
         assertEquals("", false, qos.isForwardError());
         assertEquals("", null, qos.getStateInfo());
         assertEquals("", null, qos.getKeyOid());
         assertEquals("", null, qos.getSubscriptionId());
      }
      catch (XmlBlasterException e) {
         fail("testDefault failed: " + e.toString());
      }

View Full Code Here

         for (int j=0; j<5; j++) {
            int num = 1000;
            long start = System.currentTimeMillis();
            for (int i=0; i<num; i++) {
               StatusQosData qos = factory.readObject(xml);
            }
            long elapsed = System.currentTimeMillis() - start;
            log.info(num + " parses for " + factory.getName() + ": " + elapsed + " millisec -> " +
                     ((((double)elapsed)*1000.*1000.)/((double)num)) + " nanosec/parse");
         }
View Full Code Here

   public void createFakedReturnObjects(I_QueueEntry[] entries, String state, String stateInfo) {
      for (int ii=0; ii<entries.length; ii++) {
         MsgQueueEntry msgQueueEntry = (MsgQueueEntry)entries[ii];
         if (!msgQueueEntry.wantReturnObj())
            continue;
         StatusQosData statRetQos = new StatusQosData(glob, MethodName.UPDATE);
         statRetQos.setStateInfo(stateInfo);
         statRetQos.setState(state);
         // TODO check this: it is probably wrong since here comes UPDATE_REF and not UPDATE (Michele 2003-11-05)
         // if (MethodName.UPDATE == msgQueueEntry.getMethodName()) {
         // if ( MethodName.UPDATE.getMethodName().equalsIgnoreCase(msgQueueEntry.getEmbeddedType())) {
         // !!! HACK !!!
         // "update_ref"
View Full Code Here

         String returnVal = doPing(data);
         this.connectionsHandler.getDispatchStatistic().setPingRoundTripDelay(System.currentTimeMillis() - now);
         // Ignore "" returns as this was specified to always return in older xmlBlaster versions
         if (returnVal.length() > 0 && returnVal.indexOf("OK") == -1) {
            // Fake a server standby exception: ping() is not specified to transport a remote XmlBlasterException but carries standby information in the state id.
            StatusQosData qos = glob.getStatusQosFactory().readObject(returnVal);
            if (!Constants.STATE_OK.equals(qos.getState())) {
               throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION_SERVERDENY,
                           glob.getId(), ME, (String)null,
                           "Ping result: The server is in run level " + qos.getState() + " and not ready for requests",
                           (String)null, (Timestamp)null,
                           (String)null, (String)null, (String)null,
                           true)/* We need to set serverSide==true ! */
            }
         }
View Full Code Here

                  sub.update(subscribeQos);
               }
               log.info("Ignoring duplicate subscription '" +
                       ((xmlKey.getOid()==null)?((xmlKey.getDomain()==null)?xmlKey.getQueryString():xmlKey.getDomain()):xmlKey.getOid()) +
                        "' as you have set multiSubscribe to false");
               StatusQosData qos = new StatusQosData(glob, MethodName.SUBSCRIBE);
               SubscriptionInfo i = (SubscriptionInfo)vec.elementAt(0);
               qos.setState(Constants.STATE_WARN);
               qos.setSubscriptionId(i.getSubscriptionId());
               return qos.toXml();
            }
         }

         SubscriptionInfo subsQuery = null;
         if (xmlKey.isQuery()) { // fires event for query subscription, this needs to be remembered for a match check of future published messages
         // if (true) { // fires event for query subscription, this needs to be remembered for a match check of future published messages
            subsQuery = new SubscriptionInfo(glob, sessionInfo, xmlKey, subscribeQos);
            returnOid = subsQuery.getSubscriptionId(); // XPath query
            fireSubscribeEvent(subsQuery);
         }

         KeyData[] keyDataArr = queryMatchingKeys(sessionInfo, xmlKey, subscribeQos.getData());

         for (int jj=0; jj<keyDataArr.length; jj++) {
            KeyData xmlKeyExact = keyDataArr[jj];
            if (xmlKeyExact == null && xmlKey.isExact()) // subscription on a yet unknown topic ...
               xmlKeyExact = xmlKey;
            else if (xmlKeyExact != null && xmlKey.isDomain()) {
               xmlKeyExact.setQueryType(xmlKey.getQueryType());
            }
            SubscriptionInfo subs = null;
            if (sessionInfo.getConnectQos().duplicateUpdates() == false) {
               Vector vec =  clientSubscriptions.getSubscriptionByOid(sessionInfo, xmlKeyExact.getOid(), true);
               if (vec != null) {
                  if (vec.size() > 0) {
                     subs = (SubscriptionInfo)vec.firstElement();
                     if (log.isLoggable(Level.FINE)) log.fine("Session '" + sessionInfo.getId() +
                                    "', topic '" + xmlKeyExact.getOid() + "' is subscribed " +
                                    vec.size() + " times with duplicateUpdates==false");
                  }
                  if (vec.size() > 1)
                     log.severe("Internal problem for session '" + sessionInfo.getId() + "', message '" + xmlKeyExact.getOid() + "' is subscribed " + vec.size() + " times but duplicateUpdates==false!");
               }
            }

            if (subs == null) {
               if (subsQuery != null) {
                  subs = new SubscriptionInfo(glob, sessionInfo, subsQuery, xmlKeyExact);
                  subsQuery.addSubscription(subs);
               }
               else
                  subs = new SubscriptionInfo(glob, sessionInfo, xmlKeyExact, subscribeQos);
            }

            subscribeToOid(subs, false); // fires event for subscription

            if (returnOid.equals("")) returnOid = subs.getSubscriptionId();
         }

         StatusQosData qos = null;
         if (this.glob.isClusterManagerReady()) { // cluster support - forward message to master
            try {
               subscribeQos.setSubscriptionId(returnOid); // force the same subscriptionId on all cluster nodes
               SubscribeReturnQos ret = glob.getClusterManager().forwardSubscribe(sessionInfo, xmlKey, subscribeQos);
               if (ret != null)
                  qos = ret.getData();
               //Thread.currentThread().dumpStack();
               //if (ret != null) return ret.toXml();
            }
            catch (XmlBlasterException e) {
               if (e.getErrorCode() == ErrorCode.RESOURCE_CONFIGURATION_PLUGINFAILED) {
                  this.glob.setUseCluster(false);
               }
               else {
                  e.printStackTrace();
                  throw e;
               }
            }
         }

         if (qos == null || qos.getSubscriptionId() == null ||  qos.getSubscriptionId().length() < 1) {
            // The cluster subId is unique in another cluster node as well e.g.: "__subId:heron-2"
            if (qos == null) qos = new StatusQosData(glob, MethodName.SUBSCRIBE);
            qos.setSubscriptionId(returnOid);
         }
         if (log.isLoggable(Level.FINER)) log.finer("Leaving subscribe(oid='" + xmlKey.getOid() + "', queryType='" + xmlKey.getQueryType() +
                                          "', query='" + xmlKey.getQueryString() + "', domain='" + xmlKey.getDomain() + "') from client '" +
                                          sessionInfo.getId() + "' -> subscriptionId='" + qos.getSubscriptionId() + "'");
         return qos.toXml();
      }
      catch (XmlBlasterException e) {
         log.warning(e.getMessage());
         throw e;
      }
View Full Code Here

TOP

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

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.