@SuppressWarnings("unused") @Test public void basicTests() throws IOException { RestClient a = new RestClient("prod01:80"); //a.wipeCache("metadata", "a", "a"); //String aa = a.getKylinProperties(); //System.out.println(aa); RestClient b = new RestClient("sandbox.hortonworks.com:7070"); //b.wipeCache("metadata", "a", "a"); //String bb = b.getKylinProperties(); //System.out.println(bb); } }
try { KylinConfig config = new KylinConfig(); RestClient client = new RestClient(uri); String propertyText = client.getKylinProperties(); InputStream is = IOUtils.toInputStream(propertyText, Charset.defaultCharset()); Properties prop = streamToProps(is);
public RestClient(String host, int port, String userName, String password, Integer httpConnectionTimeoutMs, Integer httpSocketTimeoutMs) { if (httpConnectionTimeoutMs != null) this.httpConnectionTimeoutMs = httpConnectionTimeoutMs; if (httpSocketTimeoutMs != null) this.httpSocketTimeoutMs = httpSocketTimeoutMs; init(host, port, userName, password); }
private static void updateMeta(KylinConfig config) { String[] nodes = config.getRestServers(); for (String node : nodes) { RestClient restClient = new RestClient(node); try { logger.info("update meta cache for " + node); restClient.wipeCache(Broadcaster.SYNC_ALL, Broadcaster.Event.UPDATE.getType(), Broadcaster.SYNC_ALL); } catch (IOException e) { logger.error(e.getMessage()); } } }
private void updateMeta(KylinConfig config, String projectName, String cubeName, DataModelDesc model) { String[] nodes = config.getRestServers(); Map<String, String> tableToProjects = new HashMap<>(); for (TableRef tableRef : model.getAllTables()) { tableToProjects.put(tableRef.getTableIdentity(), tableRef.getTableDesc().getProject()); } for (String node : nodes) { RestClient restClient = new RestClient(node); try { logger.info("update meta cache for " + node); restClient.clearCacheForCubeMigration(cubeName, projectName, model.getName(), tableToProjects); } catch (IOException e) { logger.error(e.getMessage()); } } }
logger.info("send build lookup table cache request to server: " + restServer); try { RestClient restClient = new RestClient(restServer); restClient.buildLookupSnapshotCache(projectName, tableName, snapshotID); serversNeedCheck.add(restServer); } catch (IOException e) { logger.info("check lookup table cache build status for server: " + restServer); try { RestClient restClient = new RestClient(restServer); String stateName = restClient.getLookupSnapshotCacheState(tableName, snapshotID); if (!stateName.equals(CacheState.IN_BUILDING.name())) { completeServers.add(restServer);
RestClient c = new RestClient("http://somewebsite.com/register"); c.AddHeader("Accept", "application/json"); c.AddHeader("Content-type", "application/json"); c.AddParam("UserName", user); c.AddParam("Password", password); c.Execute(RequestMethod.POST); JSONObject userKey = new JSONObject(c.getResponse());
public String communicateWithServer(String xmlInput) { String response = null; String webServiceUrl = "your-server-url"; RestClient client = new RestClient(webServiceUrl); client.setJSONString(xmlInput); client.addHeader("Content-Type", "text/xml"); try { client.execute(RequestMethod.POST); if (client.getResponseCode() != 200) { // handle error here } response = client.getResponse(); } catch (Exception e) { e.printStackTrace(); } return response; }
RestClient client = new RestClient(); client.setApplicationPath("someApp"); String url = client.login("theuser", "123456"); UserPortfolio portfolio = client.template().getForObject(client.apiUrl("portfolio"), UserPortfolio.class);
RestClient client = new RestClient("http://www.example.com/demo.php"); //Write your url here client.addParam("Name", "Bhavit"); //Here I am adding key-value parameters client.addParam("Age", "23"); client.addHeader("content-type", "application/json"); // Here I am specifying that the key-value pairs are sent in the JSON format try { String response = client.executePost(); // In case your server sends any response back, it will be saved in this response string. } catch (Exception e) { e.printStackTrace(); }
RestClient restClient = new RestClient(); Callback callback = new Callback() { @Override public void success(Object o, Response response) { Categories_ = (Categories)o; } @Override public void failure(RetrofitError error) { Toast toast = Toast.makeText(getApplication(), "Something went wrong!!", Toast.LENGTH_SHORT); toast.show(); } }; restClient.getApiService().getCategories(callback);
protected String doInBackground(String... params) { RestClient client = new RestClient(params[0]); client.AddParam("username", params[1]); client.AddParam("password", params[2]); ... }
RestClient client = new RestClient(); client.execute("http://youronlineservice.com:3430/api/somegetrequest",RequestMethod.GET); client.execute("http://youronlineservice.com:3430/api/somepostrequest",RequestMethod.POST);
RestClient restClient = new RestClient(); restClient.foo("bar");
public void ShowAlert(String Message, String ConnectionId) { RestClient Client = new RestClient("http://localhost:8888"); RestRequest Request = new RestRequest("/Listener/SignalR", Method.POST); Request.Parameters.Add(new Parameter() { Name = "Message", Type = ParameterType.QueryString, Value = Message }); Request.Parameters.Add(new Parameter() { Name = "Type", Type = ParameterType.QueryString, Value = "ShowAlert" }); Request.Parameters.Add(new Parameter() { Name = "ConnectionId", Type = ParameterType.QueryString, Value = ConnectionId }); IRestResponse Response = Client.Execute(Request); } // end Show Alert
RestClient client = new RestClient(); ClientResponse response = client.resource("http://example.com/resources/resource1").header("Accept", "application/json;q=1.0, application/xml;q=0.8").get(); // find what format was sent back String contentType = response.getHeaders().getFirst("Content-Type"); if (contentType.contains("application/json")) { JSONObject entity = response.getEntity(JSONObject.class); /* or use a String, InputStream, or other provider that supports the entity media type */ } else if (contentType.contains("application/xml") { String entity = response.getEntity(String.class); /* or use a JAXB class, InputStream, etc. */
setContentView(R.layout.activity_main); RestClient rc = new RestClient(); ArrayList<Weather> list1 = rc.getPlaces("", ""); int index = 3; String[] listArray = new String[list1.size()];
private static UriType decideUriType(String metaUri) { try { File file = new File(metaUri); if (file.exists() || metaUri.contains("/")) { if (file.exists() == false) { file.mkdirs(); } if (file.isDirectory()) { return UriType.LOCAL_FOLDER; } else if (file.isFile()) { if (file.getName().equalsIgnoreCase(KYLIN_CONF_PROPERTIES_FILE)) { return UriType.PROPERTIES_FILE; } else { throw new IllegalStateException( METADATA_URI_PREFIX + metaUri + " is a local file but not kylin.properties"); } } else { throw new IllegalStateException( METADATA_URI_PREFIX + metaUri + " looks like a file but it's neither a file nor a directory"); } } else { if (RestClient.matchFullRestPattern(metaUri)) return UriType.REST_ADDR; else throw new IllegalStateException(METADATA_URI_PREFIX + metaUri + " is not a valid REST URI address"); } } catch (Exception e) { throw new IllegalStateException(METADATA_URI_PREFIX + metaUri + " is not recognized", e); } }
@Override protected Void doInBackground(Void... voids) { try { RestClient client = new RestClient("your url goes here"); client.AddParam("param1", "value1")); client.AddParam("param2", "value2")); client.AddHeader("Headername","Value"); client.Execute(RequestMethod.POST); response = client.getResponse(); }catch (Exception e) { e.printStackTrace(); } return null; }
String webServiceUrl = "your-service-url"; RestClient client = new RestClient(webServiceUrl); String serverResponse = ""; String inputJsonString = "{" + " \"grant_type\" : \"password\"," + " \"username\" : \"perry.marange@zmod.co\"," + " \"password\" : \"password\"" + "}"; client.setJSONString(inputJsonString); client.addHeader("Content-Type", "appication/json"); // if required try { client.execute(RequestMethod.POST); if (client.getResponseCode() != 200) { // response error } else { // the response from server serverResponse = client.getResponse(); } } catch (Exception e) { // handle error }