use of java.nio.file.Path in project hive by apache.
the class LlapWrappedAppender method stop.
@Override
public void stop() {
if (!(this.isStopping() || this.isStopped())) {
super.stop();
if (appenderControl.get() != null) {
appenderControl.get().stop();
realAppender.get().stop();
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Stop invoked for " + ((RandomAccessFileAppender) realAppender.get()).getFileName());
}
if (realAppender.get() == null) {
LOGGER.info("RealAppender is null. Ignoring stop");
return;
}
RandomAccessFileAppender raf = (RandomAccessFileAppender) realAppender.get();
Path renamedPath = null;
if (renameFileOnClose) {
try {
// Look for a file to which we can move the existing file. With external services,
// it's possible for the service to be marked complete after each fragment.
int counter = 0;
while (true) {
renamedPath = getRenamedPath(raf.getFileName(), counter);
if (!Files.exists(renamedPath)) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Renaming file: " + raf.getFileName() + " to " + renamedPath);
}
Files.move(Paths.get(raf.getFileName()), renamedPath);
break;
}
counter++;
}
} catch (IOException e) {
// Bail on an exception - out of the loop.
LOGGER.warn("Failed to rename file: " + raf.getFileName() + " to " + renamedPath, e);
}
}
}
}
use of java.nio.file.Path in project tomcat by apache.
the class LoggingBaseTest method setUp.
@Before
public void setUp() throws Exception {
// Create catalina.base directory
File tempBase = new File(System.getProperty("tomcat.test.temp", "output/tmp"));
if (!tempBase.mkdirs() && !tempBase.isDirectory()) {
fail("Unable to create base temporary directory for tests");
}
Path tempBasePath = FileSystems.getDefault().getPath(tempBase.getAbsolutePath());
tempDir = Files.createTempDirectory(tempBasePath, "test").toFile();
System.setProperty("catalina.base", tempDir.getAbsolutePath());
log = LogFactory.getLog(getClass());
log.info("Starting test case [" + testName.getMethodName() + "]");
}
use of java.nio.file.Path in project zeppelin by apache.
the class HbaseInterpreter method open.
@Override
public void open() {
this.scriptingContainer = new ScriptingContainer(LocalContextScope.SINGLETON);
this.writer = new StringWriter();
scriptingContainer.setOutput(this.writer);
if (!Boolean.parseBoolean(getProperty(HBASE_TEST_MODE))) {
String hbase_home = getProperty(HBASE_HOME);
String ruby_src = getProperty(HBASE_RUBY_SRC);
Path abs_ruby_src = Paths.get(hbase_home, ruby_src).toAbsolutePath();
logger.info("Home:" + hbase_home);
logger.info("Ruby Src:" + ruby_src);
File f = abs_ruby_src.toFile();
if (!f.exists() || !f.isDirectory()) {
throw new InterpreterException("HBase ruby sources is not available at '" + abs_ruby_src + "'");
}
logger.info("Absolute Ruby Source:" + abs_ruby_src.toString());
// hirb.rb:41 requires the following system property to be set.
Properties sysProps = System.getProperties();
sysProps.setProperty(HBASE_RUBY_SRC, abs_ruby_src.toString());
Path abs_hirb_path = Paths.get(hbase_home, "bin/hirb.rb");
try {
FileInputStream fis = new FileInputStream(abs_hirb_path.toFile());
this.scriptingContainer.runScriptlet(fis, "hirb.rb");
fis.close();
} catch (IOException e) {
throw new InterpreterException(e.getCause());
}
}
}
use of java.nio.file.Path in project zeppelin by apache.
the class JDBCInterpreterTest method getJdbcConnection.
private static String getJdbcConnection() throws IOException {
if (null == jdbcConnection) {
Path tmpDir = Files.createTempDirectory("h2-test-");
tmpDir.toFile().deleteOnExit();
jdbcConnection = format("jdbc:h2:%s", tmpDir);
}
return jdbcConnection;
}
use of java.nio.file.Path in project zeppelin by apache.
the class InterpreterFactory method createRemoteRepl.
Interpreter createRemoteRepl(String interpreterPath, String interpreterSessionKey, String className, Properties property, String interpreterSettingId, String userName, Boolean isUserImpersonate, InterpreterRunner interpreterRunner) {
int connectTimeout = conf.getInt(ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT);
String localRepoPath = conf.getInterpreterLocalRepoPath() + "/" + interpreterSettingId;
int maxPoolSize = conf.getInt(ConfVars.ZEPPELIN_INTERPRETER_MAX_POOL_SIZE);
String interpreterRunnerPath;
String interpreterGroupName = interpreterSettingManager.get(interpreterSettingId).getName();
if (null != interpreterRunner) {
interpreterRunnerPath = interpreterRunner.getPath();
Path p = Paths.get(interpreterRunnerPath);
if (!p.isAbsolute()) {
interpreterRunnerPath = Joiner.on(File.separator).join(interpreterPath, interpreterRunnerPath);
}
} else {
interpreterRunnerPath = conf.getInterpreterRemoteRunnerPath();
}
RemoteInterpreter remoteInterpreter = new RemoteInterpreter(property, interpreterSessionKey, className, interpreterRunnerPath, interpreterPath, localRepoPath, connectTimeout, maxPoolSize, remoteInterpreterProcessListener, appEventListener, userName, isUserImpersonate, conf.getInt(ConfVars.ZEPPELIN_INTERPRETER_OUTPUT_LIMIT), interpreterGroupName);
remoteInterpreter.addEnv(env);
return new LazyOpenInterpreter(remoteInterpreter);
}
Aggregations