Package com.dianping.cat.message.internal

Examples of com.dianping.cat.message.internal.MessageId


    MessageBlock block = null;
    MessageTree tree = new DefaultMessageTree();

    for (i = 0; i < count; i++) {
      ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
      MessageId id = buildChannelBuffer(factory, codec, tree, buf);

      block = bucket.storeMessage(buf, id);

      if (block != null) {
        bucket.getWriter().writeBlock(block);
View Full Code Here


  private MessageId buildChannelBuffer(MessageIdFactory factory, MessageCodec codec, MessageTree tree,
        ChannelBuffer buf) {
    String messageId = factory.getNextId();

    tree.setMessageId(messageId);
    MessageId id = MessageId.parse(messageId);

    codec.encode(tree, buf);

    return id;
  }
View Full Code Here

    Set<Integer> fullBucket = new HashSet<Integer>();
    Map<Integer, Integer> maxIdForBucket = new HashMap<Integer, Integer>();

    for (int i = 0; i < count; i++) {
      ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
      MessageId id = buildChannelBuffer(factory, codec, tree, buf);

      int pos = i % buckets.length;

      if (!fullBucket.contains(pos)) {
        block = buckets[pos].storeMessage(buf, id);
View Full Code Here

    Transaction t = cat.newTransaction("BucketService", getClass().getSimpleName());

    t.setStatus(Message.SUCCESS);

    try {
      MessageId id = MessageId.parse(messageId);
      final String path = m_pathBuilder.getPath(new Date(id.getTimestamp()), "");
      final File dir = new File(m_baseDir, path);
      final String key = id.getDomain() + '-' + id.getIpAddress();
      final List<String> paths = new ArrayList<String>();

      Scanners.forDir().scan(dir, new FileMatcher() {
        @Override
        public Direction matches(File base, String name) {
          if (name.contains(key) && !name.endsWith(".idx")) {
            paths.add(path + name);
          }
          return Direction.NEXT;
        }
      });

      for (String dataFile : paths) {
        LocalMessageBucket bucket = m_buckets.get(dataFile);

        if (bucket != null) {
          MessageBlock block = bucket.flushBlock();

          if (block != null) {
            m_messageBlocks.offer(block);

            LockSupport.parkNanos(200 * 1000 * 1000L); // wait 50 ms
          }
          MessageTree tree = bucket.findByIndex(id.getIndex());

          if (tree != null && tree.getMessageId().equals(messageId)) {
            t.addData("path", dataFile);
            return tree;
          }
        } else {
          File file = new File(m_baseDir, dataFile);

          if (file.exists()) {
            try {
              bucket = (LocalMessageBucket) lookup(MessageBucket.class, LocalMessageBucket.ID);
              bucket.setBaseDir(m_baseDir);
              bucket.initialize(dataFile);

              MessageTree tree = bucket.findByIndex(id.getIndex());

              if (tree != null && tree.getMessageId().equals(messageId)) {
                t.addData("path", dataFile);
                return tree;
              }
View Full Code Here

      return "Message-Gzip-" + m_index;
    }

    private void gzipMessage(MessageItem item) {
      try {
        MessageId id = item.getMessageId();
        String name = id.getDomain() + '-' + id.getIpAddress() + '-' + m_localIp;
        String dataFile = m_pathBuilder.getPath(new Date(id.getTimestamp()), name);
        LocalMessageBucket bucket = m_buckets.get(dataFile);

        if (bucket == null) {
          synchronized (m_buckets) {
            bucket = m_buckets.get(dataFile);
View Full Code Here

TOP

Related Classes of com.dianping.cat.message.internal.MessageId

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.