Examples of AtomicLong


Examples of java.util.concurrent.atomic.AtomicLong

   */
  public MetricsHistogram(final String nam, final MetricsRegistry registry,
      final String description, boolean forwardBiased) {
    super(nam, description);

    this.min = new AtomicLong();
    this.max = new AtomicLong();
    this.sum = new AtomicLong();
    this.sample = forwardBiased ?
        new ExponentiallyDecayingSample(DEFAULT_SAMPLE_SIZE, DEFAULT_ALPHA)
    : new UniformSample(DEFAULT_SAMPLE_SIZE);

    this.variance =  new AtomicReference<double[]>(new double[]{-1, 0});
    this.count = new AtomicLong();

    this.clear();

    if (registry != null) {
      registry.add(nam, this);     
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicLong

        this.label = FileOps.basename(filename) ;
        long filesize = file.size() ;               // This is not related to used file length in mapped mode.
        long longBlockSize = blockSize ;
           
        numFileBlocks = filesize/longBlockSize ;    // This is not related to used file length in mapped mode.
        seq = new AtomicLong(numFileBlocks) ;

        if ( numFileBlocks > Integer.MAX_VALUE )
            getLog().warn(format("File size (%d) exceeds tested block number limits (%d)", filesize, blockSize)) ;

        if ( filesize%longBlockSize != 0 )
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicLong

    @Override
    public Transaction newTransaction()
    {
        return new Transaction()
        {
            private AtomicLong _storeSizeIncrease = new AtomicLong();

            @Override
            public StoreFuture commitTranAsync() throws AMQStoreException
            {
                QuotaMessageStore.this.storedSizeChange(_storeSizeIncrease.intValue());
                return StoreFuture.IMMEDIATE_FUTURE;
            }

            @Override
            public void enqueueMessage(TransactionLogResource queue, EnqueableMessage message) throws AMQStoreException
            {
                _storeSizeIncrease.addAndGet(((MessageContentSource)message).getSize());
            }

            @Override
            public void dequeueMessage(TransactionLogResource  queue, EnqueableMessage message) throws AMQStoreException
            {
                _storeSizeIncrease.addAndGet(-((MessageContentSource)message).getSize());
            }

            @Override
            public void commitTran() throws AMQStoreException
            {
                QuotaMessageStore.this.storedSizeChange(_storeSizeIncrease.intValue());
            }

            @Override
            public void abortTran() throws AMQStoreException
            {
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicLong

    super(basedir, log, fs, conf, regionInfo, flushListener);
    indexManager = new IdxRegionIndexManager(this);
    expressionEvaluator = new IdxExpressionEvaluator();
    // monitoring parameters
    numberOfOngoingIndexedScans = new AtomicInteger(0);
    totalIndexedScans = new AtomicLong(0);
    totalNonIndexedScans = new AtomicLong(0);
    buildTimes = new long[INDEX_BUILD_TIME_HISTORY_SIZE];
    resetIndexBuildTimes();
  }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicLong

        }
    }

    private void startORM(boolean _disableMysql) {
        if (!_disableMysql) {
            CSDNStatFilterstat.setSQLTIME(new AtomicLong(0l));
        }
    }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicLong

        long index = 0;
        long indexSum = 0;
        final StructuredArrayOfAtomicLong.ElementIterator iter = array.iterator();
        while (iter.hasNext()) {
            final AtomicLong atomicLong = iter.next();
            indexSum += index++;
            assertThat(valueOf(atomicLong.get()), is(valueOf(indexSum)));
        }

        iter.reset();
        indexSum = index = 0;
        while (iter.hasNext()) {
            final AtomicLong atomicLong = iter.next();
            indexSum += index++;
            assertThat(valueOf(atomicLong.get()), is(valueOf(indexSum)));
        }

        assertThat(valueOf(index), is(valueOf(length)));
    }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicLong

        final Map<String, AtomicLong> added = new HashMap<String, AtomicLong>();
        final Map<String, AtomicLong> created = new HashMap<String, AtomicLong>();
        final Map<String, AtomicLong> finished = new HashMap<String, AtomicLong>();
        final List<String> topics = new ArrayList<String>();
        for(int i=0;i<NUM_ORDERED_TOPICS;i++) {
            added.put(ORDERED_TOPICS[i], new AtomicLong());
            created.put(ORDERED_TOPICS[i], new AtomicLong());
            finished.put(ORDERED_TOPICS[i], new AtomicLong());
            topics.add(ORDERED_TOPICS[i]);
        }
        for(int i=0;i<NUM_PARALLEL_TOPICS;i++) {
            added.put(PARALLEL_TOPICS[i], new AtomicLong());
            created.put(PARALLEL_TOPICS[i], new AtomicLong());
            finished.put(PARALLEL_TOPICS[i], new AtomicLong());
            topics.add(PARALLEL_TOPICS[i]);
        }
        for(int i=0;i<NUM_ROUND_TOPICS;i++) {
            added.put(ROUND_TOPICS[i], new AtomicLong());
            created.put(ROUND_TOPICS[i], new AtomicLong());
            finished.put(ROUND_TOPICS[i], new AtomicLong());
            topics.add(ROUND_TOPICS[i]);
        }

        final List<ServiceRegistration> registrations = new ArrayList<ServiceRegistration>();
        final List<Thread> threads = new ArrayList<Thread>();
        final AtomicLong finishedThreads = new AtomicLong();

        final ServiceRegistration eventHandler = this.registerEventHandler("org/apache/sling/event/notification/job/*",
                new EventHandler() {

                    @Override
                    public void handleEvent(final Event event) {
                        final String topic = (String) event.getProperty(NotificationConstants.NOTIFICATION_PROPERTY_JOB_TOPIC);
                        if ( NotificationConstants.TOPIC_JOB_FINISHED.equals(event.getTopic())) {
                            finished.get(topic).incrementAndGet();
                        } else if ( NotificationConstants.TOPIC_JOB_ADDED.equals(event.getTopic())) {
                            added.get(topic).incrementAndGet();
                        }
                    }
                });
        try {
            // setup job consumers
            this.setupJobConsumers(registrations);

            // setup job creation tests
            this.setupJobCreationThreads(threads, jobManager, created, finishedThreads);

            this.setupChaosThreads(threads, finishedThreads);

            System.out.println("Starting threads...");
            // start threads
            for(final Thread t : threads) {
                t.start();
            }

            System.out.println("Sleeping for " + DURATION + " seconds to wait for threads to finish...");
            // for sure we can sleep for the duration
            this.sleep(DURATION * 1000);

            System.out.println("Polling for threads to finish...");
            // wait until threads are finished
            while ( finishedThreads.get() < threads.size() ) {
                this.sleep(100);
            }

            System.out.println("Waiting for job handling to finish...");
            final Set<String> allTopics = new HashSet<String>(topics);
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicLong

    // removing a column
    int numThreads = 10;
    int opsPerThread = 500;
    AtomicOperation[] all = new AtomicOperation[numThreads];

    AtomicLong timeStamps = new AtomicLong(0);
    AtomicInteger failures = new AtomicInteger(0);
    // create all threads
    for (int i = 0; i < numThreads; i++) {
      all[i] = new AtomicOperation(region, opsPerThread, timeStamps, failures) {
        @Override
        public void run() {
          boolean op = true;
          for (int i=0; i<numOps; i++) {
            try {
              // throw in some flushes
              if (i%10==0) {
                synchronized(region) {
                  LOG.debug("flushing");
                  region.flushcache();
                  if (i%100==0) {
                    region.compactStores();
                  }
                }
              }
              long ts = timeStamps.incrementAndGet();
              RowMutations rm = new RowMutations(row);
              if (op) {
                Put p = new Put(row, ts);
                p.add(fam1, qual1, value1);
                rm.add(p);
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicLong

    // removing a column
    int numThreads = 10;
    int opsPerThread = 500;
    AtomicOperation[] all = new AtomicOperation[numThreads];

    AtomicLong timeStamps = new AtomicLong(0);
    AtomicInteger failures = new AtomicInteger(0);
    final List<byte[]> rowsToLock = Arrays.asList(row, row2);
    // create all threads
    for (int i = 0; i < numThreads; i++) {
      all[i] = new AtomicOperation(region, opsPerThread, timeStamps, failures) {
        @Override
        public void run() {
          boolean op = true;
          for (int i=0; i<numOps; i++) {
            try {
              // throw in some flushes
              if (i%10==0) {
                synchronized(region) {
                  LOG.debug("flushing");
                  region.flushcache();
                  if (i%100==0) {
                    region.compactStores();
                  }
                }
              }
              long ts = timeStamps.incrementAndGet();
              List<Mutation> mrm = new ArrayList<Mutation>();
              if (op) {
                Put p = new Put(row2, ts);
                p.add(fam1, qual1, value1);
                mrm.add(p);
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicLong

      CompactionDescriptor compactionDescriptor = ProtobufUtil.toCompactionDescriptor(this.region
          .getRegionInfo(), family, storeFiles, Lists.newArrayList(newFile), region
          .getRegionFileSystem().getStoreDir(Bytes.toString(family)));

      HLogUtil.writeCompactionMarker(region.getLog(), this.region.getTableDesc(),
          this.region.getRegionInfo(), compactionDescriptor, new AtomicLong(1));

      Path recoveredEditsDir = HLogUtil.getRegionDirRecoveredEditsDir(regiondir);

      Path recoveredEdits = new Path(recoveredEditsDir, String.format("%019d", 1000));
      fs.create(recoveredEdits);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.