Package org.xmlBlaster.util

Examples of org.xmlBlaster.util.Timestamp


   private void touch(I_MapEntry entry) {
      if (entry == null) return;
      if (entry.getSortTimestamp() != null) // assert: All entries in the set must have a sortTimestamp else the Comparator fails
         this.lruSet.remove(entry);
      entry.setSortTimestamp(new Timestamp());
      this.lruSet.add(entry);
   }
View Full Code Here


               this.persistentSizeInBytes -= old.getSizeInBytes();
            }
            */
         }
         else {
            entry.setSortTimestamp(new Timestamp());
            this.lruSet.add(entry);
           
            entry.setStored(true);
            this.sizeInBytes += entry.getSizeInBytes();
            if (entry.isPersistent()) {
View Full Code Here

      // We compare the MsgUnitWrapper by its cache entry timestamp
      public final int compare(Object o1, Object o2) {
         I_MapEntry id1 = (I_MapEntry)o1;
         I_MapEntry id2 = (I_MapEntry)o2;

         if (id1.getSortTimestamp() == null) id1.setSortTimestamp(new Timestamp()); // assert != null
         if (id2.getSortTimestamp() == null) id2.setSortTimestamp(new Timestamp()); // assert != null
        
         if (id1.getSortTimestamp().getTimestamp() > id2.getSortTimestamp().getTimestamp()) {
            return 1;
         }
         else if (id1.getSortTimestamp().getTimestamp() < id2.getSortTimestamp().getTimestamp()) {
View Full Code Here

   }

   public void logToFile(String text) {
      log.info(text);
      try {
         String str = new Timestamp().toString() + " " + text + "\n";
         out_.write(str.getBytes("UTF-8"));
         out_.flush();
      } catch (IOException e) {
         e.printStackTrace();
      }
View Full Code Here

      if (to_file.getParent() != null) {
         to_file.getParentFile().mkdirs();
      }
      final FileOutputStream out = new FileOutputStream(to_file);
      out_ = out;
      out_.write(("XmlBlaster " + new Timestamp().toString()).getBytes());
      out_.write(("\n" + XmlBlasterException.createVersionInfo() + "\n").getBytes());

      log.info("Report file is '" + to_file.getAbsolutePath() + "'");
      System.out.println("Report file is '" + to_file.getAbsolutePath() + "'");
   }
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(),
                                           qos, key, content);
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-MsgQueueUpdateEntry", ex);
         }
      }
      else if (ENTRY_TYPE_HISTORY_REF.equalsIgnoreCase(type)) { // still used
         try {
            ObjectInputStream objStream = new ObjectInputStream(is);
            Object[] obj = (Object[])objStream.readObject();
            if (obj.length < 2) {
               throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME,
                  "Expected 2 entries in serialized object '" + type + "' but got " + obj.length + " for priority=" + priority + " timestamp=" + timestamp + ". Could be a version incompatibility.");
            }
            String keyOid = (String)obj[0];
            Long msgUnitWrapperUniqueId = (Long)obj[1];
            Timestamp updateEntryTimestamp = new Timestamp(timestamp);
            return new MsgQueueHistoryEntry(this.glob,
                                           PriorityEnum.toPriorityEnum(priority), storageId, updateEntryTimestamp,
                                           keyOid, msgUnitWrapperUniqueId.longValue(), persistent, sizeInBytes);
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-MsgQueueHistoryEntry", ex);
         }
      }
      else if (ENTRY_TYPE_MSG_XML.equalsIgnoreCase(type)) { // still used
         try {
            ObjectInputStream objStream = new ObjectInputStream(is);
            Object[] obj = (Object[])objStream.readObject();
            if (obj.length < 5) {
               throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME,
                         "Expected 5 entries in serialized object stream but got " + obj.length + " for priority=" + priority + " timestamp=" + timestamp);
            }
            String qos = (String)obj[0];
            String key = (String)obj[1];
            byte[] content = (byte[])obj[2];
            Integer referenceCounter = (Integer)obj[3];
            Integer historyReferenceCounter = (Integer)obj[4];
            PublishQosServer publishQosServer = new PublishQosServer(glob, qos, true); // true marks from persistent store (prevents new timestamp)
            MsgKeyData msgKeyData = glob.getMsgKeyFactory().readObject(key);
            MsgUnit msgUnit = new MsgUnit(msgKeyData, content, publishQosServer.getData());
            MsgUnitWrapper msgUnitWrapper = new MsgUnitWrapper(glob, msgUnit, storageId,
                                      referenceCounter.intValue(), historyReferenceCounter.intValue(), sizeInBytes);
            msgUnitWrapper.startExpiryTimer();
            return msgUnitWrapper;
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-MsgUnitWrapper", ex);
         }
      }
      else if (ENTRY_TYPE_MSG_SERIAL.equalsIgnoreCase(type)) {  // probably unused (not found in my tests)
         try {
            ObjectInputStream objStream = new ObjectInputStream(is);
            Object[] obj = (Object[])objStream.readObject();
            if (obj.length < 3) {
               throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME,
                         "Expected 3 entries in serialized object stream but got " + obj.length + " for priority=" + priority + " timestamp=" + timestamp);
            }
            MsgUnit msgUnit = (MsgUnit)obj[0];
            Integer referenceCounter = (Integer)obj[1];
            Integer historyReferenceCounter = (Integer)obj[2];
            msgUnit.setGlobal(glob);
            MsgUnitWrapper msgUnitWrapper = new MsgUnitWrapper(glob, msgUnit, storageId,
                             referenceCounter.intValue(), historyReferenceCounter.intValue(), sizeInBytes);
            msgUnitWrapper.startExpiryTimer();
            return msgUnitWrapper;
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-MsgUnitWrapper", ex);
         }
      }

      else if (ENTRY_TYPE_TOPIC_XML.equalsIgnoreCase(type)) { // still used
         try {
            ObjectInputStream objStream = new ObjectInputStream(is);
            Object[] obj = (Object[])objStream.readObject();
            if (obj.length < 2) {
               throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME,
                         "Expected 2 entries in serialized object stream but got " + obj.length + " for priority=" + priority + " timestamp=" + timestamp);
            }
            String qos = (String)obj[0];
            String key = (String)obj[1];
            byte[] content = null;
            PublishQosServer publishQosServer = new PublishQosServer(glob, qos, true); // true marks from persistent store (prevents new timestamp)
            MsgKeyData msgKeyData = glob.getMsgKeyFactory().readObject(key);
            MsgUnit msgUnit = new MsgUnit(msgKeyData, content, publishQosServer.getData());
            TopicEntry topicEntry = new TopicEntry(glob, msgUnit, storageId, type, sizeInBytes);
            return topicEntry;
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-TopicEntry", ex);
         }
      }
      else if (ENTRY_TYPE_TOPIC_SERIAL.equalsIgnoreCase(type)) { // probably unused (not found in my tests)
         try {
            ObjectInputStream objStream = new ObjectInputStream(is);
            Object[] obj = (Object[])objStream.readObject();
            if (obj.length < 1) {
               throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME,
                         "Expected 1 entry in serialized object stream but got " + obj.length + " for priority=" + priority + " timestamp=" + timestamp);
            }
            MsgUnit msgUnit = (MsgUnit)obj[0];
            msgUnit.setGlobal(glob);
            TopicEntry topicEntry = new TopicEntry(glob, msgUnit, storageId, type, sizeInBytes);
            return topicEntry;
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-TopicEntry", ex);
         }
      }

      else if (ENTRY_TYPE_SESSION.equalsIgnoreCase(type)) {  // still used
         try {
            ObjectInputStream objStream = new ObjectInputStream(is);
            Object[] obj = (Object[])objStream.readObject();
            if (obj.length < 1) {
               throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME,
                         "Expected 1 entry in serialized object stream but got " + obj.length + " for priority=" + priority + " timestamp=" + timestamp);
            }
            String xmlLiteral = (String)obj[0];
            SessionEntry sessionEntry = new SessionEntry(xmlLiteral, timestamp, sizeInBytes, storageId);
            return sessionEntry;
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-TopicEntry", ex);
         }
      }
      else if (ENTRY_TYPE_SUBSCRIBE.equalsIgnoreCase(type)) {  // still used
         try {
            ObjectInputStream objStream = new ObjectInputStream(is);
            Object[] obj = (Object[])objStream.readObject();
            if (obj.length < 3) {
               throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME,
                         "Expected 3 entries in serialized object stream but got " + obj.length + " for priority=" + priority + " timestamp=" + timestamp);
            }
            String keyLiteral = (String)obj[0];
            String qosLiteral = (String)obj[1];
            String sessionName = (String)obj[2];
            SubscribeEntry subscribeEntry = new SubscribeEntry(keyLiteral, qosLiteral, sessionName, timestamp, sizeInBytes, storageId);
            return subscribeEntry;
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-TopicEntry", ex);
         }
      }

      else if (ENTRY_TYPE_DUMMY.equalsIgnoreCase(type)) { // still used (for testing)
         DummyEntry entry = new DummyEntry(glob, PriorityEnum.toPriorityEnum(priority), new Timestamp(timestamp), storageId, sizeInBytes, persistent);
         //entry.setUniqueId(timestamp);
         return entry;
      }

      throw new XmlBlasterException(glob, ErrorCode.INTERNAL_NOTIMPLEMENTED, ME, "Persistent object '" + type + "' is not implemented");
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(),
                                           receiver, subscriptionId, flag, redeliverCount,
                                           qos, key, content);
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-MsgQueueUpdateEntry", ex);
         }
      }
      else if (ENTRY_TYPE_HISTORY_REF.equalsIgnoreCase(type)) { // still used
         try {
            String keyOid = (String) metaInfoMap.get(XBRef.KEY_OID);
            long msgUnitWrapperUniqueId = Long.parseLong((String) metaInfoMap.get(XBRef.MSG_WRAPPER_ID));
            Timestamp updateEntryTimestamp = new Timestamp(timestamp);
            return new MsgQueueHistoryEntry(glob,
                                           PriorityEnum.toPriorityEnum(ref.getPrio()), storageId, updateEntryTimestamp,
                                           keyOid, msgUnitWrapperUniqueId, ref.isDurable(), ref.getByteSize());
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-MsgQueueHistoryEntry", ex);
         }
      }
      else if (ENTRY_TYPE_MSG_XML.equalsIgnoreCase(type)) { // still used
         try {
            String qos = meat.getQos();
            String key = meat.getKey();
            byte[] content = meat.getContent();
            long referenceCounter = meat.getRefCount();
            long historyReferenceCounter = meat.getRefCount2();
            PublishQosServer publishQosServer = new PublishQosServer(glob, qos, true); // true marks from persistent store (prevents new timestamp)
            MsgKeyData msgKeyData = glob.getMsgKeyFactory().readObject(key);
            MsgUnit msgUnit = new MsgUnit(msgKeyData, content, publishQosServer.getData());
            MsgUnitWrapper msgUnitWrapper = new MsgUnitWrapper(glob, msgUnit, storageId,
                                      (int)referenceCounter, (int)historyReferenceCounter, meat.getByteSize());
            msgUnitWrapper.startExpiryTimer();
            return msgUnitWrapper;
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-MsgUnitWrapper", ex);
         }
      }
      else if (ENTRY_TYPE_TOPIC_XML.equalsIgnoreCase(type)) { // still used
         try {
            String qos = meat.getQos();
            String key = meat.getKey();
            byte[] content = null;
            PublishQosServer publishQosServer = new PublishQosServer(glob, qos, true); // true marks from persistent store (prevents new timestamp)
            MsgKeyData msgKeyData = glob.getMsgKeyFactory().readObject(key);
            MsgUnit msgUnit = new MsgUnit(msgKeyData, content, publishQosServer.getData());
            TopicEntry topicEntry = new TopicEntry(glob, msgUnit, storageId, type, meat.getByteSize());
            return topicEntry;
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-TopicEntry", ex);
         }
      }
      else if (ENTRY_TYPE_SESSION.equalsIgnoreCase(type)) {  // still used
         try {
            String xmlLiteral = meat.getQos();
            SessionEntry sessionEntry = new SessionEntry(xmlLiteral, timestamp, meat.getByteSize(), storageId);
            return sessionEntry;
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-TopicEntry", ex);
         }
      }
      else if (ENTRY_TYPE_SUBSCRIBE.equalsIgnoreCase(type)) {  // still used
         try {
            String keyLiteral = meat.getKey();
            String qosLiteral = meat.getQos();
            String sessionName = (String) metaInfoMap.get(XBMeat.SESSION_NAME);
            SubscribeEntry subscribeEntry = new SubscribeEntry(keyLiteral, qosLiteral, sessionName, timestamp, meat.getByteSize(), storageId);
            return subscribeEntry;
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-TopicEntry", ex);
         }
      }

      else if (ENTRY_TYPE_DUMMY.equalsIgnoreCase(type)) { // still used (for testing)
         DummyEntry entry = null;
         byte[] content = null;
         long sizeInBytes = 0L;
         if (ref != null)
            sizeInBytes = ref.getByteSize();
         if (meat != null)
            sizeInBytes = meat.getByteSize();
         if (meat != null)
            content = meat.getContent();
         int prio = 5;
         if (ref != null)
            prio = ref.getPrio();
        
         if (content != null)
            entry = new DummyEntry(glob, PriorityEnum.toPriorityEnum(prio), new Timestamp(timestamp), storageId,
                  sizeInBytes, content, ref.isDurable());
         else
            entry = new DummyEntry(glob, PriorityEnum.toPriorityEnum(prio), new Timestamp(timestamp), storageId, sizeInBytes, ref.isDurable());
         return entry;
      }

      throw new XmlBlasterException(glob, ErrorCode.INTERNAL_NOTIMPLEMENTED, ME, "Persistent object '" + type + "' is not implemented");
   }
View Full Code Here

      XBSession session = this.publisher.getJmsSession();
      XBDestination dest = new XBDestination(initialDataTopic, SpecificDefault.toString(slaveSessionNames));
      XBMessageProducer producer = new XBMessageProducer(session, dest);
      producer.setPriority(PriorityEnum.HIGH_PRIORITY.getInt());
      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
      String dumpId = "" + new Timestamp().getTimestamp();
      sendEndOfTransitionMessage(info, session, null, null, dumpId, producer);
   }
View Full Code Here

            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) {
View Full Code Here

      }

      // Persist it
      StorageId storageId = null;
      if (sessionInfo.getPersistenceUniqueId() == 0) {
         long uniqueId = new Timestamp().getTimestamp(); // new session
         SessionEntry entry = new SessionEntry(connectQosData.toXml(), uniqueId, connectQosData.size(), storageId);
         if (log.isLoggable(Level.FINE)) log.fine("addSession (persistent) for NEW uniqueId: '" + entry.getUniqueId() + "'");
         sessionInfo.setPersistenceUniqueId(uniqueId);
         this.sessionStore.put(entry);
      }
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.Timestamp

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.