Package java.util.concurrent.atomic

Examples of java.util.concurrent.atomic.AtomicLong


    }
   
    public SolrChardingSelection(Method method, int dimension) {
        this.method = method;
        this.dimension = dimension;
        this.chardID = new AtomicLong(0);
    }
View Full Code Here


    public void inc(final E obj) {
        if (obj == null) return;

        // use atomic operations
        this.map.putIfAbsent(obj, new AtomicLong(0));
        this.map.get(obj).incrementAndGet();

        // increase overall counter
        this.gcount++;
    }
View Full Code Here

    public void dec(final E obj) {
        if (obj == null) return;

        // use atomic operations
        this.map.putIfAbsent(obj, new AtomicLong(0));
        this.map.get(obj).decrementAndGet();

        // increase overall counter
        this.gcount--;
    }
View Full Code Here

    public void set(final E obj, final int newScore) {
        if (obj == null) return;

        // use atomic operations
        this.map.putIfAbsent(obj, new AtomicLong(0));
        this.map.get(obj).set(newScore);

        // increase overall counter
        this.gcount += newScore;
    }
View Full Code Here

    public void inc(final E obj, final int incrementScore) {
        if (obj == null) return;

        // use atomic operations
        this.map.putIfAbsent(obj, new AtomicLong(0));
        this.map.get(obj).addAndGet(incrementScore);

        // increase overall counter
        this.gcount += incrementScore;
    }
View Full Code Here

    }

    public int delete(final E obj) {
        // deletes entry and returns previous score
        if (obj == null) return 0;
        final AtomicLong score = this.map.remove(obj);
        if (score == null) return 0;

        // decrease overall counter
        this.gcount -= score.intValue();
        return score.intValue();
    }
View Full Code Here

        return this.map.containsKey(obj);
    }

    public int get(final E obj) {
        if (obj == null) return 0;
        final AtomicLong score = this.map.get(obj);
        if (score == null) return 0;
        return score.intValue();
    }
View Full Code Here

    lQueryCount++;

    final String sConnection = getKey();

    AtomicInteger ai = chmQueryCount.get(sConnection);
    AtomicLong al = null;
    if (ai == null) {
      ai = new AtomicInteger(1);
      chmQueryCount.put(sConnection, ai);

      al = new AtomicLong(0);
      chmQueryTime.put(sConnection, al);
    } else {
      ai.incrementAndGet();

      al = chmQueryTime.get(sConnection);
    }

    if (al == null) {
      al = new AtomicLong(0);
      chmQueryTime.put(sConnection, al);
    }

    final String sStripPassword = sConnection.substring(0, sConnection.lastIndexOf('/'));
   
    if (this.rsRezultat != null) {
      try {
        this.rsRezultat.close();
      } catch (Throwable e) {
        // ignore this
      }

      this.rsRezultat = null;
    }

    if (this.stat != null) {
      try {
        this.stat.close();
      } catch (Throwable e) {
        // ignore this
      }

      this.stat = null;
    }

    this.bIsUpdate = false;
    this.iUpdateCount = -1;
    this.first = false;
   
    final long lStartTime = System.currentTimeMillis();

    if (!connect()) {
      try {
        throw new SQLException("connection failed"); //$NON-NLS-1$
      } catch (Exception e) {
        Log.log(Log.ERROR, "lazyj.DBFunctions", sStripPassword + " --> cannot connect for query because "+getConnectFailReason()+" : \n" + sQuery, e)//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
      }

      al.addAndGet(System.currentTimeMillis() - lStartTime);

      return false;
    }
   
    try {
      this.stat = this.dbc.getConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);

      if (this.stat.execute(sQuery, Statement.NO_GENERATED_KEYS)) {
        this.rsRezultat = this.stat.getResultSet();
      }
      else {
        this.bIsUpdate = true;
        this.iUpdateCount = this.stat.getUpdateCount();

        this.stat.close();
        this.stat = null;
      }

      if (!this.bIsUpdate) {
        this.first = true;
        try {
          if (!this.rsRezultat.next())
            this.first = false;
        } catch (Exception e) {
          this.first = false;
        }
      } else
        this.first = false;

      this.dbc.free();

      return true;
    } catch (Exception e) {
      this.rsRezultat = null;
      this.first = false;

      final String s = e.getMessage();

      if (!bIgnoreErrors && s.indexOf("duplicate key") < 0 && s.indexOf("drop table") < 0) {  //$NON-NLS-1$//$NON-NLS-2$
        Log.log(Log.ERROR, "lazyj.DBFunctions", sStripPassword + " --> Error executing '" + sQuery + "'", e)//$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
        // in case of an error, close the connection
        this.dbc.close();
      } else {
        // if the error is expected, or not fatal, silently free the connection for later
        // use
        this.dbc.free();
      }

      return false;
    } finally {
      al.addAndGet(System.currentTimeMillis() - lStartTime);
    }
  }
View Full Code Here

    // Many threads can update the state at the stamp at the same time
    private final AtomicLong stamp;
    private ServerName serverName;

    public RegionState() {
      this.stamp = new AtomicLong(System.currentTimeMillis());
    }
View Full Code Here

    }

    RegionState(HRegionInfo region, State state, long stamp, ServerName serverName) {
      this.region = region;
      this.state = state;
      this.stamp = new AtomicLong(stamp);
      this.serverName = serverName;
    }
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.