Public interface to emit the preview data:
Code Block language java 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 language java 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()); } } } }
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.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; }
...
Service | Standalone (Yes/No) | Preview (Yes/No) |
---|---|---|
userInterfaceService | Yes | No |
trackerAppCreationService | Yes | No |
router | Yes | No |
streamService | YesYes | No |
exploreExecutorService | Yes | No |
exploreClient | Yes | No |
metadataService | Yes | No |
serviceStore (set/get service instances) | Yes | No |
appFabricServer | Yes | No |
previewServer | No | Yes |
datasetService | Yes | Yes |
metricsQueryService | Yes | No (Can call MetricStore query) |
txService | YesYes | No (can use standalone's tx service) |
externalAuthenticationServer (if security enabled) | Yes | Yes |
logAppenderInitializer | Yes | Yes |
kafkaClient(if audit enabled) | Yes | No |
zkClient (if audit enabled) | Yes | No |
authorizerInstantiator (started by default) | Yes | Yes? |
AppFabricServer vs PreviewServer :
...
Services | AppFabricServer | PreviewServer |
---|---|---|
notificationService | Yes | No |
schedulerService | Yes | No |
applicationLifecycleService | Yes | Yes |
systemArtifactLoader | Yes | Yes |
programRuntimeService | Yes | Yes |
streamCoordinatorClient | Yes | Yes |
programLifecycleService | Yes | Yes |
pluginService | Yes | Yes |
httpServicehandlerHttpService | Yes | Yes (but only with preview handler). CDAP Router should route calls for preview here. |
PreviewDatasetFramework
...