/** * get single value by key */ public String getValue(String key) throws Exception { Object val = null; for (ObjectName oname : hadoopObjectNames) { try { val = mbsc.getAttribute(oname, key); } catch (AttributeNotFoundException anfe) { /* just go to the next */ continue; } catch (ReflectionException re) { if (re.getCause() instanceof NoSuchMethodException) { continue; } } err("Info: key = " + key + "; val = " + (val == null ? "null" : val.getClass()) + ":" + val); break; } return (val == null) ? "" : val.toString(); }
/** * Stop the application managed by this instance. * @throws MojoExecutionException if the JMX service could not be contacted * @throws IOException if an I/O error occurs * @throws InstanceNotFoundException if the lifecycle mbean cannot be found */ public void stop() throws MojoExecutionException, IOException, InstanceNotFoundException { try { this.connection.invoke(this.objectName, "shutdown", null, null); } catch (ReflectionException ex) { throw new MojoExecutionException("Shutdown failed", ex.getCause()); } catch (MBeanException ex) { throw new MojoExecutionException("Could not invoke shutdown operation", ex); } }
/** * The CTS wants a NotCompliantMBeanException in case the MBean cannot be created. * We need this, because instanciate cannot throw NotCompliantMBeanException. */ private ObjectInstance handleExceptionOnCreate(ReflectionException refex, String className) throws NotCompliantMBeanException, ReflectionException { if (refex.getCause() instanceof InstantiationException) throw new NotCompliantMBeanException("Cannot instanciate MBean: " + className); throw refex; }
/** * The CTS wants a NotCompliantMBeanException in case the MBean cannot be created. * We need this, because instanciate cannot throw NotCompliantMBeanException. */ private ObjectInstance handleExceptionOnCreate(ReflectionException refex, String className) throws NotCompliantMBeanException, ReflectionException { if (refex.getCause() instanceof InstantiationException) throw new NotCompliantMBeanException("Cannot instanciate MBean: " + className); throw refex; }
/** * Check if the spring application managed by this instance is ready. Returns * {@code false} if the mbean is not yet deployed so this method should be repeatedly * called until a timeout is reached. * @return {@code true} if the application is ready to service requests * @throws MojoExecutionException if the JMX service could not be contacted */ public boolean isReady() throws MojoExecutionException { try { return (Boolean) this.connection.getAttribute(this.objectName, "Ready"); } catch (InstanceNotFoundException ex) { return false; // Instance not available yet } catch (AttributeNotFoundException ex) { throw new IllegalStateException("Unexpected: attribute 'Ready' not available", ex); } catch (ReflectionException ex) { throw new MojoExecutionException("Failed to retrieve Ready attribute", ex.getCause()); } catch (MBeanException | IOException ex) { throw new MojoExecutionException(ex.getMessage(), ex); } }
/** * get single value by key */ public String getValue(String key) throws Exception { Object val = null; for (ObjectName oname : hadoopObjectNames) { try { val = mbsc.getAttribute(oname, key); } catch (AttributeNotFoundException anfe) { /* just go to the next */ continue; } catch (ReflectionException re) { if (re.getCause() instanceof NoSuchMethodException) { continue; } } err("Info: key = " + key + "; val = " + (val == null ? "null" : val.getClass()) + ":" + val); break; } return (val == null) ? "" : val.toString(); }
/** * get single value by key */ public String getValue(String key) throws Exception { Object val = null; for (ObjectName oname : hadoopObjectNames) { try { val = mbsc.getAttribute(oname, key); } catch (AttributeNotFoundException anfe) { /* just go to the next */ continue; } catch (ReflectionException re) { if (re.getCause() instanceof NoSuchMethodException) { continue; } } err("Info: key = " + key + "; val = " + (val == null ? "null" : val.getClass()) + ":" + val); break; } return (val == null) ? "" : val.toString(); }
/** * get single value by key */ public String getValue(String key) throws Exception{ Object val = null; for (ObjectName oname: hadoopObjectNames) { try { val = mbsc.getAttribute(oname, key); } catch (AttributeNotFoundException anfe) { /*just go to the next */ continue; } catch(ReflectionException re) { if (re.getCause() instanceof NoSuchMethodException) { continue; } } err("Info: key = " + key + "; val = " + val); break; } return (val == null) ? null : val.toString(); }
/** * Turns all statistics on for each mbean in the list. * * @param mbeanList */ private static void setStatsOn(ArrayList<String> mbeanList, MasterRemoteControl mrc) { // for each mbean name in the list for (String aMbeanList : mbeanList) { // turn the statistics collection on String methodName = "setStatsOn"; Object[] params = new Object[]{Boolean.TRUE}; String[] signatures = new String[]{"boolean"}; try { ObjectName objName = new ObjectName(aMbeanList); mrc.invoke(objName, methodName, params, signatures); log.info("Stats for " + aMbeanList + " was turned on."); } catch (UndeclaredThrowableException e) { // HACK : this will happen for components that always collect statistics // and do not have StatsOn method. } catch (javax.management.ReflectionException e) { if (!(e.getCause() instanceof java.lang.NoSuchMethodException) || !(e.getCause().getCause() instanceof NoSuchOperationException)) { log.error("unexpected jmx exception", e); } //othewise ignore -- presumably something changed in exception handling. } catch (Exception e) { log.error(e.getMessage(), e); } } }
/** * Stop the application managed by this instance. * @throws JmxException if the JMX service could not be contacted * @throws IOException if an I/O error occurs * @throws InstanceNotFoundException if the lifecycle mbean cannot be found */ public void stop() throws IOException, InstanceNotFoundException { try { this.connection.invoke(this.objectName, "shutdown", null, null); } catch (ReflectionException ex) { throw new JmxException("Shutdown failed", ex.getCause()); } catch (MBeanException ex) { throw new JmxException("Could not invoke shutdown operation", ex); } }
private void doWaitForSpringApplication(MBeanServerConnection connection) throws IOException, MojoExecutionException, MojoFailureException { final SpringApplicationAdminClient client = new SpringApplicationAdminClient( connection, this.jmxName); try { execute(this.wait, this.maxAttempts, () -> (client.isReady() ? true : null)); } catch (ReflectionException ex) { throw new MojoExecutionException("Unable to retrieve 'ready' attribute", ex.getCause()); } catch (Exception ex) { throw new MojoFailureException("Could not invoke shutdown operation", ex); } }
/** * Check if the spring application managed by this instance is ready. Returns * {@code false} if the mbean is not yet deployed so this method should be repeatedly * called until a timeout is reached. * @return {@code true} if the application is ready to service requests * @throws org.springframework.jmx.JmxException if the JMX service could not be contacted */ public boolean isReady() { try { return (Boolean) this.connection.getAttribute(this.objectName, "Ready"); } catch (InstanceNotFoundException ex) { return false; // Instance not available yet } catch (AttributeNotFoundException ex) { throw new IllegalStateException( "Unexpected: attribute 'Ready' not available", ex); } catch (ReflectionException ex) { throw new JmxException("Failed to retrieve Ready attribute", ex.getCause()); } catch (MBeanException ex) { throw new JmxException(ex.getMessage(), ex); } catch (IOException ex) { throw new JmxException(ex.getMessage(), ex); } }
public ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { try { Object mbean = instantiate(className); return registerMBean(mbean, name, (ClassLoader) null); } catch (SecurityException e) { throw e; } catch (ReflectionException refex) { // Note, the CTS wants a NotCompliantMBeanException for this case if (refex.getCause() instanceof InstantiationException) throw new NotCompliantMBeanException("Cannot instanciate MBean: " + className); else throw refex; } }
public ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { try { Object mbean = instantiate(className); return registerMBean(mbean, name, (ClassLoader) null); } catch (SecurityException e) { throw e; } catch (ReflectionException refex) { // Note, the CTS wants a NotCompliantMBeanException for this case if (refex.getCause() instanceof InstantiationException) throw new NotCompliantMBeanException("Cannot instanciate MBean: " + className); else throw refex; } }
Throwable t = e.getCause(); if (t instanceof ClassNotFoundException) throw e;
Throwable t = e.getCause(); if (t instanceof ClassNotFoundException) throw e;
} catch (ReflectionException e) { logger.log(BasicLevel.ERROR, "Cannot upload file: " + fileName + " :", e); act.setError(e.getCause().getMessage()); return; } catch (IOException e) {
} catch (ReflectionException e) { logger.log(BasicLevel.ERROR, "Cannot upload file: " + fileName + " :", e); act.setError(e.getCause().getMessage()); return; } catch (IOException e) { } catch (ReflectionException e) { logger.log(BasicLevel.ERROR, "Cannot deploy file: " + targetFileName + " :", e); act.setError(e.getCause().getMessage()); return; } catch (IOException e) {
} catch (ReflectionException e) { logger.log(BasicLevel.ERROR, "Cannot deploy file: " + targetFileName + " :", e); act.setError(e.getCause().getMessage()); return; } catch (IOException e) {
} catch (ReflectionException e) { logger.log(BasicLevel.ERROR, "Cannot undeploy file: " + targetFileName + " :", e); act.setError(e.getCause().getMessage()); return; } catch (IOException e) {