Search in sources :

Example 1 with BASE_TX_ID

use of org.neo4j.kernel.impl.transaction.log.TransactionIdStore.BASE_TX_ID in project neo4j by neo4j.

the class StoreCopyResponsePacker method packTransactionStreamResponse.

@Override
public <T> Response<T> packTransactionStreamResponse(RequestContext context, T response) {
    final long toStartFrom = mandatoryStartTransactionId;
    final long toEndAt = transactionIdStore.getLastCommittedTransactionId();
    TransactionStream transactions = visitor -> {
        if (toStartFrom > BASE_TX_ID && toStartFrom <= toEndAt) {
            monitor.startStreamingTransactions(toStartFrom);
            extractTransactions(toStartFrom, filterVisitor(visitor, toEndAt));
            monitor.finishStreamingTransactions(toEndAt);
        }
    };
    return new TransactionStreamResponse<>(response, storeId.get(), transactions, ResourceReleaser.NO_OP);
}
Also used : Response(org.neo4j.com.Response) StoreId(org.neo4j.kernel.impl.store.StoreId) TransactionStream(org.neo4j.com.TransactionStream) TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) LogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore) NoSuchTransactionException(org.neo4j.kernel.impl.transaction.log.NoSuchTransactionException) Supplier(java.util.function.Supplier) RequestContext(org.neo4j.com.RequestContext) TransactionStreamResponse(org.neo4j.com.TransactionStreamResponse) ResponsePacker(org.neo4j.com.storecopy.ResponsePacker) CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) LogFileInformation(org.neo4j.kernel.impl.transaction.log.LogFileInformation) Monitor(org.neo4j.com.storecopy.StoreCopyServer.Monitor) StoreCopyServer(org.neo4j.com.storecopy.StoreCopyServer) ResourceReleaser(org.neo4j.com.ResourceReleaser) Visitor(org.neo4j.helpers.collection.Visitor) BASE_TX_ID(org.neo4j.kernel.impl.transaction.log.TransactionIdStore.BASE_TX_ID) TransactionStreamResponse(org.neo4j.com.TransactionStreamResponse) TransactionStream(org.neo4j.com.TransactionStream)

Example 2 with BASE_TX_ID

use of org.neo4j.kernel.impl.transaction.log.TransactionIdStore.BASE_TX_ID in project neo4j by neo4j.

the class ResponsePacker method packTransactionStreamResponse.

public <T> Response<T> packTransactionStreamResponse(RequestContext context, T response) {
    final long toStartFrom = context.lastAppliedTransaction() + 1;
    final long toEndAt = transactionIdStore.getLastCommittedTransactionId();
    TransactionStream transactions = visitor -> {
        if (toStartFrom > BASE_TX_ID && toStartFrom <= toEndAt) {
            extractTransactions(toStartFrom, filterVisitor(visitor, toEndAt));
        }
    };
    return new TransactionStreamResponse<>(response, storeId.get(), transactions, ResourceReleaser.NO_OP);
}
Also used : Response(org.neo4j.com.Response) StoreId(org.neo4j.kernel.impl.store.StoreId) TransactionStream(org.neo4j.com.TransactionStream) TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) LogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore) Supplier(java.util.function.Supplier) RequestContext(org.neo4j.com.RequestContext) IOCursor(org.neo4j.cursor.IOCursor) TransactionStreamResponse(org.neo4j.com.TransactionStreamResponse) CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) ResourceReleaser(org.neo4j.com.ResourceReleaser) Visitor(org.neo4j.helpers.collection.Visitor) TransactionObligationResponse(org.neo4j.com.TransactionObligationResponse) BASE_TX_ID(org.neo4j.kernel.impl.transaction.log.TransactionIdStore.BASE_TX_ID) TransactionStreamResponse(org.neo4j.com.TransactionStreamResponse) TransactionStream(org.neo4j.com.TransactionStream)

Example 3 with BASE_TX_ID

use of org.neo4j.kernel.impl.transaction.log.TransactionIdStore.BASE_TX_ID in project neo4j by neo4j.

the class SwitchToSlave method copyStoreFromMaster.

