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;
}
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));
}
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));
}
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;
}
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);
}
}
}
}
Aggregations