/** * convert Exception to MetaException, which sets the cause to such exception * @param e cause of the exception * @return the MetaException with the specified exception as the cause */ public static MetaException newMetaException(Exception e) { return newMetaException(e != null ? e.getMessage() : null, e); }
/** * reset the timeout value of this timer. * @param timeoutMs */ public static void resetTimeout(long timeoutMs) throws MetaException { if (timeoutMs <= 0) { throw MetaStoreUtils.newMetaException(new DeadlineException("The reset timeout value should be " + "larger than 0: " + timeoutMs)); } Deadline deadline = getCurrentDeadline(); if (deadline != null) { deadline.timeoutNanos = timeoutMs * 1000000L; } else { throw MetaStoreUtils.newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it first.")); } }
/** * start the timer before a method is invoked. * @param method method to be invoked */ public static boolean startTimer(String method) throws MetaException { Deadline deadline = getCurrentDeadline(); if (deadline == null) { throw MetaStoreUtils.newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it first.")); } if (deadline.startTime != NO_DEADLINE) return false; deadline.method = method; do { deadline.startTime = System.nanoTime(); } while (deadline.startTime == NO_DEADLINE); return true; }
private void check() throws MetaException{ try { if (startTime == NO_DEADLINE) { throw new DeadlineException("Should execute startTimer() method before " + "checkTimeout. Error happens in method: " + method); } long elapsedTime = System.nanoTime() - startTime; if (elapsedTime > timeoutNanos) { throw new DeadlineException("Timeout when executing method: " + method + "; " + (elapsedTime / 1000000L) + "ms exceeds " + (timeoutNanos / 1000000L) + "ms"); } } catch (DeadlineException e) { throw MetaStoreUtils.newMetaException(e); } } }
/** * end the time after a method is done. */ public static void stopTimer() throws MetaException { Deadline deadline = getCurrentDeadline(); if (deadline != null) { deadline.startTime = NO_DEADLINE; deadline.method = null; } else { throw MetaStoreUtils.newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it first.")); } }
/** * Check whether the long running method timeout. * @throws MetaException when the method timeout */ public static void checkTimeout() throws MetaException { Deadline deadline = getCurrentDeadline(); if (deadline != null) { deadline.check(); } else { throw MetaStoreUtils.newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it first.")); } }
public PrivilegeGrantInfo build() throws MetaException { if (privilege == null) { throw new MetaException("Privilege must be provided."); } if (grantor == null) { try { grantor = SecurityUtils.getUser(); grantorType = PrincipalType.USER; } catch (IOException e) { throw MetaStoreUtils.newMetaException(e); } } return new PrivilegeGrantInfo(privilege, createTime, grantor, grantorType, grantOption); } }
public Function build(Configuration conf) throws MetaException { try { if (owner != null) { owner = SecurityUtils.getUser(); } } catch (IOException e) { throw MetaStoreUtils.newMetaException(e); } if (catName == null) catName = MetaStoreUtils.getDefaultCatalog(conf); Function f = new Function(funcName, dbName, className, owner, ownerType, createTime, funcType, resourceUris); f.setCatName(catName); return f; }
public Database build(Configuration conf) throws MetaException { if (name == null) throw new MetaException("You must name the database"); if (catalogName == null) catalogName = MetaStoreUtils.getDefaultCatalog(conf); Database db = new Database(name, description, location, params); db.setCatalogName(catalogName); db.setCreateTime(createTime); try { if (ownerName == null) ownerName = SecurityUtils.getUser(); db.setOwnerName(ownerName); if (ownerType == null) ownerType = PrincipalType.USER; db.setOwnerType(ownerType); return db; } catch (IOException e) { throw MetaStoreUtils.newMetaException(e); } }
public Table build(Configuration conf) throws MetaException { if (tableName == null) { throw new MetaException("You must set the table name"); } if (ownerType == null) { ownerType = PrincipalType.USER; } if (owner == null) { try { owner = SecurityUtils.getUser(); } catch (IOException e) { throw MetaStoreUtils.newMetaException(e); } } if (catName == null) catName = MetaStoreUtils.getDefaultCatalog(conf); Table t = new Table(tableName, dbName, owner, createTime, lastAccessTime, retention, buildSd(), partCols, tableParams, viewOriginalText, viewExpandedText, type); if (rewriteEnabled) t.setRewriteEnabled(true); if (temporary) t.setTemporary(temporary); t.setCatName(catName); if (!mvReferencedTables.isEmpty()) { CreationMetadata cm = new CreationMetadata(catName, dbName, tableName, mvReferencedTables); if (mvValidTxnList != null) cm.setValidTxnList(mvValidTxnList); t.setCreationMetadata(cm); } return t; }
throw MetaStoreUtils.newMetaException(e);
/** * convert Exception to MetaException, which sets the cause to such exception * @param e cause of the exception * @return the MetaException with the specified exception as the cause */ public static MetaException newMetaException(Exception e) { return newMetaException(e != null ? e.getMessage() : null, e); }
/** * reset the timeout value of this timer. * @param timeoutMs */ public static void resetTimeout(long timeoutMs) throws MetaException { if (timeoutMs <= 0) { throw MetaStoreUtils.newMetaException(new DeadlineException("The reset timeout value should be " + "larger than 0: " + timeoutMs)); } Deadline deadline = getCurrentDeadline(); if (deadline != null) { deadline.timeoutNanos = timeoutMs * 1000000L; } else { throw MetaStoreUtils.newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it first.")); } }
/** * end the time after a method is done. */ public static void stopTimer() throws MetaException { Deadline deadline = getCurrentDeadline(); if (deadline != null) { deadline.startTime = NO_DEADLINE; deadline.method = null; } else { throw MetaStoreUtils.newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it first.")); } }
private void check() throws MetaException{ try { if (startTime == NO_DEADLINE) { throw new DeadlineException("Should execute startTimer() method before " + "checkTimeout. Error happens in method: " + method); } long elapsedTime = System.nanoTime() - startTime; if (elapsedTime > timeoutNanos) { throw new DeadlineException("Timeout when executing method: " + method + "; " + (elapsedTime / 1000000L) + "ms exceeds " + (timeoutNanos / 1000000L) + "ms"); } } catch (DeadlineException e) { throw MetaStoreUtils.newMetaException(e); } } }
/** * start the timer before a method is invoked. * @param method method to be invoked */ public static boolean startTimer(String method) throws MetaException { Deadline deadline = getCurrentDeadline(); if (deadline == null) { throw MetaStoreUtils.newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it first.")); } if (deadline.startTime != NO_DEADLINE) return false; deadline.method = method; do { deadline.startTime = System.nanoTime(); } while (deadline.startTime == NO_DEADLINE); return true; }
/** * Check whether the long running method timeout. * @throws MetaException when the method timeout */ public static void checkTimeout() throws MetaException { Deadline deadline = getCurrentDeadline(); if (deadline != null) { deadline.check(); } else { throw MetaStoreUtils.newMetaException(new DeadlineException("The threadlocal Deadline is null," + " please register it first.")); } }
public PrivilegeGrantInfo build() throws MetaException { if (privilege == null) { throw new MetaException("Privilege must be provided."); } if (grantor == null) { try { grantor = SecurityUtils.getUser(); grantorType = PrincipalType.USER; } catch (IOException e) { throw MetaStoreUtils.newMetaException(e); } } return new PrivilegeGrantInfo(privilege, createTime, grantor, grantorType, grantOption); } }
public Database build(Configuration conf) throws MetaException { if (name == null) throw new MetaException("You must name the database"); if (catalogName == null) catalogName = MetaStoreUtils.getDefaultCatalog(conf); Database db = new Database(name, description, location, params); db.setCatalogName(catalogName); try { if (ownerName == null) ownerName = SecurityUtils.getUser(); db.setOwnerName(ownerName); if (ownerType == null) ownerType = PrincipalType.USER; db.setOwnerType(ownerType); return db; } catch (IOException e) { throw MetaStoreUtils.newMetaException(e); } }
public Table build(Configuration conf) throws MetaException { if (tableName == null) { throw new MetaException("You must set the table name"); } if (owner == null) { try { owner = SecurityUtils.getUser(); } catch (IOException e) { throw MetaStoreUtils.newMetaException(e); } } if (catName == null) catName = MetaStoreUtils.getDefaultCatalog(conf); Table t = new Table(tableName, dbName, owner, createTime, lastAccessTime, retention, buildSd(), partCols, tableParams, viewOriginalText, viewExpandedText, type); if (rewriteEnabled) t.setRewriteEnabled(true); if (temporary) t.setTemporary(temporary); t.setCatName(catName); if (!mvReferencedTables.isEmpty()) { CreationMetadata cm = new CreationMetadata(catName, dbName, tableName, mvReferencedTables); if (mvValidTxnList != null) cm.setValidTxnList(mvValidTxnList); t.setCreationMetadata(cm); } return t; }