/** * Return the client port for this server. * * @return the client port */ public int getClientPort() { return prefs.getClientPort(); }
/** * The listener port (1-65535) for client connections. Choose a port between * 49152 and 65535 to minimize the possibility of conflicts with other * services on this host. * * @return the client port */ public int getClientPort() { return getOrDefault("client_port", DEFAULT_CLIENT_PORT); }
/** * The size for each page in the Buffer. During reads, Buffer pages * are individually locked, so it is desirable to have several smaller * pages as opposed to few larger ones. Nevertheless, be sure to balance * the desire to maximize lock granularity with the risks of having too * many open buffer files simultaneously. * * @return the buffer page size in bytes */ public long getBufferPageSize() { return getSize("buffer_page_size", DEFAULT_BUFFER_PAGE_SIZE); }
/** * Tweak some of the preferences to make this more palatable for testing * (i.e. reduce the possibility of port conflicts, etc). * * @param installDirectory */ private static void configure(String installDirectory) { ConcourseServerPreferences prefs = ConcourseServerPreferences .from(Paths.get(installDirectory + File.separator + CONF + File.separator + "concourse.prefs")); String data = installDirectory + File.separator + "data"; prefs.setBufferDirectory(data + File.separator + "buffer"); prefs.setDatabaseDirectory(data + File.separator + "database"); prefs.setClientPort(getOpenPort()); prefs.setJmxPort(getOpenPort()); prefs.setLogLevel(Level.DEBUG); prefs.setShutdownPort(getOpenPort()); }
/** * Construct a new instance. * * @param installDirectory */ private ManagedConcourseServer(String installDirectory) { this.installDirectory = installDirectory; this.prefs = ConcourseServerPreferences.from(Paths.get(installDirectory + File.separator + CONF + File.separator + "concourse.prefs")); prefs.setLogLevel(Level.DEBUG); this.destroyOnExitFlag = Paths.get(installDirectory) .resolve(".destroyOnExit"); destroyOnExit(true); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { if(destroyOnExit()) { destroy(); } } })); }
/** * Set the value associated with the {@code database_directory} key. * * @param databaseDirectory */ public void setDatabaseDirectory(String databaseDirectory) { set("database_directory", databaseDirectory); }
/** * Return a {@link ConcourseServerPreferences} handler that is backed by the * configuration information in {@code file}. * * @param file the absolute path to the preferences file (relative paths * will resolve to the user's home directory) * @return the preferences handler * @deprecated use {@link ConcourseServerPreferences#from(Path...)} instead */ @Deprecated public static ConcourseServerPreferences open(String file) { return from(Paths.get(file)); }
/** * Return the directory where the server stores buffer files. * * @return the buffer directory */ public Path getBufferDirectory() { return Paths.get(prefs.getBufferDirectory()); }
/** * Return the directory where the server stores database files. * * @return the database directory */ public Path getDatabaseDirectory() { return Paths.get(prefs.getDatabaseDirectory()); }
/** * Return a {@link ConcourseServerPreferences} handler that is sourced from * the {@link files}. * * @param files * @return the sources */ public static ConcourseServerPreferences from(Path... files) { Verify.thatArgument(files.length > 0, "Must include at least one file"); return new ConcourseServerPreferences(files); }
/** * Return the connection to the MBean sever of the managed concourse-server * process. * * @return the mbean server connection */ public MBeanServerConnection getMBeanServerConnection() { if(mBeanServerConnection == null) { try { JMXServiceURL url = new JMXServiceURL( "service:jmx:rmi:///jndi/rmi://localhost:" + prefs.getJmxPort() + "/jmxrmi"); JMXConnector connector = JMXConnectorFactory.connect(url); mBeanServerConnection = connector.getMBeanServerConnection(); } catch (Exception e) { throw CheckedExceptions.wrapAsRuntimeException(e); } } return mBeanServerConnection; }
/** * Set the value associated with the {@code jmx_port} key. * * @param port */ public void setJmxPort(int port) { set("jmx_port", port); }
/** * Set the value associated with the {@code shutdown_port} key. * * @param shutdownPort */ public void setShutdownPort(int shutdownPort) { set("shutdown_port", shutdownPort); }
/** * The listener port (1-65535) for shutdown commands. Choose a port between * 49152 and 65535 to minimize the possibility of conflicts with other * services on this host. * * @return the shutdown port */ public int getShutdownPort() { return getOrDefault("shutdown_port", DEFAULT_SHUTDOWN_PORT); }
/** * Set the value associated with the {@code buffer_directory} key. * * @param bufferDirectory */ public void setBufferDirectory(String bufferDirectory) { set("buffer_directory", bufferDirectory); }
/** * The absolute path to the directory where the Buffer data is stored. * For optimal write performance, the Buffer should be placed on a * separate disk partition (ideally a separate physical device) from * the database_directory. * * @return the buffer directory */ public String getBufferDirectory() { return getOrDefault("buffer_directory", DEFAULT_BUFFER_DIRECTORY); }
/** * Set the value associated with the {@code buffer_page_size} key. */ public void setBufferPageSize(long sizeInBytes) { set("buffer_page_size", sizeInBytes); }
/** * The absolute path to the directory where the Database record and index * files are stored. For optimal performance, the Database should be * placed on a separate disk partition (ideally a separate physical device) * from the buffer_directory. * * @return the database directory */ public String getDatabaseDirectory() { return getOrDefault("database_directory", DEFAULT_DATABASE_DIRECTORY); }
/** * Set the value associated with the {@code default_environment} key. * * @param defaultEnvironment */ public void setDefaultEnvironment(String defaultEnvironment) { set("default_environment", defaultEnvironment); }
/** * The default environment that is automatically loaded when the server * starts and is used whenever a client does not specify an environment for * its connection. * * @return the default environment */ public String getDefaultEnvironment() { return getOrDefault("default_environment", DEFAULT_DEFAULT_ENVIRONMENT); }