You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@edgent.apache.org by Susan Cline <ho...@pacbell.net> on 2016/09/27 20:50:49 UTC

StreamScope and the console

Hi,

I’m trying to do the following:

If a user creates an application using a DevelopmentProvider display the tuples in a hover that are flowing through a StreamScope oplet.

I’ve created a servlet that accepts requests when a user hovers over a StreamScope oplet and I can get an instance of a StreamScopeMXBean.
But even though I call setEnabled(true) on the StreamScopeMXBean I never get any ‘samples’ when I call StreamScopeMXBean.getSamples().

Here is the simple code in the servlet:

			StreamScopeMXBean sScopeBean = StreamScopeUtil.getStreamScope(jobId, opletId, Integer.parseInt(outputPort));
			if (sScopeBean != null) {			
				sScopeBean.setEnabled(true);
				System.out.println("is streamScopeMXBean enabled? " + sScopeBean.isEnabled());
	
				String sampleScope = sScopeBean.getSamples();
				System.out.println("sampleScope: " + sampleScope);
				Gson gson = new Gson();
		    		response.setContentType("application/json");
		    		response.setCharacterEncoding("UTF-8");
		    		response.getWriter().write(gson.toJson(sampleScope));
			}

The output to the command line is:

is streamScopeMXBean enabled? true
sampleScope: []

What am I missing?  I think that if a DevelopmentProvider is used StreamScope oplets are inserted into the graph, and I should not have to do anything else to get the sample?

Thanks,

Susan





Re: StreamScope and the console

Posted by "Susan L. Cline" <ho...@yahoo.com.INVALID>.
Ah ... okay. I kind of wondered about that. I'll try that. Thanks. 

Take care,

Susan

> On Sep 28, 2016, at 8:49 AM, Dale LaBossiere <dm...@gmail.com> wrote:
> 
> Off the top of my head…
> 
> Seems possible (likely?) that no tuples arrived between enabling the StreamScope and calling getSamples().
> Samples aren’t captured until the StreamScope is enabled and ultimately the servlet will have to periodically call getSamples().
> 
> Note, StreamScope.java has doc that may help clarify things beyond what’s in StreamScopeMXBean doc.
> 
> Yup, DevelopmentProvider injects StreamScope oplets alongside of the injected Metric oplets.  Both are presented as little grey boxes in a stream and you can hover on them.
> 
> — Dale
> 
>> On Sep 27, 2016, at 4:50 PM, Susan Cline <ho...@pacbell.net> wrote:
>> 
>> ...
>> Here is the simple code in the servlet:
>> 
>>            StreamScopeMXBean sScopeBean = StreamScopeUtil.getStreamScope(jobId, opletId, Integer.parseInt(outputPort));
>>            if (sScopeBean != null) {            
>>                sScopeBean.setEnabled(true);
>>                System.out.println("is streamScopeMXBean enabled? " + sScopeBean.isEnabled());
>>    
>>                String sampleScope = sScopeBean.getSamples();
>>                System.out.println("sampleScope: " + sampleScope);
>>                Gson gson = new Gson();
>>                    response.setContentType("application/json");
>>                    response.setCharacterEncoding("UTF-8");
>>                    response.getWriter().write(gson.toJson(sampleScope));
>>            }
>> 
>> The output to the command line is:
>> 
>> is streamScopeMXBean enabled? true
>> sampleScope: []
> 

Re: StreamScope and the console

Posted by Susan Cline <ho...@pacbell.net>.
That was it - yay!  It is working now.

Thanks,

Susan

> On Sep 28, 2016, at 8:49 AM, Dale LaBossiere <dm...@gmail.com> wrote:
> 
> Off the top of my head…
> 
> Seems possible (likely?) that no tuples arrived between enabling the StreamScope and calling getSamples().
> Samples aren’t captured until the StreamScope is enabled and ultimately the servlet will have to periodically call getSamples().
> 
> Note, StreamScope.java has doc that may help clarify things beyond what’s in StreamScopeMXBean doc.
> 


Re: StreamScope and the console

Posted by Dale LaBossiere <dm...@gmail.com>.
FYI, created EDGENT-255 for this.  The PR with the change is running checks now and I’ll merge it once it finishes.
— Dale

> On Sep 28, 2016, at 12:25 PM, Dale LaBossiere <dm...@gmail.com> wrote:
> 
> Looking at StreamScope.setEnabled(true) impl I see that it resets the sample buffer if it’s already enabled.
> 
> So if your code snippet is already being called periodically, you’ll need to:
>    if (!sScopeBean.isEnabled())  sScopeBean.setEnabled(true);


Re: StreamScope and the console

Posted by Dale LaBossiere <dm...@gmail.com>.
Looking at StreamScope.setEnabled(true) impl I see that it resets the sample buffer if it’s already enabled.

So if your code snippet is already being called periodically, you’ll need to:
    if (!sScopeBean.isEnabled())  sScopeBean.setEnabled(true);

> On Sep 28, 2016, at 11:49 AM, Dale LaBossiere <dm...@gmail.com> wrote:
> 
> ...
> Seems possible (likely?) that no tuples arrived between enabling the StreamScope and calling getSamples().
> Samples aren’t captured until the StreamScope is enabled and ultimately the servlet will have to periodically call getSamples().


Re: StreamScope and the console

Posted by Dale LaBossiere <dm...@gmail.com>.
Off the top of my head…

Seems possible (likely?) that no tuples arrived between enabling the StreamScope and calling getSamples().
Samples aren’t captured until the StreamScope is enabled and ultimately the servlet will have to periodically call getSamples().

Note, StreamScope.java has doc that may help clarify things beyond what’s in StreamScopeMXBean doc.

Yup, DevelopmentProvider injects StreamScope oplets alongside of the injected Metric oplets.  Both are presented as little grey boxes in a stream and you can hover on them.

— Dale

> On Sep 27, 2016, at 4:50 PM, Susan Cline <ho...@pacbell.net> wrote:
> 
> ...
> Here is the simple code in the servlet:
> 
> 			StreamScopeMXBean sScopeBean = StreamScopeUtil.getStreamScope(jobId, opletId, Integer.parseInt(outputPort));
> 			if (sScopeBean != null) {			
> 				sScopeBean.setEnabled(true);
> 				System.out.println("is streamScopeMXBean enabled? " + sScopeBean.isEnabled());
> 	
> 				String sampleScope = sScopeBean.getSamples();
> 				System.out.println("sampleScope: " + sampleScope);
> 				Gson gson = new Gson();
> 		    		response.setContentType("application/json");
> 		    		response.setCharacterEncoding("UTF-8");
> 		    		response.getWriter().write(gson.toJson(sampleScope));
> 			}
> 
> The output to the command line is:
> 
> is streamScopeMXBean enabled? true
> sampleScope: []