Example usage for java.util.concurrent.atomic AtomicBoolean AtomicBoolean

List of usage examples for java.util.concurrent.atomic AtomicBoolean AtomicBoolean

Introduction

In this page you can find the example usage for java.util.concurrent.atomic AtomicBoolean AtomicBoolean.

Prototype

public AtomicBoolean(boolean initialValue) 

Source Link

Document

Creates a new AtomicBoolean with the given initial value.

Usage

From source file:kn.uni.gis.foxhunt.context.GameContext.java

public static boolean isGameActive() {
    final AtomicBoolean bool = new AtomicBoolean(false);
    HttpContext.getInstance().get(currentGame.getGameUrl().toString(), new EntityHandlerAdapter() {
        @Override/* w  w  w. jav a  2 s  . c  om*/
        public void handleEntity(HttpEntity entity, int statusCode) {
            bool.set(statusCode == HttpStatus.SC_OK);
        }
    });

    return bool.get();
}

From source file:ch.algotrader.adapter.ib.IBSession.java

public IBSession(final int clientId, final String host, final int port,
        final IBSessionStateHolder sessionStateHolder, final AbstractIBMessageHandler messageHandler) {

    super(messageHandler);

    Validate.notNull(host, "host may not be null");
    Validate.isTrue(port != 0, "port may not be 0");
    Validate.notNull(sessionStateHolder, "IBSessionStateHolder is null");

    this.clientId = clientId;
    this.host = host;
    this.port = port;
    this.sessionStateHolder = sessionStateHolder;
    this.terminated = new AtomicBoolean(false);
}

From source file:org.springframework.social.twitter.api.impl.StreamDispatcher.java

public StreamDispatcher(Queue<String> queue, List<StreamListener> listeners) {
    this.queue = queue;
    this.listeners = listeners;
    pool = Executors.newCachedThreadPool();
    objectMapper = new ObjectMapper();
    objectMapper.addMixInAnnotations(Tweet.class, TweetMixin.class);
    objectMapper.addMixInAnnotations(StreamDeleteEvent.class, StreamDeleteEventMixin.class);
    objectMapper.addMixInAnnotations(StreamWarningEvent.class, StreamWarningEventMixin.class);
    objectMapper.addMixInAnnotations(StreamEvent.class, StreamEventMixin.class);
    objectMapper.addMixInAnnotations(DirectMessage.class, DirectMessageMixin.class);
    objectMapper.addMixInAnnotations(TwitterProfile.class, TwitterProfileMixin.class);
    active = new AtomicBoolean(true);
}

From source file:org.killbill.queue.DefaultQueueLifecycle.java

public DefaultQueueLifecycle(final String svcQName, final Executor executor, final int nbThreads,
        final PersistentQueueConfig config, final ObjectMapper objectMapper) {
    this.executor = executor;
    this.nbThreads = nbThreads;
    this.svcQName = svcQName;
    this.config = config;
    this.isProcessingEvents = false;
    this.curActiveThreads = 0;
    this.isProcessingSuspended = new AtomicBoolean(false);
    this.objectMapper = objectMapper;
}

From source file:com.github.brandtg.switchboard.FileLogAggregator.java

/**
 * An agent that aggregates logs from multiple sources and multiplexes them.
 *
 * @param sources//from  w  ww .  j a va 2 s  . c  o m
 *  A set of source switchboard servers from which to pull logs
 * @param separator
 *  The line delimiter (after this is reached, lines will be output to outputStream)
 * @param outputStream
 *  OutputStream to which all multiplexed logs are piped
 */
public FileLogAggregator(Set<InetSocketAddress> sources, char separator, OutputStream outputStream)
        throws IOException {
    this.separator = separator;
    this.outputStream = outputStream;
    this.isShutdown = new AtomicBoolean(true);
    this.eventExecutors = new NioEventLoopGroup();
    this.logReceivers = new HashMap<>();
    this.inputStreams = new HashMap<>();
    this.listener = new Object();
    this.muxExecutor = Executors.newSingleThreadExecutor();
    this.stringBuffers = new HashMap<>();

    for (InetSocketAddress source : sources) {
        PipedOutputStream pos = new PipedOutputStream();
        PipedInputStream pis = new PipedInputStream(pos);
        LogReceiver logReceiver = new LogReceiver(new InetSocketAddress(0), eventExecutors, pos);
        logReceiver.registerListener(listener);
        logReceivers.put(source, logReceiver);
        inputStreams.put(source, pis);
        stringBuffers.put(source, new StringBuffer());
    }
}

