List of usage examples for java.util.concurrent.atomic AtomicBoolean AtomicBoolean
public AtomicBoolean(boolean initialValue)
From source file:org.elasticsearch.client.sniff.SniffOnFailureListener.java
public SniffOnFailureListener() { this.set = new AtomicBoolean(false); }
From source file:com.civprod.writerstoolbox.apps.ToolSuite.java
public ToolSuite(boolean addOnly) { toolMap = org.apache.commons.collections4.MapUtils.synchronizedMap(new HashMap<>()); namedTools = org.apache.commons.collections4.MapUtils.synchronizedMap(new HashMap<>()); this.addOnly = new AtomicBoolean(addOnly); this.sealed = new AtomicBoolean(false); mParent = null;/*from w ww . j a v a 2 s . co m*/ myToolMapReadWriteLock = new ReadWriteConfigLock(); myNamedToolsReadWriteLock = new ReadWriteConfigLock(); myParentLock = new ReentrantReadWriteLock(false); }
From source file:br.com.ingenieux.mojo.jbake.WatchMojo.java
public void executeInternal() throws MojoExecutionException { reRender();//from www . j a va 2s . c o m Long lastProcessed = Long.valueOf(System.currentTimeMillis()); getLog().info("Now listening for changes on path " + inputDirectory.getPath()); initServer(); DirWatcher dirWatcher = null; try { dirWatcher = new DirWatcher(inputDirectory); final AtomicBoolean done = new AtomicBoolean(false); final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); (new Thread() { @Override public void run() { try { getLog().info("Running. Enter a blank line to finish. Anything else forces re-rendering."); while (true) { String line = reader.readLine(); if (isBlank(line)) { break; } reRender(); } } catch (Exception exc) { getLog().info("Ooops", exc); } finally { done.set(true); } } }).start(); dirWatcher.start(); do { Long result = dirWatcher.processEvents(); if (null == result) { // do nothing on purpose } else if (result >= lastProcessed) { getLog().info("Refreshing"); super.reRender(); lastProcessed = Long.valueOf(System.currentTimeMillis()); } } while (!done.get()); } catch (Exception exc) { getLog().info("Oops", exc); throw new MojoExecutionException("Oops", exc); } finally { getLog().info("Finishing"); if (null != dirWatcher) dirWatcher.stop(); stopServer(); } }
From source file:eagle.security.userprofile.impl.TimeWindowImpl.java
public TimeWindowImpl(Long startTimestamp, Long endTimestamp) { this.startTimestamp = startTimestamp; this.endTimestamp = endTimestamp; this.expired = new AtomicBoolean(false); this.safeWindowMs = 0l; }
From source file:net.sourceforge.ganttproject.io.CsvImportTest.java
public void testBasic() throws Exception { String header = "A, B"; String data = "a1, b1"; final AtomicBoolean wasCalled = new AtomicBoolean(false); GanttCSVOpen.RecordGroup recordGroup = new GanttCSVOpen.RecordGroup("AB", ImmutableSet.<String>of("A", "B")) { @Override/* w ww. j a va 2s.c om*/ protected boolean doProcess(CSVRecord record) { wasCalled.set(true); assertEquals("a1", record.get("A")); assertEquals("b1", record.get("B")); return true; } }; GanttCSVOpen importer = new GanttCSVOpen(createSupplier(Joiner.on('\n').join(header, data)), recordGroup); importer.load(); assertTrue(wasCalled.get()); // Now test with one empty line between header and data wasCalled.set(false); importer = new GanttCSVOpen(createSupplier(Joiner.on('\n').join(header, "", data)), recordGroup); importer.load(); assertTrue(wasCalled.get()); }
From source file:com.netflix.curator.TestSessionFailRetryLoop.java
@Test public void testRetry() throws Exception { Timing timing = new Timing(); final CuratorZookeeperClient client = new CuratorZookeeperClient(server.getConnectString(), timing.session(), timing.connection(), null, new RetryOneTime(1)); SessionFailRetryLoop retryLoop = client.newSessionFailRetryLoop(SessionFailRetryLoop.Mode.RETRY); retryLoop.start();//from w w w. ja v a 2 s. c om try { client.start(); final AtomicBoolean secondWasDone = new AtomicBoolean(false); final AtomicBoolean firstTime = new AtomicBoolean(true); while (retryLoop.shouldContinue()) { try { RetryLoop.callWithRetry(client, new Callable<Void>() { @Override public Void call() throws Exception { if (firstTime.compareAndSet(true, false)) { Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false)); KillSession.kill(client.getZooKeeper(), server.getConnectString()); client.getZooKeeper(); client.blockUntilConnectedOrTimedOut(); } Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false)); return null; } }); RetryLoop.callWithRetry(client, new Callable<Void>() { @Override public Void call() throws Exception { Assert.assertFalse(firstTime.get()); Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false)); secondWasDone.set(true); return null; } }); } catch (Exception e) { retryLoop.takeException(e); } } Assert.assertTrue(secondWasDone.get()); } finally { retryLoop.close(); IOUtils.closeQuietly(client); } }
From source file:com.comcast.viper.flume2storm.connection.receptor.EventReceptorStats.java
/** * Default constructor//w w w.ja va 2 s.c o m * * @param eventSenderId * The {@link EventSender} identifier */ public EventReceptorStats(String eventSenderId) { this.eventSenderId = eventSenderId; isConnected = new AtomicBoolean(false); nbEventsIn = new AtomicLong(); nbEventsQueued = new AtomicLong(); }
From source file:core.nipr.NiprClient.java
public void getNiprReports(Map<String, GregorianCalendar> aInDates, Map<String, LicenseInternal> aInOutLatestLicenses, Map<String, GregorianCalendar> aOutSuccessDates, StringBuilder aInOutErrors) { Map<String, LicenseInternal> lCurrentDayInfo = new HashMap<String, LicenseInternal>(); for (GregorianCalendar lCal : aInDates.values()) { String lFormattedDate = CalenderUtils.getFormattedDate(lCal); System.out.println("NiprClient: Get data for " + lFormattedDate); AtomicBoolean lSpecificFailure = new AtomicBoolean(false); lCurrentDayInfo = getSpecificReport(lCal, lSpecificFailure, aInOutErrors); if (lSpecificFailure.get()) { System.out.println("Nipr Sync for date " + lFormattedDate + " failed"); continue; }//ww w . j a va 2s.co m System.out.println("Nipr Sync for date " + lFormattedDate + " SUCCESS, generating CSV file"); // Generate a CSV for it. generateAndSendCsvFile(lFormattedDate, lCurrentDayInfo); // Previous Day is higher mergeReports(lCurrentDayInfo, aInOutLatestLicenses); GregorianCalendar lCalCopy = (GregorianCalendar) lCal.clone(); aOutSuccessDates.put(CalenderUtils.getFormattedDate(lCalCopy), lCalCopy); } }
From source file:biz.ganttproject.impex.csv.CsvImportTest.java
public void testBasic() throws Exception { String header = "A, B"; String data = "a1, b1"; final AtomicBoolean wasCalled = new AtomicBoolean(false); RecordGroup recordGroup = new RecordGroup("AB", ImmutableSet.<String>of("A", "B")) { @Override/*from w ww .ja v a 2s .co m*/ protected boolean doProcess(CSVRecord record) { if (!super.doProcess(record)) { return false; } wasCalled.set(true); assertEquals("a1", record.get("A")); assertEquals("b1", record.get("B")); return true; } }; GanttCSVOpen importer = new GanttCSVOpen(createSupplier(Joiner.on('\n').join(header, data)), recordGroup); importer.load(); assertTrue(wasCalled.get()); }
From source file:org.appcelerator.titanium.analytics.TiAnalyticsService.java
public TiAnalyticsService() { if (sending == null) { this.sending = new AtomicBoolean(false); } }