Search in sources :

Example 56 with SlaveServer

use of org.pentaho.di.cluster.SlaveServer in project pentaho-kettle by pentaho.

the class JobEntryJobTest method testJobEntry.

@SuppressWarnings("unchecked")
private void testJobEntry(Repository rep, boolean includeJobName, ObjectLocationSpecificationMethod method, ObjectLocationSpecificationMethod expectedMethod) throws KettleXMLException, ParserConfigurationException, SAXException, IOException {
    List<DatabaseMeta> databases = mock(List.class);
    List<SlaveServer> slaveServers = mock(List.class);
    IMetaStore metaStore = mock(IMetaStore.class);
    JobEntryJob jobEntryJob = getJobEntryJob();
    jobEntryJob.loadXML(getEntryNode(includeJobName, method), databases, slaveServers, rep, metaStore);
    assertEquals("If we connect to repository then we use rep_name method", expectedMethod, jobEntryJob.getSpecificationMethod());
}
Also used : SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore)

Example 57 with SlaveServer

use of org.pentaho.di.cluster.SlaveServer in project pentaho-platform by pentaho.

the class KettleSystemListener method startup.

public boolean startup(final IPentahoSession session) {
    // Default DI_HOME System Property if not set
    if (StringUtils.isEmpty(System.getProperty("DI_HOME"))) {
        String defaultKettleHomePath = PentahoSystem.getApplicationContext().getSolutionPath("system" + File.separator + "kettle");
        logger.error("DI_HOME System Property not properly set. The default location of " + defaultKettleHomePath + " will be used.");
        System.setProperty("DI_HOME", defaultKettleHomePath);
    }
    if (usePlatformLogFile) {
        KettleLogStore.init(false, false);
        initLogging();
    }
    hookInDataSourceProvider();
    try {
        KettleSystemListener.environmentInit(session);
    } catch (Throwable t) {
        t.printStackTrace();
        Logger.error(KettleSystemListener.class.getName(), Messages.getInstance().getErrorString(// $NON-NLS-1$
        "KettleSystemListener.ERROR_0001_PLUGIN_LOAD_FAILED"));
    }
    try {
        String slaveServerConfigFilename = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "system" + File.separator + "kettle" + File.separator + "slave-server-config.xml";
        File slaveServerConfigFile = new File(PentahoSystem.getApplicationContext().getSolutionPath(slaveServerConfigFilename));
        if (slaveServerConfigFile.exists()) {
            InputStream is = new FileInputStream(slaveServerConfigFile);
            Node configNode = getSlaveServerConfigNode(is);
            SlaveServerConfig config = new DIServerConfig(new LogChannel("Slave server config"), configNode);
            config.setFilename(slaveServerConfigFile.getAbsolutePath());
            SlaveServer slaveServer = new SlaveServer();
            config.setSlaveServer(slaveServer);
            CarteSingleton.setSlaveServerConfig(config);
        }
    } catch (Throwable t) {
        t.printStackTrace();
        Logger.error(KettleSystemListener.class.getName(), t.getMessage());
    }
    return true;
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Node(org.w3c.dom.Node) LogChannel(org.pentaho.di.core.logging.LogChannel) SlaveServerConfig(org.pentaho.di.www.SlaveServerConfig) SlaveServer(org.pentaho.di.cluster.SlaveServer) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 58 with SlaveServer

use of org.pentaho.di.cluster.SlaveServer in project pentaho-kettle by pentaho.

the class WebServer method startSlaveMonitoring.

/**
 * This method registers a timer to check up on all the registered slave servers every X seconds.<br>
 */
private void startSlaveMonitoring() {
    slaveMonitoringTimer = new Timer("WebServer Timer");
    TimerTask timerTask = new TimerTask() {

        public void run() {
            for (SlaveServerDetection slaveServerDetection : detections) {
                SlaveServer slaveServer = slaveServerDetection.getSlaveServer();
                // 
                try {
                    // TODO: consider making this lighter or retaining more information...
                    // throws the exception
                    slaveServer.getStatus();
                    slaveServerDetection.setActive(true);
                    slaveServerDetection.setLastActiveDate(new Date());
                } catch (Exception e) {
                    slaveServerDetection.setActive(false);
                    slaveServerDetection.setLastInactiveDate(new Date());
                // TODO: kick it out after a configurable period of time...
                }
            }
        }
    };
    int detectionTime = defaultDetectionTimer();
    slaveMonitoringTimer.schedule(timerTask, detectionTime, detectionTime);
}
Also used : Timer(java.util.Timer) TimerTask(java.util.TimerTask) SlaveServer(org.pentaho.di.cluster.SlaveServer) Date(java.util.Date) KettleException(org.pentaho.di.core.exception.KettleException) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) Constraint(org.eclipse.jetty.util.security.Constraint)

