Search in sources :

Example 1 with MetadataProperties

use of org.apache.asterix.common.config.MetadataProperties 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 MetadataProperties

use of org.apache.asterix.common.config.MetadataProperties in project asterixdb by apache.

the class NCApplication 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));
    }
    this.ncServiceCtx = (INCServiceContext) serviceCtx;
    ncServiceCtx.setThreadFactory(new AsterixThreadFactory(ncServiceCtx.getThreadFactory(), ncServiceCtx.getLifeCycleComponentManager()));
    nodeId = this.ncServiceCtx.getNodeId();
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Starting Asterix node controller: " + nodeId);
    }
    configureLoggingLevel(ncServiceCtx.getAppConfig().getLoggingLevel(ExternalProperties.Option.LOG_LEVEL));
    final NodeControllerService controllerService = (NodeControllerService) ncServiceCtx.getControllerService();
    if (System.getProperty("java.rmi.server.hostname") == null) {
        System.setProperty("java.rmi.server.hostname", (controllerService).getConfiguration().getClusterPublicAddress());
    }
    runtimeContext = new NCAppRuntimeContext(this.ncServiceCtx, getExtensions());
    MetadataProperties metadataProperties = runtimeContext.getMetadataProperties();
    if (!metadataProperties.getNodeNames().contains(this.ncServiceCtx.getNodeId())) {
        if (LOGGER.isLoggable(Level.INFO)) {
            LOGGER.info("Substitute node joining : " + this.ncServiceCtx.getNodeId());
        }
        updateOnNodeJoin();
    }
    runtimeContext.initialize(runtimeContext.getNodeProperties().isInitialRun());
    MessagingProperties messagingProperties = runtimeContext.getMessagingProperties();
    IMessageBroker messageBroker = new NCMessageBroker(controllerService, messagingProperties);
    this.ncServiceCtx.setMessageBroker(messageBroker);
    MessagingChannelInterfaceFactory interfaceFactory = new MessagingChannelInterfaceFactory((NCMessageBroker) messageBroker, messagingProperties);
    this.ncServiceCtx.setMessagingChannelInterfaceFactory(interfaceFactory);
    IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
    systemState = recoveryMgr.getSystemState();
    if (systemState == SystemState.PERMANENT_DATA_LOSS) {
        if (LOGGER.isLoggable(Level.INFO)) {
            LOGGER.info("System state: " + SystemState.PERMANENT_DATA_LOSS);
            LOGGER.info("Node ID: " + nodeId);
            LOGGER.info("Stores: " + PrintUtil.toString(metadataProperties.getStores()));
            LOGGER.info("Root Metadata Store: " + metadataProperties.getStores().get(nodeId)[0]);
        }
        PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext.getLocalResourceRepository();
        localResourceRepository.initializeNewUniverse(ClusterProperties.INSTANCE.getStorageDirectoryName());
    }
    webManager = new WebManager();
    performLocalCleanUp();
}
Also used : NodeControllerService(org.apache.hyracks.control.nc.NodeControllerService) PersistentLocalResourceRepository(org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository) MessagingChannelInterfaceFactory(org.apache.asterix.messaging.MessagingChannelInterfaceFactory) WebManager(org.apache.hyracks.http.server.WebManager) NCAppRuntimeContext(org.apache.asterix.app.nc.NCAppRuntimeContext) IMessageBroker(org.apache.hyracks.api.messages.IMessageBroker) MetadataProperties(org.apache.asterix.common.config.MetadataProperties) NCMessageBroker(org.apache.asterix.messaging.NCMessageBroker) AsterixThreadFactory(org.apache.asterix.common.api.AsterixThreadFactory) MessagingProperties(org.apache.asterix.common.config.MessagingProperties) IRecoveryManager(org.apache.asterix.common.transactions.IRecoveryManager)

Example 3 with MetadataProperties

use of org.apache.asterix.common.config.MetadataProperties in project asterixdb by apache.

the class MetadataBootstrap method startUniverse.

/**
     * bootstrap metadata
     *
     * @param ncServiceContext
     * @param isNewUniverse
     * @throws ACIDException
     * @throws RemoteException
     * @throws MetadataException
     * @throws Exception
     */
