Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.eyrie.remctl.client;
 
 import java.util.List;
 
Experimental validation strategy that sends protocol 3 NOOP messages.

Author(s):
pradtke
public class NoopValidationStrategy extends BaseValidationStrategy {

    
Sends a RemctlNoopToken token and check the response.

Parameters:
connection The connection to check
Returns:
true if org.eyrie.remctl.core.RemctlNoopToken was returned from server.
    @Override
    public boolean checkConnection(final RemctlConnection connection) {
        RemctlNoopToken noopToken = new RemctlNoopToken();
        connection.writeToken(noopToken);
        List<RemctlTokentokens = connection.readAllTokens();
        if (tokens.size() != 1) {
            .warn("Unexpected number of tokens returned in valdate ({}). Marking invalid"tokens.size());
        }
        RemctlToken token = tokens.get(0);
        if (token instanceof RemctlNoopToken) {
            return true;
        } else if (token instanceof RemctlVersionToken) {
            // Server doesn't support protocol version 3. That is OK.
            return true;
        } else {
            .warn("Unexpected token returned from NOOP message: {}"token);
        }
        return false;
    }
New to GrepCode? Check out our FAQ X