예제 #1
0
파일: Site.java 프로젝트: sumitk1/voltdb
 /** Create a native VoltDB execution engine */
 ExecutionEngine initializeEE(String serializedCatalog, final long timestamp) {
   String hostname = CoreUtils.getHostnameOrAddress();
   ExecutionEngine eeTemp = null;
   try {
     if (m_backend == BackendTarget.NATIVE_EE_JNI) {
       eeTemp =
           new ExecutionEngineJNI(
               m_context.cluster.getRelativeIndex(),
               m_siteId,
               m_partitionId,
               CoreUtils.getHostIdFromHSId(m_siteId),
               hostname,
               m_context
                   .cluster
                   .getDeployment()
                   .get("deployment")
                   .getSystemsettings()
                   .get("systemsettings")
                   .getMaxtemptablesize(),
               m_numberOfPartitions);
       eeTemp.loadCatalog(timestamp, serializedCatalog);
     } else {
       // set up the EE over IPC
       eeTemp =
           new ExecutionEngineIPC(
               m_context.cluster.getRelativeIndex(),
               m_siteId,
               m_partitionId,
               CoreUtils.getHostIdFromHSId(m_siteId),
               hostname,
               m_context
                   .cluster
                   .getDeployment()
                   .get("deployment")
                   .getSystemsettings()
                   .get("systemsettings")
                   .getMaxtemptablesize(),
               m_backend,
               VoltDB.instance().getConfig().m_ipcPorts.remove(0),
               m_numberOfPartitions);
       eeTemp.loadCatalog(timestamp, serializedCatalog);
     }
   }
   // just print error info an bail if we run into an error here
   catch (final Exception ex) {
     hostLog.l7dlog(
         Level.FATAL,
         LogKeys.host_ExecutionSite_FailedConstruction.name(),
         new Object[] {m_siteId, m_siteIndex},
         ex);
     VoltDB.crashLocalVoltDB(ex.getMessage(), true, ex);
   }
   return eeTemp;
 }
예제 #2
0
파일: Site.java 프로젝트: sumitk1/voltdb
  /** Update the catalog. If we're the MPI, don't bother with the EE. */
  public boolean updateCatalog(
      String diffCmds, CatalogContext context, CatalogSpecificPlanner csp, boolean isMPI) {
    m_context = context;
    m_loadedProcedures.loadProcedures(m_context, m_backend, csp);

    if (!isMPI) {
      // Necessary to quiesce before updating the catalog
      // so export data for the old generation is pushed to Java.
      m_ee.quiesce(m_lastCommittedTxnId);
      m_ee.updateCatalog(m_context.m_timestamp, diffCmds);
    }

    return true;
  }
예제 #3
0
파일: Site.java 프로젝트: sumitk1/voltdb
  @Override
  public void tick() {
    long time = System.currentTimeMillis();

    m_ee.tick(time, m_lastCommittedTxnId);
    statsTick(time);
  }
예제 #4
0
파일: Site.java 프로젝트: sumitk1/voltdb
 @Override
 public void exportAction(
     boolean syncAction,
     int ackOffset,
     Long sequenceNumber,
     Integer partitionId,
     String tableSignature) {
   m_ee.exportAction(syncAction, ackOffset, sequenceNumber, partitionId, tableSignature);
 }
예제 #5
0
파일: Site.java 프로젝트: sumitk1/voltdb
 @Override
 public void truncateUndoLog(boolean rollback, long beginUndoToken, long txnId, long spHandle) {
   if (rollback) {
     m_ee.undoUndoToken(beginUndoToken);
   } else {
     assert (latestUndoToken != Site.kInvalidUndoToken);
     assert (latestUndoToken >= beginUndoToken);
     if (latestUndoToken > beginUndoToken) {
       m_ee.releaseUndoToken(latestUndoToken);
     }
     m_lastCommittedTxnId = txnId;
     if (TxnEgo.getPartitionId(m_lastCommittedSpHandle) != TxnEgo.getPartitionId(spHandle)) {
       VoltDB.crashLocalVoltDB(
           "Mismatch SpHandle partitiond id "
               + TxnEgo.getPartitionId(m_lastCommittedSpHandle)
               + ", "
               + TxnEgo.getPartitionId(spHandle),
           true,
           null);
     }
     m_lastCommittedSpHandle = spHandle;
   }
 }
