Search in sources :

Example 1 with ILibraryManager

use of org.apache.asterix.common.library.ILibraryManager in project asterixdb by apache.

the class CCApplication method start.

@Override
public void start(IServiceContext serviceCtx, String[] args) throws Exception {
    if (args.length > 0) {
        throw new IllegalArgumentException("Unrecognized argument(s): " + Arrays.toString(args));
    }
    final ClusterControllerService controllerService = (ClusterControllerService) serviceCtx.getControllerService();
    this.ccServiceCtx = (ICCServiceContext) serviceCtx;
    ccServiceCtx.setMessageBroker(new CCMessageBroker(controllerService));
    configureLoggingLevel(ccServiceCtx.getAppConfig().getLoggingLevel(ExternalProperties.Option.LOG_LEVEL));
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Starting Asterix cluster controller");
    }
    ccServiceCtx.setThreadFactory(new AsterixThreadFactory(ccServiceCtx.getThreadFactory(), new LifeCycleComponentManager()));
    ILibraryManager libraryManager = new ExternalLibraryManager();
    ResourceIdManager resourceIdManager = new ResourceIdManager();
    IReplicationStrategy repStrategy = ClusterProperties.INSTANCE.getReplicationStrategy();
    IFaultToleranceStrategy ftStrategy = FaultToleranceStrategyFactory.create(ClusterProperties.INSTANCE.getCluster(), repStrategy, ccServiceCtx);
    ExternalLibraryUtils.setUpExternaLibraries(libraryManager, false);
    componentProvider = new StorageComponentProvider();
    GlobalRecoveryManager.instantiate(ccServiceCtx, getHcc(), componentProvider);
    statementExecutorCtx = new StatementExecutorContext();
    appCtx = new CcApplicationContext(ccServiceCtx, getHcc(), libraryManager, resourceIdManager, () -> MetadataManager.INSTANCE, GlobalRecoveryManager.instance(), ftStrategy, new ActiveLifecycleListener(), componentProvider);
    ClusterStateManager.INSTANCE.setCcAppCtx(appCtx);
    ccExtensionManager = new CCExtensionManager(getExtensions());
    appCtx.setExtensionManager(ccExtensionManager);
    final CCConfig ccConfig = controllerService.getCCConfig();
    if (System.getProperty("java.rmi.server.hostname") == null) {
        System.setProperty("java.rmi.server.hostname", ccConfig.getClusterListenAddress());
    }
    MetadataProperties metadataProperties = appCtx.getMetadataProperties();
    setAsterixStateProxy(AsterixStateProxy.registerRemoteObject(metadataProperties.getMetadataCallbackPort()));
    ccServiceCtx.setDistributedState(proxy);
    MetadataManager.initialize(proxy, metadataProperties);
    ccServiceCtx.addJobLifecycleListener(appCtx.getActiveLifecycleListener());
    // create event loop groups
    webManager = new WebManager();
    configureServers();
    webManager.start();
    ClusterManagerProvider.getClusterManager().registerSubscriber(GlobalRecoveryManager.instance());
    ccServiceCtx.addClusterLifecycleListener(new ClusterLifecycleListener(appCtx));
    jobCapacityController = new JobCapacityController(controllerService.getResourceManager());
}
Also used : IStatementExecutorContext(org.apache.asterix.translator.IStatementExecutorContext) StatementExecutorContext(org.apache.asterix.api.http.ctx.StatementExecutorContext) ILibraryManager(org.apache.asterix.common.library.ILibraryManager) CCMessageBroker(org.apache.asterix.messaging.CCMessageBroker) IStorageComponentProvider(org.apache.asterix.common.context.IStorageComponentProvider) StorageComponentProvider(org.apache.asterix.file.StorageComponentProvider) MetadataProperties(org.apache.asterix.common.config.MetadataProperties) AsterixThreadFactory(org.apache.asterix.common.api.AsterixThreadFactory) IFaultToleranceStrategy(org.apache.asterix.common.replication.IFaultToleranceStrategy) ResourceIdManager(org.apache.asterix.app.cc.ResourceIdManager) CCExtensionManager(org.apache.asterix.app.cc.CCExtensionManager) CcApplicationContext(org.apache.asterix.runtime.utils.CcApplicationContext) ActiveLifecycleListener(org.apache.asterix.active.ActiveLifecycleListener) WebManager(org.apache.hyracks.http.server.WebManager) IJobCapacityController(org.apache.hyracks.api.job.resource.IJobCapacityController) JobCapacityController(org.apache.asterix.runtime.job.resource.JobCapacityController) CCConfig(org.apache.hyracks.control.common.controllers.CCConfig) IReplicationStrategy(org.apache.asterix.common.replication.IReplicationStrategy) LifeCycleComponentManager(org.apache.hyracks.api.lifecycle.LifeCycleComponentManager) ExternalLibraryManager(org.apache.asterix.external.library.ExternalLibraryManager) ClusterControllerService(org.apache.hyracks.control.cc.ClusterControllerService)

