Search in sources :

Example 1 with ChannelMap

use of org.jumpmind.symmetric.model.ChannelMap in project symmetric-ds by JumpMind.

the class HttpOutgoingTransport method getSuspendIgnoreChannelLists.

public ChannelMap getSuspendIgnoreChannelLists(IConfigurationService configurationService, String queue, Node targetNode) {
    HttpURLConnection connection = requestReservation(queue);
    // Connection contains remote suspend/ignore channels list if
    // reservation was successful.
    ChannelMap suspendIgnoreChannelsList = new ChannelMap();
    String suspends = connection.getHeaderField(WebConstants.SUSPENDED_CHANNELS);
    String ignores = connection.getHeaderField(WebConstants.IGNORED_CHANNELS);
    suspendIgnoreChannelsList.addSuspendChannels(suspends);
    suspendIgnoreChannelsList.addIgnoreChannels(ignores);
    ChannelMap localSuspendIgnoreChannelsList = configurationService.getSuspendIgnoreChannelLists(targetNode.getNodeId());
    suspendIgnoreChannelsList.addSuspendChannels(localSuspendIgnoreChannelsList.getSuspendChannels());
    suspendIgnoreChannelsList.addIgnoreChannels(localSuspendIgnoreChannelsList.getIgnoreChannels());
    return suspendIgnoreChannelsList;
}
Also used : ChannelMap(org.jumpmind.symmetric.model.ChannelMap) HttpURLConnection(java.net.HttpURLConnection)

Example 2 with ChannelMap

use of org.jumpmind.symmetric.model.ChannelMap in project symmetric-ds by JumpMind.

the class DataExtractorService method extract.

public List<OutgoingBatch> extract(ProcessInfo processInfo, Node targetNode, String queue, IOutgoingTransport transport) {
    /*
         * make sure that data is routed before extracting if the route job is
         * not configured to start automatically
         */
    if (!parameterService.is(ParameterConstants.START_ROUTE_JOB) && parameterService.is(ParameterConstants.ROUTE_ON_EXTRACT)) {
        routerService.routeData(true);
    }
    OutgoingBatches batches = null;
    if (queue != null) {
        NodeGroupLinkAction defaultAction = configurationService.getNodeGroupLinkFor(nodeService.findIdentity().getNodeGroupId(), targetNode.getNodeGroupId(), false).getDataEventAction();
        ProcessInfoKey.ProcessType processType = processInfo.getKey().getProcessType();
        NodeGroupLinkAction action = null;
        if (processType.equals(ProcessInfoKey.ProcessType.PUSH_JOB)) {
            action = NodeGroupLinkAction.P;
        } else if (processType.equals(ProcessInfoKey.ProcessType.PULL_HANDLER)) {
            action = NodeGroupLinkAction.W;
        }
        batches = outgoingBatchService.getOutgoingBatches(targetNode.getNodeId(), queue, action, defaultAction, false);
    } else {
        batches = outgoingBatchService.getOutgoingBatches(targetNode.getNodeId(), false);
    }
    if (batches.containsBatches()) {
        ChannelMap channelMap = transport.getSuspendIgnoreChannelLists(configurationService, queue, targetNode);
        List<OutgoingBatch> activeBatches = filterBatchesForExtraction(batches, channelMap);
        if (activeBatches.size() > 0) {
            BufferedWriter writer = transport.openWriter();
            IDataWriter dataWriter = new ProtocolDataWriter(nodeService.findIdentityNodeId(), writer, targetNode.requires13Compatiblity());
            return extract(processInfo, targetNode, activeBatches, dataWriter, writer, ExtractMode.FOR_SYM_CLIENT);
        }
    }
    return Collections.emptyList();
}
Also used : ChannelMap(org.jumpmind.symmetric.model.ChannelMap) NodeGroupLinkAction(org.jumpmind.symmetric.model.NodeGroupLinkAction) ProtocolDataWriter(org.jumpmind.symmetric.io.data.writer.ProtocolDataWriter) ProcessType(org.jumpmind.symmetric.model.ProcessInfoKey.ProcessType) ProcessInfoKey(org.jumpmind.symmetric.model.ProcessInfoKey) OutgoingBatches(org.jumpmind.symmetric.model.OutgoingBatches) OutgoingBatch(org.jumpmind.symmetric.model.OutgoingBatch) BufferedWriter(java.io.BufferedWriter) BatchBufferedWriter(org.jumpmind.symmetric.transport.BatchBufferedWriter) IDataWriter(org.jumpmind.symmetric.io.data.IDataWriter)

Example 3 with ChannelMap

use of org.jumpmind.symmetric.model.ChannelMap in project symmetric-ds by JumpMind.

the class MakeReservationUriHandler method buildSuspendIgnoreResponseHeaders.