void copyStoreFromMaster(MasterClient masterClient, CancellationRequest cancellationRequest, MoveAfterCopy moveAfterCopy) throws Throwable {
    try {
        userLog.info("Copying store from master");
        StoreCopyClient.StoreCopyRequester requester = new StoreCopyClient.StoreCopyRequester() {

            @Override
            public Response<?> copyStore(StoreWriter writer) {
                return masterClient.copyStore(new RequestContext(0, config.get(ClusterSettings.server_id).toIntegerIndex(), 0, BASE_TX_ID, 0), writer);
            }

            @Override
            public void done() {
            // Nothing to clean up here
            }
        };
        MoveAfterCopy moveAfterCopyWithLogging = (moves, fromDirectory, toDirectory) -> {
            userLog.info("Copied store from master to " + fromDirectory);
            msgLog.info("Starting post copy operation to move store from " + fromDirectory + " to " + storeDir);
            moveAfterCopy.move(moves, fromDirectory, toDirectory);
        };
        storeCopyClient.copyStore(requester, cancellationRequest, moveAfterCopyWithLogging);
        startServicesAgain();
        userLog.info("Finished copying store from master");
    } catch (Throwable t) {
        // Delete store so that we can copy from master without conflicts next time
        cleanStoreDir();
        throw t;
    }
}
Also used : InstanceId(org.neo4j.cluster.InstanceId) StoreId(org.neo4j.kernel.impl.store.StoreId) NeoStoreDataSource(org.neo4j.kernel.NeoStoreDataSource) MasterClientResolver(org.neo4j.kernel.ha.com.slave.MasterClientResolver) Log(org.neo4j.logging.Log) OnlineBackupKernelExtension(org.neo4j.backup.OnlineBackupKernelExtension) DelegateInvocationHandler(org.neo4j.kernel.ha.DelegateInvocationHandler) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) RequestContext(org.neo4j.com.RequestContext) MasterClient(org.neo4j.kernel.ha.com.slave.MasterClient) HighAvailabilityModeSwitcher(org.neo4j.kernel.ha.cluster.modeswitch.HighAvailabilityModeSwitcher) TransactionObligationFulfiller(org.neo4j.com.storecopy.TransactionObligationFulfiller) URI(java.net.URI) MismatchingStoreIdException(org.neo4j.kernel.impl.store.MismatchingStoreIdException) StoreUtil(org.neo4j.com.storecopy.StoreUtil) ClusterMembers.hasInstanceId(org.neo4j.kernel.ha.cluster.member.ClusterMembers.hasInstanceId) Response(org.neo4j.com.Response) PageCache(org.neo4j.io.pagecache.PageCache) Iterables.filter(org.neo4j.helpers.collection.Iterables.filter) MissingLogDataException(org.neo4j.kernel.impl.transaction.log.MissingLogDataException) LogService(org.neo4j.kernel.impl.logging.LogService) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) TransactionCommittingResponseUnpacker(org.neo4j.com.storecopy.TransactionCommittingResponseUnpacker) UpdatePuller(org.neo4j.kernel.ha.UpdatePuller) UpdatePullerScheduler(org.neo4j.kernel.ha.UpdatePullerScheduler) UnableToCopyStoreFromOldMasterException(org.neo4j.kernel.ha.store.UnableToCopyStoreFromOldMasterException) ClusterMemberAvailability(org.neo4j.cluster.member.ClusterMemberAvailability) Iterables.firstOrNull(org.neo4j.helpers.collection.Iterables.firstOrNull) DependencyResolver(org.neo4j.graphdb.DependencyResolver) RequestContextFactory(org.neo4j.kernel.ha.com.RequestContextFactory) BranchedDataException(org.neo4j.kernel.ha.BranchedDataException) MoveAfterCopy(org.neo4j.com.storecopy.MoveAfterCopy) TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) StoreWriter(org.neo4j.com.storecopy.StoreWriter) Monitors(org.neo4j.kernel.monitoring.Monitors) LockSupport.parkNanos(java.util.concurrent.locks.LockSupport.parkNanos) HandshakeResult(org.neo4j.kernel.ha.com.master.HandshakeResult) Function(java.util.function.Function) Supplier(java.util.function.Supplier) PullerFactory(org.neo4j.kernel.ha.PullerFactory) ServerUtil(org.neo4j.com.ServerUtil) TransactionId(org.neo4j.kernel.impl.store.TransactionId) ClusterMembers(org.neo4j.kernel.ha.cluster.member.ClusterMembers) StoreLockerLifecycleAdapter(org.neo4j.kernel.internal.StoreLockerLifecycleAdapter) SlaveServer(org.neo4j.kernel.ha.com.slave.SlaveServer) HaIdGeneratorFactory(org.neo4j.kernel.ha.id.HaIdGeneratorFactory) CancellationRequest(org.neo4j.helpers.CancellationRequest) HighAvailabilityModeSwitcher.getServerId(org.neo4j.kernel.ha.cluster.modeswitch.HighAvailabilityModeSwitcher.getServerId) NeoStores.isStorePresent(org.neo4j.kernel.impl.store.NeoStores.isStorePresent) BASE_TX_ID(org.neo4j.kernel.impl.transaction.log.TransactionIdStore.BASE_TX_ID) Lifecycle(org.neo4j.kernel.lifecycle.Lifecycle) Config(org.neo4j.kernel.configuration.Config) IOException(java.io.IOException) HaSettings(org.neo4j.kernel.ha.HaSettings) DataSourceManager(org.neo4j.kernel.impl.transaction.state.DataSourceManager) File(java.io.File) StoreOutOfDateException(org.neo4j.kernel.ha.StoreOutOfDateException) Server(org.neo4j.com.Server) SlaveImpl(org.neo4j.kernel.ha.com.slave.SlaveImpl) IndexConfigStore(org.neo4j.kernel.impl.index.IndexConfigStore) Clock(java.time.Clock) ClusterSettings(org.neo4j.cluster.ClusterSettings) Slave(org.neo4j.kernel.ha.com.master.Slave) StoreCopyClient(org.neo4j.com.storecopy.StoreCopyClient) TransactionStats(org.neo4j.kernel.impl.transaction.TransactionStats) ClusterMember(org.neo4j.kernel.ha.cluster.member.ClusterMember) FileSystemWatcherService(org.neo4j.kernel.impl.util.watcher.FileSystemWatcherService) Clocks(org.neo4j.time.Clocks) Master(org.neo4j.kernel.ha.com.master.Master) StoreWriter(org.neo4j.com.storecopy.StoreWriter) StoreCopyClient(org.neo4j.com.storecopy.StoreCopyClient) RequestContext(org.neo4j.com.RequestContext) MoveAfterCopy(org.neo4j.com.storecopy.MoveAfterCopy)

