use of org.apache.asterix.common.api.IApplicationContext in project asterixdb by apache.
the class GenericAdapterFactory method configure.
@Override
public void configure(IServiceContext serviceContext, Map<String, String> configuration) throws HyracksDataException, AlgebricksException {
this.configuration = configuration;
IApplicationContext appCtx = (IApplicationContext) serviceContext.getApplicationContext();
ExternalDataUtils.validateDataSourceParameters(configuration);
dataSourceFactory = DatasourceFactoryProvider.getExternalDataSourceFactory(appCtx.getLibraryManager(), configuration);
if (dataSourceFactory.isIndexible() && (files != null)) {
((IIndexibleExternalDataSource) dataSourceFactory).setSnapshot(files, indexingOp);
}
dataSourceFactory.configure(serviceContext, configuration);
ExternalDataUtils.validateDataParserParameters(configuration);
dataParserFactory = ParserFactoryProvider.getDataParserFactory(appCtx.getLibraryManager(), configuration);
dataParserFactory.setRecordType(recordType);
dataParserFactory.setMetaType(metaType);
dataParserFactory.configure(configuration);
ExternalDataCompatibilityUtils.validateCompatibility(dataSourceFactory, dataParserFactory);
configureFeedLogManager();
nullifyExternalObjects();
}
use of org.apache.asterix.common.api.IApplicationContext in project asterixdb by apache.
the class LookupAdapterFactory method configure.
public void configure(IServiceContext serviceContext, Map<String, String> configuration) throws HyracksDataException, AlgebricksException {
this.configuration = configuration;
IApplicationContext appCtx = (IApplicationContext) serviceContext.getApplicationContext();
readerFactory = LookupReaderFactoryProvider.getLookupReaderFactory(serviceContext, configuration);
dataParserFactory = (IRecordDataParserFactory<T>) ParserFactoryProvider.getDataParserFactory(appCtx.getLibraryManager(), configuration);
dataParserFactory.setRecordType(recordType);
readerFactory.configure(serviceContext, configuration);
dataParserFactory.configure(configuration);
}
use of org.apache.asterix.common.api.IApplicationContext in project asterixdb by apache.
the class ReplicationCheckpointManager method getDeadReplicasMinFirstLSN.
private long getDeadReplicasMinFirstLSN(Set<String> deadReplicaIds) {
final IReplicaResourcesManager remoteResourcesManager = txnSubsystem.getAsterixAppRuntimeContextProvider().getAppContext().getReplicaResourcesManager();
final IApplicationContext propertiesProvider = txnSubsystem.getAsterixAppRuntimeContextProvider().getAppContext();
final MetadataProperties metadataProperties = propertiesProvider.getMetadataProperties();
final PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) txnSubsystem.getAsterixAppRuntimeContextProvider().getLocalResourceRepository();
// Get partitions of the dead replicas that are not active on this node
final Set<Integer> deadReplicasPartitions = new HashSet<>();
for (String deadReplicaId : deadReplicaIds) {
final ClusterPartition[] nodePartitons = metadataProperties.getNodePartitions().get(deadReplicaId);
for (ClusterPartition partition : nodePartitons) {
if (!localResourceRepository.getActivePartitions().contains(partition.getPartitionId())) {
deadReplicasPartitions.add(partition.getPartitionId());
}
}
}
return remoteResourcesManager.getPartitionsMinLSN(deadReplicasPartitions);
}
use of org.apache.asterix.common.api.IApplicationContext in project asterixdb by apache.
the class TestTypedAdapterFactory method createAdapter.
@Override
public IDataSourceAdapter createAdapter(IHyracksTaskContext ctx, int partition) throws HyracksDataException {
final String nodeId = ctx.getJobletContext().getServiceContext().getNodeId();
final ITupleParserFactory tupleParserFactory = new ITupleParserFactory() {
private static final long serialVersionUID = 1L;
@Override
public ITupleParser createTupleParser(IHyracksTaskContext ctx) throws HyracksDataException {
ADMDataParser parser;
ITupleForwarder forwarder;
ArrayTupleBuilder tb;
IApplicationContext appCtx = (IApplicationContext) ctx.getJobletContext().getServiceContext().getApplicationContext();
ClusterPartition nodePartition = appCtx.getMetadataProperties().getNodePartitions().get(nodeId)[0];
parser = new ADMDataParser(outputType, true);
forwarder = DataflowUtils.getTupleForwarder(configuration, FeedUtils.getFeedLogManager(ctx, FeedUtils.splitsForAdapter(ExternalDataUtils.getDataverse(configuration), ExternalDataUtils.getFeedName(configuration), nodeId, nodePartition)));
tb = new ArrayTupleBuilder(1);
return new ITupleParser() {
@Override
public void parse(InputStream in, IFrameWriter writer) throws HyracksDataException {
try {
parser.setInputStream(in);
forwarder.initialize(ctx, writer);
while (true) {
tb.reset();
if (!parser.parse(tb.getDataOutput())) {
break;
}
tb.addFieldEndOffset();
forwarder.addTuple(tb);
}
forwarder.close();
} catch (Exception e) {
throw new HyracksDataException(e);
}
}
};
}
};
try {
return new TestTypedAdapter(tupleParserFactory, outputType, ctx, configuration, partition);
} catch (IOException e) {
throw new HyracksDataException(e);
}
}
use of org.apache.asterix.common.api.IApplicationContext in project asterixdb by apache.
the class RSSRecordReaderFactory method getPartitionConstraint.
@Override
public AlgebricksAbsolutePartitionConstraint getPartitionConstraint() throws AlgebricksException {
int count = urls.size();
clusterLocations = IExternalDataSourceFactory.getPartitionConstraints((IApplicationContext) serviceContext.getApplicationContext(), clusterLocations, count);
return clusterLocations;
}
Aggregations