/** Constructor */ @SuppressWarnings("unchecked") public TimeIntervalCostModel( CatalogContext catalogContext, Class<? extends T> inner_class, int num_intervals) { super(TimeIntervalCostModel.class, catalogContext, new PartitionEstimator(catalogContext)); this.num_intervals = num_intervals; this.cost_models = (T[]) (new AbstractCostModel[num_intervals]); try { Constructor<?> constructor = ClassUtil.getConstructor(inner_class, Database.class, PartitionEstimator.class); for (int i = 0; i < this.cost_models.length; i++) { this.cost_models[i] = (T) constructor.newInstance(catalogContext, this.p_estimator); } // FOR } catch (Exception ex) { LOG.fatal("Failed to create the inner cost models", ex); System.exit(1); } assert (this.num_intervals > 0); if (trace.val) LOG.trace("TimeIntervalCostModel: " + this.num_intervals + " intervals"); singlepartition_ctrs = new int[num_intervals]; singlepartition_with_partitions_ctrs = new int[num_intervals]; multipartition_ctrs = new int[num_intervals]; incomplete_txn_ctrs = new int[num_intervals]; exec_mismatch_ctrs = new int[num_intervals]; partitions_touched = new int[num_intervals]; interval_weights = new double[num_intervals]; total_interval_txns = new double[num_intervals]; total_interval_queries = new double[num_intervals]; incomplete_txn_histogram = new ObjectHistogram[num_intervals]; exec_histogram = new ObjectHistogram[num_intervals]; missing_txn_histogram = new ObjectHistogram[num_intervals]; txn_skews = new double[num_intervals]; exec_skews = new double[num_intervals]; total_skews = new double[num_intervals]; for (int i = 0; i < num_intervals; i++) { incomplete_txn_histogram[i] = new ObjectHistogram<Integer>(); exec_histogram[i] = new ObjectHistogram<Integer>(); missing_txn_histogram[i] = new ObjectHistogram<Integer>(); } // FOR }
/** Add the system procedures to the catalog. */ void addSystemProcsToCatalog(final Catalog catalog, final Database database) throws VoltCompilerException { assert (catalog != null); assert (database != null); // Table of sysproc metadata. final Object[][] procedures = { // SysProcedure Class readonly everysite {LoadMultipartitionTable.class, false, true}, {DatabaseDump.class, true, true}, {RecomputeMarkovs.class, true, true}, {Shutdown.class, false, true}, {NoOp.class, true, false}, {AdHoc.class, false, false}, {GarbageCollection.class, true, true}, {ExecutorStatus.class, true, false}, {GetCatalog.class, true, false}, {SnapshotSave.class, false, false}, {SnapshotRestore.class, false, false}, {SnapshotStatus.class, false, false}, {SnapshotScan.class, false, false}, {SnapshotDelete.class, false, false}, // {"org.voltdb.sysprocs.Quiesce", false, false}, // {"org.voltdb.sysprocs.StartSampler", false, false}, // {"org.voltdb.sysprocs.Statistics", true, false}, // {"org.voltdb.sysprocs.SystemInformation", true, false}, // {"org.voltdb.sysprocs.UpdateApplicationCatalog", false, true}, // {"org.voltdb.sysprocs.UpdateLogging", false, true} }; for (int ii = 0; ii < procedures.length; ++ii) { Class<?> procClass = (Class<?>) procedures[ii][0]; boolean readonly = (Boolean) procedures[ii][1]; boolean everysite = (Boolean) procedures[ii][2]; // short name is "@ClassName" without package final String shortName = "@" + procClass.getSimpleName(); // Make sure it's a VoltSystemProcedure if (ClassUtil.getSuperClasses(procClass).contains(VoltSystemProcedure.class) == false) { String msg = String.format( "Class %s does not extend %s", procClass.getCanonicalName(), VoltSystemProcedure.class.getSimpleName()); throw new VoltCompilerException(msg); } // read annotations final ProcInfo info = procClass.getAnnotation(ProcInfo.class); if (info == null) { throw new VoltCompilerException("Sysproc " + shortName + " is missing annotation."); } // add an entry to the catalog final Procedure procedure = database.getProcedures().add(shortName); procedure.setId(this.getNextProcedureId()); procedure.setClassname(procClass.getCanonicalName()); procedure.setReadonly(readonly); procedure.setSystemproc(true); procedure.setHasjava(true); procedure.setSinglepartition(info.singlePartition()); procedure.setEverysite(everysite); ProcedureCompiler.populateProcedureParameters(this, procClass, procedure); // Stored procedure sysproc classes are present in VoltDB.jar // and not duplicated in the catalog. This was decided // arbitrarily - no one had a strong opinion. // // VoltCompiler.addClassToJar(procClass, compiler); } }