Skip to content

Commit

Permalink
Remove the backup implementation from public view by putting it in an…
Browse files Browse the repository at this point in the history
… impl package.
  • Loading branch information
chrisvest committed Dec 7, 2017
1 parent ceabe8c commit b543d3d
Show file tree
Hide file tree
Showing 60 changed files with 149 additions and 115 deletions.
Expand Up @@ -30,6 +30,11 @@
import java.util.Map;
import java.util.NoSuchElementException;

import org.neo4j.backup.impl.BackupClient;
import org.neo4j.backup.impl.BackupOutcome;
import org.neo4j.backup.impl.BackupProtocolService;
import org.neo4j.backup.impl.BackupServer;
import org.neo4j.backup.impl.ConsistencyCheck;
import org.neo4j.com.ComException;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.helpers.Args;
Expand Down
Expand Up @@ -24,6 +24,11 @@
import java.nio.file.Path;
import java.nio.file.Paths;

import org.neo4j.backup.impl.BackupClient;
import org.neo4j.backup.impl.BackupOutcome;
import org.neo4j.backup.impl.BackupProtocolService;
import org.neo4j.backup.impl.BackupServer;
import org.neo4j.backup.impl.ConsistencyCheck;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.internal.GraphDatabaseAPI;

Expand Down
Expand Up @@ -22,6 +22,8 @@
import java.net.URI;
import java.util.function.Supplier;

import org.neo4j.backup.impl.BackupImpl;
import org.neo4j.backup.impl.BackupServer;
import org.neo4j.cluster.BindingListener;
import org.neo4j.cluster.InstanceId;
import org.neo4j.cluster.client.ClusterClient;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

import org.neo4j.causalclustering.core.CausalClusteringSettings;
import org.neo4j.helpers.AdvertisedSocketAddress;
Expand Down
Expand Up @@ -17,10 +17,11 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

import java.util.concurrent.TimeUnit;

import org.neo4j.backup.TheBackupInterface;
import org.neo4j.com.Client;
import org.neo4j.com.ObjectSerializer;
import org.neo4j.com.Protocol;
Expand All @@ -40,13 +41,13 @@
import org.neo4j.kernel.monitoring.Monitors;
import org.neo4j.logging.LogProvider;

import static org.neo4j.backup.BackupServer.BACKUP_PROTOCOL_VERSION;
import static org.neo4j.backup.BackupServer.FRAME_LENGTH;
import static org.neo4j.backup.impl.BackupServer.BACKUP_PROTOCOL_VERSION;
import static org.neo4j.backup.impl.BackupServer.FRAME_LENGTH;

