Examples of AtomicLong


Examples of java.util.concurrent.atomic.AtomicLong

   }


   protected void incrementMethodCount(String httpMethod)
   {
      AtomicLong stat = stats.get(httpMethod);
      if (stat == null)
      {
         stat = new AtomicLong();
         AtomicLong old = stats.putIfAbsent(httpMethod, stat);
         if (old != null) stat = old;
      }
      stat.incrementAndGet();
   }
View Full Code Here

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

Examples of java.util.concurrent.atomic.AtomicLong

    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

Examples of java.util.concurrent.atomic.AtomicLong

    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

Examples of java.util.concurrent.atomic.AtomicLong

    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

Examples of java.util.concurrent.atomic.AtomicLong

    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

Examples of java.util.concurrent.atomic.AtomicLong

    }

    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

Examples of java.util.concurrent.atomic.AtomicLong

        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

Examples of java.util.concurrent.atomic.AtomicLong

    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

Examples of java.util.concurrent.atomic.AtomicLong

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