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