Package org.apache.sentry

Examples of org.apache.sentry.SentryUserException


  }

  public SentrySchemaTool(String sentryScripPath, Configuration sentryConf,
      String dbType) throws SentryUserException {
    if (sentryScripPath == null || sentryScripPath.isEmpty()) {
      throw new SentryUserException("No Sentry script dir provided");
    }
    this.sentryConf = sentryConf;
    this.dbType = dbType;
    this.SentryStoreSchemaInfo = new SentryStoreSchemaInfo(sentryScripPath,
        dbType);
    userName = sentryConf.get(ServiceConstants.ServerConfig.SENTRY_STORE_JDBC_USER,
        ServiceConstants.ServerConfig.SENTRY_STORE_JDBC_USER_DEFAULT);
    passWord = sentryConf.get(ServiceConstants.ServerConfig.SENTRY_STORE_JDBC_PASS,
        ServiceConstants.ServerConfig.SENTRY_STORE_JDBC_PASS_DEFAULT);
    try {
      connectionURL = getValidConfVar(ServiceConstants.ServerConfig.SENTRY_STORE_JDBC_URL);
      if(dbType.equalsIgnoreCase(SentrySchemaHelper.DB_DERBY)) {
        driver = sentryConf.get(ServiceConstants.ServerConfig.SENTRY_STORE_JDBC_DRIVER,
            ServiceConstants.ServerConfig.SENTRY_STORE_JDBC_DRIVER_DEFAULT);
      } else {
        driver = getValidConfVar(ServiceConstants.ServerConfig.SENTRY_STORE_JDBC_DRIVER);
      }
      // load required JDBC driver
      Class.forName(driver);
    } catch (IOException e) {
      throw new SentryUserException("Missing property: " + e.getMessage());
    } catch (ClassNotFoundException e) {
      throw new SentryUserException("Failed to load driver", e);
    }
  }
View Full Code Here


    }
    try {
      Statement stmt = sentryStoreConn.createStatement();
      ResultSet res = stmt.executeQuery(versionQuery);
      if (!res.next()) {
        throw new SentryUserException("Didn't find version data in sentry store");
      }
      String currentSchemaVersion = res.getString(1);
      sentryStoreConn.close();
      return currentSchemaVersion;
    } catch (SQLException e) {
      throw new SentryUserException("Failed to get schema version.", e);
    }
  }
View Full Code Here

  private void testConnectionToMetastore() throws SentryUserException {
    Connection conn = getConnectionToMetastore(true);
    try {
      conn.close();
    } catch (SQLException e) {
      throw new SentryUserException("Failed to close sentry store connection", e);
    }
  }
View Full Code Here

      System.out.println("Sentry store connection URL:\t " + connectionURL);
      System.out.println("Sentry store Connection Driver :\t " + driver);
      System.out.println("Sentry store connection User:\t " + userName);
    }
    if ((userName == null) || userName.isEmpty()) {
      throw new SentryUserException("UserName empty ");
    }
    try {
      // Connect using the JDBC URL and user/pass from conf
      return DriverManager.getConnection(connectionURL, userName, passWord);
    } catch (SQLException e) {
      throw new SentryUserException("Failed to make connection to Sentry store.", e);
    }
  }
View Full Code Here

    String newSchemaVersion =
        getMetaStoreSchemaVersion(getConnectionToMetastore(false));
    // verify that the new version is added to schema
    if (!SentryStoreSchemaInfo.getSentrySchemaVersion().equalsIgnoreCase(
        newSchemaVersion)) {
      throw new SentryUserException("Found unexpected schema version "
          + newSchemaVersion);
    }
  }
View Full Code Here

   * @throws SentryUserException
   */
  public void doUpgrade() throws SentryUserException {
    String fromVersion = getMetaStoreSchemaVersion(getConnectionToMetastore(false));
    if (fromVersion == null || fromVersion.isEmpty()) {
      throw new SentryUserException(
          "Schema version not stored in the sentry store. "
              +
          "Metastore schema is too old or corrupt. Try specifying the version manually");
    }
    doUpgrade(fromVersion);
View Full Code Here

          runBeeLine(scriptDir, scriptFile);
          System.out.println("Completed " + scriptFile);
        }
      }
    } catch (IOException eIO) {
      throw new SentryUserException(
          "Upgrade FAILED! Metastore state would be inconsistent !!", eIO);
    }

    // Revalidated the new version after upgrade
    verifySchemaVersion();
View Full Code Here

      if (!dryRun) {
        runBeeLine(initScriptDir, initScriptFile);
        System.out.println("Initialization script completed");
      }
    } catch (IOException e) {
      throw new SentryUserException("Schema initialization FAILED!"
          + " Metastore state would be inconsistent !!", e);
    }
  }
View Full Code Here

            Configuration.class, String.class);
        constrctor.setAccessible(true);
        groupMappingService = (GroupMappingService) constrctor.newInstance(new Object[] { conf,
            authResoruce });
      } catch (NoSuchMethodException e) {
        throw new SentryUserException("Unable to instantiate group mapping", e);
      } catch (SecurityException e) {
        throw new SentryUserException("Unable to instantiate group mapping", e);
      } catch (ClassNotFoundException e) {
        throw new SentryUserException("Unable to instantiate group mapping", e);
      } catch (InstantiationException e) {
        throw new SentryUserException("Unable to instantiate group mapping", e);
      } catch (IllegalAccessException e) {
        throw new SentryUserException("Unable to instantiate group mapping", e);
      } catch (IllegalArgumentException e) {
        throw new SentryUserException("Unable to instantiate group mapping", e);
      } catch (InvocationTargetException e) {
        throw new SentryUserException("Unable to instantiate group mapping", e);
      }
      return groupMappingService.getGroups(userName);
  }
View Full Code Here

    request.setRoleName(roleName);
    try {
      TCreateSentryRoleResponse response = client.create_sentry_role(request);
      Status.throwIfNotOk(response.getStatus());
    } catch (TException e) {
      throw new SentryUserException(THRIFT_EXCEPTION_MESSAGE, e);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.sentry.SentryUserException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.