예제 #6
0
  public VoltTable run(
      SystemProcedureExecutionContext ctx,
      String aggregatorFragment,
      String collectorFragment,
      String sql,
      int isReplicatedTableDML) {

    assert (collectorFragment == null);

    ExecutionEngine ee = ctx.getExecutionEngine();
    VoltTable t;

    t =
        ee.executeCustomPlanFragment(
            aggregatorFragment,
            1,
            -1,
            getTransactionId(),
            ctx.getLastCommittedTxnId(),
            ctx.getNextUndo());

    return t;
  }
예제 #7
0
파일: Site.java 프로젝트: sumitk1/voltdb
 void shutdown() {
   try {
     if (m_hsql != null) {
       HsqlBackend.shutdownInstance();
     }
     if (m_ee != null) {
       m_ee.release();
     }
     if (m_snapshotter != null) {
       m_snapshotter.shutdown();
     }
   } catch (InterruptedException e) {
     hostLog.warn("Interrupted shutdown execution site.", e);
   }
 }
예제 #8
0
파일: Site.java 프로젝트: sumitk1/voltdb
 @Override
 public VoltTable[] executePlanFragments(
     int numFragmentIds,
     long[] planFragmentIds,
     long[] inputDepIds,
     ParameterSet[] parameterSets,
     long txnId,
     boolean readOnly)
     throws EEException {
   return m_ee.executePlanFragments(
       numFragmentIds,
       planFragmentIds,
       inputDepIds,
       parameterSets,
       txnId,
       m_lastCommittedTxnId,
       readOnly ? Long.MAX_VALUE : getNextUndoToken());
 }
예제 #9
0
파일: Site.java 프로젝트: sumitk1/voltdb
  /**
   * Cache the current statistics.
   *
   * @param time
   */
  private void statsTick(long time) {
    /*
     * grab the table statistics from ee and put it into the statistics
     * agent.
     */
    if (m_tableStats != null) {
      CatalogMap<Table> tables = m_context.database.getTables();
      int[] tableIds = new int[tables.size()];
      int i = 0;
      for (Table table : tables) {
        tableIds[i++] = table.getRelativeIndex();
      }

      // data to aggregate
      long tupleCount = 0;
      int tupleDataMem = 0;
      int tupleAllocatedMem = 0;
      int indexMem = 0;
      int stringMem = 0;

      // update table stats
      final VoltTable[] s1 = m_ee.getStats(SysProcSelector.TABLE, tableIds, false, time);
      if (s1 != null) {
        VoltTable stats = s1[0];
        assert (stats != null);

        // rollup the table memory stats for this site
        while (stats.advanceRow()) {
          tupleCount += stats.getLong(7);
          tupleAllocatedMem += (int) stats.getLong(8);
          tupleDataMem += (int) stats.getLong(9);
          stringMem += (int) stats.getLong(10);
        }
        stats.resetRowPosition();

        m_tableStats.setStatsTable(stats);
      }

      // update index stats
      final VoltTable[] s2 = m_ee.getStats(SysProcSelector.INDEX, tableIds, false, time);
      if ((s2 != null) && (s2.length > 0)) {
        VoltTable stats = s2[0];
        assert (stats != null);

        // rollup the index memory stats for this site
        while (stats.advanceRow()) {
          indexMem += stats.getLong(10);
        }
        stats.resetRowPosition();

        m_indexStats.setStatsTable(stats);
      }

      // update the rolled up memory statistics
      if (m_memStats != null) {
        m_memStats.eeUpdateMemStats(
            m_siteId,
            tupleCount,
            tupleDataMem,
            tupleAllocatedMem,
            indexMem,
            stringMem,
            m_ee.getThreadLocalPoolAllocations());
      }
    }
  }
