Package com.linkedin.databus.bootstrap.common.BootstrapDBMetaDataDAO

Examples of com.linkedin.databus.bootstrap.common.BootstrapDBMetaDataDAO.SourceStatusInfo


  {
    try
    {
      incCleanerStats();

      SourceStatusInfo s = _sourceStatusInfo;
      {
        assert(s.getSrcName().equals(_source));
        BootstrapDBType type = _bootstrapCleanerStaticConfig.getBootstrapType(s.getSrcName());

        LOG.info("Cleaner running for source :" + s.getSrcName() + "("
            + s.getSrcId() + ") with bootstrapDB type :" + type);

        BootstrapLogInfo logInfo = _bootstrapDBCleanerQueryExecutor.getThresholdWindowSCN(type, s.getSrcId());

        if (null == logInfo)
        {
          LOG.info("No WindowSCN. Nothing to cleanup for source : "
              + s.getSrcName());
          return;
        }

        LOG.info("LOG info with lowest windowSCN :" + logInfo);

        LOG.info("Begin phase 1 : Gather candidate loginfo :");
        List<BootstrapLogInfo> candidateLogsInfo = _bootstrapDBCleanerQueryExecutor.getCandidateLogsInfo(
            logInfo.getMinWindowSCN(), (short) (s.getSrcId()));
        if ((null == candidateLogsInfo) || (candidateLogsInfo.isEmpty()))
        {
          LOG.info("No logs to cleanup for source :" + s.getSrcName() + "("
              + s.getSrcId() + ")");
          return;
        }
        LOG.info("End phase 1 : Gather candidate loginfo :");

        LOG.info("Initial Candidate Set for Source :" + s.getSrcName()
            + " is :" + candidateLogsInfo);
        RetentionStaticConfig rConf = _bootstrapCleanerStaticConfig.getRetentionConfig(s
            .getSrcName());
        LOG.info("Retention Config for source :" + s.getSrcName() + " is :"
            + rConf);

        LOG.info("Begin phase 2 : Filter based on retention config :");
        long scn = filterCandidateLogInfo((short) s.getSrcId(),
            candidateLogsInfo,
            _bootstrapCleanerStaticConfig.getRetentionConfig(s.getSrcName()));

        LOG.info("Log tables to be deleted for source :" + s.getSrcName() + "("
            + s.getSrcId() + ") are :" + candidateLogsInfo
            + ", Max SCN of deleted logs:" + scn);
        LOG.info("End phase 2 : Filter based on retention config :");

        if ((scn <= 0) || (candidateLogsInfo.isEmpty()))
        {
          LOG.info("Source :" + s.getSrcName() + "(" + s.getSrcId()
              + ") No log tables to be deleted !! MaxSCN : " + scn
              + ", candidateLogs :" + candidateLogsInfo);
          return;
        }

        LOG.info("Begin phase 3 : Updating Meta Info :");
        BootstrapLogInfo firstValidLog = _bootstrapDBCleanerQueryExecutor.getFirstLogTableWithGreaterSCN(
            (short) s.getSrcId(), scn);
        _bootstrapDBCleanerQueryExecutor.updateSource(firstValidLog);
        LOG.info("End phase 3 : Updating Meta Info :");

        LOG.info("Begin phase 4 : Deleting Log tables :");
        // marking logs as done; if any failures; there is a chance that the
        // logs have to be cleaned up later
        _bootstrapDBCleanerQueryExecutor.markDeleted(candidateLogsInfo);
        _bootstrapDBCleanerQueryExecutor.dropTables(candidateLogsInfo);
        LOG.info("End phase 4 : Deleting Log tables :");

        if ((_bootstrapCleanerStaticConfig.getBootstrapType(s.getSrcName()) == BootstrapDBType.BOOTSTRAP_CATCHUP_APPLIER_RUNNING)
            && ((_applier != null) || _bootstrapCleanerStaticConfig.forceTabTableCleanup(s
                .getSrcName())))
        {
          LOG.info("Source :" + s.getSrcName() + "(" + s.getSrcId()
              + ") is running in catchup_applier_running mode. "
              + "Will delete all rows whose scn is less than or equal to "
              + scn);
          if ((null != _applier) && (_applier.isAlive()))
          {
            LOG.info("Begin phase 5 : Pausing Applier and deleting Rows from tab table :");

            LOG.info("Requesting applier to pause !!");
            _applier.pause();
            LOG.info("Applier paused !!");
          }

          try
          {
            // mark ahead of time; if this doesn't work this time; it will next
            // cycle
            _bootstrapDao.updateMinScnOfSnapshot(s.getSrcId(), scn);
            String srcTable = _bootstrapDBCleanerQueryHelper.getSrcTable(s.getSrcId());
            int numRowsDeleted = _bootstrapDBCleanerQueryExecutor.deleteTable(srcTable, scn);
            LOG.info("Number of Rows deleted for source  :" + s.getSrcName()
                + "(" + s.getSrcId() + ") :" + numRowsDeleted);
            if (numRowsDeleted > 0
                && _bootstrapCleanerStaticConfig.isOptimizeTableEnabled(s.getSrcName()))
            {
              LOG.info("Optimizing table to reclaim space for source :"
                  + s.getSrcName() + "(" + s.getSrcId() + ")");
              _bootstrapDBCleanerQueryExecutor.optimizeTable(srcTable);
            }
          } finally
          {
            if ((null != _applier) && (_applier.isAlive()))
            {
              LOG.info("Requesting applier to resume !!");
              _applier.unpause();
              LOG.info("Applier resumed !!");
            }
          }

          LOG.info("End phase 5 : Deleting Rows from tab table :");
        }

        LOG.info("Cleaner done for source :" + s.getSrcName() + "("
            + s.getSrcId() + ")");
      }
    } catch (SQLException ex)
    {
      LOG.error("Got SQL exception while cleaning bootstrapDB !!", ex);
    } catch (InterruptedException ie)
View Full Code Here


                            staticConfig.getBootstrapDBHostname(),
                            staticConfig.getBootstrapDBUsername(),
                            staticConfig.getBootstrapDBPassword(),
                            staticConfig.getBootstrapDBName(),
                            autoCommit);
      SourceStatusInfo srcStatusInfo = dao.getSrcIdStatusFromDB(sourceName, false);

      if (srcStatusInfo.getSrcId() >= 0 )
      {
        dao.dropSourceInDB(srcStatusInfo.getSrcId());
      }

      dao.addNewSourceInDB(sourceName,BootstrapProducerStatus.ACTIVE);
      srcStatusInfo = dao.getSrcIdStatusFromDB(sourceName, false);

      setBootstrapLoginfoTable(_bootstrapConn, 0, Long.MAX_VALUE);

      //insert one row
      insertOneSnapshotEvent(dao, srcStatusInfo.getSrcId(), Long.MAX_VALUE - 10,
                             Long.MAX_VALUE - 100, "check", "test_payload_data");

      BootstrapCheckpointHandler bstCheckpointHandler =
          new BootstrapCheckpointHandler(sourceName);
      Checkpoint c = bstCheckpointHandler.createInitialBootstrapCheckpoint(null, 0L);
View Full Code Here

                          staticConfig.getBootstrapDBName(),
                          autoCommit);

      for (String source : sources)
      {
        SourceStatusInfo srcStatusInfo = dao.getSrcIdStatusFromDB(source, false);

        if (srcStatusInfo.getSrcId() >= 0 )
        {
          dao.dropSourceInDB(srcStatusInfo.getSrcId());
        }

        dao.addNewSourceInDB(source,BootstrapProducerStatus.ACTIVE);
      }
View Full Code Here

    dbDaoField.setAccessible(true);
    dbDaoField.set(bsp, bmdd);

    List<SourceStatusInfo> srcList = new ArrayList<SourceStatusInfo>();
    String name = "foo";
    SourceStatusInfo ssi = new SourceStatusInfo(name, srcId, 4);
    srcList.add(ssi);

    // case 1. Single source, defaultRowsThresholdForSnapshotBypass set to Long.MAX_VALUE,
    // individual overrides not set
    boolean sbs = bsp.shouldBypassSnapshot(sinceScn, startScn, srcList);
View Full Code Here

TOP

Related Classes of com.linkedin.databus.bootstrap.common.BootstrapDBMetaDataDAO.SourceStatusInfo

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.