Package org.hivedb

Examples of org.hivedb.HiveKeyNotFoundException


  }
 
  @SuppressWarnings("unchecked")
  public static<T extends Identifiable> void idIsPresentInList(Collection<T> collection, T item) {
    if(!IdentifiableUtils.isIdPresent((Collection<IdAndNameIdentifiable>)collection, (IdAndNameIdentifiable) item))
      throw new HiveKeyNotFoundException(
          String.format("Could not find %s with id %s", item.getClass().getSimpleName(), item.getId()), item);
  }
View Full Code Here


          String.format("This operation is invalid because the %s is currently set to status %s.", lockable.getClass().getSimpleName(), lockable.getStatus()));
    }
 
  public static void isNotEmpty(Collection c, String message) throws HiveKeyNotFoundException {
    if(c == null || c.size() == 0)
      throw new HiveKeyNotFoundException(message);
  }
View Full Code Here

  }

  private Collection<Integer> getNodeIdsOrThrow(Object primaryIndexKey) {
    final Collection<Integer> nodeIds = hive.directory().getNodeIdsOfPrimaryIndexKey(primaryIndexKey);
    if (nodeIds.size() == 0)
      throw new HiveKeyNotFoundException(String.format("Primary index key %s was not found on any nodes", primaryIndexKey));
    return nodeIds;
  }
View Full Code Here

  }
  public Resource getResource(String resourceName) {
    for (Resource resource : resources)
      if (resource.getName().equalsIgnoreCase(resourceName))
        return resource;
    throw new HiveKeyNotFoundException("Resource with name " + resourceName + " not found.", resourceName);
  }
View Full Code Here

    this.semaphore = semaphore;
  }

  public void deletePrimaryIndexKey(Object primaryIndexKey) throws HiveLockableException {
    if (!directory.doesPrimaryIndexKeyExist(primaryIndexKey))
      throw new HiveKeyNotFoundException("The primary index key " + primaryIndexKey
          + " does not exist", primaryIndexKey);
    Preconditions.isWritable(directory.getKeySemamphoresOfPrimaryIndexKey(primaryIndexKey), semaphore);
    directory.deletePrimaryIndexKey(primaryIndexKey);
  }
View Full Code Here

  public void deleteSecondaryIndexKey(String resource, String secondaryIndex, Object secondaryIndexKey, Object resourceId) throws HiveLockableException {
    SecondaryIndex index = getSecondaryIndex(resource, secondaryIndex);
    Preconditions.isWritable(directory.getKeySemaphoresOfResourceId(getResource(resource), resourceId), semaphore);
    if (!directory.doesSecondaryIndexKeyExist(index, secondaryIndexKey, resourceId))
      throw new HiveKeyNotFoundException(
          String.format(
              "Secondary index key %s of secondary index %s does not exist",
              secondaryIndexKey, index.getName()), secondaryIndexKey);

    directory.deleteSecondaryIndexKey(index, secondaryIndexKey, resourceId);
View Full Code Here

  @SuppressWarnings("unchecked")
  private <T> Collection<T> doRead(String sql, Object[] parameters, RowMapper mapper) {
    try {
      return (Collection<T>) getJdbcTemplate().query(sql, parameters, mapper);
    } catch (EmptyResultDataAccessException e) {
      throw new HiveKeyNotFoundException(String.format("Directory query returned no results. %s with parameters: %s", sql, parameters), e);
    }
  }
View Full Code Here

    Collection keys = doRead(
        sql.selectPrimaryIndexKeysOfResourceId(resource),
        new Object[]{id},
        RowMappers.newObjectRowMapper(resource.getPartitionDimension().getColumnType()));
    if (keys.size() == 0)
      throw new HiveKeyNotFoundException(String.format("Unable to find primary key for resource %s with id %s", resource.getName(), id), id);
    else if (keys.size() > 1)
      throw new DirectoryCorruptionException(String.format("Directory corruption: Resource %s with id %s is owned more than one primary key.", resource.getName(), id));
    return Atom.getFirstOrNull(keys);
  }
View Full Code Here

TOP

Related Classes of org.hivedb.HiveKeyNotFoundException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.