Package java.util.concurrent.atomic

Examples of java.util.concurrent.atomic.AtomicLong


    this.comparatorIgnoreType = this.comparator.getComparatorIgnoringType();
    this.kvset = new KeyValueSkipListSet(c);
    this.snapshot = new KeyValueSkipListSet(c);
    timeRangeTracker = new TimeRangeTracker();
    snapshotTimeRangeTracker = new TimeRangeTracker();
    this.size = new AtomicLong(DEEP_OVERHEAD);
    if (conf.getBoolean(USEMSLAB_KEY, USEMSLAB_DEFAULT)) {
      this.allocator = new MemStoreLAB(conf);
    } else {
      this.allocator = null;
    }
View Full Code Here


    private TimeRangeTracker snapshotTimeRangeTracker;
    private AtomicLong flushedSize;

    private StoreFlusherImpl(long cacheFlushId) {
      this.cacheFlushId = cacheFlushId;
      this.flushedSize = new AtomicLong();
    }
View Full Code Here

    final AtomicInteger hfileArchiveCount = new AtomicInteger();
    final AtomicInteger hfilesMissing = new AtomicInteger();
    final AtomicInteger hfilesCount = new AtomicInteger();
    final AtomicInteger logsMissing = new AtomicInteger();
    final AtomicInteger logsCount = new AtomicInteger();
    final AtomicLong hfileArchiveSize = new AtomicLong();
    final AtomicLong hfileSize = new AtomicLong();
    final AtomicLong logSize = new AtomicLong();
    SnapshotReferenceUtil.visitReferencedFiles(fs, snapshotDir,
      new SnapshotReferenceUtil.FileVisitor() {
        public void storeFile (final String region, final String family, final String hfile)
            throws IOException {
          Path path = new Path(family, HFileLink.createHFileLinkName(table, region, hfile));
          HFileLink link = new HFileLink(conf, path);
          boolean inArchive = false;
          long size = -1;
          try {
            if ((inArchive = fs.exists(link.getArchivePath()))) {
              size = fs.getFileStatus(link.getArchivePath()).getLen();
              hfileArchiveSize.addAndGet(size);
              hfileArchiveCount.addAndGet(1);
            } else {
              size = link.getFileStatus(fs).getLen();
              hfileSize.addAndGet(size);
              hfilesCount.addAndGet(1);
            }
          } catch (FileNotFoundException e) {
            hfilesMissing.addAndGet(1);
          }

          if (showFiles) {
            System.out.printf("%8s %s/%s/%s/%s %s%n",
              (size < 0 ? "-" : StringUtils.humanReadableInt(size)),
              table, region, family, hfile,
              (inArchive ? "(archive)" : (size < 0) ? "(NOT FOUND)" : ""));
          }
        }

        public void recoveredEdits (final String region, final String logfile)
            throws IOException {
          Path path = SnapshotReferenceUtil.getRecoveredEdits(snapshotDir, region, logfile);
          long size = fs.getFileStatus(path).getLen();
          logSize.addAndGet(size);
          logsCount.addAndGet(1);

          if (showFiles) {
            System.out.printf("%8s recovered.edits %s on region %s%n",
              StringUtils.humanReadableInt(size), logfile, region);
          }
        }

        public void logFile (final String server, final String logfile)
            throws IOException {
          HLogLink logLink = new HLogLink(conf, server, logfile);
          long size = -1;
          try {
            size = logLink.getFileStatus(fs).getLen();
            logSize.addAndGet(size);
            logsCount.addAndGet(1);
          } catch (FileNotFoundException e) {
            logsMissing.addAndGet(1);
          }

          if (showFiles) {
            System.out.printf("%8s log %s on server %s %s%n",
              (size < 0 ? "-" : StringUtils.humanReadableInt(size)),
              logfile, server,
              (size < 0 ? "(NOT FOUND)" : ""));
          }
        }
    });

    // Dump the stats
    System.out.println();
    if (hfilesMissing.get() > 0 || logsMissing.get() > 0) {
      System.out.println("**************************************************************");
      System.out.printf("BAD SNAPSHOT: %d hfile(s) and %d log(s) missing.%n",
        hfilesMissing.get(), logsMissing.get());
      System.out.println("**************************************************************");
    }

    System.out.printf("%d HFiles (%d in archive), total size %s (%.2f%% %s shared with the source table)%n",
      hfilesCount.get() + hfileArchiveCount.get(), hfileArchiveCount.get(),
      StringUtils.humanReadableInt(hfileSize.get() + hfileArchiveSize.get()),
      ((float)hfileSize.get() / (hfileSize.get() + hfileArchiveSize.get())) * 100,
      StringUtils.humanReadableInt(hfileSize.get())
    );
    System.out.printf("%d Logs, total size %s%n",
      logsCount.get(), StringUtils.humanReadableInt(logSize.get()));
    System.out.println();
  }
