Package edu.brown.hstore.txns

Examples of edu.brown.hstore.txns.RemoteTransaction


        assert(this.isLocalPartition(fragment.getPartitionId())) :
            "Trying to queue work for " + ts + " at non-local partition " + fragment.getPartitionId();
       
        if (hstore_conf.site.specexec_enable && ts instanceof RemoteTransaction && fragment.hasFutureStatements()) {
            QueryEstimate query_estimate = fragment.getFutureStatements();
            RemoteTransaction remote_ts = (RemoteTransaction)ts;
            RemoteEstimatorState t_state = (RemoteEstimatorState)remote_ts.getEstimatorState();
            if (t_state == null) {
                t_state = this.remoteTxnEstimator.startTransaction(ts.getTransactionId(),
                                                                   ts.getBasePartition(),
                                                                   ts.getProcedure(),
                                                                   null);
                remote_ts.setEstimatorState(t_state);
            }
            if (debug.val)
                LOG.debug(String.format("%s - Updating %s with %d future statement hints for partition %d",
                          ts, t_state.getClass().getSimpleName(),
                          fragment.getFutureStatements().getStmtIdsCount(),
View Full Code Here


            if (debug.val) LOG.debug("restartin on local");
          this.hstore_site.transactionInit(next.ts)
        } else {
          ee.antiCacheMergeBlocks(next.catalog_tbl);
          RemoteTransaction ts = (RemoteTransaction) next.ts;
          RpcCallback<UnevictDataResponse> callback = ts.getUnevictCallback();
          UnevictDataResponse.Builder builder = UnevictDataResponse.newBuilder()
            .setSenderSite(this.hstore_site.getSiteId())
            .setTransactionId(ts.getNewTransactionId())
            .setPartitionId(next.partition)
            .setStatus(Status.OK);
          callback.run(builder.build());         
         
        }
View Full Code Here

                System.err.println(sb.toString());
                latch.countDown();
            }
        };
       
        RemoteTransaction txn = MockHStoreSite.makeDistributedTransaction(hstore_sites[0], hstore_sites[1]);
        txn.setUnevictCallback(callback);
        int partition_id = CollectionUtil.first(this.hstore_sites[1].getLocalPartitionIds());
        MockAntiCacheManager remotemanager = (MockAntiCacheManager) hstore_sites[1].getAntiCacheManager();
        assertTrue(remotemanager.queue(txn, partition_id, catalog_tbl, block_ids, tuple_offsets));
        remotemanager.processQueue(); // force to process the queued item
       
        // block till the remote site executes the callback notifying that its done
        latch.await();
        assertNotNull(txn.getAntiCacheMergeTable()); // ensure that items were unevicted for this txn

//        assertEquals(Status.OK, cresponse.getStatus()); // does the txn go to completion
    }