Example 59 with SlaveServer

use of org.pentaho.di.cluster.SlaveServer in project pentaho-kettle by pentaho.

the class AbstractMetaTest method testAddOrReplaceSlaveServer.

@Test
public void testAddOrReplaceSlaveServer() throws Exception {
    // meta.addOrReplaceSlaveServer() right now will fail with an NPE
    assertNull(meta.getSlaveServers());
    List<SlaveServer> slaveServers = new ArrayList<>();
    meta.setSlaveServers(slaveServers);
    assertNotNull(meta.getSlaveServers());
    SlaveServer slaveServer = mock(SlaveServer.class);
    meta.addOrReplaceSlaveServer(slaveServer);
    assertFalse(meta.getSlaveServers().isEmpty());
    meta.addOrReplaceSlaveServer(slaveServer);
    assertEquals(1, meta.getSlaveServerNames().length);
    assertNull(meta.findSlaveServer(null));
    assertNull(meta.findSlaveServer(""));
    when(slaveServer.getName()).thenReturn("ss1");
    assertEquals(slaveServer, meta.findSlaveServer("ss1"));
}
Also used : ArrayList(java.util.ArrayList) SlaveServer(org.pentaho.di.cluster.SlaveServer) Test(org.junit.Test)

Example 60 with SlaveServer

use of org.pentaho.di.cluster.SlaveServer in project pentaho-kettle by pentaho.

the class DefaultRunConfigurationUI method attach.

