Search in sources :

Example 11 with INcApplicationContext

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;
}
Also used : NodeControllerService(org.apache.hyracks.control.nc.NodeControllerService) INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext) ILibraryManager(org.apache.asterix.common.library.ILibraryManager) ArrayList(java.util.ArrayList) TestGroup(org.apache.asterix.testframework.xml.TestGroup) IdentitiyResolverFactory(org.apache.asterix.external.util.IdentitiyResolverFactory)

Example 12 with INcApplicationContext

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;
}
Also used : IDatasetLifecycleManager(org.apache.asterix.common.api.IDatasetLifecycleManager) INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext) ILSMMergePolicy(org.apache.hyracks.storage.am.lsm.common.api.ILSMMergePolicy)

Example 13 with INcApplicationContext

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);
    }
}
Also used : DataOutput(java.io.DataOutput) INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext) FrameTupleReference(org.apache.hyracks.dataflow.common.data.accessors.FrameTupleReference) PermutingFrameTupleReference(org.apache.hyracks.storage.am.common.tuples.PermutingFrameTupleReference) ArrayTupleBuilder(org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder) IOException(java.io.IOException) PrimaryIndexLogMarkerCallback(org.apache.asterix.common.transactions.PrimaryIndexLogMarkerCallback) VSizeFrame(org.apache.hyracks.api.comm.VSizeFrame) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) AsterixException(org.apache.asterix.common.exceptions.AsterixException) ACIDException(org.apache.asterix.common.exceptions.ACIDException) IOException(java.io.IOException) IFrameOperationCallback(org.apache.hyracks.storage.am.lsm.common.api.IFrameOperationCallback) FrameTupleAppender(org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender) FrameTupleAccessor(org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor)

Example 14 with INcApplicationContext

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);
            }
        }
    };
}
Also used : IDatasetLifecycleManager(org.apache.asterix.common.api.IDatasetLifecycleManager) AbstractUnaryInputSinkOperatorNodePushable(org.apache.hyracks.dataflow.std.base.AbstractUnaryInputSinkOperatorNodePushable) INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext) ILockManager(org.apache.asterix.common.transactions.ILockManager) ITransactionManager(org.apache.asterix.common.transactions.ITransactionManager) ITransactionContext(org.apache.asterix.common.transactions.ITransactionContext) ByteBuffer(java.nio.ByteBuffer) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 15 with INcApplicationContext

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);
    }
}
Also used : NodeControllerService(org.apache.hyracks.control.nc.NodeControllerService) INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext) INCMessageBroker(org.apache.asterix.common.messaging.api.INCMessageBroker) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Aggregations

INcApplicationContext (org.apache.asterix.common.api.INcApplicationContext)16 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)8 ACIDException (org.apache.asterix.common.exceptions.ACIDException)4 ITransactionContext (org.apache.asterix.common.transactions.ITransactionContext)3 ITransactionManager (org.apache.asterix.common.transactions.ITransactionManager)3 IDatasetLifecycleManager (org.apache.asterix.common.api.IDatasetLifecycleManager)2 ILibraryManager (org.apache.asterix.common.library.ILibraryManager)2 PrimaryIndexLogMarkerCallback (org.apache.asterix.common.transactions.PrimaryIndexLogMarkerCallback)2 VSizeFrame (org.apache.hyracks.api.comm.VSizeFrame)2 IJobletEventListener (org.apache.hyracks.api.job.IJobletEventListener)2 JobStatus (org.apache.hyracks.api.job.JobStatus)2 NodeControllerService (org.apache.hyracks.control.nc.NodeControllerService)2 FrameTupleAccessor (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor)2 FrameTupleAppender (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender)2 FrameTupleReference (org.apache.hyracks.dataflow.common.data.accessors.FrameTupleReference)2 DataOutput (java.io.DataOutput)1 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1