org.postgresql.replication.fluent.ReplicationStreamBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mogdb-jdbc Show documentation
Show all versions of mogdb-jdbc Show documentation
Java JDBC driver for MogDB
/*
* 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);
}
});
}
}