Commit 631b60b6 authored by Yann Mombrun's avatar Yann Mombrun

Deliver version 2.1.0-beta

WEBLAB-1470 - Reset script now cleans the content folder directoy if exists
WEBLAB-1468 - Now rely on solr 6.1.0
WEBLAB-1471 - Lot of javadoc update to let it be deployed when runnoing with a JDK8
WEBLAB-1469 - For end of any command
WEBLAB-1466 - Change solr directory. Stop solr server before removing the folder.
WEBLAB-1467 - Update configuration to test if the java runtime is 8 (needed for solr and tomcat with solr-engine inside)
Lots of clean up of the launcher to prevent some warning. Remove some useless parameter from the configuration and mark them as deprecated
Fix deployment issue (sftp now preferred over scp)

git-svn-id: svn://svn.forge.objectweb.org/svnroot/weblab/trunk/WebLabApplications/bundle@4314 a803c184-d8de-4a0e-a52b-d3eef88212b6
parent 0b45d1e8
......@@ -107,7 +107,6 @@
<include>org.apache.tomcat:tomcat:zip</include>
</includes>
<useTransitiveDependencies>false</useTransitiveDependencies>
<outputFileNameMapping>${artifact.artifactId}</outputFileNameMapping>
<unpack>true</unpack>
<unpackOptions>
<excludes>
......@@ -136,7 +135,7 @@
<include>com.liferay:liferay-portal-tomcat:zip</include>
</includes>
<useTransitiveDependencies>false</useTransitiveDependencies>
<outputFileNameMapping>${artifact.artifactId}</outputFileNameMapping>
<useStrictFiltering>true</useStrictFiltering>
<unpack>true</unpack>
<unpackOptions>
<excludes>
......@@ -177,7 +176,7 @@
<include>org.ow2.weblab.osgi:karaf-weblab:tar.gz</include>
</includes>
<useTransitiveDependencies>false</useTransitiveDependencies>
<outputFileNameMapping>${artifact.artifactId}</outputFileNameMapping>
<useStrictFiltering>true</useStrictFiltering>
<unpack>true</unpack>
<fileMode>0755</fileMode>
</dependencySet>
......@@ -189,7 +188,7 @@
<include>org.apache.activemq:apache-activemq:tar.gz</include>
</includes>
<useTransitiveDependencies>false</useTransitiveDependencies>
<outputFileNameMapping>${artifact.artifactId}</outputFileNameMapping>
<useStrictFiltering>true</useStrictFiltering>
<unpack>true</unpack>
<unpackOptions>
<excludes>
......@@ -212,7 +211,7 @@
<include>org.apache.activemq:apache-activemq:zip</include>
</includes>
<useTransitiveDependencies>false</useTransitiveDependencies>
<outputFileNameMapping>${artifact.artifactId}</outputFileNameMapping>
<useStrictFiltering>true</useStrictFiltering>
<unpack>true</unpack>
<unpackOptions>
<excludes>
......@@ -243,7 +242,7 @@
<include>org.apache.solr:solr:tgz</include>
</includes>
<useTransitiveDependencies>false</useTransitiveDependencies>
<outputFileNameMapping>${artifact.artifactId}</outputFileNameMapping>
<useStrictFiltering>true</useStrictFiltering>
<unpack>true</unpack>
<unpackOptions>
<excludes>
......@@ -280,7 +279,6 @@
</includes>
<useTransitiveDependencies>false</useTransitiveDependencies>
<outputDirectory>${tomcat.path}/webapps/${artifact.artifactId}</outputDirectory>
<outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<unpack>true</unpack>
<unpackOptions>
<excludes>
......@@ -297,6 +295,7 @@
<include>org.ow2.weblab.components:solr-config:jar:*</include>
</includes>
<useTransitiveDependencies>false</useTransitiveDependencies>
<useStrictFiltering>true</useStrictFiltering>
<outputDirectory>${solr.path}/</outputDirectory>
<unpack>true</unpack>
<unpackOptions>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.ow2.weblab.bundle</groupId>
<artifactId>parent</artifactId>
<version>2.1.0-SNAPSHOT</version>
<version>2.1.0-beta</version>
<relativePath>../pom.xml</relativePath>
</parent>
......@@ -289,7 +289,7 @@
<configuration>
<tarLongFileMode>gnu</tarLongFileMode>
<descriptor>assembly.xml</descriptor>
<finalName>WebLab-Bundle-Karaf-${maven.build.timestamp}</finalName>
<finalName>WebLab-Bundle-${maven.build.timestamp}</finalName>
<encoding>UTF-8</encoding>
<outputDirectory>../target</outputDirectory>
</configuration>
......
......@@ -6,7 +6,7 @@
<parent>
<groupId>org.ow2.weblab.bundle</groupId>
<artifactId>parent</artifactId>
<version>2.1.0-SNAPSHOT</version>
<version>2.1.0-beta</version>
<relativePath>../../pom.xml</relativePath>
</parent>
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>org.ow2.weblab.bundle</groupId>
<artifactId>parent</artifactId>
<version>2.1.0-SNAPSHOT</version>
<version>2.1.0-beta</version>
<relativePath>../../pom.xml</relativePath>
</parent>
......
......@@ -52,23 +52,16 @@
</bean>
<bean id="WebLab" class="org.ow2.weblab.bundle.conf.WebLabBean">
<property name="debug" value="info" />
<property name="jmxEnabled" value="true" />
<property name="remoteAccess" value="false" />
<property name="remoteLogin" value="weblab" />
<property name="remotePassword" value="weblab" />
<property name="repository" value="${weblab.data}repository" />
<property name="solrData" value="${weblab.home}${solr.path}/server/cores/core_default/data" />
<property name="contentFolder" value="${weblab.data}content" />
<property name="servicesReconfigure" value="true" />
<!-- FIXME not here anymore ! -->
<property name="solrData" value="${weblab.data}solr" />
<property name="timeout" value="300000" />
<property name="toindex" value="${files.to.index}" />
<property name="warcs" value="${warcs.to.index}" />
<property name="bus">
<ref bean="Karaf" />
</property>
......
......@@ -6,7 +6,7 @@
<parent>
<groupId>org.ow2.weblab.bundle</groupId>
<artifactId>parent</artifactId>
<version>2.1.0-SNAPSHOT</version>
<version>2.1.0-beta</version>
<relativePath>../pom.xml</relativePath>
</parent>
......@@ -233,6 +233,4 @@
</plugins>
</build>
</project>
......@@ -4,7 +4,7 @@
<parent>
<groupId>org.ow2.weblab.bundle</groupId>
<artifactId>parent</artifactId>
<version>2.1.0-SNAPSHOT</version>
<version>2.1.0-beta</version>
<relativePath>../../pom.xml</relativePath>
</parent>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.ow2.weblab.bundle</groupId>
<artifactId>parent</artifactId>
<version>2.1.0-SNAPSHOT</version>
<version>2.1.0-beta</version>
<relativePath>../../pom.xml</relativePath>
</parent>
......@@ -106,4 +106,5 @@
</plugin>
</plugins>
</build>
</project>
......@@ -39,10 +39,10 @@ public class Emailer {
/**
* Send a mail using properties
* @param properties
* @param properties the configuration bean
* @param subject message subject
* @param message message content
* @param logger
* @param logger the logger used inside
*/
public static void sendEmail(WebLabBean properties, String subject, String message,Logger logger){
String server = properties.getMonitoring().getServer();
......
......@@ -62,6 +62,7 @@ public class Launcher {
/**
* @param args
* The main command arguments
*/
public static void main(final String[] args) {
......@@ -169,6 +170,7 @@ public class Launcher {
Launcher.end(Constants.COMMAND_FAILED);
}
Launcher.end(0);
}
......@@ -203,30 +205,43 @@ public class Launcher {
if (repositoryPath == null) {
Launcher.logger.info("No repository found. Nothing to delete from repository.");
} else {
final File repository = new File(repositoryPath);
FileUtils.deleteDirectory(repository);
Launcher.logger.info(repository.getAbsolutePath() + " has been reset.");
Launcher.cleanFolderIfExist(repositoryPath);
}
// solr index
final String solrDataPath = Launcher.configuration.getSolrData();
if (solrDataPath == null) {
Launcher.logger.info("No path to SolR index found. Nothing to delete from index.");
Launcher.logger.info("No path to Solr index found. Nothing to delete from index.");
} else {
final boolean needRestart = Launcher.configuration.getSolrServer().isEnabled() && Launcher.configuration.getSolrServer().isServerFullyStarted(true);
if (needRestart) {
Launcher.logger.info("Solr is running. Stopping it to enable reset of index.");
ServerManager.stop(Launcher.configuration.getSolrServer(), true, Launcher.logger);
}
final File index = new File(solrDataPath);
FileUtils.deleteDirectory(index);
Launcher.logger.info(index.getAbsolutePath() + " has been reset.");
Launcher.logger.info(index.getAbsolutePath() + " has been removed.");
if (Launcher.configuration.getApplicationServer().isServerFullyStarted(false)) {
Launcher.logger.info("Reloading Solr.");
Launcher.configuration.getApplicationServer().executeOnWebApp("solr", "reload");
if (needRestart) {
Launcher.logger.info("Restarting Solr.");
ServerManager.start(Launcher.configuration.getSolrServer(), Launcher.logger, true);
}
}
// Content
final String contentFolder = Launcher.configuration.getContentFolder();
if (contentFolder == null) {
Launcher.logger.info("No content folder path found. Nothing to delete.");
} else {
Launcher.cleanFolderIfExist(contentFolder);
}
// webdav
final String webdavURL = Launcher.configuration.getWebdavUrl();
if (webdavURL == null) {
Launcher.logger.info("No webDAV access found. Nothing to delete from webDAV repository.");
Launcher.logger.fine("No webDAV access found. Nothing to delete from webDAV repository.");
} else if (Launcher.configuration.getPortal().isServerFullyStarted(false)) {
final String user = Launcher.configuration.getWebdavUser();
final String password = Launcher.configuration.getWebdavPassword();
......@@ -253,7 +268,21 @@ public class Launcher {
} catch (final IOException exception) {
Launcher.logger.log(Level.SEVERE, exception.getLocalizedMessage(), exception);
}
}
/**
* @param repositoryPath
* @throws IOException
*/
protected static void cleanFolderIfExist(final String repositoryPath) throws IOException {
final File repository = new File(repositoryPath);
if (repository.exists()) {
FileUtils.cleanDirectory(repository);
Launcher.logger.info(repository.getAbsolutePath() + " has been reset.");
} else {
Launcher.logger.info(repository.getAbsolutePath() + " does not exist, nothing to reset.");
}
}
......@@ -333,7 +362,6 @@ public class Launcher {
} catch (final IOException ioe) {
Launcher.logger.log(Level.FINEST, ioe.getLocalizedMessage(), ioe);
}
Launcher.end(0);
}
}
......
......@@ -38,23 +38,30 @@ public class WebLabBean {
private String name = "WebLab";
// TODO remove ?
@Deprecated
private String debug = "info";
// TODO remove ?
@Deprecated
private String home = "info";
// TODO remove ?
@Deprecated
private boolean jmxEnabled = true;
private float classVersion = 51.0f;
private float classVersion = 52.0f;
private MonitoringBean monitoring = new MonitoringBean();
private String contentFolder = "data/content";
private boolean remoteAccess = false;
......@@ -64,26 +71,32 @@ public class WebLabBean {
private String remotePassword = "weblab";
// TODO remove ?
private String repository = "weblab";
private String repository = "data/repository";
private boolean servicesReconfigure = true;
// TODO remove ?
private String solrData = "";
private String solrData = null;
// TODO remove ?
@Deprecated
private String split = "";
// TODO remove ?
@Deprecated
private long timeout = 300000;
// TODO remove ?
@Deprecated
private String toindex = "data/toIndex";
// TODO remove ?
@Deprecated
private String warcs = "data/warcs";
......@@ -99,6 +112,8 @@ public class WebLabBean {
private String resetScript;
// TODO remove ?
@Deprecated
private String chainManagerService;
......@@ -405,4 +420,25 @@ public class WebLabBean {
public void setSolrServer(final SolrServer solrServer) {
this.solrServer = solrServer;
}
/**
* @return the contentFolder
*/
public String getContentFolder() {
return this.contentFolder;
}
/**
* @param contentFolder
* the contentFolder to set
*/
public void setContentFolder(final String contentFolder) {
this.contentFolder = contentFolder;
}
}
......@@ -29,7 +29,6 @@ import java.util.logging.Logger;
import org.apache.commons.io.FileUtils;
import org.ow2.weblab.bundle.Constants;
import org.ow2.weblab.bundle.Launcher;
import org.ow2.weblab.bundle.conf.WebLabBean;
import org.ow2.weblab.bundle.server.WebLabServer.State;
import org.ow2.weblab.bundle.utils.PathUtils;
......@@ -148,7 +147,15 @@ public class ServerManager {
}
private static final void stop(final WebLabServer server, final boolean force, final Logger logger) {
/**
* @param server
* The server to stop
* @param force
* Whether or not to kill the server if stopping it fails
* @param logger
* The logger to be used for messages
*/
public static final void stop(final WebLabServer server, final boolean force, final Logger logger) {
if (!server.isEnabled()) {
......@@ -232,10 +239,14 @@ public class ServerManager {
* Start server if it is enable.
*
* @param server
* The server to start
* @param logger
* The logger used for the messages
* @param waitForStart
* Whether or not to wait for the end of server startup
* @return Return process.
*/
private static final Process start(final WebLabServer server, final Logger logger, final boolean waitForStart) {
public static final Process start(final WebLabServer server, final Logger logger, final boolean waitForStart) {
if (server == null) {
return null;
......@@ -354,9 +365,6 @@ public class ServerManager {
}
}
Launcher.end(0);
}
......@@ -364,8 +372,11 @@ public class ServerManager {
* Execute a remote method on a TomcatServer and display results
*
* @param server
* The server on which the request should be sent
* @param webapp
* The name of the webapp to receive the request
* @param args
* The args to send (in fact only args[2] is sent
*/
public void rmi(final String server, final String webapp, final String[] args) {
// retrieve webapp name and command
......
......@@ -54,14 +54,14 @@ public class TomcatJMXClient {
/**
* JMX Client accessing JMX server on the given port
*
*
* @param logger
* a logger
* @param jmxport
* a jmx port for a tomcat server
* @param timeout
* This client will retry connection on JMX remote server until timeout
* @throws IOException
* @throws IOException If any wrong occurs
*/
public TomcatJMXClient(final Logger logger, final int jmxport, final int timeout) throws IOException {
this.logger = logger;
......@@ -80,9 +80,9 @@ public class TomcatJMXClient {
/**
* Retrieve webapp status for deploy web apps
*
*
* @return status for each web app
* @throws IOException
* @throws IOException If any wrong occurs
*/
public Map<String, String> getWebAppStatus() throws IOException {
......@@ -120,7 +120,7 @@ public class TomcatJMXClient {
/**
* Wait for some time for server start
*
*
* @param timeout
* in ms
* @return true if server is started before the end of the timeout else false
......@@ -157,7 +157,7 @@ public class TomcatJMXClient {
/**
* Return server status
*
*
* @return the server status (STARTING, STARTED, STOPPING or UNDEFINED)
*/
public State status() {
......@@ -208,7 +208,7 @@ public class TomcatJMXClient {
/**
* Execute a remote method on a MBean
*
*
* @param webapp
* the name of the webapp
* @param command
......
......@@ -21,8 +21,8 @@ package org.ow2.weblab.bundle.utils;
* Execute a method and return an Object
*
* @author asaval
*
* @param <T>
* The returned type of the status after execution
*/
public abstract class Executor<T> {
......@@ -57,9 +57,9 @@ public abstract class Executor<T> {
/**
* Execute a method and return a <T> Object or throws an Exception
* Execute a method and return a &lt;T&gt; Object or throws an Exception
*
* @return an Object of type <T>
* @return an Object of type &lt;T&gt;
* @throws Exception
* if something went wrong.
*/
......
......@@ -21,7 +21,7 @@ import java.io.File;
/**
* Utility class to manage Pathes, set as deprecated once we use Java 1.7
*
*
* @author asaval
*
*/
......@@ -45,8 +45,9 @@ public final class PathUtils {
/**
* Retrieve WebLab Home
*
*
* @param subdir
* The name of the sub directory inside weblab home
* @return WebLab Home
*/
public static String getWebLabHome(final String subdir) {
......@@ -57,7 +58,7 @@ public final class PathUtils {
/**
* Get script extension depending on OS bat for Windows and sh for others
*
*
* @return the OS depending script extension
*/
public static String getExtension() {
......@@ -67,7 +68,7 @@ public final class PathUtils {
/**
* Create a path with OS dedicated path separator
*
*
* @param waypoints
* waypoints on the path
* @return a string representing the path for the current OS
......@@ -93,7 +94,7 @@ public final class PathUtils {
/**
* Remove last separator at the end of the path if any
*
*
* @param dir
* a path
* @return the path without a separator at the end
......@@ -109,7 +110,7 @@ public final class PathUtils {
/**
* Return only the name of the file (without any extension)
*
*
* @param file
* a file
* @return name of the file
......
......@@ -112,7 +112,7 @@ public class ProcessUtils {
process.exitValue();
return process;
} catch (final IllegalThreadStateException ignored) {
//Ignored
// Ignored
}
long currentWaitingTime = 0L;
......@@ -140,11 +140,13 @@ public class ProcessUtils {
* Stop with a message it process failed.
*
* @param logger
* The logger used inside
* @param process
* the process
* @param message
* the message
* @param code
* The error code to return in case of failure
*/
public static void okOrFail(final Logger logger, final Process process, final String message, final int code) {
try {
......@@ -181,7 +183,9 @@ public class ProcessUtils {
* a logger
* @return the output of the run process
* @throws IOException
* If the process cannot be started (or an error occurred when calling start at least)
* @throws InterruptedException
* If an error occured when waiting for the end of the process
*/
public static List<String> execute(final ProcessBuilder processBuilder, final Logger logger) throws IOException, InterruptedException {
final ProcessBuilder processb = processBuilder;
......@@ -202,10 +206,13 @@ public class ProcessUtils {
* if failed, print last error
*
* @param logger
* The logger used inside
* @param executor
* the Executor
* @param millis
* time to wait
* @param <T>
* The type returned by the executor
* @return result of execute function or null if it failed
*/
public static <T> T tryToExecuteDuring(final Logger logger, final long millis, final Executor<T> executor) {
......@@ -606,13 +613,21 @@ public class ProcessUtils {
* Creates a MBeanServerConnection to a remote or local host
*
* @param host
* The host name
* @param port
* The JMX port
* @param login
* The login might be null if there is no authentication
* @param password
* The password, must be null or empty if there is no authentication
* @param path
* The jmxrmi path to the bean
* @param timeout
* THe time to wait when opening the connection
* @param log
* Whether or not to display connection error
* @param logger
* The logger used inside
* @return a MBeanServerConnection
*/
public static MBeanServerConnection createJMXclient(final String host, final int port, final String login, final String password, final String path, final int timeout, final boolean log,
......@@ -639,8 +654,11 @@ public class ProcessUtils {
* Create a MbeanServerConnection from a WebLabServer
*
* @param server
* The server, used to get the jmx port and the timeout
* @param log
* Whether or not to display connection error
* @param logger
* The logger used inside
* @return a MbeanServerConnection from a WebLabServer
*/
public static MBeanServerConnection createJMXclient(final WebLabServer server, final boolean log, final Logger logger) {
......
......@@ -45,7 +45,7 @@ public class TomcatUtils {
/**
* Copy a tomcat and return the file to the new Tomcat
*
*
* @param source
* the Tomcat to copy
* @param dest
......@@ -53,8 +53,10 @@ public class TomcatUtils {
* @param services
* list of services to copy
* @param logger
* the logger used inside
* @return file to the new Tomcat
* @throws IOException
* If an error occurs when copying, deleting or creating various files.
*/
public static File copy(final String source, final String dest, final List<String> services, final Logger logger) throws IOException {
final File newTomcat = new File(dest);
......@@ -81,15 +83,22 @@ public class TomcatUtils {
/**
* Update Tomcat server ports and return a tomcatServer
*
*
* @param tomcat
* The original tomcat server to be used as basis
* @param newTomcat
* The location of the new tomcat server
* @param tomcatName
* The name of the new tomcat server
* @param index
* The value to add to jmx port and http port to original tomcat value to create the new tomcat
* @param logger
* The logger used inside
* @param configuration
* The configuration bean to be used as basis
* @return a TomcatServer
* @throws IOException
* If an error occured compying the files
*/
public static TomcatServer updatePorts(final TomcatServer tomcat, final File newTomcat, final String tomcatName, final int index, final Logger logger, final WebLabBean configuration)
throws IOException {
......@@ -121,7 +130,7 @@ public class TomcatUtils {
/**
* Return a list of non-standard directory deployed in tomcat
*
*
* @param tomcat
* a tomcat Server
* @param logger
......@@ -150,17 +159,17 @@ public class TomcatUtils {
/**
* Return a Tomcat
*
* @param tomcat
* @param name
* @param home