예제 #10
0
  @SuppressWarnings("deprecation")
  @Override
  public void setUp() throws IOException, InterruptedException {
    VoltDB.instance().readBuildInfo("Test");

    // compile a catalog
    String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
    String catalogJar = testDir + File.separator + JAR;

    TPCCProjectBuilder pb = new TPCCProjectBuilder();
    pb.addDefaultSchema();
    pb.addDefaultPartitioning();
    pb.addProcedures(MultiSiteSelect.class, InsertNewOrder.class);

    pb.compile(catalogJar, 2, 0);

    // load a catalog
    byte[] bytes = CatalogUtil.toBytes(new File(catalogJar));
    String serializedCatalog = CatalogUtil.loadCatalogFromJar(bytes, null);

    // create the catalog (that will be passed to the ClientInterface
    catalog = new Catalog();
    catalog.execute(serializedCatalog);

    // update the catalog with the data from the deployment file
    String pathToDeployment = pb.getPathToDeployment();
    assertTrue(CatalogUtil.compileDeploymentAndGetCRC(catalog, pathToDeployment, true) >= 0);

    cluster = catalog.getClusters().get("cluster");
    CatalogMap<Procedure> procedures = cluster.getDatabases().get("database").getProcedures();
    Procedure insertProc = procedures.get("InsertNewOrder");
    assert (insertProc != null);
    selectProc = procedures.get("MultiSiteSelect");
    assert (selectProc != null);

    // Each EE needs its own thread for correct initialization.
    final AtomicReference<ExecutionEngine> site1Reference = new AtomicReference<ExecutionEngine>();
    final byte configBytes[] = LegacyHashinator.getConfigureBytes(2);
    Thread site1Thread =
        new Thread() {
          @Override
          public void run() {
            site1Reference.set(
                new ExecutionEngineJNI(
                    cluster.getRelativeIndex(),
                    1,
                    0,
                    0,
                    "",
                    100,
                    HashinatorType.LEGACY,
                    configBytes));
          }
        };
    site1Thread.start();
    site1Thread.join();

    final AtomicReference<ExecutionEngine> site2Reference = new AtomicReference<ExecutionEngine>();
    Thread site2Thread =
        new Thread() {
          @Override
          public void run() {
            site2Reference.set(
                new ExecutionEngineJNI(
                    cluster.getRelativeIndex(),
                    2,
                    1,
                    0,
                    "",
                    100,
                    HashinatorType.LEGACY,
                    configBytes));
          }
        };
    site2Thread.start();
    site2Thread.join();

    // create two EEs
    site1 = new ExecutionSite(0); // site 0
    ee1 = site1Reference.get();
    ee1.loadCatalog(0, catalog.serialize());
    site2 = new ExecutionSite(1); // site 1
    ee2 = site2Reference.get();
    ee2.loadCatalog(0, catalog.serialize());

    // cache some plan fragments
    selectStmt = selectProc.getStatements().get("selectAll");
    assert (selectStmt != null);
    int i = 0;
    // this kinda assumes the right order
    for (PlanFragment f : selectStmt.getFragments()) {
      if (i == 0) selectTopFrag = f;
      else selectBottomFrag = f;
      i++;
    }
    assert (selectTopFrag != null);
    assert (selectBottomFrag != null);

    if (selectTopFrag.getHasdependencies() == false) {
      PlanFragment temp = selectTopFrag;
      selectTopFrag = selectBottomFrag;
      selectBottomFrag = temp;
    }

    // get the insert frag
    Statement insertStmt = insertProc.getStatements().get("insert");
    assert (insertStmt != null);

    for (PlanFragment f : insertStmt.getFragments()) insertFrag = f;

    // populate plan cache
    ActivePlanRepository.clear();
    ActivePlanRepository.addFragmentForTest(
        CatalogUtil.getUniqueIdForFragment(selectBottomFrag),
        Encoder.base64Decode(selectBottomFrag.getPlannodetree()));
    ActivePlanRepository.addFragmentForTest(
        CatalogUtil.getUniqueIdForFragment(selectTopFrag),
        Encoder.base64Decode(selectTopFrag.getPlannodetree()));
    ActivePlanRepository.addFragmentForTest(
        CatalogUtil.getUniqueIdForFragment(insertFrag),
        Encoder.base64Decode(insertFrag.getPlannodetree()));

    // insert some data
    ParameterSet params = ParameterSet.fromArrayNoCopy(1L, 1L, 1L);

    VoltTable[] results =
        ee2.executePlanFragments(
            1,
            new long[] {CatalogUtil.getUniqueIdForFragment(insertFrag)},
            null,
            new ParameterSet[] {params},
            1,
            0,
            42,
            Long.MAX_VALUE);
    assert (results.length == 1);
    assert (results[0].asScalarLong() == 1L);

    params = ParameterSet.fromArrayNoCopy(2L, 2L, 2L);

    results =
        ee1.executePlanFragments(
            1,
            new long[] {CatalogUtil.getUniqueIdForFragment(insertFrag)},
            null,
            new ParameterSet[] {params},
            2,
            1,
            42,
            Long.MAX_VALUE);
    assert (results.length == 1);
    assert (results[0].asScalarLong() == 1L);
  }