@Override
public void attach(RunConfigurationDialog runConfigurationDialog) {
    this.runConfigurationDialog = runConfigurationDialog;
    FormLayout gformLayout = new FormLayout();
    gformLayout.marginWidth = 10;
    gformLayout.marginHeight = 10;
    runConfigurationDialog.getGroup().setLayout(gformLayout);
    Composite wTarget = new Composite(runConfigurationDialog.getGroup(), SWT.NONE);
    wTarget.setLayout(new FormLayout());
    props.setLook(wTarget);
    Button wbLocal = new Button(wTarget, SWT.RADIO);
    props.setLook(wbLocal);
    wbLocal.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Label.Local"));
    wbLocal.setSelection(defaultRunConfiguration.isLocal());
    FormData fdbLocal = new FormData();
    fdbLocal.top = new FormAttachment(0);
    fdbLocal.left = new FormAttachment(0);
    wbLocal.setLayoutData(fdbLocal);
    Button wbPentaho = new Button(wTarget, SWT.RADIO);
    props.setLook(wbPentaho);
    boolean connectedToPentahoServer = spoonSupplier.get().getRepository() != null && spoonSupplier.get().getRepository().getRepositoryMeta().getId().equals("PentahoEnterpriseRepository");
    wbPentaho.setVisible(connectedToPentahoServer);
    if (connectedToPentahoServer) {
        wbPentaho.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Label.Pentaho"));
        wbPentaho.setSelection(defaultRunConfiguration.isPentaho());
        FormData fdbPentaho = new FormData();
        fdbPentaho.top = new FormAttachment(wbLocal, 10);
        fdbPentaho.left = new FormAttachment(0);
        wbPentaho.setLayoutData(fdbPentaho);
    }
    Button wbRemote = new Button(wTarget, SWT.RADIO);
    props.setLook(wbRemote);
    wbRemote.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Label.Remote"));
    wbRemote.setSelection(defaultRunConfiguration.isRemote() || defaultRunConfiguration.isClustered());
    FormData fdbRemote = new FormData();
    fdbRemote.top = new FormAttachment(wbPentaho, 10);
    fdbRemote.left = new FormAttachment(0);
    wbRemote.setLayoutData(fdbRemote);
    FormData fdTarget = new FormData();
    fdTarget.left = new FormAttachment(0);
    fdTarget.top = new FormAttachment(0);
    wTarget.setLayoutData(fdTarget);
    Label vSpacer = new Label(runConfigurationDialog.getGroup(), SWT.VERTICAL | SWT.SEPARATOR);
    FormData fdvSpacer = new FormData();
    fdvSpacer.width = 1;
    fdvSpacer.left = new FormAttachment(wTarget, 30);
    fdvSpacer.top = new FormAttachment(0, 0);
    fdvSpacer.bottom = new FormAttachment(100, 0);
    vSpacer.setLayoutData(fdvSpacer);
    Composite wcLocal = new Composite(runConfigurationDialog.getGroup(), SWT.NONE);
    props.setLook(wcLocal);
    wcLocal.setLayout(new GridLayout());
    Text wlLocal = new Text(wcLocal, SWT.MULTI | SWT.WRAP);
    wlLocal.setEditable(false);
    props.setLook(wlLocal);
    wlLocal.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Text.Local"));
    GridData gdlLocal = new GridData(GridData.FILL_HORIZONTAL);
    gdlLocal.widthHint = 200;
    wlLocal.setLayoutData(gdlLocal);
    FormData fdcLocal = new FormData();
    fdcLocal.left = new FormAttachment(vSpacer, 10);
    fdcLocal.top = new FormAttachment(0);
    fdcLocal.right = new FormAttachment(100);
    fdcLocal.bottom = new FormAttachment(100);
    wcLocal.setLayoutData(fdcLocal);
    Composite wcPentaho = new Composite(runConfigurationDialog.getGroup(), SWT.NONE);
    props.setLook(wcPentaho);
    wcPentaho.setLayout(new GridLayout());
    Text wlPentaho = new Text(wcPentaho, SWT.MULTI | SWT.WRAP | SWT.LEFT);
    wlPentaho.setEditable(false);
    props.setLook(wlPentaho);
    wlPentaho.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Text.Pentaho"));
    GridData gdlPentaho = new GridData(GridData.FILL_HORIZONTAL);
    gdlPentaho.widthHint = 200;
    wlPentaho.setLayoutData(gdlPentaho);
    FormData fdcPentaho = new FormData();
    fdcPentaho.left = new FormAttachment(vSpacer, 10);
    fdcPentaho.top = new FormAttachment(0);
    fdcPentaho.right = new FormAttachment(100);
    fdcPentaho.bottom = new FormAttachment(100);
    wcPentaho.setLayoutData(fdcPentaho);
    Composite wcRemote = new Composite(runConfigurationDialog.getGroup(), SWT.NONE);
    props.setLook(wcRemote);
    wcRemote.setLayout(new FormLayout());
    Label wlRemote = new Label(wcRemote, SWT.LEFT);
    props.setLook(wlRemote);
    wlRemote.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Label.Location"));
    FormData fdlRemote = new FormData();
    fdlRemote.left = new FormAttachment(0);
    fdlRemote.top = new FormAttachment(0);
    wlRemote.setLayoutData(fdlRemote);
    wcSlaveServer = new CCombo(wcRemote, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    props.setLook(wcSlaveServer);
    FormData fdSlaveServer = new FormData();
    fdSlaveServer.width = 150;
    fdSlaveServer.top = new FormAttachment(wlRemote, 5);
    fdSlaveServer.left = new FormAttachment(0);
    wcSlaveServer.setLayoutData(fdSlaveServer);
    Button wbSendResources = new Button(wcRemote, SWT.CHECK);
    wbSendResources.setSelection(defaultRunConfiguration.isSendResources());
    wbSendResources.setVisible(!Utils.isEmpty(defaultRunConfiguration.getServer()) && !defaultRunConfiguration.isClustered());
    props.setLook(wbSendResources);
    wbSendResources.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Button.SendResources"));
    FormData fdbSendResources = new FormData();
    fdbSendResources.top = new FormAttachment(wcSlaveServer, 10);
    fdbSendResources.left = new FormAttachment(0);
    wbSendResources.setLayoutData(fdbSendResources);
    wbSendResources.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent selectionEvent) {
            defaultRunConfiguration.setSendResources(wbSendResources.getSelection());
        }
    });
    Button wbLogRemoteExecutionLocally = new Button(wcRemote, SWT.CHECK);
    wbLogRemoteExecutionLocally.setSelection(defaultRunConfiguration.isLogRemoteExecutionLocally());
    wbLogRemoteExecutionLocally.setVisible(defaultRunConfiguration.isClustered());
    props.setLook(wbLogRemoteExecutionLocally);
    wbLogRemoteExecutionLocally.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Checkbox.LogRemoteExecutionLocally"));
    FormData fdbLogRemoteExecutionLocally = new FormData();
    fdbLogRemoteExecutionLocally.top = new FormAttachment(wcSlaveServer, 10);
    fdbLogRemoteExecutionLocally.left = new FormAttachment(0);
    wbLogRemoteExecutionLocally.setLayoutData(fdbLogRemoteExecutionLocally);
    wbLogRemoteExecutionLocally.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent selectionEvent) {
            defaultRunConfiguration.setLogRemoteExecutionLocally(wbLogRemoteExecutionLocally.getSelection());
        }
    });
    Button wbShowTransformations = new Button(wcRemote, SWT.CHECK);
    wbShowTransformations.setSelection(defaultRunConfiguration.isShowTransformations());
    wbShowTransformations.setVisible(defaultRunConfiguration.isClustered());
    props.setLook(wbShowTransformations);
    wbShowTransformations.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Checkbox.ShowTransformation"));
    FormData fdbShowTransformations = new FormData();
    fdbShowTransformations.top = new FormAttachment(wbLogRemoteExecutionLocally, 10);
    fdbShowTransformations.left = new FormAttachment(0);
    wbShowTransformations.setLayoutData(fdbShowTransformations);
    wbShowTransformations.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent selectionEvent) {
            defaultRunConfiguration.setShowTransformations(wbShowTransformations.getSelection());
        }
    });
    FormData fdcRemote = new FormData();
    fdcRemote.left = new FormAttachment(vSpacer, 20);
    fdcRemote.top = new FormAttachment(0);
    fdcRemote.right = new FormAttachment(100);
    fdcRemote.bottom = new FormAttachment(100);
    wcRemote.setLayoutData(fdcRemote);
    AbstractMeta meta = (AbstractMeta) spoonSupplier.get().getActiveMeta();
    if (meta instanceof TransMeta && !Utils.isEmpty(((TransMeta) meta).getClusterSchemas())) {
        wcSlaveServer.add(CLUSTERED);
    }
    for (int i = 0; i < meta.getSlaveServers().size(); i++) {
        SlaveServer slaveServer = meta.getSlaveServers().get(i);
        wcSlaveServer.add(slaveServer.toString());
    }
    if (!Utils.isEmpty(defaultRunConfiguration.getServer())) {
        wcSlaveServer.setText(defaultRunConfiguration.getServer());
    }
    wcLocal.setVisible(defaultRunConfiguration.isLocal());
    wcPentaho.setVisible(defaultRunConfiguration.isPentaho());
    wcRemote.setVisible(defaultRunConfiguration.isRemote() || defaultRunConfiguration.isClustered());
    wcSlaveServer.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent selectionEvent) {
            if (wcSlaveServer.getText().equals(CLUSTERED)) {
                defaultRunConfiguration.setClustered(true);
                defaultRunConfiguration.setLocal(false);
                defaultRunConfiguration.setRemote(false);
                wbLogRemoteExecutionLocally.setVisible(true);
                wbShowTransformations.setVisible(true);
                wbSendResources.setVisible(false);
            } else {
                defaultRunConfiguration.setRemote(true);
                defaultRunConfiguration.setLocal(false);
                defaultRunConfiguration.setClustered(false);
                defaultRunConfiguration.setServer(wcSlaveServer.getText());
                wbLogRemoteExecutionLocally.setVisible(false);
                wbShowTransformations.setVisible(false);
                wbSendResources.setVisible(true);
            }
            checkOKEnabled();
        }
    });
    wbLocal.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent selectionEvent) {
            wcLocal.setVisible(wbLocal.getSelection());
            wcPentaho.setVisible(wbPentaho.getSelection());
            wcRemote.setVisible(wbRemote.getSelection());
            defaultRunConfiguration.setLocal(true);
            defaultRunConfiguration.setPentaho(false);
            defaultRunConfiguration.setRemote(false);
            defaultRunConfiguration.setClustered(false);
            checkOKEnabled();
        }
    });
    wbPentaho.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent selectionEvent) {
            wcLocal.setVisible(wbLocal.getSelection());
            wcPentaho.setVisible(wbPentaho.getSelection());
            wcRemote.setVisible(wbRemote.getSelection());
            defaultRunConfiguration.setLocal(false);
            defaultRunConfiguration.setPentaho(true);
            defaultRunConfiguration.setRemote(false);
            defaultRunConfiguration.setClustered(false);
            checkOKEnabled();
        }
    });
    wbRemote.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent selectionEvent) {
            wcLocal.setVisible(wbLocal.getSelection());
            wcPentaho.setVisible(wbPentaho.getSelection());
            wcRemote.setVisible(wbRemote.getSelection());
            defaultRunConfiguration.setLocal(false);
            defaultRunConfiguration.setPentaho(false);
            if (Utils.isEmpty(wcSlaveServer.getText())) {
                if (meta instanceof TransMeta && !Utils.isEmpty(((TransMeta) meta).getClusterSchemas())) {
                    wcSlaveServer.setText(CLUSTERED);
                } else if (meta.getSlaveServers().size() > 0) {
                    wcSlaveServer.setText(meta.getSlaveServers().get(0).getName());
                }
            }
            if (!wcSlaveServer.getText().equals(CLUSTERED)) {
                defaultRunConfiguration.setRemote(true);
                defaultRunConfiguration.setClustered(false);
                wbSendResources.setVisible(true);
                wbShowTransformations.setVisible(false);
                wbLogRemoteExecutionLocally.setVisible(false);
            } else {
                defaultRunConfiguration.setClustered(true);
                defaultRunConfiguration.setRemote(false);
                wbSendResources.setVisible(false);
                wbShowTransformations.setVisible(true);
                wbLogRemoteExecutionLocally.setVisible(true);
            }
            checkOKEnabled();
            if (!Utils.isEmpty(wcSlaveServer.getText())) {
                defaultRunConfiguration.setServer(wcSlaveServer.getText());
            }
        }
    });
    if (defaultRunConfiguration.isClustered()) {
        wcSlaveServer.setText(CLUSTERED);
        wbSendResources.setVisible(false);
        wbShowTransformations.setVisible(true);
        wbLogRemoteExecutionLocally.setVisible(true);
    }
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) AbstractMeta(org.pentaho.di.base.AbstractMeta) Label(org.eclipse.swt.widgets.Label) TransMeta(org.pentaho.di.trans.TransMeta) Text(org.eclipse.swt.widgets.Text) SlaveServer(org.pentaho.di.cluster.SlaveServer) GridLayout(org.eclipse.swt.layout.GridLayout) CCombo(org.eclipse.swt.custom.CCombo) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

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