ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpav...@apache.org
Subject [ignite-teamcity-bot] branch master updated: Recoding and show in monitoring list of latest URLs used
Date Sat, 29 Sep 2018 10:09:53 GMT
This is an automated email from the ASF dual-hosted git repository.

dpavlov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git


The following commit(s) were added to refs/heads/master by this push:
     new 3b59e63  Recoding and show in monitoring list of latest URLs used
3b59e63 is described below

commit 3b59e63be01b9492a33d14a3a79c1ee387de9592
Author: Dmitriy Pavlov <dpavlov@apache.org>
AuthorDate: Sat Sep 29 13:09:49 2018 +0300

    Recoding and show in monitoring list of latest URLs used
---
 .../apache/ignite/ci/IgniteTeamcityConnection.java | 19 ++++++++--
 .../org/apache/ignite/ci/di/IgniteTcBotModule.java |  3 ++
 .../ci/teamcity/ITeamcityHttpConnection.java       | 25 +++++++++++++
 .../ci/teamcity/TeamcityRecordingConnection.java   | 43 ++++++++++++++++++++++
 .../ci/web/rest/monitoring/MonitoringService.java  | 26 +++++++++++++
 .../ignite/ci/web/rest/monitoring/UrlUsed.java     | 23 ++++++++++++
 .../src/main/webapp/monitoring.html                | 39 +++++++++++++++++++-
 7 files changed, 172 insertions(+), 6 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java
index 070f4b2..eddb50b 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java
@@ -45,6 +45,7 @@ import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
+import javax.inject.Inject;
 import javax.xml.bind.JAXBException;
 import org.apache.ignite.ci.analysis.ISuiteResults;
 import org.apache.ignite.ci.analysis.LogCheckResult;
@@ -74,6 +75,7 @@ import org.apache.ignite.ci.tcmodel.result.tests.TestOccurrenceFull;
 import org.apache.ignite.ci.tcmodel.result.tests.TestOccurrences;
 import org.apache.ignite.ci.tcmodel.user.User;
 import org.apache.ignite.ci.tcmodel.user.Users;
+import org.apache.ignite.ci.teamcity.ITeamcityHttpConnection;
 import org.apache.ignite.ci.util.*;
 import org.apache.ignite.internal.util.typedef.T2;
 import org.jetbrains.annotations.NotNull;
