Ejemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.collection.RawIterator<Object[], org.neo4j.internal.kernel.api.exceptions.ProcedureException> apply(org.neo4j.kernel.api.proc.Context ctx, Object[] input, org.neo4j.kernel.api.ResourceTracker resourceTracker) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public override RawIterator <object[], ProcedureException> Apply(Context ctx, object[] input, ResourceTracker resourceTracker)
        {
            string query = input[0].ToString();

            try
            {
                // Find all beans that match the query name pattern
                IEnumerator <ObjectName> names = _jmxServer.queryNames(new ObjectName(query), null).GetEnumerator();

                // Then convert them to a Neo4j type system representation
                return(RawIterator.from(() =>
                {
                    if (!names.hasNext())
                    {
                        return null;
                    }

                    ObjectName name = names.next();
                    try
                    {
                        MBeanInfo beanInfo = _jmxServer.getMBeanInfo(name);
                        return new object[] { name.CanonicalName, beanInfo.Description, ToNeo4jValue(name, beanInfo.Attributes) };
                    }
                    catch (JMException e)
                    {
                        throw new ProcedureException(Status.General.UnknownError, e, "JMX error while accessing `%s`, please report this. Message was: %s", name, e.Message);
                    }
                }));
            }
            catch (MalformedObjectNameException)
            {
                throw new ProcedureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Procedure.ProcedureCallFailed, "'%s' is an invalid JMX name pattern. Valid queries should use" + "the syntax outlined in the javax.management.ObjectName API documentation." + "For instance, try 'org.neo4j:*' to find all JMX beans of the 'org.neo4j' " + "domain, or '*:*' to find every JMX bean.", query);
            }
        }