List of usage examples for java.util.concurrent.atomic AtomicBoolean AtomicBoolean
public AtomicBoolean(boolean initialValue)
From source file:cc.osint.graphd.client.handlers.ProtographClientResultHandler.java
public ProtographClientResultHandler() { hasExecuted = new AtomicBoolean(false); }
From source file:com.palantir.paxos.PaxosConsensusTestUtils.java
public static PaxosTestState setup(int numLeaders, int quorumSize) { List<LeaderElectionService> leaders = Lists.newArrayList(); List<PaxosAcceptor> acceptors = Lists.newArrayList(); List<PaxosLearner> learners = Lists.newArrayList(); List<AtomicBoolean> failureToggles = Lists.newArrayList(); Executor executor = PTExecutors.newCachedThreadPool(); RuntimeException e = new RuntimeException("mock server failure"); for (int i = 0; i < numLeaders; i++) { failureToggles.add(new AtomicBoolean(false)); PaxosLearner learner = PaxosLearnerImpl.newLearner(getLearnerLogDir(i)); learners.add(ToggleableExceptionProxy.newProxyInstance(PaxosLearner.class, learner, failureToggles.get(i), e)); PaxosAcceptor acceptor = PaxosAcceptorImpl.newAcceptor(getAcceptorLogDir(i)); acceptors.add(ToggleableExceptionProxy.newProxyInstance(PaxosAcceptor.class, acceptor, failureToggles.get(i), e)); }// www . j av a 2 s .c o m for (int i = 0; i < numLeaders; i++) { PaxosProposer proposer = PaxosProposerImpl.newProposer(learners.get(i), ImmutableList.<PaxosAcceptor>copyOf(acceptors), ImmutableList.<PaxosLearner>copyOf(learners), quorumSize, executor); PaxosLeaderElectionService leader = new PaxosLeaderElectionService(proposer, learners.get(i), ImmutableMap.<PingableLeader, HostAndPort>of(), ImmutableList.<PaxosAcceptor>copyOf(acceptors), ImmutableList.<PaxosLearner>copyOf(learners), executor, 0L, 0L, 0L); leaders.add(SimulatingFailingServerProxy.newProxyInstance(LeaderElectionService.class, leader, SERVER_DELAY_TIME_MS, failureToggles.get(i))); } return new PaxosTestState(leaders, acceptors, learners, failureToggles); }
From source file:name.abhijitsarkar.javaee.coffeehouse.spring.event.CoffeeHouseClosingEventListener.java
public CoffeeHouseClosingEventListener() { open = new AtomicBoolean(true); }
From source file:org.gradle.plugin.repository.internal.DefaultPluginRepositoryRegistry.java
public DefaultPluginRepositoryRegistry() { this.repositories = new ArrayList<PluginRepository>(); locked = new AtomicBoolean(false); portalAdded = new AtomicBoolean(false); }
From source file:com.grepcurl.random.WeightedCallableChooser.java
public WeightedCallableChooser(ObjectGenerator g) { _objectGenerator = g; _probabilitiesVerified = new AtomicBoolean(false); }
From source file:com.grepcurl.random.WeightedFunctionChooser.java
public WeightedFunctionChooser(ObjectGenerator g) { _objectGenerator = g; _probabilitiesVerified = new AtomicBoolean(false); }
From source file:Main.java
/** * Wraps an {@link ExecutorService} in such a way as to "protect" * it for calls to the {@link ExecutorService#shutdown()} or * {@link ExecutorService#shutdownNow()}. All other calls are delegated as-is * to the original service. <B>Note:</B> the exposed wrapped proxy will * answer correctly the {@link ExecutorService#isShutdown()} query if indeed * one of the {@code shutdown} methods was invoked. * * @param executorService The original service - ignored if {@code null} * @param shutdownOnExit If {@code true} then it is OK to shutdown the executor * so no wrapping takes place. * @return Either the original service or a wrapped one - depending on the * value of the <tt>shutdownOnExit</tt> parameter */// w ww.j a v a 2 s . c o m public static ExecutorService protectExecutorServiceShutdown(final ExecutorService executorService, boolean shutdownOnExit) { if (executorService == null || shutdownOnExit) { return executorService; } else { return (ExecutorService) Proxy.newProxyInstance(resolveDefaultClassLoader(executorService), new Class<?>[] { ExecutorService.class }, new InvocationHandler() { private final AtomicBoolean stopped = new AtomicBoolean(false); @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if ("isShutdown".equals(name)) { return stopped.get(); } else if ("shutdown".equals(name)) { stopped.set(true); return null; // void... } else if ("shutdownNow".equals(name)) { stopped.set(true); return Collections.emptyList(); } else { return method.invoke(executorService, args); } } }); } }
From source file:io.kazuki.v0.store.journal.PartitionInfoImpl.java
public PartitionInfoImpl(@JsonProperty("partitionId") String partitionId, @JsonProperty("minId") long minId, @JsonProperty("maxId") long maxId, @JsonProperty("size") long size, @JsonProperty("closed") boolean closed) { this.partitionId = partitionId; this.minId = minId; this.maxId = new AtomicLong(maxId); this.size = new AtomicLong(size); this.closed = new AtomicBoolean(closed); }
From source file:eagle.security.userprofile.impl.TimeWindowImpl.java
public TimeWindowImpl(Long startTimestamp, Long endTimestamp, Long safeWindowMs) { this.startTimestamp = startTimestamp; this.endTimestamp = endTimestamp; this.expired = new AtomicBoolean(false); this.safeWindowMs = safeWindowMs; }
From source file:com.frostwire.platform.FileSystemWalkTest.java
@Test public void testAnyFile() { final AtomicBoolean b = new AtomicBoolean(false); fs.walk(new File("any.txt"), new FileFilter() { @Override/*from www.ja v a 2s .co m*/ public boolean accept(File file) { return true; } @Override public void file(File file) { b.set(true); } }); assertFalse(b.get()); b.set(false); fs.walk(new File("any.txt"), new FileFilter() { @Override public boolean accept(File file) { return !file.isDirectory(); } @Override public void file(File file) { b.set(true); } }); assertFalse(b.get()); }