Package java.util.concurrent.atomic

Examples of java.util.concurrent.atomic.AtomicLong


    public SimpleCounter(long resetIntervalMs) {
        if(resetIntervalMs < 1) {
            throw new IllegalArgumentException("Reset interval must be positive");
        }
        this.resetIntervalMs = resetIntervalMs;
        this.lastResetTimeMs = new AtomicLong(System.currentTimeMillis());
        this.eventsValueCounter = new AtomicLong(0);
        this.eventsCounter = new AtomicLong(0);
        this.numEventsLastInterval = 0;
        this.totalEventValueLastInterval = 0;
        this.numEventsLastLastInterval = 0;
        this.totalEventValueLastLastInterval = 0;
    }
View Full Code Here


    public ClusterWideCounter(Cluster cluster) {
        this.cluster = cluster;
        this.values = new ConcurrentHashMap<Integer, AtomicLong>(cluster.getNumberOfNodes());
        for(Node node: cluster.getNodes())
            values.put(node.getId(), new AtomicLong(0L));
    }
View Full Code Here

        for(Node node: cluster.getNodes())
            values.put(node.getId(), new AtomicLong(0L));
    }

    public void incrementCount(int nodeId) {
        AtomicLong counter = values.get(nodeId);
        if(counter == null) {
            counter = new AtomicLong(0L);
            values.putIfAbsent(nodeId, counter);
        }
        counter.incrementAndGet();
    }
View Full Code Here

        for(AtomicLong counter: values.values())
            counter.set(0L);
    }

    public void clearCount(int nodeId) {
        AtomicLong counter = values.get(nodeId);
        if(counter == null) {
            counter = new AtomicLong(0L);
            values.put(nodeId, counter);
        } else
            counter.set(0L);
    }
View Full Code Here

        } else
            counter.set(0L);
    }

    public void setCount(int nodeId, Long newValue) {
        AtomicLong counter = values.get(nodeId);
        if(counter == null) {
            counter = new AtomicLong(0L);
            values.putIfAbsent(nodeId, counter);
        }
        counter.set(newValue);
    }
View Full Code Here

        }
        return Collections.unmodifiableMap(map);
    }

    public Long getCount(int nodeId) {
        AtomicLong counter = values.get(nodeId);
        if(counter == null)
            throw new IllegalArgumentException("no value for " + nodeId);
        return counter.get();
    }
View Full Code Here

  private final AtomicInteger num500s;
  private final AtomicInteger num400s;
  private final AtomicInteger num200s;

  public StatsReporter() {
    numMessages = new AtomicLong(0);
    numDisconnects = new AtomicInteger(0);
    numConnectionFailures = new AtomicInteger(0);
    numConnects = new AtomicInteger(0);
    num500s = new AtomicInteger(0);
    num400s = new AtomicInteger(0);
    num200s = new AtomicInteger(0);
    numClientEventsDropped = new AtomicLong(0);
    numMessagesDropped = new AtomicLong(0);
  }
View Full Code Here

      InputStream input = inputStreamParameter;

      // We won't know the real size of the message since we are compressing while reading the streaming.
      // This counter will be passed to the deflater to be updated for every byte read
      AtomicLong messageSize = new AtomicLong();

      DeflaterReader deflaterReader = null;

      if (session.isCompressLargeMessages())
      {
         msgI.putBooleanProperty(Message.HDR_LARGE_COMPRESSED, true);
         deflaterReader = new DeflaterReader(inputStreamParameter, messageSize);
         input = deflaterReader;
      }

      long totalSize = 0;

      boolean headerSent = false;

      while (!lastPacket)
      {
         byte[] buff = new byte[minLargeMessageSize];

         int pos = 0;

         do
         {
            int numberOfBytesRead;

            int wanted = minLargeMessageSize - pos;

            try
            {
               numberOfBytesRead = input.read(buff, pos, wanted);
            }
            catch (IOException e)
            {
               throw HornetQClientMessageBundle.BUNDLE.errorReadingBody(e);
            }

            if (numberOfBytesRead == -1)
            {
               lastPacket = true;

               break;
            }

            pos += numberOfBytesRead;
         }
         while (pos < minLargeMessageSize);

         totalSize += pos;

         final SessionSendContinuationMessage chunk;

         if (lastPacket)
         {
            if (!session.isCompressLargeMessages())
            {
               messageSize.set(totalSize);
            }

            // This is replacing the last packet by a smaller packet
            byte[] buff2 = new byte[pos];

            System.arraycopy(buff, 0, buff2, 0, pos);

            buff = buff2;

            // This is the case where the message is being converted as a regular message
            if (!headerSent && session.isCompressLargeMessages() && buff2.length < minLargeMessageSize)
            {
               msgI.getBodyBuffer().resetReaderIndex();
               msgI.getBodyBuffer().resetWriterIndex();
               msgI.putLongProperty(Message.HDR_LARGE_BODY_SIZE, deflaterReader.getTotalSize());

               msgI.getBodyBuffer().writeBytes(buff, 0, pos);
               sendRegularMessage(msgI, sendBlocking, credits, handler);
               return;
            }

            chunk = new SessionSendContinuationMessage(msgI, buff, false, sendBlocking, messageSize.get(), handler);
         }
         else
         {
            chunk = new SessionSendContinuationMessage(msgI, buff, true, false, null);
         }
View Full Code Here

    exporting = new AtomicBoolean(false);
    exported = new AtomicBoolean(false);
    jobTimeOut = new AtomicBoolean(false);
    trunkExported = new AtomicBoolean(false);
    diskResultMerged = false;
    jobMergeTime = new AtomicLong(0);
    jobExportTime = 0;
    jobMergeBranchCount = new AtomicInteger(0);
    diskResult = null;
    StringBuilder bs = new StringBuilder();
        for(JobTask jobTask : this.jobTasks) {
View Full Code Here

   */
  private AtomicLong megeredTaskConsumeTime;
 
 
  public SlaveMonitorInfo() {
    slaveExecuteTaskTime = new AtomicLong(0L);
    slaveExecutedTaskCount = new AtomicLong(0L);
    slaveConsumeDataSize = new AtomicLong(0L);
    slaveConsumeDataLine = new AtomicLong(0L);
    slaveConsumeEmptyLine = new AtomicLong(0L);
    slaveConsumeExceptionLine = new AtomicLong(0L);
    keyCount = new AtomicLong(0L);
    valueCount = new AtomicLong(0L);
    mergedTaskCount = new AtomicLong(0L);
    megeredTaskConsumeTime = new AtomicLong(0L);
  }
View Full Code Here

TOP

Related Classes of java.util.concurrent.atomic.AtomicLong

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.