/** * Invokes an operation on an MBean. * @param onameStr The name of the MBean. * @param operation The name of the operation to invoke. * @param parameters An array of Strings containing the parameters to the * operation. They will be converted to the appropriate * types to call the reuested operation. * @return The value returned by the requested operation. */ private Object invokeOperationInternal(String onameStr, String operation, String[] parameters) throws OperationsException, MBeanException, ReflectionException { ObjectName oname=new ObjectName( onameStr ); MBeanOperationInfo methodInfo = registry.getMethodInfo(oname,operation); MBeanParameterInfo[] signature = methodInfo.getSignature(); String[] signatureTypes = new String[signature.length]; Object[] values = new Object[signature.length]; for (int i = 0; i < signature.length; i++) { MBeanParameterInfo pi = signature[i]; signatureTypes[i] = pi.getType(); values[i] = registry.convertValue(pi.getType(), parameters[i] ); } return mBeanServer.invoke(oname,operation,values,signatureTypes); }
/** * Invokes an operation on an MBean. * * @param onameStr * The name of the MBean. * @param operation * The name of the operation to invoke. * @param parameters * An array of Strings containing the parameters to the * operation. They will be converted to the appropriate types to * call the requested operation. * @return The value returned by the requested operation. */ private Object invokeOperationInternal(String onameStr, String operation, String[] parameters) throws OperationsException, MBeanException, ReflectionException { ObjectName oname = new ObjectName(onameStr); MBeanOperationInfo methodInfo = registry.getMethodInfo(oname, operation); MBeanParameterInfo[] signature = methodInfo.getSignature(); String[] signatureTypes = new String[signature.length]; Object[] values = new Object[signature.length]; for (int i = 0; i < signature.length; i++) { MBeanParameterInfo pi = signature[i]; signatureTypes[i] = pi.getType(); values[i] = registry.convertValue(pi.getType(), parameters[i]); } return mBeanServer.invoke(oname, operation, values, signatureTypes); }
void setConnection(ActiveMQConnection connection) throws OperationsException, JMSException { this.session = (ActiveMQSession)connection.createSession(getUseTransaction(), Session.AUTO_ACKNOWLEDGE); if(destinationType == KahaDestination.DestinationType.TOPIC) { Topic topic = session.createTopic(java.lang.String.valueOf(destinationName)); if(hasSubscription()) { consumer = (ActiveMQMessageConsumer)session.createDurableSubscriber(topic, subscription.getSubscriptionName(), subscription.getMessageSelector(), subscription.getNoLocal()); showSubscribeAdded(); } else { consumer = (ActiveMQMessageConsumer)session.createConsumer(topic); } } else { Queue queue = session.createQueue(destinationName); consumer = (ActiveMQMessageConsumer)session.createConsumer(queue); } }
private void showJournalDestinationStatistics(JournalStatistic journalStatistic) throws OperationsException { showSeparator(); System.out.printf("Destination statistics:\r\n"); System.out.printf("- Topics: %s.\r\n", journalStatistic.getTopicCount()); System.out.printf("- Queues: %s.\r\n", journalStatistic.getQueueCount()); showCommandStatistics(journalStatistic.getTopicsDestinationStatistics()); showCommandStatistics(journalStatistic.getQueueDestinationStatistics()); DestinationStatistic[] otherDestinationStatistics = journalStatistic.getOtherDestinationStatistics(); if(otherDestinationStatistics.length != 0) { System.out.println(); System.out.printf("Commands without destination:\r\n"); showCommandStatistics(otherDestinationStatistics); } }
@SuppressWarnings("rawtypes") private void verifyGetMemberDetails(ObjectName wrapper, String memberId, boolean verifyGatewayDetails) throws AdminException, OperationsException, MBeanException, ReflectionException, IOException { logWriter.fine("Entered MemberInfoWithStatsMBeanDUnitTest.verifyGetMemberDetails() ..."); Map memberDetailsJMX = getMemberDetailsJMX(wrapper, memberId); Map memberDetailsDirect = getMemberDetailsDirect(memberId); verifyMemberDetails(memberDetailsJMX, memberDetailsDirect); if (verifyGatewayDetails) { verifyGatewayDetails(memberDetailsJMX, memberDetailsDirect); } else { verifyClientsDetails(memberDetailsJMX, memberDetailsDirect); verifyRegionsDetails(memberDetailsJMX, memberDetailsDirect); } logWriter.fine("Exited MemberInfoWithStatsMBeanDUnitTest.verifyGetMemberDetails() ..."); }
@Override @Deprecated public ObjectInputStream deserialize(ObjectName name, byte[] data) throws OperationsException { Throwable error = null; MBeanServerPlugin delegate = null; final boolean readOnly = true; try { delegate = findDelegate(name); //Special authorization authorizeClassloadingOperation(delegate, name, DESERIALIZE); return delegate.deserialize(name, data); } catch (Exception e) { error = e; if (e instanceof OperationsException) throw (OperationsException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).deserialize(name, data); } } }
@Override @Deprecated public ObjectInputStream deserialize(String className, byte[] data) throws OperationsException, ReflectionException { Throwable error = null; MBeanServerPlugin delegate = rootMBeanServer; final boolean readOnly = true; try { //Special authorization authorizeClassloadingOperation(delegate, DESERIALIZE); return delegate.deserialize(className, data); } catch (Exception e) { error = e; if (e instanceof OperationsException) throw (OperationsException)e; if (e instanceof ReflectionException) throw (ReflectionException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).deserialize(className, data); } } }
@Override @Deprecated public ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data) throws OperationsException, ReflectionException { Throwable error = null; MBeanServerPlugin delegate = rootMBeanServer; final boolean readOnly = true; try { //Special authorization authorizeClassloadingOperation(delegate, loaderName, DESERIALIZE); return delegate.deserialize(className, loaderName, data); } catch (Exception e) { error = e; if (e instanceof OperationsException) throw (OperationsException)e; if (e instanceof ReflectionException) throw (ReflectionException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).deserialize(className, loaderName, data); } } }
@Deprecated @Override public ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data) throws InstanceNotFoundException, OperationsException, ReflectionException { return mbs.deserialize(className, loaderName, data); }
/** * Sets an MBean attribute's value. */ private void setAttributeInternal(String onameStr, String attributeName, String value) throws OperationsException, MBeanException, ReflectionException { ObjectName oname=new ObjectName( onameStr ); String type=registry.getType(oname, attributeName); Object valueObj=registry.convertValue(type, value ); mBeanServer.setAttribute( oname, new Attribute(attributeName, valueObj)); }
/** * De-serializes a byte array in the context of a given MBean class loader. * The class loader is the one that loaded the class with name "className". * * @param className The name of the class whose class loader should be * used for the de-serialization. * @param data The byte array to be de-sererialized. * * @return The de-serialized object stream. * * @exception OperationsException Any of the usual Input/Output * related exceptions. * @exception ReflectionException The specified class could not be * loaded by the default loader repository * */ @Deprecated public ObjectInputStream deserialize(String className, byte[] data) throws OperationsException, ReflectionException { if (className == null) { throw new RuntimeOperationsException( new IllegalArgumentException(), "Null className passed in parameter"); } /* Permission check */ // This call requires MBeanPermission 'getClassLoaderRepository' final ClassLoaderRepository clr = getClassLoaderRepository(); Class<?> theClass; try { if (clr == null) throw new ClassNotFoundException(className); theClass = clr.loadClass(className); } catch (ClassNotFoundException e) { throw new ReflectionException(e, "The given class could not be " + "loaded by the default loader " + "repository"); } return instantiator.deserialize(theClass.getClassLoader(), data); }
/** * Call <code>checkRead()</code>, then forward this method to the * wrapped object. */ @Deprecated public ObjectInputStream deserialize(ObjectName name, byte[] data) throws InstanceNotFoundException, OperationsException { checkRead(); return getMBeanServer().deserialize(name, data); }
/** * Call <code>checkRead()</code>, then forward this method to the * wrapped object. */ @Deprecated public ObjectInputStream deserialize(String className, byte[] data) throws OperationsException, ReflectionException { checkRead(); return getMBeanServer().deserialize(className, data); }
/** * Call <code>checkRead()</code>, then forward this method to the * wrapped object. */ @Deprecated public ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data) throws InstanceNotFoundException, OperationsException, ReflectionException { checkRead(); return getMBeanServer().deserialize(className, loaderName, data); }
/** * Sets an MBean attribute's value. */ private void setAttributeInternal(String onameStr, String attributeName, String value) throws OperationsException, MBeanException, ReflectionException { ObjectName oname = new ObjectName(onameStr); String type = registry.getType(oname, attributeName); Object valueObj = registry.convertValue(type, value); mBeanServer.setAttribute(oname, new Attribute(attributeName, valueObj)); }
/** * De-serializes a byte array in the context of a classloader. * * @param loader the classloader to use for de-serialization * @param data The byte array to be de-sererialized. * * @return The de-serialized object stream. * * @exception OperationsException Any of the usual Input/Output related * exceptions. */ public ObjectInputStream deserialize(ClassLoader loader, byte[] data) throws OperationsException { // Check parameter validity if (data == null) { throw new RuntimeOperationsException(new IllegalArgumentException(), "Null data passed in parameter"); } if (data.length == 0) { throw new RuntimeOperationsException(new IllegalArgumentException(), "Empty data passed in parameter"); } // Object deserialization ByteArrayInputStream bIn; ObjectInputStream objIn; bIn = new ByteArrayInputStream(data); try { objIn = new ObjectInputStreamWithLoader(bIn,loader); } catch (IOException e) { throw new OperationsException( "An IOException occurred trying to de-serialize the data"); } return objIn; }
private void showJournalStatistic(JournalStatistic journalStatistic, int fileIndex) throws OperationsException { System.out.printf("(%s) Journal: '%s'.\r\n", fileIndex, journalStatistic.getFile()); if(journalStatistic.hasStatistic()) { showJournalDestinationStatistics(journalStatistic); showJournalCommandStatistics(journalStatistic); } showSeparator(2); }
private void showCommandStatistics(DestinationStatistic[] destinationStatistics) throws OperationsException { for (DestinationStatistic destinationStatistic : destinationStatistics) { CommandStatistic[] commandStatistics = destinationStatistic.getCommandStatistics(); if(destinationStatistic.hasDestinationId()) { System.out.println(); String destinationRemovedStr = destinationStatistic.hasRemoved() ? "- " : ""; String destinationInfo = getDestinationInfo(destinationStatistic.getDestinationType(), destinationStatistic.getDestinationId()); System.out.printf("%s%s.\r\n", destinationRemovedStr, destinationInfo); } showCommandStatistics(commandStatistics); } }
/** * Default Constructor * * @param agent Admin Agent instance * @throws OperationsException if ObjectName can't be formed for this MBean * @throws MBeanRegistrationException * @throws AdminException */ MemberInfoWithStatsMBean(Agent agent) throws OperationsException, MBeanRegistrationException, AdminException { this.agent = agent; this.logWriter = this.agent.getLogWriter().convertToLogWriterI18n(); this.objectName = ObjectName.getInstance(MBEAN_NAME); this.version = GemFireVersion.getGemFireVersion(); this.refreshInterval = -1; this.id = NOT_AVAILABLE_STR; this.forwarder = new NotificationForwarder(agent.getMBeanServer(), this.logWriter); }
/** * Connects the Admin Agent in the DS * * @return AdminDistributedSystem MBean ObjectName * @throws OperationsException * if connection to the DS fails * @throws AdminException * if connection to the DS fails */ private ObjectName connectToSystem() throws OperationsException, AdminException { ObjectName adminDsObjName = agent.connectToSystem(); AdminDistributedSystem adminDS = agent.getDistributedSystem(); if (adminDSJmx == null && adminDS instanceof AdminDistributedSystemJmxImpl) {//instanceof checks for null adminDSJmx = (AdminDistributedSystemJmxImpl) adminDS; refreshInterval = adminDSJmx.getRefreshInterval(); id = adminDSJmx.getId(); forwarder.registerNotificationListener(adminDSJmx.getObjectName()); } return adminDsObjName; }
/** * Initializes Cache, Regions & Statistics Types MBeans for the given Member. * * @param memberJmx * Member Mbean instance * @throws OperationsException * if fails to initialize required MBeans * @throws AdminException * if fails to initialize required MBeans */ private void initializeCacheRegionsAndStats(SystemMemberJmx memberJmx) throws OperationsException, AdminException { if (memberJmx != null) { SystemMemberCacheJmxImpl cache = (SystemMemberCacheJmxImpl) memberJmx.getCache(); if (cache != null) { RegionSubRegionSnapshot regionSnapshot = cache.getRegionSnapshot(); initializeRegionSubRegions(cache, regionSnapshot); } initStats(memberJmx); } }
@SuppressWarnings("rawtypes") private Map getMemberDetailsDirect(String memberId) throws OperationsException { logWriter.fine("Entered MemberInfoWithStatsMBeanDUnitTest.getMemberDetailsDirect() ..."); MemberInfoWithStatsMBean memberInfoWithStatsMBean = ((AgentImpl)agent).memberInfoWithStatsMBean; Map<String, Object> memberDetails = memberInfoWithStatsMBean.getMemberDetails(memberId); logWriter.fine("Exiting MemberInfoWithStatsMBeanDUnitTest.getMemberDetailsDirect() ..."); return memberDetails; }