org.pentaho.di.www.GetSlavesServlet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kettle-engine Show documentation
Show all versions of kettle-engine Show documentation
Container pom for Pentaho Data Integration modules
The newest version!
/*! ******************************************************************************
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2018 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
package org.pentaho.di.www;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Date;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.xml.XMLHandler;
import org.pentaho.di.i18n.BaseMessages;
public class GetSlavesServlet extends BaseHttpServlet implements CartePluginInterface {
private static Class> PKG = GetSlavesServlet.class; // for i18n purposes,
// needed by
// Translator2!!
public static final String XML_TAG_SLAVESERVER_DETECTIONS = "SlaveServerDetections";
private static final long serialVersionUID = -5472184538138241050L;
public static final String CONTEXT_PATH = "/kettle/getSlaves";
public GetSlavesServlet() {
}
public GetSlavesServlet( List slaveServers ) {
super( slaveServers );
}
public GetSlavesServlet( List slaveServers, boolean isJetty ) {
super( slaveServers, isJetty );
}
/**
/kettle/getSlaves
GET
Gets list of slave servers.
Retrieves list of slave servers which are known to specific server.
Example Request:
GET /kettle/getSlaves
Response Body
element:
(custom)
media types:
text/xml
Response contains list of slave servers.
Example Response:
Dynamic slave [localhost:909] localhost 909
cluster Encrypted 2be98afc86aa7f2e4cb1aa265cd86aac8
N
Y
2014/11/17 06:42:28.043
2014/11/17 06:42:27.372
Status Codes
code
description
200
Request was processed.
500
Internal server error occurs during request processing.
*/
public void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException,
IOException {
if ( isJettyMode() && !request.getContextPath().startsWith( CONTEXT_PATH ) ) {
return;
}
if ( log.isDebug() ) {
logDebug( BaseMessages.getString( PKG, "GetStatusServlet.StatusRequested" ) );
}
response.setStatus( HttpServletResponse.SC_OK );
// We always reply in XML...
//
response.setContentType( "text/xml" );
response.setCharacterEncoding( Const.XML_ENCODING );
PrintStream out = new PrintStream( response.getOutputStream() );
out.print( XMLHandler.getXMLHeader( Const.XML_ENCODING ) );
out.println( XMLHandler.openTag( XML_TAG_SLAVESERVER_DETECTIONS ) );
if ( getDetections() != null ) {
for ( SlaveServerDetection slaveServer : getDetections() ) {
try {
slaveServer.getSlaveServer().getStatus();
} catch ( Exception e ) {
slaveServer.setActive( false );
slaveServer.setLastInactiveDate( new Date() );
}
out.println( slaveServer.getXML() );
}
}
out.println( XMLHandler.closeTag( XML_TAG_SLAVESERVER_DETECTIONS ) );
}
public String toString() {
return "Get list of slave servers";
}
public String getService() {
return CONTEXT_PATH + " (" + toString() + ")";
}
public String getContextPath() {
return CONTEXT_PATH;
}
}