Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. API used by apps for logging the debug data

    Code Block
    languagejava
    /**
     * Interface used by CDAP applications to log the data useful for debugging during runtime.
     */
    public interface DebugLoggerFactory {
      /**
       * Returns {@code true} if application is running in debug mode otherwise false is returned.
       */
      boolean isEnabled();
    
      /**
       * Get the {@link Logger} used to log the debug data.
       * @param loggerName the name of the logger with which the log data to be associated
       * @return the instance of the Logger
       */
      Logger getLogger(String loggerName);
    }
     
    /**
     * Interface used by the CDAP applications to log the debug data.
     */
    public interface Logger {
      /**
       * Logs the data at INFO level. Multiple values can be logged against the same property.
       * @param propertyName the the name of the property
       * @param propertyValue the value associated with the property
       */
      void info(String propertyName, Object propertyValue);
     
      /**
       * Logs the data at DEBUG level. Multiple values can be logged against the same property.
       * @param propertyName the the name of the property
       * @param propertyValue the value associated with the property
       */
      void debug(String propertyName, Object propertyValue);
    
      /**
       * Logs the data at ERROR level. Multiple values can be logged against the same property.
       * @param propertyName the the name of the property
       * @param propertyValue the value associated with the property
       */
      void error(String propertyName, Object propertyValue);
     
      /**
       * Return the name of the logger instance.
       */ 
      String getName();
     
      /**
       * Return the log level associated with the logger.
       */
      LogLevel getLogLevel(); 
    }
     
    public enum LogLevel {
       INFO,
       DEBUG,
       WARN
    }
  2. REST endpoints
    1. To start a preview

      Code Block
      languagejava
      POST /v3/namespaces/{namespace-id}/preview
      where namespace-id is the name of the namespace
      Response will contain the CDAP generated unique preview-id which can be used further to get the preview data.
    2. To get the status of the preview

      Code Block
      languagejava
      GET /v3/namespaces/{namespace-id}/previews/{preview-id}/status
      where namespace-id is the name of the namespace
            preview-id is the id of the preview for which status is to be requested
    3. To get the data associated with the preview

      Code Block
      languagejava
      GET /v3/namespaces/{namespace-id}/previews/{preview-id}/loggers/{logger-id}
      where namespace-id is the name of the namespace
            preview-id is the id of the preview for which data is to be requested
            stagelogger-id is the unique name used to identify the emitterlogger
  3. Platform specific CDAP configurations:

    Code Block
    languagejava
    Application configuration will have preview related configurations which will be used by CDAP. Currently there are programId and programType configurations which will be used to identify the program to be executed as a part of preview.
    {
       "preview": {
          "programId": "MyProgram",
          "programType": "workflow",
          "logLevel": "info"
       }
    }
  4. API used by CDAP platform to interact with the preview system:

    Code Block
    languagejava
    /**
     * Interface used to start preview and also retrieve the information associated with a preview.
     */
    public interface PreviewManager {
      /**
       * Start the preview of an application config provided as an input.
       * @param namespaceId the id of 
       * @param config the config for the preview
       * @return the unique {@link PreviewId} generated for the preview run
       * @throws Exception if there were any error during starting
       */
      PreviewId start(NamespaceId namespaceId, String config) throws Exception;
    
      /**
       * Get the status for the specified {@link PreviewId}.
       * @param previewId the id of the preview for which status is to be returned
       * @return the status associated with the preview
       * @throws NotFoundException if the previewId is not found
       */
      PreviewStatus getStatus(PreviewId previewId) throws NotFoundException;
    
      /**
       * Stop the preview identified by previewId.
       * @param previewId id of the preview
       * @throws Exception if the previewId is not found or if there were any error during stop
       */
      void stop(PreviewId previewId) throws Exception;
    
      /**
       * Get the data associated with the preview.
       * @param previewId the id associated with the preview
       * @return the {@link Map} of logger name to properties associated with the logger for a given preview
       * @throws NotFoundException if the previewId is not found
       */
      Map<String, Map<String, List<String>>> getData(PreviewId previewId) throws NotFoundException;
    
      /**
       * Get the data associated with the specified logger name of the preview.
       * @param previewId id of the preview
       * @param loggerName the name of the logger for which data is to be returned
       * @return the {@link Map} of property name to property value associated with the given logger for a given preview
       * @throws NotFoundException if the previewId is not found
       */
      Map<String, List<String>> getData(PreviewId previewId, String loggerName) throws NotFoundException;
    
      /**
       * Get the metricdata associated with the specified logger name of the preview.
       * @param previewId the id of the preview
       * @return@param loggerName the {@link Collection} of metrics emitted during the preview run name of the logger for which data is to be returned
       * @throws@param NotFoundExceptionlogLevel if the previewIdlog islevel notfor foundwhich data to be */retrieved
      Collection<MetricTimeSeries> getMetrics(PreviewId previewId)* @return the {@link Map} of property name to property value associated with the given logger for a given preview
       * @throws NotFoundException if the previewId is not found
       */
      Map<String, List<String>> getData(PreviewId previewId, String loggerName, LogLevel logLevel) throws NotFoundException;
       /**
       * Get themetric logsassociated forwith the preview.
       * @param previewId the id of the preview
     for which logs* to@return bethe fetched{@link Collection} of metrics *emitted @returnduring the logspreview run
       * @throws NotFoundException if the previewId is not found
       */
      List<LogEntry>Collection<MetricTimeSeries> getLogsgetMetrics(PreviewId previewId) throws NotFoundException;
     
      /**
       * Get the logs for the preview for the specified log level.
       * @param previewId the id of the preview for which logs to be fetched
       * @return the logs
       * @throws NotFoundException if the previewId is not found
       */
      List<LogEntry> getLogs(PreviewId previewId, LogLevel level) throws NotFoundException; 
    }

Application level capabilities:

...