Search in sources :

Example 1 with TransactionStreamResponse

use of org.neo4j.com.TransactionStreamResponse in project neo4j by neo4j.

the class SlaveLocksClientTest method setUp.

@Before
public void setUp() throws Exception {
    master = mock(Master.class);
    availabilityGuard = new AvailabilityGuard(Clocks.fakeClock(), getInstance());
    lockManager = new CommunityLockManger(Config.defaults(), Clocks.systemClock());
    local = spy(lockManager.newClient());
    logProvider = new AssertableLogProvider();
    LockResult lockResultOk = new LockResult(LockStatus.OK_LOCKED);
    TransactionStreamResponse<LockResult> responseOk = new TransactionStreamResponse<>(lockResultOk, null, TransactionStream.EMPTY, ResourceReleaser.NO_OP);
    whenMasterAcquireShared().thenReturn(responseOk);
    whenMasterAcquireExclusive().thenReturn(responseOk);
    client = new SlaveLocksClient(master, local, lockManager, mock(RequestContextFactory.class), availabilityGuard, logProvider);
}
Also used : Master(org.neo4j.kernel.ha.com.master.Master) TransactionStreamResponse(org.neo4j.com.TransactionStreamResponse) CommunityLockManger(org.neo4j.kernel.impl.locking.community.CommunityLockManger) AvailabilityGuard(org.neo4j.kernel.AvailabilityGuard) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Before(org.junit.Before)

Example 2 with TransactionStreamResponse

use of org.neo4j.com.TransactionStreamResponse 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 3 with TransactionStreamResponse

use of org.neo4j.com.TransactionStreamResponse 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)

Aggregations

TransactionStreamResponse (org.neo4j.com.TransactionStreamResponse)3 Supplier (java.util.function.Supplier)2 RequestContext (org.neo4j.com.RequestContext)2 ResourceReleaser (org.neo4j.com.ResourceReleaser)2 Response (org.neo4j.com.Response)2 TransactionStream (org.neo4j.com.TransactionStream)2 Visitor (org.neo4j.helpers.collection.Visitor)2 StoreId (org.neo4j.kernel.impl.store.StoreId)2 CommittedTransactionRepresentation (org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation)2 LogicalTransactionStore (org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore)2 TransactionIdStore (org.neo4j.kernel.impl.transaction.log.TransactionIdStore)2 BASE_TX_ID (org.neo4j.kernel.impl.transaction.log.TransactionIdStore.BASE_TX_ID)2 Before (org.junit.Before)1 TransactionObligationResponse (org.neo4j.com.TransactionObligationResponse)1 ResponsePacker (org.neo4j.com.storecopy.ResponsePacker)1 StoreCopyServer (org.neo4j.com.storecopy.StoreCopyServer)1 Monitor (org.neo4j.com.storecopy.StoreCopyServer.Monitor)1 IOCursor (org.neo4j.cursor.IOCursor)1 AvailabilityGuard (org.neo4j.kernel.AvailabilityGuard)1 Master (org.neo4j.kernel.ha.com.master.Master)1