diff --git a/commons/nrjmx.thrift b/commons/nrjmx.thrift index dc3690a..75747f9 100644 --- a/commons/nrjmx.thrift +++ b/commons/nrjmx.thrift @@ -1,7 +1,7 @@ namespace java org.newrelic.nrjmx.v2.nrprotocol struct JMXConfig { - 1: string connectionURL + 1: string connectionURL, 2: string hostname, 3: i32 port, 4: optional string uriPath, @@ -12,10 +12,12 @@ struct JMXConfig { 9: string trustStore, 10: string trustStorePassword, 11: bool isRemote, - 12: bool isJBossStandaloneMode - 13: bool useSSL - 14: i64 requestTimeoutMs - 15: bool verbose + 12: bool isJBossStandaloneMode, + 13: bool useSSL, + 14: i64 requestTimeoutMs, + 15: bool verbose, + 16: bool enableInternalStats, + 17: i64 maxInternalStatsSize } enum ResponseType { @@ -36,6 +38,16 @@ struct AttributeResponse { 7: bool boolValue } +struct InternalStat { + 1: string statType, + 2: string mBean, + 3: list attrs, + 4: i64 responseCount, + 5: double milliseconds, + 6: i64 startTimestamp, + 7: bool successful +} + exception JMXError { 1: string message, 2: string causeMessage @@ -59,5 +71,7 @@ service JMXService { list getMBeanAttributes(1:string mBeanName, 2:list attributes) throws (1:JMXConnectionError connErr, 2:JMXError jmxErr), - list queryMBeanAttributes(1:string mBeanNamePattern, 2:list attributes) throws (1:JMXConnectionError connErr, 2:JMXError jmxErr) + list queryMBeanAttributes(1:string mBeanNamePattern, 2:list attributes) throws (1:JMXConnectionError connErr, 2:JMXError jmxErr), + + list getInternalStats() throws (1:JMXError jmxErr) } \ No newline at end of file diff --git a/gojmx/README.md b/gojmx/README.md index 7a4c99c..c9bf4ce 100644 --- a/gojmx/README.md +++ b/gojmx/README.md @@ -87,3 +87,40 @@ JMX allows the use of custom connectors to communicate with the application. In By default, the sub-folder connectors is in the classpath. If this folder does not exist, create it under the folder where nrjmx is installed. For example, to add support for JBoss, create a folder named connectors under the default (Linux) library path /usr/lib/nrjmx/ (/usr/lib/nrjmx/connectors/) and copy the custom connector jar ($JBOSS_HOME/bin/client/jboss-cli-client.jar) into it. You can now execute JMX queries against JBoss. + +# Internal nrjmx query stats +If `InternalStats` feature is enabled (gojmx.JMXConfig.EnableInternalStats = true), the `nrjmx` java subprocess will collect +information about each JMX request. This feature can be used to give more insights while troubleshooting performance issues. + +The `InternalStats` are collected in memory (up to 10000 samples by default). When the maximum limit is reached, old samples +will be discarded. You can increase the maximum limit using `gojmx.JMXConfig.MaxInternalStatsSize` config option. +After the stats are retrieved (using `client.GetInternalStats()`) `nrjmx` java subprocess will clean the sample storage. + +e.g.: + +```go + // JMX Client configuration. + config := &gojmx.JMXConfig{ + Hostname: "localhost", + Port: 7199, + + // Enable internal gojmx stats for troubleshooting. + EnableInternalStats: true, + } + + // Connect to JMX endpoint. + client, err := gojmx.NewClient(context.Background()).Open(config) + handleError(err) + + defer client.Close() + + ... queries ... + + // Collecting gojmx internal query stats. Use this only for troubleshooting. + internalStats, err := client.GetInternalStats() + handleError(err) + + for _, internalStat := range internalStats { + fmt.Println(internalStat.String()) + } +``` \ No newline at end of file diff --git a/gojmx/examples/main.go b/gojmx/examples/main.go index fc7c770..a69ce07 100644 --- a/gojmx/examples/main.go +++ b/gojmx/examples/main.go @@ -16,7 +16,7 @@ import ( func init() { // Uncomment this when you want use the nrjmx.jar build from the project bin directory. - _ = os.Setenv("NR_JMX_TOOL", filepath.Join("..", "bin", "nrjmx")) + _ = os.Setenv("NR_JMX_TOOL", filepath.Join("../../", "bin", "nrjmx")) // Uncomment this when you want to run both: golang debugger and java debugger. //_ = os.Setenv("NRIA_NRJMX_DEBUG", "true") @@ -28,6 +28,9 @@ func main() { Hostname: "localhost", Port: 7199, RequestTimeoutMs: 10000, + + // Enable internal gojmx stats for troubleshooting. + EnableInternalStats: true, } // Connect to JMX endpoint. @@ -53,7 +56,7 @@ func main() { } for _, attr := range jmxAttrs { if attr.ResponseType == gojmx.ResponseTypeErr { - fmt.Println(attr.StatusMsg) + fmt.Println(attr.Name, attr.StatusMsg) continue } printAttr(attr) @@ -67,11 +70,19 @@ func main() { handleError(err) for _, attr := range response { if attr.ResponseType == gojmx.ResponseTypeErr { - fmt.Println(attr.StatusMsg) + fmt.Println(attr.Name, attr.StatusMsg) continue } printAttr(attr) } + + // Collecting gojmx internal query stats. Use this only for troubleshooting. + internalStats, err := client.GetInternalStats() + handleError(err) + + for _, internalStat := range internalStats { + fmt.Println(internalStat.String()) + } } func printAttr(jmxAttr *gojmx.AttributeResponse) { diff --git a/gojmx/gojmx.go b/gojmx/gojmx.go index f73ee8e..c4743c2 100644 --- a/gojmx/gojmx.go +++ b/gojmx/gojmx.go @@ -24,9 +24,6 @@ const ( unknownNRJMXVersion = "" ) -// errPingTimeout returned if pingTimeout exceeded. -var errPingTimeout = newJMXConnectionError("could not establish communication with nrjmx process: ping timeout") - // Client to connect with a JMX endpoint. type Client struct { // jmxService is the thrift implementation to communicate with nrjmx subprocess. @@ -52,29 +49,42 @@ func (c *Client) Open(config *JMXConfig) (client *Client, err error) { return c, err } - defer func() { - if err != nil { - c.Close() - } - }() - c.jmxService, err = c.configureJMXServiceClient() if err != nil { + c.nrJMXProcess.waitExit(nrJMXExitTimeout) return c, err } c.version, err = c.ping(pingTimeout) if err != nil { + c.nrJMXProcess.waitExit(nrJMXExitTimeout) return c, err } return c, c.connect(config) } +// IsClientRunning returns if the nrjmx client is running. +func (c *Client) IsRunning() bool { + if c.nrJMXProcess == nil { + return false + } + + return c.nrJMXProcess.state.IsRunning() +} + +// checkNRJMXProccessError will check if the nrjmx subprocess returned any error. +func (c *Client) checkNRJMXProccessError() error { + if c.nrJMXProcess == nil { + return errProcessNotRunning + } + return c.nrJMXProcess.error() +} + // QueryMBeanNames returns all the mbeans that match the glob pattern DOMAIN:BEAN. // e.g *:* or jboss.as:subsystem=remoting,configuration=endpoint func (c *Client) QueryMBeanNames(mBeanGlobPattern string) ([]string, error) { - if err := c.nrJMXProcess.error(); err != nil { + if err := c.checkNRJMXProccessError(); err != nil { return nil, err } result, err := c.jmxService.QueryMBeanNames(c.ctx, mBeanGlobPattern) @@ -84,7 +94,7 @@ func (c *Client) QueryMBeanNames(mBeanGlobPattern string) ([]string, error) { // GetMBeanAttributeNames returns all the available JMX attribute names for a given mBeanName. func (c *Client) GetMBeanAttributeNames(mBeanName string) ([]string, error) { - if err := c.nrJMXProcess.error(); err != nil { + if err := c.checkNRJMXProccessError(); err != nil { return nil, err } result, err := c.jmxService.GetMBeanAttributeNames(c.ctx, mBeanName) @@ -93,7 +103,7 @@ func (c *Client) GetMBeanAttributeNames(mBeanName string) ([]string, error) { // GetMBeanAttributes returns the JMX attribute values. func (c *Client) GetMBeanAttributes(mBeanName string, mBeanAttrName ...string) ([]*AttributeResponse, error) { - if err := c.nrJMXProcess.error(); err != nil { + if err := c.checkNRJMXProccessError(); err != nil { return nil, err } @@ -103,7 +113,7 @@ func (c *Client) GetMBeanAttributes(mBeanName string, mBeanAttrName ...string) ( // Close will stop the connection with the JMX endpoint. func (c *Client) Close() error { - if err := c.nrJMXProcess.error(); err != nil { + if err := c.checkNRJMXProccessError(); err != nil { return err } c.jmxService.Disconnect(c.ctx) @@ -124,7 +134,7 @@ func (c *Client) GetClientVersion() string { // 3. GetMBeanAttributes // If an error occur it checks if it's a collection error (it can recover) or a connection error (that blocks all the collection). func (c *Client) QueryMBeanAttributes(mBeanNamePattern string, mBeanAttrName ...string) ([]*AttributeResponse, error) { - if err := c.nrJMXProcess.error(); err != nil { + if err := c.checkNRJMXProccessError(); err != nil { return nil, err } @@ -132,10 +142,23 @@ func (c *Client) QueryMBeanAttributes(mBeanNamePattern string, mBeanAttrName ... return toAttributeResponseList(result), c.handleError(err) } +// GetInternalStats returns the nrjmx internal query statistics for troubleshooting. +// Internal statistics must be enabled using JMXConfig.EnableInternalStats flag. +// Additionally you can set a maximum size for the collected stats using JMXConfig.MaxInternalStatsSize. (default: 100000) +// Each time you retrieve GetInternalStats, the internal stats will be cleaned. +func (c *Client) GetInternalStats() ([]*InternalStat, error) { + if err := c.checkNRJMXProccessError(); err != nil { + return nil, err + } + result, err := c.jmxService.GetInternalStats(c.ctx) + + return toInternalStatList(result), c.handleError(err) +} + // connect will pass the JMXConfig to nrjmx subprocess and establish the // connection with the JMX endpoint. func (c *Client) connect(config *JMXConfig) (err error) { - if err = c.nrJMXProcess.error(); err != nil { + if err = c.checkNRJMXProccessError(); err != nil { return err } err = c.jmxService.Connect(c.ctx, config.convertToProtocol()) @@ -147,6 +170,7 @@ func (c *Client) connect(config *JMXConfig) (err error) { func (c *Client) ping(timeout time.Duration) (string, error) { ctx, cancel := context.WithCancel(c.ctx) defer cancel() + done := make(chan string, 1) go func() { for ctx.Err() == nil { @@ -158,6 +182,7 @@ func (c *Client) ping(timeout time.Duration) (string, error) { break } }() + select { case <-time.After(timeout): return "", errPingTimeout diff --git a/gojmx/gojmx_test.go b/gojmx/gojmx_test.go index 1c69087..b8408ee 100644 --- a/gojmx/gojmx_test.go +++ b/gojmx/gojmx_test.go @@ -27,7 +27,7 @@ var timeStamp = time.Date(2022, time.January, 1, 01, 23, 45, 0, time.Local).Unix func init() { _ = os.Setenv("NR_JMX_TOOL", filepath.Join(testutils.PrjDir, "bin", "nrjmx")) - //_ = os.Setenv("NRIA_NRJMX_DEBUG", "true") + // _ = os.Setenv("NRIA_NRJMX_DEBUG", "true") } func Test_Query_Success_LargeAmountOfData(t *testing.T) { @@ -399,7 +399,7 @@ func Test_Query_Timeout(t *testing.T) { client, err := NewClient(ctx).Open(config) assert.NotNil(t, client) assert.Error(t, err) - defer assertCloseClientError(t, client) + defer assertCloseClientNoError(t, client) // AND Query returns expected error actual, err := client.GetMBeanAttributeNames("*:*") @@ -516,7 +516,7 @@ func Test_Wrong_Connection(t *testing.T) { client, err := NewClient(ctx).Open(config) assert.Error(t, err) assert.Contains(t, err.Error(), "Connection refused to host: localhost;") - defer assertCloseClientError(t, client) + defer assertCloseClientNoError(t, client) // AND query returns expected error assert.Contains(t, err.Error(), "Connection refused to host: localhost;") // TODO: fix this, doesn't return the correct error @@ -610,7 +610,7 @@ func Test_Wrong_Credentials(t *testing.T) { client, err := NewClient(ctx).Open(config) assert.Error(t, err) assert.Contains(t, err.Error(), "Authentication failed! Invalid username or password") - defer assertCloseClientError(t, client) + defer assertCloseClientNoError(t, client) // AND Query returns expected error actual, err := client.QueryMBeanNames("test:type=Cat,*") @@ -646,7 +646,7 @@ func Test_Wrong_Certificate_password(t *testing.T) { client, err := NewClient(ctx).Open(config) assert.Error(t, err) assert.Contains(t, err.Error(), "SSLContext") - defer assertCloseClientError(t, client) + defer assertCloseClientNoError(t, client) // AND Query returns expected error actual, err := client.QueryMBeanNames("test:type=Cat,*") @@ -854,6 +854,139 @@ func TestClientClose(t *testing.T) { assert.True(t, client.nrJMXProcess.getOSProcessState().Success()) } +func TestGetInternalStats(t *testing.T) { + ctx := context.Background() + + // GIVEN a JMX Server running inside a container + container, err := testutils.RunJMXServiceContainer(ctx) + require.NoError(t, err) + defer container.Terminate(ctx) + + var data []map[string]interface{} + + name := strings.Repeat("tomas", 100) + + for i := 0; i < 1500; i++ { + data = append(data, map[string]interface{}{ + "name": fmt.Sprintf("%s-%d", name, i), + "doubleValue": 1.2, + "floatValue": 2.2, + "numberValue": 3, + "boolValue": true, + "dateValue": timeStamp, + }) + } + + // Populate the JMX Server with mbeans + resp, err := testutils.AddMBeansBatch(ctx, container, data) + assert.NoError(t, err) + assert.Equal(t, "ok!\n", string(resp)) + + defer testutils.CleanMBeans(ctx, container) + + jmxHost, jmxPort, err := testutils.GetContainerMappedPort(ctx, container, testutils.TestServerJMXPort) + require.NoError(t, err) + + // THEN JMX connection can be oppened + config := &JMXConfig{ + Hostname: jmxHost, + Port: int32(jmxPort.Int()), + EnableInternalStats: true, + MaxInternalStatsSize: 3000, // We expect 3002 stats. With MaxInternalStatsSize we test the limit. + } + client, err := NewClient(ctx).Open(config) + assert.NoError(t, err) + defer assertCloseClientNoError(t, client) + + _, err = client.QueryMBeanAttributes("test:type=Cat,*") + assert.NoError(t, err) + + // AND query generates the expected internal stats + internalStats, err := client.GetInternalStats() + assert.NoError(t, err) + + totalCalls := 0 + totalObjects := 0 + totalTimeMs := 0 + totalAttrs := 0 + totalSucessful := 0 + + for _, stat := range internalStats { + totalCalls++ + totalObjects += int(stat.ResponseCount) + totalTimeMs += int(stat.Milliseconds) + totalAttrs += len(stat.Attrs) + + if stat.Successful { + totalSucessful++ + } + } + + assert.Equal(t, 3000, totalCalls) + assert.Equal(t, 18000, totalObjects) + assert.True(t, totalTimeMs > 0) + assert.Equal(t, 9000, totalAttrs) + assert.Equal(t, 3000, totalSucessful) + + // AND internal stats get cleaned + internalStats, err = client.GetInternalStats() + assert.NoError(t, err) + assert.True(t, len(internalStats) == 0) +} + +func TestConnectionRecovers(t *testing.T) { + ctx := context.Background() + + // GIVEN a JMX Server running inside a container + container, err := testutils.RunJMXServiceContainer(ctx) + require.NoError(t, err) + + jmxHost, jmxPort, err := testutils.GetContainerMappedPort(ctx, container, testutils.TestServerJMXPort) + require.NoError(t, err) + + // THEN JMX connection can be opened. + config := &JMXConfig{ + Hostname: jmxHost, + Port: int32(jmxPort.Int()), + RequestTimeoutMs: 5000, + EnableInternalStats: true, + } + + query := "java.lang:type=*" + + client, err := NewClient(ctx).Open(config) + assert.NoError(t, err) + defer assertCloseClientNoError(t, client) + + res, err := client.QueryMBeanNames(query) + assert.NoError(t, err) + assert.NotEmpty(t, res) + + assert.NoError(t, container.Terminate(ctx)) + + res, err = client.QueryMBeanNames(query) + assert.Nil(t, res) + assert.Error(t, err) + + _, ok := IsJMXClientError(err) + assert.False(t, ok) + assert.True(t, client.IsRunning()) + + assert.Eventually(t, func() bool { + container, err = testutils.RunJMXServiceContainer(ctx) + return err == nil + }, 200*time.Second, 50*time.Millisecond, + "didn't managed to restart the container") + + defer container.Terminate(ctx) + + assert.Eventually(t, func() bool { + _, err = client.QueryMBeanNames(query) + return err == nil + }, 20*time.Second, 50*time.Millisecond, + "didn't managed to recover connection") +} + func TestProcessExits(t *testing.T) { ctx := context.Background() diff --git a/gojmx/internal/nrprotocol/j_m_x_service-remote/j_m_x_service-remote.go b/gojmx/internal/nrprotocol/j_m_x_service-remote/j_m_x_service-remote.go index fdfe5b3..2bca946 100755 --- a/gojmx/internal/nrprotocol/j_m_x_service-remote/j_m_x_service-remote.go +++ b/gojmx/internal/nrprotocol/j_m_x_service-remote/j_m_x_service-remote.go @@ -29,6 +29,7 @@ func Usage() { fmt.Fprintln(os.Stderr, " getMBeanAttributeNames(string mBeanName)") fmt.Fprintln(os.Stderr, " getMBeanAttributes(string mBeanName, attributes)") fmt.Fprintln(os.Stderr, " queryMBeanAttributes(string mBeanNamePattern, attributes)") + fmt.Fprintln(os.Stderr, " getInternalStats()") fmt.Fprintln(os.Stderr) os.Exit(0) } @@ -156,19 +157,19 @@ func main() { fmt.Fprintln(os.Stderr, "Connect requires 1 args") flag.Usage() } - arg29 := flag.Arg(1) - mbTrans30 := thrift.NewTMemoryBufferLen(len(arg29)) - defer mbTrans30.Close() - _, err31 := mbTrans30.WriteString(arg29) - if err31 != nil { + arg35 := flag.Arg(1) + mbTrans36 := thrift.NewTMemoryBufferLen(len(arg35)) + defer mbTrans36.Close() + _, err37 := mbTrans36.WriteString(arg35) + if err37 != nil { Usage() return } - factory32 := thrift.NewTJSONProtocolFactory() - jsProt33 := factory32.GetProtocol(mbTrans30) + factory38 := thrift.NewTJSONProtocolFactory() + jsProt39 := factory38.GetProtocol(mbTrans36) argvalue0 := nrprotocol.NewJMXConfig() - err34 := argvalue0.Read(context.Background(), jsProt33) - if err34 != nil { + err40 := argvalue0.Read(context.Background(), jsProt39) + if err40 != nil { Usage() return } @@ -219,19 +220,19 @@ func main() { } argvalue0 := flag.Arg(1) value0 := argvalue0 - arg38 := flag.Arg(2) - mbTrans39 := thrift.NewTMemoryBufferLen(len(arg38)) - defer mbTrans39.Close() - _, err40 := mbTrans39.WriteString(arg38) - if err40 != nil { + arg44 := flag.Arg(2) + mbTrans45 := thrift.NewTMemoryBufferLen(len(arg44)) + defer mbTrans45.Close() + _, err46 := mbTrans45.WriteString(arg44) + if err46 != nil { Usage() return } - factory41 := thrift.NewTJSONProtocolFactory() - jsProt42 := factory41.GetProtocol(mbTrans39) + factory47 := thrift.NewTJSONProtocolFactory() + jsProt48 := factory47.GetProtocol(mbTrans45) containerStruct1 := nrprotocol.NewJMXServiceGetMBeanAttributesArgs() - err43 := containerStruct1.ReadField2(context.Background(), jsProt42) - if err43 != nil { + err49 := containerStruct1.ReadField2(context.Background(), jsProt48) + if err49 != nil { Usage() return } @@ -247,19 +248,19 @@ func main() { } argvalue0 := flag.Arg(1) value0 := argvalue0 - arg45 := flag.Arg(2) - mbTrans46 := thrift.NewTMemoryBufferLen(len(arg45)) - defer mbTrans46.Close() - _, err47 := mbTrans46.WriteString(arg45) - if err47 != nil { + arg51 := flag.Arg(2) + mbTrans52 := thrift.NewTMemoryBufferLen(len(arg51)) + defer mbTrans52.Close() + _, err53 := mbTrans52.WriteString(arg51) + if err53 != nil { Usage() return } - factory48 := thrift.NewTJSONProtocolFactory() - jsProt49 := factory48.GetProtocol(mbTrans46) + factory54 := thrift.NewTJSONProtocolFactory() + jsProt55 := factory54.GetProtocol(mbTrans52) containerStruct1 := nrprotocol.NewJMXServiceQueryMBeanAttributesArgs() - err50 := containerStruct1.ReadField2(context.Background(), jsProt49) - if err50 != nil { + err56 := containerStruct1.ReadField2(context.Background(), jsProt55) + if err56 != nil { Usage() return } @@ -268,6 +269,14 @@ func main() { fmt.Print(client.QueryMBeanAttributes(context.Background(), value0, value1)) fmt.Print("\n") break + case "getInternalStats": + if flag.NArg() - 1 != 0 { + fmt.Fprintln(os.Stderr, "GetInternalStats requires 0 args") + flag.Usage() + } + fmt.Print(client.GetInternalStats(context.Background())) + fmt.Print("\n") + break case "": Usage() break diff --git a/gojmx/internal/nrprotocol/nrjmx.go b/gojmx/internal/nrprotocol/nrjmx.go index a5ba9de..760418b 100644 --- a/gojmx/internal/nrprotocol/nrjmx.go +++ b/gojmx/internal/nrprotocol/nrjmx.go @@ -97,6 +97,8 @@ return int64(*p), nil // - UseSSL // - RequestTimeoutMs // - Verbose +// - EnableInternalStats +// - MaxInternalStatsSize type JMXConfig struct { ConnectionURL string `thrift:"connectionURL,1" db:"connectionURL" json:"connectionURL"` Hostname string `thrift:"hostname,2" db:"hostname" json:"hostname"` @@ -113,6 +115,8 @@ type JMXConfig struct { UseSSL bool `thrift:"useSSL,13" db:"useSSL" json:"useSSL"` RequestTimeoutMs int64 `thrift:"requestTimeoutMs,14" db:"requestTimeoutMs" json:"requestTimeoutMs"` Verbose bool `thrift:"verbose,15" db:"verbose" json:"verbose"` + EnableInternalStats bool `thrift:"enableInternalStats,16" db:"enableInternalStats" json:"enableInternalStats"` + MaxInternalStatsSize int64 `thrift:"maxInternalStatsSize,17" db:"maxInternalStatsSize" json:"maxInternalStatsSize"` } func NewJMXConfig() *JMXConfig { @@ -182,6 +186,14 @@ func (p *JMXConfig) GetRequestTimeoutMs() int64 { func (p *JMXConfig) GetVerbose() bool { return p.Verbose } + +func (p *JMXConfig) GetEnableInternalStats() bool { + return p.EnableInternalStats +} + +func (p *JMXConfig) GetMaxInternalStatsSize() int64 { + return p.MaxInternalStatsSize +} func (p *JMXConfig) IsSetUriPath() bool { return p.UriPath != nil } @@ -349,6 +361,26 @@ func (p *JMXConfig) Read(ctx context.Context, iprot thrift.TProtocol) error { return err } } + case 16: + if fieldTypeId == thrift.BOOL { + if err := p.ReadField16(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 17: + if fieldTypeId == thrift.I64 { + if err := p.ReadField17(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } default: if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err @@ -499,6 +531,24 @@ func (p *JMXConfig) ReadField15(ctx context.Context, iprot thrift.TProtocol) er return nil } +func (p *JMXConfig) ReadField16(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { + return thrift.PrependError("error reading field 16: ", err) +} else { + p.EnableInternalStats = v +} + return nil +} + +func (p *JMXConfig) ReadField17(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 17: ", err) +} else { + p.MaxInternalStatsSize = v +} + return nil +} + func (p *JMXConfig) Write(ctx context.Context, oprot thrift.TProtocol) error { if err := oprot.WriteStructBegin(ctx, "JMXConfig"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } @@ -518,6 +568,8 @@ func (p *JMXConfig) Write(ctx context.Context, oprot thrift.TProtocol) error { if err := p.writeField13(ctx, oprot); err != nil { return err } if err := p.writeField14(ctx, oprot); err != nil { return err } if err := p.writeField15(ctx, oprot); err != nil { return err } + if err := p.writeField16(ctx, oprot); err != nil { return err } + if err := p.writeField17(ctx, oprot); err != nil { return err } } if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } @@ -678,6 +730,26 @@ func (p *JMXConfig) writeField15(ctx context.Context, oprot thrift.TProtocol) (e return err } +func (p *JMXConfig) writeField16(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "enableInternalStats", thrift.BOOL, 16); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 16:enableInternalStats: ", p), err) } + if err := oprot.WriteBool(ctx, bool(p.EnableInternalStats)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.enableInternalStats (16) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 16:enableInternalStats: ", p), err) } + return err +} + +func (p *JMXConfig) writeField17(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "maxInternalStatsSize", thrift.I64, 17); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 17:maxInternalStatsSize: ", p), err) } + if err := oprot.WriteI64(ctx, int64(p.MaxInternalStatsSize)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.maxInternalStatsSize (17) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 17:maxInternalStatsSize: ", p), err) } + return err +} + func (p *JMXConfig) Equals(other *JMXConfig) bool { if p == other { return true @@ -704,6 +776,8 @@ func (p *JMXConfig) Equals(other *JMXConfig) bool { if p.UseSSL != other.UseSSL { return false } if p.RequestTimeoutMs != other.RequestTimeoutMs { return false } if p.Verbose != other.Verbose { return false } + if p.EnableInternalStats != other.EnableInternalStats { return false } + if p.MaxInternalStatsSize != other.MaxInternalStatsSize { return false } return true } @@ -1038,6 +1112,354 @@ func (p *AttributeResponse) String() string { return fmt.Sprintf("AttributeResponse(%+v)", *p) } +// Attributes: +// - StatType +// - MBean +// - Attrs +// - ResponseCount +// - Milliseconds +// - StartTimestamp +// - Successful +type InternalStat struct { + StatType string `thrift:"statType,1" db:"statType" json:"statType"` + MBean string `thrift:"mBean,2" db:"mBean" json:"mBean"` + Attrs []string `thrift:"attrs,3" db:"attrs" json:"attrs"` + ResponseCount int64 `thrift:"responseCount,4" db:"responseCount" json:"responseCount"` + Milliseconds float64 `thrift:"milliseconds,5" db:"milliseconds" json:"milliseconds"` + StartTimestamp int64 `thrift:"startTimestamp,6" db:"startTimestamp" json:"startTimestamp"` + Successful bool `thrift:"successful,7" db:"successful" json:"successful"` +} + +func NewInternalStat() *InternalStat { + return &InternalStat{} +} + + +func (p *InternalStat) GetStatType() string { + return p.StatType +} + +func (p *InternalStat) GetMBean() string { + return p.MBean +} + +func (p *InternalStat) GetAttrs() []string { + return p.Attrs +} + +func (p *InternalStat) GetResponseCount() int64 { + return p.ResponseCount +} + +func (p *InternalStat) GetMilliseconds() float64 { + return p.Milliseconds +} + +func (p *InternalStat) GetStartTimestamp() int64 { + return p.StartTimestamp +} + +func (p *InternalStat) GetSuccessful() bool { + return p.Successful +} +func (p *InternalStat) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.LIST { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.I64 { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 5: + if fieldTypeId == thrift.DOUBLE { + if err := p.ReadField5(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 6: + if fieldTypeId == thrift.I64 { + if err := p.ReadField6(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 7: + if fieldTypeId == thrift.BOOL { + if err := p.ReadField7(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *InternalStat) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.StatType = v +} + return nil +} + +func (p *InternalStat) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.MBean = v +} + return nil +} + +func (p *InternalStat) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]string, 0, size) + p.Attrs = tSlice + for i := 0; i < size; i ++ { +var _elem0 string + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _elem0 = v +} + p.Attrs = append(p.Attrs, _elem0) + } + if err := iprot.ReadListEnd(ctx); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *InternalStat) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 4: ", err) +} else { + p.ResponseCount = v +} + return nil +} + +func (p *InternalStat) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadDouble(ctx); err != nil { + return thrift.PrependError("error reading field 5: ", err) +} else { + p.Milliseconds = v +} + return nil +} + +func (p *InternalStat) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 6: ", err) +} else { + p.StartTimestamp = v +} + return nil +} + +func (p *InternalStat) ReadField7(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { + return thrift.PrependError("error reading field 7: ", err) +} else { + p.Successful = v +} + return nil +} + +func (p *InternalStat) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "InternalStat"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } + if err := p.writeField7(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *InternalStat) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "statType", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:statType: ", p), err) } + if err := oprot.WriteString(ctx, string(p.StatType)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.statType (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:statType: ", p), err) } + return err +} + +func (p *InternalStat) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "mBean", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:mBean: ", p), err) } + if err := oprot.WriteString(ctx, string(p.MBean)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.mBean (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:mBean: ", p), err) } + return err +} + +func (p *InternalStat) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "attrs", thrift.LIST, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:attrs: ", p), err) } + if err := oprot.WriteListBegin(ctx, thrift.STRING, len(p.Attrs)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.Attrs { + if err := oprot.WriteString(ctx, string(v)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } + } + if err := oprot.WriteListEnd(ctx); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:attrs: ", p), err) } + return err +} + +func (p *InternalStat) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "responseCount", thrift.I64, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:responseCount: ", p), err) } + if err := oprot.WriteI64(ctx, int64(p.ResponseCount)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.responseCount (4) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:responseCount: ", p), err) } + return err +} + +func (p *InternalStat) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "milliseconds", thrift.DOUBLE, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:milliseconds: ", p), err) } + if err := oprot.WriteDouble(ctx, float64(p.Milliseconds)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.milliseconds (5) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 5:milliseconds: ", p), err) } + return err +} + +func (p *InternalStat) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "startTimestamp", thrift.I64, 6); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:startTimestamp: ", p), err) } + if err := oprot.WriteI64(ctx, int64(p.StartTimestamp)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.startTimestamp (6) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 6:startTimestamp: ", p), err) } + return err +} + +func (p *InternalStat) writeField7(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "successful", thrift.BOOL, 7); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:successful: ", p), err) } + if err := oprot.WriteBool(ctx, bool(p.Successful)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.successful (7) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 7:successful: ", p), err) } + return err +} + +func (p *InternalStat) Equals(other *InternalStat) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.StatType != other.StatType { return false } + if p.MBean != other.MBean { return false } + if len(p.Attrs) != len(other.Attrs) { return false } + for i, _tgt := range p.Attrs { + _src1 := other.Attrs[i] + if _tgt != _src1 { return false } + } + if p.ResponseCount != other.ResponseCount { return false } + if p.Milliseconds != other.Milliseconds { return false } + if p.StartTimestamp != other.StartTimestamp { return false } + if p.Successful != other.Successful { return false } + return true +} + +func (p *InternalStat) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("InternalStat(%+v)", *p) +} + // Attributes: // - Message // - CauseMessage @@ -1354,6 +1776,7 @@ type JMXService interface { // - MBeanNamePattern // - Attributes QueryMBeanAttributes(ctx context.Context, mBeanNamePattern string, attributes []string) (_r []*AttributeResponse, _err error) + GetInternalStats(ctx context.Context) (_r []*InternalStat, _err error) } type JMXServiceClient struct { @@ -1394,149 +1817,166 @@ func (p *JMXServiceClient) SetLastResponseMeta_(meta thrift.ResponseMeta) { // Parameters: // - Config func (p *JMXServiceClient) Connect(ctx context.Context, config *JMXConfig) (_err error) { - var _args0 JMXServiceConnectArgs - _args0.Config = config - var _result2 JMXServiceConnectResult - var _meta1 thrift.ResponseMeta - _meta1, _err = p.Client_().Call(ctx, "connect", &_args0, &_result2) - p.SetLastResponseMeta_(_meta1) + var _args2 JMXServiceConnectArgs + _args2.Config = config + var _result4 JMXServiceConnectResult + var _meta3 thrift.ResponseMeta + _meta3, _err = p.Client_().Call(ctx, "connect", &_args2, &_result4) + p.SetLastResponseMeta_(_meta3) if _err != nil { return } switch { - case _result2.ConnErr!= nil: - return _result2.ConnErr - case _result2.JmxErr!= nil: - return _result2.JmxErr + case _result4.ConnErr!= nil: + return _result4.ConnErr + case _result4.JmxErr!= nil: + return _result4.JmxErr } return nil } func (p *JMXServiceClient) Disconnect(ctx context.Context) (_err error) { - var _args3 JMXServiceDisconnectArgs - var _result5 JMXServiceDisconnectResult - var _meta4 thrift.ResponseMeta - _meta4, _err = p.Client_().Call(ctx, "disconnect", &_args3, &_result5) - p.SetLastResponseMeta_(_meta4) + var _args5 JMXServiceDisconnectArgs + var _result7 JMXServiceDisconnectResult + var _meta6 thrift.ResponseMeta + _meta6, _err = p.Client_().Call(ctx, "disconnect", &_args5, &_result7) + p.SetLastResponseMeta_(_meta6) if _err != nil { return } switch { - case _result5.Err!= nil: - return _result5.Err + case _result7.Err!= nil: + return _result7.Err } return nil } func (p *JMXServiceClient) GetClientVersion(ctx context.Context) (_r string, _err error) { - var _args6 JMXServiceGetClientVersionArgs - var _result8 JMXServiceGetClientVersionResult - var _meta7 thrift.ResponseMeta - _meta7, _err = p.Client_().Call(ctx, "getClientVersion", &_args6, &_result8) - p.SetLastResponseMeta_(_meta7) + var _args8 JMXServiceGetClientVersionArgs + var _result10 JMXServiceGetClientVersionResult + var _meta9 thrift.ResponseMeta + _meta9, _err = p.Client_().Call(ctx, "getClientVersion", &_args8, &_result10) + p.SetLastResponseMeta_(_meta9) if _err != nil { return } switch { - case _result8.Err!= nil: - return _r, _result8.Err + case _result10.Err!= nil: + return _r, _result10.Err } - return _result8.GetSuccess(), nil + return _result10.GetSuccess(), nil } // Parameters: // - MBeanNamePattern func (p *JMXServiceClient) QueryMBeanNames(ctx context.Context, mBeanNamePattern string) (_r []string, _err error) { - var _args9 JMXServiceQueryMBeanNamesArgs - _args9.MBeanNamePattern = mBeanNamePattern - var _result11 JMXServiceQueryMBeanNamesResult - var _meta10 thrift.ResponseMeta - _meta10, _err = p.Client_().Call(ctx, "queryMBeanNames", &_args9, &_result11) - p.SetLastResponseMeta_(_meta10) + var _args11 JMXServiceQueryMBeanNamesArgs + _args11.MBeanNamePattern = mBeanNamePattern + var _result13 JMXServiceQueryMBeanNamesResult + var _meta12 thrift.ResponseMeta + _meta12, _err = p.Client_().Call(ctx, "queryMBeanNames", &_args11, &_result13) + p.SetLastResponseMeta_(_meta12) if _err != nil { return } switch { - case _result11.ConnErr!= nil: - return _r, _result11.ConnErr - case _result11.JmxErr!= nil: - return _r, _result11.JmxErr + case _result13.ConnErr!= nil: + return _r, _result13.ConnErr + case _result13.JmxErr!= nil: + return _r, _result13.JmxErr } - return _result11.GetSuccess(), nil + return _result13.GetSuccess(), nil } // Parameters: // - MBeanName func (p *JMXServiceClient) GetMBeanAttributeNames(ctx context.Context, mBeanName string) (_r []string, _err error) { - var _args12 JMXServiceGetMBeanAttributeNamesArgs - _args12.MBeanName = mBeanName - var _result14 JMXServiceGetMBeanAttributeNamesResult - var _meta13 thrift.ResponseMeta - _meta13, _err = p.Client_().Call(ctx, "getMBeanAttributeNames", &_args12, &_result14) - p.SetLastResponseMeta_(_meta13) + var _args14 JMXServiceGetMBeanAttributeNamesArgs + _args14.MBeanName = mBeanName + var _result16 JMXServiceGetMBeanAttributeNamesResult + var _meta15 thrift.ResponseMeta + _meta15, _err = p.Client_().Call(ctx, "getMBeanAttributeNames", &_args14, &_result16) + p.SetLastResponseMeta_(_meta15) if _err != nil { return } switch { - case _result14.ConnErr!= nil: - return _r, _result14.ConnErr - case _result14.JmxErr!= nil: - return _r, _result14.JmxErr + case _result16.ConnErr!= nil: + return _r, _result16.ConnErr + case _result16.JmxErr!= nil: + return _r, _result16.JmxErr } - return _result14.GetSuccess(), nil + return _result16.GetSuccess(), nil } // Parameters: // - MBeanName // - Attributes func (p *JMXServiceClient) GetMBeanAttributes(ctx context.Context, mBeanName string, attributes []string) (_r []*AttributeResponse, _err error) { - var _args15 JMXServiceGetMBeanAttributesArgs - _args15.MBeanName = mBeanName - _args15.Attributes = attributes - var _result17 JMXServiceGetMBeanAttributesResult - var _meta16 thrift.ResponseMeta - _meta16, _err = p.Client_().Call(ctx, "getMBeanAttributes", &_args15, &_result17) - p.SetLastResponseMeta_(_meta16) + var _args17 JMXServiceGetMBeanAttributesArgs + _args17.MBeanName = mBeanName + _args17.Attributes = attributes + var _result19 JMXServiceGetMBeanAttributesResult + var _meta18 thrift.ResponseMeta + _meta18, _err = p.Client_().Call(ctx, "getMBeanAttributes", &_args17, &_result19) + p.SetLastResponseMeta_(_meta18) if _err != nil { return } switch { - case _result17.ConnErr!= nil: - return _r, _result17.ConnErr - case _result17.JmxErr!= nil: - return _r, _result17.JmxErr + case _result19.ConnErr!= nil: + return _r, _result19.ConnErr + case _result19.JmxErr!= nil: + return _r, _result19.JmxErr } - return _result17.GetSuccess(), nil + return _result19.GetSuccess(), nil } // Parameters: // - MBeanNamePattern // - Attributes func (p *JMXServiceClient) QueryMBeanAttributes(ctx context.Context, mBeanNamePattern string, attributes []string) (_r []*AttributeResponse, _err error) { - var _args18 JMXServiceQueryMBeanAttributesArgs - _args18.MBeanNamePattern = mBeanNamePattern - _args18.Attributes = attributes - var _result20 JMXServiceQueryMBeanAttributesResult - var _meta19 thrift.ResponseMeta - _meta19, _err = p.Client_().Call(ctx, "queryMBeanAttributes", &_args18, &_result20) - p.SetLastResponseMeta_(_meta19) + var _args20 JMXServiceQueryMBeanAttributesArgs + _args20.MBeanNamePattern = mBeanNamePattern + _args20.Attributes = attributes + var _result22 JMXServiceQueryMBeanAttributesResult + var _meta21 thrift.ResponseMeta + _meta21, _err = p.Client_().Call(ctx, "queryMBeanAttributes", &_args20, &_result22) + p.SetLastResponseMeta_(_meta21) + if _err != nil { + return + } + switch { + case _result22.ConnErr!= nil: + return _r, _result22.ConnErr + case _result22.JmxErr!= nil: + return _r, _result22.JmxErr + } + + return _result22.GetSuccess(), nil +} + +func (p *JMXServiceClient) GetInternalStats(ctx context.Context) (_r []*InternalStat, _err error) { + var _args23 JMXServiceGetInternalStatsArgs + var _result25 JMXServiceGetInternalStatsResult + var _meta24 thrift.ResponseMeta + _meta24, _err = p.Client_().Call(ctx, "getInternalStats", &_args23, &_result25) + p.SetLastResponseMeta_(_meta24) if _err != nil { return } switch { - case _result20.ConnErr!= nil: - return _r, _result20.ConnErr - case _result20.JmxErr!= nil: - return _r, _result20.JmxErr + case _result25.JmxErr!= nil: + return _r, _result25.JmxErr } - return _result20.GetSuccess(), nil + return _result25.GetSuccess(), nil } type JMXServiceProcessor struct { @@ -1559,15 +1999,16 @@ func (p *JMXServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunctio func NewJMXServiceProcessor(handler JMXService) *JMXServiceProcessor { - self21 := &JMXServiceProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)} - self21.processorMap["connect"] = &jMXServiceProcessorConnect{handler:handler} - self21.processorMap["disconnect"] = &jMXServiceProcessorDisconnect{handler:handler} - self21.processorMap["getClientVersion"] = &jMXServiceProcessorGetClientVersion{handler:handler} - self21.processorMap["queryMBeanNames"] = &jMXServiceProcessorQueryMBeanNames{handler:handler} - self21.processorMap["getMBeanAttributeNames"] = &jMXServiceProcessorGetMBeanAttributeNames{handler:handler} - self21.processorMap["getMBeanAttributes"] = &jMXServiceProcessorGetMBeanAttributes{handler:handler} - self21.processorMap["queryMBeanAttributes"] = &jMXServiceProcessorQueryMBeanAttributes{handler:handler} -return self21 + self26 := &JMXServiceProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)} + self26.processorMap["connect"] = &jMXServiceProcessorConnect{handler:handler} + self26.processorMap["disconnect"] = &jMXServiceProcessorDisconnect{handler:handler} + self26.processorMap["getClientVersion"] = &jMXServiceProcessorGetClientVersion{handler:handler} + self26.processorMap["queryMBeanNames"] = &jMXServiceProcessorQueryMBeanNames{handler:handler} + self26.processorMap["getMBeanAttributeNames"] = &jMXServiceProcessorGetMBeanAttributeNames{handler:handler} + self26.processorMap["getMBeanAttributes"] = &jMXServiceProcessorGetMBeanAttributes{handler:handler} + self26.processorMap["queryMBeanAttributes"] = &jMXServiceProcessorQueryMBeanAttributes{handler:handler} + self26.processorMap["getInternalStats"] = &jMXServiceProcessorGetInternalStats{handler:handler} +return self26 } func (p *JMXServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { @@ -1578,12 +2019,12 @@ func (p *JMXServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.T } iprot.Skip(ctx, thrift.STRUCT) iprot.ReadMessageEnd(ctx) - x22 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name) + x27 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name) oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId) - x22.Write(ctx, oprot) + x27.Write(ctx, oprot) oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, x22 + return false, x27 } @@ -2179,6 +2620,90 @@ func (p *jMXServiceProcessorQueryMBeanAttributes) Process(ctx context.Context, s return true, err } +type jMXServiceProcessorGetInternalStats struct { + handler JMXService +} + +func (p *jMXServiceProcessorGetInternalStats) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := JMXServiceGetInternalStatsArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getInternalStats", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := JMXServiceGetInternalStatsResult{} + var retval []*InternalStat + if retval, err2 = p.handler.GetInternalStats(ctx); err2 != nil { + tickerCancel() + switch v := err2.(type) { + case *JMXError: + result.JmxErr = v + default: + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getInternalStats: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "getInternalStats", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getInternalStats", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + // HELPER FUNCTIONS AND STRUCTURES @@ -2974,13 +3499,13 @@ func (p *JMXServiceQueryMBeanNamesResult) ReadField0(ctx context.Context, iprot tSlice := make([]string, 0, size) p.Success = tSlice for i := 0; i < size; i ++ { -var _elem23 string +var _elem28 string if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _elem23 = v + _elem28 = v } - p.Success = append(p.Success, _elem23) + p.Success = append(p.Success, _elem28) } if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) @@ -3274,13 +3799,13 @@ func (p *JMXServiceGetMBeanAttributeNamesResult) ReadField0(ctx context.Context tSlice := make([]string, 0, size) p.Success = tSlice for i := 0; i < size; i ++ { -var _elem24 string +var _elem29 string if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _elem24 = v + _elem29 = v } - p.Success = append(p.Success, _elem24) + p.Success = append(p.Success, _elem29) } if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) @@ -3457,13 +3982,13 @@ func (p *JMXServiceGetMBeanAttributesArgs) ReadField2(ctx context.Context, ipro tSlice := make([]string, 0, size) p.Attributes = tSlice for i := 0; i < size; i ++ { -var _elem25 string +var _elem30 string if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _elem25 = v + _elem30 = v } - p.Attributes = append(p.Attributes, _elem25) + p.Attributes = append(p.Attributes, _elem30) } if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) @@ -3631,11 +4156,11 @@ func (p *JMXServiceGetMBeanAttributesResult) ReadField0(ctx context.Context, ip tSlice := make([]*AttributeResponse, 0, size) p.Success = tSlice for i := 0; i < size; i ++ { - _elem26 := &AttributeResponse{} - if err := _elem26.Read(ctx, iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem26), err) + _elem31 := &AttributeResponse{} + if err := _elem31.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem31), err) } - p.Success = append(p.Success, _elem26) + p.Success = append(p.Success, _elem31) } if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) @@ -3813,13 +4338,13 @@ func (p *JMXServiceQueryMBeanAttributesArgs) ReadField2(ctx context.Context, ip tSlice := make([]string, 0, size) p.Attributes = tSlice for i := 0; i < size; i ++ { -var _elem27 string +var _elem32 string if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _elem27 = v + _elem32 = v } - p.Attributes = append(p.Attributes, _elem27) + p.Attributes = append(p.Attributes, _elem32) } if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) @@ -3987,11 +4512,11 @@ func (p *JMXServiceQueryMBeanAttributesResult) ReadField0(ctx context.Context, tSlice := make([]*AttributeResponse, 0, size) p.Success = tSlice for i := 0; i < size; i ++ { - _elem28 := &AttributeResponse{} - if err := _elem28.Read(ctx, iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem28), err) + _elem33 := &AttributeResponse{} + if err := _elem33.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem33), err) } - p.Success = append(p.Success, _elem28) + p.Success = append(p.Success, _elem33) } if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) @@ -4084,4 +4609,218 @@ func (p *JMXServiceQueryMBeanAttributesResult) String() string { return fmt.Sprintf("JMXServiceQueryMBeanAttributesResult(%+v)", *p) } +type JMXServiceGetInternalStatsArgs struct { +} + +func NewJMXServiceGetInternalStatsArgs() *JMXServiceGetInternalStatsArgs { + return &JMXServiceGetInternalStatsArgs{} +} + +func (p *JMXServiceGetInternalStatsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JMXServiceGetInternalStatsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getInternalStats_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JMXServiceGetInternalStatsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("JMXServiceGetInternalStatsArgs(%+v)", *p) +} + +// Attributes: +// - Success +// - JmxErr +type JMXServiceGetInternalStatsResult struct { + Success []*InternalStat `thrift:"success,0" db:"success" json:"success,omitempty"` + JmxErr *JMXError `thrift:"jmxErr,1" db:"jmxErr" json:"jmxErr,omitempty"` +} + +func NewJMXServiceGetInternalStatsResult() *JMXServiceGetInternalStatsResult { + return &JMXServiceGetInternalStatsResult{} +} + +var JMXServiceGetInternalStatsResult_Success_DEFAULT []*InternalStat + +func (p *JMXServiceGetInternalStatsResult) GetSuccess() []*InternalStat { + return p.Success +} +var JMXServiceGetInternalStatsResult_JmxErr_DEFAULT *JMXError +func (p *JMXServiceGetInternalStatsResult) GetJmxErr() *JMXError { + if !p.IsSetJmxErr() { + return JMXServiceGetInternalStatsResult_JmxErr_DEFAULT + } +return p.JmxErr +} +func (p *JMXServiceGetInternalStatsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *JMXServiceGetInternalStatsResult) IsSetJmxErr() bool { + return p.JmxErr != nil +} + +func (p *JMXServiceGetInternalStatsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.LIST { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JMXServiceGetInternalStatsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]*InternalStat, 0, size) + p.Success = tSlice + for i := 0; i < size; i ++ { + _elem34 := &InternalStat{} + if err := _elem34.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem34), err) + } + p.Success = append(p.Success, _elem34) + } + if err := iprot.ReadListEnd(ctx); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *JMXServiceGetInternalStatsResult) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.JmxErr = &JMXError{} + if err := p.JmxErr.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.JmxErr), err) + } + return nil +} + +func (p *JMXServiceGetInternalStatsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getInternalStats_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JMXServiceGetInternalStatsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.LIST, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.Success)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.Success { + if err := v.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) + } + } + if err := oprot.WriteListEnd(ctx); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *JMXServiceGetInternalStatsResult) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetJmxErr() { + if err := oprot.WriteFieldBegin(ctx, "jmxErr", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:jmxErr: ", p), err) } + if err := p.JmxErr.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.JmxErr), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:jmxErr: ", p), err) } + } + return err +} + +func (p *JMXServiceGetInternalStatsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("JMXServiceGetInternalStatsResult(%+v)", *p) +} + diff --git a/gojmx/internal/testutils/test_utils.go b/gojmx/internal/testutils/test_utils.go index 97a3a3c..055181c 100644 --- a/gojmx/internal/testutils/test_utils.go +++ b/gojmx/internal/testutils/test_utils.go @@ -10,15 +10,16 @@ import ( "context" "encoding/json" "fmt" - "github.com/docker/go-connections/nat" - "github.com/testcontainers/testcontainers-go" - "github.com/testcontainers/testcontainers-go/wait" "io/ioutil" "net/http" "os" "os/exec" "path/filepath" "time" + + "github.com/docker/go-connections/nat" + "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/wait" ) const ( diff --git a/gojmx/process.go b/gojmx/process.go index d7f081f..1b93b3d 100644 --- a/gojmx/process.go +++ b/gojmx/process.go @@ -7,11 +7,12 @@ package gojmx import ( "context" - "github.com/newrelic/nrjmx/gojmx/internal/nrjmx" "io" "os" "os/exec" "time" + + "github.com/newrelic/nrjmx/gojmx/internal/nrjmx" ) const ( @@ -20,8 +21,11 @@ const ( ) var ( - errProcessAlreadyRunning = newJMXConnectionError("nrjmx subprocess is already running") - errProcessNotRunning = newJMXConnectionError("nrjmx subprocess is not running") + errProcessAlreadyRunning = newJMXClientError("nrjmx subprocess is already running") + errProcessNotRunning = newJMXClientError("nrjmx subprocess is not running") + + // errPingTimeout returned if pingTimeout exceeded. + errPingTimeout = newJMXConnectionError("could not establish communication with nrjmx: subprocess response timeout") ) // process will handle the nrjmx subprocess. @@ -46,15 +50,13 @@ func newProcess(ctx context.Context) *process { } // start the nrjmx subprocess. -func (p *process) start() (*process, error) { +func (p *process) start() (proc *process, err error) { if p.state.IsRunning() { return p, errProcessAlreadyRunning } p.cmd = buildExecCommand(p.ctx) - var err error - defer func() { if err != nil { _ = p.terminate() @@ -63,29 +65,31 @@ func (p *process) start() (*process, error) { p.Stdout, err = p.cmd.StdoutPipe() if err != nil { - return nil, newJMXConnectionError("failed to create stdout pipe to %q: %v", p.cmd.Path, err) + return nil, newJMXClientError("failed to create stdout pipe to %q: %v", p.cmd.Path, err) } p.Stdin, err = p.cmd.StdinPipe() if err != nil { - return nil, newJMXConnectionError("failed to create stdin pipe to %q: %v", p.cmd.Path, err) + return nil, newJMXClientError("failed to create stdin pipe to %q: %v", p.cmd.Path, err) } stderrBuff := nrjmx.NewDefaultLimitedBuffer() p.cmd.Stderr = stderrBuff - if err := p.cmd.Start(); err != nil { - return p, newJMXConnectionError("failed to start %q: %v", p.cmd.Path, err) + if err = p.cmd.Start(); err != nil { + return p, newJMXClientError("failed to start %q: %v", p.cmd.Path, err) } p.state.Start() go func() { err := p.cmd.Wait() if err != nil { - err = newJMXConnectionError("nrjmx process exited with error: %v: stderr: %s", + err = newJMXClientError("nrjmx process exited with error: %v: stderr: %s", err, stderrBuff.String()) } + + p.terminate() p.state.Stop(err) }() @@ -119,7 +123,7 @@ func (p *process) waitExit(timeout time.Duration) error { return err case <-time.After(timeout): err := p.terminate() - return newJMXConnectionError( + return newJMXClientError( "timeout exceeded while waiting for nrjmx process to exit gracefully, attempting to terminate the process, error: %v", err, ) @@ -128,15 +132,17 @@ func (p *process) waitExit(timeout time.Duration) error { // terminate will stop the nrjmx process. func (p *process) terminate() (err error) { - if !p.state.IsRunning() { - return - } - if stdoutErr := p.Stdout.Close(); stdoutErr != nil { - err = newJMXConnectionError("failed to detach stdout from %q: %v", p.cmd.Path, stdoutErr) + if p.Stdout != nil { + if stdoutErr := p.Stdout.Close(); stdoutErr != nil { + err = newJMXClientError("failed to detach stdout from %q: %v", p.cmd.Path, stdoutErr) + } } - if stdinErr := p.Stdin.Close(); stdinErr != nil { - err = newJMXConnectionError("failed to detach stdin from %q: %v", p.cmd.Path, stdinErr) + + if p.Stdin != nil { + if stdinErr := p.Stdin.Close(); stdinErr != nil { + err = newJMXClientError("failed to detach stdin from %q: %v", p.cmd.Path, stdinErr) + } } p.cancel() diff --git a/gojmx/types.go b/gojmx/types.go index 9fb5c66..a84de4f 100644 --- a/gojmx/types.go +++ b/gojmx/types.go @@ -7,9 +7,10 @@ package gojmx import ( "fmt" - "github.com/newrelic/nrjmx/gojmx/internal/nrprotocol" "strings" "unsafe" + + "github.com/newrelic/nrjmx/gojmx/internal/nrprotocol" ) /* @@ -133,3 +134,56 @@ var ( // ResponseTypeErr AttributeResponse with error ResponseTypeErr = nrprotocol.ResponseType_ERROR ) + +// InternalStat gathers stats about queries performed by nrjmx. +type InternalStat nrprotocol.InternalStat + +func (is *InternalStat) String() string { + return fmt.Sprintf("StatType: '%s', MBean: '%s', Attributes: '%v', TotalObjCount: %d, StartTimeMs: %d, Duration: %.3fms, Successful: %t", + is.StatType, + is.MBean, + is.Attrs, + is.ResponseCount, + is.StartTimestamp, + is.Milliseconds, + is.Successful, + ) +} + +func toInternalStatList(in []*nrprotocol.InternalStat) []*InternalStat { + return *(*[]*InternalStat)(unsafe.Pointer(&in)) +} + +// JMXClientError is returned when there is an nrjmx process error. +// Those errors require opening a new client. +type JMXClientError struct { + Message string +} + +func (e *JMXClientError) String() string { + if e == nil { + return "" + } + return fmt.Sprintf("nrjmx client error: %s", removeNewLines(e.Message)) +} + +func (e *JMXClientError) Error() string { + return e.String() +} + +func newJMXClientError(message string, args ...interface{}) *JMXClientError { + if len(args) > 0 { + message = fmt.Sprintf(message, args...) + } + return &JMXClientError{ + Message: message, + } +} + +// IsJMXClientError checks if the err is JMXJMXClientError. +func IsJMXClientError(err error) (*JMXClientError, bool) { + if e, ok := err.(*JMXClientError); ok { + return e, ok + } + return nil, false +} diff --git a/src/main/java/org/newrelic/nrjmx/Application.java b/src/main/java/org/newrelic/nrjmx/Application.java index f4e3ef8..6bab622 100644 --- a/src/main/java/org/newrelic/nrjmx/Application.java +++ b/src/main/java/org/newrelic/nrjmx/Application.java @@ -16,8 +16,7 @@ import org.newrelic.nrjmx.v2.StandardIOTransportServer; import org.newrelic.nrjmx.v2.nrprotocol.JMXService; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; +import java.util.concurrent.*; import java.util.logging.Logger; public class Application { @@ -106,6 +105,19 @@ private static void runV2() { handler.addServer(server); + // Add ShutdownHook to disconnect the fetcher. + Runtime.getRuntime().addShutdownHook( + new Thread(() -> { + try { + jmxFetcher.disconnect(); + } catch (Exception e) { + } finally { + serverTransport.close(); + executor.shutdownNow(); + } + }) + ); + try { server.listen(); } catch (Exception e) { @@ -115,6 +127,7 @@ private static void runV2() { serverTransport.close(); executor.shutdownNow(); } + System.exit(0); } private static void logTrace(Arguments cliArgs, Logger logger, Exception e) { diff --git a/src/main/java/org/newrelic/nrjmx/v2/InternalStats.java b/src/main/java/org/newrelic/nrjmx/v2/InternalStats.java new file mode 100644 index 0000000..56455d1 --- /dev/null +++ b/src/main/java/org/newrelic/nrjmx/v2/InternalStats.java @@ -0,0 +1,75 @@ +/* + * Copyright 2021 New Relic Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.newrelic.nrjmx.v2; + +import org.newrelic.nrjmx.v2.nrprotocol.InternalStat; + +import java.util.ArrayList; +import java.util.List; + +/** + * InternalStats class used to collect internal nrjmx query stats for troubleshooting. + */ +public class InternalStats { + private List stats; + + /* maxSize defines how many stats we can keep in memory. When limit is reached old ones are discarded. */ + private long maxSize; + + final static private long DEFAULT_MAX_SIZE = 100000; + + /** + * InternalStats constructor. + * + * @param maxSize long defines how many stats we can keep in memory. When limit is reached old ones are discarded. + */ + public InternalStats(long maxSize) { + if (maxSize < 1) { + maxSize = DEFAULT_MAX_SIZE; + } + + this.maxSize = maxSize; + this.stats = new ArrayList<>(); + } + + /** + * Records a new InternalStat and returns it for attaching more data if required. + * + * @param statType String name of the stat. + * + * @return InternalStat new registered stat to add data to it. + */ + public InternalStat record(String statType) { + if (stats.size() >= maxSize) { + stats.remove(0); + } + + InternalStat stat = new InternalStat() + .setStartTimestamp(System.currentTimeMillis()) + .setMilliseconds((double)System.nanoTime() / 1000000.0) + .setStatType(statType); + stats.add(stat); + return stat; + } + + /** + * Returns all the collected stats and clear them. + ** + * @return List returns all collected internal stats. + */ + public List getStats() { + List stats = this.stats; + this.stats = new ArrayList<>(); + return stats; + } + + /** + * Calculate the elapsed ms with .3f precision since the stat was recorded and attach it to the stat. + */ + public static void setElapsedMs(InternalStat internalStat) { + internalStat.setMilliseconds((double)System.nanoTime() / 1000000.0 - internalStat.milliseconds); + } +} diff --git a/src/main/java/org/newrelic/nrjmx/v2/JMXFetcher.java b/src/main/java/org/newrelic/nrjmx/v2/JMXFetcher.java index c8b055e..a57c118 100644 --- a/src/main/java/org/newrelic/nrjmx/v2/JMXFetcher.java +++ b/src/main/java/org/newrelic/nrjmx/v2/JMXFetcher.java @@ -34,6 +34,9 @@ public class JMXFetcher { /* ExecutorService is required to run JMX requests with timeout. */ private final ExecutorService executor; + /* JMXConnector is used to connect to JMX endpoint. */ + private JMXConnector connector; + /* MBeanServerConnection is the connection to JMX endpoint. */ private MBeanServerConnection connection; @@ -43,6 +46,9 @@ public class JMXFetcher { /* JMX configuration used to connect to JMX endpoint. */ private JMXConfig jmxConfig; + /* InternalStats used for troubleshooting. */ + private InternalStats internalStats; + public JMXFetcher(ExecutorService executor) { this.executor = executor; } @@ -69,22 +75,91 @@ public void connect(JMXConfig jmxConfig, long timeoutMs) throws JMXError, JMXCon * @throws JMXConnectionError JMX connection related exception */ public void connect(JMXConfig jmxConfig) throws JMXConnectionError { + if (jmxConfig == null) { + throw new JMXConnectionError("failed to connect to JMX server: configuration not provided"); + } + this.jmxConfig = jmxConfig; + if (jmxConfig.enableInternalStats) { + this.internalStats = new InternalStats(jmxConfig.maxInternalStatsSize); + } + String connectionString = buildConnectionString(jmxConfig); Map connectionEnv = buildConnectionEnvConfig(jmxConfig); + InternalStat internalStat = null; + if (this.internalStats != null) { + internalStat = internalStats.record("connect"); + } + try { JMXServiceURL address = new JMXServiceURL(connectionString); - JMXConnector connector = JMXConnectorFactory.connect(address, connectionEnv); + this.connector = JMXConnectorFactory.connect(address, connectionEnv); this.connection = connector.getMBeanServerConnection(); + + if (internalStat != null) { + internalStat.setSuccessful(true); + } } catch (Exception e) { String message = String.format("can't connect to JMX server: '%s', error: '%s'", connectionString, getErrorMessage(e)); throw new JMXConnectionError(message); + } finally { + if (internalStat != null) { + InternalStats.setElapsedMs(internalStat); + } + } + } + + /** + * disconnect from the JMX endpoint. + * + * @param timeoutMs long timeout for the request in milliseconds + * @throws JMXConnectionError JMX connection related exception + */ + public void disconnect(long timeoutMs) throws JMXError, JMXConnectionError { + withTimeout(executor.submit((Callable) () -> { + disconnect(); + return null; + }), timeoutMs); + } + + /** + * disconnect from the JMX endpoint. + * + * @throws JMXConnectionError JMX connection related exception + */ + public void disconnect() throws JMXConnectionError { + if (this.connector == null) { + throw new JMXConnectionError() + .setMessage("cannot disconnect, connection to JMX endpoint is not established"); + } + + InternalStat internalStat = null; + if (this.internalStats != null) { + internalStat = internalStats.record("disconnect"); + } + + // Move this to a different variable in case close operation timeouts. + JMXConnector oldConnector = this.connector; + + // Mark the connector as null in case to allow reconnection. + this.connector = null; + + try { + oldConnector.close(); + if (internalStat != null) { + internalStat.setSuccessful(true); + } + } catch (Exception e) { + } finally { + if (internalStat != null) { + InternalStats.setElapsedMs(internalStat); + } } } @@ -134,9 +209,26 @@ private Set queryMBeans(ObjectName objectName) throws JMXConnect throw new JMXError() .setMessage("can't query MBeans, provided objectName is Null"); } + + Set result = null; + + InternalStat internalStat = null; + if (this.internalStats != null) { + internalStat = internalStats.record("queryMBeans") + .setMBean(objectName.toString()); + } + try { - return getConnection().queryMBeans(objectName, null); + result = getConnection().queryMBeans(objectName, null); + + if (internalStat != null) { + internalStat.setSuccessful(true); + } + + return result; } catch (ConnectException ce) { + disconnect(); + String message = String.format("can't connect to JMX server, error: '%s'", ce.getMessage()); throw new JMXConnectionError(message); } catch (IOException ioe) { @@ -144,6 +236,14 @@ private Set queryMBeans(ObjectName objectName) throws JMXConnect .setMessage("can't get beans for query: " + objectName) .setCauseMessage(ioe.getMessage()) .setStacktrace(getStackTrace(ioe)); + } finally { + if (internalStat != null) { + InternalStats.setElapsedMs(internalStat); + + if (result != null) { + internalStat.setResponseCount(result.size()); + } + } } } @@ -179,9 +279,21 @@ private List getMBeanAttributeNames(ObjectName objectName) throws JMXCon MBeanInfo info; + InternalStat internalStat = null; + if (this.internalStats != null) { + internalStat = internalStats.record("getMBeanInfo") + .setMBean(objectName.toString()); + } + try { info = getConnection().getMBeanInfo(objectName); + + if (internalStat != null) { + internalStat.setSuccessful(true); + } } catch (ConnectException ce) { + disconnect(); + String message = String.format("can't connect to JMX server, error: '%s'", ce.getMessage()); throw new JMXConnectionError(message); } catch (InstanceNotFoundException | IntrospectionException | ReflectionException | IOException e) { @@ -189,6 +301,10 @@ private List getMBeanAttributeNames(ObjectName objectName) throws JMXCon .setMessage("can't find mBean: " + objectName) .setCauseMessage(e.getMessage()) .setStacktrace(getStackTrace(e)); + } finally { + if (internalStat != null) { + InternalStats.setElapsedMs(internalStat); + } } List result = new ArrayList<>(); @@ -197,6 +313,10 @@ private List getMBeanAttributeNames(ObjectName objectName) throws JMXCon } for (MBeanAttributeInfo attrInfo : info.getAttributes()) { + if (internalStat != null) { + internalStat.setResponseCount(internalStat.responseCount + 1); + } + if (attrInfo == null || !attrInfo.isReadable()) { continue; } @@ -251,104 +371,83 @@ private void getMBeanAttributes(ObjectName objectName, List attributes, attributes = getMBeanAttributeNames(objectName); } + InternalStat internalStat = null; + if (this.internalStats != null) { + internalStat = internalStats.record("getAttributes") + .setMBean(objectName.toString()) + .setAttrs(attributes); + } + List attrValues = new ArrayList<>(); + AttributeList attributeList; + try { + attributeList = getConnection().getAttributes(objectName, attributes.toArray(new String[0])); + + if (internalStat != null) { + internalStat.setSuccessful(true); + } + } catch (ConnectException ce) { + disconnect(); + + String message = String.format("can't connect to JMX server, error: '%s'", ce.getMessage()); + throw new JMXConnectionError(message); + } catch (Exception e) { + throw new JMXError() + .setMessage("can't get attributes: " + attributes + " for bean: " + objectName + ": ") + .setCauseMessage(e.getMessage()) + .setStacktrace(getStackTrace(e)); + } finally { + if (internalStat != null) { + InternalStats.setElapsedMs(internalStat); + } + } + + // Keep a track of requested attributes to report the ones that we fail to retrieve. + List missingAttrs = new ArrayList<>(attributes); + try { - AttributeList attributeList = getConnection().getAttributes(objectName, attributes.toArray(new String[0])); if (attributeList == null) { return; } + for (Object value : attributeList) { + if (internalStat != null) { + internalStat.setResponseCount(internalStat.responseCount + 1); + } + if (value instanceof Attribute) { Attribute attr = (Attribute) value; attrValues.add(attr); - } else { - throw new Exception("unexpected type for Attribute"); + + missingAttrs.remove(attr.getName()); } } - } catch (ConnectException ce) { - String message = String.format("can't connect to JMX server, error: '%s'", ce.getMessage()); - throw new JMXConnectionError(message); - } catch (Exception e) { - // When running a call for multiple attributes it can fail only because one of them. - // In that case we try to make a separate call for each one. - for (String attribute : attributes) { - String formattedAttrName = formatAttributeName(objectName, attribute); + + for (Attribute attrValue : attrValues) { + String formattedAttrName = formatAttributeName(objectName, attrValue.getName()); try { - getMBeanAttribute(objectName, attribute, output); + parseValue(formattedAttrName, attrValue.getValue(), output); } catch (JMXError je) { - String statusMessage = String.format("can't get attribute, error: '%s', cause: '%s', stacktrace: '%s'", je.message, je.causeMessage, je.stacktrace); + String statusMessage = String.format("can't parse attribute, error: '%s', cause: '%s', stacktrace: '%s'", je.message, je.causeMessage, je.stacktrace); output.add(new AttributeResponse() .setName(formattedAttrName) .setResponseType(ResponseType.ERROR) .setStatusMsg(statusMessage)); } } - } - - for (Attribute attrValue : attrValues) { - String formattedAttrName = formatAttributeName(objectName, attrValue.getName()); - - try { - parseValue(formattedAttrName, attrValue.getValue(), output); - } catch (JMXError je) { - String statusMessage = String.format("can't parse attribute, error: '%s', cause: '%s', stacktrace: '%s'", je.message, je.causeMessage, je.stacktrace); + } finally { + // Report requested attributes that we didn't retrieve. + for (String attr : missingAttrs) { + String formattedAttrName = formatAttributeName(objectName, attr); output.add(new AttributeResponse() .setName(formattedAttrName) .setResponseType(ResponseType.ERROR) - .setStatusMsg(statusMessage)); + .setStatusMsg("failed to retrieve attribute value from server")); } } } - /** - * getMBeanAttribute fetches the attribute value for an mBeanName. - * CompositeData is handled as multiple values. - * - * @param objectName of which we want to retrieve the attribute values - * @param attribute of which we want to retrieve the attribute values - * @param output List to add the fetched attribute values. - * @throws JMXError JMX related Exception - * @throws JMXConnectionError JMX connection related exception - */ - private void getMBeanAttribute(ObjectName objectName, String attribute, List output) throws JMXConnectionError, JMXError { - if (objectName == null) { - throw new JMXError() - .setMessage("can't get attribute value, provided objectName is Null"); - } - - if (attribute == null) { - throw new JMXError() - .setMessage("can't get attribute value, provided attribute name is Null"); - } - - if (output == null) { - throw new JMXError() - .setMessage("can't deserialize attribute value, provided output list is Null"); - } - - Object value; - try { - value = getConnection().getAttribute(objectName, attribute); - if (value instanceof Attribute) { - Attribute jmxAttr = (Attribute) value; - value = jmxAttr.getValue(); - } - } catch (ConnectException ce) { - String message = String.format("can't connect to JMX server, error: '%s'", ce.getMessage()); - throw new JMXConnectionError(message); - } catch (Exception e) { - throw new JMXError() - .setMessage("can't get attribute: " + attribute + " for bean: " + objectName + ": ") - .setCauseMessage(e.getMessage()) - .setStacktrace(getStackTrace(e)); - } - - - String formattedAttrName = formatAttributeName(objectName, attribute); - parseValue(formattedAttrName, value, output); - } - /** * queryMBeanAttributes will fetch all the available mBeans attributes for the mBean pattern. * @@ -518,13 +617,35 @@ private void parseValue(String mBeanAttributeName, Object value, List the collected nrjmx internal query stats. + */ + public List getInternalStats() throws JMXError { + if (internalStats == null) { + throw new JMXError() + .setMessage("internal stats not activated"); + } + + return internalStats.getStats(); + } + /** * getConnection returns the connection the the JMX endpoint. * * @return MBeanServerConnection the connection to the JMX endpoint * @throws JMXConnectionError JMX connection related Exception */ - private MBeanServerConnection getConnection() throws JMXConnectionError { + private MBeanServerConnection getConnection() throws JMXConnectionError, JMXError { + if (jmxConfig == null) { + throw new JMXConnectionError("failed to get connection to JMX server: configuration not provided"); + } + + if (this.connector == null) { + connect(jmxConfig); + } + if (this.connection == null) { throw new JMXConnectionError() .setMessage("connection to JMX endpoint is not established"); diff --git a/src/main/java/org/newrelic/nrjmx/v2/JMXServiceHandler.java b/src/main/java/org/newrelic/nrjmx/v2/JMXServiceHandler.java index 5150dc5..63db68f 100644 --- a/src/main/java/org/newrelic/nrjmx/v2/JMXServiceHandler.java +++ b/src/main/java/org/newrelic/nrjmx/v2/JMXServiceHandler.java @@ -31,7 +31,9 @@ public String getClientVersion() { @Override public void connect(JMXConfig config) throws TException { - this.requestTimeoutMs = config.requestTimeoutMs; + if (config != null) { + requestTimeoutMs = config.requestTimeoutMs; + } jmxFetcher.connect(config, requestTimeoutMs); } @@ -40,12 +42,17 @@ public void disconnect() throws TException { if (server == null) { throw new TException("cannot disconnect, nrjmx handler null"); } - server.stop(); + + try { + jmxFetcher.disconnect(requestTimeoutMs); + } finally { + server.stop(); + } } @Override public List queryMBeanNames(String mBeanNamePattern) throws TException { - return jmxFetcher.queryMBeanNames(mBeanNamePattern, requestTimeoutMs); + return jmxFetcher.queryMBeanNames(mBeanNamePattern, requestTimeoutMs); } @Override @@ -63,6 +70,11 @@ public List queryMBeanAttributes(String mBeanNamePattern, Lis return jmxFetcher.queryMBeanAttributes(mBeanNamePattern, attributes, requestTimeoutMs); } + @Override + public List getInternalStats() throws TException { + return jmxFetcher.getInternalStats(); + } + public void addServer(TServer server) { this.server = server; } diff --git a/src/main/java/org/newrelic/nrjmx/v2/StandardIOServer.java b/src/main/java/org/newrelic/nrjmx/v2/StandardIOServer.java index e09b1fc..2c0589d 100644 --- a/src/main/java/org/newrelic/nrjmx/v2/StandardIOServer.java +++ b/src/main/java/org/newrelic/nrjmx/v2/StandardIOServer.java @@ -76,6 +76,9 @@ public void serve() { * stop StandardIOServer listen. */ public void stop() { + if (stopped_) { + return; + } stopped_ = true; serverTransport_.interrupt(); } diff --git a/src/main/java/org/newrelic/nrjmx/v2/StandardIOTransportServer.java b/src/main/java/org/newrelic/nrjmx/v2/StandardIOTransportServer.java index f429e4f..c31fb14 100644 --- a/src/main/java/org/newrelic/nrjmx/v2/StandardIOTransportServer.java +++ b/src/main/java/org/newrelic/nrjmx/v2/StandardIOTransportServer.java @@ -25,6 +25,7 @@ public void listen() throws TTransportException { public void close() { if (transport != null) { transport.close(); + transport = null; } } diff --git a/src/main/java/org/newrelic/nrjmx/v2/nrprotocol/InternalStat.java b/src/main/java/org/newrelic/nrjmx/v2/nrprotocol/InternalStat.java new file mode 100644 index 0000000..c61adfd --- /dev/null +++ b/src/main/java/org/newrelic/nrjmx/v2/nrprotocol/InternalStat.java @@ -0,0 +1,1022 @@ +/** + * Autogenerated by Thrift Compiler (0.16.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.newrelic.nrjmx.v2.nrprotocol; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) +public class InternalStat implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("InternalStat"); + + private static final org.apache.thrift.protocol.TField STAT_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("statType", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField M_BEAN_FIELD_DESC = new org.apache.thrift.protocol.TField("mBean", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField ATTRS_FIELD_DESC = new org.apache.thrift.protocol.TField("attrs", org.apache.thrift.protocol.TType.LIST, (short)3); + private static final org.apache.thrift.protocol.TField RESPONSE_COUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("responseCount", org.apache.thrift.protocol.TType.I64, (short)4); + private static final org.apache.thrift.protocol.TField MILLISECONDS_FIELD_DESC = new org.apache.thrift.protocol.TField("milliseconds", org.apache.thrift.protocol.TType.DOUBLE, (short)5); + private static final org.apache.thrift.protocol.TField START_TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("startTimestamp", org.apache.thrift.protocol.TType.I64, (short)6); + private static final org.apache.thrift.protocol.TField SUCCESSFUL_FIELD_DESC = new org.apache.thrift.protocol.TField("successful", org.apache.thrift.protocol.TType.BOOL, (short)7); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new InternalStatStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new InternalStatTupleSchemeFactory(); + + public @org.apache.thrift.annotation.Nullable java.lang.String statType; // required + public @org.apache.thrift.annotation.Nullable java.lang.String mBean; // required + public @org.apache.thrift.annotation.Nullable java.util.List attrs; // required + public long responseCount; // required + public double milliseconds; // required + public long startTimestamp; // required + public boolean successful; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + STAT_TYPE((short)1, "statType"), + M_BEAN((short)2, "mBean"), + ATTRS((short)3, "attrs"), + RESPONSE_COUNT((short)4, "responseCount"), + MILLISECONDS((short)5, "milliseconds"), + START_TIMESTAMP((short)6, "startTimestamp"), + SUCCESSFUL((short)7, "successful"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // STAT_TYPE + return STAT_TYPE; + case 2: // M_BEAN + return M_BEAN; + case 3: // ATTRS + return ATTRS; + case 4: // RESPONSE_COUNT + return RESPONSE_COUNT; + case 5: // MILLISECONDS + return MILLISECONDS; + case 6: // START_TIMESTAMP + return START_TIMESTAMP; + case 7: // SUCCESSFUL + return SUCCESSFUL; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __RESPONSECOUNT_ISSET_ID = 0; + private static final int __MILLISECONDS_ISSET_ID = 1; + private static final int __STARTTIMESTAMP_ISSET_ID = 2; + private static final int __SUCCESSFUL_ISSET_ID = 3; + private byte __isset_bitfield = 0; + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.STAT_TYPE, new org.apache.thrift.meta_data.FieldMetaData("statType", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.M_BEAN, new org.apache.thrift.meta_data.FieldMetaData("mBean", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.ATTRS, new org.apache.thrift.meta_data.FieldMetaData("attrs", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + tmpMap.put(_Fields.RESPONSE_COUNT, new org.apache.thrift.meta_data.FieldMetaData("responseCount", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.MILLISECONDS, new org.apache.thrift.meta_data.FieldMetaData("milliseconds", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE))); + tmpMap.put(_Fields.START_TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("startTimestamp", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.SUCCESSFUL, new org.apache.thrift.meta_data.FieldMetaData("successful", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(InternalStat.class, metaDataMap); + } + + public InternalStat() { + } + + public InternalStat( + java.lang.String statType, + java.lang.String mBean, + java.util.List attrs, + long responseCount, + double milliseconds, + long startTimestamp, + boolean successful) + { + this(); + this.statType = statType; + this.mBean = mBean; + this.attrs = attrs; + this.responseCount = responseCount; + setResponseCountIsSet(true); + this.milliseconds = milliseconds; + setMillisecondsIsSet(true); + this.startTimestamp = startTimestamp; + setStartTimestampIsSet(true); + this.successful = successful; + setSuccessfulIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public InternalStat(InternalStat other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetStatType()) { + this.statType = other.statType; + } + if (other.isSetMBean()) { + this.mBean = other.mBean; + } + if (other.isSetAttrs()) { + java.util.List __this__attrs = new java.util.ArrayList(other.attrs); + this.attrs = __this__attrs; + } + this.responseCount = other.responseCount; + this.milliseconds = other.milliseconds; + this.startTimestamp = other.startTimestamp; + this.successful = other.successful; + } + + public InternalStat deepCopy() { + return new InternalStat(this); + } + + @Override + public void clear() { + this.statType = null; + this.mBean = null; + this.attrs = null; + setResponseCountIsSet(false); + this.responseCount = 0; + setMillisecondsIsSet(false); + this.milliseconds = 0.0; + setStartTimestampIsSet(false); + this.startTimestamp = 0; + setSuccessfulIsSet(false); + this.successful = false; + } + + @org.apache.thrift.annotation.Nullable + public java.lang.String getStatType() { + return this.statType; + } + + public InternalStat setStatType(@org.apache.thrift.annotation.Nullable java.lang.String statType) { + this.statType = statType; + return this; + } + + public void unsetStatType() { + this.statType = null; + } + + /** Returns true if field statType is set (has been assigned a value) and false otherwise */ + public boolean isSetStatType() { + return this.statType != null; + } + + public void setStatTypeIsSet(boolean value) { + if (!value) { + this.statType = null; + } + } + + @org.apache.thrift.annotation.Nullable + public java.lang.String getMBean() { + return this.mBean; + } + + public InternalStat setMBean(@org.apache.thrift.annotation.Nullable java.lang.String mBean) { + this.mBean = mBean; + return this; + } + + public void unsetMBean() { + this.mBean = null; + } + + /** Returns true if field mBean is set (has been assigned a value) and false otherwise */ + public boolean isSetMBean() { + return this.mBean != null; + } + + public void setMBeanIsSet(boolean value) { + if (!value) { + this.mBean = null; + } + } + + public int getAttrsSize() { + return (this.attrs == null) ? 0 : this.attrs.size(); + } + + @org.apache.thrift.annotation.Nullable + public java.util.Iterator getAttrsIterator() { + return (this.attrs == null) ? null : this.attrs.iterator(); + } + + public void addToAttrs(java.lang.String elem) { + if (this.attrs == null) { + this.attrs = new java.util.ArrayList(); + } + this.attrs.add(elem); + } + + @org.apache.thrift.annotation.Nullable + public java.util.List getAttrs() { + return this.attrs; + } + + public InternalStat setAttrs(@org.apache.thrift.annotation.Nullable java.util.List attrs) { + this.attrs = attrs; + return this; + } + + public void unsetAttrs() { + this.attrs = null; + } + + /** Returns true if field attrs is set (has been assigned a value) and false otherwise */ + public boolean isSetAttrs() { + return this.attrs != null; + } + + public void setAttrsIsSet(boolean value) { + if (!value) { + this.attrs = null; + } + } + + public long getResponseCount() { + return this.responseCount; + } + + public InternalStat setResponseCount(long responseCount) { + this.responseCount = responseCount; + setResponseCountIsSet(true); + return this; + } + + public void unsetResponseCount() { + __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __RESPONSECOUNT_ISSET_ID); + } + + /** Returns true if field responseCount is set (has been assigned a value) and false otherwise */ + public boolean isSetResponseCount() { + return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __RESPONSECOUNT_ISSET_ID); + } + + public void setResponseCountIsSet(boolean value) { + __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __RESPONSECOUNT_ISSET_ID, value); + } + + public double getMilliseconds() { + return this.milliseconds; + } + + public InternalStat setMilliseconds(double milliseconds) { + this.milliseconds = milliseconds; + setMillisecondsIsSet(true); + return this; + } + + public void unsetMilliseconds() { + __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __MILLISECONDS_ISSET_ID); + } + + /** Returns true if field milliseconds is set (has been assigned a value) and false otherwise */ + public boolean isSetMilliseconds() { + return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __MILLISECONDS_ISSET_ID); + } + + public void setMillisecondsIsSet(boolean value) { + __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __MILLISECONDS_ISSET_ID, value); + } + + public long getStartTimestamp() { + return this.startTimestamp; + } + + public InternalStat setStartTimestamp(long startTimestamp) { + this.startTimestamp = startTimestamp; + setStartTimestampIsSet(true); + return this; + } + + public void unsetStartTimestamp() { + __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __STARTTIMESTAMP_ISSET_ID); + } + + /** Returns true if field startTimestamp is set (has been assigned a value) and false otherwise */ + public boolean isSetStartTimestamp() { + return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __STARTTIMESTAMP_ISSET_ID); + } + + public void setStartTimestampIsSet(boolean value) { + __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __STARTTIMESTAMP_ISSET_ID, value); + } + + public boolean isSuccessful() { + return this.successful; + } + + public InternalStat setSuccessful(boolean successful) { + this.successful = successful; + setSuccessfulIsSet(true); + return this; + } + + public void unsetSuccessful() { + __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESSFUL_ISSET_ID); + } + + /** Returns true if field successful is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccessful() { + return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESSFUL_ISSET_ID); + } + + public void setSuccessfulIsSet(boolean value) { + __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESSFUL_ISSET_ID, value); + } + + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + case STAT_TYPE: + if (value == null) { + unsetStatType(); + } else { + setStatType((java.lang.String)value); + } + break; + + case M_BEAN: + if (value == null) { + unsetMBean(); + } else { + setMBean((java.lang.String)value); + } + break; + + case ATTRS: + if (value == null) { + unsetAttrs(); + } else { + setAttrs((java.util.List)value); + } + break; + + case RESPONSE_COUNT: + if (value == null) { + unsetResponseCount(); + } else { + setResponseCount((java.lang.Long)value); + } + break; + + case MILLISECONDS: + if (value == null) { + unsetMilliseconds(); + } else { + setMilliseconds((java.lang.Double)value); + } + break; + + case START_TIMESTAMP: + if (value == null) { + unsetStartTimestamp(); + } else { + setStartTimestamp((java.lang.Long)value); + } + break; + + case SUCCESSFUL: + if (value == null) { + unsetSuccessful(); + } else { + setSuccessful((java.lang.Boolean)value); + } + break; + + } + } + + @org.apache.thrift.annotation.Nullable + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case STAT_TYPE: + return getStatType(); + + case M_BEAN: + return getMBean(); + + case ATTRS: + return getAttrs(); + + case RESPONSE_COUNT: + return getResponseCount(); + + case MILLISECONDS: + return getMilliseconds(); + + case START_TIMESTAMP: + return getStartTimestamp(); + + case SUCCESSFUL: + return isSuccessful(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case STAT_TYPE: + return isSetStatType(); + case M_BEAN: + return isSetMBean(); + case ATTRS: + return isSetAttrs(); + case RESPONSE_COUNT: + return isSetResponseCount(); + case MILLISECONDS: + return isSetMilliseconds(); + case START_TIMESTAMP: + return isSetStartTimestamp(); + case SUCCESSFUL: + return isSetSuccessful(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof InternalStat) + return this.equals((InternalStat)that); + return false; + } + + public boolean equals(InternalStat that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_statType = true && this.isSetStatType(); + boolean that_present_statType = true && that.isSetStatType(); + if (this_present_statType || that_present_statType) { + if (!(this_present_statType && that_present_statType)) + return false; + if (!this.statType.equals(that.statType)) + return false; + } + + boolean this_present_mBean = true && this.isSetMBean(); + boolean that_present_mBean = true && that.isSetMBean(); + if (this_present_mBean || that_present_mBean) { + if (!(this_present_mBean && that_present_mBean)) + return false; + if (!this.mBean.equals(that.mBean)) + return false; + } + + boolean this_present_attrs = true && this.isSetAttrs(); + boolean that_present_attrs = true && that.isSetAttrs(); + if (this_present_attrs || that_present_attrs) { + if (!(this_present_attrs && that_present_attrs)) + return false; + if (!this.attrs.equals(that.attrs)) + return false; + } + + boolean this_present_responseCount = true; + boolean that_present_responseCount = true; + if (this_present_responseCount || that_present_responseCount) { + if (!(this_present_responseCount && that_present_responseCount)) + return false; + if (this.responseCount != that.responseCount) + return false; + } + + boolean this_present_milliseconds = true; + boolean that_present_milliseconds = true; + if (this_present_milliseconds || that_present_milliseconds) { + if (!(this_present_milliseconds && that_present_milliseconds)) + return false; + if (this.milliseconds != that.milliseconds) + return false; + } + + boolean this_present_startTimestamp = true; + boolean that_present_startTimestamp = true; + if (this_present_startTimestamp || that_present_startTimestamp) { + if (!(this_present_startTimestamp && that_present_startTimestamp)) + return false; + if (this.startTimestamp != that.startTimestamp) + return false; + } + + boolean this_present_successful = true; + boolean that_present_successful = true; + if (this_present_successful || that_present_successful) { + if (!(this_present_successful && that_present_successful)) + return false; + if (this.successful != that.successful) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetStatType()) ? 131071 : 524287); + if (isSetStatType()) + hashCode = hashCode * 8191 + statType.hashCode(); + + hashCode = hashCode * 8191 + ((isSetMBean()) ? 131071 : 524287); + if (isSetMBean()) + hashCode = hashCode * 8191 + mBean.hashCode(); + + hashCode = hashCode * 8191 + ((isSetAttrs()) ? 131071 : 524287); + if (isSetAttrs()) + hashCode = hashCode * 8191 + attrs.hashCode(); + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(responseCount); + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(milliseconds); + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(startTimestamp); + + hashCode = hashCode * 8191 + ((successful) ? 131071 : 524287); + + return hashCode; + } + + @Override + public int compareTo(InternalStat other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.compare(isSetStatType(), other.isSetStatType()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatType()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.statType, other.statType); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetMBean(), other.isSetMBean()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMBean()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.mBean, other.mBean); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetAttrs(), other.isSetAttrs()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetAttrs()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.attrs, other.attrs); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetResponseCount(), other.isSetResponseCount()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetResponseCount()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.responseCount, other.responseCount); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetMilliseconds(), other.isSetMilliseconds()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMilliseconds()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.milliseconds, other.milliseconds); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetStartTimestamp(), other.isSetStartTimestamp()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStartTimestamp()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.startTimestamp, other.startTimestamp); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetSuccessful(), other.isSetSuccessful()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccessful()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.successful, other.successful); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + @org.apache.thrift.annotation.Nullable + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("InternalStat("); + boolean first = true; + + sb.append("statType:"); + if (this.statType == null) { + sb.append("null"); + } else { + sb.append(this.statType); + } + first = false; + if (!first) sb.append(", "); + sb.append("mBean:"); + if (this.mBean == null) { + sb.append("null"); + } else { + sb.append(this.mBean); + } + first = false; + if (!first) sb.append(", "); + sb.append("attrs:"); + if (this.attrs == null) { + sb.append("null"); + } else { + sb.append(this.attrs); + } + first = false; + if (!first) sb.append(", "); + sb.append("responseCount:"); + sb.append(this.responseCount); + first = false; + if (!first) sb.append(", "); + sb.append("milliseconds:"); + sb.append(this.milliseconds); + first = false; + if (!first) sb.append(", "); + sb.append("startTimestamp:"); + sb.append(this.startTimestamp); + first = false; + if (!first) sb.append(", "); + sb.append("successful:"); + sb.append(this.successful); + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class InternalStatStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public InternalStatStandardScheme getScheme() { + return new InternalStatStandardScheme(); + } + } + + private static class InternalStatStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, InternalStat struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // STAT_TYPE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.statType = iprot.readString(); + struct.setStatTypeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // M_BEAN + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.mBean = iprot.readString(); + struct.setMBeanIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // ATTRS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list0 = iprot.readListBegin(); + struct.attrs = new java.util.ArrayList(_list0.size); + @org.apache.thrift.annotation.Nullable java.lang.String _elem1; + for (int _i2 = 0; _i2 < _list0.size; ++_i2) + { + _elem1 = iprot.readString(); + struct.attrs.add(_elem1); + } + iprot.readListEnd(); + } + struct.setAttrsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // RESPONSE_COUNT + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.responseCount = iprot.readI64(); + struct.setResponseCountIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 5: // MILLISECONDS + if (schemeField.type == org.apache.thrift.protocol.TType.DOUBLE) { + struct.milliseconds = iprot.readDouble(); + struct.setMillisecondsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 6: // START_TIMESTAMP + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.startTimestamp = iprot.readI64(); + struct.setStartTimestampIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 7: // SUCCESSFUL + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.successful = iprot.readBool(); + struct.setSuccessfulIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, InternalStat struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.statType != null) { + oprot.writeFieldBegin(STAT_TYPE_FIELD_DESC); + oprot.writeString(struct.statType); + oprot.writeFieldEnd(); + } + if (struct.mBean != null) { + oprot.writeFieldBegin(M_BEAN_FIELD_DESC); + oprot.writeString(struct.mBean); + oprot.writeFieldEnd(); + } + if (struct.attrs != null) { + oprot.writeFieldBegin(ATTRS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.attrs.size())); + for (java.lang.String _iter3 : struct.attrs) + { + oprot.writeString(_iter3); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(RESPONSE_COUNT_FIELD_DESC); + oprot.writeI64(struct.responseCount); + oprot.writeFieldEnd(); + oprot.writeFieldBegin(MILLISECONDS_FIELD_DESC); + oprot.writeDouble(struct.milliseconds); + oprot.writeFieldEnd(); + oprot.writeFieldBegin(START_TIMESTAMP_FIELD_DESC); + oprot.writeI64(struct.startTimestamp); + oprot.writeFieldEnd(); + oprot.writeFieldBegin(SUCCESSFUL_FIELD_DESC); + oprot.writeBool(struct.successful); + oprot.writeFieldEnd(); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class InternalStatTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public InternalStatTupleScheme getScheme() { + return new InternalStatTupleScheme(); + } + } + + private static class InternalStatTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, InternalStat struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetStatType()) { + optionals.set(0); + } + if (struct.isSetMBean()) { + optionals.set(1); + } + if (struct.isSetAttrs()) { + optionals.set(2); + } + if (struct.isSetResponseCount()) { + optionals.set(3); + } + if (struct.isSetMilliseconds()) { + optionals.set(4); + } + if (struct.isSetStartTimestamp()) { + optionals.set(5); + } + if (struct.isSetSuccessful()) { + optionals.set(6); + } + oprot.writeBitSet(optionals, 7); + if (struct.isSetStatType()) { + oprot.writeString(struct.statType); + } + if (struct.isSetMBean()) { + oprot.writeString(struct.mBean); + } + if (struct.isSetAttrs()) { + { + oprot.writeI32(struct.attrs.size()); + for (java.lang.String _iter4 : struct.attrs) + { + oprot.writeString(_iter4); + } + } + } + if (struct.isSetResponseCount()) { + oprot.writeI64(struct.responseCount); + } + if (struct.isSetMilliseconds()) { + oprot.writeDouble(struct.milliseconds); + } + if (struct.isSetStartTimestamp()) { + oprot.writeI64(struct.startTimestamp); + } + if (struct.isSetSuccessful()) { + oprot.writeBool(struct.successful); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, InternalStat struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(7); + if (incoming.get(0)) { + struct.statType = iprot.readString(); + struct.setStatTypeIsSet(true); + } + if (incoming.get(1)) { + struct.mBean = iprot.readString(); + struct.setMBeanIsSet(true); + } + if (incoming.get(2)) { + { + org.apache.thrift.protocol.TList _list5 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRING); + struct.attrs = new java.util.ArrayList(_list5.size); + @org.apache.thrift.annotation.Nullable java.lang.String _elem6; + for (int _i7 = 0; _i7 < _list5.size; ++_i7) + { + _elem6 = iprot.readString(); + struct.attrs.add(_elem6); + } + } + struct.setAttrsIsSet(true); + } + if (incoming.get(3)) { + struct.responseCount = iprot.readI64(); + struct.setResponseCountIsSet(true); + } + if (incoming.get(4)) { + struct.milliseconds = iprot.readDouble(); + struct.setMillisecondsIsSet(true); + } + if (incoming.get(5)) { + struct.startTimestamp = iprot.readI64(); + struct.setStartTimestampIsSet(true); + } + if (incoming.get(6)) { + struct.successful = iprot.readBool(); + struct.setSuccessfulIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } +} + diff --git a/src/main/java/org/newrelic/nrjmx/v2/nrprotocol/JMXConfig.java b/src/main/java/org/newrelic/nrjmx/v2/nrprotocol/JMXConfig.java index f8689a0..bd79dad 100644 --- a/src/main/java/org/newrelic/nrjmx/v2/nrprotocol/JMXConfig.java +++ b/src/main/java/org/newrelic/nrjmx/v2/nrprotocol/JMXConfig.java @@ -25,6 +25,8 @@ public class JMXConfig implements org.apache.thrift.TBase byName = new java.util.HashMap(); @@ -107,6 +113,10 @@ public static _Fields findByThriftId(int fieldId) { return REQUEST_TIMEOUT_MS; case 15: // VERBOSE return VERBOSE; + case 16: // ENABLE_INTERNAL_STATS + return ENABLE_INTERNAL_STATS; + case 17: // MAX_INTERNAL_STATS_SIZE + return MAX_INTERNAL_STATS_SIZE; default: return null; } @@ -154,6 +164,8 @@ public java.lang.String getFieldName() { private static final int __USESSL_ISSET_ID = 3; private static final int __REQUESTTIMEOUTMS_ISSET_ID = 4; private static final int __VERBOSE_ISSET_ID = 5; + private static final int __ENABLEINTERNALSTATS_ISSET_ID = 6; + private static final int __MAXINTERNALSTATSSIZE_ISSET_ID = 7; private byte __isset_bitfield = 0; private static final _Fields optionals[] = {_Fields.URI_PATH}; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; @@ -189,6 +201,10 @@ public java.lang.String getFieldName() { new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.VERBOSE, new org.apache.thrift.meta_data.FieldMetaData("verbose", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.ENABLE_INTERNAL_STATS, new org.apache.thrift.meta_data.FieldMetaData("enableInternalStats", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.MAX_INTERNAL_STATS_SIZE, new org.apache.thrift.meta_data.FieldMetaData("maxInternalStatsSize", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(JMXConfig.class, metaDataMap); } @@ -210,7 +226,9 @@ public JMXConfig( boolean isJBossStandaloneMode, boolean useSSL, long requestTimeoutMs, - boolean verbose) + boolean verbose, + boolean enableInternalStats, + long maxInternalStatsSize) { this(); this.connectionURL = connectionURL; @@ -233,6 +251,10 @@ public JMXConfig( setRequestTimeoutMsIsSet(true); this.verbose = verbose; setVerboseIsSet(true); + this.enableInternalStats = enableInternalStats; + setEnableInternalStatsIsSet(true); + this.maxInternalStatsSize = maxInternalStatsSize; + setMaxInternalStatsSizeIsSet(true); } /** @@ -273,6 +295,8 @@ public JMXConfig(JMXConfig other) { this.useSSL = other.useSSL; this.requestTimeoutMs = other.requestTimeoutMs; this.verbose = other.verbose; + this.enableInternalStats = other.enableInternalStats; + this.maxInternalStatsSize = other.maxInternalStatsSize; } public JMXConfig deepCopy() { @@ -302,6 +326,10 @@ public void clear() { this.requestTimeoutMs = 0; setVerboseIsSet(false); this.verbose = false; + setEnableInternalStatsIsSet(false); + this.enableInternalStats = false; + setMaxInternalStatsSizeIsSet(false); + this.maxInternalStatsSize = 0; } @org.apache.thrift.annotation.Nullable @@ -667,6 +695,52 @@ public void setVerboseIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __VERBOSE_ISSET_ID, value); } + public boolean isEnableInternalStats() { + return this.enableInternalStats; + } + + public JMXConfig setEnableInternalStats(boolean enableInternalStats) { + this.enableInternalStats = enableInternalStats; + setEnableInternalStatsIsSet(true); + return this; + } + + public void unsetEnableInternalStats() { + __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __ENABLEINTERNALSTATS_ISSET_ID); + } + + /** Returns true if field enableInternalStats is set (has been assigned a value) and false otherwise */ + public boolean isSetEnableInternalStats() { + return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __ENABLEINTERNALSTATS_ISSET_ID); + } + + public void setEnableInternalStatsIsSet(boolean value) { + __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __ENABLEINTERNALSTATS_ISSET_ID, value); + } + + public long getMaxInternalStatsSize() { + return this.maxInternalStatsSize; + } + + public JMXConfig setMaxInternalStatsSize(long maxInternalStatsSize) { + this.maxInternalStatsSize = maxInternalStatsSize; + setMaxInternalStatsSizeIsSet(true); + return this; + } + + public void unsetMaxInternalStatsSize() { + __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __MAXINTERNALSTATSSIZE_ISSET_ID); + } + + /** Returns true if field maxInternalStatsSize is set (has been assigned a value) and false otherwise */ + public boolean isSetMaxInternalStatsSize() { + return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __MAXINTERNALSTATSSIZE_ISSET_ID); + } + + public void setMaxInternalStatsSizeIsSet(boolean value) { + __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __MAXINTERNALSTATSSIZE_ISSET_ID, value); + } + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { switch (field) { case CONNECTION_URL: @@ -789,6 +863,22 @@ public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable } break; + case ENABLE_INTERNAL_STATS: + if (value == null) { + unsetEnableInternalStats(); + } else { + setEnableInternalStats((java.lang.Boolean)value); + } + break; + + case MAX_INTERNAL_STATS_SIZE: + if (value == null) { + unsetMaxInternalStatsSize(); + } else { + setMaxInternalStatsSize((java.lang.Long)value); + } + break; + } } @@ -840,6 +930,12 @@ public java.lang.Object getFieldValue(_Fields field) { case VERBOSE: return isVerbose(); + case ENABLE_INTERNAL_STATS: + return isEnableInternalStats(); + + case MAX_INTERNAL_STATS_SIZE: + return getMaxInternalStatsSize(); + } throw new java.lang.IllegalStateException(); } @@ -881,6 +977,10 @@ public boolean isSet(_Fields field) { return isSetRequestTimeoutMs(); case VERBOSE: return isSetVerbose(); + case ENABLE_INTERNAL_STATS: + return isSetEnableInternalStats(); + case MAX_INTERNAL_STATS_SIZE: + return isSetMaxInternalStatsSize(); } throw new java.lang.IllegalStateException(); } @@ -1033,6 +1133,24 @@ public boolean equals(JMXConfig that) { return false; } + boolean this_present_enableInternalStats = true; + boolean that_present_enableInternalStats = true; + if (this_present_enableInternalStats || that_present_enableInternalStats) { + if (!(this_present_enableInternalStats && that_present_enableInternalStats)) + return false; + if (this.enableInternalStats != that.enableInternalStats) + return false; + } + + boolean this_present_maxInternalStatsSize = true; + boolean that_present_maxInternalStatsSize = true; + if (this_present_maxInternalStatsSize || that_present_maxInternalStatsSize) { + if (!(this_present_maxInternalStatsSize && that_present_maxInternalStatsSize)) + return false; + if (this.maxInternalStatsSize != that.maxInternalStatsSize) + return false; + } + return true; } @@ -1088,6 +1206,10 @@ public int hashCode() { hashCode = hashCode * 8191 + ((verbose) ? 131071 : 524287); + hashCode = hashCode * 8191 + ((enableInternalStats) ? 131071 : 524287); + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(maxInternalStatsSize); + return hashCode; } @@ -1249,6 +1371,26 @@ public int compareTo(JMXConfig other) { return lastComparison; } } + lastComparison = java.lang.Boolean.compare(isSetEnableInternalStats(), other.isSetEnableInternalStats()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetEnableInternalStats()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.enableInternalStats, other.enableInternalStats); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetMaxInternalStatsSize(), other.isSetMaxInternalStatsSize()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMaxInternalStatsSize()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.maxInternalStatsSize, other.maxInternalStatsSize); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -1367,6 +1509,14 @@ public java.lang.String toString() { sb.append("verbose:"); sb.append(this.verbose); first = false; + if (!first) sb.append(", "); + sb.append("enableInternalStats:"); + sb.append(this.enableInternalStats); + first = false; + if (!first) sb.append(", "); + sb.append("maxInternalStatsSize:"); + sb.append(this.maxInternalStatsSize); + first = false; sb.append(")"); return sb.toString(); } @@ -1532,6 +1682,22 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, JMXConfig struct) t org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 16: // ENABLE_INTERNAL_STATS + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.enableInternalStats = iprot.readBool(); + struct.setEnableInternalStatsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 17: // MAX_INTERNAL_STATS_SIZE + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.maxInternalStatsSize = iprot.readI64(); + struct.setMaxInternalStatsSizeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -1612,6 +1778,12 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, JMXConfig struct) oprot.writeFieldBegin(VERBOSE_FIELD_DESC); oprot.writeBool(struct.verbose); oprot.writeFieldEnd(); + oprot.writeFieldBegin(ENABLE_INTERNAL_STATS_FIELD_DESC); + oprot.writeBool(struct.enableInternalStats); + oprot.writeFieldEnd(); + oprot.writeFieldBegin(MAX_INTERNAL_STATS_SIZE_FIELD_DESC); + oprot.writeI64(struct.maxInternalStatsSize); + oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -1675,7 +1847,13 @@ public void write(org.apache.thrift.protocol.TProtocol prot, JMXConfig struct) t if (struct.isSetVerbose()) { optionals.set(14); } - oprot.writeBitSet(optionals, 15); + if (struct.isSetEnableInternalStats()) { + optionals.set(15); + } + if (struct.isSetMaxInternalStatsSize()) { + optionals.set(16); + } + oprot.writeBitSet(optionals, 17); if (struct.isSetConnectionURL()) { oprot.writeString(struct.connectionURL); } @@ -1721,12 +1899,18 @@ public void write(org.apache.thrift.protocol.TProtocol prot, JMXConfig struct) t if (struct.isSetVerbose()) { oprot.writeBool(struct.verbose); } + if (struct.isSetEnableInternalStats()) { + oprot.writeBool(struct.enableInternalStats); + } + if (struct.isSetMaxInternalStatsSize()) { + oprot.writeI64(struct.maxInternalStatsSize); + } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, JMXConfig struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; - java.util.BitSet incoming = iprot.readBitSet(15); + java.util.BitSet incoming = iprot.readBitSet(17); if (incoming.get(0)) { struct.connectionURL = iprot.readString(); struct.setConnectionURLIsSet(true); @@ -1787,6 +1971,14 @@ public void read(org.apache.thrift.protocol.TProtocol prot, JMXConfig struct) th struct.verbose = iprot.readBool(); struct.setVerboseIsSet(true); } + if (incoming.get(15)) { + struct.enableInternalStats = iprot.readBool(); + struct.setEnableInternalStatsIsSet(true); + } + if (incoming.get(16)) { + struct.maxInternalStatsSize = iprot.readI64(); + struct.setMaxInternalStatsSizeIsSet(true); + } } } diff --git a/src/main/java/org/newrelic/nrjmx/v2/nrprotocol/JMXService.java b/src/main/java/org/newrelic/nrjmx/v2/nrprotocol/JMXService.java index a21dc67..7a83395 100644 --- a/src/main/java/org/newrelic/nrjmx/v2/nrprotocol/JMXService.java +++ b/src/main/java/org/newrelic/nrjmx/v2/nrprotocol/JMXService.java @@ -25,6 +25,8 @@ public interface Iface { public java.util.List queryMBeanAttributes(java.lang.String mBeanNamePattern, java.util.List attributes) throws JMXConnectionError, JMXError, org.apache.thrift.TException; + public java.util.List getInternalStats() throws JMXError, org.apache.thrift.TException; + } public interface AsyncIface { @@ -43,6 +45,8 @@ public interface AsyncIface { public void queryMBeanAttributes(java.lang.String mBeanNamePattern, java.util.List attributes, org.apache.thrift.async.AsyncMethodCallback> resultHandler) throws org.apache.thrift.TException; + public void getInternalStats(org.apache.thrift.async.AsyncMethodCallback> resultHandler) throws org.apache.thrift.TException; + } public static class Client extends org.apache.thrift.TServiceClient implements Iface { @@ -256,6 +260,31 @@ public java.util.List recv_queryMBeanAttributes() throws JMXC throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "queryMBeanAttributes failed: unknown result"); } + public java.util.List getInternalStats() throws JMXError, org.apache.thrift.TException + { + send_getInternalStats(); + return recv_getInternalStats(); + } + + public void send_getInternalStats() throws org.apache.thrift.TException + { + getInternalStats_args args = new getInternalStats_args(); + sendBase("getInternalStats", args); + } + + public java.util.List recv_getInternalStats() throws JMXError, org.apache.thrift.TException + { + getInternalStats_result result = new getInternalStats_result(); + receiveBase(result, "getInternalStats"); + if (result.isSetSuccess()) { + return result.success; + } + if (result.jmxErr != null) { + throw result.jmxErr; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getInternalStats failed: unknown result"); + } + } public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { public static class Factory implements org.apache.thrift.async.TAsyncClientFactory { @@ -498,6 +527,35 @@ public java.util.List getResult() throws JMXConnectionError, } } + public void getInternalStats(org.apache.thrift.async.AsyncMethodCallback> resultHandler) throws org.apache.thrift.TException { + checkReady(); + getInternalStats_call method_call = new getInternalStats_call(resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class getInternalStats_call extends org.apache.thrift.async.TAsyncMethodCall> { + public getInternalStats_call(org.apache.thrift.async.AsyncMethodCallback> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getInternalStats", org.apache.thrift.protocol.TMessageType.CALL, 0)); + getInternalStats_args args = new getInternalStats_args(); + args.write(prot); + prot.writeMessageEnd(); + } + + public java.util.List getResult() throws JMXError, org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new java.lang.IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_getInternalStats(); + } + } + } public static class Processor extends org.apache.thrift.TBaseProcessor implements org.apache.thrift.TProcessor { @@ -518,6 +576,7 @@ protected Processor(I iface, java.util.Map extends org.apache.thrift.ProcessFunction { + public getInternalStats() { + super("getInternalStats"); + } + + public getInternalStats_args getEmptyArgsInstance() { + return new getInternalStats_args(); + } + + protected boolean isOneway() { + return false; + } + + @Override + protected boolean rethrowUnhandledExceptions() { + return false; + } + + public getInternalStats_result getResult(I iface, getInternalStats_args args) throws org.apache.thrift.TException { + getInternalStats_result result = new getInternalStats_result(); + try { + result.success = iface.getInternalStats(); + } catch (JMXError jmxErr) { + result.jmxErr = jmxErr; + } + return result; + } + } + } public static class AsyncProcessor extends org.apache.thrift.TBaseAsyncProcessor { @@ -754,6 +842,7 @@ protected AsyncProcessor(I iface, java.util.Map extends org.apache.thrift.AsyncProcessFunction> { + public getInternalStats() { + super("getInternalStats"); + } + + public getInternalStats_args getEmptyArgsInstance() { + return new getInternalStats_args(); + } + + public org.apache.thrift.async.AsyncMethodCallback> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new org.apache.thrift.async.AsyncMethodCallback>() { + public void onComplete(java.util.List o) { + getInternalStats_result result = new getInternalStats_result(); + result.success = o; + try { + fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + } catch (org.apache.thrift.transport.TTransportException e) { + _LOGGER.error("TTransportException writing to internal frame buffer", e); + fb.close(); + } catch (java.lang.Exception e) { + _LOGGER.error("Exception writing to internal frame buffer", e); + onError(e); + } + } + public void onError(java.lang.Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TSerializable msg; + getInternalStats_result result = new getInternalStats_result(); + if (e instanceof JMXError) { + result.jmxErr = (JMXError) e; + result.setJmxErrIsSet(true); + msg = result; + } else if (e instanceof org.apache.thrift.transport.TTransportException) { + _LOGGER.error("TTransportException inside handler", e); + fb.close(); + return; + } else if (e instanceof org.apache.thrift.TApplicationException) { + _LOGGER.error("TApplicationException inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TApplicationException)e; + } else { + _LOGGER.error("Exception inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + } catch (java.lang.Exception ex) { + _LOGGER.error("Exception writing to internal frame buffer", ex); + fb.close(); + } + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, getInternalStats_args args, org.apache.thrift.async.AsyncMethodCallback> resultHandler) throws org.apache.thrift.TException { + iface.getInternalStats(resultHandler); + } + } + } public static class connect_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { @@ -4263,13 +4417,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, queryMBeanNames_res case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list0 = iprot.readListBegin(); - struct.success = new java.util.ArrayList(_list0.size); - @org.apache.thrift.annotation.Nullable java.lang.String _elem1; - for (int _i2 = 0; _i2 < _list0.size; ++_i2) + org.apache.thrift.protocol.TList _list8 = iprot.readListBegin(); + struct.success = new java.util.ArrayList(_list8.size); + @org.apache.thrift.annotation.Nullable java.lang.String _elem9; + for (int _i10 = 0; _i10 < _list8.size; ++_i10) { - _elem1 = iprot.readString(); - struct.success.add(_elem1); + _elem9 = iprot.readString(); + struct.success.add(_elem9); } iprot.readListEnd(); } @@ -4315,9 +4469,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, queryMBeanNames_re oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.success.size())); - for (java.lang.String _iter3 : struct.success) + for (java.lang.String _iter11 : struct.success) { - oprot.writeString(_iter3); + oprot.writeString(_iter11); } oprot.writeListEnd(); } @@ -4364,9 +4518,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, queryMBeanNames_res if (struct.isSetSuccess()) { { oprot.writeI32(struct.success.size()); - for (java.lang.String _iter4 : struct.success) + for (java.lang.String _iter12 : struct.success) { - oprot.writeString(_iter4); + oprot.writeString(_iter12); } } } @@ -4384,13 +4538,13 @@ public void read(org.apache.thrift.protocol.TProtocol prot, queryMBeanNames_resu java.util.BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { { - org.apache.thrift.protocol.TList _list5 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRING); - struct.success = new java.util.ArrayList(_list5.size); - @org.apache.thrift.annotation.Nullable java.lang.String _elem6; - for (int _i7 = 0; _i7 < _list5.size; ++_i7) + org.apache.thrift.protocol.TList _list13 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRING); + struct.success = new java.util.ArrayList(_list13.size); + @org.apache.thrift.annotation.Nullable java.lang.String _elem14; + for (int _i15 = 0; _i15 < _list13.size; ++_i15) { - _elem6 = iprot.readString(); - struct.success.add(_elem6); + _elem14 = iprot.readString(); + struct.success.add(_elem14); } } struct.setSuccessIsSet(true); @@ -5257,13 +5411,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getMBeanAttributeNa case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list8 = iprot.readListBegin(); - struct.success = new java.util.ArrayList(_list8.size); - @org.apache.thrift.annotation.Nullable java.lang.String _elem9; - for (int _i10 = 0; _i10 < _list8.size; ++_i10) + org.apache.thrift.protocol.TList _list16 = iprot.readListBegin(); + struct.success = new java.util.ArrayList(_list16.size); + @org.apache.thrift.annotation.Nullable java.lang.String _elem17; + for (int _i18 = 0; _i18 < _list16.size; ++_i18) { - _elem9 = iprot.readString(); - struct.success.add(_elem9); + _elem17 = iprot.readString(); + struct.success.add(_elem17); } iprot.readListEnd(); } @@ -5309,9 +5463,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getMBeanAttributeN oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.success.size())); - for (java.lang.String _iter11 : struct.success) + for (java.lang.String _iter19 : struct.success) { - oprot.writeString(_iter11); + oprot.writeString(_iter19); } oprot.writeListEnd(); } @@ -5358,9 +5512,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, getMBeanAttributeNa if (struct.isSetSuccess()) { { oprot.writeI32(struct.success.size()); - for (java.lang.String _iter12 : struct.success) + for (java.lang.String _iter20 : struct.success) { - oprot.writeString(_iter12); + oprot.writeString(_iter20); } } } @@ -5378,13 +5532,13 @@ public void read(org.apache.thrift.protocol.TProtocol prot, getMBeanAttributeNam java.util.BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { { - org.apache.thrift.protocol.TList _list13 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRING); - struct.success = new java.util.ArrayList(_list13.size); - @org.apache.thrift.annotation.Nullable java.lang.String _elem14; - for (int _i15 = 0; _i15 < _list13.size; ++_i15) + org.apache.thrift.protocol.TList _list21 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRING); + struct.success = new java.util.ArrayList(_list21.size); + @org.apache.thrift.annotation.Nullable java.lang.String _elem22; + for (int _i23 = 0; _i23 < _list21.size; ++_i23) { - _elem14 = iprot.readString(); - struct.success.add(_elem14); + _elem22 = iprot.readString(); + struct.success.add(_elem22); } } struct.setSuccessIsSet(true); @@ -5812,13 +5966,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getMBeanAttributes_ case 2: // ATTRIBUTES if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list16 = iprot.readListBegin(); - struct.attributes = new java.util.ArrayList(_list16.size); - @org.apache.thrift.annotation.Nullable java.lang.String _elem17; - for (int _i18 = 0; _i18 < _list16.size; ++_i18) + org.apache.thrift.protocol.TList _list24 = iprot.readListBegin(); + struct.attributes = new java.util.ArrayList(_list24.size); + @org.apache.thrift.annotation.Nullable java.lang.String _elem25; + for (int _i26 = 0; _i26 < _list24.size; ++_i26) { - _elem17 = iprot.readString(); - struct.attributes.add(_elem17); + _elem25 = iprot.readString(); + struct.attributes.add(_elem25); } iprot.readListEnd(); } @@ -5851,9 +6005,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getMBeanAttributes oprot.writeFieldBegin(ATTRIBUTES_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.attributes.size())); - for (java.lang.String _iter19 : struct.attributes) + for (java.lang.String _iter27 : struct.attributes) { - oprot.writeString(_iter19); + oprot.writeString(_iter27); } oprot.writeListEnd(); } @@ -5890,9 +6044,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, getMBeanAttributes_ if (struct.isSetAttributes()) { { oprot.writeI32(struct.attributes.size()); - for (java.lang.String _iter20 : struct.attributes) + for (java.lang.String _iter28 : struct.attributes) { - oprot.writeString(_iter20); + oprot.writeString(_iter28); } } } @@ -5908,13 +6062,13 @@ public void read(org.apache.thrift.protocol.TProtocol prot, getMBeanAttributes_a } if (incoming.get(1)) { { - org.apache.thrift.protocol.TList _list21 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRING); - struct.attributes = new java.util.ArrayList(_list21.size); - @org.apache.thrift.annotation.Nullable java.lang.String _elem22; - for (int _i23 = 0; _i23 < _list21.size; ++_i23) + org.apache.thrift.protocol.TList _list29 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRING); + struct.attributes = new java.util.ArrayList(_list29.size); + @org.apache.thrift.annotation.Nullable java.lang.String _elem30; + for (int _i31 = 0; _i31 < _list29.size; ++_i31) { - _elem22 = iprot.readString(); - struct.attributes.add(_elem22); + _elem30 = iprot.readString(); + struct.attributes.add(_elem30); } } struct.setAttributesIsSet(true); @@ -6409,14 +6563,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, getMBeanAttributes_ case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list24 = iprot.readListBegin(); - struct.success = new java.util.ArrayList(_list24.size); - @org.apache.thrift.annotation.Nullable AttributeResponse _elem25; - for (int _i26 = 0; _i26 < _list24.size; ++_i26) + org.apache.thrift.protocol.TList _list32 = iprot.readListBegin(); + struct.success = new java.util.ArrayList(_list32.size); + @org.apache.thrift.annotation.Nullable AttributeResponse _elem33; + for (int _i34 = 0; _i34 < _list32.size; ++_i34) { - _elem25 = new AttributeResponse(); - _elem25.read(iprot); - struct.success.add(_elem25); + _elem33 = new AttributeResponse(); + _elem33.read(iprot); + struct.success.add(_elem33); } iprot.readListEnd(); } @@ -6462,9 +6616,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, getMBeanAttributes oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.success.size())); - for (AttributeResponse _iter27 : struct.success) + for (AttributeResponse _iter35 : struct.success) { - _iter27.write(oprot); + _iter35.write(oprot); } oprot.writeListEnd(); } @@ -6511,9 +6665,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, getMBeanAttributes_ if (struct.isSetSuccess()) { { oprot.writeI32(struct.success.size()); - for (AttributeResponse _iter28 : struct.success) + for (AttributeResponse _iter36 : struct.success) { - _iter28.write(oprot); + _iter36.write(oprot); } } } @@ -6531,14 +6685,14 @@ public void read(org.apache.thrift.protocol.TProtocol prot, getMBeanAttributes_r java.util.BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { { - org.apache.thrift.protocol.TList _list29 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT); - struct.success = new java.util.ArrayList(_list29.size); - @org.apache.thrift.annotation.Nullable AttributeResponse _elem30; - for (int _i31 = 0; _i31 < _list29.size; ++_i31) + org.apache.thrift.protocol.TList _list37 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT); + struct.success = new java.util.ArrayList(_list37.size); + @org.apache.thrift.annotation.Nullable AttributeResponse _elem38; + for (int _i39 = 0; _i39 < _list37.size; ++_i39) { - _elem30 = new AttributeResponse(); - _elem30.read(iprot); - struct.success.add(_elem30); + _elem38 = new AttributeResponse(); + _elem38.read(iprot); + struct.success.add(_elem38); } } struct.setSuccessIsSet(true); @@ -6966,13 +7120,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, queryMBeanAttribute case 2: // ATTRIBUTES if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list32 = iprot.readListBegin(); - struct.attributes = new java.util.ArrayList(_list32.size); - @org.apache.thrift.annotation.Nullable java.lang.String _elem33; - for (int _i34 = 0; _i34 < _list32.size; ++_i34) + org.apache.thrift.protocol.TList _list40 = iprot.readListBegin(); + struct.attributes = new java.util.ArrayList(_list40.size); + @org.apache.thrift.annotation.Nullable java.lang.String _elem41; + for (int _i42 = 0; _i42 < _list40.size; ++_i42) { - _elem33 = iprot.readString(); - struct.attributes.add(_elem33); + _elem41 = iprot.readString(); + struct.attributes.add(_elem41); } iprot.readListEnd(); } @@ -7005,9 +7159,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, queryMBeanAttribut oprot.writeFieldBegin(ATTRIBUTES_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.attributes.size())); - for (java.lang.String _iter35 : struct.attributes) + for (java.lang.String _iter43 : struct.attributes) { - oprot.writeString(_iter35); + oprot.writeString(_iter43); } oprot.writeListEnd(); } @@ -7044,9 +7198,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, queryMBeanAttribute if (struct.isSetAttributes()) { { oprot.writeI32(struct.attributes.size()); - for (java.lang.String _iter36 : struct.attributes) + for (java.lang.String _iter44 : struct.attributes) { - oprot.writeString(_iter36); + oprot.writeString(_iter44); } } } @@ -7062,13 +7216,13 @@ public void read(org.apache.thrift.protocol.TProtocol prot, queryMBeanAttributes } if (incoming.get(1)) { { - org.apache.thrift.protocol.TList _list37 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRING); - struct.attributes = new java.util.ArrayList(_list37.size); - @org.apache.thrift.annotation.Nullable java.lang.String _elem38; - for (int _i39 = 0; _i39 < _list37.size; ++_i39) + org.apache.thrift.protocol.TList _list45 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRING); + struct.attributes = new java.util.ArrayList(_list45.size); + @org.apache.thrift.annotation.Nullable java.lang.String _elem46; + for (int _i47 = 0; _i47 < _list45.size; ++_i47) { - _elem38 = iprot.readString(); - struct.attributes.add(_elem38); + _elem46 = iprot.readString(); + struct.attributes.add(_elem46); } } struct.setAttributesIsSet(true); @@ -7563,14 +7717,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, queryMBeanAttribute case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list40 = iprot.readListBegin(); - struct.success = new java.util.ArrayList(_list40.size); - @org.apache.thrift.annotation.Nullable AttributeResponse _elem41; - for (int _i42 = 0; _i42 < _list40.size; ++_i42) + org.apache.thrift.protocol.TList _list48 = iprot.readListBegin(); + struct.success = new java.util.ArrayList(_list48.size); + @org.apache.thrift.annotation.Nullable AttributeResponse _elem49; + for (int _i50 = 0; _i50 < _list48.size; ++_i50) { - _elem41 = new AttributeResponse(); - _elem41.read(iprot); - struct.success.add(_elem41); + _elem49 = new AttributeResponse(); + _elem49.read(iprot); + struct.success.add(_elem49); } iprot.readListEnd(); } @@ -7616,9 +7770,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, queryMBeanAttribut oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.success.size())); - for (AttributeResponse _iter43 : struct.success) + for (AttributeResponse _iter51 : struct.success) { - _iter43.write(oprot); + _iter51.write(oprot); } oprot.writeListEnd(); } @@ -7665,9 +7819,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, queryMBeanAttribute if (struct.isSetSuccess()) { { oprot.writeI32(struct.success.size()); - for (AttributeResponse _iter44 : struct.success) + for (AttributeResponse _iter52 : struct.success) { - _iter44.write(oprot); + _iter52.write(oprot); } } } @@ -7685,14 +7839,14 @@ public void read(org.apache.thrift.protocol.TProtocol prot, queryMBeanAttributes java.util.BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { { - org.apache.thrift.protocol.TList _list45 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT); - struct.success = new java.util.ArrayList(_list45.size); - @org.apache.thrift.annotation.Nullable AttributeResponse _elem46; - for (int _i47 = 0; _i47 < _list45.size; ++_i47) + org.apache.thrift.protocol.TList _list53 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT); + struct.success = new java.util.ArrayList(_list53.size); + @org.apache.thrift.annotation.Nullable AttributeResponse _elem54; + for (int _i55 = 0; _i55 < _list53.size; ++_i55) { - _elem46 = new AttributeResponse(); - _elem46.read(iprot); - struct.success.add(_elem46); + _elem54 = new AttributeResponse(); + _elem54.read(iprot); + struct.success.add(_elem54); } } struct.setSuccessIsSet(true); @@ -7715,4 +7869,783 @@ private static S scheme(org.apache. } } + public static class getInternalStats_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getInternalStats_args"); + + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getInternalStats_argsStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getInternalStats_argsTupleSchemeFactory(); + + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { +; + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public java.lang.String getFieldName() { + return _fieldName; + } + } + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getInternalStats_args.class, metaDataMap); + } + + public getInternalStats_args() { + } + + /** + * Performs a deep copy on other. + */ + public getInternalStats_args(getInternalStats_args other) { + } + + public getInternalStats_args deepCopy() { + return new getInternalStats_args(this); + } + + @Override + public void clear() { + } + + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + } + } + + @org.apache.thrift.annotation.Nullable + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof getInternalStats_args) + return this.equals((getInternalStats_args)that); + return false; + } + + public boolean equals(getInternalStats_args that) { + if (that == null) + return false; + if (this == that) + return true; + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + return hashCode; + } + + @Override + public int compareTo(getInternalStats_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + return 0; + } + + @org.apache.thrift.annotation.Nullable + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("getInternalStats_args("); + boolean first = true; + + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class getInternalStats_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public getInternalStats_argsStandardScheme getScheme() { + return new getInternalStats_argsStandardScheme(); + } + } + + private static class getInternalStats_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, getInternalStats_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, getInternalStats_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getInternalStats_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public getInternalStats_argsTupleScheme getScheme() { + return new getInternalStats_argsTupleScheme(); + } + } + + private static class getInternalStats_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getInternalStats_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getInternalStats_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + public static class getInternalStats_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getInternalStats_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.LIST, (short)0); + private static final org.apache.thrift.protocol.TField JMX_ERR_FIELD_DESC = new org.apache.thrift.protocol.TField("jmxErr", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getInternalStats_resultStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getInternalStats_resultTupleSchemeFactory(); + + public @org.apache.thrift.annotation.Nullable java.util.List success; // required + public @org.apache.thrift.annotation.Nullable JMXError jmxErr; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"), + JMX_ERR((short)1, "jmxErr"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + case 1: // JMX_ERR + return JMX_ERR; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + @org.apache.thrift.annotation.Nullable + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, InternalStat.class)))); + tmpMap.put(_Fields.JMX_ERR, new org.apache.thrift.meta_data.FieldMetaData("jmxErr", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, JMXError.class))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getInternalStats_result.class, metaDataMap); + } + + public getInternalStats_result() { + } + + public getInternalStats_result( + java.util.List success, + JMXError jmxErr) + { + this(); + this.success = success; + this.jmxErr = jmxErr; + } + + /** + * Performs a deep copy on other. + */ + public getInternalStats_result(getInternalStats_result other) { + if (other.isSetSuccess()) { + java.util.List __this__success = new java.util.ArrayList(other.success.size()); + for (InternalStat other_element : other.success) { + __this__success.add(new InternalStat(other_element)); + } + this.success = __this__success; + } + if (other.isSetJmxErr()) { + this.jmxErr = new JMXError(other.jmxErr); + } + } + + public getInternalStats_result deepCopy() { + return new getInternalStats_result(this); + } + + @Override + public void clear() { + this.success = null; + this.jmxErr = null; + } + + public int getSuccessSize() { + return (this.success == null) ? 0 : this.success.size(); + } + + @org.apache.thrift.annotation.Nullable + public java.util.Iterator getSuccessIterator() { + return (this.success == null) ? null : this.success.iterator(); + } + + public void addToSuccess(InternalStat elem) { + if (this.success == null) { + this.success = new java.util.ArrayList(); + } + this.success.add(elem); + } + + @org.apache.thrift.annotation.Nullable + public java.util.List getSuccess() { + return this.success; + } + + public getInternalStats_result setSuccess(@org.apache.thrift.annotation.Nullable java.util.List success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + @org.apache.thrift.annotation.Nullable + public JMXError getJmxErr() { + return this.jmxErr; + } + + public getInternalStats_result setJmxErr(@org.apache.thrift.annotation.Nullable JMXError jmxErr) { + this.jmxErr = jmxErr; + return this; + } + + public void unsetJmxErr() { + this.jmxErr = null; + } + + /** Returns true if field jmxErr is set (has been assigned a value) and false otherwise */ + public boolean isSetJmxErr() { + return this.jmxErr != null; + } + + public void setJmxErrIsSet(boolean value) { + if (!value) { + this.jmxErr = null; + } + } + + public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((java.util.List)value); + } + break; + + case JMX_ERR: + if (value == null) { + unsetJmxErr(); + } else { + setJmxErr((JMXError)value); + } + break; + + } + } + + @org.apache.thrift.annotation.Nullable + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + case JMX_ERR: + return getJmxErr(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + case JMX_ERR: + return isSetJmxErr(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that instanceof getInternalStats_result) + return this.equals((getInternalStats_result)that); + return false; + } + + public boolean equals(getInternalStats_result that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + boolean this_present_jmxErr = true && this.isSetJmxErr(); + boolean that_present_jmxErr = true && that.isSetJmxErr(); + if (this_present_jmxErr || that_present_jmxErr) { + if (!(this_present_jmxErr && that_present_jmxErr)) + return false; + if (!this.jmxErr.equals(that.jmxErr)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); + if (isSetSuccess()) + hashCode = hashCode * 8191 + success.hashCode(); + + hashCode = hashCode * 8191 + ((isSetJmxErr()) ? 131071 : 524287); + if (isSetJmxErr()) + hashCode = hashCode * 8191 + jmxErr.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(getInternalStats_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.compare(isSetSuccess(), other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.compare(isSetJmxErr(), other.isSetJmxErr()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetJmxErr()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.jmxErr, other.jmxErr); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + @org.apache.thrift.annotation.Nullable + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("getInternalStats_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + if (!first) sb.append(", "); + sb.append("jmxErr:"); + if (this.jmxErr == null) { + sb.append("null"); + } else { + sb.append(this.jmxErr); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class getInternalStats_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public getInternalStats_resultStandardScheme getScheme() { + return new getInternalStats_resultStandardScheme(); + } + } + + private static class getInternalStats_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, getInternalStats_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list56 = iprot.readListBegin(); + struct.success = new java.util.ArrayList(_list56.size); + @org.apache.thrift.annotation.Nullable InternalStat _elem57; + for (int _i58 = 0; _i58 < _list56.size; ++_i58) + { + _elem57 = new InternalStat(); + _elem57.read(iprot); + struct.success.add(_elem57); + } + iprot.readListEnd(); + } + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 1: // JMX_ERR + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.jmxErr = new JMXError(); + struct.jmxErr.read(iprot); + struct.setJmxErrIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, getInternalStats_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.success.size())); + for (InternalStat _iter59 : struct.success) + { + _iter59.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.jmxErr != null) { + oprot.writeFieldBegin(JMX_ERR_FIELD_DESC); + struct.jmxErr.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getInternalStats_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public getInternalStats_resultTupleScheme getScheme() { + return new getInternalStats_resultTupleScheme(); + } + } + + private static class getInternalStats_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getInternalStats_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + if (struct.isSetJmxErr()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetSuccess()) { + { + oprot.writeI32(struct.success.size()); + for (InternalStat _iter60 : struct.success) + { + _iter60.write(oprot); + } + } + } + if (struct.isSetJmxErr()) { + struct.jmxErr.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getInternalStats_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + { + org.apache.thrift.protocol.TList _list61 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT); + struct.success = new java.util.ArrayList(_list61.size); + @org.apache.thrift.annotation.Nullable InternalStat _elem62; + for (int _i63 = 0; _i63 < _list61.size; ++_i63) + { + _elem62 = new InternalStat(); + _elem62.read(iprot); + struct.success.add(_elem62); + } + } + struct.setSuccessIsSet(true); + } + if (incoming.get(1)) { + struct.jmxErr = new JMXError(); + struct.jmxErr.read(iprot); + struct.setJmxErrIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + }