Directory

← Back

DiagnosticServlet

Custom servlet which enables setting component's communication id's with setId()-method

Author

Rating

Popularity

<100

Experimental utilities (DiagnosticServlet and DiagnosticInterceptor) for tests and diagnostics.

DiagnosticServlet

Experimental and simple custom servlet which enables setting component's communication id's. This will help one to write scalability tests for Vaadin with e.g JMeter or Gatling.

For VAADIN 8.1 use ConnectorIdGenerator add-on instead

See the following wiki articles for more information about the scalability testing: http://bit.do/vaadin-gatling http://bit.do/vaadin-jmeter

Caution! Use unique ids for components!

DiagnosticInterceptor

Server-side interceptor for recording Push WebSocket communication. You can use recorded requests e.g. for scalability testing a Vaadin application with JMeter. See also (https://github.com/johannest/JMeter-WebSocketSampler) for a customized WebSocketSampler plugin for JMeter.

Sample code

public class MyVaadinUI extends UI {

    @WebServlet(value = "/*", asyncSupported = true, initParams = {
        // disables xsrf forgering protection, not good for production, but makes
        // load testing easier
        @WebInitParam(name = "disable-xsrf-protection", value = "true"),
        // disables syncid verifation in vaadin client-server communiction
        // not good for production, but makes load testing easier
        @WebInitParam(name = "syncId", value = "false"),
    })
    @VaadinServletConfiguration(productionMode = false, ui = MyVaadinUI.class)
    public static class Servlet extends DiagnosticAndTestServlet {
    }

@Override
    protected void init(VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);
        
        final TextField tf = new TextField("test");
        tf.setId("test-textfield");
        tf.addValueChangeListener(new ValueChangeListener() {
			@Override
			public void valueChange(ValueChangeEvent e) {
				System.out.println("Text input: "+e.getProperty().getValue());
			}
        });
        
        Button button = new Button("Click Me");
        button.setId("click-me-button");
        button.addClickListener(new ClickListener() {			
			@Override
			public void buttonClick(ClickEvent e) {
	        	System.out.println("Button clicked");
	        	layout.addComponent(new Label("Thank you for clicking: "+tf.getValue()));
			}
        });
        
        layout.addComponents(tf,button);
    }
}
@Override
protected void init(VaadinRequest request) {
	// 1. clear all previously recorded requests
	DiagnosticInterceptor.clearRecordedRequests();
	
	// some ui code
	// ...
	
	Button button = new Button("Show recorded request frames with pauses");
	button.setId("show-requests-button");
	button.addClickListener(e->{
	
		// 2. fetch requests recorded this far
		String requestsLines = DiagnosticInterceptor.getRecordedRequesWithPauses();
		
		// 3. then show them, log them or export into file
		Label label = new Label(requestsLines, ContentMode.PREFORMATTED);
		label.addStyleName(ValoTheme.LABEL_TINY);
		layout.addComponent(label);
	});
	
	
	// ...
}

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Vaadin 8.0 version

Released
2017-06-29
Maturity
EXPERIMENTAL
License
Apache License 2.0

Compatibility

Framework
Vaadin 8.0
Vaadin 7.3+ in 0.1.3
Browser
Browser Independent

DiagnosticServlet - Vaadin Add-on Directory

Custom servlet which enables setting component's communication id's with setId()-method DiagnosticServlet - Vaadin Add-on Directory
Experimental utilities (DiagnosticServlet and DiagnosticInterceptor) for tests and diagnostics. DiagnosticServlet Experimental and simple custom servlet which enables setting component's communication id's. This will help one to write scalability tests for Vaadin with e.g JMeter or Gatling. **For VAADIN 8.1 use ConnectorIdGenerator add-on instead** See the following wiki articles for more information about the scalability testing: http://bit.do/vaadin-gatling http://bit.do/vaadin-jmeter Caution! Use unique ids for components! DiagnosticInterceptor Server-side interceptor for recording Push WebSocket communication. You can use recorded requests e.g. for scalability testing a Vaadin application with JMeter. See also (https://github.com/johannest/JMeter-WebSocketSampler) for a customized WebSocketSampler plugin for JMeter.
Online