use of io.cdap.cdap.runtime.spi.provisioner.Node in project cdap by caskdata.
the class ElasticMapReduceProvisioner method getMasterExternalIp.
private String getMasterExternalIp(Cluster cluster) {
Node masterNode = cluster.getNodes().stream().filter(node -> Node.Type.MASTER == node.getType()).findFirst().orElseThrow(() -> new IllegalArgumentException("Cluster has no node of master type: " + cluster));
String ip = masterNode.getIpAddress();
if (ip == null) {
throw new IllegalArgumentException(String.format("External IP is not defined for node '%s' in cluster %s", masterNode.getId(), cluster));
}
return ip;
}
use of io.cdap.cdap.runtime.spi.provisioner.Node in project cdap by caskdata.
the class RemoteHadoopProvisioner method createCluster.
@Override
public Cluster createCluster(ProvisionerContext context) {
RemoteHadoopConf conf = RemoteHadoopConf.fromProperties(context.getProperties());
context.getSSHContext().setSSHKeyPair(conf.getKeyPair());
Collection<Node> nodes = Collections.singletonList(new Node(conf.getHost(), Node.Type.MASTER, conf.getHost(), 0, Collections.emptyMap()));
Map<String, String> properties = new HashMap<>();
String principal = conf.getKerberosPrincipal();
String keytab = conf.getKerberosKeytabPath();
if (principal != null && keytab != null) {
properties.put(ClusterProperties.KERBEROS_PRINCIPAL, principal);
properties.put(ClusterProperties.KERBEROS_KEYTAB, keytab);
}
return new Cluster(conf.getHost(), ClusterStatus.RUNNING, nodes, properties);
}
use of io.cdap.cdap.runtime.spi.provisioner.Node in project cdap by cdapio.
the class DefaultRuntimeJobTest method testInjector.
@Test
public void testInjector() throws Exception {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().toString());
LocationFactory locationFactory = new LocalLocationFactory(TEMP_FOLDER.newFile());
DefaultRuntimeJob defaultRuntimeJob = new DefaultRuntimeJob();
Arguments systemArgs = new BasicArguments(Collections.singletonMap(SystemArguments.PROFILE_NAME, "test"));
Node node = new Node("test", Node.Type.MASTER, "127.0.0.1", System.currentTimeMillis(), Collections.emptyMap());
Cluster cluster = new Cluster("test", ClusterStatus.RUNNING, Collections.singleton(node), Collections.emptyMap());
ProgramRunId programRunId = NamespaceId.DEFAULT.app("app").workflow("workflow").run(RunIds.generate());
SimpleProgramOptions programOpts = new SimpleProgramOptions(programRunId.getParent(), systemArgs, new BasicArguments());
Injector injector = Guice.createInjector(defaultRuntimeJob.createModules(new RuntimeJobEnvironment() {
@Override
public LocationFactory getLocationFactory() {
return locationFactory;
}
@Override
public TwillRunner getTwillRunner() {
return new NoopTwillRunnerService();
}
@Override
public Map<String, String> getProperties() {
return Collections.emptyMap();
}
}, cConf, programRunId, programOpts));
injector.getInstance(LogAppenderInitializer.class);
defaultRuntimeJob.createCoreServices(injector, systemArgs, cluster);
}
use of io.cdap.cdap.runtime.spi.provisioner.Node in project cdap by cdapio.
the class EMRClient method getCluster.
/**
* Get information about the specified cluster. The cluster will not be present if it could not be found.
*
* @param id the cluster id
* @return the cluster information if it exists
*/
public Optional<io.cdap.cdap.runtime.spi.provisioner.Cluster> getCluster(String id) {
Cluster cluster = describeCluster(id);
List<Node> nodes = new ArrayList<>();
nodes.add(new Node("id", Node.Type.MASTER, cluster.getMasterPublicDnsName(), System.currentTimeMillis(), Collections.emptyMap()));
return Optional.of(new io.cdap.cdap.runtime.spi.provisioner.Cluster(cluster.getId(), convertStatus(cluster.getStatus()), nodes, Collections.emptyMap()));
}
use of io.cdap.cdap.runtime.spi.provisioner.Node in project cdap by cdapio.
the class ElasticMapReduceProvisioner method getMasterExternalIp.
private String getMasterExternalIp(Cluster cluster) {
Node masterNode = cluster.getNodes().stream().filter(node -> Node.Type.MASTER == node.getType()).findFirst().orElseThrow(() -> new IllegalArgumentException("Cluster has no node of master type: " + cluster));
String ip = masterNode.getIpAddress();
if (ip == null) {
throw new IllegalArgumentException(String.format("External IP is not defined for node '%s' in cluster %s", masterNode.getId(), cluster));
}
return ip;
}
Aggregations