View Full Code Here

    this.user = user;
    this.sinkCounter = sinkCounter;
    this.onIdleCallback = onIdleCallback;
    this.idleTimeout = idleTimeout;

    fileExtensionCounter = new AtomicLong(clock.currentTimeMillis());

    isOpen = false;
    writer.configure(context);
  }
View Full Code Here

  @Test
  public void testThreadedAppend() throws IOException, InterruptedException {
    int numThreads = 10;
    final CountDownLatch startLatch = new CountDownLatch(numThreads);
    final CountDownLatch stopLatch = new CountDownLatch(numThreads);
    final AtomicLong seqid = new AtomicLong(0);
    final List<String> globalExpected = Collections.synchronizedList(new ArrayList<String>());
    final List<Exception> errors = Collections.synchronizedList(new ArrayList<Exception>());
    for (int i = 0; i < numThreads; i++) {
      final int id = i;
      Thread t = new Thread() {
        @Override
        public void run() {
          try {
            List<String> expected = strings(100);
            globalExpected.addAll(expected);
            startLatch.countDown();
            startLatch.await();
            // half batch, half do not
            if(id % 2 == 0) {
              for(String s : expected) {
                wal.writeEntry(new WALEntry<Text>(new Text(s), seqid.incrementAndGet()));
              }
            } else {
              List<WALEntry<Text>> batch = Lists.newArrayList();
              for(String s : expected) {
                batch.add(new WALEntry<Text>(new Text(s), seqid.incrementAndGet()));
              }
              wal.writeEntries(batch);
            }
          } catch (Exception e) {
            logger.warn("Error doing appends", e);
View Full Code Here

    private final AtomicLong value;

    CachedFSUsableSpace(File fs, long interval) {
      this.fs = fs;
      this.interval = interval;
      this.value = new AtomicLong(fs.getUsableSpace());
      this.lastRefresh = new AtomicLong(System.currentTimeMillis());
    }
View Full Code Here

      }
    }
  }

  public WALReplayResult<T> replay() throws IOException {
    final AtomicLong sequenceID = new AtomicLong(0);
    final Map<String, Long> fileLargestSequenceIDMap = Maps.newHashMap();
    final AtomicLong totalBytes = new AtomicLong(0);
    // first get the total amount of data we have to read in
    readFiles(sequenceIDPath, new Function<File, Void>() {
      @Override
      public Void apply(File input) {
        totalBytes.addAndGet(input.length());
        return null;
      }
    });
    // then estimate the size of the array
    // needed to hold all the sequence ids
    int baseSize = WALEntry.getBaseSize();
    int numEntries = Math.max((int)((totalBytes.get() / baseSize) * 1.05f) + 1,
        numReplaySequenceIDOverride);
    LOG.info("Replay assumptions: baseSize = " + baseSize
        + ", estimatedNumEntries " + numEntries);
    final SequenceIDBuffer sequenceIDs = new SequenceIDBuffer(numEntries);

View Full Code Here

            client.start();
            client.getZookeeperClient().blockUntilConnectedOrTimedOut();

            final CountDownLatch latch = new CountDownLatch(TIMES);
            final List<Long> times = Lists.newArrayList();
            final AtomicLong start = new AtomicLong(System.currentTimeMillis());
            ((CuratorFrameworkImpl)client).debugListener = new CuratorFrameworkImpl.DebugBackgroundListener()
            {
                @Override
                public void listen(OperationAndData<?> data)
                {
                    if ( data.getOperation().getClass().getName().contains("CreateBuilderImpl") )
                    {
                        long now = System.currentTimeMillis();
                        times.add(now - start.get());
                        start.set(now);
                        latch.countDown();
                    }
                }
            };
View Full Code Here

    private TimeRangeTracker snapshotTimeRangeTracker;
    private AtomicLong flushedSize;

    private StoreFlusherImpl(long cacheFlushId) {
      this.cacheFlushId = cacheFlushId;
      this.flushedSize = new AtomicLong();
    }
View Full Code Here

   */
  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

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.