class BackupClient extends Client<TheBackupInterface> implements TheBackupInterface
public class BackupClient extends Client<TheBackupInterface> implements TheBackupInterface
{

static final long BIG_READ_TIMEOUT = TimeUnit.MINUTES.toMillis( 20 );
public static final long BIG_READ_TIMEOUT = TimeUnit.MINUTES.toMillis( 20 );

BackupClient( String destinationHostNameOrIp, int destinationPort, String originHostNameOrIp,
LogProvider logProvider, StoreId storeId, long timeout,
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

import java.io.File;
import java.io.IOException;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

import java.io.IOException;
import java.nio.file.Path;
Expand Down
Expand Up @@ -17,10 +17,11 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

import java.util.function.Supplier;

import org.neo4j.backup.TheBackupInterface;
import org.neo4j.com.RequestContext;
import org.neo4j.com.Response;
import org.neo4j.com.storecopy.ResponsePacker;
Expand All @@ -35,7 +36,7 @@

import static org.neo4j.com.RequestContext.anonymous;

class BackupImpl implements TheBackupInterface
public class BackupImpl implements TheBackupInterface
{
static final String FULL_BACKUP_CHECKPOINT_TRIGGER = "full backup";

Expand All @@ -47,9 +48,9 @@ class BackupImpl implements TheBackupInterface
private final LogFileInformation logFileInformation;
private final Logger logger;

BackupImpl( StoreCopyServer storeCopyServer,
LogicalTransactionStore logicalTransactionStore, TransactionIdStore transactionIdStore,
LogFileInformation logFileInformation, Supplier<StoreId> storeId, LogProvider logProvider )
public BackupImpl( StoreCopyServer storeCopyServer,
LogicalTransactionStore logicalTransactionStore, TransactionIdStore transactionIdStore,
LogFileInformation logFileInformation, Supplier<StoreId> storeId, LogProvider logProvider )
{
this.storeCopyServer = storeCopyServer;
this.logicalTransactionStore = logicalTransactionStore;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

import java.time.Clock;

Expand Down
Expand Up @@ -17,9 +17,9 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

class BackupOutcome
public class BackupOutcome
{
private final boolean consistent;
private final long lastCommittedTx;
Expand All @@ -30,7 +30,7 @@ class BackupOutcome
this.consistent = consistent;
}

long getLastCommittedTx()
public long getLastCommittedTx()
{
return lastCommittedTx;
}
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

import java.io.File;
import java.io.IOException;
Expand All @@ -32,6 +32,7 @@
import java.util.function.Supplier;
import javax.annotation.Nullable;

import org.neo4j.backup.IncrementalBackupNotPossibleException;
import org.neo4j.com.RequestContext;
import org.neo4j.com.Response;
import org.neo4j.com.monitor.RequestMonitor;
Expand Down Expand Up @@ -87,7 +88,7 @@
/**
* Client-side convenience service for doing backups from a running database instance.
*/
class BackupProtocolService
public class BackupProtocolService
{
static final String TOO_OLD_BACKUP = "It's been too long since this backup was last updated, and it has " +
"fallen too far behind the database transaction stream for incremental backup to be possible. You need to" +
Expand All @@ -103,12 +104,12 @@ class BackupProtocolService
private final Monitors monitors;
private final PageCache pageCache;

BackupProtocolService()
public BackupProtocolService()
{
this( System.out );
}

BackupProtocolService( OutputStream logDestination )
public BackupProtocolService( OutputStream logDestination )
{
this( DefaultFileSystemAbstraction::new, FormattedLogProvider.toOutputStream( logDestination ), logDestination, new Monitors(),
createPageCache( new DefaultFileSystemAbstraction() ) );
Expand All @@ -126,8 +127,9 @@ class BackupProtocolService
monitors.addMonitorListener( new StoreCopyClientLoggingMonitor( log ), getClass().getName() );
}

BackupOutcome doFullBackup( final String sourceHostNameOrIp, final int sourcePort, Path targetDirectory,
ConsistencyCheck consistencyCheck, Config tuningConfiguration, final long timeout, final boolean forensics )
public BackupOutcome doFullBackup( final String sourceHostNameOrIp, final int sourcePort, Path targetDirectory,
ConsistencyCheck consistencyCheck, Config tuningConfiguration,
final long timeout, final boolean forensics )
{
try ( FileSystemAbstraction fileSystem = fileSystemSupplier.get() )
{
Expand Down Expand Up @@ -176,7 +178,7 @@ private BackupOutcome fullBackup( FileSystemAbstraction fileSystem, String sourc
}
}

BackupOutcome doIncrementalBackup(
public BackupOutcome doIncrementalBackup(
String sourceHostNameOrIp, int sourcePort, Path targetDirectory, ConsistencyCheck consistencyCheck,
long timeout, Config config )
throws IncrementalBackupNotPossibleException
Expand Down Expand Up @@ -256,8 +258,10 @@ private Map<String,String> getTemporaryDbConfig()
return tempDbConfig;
}

BackupOutcome doIncrementalBackupOrFallbackToFull( String sourceHostNameOrIp, int sourcePort, Path targetDirectory,
ConsistencyCheck consistencyCheck, Config config, long timeout, boolean forensics )
public BackupOutcome doIncrementalBackupOrFallbackToFull( String sourceHostNameOrIp, int sourcePort,
Path targetDirectory,
ConsistencyCheck consistencyCheck, Config config,
long timeout, boolean forensics )
{
try ( FileSystemAbstraction fileSystem = fileSystemSupplier.get() )
{
Expand Down Expand Up @@ -309,8 +313,8 @@ BackupOutcome doIncrementalBackupOrFallbackToFull( String sourceHostNameOrIp, in
}
}

BackupOutcome doIncrementalBackup( String sourceHostNameOrIp, int sourcePort, GraphDatabaseAPI targetDb,
long timeout ) throws IncrementalBackupNotPossibleException
public BackupOutcome doIncrementalBackup( String sourceHostNameOrIp, int sourcePort, GraphDatabaseAPI targetDb,
long timeout ) throws IncrementalBackupNotPossibleException
{
long lastCommittedTransaction = incrementalWithContext( sourceHostNameOrIp, sourcePort, targetDb, timeout,
slaveContextOf( targetDb ) );
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

import java.nio.file.Path;
import java.util.Map;
Expand All @@ -27,7 +27,7 @@
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.internal.GraphDatabaseAPI;

import static org.neo4j.backup.BackupProtocolService.startTemporaryDb;
import static org.neo4j.backup.impl.BackupProtocolService.startTemporaryDb;

class BackupRecoveryService
{
Expand Down
Expand Up @@ -17,12 +17,13 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;

import org.neo4j.backup.BackupClient.BackupRequestType;
import org.neo4j.backup.TheBackupInterface;
import org.neo4j.backup.impl.BackupClient.BackupRequestType;
import org.neo4j.com.ChunkingChannelBuffer;
import org.neo4j.com.Client;
import org.neo4j.com.Protocol;
Expand All @@ -39,7 +40,7 @@
import static org.neo4j.com.ProtocolVersion.INTERNAL_PROTOCOL_VERSION;
import static org.neo4j.com.TxChecksumVerifier.ALWAYS_MATCH;

class BackupServer extends Server<TheBackupInterface,Object>
public class BackupServer extends Server<TheBackupInterface,Object>
{
private static final long DEFAULT_OLD_CHANNEL_THRESHOLD = Client.DEFAULT_READ_RESPONSE_TIMEOUT_SECONDS * 1000;
private static final int DEFAULT_MAX_CONCURRENT_TX = 3;
Expand All @@ -54,11 +55,11 @@ class BackupServer extends Server<TheBackupInterface,Object>
public static final ProtocolVersion BACKUP_PROTOCOL_VERSION =
new ProtocolVersion( (byte) 2, INTERNAL_PROTOCOL_VERSION );

static final int DEFAULT_PORT = 6362;
public static final int DEFAULT_PORT = 6362;
static final int FRAME_LENGTH = Protocol.MEGA * 4;

BackupServer( TheBackupInterface requestTarget, final HostnamePort server, LogProvider logProvider,
ByteCounterMonitor byteCounterMonitor, RequestMonitor requestMonitor )
public BackupServer( TheBackupInterface requestTarget, final HostnamePort server, LogProvider logProvider,
ByteCounterMonitor byteCounterMonitor, RequestMonitor requestMonitor )
{
super( requestTarget, newBackupConfig( FRAME_LENGTH, server ), logProvider, FRAME_LENGTH,
BACKUP_PROTOCOL_VERSION, ALWAYS_MATCH, Clocks.systemClock(), byteCounterMonitor, requestMonitor );
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

enum BackupStageOutcome
{
Expand Down
Expand Up @@ -17,12 +17,12 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

import java.nio.file.Path;

import org.neo4j.kernel.impl.util.OptionalHostnamePort;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.util.OptionalHostnamePort;
import org.neo4j.kernel.lifecycle.Lifecycle;

interface BackupStrategy extends Lifecycle
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

import java.io.File;
import java.nio.file.Path;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -60,7 +60,7 @@ class BackupStrategyCoordinatorFactory
* @return strategy coordinator that handles the which backup strategies are tried and establishes if a backup was successful or not
*/
BackupStrategyCoordinator backupStrategyCoordinator( OnlineBackupContext onlineBackupContext, BackupProtocolService backupProtocolService,
BackupDelegator backupDelegator, PageCache pageCache )
BackupDelegator backupDelegator, PageCache pageCache )
{
BackupCopyService copyService = new BackupCopyService( pageCache, new FileMoveProvider( pageCache ) );
ProgressMonitorFactory progressMonitorFactory = ProgressMonitorFactory.textual( outsideWorld.errorStream() );
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

/**
* Possible states that can describe the outcome of any single backup strategy (BackupProtocol, TransactionProtocol etc.)
Expand Down
Expand Up @@ -17,14 +17,14 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

import java.io.IOException;
import java.nio.file.Path;

import org.neo4j.kernel.impl.util.OptionalHostnamePort;
import org.neo4j.io.pagecache.PageCache;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.util.OptionalHostnamePort;
import org.neo4j.kernel.lifecycle.LifeSupport;
import org.neo4j.logging.Log;
import org.neo4j.logging.LogProvider;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

import org.neo4j.io.pagecache.PageCache;

Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;
package org.neo4j.backup.impl;

import java.io.OutputStream;
import java.time.Clock;
Expand Down

0 comments on commit b543d3d

Please sign in to comment.