use of org.apache.asterix.common.api.INcApplicationContext in project asterixdb by apache.
the class ExecutionTestUtil method setUp.
public static List<ILibraryManager> setUp(boolean cleanup, String configFile, AsterixHyracksIntegrationUtil alternateIntegrationUtil, boolean startHdfs) throws Exception {
System.out.println("Starting setup");
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("Starting setup");
}
System.setProperty(GlobalConfig.CONFIG_FILE_PROPERTY, configFile);
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("initializing pseudo cluster");
}
integrationUtil = alternateIntegrationUtil;
integrationUtil.init(cleanup);
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("initializing HDFS");
}
if (startHdfs) {
HDFSCluster.getInstance().setup();
}
// Set the node resolver to be the identity resolver that expects node
// names
// to be node controller ids; a valid assumption in test environment.
System.setProperty(ExternalDataConstants.NODE_RESOLVER_FACTORY_PROPERTY, IdentitiyResolverFactory.class.getName());
FailedGroup = new TestGroup();
FailedGroup.setName("failed");
List<ILibraryManager> libraryManagers = new ArrayList<>();
// Adds the library manager for CC.
libraryManagers.add(((ICcApplicationContext) integrationUtil.cc.getApplicationContext()).getLibraryManager());
// Adds library managers for NCs, one-per-NC.
for (NodeControllerService nc : integrationUtil.ncs) {
INcApplicationContext runtimeCtx = (INcApplicationContext) nc.getApplicationContext();
libraryManagers.add(runtimeCtx.getLibraryManager());
}
return libraryManagers;
}
use of org.apache.asterix.common.api.INcApplicationContext in project asterixdb by apache.
the class CorrelatedPrefixMergePolicyFactory method createMergePolicy.
@Override
public ILSMMergePolicy createMergePolicy(Map<String, String> configuration, INCServiceContext ctx) {
IDatasetLifecycleManager dslcManager = ((INcApplicationContext) ctx.getApplicationContext()).getDatasetLifecycleManager();
int datasetId = Integer.parseInt(configuration.get(KEY_DATASET_ID));
ILSMMergePolicy policy = new CorrelatedPrefixMergePolicy(dslcManager, datasetId);
policy.configure(configuration);
return policy;
}
use of org.apache.asterix.common.api.INcApplicationContext in project asterixdb by apache.
the class LSMPrimaryUpsertOperatorNodePushable method open.
// we have the permutation which has [pk locations, record location, optional:filter-location]
// the index -> we don't need anymore data?
// we need to use the primary index opTracker and secondary indexes callbacks for insert/delete since the lock would
// have been obtained through searchForUpsert operation
@Override
public void open() throws HyracksDataException {
accessor = new FrameTupleAccessor(inputRecDesc);
writeBuffer = new VSizeFrame(ctx);
writer.open();
indexHelper.open();
index = indexHelper.getIndexInstance();
try {
if (ctx.getSharedObject() != null) {
PrimaryIndexLogMarkerCallback callback = new PrimaryIndexLogMarkerCallback((AbstractLSMIndex) index);
TaskUtil.putInSharedMap(ILogMarkerCallback.KEY_MARKER_CALLBACK, callback, ctx);
}
missingTupleBuilder = new ArrayTupleBuilder(1);
DataOutput out = missingTupleBuilder.getDataOutput();
try {
missingWriter.writeMissing(out);
} catch (IOException e) {
throw new HyracksDataException(e);
}
missingTupleBuilder.addFieldEndOffset();
searchPred = createSearchPredicate();
tb = new ArrayTupleBuilder(recordDesc.getFieldCount());
dos = tb.getDataOutput();
appender = new FrameTupleAppender(new VSizeFrame(ctx), true);
modCallback = modOpCallbackFactory.createModificationOperationCallback(indexHelper.getResource(), ctx, this);
abstractModCallback = (AbstractIndexModificationOperationCallback) modCallback;
searchCallback = (LockThenSearchOperationCallback) searchCallbackFactory.createSearchOperationCallback(indexHelper.getResource().getId(), ctx, this);
indexAccessor = index.createAccessor(abstractModCallback, searchCallback);
lsmAccessor = (LSMTreeIndexAccessor) indexAccessor;
cursor = indexAccessor.createSearchCursor(false);
frameTuple = new FrameTupleReference();
INcApplicationContext appCtx = (INcApplicationContext) ctx.getJobletContext().getServiceContext().getApplicationContext();
LSMIndexUtil.checkAndSetFirstLSN((AbstractLSMIndex) index, appCtx.getTransactionSubsystem().getLogManager());
frameOpCallback = new IFrameOperationCallback() {
IFrameOperationCallback callback = frameOpCallbackFactory.createFrameOperationCallback(ctx, (ILSMIndexAccessor) indexAccessor);
@Override
public void frameCompleted() throws HyracksDataException {
callback.frameCompleted();
appender.write(writer, true);
}
};
} catch (Exception e) {
indexHelper.close();
throw new HyracksDataException(e);
}
}
use of org.apache.asterix.common.api.INcApplicationContext in project asterixdb by apache.
the class FlushDatasetOperatorDescriptor method createPushRuntime.
@Override
public IOperatorNodePushable createPushRuntime(final IHyracksTaskContext ctx, IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) throws HyracksDataException {
return new AbstractUnaryInputSinkOperatorNodePushable() {
@Override
public void open() throws HyracksDataException {
}
@Override
public void nextFrame(ByteBuffer buffer) throws HyracksDataException {
}
@Override
public void fail() throws HyracksDataException {
this.close();
}
@Override
public void close() throws HyracksDataException {
try {
INcApplicationContext appCtx = (INcApplicationContext) ctx.getJobletContext().getServiceContext().getApplicationContext();
IDatasetLifecycleManager datasetLifeCycleManager = appCtx.getDatasetLifecycleManager();
ILockManager lockManager = appCtx.getTransactionSubsystem().getLockManager();
ITransactionManager txnManager = appCtx.getTransactionSubsystem().getTransactionManager();
// get the local transaction
ITransactionContext txnCtx = txnManager.getTransactionContext(jobId, false);
// lock the dataset granule
lockManager.lock(datasetId, -1, LockMode.S, txnCtx);
// flush the dataset synchronously
datasetLifeCycleManager.flushDataset(datasetId.getId(), false);
} catch (ACIDException e) {
throw new HyracksDataException(e);
}
}
};
}
use of org.apache.asterix.common.api.INcApplicationContext in project asterixdb by apache.
the class ReportMaxResourceIdMessage method send.
public static void send(NodeControllerService cs) throws HyracksDataException {
NodeControllerService ncs = cs;
INcApplicationContext appContext = (INcApplicationContext) ncs.getApplicationContext();
long maxResourceId = Math.max(appContext.getLocalResourceRepository().maxId(), MetadataIndexImmutableProperties.FIRST_AVAILABLE_USER_DATASET_ID);
ReportMaxResourceIdMessage maxResourceIdMsg = new ReportMaxResourceIdMessage(ncs.getId(), maxResourceId);
try {
((INCMessageBroker) ncs.getContext().getMessageBroker()).sendMessageToCC(maxResourceIdMsg);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Unable to report max local resource id", e);
throw HyracksDataException.create(e);
}
}
Aggregations