Search in sources :

Example 41 with ClusterSchema

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

the class Spoon method editClustering.

/**
 * Select a clustering schema for this step.
 *
 * @param stepMetas The steps (at least one!) to set the clustering schema for.
 */
public void editClustering(TransMeta transMeta, List<StepMeta> stepMetas) {
    String[] clusterSchemaNames = transMeta.getClusterSchemaNames();
    StepMeta stepMeta = stepMetas.get(0);
    int idx = -1;
    if (stepMeta.getClusterSchema() != null) {
        idx = transMeta.getClusterSchemas().indexOf(stepMeta.getClusterSchema());
    }
    EnterSelectionDialog dialog = new EnterSelectionDialog(shell, clusterSchemaNames, BaseMessages.getString(PKG, "Spoon.Dialog.SelectClusteringSchema.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.SelectClusteringSchema.Message"));
    String schemaName = dialog.open(idx);
    if (schemaName == null) {
        for (StepMeta step : stepMetas) {
            step.setClusterSchema(null);
        }
    } else {
        ClusterSchema clusterSchema = transMeta.findClusterSchema(schemaName);
        for (StepMeta step : stepMetas) {
            step.setClusterSchema(clusterSchema);
        }
    }
    transMeta.setChanged();
    refreshTree();
    refreshGraph();
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

Example 42 with ClusterSchema

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

the class SpoonClustersDelegate method newClusteringSchema.

public void newClusteringSchema(TransMeta transMeta) {
    ClusterSchema clusterSchema = new ClusterSchema();
    ClusterSchemaDialog dialog = new ClusterSchemaDialog(spoon.getShell(), clusterSchema, transMeta.getClusterSchemas(), transMeta.getSlaveServers());
    if (dialog.open()) {
        List<ClusterSchema> clusterSchemas = transMeta.getClusterSchemas();
        if (isDuplicate(clusterSchemas, clusterSchema)) {
            new ErrorDialog(spoon.getShell(), getMessage("Spoon.Dialog.ErrorSavingCluster.Title"), getMessage("Spoon.Dialog.ErrorSavingCluster.Message", clusterSchema.getName()), new KettleException(getMessage("Spoon.Dialog.ErrorSavingCluster.NotUnique")));
            return;
        }
        clusterSchemas.add(clusterSchema);
        if (spoon.rep != null) {
            try {
                if (!spoon.rep.getSecurityProvider().isReadOnly()) {
                    spoon.rep.save(clusterSchema, Const.VERSION_COMMENT_INITIAL_VERSION, null);
                    if (sharedObjectSyncUtil != null) {
                        sharedObjectSyncUtil.reloadTransformationRepositoryObjects(false);
                    }
                } else {
                    throw new KettleException(BaseMessages.getString(PKG, "Spoon.Dialog.Exception.ReadOnlyRepositoryUser"));
                }
            } catch (KettleException e) {
                showSaveError(clusterSchema, e);
            }
        }
        spoon.refreshTree();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ClusterSchema(org.pentaho.di.cluster.ClusterSchema) ClusterSchemaDialog(org.pentaho.di.ui.cluster.dialog.ClusterSchemaDialog)

Example 43 with ClusterSchema

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

the class SpoonTreeDelegate method getTreeObjects.

/**
 * @return The object that is selected in the tree or null if we couldn't figure it out. (titles etc. == null)
 */
public TreeSelection[] getTreeObjects(final Tree tree, Tree selectionTree, Tree coreObjectsTree) {
    List<TreeSelection> objects = new ArrayList<TreeSelection>();
    if (selectionTree != null && !selectionTree.isDisposed() && tree.equals(selectionTree)) {
        TreeItem[] selection = selectionTree.getSelection();
        for (int s = 0; s < selection.length; s++) {
            TreeItem treeItem = selection[s];
            String[] path = ConstUI.getTreeStrings(treeItem);
            TreeSelection object = null;
            switch(path.length) {
                case 0:
                    break;
                case // ------complete-----
                1:
                    if (path[0].equals(Spoon.STRING_TRANSFORMATIONS)) {
                        // the top level Transformations entry
                        object = new TreeSelection(path[0], TransMeta.class);
                    }
                    if (path[0].equals(Spoon.STRING_JOBS)) {
                        // the top level Jobs entry
                        object = new TreeSelection(path[0], JobMeta.class);
                    }
                    break;
                case // ------complete-----
                2:
                    if (path[0].equals(Spoon.STRING_BUILDING_BLOCKS)) {
                        if (path[1].equals(Spoon.STRING_TRANS_BASE)) {
                            object = new TreeSelection(path[1], PluginInterface.class);
                        }
                    }
                    if (path[0].equals(Spoon.STRING_TRANSFORMATIONS)) {
                        // Transformation title
                        object = new TreeSelection(path[1], spoon.delegates.trans.getTransformation(path[1]));
                    }
                    if (path[0].equals(Spoon.STRING_JOBS)) {
                        // Jobs title
                        object = new TreeSelection(path[1], spoon.delegates.jobs.getJob(path[1]));
                    }
                    break;
                case // ------complete-----
                3:
                    if (path[0].equals(Spoon.STRING_TRANSFORMATIONS)) {
                        // Transformations title
                        TransMeta transMeta = spoon.delegates.trans.getTransformation(path[1]);
                        if (path[2].equals(Spoon.STRING_CONNECTIONS)) {
                            object = new TreeSelection(path[2], DatabaseMeta.class, transMeta);
                        }
                        if (path[2].equals(Spoon.STRING_STEPS)) {
                            object = new TreeSelection(path[2], StepMeta.class, transMeta);
                        }
                        if (path[2].equals(Spoon.STRING_HOPS)) {
                            object = new TreeSelection(path[2], TransHopMeta.class, transMeta);
                        }
                        if (path[2].equals(Spoon.STRING_PARTITIONS)) {
                            object = new TreeSelection(path[2], PartitionSchema.class, transMeta);
                        }
                        if (path[2].equals(Spoon.STRING_SLAVES)) {
                            object = new TreeSelection(path[2], SlaveServer.class, transMeta);
                        }
                        if (path[2].equals(Spoon.STRING_CLUSTERS)) {
                            object = new TreeSelection(path[2], ClusterSchema.class, transMeta);
                        }
                        executeExtensionPoint(new SpoonTreeDelegateExtension(transMeta, path, 3, objects));
                    }
                    if (path[0].equals(Spoon.STRING_JOBS)) {
                        // Jobs title
                        JobMeta jobMeta = spoon.delegates.jobs.getJob(path[1]);
                        if (path[2].equals(Spoon.STRING_CONNECTIONS)) {
                            object = new TreeSelection(path[2], DatabaseMeta.class, jobMeta);
                        }
                        if (path[2].equals(Spoon.STRING_JOB_ENTRIES)) {
                            object = new TreeSelection(path[2], JobEntryCopy.class, jobMeta);
                        }
                        if (path[2].equals(Spoon.STRING_SLAVES)) {
                            object = new TreeSelection(path[2], SlaveServer.class, jobMeta);
                        }
                        executeExtensionPoint(new SpoonTreeDelegateExtension(jobMeta, path, 3, objects));
                    }
                    break;
                case // ------complete-----
                4:
                    if (path[0].equals(Spoon.STRING_TRANSFORMATIONS)) {
                        // The name of a transformation
                        final TransMeta transMeta = spoon.delegates.trans.getTransformation(path[1]);
                        if (transMeta != null) {
                            if (path[2].equals(Spoon.STRING_CONNECTIONS)) {
                                String dbName = path[3];
                                DatabaseMeta databaseMeta = transMeta.findDatabase(dbName);
                                if (databaseMeta != null) {
                                    dbName = databaseMeta.getName();
                                }
                                object = new TreeSelection(dbName, databaseMeta, transMeta);
                            }
                            if (path[2].equals(Spoon.STRING_STEPS)) {
                                object = new TreeSelection(path[3], transMeta.findStep(path[3]), transMeta);
                            }
                            if (path[2].equals(Spoon.STRING_HOPS)) {
                                object = new TreeSelection(path[3], transMeta.findTransHop(path[3]), transMeta);
                            }
                            if (path[2].equals(Spoon.STRING_PARTITIONS)) {
                                object = new TreeSelection(path[3], transMeta.findPartitionSchema(path[3]), transMeta);
                            }
                            if (path[2].equals(Spoon.STRING_SLAVES)) {
                                object = new TreeSelection(path[3], transMeta.findSlaveServer(path[3]), transMeta);
                            }
                            if (path[2].equals(Spoon.STRING_CLUSTERS)) {
                                object = new TreeSelection(path[3], transMeta.findClusterSchema(path[3]), transMeta);
                            }
                            executeExtensionPoint(new SpoonTreeDelegateExtension(transMeta, path, 4, objects));
                        }
                    }
                    if (path[0].equals(Spoon.STRING_JOBS)) {
                        // The name of a job
                        JobMeta jobMeta = spoon.delegates.jobs.getJob(path[1]);
                        if (jobMeta != null && path[2].equals(Spoon.STRING_CONNECTIONS)) {
                            String dbName = path[3];
                            DatabaseMeta databaseMeta = jobMeta.findDatabase(dbName);
                            if (databaseMeta != null) {
                                dbName = databaseMeta.getName();
                            }
                            object = new TreeSelection(dbName, databaseMeta, jobMeta);
                        }
                        if (jobMeta != null && path[2].equals(Spoon.STRING_JOB_ENTRIES)) {
                            object = new TreeSelection(path[3], jobMeta.findJobEntry(path[3]), jobMeta);
                        }
                        if (jobMeta != null && path[2].equals(Spoon.STRING_SLAVES)) {
                            object = new TreeSelection(path[3], jobMeta.findSlaveServer(path[3]), jobMeta);
                        }
                        executeExtensionPoint(new SpoonTreeDelegateExtension(jobMeta, path, 4, objects));
                    }
                    break;
                case 5:
                    if (path[0].equals(Spoon.STRING_TRANSFORMATIONS)) {
                        // The name of a transformation
                        TransMeta transMeta = spoon.delegates.trans.getTransformation(path[1]);
                        if (transMeta != null && path[2].equals(Spoon.STRING_CLUSTERS)) {
                            ClusterSchema clusterSchema = transMeta.findClusterSchema(path[3]);
                            object = new TreeSelection(path[4], clusterSchema.findSlaveServer(path[4]), clusterSchema, transMeta);
                        }
                    }
                    break;
                default:
                    break;
            }
            if (object != null) {
                objects.add(object);
            }
        }
    }
    if (tree != null && coreObjectsTree != null && tree.equals(coreObjectsTree)) {
        TreeItem[] selection = coreObjectsTree.getSelection();
        for (int s = 0; s < selection.length; s++) {
            TreeItem treeItem = selection[s];
            String[] path = ConstUI.getTreeStrings(treeItem);
            TreeSelection object = null;
            switch(path.length) {
                case 0:
                    break;
                case // Job entries
                2:
                    if (spoon.showJob) {
                        PluginRegistry registry = PluginRegistry.getInstance();
                        Class<? extends PluginTypeInterface> pluginType = JobEntryPluginType.class;
                        PluginInterface plugin = registry.findPluginWithName(pluginType, path[1]);
                        // 
                        if (plugin == null) {
                            if (path[1].equals(JobMeta.STRING_SPECIAL_START)) {
                                plugin = registry.findPluginWithId(pluginType, JobMeta.STRING_SPECIAL);
                            }
                        }
                        // 
                        if (plugin == null) {
                            if (path[1].equals(JobMeta.STRING_SPECIAL_DUMMY)) {
                                plugin = registry.findPluginWithId(pluginType, JobMeta.STRING_SPECIAL);
                            }
                        }
                        if (plugin != null) {
                            object = new TreeSelection(path[1], plugin);
                        }
                    }
                    if (spoon.showTrans) {
                        String stepId = (String) treeItem.getData("StepId");
                        if (stepId != null) {
                            object = new TreeSelection(path[1], PluginRegistry.getInstance().findPluginWithId(StepPluginType.class, stepId));
                        } else {
                            object = new TreeSelection(path[1], PluginRegistry.getInstance().findPluginWithName(StepPluginType.class, path[1]));
                        }
                    }
                    break;
                default:
                    break;
            }
            if (object != null) {
                objects.add(object);
            }
        }
    }
    return objects.toArray(new TreeSelection[objects.size()]);
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) TreeItem(org.eclipse.swt.widgets.TreeItem) PartitionSchema(org.pentaho.di.partition.PartitionSchema) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ArrayList(java.util.ArrayList) TransMeta(org.pentaho.di.trans.TransMeta) SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) JobEntryPluginType(org.pentaho.di.core.plugins.JobEntryPluginType) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) TreeSelection(org.pentaho.di.ui.spoon.TreeSelection) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) TransHopMeta(org.pentaho.di.trans.TransHopMeta) ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

