Skip to content

Commit

Permalink
Connection Diagnostic Tool Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
JJStarrett committed Jul 22, 2019
1 parent 62b5da9 commit 5958e20
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 35 deletions.
Expand Up @@ -21,31 +21,33 @@

package org.jumpmind.symmetric.transport;

import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;

import org.jumpmind.symmetric.model.BatchAck;
import org.jumpmind.symmetric.model.IncomingBatch;
import org.jumpmind.symmetric.model.Node;

import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;

import org.jumpmind.symmetric.model.BatchAck;
import org.jumpmind.symmetric.model.IncomingBatch;
import org.jumpmind.symmetric.model.Node;

public interface ITransportManager {

public int sendAcknowledgement(Node remote, List<IncomingBatch> list, Node local, String securityToken, String registrationUrl) throws IOException;

public void writeAcknowledgement(OutputStream out, Node remote, List<IncomingBatch> list, Node local, String securityToken) throws IOException;

public List<BatchAck> readAcknowledgement(String parameterString1, String parameterString2) throws IOException;

public IIncomingTransport getFilePullTransport(Node remote, Node local, String securityToken,
Map<String, String> requestProperties, String registrationUrl) throws IOException;

public IOutgoingWithResponseTransport getFilePushTransport(Node remote, Node local,
public List<BatchAck> readAcknowledgement(String parameterString1, String parameterString2) throws IOException;

public IIncomingTransport getFilePullTransport(Node remote, Node local, String securityToken,
Map<String, String> requestProperties, String registrationUrl) throws IOException;

public IOutgoingWithResponseTransport getFilePushTransport(Node remote, Node local,
String securityToken, String registrationUrl) throws IOException;

public IIncomingTransport getPullTransport(Node remote, Node local, String securityToken, Map<String,String> requestProperties, String registrationUrl) throws IOException;

public IIncomingTransport getPingTransport(Node remote, Node local, String registrationUrl) throws IOException;

public IOutgoingWithResponseTransport getPushTransport(Node remote, Node local, String securityToken, String registrationUrl) throws IOException;

public IOutgoingWithResponseTransport getPushTransport(Node remote, Node local, String securityToken, Map<String,String> requestProperties, String registrationUrl) throws IOException;
Expand Down
Expand Up @@ -240,6 +240,11 @@ public IIncomingTransport getPullTransport(Node remote, Node local, String secur
return new HttpIncomingTransport(conn, engine.getParameterService());
}

public IIncomingTransport getPingTransport(Node remote, Node local, String registrationUrl) throws IOException {
HttpURLConnection conn = createGetConnectionFor(new URL(resolveURL(remote.getSyncUrl(), registrationUrl) + "/ping"));
return new HttpIncomingTransport(conn, engine.getParameterService());
}

public IOutgoingWithResponseTransport getPushTransport(Node remote, Node local,
String securityToken, Map<String, String> requestProperties,
String registrationUrl) throws IOException {
Expand Down
Expand Up @@ -47,6 +47,7 @@
import org.jumpmind.symmetric.transport.IOutgoingTransport;
import org.jumpmind.symmetric.transport.IOutgoingWithResponseTransport;
import org.jumpmind.symmetric.transport.ITransportManager;
import org.jumpmind.symmetric.transport.http.HttpIncomingTransport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -119,6 +120,10 @@ public void run(ISymmetricEngine engine, InputStream is, OutputStream os)
return new InternalIncomingTransport(respIs);
}

public IIncomingTransport getPingTransport(Node remote, Node local, String registrationUrl) throws IOException {
return null;
}

public IOutgoingWithResponseTransport getPushTransport(final Node targetNode, final Node sourceNode,
String securityToken, String registrationUrl) throws IOException {
return getPushTransport(targetNode, sourceNode, securityToken, null, registrationUrl);
Expand Down
Expand Up @@ -21,16 +21,17 @@

package org.jumpmind.symmetric.transport;

import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.util.List;
import java.util.Map;

import org.jumpmind.symmetric.model.BatchAck;
import org.jumpmind.symmetric.model.IncomingBatch;
import org.jumpmind.symmetric.model.Node;

import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.util.List;
import java.util.Map;

import org.jumpmind.symmetric.model.BatchAck;
import org.jumpmind.symmetric.model.IncomingBatch;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.transport.http.HttpIncomingTransport;

public class MockTransportManager implements ITransportManager {

protected IIncomingTransport incomingTransport;
Expand All @@ -48,11 +49,15 @@ public IIncomingTransport getPullTransport(Node remote, Node local,
String securityToken, Map<String, String> requestProperties, String registrationUrl)
throws IOException {
return incomingTransport;
}

public IIncomingTransport getFilePullTransport(Node remote, Node local, String securityToken,
Map<String, String> requestProperties, String registrationUrl) throws IOException {
return incomingTransport;
}

public IIncomingTransport getPingTransport(Node remote, Node local, String registrationUrl) throws IOException {
return incomingTransport;
}

public IIncomingTransport getFilePullTransport(Node remote, Node local, String securityToken,
Map<String, String> requestProperties, String registrationUrl) throws IOException {
return incomingTransport;
}

public IOutgoingWithResponseTransport getPushTransport(Node remote,
Expand Down Expand Up @@ -110,11 +115,11 @@ public List<BatchAck> readAcknowledgement(Map<String, Object> parameters) {

public List<BatchAck> readAcknowledgement(String parameterString1, String parameterString2) throws IOException {
return null;
}

public IOutgoingWithResponseTransport getFilePushTransport(Node remote, Node local,
String securityToken, String registrationUrl) throws IOException {
return outgoingTransport;
}

public IOutgoingWithResponseTransport getFilePushTransport(Node remote, Node local,
String securityToken, String registrationUrl) throws IOException {
return outgoingTransport;
}

@Override
Expand Down
Expand Up @@ -21,11 +21,13 @@
package org.jumpmind.symmetric.web;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.RandomStringUtils;
import org.jumpmind.symmetric.service.IParameterService;

/**
Expand All @@ -44,4 +46,13 @@ public void handle(HttpServletRequest req, HttpServletResponse res) throws IOExc
res.getWriter().write("pong");
}

public void bandwidthTest(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
res.setContentType("text/plain");
Long start = System.currentTimeMillis();
long end = start + 5000;
while (System.currentTimeMillis() < end) {
res.getWriter().write( RandomStringUtils.randomAlphabetic(600));
}
}

}

0 comments on commit 5958e20

Please sign in to comment.