Package org.apache.excalibur.instrument.manager

Examples of org.apache.excalibur.instrument.manager.InstrumentDescriptor


        }
    }
   
    private void assertInstrumentExists( String name )
    {
        InstrumentDescriptor descriptor =
            m_instrumentManager.locateInstrumentDescriptor( name );
        assertEquals( "Looked up instrument name incorrect.", descriptor.getName(), name );
    }
View Full Code Here


    {
        String name = getParameter( parameters, "name" );
        boolean packed = getBooleanParameter( parameters, "packed", false );
        boolean recurse = getBooleanParameter( parameters, "recurse", false );
       
        InstrumentDescriptor desc;
        try
        {
            desc = getInstrumentManager().locateInstrumentDescriptor( name );
        }
        catch ( NoSuchInstrumentException e )
View Full Code Here

        tableHeaderCell( out, "Name" );
        endTableHeaderRow( out );
       
        for ( int i = 0; i < descs.length; i++ )
        {
            InstrumentDescriptor desc = descs[i];
           
            startTableRow( out, i );
            tableCell( out, "<a href='instrument.html?name=" + urlEncode( desc.getName() ) + "'>"
                + desc.getDescription() + "</a>" );
            endTableRow( out );
        }
       
        endTable( out );
    }
View Full Code Here

                }
            }
           
            for ( int i = 0; i < instruments.length; i++ )
            {
                InstrumentDescriptor instrument = instruments[i];
                if ( recurse )
                {
                    outputInstrument( out, instrument, childIndent, recurse, packed );
                }
                else
View Full Code Here

                long interval = intervals[i];
                int size = sizes[i];
                long lease = leases[i];
                int type = types[i];
               
                InstrumentDescriptor desc;
                try
                {
                    desc = getInstrumentManager().locateInstrumentDescriptor( name );
                }
                catch ( NoSuchInstrumentException e )
                {
                    // Not found, ignore.
                    desc = null;
                }
               
                if ( desc != null )
                {
                    // The instrument manager will do its own tests of the lease, but the
                    //  restrictions on this connector may be stronger so they must be tested
                    //  here as well.
                    size = Math.max( 1, Math.min( size, getConnector().getMaxLeasedSampleSize() ) );
                    lease = Math.max(
                        1, Math.min( lease, getConnector().getMaxLeasedSampleLease() ) );
                   
                    if ( getInstrumentManager().getLeaseSampleCount()
                        >= getConnector().getMaxLeasedSamples() )
                    {
                        lease = 1;
                    }
                   
                    // Register the new lease
                    InstrumentSampleDescriptor sample;
                    try
                    {
                        sample =
                            desc.createInstrumentSample( description, interval, size, lease, type );
                    }
                    catch ( IllegalArgumentException e )
                    {
                        // The sample type is not valid.
                        throw new FileNotFoundException( e.getMessage() );
View Full Code Here

        int size = getIntegerParameter( parameters, "size" );
        long lease = getLongParameter( parameters, "lease" );
        int type = getIntegerParameter( parameters, "type" );
        boolean packed = getBooleanParameter( parameters, "packed", false );
       
        InstrumentDescriptor desc;
        try
        {
            desc = getInstrumentManager().locateInstrumentDescriptor( name );
        }
        catch ( NoSuchInstrumentException e )
        {
            throw new FileNotFoundException(
                "The specified instrument does not exist: " + name );
        }
       
        // The instrument manager will do its own tests of the lease, but the
        //  restrictions on this connector may be stronger so they must be tested
        //  here as well.
        size = Math.max( 1, Math.min( size, getConnector().getMaxLeasedSampleSize() ) );
        lease = Math.max( 1, Math.min( lease, getConnector().getMaxLeasedSampleLease() ) );
       
        if ( getInstrumentManager().getLeaseSampleCount() >= getConnector().getMaxLeasedSamples() )
        {
            lease = 1;
        }
       
        // Register the new lease
        InstrumentSampleDescriptor sample;
        try
        {
            sample = desc.createInstrumentSample( description, interval, size, lease, type );
        }
        catch ( IllegalArgumentException e )
        {
            // The sample type is not valid.
            throw new FileNotFoundException( e.getMessage() );
View Full Code Here

     */
    public void doGet( String path, Map parameters, PrintWriter out )
        throws IOException
    {
        String name = getParameter( parameters, "name" );
        InstrumentDescriptor desc;
        try
        {
            desc = getInstrumentManager().locateInstrumentDescriptor( name );
        }
        catch ( NoSuchInstrumentException e )
        {
            // Sample no longer exists, go back to the parent instrument.
            int pos = name.lastIndexOf( '.' );
            if ( pos >= 0 )
            {
                throw new HTTPRedirect(
                    "instrumentable.html?name=" + urlEncode( name.substring( 0,  pos ) ) );
            }
            else
            {
                throw new HTTPRedirect( "instrument-manager.html" );
            }
        }
       
        String type;
        StringBuffer types = new StringBuffer();
        types.append( "<select name='type' onKeyPress=\"javascript:fieldChanged()\">" );
        StringBuffer presets = new StringBuffer();
        presets.append( "<select name='preset' onChange=\"javascript:applyPreset(this.options[this.selectedIndex].value)\">" );
        presets.append( "<option value='0-0' selected>-- Select a Preset --</option>" );
        switch ( desc.getType() )
        {
        case DefaultInstrumentManager.INSTRUMENT_TYPE_COUNTER:
            type = "Counter";
            types.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_COUNTER
                + "' selected>Count</option>" );
           
            presets.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_COUNTER
                + "-0'>Count / Second Over 10 Minutes</option>" );
            presets.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_COUNTER
                + "-1'>Count / Minute Over 1 Day</option>" );
            presets.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_COUNTER
                + "-2'>Count / Hour Over 1 Month</option>" );
            break;
           
        case DefaultInstrumentManager.INSTRUMENT_TYPE_VALUE:
            type = "Value";
            types.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MAXIMUM
                + "' selected>Maximum Value</option>" );
            types.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MINIMUM
                + "'>Minimum Value</option>" );
            types.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MEAN
                + "'>Mean Value</option>" );
           
            presets.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MAXIMUM
                + "-0'>Max Value / Second Over 10 Minutes</option>" );
            presets.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MAXIMUM
                + "-1'>Max Value / Minute Over 1 Day</option>" );
            presets.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MAXIMUM
                + "-2'>Max Value / Hour Over 1 Month</option>" );
           
            presets.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MINIMUM
                + "-0'>Min Value / Second Over 10 Minutes</option>" );
            presets.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MINIMUM
                + "-1'>Min Value / Minute Over 1 Day</option>" );
            presets.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MINIMUM
                + "-2'>Min Value / Hour Over 1 Month</option>" );
           
            presets.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MEAN
                + "-0'>Mean Value / Second Over 10 Minutes</option>" );
            presets.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MEAN
                + "-1'>Mean Value / Minute Over 1 Day</option>" );
            presets.append( "<option value='"
                + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MEAN
                + "-2'>Mean Value / Hour Over 1 Month</option>" );
            break;
           
        default:
            type = "Unknown";
            break;
        }
        types.append( "</select>" );
        presets.append( "</select>" );
       
        out.println( "<html>" );
        out.println( "<head><title>" + desc.getDescription() + "</title></head>" );
        out.println( "<body>" );
       
        breadCrumbs( out, desc, false );
       
        out.println( "<h2>Instrument</h2>" );
        startTable( out );
        tableRow( out, 0, "Name", desc.getName() );
        tableRow( out, 0, "Description", desc.getDescription() );
        tableRow( out, 0, "Type", type );
        endTable( out );
       
        InstrumentSampleDescriptor[] samples = desc.getInstrumentSampleDescriptors();
        if ( samples.length > 0 )
        {
            out.println( "<h2>Registered Samples</h2>" );
            outputInstrumentSamples( out, samples, getConnector().isReadOnly() );
        }
       
        if ( !getConnector().isReadOnly() )
        {
            out.println( "<h2>Register Sample</h2>" );
            out.println( "<SCRIPT LANGUAGE=\"JavaScript\">" );
            out.println( "function fieldChanged() {" );
            out.println( "  var form = document.forms[0];" );
            out.println( "  form.preset.value=\"0-0\";" );
            out.println( "}" );
            out.println( "function applyPreset(preset) {" );
            out.println( "  var form = document.forms[0];" );
            out.println( "  var pos = preset.indexOf('-');" );
            out.println( "  var type = preset.substring(0, pos);" );
            out.println( "  var spec = preset.substring(pos + 1);" );
            out.println( "  var prefix;" );
            out.println( "  if (type == 0) {" );
            out.println( "    return;" );
            out.println( "  } else if (type == " + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_COUNTER + ") {" );
            out.println( "    typeLbl = \"Count\"" );
            out.println( "  } else if (type == " + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MAXIMUM + ") {" );
            out.println( "    typeLbl = \"Max Value\"" );
            out.println( "  } else if (type == " + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MINIMUM + ") {" );
            out.println( "    typeLbl = \"Min Value\"" );
            out.println( "  } else if (type == " + DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MEAN + ") {" );
            out.println( "    typeLbl = \"Mean Value\"" );
            out.println( "  } else {" );
            out.println( "    typeLbl = \"Unknown\"" );
            out.println( "  }" );
            out.println( "  var intervalLbl;" );
            out.println( "  var interval;" );
            out.println( "  var size;" );
            out.println( "  var lease;" );
            out.println( "  if (spec == 1) {" );
            out.println( "    intervalLbl = \"Minute\";" );
            out.println( "    interval = 60000;" );
            out.println( "    size = 1440;" );
            out.println( "    lease = 86400000;" );
            out.println( "  } else if (spec == 2) {" );
            out.println( "    intervalLbl = \"Hour\";" );
            out.println( "    interval = 3600000;" );
            out.println( "    size = 672;" );
            out.println( "    lease = 86400000;" );
            out.println( "  } else {" );
            out.println( "    intervalLbl = \"Second\";" );
            out.println( "    interval = 1000;" );
            out.println( "    size = 600;" );
            out.println( "    lease = 600000;" );
            out.println( "  }" );
            out.println( "  form.description.value = typeLbl + \" / \" + intervalLbl;" );
            out.println( "  form.interval.value = interval;" );
            out.println( "  form.size.value = size;" );
            out.println( "  form.lease.value = lease;" );
            out.println( "  form.type.value = type;" );
            out.println( "}" );
            out.println( "</SCRIPT>" );
   
            out.println( "<form action='create-sample.html' method='GET' accept-charset='UTF-8'>" );
            startTable( out );
            tableRow( out, 0, "Description", "<input name='description' type='text' size='40' value='' onKeyPress=\"javascript:fieldChanged()\">" );
            tableRow( out, 0, "Interval (ms.)", "<input name='interval' type='text' size='10' value='' onKeyPress=\"javascript:fieldChanged()\">" );
            tableRow( out, 0, "Size", "<input name='size' type='text' size='10' value='' onKeyPress=\"javascript:fieldChanged()\">" );
            tableRow( out, 0, "Lease (ms.)", "<input name='lease' type='text' size='10' value='' onKeyPress=\"javascript:fieldChanged()\">" );
            tableRow( out, 0, "Type", types.toString() );
            tableRow( out, 0, "Presets", presets.toString() );
            endTable( out );
            out.println( "<input type='hidden' name='name' value='" + desc.getName() + "'>" );
            out.println( "<input type='submit' value='Submit'>" );
           
            out.println( "</form>" );
        }
       
