Package java.util.concurrent.atomic

Examples of java.util.concurrent.atomic.AtomicLong


                                                                                          //   then use the other constructor
         threadPoolSize = Math.max(cpuBasedThreadCount, minNumThreads);
      }
      executor = (ThreadPoolExecutor)Executors.newFixedThreadPool(threadPoolSize);
      schedule = Executors.newSingleThreadScheduledExecutor();
      numLimited = new AtomicLong(0);
     
      if (maxNumWaitingLimitedTasks < 0)
         maxNumWaitingLimitedTasks = 20 * threadPoolSize;
   }
View Full Code Here


         {
            return inProcessMessages.get();
         }
      });

      numberOfMPs = new AtomicLong();
      lastOutputCycleMillis = new AtomicLong();
      mpsCreated = Metrics.newMeter(createName(MN_MP_CREATE), "instances", TimeUnit.SECONDS);
      mpsDeleted = Metrics.newMeter(createName(MN_MP_DELETE), "instances", TimeUnit.SECONDS);
      Metrics.newGauge(createName(GAGE_MPS), new com.yammer.metrics.core.Gauge<Long>() {
         @Override
         public Long value() {
View Full Code Here

  }

  public SlidingTimeWindowReservoir(long windowMs, Clock clock) {
    this.windowMs = windowMs * TIME_COLLISION_BUFFER;
    this.storage = new ConcurrentSkipListMap<Long, Long>();
    this.count = new AtomicLong();
    this.lastUpdatingTime = new AtomicLong();
    this.clock = clock;
  }
View Full Code Here

  private final String name;
  private final AtomicLong count;

  public Counter(String name) {
    this.name = name;
    this.count = new AtomicLong(0);
  }
View Full Code Here

      {
         for (int i = 0; i < threads.length; i++)
         {

            finished[i] = new AtomicBoolean(true);
            counts[i] = new AtomicLong(0);

            final int curIndex = i;

            Thread t = new Thread(new Runnable()
            {
View Full Code Here

   @Test
   public void testMessagesPending() {
      assertEquals("none yet", 0L, getStatValue(stats, StatsCollectorCoda.GAGE_MSG_PENDING));
      assertEquals("none yet", 0L, stats.getMessagesPending());
      final AtomicLong count = new AtomicLong(0);
      StatsCollector.Gauge gauge = new StatsCollector.Gauge()
      {
         @Override
         public long value()
         {
            return count.get();
         }
      };
      stats.setMessagesPendingGauge(gauge);
      assertEquals("none yet", 0L, getStatValue(stats, StatsCollectorCoda.GAGE_MSG_PENDING));
      assertEquals("none yet", 0L, stats.getMessagesPending());
      count.set(10);
      assertEquals("final value", 10L, getStatValue(stats, StatsCollectorCoda.GAGE_MSG_PENDING));
      assertEquals("final value", 10L, stats.getMessagesPending());
   }
View Full Code Here

   @Test
   public void testMessagesOutPending() {
      assertEquals("none yet", 0L, getStatValue(stats, StatsCollectorCoda.GAGE_MSG_OUT_PENDING));
      assertEquals("none yet", 0L, stats.getMessagesPending());
      final AtomicLong count = new AtomicLong(0);
      StatsCollector.Gauge gauge = new StatsCollector.Gauge()
      {
         @Override
         public long value()
         {
            return count.get();
         }
      };
      stats.setMessagesOutPendingGauge(gauge);
      assertEquals("none yet", 0L, getStatValue(stats, StatsCollectorCoda.GAGE_MSG_OUT_PENDING));
      assertEquals("none yet", 0L, stats.getMessagesOutPending());
      count.set(10);
      assertEquals("final value", 10L, getStatValue(stats, StatsCollectorCoda.GAGE_MSG_OUT_PENDING));
      assertEquals("final value", 10L, stats.getMessagesOutPending());
   }
View Full Code Here

   {
      // now lets startup the server.
      ZookeeperTestServer server = null;
      final AtomicReference<ZookeeperSession> sessionRef = new AtomicReference<ZookeeperSession>();
      ZookeeperSession session = null;
      final AtomicLong processCount = new AtomicLong(0);
     
      Dempsy[] dempsy = new Dempsy[3];
      try
      {
         server = new ZookeeperTestServer();
         server.start();

         session = new ZookeeperSession("127.0.0.1:" + port,5000) {
            @Override
            public WatcherProxy makeWatcherProxy(ClusterInfoWatcher w)
            {
                     processCount.incrementAndGet();
                     return super.makeWatcherProxy(w);
            };
         };
         sessionRef.set(session);

         final FullApplication app = new FullApplication();
         ApplicationDefinition ad = app.getTopology();

         assertEquals(0,processCount.intValue()); // no calls yet

         dempsy[0] = getDempsyFor(new ClusterId(FullApplication.class.getSimpleName(),FullApplication.MyAdaptor.class.getSimpleName()),ad);
         dempsy[0].setClusterSessionFactory(new ZookeeperSessionFactory("127.0.0.1:" + port,5000));

         dempsy[1] = getDempsyFor(new ClusterId(FullApplication.class.getSimpleName(),FullApplication.MyMp.class.getSimpleName()),ad);
View Full Code Here

   *
   * @throws Exception
   */
  @Test
  public void ifModifiedSinceHeader() throws Exception {
    final AtomicLong header = new AtomicLong();
    handler = new RequestHandler() {

      @Override
      public void handle(Request request, HttpServletResponse response) {
        response.setStatus(HTTP_OK);
        header.set(request.getDateHeader("If-Modified-Since"));
      }
    };
    assertTrue(get(url).ifModifiedSince(5000).ok());
    assertEquals(5000, header.get());
  }
View Full Code Here

      }
    };
    final File file = File.createTempFile("post", ".txt");
    new FileWriter(file).append("hello").close();

    final AtomicLong tx = new AtomicLong(0);
    UploadProgress progress = new UploadProgress() {
      public void onUpload(long transferred, long total) {
        assertEquals(file.length(), total);
        assertEquals(tx.incrementAndGet(), transferred);
      }
    };
    post(url).bufferSize(1).progress(progress).send(file).code();
    assertEquals(file.length(), tx.get());
  }
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.