Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify the documentation about the Telnet command to match the code impl… #200

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions docs/en-us/user/references/telnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ The built-in telnet commands are listed below. Furthermore, it is possible to ex

### `invoke`

0. `invoke XxxService.xxxMethod({"prop": "value"})`: invoke particular method for the given service
0. `invoke xxxMethod({"prop": "value"})`: invoke particular method for the default service
0. `invoke xxxService.xxxMethod("paramStr")`或`invoke xxxService.xxxMethod(18)`: invoke particular method with a primitive type parameter
0. `invoke xxxService.xxxMethod("paramStr") -p java.lang.String`: invoke particular method with a String type parameter

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the following command on latest 2.7.x branch and got following error

dubbo>invoke org.apache.dubbo.demo.DemoService.sayHello("hello") -p java.lang.String
Invalid parameters, format: service.method(args)

It looks like -p java.lang.String does not work. How did you get it to work?

Copy link
Member Author

@kexianjun kexianjun Dec 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the following command on latest 2.7.x branch and got following error

dubbo>invoke org.apache.dubbo.demo.DemoService.sayHello("hello") -p java.lang.String
Invalid parameters, format: service.method(args)

It looks like -p java.lang.String does not work. How did you get it to work?

I have made more test on the latest master branch.My test is as the following:

package org.apache.dubbo.demo;

public class Student {
    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
package org.apache.dubbo.demo;

public interface DemoService {

    String sayHello(String name);

    String sayHello(Long name);

    String sayHello(Integer age);

    String sayHello(Student student);

    String sayHello(String name, Integer age);

}
package org.apache.dubbo.demo.provider;

import org.apache.dubbo.demo.DemoService;
import org.apache.dubbo.demo.Student;
import org.apache.dubbo.rpc.RpcContext;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DemoServiceImpl implements DemoService {

    @Override
    public String sayHello(String name) {
        System.out.println("[" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "] Hello " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress());
        return "Hello " + name + ", response from provider: " + RpcContext.getContext().getLocalAddress();
    }

    @Override
    public String sayHello(Long name) {
        return "Long from sayHello " + name;
    }

    @Override
    public String sayHello(Integer age) {
        return "int from sayHello " + age;
    }

    @Override
    public String sayHello(Student student) {
        return "Student from sayHello ,name:" + student.getName() + ",age:" + student.getAge();
    }

    @Override
    public String sayHello(String name, Integer age) {
        return "name and age from sayHello,name:" + name + ",age" + age;
    }
}

here is my result:
image
image

And based on your result,the error message from org/apache/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java:158

if (i < 0 || !message.endsWith(")")) {
            return "Invalid parameters, format: service.method(args)";
        }

it may indicate something wrong with the input parentheses or the following class

org/apache/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java

different from the master branch

.Would you maind to take a look at this and provide more detail about your test?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, sorry for the late reply, I am going to try it out in next few days.

0. `invoke xxxService.xxxMethod(18) -p java.lang.Integer`: invoke particular method with an Integer type parameter
0. `invoke xxxService.xxxMethod(18L) -p java.lang.Long`: invoke particular method with a Long type parameter
0. `invoke xxxService.xxxMethod(18, 18L) -p java.lang.Integer java.lang.Long`: invoke particular method with an Integer and a Long type parameters
0. `invoke xxxService.xxxMethod({"prop": "value1"}) -p xxx.xx.XxxClass`: invoke particular method with a XxxClass(witch prop attribute's value is value1) type parameter
0. `invoke xxxService.xxxMethod({"prop": "value"},{"prop1":"value1"}) -p xxx.xx.XxxClass1 xxx.xx.XxxClass`: invoke particular method with a XxxCalss1 and a XxxClass type parameters

### `status`

Expand Down
9 changes: 7 additions & 2 deletions docs/zh-cn/user/references/telnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ status命令所检查的资源也可以扩展,参见:[扩展参考手册](..

### `invoke`

0. `invoke XxxService.xxxMethod({"prop": "value"})`: 调用服务的方法
0. `invoke xxxMethod({"prop": "value"})`: 调用服务的方法(自动查找包含此方法的服务)
0. `invoke xxxService.xxxMethod("paramStr")`或`invoke xxxService.xxxMethod(18)`: 调用参数为基本类型的方法
0. `invoke xxxService.xxxMethod("paramStr") -p java.lang.String`: 调用参数为String类型的方法
0. `invoke xxxService.xxxMethod(18) -p java.lang.Integer`: 调用参数为Integer类型的方法
0. `invoke xxxService.xxxMethod(18L) -p java.lang.Long`: 调用参数为Long类型的方法
0. `invoke xxxService.xxxMethod(18, 18L) -p java.lang.Integer java.lang.Long`: 调用参数为Integer、Long类型的方法
0. `invoke xxxService.xxxMethod({"prop": "value"}) -p xxx.xx.XxxClass`: 调用参数为XxxClass(属性prop的值为value)类型的方法
0. `invoke xxxService.xxxMethod({"prop": "value"},{"prop1":"value1"}) -p xxx.xx.XxxClass1 xxx.xx.XxxClass`: 调用参数为XxxClass1、XxxClass类型的方法

### `status`

Expand Down