use of org.pentaho.di.cluster.SlaveServer in project pentaho-kettle by pentaho.
the class SlaveServerConcurrentTest method generateSlaveServer.
private SlaveServer generateSlaveServer() {
Random random = new Random();
int id = random.nextInt();
SlaveServer slaveServer = new SlaveServer();
slaveServer.setName(NAME + id);
slaveServer.setHostname(HOST_NAME + id);
slaveServer.setPort(PORT + id);
slaveServer.setWebAppName(WEB_APP_NAME + id);
slaveServer.setUsername(USERNAME + id);
slaveServer.setPassword(PASSWORD + id);
slaveServer.setProxyHostname(PROXY_HOST_NAME + id);
slaveServer.setProxyPort(PROXY_PORT + id);
slaveServer.setNonProxyHosts(NON_PROXY_HOSTS + id);
slaveServer.setObjectId(new StringObjectId(ID + id));
return slaveServer;
}
use of org.pentaho.di.cluster.SlaveServer in project pentaho-kettle by pentaho.
the class DefaultRunConfigurationExecutor method setSlaveServer.
private void setSlaveServer(ExecutionConfiguration executionConfiguration, AbstractMeta meta, DefaultRunConfiguration defaultRunConfiguration, VariableSpace variableSpace) throws KettleException {
SlaveServer slaveServer = meta.findSlaveServer(defaultRunConfiguration.getServer());
executionConfiguration.setRemoteServer(slaveServer);
if (slaveServer == null) {
String filename = "";
if (variableSpace instanceof AbstractMeta) {
filename = ((AbstractMeta) variableSpace).getFilename();
}
throw new KettleException(BaseMessages.getString(PKG, "DefaultRunConfigurationExecutor.RemoteNotFound.Error", filename, defaultRunConfiguration.getName(), "{0}", defaultRunConfiguration.getServer()));
}
}
use of org.pentaho.di.cluster.SlaveServer in project pentaho-kettle by pentaho.
the class RunConfigurationImportExtensionPointTest method shouldCreateRunConfigurationsForSlaveServer.
@Test
public void shouldCreateRunConfigurationsForSlaveServer() throws Exception {
JobMeta jobMeta = mock(JobMeta.class);
JobEntryCopy jobEntryCopy1 = mock(JobEntryCopy.class);
JobEntryCopy jobEntryCopy2 = mock(JobEntryCopy.class);
JobEntryCopy jobEntryCopy3 = mock(JobEntryCopy.class);
JobEntryTrans trans1 = mock(JobEntryTrans.class);
JobEntryTrans trans2 = mock(JobEntryTrans.class);
JobEntryTrans trans3 = mock(JobEntryTrans.class);
ArgumentCaptor<DefaultRunConfiguration> rcCaptor = ArgumentCaptor.forClass(DefaultRunConfiguration.class);
when(jobMeta.getEmbeddedMetaStore()).thenReturn(embeddedMetaStore);
when(jobMeta.getSlaveServers()).thenReturn(Arrays.asList(new SlaveServer("carte1", "host1", "1234", "user", "passw"), new SlaveServer("carte2", "host2", "1234", "user", "passw")));
when(jobMeta.getJobCopies()).thenReturn(Arrays.asList(jobEntryCopy1, jobEntryCopy2, jobEntryCopy3));
when(jobEntryCopy1.getEntry()).thenReturn(trans1);
when(jobEntryCopy2.getEntry()).thenReturn(trans2);
when(jobEntryCopy3.getEntry()).thenReturn(trans3);
when(trans1.getRemoteSlaveServerName()).thenReturn("carte1");
when(trans2.getRemoteSlaveServerName()).thenReturn("carte1");
when(trans3.getRemoteSlaveServerName()).thenReturn("carte2");
when(trans1.getRunConfiguration()).thenReturn(null);
when(trans2.getRunConfiguration()).thenReturn(null);
when(trans3.getRunConfiguration()).thenReturn(null);
when(runConfigurationManager.getNames()).thenReturn(Collections.singletonList("pentaho_auto_carte1_config"));
runConfigurationImportExtensionPoint.callExtensionPoint(log, jobMeta);
verify(runConfigurationManager, times(2)).save(rcCaptor.capture());
verify(trans1).setRunConfiguration("pentaho_auto_carte1_config_1");
verify(trans2).setRunConfiguration("pentaho_auto_carte1_config_1");
verify(trans3).setRunConfiguration("pentaho_auto_carte2_config");
List<DefaultRunConfiguration> allValues = rcCaptor.getAllValues();
DefaultRunConfiguration runConfiguration1 = allValues.get(0);
assertEquals("pentaho_auto_carte1_config_1", runConfiguration1.getName());
assertEquals("carte1", runConfiguration1.getServer());
DefaultRunConfiguration runConfiguration2 = allValues.get(1);
assertEquals("pentaho_auto_carte2_config", runConfiguration2.getName());
assertEquals("carte2", runConfiguration2.getServer());
}
use of org.pentaho.di.cluster.SlaveServer in project pentaho-kettle by pentaho.
the class SlaveServerConfig method getXML.
public String getXML() {
StringBuilder xml = new StringBuilder();
xml.append(XMLHandler.openTag(XML_TAG));
for (SlaveServer slaveServer : masters) {
xml.append(slaveServer.getXML());
}
XMLHandler.addTagValue("report_to_masters", reportingToMasters);
if (slaveServer != null) {
xml.append(slaveServer.getXML());
}
XMLHandler.addTagValue("joining", joining);
XMLHandler.addTagValue("max_log_lines", maxLogLines);
XMLHandler.addTagValue("max_log_timeout_minutes", maxLogTimeoutMinutes);
XMLHandler.addTagValue("object_timeout_minutes", objectTimeoutMinutes);
xml.append(XMLHandler.openTag(XML_TAG_SEQUENCES));
for (SlaveSequence slaveSequence : slaveSequences) {
xml.append(XMLHandler.openTag(SlaveSequence.XML_TAG));
xml.append(slaveSequence.getXML());
xml.append(XMLHandler.closeTag(SlaveSequence.XML_TAG));
}
xml.append(XMLHandler.closeTag(XML_TAG_SEQUENCES));
if (autoSequence != null) {
xml.append(XMLHandler.openTag(XML_TAG_AUTOSEQUENCE));
xml.append(autoSequence.getXML());
xml.append(XMLHandler.addTagValue(XML_TAG_AUTO_CREATE, automaticCreationAllowed));
xml.append(XMLHandler.closeTag(XML_TAG_AUTOSEQUENCE));
}
if (repositoryMeta != null) {
xml.append(XMLHandler.openTag(XML_TAG_REPOSITORY));
xml.append(" ").append(XMLHandler.addTagValue("id", repositoryMeta.getId()));
xml.append(" ").append(XMLHandler.addTagValue("username", repositoryUsername));
xml.append(" ").append(XMLHandler.addTagValue("password", Encr.encryptPasswordIfNotUsingVariables(repositoryPassword)));
xml.append(XMLHandler.closeTag(XML_TAG_REPOSITORY));
}
xml.append(XMLHandler.closeTag(XML_TAG));
return xml.toString();
}
use of org.pentaho.di.cluster.SlaveServer in project pentaho-kettle by pentaho.
the class WebServer method startServer.
public void startServer() throws Exception {
server = new Server();
List<String> roles = new ArrayList<String>();
roles.add(Constraint.ANY_ROLE);
// Set up the security handler, optionally with JAAS
//
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
if (System.getProperty("loginmodulename") != null && System.getProperty("java.security.auth.login.config") != null) {
JAASLoginService jaasLoginService = new JAASLoginService("Kettle");
jaasLoginService.setLoginModuleName(System.getProperty("loginmodulename"));
securityHandler.setLoginService(jaasLoginService);
} else {
roles.add("default");
HashLoginService hashLoginService;
SlaveServer slaveServer = transformationMap.getSlaveServerConfig().getSlaveServer();
if (!Utils.isEmpty(slaveServer.getPassword())) {
hashLoginService = new HashLoginService("Kettle");
hashLoginService.putUser(slaveServer.getUsername(), new Password(slaveServer.getPassword()), new String[] { "default" });
} else {
// See if there is a kettle.pwd file in the KETTLE_HOME directory:
if (Utils.isEmpty(passwordFile)) {
File homePwdFile = new File(Const.getKettleCartePasswordFile());
if (homePwdFile.exists()) {
passwordFile = Const.getKettleCartePasswordFile();
} else {
passwordFile = Const.getKettleLocalCartePasswordFile();
}
}
hashLoginService = new HashLoginService("Kettle", passwordFile) {
@Override
public synchronized UserIdentity putUser(String userName, Credential credential, String[] roles) {
List<String> newRoles = new ArrayList<String>();
newRoles.add("default");
Collections.addAll(newRoles, roles);
return super.putUser(userName, credential, newRoles.toArray(new String[newRoles.size()]));
}
};
}
securityHandler.setLoginService(hashLoginService);
}
Constraint constraint = new Constraint();
constraint.setName(Constraint.__BASIC_AUTH);
constraint.setRoles(roles.toArray(new String[roles.size()]));
constraint.setAuthenticate(true);
ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint(constraint);
constraintMapping.setPathSpec("/*");
securityHandler.setConstraintMappings(new ConstraintMapping[] { constraintMapping });
// Add all the servlets defined in kettle-servlets.xml ...
//
ContextHandlerCollection contexts = new ContextHandlerCollection();
// Root
//
ServletContextHandler root = new ServletContextHandler(contexts, GetRootServlet.CONTEXT_PATH, ServletContextHandler.SESSIONS);
GetRootServlet rootServlet = new GetRootServlet();
rootServlet.setJettyMode(true);
root.addServlet(new ServletHolder(rootServlet), "/*");
PluginRegistry pluginRegistry = PluginRegistry.getInstance();
List<PluginInterface> plugins = pluginRegistry.getPlugins(CartePluginType.class);
for (PluginInterface plugin : plugins) {
CartePluginInterface servlet = pluginRegistry.loadClass(plugin, CartePluginInterface.class);
servlet.setup(transformationMap, jobMap, socketRepository, detections);
servlet.setJettyMode(true);
ServletContextHandler servletContext = new ServletContextHandler(contexts, getContextPath(servlet), ServletContextHandler.SESSIONS);
ServletHolder servletHolder = new ServletHolder((Servlet) servlet);
servletContext.addServlet(servletHolder, "/*");
}
// setup jersey (REST)
ServletHolder jerseyServletHolder = new ServletHolder(ServletContainer.class);
jerseyServletHolder.setInitParameter("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.PackagesResourceConfig");
jerseyServletHolder.setInitParameter("com.sun.jersey.config.property.packages", "org.pentaho.di.www.jaxrs");
root.addServlet(jerseyServletHolder, "/api/*");
// setup static resource serving
// ResourceHandler mobileResourceHandler = new ResourceHandler();
// mobileResourceHandler.setWelcomeFiles(new String[]{"index.html"});
// mobileResourceHandler.setResourceBase(getClass().getClassLoader().
// getResource("org/pentaho/di/www/mobile").toExternalForm());
// Context mobileContext = new Context(contexts, "/mobile", Context.SESSIONS);
// mobileContext.setHandler(mobileResourceHandler);
// Allow png files to be shown for transformations and jobs...
//
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase("temp");
// add all handlers/contexts to server
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { contexts, resourceHandler });
securityHandler.setHandler(handlers);
server.setHandler(securityHandler);
// Start execution
createListeners();
server.start();
}
Aggregations