protected void buildSuspendIgnoreResponseHeaders(final String nodeId, final ServletResponse resp) {
    HttpServletResponse httpResponse = (HttpServletResponse) resp;
    ChannelMap suspendIgnoreChannels = engine.getConfigurationService().getSuspendIgnoreChannelLists(nodeId);
    httpResponse.setHeader(WebConstants.SUSPENDED_CHANNELS, suspendIgnoreChannels.getSuspendChannelsAsString());
    httpResponse.setHeader(WebConstants.IGNORED_CHANNELS, suspendIgnoreChannels.getIgnoreChannelsAsString());
}
Also used : ChannelMap(org.jumpmind.symmetric.model.ChannelMap) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Example 4 with ChannelMap

use of org.jumpmind.symmetric.model.ChannelMap in project symmetric-ds by JumpMind.

the class PullUriHandler method handleWithCompression.

public void handleWithCompression(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
    // request has the "other" nodes info
    String nodeId = ServletUtils.getParameter(req, WebConstants.NODE_ID);
    log.debug("Pull request received from {}", nodeId);
    if (StringUtils.isBlank(nodeId)) {
        ServletUtils.sendError(res, HttpServletResponse.SC_BAD_REQUEST, "Node must be specified");
        return;
    }
    ChannelMap map = new ChannelMap();
    map.addSuspendChannels(req.getHeader(WebConstants.SUSPENDED_CHANNELS));
    map.addIgnoreChannels(req.getHeader(WebConstants.IGNORED_CHANNELS));
    // pull out headers and pass to pull() method
    pull(nodeId, req.getRemoteHost(), req.getRemoteAddr(), res.getOutputStream(), req.getHeader(WebConstants.HEADER_ACCEPT_CHARSET), map);
    log.debug("Done with Pull request from {}", nodeId);
}
Also used : ChannelMap(org.jumpmind.symmetric.model.ChannelMap)

Example 5 with ChannelMap

use of org.jumpmind.symmetric.model.ChannelMap in project symmetric-ds by JumpMind.

the class DataExtractorService method extract.

public List<OutgoingBatch> extract(ProcessInfo processInfo, Node targetNode, IOutgoingTransport transport) {
    /*
         * make sure that data is routed before extracting if the route job is
         * not configured to start automatically
         */
    if (!parameterService.is(ParameterConstants.START_ROUTE_JOB)) {
        routerService.routeData(true);
    }
    OutgoingBatches batches = outgoingBatchService.getOutgoingBatches(targetNode.getNodeId(), false);
    if (batches.containsBatches()) {
        ChannelMap channelMap = transport.getSuspendIgnoreChannelLists(configurationService, targetNode);
        List<OutgoingBatch> activeBatches = filterBatchesForExtraction(batches, channelMap);
        if (activeBatches.size() > 0) {
            IDataWriter dataWriter = new ProtocolDataWriter(nodeService.findIdentityNodeId(), transport.openWriter(), targetNode.requires13Compatiblity());
            return extract(processInfo, targetNode, activeBatches, dataWriter, ExtractMode.FOR_SYM_CLIENT);
        }
    }
    return Collections.emptyList();
}
Also used : ChannelMap(org.jumpmind.symmetric.model.ChannelMap) ProtocolDataWriter(org.jumpmind.symmetric.io.data.writer.ProtocolDataWriter) OutgoingBatches(org.jumpmind.symmetric.model.OutgoingBatches) OutgoingBatch(org.jumpmind.symmetric.model.OutgoingBatch) IDataWriter(org.jumpmind.symmetric.io.data.IDataWriter)

Aggregations

ChannelMap (org.jumpmind.symmetric.model.ChannelMap)13 OutgoingBatch (org.jumpmind.symmetric.model.OutgoingBatch)5 ProcessInfoKey (org.jumpmind.symmetric.model.ProcessInfoKey)5 ProcessInfo (org.jumpmind.symmetric.model.ProcessInfo)4 Node (org.jumpmind.symmetric.model.Node)3 NodeSecurity (org.jumpmind.symmetric.model.NodeSecurity)3 OutgoingBatches (org.jumpmind.symmetric.model.OutgoingBatches)3 IOutgoingTransport (org.jumpmind.symmetric.transport.IOutgoingTransport)3 IOException (java.io.IOException)2 HttpURLConnection (java.net.HttpURLConnection)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 IDataWriter (org.jumpmind.symmetric.io.data.IDataWriter)2 ProtocolDataWriter (org.jumpmind.symmetric.io.data.writer.ProtocolDataWriter)2 BufferedWriter (java.io.BufferedWriter)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 PipedInputStream (java.io.PipedInputStream)1 PipedOutputStream (java.io.PipedOutputStream)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1