Package org.xmlBlaster.util

Examples of org.xmlBlaster.util.SessionName


      for (int ii = 0; ii < destinationArr.length; ii++) {
         Destination destination = destinationArr[ii];

         if (log.isLoggable(Level.FINE)) log.fine(ME+": Working on PtP message for destination [" + destination.getDestination() + "]");

         SessionName destinationSessionName = destination.getDestination();
         boolean destinationIsSession = destinationSessionName.isSession();
         boolean forceQueing = destination.forceQueuing();
         boolean wantsPtP = true; // TODO if destination never has logged in spam would be possible!

         SubjectInfo destinationClient = null;

         // Handle PtP to subject in a thread safe manner
         if (!destinationIsSession) { // -> subject
            // 3 + 6 (force queing ignored since same reaction for both)
            destinationClient = authenticate.getSubjectInfoByName(destination.getDestination());
            if (!forceQueing && destinationClient==null) {
               String tmp = ME+": Sending PtP message '" + cacheEntry.getLogId() + "' to '" + destination.getDestination() + "' failed, the destination is unkown, the message rejected.";
               //log.warning(tmp); is logged by caller already
               throw new XmlBlasterException(serverScope, ErrorCode.USER_PTP_UNKNOWNDESTINATION, ME, tmp +
                   " Client is not logged in and <destination forceQueuing='true'> is not set");
            }
            if (log.isLoggable(Level.FINE)) log.fine(ME+": Queuing PtP message '" + cacheEntry.getLogId() + "' for subject destination [" + destination.getDestination() + "], forceQueing="+forceQueing);

            // We are responsible to call destinationClient.getLock().release()
            final boolean returnLocked = true;
            destinationClient = authenticate.getOrCreateSubjectInfoByName(destination.getDestination(), returnLocked, null, null);
            try {
               MsgQueueUpdateEntry msgEntrySubject = new MsgQueueUpdateEntry(serverScope, cacheEntry,
                        destinationClient.getSubjectQueue().getStorageId(), destination.getDestination(),
                        Constants.SUBSCRIPTIONID_PtP, false);
               destinationClient.queueMessage(msgEntrySubject);
               continue;
            }
            finally {
               destinationClient.getLock().release();
            }
         }

         // Handle PtP to session in a thread safe manner
         SessionInfo receiverSessionInfo = null;
         try {
            receiverSessionInfo = authenticate.getSessionInfo(destination.getDestination());
            if (receiverSessionInfo != null) {
               receiverSessionInfo.getLock().lock();
               //receiverSessionInfo.waitUntilAlive();
               if (receiverSessionInfo.isAlive()) {
                  if (!receiverSessionInfo.getConnectQos().isPtpAllowed() &&
                      !Constants.EVENT_OID_ERASEDTOPIC.equals(cacheEntry.getKeyOid())) { // no spam, case 2
                     if (log.isLoggable(Level.FINE)) log.fine(ME+": Rejecting PtP message '" + cacheEntry.getLogId() + "' for destination [" + destination.getDestination() + "], isPtpAllowed=false");
                     throw new XmlBlasterException(serverScope, ErrorCode.USER_PTP_DENIED, ME,
                           receiverSessionInfo.getId() + " does not accept PtP messages '" + cacheEntry.getLogId() +
                           "' is rejected");
                  }
               }
               else {
                  receiverSessionInfo.releaseLockAssertOne("Topic=" + getId());
                  receiverSessionInfo = null;
               }
            }

            if (receiverSessionInfo == null && !forceQueing) {
               String tmp = ME+": Sending PtP message '" + cacheEntry.getLogId() + "' to '" + destination.getDestination() + "' failed, the destination is unkown, the message rejected.";
               log.warning(tmp);
               throw new XmlBlasterException(serverScope, ErrorCode.USER_PTP_UNKNOWNDESTINATION, ME, tmp +
                     " Client is not logged in and <destination forceQueuing='true'> is not set");
            }

            // Row 1 in table
            if (receiverSessionInfo == null) { // We create a faked session without password check
               if (log.isLoggable(Level.FINE)) log.fine(ME+": Working on PtP message '" + cacheEntry.getLogId() + "' for destination [" + destination.getDestination() + "] which does not exist, forceQueuing=true, we create a dummy session");
               ConnectQos connectQos = new ConnectQos(serverScope);
               connectQos.setSessionName(destinationSessionName);
               connectQos.setUserId(destinationSessionName.getLoginName());
               ConnectQosServer connectQosServer = new ConnectQosServer(serverScope, connectQos.getData());
               connectQosServer.bypassCredentialCheck(true);
               long sessionTimeout = serverScope.getProperty().get("session.ptp.defaultTimeout", -1L);
               connectQosServer.getSessionQos().setSessionTimeout(sessionTimeout)// Or use message timeout?
               for (int i=0; ; i++) {
View Full Code Here


            }
            catch (Throwable e) {
               // sender =      publisherSessionInfo.getLoginName()
               // receiver =    sub.getSessionInfo().getLoginName()
               // 1. We just log the situation:
               SessionName publisherName = (publisherSessionInfo != null) ? publisherSessionInfo.getSessionName() :
                                  msgUnitWrapper.getMsgQosData().getSender();
               String reason = "Mime access filter '" + filterQos[ii].getType() + "' for message '" +
                         msgUnitWrapper.getLogId() + "' from sender '" + publisherName + "' to subscriber '" +
                         sub.getSessionInfo().getSessionName() + "' threw an exception, we don't deliver " +
                         "the message to the subscriber: " + e.toString();
View Full Code Here

         // If in MsgQueueUpdateEntry we set super.wantReturnObj = true; (see ReferenceEntry.java):
         //UpdateReturnQosServer retQos = (UpdateReturnQosServer)entry.getReturnObj();
         return 1;
      }
      catch (Throwable e) {
         SessionName publisherName = (publisherSessionInfo != null) ? publisherSessionInfo.getSessionName() :
                                     msgUnitWrapper.getMsgQosData().getSender();
         if ( doErrorHandling ) {
            if (log.isLoggable(Level.FINE)) log.fine(ME+": Sending of message from " + publisherName + " to " +
                               sub.getSessionInfo().getId() + " failed: " + e.toString());
            try {
View Full Code Here

      if (infoArr.length < 1)
         return new String[] { "This topic has currently no subscriber" };

      SessionInfo sessionInfo = null;
      SessionName wanted = new SessionName(serverScope, sessionName);
      for (int i=0; i<infoArr.length; i++) {
         SessionName tmp = infoArr[i].getSessionInfo().getSessionName();
         if (wanted.equalsRelative(tmp) || wanted.equalsAbsolute(tmp)) {
            sessionInfo = infoArr[i].getSessionInfo();
            break;
         }
      }
View Full Code Here

      if (isXPathQuery()) {
         log.severe("Query type " + queryType + " is not implemented");
         //throw new IllegalArgumentException(ME+": Query type " + queryType + " is not implemented");
      }
      else {
         setDestination(new SessionName(Global.instance(), address));
      }
   }
View Full Code Here

    * Only for testing
    *    java org.xmlBlaster.engine.Destination
    */
   public static void main(String args[]) {
      Destination dest = new Destination();
      dest.setDestination(new SessionName(Global.instance(), "Johann"));
      dest.forceQueuing(true);
      System.out.println(dest.toXml());
   }
View Full Code Here

            }

            if (log.isLoggable(Level.FINE)) log.fine("storageId=" + storageId + ": Read timestamp=" + timestamp + " topic keyOid=" + keyOid +
                         " msgUnitWrapperUniqueId=" + msgUnitWrapperUniqueId + " receiverStr=" + receiverStr +
                         " subscriptionId=" + subscriptionId + " flag=" + flag + " redeliverCount=" + redeliverCount);
            SessionName receiver = new SessionName(glob, receiverStr);
            Timestamp updateEntryTimestamp = new Timestamp(timestamp);
            return new MsgQueueUpdateEntry(this.glob,
                                           PriorityEnum.toPriorityEnum(priority), storageId, updateEntryTimestamp,
                                           keyOid, msgUnitWrapperUniqueId.longValue(), persistent, sizeInBytes,
                                           receiver, subscriptionId, flag, redeliverCount.intValue(),
View Full Code Here

            }
              
            if (log.isLoggable(Level.FINE)) log.fine("storageId=" + store.toString() + ": Read timestamp=" + timestamp + " topic keyOid=" + keyOid +
                         " msgUnitWrapperUniqueId=" + msgUnitWrapperUniqueId + " receiverStr=" + receiverStr +
                         " subscriptionId=" + subscriptionId + " flag=" + flag + " redeliverCount=" + redeliverCount);
            SessionName receiver = new SessionName(glob, receiverStr);
            Timestamp updateEntryTimestamp = new Timestamp(timestamp);
           
            return new MsgQueueUpdateEntry(glob,
                                           PriorityEnum.toPriorityEnum(ref.getPrio()), storageId, updateEntryTimestamp,
                                           keyOid, msgUnitWrapperUniqueId, ref.isDurable(), ref.getByteSize(),
View Full Code Here

              ConnectQosServer qos = new ConnectQosServer(this.global, data);
              qos.isFromPersistenceRecovery(true);
              qos.setPersistenceUniqueId(entry.getUniqueId());
              qos.setAddressServer(this.addressServer);

              SessionName sessionName = data.getSessionName();
              String sessionId = data.getSessionQos().getSecretSessionId();
              sessionIds.put(sessionName.getAbsoluteName(), sessionId);
              if (log.isLoggable(Level.FINE))
                 log.fine("recoverSessions: store in map session='" + sessionName.getAbsoluteName() + "' has secret sessionId='" + sessionId + "' and persistenceUniqueId=" + entry.getUniqueId());
              // if (log.isLoggable(Level.FINE)) log.trace(ME, "recoverSessions: session: '" + data.getSessionName() + "' secretSessionId='" + qos.getSessionQos().getSecretSessionId() + "' qos='" + qos.toXml() + "'");
              ConnectReturnQosServer ret = this.global.getAuthenticate().connect(qos);
              if (log.isLoggable(Level.FINEST))
                 log.finest("recoverSessions: return of connect: returnConnectQos='" + ret.toXml() + "'");
           }
View Full Code Here

                     SubscribeEntry subscribeEntry = (SubscribeEntry)entry;
                     //QueryKeyData keyData = queryKeyFactory.readObject(subscribeEntry.getKey());
                     QueryQosData qosData = global.getQueryQosFactory().readObject(subscribeEntry.getQos());
                     //String key = keyData.getOid() + qosData.getSender().getAbsoluteName();

                     SessionName sessionName = new SessionName(global, subscribeEntry.getSessionName());
                     Object found = sessionIds.get(sessionName.getAbsoluteName());
                     if (found == null) {
                        if (errorCounter == 0) {
                           log.warning("Ignoring invalid entry '" + sessionName.getAbsoluteName() + "' as user is not known");
                        }
                        errorCounter++;
                        return null;
                     }

                     String key = qosData.getSubscriptionId();
                     if (log.isLoggable(Level.FINE))
                        log.fine("Cleanup of duplicate subscriptions, key=" + key);
                     if (duplicates.containsKey(key)) {
                        if (duplicateCounter == 0)
                           log.warning("Cleanup of duplicate subscriptions, this may take a while, please wait ...");
                        duplicateCounter++;
                        //log.warn(ME, "Removing duplicate subscription '" + key + "' oid=" + keyData.getOid());
                        //subscribeStore.remove(subscribeEntry);
                     }
                     else {
                        duplicates.put(key, subscribeEntry);
                     }
                  }
                  catch (XmlBlasterException e) {
                     log.severe("Ignoring unexpected problem in checkForDuplicateSubscriptions :" + e.toString());
                  }
                  return null;
               }
            });
            if (duplicateCounter > 0) {
               this.subscribeStore.clear();
               if (this.subscribeStore.getNumOfEntries() > 0)
                     log.severe("Internal prpblem with checkForDuplicateSubscriptions");
               java.util.Iterator it = duplicates.keySet().iterator();
               while (it.hasNext()) {
                  this.subscribeStore.put((I_MapEntry)duplicates.get(it.next()));
               }
               log.warning("Removed " + (duplicateCounter-duplicates.size()) + " identical subscriptions, keeping " + duplicates.size() + ". Ignored " + errorCounter + " invalid subscriptions as no session was found");
            }
         }
      }

      I_MapEntry[] entries = this.subscribeStore.getAll(null);

      for (int i=0; i < entries.length; i++) {
         if (entries[i] instanceof SubscribeEntry) {
            // do connect
            SubscribeEntry entry = (SubscribeEntry)entries[i];
            String qos = entry.getQos();
            QueryQosData qosData = global.getQueryQosFactory().readObject(qos);

            ClientProperty clientProperty = qosData.getClientProperty(Constants.PERSISTENCE_ID);
            if (clientProperty == null) {
               log.severe("SubscribeQos with missing " + Constants.PERSISTENCE_ID + ": " + qosData.toXml());
               long uniqueId = new Timestamp().getTimestamp();
               qosData.getClientProperties().put(Constants.PERSISTENCE_ID, new ClientProperty(Constants.PERSISTENCE_ID, "long", null, "" + uniqueId));
            }

            boolean initialUpdates = qosData.getInitialUpdateProp().getValue();
            if (initialUpdates) {
               qosData.getClientProperties().put(ORIGINAL_INITIAL_UPDATES, new ClientProperty(ORIGINAL_INITIAL_UPDATES, "boolean", null, "true"));
            }
            SessionName sessionName = new SessionName(this.global, entry.getSessionName());
            String sessionId = (String)sessionIds.get(sessionName.getAbsoluteName());
            if (sessionId == null) {
               log.severe("The persistent session '" + sessionName.getAbsoluteName() + "' is not found, removing persistent subscription " + entry.getLogId());
               this.subscribeStore.remove(entry);
               continue;
               //throw new XmlBlasterException(this.global, ErrorCode.INTERNAL_NULLPOINTER, ME + ".recoverSubscriptions", "The secret sessionId was not found for session='" + sessionName.getAbsoluteName() + "'");
            }
            // TODO remove the setting of client properties and invoke directly requestBroker.subscribe with subscribeQosServer.inhibitInitialUpdates(true);
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.SessionName

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.