예제 #11
0
  public void testMultiSiteSelectAll() {
    ParameterSet params = ParameterSet.emptyParameterSet();

    int outDepId = 1 | DtxnConstants.MULTIPARTITION_DEPENDENCY;
    VoltTable dependency1 =
        ee1.executePlanFragments(
                1,
                new long[] {CatalogUtil.getUniqueIdForFragment(selectBottomFrag)},
                null,
                new ParameterSet[] {params},
                3,
                2,
                42,
                Long.MAX_VALUE)[0];
    try {
      System.out.println(dependency1.toString());
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    assertTrue(dependency1 != null);

    VoltTable dependency2 =
        ee2.executePlanFragments(
                1,
                new long[] {CatalogUtil.getUniqueIdForFragment(selectBottomFrag)},
                null,
                new ParameterSet[] {params},
                3,
                2,
                42,
                Long.MAX_VALUE)[0];
    try {
      System.out.println(dependency2.toString());
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    assertTrue(dependency2 != null);

    ee1.stashDependency(outDepId, dependency1);
    ee1.stashDependency(outDepId, dependency2);

    dependency1 =
        ee1.executePlanFragments(
                1,
                new long[] {CatalogUtil.getUniqueIdForFragment(selectTopFrag)},
                new long[] {outDepId},
                new ParameterSet[] {params},
                3,
                2,
                42,
                Long.MAX_VALUE)[0];
    try {
      System.out.println("Final Result");
      System.out.println(dependency1.toString());
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
예제 #12
0
파일: Site.java 프로젝트: sumitk1/voltdb
 @Override
 public void loadTable(long txnId, int tableId, VoltTable data) {
   m_ee.loadTable(tableId, data, txnId, m_lastCommittedTxnId);
 }
예제 #13
0
파일: Site.java 프로젝트: sumitk1/voltdb
 @Override
 public long loadPlanFragment(byte[] plan) throws EEException {
   return m_ee.loadPlanFragment(plan);
 }
예제 #14
0
파일: Site.java 프로젝트: sumitk1/voltdb
 @Override
 public VoltTable[] getStats(
     SysProcSelector selector, int[] locators, boolean interval, Long now) {
   return m_ee.getStats(selector, locators, interval, now);
 }
예제 #15
0
파일: Site.java 프로젝트: sumitk1/voltdb
 @Override
 public void updateBackendLogLevels() {
   m_ee.setLogLevels(org.voltdb.jni.EELoggers.getLogLevels());
 }
예제 #16
0
파일: Site.java 프로젝트: sumitk1/voltdb
 @Override
 public void quiesce() {
   m_ee.quiesce(m_lastCommittedTxnId);
 }
예제 #17
0
파일: Site.java 프로젝트: sumitk1/voltdb
 @Override
 public void stashWorkUnitDependencies(Map<Integer, List<VoltTable>> dependencies) {
   m_ee.stashWorkUnitDependencies(dependencies);
 }
예제 #18
0
파일: Site.java 프로젝트: sumitk1/voltdb
 @Override
 public void toggleProfiler(int toggle) {
   m_ee.toggleProfiler(toggle);
 }
예제 #19
0
파일: Site.java 프로젝트: sumitk1/voltdb
 @Override
 public long[] getUSOForExportTable(String signature) {
   return m_ee.getUSOForExportTable(signature);
 }