/** Writes a file to the logs dir containing the ports for the given transport type */ private void writePortsFile(String type, BoundTransportAddress boundAddress) { Path tmpPortsFile = environment.logsFile().resolve(type + ".ports.tmp"); try (BufferedWriter writer = Files.newBufferedWriter(tmpPortsFile, Charset.forName("UTF-8"))) { for (TransportAddress address : boundAddress.boundAddresses()) { InetAddress inetAddress = InetAddress.getByName(address.getAddress()); writer.write(NetworkAddress.format(new InetSocketAddress(inetAddress, address.getPort())) + "\n"); } } catch (IOException e) { throw new RuntimeException("Failed to write ports file", e); } Path portsFile = environment.logsFile().resolve(type + ".ports"); try { Files.move(tmpPortsFile, portsFile, StandardCopyOption.ATOMIC_MOVE); } catch (IOException e) { throw new RuntimeException("Failed to rename ports file", e); } }
/** * Configure logging reading from any log4j2.properties found in the config directory and its * subdirectories from the specified environment. Will also configure logging to point the logs * directory from the specified environment. * * @param environment the environment for reading configs and the logs path * @throws IOException if there is an issue readings any log4j2.properties in the config * directory * @throws UserException if there are no log4j2.properties in the specified configs path */ public static void configure(final Environment environment) throws IOException, UserException { Objects.requireNonNull(environment); try { // we are about to configure logging, check that the status logger did not log any error-level messages checkErrorListener(); } finally { // whether or not the error listener check failed we can remove the listener now StatusLogger.getLogger().removeListener(ERROR_LISTENER); } configure(environment.settings(), environment.configFile(), environment.logsFile()); }
output.put(Environment.PATH_LOGS_SETTING.getKey(), environment.logsFile().toAbsolutePath().normalize().toString()); return new Environment(output.build(), configPath);
environment.configFile(), Arrays.toString(environment.dataFiles()), environment.logsFile(), environment.pluginsFile());
addDirectoryPath(policy, Environment.PATH_LOGS_SETTING.getKey(), environment.logsFile(), "read,readlink,write,delete"); if (environment.sharedDataFile() != null) { addDirectoryPath(policy, Environment.PATH_SHARED_DATA_SETTING.getKey(), environment.sharedDataFile(),
/** * asserts that the two environments are equivalent for all things the environment cares about (i.e., all but the setting * object which may contain different setting) */ public static void assertEquivalent(Environment actual, Environment expected) { assertEquals(actual.dataFiles(), expected.dataFiles(), "dataFiles"); assertEquals(actual.repoFiles(), expected.repoFiles(), "repoFiles"); assertEquals(actual.configFile(), expected.configFile(), "configFile"); assertEquals(actual.pluginsFile(), expected.pluginsFile(), "pluginsFile"); assertEquals(actual.binFile(), expected.binFile(), "binFile"); assertEquals(actual.libFile(), expected.libFile(), "libFile"); assertEquals(actual.modulesFile(), expected.modulesFile(), "modulesFile"); assertEquals(actual.logsFile(), expected.logsFile(), "logsFile"); assertEquals(actual.pidFile(), expected.pidFile(), "pidFile"); assertEquals(actual.tmpFile(), expected.tmpFile(), "tmpFile"); }
/** Writes a file to the logs dir containing the ports for the given transport type */ private void writePortsFile(String type, BoundTransportAddress boundAddress) { Path tmpPortsFile = environment.logsFile().resolve(type + ".ports.tmp"); try (BufferedWriter writer = Files.newBufferedWriter(tmpPortsFile, Charset.forName("UTF-8"))) { for (TransportAddress address : boundAddress.boundAddresses()) { InetAddress inetAddress = InetAddress.getByName(address.getAddress()); writer.write(NetworkAddress.format(new InetSocketAddress(inetAddress, address.getPort())) + "\n"); } } catch (IOException e) { throw new RuntimeException("Failed to write ports file", e); } Path portsFile = environment.logsFile().resolve(type + ".ports"); try { Files.move(tmpPortsFile, portsFile, StandardCopyOption.ATOMIC_MOVE); } catch (IOException e) { throw new RuntimeException("Failed to rename ports file", e); } }
/** Writes a file to the logs dir containing the ports for the given transport type */ private void writePortsFile(String type, BoundTransportAddress boundAddress) { Path tmpPortsFile = environment.logsFile().resolve(type + ".ports.tmp"); try (BufferedWriter writer = Files.newBufferedWriter(tmpPortsFile, Charset.forName("UTF-8"))) { for (TransportAddress address : boundAddress.boundAddresses()) { InetAddress inetAddress = InetAddress.getByName(address.getAddress()); if (inetAddress instanceof Inet6Address && inetAddress.isLinkLocalAddress()) { // no link local, just causes problems continue; } writer.write(NetworkAddress.format(new InetSocketAddress(inetAddress, address.getPort())) + "\n"); } } catch (IOException e) { throw new RuntimeException("Failed to write ports file", e); } Path portsFile = environment.logsFile().resolve(type + ".ports"); try { Files.move(tmpPortsFile, portsFile, StandardCopyOption.ATOMIC_MOVE); } catch (IOException e) { throw new RuntimeException("Failed to rename ports file", e); } } }
/** Writes a file to the logs dir containing the ports for the given transport type */ private void writePortsFile(String type, BoundTransportAddress boundAddress) { Path tmpPortsFile = environment.logsFile().resolve(type + ".ports.tmp"); try (BufferedWriter writer = Files.newBufferedWriter(tmpPortsFile, Charset.forName("UTF-8"))) { for (TransportAddress address : boundAddress.boundAddresses()) { InetAddress inetAddress = InetAddress.getByName(address.getAddress()); if (inetAddress instanceof Inet6Address && inetAddress.isLinkLocalAddress()) { // no link local, just causes problems continue; } writer.write(NetworkAddress.format(new InetSocketAddress(inetAddress, address.getPort())) + "\n"); } } catch (IOException e) { throw new RuntimeException("Failed to write ports file", e); } Path portsFile = environment.logsFile().resolve(type + ".ports"); try { Files.move(tmpPortsFile, portsFile, StandardCopyOption.ATOMIC_MOVE); } catch (IOException e) { throw new RuntimeException("Failed to rename ports file", e); } }
/** * Configure logging reading from any log4j2.properties found in the config directory and its * subdirectories from the specified environment. Will also configure logging to point the logs * directory from the specified environment. * * @param environment the environment for reading configs and the logs path * @throws IOException if there is an issue readings any log4j2.properties in the config * directory * @throws UserException if there are no log4j2.properties in the specified configs path */ public static void configure(final Environment environment) throws IOException, UserException { Objects.requireNonNull(environment); try { // we are about to configure logging, check that the status logger did not log any error-level messages checkErrorListener(); } finally { // whether or not the error listener check failed we can remove the listener now StatusLogger.getLogger().removeListener(ERROR_LISTENER); } configure(environment.settings(), environment.configFile(), environment.logsFile()); }
/** * Configure logging reading from any log4j2.properties found in the config directory and its * subdirectories from the specified environment. Will also configure logging to point the logs * directory from the specified environment. * * @param environment the environment for reading configs and the logs path * @throws IOException if there is an issue readings any log4j2.properties in the config * directory * @throws UserException if there are no log4j2.properties in the specified configs path */ public static void configure(final Environment environment) throws IOException, UserException { Objects.requireNonNull(environment); try { // we are about to configure logging, check that the status logger did not log any error-level messages checkErrorListener(); } finally { // whether or not the error listener check failed we can remove the listener now StatusLogger.getLogger().removeListener(ERROR_LISTENER); } configure(environment.settings(), environment.configFile(), environment.logsFile()); }
output.put(Environment.PATH_LOGS_SETTING.getKey(), cleanPath(environment.logsFile().toAbsolutePath().toString())); String configExtension = foundSuffixes.isEmpty() ? null : foundSuffixes.iterator().next(); return new Environment(output.build(), configExtension);
output.put(Environment.PATH_LOGS_SETTING.getKey(), environment.logsFile().toAbsolutePath().normalize().toString()); return new Environment(output.build(), configPath);
output.put(Environment.PATH_LOGS_SETTING.getKey(), environment.logsFile().toAbsolutePath().normalize().toString()); return new Environment(output.build(), configPath);
output.put("path.logs", cleanPath(environment.logsFile().toAbsolutePath().toString()));
addDirectoryPath(policy, Environment.PATH_LOGS_SETTING.getKey(), environment.logsFile(), "read,readlink,write,delete"); if (environment.sharedDataFile() != null) { addDirectoryPath(policy, Environment.PATH_SHARED_DATA_SETTING.getKey(), environment.sharedDataFile(),
/** * asserts that the two environments are equivalent for all things the environment cares about (i.e., all but the setting * object which may contain different setting) */ public static void assertEquivalent(Environment actual, Environment expected) { assertEquals(actual.dataWithClusterFiles(), expected.dataWithClusterFiles(), "dataWithClusterFiles"); assertEquals(actual.repoFiles(), expected.repoFiles(), "repoFiles"); assertEquals(actual.configFile(), expected.configFile(), "configFile"); assertEquals(actual.pluginsFile(), expected.pluginsFile(), "pluginsFile"); assertEquals(actual.binFile(), expected.binFile(), "binFile"); assertEquals(actual.libFile(), expected.libFile(), "libFile"); assertEquals(actual.modulesFile(), expected.modulesFile(), "modulesFile"); assertEquals(actual.logsFile(), expected.logsFile(), "logsFile"); assertEquals(actual.pidFile(), expected.pidFile(), "pidFile"); assertEquals(actual.tmpFile(), expected.tmpFile(), "tmpFile"); }
/** * asserts that the two environments are equivalent for all things the environment cares about (i.e., all but the setting * object which may contain different setting) */ public static void assertEquivalent(Environment actual, Environment expected) { assertEquals(actual.dataWithClusterFiles(), expected.dataWithClusterFiles(), "dataWithClusterFiles"); assertEquals(actual.repoFiles(), expected.repoFiles(), "repoFiles"); assertEquals(actual.configFile(), expected.configFile(), "configFile"); assertEquals(actual.pluginsFile(), expected.pluginsFile(), "pluginsFile"); assertEquals(actual.binFile(), expected.binFile(), "binFile"); assertEquals(actual.libFile(), expected.libFile(), "libFile"); assertEquals(actual.modulesFile(), expected.modulesFile(), "modulesFile"); assertEquals(actual.logsFile(), expected.logsFile(), "logsFile"); assertEquals(actual.pidFile(), expected.pidFile(), "pidFile"); assertEquals(actual.tmpFile(), expected.tmpFile(), "tmpFile"); }
/** * asserts that the two environments are equivalent for all things the environment cares about (i.e., all but the setting * object which may contain different setting) */ public static void assertEquivalent(Environment actual, Environment expected) { assertEquals(actual.dataWithClusterFiles(), expected.dataWithClusterFiles(), "dataWithClusterFiles"); assertEquals(actual.repoFiles(), expected.repoFiles(), "repoFiles"); assertEquals(actual.configFile(), expected.configFile(), "configFile"); assertEquals(actual.scriptsFile(), expected.scriptsFile(), "scriptsFile"); assertEquals(actual.pluginsFile(), expected.pluginsFile(), "pluginsFile"); assertEquals(actual.binFile(), expected.binFile(), "binFile"); assertEquals(actual.libFile(), expected.libFile(), "libFile"); assertEquals(actual.modulesFile(), expected.modulesFile(), "modulesFile"); assertEquals(actual.logsFile(), expected.logsFile(), "logsFile"); assertEquals(actual.pidFile(), expected.pidFile(), "pidFile"); assertEquals(actual.tmpFile(), expected.tmpFile(), "tmpFile"); }
addPath(policy, "path.logs", environment.logsFile(), "read,readlink,write,delete"); if (environment.sharedDataFile() != null) { addPath(policy, "path.shared_data", environment.sharedDataFile(), "read,readlink,write,delete");