use of org.pentaho.di.www.SlaveServerJobStatus 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));
}
use of org.pentaho.di.www.SlaveServerJobStatus in project pentaho-kettle by pentaho.
the class SpoonSlave method refreshView.
private synchronized void refreshView() {
if (wTree.isDisposed()) {
return;
}
if (refreshBusy) {
return;
}
refreshBusy = true;
if (log.isDetailed()) {
log.logDetailed("Refresh");
}
transParentItem.removeAll();
jobParentItem.removeAll();
wText.setText("");
// Determine the transformations on the slave servers
try {
slaveServerStatus = slaveServer.getStatus();
} catch (Exception e) {
slaveServerStatus = new SlaveServerStatus("Error contacting server");
slaveServerStatus.setErrorDescription(Const.getStackTracker(e));
if (log.isDebug()) {
log.logDebug(slaveServerStatus.getErrorDescription());
}
wText.setText(setExceptionMessage(e));
}
List<SlaveServerTransStatus> transStatusList = slaveServerStatus.getTransStatusList();
for (SlaveServerTransStatus transStatus : transStatusList) {
TreeItem transItem = new TreeItem(transParentItem, SWT.NONE);
transItem.setText(0, transStatus.getTransName());
transItem.setText(9, transStatus.getStatusDescription());
transItem.setText(13, Const.NVL(transStatus.getId(), ""));
transItem.setText(14, Const.NVL(XMLHandler.date2string(transStatus.getLogDate()), ""));
transItem.setImage(GUIResource.getInstance().getImageTransGraph());
transItem.setData("transStatus", transStatus);
}
for (int i = 0; i < slaveServerStatus.getJobStatusList().size(); i++) {
SlaveServerJobStatus jobStatus = slaveServerStatus.getJobStatusList().get(i);
TreeItem jobItem = new TreeItem(jobParentItem, SWT.NONE);
jobItem.setText(0, jobStatus.getJobName());
jobItem.setText(9, jobStatus.getStatusDescription());
jobItem.setText(13, Const.NVL(jobStatus.getId(), ""));
jobItem.setText(14, Const.NVL(XMLHandler.date2string(jobStatus.getLogDate()), ""));
jobItem.setImage(GUIResource.getInstance().getImageJobGraph());
jobItem.setData("jobStatus", jobStatus);
}
TreeMemory.setExpandedFromMemory(wTree, STRING_SLAVE_LOG_TREE_NAME + slaveServer.toString());
TreeUtil.setOptimalWidthOnColumns(wTree);
refreshBusy = false;
}
use of org.pentaho.di.www.SlaveServerJobStatus in project pentaho-kettle by pentaho.
the class SpoonSlave method start.
protected void start() {
TreeEntry treeEntry = getTreeEntry();
if (treeEntry == null) {
return;
}
if (treeEntry.isTransformation()) {
// Transformation
SlaveServerTransStatus transStatus = slaveServerStatus.findTransStatus(treeEntry.name, treeEntry.id);
if (transStatus != null) {
if (!transStatus.isRunning()) {
try {
WebResult webResult = slaveServer.startTransformation(treeEntry.name, transStatus.getId());
if (!WebResult.STRING_OK.equalsIgnoreCase(webResult.getResult())) {
EnterTextDialog dialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingTrans.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingTrans.Message"), webResult.getMessage());
dialog.setReadOnly();
dialog.open();
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingTrans.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingTrans.Message"), e);
}
}
}
} else if (treeEntry.isJob()) {
// Job
SlaveServerJobStatus jobStatus = slaveServerStatus.findJobStatus(treeEntry.name, treeEntry.id);
if (jobStatus != null) {
if (!jobStatus.isRunning()) {
try {
WebResult webResult = slaveServer.startJob(treeEntry.name, jobStatus.getId());
if (!WebResult.STRING_OK.equalsIgnoreCase(webResult.getResult())) {
EnterTextDialog dialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingJob.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingJob.Message"), webResult.getMessage());
dialog.setReadOnly();
dialog.open();
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingJob.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorStartingJob.Message"), e);
}
}
}
}
}
use of org.pentaho.di.www.SlaveServerJobStatus in project pentaho-kettle by pentaho.
the class SpoonSlave method showLog.
/**
* Someone clicks on a line: show the log or error message associated with that in the text-box
*/
public void showLog() {
TreeEntry treeEntry = getTreeEntry();
if (treeEntry == null) {
return;
}
if (treeEntry.length <= 1) {
return;
}
if (treeEntry.isTransformation()) {
// Transformation
SlaveServerTransStatus transStatus = slaveServerStatus.findTransStatus(treeEntry.name, treeEntry.id);
StringBuilder message = new StringBuilder();
String errorDescription = transStatus.getErrorDescription();
if (!Utils.isEmpty(errorDescription)) {
message.append(errorDescription).append(Const.CR).append(Const.CR);
}
if (!Utils.isEmpty(currentLogText)) {
message.append(currentLogText).append(Const.CR);
}
wText.setText(message.toString());
wText.setSelection(wText.getText().length());
wText.showSelection();
} else if (treeEntry.isJob()) {
// Job
SlaveServerJobStatus jobStatus = slaveServerStatus.findJobStatus(treeEntry.name, treeEntry.id);
StringBuilder message = new StringBuilder();
String errorDescription = jobStatus.getErrorDescription();
if (!Utils.isEmpty(errorDescription)) {
message.append(errorDescription).append(Const.CR).append(Const.CR);
}
if (!Utils.isEmpty(currentLogText)) {
message.append(currentLogText).append(Const.CR);
}
wText.setText(message.toString());
wText.setSelection(wText.getText().length());
wText.showSelection();
} else {
currentLogText = null;
}
}
use of org.pentaho.di.www.SlaveServerJobStatus in project pentaho-kettle by pentaho.
the class SpoonSlave method remove.
protected void remove() {
TreeEntry treeEntry = getTreeEntry();
if (treeEntry == null) {
return;
}
if (treeEntry.isTransformation()) {
// Transformation
SlaveServerTransStatus transStatus = slaveServerStatus.findTransStatus(treeEntry.name, treeEntry.id);
if (transStatus != null) {
if (!transStatus.isRunning() && !transStatus.isPaused() && !transStatus.isStopped()) {
try {
WebResult webResult = slaveServer.removeTransformation(treeEntry.name, transStatus.getId());
if (WebResult.STRING_OK.equalsIgnoreCase(webResult.getResult())) {
// Force refresh in order to give faster visual feedback and reengage the timer
wTree.deselectAll();
engageViewAndLogUpdateTimer();
} else {
EnterTextDialog dialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingTrans.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingTrans.Message"), webResult.getMessage());
dialog.setReadOnly();
dialog.open();
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingTrans.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingTrans.Message"), e);
}
}
}
} else if (treeEntry.isJob()) {
// Job
SlaveServerJobStatus jobStatus = slaveServerStatus.findJobStatus(treeEntry.name, treeEntry.id);
if (jobStatus != null) {
if (!jobStatus.isRunning()) {
try {
WebResult webResult = slaveServer.removeJob(treeEntry.name, jobStatus.getId());
if (WebResult.STRING_OK.equalsIgnoreCase(webResult.getResult())) {
// Force refresh in order to give faster visual feedback and reengage the timer
wTree.deselectAll();
engageViewAndLogUpdateTimer();
} else {
EnterTextDialog dialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingJob.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingJob.Message"), webResult.getMessage());
dialog.setReadOnly();
dialog.open();
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingJob.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorRemovingJob.Message"), e);
}
}
}
}
}
Aggregations