Search in sources :

Example 16 with SlaveServer

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

the class KettleDatabaseRepository method getSlaveServers.

/**
 * @return a list of all the slave servers in the repository.
 * @throws KettleException
 */
public List<SlaveServer> getSlaveServers() throws KettleException {
    List<SlaveServer> list = new ArrayList<>();
    ObjectId[] slaveIDs = getSlaveIDs(false);
    for (int i = 0; i < slaveIDs.length; i++) {
        // Load last
        SlaveServer slaveServer = loadSlaveServer(slaveIDs[i], null);
        // version
        list.add(slaveServer);
    }
    return list;
}
Also used : LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) ArrayList(java.util.ArrayList) SlaveServer(org.pentaho.di.cluster.SlaveServer) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 17 with SlaveServer

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

the class ClusterSchemaDialog method refreshSlaveServers.

private void refreshSlaveServers() {
    wServers.clearAll(false);
    List<SlaveServer> slServers = clusterSchema.getSlaveServers();
    for (int i = 0; i < slServers.size(); i++) {
        TableItem item = new TableItem(wServers.table, SWT.NONE);
        SlaveServer slaveServer = slServers.get(i);
        item.setText(1, Const.NVL(slaveServer.getName(), ""));
        item.setText(2, Const.NVL(slaveServer.toString(), ""));
        item.setText(3, slaveServer.isMaster() ? "Y" : "N");
    }
    wServers.removeEmptyRows();
    wServers.setRowNums();
    wServers.optWidth(true);
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) SlaveServer(org.pentaho.di.cluster.SlaveServer)

Example 18 with SlaveServer

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

the class ClusterSchemaDialog method selectSlaveServers.

private void selectSlaveServers() {
    String[] names = SlaveServer.getSlaveServerNames(slaveServers);
    int[] idx = Const.indexsOfFoundStrings(wServers.getItems(0), names);
    EnterSelectionDialog dialog = new EnterSelectionDialog(shell, names, BaseMessages.getString(PKG, "ClusterSchemaDialog.SelectServers.Label"), BaseMessages.getString(PKG, "ClusterSchemaDialog.SelectServersCluster.Label"));
    dialog.setAvoidQuickSearch();
    dialog.setSelectedNrs(idx);
    dialog.setMulti(true);
    if (dialog.open() != null) {
        clusterSchema.getSlaveServers().clear();
        int[] indeces = dialog.getSelectionIndeces();
        for (int i = 0; i < indeces.length; i++) {
            SlaveServer slaveServer = SlaveServer.findSlaveServer(slaveServers, names[indeces[i]]);
            clusterSchema.getSlaveServers().add(slaveServer);
        }
        refreshSlaveServers();
    }
}
Also used : SlaveServer(org.pentaho.di.cluster.SlaveServer) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog)

Example 19 with SlaveServer

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

the class ClusterSchemaDialog method getInfo.

private void getInfo() {
    clusterSchema.setName(wName.getText());
    clusterSchema.setBasePort(wPort.getText());
    clusterSchema.setSocketsBufferSize(wBufferSize.getText());
    clusterSchema.setSocketsFlushInterval(wFlushInterval.getText());
    clusterSchema.setSocketsCompressed(wCompressed.getSelection());
    clusterSchema.setDynamic(wDynamic.getSelection());
    String[] names = SlaveServer.getSlaveServerNames(slaveServers);
    int[] idx = Const.indexsOfFoundStrings(wServers.getItems(0), names);
    clusterSchema.getSlaveServers().clear();
    for (int i = 0; i < idx.length; i++) {
        SlaveServer slaveServer = SlaveServer.findSlaveServer(slaveServers, names[idx[i]]);
        clusterSchema.getSlaveServers().add(slaveServer);
    }
}
Also used : SlaveServer(org.pentaho.di.cluster.SlaveServer)

Example 20 with SlaveServer

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

the class JobEntryJobIT method testLogfileWritesFromRemote.

@Test
public void testLogfileWritesFromRemote() throws Exception {
    JobEntryJob job = spy(new JobEntryJob(JOB_ENTRY_JOB_NAME));
    doCallRealMethod().when(job).execute(any(Result.class), anyInt());
    Job parentJob = mock(Job.class);
    JobMeta parentJobMeta = mock(JobMeta.class);
    JobMeta jobMeta = mock(JobMeta.class);
    SlaveServer slaveServer = mock(SlaveServer.class);
    LogChannelInterface log = mock(LogChannelInterface.class);
    SlaveServerJobStatus status = mock(SlaveServerJobStatus.class);
    when(parentJob.getLogLevel()).thenReturn(LogLevel.BASIC);
    when(parentJobMeta.getRepositoryDirectory()).thenReturn(null);
    when(jobMeta.getRepositoryDirectory()).thenReturn(mock(RepositoryDirectoryInterface.class));
    when(jobMeta.getName()).thenReturn(JOB_META_NAME);
    when(parentJob.getJobMeta()).thenReturn(parentJobMeta);
    when(parentJobMeta.findSlaveServer(REMOTE_SLAVE_SERVER_NAME)).thenReturn(slaveServer);
    when(slaveServer.getLogChannel()).thenReturn(log);
    when(log.getLogLevel()).thenReturn(LogLevel.BASIC);
    when(slaveServer.sendXML(anyString(), anyString())).thenReturn(REPLY);
    when(slaveServer.execService(anyString())).thenReturn(REPLY);
    when(slaveServer.getJobStatus(anyString(), anyString(), anyInt())).thenReturn(status);
    when(status.getResult()).thenReturn(mock(Result.class));
    when(status.getLoggingString()).thenReturn(LOG);
    file = Files.createTempFile("file", "");
    doReturn(LOG_FILE_NAME).when(job).getLogFilename();
    doReturn(file.toString()).when(job).environmentSubstitute(LOG_FILE_NAME);
    doReturn(REMOTE_SLAVE_SERVER_NAME).when(job).environmentSubstitute(REMOTE_SLAVE_SERVER_NAME);
    doReturn(jobMeta).when(job).getJobMeta(any(Repository.class), any(VariableSpace.class));
    doNothing().when(job).copyVariablesFrom(anyObject());
    doNothing().when(job).setParentVariableSpace(anyObject());
    job.setLogfile = true;
    job.createParentFolder = false;
    job.logFileLevel = LogLevel.BASIC;
    job.execPerRow = false;
    job.paramsFromPrevious = false;
    job.argFromPrevious = false;
    job.waitingToFinish = true;
    job.setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
    job.setRemoteSlaveServerName(REMOTE_SLAVE_SERVER_NAME);
    job.setParentJob(parentJob);
    job.setParentJobMeta(parentJobMeta);
    job.execute(new Result(), 0);
    String result = Files.lines(file).collect(Collectors.joining(""));
    assertTrue(result.contains(LOG));
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) JobMeta(org.pentaho.di.job.JobMeta) SlaveServerJobStatus(org.pentaho.di.www.SlaveServerJobStatus) Repository(org.pentaho.di.repository.Repository) VariableSpace(org.pentaho.di.core.variables.VariableSpace) Matchers.anyString(org.mockito.Matchers.anyString) Job(org.pentaho.di.job.Job) SlaveServer(org.pentaho.di.cluster.SlaveServer) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) Result(org.pentaho.di.core.Result) Test(org.junit.Test)

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