示例#1
0
  /**
   * Constructor
   *
   * @param executor
   */
  public AbstractTransaction(HStoreSite hstore_site) {
    this.hstore_site = hstore_site;
    int numPartitions = hstore_site.getCatalogContext().numberOfPartitions;

    this.released = new boolean[numPartitions];
    this.prepared = new boolean[numPartitions];
    this.finished = new boolean[numPartitions];
    this.round_state = new RoundState[numPartitions];
    this.round_ctr = new int[numPartitions];
    this.exec_readOnly = new boolean[numPartitions];
    this.exec_queueWork = new boolean[numPartitions];
    this.exec_eeWork = new boolean[numPartitions];

    this.exec_firstUndoToken = new long[numPartitions];
    this.exec_lastUndoToken = new long[numPartitions];
    this.exec_noUndoBuffer = new boolean[numPartitions];

    this.init_task = new InitializeTxnMessage(this);

    this.readTables = new boolean[numPartitions][];
    this.writeTables = new boolean[numPartitions][];

    Arrays.fill(this.exec_firstUndoToken, HStoreConstants.NULL_UNDO_LOGGING_TOKEN);
    Arrays.fill(this.exec_lastUndoToken, HStoreConstants.NULL_UNDO_LOGGING_TOKEN);
    Arrays.fill(this.exec_readOnly, true);
    Arrays.fill(this.exec_queueWork, false);
    Arrays.fill(this.exec_eeWork, false);
  }
示例#2
0
 /**
  * Mark that this txn has executed a modifying query for the tableIds at the given partition.
  * <B>Note:</B> This is just tracking that we executed a query. It does not necessarily mean that
  * the query actually changed anything.
  *
  * @param partition
  * @param tableIds
  */
 public final void markTableIdsAsWritten(int partition, int... tableIds) {
   if (this.writeTables[partition] == null) {
     this.writeTables[partition] = new boolean[hstore_site.getCatalogContext().numberOfTables + 1];
   }
   for (int id : tableIds) {
     this.writeTables[partition][id] = true;
   } // FOR
 }
示例#3
0
 public final WorkFragmentMessage getWorkFragmentMessage(WorkFragment fragment) {
   if (this.work_task == null) {
     this.work_task = new WorkFragmentMessage[hstore_site.getCatalogContext().numberOfPartitions];
   }
   int partition = fragment.getPartitionId();
   if (this.work_task[partition] == null) {
     this.work_task[partition] = new WorkFragmentMessage(this, fragment);
   } else {
     this.work_task[partition].setFragment(fragment);
   }
   return (this.work_task[partition]);
 }
  /**
   * Send a copy of a single message request to the partitions given as input If a partition is
   * managed by the local HStoreSite, then we will invoke the sendLocal() method. If it is on a
   * remote HStoreSite, then we will invoke sendRemote().
   *
   * @param ts
   * @param request
   * @param callback
   * @param partitions
   */
  public void sendMessages(
      LocalTransaction ts, T request, RpcCallback<U> callback, PartitionSet partitions) {
    // If this flag is true, then we'll invoke the local method
    // We want to do this *after* we send out all the messages to the remote sites
    // so that we don't have to wait as long for the responses to come back over the network
    boolean send_local = false;
    boolean site_sent[] = new boolean[this.num_sites];

    if (debug.val)
      LOG.debug(
          String.format(
              "Sending %s to %d partitions for %s",
              request.getClass().getSimpleName(), partitions.size(), ts));

    for (int partition : partitions.values()) {
      int dest_site_id = hstore_site.getCatalogContext().getSiteIdForPartitionId(partition);

      // Skip this HStoreSite if we're already sent it a message
      if (site_sent[dest_site_id]) continue;

      if (trace.val)
        LOG.trace(
            String.format(
                "Sending %s message to %s for %s",
                request.getClass().getSimpleName(),
                HStoreThreadManager.formatSiteName(dest_site_id),
                ts));

      // Local Partition
      if (this.local_site_id == dest_site_id) {
        send_local = true;
      }
      // Remote Partition
      else {
        HStoreService channel = coordinator.getChannel(dest_site_id);
        assert (channel != null) : "Invalid partition id '" + partition + "'";
        ProtoRpcController controller = this.getProtoRpcController(ts, dest_site_id);
        assert (controller != null)
            : "Invalid "
                + request.getClass().getSimpleName()
                + " ProtoRpcController for site #"
                + dest_site_id;
        this.sendRemote(channel, controller, request, callback);
      }
      site_sent[dest_site_id] = true;
    } // FOR
    // Optimization: We'll invoke sendLocal() after we have sent out
    // all of the messages to remote sites
    if (send_local) this.sendLocal(ts.getTransactionId(), request, partitions, callback);
  }
示例#5
0
 /**
  * Mark that this txn has executed a modifying query for the Table at the given partition.
  * <B>Note:</B> This is just tracking that we executed a query. It does not necessarily mean that
  * the query actually changed anything.
  *
  * @param partition
  * @param catalog_tbl
  */
 public final void markTableAsWritten(int partition, Table catalog_tbl) {
   if (this.writeTables[partition] == null) {
     this.writeTables[partition] = new boolean[hstore_site.getCatalogContext().numberOfTables + 1];
   }
   this.writeTables[partition][catalog_tbl.getRelativeIndex()] = true;
 }