Package com.linkedin.databus.core.util

Examples of com.linkedin.databus.core.util.RateMonitor


 
  public DbusSeederBaseThread(String name)
  {
    super(name);
    _stopped = new CountDownLatch(1);
    _rate = new RateMonitor(name);
    _isError = false;
  }
View Full Code Here


    File f = _keyTxnFilesMap.get(srcName);
    FileWriter oStream = new FileWriter(f,f.exists());
    BufferedWriter keyTxnWriter = new BufferedWriter(oStream,_keyTxnBufferSizeMap.get(srcName));

    _bootstrapSeedWriter.startEvents();
    RateMonitor seedingRate = new RateMonitor("Seeding Rate");
    RateMonitor queryRate = new RateMonitor("Query Rate");
    seedingRate.start();
    seedingRate.suspend();
    queryRate.start();
    queryRate.suspend();
    boolean isException = false;
    long totProcessTime =0;
    try
    {
      conn  = _dataSource.getConnection();
      pstmt = conn.prepareStatement(sql);

      if ( _enableNumRowsQuery )
        numRows = getNumRows(conn, getTableName(sourceInfo));
      else
        numRows = -1;

      long currRowId = _lastRows.get(sourceInfo.getEventView());

      /**
       * First Key to be seeded will be decided in the following order:
       * 1. Use bootstrap_seeder_state's last srcKey as the key for the first chunk.
       * 2. If (1) is empty, use passed-in begin srcKey.
       * 3. If (2) is also empty, use Oracle's minKey as the first Chunk Key.
       */
      if ( null == lastKey )
      {
        lastKey = _beginSrcKeyMap.get(sourceInfo.getEventView());
        LOG.info("No last Src Key available in bootstrap_seeder_state for source ("  + sourceInfo + ". Trying beginSrc Key from config :" + lastKey);
      }

      if ( (null == lastKey) || (lastKey.trim().isEmpty()) )
      {
        if ( KeyType.LONG == keyType )
          pKey = new PrimaryKeyTxn(executeAndGetLong(minKeySQL));
        else
          pKey = new PrimaryKeyTxn(executeAndGetString(minKeySQL));
      } else {
        if ( KeyType.LONG == keyType )
          pKey = new PrimaryKeyTxn(Long.parseLong(lastKey));
        else
          pKey = new PrimaryKeyTxn(lastKey);
      }

      PrimaryKeyTxn lastRoundKeyTxn = new PrimaryKeyTxn(pKey);
      PrimaryKeyTxn lastKeyTxn = new PrimaryKeyTxn(pKey);
      long numUniqueKeysThisRound = 0;

      boolean first  = true;
      _rate.resume();
      while ( ! done )
      {
        LOG.info("MinKey being used for this round:" + pKey );
        numUniqueKeysThisRound = 0;
        try
        {
          lastRoundKeyTxn.copyFrom(pKey);

          if ( KeyType.LONG == keyType )
          {
            pstmt.setLong(1,pKey.getKey());
          } else {
            String key = pKey.getKeyStr();
            pstmt.setString(1, key);
          }

          pstmt.setLong(2, _numRowsPerQuery);
          pstmt.setFetchSize(_numRowsPrefetch);

          if ( _oraclePreparedStatementClass.isInstance(pstmt))
          {
            try
            {
              _setLobPrefetchSizeMethod.invoke(pstmt, _LOBPrefetchSize);
            } catch (Exception e)
            {
              throw new EventCreationException("Unable to set Lob Prefetch size" + e.getMessage());
            }
          }

          LOG.info("Executing Oracle Query :" + sql + ". Key: " + pKey + ",NumRows: " +  _numRowsPerQuery);
          queryRate.resume();
          rs = pstmt.executeQuery();
          queryRate.suspend();

          LOG.info("Total Query Latency :" + queryRate.getDuration()/1000000000L);
          long totLatency = 0;
          long txnId = 0;
          int numRowsThisRound = 0;
          seedingRate.resume();
          while (rs.next())
View Full Code Here

      long timeStart = timestamp;
      long lastTime = timestamp;
      long commitInterval = _config.getCommitInterval();
      long totLatency = 0;
      GenericRecord record = null;
      RateMonitor seedingRate = new RateMonitor("Seeding Rate");
      seedingRate.start();   
      seedingRate.suspend();
     
      long startRowId = _lastRows.get(sourceInfo.getEventView());
     
      LOG.info("Last Known Row Id is :" + startRowId);
     
      boolean resumeSeedingRate = true;
     
    for (File avroSeedFile : files)
      {
        if (! avroSeedFile.isFile())
          continue;
       
        LOG.info("Seeding from File : " + avroSeedFile);
       
        try {
          reader = new DataFileReader<GenericRecord>(avroSeedFile, new GenericDatumReader<GenericRecord>());
        } catch (IOException e) {
          LOG.fatal("Failed to bootstrap from file " + avroSeedFile.getAbsolutePath(), e);
          throw new RuntimeException("Failed to bootstrap from file " + avroSeedFile.getAbsolutePath(), e);
        }

       
        try
       
          boolean committed = false;
          for (GenericRecord hdfsRecord : reader)
          {
            record = hdfsRecord;
            committed = false;
            numRead++;

            if (numRead < startRowId)
              continue;
           
            if (resumeSeedingRate)
            {
              seedingRate.resume();
              resumeSeedingRate = false;
            }
           
            seedingRate.tick();
           
            //LOG.info("Read record :" + record);           
            long start = System.nanoTime();
            long eventSize = sourceInfo.getFactory().createAndAppendEvent(windowSCN, timestamp, hdfsRecord,
                        _bootstrapEventBuffer, false, null);         
           
            numBytes+=eventSize;
            long latency = System.nanoTime() - start;
            totLatency += latency;
            if (numRead%commitInterval == 0)
            {
              _bootstrapEventBuffer.endEvents(numRead,timestamp,null);
              _bootstrapEventBuffer.startEvents();
              long procTime = totLatency/1000000000;
              long currTime = System.currentTimeMillis();
              long diff = (currTime - lastTime)/1000;
              long timeSinceStart = (currTime - timeStart)/1000;
              LOG.info("Processed " + commitInterval + " rows in " + diff
                  + " seconds, Avro Processing Time (seconds) so far :" + (procTime)
                  + ",Seconds elapsed since start :" + (timeSinceStart)
                  + ",Overall Row Rate:" + seedingRate.getRate() +
                  ", NumRows Fetched so far:" + numRead +
                  ". TotalEventSize :" + numBytes);
              lastTime = currTime;
              seedingRate.resume();
              committed = true;
            }
          }
         
          if ( ! committed)
          {
            _bootstrapEventBuffer.endEvents(numRead,timestamp,null);
            _bootstrapEventBuffer.startEvents();
            long procTime = totLatency/1000000000;
            long currTime = System.currentTimeMillis();
            long diff = (currTime - lastTime)/1000;
            long timeSinceStart = (currTime - timeStart)/1000;
            LOG.info("Completed Seeding from : " + avroSeedFile + ", Processed " + commitInterval + " rows in " + diff
                + " seconds, Avro Processing Time (seconds) so far :" + (procTime)
                + ",Seconds elapsed since start :" + (timeSinceStart)
                + ",Overall Row Rate:" + seedingRate.getRate() +
                ", NumRows Fetched so far:" + numRead +
                ". TotalEventSize :" + numBytes);
            lastTime = currTime;
            seedingRate.resume();
          }
        } catch (Exception e) {
          LOG.fatal("NumRead :" + numRead + ", Got Exception while processing generic record :" + record, e);
          throw new RuntimeException(e);
        }
View Full Code Here

    _numInvalidTxnsSeen = 0;
    _txnEndSeen = false;
    _beginTxnSeen = false;
    _firstTxnSeen = false;
    _currTxnStr.setLength(0);
    _queryRateMonitor = new RateMonitor("XPath_GGTransactionFinder");
    _queryRateMonitor.start();
    _queryRateMonitor.suspend();

    _rateMonitor = new RateMonitor("GGTransactionFinder");
    _rateMonitor.start();
    _rateMonitor.suspend();
  }
View Full Code Here

    _source = source;
    _bootstrapDao = null;
    _config = config;
    _retryTimer = new BackoffTimer(name + "RetryTimer", config.getRetryConfig());
    _statsCollector = statsCollector;
    _srcRm = new RateMonitor(name + "ProducerSourceRateMonitor");
    _totalRm = new RateMonitor(name + "ProducerTotalRateMonitor");

  }
View Full Code Here

TOP

Related Classes of com.linkedin.databus.core.util.RateMonitor

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.