Java Code Examples for org.pentaho.di.trans.TransMeta#findClusterSchema()

The following examples show how to use org.pentaho.di.trans.TransMeta#findClusterSchema() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseCluster.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public TransMeta loadAndModifyTestTransformation( ClusterGenerator clusterGenerator, String filename ) throws KettleException {
  TransMeta transMeta = new TransMeta( filename );

  // Add the slave servers
  //
  for ( SlaveServer slaveServer : ClusterGenerator.LOCAL_TEST_SLAVES ) {
    transMeta.getSlaveServers().add( slaveServer );
  }

  // Replace the slave servers in the specified cluster schema...
  //
  ClusterSchema clusterSchema = transMeta.findClusterSchema( ClusterGenerator.TEST_CLUSTER_NAME );
  assertNotNull( "Cluster schema '" + ClusterGenerator.TEST_CLUSTER_NAME + "' couldn't be found", clusterSchema );
  clusterSchema.getSlaveServers().clear();
  clusterSchema.getSlaveServers().addAll( Arrays.asList( ClusterGenerator.LOCAL_TEST_SLAVES ) );

  return transMeta;
}
 
Example 2
Source File: MasterSlaveIT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private static TransMeta loadTransMetaReplaceSlavesInCluster( ClusterGenerator clusterGenerator,
  String testFilename ) throws KettleException {
  TransMeta transMeta = new TransMeta( testFilename );

  // Add the slave servers
  //
  for ( SlaveServer slaveServer : ClusterGenerator.LOCAL_TEST_SLAVES ) {
    transMeta.getSlaveServers().add( slaveServer );
  }

  // Replace the slave servers in the specified cluster schema...
  //
  ClusterSchema clusterSchema = transMeta.findClusterSchema( ClusterGenerator.TEST_CLUSTER_NAME );
  assertNotNull( "Cluster schema '" + ClusterGenerator.TEST_CLUSTER_NAME + "' couldn't be found", clusterSchema );
  clusterSchema.getSlaveServers().clear();
  clusterSchema.getSlaveServers().addAll( Arrays.asList( ClusterGenerator.LOCAL_TEST_SLAVES ) );

  return transMeta;
}
 
Example 3
Source File: KettleDatabaseRepositoryTransDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Read the clusters in the repository and add them to this transformation if they are not yet present.
 *
 * @param transMeta
 *          The transformation to load into.
 * @param overWriteShared
 *          if an object with the same name exists, overwrite
 * @throws KettleException
 */
public void readClusters( TransMeta transMeta, boolean overWriteShared ) throws KettleException {
  try {
    ObjectId[] dbids = repository.getClusterIDs( false );
    for ( int i = 0; i < dbids.length; i++ ) {
      ClusterSchema clusterSchema = repository.loadClusterSchema( dbids[i], transMeta.getSlaveServers(), null );
      clusterSchema.shareVariablesWith( transMeta );
      // Check if there already is one in the transformation
      ClusterSchema check = transMeta.findClusterSchema( clusterSchema.getName() );
      if ( check == null || overWriteShared ) {
        if ( !Utils.isEmpty( clusterSchema.getName() ) ) {
          transMeta.addOrReplaceClusterSchema( clusterSchema );
          if ( !overWriteShared ) {
            clusterSchema.setChanged( false );
          }
        }
      }
    }
  } catch ( KettleDatabaseException dbe ) {
    throw new KettleException(
      BaseMessages.getString( PKG, "TransMeta.Log.UnableToReadClustersFromRepository" ), dbe );
  }
}
 
Example 4
Source File: TransDelegate.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Add clusters in the repository to this transformation if they are not yet present.
 * 
 * @param TransMeta
 *          The transformation to load into.
 * @param overWriteShared
 *          if an object with the same name exists, overwrite
 */
protected void readClusters( TransMeta transMeta, boolean overWriteShared, List<ClusterSchema> clusterSchemas ) {
  for ( ClusterSchema clusterSchema : clusterSchemas ) {
    if ( overWriteShared || transMeta.findClusterSchema( clusterSchema.getName() ) == null ) {
      if ( !Utils.isEmpty( clusterSchema.getName() ) ) {
        clusterSchema.shareVariablesWith( transMeta );
        transMeta.addOrReplaceClusterSchema( clusterSchema );
        if ( !overWriteShared ) {
          clusterSchema.setChanged( false );
        }
      }
    }
  }
}