/** * @see stream.io.Barrel#clear() */ @Override public int clear() { for (SnappyBlockingQueue queue : queues.values()) { queue.clear(); } return -1; }
/** * @see stream.io.QueueService#enqueue(stream.Data) */ private boolean insert(Data item) { // insert dataItem data[head] = item; head = inc(head); ++count; // if (!readSnap) notEmpty.signal(); else if (conditionReadNotSnap()) { readSnap = false; notEmpty.signal(); } return true; }
/** * @see stream.io.Sink#write(stream.Data) */ @Override public boolean write(Data item) throws Exception { log.trace("Queue {}: Enqueuing event {}", getId(), item); if (item == null) throw new NullPointerException(); if (closed) return false; final ReentrantLock lock = this.lock; lock.lockInterruptibly(); try { while (conditionWriteSnap()) { writeSnap = true; notFull.await(); } return insert(item); } finally { lock.unlock(); } }
if (queue != null) { try { queue.write(data); } catch (Exception e) { e.printStackTrace();
/** * @see stream.io.Source#init() */ @Override public void init() throws Exception { if (getCapacity() < 1) throw new IllegalArgumentException("Invalid queue-capacity '" + getCapacity() + "'!"); if (index == null || index.isEmpty()) throw new IllegalArgumentException("Index is not specified"); if (streams == null || streams.size() == 0) throw new IllegalArgumentException("Index is not specified"); if (sync == null || sync.isEmpty()) throw new IllegalArgumentException("Index is not specified"); for (String unit : streams) { queues.put(unit, new SnappyBlockingQueue(capacity)); } reads = streams.size(); readQueue = new String[reads]; dataQueue = new Data[reads]; accs = new long[reads]; int j = 0; for (String unit : streams) { readQueue[j] = unit; j++; } }
dataQueue[i] = queues.get(readQueue[i]).read(); Serializable s = dataQueue[i].get(index); if (s != null && s instanceof Long) {
private Data extract() { final Data[] data = this.data; Data item = data[last]; data[last] = null; last = inc(last); --count; log.trace("last: {}", last); log.trace("take size: {}", count); log.trace("took item from queue: {}", item); if (!writeSnap) notFull.signal(); else if (conditionWriteSnap()) { writeSnap = false; notFull.signal(); // log.info("changed state"); } return item; }
/** * @see stream.io.Source#init() */ @Override public void init() throws Exception { if (getCapacity() < 1) { throw new IllegalArgumentException("Invalid queue-capacity '" + getCapacity() + "'!"); } }
/** * @see stream.io.Stream#close() */ public void close() throws Exception { log.debug("Closing queue '{}'...", getId()); lock.lockInterruptibly(); try { if (closed) { log.debug("Queue '{}' already closed.", getId()); return; } // log.debug("queue: {}", queue); closed = true; } finally { lock.unlock(); } }
if (queue != null) { try { queue.write(data); } catch (Exception e) { e.printStackTrace();
/** * @see stream.io.Source#init() */ @Override public void init() throws Exception { if (getCapacity() < 1) throw new IllegalArgumentException("Invalid queue-capacity '" + getCapacity() + "'!"); if (index == null || index.isEmpty()) throw new IllegalArgumentException("Index is not specified"); if (streams == null || streams.size() == 0) throw new IllegalArgumentException("Index is not specified"); if (sync == null || sync.isEmpty()) throw new IllegalArgumentException("Index is not specified"); for (String unit : streams) { queues.put(unit, new SnappyBlockingQueue(capacity)); } reads = streams.size(); readQueue = new String[reads]; dataQueue = new Data[reads]; accs = new long[reads]; int j = 0; for (String unit : streams) { readQueue[j] = unit; j++; } }
dataQueue[i] = queues.get(readQueue[i]).read(); Serializable s = dataQueue[i].get(index); if (s != null && s instanceof Long) {
/** * @see stream.io.Barrel#clear() */ @Override public int clear() { for (SnappyBlockingQueue queue : queues.values()) { queue.clear(); } return -1; }