Esempio n. 1
0
  /** Validates the properties of the chosen cache pool. Throws on error. */
  public static void validateCachePool(
      THdfsCachingOp op, Long directiveId, TableName table, HdfsPartition partition)
      throws ImpalaRuntimeException {

    CacheDirectiveEntry entry = getDirective(directiveId);
    Preconditions.checkNotNull(entry);

    if (!op.getCache_pool_name().equals(entry.getInfo().getPool())) {
      throw new ImpalaRuntimeException(
          String.format(
              "Cannot cache partition in "
                  + "pool '%s' because it is already cached in '%s'. To change the cache "
                  + "pool for this partition, first uncache using: ALTER TABLE %s.%s "
                  + "%sSET UNCACHED",
              op.getCache_pool_name(),
              entry.getInfo().getPool(),
              table.getDb(),
              table,
              // Insert partition string if partition non null
              partition != null
                  ? String.format(
                      " PARTITION(%s) ", partition.getPartitionName().replaceAll("/", ", "))
                  : ""));
    }
  }
Esempio n. 2
0
  /**
   * Returns a boolean indicating if the given thrift caching operation would perform an update on
   * an already existing cache directive.
   */
  public static boolean isUpdateOp(THdfsCachingOp op, Map<String, String> params)
      throws ImpalaRuntimeException {

    Long directiveId = Long.parseLong(params.get(CACHE_DIR_ID_PROP_NAME));
    CacheDirectiveEntry entry = getDirective(directiveId);
    Preconditions.checkNotNull(entry);

    // Verify cache pool
    if (!op.getCache_pool_name().equals(entry.getInfo().getPool())) {
      return false;
    }

    // Check cache replication factor
    if ((op.isSetReplication() && op.getReplication() != entry.getInfo().getReplication())
        || (!op.isSetReplication()
            && entry.getInfo().getReplication()
                != JniCatalogConstants.HDFS_DEFAULT_CACHE_REPLICATION_FACTOR)) {
      return true;
    }
    return false;
  }
Esempio n. 3
0
 /** Helper method for frequent lookup of replication factor in the thrift caching structure. */
 public static short getReplicationOrDefault(THdfsCachingOp op) {
   return op.isSetReplication()
       ? op.getReplication()
       : JniCatalogConstants.HDFS_DEFAULT_CACHE_REPLICATION_FACTOR;
 }