Search in sources :

Example 36 with ClusterSchema

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

the class SharedObjectSyncUtilTest method createClusterSchema.

private static ClusterSchema createClusterSchema(String name, boolean shared) {
    ClusterSchema clusterSchema = new ClusterSchema();
    clusterSchema.setName(name);
    clusterSchema.setDescription(BEFORE_SYNC_VALUE);
    clusterSchema.setDynamic(false);
    clusterSchema.setShared(shared);
    return clusterSchema;
}
Also used : ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

Example 37 with ClusterSchema

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

the class SharedObjectSyncUtilTest method synchronizeClusterSchemas_use_case_sensitive_name.

@Test
public void synchronizeClusterSchemas_use_case_sensitive_name() throws Exception {
    TransMeta transformarion1 = createTransMeta();
    ClusterSchema clusterSchema1 = createClusterSchema("ClusterSchema", true);
    transformarion1.setClusterSchemas(Collections.singletonList(clusterSchema1));
    spoonDelegates.trans.addTransformation(transformarion1);
    TransMeta transformarion2 = createTransMeta();
    ClusterSchema clusterSchema2 = createClusterSchema("Clusterschema", true);
    transformarion2.setClusterSchemas(Collections.singletonList(clusterSchema2));
    spoonDelegates.trans.addTransformation(transformarion2);
    clusterSchema2.setDynamic(true);
    sharedUtil.synchronizeClusterSchemas(clusterSchema2);
    assertThat(clusterSchema1.isDynamic(), equalTo(false));
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) ClusterSchema(org.pentaho.di.cluster.ClusterSchema) Test(org.junit.Test)

Example 38 with ClusterSchema

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

the class SharedObjectSyncUtilTest method synchronizeClusterSchemas_should_not_sync_unshared.

@Test
public void synchronizeClusterSchemas_should_not_sync_unshared() throws Exception {
    final String clusterSchemaName = "ClusterSchema";
    TransMeta transformarion1 = createTransMeta();
    ClusterSchema clusterSchema1 = createClusterSchema(clusterSchemaName, true);
    transformarion1.setClusterSchemas(Collections.singletonList(clusterSchema1));
    spoonDelegates.trans.addTransformation(transformarion1);
    TransMeta transformarion2 = createTransMeta();
    ClusterSchema clusterSchema2 = createClusterSchema(clusterSchemaName, false);
    transformarion2.setClusterSchemas(Collections.singletonList(clusterSchema2));
    spoonDelegates.trans.addTransformation(transformarion2);
    clusterSchema2.setDynamic(true);
    sharedUtil.synchronizeClusterSchemas(clusterSchema2);
    assertThat(clusterSchema1.isDynamic(), equalTo(false));
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) ClusterSchema(org.pentaho.di.cluster.ClusterSchema) Test(org.junit.Test)

Example 39 with ClusterSchema

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

the class SpoonRefreshClustersSubtreeTest method prepareMeta.

