Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  1. Public interface to emit the preview data:

    Code Block
    languagejava
    public interface PreviewEmitter<V> PreviewEmitter {
    	
    	/**
     	 * Emitput the Map of properties corresponding to the given key.
     	 * @param key the key under which properties are stored
    	 * @param propertyValues the map of property values to be stored under the given key
     	 */
    	 void emitput(String key, Map<String, List<V>>List<Object>> propertyValues);
     
    	/**
     	 * Emit the property specified by name and value for the given key.
     	 * @param key the key under which properties are stored
         * @param propertyName the the name of the property
    	 * @param propertyValue the value associated with the property
     	 */
    	 void emit(String key, String propertyName, VObject propertyValue);
    	
    } 

    2. Preview Context API

    3. How the application will get access to the PreviewEmitter? Similar to Metric and @UseDataSet, instance of the PreviewEmitter will be injected by CDAP in the application.

    Code Block
    languagejava
    public class MyMapReduce extends AbstractMapReduce {
    	private PreviewEmitter<String> emitter;
     
        @Override
        public void initialize() throws Exception {
    		emitter.emit("MyMapReduce.initialize", "logical.start.time", getContext().getLogicalStartTime().toString());
    		emitter.emit("MyMapReduce.initialize", "actual.start.time", System.currentTimeMillis().toString());
        }
     
        public MyMapper extends Mapper<byte[], Text, Text, Text> {
    		@Override
    		public void map(byte[] key, Text value, Context context) throws IOException {
    			if (value.toString().startsWith("Product") {
    				emitter.emit("MapReduce.map", "map.product", value.toString());	
    			}
    		}
    	}
    } 
  2. Preview Context Public API

     

    Code Block
    public interface PreviewContext() {
    	/**
    	 * boolean flag to indicate if preview is enabled or not.
    	 */
    	boolean isPreviewEnabled();
     
    	/**
    	 * get PreviewEmitter, PreviewEmitter can be used to emit objects collected by key and field names.
    	 */
        PreviewEmitter getPreviewEmitter();
    }


    PreviewContext implementation will use previewId to create a preview emitter which can be obtained using getPreviewEmitter by programs. Programs can use isPreviewEnabled to check if preview is enabled before emitting. 

     

  3. How will CDAP get data from the preview?

    Code Block
    /**
     * Represents the state of the preview.
     */
    public class PreviewStatePreviewStatus {
      public enum Status {
    	RUNNING,
    	COMPLETED,
    	DEPLOY_FAILED,
    	RUNTIME_FAILED	
      };
     
      Status previewStatus;
      @Nullable	
      String failureMessage;			
    }
     
    // This is internal interface which will be used by REST handlers
    // to retrieve the preview information.
    public interface PreviewInfoPreviewManager {
     
        /**
    	 * Get the state of the preview represented by previewId.
         */
    	PreviewStatePreviewStatus getStatus(PreviewId previewId);
     
    	/**
    	 * Get the data associated with the preview represented by previewId.
    	 */
        Map<String, Map<String, List<V>>List<Object>> getData(PreviewId previewId);
     
    	/**
    	 * Get all metrics associated with the preview represented by previewId.
    	 */
    	Collection<MetricTimeSeries> getMetrics(PreviewId previewId);
      
     	/**
    	 * Get all logs associated with the preview represented by previewId.
    	 */
    	StringList<LogEntry> getLogs(PreviewId previewId);
    }
     
    class PreviewId extends EntityId implements NamespaceId, ParentId<NamespaceId> {
    	NamespaceId namespace;
        String preview;
    }

...

ServiceStandalone (Yes/No)Preview (Yes/No)
userInterfaceService
YesNo
trackerAppCreationService
YesNo
router
YesNo
streamService
YesYesNo
exploreExecutorService
YesNo
exploreClient
YesNo
metadataService
YesNo
serviceStore (set/get service instances)
YesNo
appFabricServer
YesNo
previewServer
NoYes
datasetService
YesYes
metricsQueryService
YesNo (Can call MetricStore query)
txService
YesYesNo (can use standalone's tx service)
externalAuthenticationServer (if security enabled)
YesYes
logAppenderInitializer
YesYes
kafkaClient(if audit enabled)
YesNo
zkClient (if audit enabled)
YesNo
authorizerInstantiator (started by default)
YesYes?

 

AppFabricServer vs PreviewServer :

...

ServicesAppFabricServerPreviewServer
notificationService
YesNo
schedulerService
YesNo
applicationLifecycleService
YesYes
systemArtifactLoader
YesYes
programRuntimeService
YesYes
streamCoordinatorClient
YesYes
programLifecycleService
YesYes
pluginService
YesYes
httpServicehandlerHttpService
YesYes (but only with preview handler). CDAP Router should route calls for preview here.

 

 

PreviewDatasetFramework

...