use of org.apache.hyracks.control.nc.NodeControllerService in project asterixdb by apache.
the class AsterixHyracksIntegrationUtil method init.
public void init(boolean deleteOldInstanceData) throws Exception {
final ICCApplication ccApplication = createCCApplication();
configManager = new ConfigManager();
ccApplication.registerConfig(configManager);
final CCConfig ccConfig = createCCConfig(configManager);
cc = new ClusterControllerService(ccConfig, ccApplication);
nodeNames = ccConfig.getConfigManager().getNodeNames();
if (deleteOldInstanceData) {
deleteTransactionLogs();
removeTestStorageFiles();
}
final List<NodeControllerService> nodeControllers = new ArrayList<>();
for (String nodeId : nodeNames) {
// mark this NC as virtual in the CC's config manager, so he doesn't try to contact NCService...
configManager.set(nodeId, NCConfig.Option.VIRTUAL_NC, true);
final INCApplication ncApplication = createNCApplication();
ConfigManager ncConfigManager = new ConfigManager();
ncApplication.registerConfig(ncConfigManager);
nodeControllers.add(new NodeControllerService(fixupIODevices(createNCConfig(nodeId, ncConfigManager)), ncApplication));
}
;
cc.start();
// Starts ncs.
nodeNames = ccConfig.getConfigManager().getNodeNames();
List<Thread> startupThreads = new ArrayList<>();
for (NodeControllerService nc : nodeControllers) {
Thread ncStartThread = new Thread("IntegrationUtil-" + nc.getId()) {
@Override
public void run() {
try {
nc.start();
} catch (Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
}
};
ncStartThread.start();
startupThreads.add(ncStartThread);
}
//wait until all NCs complete their startup
for (Thread thread : startupThreads) {
thread.join();
}
// Wait until cluster becomes active
ClusterStateManager.INSTANCE.waitForState(ClusterState.ACTIVE);
hcc = new HyracksConnection(cc.getConfig().getClientListenAddress(), cc.getConfig().getClientListenPort());
this.ncs = nodeControllers.toArray(new NodeControllerService[nodeControllers.size()]);
}
use of org.apache.hyracks.control.nc.NodeControllerService in project asterixdb by apache.
the class NCApplication method getHcc.
protected IHyracksClientConnection getHcc() throws Exception {
NodeControllerService ncSrv = (NodeControllerService) ncServiceCtx.getControllerService();
ClusterControllerInfo ccInfo = ncSrv.getNodeParameters().getClusterControllerInfo();
return new HyracksConnection(ccInfo.getClientNetAddress(), ccInfo.getClientNetPort());
}
use of org.apache.hyracks.control.nc.NodeControllerService in project asterixdb by apache.
the class NCApplication method updateOnNodeJoin.
private void updateOnNodeJoin() {
MetadataProperties metadataProperties = runtimeContext.getMetadataProperties();
if (!metadataProperties.getNodeNames().contains(nodeId)) {
Cluster cluster = ClusterProperties.INSTANCE.getCluster();
if (cluster == null) {
throw new IllegalStateException("No cluster configuration found for this instance");
}
NCConfig ncConfig = ((NodeControllerService) ncServiceCtx.getControllerService()).getConfiguration();
ncConfig.getConfigManager().registerVirtualNode(nodeId);
String asterixInstanceName = metadataProperties.getInstanceName();
TransactionProperties txnProperties = runtimeContext.getTransactionProperties();
Node self = null;
List<Node> nodes;
if (cluster.getSubstituteNodes() != null) {
nodes = cluster.getSubstituteNodes().getNode();
} else {
throw new IllegalStateException("Unknown node joining the cluster");
}
for (Node node : nodes) {
String ncId = asterixInstanceName + "_" + node.getId();
if (ncId.equalsIgnoreCase(nodeId)) {
String storeDir = ClusterProperties.INSTANCE.getStorageDirectoryName();
String nodeIoDevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
String[] ioDevicePaths = nodeIoDevices.trim().split(",");
for (int i = 0; i < ioDevicePaths.length; i++) {
// construct full store path
ioDevicePaths[i] += File.separator + storeDir;
}
metadataProperties.getStores().put(nodeId, ioDevicePaths);
String coredumpPath = node.getLogDir() == null ? cluster.getLogDir() : node.getLogDir();
metadataProperties.getCoredumpPaths().put(nodeId, coredumpPath);
String txnLogDir = node.getTxnLogDir() == null ? cluster.getTxnLogDir() : node.getTxnLogDir();
txnProperties.getLogDirectories().put(nodeId, txnLogDir);
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("Store set to : " + storeDir);
LOGGER.info("Coredump dir set to : " + coredumpPath);
LOGGER.info("Transaction log dir set to :" + txnLogDir);
}
self = node;
break;
}
}
if (self != null) {
cluster.getSubstituteNodes().getNode().remove(self);
cluster.getNode().add(self);
} else {
throw new IllegalStateException("Unknown node joining the cluster");
}
}
}
use of org.apache.hyracks.control.nc.NodeControllerService in project asterixdb by apache.
the class HyracksUtils method init.
public static void init() throws Exception {
CCConfig ccConfig = new CCConfig();
ccConfig.setClientListenAddress(CC_HOST);
ccConfig.setClusterListenAddress(CC_HOST);
ccConfig.setClusterListenPort(TEST_HYRACKS_CC_PORT);
ccConfig.setClientListenPort(TEST_HYRACKS_CC_CLIENT_PORT);
ccConfig.setJobHistorySize(0);
ccConfig.setProfileDumpPeriod(-1);
// cluster controller
cc = new ClusterControllerService(ccConfig);
cc.start();
// two node controllers
NCConfig ncConfig1 = new NCConfig(NC1_ID);
ncConfig1.setClusterAddress("localhost");
ncConfig1.setClusterListenAddress("localhost");
ncConfig1.setClusterPort(TEST_HYRACKS_CC_PORT);
ncConfig1.setDataListenAddress("127.0.0.1");
ncConfig1.setResultListenAddress("127.0.0.1");
nc1 = new NodeControllerService(ncConfig1);
nc1.start();
NCConfig ncConfig2 = new NCConfig(NC2_ID);
ncConfig2.setClusterAddress("localhost");
ncConfig2.setClusterListenAddress("localhost");
ncConfig2.setClusterPort(TEST_HYRACKS_CC_PORT);
ncConfig2.setDataListenAddress("127.0.0.1");
ncConfig2.setResultListenAddress("127.0.0.1");
nc2 = new NodeControllerService(ncConfig2);
nc2.start();
// hyracks connection
hcc = new HyracksConnection(CC_HOST, TEST_HYRACKS_CC_CLIENT_PORT);
}
use of org.apache.hyracks.control.nc.NodeControllerService 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