Search in sources :

Example 41 with SlaveServer

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;
}
Also used : Random(java.util.Random) SlaveServer(org.pentaho.di.cluster.SlaveServer) StringObjectId(org.pentaho.di.repository.StringObjectId)

Example 42 with 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()));
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) AbstractMeta(org.pentaho.di.base.AbstractMeta) SlaveServer(org.pentaho.di.cluster.SlaveServer)

Example 43 with SlaveServer

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());
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) SlaveServer(org.pentaho.di.cluster.SlaveServer) Test(org.junit.Test)

Example 44 with SlaveServer

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();
}
Also used : SlaveServer(org.pentaho.di.cluster.SlaveServer)

Example 45 with SlaveServer

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();
}
Also used : HandlerList(org.eclipse.jetty.server.handler.HandlerList) Server(org.eclipse.jetty.server.Server) SlaveServer(org.pentaho.di.cluster.SlaveServer) Constraint(org.eclipse.jetty.util.security.Constraint) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ArrayList(java.util.ArrayList) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) ResourceHandler(org.eclipse.jetty.server.handler.ResourceHandler) SlaveServer(org.pentaho.di.cluster.SlaveServer) HashLoginService(org.eclipse.jetty.security.HashLoginService) ConstraintSecurityHandler(org.eclipse.jetty.security.ConstraintSecurityHandler) ArrayList(java.util.ArrayList) HandlerList(org.eclipse.jetty.server.handler.HandlerList) List(java.util.List) Password(org.eclipse.jetty.util.security.Password) Credential(org.eclipse.jetty.util.security.Credential) ConstraintMapping(org.eclipse.jetty.security.ConstraintMapping) UserIdentity(org.eclipse.jetty.server.UserIdentity) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) JAASLoginService(org.eclipse.jetty.plus.jaas.JAASLoginService) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) File(java.io.File)

Aggregations

SlaveServer (org.pentaho.di.cluster.SlaveServer)103 KettleException (org.pentaho.di.core.exception.KettleException)35 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)28 ClusterSchema (org.pentaho.di.cluster.ClusterSchema)22 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)18 PartitionSchema (org.pentaho.di.partition.PartitionSchema)18 Test (org.junit.Test)17 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)17 JobMeta (org.pentaho.di.job.JobMeta)16 ObjectId (org.pentaho.di.repository.ObjectId)15 StepMeta (org.pentaho.di.trans.step.StepMeta)14 ArrayList (java.util.ArrayList)13 TransMeta (org.pentaho.di.trans.TransMeta)11 KettleFileException (org.pentaho.di.core.exception.KettleFileException)10 NotePadMeta (org.pentaho.di.core.NotePadMeta)9 UnknownParamException (org.pentaho.di.core.parameters.UnknownParamException)9 Point (org.pentaho.di.core.gui.Point)8 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)7 DuplicateParamException (org.pentaho.di.core.parameters.DuplicateParamException)7 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)7