public ClusterSchema loadClusterSchema(ObjectId id_cluster_schema, List<SlaveServer> slaveServers)
      throws KettleException {
    ClusterSchema clusterSchema = new ClusterSchema();
    RowMetaAndData row = getClusterSchema(id_cluster_schema);

    clusterSchema.setObjectId(id_cluster_schema);
    clusterSchema.setName(row.getString(KettleDatabaseRepository.FIELD_CLUSTER_NAME, null));
    clusterSchema.setBasePort(
        row.getString(KettleDatabaseRepository.FIELD_CLUSTER_BASE_PORT, null));
    clusterSchema.setSocketsBufferSize(
        row.getString(KettleDatabaseRepository.FIELD_CLUSTER_SOCKETS_BUFFER_SIZE, null));
    clusterSchema.setSocketsFlushInterval(
        row.getString(KettleDatabaseRepository.FIELD_CLUSTER_SOCKETS_FLUSH_INTERVAL, null));
    clusterSchema.setSocketsCompressed(
        row.getBoolean(KettleDatabaseRepository.FIELD_CLUSTER_SOCKETS_COMPRESSED, true));
    clusterSchema.setDynamic(row.getBoolean(KettleDatabaseRepository.FIELD_CLUSTER_DYNAMIC, true));

    ObjectId[] pids = repository.getClusterSlaveIDs(id_cluster_schema);
    for (int i = 0; i < pids.length; i++) {
      SlaveServer slaveServer = repository.loadSlaveServer(pids[i], null); // Load last version
      SlaveServer reference = SlaveServer.findSlaveServer(slaveServers, slaveServer.getName());
      if (reference != null) {
        clusterSchema.getSlaveServers().add(reference);
      } else {
        clusterSchema.getSlaveServers().add(slaveServer);
      }
    }

    return clusterSchema;
  }
示例#2
0
  // Load user with login from repository, don't verify password...
  public UserInfo(Repository rep, String login) throws KettleException {
    try {
      long id_profile;

      setID(rep.getUserID(login));
      if (getID() > 0) {
        RowMetaAndData r = rep.getUser(getID());
        if (r != null) {
          this.login = r.getString("LOGIN", null);
          password = Encr.decryptPassword(r.getString("PASSWORD", null));
          name = r.getString("NAME", null);
          description = r.getString("DESCRIPTION", null);
          enabled = r.getBoolean("ENABLED", false);
          id_profile = r.getInteger("ID_PROFILE", 0);
          profile = new ProfileMeta(rep, id_profile);
        } else {
          setID(-1L);
          throw new KettleDatabaseException(
              Messages.getString("UserInfo.Error.UserNotFound", login));
        }
      } else {
        setID(-1L);
        throw new KettleDatabaseException(Messages.getString("UserInfo.Error.UserNotFound", login));
      }
    } catch (KettleDatabaseException dbe) {
      rep.log.logError(
          toString(), Messages.getString("UserInfo.Error.UserNotLoaded", login, dbe.getMessage()));
      throw new KettleException(Messages.getString("UserInfo.Error.UserNotLoaded", login, ""), dbe);
    }
  }
  /**
   * Create a new step by loading the metadata from the specified repository.
   *
   * @param rep
   * @param stepId
   * @param databases
   * @param counters
   * @param partitionSchemas
   * @throws KettleException
   */
  public StepMeta loadStepMeta(
      ObjectId stepId, List<DatabaseMeta> databases, List<PartitionSchema> partitionSchemas)
      throws KettleException {
    StepMeta stepMeta = new StepMeta();
    PluginRegistry registry = PluginRegistry.getInstance();

    try {
      RowMetaAndData r = getStep(stepId);
      if (r != null) {
        stepMeta.setObjectId(stepId);

        stepMeta.setName(r.getString(KettleDatabaseRepository.FIELD_STEP_NAME, null));
        stepMeta.setDescription(r.getString(KettleDatabaseRepository.FIELD_STEP_DESCRIPTION, null));

        long id_step_type = r.getInteger(KettleDatabaseRepository.FIELD_STEP_ID_STEP_TYPE, -1L);
        RowMetaAndData steptyperow = getStepType(new LongObjectId(id_step_type));

        stepMeta.setStepID(
            steptyperow.getString(KettleDatabaseRepository.FIELD_STEP_TYPE_CODE, null));
        stepMeta.setDistributes(r.getBoolean(KettleDatabaseRepository.FIELD_STEP_DISTRIBUTE, true));
        int copies = (int) r.getInteger(KettleDatabaseRepository.FIELD_STEP_COPIES, 1);
        String copiesString = r.getString(KettleDatabaseRepository.FIELD_STEP_COPIES_STRING, null);
        if (!Const.isEmpty(copiesString)) {
          stepMeta.setCopiesString(copiesString);
        } else {
          stepMeta.setCopies(copies);
        }

        int x = (int) r.getInteger(KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_X, 0);
        int y = (int) r.getInteger(KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_Y, 0);
        stepMeta.setLocation(new Point(x, y));
        stepMeta.setDraw(r.getBoolean(KettleDatabaseRepository.FIELD_STEP_GUI_DRAW, false));

        // Generate the appropriate class...
        PluginInterface sp = registry.findPluginWithId(StepPluginType.class, stepMeta.getStepID());
        if (sp != null) {
          stepMeta.setStepMetaInterface((StepMetaInterface) registry.loadClass(sp));
        } else {
          throw new KettlePluginLoaderException(
              stepMeta.getStepID(),
              BaseMessages.getString(
                  PKG, "StepMeta.Exception.UnableToLoadClass", stepMeta.getStepID() + Const.CR));
        }

        if (stepMeta.getStepMetaInterface() != null) {
          // Read the step info from the repository!
          readRepCompatibleStepMeta(
              stepMeta.getStepMetaInterface(), repository, stepMeta.getObjectId(), databases);
          stepMeta
              .getStepMetaInterface()
              .readRep(repository, repository.metaStore, stepMeta.getObjectId(), databases);
        }

        // Get the partitioning as well...
        //
        stepMeta.setStepPartitioningMeta(loadStepPartitioningMeta(stepMeta.getObjectId()));
        stepMeta.getStepPartitioningMeta().setPartitionSchemaAfterLoading(partitionSchemas);

        // Get the cluster schema name
        //
        stepMeta.setClusterSchemaName(repository.getStepAttributeString(stepId, "cluster_schema"));

        // Are we using a custom row distribution plugin?
        //
        String rowDistributionCode =
            repository.getStepAttributeString(stepId, 0, "row_distribution_code");
        RowDistributionInterface rowDistribution =
            PluginRegistry.getInstance()
                .loadClass(
                    RowDistributionPluginType.class,
                    rowDistributionCode,
                    RowDistributionInterface.class);
        stepMeta.setRowDistribution(rowDistribution);

        // Load the attribute groups map
        //
        stepMeta.setAttributesMap(loadStepAttributesMap(stepId));

        // Done!
        //
        return stepMeta;
      } else {
        throw new KettleException(
            BaseMessages.getString(
                PKG, "StepMeta.Exception.StepInfoCouldNotBeFound", String.valueOf(stepId)));
      }
    } catch (KettleDatabaseException dbe) {
      throw new KettleException(
          BaseMessages.getString(
              PKG,
              "StepMeta.Exception.StepCouldNotBeLoaded",
              String.valueOf(stepMeta.getObjectId())),
          dbe);
    }
  }