use of org.apache.hyracks.control.common.controllers.CCConfig 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.hyracks.control.common.controllers.CCConfig in project asterixdb by apache.
the class CCDriver method main.
public static void main(String[] args) throws Exception {
try {
final ConfigManager configManager = new ConfigManager(args);
ICCApplication application = getApplication(args);
application.registerConfig(configManager);
CCConfig ccConfig = new CCConfig(configManager);
ClusterControllerService ccService = new ClusterControllerService(ccConfig, application);
ccService.start();
while (true) {
Thread.sleep(100000);
}
} catch (CmdLineException e) {
LOGGER.log(Level.FINE, "Exception parsing command line: " + Arrays.toString(args), e);
System.exit(2);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Exiting CCDriver due to exception", e);
System.exit(1);
}
}
use of org.apache.hyracks.control.common.controllers.CCConfig 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());
}
}
use of org.apache.hyracks.control.common.controllers.CCConfig in project asterixdb by apache.
the class JobManagerTest method testCancel.
@Test
public void testCancel() throws HyracksException {
CCConfig ccConfig = new CCConfig();
IJobCapacityController jobCapacityController = mock(IJobCapacityController.class);
IJobManager jobManager = spy(new JobManager(ccConfig, mockClusterControllerService(), jobCapacityController));
// Submits runnable jobs.
List<JobRun> acceptedRuns = new ArrayList<>();
for (int id = 0; id < 4096; ++id) {
// Mocks an immediately executable job.
JobRun run = mockJobRun(id);
JobSpecification job = mock(JobSpecification.class);
when(run.getJobSpecification()).thenReturn(job);
when(jobCapacityController.allocate(job)).thenReturn(IJobCapacityController.JobSubmissionStatus.EXECUTE);
// Submits the job.
acceptedRuns.add(run);
jobManager.add(run);
Assert.assertTrue(jobManager.getRunningJobs().size() == id + 1);
Assert.assertTrue(jobManager.getPendingJobs().isEmpty());
}
// Submits jobs that will be deferred due to the capacity limitation.
List<JobRun> deferredRuns = new ArrayList<>();
for (int id = 4096; id < 8192; ++id) {
// Mocks a deferred job.
JobRun run = mockJobRun(id);
JobSpecification job = mock(JobSpecification.class);
when(run.getJobSpecification()).thenReturn(job);
when(jobCapacityController.allocate(job)).thenReturn(IJobCapacityController.JobSubmissionStatus.QUEUE).thenReturn(IJobCapacityController.JobSubmissionStatus.EXECUTE);
// Submits the job.
deferredRuns.add(run);
jobManager.add(run);
Assert.assertTrue(jobManager.getRunningJobs().size() == 4096);
Assert.assertTrue(jobManager.getPendingJobs().size() == id + 1 - 4096);
}
// Cancels deferred jobs.
for (JobRun run : deferredRuns) {
jobManager.cancel(run.getJobId());
}
// Cancels runnable jobs.
for (JobRun run : acceptedRuns) {
jobManager.cancel(run.getJobId());
}
Assert.assertTrue(jobManager.getPendingJobs().isEmpty());
Assert.assertTrue(jobManager.getArchivedJobs().size() == ccConfig.getJobHistorySize());
verify(jobManager, times(0)).prepareComplete(any(), any(), any());
verify(jobManager, times(0)).finalComplete(any());
}
use of org.apache.hyracks.control.common.controllers.CCConfig in project asterixdb by apache.
the class JobManagerTest method setup.
@Before
public void setup() throws IOException, CmdLineException {
ccConfig = new CCConfig();
ccConfig.getConfigManager().processConfig();
}
Aggregations