From c1d5df1d833b4ebf4a144257b8625717969eb283 Mon Sep 17 00:00:00 2001 From: Pamir Erdem Date: Sat, 8 Feb 2020 23:54:22 +0300 Subject: [PATCH 1/5] java file should be batch request --- .../microsoft/cognitiveservice/anomalydetection/Main.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java index 8e7a5eb..11a3720 100644 --- a/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java +++ b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java @@ -18,13 +18,13 @@ public class Main { // ********************************************** // Replace the subscriptionKey string value with your valid subscription key. - private static final String subscriptionKey = ""; + private static final String subscriptionKey = "accf4775-6f1f-4382-9f89-64a8658f02ba"; // Choose which anomaly detection way you want to use and change the uriBase's second part - private static final String rootUrl = "https://westus2.api.cognitive.microsoft.com/anomalydetector/v1.0"; + private static final String rootUrl = "http://localhost:5000/anomalydetector/v1.0"; private static final String lastDetect = "/timeseries/last/detect"; private static final String entireDetect = "/timeseries/entire/detect"; - private static final String uriBase = rootUrl + lastDetect; + private static final String uriBase = rootUrl + entireDetect; public static void main(String[] args) throws FileNotFoundException { String resourceName = "/request-data.json"; From 5c28b73bad6132bd17cc42aa3558bdbb0a6fb012 Mon Sep 17 00:00:00 2001 From: Pamir Date: Sat, 8 Feb 2020 23:59:11 +0300 Subject: [PATCH 2/5] Update Main.java Client should send Batch sample data to entire context path --- .../com/microsoft/cognitiveservice/anomalydetection/Main.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java index 8e7a5eb..12980ff 100644 --- a/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java +++ b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java @@ -24,7 +24,7 @@ public class Main { private static final String rootUrl = "https://westus2.api.cognitive.microsoft.com/anomalydetector/v1.0"; private static final String lastDetect = "/timeseries/last/detect"; private static final String entireDetect = "/timeseries/entire/detect"; - private static final String uriBase = rootUrl + lastDetect; + private static final String uriBase = rootUrl + entireDetect; public static void main(String[] args) throws FileNotFoundException { String resourceName = "/request-data.json"; From 192dc1235135c80792f590eaa447efbc3eaee458 Mon Sep 17 00:00:00 2001 From: Pamir Erdem Date: Sun, 9 Feb 2020 01:07:42 +0300 Subject: [PATCH 3/5] stream mode added --- other-samples/java-sample/.classpath | 49 +++++ other-samples/java-sample/.project | 23 +++ .../.settings/org.eclipse.jdt.apt.core.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 9 + .../.settings/org.eclipse.m2e.core.prefs | 4 + .../java-sample/.vscode/settings.json | 3 + other-samples/java-sample/pom.xml | 23 ++- .../AnomalyDetectorRequest.java | 26 +++ .../anomalydetection/Main.java | 2 +- .../anomalydetection/Point.java | 35 ++++ .../anomalydetection/StreamMain.java | 87 ++++++++ .../anomalydetection/StreamResponse.java | 80 ++++++++ .../target/classes/request-data.json | 193 ++++++++++++++++++ .../compile/default-compile/createdFiles.lst | 4 + .../compile/default-compile/inputFiles.lst | 4 + 15 files changed, 539 insertions(+), 5 deletions(-) create mode 100644 other-samples/java-sample/.classpath create mode 100644 other-samples/java-sample/.project create mode 100644 other-samples/java-sample/.settings/org.eclipse.jdt.apt.core.prefs create mode 100644 other-samples/java-sample/.settings/org.eclipse.jdt.core.prefs create mode 100644 other-samples/java-sample/.settings/org.eclipse.m2e.core.prefs create mode 100644 other-samples/java-sample/.vscode/settings.json create mode 100644 other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/AnomalyDetectorRequest.java create mode 100644 other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Point.java create mode 100644 other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/StreamMain.java create mode 100644 other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/StreamResponse.java create mode 100644 other-samples/java-sample/target/classes/request-data.json create mode 100644 other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst diff --git a/other-samples/java-sample/.classpath b/other-samples/java-sample/.classpath new file mode 100644 index 0000000..1b799f3 --- /dev/null +++ b/other-samples/java-sample/.classpath @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/other-samples/java-sample/.project b/other-samples/java-sample/.project new file mode 100644 index 0000000..28d7e9e --- /dev/null +++ b/other-samples/java-sample/.project @@ -0,0 +1,23 @@ + + + anomalydetction + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/other-samples/java-sample/.settings/org.eclipse.jdt.apt.core.prefs b/other-samples/java-sample/.settings/org.eclipse.jdt.apt.core.prefs new file mode 100644 index 0000000..d4313d4 --- /dev/null +++ b/other-samples/java-sample/.settings/org.eclipse.jdt.apt.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.apt.aptEnabled=false diff --git a/other-samples/java-sample/.settings/org.eclipse.jdt.core.prefs b/other-samples/java-sample/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ac8e750 --- /dev/null +++ b/other-samples/java-sample/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.processAnnotations=disabled +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/other-samples/java-sample/.settings/org.eclipse.m2e.core.prefs b/other-samples/java-sample/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/other-samples/java-sample/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/other-samples/java-sample/.vscode/settings.json b/other-samples/java-sample/.vscode/settings.json new file mode 100644 index 0000000..e0f15db --- /dev/null +++ b/other-samples/java-sample/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "automatic" +} \ No newline at end of file diff --git a/other-samples/java-sample/pom.xml b/other-samples/java-sample/pom.xml index 62dcaa1..a0efe43 100644 --- a/other-samples/java-sample/pom.xml +++ b/other-samples/java-sample/pom.xml @@ -1,7 +1,5 @@ - - + + 4.0.0 com.microsoft.cognitiveservice @@ -19,6 +17,23 @@ json 20180130 + + + org.apache.commons + commons-lang3 + 3.9 + + + com.google.code.gson + gson + 2.8.6 + + + + commons-io + commons-io + 2.6 + \ No newline at end of file diff --git a/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/AnomalyDetectorRequest.java b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/AnomalyDetectorRequest.java new file mode 100644 index 0000000..743308c --- /dev/null +++ b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/AnomalyDetectorRequest.java @@ -0,0 +1,26 @@ +package com.microsoft.cognitiveservice.anomalydetection; + +import java.util.Collection; + +public class AnomalyDetectorRequest{ + public AnomalyDetectorRequest(Collection points,String granularity){ + this.series = points; + this.granularity = granularity; + } + private String granularity; + + private Collection series; + + public void setGranularity(String granularity){ + this.granularity = granularity; + } + public String getGranularity(){ + return this.granularity; + } + public void setSeries(Collection series){ + this.series = series; + } + public Collection getSeries(){ + return this.series; + } +} \ No newline at end of file diff --git a/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java index 11a3720..6ed1424 100644 --- a/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java +++ b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java @@ -18,7 +18,7 @@ public class Main { // ********************************************** // Replace the subscriptionKey string value with your valid subscription key. - private static final String subscriptionKey = "accf4775-6f1f-4382-9f89-64a8658f02ba"; + private static final String subscriptionKey = "xxxxx"; // Choose which anomaly detection way you want to use and change the uriBase's second part private static final String rootUrl = "http://localhost:5000/anomalydetector/v1.0"; diff --git a/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Point.java b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Point.java new file mode 100644 index 0000000..8b234f8 --- /dev/null +++ b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Point.java @@ -0,0 +1,35 @@ +package com.microsoft.cognitiveservice.anomalydetection; + +import org.apache.commons.lang3.StringUtils; + +public class Point implements Comparable { + private String timestamp; + + private long value; + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public String getTimestamp() { + return this.timestamp; + } + + public void setValue(long value) { + this.value = value; + } + + public long getValue() { + return this.value; + } + + @Override + public int compareTo(Point o) { + if (o == null || StringUtils.isEmpty(o.getTimestamp())) + return 1; + else if (StringUtils.isEmpty(this.getTimestamp())) + return -1; + + return this.getTimestamp().compareTo(o.timestamp); + } +} diff --git a/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/StreamMain.java b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/StreamMain.java new file mode 100644 index 0000000..a662df1 --- /dev/null +++ b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/StreamMain.java @@ -0,0 +1,87 @@ +package com.microsoft.cognitiveservice.anomalydetection; + +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collection; + +import com.google.gson.Gson; + +import org.apache.commons.io.IOUtils; + +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; + +public class StreamMain{ + + private static final String subscriptionKey = "xxxxx"; + + // Choose which anomaly detection way you want to use and change the uriBase's second part + private static final String rootUrl = "http://localhost:5000/anomalydetector/v1.0"; + private static final String lastDetect = "/timeseries/last/detect"; + private static final String uriBase = rootUrl + lastDetect; + + public static void main(String[] args) throws Exception{ + String resourceName = "/request-data.json"; + String rawRequest = IOUtils.toString(StreamMain.class.getResourceAsStream(resourceName),StandardCharsets.UTF_8); + AnomalyDetectorRequest anomalyDetectorRequest = new Gson().fromJson(rawRequest, AnomalyDetectorRequest.class); + Collection pointCollection = anomalyDetectorRequest.getSeries(); + int i = 0; + AnomalyDetectorRequest request = new AnomalyDetectorRequest(new ArrayList(), anomalyDetectorRequest.getGranularity()); + for(Point p : pointCollection){ + + request.getSeries().add(p); + if(++i == 12){ + doRequest(request); + request = new AnomalyDetectorRequest(new ArrayList(), anomalyDetectorRequest.getGranularity()); + i = 0; + } + + } + } + + private static void doRequest(AnomalyDetectorRequest anomalyDetectorRequest){ + CloseableHttpClient client = HttpClients.createDefault(); + HttpPost request = new HttpPost(uriBase); + + // Request headers. + request.setHeader("Content-Type", "application/json"); + request.setHeader("Ocp-Apim-Subscription-Key", subscriptionKey); + + try { + StringEntity params = new StringEntity(new Gson().toJson(anomalyDetectorRequest)); + request.setEntity(params); + + CloseableHttpResponse response = client.execute(request); + try { + HttpEntity respEntity = response.getEntity(); + if (respEntity != null) { + System.out.println("----------"); + System.out.println(response.getStatusLine()); + System.out.println("Response content is :\n"); + System.out.println(EntityUtils.toString(respEntity, "utf-8")); + System.out.println("----------"); + } + } catch (Exception respEx) { + respEx.printStackTrace(); + } finally { + response.close(); + } + + } catch (Exception ex) { + System.err.println("Exception on Anomaly Detection: " + ex.getMessage()); + ex.printStackTrace(); + } finally { + try { + client.close(); + } catch (Exception e) { + System.err.println("Exception on closing HttpClient: " + e.getMessage()); + e.printStackTrace(); + } + } + } +} \ No newline at end of file diff --git a/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/StreamResponse.java b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/StreamResponse.java new file mode 100644 index 0000000..015891b --- /dev/null +++ b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/StreamResponse.java @@ -0,0 +1,80 @@ +package com.microsoft.cognitiveservice.anomalydetection; + +public class StreamResponse { + private float expectedValue; + private boolean isAnomaly; + private boolean isNegativeAnomaly; + private boolean isPositiveAnomaly; + private float lowerMargin; + private float period; + private float suggestedWindow; + private float upperMargin; + + // Getter Methods + + public float getExpectedValue() { + return expectedValue; + } + + public boolean getIsAnomaly() { + return isAnomaly; + } + + public boolean getIsNegativeAnomaly() { + return isNegativeAnomaly; + } + + public boolean getIsPositiveAnomaly() { + return isPositiveAnomaly; + } + + public float getLowerMargin() { + return lowerMargin; + } + + public float getPeriod() { + return period; + } + + public float getSuggestedWindow() { + return suggestedWindow; + } + + public float getUpperMargin() { + return upperMargin; + } + + // Setter Methods + + public void setExpectedValue(float expectedValue) { + this.expectedValue = expectedValue; + } + + public void setIsAnomaly(boolean isAnomaly) { + this.isAnomaly = isAnomaly; + } + + public void setIsNegativeAnomaly(boolean isNegativeAnomaly) { + this.isNegativeAnomaly = isNegativeAnomaly; + } + + public void setIsPositiveAnomaly(boolean isPositiveAnomaly) { + this.isPositiveAnomaly = isPositiveAnomaly; + } + + public void setLowerMargin(float lowerMargin) { + this.lowerMargin = lowerMargin; + } + + public void setPeriod(float period) { + this.period = period; + } + + public void setSuggestedWindow(float suggestedWindow) { + this.suggestedWindow = suggestedWindow; + } + + public void setUpperMargin(float upperMargin) { + this.upperMargin = upperMargin; + } +} \ No newline at end of file diff --git a/other-samples/java-sample/target/classes/request-data.json b/other-samples/java-sample/target/classes/request-data.json new file mode 100644 index 0000000..11e946c --- /dev/null +++ b/other-samples/java-sample/target/classes/request-data.json @@ -0,0 +1,193 @@ +{ + "granularity": "daily", + "series": [ + { + "timestamp": "2018-03-01T00:00:00Z", + "value": 32858923 + }, + { + "timestamp": "2018-03-02T00:00:00Z", + "value": 29615278 + }, + { + "timestamp": "2018-03-03T00:00:00Z", + "value": 22839355 + }, + { + "timestamp": "2018-03-04T00:00:00Z", + "value": 25948736 + }, + { + "timestamp": "2018-03-05T00:00:00Z", + "value": 34139159 + }, + { + "timestamp": "2018-03-06T00:00:00Z", + "value": 33843985 + }, + { + "timestamp": "2018-03-07T00:00:00Z", + "value": 33637661 + }, + { + "timestamp": "2018-03-08T00:00:00Z", + "value": 32627350 + }, + { + "timestamp": "2018-03-09T00:00:00Z", + "value": 29881076 + }, + { + "timestamp": "2018-03-10T00:00:00Z", + "value": 22681575 + }, + { + "timestamp": "2018-03-11T00:00:00Z", + "value": 24629393 + }, + { + "timestamp": "2018-03-12T00:00:00Z", + "value": 34010679 + }, + { + "timestamp": "2018-03-13T00:00:00Z", + "value": 33893888 + }, + { + "timestamp": "2018-03-14T00:00:00Z", + "value": 33760076 + }, + { + "timestamp": "2018-03-15T00:00:00Z", + "value": 33093515 + }, + { + "timestamp": "2018-03-16T00:00:00Z", + "value": 29945555 + }, + { + "timestamp": "2018-03-17T00:00:00Z", + "value": 22676212 + }, + { + "timestamp": "2018-03-18T00:00:00Z", + "value": 25262514 + }, + { + "timestamp": "2018-03-19T00:00:00Z", + "value": 33631649 + }, + { + "timestamp": "2018-03-20T00:00:00Z", + "value": 34468310 + }, + { + "timestamp": "2018-03-21T00:00:00Z", + "value": 34212281 + }, + { + "timestamp": "2018-03-22T00:00:00Z", + "value": 38144434 + }, + { + "timestamp": "2018-03-23T00:00:00Z", + "value": 34662949 + }, + { + "timestamp": "2018-03-24T00:00:00Z", + "value": 24623684 + }, + { + "timestamp": "2018-03-25T00:00:00Z", + "value": 26530491 + }, + { + "timestamp": "2018-03-26T00:00:00Z", + "value": 35445003 + }, + { + "timestamp": "2018-03-27T00:00:00Z", + "value": 34250789 + }, + { + "timestamp": "2018-03-28T00:00:00Z", + "value": 33423012 + }, + { + "timestamp": "2018-03-29T00:00:00Z", + "value": 30744783 + }, + { + "timestamp": "2018-03-30T00:00:00Z", + "value": 25825128 + }, + { + "timestamp": "2018-03-31T00:00:00Z", + "value": 21244209 + }, + { + "timestamp": "2018-04-01T00:00:00Z", + "value": 22576956 + }, + { + "timestamp": "2018-04-02T00:00:00Z", + "value": 31957221 + }, + { + "timestamp": "2018-04-03T00:00:00Z", + "value": 33841228 + }, + { + "timestamp": "2018-04-04T00:00:00Z", + "value": 33554483 + }, + { + "timestamp": "2018-04-05T00:00:00Z", + "value": 32383350 + }, + { + "timestamp": "2018-04-06T00:00:00Z", + "value": 29494850 + }, + { + "timestamp": "2018-04-07T00:00:00Z", + "value": 22815534 + }, + { + "timestamp": "2018-04-08T00:00:00Z", + "value": 25557267 + }, + { + "timestamp": "2018-04-09T00:00:00Z", + "value": 34858252 + }, + { + "timestamp": "2018-04-10T00:00:00Z", + "value": 34750597 + }, + { + "timestamp": "2018-04-11T00:00:00Z", + "value": 34717956 + }, + { + "timestamp": "2018-04-12T00:00:00Z", + "value": 34132534 + }, + { + "timestamp": "2018-04-13T00:00:00Z", + "value": 30762236 + }, + { + "timestamp": "2018-04-14T00:00:00Z", + "value": 22504059 + }, + { + "timestamp": "2018-04-15T00:00:00Z", + "value": 26149060 + }, + { + "timestamp": "2018-04-16T00:00:00Z", + "value": 35250105 + } + ] + } \ No newline at end of file diff --git a/other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..496e9e1 --- /dev/null +++ b/other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,4 @@ +com/microsoft/cognitiveservice/anomalydetection/AnomalyDetectorRequest.class +com/microsoft/cognitiveservice/anomalydetection/StreamResponse.class +com/microsoft/cognitiveservice/anomalydetection/Main.class +com/microsoft/cognitiveservice/anomalydetection/Point.class diff --git a/other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..f037cf8 --- /dev/null +++ b/other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,4 @@ +/Users/pamir/dev/projects/opensource/microsoft/AnomalyDetector/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java +/Users/pamir/dev/projects/opensource/microsoft/AnomalyDetector/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/AnomalyDetectorRequest.java +/Users/pamir/dev/projects/opensource/microsoft/AnomalyDetector/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Point.java +/Users/pamir/dev/projects/opensource/microsoft/AnomalyDetector/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/StreamResponse.java From d003f2a9092143c9202b374930d0ebd2ff119402 Mon Sep 17 00:00:00 2001 From: Pamir Erdem Date: Sun, 9 Feb 2020 01:09:14 +0300 Subject: [PATCH 4/5] stream mode and container sample added --- .../anomalydetection/Main.java | 8 +- .../target/classes/request-data.json | 193 ------------------ .../compile/default-compile/createdFiles.lst | 4 - .../compile/default-compile/inputFiles.lst | 4 - 4 files changed, 5 insertions(+), 204 deletions(-) delete mode 100644 other-samples/java-sample/target/classes/request-data.json delete mode 100644 other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst delete mode 100644 other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst diff --git a/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java index 6ed1424..0437ed7 100644 --- a/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java +++ b/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java @@ -18,13 +18,15 @@ public class Main { // ********************************************** // Replace the subscriptionKey string value with your valid subscription key. - private static final String subscriptionKey = "xxxxx"; + + private static final String subscriptionKey = ""; + // Choose which anomaly detection way you want to use and change the uriBase's second part - private static final String rootUrl = "http://localhost:5000/anomalydetector/v1.0"; + private static final String rootUrl = "https://westus2.api.cognitive.microsoft.com/anomalydetector/v1.0"; private static final String lastDetect = "/timeseries/last/detect"; private static final String entireDetect = "/timeseries/entire/detect"; - private static final String uriBase = rootUrl + entireDetect; + private static final String uriBase = rootUrl + lastDetect; public static void main(String[] args) throws FileNotFoundException { String resourceName = "/request-data.json"; diff --git a/other-samples/java-sample/target/classes/request-data.json b/other-samples/java-sample/target/classes/request-data.json deleted file mode 100644 index 11e946c..0000000 --- a/other-samples/java-sample/target/classes/request-data.json +++ /dev/null @@ -1,193 +0,0 @@ -{ - "granularity": "daily", - "series": [ - { - "timestamp": "2018-03-01T00:00:00Z", - "value": 32858923 - }, - { - "timestamp": "2018-03-02T00:00:00Z", - "value": 29615278 - }, - { - "timestamp": "2018-03-03T00:00:00Z", - "value": 22839355 - }, - { - "timestamp": "2018-03-04T00:00:00Z", - "value": 25948736 - }, - { - "timestamp": "2018-03-05T00:00:00Z", - "value": 34139159 - }, - { - "timestamp": "2018-03-06T00:00:00Z", - "value": 33843985 - }, - { - "timestamp": "2018-03-07T00:00:00Z", - "value": 33637661 - }, - { - "timestamp": "2018-03-08T00:00:00Z", - "value": 32627350 - }, - { - "timestamp": "2018-03-09T00:00:00Z", - "value": 29881076 - }, - { - "timestamp": "2018-03-10T00:00:00Z", - "value": 22681575 - }, - { - "timestamp": "2018-03-11T00:00:00Z", - "value": 24629393 - }, - { - "timestamp": "2018-03-12T00:00:00Z", - "value": 34010679 - }, - { - "timestamp": "2018-03-13T00:00:00Z", - "value": 33893888 - }, - { - "timestamp": "2018-03-14T00:00:00Z", - "value": 33760076 - }, - { - "timestamp": "2018-03-15T00:00:00Z", - "value": 33093515 - }, - { - "timestamp": "2018-03-16T00:00:00Z", - "value": 29945555 - }, - { - "timestamp": "2018-03-17T00:00:00Z", - "value": 22676212 - }, - { - "timestamp": "2018-03-18T00:00:00Z", - "value": 25262514 - }, - { - "timestamp": "2018-03-19T00:00:00Z", - "value": 33631649 - }, - { - "timestamp": "2018-03-20T00:00:00Z", - "value": 34468310 - }, - { - "timestamp": "2018-03-21T00:00:00Z", - "value": 34212281 - }, - { - "timestamp": "2018-03-22T00:00:00Z", - "value": 38144434 - }, - { - "timestamp": "2018-03-23T00:00:00Z", - "value": 34662949 - }, - { - "timestamp": "2018-03-24T00:00:00Z", - "value": 24623684 - }, - { - "timestamp": "2018-03-25T00:00:00Z", - "value": 26530491 - }, - { - "timestamp": "2018-03-26T00:00:00Z", - "value": 35445003 - }, - { - "timestamp": "2018-03-27T00:00:00Z", - "value": 34250789 - }, - { - "timestamp": "2018-03-28T00:00:00Z", - "value": 33423012 - }, - { - "timestamp": "2018-03-29T00:00:00Z", - "value": 30744783 - }, - { - "timestamp": "2018-03-30T00:00:00Z", - "value": 25825128 - }, - { - "timestamp": "2018-03-31T00:00:00Z", - "value": 21244209 - }, - { - "timestamp": "2018-04-01T00:00:00Z", - "value": 22576956 - }, - { - "timestamp": "2018-04-02T00:00:00Z", - "value": 31957221 - }, - { - "timestamp": "2018-04-03T00:00:00Z", - "value": 33841228 - }, - { - "timestamp": "2018-04-04T00:00:00Z", - "value": 33554483 - }, - { - "timestamp": "2018-04-05T00:00:00Z", - "value": 32383350 - }, - { - "timestamp": "2018-04-06T00:00:00Z", - "value": 29494850 - }, - { - "timestamp": "2018-04-07T00:00:00Z", - "value": 22815534 - }, - { - "timestamp": "2018-04-08T00:00:00Z", - "value": 25557267 - }, - { - "timestamp": "2018-04-09T00:00:00Z", - "value": 34858252 - }, - { - "timestamp": "2018-04-10T00:00:00Z", - "value": 34750597 - }, - { - "timestamp": "2018-04-11T00:00:00Z", - "value": 34717956 - }, - { - "timestamp": "2018-04-12T00:00:00Z", - "value": 34132534 - }, - { - "timestamp": "2018-04-13T00:00:00Z", - "value": 30762236 - }, - { - "timestamp": "2018-04-14T00:00:00Z", - "value": 22504059 - }, - { - "timestamp": "2018-04-15T00:00:00Z", - "value": 26149060 - }, - { - "timestamp": "2018-04-16T00:00:00Z", - "value": 35250105 - } - ] - } \ No newline at end of file diff --git a/other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst deleted file mode 100644 index 496e9e1..0000000 --- a/other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ /dev/null @@ -1,4 +0,0 @@ -com/microsoft/cognitiveservice/anomalydetection/AnomalyDetectorRequest.class -com/microsoft/cognitiveservice/anomalydetection/StreamResponse.class -com/microsoft/cognitiveservice/anomalydetection/Main.class -com/microsoft/cognitiveservice/anomalydetection/Point.class diff --git a/other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index f037cf8..0000000 --- a/other-samples/java-sample/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1,4 +0,0 @@ -/Users/pamir/dev/projects/opensource/microsoft/AnomalyDetector/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Main.java -/Users/pamir/dev/projects/opensource/microsoft/AnomalyDetector/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/AnomalyDetectorRequest.java -/Users/pamir/dev/projects/opensource/microsoft/AnomalyDetector/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/Point.java -/Users/pamir/dev/projects/opensource/microsoft/AnomalyDetector/other-samples/java-sample/src/main/java/com/microsoft/cognitiveservice/anomalydetection/StreamResponse.java From 551a5073ddc8cd07bd47958c4f8802f952e2af0f Mon Sep 17 00:00:00 2001 From: Pamir Erdem Date: Sun, 9 Feb 2020 01:18:23 +0300 Subject: [PATCH 5/5] git ignore files added --- .gitignore | 12 +++++ other-samples/java-sample/.classpath | 49 ------------------- other-samples/java-sample/.gitignore | 3 ++ other-samples/java-sample/.project | 23 --------- .../.settings/org.eclipse.jdt.apt.core.prefs | 2 - .../.settings/org.eclipse.jdt.core.prefs | 9 ---- .../.settings/org.eclipse.m2e.core.prefs | 4 -- .../java-sample/.vscode/settings.json | 3 -- other-samples/java-sample/anomalydetction.iml | 2 - 9 files changed, 15 insertions(+), 92 deletions(-) delete mode 100644 other-samples/java-sample/.classpath delete mode 100644 other-samples/java-sample/.project delete mode 100644 other-samples/java-sample/.settings/org.eclipse.jdt.apt.core.prefs delete mode 100644 other-samples/java-sample/.settings/org.eclipse.jdt.core.prefs delete mode 100644 other-samples/java-sample/.settings/org.eclipse.m2e.core.prefs delete mode 100644 other-samples/java-sample/.vscode/settings.json delete mode 100644 other-samples/java-sample/anomalydetction.iml diff --git a/.gitignore b/.gitignore index 3e759b7..cbde30a 100644 --- a/.gitignore +++ b/.gitignore @@ -328,3 +328,15 @@ ASALocalRun/ # MFractors (Xamarin productivity tool) working folder .mfractor/ + + +#eclipse +.project +.classpath +.settings/ + +#IntelliJ Extesions +*.iml + +#visual code +.vscode/ diff --git a/other-samples/java-sample/.classpath b/other-samples/java-sample/.classpath deleted file mode 100644 index 1b799f3..0000000 --- a/other-samples/java-sample/.classpath +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/other-samples/java-sample/.gitignore b/other-samples/java-sample/.gitignore index 6143e53..1a4c78e 100644 --- a/other-samples/java-sample/.gitignore +++ b/other-samples/java-sample/.gitignore @@ -20,3 +20,6 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + + +.vscode \ No newline at end of file diff --git a/other-samples/java-sample/.project b/other-samples/java-sample/.project deleted file mode 100644 index 28d7e9e..0000000 --- a/other-samples/java-sample/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - anomalydetction - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/other-samples/java-sample/.settings/org.eclipse.jdt.apt.core.prefs b/other-samples/java-sample/.settings/org.eclipse.jdt.apt.core.prefs deleted file mode 100644 index d4313d4..0000000 --- a/other-samples/java-sample/.settings/org.eclipse.jdt.apt.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.apt.aptEnabled=false diff --git a/other-samples/java-sample/.settings/org.eclipse.jdt.core.prefs b/other-samples/java-sample/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index ac8e750..0000000 --- a/other-samples/java-sample/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore -org.eclipse.jdt.core.compiler.processAnnotations=disabled -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.5 diff --git a/other-samples/java-sample/.settings/org.eclipse.m2e.core.prefs b/other-samples/java-sample/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f..0000000 --- a/other-samples/java-sample/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/other-samples/java-sample/.vscode/settings.json b/other-samples/java-sample/.vscode/settings.json deleted file mode 100644 index e0f15db..0000000 --- a/other-samples/java-sample/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "java.configuration.updateBuildConfiguration": "automatic" -} \ No newline at end of file diff --git a/other-samples/java-sample/anomalydetction.iml b/other-samples/java-sample/anomalydetction.iml deleted file mode 100644 index 74f3f13..0000000 --- a/other-samples/java-sample/anomalydetction.iml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file