All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.postgresql.replication.fluent.ReplicationStreamBuilder Maven / Gradle / Ivy

There is a newer version: 5.0.0.9.pg
Show newest version
/*
 * Copyright (c) 2016, PostgreSQL Global Development Group
 * See the LICENSE file in the project root for more information.
 */

package io.mogdb.replication.fluent;

import io.mogdb.core.BaseConnection;
import io.mogdb.core.ReplicationProtocol;
import io.mogdb.replication.PGReplicationStream;
import io.mogdb.replication.fluent.logical.ChainedLogicalStreamBuilder;
import io.mogdb.replication.fluent.logical.LogicalReplicationOptions;
import io.mogdb.replication.fluent.logical.LogicalStreamBuilder;
import io.mogdb.replication.fluent.logical.StartLogicalReplicationCallback;
import io.mogdb.replication.fluent.physical.ChainedPhysicalStreamBuilder;
import io.mogdb.replication.fluent.physical.PhysicalReplicationOptions;
import io.mogdb.replication.fluent.physical.PhysicalStreamBuilder;
import io.mogdb.replication.fluent.physical.StartPhysicalReplicationCallback;

import java.sql.SQLException;

public class ReplicationStreamBuilder implements ChainedStreamBuilder {
  private final BaseConnection baseConnection;

  /**
   * @param connection not null connection with that will be associate replication
   */
  public ReplicationStreamBuilder(final BaseConnection connection) {
    this.baseConnection = connection;
  }

  @Override
  public ChainedLogicalStreamBuilder logical() {
    return new LogicalStreamBuilder(new StartLogicalReplicationCallback() {
      @Override
      public PGReplicationStream start(LogicalReplicationOptions options) throws SQLException {
        ReplicationProtocol protocol = baseConnection.getReplicationProtocol();
        return protocol.startLogical(options);
      }
    });
  }

  @Override
  public ChainedPhysicalStreamBuilder physical() {
    return new PhysicalStreamBuilder(new StartPhysicalReplicationCallback() {
      @Override
      public PGReplicationStream start(PhysicalReplicationOptions options) throws SQLException {
        ReplicationProtocol protocol = baseConnection.getReplicationProtocol();
        return protocol.startPhysical(options);
      }
    });
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy