-
Notifications
You must be signed in to change notification settings - Fork 1
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 #12 from toast-tk/156-review-webapp-connectivity
156 review webapp connectivity
- Loading branch information
Showing
10 changed files
with
166 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
if [ ${TRAVIS_PULL_REQUEST} = 'false' ] && [[ $TRAVIS_BRANCH = 'master' || ${TRAVIS_BRANCH} = 'snapshot' ]]; then | ||
echo 'Checking Quality Gates against sonar' | ||
mvn --batch-mode clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.1:sonar -Dsonar.host.url=${SONAR_URL} -Dsonar.login=${SONAR_LOGIN} --settings ./settings.xml; | ||
mvn --batch-mode clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.1:sonar -Dsonar.host.url=${SONAR_URL} -Dsonar.login=${SONAR_LOGIN} -Dsonar.organization=${SONAR_ORGANIZATION} --settings ./settings.xml; | ||
elif [ ${TRAVIS_PULL_REQUEST} != 'false' ]; then | ||
echo 'Build and analyze pull request' | ||
mvn --batch-mode clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.1:sonar -Dsonar.analysis.mode=issues -Dsonar.host.url=${SONAR_URL} -Dsonar.login=${SONAR_LOGIN} -Dsonar.password=${SONAR_PASSWORD} -Dsonar.github.oauth=${SONAR_GITHUB_OAUTH} -Dsonar.github.repository=toast-tk/toast-tk-agent -Dsonar.github.pullRequest=${TRAVIS_PULL_REQUEST}; | ||
mvn --batch-mode clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.1:sonar -Dsonar.analysis.mode=issues -Dsonar.host.url=${SONAR_URL} -Dsonar.login=${SONAR_LOGIN} -Dsonar.organization=${SONAR_ORGANIZATION} -Dsonar.github.oauth=${SONAR_GITHUB_OAUTH} -Dsonar.github.repository=toast-tk/toast-tk-agent -Dsonar.github.pullRequest=${TRAVIS_PULL_REQUEST}; | ||
fi |
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
35 changes: 35 additions & 0 deletions
35
toast-tk-web-agent/src/main/java/io/toast/tk/agent/web/WebAppSocketListener.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,35 @@ | ||
package io.toast.tk.agent.web; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.asynchttpclient.ws.WebSocket; | ||
import org.asynchttpclient.ws.WebSocketTextListener; | ||
|
||
/** | ||
* Webapp connection alive checkecker socket | ||
* | ||
*/ | ||
public class WebAppSocketListener implements WebSocketTextListener { | ||
|
||
private static final Logger LOG = LogManager.getLogger(WebAppSocketListener.class); | ||
|
||
@Override | ||
public void onOpen(WebSocket webSocket) { | ||
//NO-OP | ||
} | ||
|
||
@Override | ||
public void onClose(WebSocket webSocket) { | ||
//NO-OP | ||
} | ||
|
||
@Override | ||
public void onError(Throwable throwable) { | ||
LOG.error(throwable.getMessage(), throwable); | ||
} | ||
|
||
@Override | ||
public void onMessage(String message) { | ||
//NO-OP | ||
} | ||
} |
79 changes: 49 additions & 30 deletions
79
toast-tk-web-agent/src/main/java/io/toast/tk/agent/web/rest/AsyncHttpClientProvider.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 |
---|---|---|
@@ -1,42 +1,61 @@ | ||
package io.toast.tk.agent.web.rest; | ||
|
||
import com.google.common.base.Strings; | ||
import com.google.inject.Inject; | ||
import com.google.inject.Provider; | ||
import io.toast.tk.agent.config.AgentConfig; | ||
import org.asynchttpclient.AsyncHttpClientConfig; | ||
import javax.net.ssl.SSLException; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.asynchttpclient.DefaultAsyncHttpClient; | ||
import org.asynchttpclient.DefaultAsyncHttpClientConfig; | ||
import org.asynchttpclient.DefaultAsyncHttpClientConfig.Builder; | ||
import org.asynchttpclient.Realm; | ||
import org.asynchttpclient.Realm.AuthScheme; | ||
import org.asynchttpclient.netty.ssl.InsecureTrustManagerFactory; | ||
import org.asynchttpclient.proxy.ProxyServer; | ||
|
||
import com.google.common.base.Strings; | ||
import com.google.inject.Inject; | ||
import com.google.inject.Provider; | ||
|
||
import io.netty.handler.ssl.SslContextBuilder; | ||
import io.toast.tk.agent.config.AgentConfig; | ||
|
||
public class AsyncHttpClientProvider implements Provider<DefaultAsyncHttpClient> { | ||
|
||
private static final Logger LOG = LogManager.getLogger(AsyncHttpClientProvider.class); | ||
private final AgentConfig config; | ||
|
||
@Inject | ||
public AsyncHttpClientProvider(AgentConfig config) { | ||
this.config = config; | ||
} | ||
|
||
@Override | ||
public DefaultAsyncHttpClient get() { | ||
if (Boolean.valueOf(this.config.getProxyActivate())) { | ||
String proxyPort = this.config.getProxyPort(); | ||
int port = Strings.isNullOrEmpty(proxyPort) ? -1 : Integer.parseInt(proxyPort); | ||
ProxyServer proxyServer = new ProxyServer.Builder(config.getProxyAdress(), port).build(); | ||
|
||
Builder builder = new DefaultAsyncHttpClientConfig.Builder().setProxyServer(proxyServer); | ||
|
||
if (!Strings.isNullOrEmpty(config.getProxyUserName()) | ||
&& !Strings.isNullOrEmpty(config.getProxyUserPswd())) { | ||
Realm realm = new Realm.Builder(config.getProxyUserName(), config.getProxyUserPswd()) | ||
.setScheme(AuthScheme.BASIC).build(); | ||
builder.setRealm(realm); | ||
} | ||
|
||
try { | ||
if (proxyServer.getHost().startsWith("https")) { | ||
builder.setSslContext( | ||
SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build()); | ||
} | ||
} catch (SSLException e) { | ||
LOG.error(e.getMessage(), e); | ||
} | ||
|
||
private final AgentConfig config; | ||
|
||
@Inject | ||
public AsyncHttpClientProvider(AgentConfig config){ | ||
this.config = config; | ||
} | ||
|
||
@Override | ||
public DefaultAsyncHttpClient get() { | ||
if(Boolean.valueOf(this.config.getProxyActivate())){ | ||
String proxyPort = this.config.getProxyPort(); | ||
int port = Strings.isNullOrEmpty(proxyPort ) ? -1 : Integer.parseInt(proxyPort); | ||
ProxyServer proxyServer = new ProxyServer.Builder(config.getProxyAdress(), port).build(); | ||
if(!Strings.isNullOrEmpty(config.getProxyUserName()) && !Strings.isNullOrEmpty(config.getProxyUserPswd()) ){ | ||
Realm realm = new Realm.Builder(config.getProxyUserName(), config.getProxyUserPswd()).build(); | ||
AsyncHttpClientConfig cf = new DefaultAsyncHttpClientConfig.Builder() | ||
.setProxyServer(proxyServer).setRealm(realm).build(); | ||
return new DefaultAsyncHttpClient(cf); | ||
} | ||
AsyncHttpClientConfig cf = new DefaultAsyncHttpClientConfig.Builder() | ||
.setProxyServer(proxyServer).build(); | ||
return new DefaultAsyncHttpClient(cf); | ||
} | ||
return new DefaultAsyncHttpClient(); | ||
} | ||
return new DefaultAsyncHttpClient(builder.build()); | ||
} | ||
return new DefaultAsyncHttpClient(); | ||
} | ||
} |
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