예제 #1
0
 /**
  * Given an Object value, pick a partition to store the data. Currently only String objects can be
  * hashed.
  *
  * @param value The value to hash.
  * @param partitionCount The number of partitions to choose from.
  * @return A value between 0 and partitionCount-1, hopefully pretty evenly distributed.
  */
 static int hashinate(Object value, int partitionCount) {
   if (value instanceof String) {
     String string = (String) value;
     try {
       byte bytes[] = string.getBytes("UTF-8");
       int hashCode = 0;
       int offset = 0;
       for (int ii = 0; ii < bytes.length; ii++) {
         hashCode = 31 * hashCode + bytes[offset++];
       }
       return java.lang.Math.abs(hashCode % partitionCount);
     } catch (UnsupportedEncodingException e) {
       hostLogger.l7dlog(
           Level.FATAL,
           LogKeys.host_TheHashinator_ExceptionHashingString.name(),
           new Object[] {string},
           e);
       HStore.crashDB();
     }
   }
   hostLogger.l7dlog(
       Level.FATAL,
       LogKeys.host_TheHashinator_AttemptedToHashinateNonLongOrString.name(),
       new Object[] {value.getClass().getName()},
       null);
   HStore.crashDB();
   return -1;
 }
  @Override
  protected void setUp() throws Exception {
    super.setUp(ProjectType.TPCC);
    addPartitions(NUM_PARTITONS);

    Site catalog_site = CollectionUtil.first(CatalogUtil.getCluster(catalog).getSites());
    assertNotNull(catalog_site);
    hstore_site = HStore.initialize(catalog_site, HStoreConf.singleton());
    for (int p = 0; p < NUM_PARTITONS; p++) {
      PartitionExecutor site = new MockPartitionExecutor(p, catalog, p_estimator);
      hstore_site.addPartitionExecutor(p, site);
    } // FOR

    this.queue = new TransactionQueueManager(hstore_site);
  }
예제 #3
0
 @Override
 public void faultOccured(VoltFault fault) {
   System.err.println("Unrecoverable fault occured: " + fault.toString());
   HStore.crashDB();
 }