private static TransMeta prepareMeta() {
    TransMeta meta = mock(TransMeta.class);
    List<ClusterSchema> schemas = Arrays.asList(createSchema("1"), createSchema("2"), createSchema("3"));
    when(meta.getClusterSchemas()).thenReturn(schemas);
    return meta;
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

Example 40 with ClusterSchema

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

the class Spoon method loadSessionInformation.

private void loadSessionInformation(Repository repository, boolean saveOldDatabases) {
    JobMeta[] jobMetas = getLoadedJobs();
    for (JobMeta jobMeta : jobMetas) {
        for (int i = 0; i < jobMeta.nrDatabases(); i++) {
            jobMeta.getDatabase(i).setObjectId(null);
        }
        // Set for the existing job the ID at -1!
        jobMeta.setObjectId(null);
        // Keep track of the old databases for now.
        List<DatabaseMeta> oldDatabases = jobMeta.getDatabases();
        // In order to re-match the databases on name (not content), we
        // need to load the databases from the new repository.
        // NOTE: for purposes such as DEVELOP - TEST - PRODUCTION
        // cycles.
        // first clear the list of databases and slave servers
        jobMeta.setDatabases(new ArrayList<DatabaseMeta>());
        jobMeta.setSlaveServers(new ArrayList<SlaveServer>());
        // Read them from the new repository.
        try {
            SharedObjects sharedObjects = repository != null ? repository.readJobMetaSharedObjects(jobMeta) : jobMeta.readSharedObjects();
            sharedObjectsFileMap.put(sharedObjects.getFilename(), sharedObjects);
        } catch (KettleException e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Message", makeTabName(jobMeta, true)), e);
        }
        // Then we need to re-match the databases at save time...
        for (DatabaseMeta oldDatabase : oldDatabases) {
            DatabaseMeta newDatabase = DatabaseMeta.findDatabase(jobMeta.getDatabases(), oldDatabase.getName());
            // If it exists, change the settings...
            if (newDatabase != null) {
                // 
                // A database connection with the same name exists in
                // the new repository.
                // Change the old connections to reflect the settings in
                // the new repository
                // 
                oldDatabase.setDatabaseInterface(newDatabase.getDatabaseInterface());
            } else {
                if (saveOldDatabases) {
                    // 
                    // The old database is not present in the new
                    // repository: simply add it to the list.
                    // When the job gets saved, it will be added
                    // to the repository.
                    // 
                    jobMeta.addDatabase(oldDatabase);
                }
            }
        }
        if (repository != null) {
            try {
                // For the existing job, change the directory too:
                // Try to find the same directory in the new repository...
                RepositoryDirectoryInterface rdi = repository.findDirectory(jobMeta.getRepositoryDirectory().getPath());
                if (rdi != null && !rdi.getPath().equals("/")) {
                    jobMeta.setRepositoryDirectory(rdi);
                } else {
                    // the root is the default!
                    jobMeta.setRepositoryDirectory(repository.loadRepositoryDirectoryTree());
                }
            } catch (KettleException ke) {
                rep = null;
                new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorConnectingRepository.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorConnectingRepository.Message", Const.CR), ke);
            }
        }
    }
    TransMeta[] transMetas = getLoadedTransformations();
    for (TransMeta transMeta : transMetas) {
        for (int i = 0; i < transMeta.nrDatabases(); i++) {
            transMeta.getDatabase(i).setObjectId(null);
        }
        // Set for the existing transformation the ID at -1!
        transMeta.setObjectId(null);
        // Keep track of the old databases for now.
        List<DatabaseMeta> oldDatabases = transMeta.getDatabases();
        // In order to re-match the databases on name (not content), we
        // need to load the databases from the new repository.
        // NOTE: for purposes such as DEVELOP - TEST - PRODUCTION
        // cycles.
        // first clear the list of databases, partition schemas, slave
        // servers, clusters
        transMeta.setDatabases(new ArrayList<DatabaseMeta>());
        transMeta.setPartitionSchemas(new ArrayList<PartitionSchema>());
        transMeta.setSlaveServers(new ArrayList<SlaveServer>());
        transMeta.setClusterSchemas(new ArrayList<ClusterSchema>());
        // Read them from the new repository.
        try {
            SharedObjects sharedObjects = repository != null ? repository.readTransSharedObjects(transMeta) : transMeta.readSharedObjects();
            sharedObjectsFileMap.put(sharedObjects.getFilename(), sharedObjects);
        } catch (KettleException e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Message", makeTabName(transMeta, true)), e);
        }
        // Then we need to re-match the databases at save time...
        for (DatabaseMeta oldDatabase : oldDatabases) {
            DatabaseMeta newDatabase = DatabaseMeta.findDatabase(transMeta.getDatabases(), oldDatabase.getName());
            // If it exists, change the settings...
            if (newDatabase != null) {
                // 
                // A database connection with the same name exists in
                // the new repository.
                // Change the old connections to reflect the settings in
                // the new repository
                // 
                oldDatabase.setDatabaseInterface(newDatabase.getDatabaseInterface());
            } else {
                if (saveOldDatabases) {
                    // 
                    // The old database is not present in the new
                    // repository: simply add it to the list.
                    // When the transformation gets saved, it will be added
                    // to the repository.
                    // 
                    transMeta.addDatabase(oldDatabase);
                }
            }
        }
        if (repository != null) {
            try {
                // For the existing transformation, change the directory too:
                // Try to find the same directory in the new repository...
                RepositoryDirectoryInterface rdi = repository.findDirectory(transMeta.getRepositoryDirectory().getPath());
                if (rdi != null && !rdi.getPath().equals("/")) {
                    transMeta.setRepositoryDirectory(rdi);
                } else {
                    // the root is the default!
                    transMeta.setRepositoryDirectory(repository.loadRepositoryDirectoryTree());
                }
            } catch (KettleException ke) {
                rep = null;
                new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorConnectingRepository.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorConnectingRepository.Message", Const.CR), ke);
            }
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) JobMeta(org.pentaho.di.job.JobMeta) PartitionSchema(org.pentaho.di.partition.PartitionSchema) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SharedObjects(org.pentaho.di.shared.SharedObjects) SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) 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