Search in sources :

Example 1 with RuntimeProgramContextAware

use of io.cdap.cdap.data.RuntimeProgramContextAware in project cdap by caskdata.

the class AbstractContext method getDataset.

@Override
public <T extends Dataset> T getDataset(final String namespace, final String name, final Map<String, String> arguments, final AccessType accessType) throws DatasetInstantiationException {
    return Retries.callWithRetries(() -> {
        T dataset = datasetCache.getDataset(namespace, name, arguments, accessType);
        if (dataset instanceof RuntimeProgramContextAware) {
            DatasetId datasetId = new NamespaceId(namespace).dataset(name);
            ((RuntimeProgramContextAware) dataset).setContext(createRuntimeProgramContext(datasetId));
        }
        return dataset;
    }, retryStrategy);
}
Also used : NamespaceId(io.cdap.cdap.proto.id.NamespaceId) RuntimeProgramContextAware(io.cdap.cdap.data.RuntimeProgramContextAware) DatasetId(io.cdap.cdap.proto.id.DatasetId)

Example 2 with RuntimeProgramContextAware

use of io.cdap.cdap.data.RuntimeProgramContextAware in project cdap by cdapio.

the class AbstractContext method getDataset.

@Override
public <T extends Dataset> T getDataset(final String namespace, final String name, final Map<String, String> arguments, final AccessType accessType) throws DatasetInstantiationException {
    return Retries.callWithRetries(() -> {
        T dataset = datasetCache.getDataset(namespace, name, arguments, accessType);
        if (dataset instanceof RuntimeProgramContextAware) {
            DatasetId datasetId = new NamespaceId(namespace).dataset(name);
            ((RuntimeProgramContextAware) dataset).setContext(createRuntimeProgramContext(datasetId));
        }
        return dataset;
    }, retryStrategy);
}
Also used : NamespaceId(io.cdap.cdap.proto.id.NamespaceId) RuntimeProgramContextAware(io.cdap.cdap.data.RuntimeProgramContextAware) DatasetId(io.cdap.cdap.proto.id.DatasetId)

Aggregations

RuntimeProgramContextAware (io.cdap.cdap.data.RuntimeProgramContextAware)2 DatasetId (io.cdap.cdap.proto.id.DatasetId)2 NamespaceId (io.cdap.cdap.proto.id.NamespaceId)2