Aggregations

Supplier (java.util.function.Supplier)3 RequestContext (org.neo4j.com.RequestContext)3 Response (org.neo4j.com.Response)3 StoreId (org.neo4j.kernel.impl.store.StoreId)3 TransactionIdStore (org.neo4j.kernel.impl.transaction.log.TransactionIdStore)3 BASE_TX_ID (org.neo4j.kernel.impl.transaction.log.TransactionIdStore.BASE_TX_ID)3 ResourceReleaser (org.neo4j.com.ResourceReleaser)2 TransactionStream (org.neo4j.com.TransactionStream)2 TransactionStreamResponse (org.neo4j.com.TransactionStreamResponse)2 Visitor (org.neo4j.helpers.collection.Visitor)2 File (java.io.File)1 IOException (java.io.IOException)1 URI (java.net.URI)1 Clock (java.time.Clock)1 MILLISECONDS (java.util.concurrent.TimeUnit.MILLISECONDS)1 LockSupport.parkNanos (java.util.concurrent.locks.LockSupport.parkNanos)1 Function (java.util.function.Function)1 OnlineBackupKernelExtension (org.neo4j.backup.OnlineBackupKernelExtension)1 ClusterSettings (org.neo4j.cluster.ClusterSettings)1 InstanceId (org.neo4j.cluster.InstanceId)1