View Full Code Here

        long interval = getLongParameter( parameters, "interval" );
        int size = getIntegerParameter( parameters, "size" );
        long lease = getLongParameter( parameters, "lease" );
        int type = getIntegerParameter( parameters, "type" );
       
        InstrumentDescriptor desc;
        try
        {
            desc = getInstrumentManager().locateInstrumentDescriptor( name );
        }
        catch ( NoSuchInstrumentException e )
        {
            // Sample no longer exists, go back to the parent instrument.
            int pos = name.lastIndexOf( '.' );
            if ( pos >= 0 )
            {
                throw new HTTPRedirect(
                    "instrumentable.html?name=" + urlEncode( name.substring( 0,  pos ) ) );
            }
            else
            {
                throw new HTTPRedirect( "instrument-manager.html" );
            }
        }
       
        // The instrument manager will do its own tests of the lease, but the
        //  restrictions on this connector may be stronger so they must be tested
        //  here as well.
        size = Math.max( 1, Math.min( size, getConnector().getMaxLeasedSampleSize() ) );
        lease = Math.max( 1, Math.min( lease, getConnector().getMaxLeasedSampleLease() ) );
       
        if ( getInstrumentManager().getLeaseSampleCount() >= getConnector().getMaxLeasedSamples() )
        {
            lease = 1;
        }
       
        // Register the new lease
        InstrumentSampleDescriptor sample;
        try
        {
            sample = desc.createInstrumentSample( description, interval, size, lease, type );
        }
        catch ( IllegalArgumentException e )
        {
            // The sample type is not valid.
            throw new FileNotFoundException( e.getMessage() );
View Full Code Here

        long interval = getLongParameter( parameters, "interval" );
        int size = getIntegerParameter( parameters, "size" );
        long lease = getLongParameter( parameters, "lease" );
        int type = getIntegerParameter( parameters, "type" );
       
        InstrumentDescriptor desc;
        try
        {
            desc = getInstrumentManager().locateInstrumentDescriptor( name );
        }
        catch ( NoSuchInstrumentException e )
        {
            // Sample no longer exists, go back to the parent instrument.
            int pos = name.lastIndexOf( '.' );
            if ( pos >= 0 )
            {
                throw new HTTPRedirect(
                    "instrumentable.html?name=" + urlEncode( name.substring( 0,  pos ) ) );
            }
            else
            {
                throw new HTTPRedirect( "instrument-manager.html" );
            }
        }
       
        // The instrument manager will do its own tests of the lease, but the
        //  restrictions on this connector may be stronger so they must be tested
        //  here as well.
        size = Math.max( 1, Math.min( size, m_connector.getMaxLeasedSampleSize() ) );
        lease = Math.max( 1, Math.min( lease, m_connector.getMaxLeasedSampleLease() ) );
       
        if ( getInstrumentManager().getLeaseSampleCount() >= m_connector.getMaxLeasedSamples() )
        {
            lease = 1;
        }
       
        // Register the new lease
        InstrumentSampleDescriptor sample;
        try
        {
            sample = desc.createInstrumentSample( description, interval, size, lease, type );
        }
        catch ( IllegalArgumentException e )
        {
            // The sample type is not valid.
            throw new FileNotFoundException( e.getMessage() );
View Full Code Here

                }
            }
           
            for ( int i = 0; i < instruments.length; i++ )
            {
                InstrumentDescriptor instrument = instruments[i];
                if ( recurse )
                {
                    outputInstrument( out, instrument, childIndent, recurse, packed );
                }
                else
View Full Code Here

TOP

Related Classes of org.apache.excalibur.instrument.manager.InstrumentDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.