Search in sources :

Example 1 with ClusterControllerService

use of org.apache.hyracks.control.cc.ClusterControllerService 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 ClusterControllerService

use of org.apache.hyracks.control.cc.ClusterControllerService in project asterixdb by apache.

the class RuntimeUtils method getForcedNodeControllerMap.

public static Map<InetAddress, Set<String>> getForcedNodeControllerMap(ICcApplicationContext appCtx) {
    ClusterControllerService ccs = (ClusterControllerService) appCtx.getServiceContext().getControllerService();
    INodeManager nodeManager = ccs.getNodeManager();
    return nodeManager.getIpAddressNodeNameMap();
}
Also used : INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) ClusterControllerService(org.apache.hyracks.control.cc.ClusterControllerService)

Example 3 with ClusterControllerService

use of org.apache.hyracks.control.cc.ClusterControllerService in project asterixdb by apache.

the class AbstractIntegrationTest method init.

@BeforeClass
public static void init() throws Exception {
    CCConfig ccConfig = new CCConfig();
    ccConfig.setClientListenAddress("127.0.0.1");
    ccConfig.setClientListenPort(39000);
    ccConfig.setClusterListenAddress("127.0.0.1");
    ccConfig.setClusterListenPort(39001);
    ccConfig.setProfileDumpPeriod(10000);
    FileUtils.deleteQuietly(new File("target" + File.separator + "data"));
    FileUtils.copyDirectory(new File("data"), new File(joinPath("target", "data")));
    File outDir = new File("target" + File.separator + "ClusterController");
    outDir.mkdirs();
    File ccRoot = File.createTempFile(AbstractIntegrationTest.class.getName(), ".data", outDir);
    ccRoot.delete();
    ccRoot.mkdir();
    ccConfig.setRootDir(ccRoot.getAbsolutePath());
    cc = new ClusterControllerService(ccConfig);
    cc.start();
    NCConfig ncConfig1 = new NCConfig(NC1_ID);
    ncConfig1.setClusterAddress("localhost");
    ncConfig1.setClusterPort(39001);
    ncConfig1.setClusterListenAddress("127.0.0.1");
    ncConfig1.setDataListenAddress("127.0.0.1");
    ncConfig1.setResultListenAddress("127.0.0.1");
    ncConfig1.setIODevices(new String[] { joinPath(System.getProperty("user.dir"), "target", "data", "device0") });
    nc1 = new NodeControllerService(ncConfig1);
    nc1.start();
    NCConfig ncConfig2 = new NCConfig(NC2_ID);
    ncConfig2.setClusterAddress("localhost");
    ncConfig2.setClusterPort(39001);
    ncConfig2.setClusterListenAddress("127.0.0.1");
    ncConfig2.setDataListenAddress("127.0.0.1");
    ncConfig2.setResultListenAddress("127.0.0.1");
    ncConfig2.setIODevices(new String[] { joinPath(System.getProperty("user.dir"), "target", "data", "device1") });
    nc2 = new NodeControllerService(ncConfig2);
    nc2.start();
    hcc = new HyracksConnection(ccConfig.getClientListenAddress(), ccConfig.getClientListenPort());
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Starting CC in " + ccRoot.getAbsolutePath());
    }
}
Also used : NodeControllerService(org.apache.hyracks.control.nc.NodeControllerService) CCConfig(org.apache.hyracks.control.common.controllers.CCConfig) NCConfig(org.apache.hyracks.control.common.controllers.NCConfig) HyracksConnection(org.apache.hyracks.api.client.HyracksConnection) File(java.io.File) ClusterControllerService(org.apache.hyracks.control.cc.ClusterControllerService) BeforeClass(org.junit.BeforeClass)

Example 4 with ClusterControllerService

use of org.apache.hyracks.control.cc.ClusterControllerService in project asterixdb by apache.

the class JobManagerTest method mockClusterControllerService.

private ClusterControllerService mockClusterControllerService() {
    ClusterControllerService ccs = mock(ClusterControllerService.class);
    CCServiceContext ccServiceCtx = mock(CCServiceContext.class);
    LogFile logFile = mock(LogFile.class);
    INodeManager nodeManager = mockNodeManager();
    when(ccs.getContext()).thenReturn(ccServiceCtx);
    when(ccs.getJobLogFile()).thenReturn(logFile);
    when(ccs.getNodeManager()).thenReturn(nodeManager);
    when(ccs.getCCConfig()).thenReturn(ccConfig);
    return ccs;
}
Also used : LogFile(org.apache.hyracks.control.common.logs.LogFile) INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) CCServiceContext(org.apache.hyracks.control.cc.application.CCServiceContext) ClusterControllerService(org.apache.hyracks.control.cc.ClusterControllerService)

