diff --git a/assembly/assembly-wsagent-war/src/main/java/org/eclipse/che/wsagent/server/WsAgentAnalyticsAddresser.java b/assembly/assembly-wsagent-war/src/main/java/org/eclipse/che/wsagent/server/WsAgentAnalyticsAddresser.java new file mode 100644 index 00000000000..c27b86efa73 --- /dev/null +++ b/assembly/assembly-wsagent-war/src/main/java/org/eclipse/che/wsagent/server/WsAgentAnalyticsAddresser.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.wsagent.server; + +import org.eclipse.che.commons.schedule.ScheduleRate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.inject.Singleton; +import javax.net.ssl.HttpsURLConnection; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.concurrent.TimeUnit; + +@Singleton +public class WsAgentAnalyticsAddresser { + + private static final Logger LOG = LoggerFactory.getLogger(WsAgentAnalyticsAddresser.class); + + @ScheduleRate(period = 1, unit = TimeUnit.HOURS) + void send() { + HttpURLConnection connection = null; + try { + final URL url = new URL("https://install.codenvycorp.com/che/telemetry/workspace"); + connection = (HttpsURLConnection)url.openConnection(); + connection.getResponseCode(); + } catch (IOException e) { + LOG.error("Failed to send agent analytics", e); + } finally { + if (connection != null) { + connection.disconnect(); + } + } + } +} diff --git a/assembly/assembly-wsagent-war/src/main/java/org/eclipse/che/wsagent/server/WsAgentModule.java b/assembly/assembly-wsagent-war/src/main/java/org/eclipse/che/wsagent/server/WsAgentModule.java index 5d7edff7360..de7cbb0f84c 100644 --- a/assembly/assembly-wsagent-war/src/main/java/org/eclipse/che/wsagent/server/WsAgentModule.java +++ b/assembly/assembly-wsagent-war/src/main/java/org/eclipse/che/wsagent/server/WsAgentModule.java @@ -66,6 +66,7 @@ protected void configure() { install(new ProjectApiModule()); install(new org.eclipse.che.swagger.deploy.DocsModule()); install(new org.eclipse.che.api.debugger.server.DebuggerModule()); + install(new org.eclipse.che.commons.schedule.executor.ScheduleModule()); bind(GitUserResolver.class).to(LocalGitUserResolver.class); bind(GitConnectionFactory.class).to(JGitConnectionFactory.class); @@ -80,6 +81,7 @@ protected void configure() { bind(String.class).annotatedWith(Names.named("event.bus.url")).toProvider(EventBusURLProvider.class); bind(ApiEndpointAccessibilityChecker.class); + bind(WsAgentAnalyticsAddresser.class); bind(String.class).annotatedWith(Names.named("wsagent.endpoint")) .toProvider(WsAgentURLProvider.class); diff --git a/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterAnalyticsAddresser.java b/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterAnalyticsAddresser.java new file mode 100644 index 00000000000..67b7419fb65 --- /dev/null +++ b/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterAnalyticsAddresser.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.api.deploy; + +import org.eclipse.che.commons.schedule.ScheduleRate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.inject.Singleton; +import javax.net.ssl.HttpsURLConnection; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.concurrent.TimeUnit; + +@Singleton +public class WsMasterAnalyticsAddresser { + + private static final Logger LOG = LoggerFactory.getLogger(WsMasterAnalyticsAddresser.class); + + @ScheduleRate(period = 1, unit = TimeUnit.HOURS) + void send() { + HttpURLConnection connection = null; + try { + final URL url = new URL("https://install.codenvycorp.com/che/telemetry/master"); + connection = (HttpsURLConnection)url.openConnection(); + connection.getResponseCode(); + } catch (IOException e) { + LOG.error("Failed to send master analytics", e); + } finally { + if (connection != null) { + connection.disconnect(); + } + } + } +} diff --git a/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterModule.java b/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterModule.java index acbe2389049..e0bfca91ff9 100644 --- a/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterModule.java +++ b/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterModule.java @@ -83,6 +83,7 @@ protected void configure() { .to(org.eclipse.che.api.machine.server.wsagent.WsAgentLauncherImpl.class); bind(org.eclipse.che.api.machine.server.terminal.MachineTerminalLauncher.class); + bind(org.eclipse.che.api.deploy.WsMasterAnalyticsAddresser.class); Multibinder machineImageProviderMultibinder = Multibinder.newSetBinder(binder(), org.eclipse.che.api.machine.server.spi.InstanceProvider.class);