下面列出了java.util.concurrent.atomic.LongAdder#longValue() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected Acquire tryAcquireRequest() {
if (cache == null) {
return Acquire.SUCCESS;
}
try {
LongAdder times = cache.get(System.currentTimeMillis() / 1000, LongAdder::new);
if (limiterConfig.getRatePermit() > times.longValue()) {
return Acquire.SUCCESS;
}
} catch (Exception e) {
log.error("The try acquire memory rate limiter is exception", e);
return Acquire.EXCEPTION;
}
return Acquire.FAILURE;
}
static void testLongAdder() {
LongAdder a = new LongAdder();
a.add(45);
LongAdder result = echo(a);
if (result.longValue() != a.longValue())
throw new RuntimeException("Unexpected longValue");
checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}
static void testLongAdder() {
LongAdder a = new LongAdder();
a.add(45);
LongAdder result = echo(a);
if (result.longValue() != a.longValue())
throw new RuntimeException("Unexpected longValue");
checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}
static void testLongAdder() {
LongAdder a = new LongAdder();
a.add(45);
LongAdder result = echo(a);
if (result.longValue() != a.longValue())
throw new RuntimeException("Unexpected longValue");
checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}
static void testLongAdder() {
LongAdder a = new LongAdder();
a.add(45);
LongAdder result = echo(a);
if (result.longValue() != a.longValue())
throw new RuntimeException("Unexpected longValue");
checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}
static void testLongAdder() {
LongAdder a = new LongAdder();
a.add(45);
LongAdder result = echo(a);
if (result.longValue() != a.longValue())
throw new RuntimeException("Unexpected longValue");
checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}
static void testLongAdder() {
LongAdder a = new LongAdder();
a.add(45);
LongAdder result = echo(a);
if (result.longValue() != a.longValue())
throw new RuntimeException("Unexpected longValue");
checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}
static void testLongAdder() {
LongAdder a = new LongAdder();
a.add(45);
LongAdder result = echo(a);
if (result.longValue() != a.longValue())
throw new RuntimeException("Unexpected longValue");
checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}
static void testLongAdder() {
LongAdder a = new LongAdder();
a.add(45);
LongAdder result = echo(a);
if (result.longValue() != a.longValue())
throw new RuntimeException("Unexpected longValue");
checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}
static void testLongAdder() {
LongAdder a = new LongAdder();
a.add(45);
LongAdder result = echo(a);
if (result.longValue() != a.longValue())
throw new RuntimeException("Unexpected longValue");
checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}
static void testLongAdder() {
LongAdder a = new LongAdder();
a.add(45);
LongAdder result = echo(a);
if (result.longValue() != a.longValue())
throw new RuntimeException("Unexpected longValue");
checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}
static void testLongAdder() {
LongAdder a = new LongAdder();
a.add(45);
LongAdder result = echo(a);
if (result.longValue() != a.longValue())
throw new RuntimeException("Unexpected longValue");
checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}
static void testLongAdder() {
LongAdder a = new LongAdder();
a.add(45);
LongAdder result = echo(a);
if (result.longValue() != a.longValue())
throw new RuntimeException("Unexpected longValue");
checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}
static void testLongAdder() {
LongAdder a = new LongAdder();
a.add(45);
LongAdder result = echo(a);
if (result.longValue() != a.longValue())
throw new RuntimeException("Unexpected longValue");
checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}
static void testLongAdder() {
LongAdder a = new LongAdder();
a.add(45);
LongAdder result = echo(a);
if (result.longValue() != a.longValue())
throw new RuntimeException("Unexpected longValue");
checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}
@Override
public long getPrefixedReceivedCount(final TablesKey tablesKey) {
final LongAdder counter = this.prefixesReceived.get(tablesKey);
if (counter == null) {
return 0;
}
return counter.longValue();
}
@Override
public long getPrefixedInstalledCount(final TablesKey tablesKey) {
final LongAdder counter = this.prefixesInstalled.get(tablesKey);
if (counter == null) {
return 0;
}
return counter.longValue();
}
@Override
public long getCurrentSession(Transport transport) {
LongAdder counter = transportCounter.get(transport.getId());
return counter == null ? 0 : counter.longValue();
}
public void mergeRegions(String tblName, int targetRegions) throws Exception {
TableName table = TableName.valueOf(tblName);
Path tableDir = getTablePath(table);
try(Connection conn = ConnectionFactory.createConnection(conf)) {
Admin admin = conn.getAdmin();
LongAdder counter = new LongAdder();
LongAdder lastTimeProgessed = new LongAdder();
//need to get all regions for the table, regardless of region state
List<RegionInfo> regions = admin.getRegions(table);
Map<Future, Pair<RegionInfo, RegionInfo>> regionsMerging = new ConcurrentHashMap<>();
long roundsNoProgress = 0;
while (regions.size() > targetRegions) {
LOG.info("Iteration: {}", counter);
RegionInfo previous = null;
int regionSize = regions.size();
LOG.info("Attempting to merge {} regions to reach the target {} ...", regionSize, targetRegions);
//to request merge, regions must be OPEN, though
regions = getOpenRegions(conn, table);
for (RegionInfo current : regions) {
if (!current.isSplit()) {
if (previous != null && canMerge(tableDir, previous, current, regionsMerging.values())) {
Future f = admin.mergeRegionsAsync(current.getEncodedNameAsBytes(),
previous.getEncodedNameAsBytes(), true);
Pair<RegionInfo, RegionInfo> regionPair = new Pair<>(previous, current);
regionsMerging.put(f,regionPair);
previous = null;
if ((regionSize - regionsMerging.size()) <= targetRegions) {
break;
}
} else {
previous = current;
}
}
else{
LOG.debug("Skipping split region: {}", current.getEncodedName());
}
}
counter.increment();
LOG.info("Sleeping for {} seconds before next iteration...", (sleepBetweenCycles/1000));
Thread.sleep(sleepBetweenCycles);
regionsMerging.forEach((f, currentPair)-> {
if (f.isDone()) {
LOG.info("Merged regions {} and {} together.",
currentPair.getFirst().getEncodedName(),
currentPair.getSecond().getEncodedName());
regionsMerging.remove(f);
lastTimeProgessed.reset();
lastTimeProgessed.add(counter.longValue());
} else {
LOG.warn("Merge of regions {} and {} isn't completed yet.",
currentPair.getFirst(),
currentPair.getSecond());
}
});
roundsNoProgress = counter.longValue() - lastTimeProgessed.longValue();
if(roundsNoProgress == this.maxRoundsStuck){
LOG.warn("Reached {} iterations without progressing with new merges. Aborting...",
roundsNoProgress);
break;
}
//again, get all regions, regardless of the state,
// in order to avoid breaking the loop prematurely
regions = admin.getRegions(table);
}
}
}
private long getAndReset(LongAdder longAdder) {
long result = longAdder.longValue();
longAdder.add(-result);
return result;
}