Example 2 with ILibraryManager

use of org.apache.asterix.common.library.ILibraryManager in project asterixdb by apache.

the class TestLibrarian method install.

@Override
public void install(String dvName, String libName, String libPath) throws Exception {
    // get the directory of the to be installed libraries
    File installLibDir = ExternalLibraryUtils.getLibraryInstallDir();
    // directory exists?
    if (!installLibDir.exists()) {
        installLibDir.mkdir();
    }
    // copy the library file into the directory
    File destinationDir = new File(installLibDir.getAbsolutePath() + File.separator + dvName + File.separator + libName);
    FileUtils.deleteQuietly(destinationDir);
    destinationDir.mkdirs();
    try {
        AsterixEventServiceUtil.unzip(libPath, destinationDir.getAbsolutePath());
    } catch (Exception e) {
        throw new Exception("Couldn't unzip the file: " + libPath, e);
    }
    for (ILibraryManager libraryManager : libraryManagers) {
        ExternalLibraryUtils.registerLibrary(libraryManager, dvName, libName);
    }
    // get library file
    // install if needed (add functions, adapters, datasources, parsers to the metadata)
    // <Not required for use>
    ExternalLibraryUtils.installLibraryIfNeeded(dvName, destinationDir, new HashMap<>());
}
Also used : ILibraryManager(org.apache.asterix.common.library.ILibraryManager) File(java.io.File) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IOException(java.io.IOException) AsterixException(org.apache.asterix.common.exceptions.AsterixException) RemoteException(java.rmi.RemoteException) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 3 with ILibraryManager

use of org.apache.asterix.common.library.ILibraryManager 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 4 with ILibraryManager

use of org.apache.asterix.common.library.ILibraryManager in project asterixdb by apache.

the class TestLibrarian method cleanup.

public void cleanup() throws AsterixException, RemoteException, ACIDException {
    for (ILibraryManager libraryManager : libraryManagers) {
        List<Pair<String, String>> libs = libraryManager.getAllLibraries();
        for (Pair<String, String> dvAndLib : libs) {
            ExternalLibraryUtils.uninstallLibrary(dvAndLib.first, dvAndLib.second);
            libraryManager.deregisterLibraryClassLoader(dvAndLib.first, dvAndLib.second);
        }
    }
    // get the directory of the to be installed libraries
    File installLibDir = ExternalLibraryUtils.getLibraryInstallDir();
    FileUtils.deleteQuietly(installLibDir);
}
Also used : ILibraryManager(org.apache.asterix.common.library.ILibraryManager) File(java.io.File) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Example 5 with ILibraryManager

use of org.apache.asterix.common.library.ILibraryManager 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)

Aggregations

ILibraryManager (org.apache.asterix.common.library.ILibraryManager)6 File (java.io.File)3 INcApplicationContext (org.apache.asterix.common.api.INcApplicationContext)2 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)2 IOException (java.io.IOException)1 RemoteException (java.rmi.RemoteException)1 ArrayList (java.util.ArrayList)1 ActiveLifecycleListener (org.apache.asterix.active.ActiveLifecycleListener)1 StatementExecutorContext (org.apache.asterix.api.http.ctx.StatementExecutorContext)1 CCExtensionManager (org.apache.asterix.app.cc.CCExtensionManager)1 ResourceIdManager (org.apache.asterix.app.cc.ResourceIdManager)1 TestLibrarian (org.apache.asterix.app.external.TestLibrarian)1 AsterixThreadFactory (org.apache.asterix.common.api.AsterixThreadFactory)1 MetadataProperties (org.apache.asterix.common.config.MetadataProperties)1 IStorageComponentProvider (org.apache.asterix.common.context.IStorageComponentProvider)1 ACIDException (org.apache.asterix.common.exceptions.ACIDException)1 AsterixException (org.apache.asterix.common.exceptions.AsterixException)1 RuntimeDataException (org.apache.asterix.common.exceptions.RuntimeDataException)1 IFaultToleranceStrategy (org.apache.asterix.common.replication.IFaultToleranceStrategy)1 IReplicationStrategy (org.apache.asterix.common.replication.IReplicationStrategy)1