@Inject public DatasetInstanceManager(TransactionSystemClientService txClientService, TransactionExecutorFactory txExecutorFactory, @Named("datasetMDS") DatasetFramework datasetFramework) { this.txExecutorFactory = txExecutorFactory; Map<String, String> emptyArgs = Collections.emptyMap(); this.datasetCache = new MultiThreadDatasetCache(new SystemDatasetInstantiator(datasetFramework), new TransactionSystemClientAdapter(txClientService), NamespaceId.SYSTEM, emptyArgs, null, ImmutableMap.of( DatasetMetaTableUtil.INSTANCE_TABLE_NAME, emptyArgs )); }
public <T extends Dataset> T getDataset(DatasetId datasetId) throws DatasetInstantiationException { return getDataset(datasetId, DatasetDefinition.NO_ARGUMENTS); }
@Override public void close() throws IOException { datasetInstantiator.close(); context.close(); } }
/** * Creates a new instance of a dataset based on the given information. */ private Dataset createDatasetInstance(DatasetCacheKey key, boolean recordLineage) { DatasetId datasetId = new DatasetId(key.getNamespace(), key.getName()); Dataset dataset = instantiator.getDataset(datasetId, key.getArguments(), key.getAccessType()); if (dataset instanceof MeteredDataset && metricsContext != null) { ((MeteredDataset) dataset).setMetricsCollector( metricsContext.childContext(Constants.Metrics.Tag.DATASET, key.getName())); } if (recordLineage) { instantiator.writeLineage(datasetId, key.getAccessType()); } return dataset; }
private <T> T performDatasetAdmin(final DatasetId datasetInstanceId, Operation<T> operation) throws Exception { try (SystemDatasetInstantiator datasetInstantiator = datasetInstantiatorFactory.create()) { DatasetAdmin admin = impersonator.doAs(datasetInstanceId, (Callable<DatasetAdmin>) () -> { DatasetAdmin admin1 = datasetInstantiator.getDatasetAdmin(datasetInstanceId); if (admin1 == null) { throw new NotFoundException("Couldn't obtain DatasetAdmin for dataset instance " + datasetInstanceId); } // returns a DatasetAdmin that executes operations as a particular user, for a particular namespace return new ImpersonatingDatasetAdmin(admin1, impersonator, datasetInstanceId); }); try { return operation.perform(admin); } finally { Closeables.closeQuietly(admin); } } }
/** * Creates a new instance of a dataset based on the given information. */ private Dataset createDatasetInstance(DatasetCacheKey key, boolean recordLineage) { DatasetId datasetId = new DatasetId(key.getNamespace(), key.getName()); Dataset dataset = instantiator.getDataset(datasetId, key.getArguments(), key.getAccessType()); if (dataset instanceof MeteredDataset && metricsContext != null) { ((MeteredDataset) dataset).setMetricsCollector( metricsContext.childContext(Constants.Metrics.Tag.DATASET, key.getName())); } if (recordLineage) { instantiator.writeLineage(datasetId, key.getAccessType()); } return dataset; }
private <T> T performDatasetAdmin(final DatasetId datasetInstanceId, Operation<T> operation) throws Exception { try (SystemDatasetInstantiator datasetInstantiator = datasetInstantiatorFactory.create()) { DatasetAdmin admin = impersonator.doAs(datasetInstanceId, (Callable<DatasetAdmin>) () -> { DatasetAdmin admin1 = datasetInstantiator.getDatasetAdmin(datasetInstanceId); if (admin1 == null) { throw new NotFoundException("Couldn't obtain DatasetAdmin for dataset instance " + datasetInstanceId); } // returns a DatasetAdmin that executes operations as a particular user, for a particular namespace return new ImpersonatingDatasetAdmin(admin1, impersonator, datasetInstanceId); }); try { return operation.perform(admin); } finally { Closeables.closeQuietly(admin); } } }
@Inject public DatasetInstanceManager(TransactionSystemClientService txClientService, TransactionExecutorFactory txExecutorFactory, @Named("datasetMDS") DatasetFramework datasetFramework) { this.txExecutorFactory = txExecutorFactory; Map<String, String> emptyArgs = Collections.emptyMap(); this.datasetCache = new MultiThreadDatasetCache(new SystemDatasetInstantiator(datasetFramework), new TransactionSystemClientAdapter(txClientService), NamespaceId.SYSTEM, emptyArgs, null, ImmutableMap.of( DatasetMetaTableUtil.INSTANCE_TABLE_NAME, emptyArgs )); }
public <T extends Dataset> T getDataset(DatasetId datasetId, Map<String, String> arguments) throws DatasetInstantiationException { return getDataset(datasetId, arguments, AccessType.UNKNOWN); }
@Override public void close() throws IOException { datasetInstantiator.close(); context.close(); } }
@Override public DynamicDatasetCache get() { SystemDatasetInstantiator dsInstantiator = new SystemDatasetInstantiator(dsFramework); return new MultiThreadDatasetCache( dsInstantiator, txClient, NamespaceId.SYSTEM, ImmutableMap.of(), metricsCollectionService.getContext(ImmutableMap.of()), ImmutableMap.of() ); } }
public <T extends Dataset> T getDataset(DatasetId datasetId, Map<String, String> arguments) throws DatasetInstantiationException { return getDataset(datasetId, arguments, AccessType.UNKNOWN); }
@Override public DynamicDatasetCache get() { SystemDatasetInstantiator dsInstantiator = new SystemDatasetInstantiator(dsFramework); return new MultiThreadDatasetCache( dsInstantiator, txClient, NamespaceId.SYSTEM, ImmutableMap.of(), metricsCollectionService.getContext(ImmutableMap.of()), ImmutableMap.of() ); } }
public <T extends Dataset> T getDataset(DatasetId datasetId) throws DatasetInstantiationException { return getDataset(datasetId, DatasetDefinition.NO_ARGUMENTS); }
@Inject public LocalRouteStore(DatasetFramework datasetFramework, TransactionSystemClient txClient) { this.datasetFramework = datasetFramework; this.transactional = Transactions.createTransactionalWithRetry( Transactions.createTransactional(new MultiThreadDatasetCache( new SystemDatasetInstantiator(datasetFramework), txClient, NamespaceId.SYSTEM, ImmutableMap.<String, String>of(), null, null)), RetryStrategies.retryOnConflict(20, 100)); }
public void initialize() throws IOException, DatasetManagementException, DatasetNotFoundException, ClassNotFoundException { dataset = datasetInstantiator.getDataset(datasetId); if (dataset instanceof TransactionAware) { ((TransactionAware) dataset).startTx(transaction); } }
@VisibleForTesting public DefaultFieldLineageReader(DatasetFramework datasetFramework, TransactionSystemClient txClient, DatasetId fieldLineageDatasetId) { this.datasetFramework = datasetFramework; this.fieldLineageDatasetId = fieldLineageDatasetId; this.transactional = Transactions.createTransactional(new MultiThreadDatasetCache( new SystemDatasetInstantiator(datasetFramework), new TransactionSystemClientAdapter(txClient), NamespaceId.SYSTEM, ImmutableMap.of(), null, null)); }
public void initialize() throws IOException, DatasetManagementException, DatasetNotFoundException, ClassNotFoundException { dataset = datasetInstantiator.getDataset(datasetId); if (dataset instanceof TransactionAware) { ((TransactionAware) dataset).startTx(transaction); } }
@Inject public MDSViewStore(DatasetFramework datasetFramework, TransactionSystemClient txClient) { this.datasetFramework = datasetFramework; this.transactional = Transactions.createTransactionalWithRetry( Transactions.createTransactional(new MultiThreadDatasetCache( new SystemDatasetInstantiator(datasetFramework), txClient, NamespaceId.SYSTEM, ImmutableMap.<String, String>of(), null, null)), RetryStrategies.retryOnConflict(20, 100) ); }
private String generateEnableStatement(DatasetId datasetId, DatasetSpecification spec, boolean truncating) throws UnsupportedTypeException, ExploreException { try (SystemDatasetInstantiator datasetInstantiator = datasetInstantiatorFactory.create()) { Dataset dataset = datasetInstantiator.getDataset(datasetId); try { return generateEnableStatement(dataset, spec, datasetId, tableNaming.getTableName(datasetId, spec.getProperties()), truncating); } finally { Closeables.closeQuietly(dataset); } } catch (IOException e) { throw new ExploreException("Exception while trying to instantiate dataset " + datasetId, e); } }