View Full Code Here

    public RemoteTransaction createRemoteTransaction(Long txn_id,
                                                     PartitionSet partitions,
                                                     ParameterSet procParams,
                                                     int base_partition,
                                                     int proc_id) {
        RemoteTransaction ts = null;
        Procedure catalog_proc = this.catalogContext.getProcedureById(proc_id);
        try {
            ts = new RemoteTransaction(this.hstore_site);
            assert(ts.isInitialized() == false);
            ts.init(txn_id, base_partition, procParams, catalog_proc, partitions, true);
            if (debug.val)
                LOG.debug(String.format("Creating new RemoteTransactionState %s from " +
                      "remote partition %d [partitions=%s, hashCode=%d]",
                          ts, base_partition, partitions, ts.hashCode()));
        } catch (Throwable ex) {
            String msg = "Failed to instantiate new remote transaction handle for " + TransactionUtil.formatTxnName(catalog_proc, txn_id);
            throw new RuntimeException(msg, ex);
        }
        AbstractTransaction dupe = this.inflight_txns.put(txn_id, ts);
View Full Code Here

        @Override
        public void transactionInit(RpcController controller, TransactionInitRequest request, RpcCallback<TransactionInitResponse> done) {
            LOG.info("Incoming " + request.getClass().getSimpleName());
            PartitionSet partitions = new PartitionSet(request.getPartitionsList());
            RemoteTransaction ts = hstore_site.getTransactionInitializer()
                                             .createRemoteTransaction(request.getTransactionId(),
                                                                      partitions,
                                                                      null,
                                                                      request.getBasePartition(),
                                                                      request.getProcedureId());
View Full Code Here

        PartitionSet partitions = new PartitionSet(request.getPartitionsList());
        assert(partitions.isEmpty() == false) :
            "Unexpected empty list of updated partitions for txn #" + txn_id;
        partitions.retainAll(hstore_site.getLocalPartitionIds());
       
        RemoteTransaction ts = this.hstore_site.getTransaction(txn_id);
        assert(ts != null) : "Unexpected null transaction handle for txn #" + txn_id;
       
        // Always create a new prepare callback because we may get multiple messages
        // to prepare this txn for commit.
        RemotePrepareCallback wrapper = ts.getPrepareCallback();
        assert(wrapper.isInitialized() == false);
        wrapper.init(ts, partitions, callback);
       
        this.hstore_site.transactionPrepare(ts, partitions, wrapper);
    }
View Full Code Here

        Long txn_id = Long.valueOf(request.getTransactionId());
        if (debug.val)
            LOG.debug(String.format("Got %s for txn #%d [partitionFragments=%d]",
                      request.getClass().getSimpleName(), txn_id, request.getFragmentsCount()));
       
        RemoteTransaction ts = hstore_site.getTransaction(txn_id);
        assert(ts != null);
        assert(txn_id.equals(ts.getTransactionId())) :
            String.format("Mismatched %s - Expected[%d] != Actual[%s]", ts, txn_id, ts.getTransactionId());
       
        // Deserialize embedded ParameterSets and store it in the RemoteTransaction handle
        // This way we only do it once per HStoreSite. This will also force us to avoid having
        // to do it for local work
        ParameterSet parameterSets[] = new ParameterSet[request.getParamsCount()]; // TODO: Cache!
        for (int i = 0; i < parameterSets.length; i++) {
            ByteString paramData = request.getParams(i);
            if (paramData != null && paramData.isEmpty() == false) {
                final FastDeserializer fds = new FastDeserializer(paramData.asReadOnlyByteBuffer());
                if (trace.val)
                    LOG.trace(String.format("Txn #%d paramData[%d] => %s",
                              txn_id, i, fds.buffer()));
                try {
                    parameterSets[i] = fds.readObject(ParameterSet.class);
                } catch (Exception ex) {
                    String msg = String.format("Failed to deserialize ParameterSet[%d] for txn #%d TransactionRequest", i, txn_id);
                    throw new ServerFaultException(msg, ex, txn_id);
                }
                // LOG.info("PARAMETER[" + i + "]: " + parameterSets[i]);
            } else {
                parameterSets[i] = ParameterSet.EMPTY;
            }
        } // FOR
        ts.attachParameterSets(parameterSets);
       
        // Deserialize attached VoltTable input dependencies
        FastDeserializer fds = null;
        VoltTable vt = null;
        for (int i = 0, cnt = request.getAttachedDataCount(); i < cnt; i++) {
            int input_dep_id = request.getAttachedDepId(i);
            ByteString data = request.getAttachedData(i);
            if (data.isEmpty()) {
                String msg = String.format("%s input dependency %d is empty", ts, input_dep_id);
                LOG.warn(msg + "\n" + request);
                throw new ServerFaultException(msg, txn_id);
            }
           
            if (fds == null) fds = new FastDeserializer(data.asReadOnlyByteBuffer());
            else fds.setBuffer(data.asReadOnlyByteBuffer());

            vt = null;
            try {
                vt = fds.readObject(VoltTable.class);
            } catch (Exception ex) {
                String msg = String.format("Failed to deserialize VoltTable[%d] for txn #%d", input_dep_id, txn_id);
                throw new ServerFaultException(msg, ex, txn_id);
            }
            assert(vt != null);
            ts.attachInputDependency(input_dep_id, vt);
        } // FOR
       
        // This is work from a transaction executing at another node
        // Any other message can just be sent along to the ExecutionSite without sending
        // back anything right away. The ExecutionSite will use our wrapped callback handle
        // to send back whatever response it needs to, but we won't actually send it
        // until we get back results from all of the partitions
        // TODO: The base information of a set of FragmentTaskMessages should be moved into
        // the message wrapper (e.g., base partition, client handle)
        boolean first = true;
        int fragmentCount = request.getFragmentsCount();
        PartitionSet partitions = null;
        if (fragmentCount == 1) {
            WorkFragment work = CollectionUtil.first(request.getFragmentsList());
            partitions = this.catalogContext.getPartitionSetSingleton(work.getPartitionId());
        }
        else {
            partitions = new PartitionSet();
            for (WorkFragment work : request.getFragmentsList()) {
                partitions.add(work.getPartitionId());
            } // FOR
        }
       
        for (WorkFragment work : request.getFragmentsList()) {
            // Always initialize the TransactionWorkCallback for the first callback
            if (first) {
                RemoteWorkCallback work_callback = ts.getWorkCallback();
                if (work_callback.isInitialized()) work_callback.finish(); // HACK
                work_callback.init(ts, partitions, callback);
                if (debug.val)
                    LOG.debug(String.format("Initializing %s for %s",
                              work_callback.getClass().getSimpleName(), ts));
View Full Code Here

                predict_touchedPartitions, predict_readOnly, predict_canAbort,
                catalog_proc, params, client_callback);
       
        base_hstore_site.getTransactionInitializer().registerTransaction(ts, base_partition);
        PartitionSet partitions = remote_hstore_site.getLocalPartitionIds();
        RemoteTransaction remote_ts = remote_hstore_site.getTransactionInitializer().createRemoteTransaction(txnId, partitions, params, base_partition, catalog_proc.getId());
       
        EstTimeUpdater.update(System.currentTimeMillis());
        return (remote_ts);
    }
View Full Code Here

        } // FOR
       
        int dep_id = 10001;
        DependencySet result = new DependencySet(new int[]{ dep_id }, new VoltTable[]{ vt });
       
        RemoteTransaction ts = new RemoteTransaction(hstore_site);
        WorkResult partitionResult = executor.buildWorkResult(ts, result, Status.OK, null);
        assertNotNull(partitionResult);
        assertEquals(result.size(), partitionResult.getDepDataCount());
       
        assertEquals(1, partitionResult.getDepDataCount());
View Full Code Here

TOP

Related Classes of edu.brown.hstore.txns.RemoteTransaction

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.