public void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { try { delegate.setAttribute(name, attribute); } catch(IOException e) { throw new RuntimeException(e); } }
public void setContentionMonitoringEnabled(boolean enabled) { if (enabled) { try { Attribute attr = new Attribute("ThreadContentionMonitoringEnabled", Boolean.TRUE); mserver.setAttribute(THREADING_MBEAN, attr); } catch (Exception e) { // ignore } } contentionMonitoringEnabled = enabled; }
this.serverToUse.setAttribute(this.objectName, new Attribute(attributeName, invocation.getArguments()[0])); return null;
public void setProperty(String property, Object value) { try { server.setAttribute(name, new Attribute(property, value)); } catch (MBeanException e) { throwExceptionWithTarget("Could not set property: " + property + ". Reason: ", e); } catch (Exception e) { throwException("Could not set property: " + property + ". Reason: ", e); } }
this.serverToUse.setAttribute(this.objectName, new Attribute(attributeName, invocation.getArguments()[0])); return null;
public void set(ObjectName bean, String attr, String value) throws Exception { MBeanInfo mbinfo = mserver.getMBeanInfo(bean); MBeanAttributeInfo ai = attrInfo(mbinfo, attr); if (ai == null) { throw new IllegalArgumentException("No such attribute '" + attr + "'"); } if (!ai.isWritable()) { throw new IllegalArgumentException("Attribute '" + attr + "' is not writeable"); } String type = ai.getType(); Object ov = convert(value, type); mserver.setAttribute(bean, new Attribute(attr, ov)); }
protected static Object doAttributeOperation(MBeanServerConnection mbsc, ObjectInstance instance, String command, MBeanAttributeInfo[] infos) throws Exception { // Usually we get attributes. If an argument, then we're being asked // to set attribute. CommandParse parse = new CommandParse(command); if (parse.getArgs() == null || parse.getArgs().length == 0) { // Special-casing. If the subCommand is 'Attributes', then return // list of all attributes. if (command.equals("Attributes")) { String[] names = new String[infos.length]; for (int i = 0; i < infos.length; i++) { names[i] = infos[i].getName(); } return mbsc.getAttributes(instance.getObjectName(), names); } return mbsc.getAttribute(instance.getObjectName(), parse.getCmd()); } if (parse.getArgs().length != 1) { throw new IllegalArgumentException("One only argument setting " + "attribute values: " + parse.getArgs()); } // Get first attribute of name 'cmd'. Assumption is no method // overrides. Then, look at the attribute and use its type. MBeanAttributeInfo info = (MBeanAttributeInfo) getFeatureInfo(infos, parse.getCmd()); java.lang.reflect.Constructor c = Class.forName(info.getType()).getConstructor(new Class[] { String.class }); Attribute a = new Attribute(parse.getCmd(), c.newInstance(new Object[] { parse.getArgs()[0] })); mbsc.setAttribute(instance.getObjectName(), a); return null; }
server.getMBeanServerConnection().setAttribute(objectName, attr);
server.getMBeanServerConnection().setAttribute(objectName, attr);
JMXEnv.conn().setAttribute(obsBean, new Attribute("LearnerMaster", Long.toString(3 - observerMasterId))); Assert.assertTrue("server failed to disconnect on terminate", latch.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)); JMXEnv.conn().setAttribute(obsBean, new Attribute("LearnerMaster", Long.toString(3 - leaderId))); Assert.fail("should have seen an exception on previous command"); } catch (RuntimeMBeanException e) {
private Object setAttribute(JmxWriteRequest request, MBeanServerConnection server) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException, IntrospectionException, InvalidAttributeValueException, IllegalAccessException, InvocationTargetException, IOException { // Old value, will throw an exception if attribute is not known. That's good. Object oldValue = server.getAttribute(request.getObjectName(), request.getAttributeName()); MBeanInfo mInfo = server.getMBeanInfo(request.getObjectName()); MBeanAttributeInfo aInfo = null; for (MBeanAttributeInfo i : mInfo.getAttributes()) { if (i.getName().equals(request.getAttributeName())) { aInfo = i; break; } } Object values[]; if (aInfo instanceof OpenMBeanAttributeInfo) { values = getValues((OpenMBeanAttributeInfo) aInfo, oldValue, request); } else { // aInfo is != null otherwise getAttribute() would have already thrown an ArgumentNotFoundException values = getValues(aInfo.getType(), oldValue, request); } Attribute attribute = new Attribute(request.getAttributeName(),values[0]); server.setAttribute(request.getObjectName(),attribute); return values[1]; }
public Void call() throws Exception { getConnectionOrFail().setAttribute(realObjectName, new javax.management.Attribute(attribute, val)); return null; }}); if (LOG.isTraceEnabled()) LOG.trace("From {}, for jmx attribute {}.{}, set value {}", new Object[] {url, objectName.getCanonicalName(), attribute, val});
public void setAttribute(Attribute attribute) throws RemoteException, InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException, java.io.IOException { String attrName = attribute.getName(); Set appList = new HashSet(Arrays.asList(JSR_SERVER_INFO)); if(appList.contains(attrName)){ this.conn.setAttribute(this.runtimeObjName, attribute); } }
public void setEnableNetworkPartitionDetection(boolean newValue) { try { this.mbs.setAttribute(this.agentName, new Attribute("enableNetworkPartitionDetection", new Boolean(newValue))); } catch (Exception ex) { throw handleException(ex); } } public boolean getEnableNetworkPartitionDetection() {
public void setSSLAuthenticationRequired(boolean authRequired) { try { this.mbs.setAttribute(this.agentName, new Attribute("sslAuthenticationRequired", new Boolean(authRequired))); } catch (Exception ex) { throw handleException(ex); } }
public void setLogFile(String logFile) { try { this.mbs.setAttribute(this.agentName, new Attribute("logFile", logFile)); } catch (Exception ex) { throw handleException(ex); } }
public void setRefreshInterval(int interval) { try { this.mbs.setAttribute(this.objectName, new Attribute("refreshInterval", interval)); } catch (Exception ex) { throw handleException(ex); } }
public void setCacheXMLFile(String cacheXml) { try { Assert.assertTrue(this.objectName != null); this.mbs.setAttribute(this.objectName, new Attribute("cacheXMLFile", cacheXml)); } catch (Exception ex) { throw handleException(ex); } }
public void setRemoteCommand(String remoteCommand) { checkForRmiConnection(); try { Assert.assertTrue(this.objectName != null); this.mbs.setAttribute(this.objectName, new Attribute("remoteCommand", remoteCommand)); } catch (Exception ex) { String s = "While setting the remote command"; throw new InternalGemFireException(s, ex); } }
public Object perform(Object[] args) throws Throwable { Object value = MXBeanUtils.construct(attribute.getOpenType(), args[0], "Set attribute: " + attribute.getName()); Attribute attr = new Attribute(attribute.getName(), value); mbeanServerConnection.setAttribute(objectName, attr); return null; } }