Search in sources :

Example 1 with INcApplicationContext

use of org.apache.asterix.common.api.INcApplicationContext in project asterixdb by apache.

the class JobEventListenerFactory method createListener.

@Override
public IJobletEventListener createListener(final IHyracksJobletContext jobletContext) {
    return new IJobletEventListener() {

        @Override
        public void jobletFinish(JobStatus jobStatus) {
            try {
                ITransactionManager txnManager = ((INcApplicationContext) jobletContext.getServiceContext().getApplicationContext()).getTransactionSubsystem().getTransactionManager();
                ITransactionContext txnContext = txnManager.getTransactionContext(jobId, false);
                txnContext.setWriteTxn(transactionalWrite);
                txnManager.completedTransaction(txnContext, DatasetId.NULL, -1, !(jobStatus == JobStatus.FAILURE));
            } catch (ACIDException e) {
                throw new Error(e);
            }
        }

        @Override
        public void jobletStart() {
            try {
                ((INcApplicationContext) jobletContext.getServiceContext().getApplicationContext()).getTransactionSubsystem().getTransactionManager().getTransactionContext(jobId, true);
            } catch (ACIDException e) {
                throw new Error(e);
            }
        }
    };
}
Also used : JobStatus(org.apache.hyracks.api.job.JobStatus) INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext) ITransactionManager(org.apache.asterix.common.transactions.ITransactionManager) ITransactionContext(org.apache.asterix.common.transactions.ITransactionContext) IJobletEventListener(org.apache.hyracks.api.job.IJobletEventListener) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 2 with INcApplicationContext

use of org.apache.asterix.common.api.INcApplicationContext in project asterixdb by apache.

the class FeedIntakeOperatorDescriptor method createExternalAdapterFactory.

private IAdapterFactory createExternalAdapterFactory(IHyracksTaskContext ctx) throws HyracksDataException {
    IAdapterFactory adapterFactory;
    INcApplicationContext runtimeCtx = (INcApplicationContext) ctx.getJobletContext().getServiceContext().getApplicationContext();
    ILibraryManager libraryManager = runtimeCtx.getLibraryManager();
    ClassLoader classLoader = libraryManager.getLibraryClassLoader(feedId.getDataverse(), adaptorLibraryName);
    if (classLoader != null) {
        try {
            adapterFactory = (IAdapterFactory) (classLoader.loadClass(adaptorFactoryClassName).newInstance());
            adapterFactory.setOutputType(adapterOutputType);
            adapterFactory.configure(ctx.getJobletContext().getServiceContext(), adaptorConfiguration);
        } catch (Exception e) {
            throw new HyracksDataException(e);
        }
    } else {
        RuntimeDataException err = new RuntimeDataException(ErrorCode.OPERATORS_FEED_INTAKE_OPERATOR_DESCRIPTOR_CLASSLOADER_NOT_CONFIGURED, adaptorLibraryName, feedId.getDataverse());
        LOGGER.severe(err.getMessage());
        throw err;
    }
    return adapterFactory;
}
Also used : INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext) ILibraryManager(org.apache.asterix.common.library.ILibraryManager) IAdapterFactory(org.apache.asterix.external.api.IAdapterFactory) RuntimeDataException(org.apache.asterix.common.exceptions.RuntimeDataException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) RuntimeDataException(org.apache.asterix.common.exceptions.RuntimeDataException)

Example 3 with INcApplicationContext

use of org.apache.asterix.common.api.INcApplicationContext in project asterixdb by apache.

the class CheckpointTask method perform.

@Override
public void perform(IControllerService cs) throws HyracksDataException {
    INcApplicationContext appContext = (INcApplicationContext) cs.getApplicationContext();
    ICheckpointManager checkpointMgr = appContext.getTransactionSubsystem().getCheckpointManager();
    checkpointMgr.doSharpCheckpoint();
}
Also used : ICheckpointManager(org.apache.asterix.common.transactions.ICheckpointManager) INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext)

Example 4 with INcApplicationContext

use of org.apache.asterix.common.api.INcApplicationContext in project asterixdb by apache.

the class RemoteRecoveryTask method perform.

@Override
public void perform(IControllerService cs) throws HyracksDataException {
    INcApplicationContext appContext = (INcApplicationContext) cs.getApplicationContext();
    appContext.getRemoteRecoveryManager().doRemoteRecoveryPlan(recoveryPlan);
}
Also used : INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext)

Example 5 with INcApplicationContext

use of org.apache.asterix.common.api.INcApplicationContext in project asterixdb by apache.

the class StartFailbackTask method perform.

@Override
public void perform(IControllerService cs) throws HyracksDataException {
    INcApplicationContext appContext = (INcApplicationContext) cs.getApplicationContext();
    appContext.getRemoteRecoveryManager().startFailbackProcess();
}
Also used : INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext)

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