Review Board 1.7.22


SQOOP-815 Sqoop2: Get version for client requires working connection to server

Review Request #8858 - Created Jan. 7, 2013 and submitted

Jarek Cecho
SQOOP-815
Reviewers
Sqoop
sqoop-sqoop2
I've rearrange order of printing out server and client version, so that we can display only client version without server connection if needed.
Tested on real cluster with and without running server.
client/src/main/java/org/apache/sqoop/client/shell/ShowVersionFunction.java
Revision a0f3691c70a90a16d05d1e714698162e642351f5 New Change
[20] 25 lines
[+20]
26
import org.apache.commons.cli.OptionBuilder;
26
import org.apache.commons.cli.OptionBuilder;
27
import org.apache.commons.lang.StringEscapeUtils;
27
import org.apache.commons.lang.StringEscapeUtils;
28
import org.apache.sqoop.client.core.Constants;
28
import org.apache.sqoop.client.core.Constants;
29
import org.apache.sqoop.client.core.Environment;
29
import org.apache.sqoop.client.core.Environment;
30
import org.apache.sqoop.client.request.VersionRequest;
30
import org.apache.sqoop.client.request.VersionRequest;

    
   
31
import org.apache.sqoop.common.VersionInfo;
31
import org.apache.sqoop.json.VersionBean;
32
import org.apache.sqoop.json.VersionBean;
32
import org.codehaus.groovy.tools.shell.IO;
33
import org.codehaus.groovy.tools.shell.IO;
33

    
   
34

   
34
@SuppressWarnings("serial")
35
@SuppressWarnings("serial")
35
public class ShowVersionFunction extends SqoopFunction
36
public class ShowVersionFunction extends SqoopFunction
[+20] [20] 63 lines
[+20] [+] public Object execute(List<String> args) {
99

    
   
100

   
100
    return null;
101
    return null;
101
  }
102
  }
102

    
   
103

   
103
  private void showVersion(boolean server, boolean client, boolean protocol) {
104
  private void showVersion(boolean server, boolean client, boolean protocol) {

    
   
105

   

    
   
106
    // Print out client string if needed

    
   
107
    String s;

    
   
108
    if (client) {

    
   
109
      s = MessageFormat.format(

    
   
110
        getResource().getString(Constants.RES_SHOW_PROMPT_VERSION_CLIENT_SERVER),

    
   
111
        Constants.OPT_CLIENT,

    
   
112
        VersionInfo.getVersion(),

    
   
113
        VersionInfo.getRevision(),

    
   
114
        VersionInfo.getUser(),

    
   
115
        VersionInfo.getDate()

    
   
116
      );

    
   
117
      io.out.println(StringEscapeUtils.unescapeJava(s));

    
   
118
    }

    
   
119

   

    
   
120
    // If only client version was required we do not need to continue

    
   
121
    if(!server && !protocol) {

    
   
122
      return;

    
   
123
    }

    
   
124

   
104
    if (versionRequest == null) {
125
    if (versionRequest == null) {
105
      versionRequest = new VersionRequest();
126
      versionRequest = new VersionRequest();
106
    }
127
    }
107
    VersionBean versionBean =
128
    VersionBean versionBean =
108
        versionRequest.doGet(Environment.getServerUrl());
129
        versionRequest.doGet(Environment.getServerUrl());
109
    MessageFormat msg;

   
110
    String s;

   
111

    
   
130

   
112
    if (server) {
131
    if (server) {
113
      s = MessageFormat.format(getResource().getString(Constants
132
      s = MessageFormat.format(
114
          .RES_SHOW_PROMPT_VERSION_CLIENT_SERVER), Constants.OPT_SERVER,
133
        getResource().getString(Constants.RES_SHOW_PROMPT_VERSION_CLIENT_SERVER),
115
          versionBean.getVersion(), versionBean.getRevision(),
134
        Constants.OPT_SERVER,
116
          versionBean.getUser(), versionBean.getDate());
135
        versionBean.getVersion(),
117
      io.out.println(StringEscapeUtils.unescapeJava(s));
136
        versionBean.getRevision(),
118
    }
137
        versionBean.getUser(),
119

    
   
138
        versionBean.getDate()
120
    if (client) {
139
      );
121
      s = MessageFormat.format(getResource().getString(Constants

   
122
          .RES_SHOW_PROMPT_VERSION_CLIENT_SERVER), Constants.OPT_CLIENT,

   
123
          versionBean.getVersion(), versionBean.getRevision(),

   
124
          versionBean.getUser(), versionBean.getDate());

   
125
      io.out.println(StringEscapeUtils.unescapeJava(s));
140
      io.out.println(StringEscapeUtils.unescapeJava(s));
126
    }
141
    }
127

    
   
142

   
128
    if (protocol) {
143
    if (protocol) {
129
      s = MessageFormat.format(getResource().getString(Constants
144
      s = MessageFormat.format(
130
          .RES_SHOW_PROMPT_VERSION_PROTOCOL), Arrays.toString(versionBean.
145
        getResource().getString(Constants.RES_SHOW_PROMPT_VERSION_PROTOCOL),
131
          getProtocols()));
146
        Arrays.toString(versionBean.getProtocols())

    
   
147
      );
132
      io.out.println(StringEscapeUtils.unescapeJava(s));
148
      io.out.println(StringEscapeUtils.unescapeJava(s));
133
    }
149
    }
134

    
   
150

   
135
    io.out.println();
151
    io.out.println();
136
  }
152
  }
137
}
153
}
  1. client/src/main/java/org/apache/sqoop/client/shell/ShowVersionFunction.java: Loading...