@@ -104,6 +106,10 @@ public class IgniteTeamcityConnection implements ITeamcity {
     /** TeamCity authorization token. */
     private String basicAuthTok;
 
+    @Inject
+    private ITeamcityHttpConnection teamcityHttpConnection;
+
+
     /** GitHub authorization token.  */
     private String gitAuthTok;
 
@@ -133,12 +139,14 @@ public class IgniteTeamcityConnection implements ITeamcity {
         final String hostConf = props.getProperty(HelperConfig.HOST, "https://ci.ignite.apache.org/");
 
         this.host = hostConf.trim() + (hostConf.endsWith("/") ? "" : "/");
+
         try {
             if (props.getProperty(HelperConfig.USERNAME) != null
                     && props.getProperty(HelperConfig.ENCODED_PASSWORD) != null)
                 setAuthToken(HelperConfig.prepareBasicHttpAuthToken(props, configName));
         } catch (Exception e) {
             e.printStackTrace();
+            logger.error("Failed to set credentials", e);
         }
 
         setGitToken(HelperConfig.prepareGithubHttpAuthToken(props));
@@ -446,7 +454,7 @@ public class IgniteTeamcityConnection implements ITeamcity {
 
     private <T> T sendGetXmlParseJaxb(String url, Class<T> rootElem) {
         try {
-            try (InputStream inputStream = HttpUtil.sendGetWithBasicAuth(basicAuthTok, url))
{
+            try (InputStream inputStream = teamcityHttpConnection.sendGet(basicAuthTok, url))
{
                 final InputStreamReader reader = new InputStreamReader(inputStream);
 
                 return loadXml(rootElem, reader);
@@ -460,6 +468,8 @@ public class IgniteTeamcityConnection implements ITeamcity {
         }
     }
 
+
+
     @SuppressWarnings("WeakerAccess")
     @AutoProfiling
     protected <T> T loadXml(Class<T> rootElem, InputStreamReader reader) throws
JAXBException {
@@ -578,8 +588,7 @@ public class IgniteTeamcityConnection implements ITeamcity {
 
     /** {@inheritDoc} */
     @AutoProfiling
-    @Override public List<BuildRef> getFinishedBuilds(String projectId,
-        String branch) {
+    @Override public List<BuildRef> getFinishedBuilds(String projectId, String branch)
{
 
         return getFinishedBuilds(projectId, branch, null, null, null);
     }
@@ -664,7 +673,9 @@ public class IgniteTeamcityConnection implements ITeamcity {
         return zipFut.thenApplyAsync(zipFile -> runCheckForZippedLog(dumpLastTest, zipFile),
executor);
     }
 
-    @NotNull private LogCheckTask runCheckForZippedLog(boolean dumpLastTest, File zipFile)
{
+    @SuppressWarnings("WeakerAccess")
+    @AutoProfiling
+    @NotNull protected LogCheckTask runCheckForZippedLog(boolean dumpLastTest, File zipFile)
{
         LogCheckTask task = new LogCheckTask(zipFile);
 
         try {
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/di/IgniteTcBotModule.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/di/IgniteTcBotModule.java
index 442301c..4ba758c 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/di/IgniteTcBotModule.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/di/IgniteTcBotModule.java
@@ -29,6 +29,8 @@ import org.apache.ignite.ci.issue.IssueDetector;
 import org.apache.ignite.ci.jira.IJiraIntegration;
 import org.apache.ignite.ci.observer.BuildObserver;
 import org.apache.ignite.ci.observer.ObserverTask;
+import org.apache.ignite.ci.teamcity.ITeamcityHttpConnection;
+import org.apache.ignite.ci.teamcity.TeamcityRecordingConnection;
 import org.apache.ignite.ci.user.ICredentialsProv;
 import org.apache.ignite.ci.util.ExceptionUtil;
 import org.apache.ignite.ci.web.TcUpdatePool;
@@ -74,6 +76,7 @@ public class IgniteTcBotModule extends AbstractModule {
         bind(ITcHelper.class).to(TcHelper.class).in(new SingletonScope());
 
         bind(IJiraIntegration.class).to(Jira.class).in(new SingletonScope());
+        bind(ITeamcityHttpConnection.class).to(TeamcityRecordingConnection.class).in(new
SingletonScope());
     }
 
     //todo fallback to TC big class
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ITeamcityHttpConnection.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ITeamcityHttpConnection.java
new file mode 100644
index 0000000..4a6dd3c
--- /dev/null
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ITeamcityHttpConnection.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ci.teamcity;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public interface ITeamcityHttpConnection {
+    InputStream sendGet(String basicAuthTok, String url) throws IOException;
+}
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/TeamcityRecordingConnection.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/TeamcityRecordingConnection.java
new file mode 100644
index 0000000..455a42f
--- /dev/null
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/TeamcityRecordingConnection.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.ci.teamcity;
+
+import org.apache.ignite.ci.util.HttpUtil;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+public class TeamcityRecordingConnection implements ITeamcityHttpConnection {
+    private ConcurrentLinkedQueue<String> urls = new ConcurrentLinkedQueue<>();
+
+    public InputStream sendGet(String basicAuthTok, String url) throws IOException {
+        urls.add(url);
+        if(urls.size()>100)
+            urls.remove();
+
+        return HttpUtil.sendGetWithBasicAuth(basicAuthTok, url);
+    }
+
+    public List<String> getUrls() {
+        final ArrayList<String> list = new ArrayList<>(urls);
+
+        return list;
+    }
+}
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/monitoring/MonitoringService.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/monitoring/MonitoringService.java
index e0ba52a..c965625 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/monitoring/MonitoringService.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/monitoring/MonitoringService.java
@@ -22,6 +22,8 @@ import org.apache.ignite.cache.CacheMetrics;
 import org.apache.ignite.cache.affinity.Affinity;
 import org.apache.ignite.ci.di.AutoProfilingInterceptor;
 import org.apache.ignite.ci.di.MonitoredTaskInterceptor;
+import org.apache.ignite.ci.teamcity.ITeamcityHttpConnection;
+import org.apache.ignite.ci.teamcity.TeamcityRecordingConnection;
 import org.apache.ignite.ci.web.CtxListener;
 
 import javax.annotation.security.PermitAll;
@@ -116,4 +118,28 @@ public class MonitoringService {
         }
         return res;
     }
+
+
+    @GET
+    @PermitAll
+    @Path("urls")
+    public List<UrlUsed> getUrlsUsed() {
+        final ITeamcityHttpConnection tcConn = CtxListener.getInjector(ctx).getInstance(ITeamcityHttpConnection.class);
+
+        if (!(tcConn instanceof TeamcityRecordingConnection)) {
+            return Collections.emptyList();
+        }
+
+        final TeamcityRecordingConnection tcConn1 = (TeamcityRecordingConnection) tcConn;
+
+        final List<String> urls = tcConn1.getUrls();
+
+        return urls.stream().map(s -> {
+            final UrlUsed urlRequested = new UrlUsed();
+            urlRequested.url = s;
+            return urlRequested;
+        }).collect(Collectors.toList());
+
+
+    }
 }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/monitoring/UrlUsed.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/monitoring/UrlUsed.java
new file mode 100644
index 0000000..3bffab2
--- /dev/null
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/monitoring/UrlUsed.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.ci.web.rest.monitoring;
+
+
+@SuppressWarnings("WeakerAccess")
+public class UrlUsed {
+    public String url;
+}
diff --git a/ignite-tc-helper-web/src/main/webapp/monitoring.html b/ignite-tc-helper-web/src/main/webapp/monitoring.html
index 35ad17b..5bae24f 100644
--- a/ignite-tc-helper-web/src/main/webapp/monitoring.html
+++ b/ignite-tc-helper-web/src/main/webapp/monitoring.html
@@ -61,6 +61,16 @@
             },
             error: showErrInLoadStatus
         });
+
+        $.ajax({
+            url: "rest/monitoring/urls",
+            success: function(result) {
+                $("#loadStatus").html("");
+
+                showUrlsUsed(result);
+            },
+            error: showErrInLoadStatus
+        });
     }
 
     /**
@@ -121,17 +131,42 @@
         $("#caches").html(res);
     }
 
+    /**
+     * @param result org.apache.ignite.ci.web.rest.monitoring.HotSpot
+     */
+    function showUrlsUsed(result) {
+        var res = "<table class='stat'>" ;
+        res += "<tr>";
+        res += "<th>URL</th>";
+        res += "</tr>";
+        for (var i = 0; i < result.length; i++) {
+            var inv = result[i];
+            res += "<tr>";
+            res += "<td>" + inv.url + "</td>";
+            res += "</tr>";
+        }
+        res += "</table>";
+        $("#urlUsed").html(res);
+    }
+
 </script>
 
 Tasks Monitoring Data:
 <div id="tasks" style="font-family: monospace"></div>
 <br>
 
-Profiling Data:
+<hr>
+<b>Method Profiling Data:</b>
 <div id="profiling" style="font-family: monospace"></div>
 <br>
-Caches Data:
+
+<hr>
+<b>Ignite Caches Data:</b>
 <div id="caches" style="font-family: monospace"></div>
+
+<hr>
+<b>Services URLs used:</b>
+<div id="urlUsed"></div>
 <br>
 <div id="loadStatus"></div>
 <div id="version"></div>


Mime
View raw message