From source file:com.github.brandtg.switchboard.MysqlReplicationApplier.java

/**
 * Applies a stream of MySQL binary log events to a MySQL instance.
 *
 * @param inputStream/* w  w  w .  ja v a  2  s  .c  o  m*/
 *  An input stream containing raw MySQL binary log.
 * @param dataSource
 *  A data source for the database to which replicated events are to be applied.
 */
public MysqlReplicationApplier(InputStream inputStream, DataSource dataSource) {
    this.inputStream = inputStream;
    this.dataSource = dataSource;
    this.isShutdown = new AtomicBoolean(false);
}

From source file:com.baidu.oped.apm.profiler.sender.UdpDataSenderTest.java

private boolean sendMessage_getLimit(TBase tbase) throws InterruptedException {
    final AtomicBoolean limitCounter = new AtomicBoolean(false);
    final CountDownLatch latch = new CountDownLatch(1);

    UdpDataSender sender = new UdpDataSender("localhost", 9009, "test", 128, 1000, 1024 * 64 * 100) {
        @Override/*from   w w  w  .j  av  a 2s . c  om*/
        protected boolean isLimit(int interBufferSize) {
            boolean limit = super.isLimit(interBufferSize);
            limitCounter.set(limit);
            latch.countDown();
            return limit;
        }
    };
    try {
        sender.send(tbase);
        latch.await(5000, TimeUnit.MILLISECONDS);
    } finally {
        sender.stop();
    }
    return limitCounter.get();
}

From source file:com.github.brandtg.pantopod.consumer.PantopodKafkaConsumer.java

public PantopodKafkaConsumer(String zkConnectionString, String kafkaBrokerList, String kafkaGroupId,
        String kafkaTopic, ExecutorService executorService, PantopodEventHandler eventHandler, String uriChroot,
        String startPage) {//w ww.j  a  va  2 s. co m
    this.zkConnectionString = zkConnectionString;
    this.kafkaGroupId = kafkaGroupId;
    this.kafkaTopic = kafkaTopic;
    this.uriChroot = uriChroot;
    this.startPage = startPage;
    this.kafkaBrokerList = kafkaBrokerList;
    this.executorService = executorService;
    this.eventHandler = eventHandler;
    this.isRunning = new AtomicBoolean(false);
}

From source file:edu.iu.dymoro.Scheduler.java

public Scheduler(int numRowSplits, int numColSplits, Int2ObjectOpenHashMap<D>[] vWHMap, long time,
        List<T> tasks) {/*ww  w  . j  av a 2s .  c  o  m*/
    rowCount = new int[numRowSplits];
    this.numRowSplits = numRowSplits;
    numRowLimit = numColSplits;
    freeRow = new int[numRowSplits];
    numFreeRows = 0;
    colCount = new int[numColSplits];
    this.numColSplits = numColSplits;
    numColLimit = numRowSplits;
    freeCol = new int[numColSplits];
    numFreeCols = 0;
    splitMap = new byte[numRowSplits][numColSplits];
    numItemsTrained = 0L;
    this.vWHMap = vWHMap;

    this.time = time;
    this.timer = new Timer();
    random = new Random(System.currentTimeMillis());
    isRunning = new AtomicBoolean(true);
    compute = new DynamicScheduler<>(tasks);
    compute.start();
}

From source file:com.mattc.argus.concurrent.ZipProcess.java

public ZipProcess(File zipFile, File destDir) {
    if (!zipFile.exists())
        throw new IllegalArgumentException("The desired ZipFile Does Not Exist");
    if (!destDir.exists()) {
        destDir.mkdirs();//from   www  .  j a va 2 s  .c  om
    }

    //Get Buffer Size and Create Byte Buffer
    BUFFER_SIZE = 8192; //Standard Cache Size
    buffer = new byte[BUFFER_SIZE];
    this.destDir = destDir;
    this.zipFile = zipFile;

    running = new AtomicBoolean(false);
}