Author: jbellis Date: Wed Jul 14 13:51:31 2010 New Revision: 964048 URL: http://svn.apache.org/viewvc?rev=964048&view=rev Log: r/m unused code (and underscores) from AsyncResult. patch by jbellis
Modified: cassandra/trunk/src/java/org/apache/cassandra/net/AsyncResult.java cassandra/trunk/src/java/org/apache/cassandra/net/IAsyncResult.java cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java Modified: cassandra/trunk/src/java/org/apache/cassandra/net/AsyncResult.java URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/net/AsyncResult.java?rev=964048&r1=964047&r2=964048&view=diff ============================================================================== --- cassandra/trunk/src/java/org/apache/cassandra/net/AsyncResult.java (original) +++ cassandra/trunk/src/java/org/apache/cassandra/net/AsyncResult.java Wed Jul 14 13:51:31 2010 @@ -30,60 +30,31 @@ import org.slf4j.LoggerFactory; class AsyncResult implements IAsyncResult { - private static Logger logger_ = LoggerFactory.getLogger( AsyncResult.class ); - private byte[] result_; - private AtomicBoolean done_ = new AtomicBoolean(false); - private Lock lock_ = new ReentrantLock(); - private Condition condition_; - private long startTime_; + private static Logger logger = LoggerFactory.getLogger(AsyncResult.class); + private byte[] result; + private AtomicBoolean done = new AtomicBoolean(false); + private Lock lock = new ReentrantLock(); + private Condition condition; + private long startTime; public AsyncResult() { - condition_ = lock_.newCondition(); - startTime_ = System.currentTimeMillis(); + condition = lock.newCondition(); + startTime = System.currentTimeMillis(); } - - public byte[] get() - { - lock_.lock(); - try - { - if (!done_.get()) - { - condition_.await(); - } - } - catch (InterruptedException ex) - { - throw new AssertionError(ex); - } - finally - { - lock_.unlock(); - } - return result_; - } - - public boolean isDone() - { - return done_.get(); - } - + public byte[] get(long timeout, TimeUnit tu) throws TimeoutException { - lock_.lock(); + lock.lock(); try { boolean bVal = true; try { - if ( !done_.get() ) + if (!done.get()) { - long overall_timeout = timeout - (System.currentTimeMillis() - startTime_); - if(overall_timeout > 0) - bVal = condition_.await(overall_timeout, TimeUnit.MILLISECONDS); - else - bVal = false; + long overall_timeout = timeout - (System.currentTimeMillis() - startTime); + bVal = overall_timeout > 0 && condition.await(overall_timeout, TimeUnit.MILLISECONDS); } } catch (InterruptedException ex) @@ -91,33 +62,33 @@ class AsyncResult implements IAsyncResul throw new AssertionError(ex); } - if ( !bVal && !done_.get() ) + if (!bVal && !done.get()) { throw new TimeoutException("Operation timed out."); } } finally { - lock_.unlock(); + lock.unlock(); } - return result_; + return result; } public void result(Message response) { try { - lock_.lock(); - if ( !done_.get() ) + lock.lock(); + if (!done.get()) { - result_ = response.getMessageBody(); - done_.set(true); - condition_.signal(); + result = response.getMessageBody(); + done.set(true); + condition.signal(); } } finally { - lock_.unlock(); + lock.unlock(); } } } Modified: cassandra/trunk/src/java/org/apache/cassandra/net/IAsyncResult.java URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/net/IAsyncResult.java?rev=964048&r1=964047&r2=964048&view=diff ============================================================================== --- cassandra/trunk/src/java/org/apache/cassandra/net/IAsyncResult.java (original) +++ cassandra/trunk/src/java/org/apache/cassandra/net/IAsyncResult.java Wed Jul 14 13:51:31 2010 @@ -25,19 +25,6 @@ import java.util.concurrent.TimeoutExcep public interface IAsyncResult { /** - * This is used to check if the task has been completed - * - * @return true if the task has been completed and false otherwise. - */ - public boolean isDone(); - - /** - * Returns the result for the task that was submitted. - * @return the result wrapped in an Object[] - */ - public byte[] get(); - - /** * Same operation as the above get() but allows the calling * thread to specify a timeout. * @param timeout the maximum time to wait Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java?rev=964048&r1=964047&r2=964048&view=diff ============================================================================== --- cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java (original) +++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java Wed Jul 14 13:51:31 2010 @@ -594,7 +594,6 @@ public class StorageProxy implements Sto // an empty message acts as a request to the SchemaCheckVerbHandler. MessagingService.instance.sendRR(msg, liveHosts.toArray(new InetAddress[]{}), new IAsyncCallback() { - @Override public void response(Message msg) { // record the response from the remote node.