當前位置: 首頁>>代碼示例>>Java>>正文


Java Const.toLong方法代碼示例

本文整理匯總了Java中org.pentaho.di.core.Const.toLong方法的典型用法代碼示例。如果您正苦於以下問題:Java Const.toLong方法的具體用法?Java Const.toLong怎麽用?Java Const.toLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.pentaho.di.core.Const的用法示例。


在下文中一共展示了Const.toLong方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doGet

import org.pentaho.di.core.Const; //導入方法依賴的package包/類
public void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
  if ( isJettyMode() && !request.getContextPath().startsWith( CONTEXT_PATH ) ) {
    return;
  }

  String serviceName = request.getParameter( "service" );
  int lastSize = Const.toInt( request.getParameter( "last" ), -1 );
  int lastPeriod = Const.toInt( request.getParameter( "lastPeriod" ), -1 );
  long fromId = Const.toLong( request.getParameter( "fromId" ), -1L );
  long toId = Const.toLong( request.getParameter( "toId" ), -1L );
  int newSize = Const.toInt( request.getParameter( "new" ), -1 );
  int maxWait = Const.toInt( request.getParameter( "maxWait" ), -1 );
  String binaryOption = request.getParameter( "binary" );
  boolean binary = "y".equalsIgnoreCase(binaryOption) || "true".equalsIgnoreCase(binaryOption);
  long now = System.currentTimeMillis();

  // last=60
  // fromId=100
  // new=5
  // maxWait10

  response.setStatus( HttpServletResponse.SC_OK );

  if (binary) {
    LogChannel.GENERAL.logBasic( "Binary data asked for service '"+serviceName+"'");
    response.setContentType( "application/octet-stream" );
  } else {
    LogChannel.GENERAL.logBasic( "JSON data asked for service '"+serviceName+"'");
    response.setContentType( "application/json" );
    response.setCharacterEncoding( Const.XML_ENCODING );
  }
  
  try {

    if ( !Const.isEmpty( serviceName ) ) {

      StreamingCache cache = StreamingCache.getInstance();
      StreamingCacheEntry streamingCacheEntry = cache.get( serviceName );
      if ( streamingCacheEntry != null ) {
        log.logBasic( "Cache entry of '"+serviceName+"' found");
        
        // Now we have a cache entry for the service.
        // Let's get the rows from the cache with the given options...
        //
        List<StreamingTimedNumberedRow> rows = streamingCacheEntry.findRows( log, lastSize, lastPeriod, fromId, toId, newSize, maxWait, now );
        while ( rows == null ) {
          // Keep retrying with a one second delay until the service transformation has some rows.
          Thread.sleep( 1000 );
          rows = streamingCacheEntry.findRows( log, lastSize, lastPeriod, fromId, toId, newSize, maxWait, now );
        }
        
        LogChannel.GENERAL.logBasic( "Data export for '"+serviceName+"' found, "+rows.size()+" rows found");
        if (binary) {
          writeBinaryData(serviceName, response, streamingCacheEntry, rows);
        } else {
          writeJsonData(serviceName, response, streamingCacheEntry, rows);
        }
      }
    } else {
      String comment = "Streaming cache service '" + serviceName + "' doesn't exist";
      LogChannel.GENERAL.logError( comment );
      throw new KettleException(comment);
    }
  } catch ( Exception e ) {
    LogChannel.GENERAL.logError( "Error get streaming data for service '" + serviceName + "'", e);
    try {
      response.sendError(500, e.getMessage()+" - "+Const.getStackTracker(e));
    } catch(IOException ioe) {
      LogChannel.GENERAL.logError( "Error writing error response for service '" + serviceName + "'", ioe );
    }
  }

  
}
 
開發者ID:mattcasters,項目名稱:pentaho-pdi-streaming,代碼行數:75,代碼來源:GetStreamingServicesServlet.java


注:本文中的org.pentaho.di.core.Const.toLong方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。