Package org.voltdb.catalog

Examples of org.voltdb.catalog.Procedure


        // 2012-10-17: This is kind of funky because we have to populate the
        // probabilities for the MarkovEstimate here, whereas for the initial estimate
        // we did it inside of the MarkovPathEstimator
        MarkovEstimate estimate = state.createNextEstimate(state.getCurrent(), false);
        assert(estimate != null);
        Procedure catalog_proc = markov.getProcedure();
        Object procArgs[] = state.getProcedureParameters();
        this.estimatePath(state, estimate, catalog_proc, procArgs);
       
        if (debug.val)
            LOG.debug(String.format("Next MarkovEstimate for txn #%d\n%s",
View Full Code Here


    public FixedTPCCEstimator(PartitionEstimator p_estimator) {
        super(p_estimator);
       
        // Prefetchable Statements
        if (hstore_conf.site.exec_prefetch_queries) {
            Procedure catalog_proc = catalogContext.procedures.getIgnoreCase("neworder");
            String prefetchables[] = { "getStockInfo" };
            this.neworder_prefetchables = new Statement[prefetchables.length];
            for (int i = 0; i < this.neworder_prefetchables.length; i++) {
                Statement catalog_stmt = catalog_proc.getStatements().getIgnoreCase(prefetchables[i]);
                assert(catalog_stmt != null) :
                    String.format("Invalid prefetchable Statement %s.%s",
                                  catalog_proc.getName(), prefetchables[i]);
                this.neworder_prefetchables[i] = catalog_stmt;
            } // FOR
        } else {
            this.neworder_prefetchables = null;   
        }
View Full Code Here

                Timestamp current = new Timestamp(date.getTime());
                String nonce = Long.toString(current.getTime());

                CatalogContext cc = this.getCatalogContext();
                String procName = VoltSystemProcedure.procCallName(SnapshotSave.class);
                Procedure catalog_proc = cc.procedures.getIgnoreCase(procName);

                ParameterSet params = new ParameterSet();
                params.setParameters(
                        path,  // snapshot dir
                        nonce, // nonce - timestamp
View Full Code Here

            LOG.debug(String.format("Raw Request: clientHandle=%d / basePartition=%d / procId=%d / procName=%s",
                      client_handle, base_partition,
                      procId, StoredProcedureInvocation.getProcedureName(incomingDeserializer)));
       
        // Optimization: We can get the Procedure catalog handle from its procId
        Procedure catalog_proc = catalogContext.getProcedureById(procId);
    
        // Otherwise, we have to get the procedure name and do a look up with that.
        if (catalog_proc == null) {
            String procName = StoredProcedureInvocation.getProcedureName(incomingDeserializer);
            catalog_proc = this.catalogContext.procedures.getIgnoreCase(procName);
            if (catalog_proc == null) {
                String msg = "Unknown procedure '" + procName + "'";
                this.responseError(client_handle,
                                   Status.ABORT_UNEXPECTED,
                                   msg,
                                   clientCallback,
                                   timestamp);
                return;
            }
        }
        boolean sysproc = catalog_proc.getSystemproc();
       
        // -------------------------------
        // PARAMETERSET INITIALIZATION
        // -------------------------------
       
        // Extract just the ParameterSet from the StoredProcedureInvocation
        // We will deserialize the rest of it later
        ParameterSet procParams = new ParameterSet();
        try {
            StoredProcedureInvocation.seekToParameterSet(buffer);
            incomingDeserializer.setBuffer(buffer);
            procParams.readExternal(incomingDeserializer);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
        assert(procParams != null) :
            "The parameters object is null for new txn from client #" + client_handle;
        if (debug.val)
            LOG.debug(String.format("Received new stored procedure invocation request for %s [handle=%d]",
                      catalog_proc.getName(), client_handle));
       
        // System Procedure Check
        // If this method returns true, then we want to halt processing the
        // request any further and immediately return
        if (sysproc && this.processSysProc(client_handle, catalog_proc, procParams, clientCallback)) {
View Full Code Here

            if (this.isLocalPartition(redirect_partition) == false && orig_ts.getRestartCounter() == 0) {
                if (debug.val)
                    LOG.debug(String.format("%s - Redirecting to partition %d because of misprediction",
                              orig_ts, redirect_partition));
               
                Procedure catalog_proc = orig_ts.getProcedure();
                StoredProcedureInvocation spi = new StoredProcedureInvocation(orig_ts.getClientHandle(),
                                                                              catalog_proc.getId(),
                                                                              catalog_proc.getName(),
                                                                              orig_ts.getProcedureParameters().toArray());
                spi.setBasePartition(redirect_partition);
                spi.setRestartCounter(orig_ts.getRestartCounter()+1);
               
                FastSerializer out = this.outgoingSerializers.get();
View Full Code Here

     * @param status
     */
    protected void deleteLocalTransaction(LocalTransaction ts, final Status status) {
        final Long txn_id = ts.getTransactionId();
        final int base_partition = ts.getBasePartition();
        final Procedure catalog_proc = ts.getProcedure();
        final boolean singlePartitioned = ts.isPredictSinglePartition();
        if (debug.val) {
            LOG.debug(String.format("About to delete %s [%s]", ts, status));
            if (trace.val) LOG.trace(ts + " - State before delete:\n" + ts.debug());
        }
View Full Code Here

    /**
     * testReplicatedInsert
     */
    public void testReplicatedInsert() throws Exception {
        Object params[] = new Object[]{ 9999, "FUCK", "YO", "COUCH" };
        Procedure proc = this.getProcedure("InsertCountry");
        Statement stmt = CollectionUtil.first(proc.getStatements());
        this.batch = new SQLStmt[]{ new SQLStmt(stmt) };
        this.args = new ParameterSet[]{ new ParameterSet(params) };
       
        BatchPlanner planner = new BatchPlanner(batch, catalog_proc, p_estimator);
        this.touched_partitions.clear();
View Full Code Here

   
    /**
     * testFragmentOrder
     */
    public void testFragmentOrder() throws Exception {
        Procedure catalog_proc = this.getProcedure(BatchPlannerConflictProc.class);
       
        // Create a big batch and make sure that the fragments are in the correct order
        Statement stmts[] = new Statement[]{
            catalog_proc.getStatements().getIgnoreCase("ReplicatedInsert"),
            catalog_proc.getStatements().getIgnoreCase("ReplicatedSelect")
        };
        SQLStmt batch[] = new SQLStmt[stmts.length];
        ParameterSet params[] = new ParameterSet[stmts.length];
        int stmtCounters[] = new int[stmts.length];
        for (int i = 0; i < stmts.length; i++) {
View Full Code Here

        // Get Procedure catalog handle
        if (procName == null || procName.isEmpty()) {
            LOG.error("Missing procedure name");
            return (null);
        }
        Procedure catalog_proc = catalog_db.getProcedures().getIgnoreCase(procName);
        if (catalog_proc == null) {
            throw new Exception("Invalid procedure name '" + procName + "'");
        }
       
        int expectedParams = catalog_proc.getParameters().size();
        // Hack for @AdHoc
        if (catalog_proc.getName().equalsIgnoreCase("@AdHoc")) {
            expectedParams = 1;
        }
       
        // Procedure Parameters
        if (params.length != expectedParams) {
            Map<String, Object> m = new LinkedHashMap<String, Object>();
            for (ProcParameter catalog_param : CatalogUtil.getSortedCatalogItems(catalog_proc.getParameters(), "index")) {
                VoltType vtype = VoltType.get(catalog_param.getType());
                String key = String.format("[%02d]", catalog_param.getIndex());
                String val = vtype.name();
               
                if (vtype == VoltType.TIMESTAMP) {
                    val += " (FORMATS: ";
                    String add = "";
                    int spacer = val.length();
                    for (String f : VoltTypeUtil.DATE_FORMAT_PATTERNS) {
                        val += add + f;
                        add = "\n" + StringUtil.repeat(" ", spacer);
                    }
                    val += ")";
                }
               
                m.put(key, val);
            }
            throw new Exception(String.format("Incorrect number of parameters for %s. Expected %d, but was only given %d\n" +
                                    "Expected Input Parameters:\n%s",
                                    catalog_proc, catalog_proc.getParameters().size(), params.length,
                                    StringUtil.prefix(StringUtil.formatMaps(m), "  ")).trim());
        }
       
        // Convert parameters to the proper type
        Object parameters[] = new Object[expectedParams];
        for (int i = 0; i < expectedParams; i++) {
            ProcParameter catalog_param = catalog_proc.getParameters().get(i);
            assert(catalog_param != null) : String.format("Null %s parameter at %d", catalog_proc.getName(), i);
            VoltType vt = VoltType.get(catalog_param.getType());
           
            try {
                // Split into array
                if (catalog_param.getIsarray()) {
                    List<String> arr = (List<String>)CollectionUtil.addAll(new ArrayList<String>(),
                                                                           params[i].split(","));
                    Object inner[] = new Object[arr.size()];
                    for (int ii = 0, cnt = arr.size(); ii < cnt; ii++) {
                        inner[ii] = VoltTypeUtil.getObjectFromString(vt, arr.get(ii));
                    } // FOR
                    parameters[i] = inner;
                // Scalar Paramter
                } else {
                    parameters[i] = VoltTypeUtil.getObjectFromString(vt, params[i]);
                }
            } catch (ParseException ex) {
                LOG.error("Invalid parameter #" + i + ": " + params[i], ex);
                return (null);
            }
            if (LOG.isDebugEnabled())
                LOG.debug(String.format("%s: %s [%s / %s]", catalog_param.fullName(),
                                                            (catalog_param.getIsarray() ? Arrays.toString((Object[])parameters[i]) : parameters[i]),
                                                            vt, parameters[i].getClass()));
        } // FOR
       
        LOG.info(String.format("Invoking %s [params=%s]",
                               catalog_proc.getName(), Arrays.toString(parameters)));
        ClientResponse cresponse = client.callProcedure(catalog_proc.getName(), parameters);
       
        return (cresponse);
    }
View Full Code Here

        long evicted = evictResult.getLong("ANTICACHE_TUPLES_EVICTED");
        assertTrue("No tuples were evicted!\n"+evictResult, evicted > 0);
        // System.err.println(VoltTableUtil.format(evictResult));
       
        // Now execute a query that needs to access data from this block
        Procedure proc = this.getProcedure(procName); // Special Single-Stmt Proc
        ClientResponse cresponse = null;
        if (useLimit) {
            cresponse = this.client.callProcedure(proc.getName(), expected);
        } else {
            cresponse = this.client.callProcedure(proc.getName());
        }
        assertEquals(Status.OK, cresponse.getStatus());

        // Make sure that we tracked that we tried to touch evicted data
        assertEquals(1, this.profiler.evictedaccess_history.size());
View Full Code Here

TOP

Related Classes of org.voltdb.catalog.Procedure

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.