public static UserGroupInformation getCurrentUser() { try { return UserGroupInformation.getCurrentUser(); } catch( IOException exception ) { throw new CascadingException( "unable to get current user", exception ); } }
protected void setAutoCommit( Connection connection ) { try { connection.setAutoCommit( false ); } catch( SQLException exception ) { throw new CascadingException( "unable to set auto commit", exception ); } }
public static UserGroupInformation getCurrentUser() { try { return UserGroupInformation.getCurrentUser(); } catch( IOException exception ) { throw new CascadingException( "unable to get current user", exception ); } }
public static Class<?> loadClass( String typeString ) { try { return Thread.currentThread().getContextClassLoader().loadClass( typeString ); } catch( ClassNotFoundException exception ) { throw new CascadingException( "unable to load class: " + typeString, exception ); } }
protected static <C extends Configuration> C callCopyConstructor( Class type, Configuration parent ) { try { Constructor<C> constructor = type.getConstructor( parent.getClass() ); return constructor.newInstance( parent ); } catch( NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException exception ) { throw new CascadingException( "unable to create copy of: " + type ); } }
protected static <C extends Configuration> C callCopyConstructor( Class type, Configuration parent ) { try { Constructor<C> constructor = type.getConstructor( parent.getClass() ); return constructor.newInstance( parent ); } catch( NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException exception ) { throw new CascadingException( "unable to create copy of: " + type ); } }
private static Comparator createComparator( Configuration jobConf, String typeName ) { LOG.debug( "using default comparator: {}", typeName ); try { Class<Comparator> type = (Class<Comparator>) TupleSerialization.class.getClassLoader().loadClass( typeName ); return ReflectionUtils.newInstance( type, jobConf ); } catch( ClassNotFoundException exception ) { throw new CascadingException( "unable to load class: " + typeName, exception ); } }
private static Comparator createComparator( Configuration jobConf, String typeName ) { LOG.debug( "using default comparator: {}", typeName ); try { Class<Comparator> type = (Class<Comparator>) TupleSerialization.class.getClassLoader().loadClass( typeName ); return ReflectionUtils.newInstance( type, jobConf ); } catch( ClassNotFoundException exception ) { throw new CascadingException( "unable to load class: " + typeName, exception ); } }
public static Object invokeStaticMethod( Class type, String methodName, Object[] parameters, Class[] parameterTypes ) { try { Method method = type.getDeclaredMethod( methodName, parameterTypes ); method.setAccessible( true ); return method.invoke( null, parameters ); } catch( Exception exception ) { throw new CascadingException( "unable to invoke static method: " + type.getName() + "." + methodName, exception ); } }
public static Object invokeStaticMethod( Class type, String methodName, Object[] parameters, Class[] parameterTypes ) { try { Method method = type.getDeclaredMethod( methodName, parameterTypes ); method.setAccessible( true ); return method.invoke( null, parameters ); } catch( Exception exception ) { throw new CascadingException( "unable to invoke static method: " + type.getName() + "." + methodName, exception ); } }
public static <T> T getStaticField( Class type, String fieldName ) { try { Field field = type.getDeclaredField( fieldName ); field.setAccessible( true ); return (T) field.get( null ); } catch( Exception exception ) { throw new CascadingException( "unable to get static field: " + type.getName() + "." + fieldName, exception ); } }
public static Object invokeStaticMethod( Class type, String methodName, Object[] parameters, Class[] parameterTypes ) { try { Method method = type.getDeclaredMethod( methodName, parameterTypes ); method.setAccessible( true ); return method.invoke( null, parameters ); } catch( Exception exception ) { throw new CascadingException( "unable to invoke static method: " + type.getName() + "." + methodName, exception ); } }
public static <T> T invokeConstructor( Class<T> target, Object[] parameters, Class[] parameterTypes ) { try { Constructor<T> constructor = target.getConstructor( parameterTypes ); constructor.setAccessible( true ); return constructor.newInstance( parameters ); } catch( Exception exception ) { throw new CascadingException( "unable to create new instance: " + target.getName() + "(" + Arrays.toString( parameters ) + ")", exception ); } }
public static Object newInstance( Class type ) { try { Constructor constructor = type.getDeclaredConstructor(); constructor.setAccessible( true ); return constructor.newInstance(); } catch( Exception exception ) { throw new CascadingException( "unable to create new instance of: " + type.getName(), exception ); } }
public static <T> T getStaticField( Class type, String fieldName ) { try { Field field = type.getDeclaredField( fieldName ); field.setAccessible( true ); return (T) field.get( null ); } catch( Exception exception ) { throw new CascadingException( "unable to get static field: " + type.getName() + "." + fieldName, exception ); } }
public static Object invokeInstanceMethod( Object target, String methodName, Object[] parameters, Class[] parameterTypes ) { try { Method method = target.getClass().getMethod( methodName, parameterTypes ); method.setAccessible( true ); return method.invoke( target, parameters ); } catch( Exception exception ) { throw new CascadingException( "unable to invoke instance method: " + target.getClass().getName() + "." + methodName, exception ); } }
@Override public Object newInstance( String className ) { if( className == null || className.isEmpty() ) return null; try { Class type = (Class) Hadoop2TezFlowProcess.class.getClassLoader().loadClass( className.toString() ); return ReflectionUtils.newInstance( type, configuration ); } catch( ClassNotFoundException exception ) { throw new CascadingException( "unable to load class: " + className.toString(), exception ); } }
@Override public Object newInstance( String className ) { if( className == null || className.isEmpty() ) return null; try { Class type = (Class) HadoopFlowProcess.class.getClassLoader().loadClass( className.toString() ); return ReflectionUtils.newInstance( type, jobConf ); } catch( ClassNotFoundException exception ) { throw new CascadingException( "unable to load class: " + className.toString(), exception ); } }
@Override public Object newInstance( String className ) { if( className == null || className.isEmpty() ) return null; try { Class type = (Class) Hadoop2TezFlowProcess.class.getClassLoader().loadClass( className.toString() ); return ReflectionUtils.newInstance( type, configuration ); } catch( ClassNotFoundException exception ) { throw new CascadingException( "unable to load class: " + className.toString(), exception ); } }
public static Object invokeConstructor( String className, Object[] parameters, Class[] parameterTypes ) { try { Class type = Util.class.getClassLoader().loadClass( className ); return invokeConstructor( type, parameters, parameterTypes ); } catch( ClassNotFoundException exception ) { throw new CascadingException( "unable to load class: " + className, exception ); } }