Search in sources :

Example 1 with UISlave

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UISlave in project pentaho-kettle by pentaho.

the class SlavesController method refreshSlaves.

public void refreshSlaves() {
    if (repository != null) {
        final List<UISlave> tmpList = new ArrayList<UISlave>();
        Runnable r = new Runnable() {

            public void run() {
                try {
                    ObjectId[] slaveIdList = repository.getSlaveIDs(false);
                    for (ObjectId slaveId : slaveIdList) {
                        SlaveServer slave = repository.loadSlaveServer(slaveId, null);
                        // Add the database slave to the list
                        tmpList.add(new UISlave(slave));
                    }
                } catch (KettleException e) {
                    if (mainController == null || !mainController.handleLostRepository(e)) {
                        // convert to runtime exception so it bubbles up through the UI
                        throw new RuntimeException(e);
                    }
                }
            }
        };
        doWithBusyIndicator(r);
        slaveList.setChildren(tmpList);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) UISlave(org.pentaho.di.ui.repository.repositoryexplorer.model.UISlave) ObjectId(org.pentaho.di.repository.ObjectId) ArrayList(java.util.ArrayList) SlaveServer(org.pentaho.di.cluster.SlaveServer)

Example 2 with UISlave

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UISlave in project pentaho-kettle by pentaho.

the class SlavesController method removeSlave.

public void removeSlave() {
    String slaveServerName = "";
    try {
        Collection<UISlave> slaves = slavesTable.getSelectedItems();
        if (slaves != null && !slaves.isEmpty()) {
            for (Object obj : slaves) {
                if (obj != null && obj instanceof UISlave) {
                    UISlave slave = (UISlave) obj;
                    SlaveServer slaveServer = slave.getSlaveServer();
                    slaveServerName = slaveServer.getName();
                    // Make sure the slave to delete exists in the repository
                    ObjectId slaveId = repository.getSlaveID(slaveServer.getName());
                    if (slaveId == null) {
                        MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                        mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.DoesNotExists.Message", slaveServerName));
                        mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Delete.Title"));
                        mb.open();
                    } else {
                        repository.deleteSlave(slaveId);
                        if (getSharedObjectSyncUtil() != null) {
                            getSharedObjectSyncUtil().deleteSlaveServer(slaveServer);
                        }
                    }
                }
            }
        } else {
            MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
            mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.NoItemSelected.Message"));
            mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Delete.Title"));
            mb.open();
        }
    } catch (KettleException e) {
        if (mainController == null || !mainController.handleLostRepository(e)) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Delete.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Delete.UnexpectedError.Message") + slaveServerName + "]", e);
        }
    } finally {
        refreshSlaves();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) UISlave(org.pentaho.di.ui.repository.repositoryexplorer.model.UISlave) ObjectId(org.pentaho.di.repository.ObjectId) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SlaveServer(org.pentaho.di.cluster.SlaveServer) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 3 with UISlave

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UISlave in project pentaho-kettle by pentaho.

the class SlavesController method editSlave.

public void editSlave() {
    String slaveServerName = "";
    try {
        Collection<UISlave> slaves = slavesTable.getSelectedItems();
        if (slaves != null && !slaves.isEmpty()) {
            // Grab the first item in the list & send it to the slave dialog
            SlaveServer slaveServer = ((UISlave) slaves.toArray()[0]).getSlaveServer();
            slaveServerName = slaveServer.getName();
            // Make sure the slave already exists
            ObjectId slaveId = repository.getSlaveID(slaveServer.getName());
            if (slaveId == null) {
                MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.DoesNotExists.Message", slaveServerName));
                mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.Title"));
                mb.open();
            } else {
                SlaveServerDialog ssd = new SlaveServerDialog(shell, slaveServer);
                if (ssd.open()) {
                    if (slaveServer.getName() != null && !slaveServer.getName().equals("")) {
                        repository.insertLogEntry(BaseMessages.getString(PKG, "SlavesController.Message.UpdatingSlave", slaveServer.getName()));
                        repository.save(slaveServer, Const.VERSION_COMMENT_EDIT_VERSION, null);
                        if (getSharedObjectSyncUtil() != null) {
                            getSharedObjectSyncUtil().synchronizeSlaveServers(slaveServer, slaveServerName);
                        }
                    } else {
                        MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                        mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.InvalidName.Message"));
                        mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.Title"));
                        mb.open();
                    }
                }
            }
        } else {
            MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
            mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.NoItemSelected.Message"));
            mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.Title"));
            mb.open();
        }
    } catch (KettleException e) {
        if (mainController == null || !mainController.handleLostRepository(e)) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.UnexpectedError.Message") + slaveServerName + "]", e);
        }
    } finally {
        refreshSlaves();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) UISlave(org.pentaho.di.ui.repository.repositoryexplorer.model.UISlave) ObjectId(org.pentaho.di.repository.ObjectId) SlaveServerDialog(org.pentaho.di.ui.cluster.dialog.SlaveServerDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SlaveServer(org.pentaho.di.cluster.SlaveServer) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

SlaveServer (org.pentaho.di.cluster.SlaveServer)3 KettleException (org.pentaho.di.core.exception.KettleException)3 ObjectId (org.pentaho.di.repository.ObjectId)3 UISlave (org.pentaho.di.ui.repository.repositoryexplorer.model.UISlave)3 MessageBox (org.eclipse.swt.widgets.MessageBox)2 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)2 ArrayList (java.util.ArrayList)1 SlaveServerDialog (org.pentaho.di.ui.cluster.dialog.SlaveServerDialog)1