Example 5 with ClusterControllerService

use of org.apache.hyracks.control.cc.ClusterControllerService in project asterixdb by apache.

the class PredistributedJobsTest method init.

@BeforeClass
public static void init() throws Exception {
    CCConfig ccConfig = new CCConfig();
    ccConfig.setClientListenAddress("127.0.0.1");
    ccConfig.setClientListenPort(39000);
    ccConfig.setClusterListenAddress("127.0.0.1");
    ccConfig.setClusterListenPort(39001);
    ccConfig.setProfileDumpPeriod(10000);
    FileUtils.deleteQuietly(new File(joinPath("target", "data")));
    FileUtils.copyDirectory(new File("data"), new File(joinPath("target", "data")));
    File outDir = new File("target" + File.separator + "ClusterController");
    outDir.mkdirs();
    File ccRoot = File.createTempFile(AbstractIntegrationTest.class.getName(), ".data", outDir);
    ccRoot.delete();
    ccRoot.mkdir();
    ccConfig.setRootDir(ccRoot.getAbsolutePath());
    ClusterControllerService ccBase = new ClusterControllerService(ccConfig);
    cc = Mockito.spy(ccBase);
    cc.start();
    NCConfig ncConfig1 = new NCConfig(NC1_ID);
    ncConfig1.setClusterAddress("localhost");
    ncConfig1.setClusterPort(39001);
    ncConfig1.setClusterListenAddress("127.0.0.1");
    ncConfig1.setDataListenAddress("127.0.0.1");
    ncConfig1.setResultListenAddress("127.0.0.1");
    ncConfig1.setResultSweepThreshold(5000);
    ncConfig1.setIODevices(new String[] { joinPath(System.getProperty("user.dir"), "target", "data", "device0") });
    NodeControllerService nc1Base = new NodeControllerService(ncConfig1);
    nc1 = Mockito.spy(nc1Base);
    nc1.start();
    NCConfig ncConfig2 = new NCConfig(NC2_ID);
    ncConfig2.setClusterAddress("localhost");
    ncConfig2.setClusterPort(39001);
    ncConfig2.setClusterListenAddress("127.0.0.1");
    ncConfig2.setDataListenAddress("127.0.0.1");
    ncConfig2.setResultListenAddress("127.0.0.1");
    ncConfig2.setResultSweepThreshold(5000);
    ncConfig2.setIODevices(new String[] { joinPath(System.getProperty("user.dir"), "target", "data", "device1") });
    NodeControllerService nc2Base = new NodeControllerService(ncConfig2);
    nc2 = Mockito.spy(nc2Base);
    nc2.start();
    hcc = new HyracksConnection(ccConfig.getClientListenAddress(), ccConfig.getClientListenPort());
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Starting CC in " + ccRoot.getAbsolutePath());
    }
}
Also used : NodeControllerService(org.apache.hyracks.control.nc.NodeControllerService) CCConfig(org.apache.hyracks.control.common.controllers.CCConfig) NCConfig(org.apache.hyracks.control.common.controllers.NCConfig) HyracksConnection(org.apache.hyracks.api.client.HyracksConnection) File(java.io.File) ClusterControllerService(org.apache.hyracks.control.cc.ClusterControllerService) BeforeClass(org.junit.BeforeClass)

Aggregations

ClusterControllerService (org.apache.hyracks.control.cc.ClusterControllerService)12 CCConfig (org.apache.hyracks.control.common.controllers.CCConfig)8 HyracksConnection (org.apache.hyracks.api.client.HyracksConnection)7 NodeControllerService (org.apache.hyracks.control.nc.NodeControllerService)7 NCConfig (org.apache.hyracks.control.common.controllers.NCConfig)6 File (java.io.File)4 CCExtensionManager (org.apache.asterix.app.cc.CCExtensionManager)2 IStorageComponentProvider (org.apache.asterix.common.context.IStorageComponentProvider)2 CCMessageBroker (org.apache.asterix.messaging.CCMessageBroker)2 IStatementExecutorContext (org.apache.asterix.translator.IStatementExecutorContext)2 INodeManager (org.apache.hyracks.control.cc.cluster.INodeManager)2 BeforeClass (org.junit.BeforeClass)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1