-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from Azure/dev
Client request properties and ResultSet ingestion
- Loading branch information
Showing
22 changed files
with
693 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
data/src/main/java/com/microsoft/azure/kusto/data/ClientRequestProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.microsoft.azure.kusto.data; | ||
|
||
import org.json.JSONObject; | ||
|
||
import java.util.HashMap; | ||
|
||
/* | ||
* Kusto supports attaching various properties to client requests (such as queries and control commands). | ||
* Such properties may be used to provide additional information to Kusto (for example, for the purpose of correlating client/service interaction), | ||
* may affect what limits and policies get applied to the request, and much more. | ||
* For a complete list of available client request properties | ||
* check out https://docs.microsoft.com/en-us/azure/kusto/api/netfx/request-properties#list-of-clientrequestproperties | ||
*/ | ||
public class ClientRequestProperties { | ||
private static final String OPTIONS_KEY = "Options"; | ||
private static final String OPTION_SERVER_TIMEOUT = "servertimeout"; | ||
private HashMap<String, Object> properties; | ||
private HashMap<String, Object> options; | ||
|
||
public ClientRequestProperties() { | ||
properties = new HashMap<>(); | ||
options = new HashMap<>(); | ||
properties.put(OPTIONS_KEY, options); | ||
} | ||
|
||
public void setOption(String name, Object value) { | ||
options.put(name, value); | ||
} | ||
|
||
public Object getOption(String name) { | ||
return options.get(name); | ||
} | ||
|
||
public void removeOption(String name) { | ||
options.remove(name); | ||
} | ||
|
||
public void clearOptions() { | ||
options.clear(); | ||
} | ||
|
||
public Long getTimeoutInMilliSec() { | ||
return (Long) getOption(OPTION_SERVER_TIMEOUT); | ||
} | ||
|
||
public void setTimeoutInMilliSec(Long timeoutInMs) { | ||
options.put(OPTION_SERVER_TIMEOUT, timeoutInMs); | ||
} | ||
|
||
JSONObject toJson() { | ||
return new JSONObject(properties); | ||
} | ||
|
||
public String toString() { | ||
return toJson().toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
data/src/test/java/com/microsoft/azure/kusto/data/ClientRequestPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.microsoft.azure.kusto.data; | ||
|
||
import org.json.JSONException; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.skyscreamer.jsonassert.JSONAssert; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
public class ClientRequestPropertiesTest { | ||
@Test | ||
@DisplayName("test set/get timeout") | ||
void timeoutSetGet() { | ||
ClientRequestProperties props = new ClientRequestProperties(); | ||
Long expected = TimeUnit.MINUTES.toMillis(100); | ||
|
||
// before setting value should be null | ||
Assertions.assertEquals(null, props.getTimeoutInMilliSec()); | ||
|
||
props.setTimeoutInMilliSec(expected); | ||
Assertions.assertEquals(expected, props.getTimeoutInMilliSec()); | ||
} | ||
|
||
@Test | ||
@DisplayName("test ClientRequestProperties toString") | ||
void propertiesToString() throws JSONException { | ||
ClientRequestProperties props = new ClientRequestProperties(); | ||
props.setOption("a", 1); | ||
props.setOption("b", "hello"); | ||
|
||
JSONAssert.assertEquals("{\"Options\": {\"a\":1, \"b\":\"hello\"}}", props.toString(), false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# SLF4J's SimpleLogger configuration file | ||
# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err. | ||
|
||
# Default logging detail level for all instances of SimpleLogger. | ||
# Must be one of ("trace", "debug", "info", "warn", or "error"). | ||
# If not specified, defaults to "info". | ||
org.slf4j.simpleLogger.log.com.microsoft.azure.kusto=debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.