Search in sources :

Example 26 with ProcessInfo

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

the class StatisticManager method getProcessInfosThatHaveDoneWork.

public List<ProcessInfo> getProcessInfosThatHaveDoneWork() {
    List<ProcessInfo> toReturn = new ArrayList<ProcessInfo>();
    List<ProcessInfo> infosList = new ArrayList<ProcessInfo>(processInfos.values());
    Iterator<ProcessInfo> i = infosList.iterator();
    while (i.hasNext()) {
        ProcessInfo info = i.next();
        if (info.getStatus() == ProcessInfo.Status.OK && info.getCurrentDataCount() == 0) {
            ProcessInfo lastThatDidWork = processInfosThatHaveDoneWork.get(info.getKey());
            if (lastThatDidWork != null) {
                toReturn.add(lastThatDidWork.copy());
            }
        } else {
            toReturn.add(info.copy());
        }
    }
    return toReturn;
}
Also used : ArrayList(java.util.ArrayList) ProcessInfo(org.jumpmind.symmetric.model.ProcessInfo)

Example 27 with ProcessInfo

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

the class InternalTransportManager method getPullTransport.

public IIncomingTransport getPullTransport(Node remote, final Node local, String securityToken, Map<String, String> requestProperties, String registrationUrl) throws IOException {
    final PipedOutputStream respOs = new PipedOutputStream();
    final PipedInputStream respIs = new PipedInputStream(respOs);
    final ChannelMap suspendIgnoreChannels = symmetricEngine.getConfigurationService().getSuspendIgnoreChannelLists(remote.getNodeId());
    runAtClient(remote.getSyncUrl(), null, respOs, new IClientRunnable() {

        public void run(ISymmetricEngine engine, InputStream is, OutputStream os) throws Exception {
            IOutgoingTransport transport = new InternalOutgoingTransport(respOs, suspendIgnoreChannels, IoConstants.ENCODING);
            ProcessInfo processInfo = engine.getStatisticManager().newProcessInfo(new ProcessInfoKey(engine.getNodeService().findIdentityNodeId(), local.getNodeId(), ProcessType.PULL_HANDLER));
            try {
                engine.getDataExtractorService().extract(processInfo, local, transport);
                processInfo.setStatus(Status.OK);
            } catch (RuntimeException ex) {
                processInfo.setStatus(Status.ERROR);
                throw ex;
            }
            transport.close();
        }
    });
    return new InternalIncomingTransport(respIs);
}
Also used : ChannelMap(org.jumpmind.symmetric.model.ChannelMap) PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) PipedOutputStream(java.io.PipedOutputStream) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) ProcessInfoKey(org.jumpmind.symmetric.model.ProcessInfoKey) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) ProcessInfo(org.jumpmind.symmetric.model.ProcessInfo) IOException(java.io.IOException) IOutgoingTransport(org.jumpmind.symmetric.transport.IOutgoingTransport)

Example 28 with ProcessInfo

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

the class InternalTransportManager method getFilePullTransport.

public IIncomingTransport getFilePullTransport(Node remote, final Node local, String securityToken, Map<String, String> requestProperties, String registrationUrl) throws IOException {
    final PipedOutputStream respOs = new PipedOutputStream();
    final PipedInputStream respIs = new PipedInputStream(respOs);
    runAtClient(remote.getSyncUrl(), null, respOs, new IClientRunnable() {

        public void run(ISymmetricEngine engine, InputStream is, OutputStream os) throws Exception {
            IOutgoingTransport transport = new InternalOutgoingTransport(respOs, null);
            ProcessInfo processInfo = engine.getStatisticManager().newProcessInfo(new ProcessInfoKey(engine.getNodeService().findIdentityNodeId(), local.getNodeId(), ProcessType.FILE_SYNC_PULL_HANDLER));
            try {
                engine.getFileSyncService().sendFiles(processInfo, local, transport);
                processInfo.setStatus(Status.OK);
            } catch (RuntimeException ex) {
                processInfo.setStatus(Status.ERROR);
                throw ex;
            }
            transport.close();
        }
    });
    return new InternalIncomingTransport(respIs);
}
Also used : PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) PipedOutputStream(java.io.PipedOutputStream) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) ProcessInfoKey(org.jumpmind.symmetric.model.ProcessInfoKey) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) ProcessInfo(org.jumpmind.symmetric.model.ProcessInfo) IOException(java.io.IOException) IOutgoingTransport(org.jumpmind.symmetric.transport.IOutgoingTransport)

Example 29 with ProcessInfo

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

the class DataGapRouteReaderTest method buildReader.

