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());
}
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<>());
}
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;
}
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);
}
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;
}
Aggregations