List of usage examples for java.util.concurrent.atomic AtomicInteger toString
public String toString()
From source file:Main.java
public static void main(String[] argv) throws Exception { AtomicInteger atomicInteger = new AtomicInteger(); System.out.println(atomicInteger.toString()); }
From source file:com.graphaware.importer.stats.LoggingStatisticsCollector.java
/** * Print (log) all the stats for a given category. * * @param category to print.//from w w w.j a va 2 s . co m */ protected void printCategory(String category) { Map<String, AtomicInteger> stats = counters.get(category); for (String statistic : stats.keySet()) { StringBuilder spaces = new StringBuilder(); AtomicInteger value = stats.get(statistic); int length = statistic.length() + value.toString().length(); while (length + spaces.length() < DIVIDER.length() - 1) { spaces.append(" "); } LOG.info(statistic + ":" + spaces + value.get()); } }
From source file:org.apache.hadoop.hbase.master.procedure.TestWALProcedureStoreOnHDFS.java
@Test(timeout = 60000) public void testWalAbortOnLowReplicationWithQueuedWriters() throws Exception { assertEquals(3, UTIL.getDFSCluster().getDataNodes().size()); store.registerListener(new ProcedureStore.ProcedureStoreListener() { @Override//from w w w. j a v a 2 s.c o m public void postSync() { Threads.sleepWithoutInterrupt(2000); } @Override public void abortProcess() { } }); final AtomicInteger reCount = new AtomicInteger(0); Thread[] thread = new Thread[store.getNumThreads() * 2 + 1]; for (int i = 0; i < thread.length; ++i) { final long procId = i + 1; thread[i] = new Thread() { public void run() { try { LOG.debug("[S] INSERT " + procId); store.insert(new TestProcedure(procId, -1), null); LOG.debug("[E] INSERT " + procId); } catch (RuntimeException e) { reCount.incrementAndGet(); LOG.debug("[F] INSERT " + procId + ": " + e.getMessage()); } } }; thread[i].start(); } Thread.sleep(1000); LOG.info("Stop DataNode"); UTIL.getDFSCluster().stopDataNode(0); assertEquals(2, UTIL.getDFSCluster().getDataNodes().size()); for (int i = 0; i < thread.length; ++i) { thread[i].join(); } assertFalse(store.isRunning()); assertTrue(reCount.toString(), reCount.get() >= store.getNumThreads() && reCount.get() < thread.length); }
From source file:ca.oson.json.Oson.java
private String atomicInteger2JsonDefault(FieldData objectDTO) { AtomicInteger valueToReturn = json2AtomicIntegerDefault(objectDTO); if (valueToReturn == null) { return null; }//from www .ja v a 2s . co m return valueToReturn.toString(); }