@Test public void testGetTunnelEndpoint() throws Exception { String server = odps.projects().get().getTunnelEndpoint(); assertNotNull(server); System.out.println(server); try { odps.projects().get("not_exists").getTunnelEndpoint(); assertNotNull("Expect exception when project not found", null); } catch (OdpsException e) { assertTrue(e.getMessage().contains("not found")); } }
public String getTunnelEndpoint() throws OdpsException { String protocol; try { URI u = new URI(client.getEndpoint()); protocol = u.getScheme(); } catch (URISyntaxException e) { throw new OdpsException(e.getMessage(), e); } String resource = ResourceBuilder.buildProjectResource(model.name).concat("/tunnel"); HashMap<String, String> params = new HashMap<String, String>(); params.put("service", null); Response resp = client.request(resource, "GET", params, null, null); String tunnel; if (resp.isOK()) { tunnel = new String(resp.getBody()); } else { throw new OdpsException("Can't get tunnel server address: " + resp.getStatus()); } return protocol + ": }
Project extends LazyLoad { public String getTunnelEndpoint() throws OdpsException { String protocol; try { URI u = new URI(client.getEndpoint()); protocol = u.getScheme(); } catch (URISyntaxException e) { throw new OdpsException(e.getMessage(), e); } String resource = ResourceBuilder.buildProjectResource(model.name).concat("/tunnel"); HashMap<String, String> params = new HashMap<String, String>(); params.put("service", null); Response resp = client.request(resource, "GET", params, null, null); String tunnel; if (resp.isOK()) { tunnel = new String(resp.getBody()); } else { throw new OdpsException("Can't get tunnel server address: " + resp.getStatus()); } return protocol + ": } }
Project extends LazyLoad { public String getTunnelEndpoint() throws OdpsException { String protocol; try { URI u = new URI(client.getEndpoint()); protocol = u.getScheme(); } catch (URISyntaxException e) { throw new OdpsException(e.getMessage(), e); } String resource = ResourceBuilder.buildProjectResource(model.name).concat("/tunnel"); HashMap<String, String> params = new HashMap<String, String>(); params.put("service", null); Response resp = client.request(resource, "GET", params, null, null); String tunnel; if (resp.isOK()) { tunnel = new String(resp.getBody()); } else { throw new OdpsException("Can't get tunnel server address: " + resp.getStatus()); } return protocol + ": } Project(ProjectModel model, RestClient client); }
Project extends LazyLoad { public String getTunnelEndpoint() throws OdpsException { String protocol; try { URI u = new URI(client.getEndpoint()); protocol = u.getScheme(); } catch (URISyntaxException e) { throw new OdpsException(e.getMessage(), e); } String resource = ResourceBuilder.buildProjectResource(model.name).concat("/tunnel"); HashMap<String, String> params = new HashMap<String, String>(); params.put("service", null); Response resp = client.request(resource, "GET", params, null, null); String tunnel; if (resp.isOK()) { tunnel = new String(resp.getBody()); } else { throw new OdpsException("Can't get tunnel server address: " + resp.getStatus()); } return protocol + ": } Project(ProjectModel model, RestClient client); @SuppressWarnings("unchecked") @Override void reload(); String getName(); ProjectType getType(); String getComment(); String getOwner(); Date getCreatedTime(); Date getLastModifiedTime(); Status getStatus(); Map<String, String> getProperties(); Map<String, String> getAllProperties(); String getProperty(String key); Map<String, String> getExtendedProperties(); SecurityManager getSecurityManager(); String getTunnelEndpoint(); }
Project extends LazyLoad { public String getTunnelEndpoint() throws OdpsException { String protocol; try { URI u = new URI(client.getEndpoint()); protocol = u.getScheme(); } catch (URISyntaxException e) { throw new OdpsException(e.getMessage(), e); } String resource = ResourceBuilder.buildProjectResource(model.name).concat("/tunnel"); HashMap<String, String> params = new HashMap<String, String>(); params.put("service", null); Response resp = client.request(resource, "GET", params, null, null); String tunnel; if (resp.isOK()) { tunnel = new String(resp.getBody()); } else { throw new OdpsException("Can't get tunnel server address: " + resp.getStatus()); } return protocol + ": } Project(ProjectModel model, RestClient client); @SuppressWarnings("unchecked") @Override void reload(); String getName(); ProjectType getType(); String getComment(); String getOwner(); Date getCreatedTime(); Date getLastModifiedTime(); Status getStatus(); Map<String, String> getProperties(); Map<String, String> getAllProperties(); String getProperty(String key); Map<String, String> getExtendedProperties(); SecurityManager getSecurityManager(); String getTunnelEndpoint();  }