/** * Empties the contents of the central queue into the outbound queue. */ private void consumeCentralQueue() { lock.lock(); try { checkForInputErrors(); // Wait until data is available. while (!((centralQueue.size() > 0) || inputComplete)) { waitForUpdate(); checkForInputErrors(); } outboundQueue.addAll(centralQueue); centralQueue.clear(); signalUpdate(); } finally { lock.unlock(); } }
/** * Empties the contents of the central queue into the outbound queue. */ private void consumeCentralQueue() { lock.lock(); try { checkForInputErrors(); // Wait until data is available. while (!((centralQueue.size() > 0) || inputComplete)) { waitForUpdate(); checkForInputErrors(); } outboundQueue.addAll(centralQueue); centralQueue.clear(); signalUpdate(); } finally { lock.unlock(); } }
/** * Adds a group of objects to the central queue ready for consumption by the * receiver. * * @param o * The objects to be added. */ private void populateCentralQueue() { lock.lock(); try { checkForOutputErrors(); // Wait until the currently posted data is cleared. while (centralQueue.size() >= bufferCapacity) { waitForUpdate(); checkForOutputErrors(); } // Post the new data. centralQueue.addAll(inboundQueue); inboundQueue.clear(); signalUpdate(); } finally { lock.unlock(); } }
/** * Adds a group of objects to the central queue ready for consumption by the * receiver. * * @param o * The objects to be added. */ private void populateCentralQueue() { lock.lock(); try { checkForOutputErrors(); // Wait until the currently posted data is cleared. while (centralQueue.size() >= bufferCapacity) { waitForUpdate(); checkForOutputErrors(); } // Post the new data. centralQueue.addAll(inboundQueue); inboundQueue.clear(); signalUpdate(); } finally { lock.unlock(); } }
/** * Notifies that the output thread has completed processing. This will block * until either the input thread has called complete, or an input error * occurs. */ public void outputComplete() { if (!outputInitialized) { throw new OsmosisRuntimeException("outputInitialize has not been called"); } lock.lock(); try { checkForInputErrors(); // We must wait until the input thread completes or encounters an // error. while (!inputComplete) { waitForUpdate(); checkForInputErrors(); } outputComplete = true; signalUpdate(); } finally { lock.unlock(); } }
/** * {@inheritDoc} */ @Override public void complete() { if (!inputInitialized) { throw new OsmosisRuntimeException("initialize has not been called"); } lock.lock(); try { populateCentralQueue(); inputComplete = true; signalUpdate(); // Now we must wait until the output thread completes or // encounters an error. while (!outputComplete) { waitForUpdate(); checkForOutputErrors(); } } finally { lock.unlock(); } }
/** * {@inheritDoc} */ @Override public void initialize(Map<String, Object> metaData) { if (inputInitialized) { throw new OsmosisRuntimeException("initialize has already been called"); } lock.lock(); try { checkForOutputErrors(); // Set the processing metadata, and flag that we have initialized. processingMetaData = metaData; inputInitialized = true; signalUpdate(); // Now we must wait until the output thread initializes or // encounters an error. while (!outputInitialized) { waitForUpdate(); checkForOutputErrors(); } } finally { lock.unlock(); } }
/** * Notifies that the output thread has begun processing, and gets the * initialization data set by the input thread. This will block until either * the input thread has called initialize, or an input error occurs. * * @return The initialization data. */ public Map<String, Object> outputInitialize() { if (outputInitialized) { throw new OsmosisRuntimeException("outputInitialize has already been called"); } lock.lock(); try { checkForInputErrors(); // We must wait until the input thread initializes or // encounters an error. while (!inputInitialized) { waitForUpdate(); checkForInputErrors(); } outputInitialized = true; signalUpdate(); return processingMetaData; } finally { lock.unlock(); } }
/** * {@inheritDoc} */ @Override public void initialize(Map<String, Object> metaData) { if (inputInitialized) { throw new OsmosisRuntimeException("initialize has already been called"); } lock.lock(); try { checkForOutputErrors(); // Set the processing metadata, and flag that we have initialized. processingMetaData = metaData; inputInitialized = true; signalUpdate(); // Now we must wait until the output thread initializes or // encounters an error. while (!outputInitialized) { waitForUpdate(); checkForOutputErrors(); } } finally { lock.unlock(); } }
/** * Notifies that the output thread has completed processing. This will block * until either the input thread has called complete, or an input error * occurs. */ public void outputComplete() { if (!outputInitialized) { throw new OsmosisRuntimeException("outputInitialize has not been called"); } lock.lock(); try { checkForInputErrors(); // We must wait until the input thread completes or encounters an // error. while (!inputComplete) { waitForUpdate(); checkForInputErrors(); } outputComplete = true; signalUpdate(); } finally { lock.unlock(); } }
/** * {@inheritDoc} */ @Override public void complete() { if (!inputInitialized) { throw new OsmosisRuntimeException("initialize has not been called"); } lock.lock(); try { populateCentralQueue(); inputComplete = true; signalUpdate(); // Now we must wait until the output thread completes or // encounters an error. while (!outputComplete) { waitForUpdate(); checkForOutputErrors(); } } finally { lock.unlock(); } }
/** * Notifies that the output thread has begun processing, and gets the * initialization data set by the input thread. This will block until either * the input thread has called initialize, or an input error occurs. * * @return The initialization data. */ public Map<String, Object> outputInitialize() { if (outputInitialized) { throw new OsmosisRuntimeException("outputInitialize has already been called"); } lock.lock(); try { checkForInputErrors(); // We must wait until the input thread initializes or // encounters an error. while (!inputInitialized) { waitForUpdate(); checkForInputErrors(); } outputInitialized = true; signalUpdate(); return processingMetaData; } finally { lock.unlock(); } }