use of org.apache.slider.client.SliderClient in project hive by apache.
the class LlapSliderUtils method createSliderClient.
public static SliderClient createSliderClient(Configuration conf) throws Exception {
SliderClient sliderClient = new SliderClient() {
@Override
public void serviceInit(Configuration conf) throws Exception {
super.serviceInit(conf);
initHadoopBinding();
}
};
Configuration sliderClientConf = new Configuration(conf);
sliderClientConf = sliderClient.bindArgs(sliderClientConf, new String[] { "help" });
sliderClient.init(sliderClientConf);
sliderClient.start();
return sliderClient;
}
use of org.apache.slider.client.SliderClient in project hive by apache.
the class LlapSliderUtils method startSetSliderLibDir.
public static File startSetSliderLibDir() throws IOException {
// TODO: this is currently required for the use of slider create API. Need SLIDER-1192.
File sliderJarDir = SliderUtils.findContainingJar(SliderClient.class).getParentFile();
File gz = new File(sliderJarDir, SLIDER_GZ);
if (gz.exists()) {
String path = sliderJarDir.getAbsolutePath();
LOG.info("Setting slider.libdir based on jar file location: " + path);
System.setProperty("slider.libdir", path);
return null;
}
// There's no gz file next to slider jars. Due to the horror that is SliderClient, we'd have
// to find it and copy it there. Let's try to find it. Also set slider.libdir.
String path = System.getProperty("slider.libdir");
gz = null;
if (path != null && !path.isEmpty()) {
LOG.info("slider.libdir was already set: " + path);
gz = new File(path, SLIDER_GZ);
if (!gz.exists()) {
gz = null;
}
}
if (gz == null) {
path = System.getenv("SLIDER_HOME");
if (path != null && !path.isEmpty()) {
gz = new File(new File(path, "lib"), SLIDER_GZ);
if (gz.exists()) {
path = gz.getParentFile().getAbsolutePath();
LOG.info("Setting slider.libdir based on SLIDER_HOME: " + path);
System.setProperty("slider.libdir", path);
} else {
gz = null;
}
}
}
if (gz == null) {
// This is a terrible hack trying to find slider on a typical installation. Sigh...
File rootDir = SliderUtils.findContainingJar(HiveConf.class).getParentFile().getParentFile().getParentFile();
File sliderJarDir2 = new File(new File(rootDir, "slider"), "lib");
if (sliderJarDir2.exists()) {
gz = new File(sliderJarDir2, SLIDER_GZ);
if (gz.exists()) {
path = sliderJarDir2.getAbsolutePath();
LOG.info("Setting slider.libdir based on guesswork: " + path);
System.setProperty("slider.libdir", path);
} else {
gz = null;
}
}
}
if (gz == null) {
throw new IOException("Cannot find " + SLIDER_GZ + ". Please ensure SLIDER_HOME is set.");
}
File newGz = new File(sliderJarDir, SLIDER_GZ);
LOG.info("Copying " + gz + " to " + newGz);
Files.copy(gz, newGz);
newGz.deleteOnExit();
return newGz;
}
use of org.apache.slider.client.SliderClient in project hive by apache.
the class LlapSliderUtils method startCluster.
public static void startCluster(Configuration conf, String name, String packageName, Path packageDir, String queue) {
LOG.info("Starting cluster with " + name + ", " + packageName + ", " + queue + ", " + packageDir);
SliderClient sc;
try {
sc = createSliderClient(conf);
} catch (Exception e) {
throw new RuntimeException(e);
}
try {
LOG.info("Executing the freeze command");
ActionFreezeArgs freezeArgs = new ActionFreezeArgs();
freezeArgs.force = true;
// Wait forever (or at least for an hour).
freezeArgs.setWaittime(3600);
try {
sc.actionFreeze(name, freezeArgs);
} catch (UnknownApplicationInstanceException ex) {
LOG.info("There was no old application instance to freeze");
}
LOG.info("Executing the destroy command");
ActionDestroyArgs destroyArg = new ActionDestroyArgs();
destroyArg.force = true;
try {
sc.actionDestroy(name, destroyArg);
} catch (UnknownApplicationInstanceException ex) {
LOG.info("There was no old application instance to destroy");
}
LOG.info("Executing the install command");
ActionInstallPackageArgs installArgs = new ActionInstallPackageArgs();
installArgs.name = "LLAP";
installArgs.packageURI = new Path(packageDir, packageName).toString();
installArgs.replacePkg = true;
sc.actionInstallPkg(installArgs);
LOG.info("Executing the create command");
ActionCreateArgs createArgs = new ActionCreateArgs();
createArgs.resources = new File(new Path(packageDir, "resources.json").toString());
createArgs.template = new File(new Path(packageDir, "appConfig.json").toString());
createArgs.setWaittime(3600);
if (queue != null) {
createArgs.queue = queue;
}
// See the comments in the method. SliderClient doesn't work in normal circumstances.
File bogusSliderFile = startSetSliderLibDir();
try {
sc.actionCreate(name, createArgs);
} finally {
endSetSliderLibDir(bogusSliderFile);
}
LOG.debug("Started the cluster via slider API");
} catch (YarnException | IOException e) {
throw new RuntimeException(e);
} finally {
try {
sc.close();
} catch (IOException e) {
LOG.info("Failed to close slider client", e);
}
}
}
Aggregations