protected DataGapRouteReader buildReader(int peekAheadMemoryThreshold, List<DataGap> dataGaps) throws Exception {
    when(parameterService.getEngineName()).thenReturn(ENGINE_NAME);
    when(parameterService.is(ParameterConstants.SYNCHRONIZE_ALL_JOBS)).thenReturn(true);
    when(parameterService.getInt(ParameterConstants.ROUTING_WAIT_FOR_DATA_TIMEOUT_SECONDS)).thenReturn(330);
    when(parameterService.getInt(ParameterConstants.ROUTING_PEEK_AHEAD_MEMORY_THRESHOLD)).thenReturn(peekAheadMemoryThreshold);
    when(parameterService.getInt(ParameterConstants.ROUTING_MAX_GAPS_TO_QUALIFY_IN_SQL)).thenReturn(100);
    when(parameterService.getInt(ParameterConstants.ROUTING_DATA_READER_THRESHOLD_GAPS_TO_USE_GREATER_QUERY)).thenReturn(100);
    when(parameterService.is(ParameterConstants.ROUTING_DATA_READER_ORDER_BY_DATA_ID_ENABLED)).thenReturn(true);
    IStatisticManager statisticManager = mock(StatisticManager.class);
    when(statisticManager.newProcessInfo((ProcessInfoKey) any())).thenReturn(new ProcessInfo());
    INodeService nodeService = mock(NodeService.class);
    when(nodeService.findIdentity()).thenReturn(new Node(NODE_ID, NODE_GROUP_ID));
    IDatabasePlatform platform = mock(IDatabasePlatform.class);
    when(platform.getSqlTemplate()).thenReturn(sqlTemplate);
    when(platform.getDatabaseInfo()).thenReturn(new DatabaseInfo());
    ISymmetricDialect symmetricDialect = mock(AbstractSymmetricDialect.class);
    when(symmetricDialect.supportsTransactionId()).thenReturn(true);
    when(symmetricDialect.getPlatform()).thenReturn(platform);
    IExtensionService extensionService = mock(ExtensionService.class);
    ISymmetricEngine engine = mock(AbstractSymmetricEngine.class);
    when(engine.getParameterService()).thenReturn(parameterService);
    when(engine.getStatisticManager()).thenReturn(statisticManager);
    when(engine.getNodeService()).thenReturn(nodeService);
    when(engine.getDataService()).thenReturn(dataService);
    when(engine.getSymmetricDialect()).thenReturn(symmetricDialect);
    when(engine.getExtensionService()).thenReturn(extensionService);
    IRouterService routerService = new RouterService(engine);
    when(engine.getRouterService()).thenReturn(routerService);
    ChannelRouterContext context = new ChannelRouterContext(NODE_ID, nodeChannel, mock(ISqlTransaction.class));
    context.setDataGaps(dataGaps);
    return new DataGapRouteReader(context, engine);
}
Also used : ISymmetricDialect(org.jumpmind.symmetric.db.ISymmetricDialect) RouterService(org.jumpmind.symmetric.service.impl.RouterService) IRouterService(org.jumpmind.symmetric.service.IRouterService) IDatabasePlatform(org.jumpmind.db.platform.IDatabasePlatform) DatabaseInfo(org.jumpmind.db.platform.DatabaseInfo) Node(org.jumpmind.symmetric.model.Node) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) ProcessInfo(org.jumpmind.symmetric.model.ProcessInfo) IRouterService(org.jumpmind.symmetric.service.IRouterService) IStatisticManager(org.jumpmind.symmetric.statistic.IStatisticManager) ISqlTransaction(org.jumpmind.db.sql.ISqlTransaction) INodeService(org.jumpmind.symmetric.service.INodeService) IExtensionService(org.jumpmind.symmetric.service.IExtensionService)

Example 30 with ProcessInfo

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

the class AbstractDataExtractorServiceTest method extract.

protected ExtractResults extract() {
    IDataExtractorService service = getDataExtractorService();
    StringWriter writer = new StringWriter();
    InternalOutgoingTransport transport = new InternalOutgoingTransport(new BufferedWriter(writer));
    List<OutgoingBatch> batches = service.extract(new ProcessInfo(), TestConstants.TEST_CLIENT_NODE, transport);
    transport.close();
    return new ExtractResults(batches, writer.getBuffer().toString());
}
Also used : InternalOutgoingTransport(org.jumpmind.symmetric.transport.internal.InternalOutgoingTransport) StringWriter(java.io.StringWriter) ProcessInfo(org.jumpmind.symmetric.model.ProcessInfo) OutgoingBatch(org.jumpmind.symmetric.model.OutgoingBatch) IDataExtractorService(org.jumpmind.symmetric.service.IDataExtractorService) BufferedWriter(java.io.BufferedWriter)

Aggregations

ProcessInfo (org.jumpmind.symmetric.model.ProcessInfo)32 ProcessInfoKey (org.jumpmind.symmetric.model.ProcessInfoKey)22 Node (org.jumpmind.symmetric.model.Node)18 IOException (java.io.IOException)10 OutgoingBatch (org.jumpmind.symmetric.model.OutgoingBatch)10 IncomingBatch (org.jumpmind.symmetric.model.IncomingBatch)8 NodeSecurity (org.jumpmind.symmetric.model.NodeSecurity)7 ArrayList (java.util.ArrayList)5 IoException (org.jumpmind.exception.IoException)5 ISymmetricEngine (org.jumpmind.symmetric.ISymmetricEngine)5 SymmetricException (org.jumpmind.symmetric.SymmetricException)5 INodeService (org.jumpmind.symmetric.service.INodeService)5 MalformedURLException (java.net.MalformedURLException)4 ISqlTransaction (org.jumpmind.db.sql.ISqlTransaction)4 Date (java.util.Date)3 ChannelMap (org.jumpmind.symmetric.model.ChannelMap)3 IOutgoingTransport (org.jumpmind.symmetric.transport.IOutgoingTransport)3 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 PipedInputStream (java.io.PipedInputStream)2