Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package me.prettyprint.cassandra.service;
  
  import java.util.Map;
  
 
Defines an operation performed on cassandra

Parameters:
<T> The result type of the operation (if it has a result), such as the result of get_count or get_column Oh closures, how I wish you were here...
 
 public abstract class Operation<T> {
   private static final Map<StringStringEMPTY_CREDENTIALS = Collections.emptyMap();

  
Counts failed attempts
 
   public final Counter failCounter;

  
The stopwatch used to measure operation performance
 
   public final String stopWatchTagName;
 
   
   public String keyspaceName;
 
   public Map<StringStringcredentials;
   
   protected T result;
   private HectorException exception;
   private long execTime;
   public final OperationType operationType;
   
   public Operation(OperationType operationType) {
     this. = operationType.equals(.) ? . :
       .;
     this. = operationType;
     this. = operationType.name();
   }
 
   public Operation(OperationType operationTypeMap<StringStringcredentials) {
     this(operationType.nullcredentials);
   }
   
   public Operation(OperationType operationTypeFailoverPolicy failoverPolicyString keyspaceNameMap<StringStringcredentials) {
     this. = operationType.equals(.) ? . :
       .;
     this. = operationType;
     this. = operationType.name();
     this. = failoverPolicy;
     this. = keyspaceName;
     this. = Collections.unmodifiableMap(credentials);
   }
   
   
   public void applyConnectionParams(String keyspaceConsistencyLevelPolicy consistencyLevelPolicy,
       FailoverPolicy failoverPolicyMap<String,Stringcredentials) {
     // TODO this is a first step. must be cleaned up.
     this. = keyspace;
     this. = consistencyLevelPolicy;
     this. = failoverPolicy;
     this. = credentials;
   }
 
   public void setResult(T executionResult) {
      = executionResult;
   }

  

Returns:
The result of the operation, if this is an operation that has a result (such as getColumn etc.
 
   public T getResult() {
     // TODO remove in favor of getExecutionResult
     return ;
   }
   
   public ExecutionResult<T> getExecutionResult() {
     return new ExecutionResult<T>();
   }

  
Performs the operation on the given cassandra instance.
 
   public abstract T execute(Cassandra.Client cassandrathrows HectorException;
 
   public void executeAndSetResult(Cassandra.Client cassandraCassandraHost cassandraHostthrows HectorException {
     this. = cassandraHost;
    long startTime = System.nanoTime();
    setResult(execute(cassandra));
     = System.nanoTime() - startTime;
  }
  public void setException(HectorException e) {
     = e;
  }
  public boolean hasException() {
    return  != null;
  }
    return ;
  }
  
    return this.;
  }
New to GrepCode? Check out our FAQ X