Search in sources :

Example 16 with Path

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);
            }
        }
    }
}
Also used : Path(java.nio.file.Path) RandomAccessFileAppender(org.apache.logging.log4j.core.appender.RandomAccessFileAppender) IOException(java.io.IOException)

Example 17 with Path

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() + "]");
}
Also used : Path(java.nio.file.Path) File(java.io.File) Before(org.junit.Before)

Example 18 with Path

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());
        }
    }
}
Also used : Path(java.nio.file.Path) ScriptingContainer(org.jruby.embed.ScriptingContainer) StringWriter(java.io.StringWriter) IOException(java.io.IOException) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 19 with Path

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;
}
Also used : Path(java.nio.file.Path)

Example 20 with Path

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);
}
Also used : Path(java.nio.file.Path) RemoteInterpreter(org.apache.zeppelin.interpreter.remote.RemoteInterpreter)

Aggregations

Path (java.nio.file.Path)4893 Test (org.junit.Test)1960 IOException (java.io.IOException)829 File (java.io.File)445 SourcePath (com.facebook.buck.rules.SourcePath)389 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)334 BuildTarget (com.facebook.buck.model.BuildTarget)320 ArrayList (java.util.ArrayList)313 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)250 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)231 PathSourcePath (com.facebook.buck.rules.PathSourcePath)226 InputStream (java.io.InputStream)210 ImmutableList (com.google.common.collect.ImmutableList)175 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)166 HashMap (java.util.HashMap)159 ImmutableMap (com.google.common.collect.ImmutableMap)157 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)154 Matchers.containsString (org.hamcrest.Matchers.containsString)148 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)147 Map (java.util.Map)146