public InvalidOperationException deepCopy() { return new InvalidOperationException(this); }
private InvalidOperationException invalidOperationException(Exception e) { InvalidOperationException ex = new InvalidOperationException(e.getMessage()); ex.initCause(e.getCause()); return ex; }
public static boolean replCkptStatus(String dbName, Map<String, String> props, String dumpRoot) throws InvalidOperationException { // If ckpt property not set or empty means, bootstrap is not run on this object. if ((props != null) && props.containsKey(REPL_CHECKPOINT_KEY) && !props.get(REPL_CHECKPOINT_KEY).isEmpty()) { if (props.get(REPL_CHECKPOINT_KEY).equals(dumpRoot)) { return true; } throw new InvalidOperationException(ErrorMsg.REPL_BOOTSTRAP_LOAD_PATH_NOT_VALID.format(dumpRoot, props.get(REPL_CHECKPOINT_KEY))); } return false; }
private InvalidOperationException invalidOperationException(Exception e) { InvalidOperationException ex = new InvalidOperationException(e.getMessage()); ex.initCause(e.getCause()); return ex; }
var processInfo = new ProcessStartInfo("java.exe", "-jar app.jar") { CreateNoWindow = true, UseShellExecute = false }; Process proc; if ((proc = Process.Start(processInfo)) == null) { throw new InvalidOperationException("??"); } proc.WaitForExit(); int exitCode = proc.ExitCode; proc.Close();
private void checkColTypeChangeCompatible(List<FieldSchema> oldCols, List<FieldSchema> newCols) throws InvalidOperationException { List<String> incompatibleCols = new ArrayList<>(); int maxCols = Math.min(oldCols.size(), newCols.size()); for (int i = 0; i < maxCols; i++) { if (!ColumnType.areColTypesCompatible( ColumnType.getTypeName(oldCols.get(i).getType()), ColumnType.getTypeName(newCols.get(i).getType()))) { incompatibleCols.add(newCols.get(i).getName()); } } if (!incompatibleCols.isEmpty()) { throw new InvalidOperationException( "The following columns have types incompatible with the existing " + "columns in their respective positions :\n" + org.apache.commons.lang.StringUtils.join(incompatibleCols, ',') ); } }
private ReplLoadOpType getLoadDbType(String dbName) throws InvalidOperationException, HiveException { Database db = context.hiveDb.getDatabase(dbName); if (db == null) { return ReplLoadOpType.LOAD_NEW; } if (isDbAlreadyBootstrapped(db)) { throw new InvalidOperationException("Bootstrap REPL LOAD is not allowed on Database: " + dbName + " as it was already done."); } if (ReplUtils.replCkptStatus(dbName, db.getParameters(), context.dumpDirectory)) { return ReplLoadOpType.LOAD_SKIP; } if (isDbEmpty(dbName)) { return ReplLoadOpType.LOAD_REPLACE; } throw new InvalidOperationException("Bootstrap REPL LOAD is not allowed on Database: " + dbName + " as it is not empty. One or more tables/functions exist."); }
newStatus = Status.valueOf(status); } catch (IllegalArgumentException e) { throw new InvalidOperationException("Invalid status: " + status); case ACTIVE: // No status change for active resource plan, first activate another plan. if (!canDeactivate) { throw new InvalidOperationException( "Resource plan " + name + " is active; activate another plan first, or disable workload management."); doActivate = (newStatus == Status.ACTIVE); if (doActivate && !canActivateDisabled) { throw new InvalidOperationException("Resource plan " + name + " is disabled and should be enabled before activation (or in the same command)"); throw new InvalidOperationException( "ResourcePlan: " + name + " is invalid: " + response.getErrors());
@Override public List<String> get_table_names_by_filter( final String dbName, final String filter, final short maxTables) throws MetaException, InvalidOperationException, UnknownDBException { List<String> tables = null; startFunction("get_table_names_by_filter", ": db = " + dbName + ", filter = " + filter); Exception ex = null; String[] parsedDbName = parseDbName(dbName, conf); try { if (parsedDbName[CAT_NAME] == null || parsedDbName[CAT_NAME].isEmpty() || parsedDbName[DB_NAME] == null || parsedDbName[DB_NAME].isEmpty()) { throw new UnknownDBException("DB name is null or empty"); } if (filter == null) { throw new InvalidOperationException(filter + " cannot apply null filter"); } tables = getMS().listTableNamesByFilter(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], filter, maxTables); tables = FilterUtils.filterTableNamesIfEnabled( isServerFilterEnabled, filterHook, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tables); } catch (MetaException | InvalidOperationException | UnknownDBException e) { ex = e; throw e; } catch (Exception e) { ex = e; throw newMetaException(e); } finally { endFunction("get_table_names_by_filter", tables != null, ex, join(tables, ",")); } return tables; }
if (resourcePlan.getDefaultPool() != null && resourcePlan.getDefaultPool().getPath().equals(poolPath)) { throw new InvalidOperationException("Cannot drop default pool of a resource plan"); throw new InvalidOperationException("Cannot drop a pool that has child pools"); } catch(Exception e) { if (getConstraintException(e) != null) { throw new InvalidOperationException("Please remove all mappings for this pool.");
@Override public void alterCatalog(String catName, Catalog cat) throws MetaException, InvalidOperationException { if (!cat.getName().equals(catName)) { throw new InvalidOperationException("You cannot change a catalog's name"); } boolean committed = false; try { MCatalog mCat = getMCatalog(catName); if (org.apache.commons.lang.StringUtils.isNotBlank(cat.getLocationUri())) { mCat.setLocationUri(cat.getLocationUri()); } if (org.apache.commons.lang.StringUtils.isNotBlank(cat.getDescription())) { mCat.setDescription(cat.getDescription()); } openTransaction(); pm.makePersistent(mCat); committed = commitTransaction(); } finally { if (!committed) { rollbackTransaction(); } } }
} catch (InvalidOperationException e) { throw new InvalidOperationException("There are still objects in the default " + "database for catalog " + catName); } catch (InvalidObjectException|IOException|InvalidInputException e) { throw new InvalidOperationException("There are non-default databases in the catalog " + catName + " so it cannot be dropped.");
throw new InvalidOperationException("Cannot change values during replace."); && changes.getStatus() == WMResourcePlanStatus.ACTIVE); if (isReplacingActive == isReplacingSpecific) { throw new InvalidOperationException("Must specify a name, or the active plan; received " + changes.getName() + ", " + (changes.isSetStatus() ? changes.getStatus() : null)); throw new InvalidOperationException("Invalid replace - no name specified"); throw new InvalidOperationException("A plan cannot replace itself"); throw new InvalidOperationException("Cannot change the namespace; replacing " + oldNs + " with " + newNs);
ex = new InvalidOperationException("Schema " + schemaName + " cannot be dropped, it has" + " at least one valid version"); throw (InvalidObjectException)ex;
@Override public WMFullResourcePlan alterResourcePlan(String name, String ns, WMNullableResourcePlan changes, boolean canActivateDisabled, boolean canDeactivate, boolean isReplace) throws AlreadyExistsException, NoSuchObjectException, InvalidOperationException, MetaException { name = name == null ? null : normalizeIdentifier(name); if (isReplace && name == null) { throw new InvalidOperationException("Cannot replace without specifying the source plan"); } boolean commited = false; Query query = null; // This method only returns the result when activating a resource plan. // We could also add a boolean flag to be specified by the caller to see // when the result might be needed. WMFullResourcePlan result = null; try { openTransaction(); if (isReplace) { result = handleAlterReplace(name, ns, changes); } else { result = handleSimpleAlter(name, ns, changes, canActivateDisabled, canDeactivate); } commited = commitTransaction(); return result; } catch (Exception e) { checkForConstraintException(e, "Resource plan name should be unique: "); throw e; } finally { rollbackAndCleanup(commited, query); } }
boolean hasNsChange = changes.isSetNs() && !changes.getNs().equals(getNsOrDefault(plan.getNs())); if (hasNsChange) { throw new InvalidOperationException("Cannot change ns; from " + getNsOrDefault(plan.getNs()) + " to " + changes.getNs()); || changes.isSetIsSetDefaultPoolPath() || hasNameChange) { if (changes.isSetStatus()) { throw new InvalidOperationException("Cannot change values during status switch."); } else if (plan.getStatus() != MWMResourcePlan.Status.DISABLED) { throw new InvalidOperationException("Resource plan must be disabled to edit it."); String newName = normalizeIdentifier(changes.getName()); if (newName.isEmpty()) { throw new InvalidOperationException("Cannot rename to empty value."); if (changes.isSetQueryParallelism()) { if (changes.getQueryParallelism() <= 0) { throw new InvalidOperationException("queryParallelism should be positive.");
throw new InvalidOperationException(e.getMessage()); } catch (MetaException | InvalidOperationException e) { ex = e;
private MWMResourcePlan getMWMResourcePlan(String name, String ns, boolean editCheck, boolean mustExist) throws NoSuchObjectException, InvalidOperationException { MWMResourcePlan resourcePlan; boolean commited = false; Query query = null; name = normalizeIdentifier(name); try { query = createGetResourcePlanQuery(); ns = getNsOrDefault(ns); resourcePlan = (MWMResourcePlan) query.execute(name, ns); pm.retrieve(resourcePlan); commited = commitTransaction(); } finally { rollbackAndCleanup(commited, query); } if (mustExist && resourcePlan == null) { throw new NoSuchObjectException("There is no resource plan named: " + name + " in " + ns); } if (editCheck && resourcePlan != null && resourcePlan.getStatus() != MWMResourcePlan.Status.DISABLED) { throw new InvalidOperationException("Resource plan must be disabled to edit it."); } return resourcePlan; }
@Override public void createPool(WMPool pool) throws AlreadyExistsException, NoSuchObjectException, InvalidOperationException, MetaException { boolean commited = false; try { openTransaction(); MWMResourcePlan resourcePlan = getMWMResourcePlan( pool.getResourcePlanName(), pool.getNs(), true); if (!poolParentExists(resourcePlan, pool.getPoolPath())) { throw new NoSuchObjectException("Pool path is invalid, the parent does not exist"); } String policy = pool.getSchedulingPolicy(); if (!MetaStoreUtils.isValidSchedulingPolicy(policy)) { throw new InvalidOperationException("Invalid scheduling policy " + policy); } MWMPool mPool = new MWMPool(resourcePlan, pool.getPoolPath(), pool.getAllocFraction(), pool.getQueryParallelism(), policy); pm.makePersistent(mPool); commited = commitTransaction(); } catch (Exception e) { checkForConstraintException(e, "Pool already exists: "); throw e; } finally { rollbackAndCleanup(commited, (Query)null); } }
String policy = pool.getSchedulingPolicy(); if (!MetaStoreUtils.isValidSchedulingPolicy(policy)) { throw new InvalidOperationException("Invalid scheduling policy " + policy);