Example 44 with ClusterSchema

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

the class ClusterDelegate method dataNodeToElement.

public RepositoryElementInterface dataNodeToElement(DataNode rootNode) throws KettleException {
    ClusterSchema clusterSchema = new ClusterSchema();
    dataNodeToElement(rootNode, clusterSchema);
    return clusterSchema;
}
Also used : ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

Example 45 with ClusterSchema

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

the class ClusterDelegate method assemble.

public ClusterSchema assemble(RepositoryFile file, NodeRepositoryFileData data, VersionSummary version) throws KettleException {
    ClusterSchema clusterSchema = (ClusterSchema) dataNodeToElement(data.getNode());
    clusterSchema.setName(file.getTitle());
    clusterSchema.setObjectId(new StringObjectId(file.getId().toString()));
    clusterSchema.setObjectRevision(repo.createObjectRevision(version));
    clusterSchema.clearChanged();
    return clusterSchema;
}
Also used : StringObjectId(org.pentaho.di.repository.StringObjectId) ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

Aggregations

ClusterSchema (org.pentaho.di.cluster.ClusterSchema)52 SlaveServer (org.pentaho.di.cluster.SlaveServer)23 KettleException (org.pentaho.di.core.exception.KettleException)19 PartitionSchema (org.pentaho.di.partition.PartitionSchema)19 TransMeta (org.pentaho.di.trans.TransMeta)16 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)15 StepMeta (org.pentaho.di.trans.step.StepMeta)15 ObjectId (org.pentaho.di.repository.ObjectId)11 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)7 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)7 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)7 NotePadMeta (org.pentaho.di.core.NotePadMeta)6 TransHopMeta (org.pentaho.di.trans.TransHopMeta)6 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)5 Point (org.pentaho.di.core.gui.Point)5 ClusterSchemaDialog (org.pentaho.di.ui.cluster.dialog.ClusterSchemaDialog)5 List (java.util.List)4 MessageBox (org.eclipse.swt.widgets.MessageBox)4 JobMeta (org.pentaho.di.job.JobMeta)4