public static void startUniverse(INCServiceContext ncServiceContext, boolean isNewUniverse) throws RemoteException, ACIDException, MetadataException {
    MetadataBootstrap.setNewUniverse(isNewUniverse);
    appContext = (INcApplicationContext) ncServiceContext.getApplicationContext();
    MetadataProperties metadataProperties = appContext.getMetadataProperties();
    metadataNodeName = metadataProperties.getMetadataNodeName();
    nodeNames = metadataProperties.getNodeNames();
    localResourceRepository = appContext.getLocalResourceRepository();
    ioManager = ncServiceContext.getIoManager();
    MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
    try {
        // Begin a transaction against the metadata.
        // Lock the metadata in X mode.
        MetadataManager.INSTANCE.lock(mdTxnCtx, LockMode.X);
        for (int i = 0; i < PRIMARY_INDEXES.length; i++) {
            enlistMetadataDataset(ncServiceContext, PRIMARY_INDEXES[i]);
        }
        if (LOGGER.isLoggable(Level.INFO)) {
            LOGGER.info("Finished enlistment of metadata B-trees in " + (isNewUniverse ? "new" : "old") + " universe");
        }
        if (isNewUniverse) {
            insertInitialDataverses(mdTxnCtx);
            insertMetadataDatasets(mdTxnCtx, PRIMARY_INDEXES);
            insertMetadataDatatypes(mdTxnCtx);
            insertNodes(mdTxnCtx);
            insertInitialGroups(mdTxnCtx);
            insertInitialAdapters(mdTxnCtx);
            insertInitialFeedPolicies(mdTxnCtx);
            insertInitialCompactionPolicies(mdTxnCtx);
            if (LOGGER.isLoggable(Level.INFO)) {
                LOGGER.info("Finished creating metadata B-trees.");
            }
        }
        // #. initialize datasetIdFactory
        MetadataManager.INSTANCE.initializeDatasetIdFactory(mdTxnCtx);
        MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
    } catch (Exception e) {
        try {
            if (IS_DEBUG_MODE) {
                LOGGER.log(Level.SEVERE, "Failure during metadata bootstrap", e);
            }
            MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
        } catch (Exception e2) {
            e.addSuppressed(e2);
            // TODO change the exception type to AbortFailureException
            throw new MetadataException(e);
        }
        throw new MetadataException(e);
    }
}
Also used : MetadataTransactionContext(org.apache.asterix.metadata.MetadataTransactionContext) MetadataProperties(org.apache.asterix.common.config.MetadataProperties) ACIDException(org.apache.asterix.common.exceptions.ACIDException) MetadataException(org.apache.asterix.metadata.MetadataException) RemoteException(java.rmi.RemoteException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) MetadataException(org.apache.asterix.metadata.MetadataException)

Example 4 with MetadataProperties

use of org.apache.asterix.common.config.MetadataProperties in project asterixdb by apache.

the class LangExpressionToPlanTranslator method getDefaultOutputFileLocation.

private FileSplit getDefaultOutputFileLocation(ICcApplicationContext appCtx) throws MetadataException {
    String outputDir = System.getProperty("java.io.tmpDir");
    String filePath = outputDir + System.getProperty("file.separator") + OUTPUT_FILE_PREFIX + outputFileID.incrementAndGet();
    MetadataProperties metadataProperties = appCtx.getMetadataProperties();
    return new ManagedFileSplit(metadataProperties.getMetadataNodeName(), filePath);
}
Also used : ManagedFileSplit(org.apache.hyracks.api.io.ManagedFileSplit) AString(org.apache.asterix.om.base.AString) MetadataProperties(org.apache.asterix.common.config.MetadataProperties)

Example 5 with MetadataProperties

use of org.apache.asterix.common.config.MetadataProperties in project asterixdb by apache.

the class ReplicationCheckpointManager method getDeadReplicasMinFirstLSN.

private long getDeadReplicasMinFirstLSN(Set<String> deadReplicaIds) {
    final IReplicaResourcesManager remoteResourcesManager = txnSubsystem.getAsterixAppRuntimeContextProvider().getAppContext().getReplicaResourcesManager();
    final IApplicationContext propertiesProvider = txnSubsystem.getAsterixAppRuntimeContextProvider().getAppContext();
    final MetadataProperties metadataProperties = propertiesProvider.getMetadataProperties();
    final PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) txnSubsystem.getAsterixAppRuntimeContextProvider().getLocalResourceRepository();
    // Get partitions of the dead replicas that are not active on this node
    final Set<Integer> deadReplicasPartitions = new HashSet<>();
    for (String deadReplicaId : deadReplicaIds) {
        final ClusterPartition[] nodePartitons = metadataProperties.getNodePartitions().get(deadReplicaId);
        for (ClusterPartition partition : nodePartitons) {
            if (!localResourceRepository.getActivePartitions().contains(partition.getPartitionId())) {
                deadReplicasPartitions.add(partition.getPartitionId());
            }
        }
    }
    return remoteResourcesManager.getPartitionsMinLSN(deadReplicasPartitions);
}
Also used : PersistentLocalResourceRepository(org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository) IReplicaResourcesManager(org.apache.asterix.common.replication.IReplicaResourcesManager) IApplicationContext(org.apache.asterix.common.api.IApplicationContext) MetadataProperties(org.apache.asterix.common.config.MetadataProperties) HashSet(java.util.HashSet) ClusterPartition(org.apache.asterix.common.cluster.ClusterPartition)

Aggregations

MetadataProperties (org.apache.asterix.common.config.MetadataProperties)7 AsterixThreadFactory (org.apache.asterix.common.api.AsterixThreadFactory)2 PersistentLocalResourceRepository (org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository)2 NodeControllerService (org.apache.hyracks.control.nc.NodeControllerService)2 WebManager (org.apache.hyracks.http.server.WebManager)2 RemoteException (java.rmi.RemoteException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)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 NCAppRuntimeContext (org.apache.asterix.app.nc.NCAppRuntimeContext)1 IApplicationContext (org.apache.asterix.common.api.IApplicationContext)1 INcApplicationContext (org.apache.asterix.common.api.INcApplicationContext)1 ClusterPartition (org.apache.asterix.common.cluster.ClusterPartition)1 MessagingProperties (org.apache.asterix.common.config.MessagingProperties)1 TransactionProperties (org.apache.asterix.common.config.TransactionProperties)1 IStorageComponentProvider (org.apache.asterix.common.context.IStorageComponentProvider)1 ACIDException (org.apache.asterix.common.exceptions.ACIDException)1